| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, | 160 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, |
| 161 draw_info->clip_right - draw_info->clip_left, | 161 draw_info->clip_right - draw_info->clip_left, |
| 162 draw_info->clip_bottom - draw_info->clip_top); | 162 draw_info->clip_bottom - draw_info->clip_top); |
| 163 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, | 163 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, |
| 164 cc::SurfaceId(frame_sink_id_, child_id_)); | 164 cc::SurfaceId(frame_sink_id_, child_id_)); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void HardwareRenderer::AllocateSurface() { | 167 void HardwareRenderer::AllocateSurface() { |
| 168 DCHECK(!child_id_.is_valid()); | 168 DCHECK(!child_id_.is_valid()); |
| 169 child_id_ = surface_id_allocator_->GenerateId(); | 169 child_id_ = surface_id_allocator_->GenerateId(); |
| 170 surface_factory_->Create(child_id_); |
| 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()); |
| 180 |
| 179 surfaces_->RemoveChildId(cc::SurfaceId(frame_sink_id_, child_id_)); | 181 surfaces_->RemoveChildId(cc::SurfaceId(frame_sink_id_, child_id_)); |
| 180 surface_factory_->EvictSurface(); | 182 surface_factory_->Destroy(child_id_); |
| 181 child_id_ = cc::LocalFrameId(); | 183 child_id_ = cc::LocalFrameId(); |
| 182 } | 184 } |
| 183 | 185 |
| 184 void HardwareRenderer::ReturnResources( | 186 void HardwareRenderer::ReturnResources( |
| 185 const cc::ReturnedResourceArray& resources) { | 187 const cc::ReturnedResourceArray& resources) { |
| 186 ReturnResourcesToCompositor(resources, compositor_id_, | 188 ReturnResourcesToCompositor(resources, compositor_id_, |
| 187 last_submitted_compositor_frame_sink_id_); | 189 last_submitted_compositor_frame_sink_id_); |
| 188 } | 190 } |
| 189 | 191 |
| 190 void HardwareRenderer::SetBeginFrameSource( | 192 void HardwareRenderer::SetBeginFrameSource( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 const cc::ReturnedResourceArray& resources, | 250 const cc::ReturnedResourceArray& resources, |
| 249 const CompositorID& compositor_id, | 251 const CompositorID& compositor_id, |
| 250 uint32_t compositor_frame_sink_id) { | 252 uint32_t compositor_frame_sink_id) { |
| 251 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) | 253 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) |
| 252 return; | 254 return; |
| 253 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 255 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 254 compositor_frame_sink_id); | 256 compositor_frame_sink_id); |
| 255 } | 257 } |
| 256 | 258 |
| 257 } // namespace android_webview | 259 } // namespace android_webview |
| OLD | NEW |