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

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

Issue 2375743002: [Merge M54] aw: Fix FBO restore in webview functor (Closed)
Patch Set: Created 4 years, 2 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"
(...skipping 21 matching lines...) Expand all
32 } // namespace 32 } // namespace
33 33
34 // static 34 // static
35 scoped_refptr<SurfacesInstance> SurfacesInstance::GetOrCreateInstance() { 35 scoped_refptr<SurfacesInstance> SurfacesInstance::GetOrCreateInstance() {
36 if (g_surfaces_instance) 36 if (g_surfaces_instance)
37 return make_scoped_refptr(g_surfaces_instance); 37 return make_scoped_refptr(g_surfaces_instance);
38 return make_scoped_refptr(new SurfacesInstance); 38 return make_scoped_refptr(new SurfacesInstance);
39 } 39 }
40 40
41 SurfacesInstance::SurfacesInstance() 41 SurfacesInstance::SurfacesInstance()
42 : next_surface_client_id_(1u), gl_surface_(new AwGLSurface) { 42 : next_surface_client_id_(1u) {
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( 53 surface_id_allocator_.reset(
54 new cc::SurfaceIdAllocator(next_surface_client_id_++)); 54 new cc::SurfaceIdAllocator(next_surface_client_id_++));
55 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); 55 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id());
56 56
57 std::unique_ptr<cc::BeginFrameSource> begin_frame_source( 57 std::unique_ptr<cc::BeginFrameSource> begin_frame_source(
58 new cc::StubBeginFrameSource); 58 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 gl_surface_, DeferredGpuCommandService::GetInstance()))); 63 make_scoped_refptr(new AwGLSurface),
64 DeferredGpuCommandService::GetInstance())));
64 output_surface_ = output_surface_holder.get(); 65 output_surface_ = output_surface_holder.get();
65 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( 66 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler(
66 begin_frame_source.get(), nullptr, 67 begin_frame_source.get(), nullptr,
67 output_surface_holder->capabilities().max_frames_pending)); 68 output_surface_holder->capabilities().max_frames_pending));
68 display_.reset(new cc::Display( 69 display_.reset(new cc::Display(
69 nullptr /* shared_bitmap_manager */, 70 nullptr /* shared_bitmap_manager */,
70 nullptr /* gpu_memory_buffer_manager */, settings, 71 nullptr /* gpu_memory_buffer_manager */, settings,
71 std::move(begin_frame_source), std::move(output_surface_holder), 72 std::move(begin_frame_source), std::move(output_surface_holder),
72 std::move(scheduler), std::move(texture_mailbox_deleter))); 73 std::move(scheduler), std::move(texture_mailbox_deleter)));
73 display_->Initialize(this, surface_manager_.get(), 74 display_->Initialize(this, surface_manager_.get(),
(...skipping 20 matching lines...) Expand all
94 } 95 }
95 96
96 uint32_t SurfacesInstance::AllocateSurfaceClientId() { 97 uint32_t SurfacesInstance::AllocateSurfaceClientId() {
97 return next_surface_client_id_++; 98 return next_surface_client_id_++;
98 } 99 }
99 100
100 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() { 101 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() {
101 return surface_manager_.get(); 102 return surface_manager_.get();
102 } 103 }
103 104
104 void SurfacesInstance::SetBackingFrameBufferObject(
105 int framebuffer_binding_ext) {
106 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext);
107 }
108
109 void SurfacesInstance::DrawAndSwap(const gfx::Size& viewport, 105 void SurfacesInstance::DrawAndSwap(const gfx::Size& viewport,
110 const gfx::Rect& clip, 106 const gfx::Rect& clip,
111 const gfx::Transform& transform, 107 const gfx::Transform& transform,
112 const gfx::Size& frame_size, 108 const gfx::Size& frame_size,
113 const cc::SurfaceId& child_id, 109 const cc::SurfaceId& child_id) {
114 const ScopedAppGLStateRestore& gl_state) {
115 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) != 110 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) !=
116 child_ids_.end()); 111 child_ids_.end());
117 112
118 // Create a frame with a single SurfaceDrawQuad referencing the child 113 // Create a frame with a single SurfaceDrawQuad referencing the child
119 // Surface and transformed using the given transform. 114 // Surface and transformed using the given transform.
120 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); 115 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
121 render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(viewport), clip, 116 render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(viewport), clip,
122 gfx::Transform(), false); 117 gfx::Transform(), false);
123 118
124 cc::SharedQuadState* quad_state = 119 cc::SharedQuadState* quad_state =
(...skipping 16 matching lines...) Expand all
141 frame.metadata.referenced_surfaces = child_ids_; 136 frame.metadata.referenced_surfaces = child_ids_;
142 137
143 if (root_id_.is_null()) { 138 if (root_id_.is_null()) {
144 root_id_ = surface_id_allocator_->GenerateId(); 139 root_id_ = surface_id_allocator_->GenerateId();
145 surface_factory_->Create(root_id_); 140 surface_factory_->Create(root_id_);
146 display_->SetSurfaceId(root_id_, 1.f); 141 display_->SetSurfaceId(root_id_, 1.f);
147 } 142 }
148 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), 143 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame),
149 cc::SurfaceFactory::DrawCallback()); 144 cc::SurfaceFactory::DrawCallback());
150 145
151 output_surface_->SetGLState(gl_state); 146 output_surface_->UpdateStencilTest();
152 display_->Resize(viewport); 147 display_->Resize(viewport);
153 display_->SetExternalClip(clip); 148 display_->SetExternalClip(clip);
154 display_->DrawAndSwap(); 149 display_->DrawAndSwap();
155 } 150 }
156 151
157 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) { 152 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) {
158 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) == 153 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) ==
159 child_ids_.end()); 154 child_ids_.end());
160 child_ids_.push_back(child_id); 155 child_ids_.push_back(child_id);
161 if (!root_id_.is_null()) 156 if (!root_id_.is_null())
(...skipping 23 matching lines...) Expand all
185 CHECK(resources.empty()); 180 CHECK(resources.empty());
186 } 181 }
187 182
188 void SurfacesInstance::SetBeginFrameSource( 183 void SurfacesInstance::SetBeginFrameSource(
189 cc::BeginFrameSource* begin_frame_source) { 184 cc::BeginFrameSource* begin_frame_source) {
190 // Parent compsitor calls DrawAndSwap directly and doesn't use 185 // Parent compsitor calls DrawAndSwap directly and doesn't use
191 // BeginFrameSource. 186 // BeginFrameSource.
192 } 187 }
193 188
194 } // namespace android_webview 189 } // 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