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

Unified Diff: services/ui/ws/frame_generator.cc

Issue 2140783002: services/ui: Detect when a video is playing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot merge Created 4 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 | « services/ui/ws/frame_generator.h ('k') | services/ui/ws/frame_generator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/frame_generator.cc
diff --git a/services/ui/ws/frame_generator.cc b/services/ui/ws/frame_generator.cc
index 46e864cb95e44c48f7a085265ab619904bfc529f..c944b651785d3ece393a03cb3dd884effdb0f68e 100644
--- a/services/ui/ws/frame_generator.cc
+++ b/services/ui/ws/frame_generator.cc
@@ -69,8 +69,19 @@ void FrameGenerator::Draw() {
if (!delegate_->GetRootWindow()->visible())
return;
+ const ViewportMetrics& metrics = delegate_->GetViewportMetrics();
+ const gfx::Rect& output_rect = metrics.bounds;
+ dirty_rect_.Intersect(output_rect);
// TODO(fsamuel): We should add a trace for generating a top level frame.
- cc::CompositorFrame frame(GenerateCompositorFrame());
+ cc::CompositorFrame frame(GenerateCompositorFrame(output_rect));
+ if (frame.metadata.may_contain_video != may_contain_video_) {
+ may_contain_video_ = frame.metadata.may_contain_video;
+ // TODO(sad): Schedule notifying observers.
+ if (may_contain_video_) {
+ // TODO(sad): Start a timer to reset the bit if no new frame with video
+ // is submitted 'soon'.
+ }
+ }
frame_pending_ = true;
if (display_compositor_) {
display_compositor_->SubmitCompositorFrame(
@@ -87,17 +98,16 @@ void FrameGenerator::DidDraw() {
WantToDraw();
}
-cc::CompositorFrame FrameGenerator::GenerateCompositorFrame() {
- const ViewportMetrics& metrics = delegate_->GetViewportMetrics();
- std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
- gfx::Rect output_rect = metrics.bounds;
- dirty_rect_.Intersect(output_rect);
+cc::CompositorFrame FrameGenerator::GenerateCompositorFrame(
+ const gfx::Rect& output_rect) const {
const cc::RenderPassId render_pass_id(1, 1);
+ std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
render_pass->SetNew(render_pass_id, output_rect, dirty_rect_,
gfx::Transform());
+ bool may_contain_video = false;
DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(),
- 1.0f);
+ 1.0f, &may_contain_video);
std::unique_ptr<cc::DelegatedFrameData> frame_data(
new cc::DelegatedFrameData);
@@ -123,6 +133,7 @@ cc::CompositorFrame FrameGenerator::GenerateCompositorFrame() {
cc::CompositorFrame frame;
frame.delegated_frame_data = std::move(frame_data);
+ frame.metadata.may_contain_video = may_contain_video;
return frame;
}
@@ -130,7 +141,8 @@ void FrameGenerator::DrawWindowTree(
cc::RenderPass* pass,
ServerWindow* window,
const gfx::Vector2d& parent_to_root_origin_offset,
- float opacity) {
+ float opacity,
+ bool* may_contain_video) const {
if (!window->visible())
return;
@@ -144,7 +156,7 @@ void FrameGenerator::DrawWindowTree(
const float combined_opacity = opacity * window->opacity();
for (ServerWindow* child : base::Reversed(children)) {
DrawWindowTree(pass, child, absolute_bounds.OffsetFromOrigin(),
- combined_opacity);
+ combined_opacity, may_contain_video);
}
if (!window->surface_manager() || !window->surface_manager()->ShouldDraw())
@@ -176,6 +188,8 @@ void FrameGenerator::DrawWindowTree(
gfx::Rect() /* opaque_rect */,
bounds_at_origin /* visible_rect */, true /* needs_blending*/,
default_surface->id());
+ if (default_surface->may_contain_video())
+ *may_contain_video = true;
}
if (underlay_surface) {
const gfx::Rect underlay_absolute_bounds =
@@ -198,6 +212,7 @@ void FrameGenerator::DrawWindowTree(
gfx::Rect() /* opaque_rect */,
bounds_at_origin /* visible_rect */, true /* needs_blending*/,
underlay_surface->id());
+ DCHECK(!underlay_surface->may_contain_video());
}
}
« no previous file with comments | « services/ui/ws/frame_generator.h ('k') | services/ui/ws/frame_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698