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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 // Should be kept in sync with compositor_impl_android.cc. | 47 // Should be kept in sync with compositor_impl_android.cc. |
48 settings.allow_antialiasing = false; | 48 settings.allow_antialiasing = false; |
49 settings.highp_threshold_min = 2048; | 49 settings.highp_threshold_min = 2048; |
50 | 50 |
51 // Webview does not own the surface so should not clear it. | 51 // Webview does not own the surface so should not clear it. |
52 settings.should_clear_root_render_pass = false; | 52 settings.should_clear_root_render_pass = false; |
53 | 53 |
54 surface_manager_.reset(new cc::SurfaceManager); | 54 surface_manager_.reset(new cc::SurfaceManager); |
55 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(1)); | 55 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(1)); |
| 56 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); |
| 57 surface_manager_->RegisterSurfaceFactoryClient( |
| 58 surface_id_allocator_->id_namespace(), this); |
56 display_.reset(new cc::Display(this, surface_manager_.get(), nullptr, nullptr, | 59 display_.reset(new cc::Display(this, surface_manager_.get(), nullptr, nullptr, |
57 settings)); | 60 settings)); |
58 } | 61 } |
59 | 62 |
60 HardwareRenderer::~HardwareRenderer() { | 63 HardwareRenderer::~HardwareRenderer() { |
61 // Must reset everything before |surface_factory_| to ensure all | 64 // Must reset everything before |surface_factory_| to ensure all |
62 // resources are returned before resetting. | 65 // resources are returned before resetting. |
63 if (!root_id_.is_null()) | 66 if (!root_id_.is_null()) |
64 surface_factory_->Destroy(root_id_); | 67 surface_factory_->Destroy(root_id_); |
65 if (!child_id_.is_null()) | 68 if (!child_id_.is_null()) |
66 surface_factory_->Destroy(child_id_); | 69 surface_factory_->Destroy(child_id_); |
67 display_.reset(); | 70 display_.reset(); |
68 surface_factory_.reset(); | 71 surface_factory_.reset(); |
| 72 surface_manager_->UnregisterSurfaceFactoryClient( |
| 73 surface_id_allocator_->id_namespace()); |
69 | 74 |
70 // Reset draw constraints. | 75 // Reset draw constraints. |
71 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT( | 76 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT( |
72 ParentCompositorDrawConstraints()); | 77 ParentCompositorDrawConstraints()); |
73 ReturnResourcesInChildFrame(); | 78 ReturnResourcesInChildFrame(); |
74 } | 79 } |
75 | 80 |
76 void HardwareRenderer::CommitFrame() { | 81 void HardwareRenderer::CommitFrame() { |
77 TRACE_EVENT0("android_webview", "CommitFrame"); | 82 TRACE_EVENT0("android_webview", "CommitFrame"); |
78 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT(); | 83 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 display_->SetExternalClip(clip); | 220 display_->SetExternalClip(clip); |
216 display_->DrawAndSwap(); | 221 display_->DrawAndSwap(); |
217 } | 222 } |
218 | 223 |
219 void HardwareRenderer::ReturnResources( | 224 void HardwareRenderer::ReturnResources( |
220 const cc::ReturnedResourceArray& resources) { | 225 const cc::ReturnedResourceArray& resources) { |
221 ReturnResourcesToCompositor(resources, compositor_id_); | 226 ReturnResourcesToCompositor(resources, compositor_id_); |
222 } | 227 } |
223 | 228 |
224 void HardwareRenderer::SetBeginFrameSource( | 229 void HardwareRenderer::SetBeginFrameSource( |
225 cc::SurfaceId surface_id, | |
226 cc::BeginFrameSource* begin_frame_source) { | 230 cc::BeginFrameSource* begin_frame_source) { |
227 // TODO(tansell): Hook this up. | 231 // TODO(tansell): Hook this up. |
228 } | 232 } |
229 | 233 |
230 void HardwareRenderer::SetBackingFrameBufferObject( | 234 void HardwareRenderer::SetBackingFrameBufferObject( |
231 int framebuffer_binding_ext) { | 235 int framebuffer_binding_ext) { |
232 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); | 236 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); |
233 } | 237 } |
234 | 238 |
235 void HardwareRenderer::ReturnResourcesInChildFrame() { | 239 void HardwareRenderer::ReturnResourcesInChildFrame() { |
(...skipping 11 matching lines...) Expand all Loading... |
247 child_frame_.reset(); | 251 child_frame_.reset(); |
248 } | 252 } |
249 | 253 |
250 void HardwareRenderer::ReturnResourcesToCompositor( | 254 void HardwareRenderer::ReturnResourcesToCompositor( |
251 const cc::ReturnedResourceArray& resources, | 255 const cc::ReturnedResourceArray& resources, |
252 unsigned int compositor_id) { | 256 unsigned int compositor_id) { |
253 shared_renderer_state_->InsertReturnedResourcesOnRT(resources, compositor_id); | 257 shared_renderer_state_->InsertReturnedResourcesOnRT(resources, compositor_id); |
254 } | 258 } |
255 | 259 |
256 } // namespace android_webview | 260 } // namespace android_webview |
OLD | NEW |