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

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

Issue 2520513002: Add DisplayCompositorTest. (Closed)
Patch Set: Add non-exported base. Created 4 years 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/display_compositor.h ('k') | services/ui/surfaces/display_compositor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/surfaces/display_compositor.cc
diff --git a/services/ui/surfaces/display_compositor.cc b/services/ui/surfaces/display_compositor.cc
index ab1508aa82c3b9860fe33b5fa0cca16ab725f69d..340ac72dc99de30ed70b604ffca1703a74944178 100644
--- a/services/ui/surfaces/display_compositor.cc
+++ b/services/ui/surfaces/display_compositor.cc
@@ -4,6 +4,8 @@
#include "services/ui/surfaces/display_compositor.h"
+#include <utility>
+
#include "cc/output/in_process_context_provider.h"
#include "cc/surfaces/surface.h"
#include "gpu/command_buffer/client/shared_memory_limits.h"
@@ -24,6 +26,7 @@ DisplayCompositor::DisplayCompositor(
gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)),
image_factory_(image_factory),
client_(std::move(client)),
+ reference_manager_(&manager_),
binding_(this, std::move(request)) {
manager_.AddObserver(this);
}
@@ -54,7 +57,7 @@ void DisplayCompositor::CreateCompositorFrameSink(
void DisplayCompositor::AddRootSurfaceReference(const cc::SurfaceId& child_id) {
DCHECK(thread_checker_.CalledOnValidThread());
- AddSurfaceReference(manager_.GetRootSurfaceId(), child_id);
+ AddSurfaceReference(GetRootSurfaceId(), child_id);
}
void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
@@ -65,7 +68,7 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
// If there are no temporary references for the FrameSinkId then we can just
// add reference and return.
if (vector_iter == temp_references_.end()) {
- manager_.AddSurfaceReference(parent_id, child_id);
+ reference_manager_->AddSurfaceReference(parent_id, child_id);
return;
}
@@ -77,16 +80,16 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
std::find(refs.begin(), refs.end(), child_id.local_frame_id());
if (temp_ref_iter == refs.end()) {
- manager_.AddSurfaceReference(parent_id, child_id);
+ reference_manager_->AddSurfaceReference(parent_id, child_id);
return;
}
// All surfaces get a temporary reference to the top level root. If the parent
// wants to add a reference to the top level root then we do nothing.
// Otherwise remove the temporary reference and add the reference.
- if (parent_id != manager_.GetRootSurfaceId()) {
- manager_.AddSurfaceReference(parent_id, child_id);
- manager_.RemoveSurfaceReference(manager_.GetRootSurfaceId(), child_id);
+ if (parent_id != GetRootSurfaceId()) {
+ reference_manager_->AddSurfaceReference(parent_id, child_id);
+ reference_manager_->RemoveSurfaceReference(GetRootSurfaceId(), child_id);
}
// Remove temporary references for surfaces with the same FrameSinkId that
@@ -95,7 +98,7 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
// parent doesn't need them anymore.
for (auto iter = refs.begin(); iter != temp_ref_iter; ++iter) {
cc::SurfaceId id = cc::SurfaceId(child_id.frame_sink_id(), *iter);
- manager_.RemoveSurfaceReference(manager_.GetRootSurfaceId(), id);
+ reference_manager_->RemoveSurfaceReference(GetRootSurfaceId(), id);
}
// Remove markers for temporary references up to |child_id|, as the temporary
@@ -111,7 +114,7 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
void DisplayCompositor::RemoveRootSurfaceReference(
const cc::SurfaceId& child_id) {
DCHECK(thread_checker_.CalledOnValidThread());
- RemoveSurfaceReference(manager_.GetRootSurfaceId(), child_id);
+ RemoveSurfaceReference(GetRootSurfaceId(), child_id);
}
void DisplayCompositor::RemoveSurfaceReference(const cc::SurfaceId& parent_id,
@@ -119,7 +122,7 @@ void DisplayCompositor::RemoveSurfaceReference(const cc::SurfaceId& parent_id,
DCHECK(thread_checker_.CalledOnValidThread());
// TODO(kylechar): Each remove reference can trigger GC, it would be better if
// we GC only once if removing multiple references.
- manager_.RemoveSurfaceReference(parent_id, child_id);
+ reference_manager_->RemoveSurfaceReference(parent_id, child_id);
}
DisplayCompositor::~DisplayCompositor() {
@@ -128,9 +131,8 @@ DisplayCompositor::~DisplayCompositor() {
for (auto& map_entry : temp_references_) {
const cc::FrameSinkId& frame_sink_id = map_entry.first;
for (auto& local_frame_id : map_entry.second) {
- manager_.RemoveSurfaceReference(
- manager_.GetRootSurfaceId(),
- cc::SurfaceId(frame_sink_id, local_frame_id));
+ reference_manager_->RemoveSurfaceReference(
+ GetRootSurfaceId(), cc::SurfaceId(frame_sink_id, local_frame_id));
}
}
manager_.RemoveObserver(this);
@@ -155,6 +157,10 @@ void DisplayCompositor::OnCompositorFrameSinkPrivateConnectionLost(
compositor_frame_sinks_.erase(frame_sink_id);
}
+const cc::SurfaceId& DisplayCompositor::GetRootSurfaceId() const {
+ return reference_manager_->GetRootSurfaceId();
+}
+
void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id,
const gfx::Size& frame_size,
float device_scale_factor) {
@@ -165,7 +171,7 @@ void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id,
// the first will be destroyed and then if there are no references it will be
// deleted during surface GC. A temporary reference, removed when a real
// reference is received, is added to prevent this from happening.
- manager_.AddSurfaceReference(manager_.GetRootSurfaceId(), surface_id);
+ reference_manager_->AddSurfaceReference(GetRootSurfaceId(), surface_id);
temp_references_[surface_id.frame_sink_id()].push_back(
surface_id.local_frame_id());
« no previous file with comments | « services/ui/surfaces/display_compositor.h ('k') | services/ui/surfaces/display_compositor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698