| 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" |
| 11 #include "android_webview/browser/child_frame.h" | 11 #include "android_webview/browser/child_frame.h" |
| 12 #include "android_webview/browser/deferred_gpu_command_service.h" | 12 #include "android_webview/browser/deferred_gpu_command_service.h" |
| 13 #include "android_webview/browser/parent_compositor_draw_constraints.h" | 13 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| 14 #include "android_webview/browser/parent_output_surface.h" | 14 #include "android_webview/browser/parent_output_surface.h" |
| 15 #include "android_webview/browser/render_thread_manager.h" | 15 #include "android_webview/browser/render_thread_manager.h" |
| 16 #include "android_webview/public/browser/draw_gl.h" | 16 #include "android_webview/public/browser/draw_gl.h" |
| 17 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
| 20 #include "cc/output/compositor_frame.h" | 20 #include "cc/output/compositor_frame.h" |
| 21 #include "cc/output/output_surface.h" | 21 #include "cc/output/output_surface.h" |
| 22 #include "cc/output/renderer_settings.h" | 22 #include "cc/output/renderer_settings.h" |
| 23 #include "cc/output/texture_mailbox_deleter.h" |
| 23 #include "cc/quads/shared_quad_state.h" | 24 #include "cc/quads/shared_quad_state.h" |
| 24 #include "cc/quads/surface_draw_quad.h" | 25 #include "cc/quads/surface_draw_quad.h" |
| 26 #include "cc/scheduler/begin_frame_source.h" |
| 25 #include "cc/surfaces/display.h" | 27 #include "cc/surfaces/display.h" |
| 28 #include "cc/surfaces/display_scheduler.h" |
| 26 #include "cc/surfaces/surface_factory.h" | 29 #include "cc/surfaces/surface_factory.h" |
| 27 #include "cc/surfaces/surface_id_allocator.h" | 30 #include "cc/surfaces/surface_id_allocator.h" |
| 28 #include "gpu/command_buffer/client/gl_in_process_context.h" | 31 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 29 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 32 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 30 #include "ui/gfx/geometry/rect_conversions.h" | 33 #include "ui/gfx/geometry/rect_conversions.h" |
| 31 #include "ui/gfx/geometry/rect_f.h" | 34 #include "ui/gfx/geometry/rect_f.h" |
| 32 #include "ui/gfx/transform.h" | 35 #include "ui/gfx/transform.h" |
| 33 #include "ui/gl/gl_bindings.h" | 36 #include "ui/gl/gl_bindings.h" |
| 34 | 37 |
| 35 namespace android_webview { | 38 namespace android_webview { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 52 | 55 |
| 53 // Webview does not own the surface so should not clear it. | 56 // Webview does not own the surface so should not clear it. |
| 54 settings.should_clear_root_render_pass = false; | 57 settings.should_clear_root_render_pass = false; |
| 55 | 58 |
| 56 surface_manager_.reset(new cc::SurfaceManager); | 59 surface_manager_.reset(new cc::SurfaceManager); |
| 57 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(1)); | 60 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(1)); |
| 58 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); | 61 surface_id_allocator_->RegisterSurfaceIdNamespace(surface_manager_.get()); |
| 59 surface_manager_->RegisterSurfaceFactoryClient( | 62 surface_manager_->RegisterSurfaceFactoryClient( |
| 60 surface_id_allocator_->id_namespace(), this); | 63 surface_id_allocator_->id_namespace(), this); |
| 61 | 64 |
| 65 std::unique_ptr<cc::BeginFrameSource> begin_frame_source( |
| 66 new cc::StubBeginFrameSource); |
| 67 std::unique_ptr<cc::TextureMailboxDeleter> texture_mailbox_deleter( |
| 68 new cc::TextureMailboxDeleter(nullptr)); |
| 62 std::unique_ptr<ParentOutputSurface> output_surface_holder( | 69 std::unique_ptr<ParentOutputSurface> output_surface_holder( |
| 63 new ParentOutputSurface(AwRenderThreadContextProvider::Create( | 70 new ParentOutputSurface(AwRenderThreadContextProvider::Create( |
| 64 gl_surface_, DeferredGpuCommandService::GetInstance()))); | 71 gl_surface_, DeferredGpuCommandService::GetInstance()))); |
| 65 output_surface_ = output_surface_holder.get(); | 72 output_surface_ = output_surface_holder.get(); |
| 73 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
| 74 begin_frame_source.get(), nullptr, |
| 75 output_surface_holder->capabilities().max_frames_pending)); |
| 66 display_.reset(new cc::Display( | 76 display_.reset(new cc::Display( |
| 67 surface_manager_.get(), nullptr /* shared_bitmap_manager */, | 77 surface_manager_.get(), nullptr /* shared_bitmap_manager */, |
| 68 nullptr /* gpu_memory_buffer_manager */, settings, | 78 nullptr /* gpu_memory_buffer_manager */, settings, |
| 69 surface_id_allocator_->id_namespace(), nullptr /* task_runner */, | 79 surface_id_allocator_->id_namespace(), std::move(begin_frame_source), |
| 70 std::move(output_surface_holder))); | 80 std::move(output_surface_holder), std::move(scheduler), |
| 81 std::move(texture_mailbox_deleter))); |
| 71 display_->Initialize(this); | 82 display_->Initialize(this); |
| 72 } | 83 } |
| 73 | 84 |
| 74 HardwareRenderer::~HardwareRenderer() { | 85 HardwareRenderer::~HardwareRenderer() { |
| 75 // Must reset everything before |surface_factory_| to ensure all | 86 // Must reset everything before |surface_factory_| to ensure all |
| 76 // resources are returned before resetting. | 87 // resources are returned before resetting. |
| 77 if (!root_id_.is_null()) | 88 if (!root_id_.is_null()) |
| 78 surface_factory_->Destroy(root_id_); | 89 surface_factory_->Destroy(root_id_); |
| 79 if (!child_id_.is_null()) | 90 if (!child_id_.is_null()) |
| 80 surface_factory_->Destroy(child_id_); | 91 surface_factory_->Destroy(child_id_); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 const cc::ReturnedResourceArray& resources, | 273 const cc::ReturnedResourceArray& resources, |
| 263 uint32_t compositor_id, | 274 uint32_t compositor_id, |
| 264 uint32_t output_surface_id) { | 275 uint32_t output_surface_id) { |
| 265 if (output_surface_id != last_committed_output_surface_id_) | 276 if (output_surface_id != last_committed_output_surface_id_) |
| 266 return; | 277 return; |
| 267 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 278 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 268 output_surface_id); | 279 output_surface_id); |
| 269 } | 280 } |
| 270 | 281 |
| 271 } // namespace android_webview | 282 } // namespace android_webview |
| OLD | NEW |