Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: android_webview/browser/surfaces_instance.cc

Issue 2647583002: Switching to CompositorFrameSinkSupport in android_webview::SurfacesInstance (Closed)
Patch Set: c Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « android_webview/browser/surfaces_instance.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/display.h" 20 #include "cc/surfaces/display.h"
20 #include "cc/surfaces/display_scheduler.h" 21 #include "cc/surfaces/display_scheduler.h"
21 #include "cc/surfaces/surface_factory.h"
22 #include "cc/surfaces/surface_id_allocator.h" 22 #include "cc/surfaces/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;
(...skipping 12 matching lines...) Expand all
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 surface_id_allocator_.reset(new cc::SurfaceIdAllocator());
54 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 54 support_.reset(new cc::CompositorFrameSinkSupport(
55 surface_factory_.reset( 55 this, surface_manager_.get(), frame_sink_id_,
56 new cc::SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)); 56 true /* submits_to_display_compositor */));
57 57
58 begin_frame_source_.reset(new cc::StubBeginFrameSource); 58 begin_frame_source_.reset(new cc::StubBeginFrameSource);
59 std::unique_ptr<cc::TextureMailboxDeleter> texture_mailbox_deleter( 59 std::unique_ptr<cc::TextureMailboxDeleter> texture_mailbox_deleter(
60 new cc::TextureMailboxDeleter(nullptr)); 60 new cc::TextureMailboxDeleter(nullptr));
61 std::unique_ptr<ParentOutputSurface> output_surface_holder( 61 std::unique_ptr<ParentOutputSurface> output_surface_holder(
62 new ParentOutputSurface(AwRenderThreadContextProvider::Create( 62 new ParentOutputSurface(AwRenderThreadContextProvider::Create(
63 make_scoped_refptr(new AwGLSurface), 63 make_scoped_refptr(new AwGLSurface),
64 DeferredGpuCommandService::GetInstance()))); 64 DeferredGpuCommandService::GetInstance())));
65 output_surface_ = output_surface_holder.get(); 65 output_surface_ = output_surface_holder.get();
66 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( 66 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler(
67 nullptr, output_surface_holder->capabilities().max_frames_pending)); 67 nullptr, output_surface_holder->capabilities().max_frames_pending));
68 display_.reset(new cc::Display( 68 display_.reset(new cc::Display(
69 nullptr /* shared_bitmap_manager */, 69 nullptr /* shared_bitmap_manager */,
70 nullptr /* gpu_memory_buffer_manager */, settings, frame_sink_id_, 70 nullptr /* gpu_memory_buffer_manager */, settings, frame_sink_id_,
71 begin_frame_source_.get(), std::move(output_surface_holder), 71 begin_frame_source_.get(), std::move(output_surface_holder),
72 std::move(scheduler), std::move(texture_mailbox_deleter))); 72 std::move(scheduler), std::move(texture_mailbox_deleter)));
73 display_->Initialize(this, surface_manager_.get()); 73 display_->Initialize(this, surface_manager_.get());
74 display_->SetVisible(true); 74 display_->SetVisible(true);
75 75
76 DCHECK(!g_surfaces_instance); 76 DCHECK(!g_surfaces_instance);
77 g_surfaces_instance = this; 77 g_surfaces_instance = this;
78
79 } 78 }
80 79
81 SurfacesInstance::~SurfacesInstance() { 80 SurfacesInstance::~SurfacesInstance() {
82 DCHECK_EQ(g_surfaces_instance, this); 81 DCHECK_EQ(g_surfaces_instance, this);
83 g_surfaces_instance = nullptr; 82 g_surfaces_instance = nullptr;
84
85 DCHECK(child_ids_.empty()); 83 DCHECK(child_ids_.empty());
86 surface_factory_->EvictSurface();
87
88 surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
89 } 84 }
90 85
91 void SurfacesInstance::DisplayOutputSurfaceLost() { 86 void SurfacesInstance::DisplayOutputSurfaceLost() {
92 // Android WebView does not handle context loss. 87 // Android WebView does not handle context loss.
93 LOG(FATAL) << "Render thread context loss"; 88 LOG(FATAL) << "Render thread context loss";
94 } 89 }
95 90
96 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() { 91 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() {
97 return cc::FrameSinkId(next_client_id_++, 0 /* sink_id */); 92 return cc::FrameSinkId(next_client_id_++, 0 /* sink_id */);
98 } 93 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 gfx::Rect(quad_state->quad_layer_bounds), child_id); 125 gfx::Rect(quad_state->quad_layer_bounds), child_id);
131 126
132 cc::CompositorFrame frame; 127 cc::CompositorFrame frame;
133 frame.render_pass_list.push_back(std::move(render_pass)); 128 frame.render_pass_list.push_back(std::move(render_pass));
134 frame.metadata.referenced_surfaces = child_ids_; 129 frame.metadata.referenced_surfaces = child_ids_;
135 130
136 if (!root_id_.is_valid()) { 131 if (!root_id_.is_valid()) {
137 root_id_ = surface_id_allocator_->GenerateId(); 132 root_id_ = surface_id_allocator_->GenerateId();
138 display_->SetLocalSurfaceId(root_id_, 1.f); 133 display_->SetLocalSurfaceId(root_id_, 1.f);
139 } 134 }
140 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), 135 support_->SubmitCompositorFrame(root_id_, std::move(frame));
141 cc::SurfaceFactory::DrawCallback());
142 136
143 display_->Resize(viewport); 137 display_->Resize(viewport);
144 display_->DrawAndSwap(); 138 display_->DrawAndSwap();
145 } 139 }
146 140
147 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) { 141 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) {
148 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) == 142 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) ==
149 child_ids_.end()); 143 child_ids_.end());
150 child_ids_.push_back(child_id); 144 child_ids_.push_back(child_id);
151 if (root_id_.is_valid()) 145 if (root_id_.is_valid())
152 SetEmptyRootFrame(); 146 SetEmptyRootFrame();
153 } 147 }
154 148
155 void SurfacesInstance::RemoveChildId(const cc::SurfaceId& child_id) { 149 void SurfacesInstance::RemoveChildId(const cc::SurfaceId& child_id) {
156 auto itr = std::find(child_ids_.begin(), child_ids_.end(), child_id); 150 auto itr = std::find(child_ids_.begin(), child_ids_.end(), child_id);
157 DCHECK(itr != child_ids_.end()); 151 DCHECK(itr != child_ids_.end());
158 child_ids_.erase(itr); 152 child_ids_.erase(itr);
159 if (root_id_.is_valid()) 153 if (root_id_.is_valid())
160 SetEmptyRootFrame(); 154 SetEmptyRootFrame();
161 } 155 }
162 156
163 void SurfacesInstance::SetEmptyRootFrame() { 157 void SurfacesInstance::SetEmptyRootFrame() {
164 cc::CompositorFrame empty_frame; 158 cc::CompositorFrame empty_frame;
165 empty_frame.metadata.referenced_surfaces = child_ids_; 159 empty_frame.metadata.referenced_surfaces = child_ids_;
166 surface_factory_->SubmitCompositorFrame(root_id_, std::move(empty_frame), 160 support_->SubmitCompositorFrame(root_id_, std::move(empty_frame));
167 cc::SurfaceFactory::DrawCallback());
168 } 161 }
169 162
170 void SurfacesInstance::ReturnResources( 163 void SurfacesInstance::DidReceiveCompositorFrameAck() {}
164
165 void SurfacesInstance::OnBeginFrame(const cc::BeginFrameArgs& args) {}
166
167 void SurfacesInstance::WillDrawSurface() {}
168
169 void SurfacesInstance::ReclaimResources(
171 const cc::ReturnedResourceArray& resources) { 170 const cc::ReturnedResourceArray& resources) {
172 // Root surface should have no resources to return. 171 // Root surface should have no resources to return.
173 CHECK(resources.empty()); 172 CHECK(resources.empty());
174 } 173 }
175 174
176 void SurfacesInstance::SetBeginFrameSource(
177 cc::BeginFrameSource* begin_frame_source) {
178 // Parent compsitor calls DrawAndSwap directly and doesn't use
179 // BeginFrameSource.
180 }
181
182 } // namespace android_webview 175 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/surfaces_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698