summaryrefslogtreecommitdiffstats
path: root/chromecast/media
diff options
context:
space:
mode:
authorservolk <servolk@chromium.org>2014-12-17 20:01:24 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-18 04:01:56 +0000
commitab5bcf3cdcfe34635e4fa7ea38d2a92e6ec1eedf (patch)
treed31b1470df87d674d449342e28e79d008cb97209 /chromecast/media
parent7476088d404e3b04f2cf805f3e0622283606ea77 (diff)
downloadchromium_src-ab5bcf3cdcfe34635e4fa7ea38d2a92e6ec1eedf.zip
chromium_src-ab5bcf3cdcfe34635e4fa7ea38d2a92e6ec1eedf.tar.gz
chromium_src-ab5bcf3cdcfe34635e4fa7ea38d2a92e6ec1eedf.tar.bz2
Chromecast: Add a way to notify video plane about resolution changes
Added OnScreenResolutionChanged to be notified about screen resolution changes (needed to fix b/18205424), plus a bit of a refactoring- got rid of platform-specific videoplane registries (duplicated code anyway), introduced a VideoPlaneFactory. BUG=none Review URL: https://codereview.chromium.org/809173002 Cr-Commit-Position: refs/heads/master@{#308945}
Diffstat (limited to 'chromecast/media')
-rw-r--r--chromecast/media/cma/backend/video_plane.cc37
-rw-r--r--chromecast/media/cma/backend/video_plane.h13
-rw-r--r--chromecast/media/cma/backend/video_plane_fake.cc11
-rw-r--r--chromecast/media/cma/backend/video_plane_fake.h14
-rw-r--r--chromecast/media/cma/backend/video_plane_fake_factory.cc5
5 files changed, 58 insertions, 22 deletions
diff --git a/chromecast/media/cma/backend/video_plane.cc b/chromecast/media/cma/backend/video_plane.cc
index 192fab8..5d8097f 100644
--- a/chromecast/media/cma/backend/video_plane.cc
+++ b/chromecast/media/cma/backend/video_plane.cc
@@ -4,6 +4,8 @@
#include "chromecast/media/cma/backend/video_plane.h"
+#include "base/memory/singleton.h"
+
namespace chromecast {
namespace media {
@@ -13,5 +15,40 @@ VideoPlane::VideoPlane() {
VideoPlane::~VideoPlane() {
}
+class VideoPlaneRegistry {
+ public:
+ static VideoPlaneRegistry* GetInstance() {
+ return Singleton<VideoPlaneRegistry>::get();
+ }
+
+ VideoPlane* GetVideoPlane();
+
+ private:
+ friend struct DefaultSingletonTraits<VideoPlaneRegistry>;
+ friend class Singleton<VideoPlaneRegistry>;
+
+ VideoPlaneRegistry();
+ virtual ~VideoPlaneRegistry();
+
+ scoped_ptr<VideoPlane> video_plane_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoPlaneRegistry);
+};
+
+VideoPlaneRegistry::VideoPlaneRegistry() :
+ video_plane_(CreateVideoPlane()) {
+}
+
+VideoPlaneRegistry::~VideoPlaneRegistry() {
+}
+
+VideoPlane* VideoPlaneRegistry::GetVideoPlane() {
+ return video_plane_.get();
+}
+
+VideoPlane* GetVideoPlane() {
+ return VideoPlaneRegistry::GetInstance()->GetVideoPlane();
+}
+
} // namespace media
} // namespace chromecast
diff --git a/chromecast/media/cma/backend/video_plane.h b/chromecast/media/cma/backend/video_plane.h
index 6938b8d3..6c98d29 100644
--- a/chromecast/media/cma/backend/video_plane.h
+++ b/chromecast/media/cma/backend/video_plane.h
@@ -6,6 +6,7 @@
#define CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_H_
#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
namespace gfx {
class QuadF;
@@ -28,8 +29,8 @@ class VideoPlane {
VideoPlane();
virtual ~VideoPlane();
- // Gets video plane resolution.
- virtual gfx::Size GetVideoPlaneResolution() = 0;
+ // Gets output screen resolution.
+ virtual gfx::Size GetScreenResolution() = 0;
// Updates the video plane geometry.
// |quad.p1()| corresponds to the top left of the original video,
@@ -41,10 +42,18 @@ class VideoPlane {
virtual void SetGeometry(const gfx::QuadF& quad,
CoordinateType coordinate_type) = 0;
+ // Should be invoked whenever screen resolution changes (e.g. when a device is
+ // plugged into a new HDMI port and a new HDMI EDID is received).
+ // VideoPlane should reposition itself according to the new screen resolution.
+ virtual void OnScreenResolutionChanged(const gfx::Size& screen_res) = 0;
+
private:
DISALLOW_COPY_AND_ASSIGN(VideoPlane);
};
+// Factory to create a VideoPlane.
+scoped_ptr<VideoPlane> CreateVideoPlane();
+
// Global accessor to the video plane.
VideoPlane* GetVideoPlane();
diff --git a/chromecast/media/cma/backend/video_plane_fake.cc b/chromecast/media/cma/backend/video_plane_fake.cc
index a129d8d..73fa39e 100644
--- a/chromecast/media/cma/backend/video_plane_fake.cc
+++ b/chromecast/media/cma/backend/video_plane_fake.cc
@@ -5,25 +5,19 @@
#include "chromecast/media/cma/backend/video_plane_fake.h"
#include "base/logging.h"
-#include "base/memory/singleton.h"
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/size.h"
namespace chromecast {
namespace media {
-// static
-VideoPlaneFake* VideoPlaneFake::GetInstance() {
- return Singleton<VideoPlaneFake>::get();
-}
-
VideoPlaneFake::VideoPlaneFake() {
}
VideoPlaneFake::~VideoPlaneFake() {
}
-gfx::Size VideoPlaneFake::GetVideoPlaneResolution() {
+gfx::Size VideoPlaneFake::GetScreenResolution() {
return gfx::Size(1920, 1080);
}
@@ -32,5 +26,8 @@ void VideoPlaneFake::SetGeometry(const gfx::QuadF& quad,
// Nothing to be done.
}
+void VideoPlaneFake::OnScreenResolutionChanged(const gfx::Size& screen_res) {
+}
+
} // namespace media
} // namespace chromecast
diff --git a/chromecast/media/cma/backend/video_plane_fake.h b/chromecast/media/cma/backend/video_plane_fake.h
index f809015..1cfe38c 100644
--- a/chromecast/media/cma/backend/video_plane_fake.h
+++ b/chromecast/media/cma/backend/video_plane_fake.h
@@ -6,7 +6,6 @@
#define CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_FAKE_H_
#include "base/macros.h"
-#include "base/memory/singleton.h"
#include "chromecast/media/cma/backend/video_plane.h"
namespace chromecast {
@@ -14,19 +13,14 @@ namespace media {
class VideoPlaneFake : public VideoPlane {
public:
- static VideoPlaneFake* GetInstance();
+ VideoPlaneFake();
+ virtual ~VideoPlaneFake();
// VideoPlane implementation.
- gfx::Size GetVideoPlaneResolution() override;
+ gfx::Size GetScreenResolution() override;
void SetGeometry(const gfx::QuadF& quad,
CoordinateType coordinate_type) override;
-
- private:
- friend struct DefaultSingletonTraits<VideoPlaneFake>;
- friend class Singleton<VideoPlaneFake>;
-
- VideoPlaneFake();
- virtual ~VideoPlaneFake();
+ void OnScreenResolutionChanged(const gfx::Size& screen_res) override;
DISALLOW_COPY_AND_ASSIGN(VideoPlaneFake);
};
diff --git a/chromecast/media/cma/backend/video_plane_fake_factory.cc b/chromecast/media/cma/backend/video_plane_fake_factory.cc
index 2345009..310c8bc 100644
--- a/chromecast/media/cma/backend/video_plane_fake_factory.cc
+++ b/chromecast/media/cma/backend/video_plane_fake_factory.cc
@@ -7,9 +7,8 @@
namespace chromecast {
namespace media {
-// Global accessor to the video plane.
-VideoPlane* GetVideoPlane() {
- return VideoPlaneFake::GetInstance();
+scoped_ptr<VideoPlane> CreateVideoPlane() {
+ return make_scoped_ptr(new VideoPlaneFake());
}
} // namespace media