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 "android_webview/browser/aw_gl_surface.h" | 7 #include "android_webview/browser/aw_gl_surface.h" |
8 #include "android_webview/browser/aw_render_thread_context_provider.h" | 8 #include "android_webview/browser/aw_render_thread_context_provider.h" |
9 #include "android_webview/browser/child_frame.h" | 9 #include "android_webview/browser/child_frame.h" |
10 #include "android_webview/browser/deferred_gpu_command_service.h" | 10 #include "android_webview/browser/deferred_gpu_command_service.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 surface_factory_->Destroy(child_id_); | 99 surface_factory_->Destroy(child_id_); |
100 child_id_ = surface_id_allocator_->GenerateId(); | 100 child_id_ = surface_id_allocator_->GenerateId(); |
101 surface_factory_->Create(child_id_); | 101 surface_factory_->Create(child_id_); |
102 } | 102 } |
103 | 103 |
104 surface_factory_->SubmitCompositorFrame(child_id_, frame.Pass(), | 104 surface_factory_->SubmitCompositorFrame(child_id_, frame.Pass(), |
105 cc::SurfaceFactory::DrawCallback()); | 105 cc::SurfaceFactory::DrawCallback()); |
106 } | 106 } |
107 | 107 |
108 void HardwareRenderer::DrawGL(bool stencil_enabled, | 108 void HardwareRenderer::DrawGL(bool stencil_enabled, |
109 int framebuffer_binding_ext, | |
110 AwDrawGLInfo* draw_info) { | 109 AwDrawGLInfo* draw_info) { |
111 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); | 110 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); |
112 | 111 |
113 // We need to watch if the current Android context has changed and enforce | 112 // We need to watch if the current Android context has changed and enforce |
114 // a clean-up in the compositor. | 113 // a clean-up in the compositor. |
115 EGLContext current_context = eglGetCurrentContext(); | 114 EGLContext current_context = eglGetCurrentContext(); |
116 DCHECK(current_context) << "DrawGL called without EGLContext"; | 115 DCHECK(current_context) << "DrawGL called without EGLContext"; |
117 | 116 |
118 // TODO(boliu): Handle context loss. | 117 // TODO(boliu): Handle context loss. |
119 if (last_egl_context_ != current_context) | 118 if (last_egl_context_ != current_context) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 if (root_id_.is_null()) { | 167 if (root_id_.is_null()) { |
169 root_id_ = surface_id_allocator_->GenerateId(); | 168 root_id_ = surface_id_allocator_->GenerateId(); |
170 surface_factory_->Create(root_id_); | 169 surface_factory_->Create(root_id_); |
171 display_->SetSurfaceId(root_id_, 1.f); | 170 display_->SetSurfaceId(root_id_, 1.f); |
172 } | 171 } |
173 surface_factory_->SubmitCompositorFrame(root_id_, frame.Pass(), | 172 surface_factory_->SubmitCompositorFrame(root_id_, frame.Pass(), |
174 cc::SurfaceFactory::DrawCallback()); | 173 cc::SurfaceFactory::DrawCallback()); |
175 | 174 |
176 display_->Resize(viewport); | 175 display_->Resize(viewport); |
177 | 176 |
178 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); | |
179 if (!output_surface_) { | 177 if (!output_surface_) { |
180 scoped_refptr<cc::ContextProvider> context_provider = | 178 scoped_refptr<cc::ContextProvider> context_provider = |
181 AwRenderThreadContextProvider::Create( | 179 AwRenderThreadContextProvider::Create( |
182 gl_surface_, DeferredGpuCommandService::GetInstance()); | 180 gl_surface_, DeferredGpuCommandService::GetInstance()); |
183 scoped_ptr<ParentOutputSurface> output_surface_holder( | 181 scoped_ptr<ParentOutputSurface> output_surface_holder( |
184 new ParentOutputSurface(context_provider)); | 182 new ParentOutputSurface(context_provider)); |
185 output_surface_ = output_surface_holder.get(); | 183 output_surface_ = output_surface_holder.get(); |
186 display_->Initialize(output_surface_holder.Pass(), nullptr); | 184 display_->Initialize(output_surface_holder.Pass(), nullptr); |
187 } | 185 } |
188 output_surface_->SetExternalStencilTest(stencil_enabled); | 186 output_surface_->SetExternalStencilTest(stencil_enabled); |
189 display_->SetExternalClip(clip); | 187 display_->SetExternalClip(clip); |
190 display_->DrawAndSwap(); | 188 display_->DrawAndSwap(); |
191 gl_surface_->ResetBackingFrameBufferObject(); | |
192 } | 189 } |
193 | 190 |
194 void HardwareRenderer::ReturnResources( | 191 void HardwareRenderer::ReturnResources( |
195 const cc::ReturnedResourceArray& resources) { | 192 const cc::ReturnedResourceArray& resources) { |
196 shared_renderer_state_->InsertReturnedResourcesOnRT(resources); | 193 shared_renderer_state_->InsertReturnedResourcesOnRT(resources); |
197 } | 194 } |
198 | 195 |
| 196 void HardwareRenderer::SetBackingFrameBufferObject( |
| 197 int framebuffer_binding_ext) { |
| 198 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); |
| 199 } |
| 200 |
199 } // namespace android_webview | 201 } // namespace android_webview |
OLD | NEW |