Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1227)

Unified Diff: ui/ozone/platform/cast/overlay_manager_cast.cc

Issue 1223793009: Fixes to Cast use of overlays for video frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added dependency on media_base Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/cast/cast.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/cast/overlay_manager_cast.cc
diff --git a/ui/ozone/platform/cast/overlay_manager_cast.cc b/ui/ozone/platform/cast/overlay_manager_cast.cc
index cb7d6419ba97d83aeacc4b1f1578694c579e1db5..9d173008ce9880bc57e4630adaf02e2b16d34df1 100644
--- a/ui/ozone/platform/cast/overlay_manager_cast.cc
+++ b/ui/ozone/platform/cast/overlay_manager_cast.cc
@@ -4,6 +4,11 @@
#include "ui/ozone/platform/cast/overlay_manager_cast.h"
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
+#include "chromecast/media/base/media_message_loop.h"
#include "chromecast/public/cast_media_shlib.h"
#include "chromecast/public/graphics_types.h"
#include "chromecast/public/video_plane.h"
@@ -13,6 +18,16 @@
namespace ui {
namespace {
+void SetVideoPlaneGeometry(
+ const chromecast::RectF& display_rect,
+ chromecast::media::VideoPlane::CoordinateType coordinate_type,
+ chromecast::media::VideoPlane::Transform transform) {
+ chromecast::media::VideoPlane* video_plane =
+ chromecast::media::CastMediaShlib::GetVideoPlane();
+ CHECK(video_plane);
+ video_plane->SetGeometry(display_rect, coordinate_type, transform);
+}
+
// Translates a gfx::OverlayTransform into a VideoPlane::Transform.
// Could be just a lookup table once we have unit tests for this code
// to ensure it stays in sync with OverlayTransform.
@@ -37,31 +52,60 @@ chromecast::media::VideoPlane::Transform ConvertTransform(
}
}
+bool ExactlyEqual(const chromecast::RectF& r1, const chromecast::RectF& r2) {
+ return r1.x == r2.x && r1.y == r2.y && r1.width == r2.width &&
+ r1.height == r2.height;
+}
+
class OverlayCandidatesCast : public OverlayCandidatesOzone {
public:
- void CheckOverlaySupport(OverlaySurfaceCandidateList* surfaces) override {
- for (auto& candidate : *surfaces) {
- if (candidate.plane_z_order == -1) {
- candidate.overlay_handled = true;
-
- // Compositor requires all overlay rectangles to have integer coords
- candidate.display_rect = gfx::ToEnclosedRect(candidate.display_rect);
-
- chromecast::media::VideoPlane* video_plane =
- chromecast::media::CastMediaShlib::GetVideoPlane();
-
- chromecast::RectF display_rect(
- candidate.display_rect.x(), candidate.display_rect.y(),
- candidate.display_rect.width(), candidate.display_rect.height());
- video_plane->SetGeometry(
- display_rect,
- chromecast::media::VideoPlane::COORDINATE_TYPE_GRAPHICS_PLANE,
- ConvertTransform(candidate.transform));
- return;
- }
+ OverlayCandidatesCast()
+ : media_task_runner_(
+ chromecast::media::MediaMessageLoop::GetTaskRunner()),
+ transform_(gfx::OVERLAY_TRANSFORM_INVALID),
+ display_rect_(0, 0, 0, 0) {}
+
+ void CheckOverlaySupport(OverlaySurfaceCandidateList* surfaces) override;
+
+ private:
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
+ gfx::OverlayTransform transform_;
+ chromecast::RectF display_rect_;
+};
+
+void OverlayCandidatesCast::CheckOverlaySupport(
+ OverlaySurfaceCandidateList* surfaces) {
+ for (auto& candidate : *surfaces) {
+ if (candidate.plane_z_order != -1)
+ continue;
+
+ candidate.overlay_handled = true;
+
+ // Compositor requires all overlay rectangles to have integer coords
+ candidate.display_rect = gfx::ToEnclosedRect(candidate.display_rect);
+
+ chromecast::RectF display_rect(
+ candidate.display_rect.x(), candidate.display_rect.y(),
+ candidate.display_rect.width(), candidate.display_rect.height());
+
+ // Update video plane geometry + transform to match compositor quad.
+ // This must be done on media thread - and no point doing if it hasn't
+ // changed.
+ if (candidate.transform != transform_ ||
+ !ExactlyEqual(display_rect, display_rect_)) {
+ transform_ = candidate.transform;
+ display_rect_ = display_rect;
+
+ media_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &SetVideoPlaneGeometry, display_rect,
+ chromecast::media::VideoPlane::COORDINATE_TYPE_GRAPHICS_PLANE,
+ ConvertTransform(candidate.transform)));
}
+ return;
}
-};
+}
} // namespace
« no previous file with comments | « ui/ozone/platform/cast/cast.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698