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

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

Issue 2136413002: Update Surface ID Terminology (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix webkit_unit_tests Created 4 years, 5 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_output_surface.h" 5 #include "content/renderer/android/synchronous_compositor_output_surface.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 26 matching lines...) Expand all
37 #include "third_party/skia/include/core/SkCanvas.h" 37 #include "third_party/skia/include/core/SkCanvas.h"
38 #include "ui/gfx/geometry/rect_conversions.h" 38 #include "ui/gfx/geometry/rect_conversions.h"
39 #include "ui/gfx/skia_util.h" 39 #include "ui/gfx/skia_util.h"
40 #include "ui/gfx/transform.h" 40 #include "ui/gfx/transform.h"
41 41
42 namespace content { 42 namespace content {
43 43
44 namespace { 44 namespace {
45 45
46 const int64_t kFallbackTickTimeoutInMilliseconds = 100; 46 const int64_t kFallbackTickTimeoutInMilliseconds = 100;
47 const uint32_t kCompositorSurfaceNamespace = 1; 47 const uint32_t kCompositorClientId = 1;
48 48
49 // Do not limit number of resources, so use an unrealistically high value. 49 // Do not limit number of resources, so use an unrealistically high value.
50 const size_t kNumResourcesLimit = 10 * 1000 * 1000; 50 const size_t kNumResourcesLimit = 10 * 1000 * 1000;
51 51
52 } // namespace 52 } // namespace
53 53
54 class SoftwareDevice : public cc::SoftwareOutputDevice { 54 class SoftwareDevice : public cc::SoftwareOutputDevice {
55 public: 55 public:
56 SoftwareDevice(SkCanvas** canvas) : canvas_(canvas) {} 56 SoftwareDevice(SkCanvas** canvas) : canvas_(canvas) {}
57 57
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 std::move(worker_context_provider), 91 std::move(worker_context_provider),
92 nullptr), 92 nullptr),
93 routing_id_(routing_id), 93 routing_id_(routing_id),
94 output_surface_id_(output_surface_id), 94 output_surface_id_(output_surface_id),
95 registry_(registry), 95 registry_(registry),
96 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()), 96 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()),
97 memory_policy_(0u), 97 memory_policy_(0u),
98 frame_swap_message_queue_(frame_swap_message_queue), 98 frame_swap_message_queue_(frame_swap_message_queue),
99 surface_manager_(new cc::SurfaceManager), 99 surface_manager_(new cc::SurfaceManager),
100 surface_id_allocator_( 100 surface_id_allocator_(
101 new cc::SurfaceIdAllocator(kCompositorSurfaceNamespace)), 101 new cc::SurfaceIdAllocator(0 /* gpu_id */, kCompositorClientId)),
102 surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)) { 102 surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)) {
103 DCHECK(registry_); 103 DCHECK(registry_);
104 DCHECK(sender_); 104 DCHECK(sender_);
105 thread_checker_.DetachFromThread(); 105 thread_checker_.DetachFromThread();
106 capabilities_.adjust_deadline_for_parent = false; 106 capabilities_.adjust_deadline_for_parent = false;
107 capabilities_.delegated_rendering = true; 107 capabilities_.delegated_rendering = true;
108 memory_policy_.priority_cutoff_when_visible = 108 memory_policy_.priority_cutoff_when_visible =
109 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; 109 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
110 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); 110 surface_id_allocator_->RegisterSurfaceClientId(surface_manager_.get());
111 } 111 }
112 112
113 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} 113 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {}
114 114
115 void SynchronousCompositorOutputSurface::SetSyncClient( 115 void SynchronousCompositorOutputSurface::SetSyncClient(
116 SynchronousCompositorOutputSurfaceClient* compositor) { 116 SynchronousCompositorOutputSurfaceClient* compositor) {
117 DCHECK(CalledOnValidThread()); 117 DCHECK(CalledOnValidThread());
118 sync_client_ = compositor; 118 sync_client_ = compositor;
119 if (sync_client_) 119 if (sync_client_)
120 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_)); 120 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_));
(...skipping 17 matching lines...) Expand all
138 return false; 138 return false;
139 139
140 client_->SetMemoryPolicy(memory_policy_); 140 client_->SetMemoryPolicy(memory_policy_);
141 client_->SetTreeActivationCallback( 141 client_->SetTreeActivationCallback(
142 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, 142 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree,
143 base::Unretained(this))); 143 base::Unretained(this)));
144 registry_->RegisterOutputSurface(routing_id_, this); 144 registry_->RegisterOutputSurface(routing_id_, this);
145 registered_ = true; 145 registered_ = true;
146 146
147 surface_manager_->RegisterSurfaceFactoryClient( 147 surface_manager_->RegisterSurfaceFactoryClient(
148 surface_id_allocator_->id_namespace(), this); 148 surface_id_allocator_->client_id(), this);
149 149
150 cc::RendererSettings software_renderer_settings; 150 cc::RendererSettings software_renderer_settings;
151 151
152 // The shared_bitmap_manager and gpu_memory_buffer_manager here are null as 152 // The shared_bitmap_manager and gpu_memory_buffer_manager here are null as
153 // this Display is only used for resourcesless software draws, where no 153 // this Display is only used for resourcesless software draws, where no
154 // resources are included in the frame swapped from the compositor. So there 154 // resources are included in the frame swapped from the compositor. So there
155 // is no need for these. 155 // is no need for these.
156 display_.reset(new cc::Display( 156 display_.reset(new cc::Display(
157 surface_manager_.get(), nullptr /* shared_bitmap_manager */, 157 surface_manager_.get(), nullptr /* shared_bitmap_manager */,
158 nullptr /* gpu_memory_buffer_manager */, software_renderer_settings, 158 nullptr /* gpu_memory_buffer_manager */, software_renderer_settings,
159 surface_id_allocator_->id_namespace(), nullptr /* begin_frame_source */, 159 surface_id_allocator_->client_id(), nullptr /* begin_frame_source */,
160 base::MakeUnique<SoftwareOutputSurface>( 160 base::MakeUnique<SoftwareOutputSurface>(
161 base::MakeUnique<SoftwareDevice>(&current_sw_canvas_)), 161 base::MakeUnique<SoftwareDevice>(&current_sw_canvas_)),
162 nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */)); 162 nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */));
163 display_->Initialize(&display_client_); 163 display_->Initialize(&display_client_);
164 return true; 164 return true;
165 } 165 }
166 166
167 void SynchronousCompositorOutputSurface::DetachFromClient() { 167 void SynchronousCompositorOutputSurface::DetachFromClient() {
168 DCHECK(CalledOnValidThread()); 168 DCHECK(CalledOnValidThread());
169 if (registered_) { 169 if (registered_) {
170 registry_->UnregisterOutputSurface(routing_id_, this); 170 registry_->UnregisterOutputSurface(routing_id_, this);
171 } 171 }
172 client_->SetTreeActivationCallback(base::Closure()); 172 client_->SetTreeActivationCallback(base::Closure());
173 if (!delegated_surface_id_.is_null()) 173 if (!delegated_surface_id_.is_null())
174 surface_factory_->Destroy(delegated_surface_id_); 174 surface_factory_->Destroy(delegated_surface_id_);
175 surface_manager_->UnregisterSurfaceFactoryClient( 175 surface_manager_->UnregisterSurfaceFactoryClient(
176 surface_id_allocator_->id_namespace()); 176 surface_id_allocator_->client_id());
177 display_ = nullptr; 177 display_ = nullptr;
178 surface_factory_ = nullptr; 178 surface_factory_ = nullptr;
179 surface_id_allocator_ = nullptr; 179 surface_id_allocator_ = nullptr;
180 surface_manager_ = nullptr; 180 surface_manager_ = nullptr;
181 cc::OutputSurface::DetachFromClient(); 181 cc::OutputSurface::DetachFromClient();
182 CancelFallbackTick(); 182 CancelFallbackTick();
183 } 183 }
184 184
185 void SynchronousCompositorOutputSurface::Reshape( 185 void SynchronousCompositorOutputSurface::Reshape(
186 const gfx::Size& size, 186 const gfx::Size& size,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 client_->ReclaimResources(&ack); 402 client_->ReclaimResources(&ack);
403 } 403 }
404 404
405 void SynchronousCompositorOutputSurface::SetBeginFrameSource( 405 void SynchronousCompositorOutputSurface::SetBeginFrameSource(
406 cc::BeginFrameSource* begin_frame_source) { 406 cc::BeginFrameSource* begin_frame_source) {
407 // Software output is synchronous and doesn't use a BeginFrameSource. 407 // Software output is synchronous and doesn't use a BeginFrameSource.
408 NOTREACHED(); 408 NOTREACHED();
409 } 409 }
410 410
411 } // namespace content 411 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698