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

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

Issue 2785103003: [cc] CompositorFrameSinkSupport: Defer BeginFrameAck of pending frames. (Closed)
Patch Set: add comment 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 Surface* surface, 109 Surface* surface,
110 const std::vector<SurfaceId>* active_referenced_surfaces, 110 const std::vector<SurfaceId>* active_referenced_surfaces,
111 const std::vector<SurfaceId>* pending_referenced_surfaces) { 111 const std::vector<SurfaceId>* pending_referenced_surfaces) {
112 client_->ReferencedSurfacesChanged(surface->surface_id().local_surface_id(), 112 client_->ReferencedSurfacesChanged(surface->surface_id().local_surface_id(),
113 active_referenced_surfaces, 113 active_referenced_surfaces,
114 pending_referenced_surfaces); 114 pending_referenced_surfaces);
115 } 115 }
116 116
117 void SurfaceFactory::OnSurfaceActivated(Surface* surface) { 117 void SurfaceFactory::OnSurfaceActivated(Surface* surface) {
118 DCHECK(surface->HasActiveFrame()); 118 DCHECK(surface->HasActiveFrame());
119
120 client_->PendingFrameActivated(surface->surface_id().local_surface_id());
121
119 if (seen_first_frame_activation_) 122 if (seen_first_frame_activation_)
120 return; 123 return;
121 124
122 seen_first_frame_activation_ = true; 125 seen_first_frame_activation_ = true;
123 126
124 const CompositorFrame& frame = surface->GetActiveFrame(); 127 const CompositorFrame& frame = surface->GetActiveFrame();
125 // CompositorFrames might not be populated with a RenderPass in unit tests. 128 // CompositorFrames might not be populated with a RenderPass in unit tests.
126 gfx::Size frame_size; 129 gfx::Size frame_size;
127 if (!frame.render_pass_list.empty()) 130 if (!frame.render_pass_list.empty())
128 frame_size = frame.render_pass_list.back()->output_rect.size(); 131 frame_size = frame.render_pass_list.back()->output_rect.size();
129 132
130 // SurfaceCreated only applies for the first Surface activation. Thus, 133 // SurfaceCreated only applies for the first Surface activation. Thus,
131 // SurfaceFactory stops observing new activations after the first one. 134 // SurfaceFactory stops observing new activations after the first one.
132 manager_->SurfaceCreated(SurfaceInfo( 135 manager_->SurfaceCreated(SurfaceInfo(
133 surface->surface_id(), frame.metadata.device_scale_factor, frame_size)); 136 surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
134 } 137 }
135 138
136 void SurfaceFactory::OnSurfaceDependenciesChanged( 139 void SurfaceFactory::OnSurfaceDependenciesChanged(
137 Surface* surface, 140 Surface* surface,
138 const SurfaceDependencies& added_dependencies, 141 const SurfaceDependencies& added_dependencies,
139 const SurfaceDependencies& removed_dependencies) {} 142 const SurfaceDependencies& removed_dependencies) {}
140 143
141 void SurfaceFactory::OnSurfaceDiscarded(Surface* surface) {} 144 void SurfaceFactory::OnSurfaceDiscarded(Surface* surface) {
145 client_->SurfaceDiscarded(surface->surface_id().local_surface_id());
146 }
142 147
143 std::unique_ptr<Surface> SurfaceFactory::Create( 148 std::unique_ptr<Surface> SurfaceFactory::Create(
144 const LocalSurfaceId& local_surface_id) { 149 const LocalSurfaceId& local_surface_id) {
145 seen_first_frame_activation_ = false; 150 seen_first_frame_activation_ = false;
146 std::unique_ptr<Surface> surface = 151 std::unique_ptr<Surface> surface =
147 manager_->CreateSurface(weak_factory_.GetWeakPtr(), local_surface_id); 152 manager_->CreateSurface(weak_factory_.GetWeakPtr(), local_surface_id);
148 surface->AddObserver(this); 153 surface->AddObserver(this);
149 return surface; 154 return surface;
150 } 155 }
151 156
152 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { 157 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) {
158 LocalSurfaceId surface_id = surface->surface_id().local_surface_id();
153 surface->RemoveObserver(this); 159 surface->RemoveObserver(this);
154 manager_->DestroySurface(std::move(surface)); 160 manager_->DestroySurface(std::move(surface));
161 client_->SurfaceDiscarded(surface_id);
155 } 162 }
156 163
157 } // namespace cc 164 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/direct_compositor_frame_sink_unittest.cc ('k') | cc/surfaces/surface_factory_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698