| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (!child_frame.get()) | 63 if (!child_frame.get()) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 last_committed_output_surface_id_ = child_frame->output_surface_id; | 66 last_committed_output_surface_id_ = child_frame->output_surface_id; |
| 67 ReturnResourcesInChildFrame(); | 67 ReturnResourcesInChildFrame(); |
| 68 child_frame_ = std::move(child_frame); | 68 child_frame_ = std::move(child_frame); |
| 69 DCHECK(child_frame_->frame.get()); | 69 DCHECK(child_frame_->frame.get()); |
| 70 DCHECK(!child_frame_->frame->gl_frame_data); | 70 DCHECK(!child_frame_->frame->gl_frame_data); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info, | 73 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
| 74 const ScopedAppGLStateRestore& gl_state) { | |
| 75 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); | 74 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); |
| 76 | 75 |
| 77 // We need to watch if the current Android context has changed and enforce | 76 // We need to watch if the current Android context has changed and enforce |
| 78 // a clean-up in the compositor. | 77 // a clean-up in the compositor. |
| 79 EGLContext current_context = eglGetCurrentContext(); | 78 EGLContext current_context = eglGetCurrentContext(); |
| 80 DCHECK(current_context) << "DrawGL called without EGLContext"; | 79 DCHECK(current_context) << "DrawGL called without EGLContext"; |
| 81 | 80 |
| 82 // TODO(boliu): Handle context loss. | 81 // TODO(boliu): Handle context loss. |
| 83 if (last_egl_context_ != current_context) | 82 if (last_egl_context_ != current_context) |
| 84 DLOG(WARNING) << "EGLContextChanged"; | 83 DLOG(WARNING) << "EGLContextChanged"; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( | 133 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( |
| 135 draw_constraints); | 134 draw_constraints); |
| 136 } | 135 } |
| 137 | 136 |
| 138 if (child_id_.is_null()) | 137 if (child_id_.is_null()) |
| 139 return; | 138 return; |
| 140 | 139 |
| 141 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, | 140 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, |
| 142 draw_info->clip_right - draw_info->clip_left, | 141 draw_info->clip_right - draw_info->clip_left, |
| 143 draw_info->clip_bottom - draw_info->clip_top); | 142 draw_info->clip_bottom - draw_info->clip_top); |
| 144 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, child_id_, | 143 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, child_id_); |
| 145 gl_state); | |
| 146 } | 144 } |
| 147 | 145 |
| 148 void HardwareRenderer::AllocateSurface() { | 146 void HardwareRenderer::AllocateSurface() { |
| 149 DCHECK(child_id_.is_null()); | 147 DCHECK(child_id_.is_null()); |
| 150 DCHECK(surface_factory_); | 148 DCHECK(surface_factory_); |
| 151 child_id_ = surface_id_allocator_->GenerateId(); | 149 child_id_ = surface_id_allocator_->GenerateId(); |
| 152 surface_factory_->Create(child_id_); | 150 surface_factory_->Create(child_id_); |
| 153 surfaces_->AddChildId(child_id_); | 151 surfaces_->AddChildId(child_id_); |
| 154 } | 152 } |
| 155 | 153 |
| 156 void HardwareRenderer::DestroySurface() { | 154 void HardwareRenderer::DestroySurface() { |
| 157 DCHECK(!child_id_.is_null()); | 155 DCHECK(!child_id_.is_null()); |
| 158 DCHECK(surface_factory_); | 156 DCHECK(surface_factory_); |
| 159 surfaces_->RemoveChildId(child_id_); | 157 surfaces_->RemoveChildId(child_id_); |
| 160 surface_factory_->Destroy(child_id_); | 158 surface_factory_->Destroy(child_id_); |
| 161 child_id_ = cc::SurfaceId(); | 159 child_id_ = cc::SurfaceId(); |
| 162 } | 160 } |
| 163 | 161 |
| 164 void HardwareRenderer::ReturnResources( | 162 void HardwareRenderer::ReturnResources( |
| 165 const cc::ReturnedResourceArray& resources) { | 163 const cc::ReturnedResourceArray& resources) { |
| 166 ReturnResourcesToCompositor(resources, compositor_id_, | 164 ReturnResourcesToCompositor(resources, compositor_id_, |
| 167 last_submitted_output_surface_id_); | 165 last_submitted_output_surface_id_); |
| 168 } | 166 } |
| 169 | 167 |
| 170 void HardwareRenderer::SetBeginFrameSource( | 168 void HardwareRenderer::SetBeginFrameSource( |
| 171 cc::BeginFrameSource* begin_frame_source) { | 169 cc::BeginFrameSource* begin_frame_source) { |
| 172 // TODO(tansell): Hook this up. | 170 // TODO(tansell): Hook this up. |
| 173 } | 171 } |
| 174 | 172 |
| 175 void HardwareRenderer::SetBackingFrameBufferObject( | |
| 176 int framebuffer_binding_ext) { | |
| 177 surfaces_->SetBackingFrameBufferObject(framebuffer_binding_ext); | |
| 178 } | |
| 179 | |
| 180 void HardwareRenderer::ReturnResourcesInChildFrame() { | 173 void HardwareRenderer::ReturnResourcesInChildFrame() { |
| 181 if (child_frame_.get() && child_frame_->frame.get()) { | 174 if (child_frame_.get() && child_frame_->frame.get()) { |
| 182 cc::ReturnedResourceArray resources_to_return; | 175 cc::ReturnedResourceArray resources_to_return; |
| 183 cc::TransferableResource::ReturnResources( | 176 cc::TransferableResource::ReturnResources( |
| 184 child_frame_->frame->delegated_frame_data->resource_list, | 177 child_frame_->frame->delegated_frame_data->resource_list, |
| 185 &resources_to_return); | 178 &resources_to_return); |
| 186 | 179 |
| 187 // The child frame's compositor id is not necessarily same as | 180 // The child frame's compositor id is not necessarily same as |
| 188 // compositor_id_. | 181 // compositor_id_. |
| 189 ReturnResourcesToCompositor(resources_to_return, | 182 ReturnResourcesToCompositor(resources_to_return, |
| 190 child_frame_->compositor_id, | 183 child_frame_->compositor_id, |
| 191 child_frame_->output_surface_id); | 184 child_frame_->output_surface_id); |
| 192 } | 185 } |
| 193 child_frame_.reset(); | 186 child_frame_.reset(); |
| 194 } | 187 } |
| 195 | 188 |
| 196 void HardwareRenderer::ReturnResourcesToCompositor( | 189 void HardwareRenderer::ReturnResourcesToCompositor( |
| 197 const cc::ReturnedResourceArray& resources, | 190 const cc::ReturnedResourceArray& resources, |
| 198 const CompositorID& compositor_id, | 191 const CompositorID& compositor_id, |
| 199 uint32_t output_surface_id) { | 192 uint32_t output_surface_id) { |
| 200 if (output_surface_id != last_committed_output_surface_id_) | 193 if (output_surface_id != last_committed_output_surface_id_) |
| 201 return; | 194 return; |
| 202 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 195 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 203 output_surface_id); | 196 output_surface_id); |
| 204 } | 197 } |
| 205 | 198 |
| 206 } // namespace android_webview | 199 } // namespace android_webview |
| OLD | NEW |