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

Side by Side Diff: content/renderer/android/synchronous_compositor_frame_sink.cc

Issue 2388753003: Introduce cc::LocalFrameId and use in SurfaceFactory (Closed)
Patch Set: Fix exo_unittests Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/android/synchronous_compositor_frame_sink.h" 5 #include "content/renderer/android/synchronous_compositor_frame_sink.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) 111 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue)
112 : cc::CompositorFrameSink(std::move(context_provider), 112 : cc::CompositorFrameSink(std::move(context_provider),
113 std::move(worker_context_provider)), 113 std::move(worker_context_provider)),
114 routing_id_(routing_id), 114 routing_id_(routing_id),
115 compositor_frame_sink_id_(compositor_frame_sink_id), 115 compositor_frame_sink_id_(compositor_frame_sink_id),
116 registry_(registry), 116 registry_(registry),
117 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()), 117 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()),
118 memory_policy_(0u), 118 memory_policy_(0u),
119 frame_swap_message_queue_(frame_swap_message_queue), 119 frame_swap_message_queue_(frame_swap_message_queue),
120 surface_manager_(new cc::SurfaceManager), 120 surface_manager_(new cc::SurfaceManager),
121 surface_id_allocator_(new cc::SurfaceIdAllocator(kFrameSinkId)), 121 surface_id_allocator_(new cc::SurfaceIdAllocator()),
122 surface_factory_( 122 surface_factory_(
123 new cc::SurfaceFactory(kFrameSinkId, surface_manager_.get(), this)), 123 new cc::SurfaceFactory(kFrameSinkId, surface_manager_.get(), this)),
124 begin_frame_source_(std::move(begin_frame_source)) { 124 begin_frame_source_(std::move(begin_frame_source)) {
125 DCHECK(registry_); 125 DCHECK(registry_);
126 DCHECK(sender_); 126 DCHECK(sender_);
127 DCHECK(begin_frame_source_); 127 DCHECK(begin_frame_source_);
128 thread_checker_.DetachFromThread(); 128 thread_checker_.DetachFromThread();
129 memory_policy_.priority_cutoff_when_visible = 129 memory_policy_.priority_cutoff_when_visible =
130 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; 130 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
131 } 131 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 191
192 void SynchronousCompositorFrameSink::DetachFromClient() { 192 void SynchronousCompositorFrameSink::DetachFromClient() {
193 DCHECK(CalledOnValidThread()); 193 DCHECK(CalledOnValidThread());
194 client_->SetBeginFrameSource(nullptr); 194 client_->SetBeginFrameSource(nullptr);
195 // Destroy the begin frame source on the same thread it was bound on. 195 // Destroy the begin frame source on the same thread it was bound on.
196 begin_frame_source_ = nullptr; 196 begin_frame_source_ = nullptr;
197 if (registered_) 197 if (registered_)
198 registry_->UnregisterCompositorFrameSink(routing_id_, this); 198 registry_->UnregisterCompositorFrameSink(routing_id_, this);
199 client_->SetTreeActivationCallback(base::Closure()); 199 client_->SetTreeActivationCallback(base::Closure());
200 if (!root_surface_id_.is_null()) { 200 if (!root_local_frame_id_.is_null()) {
201 surface_factory_->Destroy(root_surface_id_); 201 surface_factory_->Destroy(root_local_frame_id_);
202 surface_factory_->Destroy(child_surface_id_); 202 surface_factory_->Destroy(child_local_frame_id_);
203 } 203 }
204 surface_manager_->UnregisterSurfaceFactoryClient(kFrameSinkId); 204 surface_manager_->UnregisterSurfaceFactoryClient(kFrameSinkId);
205 surface_manager_->InvalidateFrameSinkId(kFrameSinkId); 205 surface_manager_->InvalidateFrameSinkId(kFrameSinkId);
206 software_output_surface_ = nullptr; 206 software_output_surface_ = nullptr;
207 display_ = nullptr; 207 display_ = nullptr;
208 surface_factory_ = nullptr; 208 surface_factory_ = nullptr;
209 surface_id_allocator_ = nullptr; 209 surface_id_allocator_ = nullptr;
210 surface_manager_ = nullptr; 210 surface_manager_ = nullptr;
211 cc::CompositorFrameSink::DetachFromClient(); 211 cc::CompositorFrameSink::DetachFromClient();
212 CancelFallbackTick(); 212 CancelFallbackTick();
(...skipping 13 matching lines...) Expand all
226 return; 226 return;
227 } 227 }
228 228
229 cc::CompositorFrame swap_frame; 229 cc::CompositorFrame swap_frame;
230 230
231 if (in_software_draw_) { 231 if (in_software_draw_) {
232 // The frame we send to the client is actually just the metadata. Preserve 232 // The frame we send to the client is actually just the metadata. Preserve
233 // the |frame| for the software path below. 233 // the |frame| for the software path below.
234 swap_frame.metadata = frame.metadata.Clone(); 234 swap_frame.metadata = frame.metadata.Clone();
235 235
236 if (root_surface_id_.is_null()) { 236 if (root_local_frame_id_.is_null()) {
237 root_surface_id_ = surface_id_allocator_->GenerateId(); 237 root_local_frame_id_ = surface_id_allocator_->GenerateId();
238 surface_factory_->Create(root_surface_id_); 238 surface_factory_->Create(root_local_frame_id_);
239 child_surface_id_ = surface_id_allocator_->GenerateId(); 239 child_local_frame_id_ = surface_id_allocator_->GenerateId();
240 surface_factory_->Create(child_surface_id_); 240 surface_factory_->Create(child_local_frame_id_);
241 } 241 }
242 242
243 display_->SetSurfaceId(root_surface_id_, 243 display_->SetSurfaceId(cc::SurfaceId(kFrameSinkId, root_local_frame_id_),
244 frame.metadata.device_scale_factor); 244 frame.metadata.device_scale_factor);
245 245
246 // The layer compositor should be giving a frame that covers the 246 // The layer compositor should be giving a frame that covers the
247 // |sw_viewport_for_current_draw_| but at 0,0. 247 // |sw_viewport_for_current_draw_| but at 0,0.
248 gfx::Size child_size = sw_viewport_for_current_draw_.size(); 248 gfx::Size child_size = sw_viewport_for_current_draw_.size();
249 DCHECK(gfx::Rect(child_size) == 249 DCHECK(gfx::Rect(child_size) ==
250 frame.delegated_frame_data->render_pass_list.back()->output_rect); 250 frame.delegated_frame_data->render_pass_list.back()->output_rect);
251 251
252 // Make a size that covers from 0,0 and includes the area coming from the 252 // Make a size that covers from 0,0 and includes the area coming from the
253 // layer compositor. 253 // layer compositor.
(...skipping 27 matching lines...) Expand all
281 // The RenderPass has a single SurfaceDrawQuad (and SharedQuadState for it). 281 // The RenderPass has a single SurfaceDrawQuad (and SharedQuadState for it).
282 auto* shared_quad_state = 282 auto* shared_quad_state =
283 embed_render_pass->CreateAndAppendSharedQuadState(); 283 embed_render_pass->CreateAndAppendSharedQuadState();
284 auto* surface_quad = 284 auto* surface_quad =
285 embed_render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); 285 embed_render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
286 shared_quad_state->SetAll( 286 shared_quad_state->SetAll(
287 child_transform, child_size, gfx::Rect(child_size), 287 child_transform, child_size, gfx::Rect(child_size),
288 gfx::Rect() /* clip_rect */, false /* is_clipped */, 1.f /* opacity */, 288 gfx::Rect() /* clip_rect */, false /* is_clipped */, 1.f /* opacity */,
289 SkXfermode::kSrcOver_Mode, 0 /* sorting_context_id */); 289 SkXfermode::kSrcOver_Mode, 0 /* sorting_context_id */);
290 surface_quad->SetNew(shared_quad_state, gfx::Rect(child_size), 290 surface_quad->SetNew(shared_quad_state, gfx::Rect(child_size),
291 gfx::Rect(child_size), child_surface_id_); 291 gfx::Rect(child_size),
292 cc::SurfaceId(kFrameSinkId, child_local_frame_id_));
292 293
293 surface_factory_->SubmitCompositorFrame(child_surface_id_, std::move(frame), 294 surface_factory_->SubmitCompositorFrame(
294 base::Bind(&NoOpDrawCallback)); 295 child_local_frame_id_, std::move(frame), base::Bind(&NoOpDrawCallback));
295 surface_factory_->SubmitCompositorFrame(root_surface_id_, 296 surface_factory_->SubmitCompositorFrame(root_local_frame_id_,
296 std::move(embed_frame), 297 std::move(embed_frame),
297 base::Bind(&NoOpDrawCallback)); 298 base::Bind(&NoOpDrawCallback));
298 display_->DrawAndSwap(); 299 display_->DrawAndSwap();
299 } else { 300 } else {
300 // For hardware draws we send the whole frame to the client so it can draw 301 // For hardware draws we send the whole frame to the client so it can draw
301 // the content in it. 302 // the content in it.
302 swap_frame = std::move(frame); 303 swap_frame = std::move(frame);
303 } 304 }
304 305
305 sync_client_->SwapBuffers(compositor_frame_sink_id_, std::move(swap_frame)); 306 sync_client_->SwapBuffers(compositor_frame_sink_id_, std::move(swap_frame));
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 client_->ReclaimResources(resources); 464 client_->ReclaimResources(resources);
464 } 465 }
465 466
466 void SynchronousCompositorFrameSink::SetBeginFrameSource( 467 void SynchronousCompositorFrameSink::SetBeginFrameSource(
467 cc::BeginFrameSource* begin_frame_source) { 468 cc::BeginFrameSource* begin_frame_source) {
468 // Software output is synchronous and doesn't use a BeginFrameSource. 469 // Software output is synchronous and doesn't use a BeginFrameSource.
469 NOTREACHED(); 470 NOTREACHED();
470 } 471 }
471 472
472 } // namespace content 473 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698