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/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
18 #include "cc/surfaces/surface_factory.h" | 18 #include "cc/surfaces/surface_factory.h" |
19 #include "cc/surfaces/surface_id_allocator.h" | 19 #include "cc/surfaces/surface_id_allocator.h" |
20 #include "cc/surfaces/surface_manager.h" | 20 #include "cc/surfaces/surface_manager.h" |
21 #include "ui/gfx/transform.h" | 21 #include "ui/gfx/transform.h" |
22 #include "ui/gl/gl_bindings.h" | 22 #include "ui/gl/gl_bindings.h" |
23 | 23 |
24 namespace android_webview { | 24 namespace android_webview { |
25 | 25 |
26 HardwareRenderer::HardwareRenderer(RenderThreadManager* state) | 26 HardwareRenderer::HardwareRenderer(RenderThreadManager* state) |
27 : render_thread_manager_(state), | 27 : render_thread_manager_(state), |
28 last_egl_context_(eglGetCurrentContext()), | 28 last_egl_context_(eglGetCurrentContext()), |
29 surfaces_(SurfacesInstance::GetOrCreateInstance()), | 29 surfaces_(SurfacesInstance::GetOrCreateInstance()), |
30 surface_id_allocator_(surfaces_->CreateSurfaceIdAllocator()), | 30 surface_id_allocator_( |
| 31 new cc::SurfaceIdAllocator(surfaces_->AllocateSurfaceClientId())), |
31 last_committed_output_surface_id_(0u), | 32 last_committed_output_surface_id_(0u), |
32 last_submitted_output_surface_id_(0u) { | 33 last_submitted_output_surface_id_(0u) { |
33 DCHECK(last_egl_context_); | 34 DCHECK(last_egl_context_); |
| 35 surfaces_->GetSurfaceManager()->RegisterSurfaceClientId( |
| 36 surface_id_allocator_->client_id()); |
34 surfaces_->GetSurfaceManager()->RegisterSurfaceFactoryClient( | 37 surfaces_->GetSurfaceManager()->RegisterSurfaceFactoryClient( |
35 surface_id_allocator_->client_id(), this); | 38 surface_id_allocator_->client_id(), this); |
36 } | 39 } |
37 | 40 |
38 HardwareRenderer::~HardwareRenderer() { | 41 HardwareRenderer::~HardwareRenderer() { |
39 // Must reset everything before |surface_factory_| to ensure all | 42 // Must reset everything before |surface_factory_| to ensure all |
40 // resources are returned before resetting. | 43 // resources are returned before resetting. |
41 if (!child_id_.is_null()) | 44 if (!child_id_.is_null()) |
42 DestroySurface(); | 45 DestroySurface(); |
43 surface_factory_.reset(); | 46 surface_factory_.reset(); |
44 surfaces_->GetSurfaceManager()->UnregisterSurfaceFactoryClient( | 47 surfaces_->GetSurfaceManager()->UnregisterSurfaceFactoryClient( |
45 surface_id_allocator_->client_id()); | 48 surface_id_allocator_->client_id()); |
| 49 surfaces_->GetSurfaceManager()->InvalidateSurfaceClientId( |
| 50 surface_id_allocator_->client_id()); |
46 | 51 |
47 // Reset draw constraints. | 52 // Reset draw constraints. |
48 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( | 53 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( |
49 ParentCompositorDrawConstraints()); | 54 ParentCompositorDrawConstraints()); |
50 ReturnResourcesInChildFrame(); | 55 ReturnResourcesInChildFrame(); |
51 } | 56 } |
52 | 57 |
53 void HardwareRenderer::CommitFrame() { | 58 void HardwareRenderer::CommitFrame() { |
54 TRACE_EVENT0("android_webview", "CommitFrame"); | 59 TRACE_EVENT0("android_webview", "CommitFrame"); |
55 scroll_offset_ = render_thread_manager_->GetScrollOffsetOnRT(); | 60 scroll_offset_ = render_thread_manager_->GetScrollOffsetOnRT(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 const cc::ReturnedResourceArray& resources, | 197 const cc::ReturnedResourceArray& resources, |
193 const CompositorID& compositor_id, | 198 const CompositorID& compositor_id, |
194 uint32_t output_surface_id) { | 199 uint32_t output_surface_id) { |
195 if (output_surface_id != last_committed_output_surface_id_) | 200 if (output_surface_id != last_committed_output_surface_id_) |
196 return; | 201 return; |
197 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 202 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
198 output_surface_id); | 203 output_surface_id); |
199 } | 204 } |
200 | 205 |
201 } // namespace android_webview | 206 } // namespace android_webview |
OLD | NEW |