OLD | NEW |
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 "android_webview/browser/hardware_renderer.h" | 5 #include "android_webview/browser/hardware_renderer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "android_webview/browser/aw_gl_surface.h" | 9 #include "android_webview/browser/aw_gl_surface.h" |
10 #include "android_webview/browser/aw_render_thread_context_provider.h" | 10 #include "android_webview/browser/aw_render_thread_context_provider.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 settings.highp_threshold_min = 2048; | 51 settings.highp_threshold_min = 2048; |
52 | 52 |
53 // Webview does not own the surface so should not clear it. | 53 // Webview does not own the surface so should not clear it. |
54 settings.should_clear_root_render_pass = false; | 54 settings.should_clear_root_render_pass = false; |
55 | 55 |
56 surface_manager_.reset(new cc::SurfaceManager); | 56 surface_manager_.reset(new cc::SurfaceManager); |
57 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(1)); | 57 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(1)); |
58 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); | 58 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); |
59 surface_manager_->RegisterSurfaceFactoryClient( | 59 surface_manager_->RegisterSurfaceFactoryClient( |
60 surface_id_allocator_->id_namespace(), this); | 60 surface_id_allocator_->id_namespace(), this); |
61 display_.reset(new cc::Display(this, surface_manager_.get(), nullptr, nullptr, | 61 |
62 settings, | 62 std::unique_ptr<ParentOutputSurface> output_surface_holder( |
63 surface_id_allocator_->id_namespace())); | 63 new ParentOutputSurface(AwRenderThreadContextProvider::Create( |
| 64 gl_surface_, DeferredGpuCommandService::GetInstance()))); |
| 65 output_surface_ = output_surface_holder.get(); |
| 66 display_.reset(new cc::Display( |
| 67 surface_manager_.get(), nullptr /* shared_bitmap_manager */, |
| 68 nullptr /* gpu_memory_buffer_manager */, settings, |
| 69 surface_id_allocator_->id_namespace(), nullptr /* task_runner */, |
| 70 std::move(output_surface_holder))); |
| 71 display_->Initialize(this); |
64 } | 72 } |
65 | 73 |
66 HardwareRenderer::~HardwareRenderer() { | 74 HardwareRenderer::~HardwareRenderer() { |
67 // Must reset everything before |surface_factory_| to ensure all | 75 // Must reset everything before |surface_factory_| to ensure all |
68 // resources are returned before resetting. | 76 // resources are returned before resetting. |
69 if (!root_id_.is_null()) | 77 if (!root_id_.is_null()) |
70 surface_factory_->Destroy(root_id_); | 78 surface_factory_->Destroy(root_id_); |
71 if (!child_id_.is_null()) | 79 if (!child_id_.is_null()) |
72 surface_factory_->Destroy(child_id_); | 80 surface_factory_->Destroy(child_id_); |
73 display_.reset(); | 81 display_.reset(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 if (root_id_.is_null()) { | 214 if (root_id_.is_null()) { |
207 root_id_ = surface_id_allocator_->GenerateId(); | 215 root_id_ = surface_id_allocator_->GenerateId(); |
208 surface_factory_->Create(root_id_); | 216 surface_factory_->Create(root_id_); |
209 display_->SetSurfaceId(root_id_, 1.f); | 217 display_->SetSurfaceId(root_id_, 1.f); |
210 } | 218 } |
211 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), | 219 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), |
212 cc::SurfaceFactory::DrawCallback()); | 220 cc::SurfaceFactory::DrawCallback()); |
213 | 221 |
214 display_->Resize(viewport); | 222 display_->Resize(viewport); |
215 | 223 |
216 if (!output_surface_) { | |
217 scoped_refptr<cc::ContextProvider> context_provider = | |
218 AwRenderThreadContextProvider::Create( | |
219 gl_surface_, DeferredGpuCommandService::GetInstance()); | |
220 std::unique_ptr<ParentOutputSurface> output_surface_holder( | |
221 new ParentOutputSurface(context_provider)); | |
222 output_surface_ = output_surface_holder.get(); | |
223 display_->Initialize(std::move(output_surface_holder), nullptr); | |
224 } | |
225 output_surface_->SetGLState(gl_state); | 224 output_surface_->SetGLState(gl_state); |
226 display_->SetExternalClip(clip); | 225 display_->SetExternalClip(clip); |
227 display_->DrawAndSwap(); | 226 display_->DrawAndSwap(); |
228 } | 227 } |
229 | 228 |
230 void HardwareRenderer::ReturnResources( | 229 void HardwareRenderer::ReturnResources( |
231 const cc::ReturnedResourceArray& resources) { | 230 const cc::ReturnedResourceArray& resources) { |
232 ReturnResourcesToCompositor(resources, compositor_id_, | 231 ReturnResourcesToCompositor(resources, compositor_id_, |
233 last_submitted_output_surface_id_); | 232 last_submitted_output_surface_id_); |
234 } | 233 } |
(...skipping 28 matching lines...) Expand all Loading... |
263 const cc::ReturnedResourceArray& resources, | 262 const cc::ReturnedResourceArray& resources, |
264 uint32_t compositor_id, | 263 uint32_t compositor_id, |
265 uint32_t output_surface_id) { | 264 uint32_t output_surface_id) { |
266 if (output_surface_id != last_committed_output_surface_id_) | 265 if (output_surface_id != last_committed_output_surface_id_) |
267 return; | 266 return; |
268 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 267 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
269 output_surface_id); | 268 output_surface_id); |
270 } | 269 } |
271 | 270 |
272 } // namespace android_webview | 271 } // namespace android_webview |
OLD | NEW |