| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/surfaces_instance.h" | 5 #include "android_webview/browser/surfaces_instance.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_gl_surface.h" | 10 #include "android_webview/browser/aw_gl_surface.h" |
| 11 #include "android_webview/browser/aw_render_thread_context_provider.h" | 11 #include "android_webview/browser/aw_render_thread_context_provider.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_output_surface.h" | 13 #include "android_webview/browser/parent_output_surface.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "cc/output/renderer_settings.h" | 15 #include "cc/output/renderer_settings.h" |
| 16 #include "cc/output/texture_mailbox_deleter.h" | 16 #include "cc/output/texture_mailbox_deleter.h" |
| 17 #include "cc/quads/surface_draw_quad.h" | 17 #include "cc/quads/surface_draw_quad.h" |
| 18 #include "cc/scheduler/begin_frame_source.h" | 18 #include "cc/scheduler/begin_frame_source.h" |
| 19 #include "cc/surfaces/compositor_frame_sink_support.h" | 19 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 20 #include "cc/surfaces/display.h" | 20 #include "cc/surfaces/display.h" |
| 21 #include "cc/surfaces/display_scheduler.h" | 21 #include "cc/surfaces/display_scheduler.h" |
| 22 #include "cc/surfaces/surface_id_allocator.h" | 22 #include "cc/surfaces/local_surface_id_allocator.h" |
| 23 #include "cc/surfaces/surface_manager.h" | 23 #include "cc/surfaces/surface_manager.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
| 25 #include "ui/gfx/geometry/size.h" | 25 #include "ui/gfx/geometry/size.h" |
| 26 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
| 27 | 27 |
| 28 namespace android_webview { | 28 namespace android_webview { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 SurfacesInstance* g_surfaces_instance = nullptr; | 31 SurfacesInstance* g_surfaces_instance = nullptr; |
| 32 } // namespace | 32 } // namespace |
| (...skipping 10 matching lines...) Expand all Loading... |
| 43 cc::RendererSettings settings; | 43 cc::RendererSettings settings; |
| 44 | 44 |
| 45 // Should be kept in sync with compositor_impl_android.cc. | 45 // Should be kept in sync with compositor_impl_android.cc. |
| 46 settings.allow_antialiasing = false; | 46 settings.allow_antialiasing = false; |
| 47 settings.highp_threshold_min = 2048; | 47 settings.highp_threshold_min = 2048; |
| 48 | 48 |
| 49 // Webview does not own the surface so should not clear it. | 49 // Webview does not own the surface so should not clear it. |
| 50 settings.should_clear_root_render_pass = false; | 50 settings.should_clear_root_render_pass = false; |
| 51 | 51 |
| 52 surface_manager_.reset(new cc::SurfaceManager); | 52 surface_manager_.reset(new cc::SurfaceManager); |
| 53 surface_id_allocator_.reset(new cc::SurfaceIdAllocator()); | 53 local_surface_id_allocator_.reset(new cc::LocalSurfaceIdAllocator()); |
| 54 | 54 |
| 55 constexpr bool is_root = true; | 55 constexpr bool is_root = true; |
| 56 constexpr bool handles_frame_sink_id_invalidation = true; | 56 constexpr bool handles_frame_sink_id_invalidation = true; |
| 57 constexpr bool needs_sync_points = true; | 57 constexpr bool needs_sync_points = true; |
| 58 support_.reset(new cc::CompositorFrameSinkSupport( | 58 support_.reset(new cc::CompositorFrameSinkSupport( |
| 59 this, surface_manager_.get(), frame_sink_id_, is_root, | 59 this, surface_manager_.get(), frame_sink_id_, is_root, |
| 60 handles_frame_sink_id_invalidation, needs_sync_points)); | 60 handles_frame_sink_id_invalidation, needs_sync_points)); |
| 61 | 61 |
| 62 begin_frame_source_.reset(new cc::StubBeginFrameSource); | 62 begin_frame_source_.reset(new cc::StubBeginFrameSource); |
| 63 std::unique_ptr<cc::TextureMailboxDeleter> texture_mailbox_deleter( | 63 std::unique_ptr<cc::TextureMailboxDeleter> texture_mailbox_deleter( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 127 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
| 128 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds), | 128 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds), |
| 129 gfx::Rect(quad_state->quad_layer_bounds), child_id, | 129 gfx::Rect(quad_state->quad_layer_bounds), child_id, |
| 130 cc::SurfaceDrawQuadType::PRIMARY, nullptr); | 130 cc::SurfaceDrawQuadType::PRIMARY, nullptr); |
| 131 | 131 |
| 132 cc::CompositorFrame frame; | 132 cc::CompositorFrame frame; |
| 133 frame.render_pass_list.push_back(std::move(render_pass)); | 133 frame.render_pass_list.push_back(std::move(render_pass)); |
| 134 frame.metadata.referenced_surfaces = child_ids_; | 134 frame.metadata.referenced_surfaces = child_ids_; |
| 135 | 135 |
| 136 if (!root_id_.is_valid()) { | 136 if (!root_id_.is_valid()) { |
| 137 root_id_ = surface_id_allocator_->GenerateId(); | 137 root_id_ = local_surface_id_allocator_->GenerateId(); |
| 138 display_->SetLocalSurfaceId(root_id_, 1.f); | 138 display_->SetLocalSurfaceId(root_id_, 1.f); |
| 139 } | 139 } |
| 140 support_->SubmitCompositorFrame(root_id_, std::move(frame)); | 140 support_->SubmitCompositorFrame(root_id_, std::move(frame)); |
| 141 | 141 |
| 142 display_->Resize(viewport); | 142 display_->Resize(viewport); |
| 143 display_->DrawAndSwap(); | 143 display_->DrawAndSwap(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) { | 146 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) { |
| 147 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) == | 147 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) == |
| (...skipping 25 matching lines...) Expand all Loading... |
| 173 const cc::LocalSurfaceId& local_surface_id, | 173 const cc::LocalSurfaceId& local_surface_id, |
| 174 const gfx::Rect& damage_rect) {} | 174 const gfx::Rect& damage_rect) {} |
| 175 | 175 |
| 176 void SurfacesInstance::ReclaimResources( | 176 void SurfacesInstance::ReclaimResources( |
| 177 const cc::ReturnedResourceArray& resources) { | 177 const cc::ReturnedResourceArray& resources) { |
| 178 // Root surface should have no resources to return. | 178 // Root surface should have no resources to return. |
| 179 CHECK(resources.empty()); | 179 CHECK(resources.empty()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace android_webview | 182 } // namespace android_webview |
| OLD | NEW |