| 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/parent_compositor_draw_constraints.h" | 11 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| 12 #include "android_webview/browser/render_thread_manager.h" | 12 #include "android_webview/browser/render_thread_manager.h" |
| 13 #include "android_webview/browser/surfaces_instance.h" | 13 #include "android_webview/browser/surfaces_instance.h" |
| 14 #include "android_webview/public/browser/draw_gl.h" | 14 #include "android_webview/public/browser/draw_gl.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.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/local_surface_id_allocator.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_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 frame_sink_id_(surfaces_->AllocateFrameSinkId()), | 30 frame_sink_id_(surfaces_->AllocateFrameSinkId()), |
| 31 surface_id_allocator_(base::MakeUnique<cc::SurfaceIdAllocator>()), | 31 local_surface_id_allocator_( |
| 32 base::MakeUnique<cc::LocalSurfaceIdAllocator>()), |
| 32 surface_factory_(new cc::SurfaceFactory(frame_sink_id_, | 33 surface_factory_(new cc::SurfaceFactory(frame_sink_id_, |
| 33 surfaces_->GetSurfaceManager(), | 34 surfaces_->GetSurfaceManager(), |
| 34 this)), | 35 this)), |
| 35 last_committed_compositor_frame_sink_id_(0u), | 36 last_committed_compositor_frame_sink_id_(0u), |
| 36 last_submitted_compositor_frame_sink_id_(0u) { | 37 last_submitted_compositor_frame_sink_id_(0u) { |
| 37 DCHECK(last_egl_context_); | 38 DCHECK(last_egl_context_); |
| 38 surfaces_->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); | 39 surfaces_->GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
| 39 surfaces_->GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, | 40 surfaces_->GetSurfaceManager()->RegisterSurfaceFactoryClient(frame_sink_id_, |
| 40 this); | 41 this); |
| 41 } | 42 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 160 |
| 160 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, | 161 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, |
| 161 draw_info->clip_right - draw_info->clip_left, | 162 draw_info->clip_right - draw_info->clip_left, |
| 162 draw_info->clip_bottom - draw_info->clip_top); | 163 draw_info->clip_bottom - draw_info->clip_top); |
| 163 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, | 164 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, |
| 164 cc::SurfaceId(frame_sink_id_, child_id_)); | 165 cc::SurfaceId(frame_sink_id_, child_id_)); |
| 165 } | 166 } |
| 166 | 167 |
| 167 void HardwareRenderer::AllocateSurface() { | 168 void HardwareRenderer::AllocateSurface() { |
| 168 DCHECK(!child_id_.is_valid()); | 169 DCHECK(!child_id_.is_valid()); |
| 169 child_id_ = surface_id_allocator_->GenerateId(); | 170 child_id_ = local_surface_id_allocator_->GenerateId(); |
| 170 surfaces_->AddChildId(cc::SurfaceId(frame_sink_id_, child_id_)); | 171 surfaces_->AddChildId(cc::SurfaceId(frame_sink_id_, child_id_)); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void HardwareRenderer::DestroySurface() { | 174 void HardwareRenderer::DestroySurface() { |
| 174 DCHECK(child_id_.is_valid()); | 175 DCHECK(child_id_.is_valid()); |
| 175 | 176 |
| 176 // Submit an empty frame to force any existing resources to be returned. | 177 // Submit an empty frame to force any existing resources to be returned. |
| 177 surface_factory_->SubmitCompositorFrame(child_id_, cc::CompositorFrame(), | 178 surface_factory_->SubmitCompositorFrame(child_id_, cc::CompositorFrame(), |
| 178 cc::SurfaceFactory::DrawCallback()); | 179 cc::SurfaceFactory::DrawCallback()); |
| 179 surfaces_->RemoveChildId(cc::SurfaceId(frame_sink_id_, child_id_)); | 180 surfaces_->RemoveChildId(cc::SurfaceId(frame_sink_id_, child_id_)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 const cc::ReturnedResourceArray& resources, | 249 const cc::ReturnedResourceArray& resources, |
| 249 const CompositorID& compositor_id, | 250 const CompositorID& compositor_id, |
| 250 uint32_t compositor_frame_sink_id) { | 251 uint32_t compositor_frame_sink_id) { |
| 251 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) | 252 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) |
| 252 return; | 253 return; |
| 253 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 254 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 254 compositor_frame_sink_id); | 255 compositor_frame_sink_id); |
| 255 } | 256 } |
| 256 | 257 |
| 257 } // namespace android_webview | 258 } // namespace android_webview |
| OLD | NEW |