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

Unified Diff: services/ui/surfaces/gpu_compositor_frame_sink.cc

Issue 2632273003: Move ReferencedSurfaceTracker into GpuCompositorFrameSink. (Closed)
Patch Set: Fix iterator invalidation. Created 3 years, 11 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/surfaces/gpu_compositor_frame_sink.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/surfaces/gpu_compositor_frame_sink.cc
diff --git a/services/ui/surfaces/gpu_compositor_frame_sink.cc b/services/ui/surfaces/gpu_compositor_frame_sink.cc
index 34ef009d4fd1206f85067b472a8321c400c702b3..0e1584f94e80ffb369c5c68aa56f3a592ad8c7a4 100644
--- a/services/ui/surfaces/gpu_compositor_frame_sink.cc
+++ b/services/ui/surfaces/gpu_compositor_frame_sink.cc
@@ -4,6 +4,7 @@
#include "services/ui/surfaces/gpu_compositor_frame_sink.h"
+#include "cc/surfaces/surface_reference.h"
#include "services/ui/surfaces/display_compositor.h"
namespace ui {
@@ -24,6 +25,7 @@ GpuCompositorFrameSink::GpuCompositorFrameSink(
frame_sink_id,
std::move(display),
std::move(begin_frame_source)),
+ surface_tracker_(frame_sink_id),
client_(std::move(client)),
binding_(this, std::move(request)),
compositor_frame_sink_private_binding_(
@@ -38,7 +40,17 @@ GpuCompositorFrameSink::GpuCompositorFrameSink(
base::Unretained(this)));
}
-GpuCompositorFrameSink::~GpuCompositorFrameSink() {}
+GpuCompositorFrameSink::~GpuCompositorFrameSink() {
+ // For display root surfaces, remove the reference from top level root to
+ // indicate the display root surface is no longer visible.
+ if (support_.display() && surface_tracker_.current_surface_id().is_valid()) {
+ const cc::SurfaceId top_level_root_surface_id =
+ display_compositor_->manager()->GetRootSurfaceId();
+ std::vector<cc::SurfaceReference> references_to_remove{cc::SurfaceReference(
+ top_level_root_surface_id, surface_tracker_.current_surface_id())};
+ display_compositor_->RemoveSurfaceReferences(references_to_remove);
+ }
+}
void GpuCompositorFrameSink::EvictFrame() {
support_.EvictFrame();
@@ -51,17 +63,41 @@ void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) {
void GpuCompositorFrameSink::SubmitCompositorFrame(
const cc::LocalFrameId& local_frame_id,
cc::CompositorFrame frame) {
- support_.SubmitCompositorFrame(local_frame_id, std::move(frame));
-}
+ cc::SurfaceId start_surface_id = surface_tracker_.current_surface_id();
+ surface_tracker_.UpdateReferences(local_frame_id,
+ frame.metadata.referenced_surfaces);
-void GpuCompositorFrameSink::AddSurfaceReferences(
- const std::vector<cc::SurfaceReference>& references) {
- display_compositor_->AddSurfaceReferences(references);
-}
+ support_.SubmitCompositorFrame(local_frame_id, std::move(frame));
-void GpuCompositorFrameSink::RemoveSurfaceReferences(
- const std::vector<cc::SurfaceReference>& references) {
- display_compositor_->RemoveSurfaceReferences(references);
+ // Get the list of surfaces to add/remove from |surface_tracker_| so we can
+ // append to them before adding/removing.
+ std::vector<cc::SurfaceReference>& references_to_add =
+ surface_tracker_.references_to_add();
+ std::vector<cc::SurfaceReference>& references_to_remove =
+ surface_tracker_.references_to_remove();
+
+ // Append TLR references for the display root surfaces when display root
+ // surface changes.
+ if (support_.display() &&
+ start_surface_id != surface_tracker_.current_surface_id()) {
+ const cc::SurfaceId top_level_root_surface_id =
+ display_compositor_->manager()->GetRootSurfaceId();
+
+ // The first frame will not have a valid |start_surface_id| and there will
+ // be no surface to remove.
+ if (start_surface_id.local_frame_id().is_valid()) {
+ references_to_remove.push_back(
+ cc::SurfaceReference(top_level_root_surface_id, start_surface_id));
+ }
+
+ references_to_add.push_back(cc::SurfaceReference(
+ top_level_root_surface_id, surface_tracker_.current_surface_id()));
+ }
+
+ if (!references_to_add.empty())
+ display_compositor_->AddSurfaceReferences(references_to_add);
+ if (!references_to_remove.empty())
+ display_compositor_->RemoveSurfaceReferences(references_to_remove);
}
void GpuCompositorFrameSink::Require(const cc::LocalFrameId& local_frame_id,
« no previous file with comments | « services/ui/surfaces/gpu_compositor_frame_sink.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698