| 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_manager_->RegisterSurfaceFactoryClient( |
| 57 surface_id_allocator_.id_namespace(), this); |
| 56 display_.reset(new cc::Display(this, surface_manager_.get(), nullptr, nullptr, | 58 display_.reset(new cc::Display(this, surface_manager_.get(), nullptr, nullptr, |
| 57 settings)); | 59 settings)); |
| 58 } | 60 } |
| 59 | 61 |
| 60 HardwareRenderer::~HardwareRenderer() { | 62 HardwareRenderer::~HardwareRenderer() { |
| 61 // Must reset everything before |surface_factory_| to ensure all | 63 // Must reset everything before |surface_factory_| to ensure all |
| 62 // resources are returned before resetting. | 64 // resources are returned before resetting. |
| 63 if (!root_id_.is_null()) | 65 if (!root_id_.is_null()) |
| 64 surface_factory_->Destroy(root_id_); | 66 surface_factory_->Destroy(root_id_); |
| 65 if (!child_id_.is_null()) | 67 if (!child_id_.is_null()) |
| 66 surface_factory_->Destroy(child_id_); | 68 surface_factory_->Destroy(child_id_); |
| 67 display_.reset(); | 69 display_.reset(); |
| 68 surface_factory_.reset(); | 70 surface_factory_.reset(); |
| 71 surface_manager_->RegisterSurfaceFactoryClient( |
| 72 surface_id_allocator_.id_namespace(), nullptr); |
| 69 | 73 |
| 70 // Reset draw constraints. | 74 // Reset draw constraints. |
| 71 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT( | 75 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT( |
| 72 ParentCompositorDrawConstraints()); | 76 ParentCompositorDrawConstraints()); |
| 73 ReturnResourcesInChildFrame(); | 77 ReturnResourcesInChildFrame(); |
| 74 } | 78 } |
| 75 | 79 |
| 76 void HardwareRenderer::CommitFrame() { | 80 void HardwareRenderer::CommitFrame() { |
| 77 TRACE_EVENT0("android_webview", "CommitFrame"); | 81 TRACE_EVENT0("android_webview", "CommitFrame"); |
| 78 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT(); | 82 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 display_->SetExternalClip(clip); | 219 display_->SetExternalClip(clip); |
| 216 display_->DrawAndSwap(); | 220 display_->DrawAndSwap(); |
| 217 } | 221 } |
| 218 | 222 |
| 219 void HardwareRenderer::ReturnResources( | 223 void HardwareRenderer::ReturnResources( |
| 220 const cc::ReturnedResourceArray& resources) { | 224 const cc::ReturnedResourceArray& resources) { |
| 221 ReturnResourcesToCompositor(resources, compositor_id_); | 225 ReturnResourcesToCompositor(resources, compositor_id_); |
| 222 } | 226 } |
| 223 | 227 |
| 224 void HardwareRenderer::SetBeginFrameSource( | 228 void HardwareRenderer::SetBeginFrameSource( |
| 225 cc::SurfaceId surface_id, | |
| 226 cc::BeginFrameSource* begin_frame_source) { | 229 cc::BeginFrameSource* begin_frame_source) { |
| 227 // TODO(tansell): Hook this up. | 230 // TODO(tansell): Hook this up. |
| 228 } | 231 } |
| 229 | 232 |
| 230 void HardwareRenderer::SetBackingFrameBufferObject( | 233 void HardwareRenderer::SetBackingFrameBufferObject( |
| 231 int framebuffer_binding_ext) { | 234 int framebuffer_binding_ext) { |
| 232 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); | 235 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); |
| 233 } | 236 } |
| 234 | 237 |
| 235 void HardwareRenderer::ReturnResourcesInChildFrame() { | 238 void HardwareRenderer::ReturnResourcesInChildFrame() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 247 child_frame_.reset(); | 250 child_frame_.reset(); |
| 248 } | 251 } |
| 249 | 252 |
| 250 void HardwareRenderer::ReturnResourcesToCompositor( | 253 void HardwareRenderer::ReturnResourcesToCompositor( |
| 251 const cc::ReturnedResourceArray& resources, | 254 const cc::ReturnedResourceArray& resources, |
| 252 unsigned int compositor_id) { | 255 unsigned int compositor_id) { |
| 253 shared_renderer_state_->InsertReturnedResourcesOnRT(resources, compositor_id); | 256 shared_renderer_state_->InsertReturnedResourcesOnRT(resources, compositor_id); |
| 254 } | 257 } |
| 255 | 258 |
| 256 } // namespace android_webview | 259 } // namespace android_webview |
| OLD | NEW |