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

Side by Side Diff: cc/surfaces/surface_factory.cc

Issue 2811813004: Surface Synchronization: Distinguish between dependencies and references (Closed)
Patch Set: Addressed Vlad's comments Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/surfaces/surface_factory.h" 5 #include "cc/surfaces/surface_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { 100 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
101 holder_.RefResources(resources); 101 holder_.RefResources(resources);
102 } 102 }
103 103
104 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { 104 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
105 holder_.UnrefResources(resources); 105 holder_.UnrefResources(resources);
106 } 106 }
107 107
108 void SurfaceFactory::OnReferencedSurfacesChanged(
109 Surface* surface,
110 const std::vector<SurfaceId>* active_referenced_surfaces,
111 const std::vector<SurfaceId>* pending_referenced_surfaces) {
112 client_->ReferencedSurfacesChanged(surface->surface_id().local_surface_id(),
113 active_referenced_surfaces,
114 pending_referenced_surfaces);
115 }
116
117 void SurfaceFactory::OnSurfaceActivated(Surface* surface) { 108 void SurfaceFactory::OnSurfaceActivated(Surface* surface) {
118 DCHECK(surface->HasActiveFrame()); 109 DCHECK(surface->HasActiveFrame());
119 if (seen_first_frame_activation_) 110 if (!seen_first_frame_activation_) {
120 return; 111 seen_first_frame_activation_ = true;
121 112
122 seen_first_frame_activation_ = true; 113 const CompositorFrame& frame = surface->GetActiveFrame();
114 // CompositorFrames might not be populated with a RenderPass in unit tests.
115 gfx::Size frame_size;
116 if (!frame.render_pass_list.empty())
117 frame_size = frame.render_pass_list.back()->output_rect.size();
123 118
124 const CompositorFrame& frame = surface->GetActiveFrame(); 119 // SurfaceCreated only applies for the first Surface activation. Thus,
125 // CompositorFrames might not be populated with a RenderPass in unit tests. 120 // SurfaceFactory stops observing new activations after the first one.
126 gfx::Size frame_size; 121 manager_->SurfaceCreated(SurfaceInfo(
127 if (!frame.render_pass_list.empty()) 122 surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
128 frame_size = frame.render_pass_list.back()->output_rect.size(); 123 }
129 124 // Fire SurfaceCreated first so that a temporary reference is added before it
130 // SurfaceCreated only applies for the first Surface activation. Thus, 125 // is potentially transformed into a real reference by the client.
131 // SurfaceFactory stops observing new activations after the first one. 126 client_->ReferencedSurfacesChanged(surface->surface_id().local_surface_id(),
132 manager_->SurfaceCreated(SurfaceInfo( 127 surface->active_referenced_surfaces());
133 surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
134 } 128 }
135 129
136 void SurfaceFactory::OnSurfaceDependenciesChanged( 130 void SurfaceFactory::OnSurfaceDependenciesChanged(
137 Surface* surface, 131 Surface* surface,
138 const SurfaceDependencies& added_dependencies, 132 const SurfaceDependencies& added_dependencies,
139 const SurfaceDependencies& removed_dependencies) {} 133 const SurfaceDependencies& removed_dependencies) {}
140 134
141 void SurfaceFactory::OnSurfaceDiscarded(Surface* surface) {} 135 void SurfaceFactory::OnSurfaceDiscarded(Surface* surface) {}
142 136
143 std::unique_ptr<Surface> SurfaceFactory::Create( 137 std::unique_ptr<Surface> SurfaceFactory::Create(
144 const LocalSurfaceId& local_surface_id) { 138 const LocalSurfaceId& local_surface_id) {
145 seen_first_frame_activation_ = false; 139 seen_first_frame_activation_ = false;
146 std::unique_ptr<Surface> surface = 140 std::unique_ptr<Surface> surface =
147 manager_->CreateSurface(weak_factory_.GetWeakPtr(), local_surface_id); 141 manager_->CreateSurface(weak_factory_.GetWeakPtr(), local_surface_id);
148 surface->AddObserver(this); 142 surface->AddObserver(this);
149 return surface; 143 return surface;
150 } 144 }
151 145
152 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { 146 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) {
153 surface->RemoveObserver(this); 147 surface->RemoveObserver(this);
154 manager_->DestroySurface(std::move(surface)); 148 manager_->DestroySurface(std::move(surface));
155 } 149 }
156 150
157 } // namespace cc 151 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698