| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
| 23 #include "ui/gl/gl_bindings.h" | 23 #include "ui/gl/gl_bindings.h" |
| 24 | 24 |
| 25 namespace android_webview { | 25 namespace android_webview { |
| 26 | 26 |
| 27 HardwareRenderer::HardwareRenderer(RenderThreadManager* state) | 27 HardwareRenderer::HardwareRenderer(RenderThreadManager* state) |
| 28 : render_thread_manager_(state), | 28 : render_thread_manager_(state), |
| 29 last_egl_context_(eglGetCurrentContext()), | 29 last_egl_context_(eglGetCurrentContext()), |
| 30 surfaces_(SurfacesInstance::GetOrCreateInstance()), | 30 surfaces_(SurfacesInstance::GetOrCreateInstance()), |
| 31 frame_sink_id_(surfaces_->AllocateFrameSinkId()), | 31 frame_sink_id_(surfaces_->AllocateFrameSinkId()), |
| 32 surface_id_allocator_( | 32 surface_id_allocator_(base::MakeUnique<cc::SurfaceIdAllocator>()), |
| 33 base::MakeUnique<cc::SurfaceIdAllocator>(frame_sink_id_)), | |
| 34 last_committed_compositor_frame_sink_id_(0u), | 33 last_committed_compositor_frame_sink_id_(0u), |
| 35 last_submitted_compositor_frame_sink_id_(0u) { | 34 last_submitted_compositor_frame_sink_id_(0u) { |
| 36 DCHECK(last_egl_context_); | 35 DCHECK(last_egl_context_); |
| 37 surfaces_->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); | 36 surfaces_->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
| 38 surfaces_->GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, | 37 surfaces_->GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, |
| 39 this); | 38 this); |
| 40 } | 39 } |
| 41 | 40 |
| 42 HardwareRenderer::~HardwareRenderer() { | 41 HardwareRenderer::~HardwareRenderer() { |
| 43 // Must reset everything before |surface_factory_| to ensure all | 42 // Must reset everything before |surface_factory_| to ensure all |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( | 135 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( |
| 137 draw_constraints); | 136 draw_constraints); |
| 138 } | 137 } |
| 139 | 138 |
| 140 if (child_id_.is_null()) | 139 if (child_id_.is_null()) |
| 141 return; | 140 return; |
| 142 | 141 |
| 143 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, | 142 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, |
| 144 draw_info->clip_right - draw_info->clip_left, | 143 draw_info->clip_right - draw_info->clip_left, |
| 145 draw_info->clip_bottom - draw_info->clip_top); | 144 draw_info->clip_bottom - draw_info->clip_top); |
| 146 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, child_id_); | 145 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, |
| 146 cc::SurfaceId(frame_sink_id_, child_id_)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void HardwareRenderer::AllocateSurface() { | 149 void HardwareRenderer::AllocateSurface() { |
| 150 DCHECK(child_id_.is_null()); | 150 DCHECK(child_id_.is_null()); |
| 151 DCHECK(surface_factory_); | 151 DCHECK(surface_factory_); |
| 152 child_id_ = surface_id_allocator_->GenerateId(); | 152 child_id_ = surface_id_allocator_->GenerateId(); |
| 153 surface_factory_->Create(child_id_); | 153 surface_factory_->Create(child_id_); |
| 154 surfaces_->AddChildId(child_id_); | 154 surfaces_->AddChildId(cc::SurfaceId(frame_sink_id_, child_id_)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void HardwareRenderer::DestroySurface() { | 157 void HardwareRenderer::DestroySurface() { |
| 158 DCHECK(!child_id_.is_null()); | 158 DCHECK(!child_id_.is_null()); |
| 159 DCHECK(surface_factory_); | 159 DCHECK(surface_factory_); |
| 160 surfaces_->RemoveChildId(child_id_); | 160 surfaces_->RemoveChildId(cc::SurfaceId(frame_sink_id_, child_id_)); |
| 161 surface_factory_->Destroy(child_id_); | 161 surface_factory_->Destroy(child_id_); |
| 162 child_id_ = cc::SurfaceId(); | 162 child_id_ = cc::LocalFrameId(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void HardwareRenderer::ReturnResources( | 165 void HardwareRenderer::ReturnResources( |
| 166 const cc::ReturnedResourceArray& resources) { | 166 const cc::ReturnedResourceArray& resources) { |
| 167 ReturnResourcesToCompositor(resources, compositor_id_, | 167 ReturnResourcesToCompositor(resources, compositor_id_, |
| 168 last_submitted_compositor_frame_sink_id_); | 168 last_submitted_compositor_frame_sink_id_); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void HardwareRenderer::SetBeginFrameSource( | 171 void HardwareRenderer::SetBeginFrameSource( |
| 172 cc::BeginFrameSource* begin_frame_source) { | 172 cc::BeginFrameSource* begin_frame_source) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 193 const cc::ReturnedResourceArray& resources, | 193 const cc::ReturnedResourceArray& resources, |
| 194 const CompositorID& compositor_id, | 194 const CompositorID& compositor_id, |
| 195 uint32_t compositor_frame_sink_id) { | 195 uint32_t compositor_frame_sink_id) { |
| 196 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) | 196 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) |
| 197 return; | 197 return; |
| 198 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 198 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 199 compositor_frame_sink_id); | 199 compositor_frame_sink_id); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace android_webview | 202 } // namespace android_webview |
| OLD | NEW |