| 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/parent_compositor_draw_constraints.h" | 12 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| 13 #include "android_webview/browser/render_thread_manager.h" | 13 #include "android_webview/browser/render_thread_manager.h" |
| 14 #include "android_webview/browser/surfaces_instance.h" | 14 #include "android_webview/browser/surfaces_instance.h" |
| 15 #include "android_webview/public/browser/draw_gl.h" | 15 #include "android_webview/public/browser/draw_gl.h" |
| 16 #include "base/memory/ptr_util.h" |
| 16 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 17 #include "cc/output/compositor_frame.h" | 18 #include "cc/output/compositor_frame.h" |
| 18 #include "cc/surfaces/surface_factory.h" | 19 #include "cc/surfaces/surface_factory.h" |
| 19 #include "cc/surfaces/surface_id_allocator.h" | 20 #include "cc/surfaces/surface_id_allocator.h" |
| 20 #include "cc/surfaces/surface_manager.h" | 21 #include "cc/surfaces/surface_manager.h" |
| 21 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
| 22 #include "ui/gl/gl_bindings.h" | 23 #include "ui/gl/gl_bindings.h" |
| 23 | 24 |
| 24 namespace android_webview { | 25 namespace android_webview { |
| 25 | 26 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 DCHECK(child_id_.is_null()); | 148 DCHECK(child_id_.is_null()); |
| 148 DCHECK(surface_factory_); | 149 DCHECK(surface_factory_); |
| 149 child_id_ = surface_id_allocator_->GenerateId(); | 150 child_id_ = surface_id_allocator_->GenerateId(); |
| 150 surface_factory_->Create(child_id_); | 151 surface_factory_->Create(child_id_); |
| 151 surfaces_->AddChildId(child_id_); | 152 surfaces_->AddChildId(child_id_); |
| 152 } | 153 } |
| 153 | 154 |
| 154 void HardwareRenderer::DestroySurface() { | 155 void HardwareRenderer::DestroySurface() { |
| 155 DCHECK(!child_id_.is_null()); | 156 DCHECK(!child_id_.is_null()); |
| 156 DCHECK(surface_factory_); | 157 DCHECK(surface_factory_); |
| 158 |
| 159 // Submit an empty frame to force any existing resources to be returned. |
| 160 cc::CompositorFrame empty_frame; |
| 161 empty_frame.delegated_frame_data = |
| 162 base::WrapUnique(new cc::DelegatedFrameData); |
| 163 surface_factory_->SubmitCompositorFrame(child_id_, std::move(empty_frame), |
| 164 cc::SurfaceFactory::DrawCallback()); |
| 165 |
| 157 surfaces_->RemoveChildId(child_id_); | 166 surfaces_->RemoveChildId(child_id_); |
| 158 surface_factory_->Destroy(child_id_); | 167 surface_factory_->Destroy(child_id_); |
| 159 child_id_ = cc::SurfaceId(); | 168 child_id_ = cc::SurfaceId(); |
| 160 } | 169 } |
| 161 | 170 |
| 162 void HardwareRenderer::ReturnResources( | 171 void HardwareRenderer::ReturnResources( |
| 163 const cc::ReturnedResourceArray& resources) { | 172 const cc::ReturnedResourceArray& resources) { |
| 164 ReturnResourcesToCompositor(resources, compositor_id_, | 173 ReturnResourcesToCompositor(resources, compositor_id_, |
| 165 last_submitted_output_surface_id_); | 174 last_submitted_output_surface_id_); |
| 166 } | 175 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 190 const cc::ReturnedResourceArray& resources, | 199 const cc::ReturnedResourceArray& resources, |
| 191 const CompositorID& compositor_id, | 200 const CompositorID& compositor_id, |
| 192 uint32_t output_surface_id) { | 201 uint32_t output_surface_id) { |
| 193 if (output_surface_id != last_committed_output_surface_id_) | 202 if (output_surface_id != last_committed_output_surface_id_) |
| 194 return; | 203 return; |
| 195 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 204 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 196 output_surface_id); | 205 output_surface_id); |
| 197 } | 206 } |
| 198 | 207 |
| 199 } // namespace android_webview | 208 } // namespace android_webview |
| OLD | NEW |