OLD | NEW |
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 Loading... |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 : cc::OutputSurface(std::move(context_provider), | 90 : cc::OutputSurface(std::move(context_provider), |
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_(new cc::SurfaceIdAllocator(kCompositorClientId)), |
101 new cc::SurfaceIdAllocator(kCompositorSurfaceNamespace)), | |
102 surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)) { | 101 surface_factory_(new cc::SurfaceFactory(surface_manager_.get(), this)) { |
103 DCHECK(registry_); | 102 DCHECK(registry_); |
104 DCHECK(sender_); | 103 DCHECK(sender_); |
105 thread_checker_.DetachFromThread(); | 104 thread_checker_.DetachFromThread(); |
106 capabilities_.adjust_deadline_for_parent = false; | 105 capabilities_.adjust_deadline_for_parent = false; |
107 capabilities_.delegated_rendering = true; | 106 capabilities_.delegated_rendering = true; |
108 memory_policy_.priority_cutoff_when_visible = | 107 memory_policy_.priority_cutoff_when_visible = |
109 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 108 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
110 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); | 109 surface_id_allocator_->RegisterSurfaceClientId(surface_manager_.get()); |
111 } | 110 } |
112 | 111 |
113 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} | 112 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} |
114 | 113 |
115 void SynchronousCompositorOutputSurface::SetSyncClient( | 114 void SynchronousCompositorOutputSurface::SetSyncClient( |
116 SynchronousCompositorOutputSurfaceClient* compositor) { | 115 SynchronousCompositorOutputSurfaceClient* compositor) { |
117 DCHECK(CalledOnValidThread()); | 116 DCHECK(CalledOnValidThread()); |
118 sync_client_ = compositor; | 117 sync_client_ = compositor; |
119 if (sync_client_) | 118 if (sync_client_) |
120 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_)); | 119 Send(new SyncCompositorHostMsg_OutputSurfaceCreated(routing_id_)); |
(...skipping 17 matching lines...) Expand all Loading... |
138 return false; | 137 return false; |
139 | 138 |
140 client_->SetMemoryPolicy(memory_policy_); | 139 client_->SetMemoryPolicy(memory_policy_); |
141 client_->SetTreeActivationCallback( | 140 client_->SetTreeActivationCallback( |
142 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, | 141 base::Bind(&SynchronousCompositorOutputSurface::DidActivatePendingTree, |
143 base::Unretained(this))); | 142 base::Unretained(this))); |
144 registry_->RegisterOutputSurface(routing_id_, this); | 143 registry_->RegisterOutputSurface(routing_id_, this); |
145 registered_ = true; | 144 registered_ = true; |
146 | 145 |
147 surface_manager_->RegisterSurfaceFactoryClient( | 146 surface_manager_->RegisterSurfaceFactoryClient( |
148 surface_id_allocator_->id_namespace(), this); | 147 surface_id_allocator_->client_id(), this); |
149 | 148 |
150 cc::RendererSettings software_renderer_settings; | 149 cc::RendererSettings software_renderer_settings; |
151 | 150 |
152 // The shared_bitmap_manager and gpu_memory_buffer_manager here are null as | 151 // 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 | 152 // this Display is only used for resourcesless software draws, where no |
154 // resources are included in the frame swapped from the compositor. So there | 153 // resources are included in the frame swapped from the compositor. So there |
155 // is no need for these. | 154 // is no need for these. |
156 display_.reset(new cc::Display( | 155 display_.reset(new cc::Display( |
157 surface_manager_.get(), nullptr /* shared_bitmap_manager */, | 156 surface_manager_.get(), nullptr /* shared_bitmap_manager */, |
158 nullptr /* gpu_memory_buffer_manager */, software_renderer_settings, | 157 nullptr /* gpu_memory_buffer_manager */, software_renderer_settings, |
159 surface_id_allocator_->id_namespace(), nullptr /* begin_frame_source */, | 158 surface_id_allocator_->client_id(), nullptr /* begin_frame_source */, |
160 base::MakeUnique<SoftwareOutputSurface>( | 159 base::MakeUnique<SoftwareOutputSurface>( |
161 base::MakeUnique<SoftwareDevice>(¤t_sw_canvas_)), | 160 base::MakeUnique<SoftwareDevice>(¤t_sw_canvas_)), |
162 nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */)); | 161 nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */)); |
163 display_->Initialize(&display_client_); | 162 display_->Initialize(&display_client_); |
164 return true; | 163 return true; |
165 } | 164 } |
166 | 165 |
167 void SynchronousCompositorOutputSurface::DetachFromClient() { | 166 void SynchronousCompositorOutputSurface::DetachFromClient() { |
168 DCHECK(CalledOnValidThread()); | 167 DCHECK(CalledOnValidThread()); |
169 if (registered_) { | 168 if (registered_) { |
170 registry_->UnregisterOutputSurface(routing_id_, this); | 169 registry_->UnregisterOutputSurface(routing_id_, this); |
171 } | 170 } |
172 client_->SetTreeActivationCallback(base::Closure()); | 171 client_->SetTreeActivationCallback(base::Closure()); |
173 if (!delegated_surface_id_.is_null()) | 172 if (!delegated_surface_id_.is_null()) |
174 surface_factory_->Destroy(delegated_surface_id_); | 173 surface_factory_->Destroy(delegated_surface_id_); |
175 surface_manager_->UnregisterSurfaceFactoryClient( | 174 surface_manager_->UnregisterSurfaceFactoryClient( |
176 surface_id_allocator_->id_namespace()); | 175 surface_id_allocator_->client_id()); |
177 display_ = nullptr; | 176 display_ = nullptr; |
178 surface_factory_ = nullptr; | 177 surface_factory_ = nullptr; |
179 surface_id_allocator_ = nullptr; | 178 surface_id_allocator_ = nullptr; |
180 surface_manager_ = nullptr; | 179 surface_manager_ = nullptr; |
181 cc::OutputSurface::DetachFromClient(); | 180 cc::OutputSurface::DetachFromClient(); |
182 CancelFallbackTick(); | 181 CancelFallbackTick(); |
183 } | 182 } |
184 | 183 |
185 void SynchronousCompositorOutputSurface::Reshape( | 184 void SynchronousCompositorOutputSurface::Reshape( |
186 const gfx::Size& size, | 185 const gfx::Size& size, |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 client_->ReclaimResources(&ack); | 401 client_->ReclaimResources(&ack); |
403 } | 402 } |
404 | 403 |
405 void SynchronousCompositorOutputSurface::SetBeginFrameSource( | 404 void SynchronousCompositorOutputSurface::SetBeginFrameSource( |
406 cc::BeginFrameSource* begin_frame_source) { | 405 cc::BeginFrameSource* begin_frame_source) { |
407 // Software output is synchronous and doesn't use a BeginFrameSource. | 406 // Software output is synchronous and doesn't use a BeginFrameSource. |
408 NOTREACHED(); | 407 NOTREACHED(); |
409 } | 408 } |
410 | 409 |
411 } // namespace content | 410 } // namespace content |
OLD | NEW |