Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 | 65 |
| 66 last_committed_compositor_frame_sink_id_ = | 66 last_committed_compositor_frame_sink_id_ = |
| 67 child_frame->compositor_frame_sink_id; | 67 child_frame->compositor_frame_sink_id; |
| 68 ReturnResourcesInChildFrame(); | 68 ReturnResourcesInChildFrame(); |
| 69 child_frame_ = std::move(child_frame); | 69 child_frame_ = std::move(child_frame); |
| 70 DCHECK(child_frame_->frame.get()); | 70 DCHECK(child_frame_->frame.get()); |
| 71 DCHECK(!child_frame_->frame->gl_frame_data); | 71 DCHECK(!child_frame_->frame->gl_frame_data); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info, | 74 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info, |
| 75 const ScopedAppGLStateRestore& gl_state) { | 75 const ScopedAppGLStateRestore& gl_state) { |
|
Tobias Sargeant
2016/09/26 09:46:18
If we make ScopedAppGLStateRestore global, maybe w
boliu
2016/09/26 15:54:52
Done.
| |
| 76 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); | 76 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); |
| 77 | 77 |
| 78 // We need to watch if the current Android context has changed and enforce | 78 // We need to watch if the current Android context has changed and enforce |
| 79 // a clean-up in the compositor. | 79 // a clean-up in the compositor. |
| 80 EGLContext current_context = eglGetCurrentContext(); | 80 EGLContext current_context = eglGetCurrentContext(); |
| 81 DCHECK(current_context) << "DrawGL called without EGLContext"; | 81 DCHECK(current_context) << "DrawGL called without EGLContext"; |
| 82 | 82 |
| 83 // TODO(boliu): Handle context loss. | 83 // TODO(boliu): Handle context loss. |
| 84 if (last_egl_context_ != current_context) | 84 if (last_egl_context_ != current_context) |
| 85 DLOG(WARNING) << "EGLContextChanged"; | 85 DLOG(WARNING) << "EGLContextChanged"; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 const cc::ReturnedResourceArray& resources) { | 168 const cc::ReturnedResourceArray& resources) { |
| 169 ReturnResourcesToCompositor(resources, compositor_id_, | 169 ReturnResourcesToCompositor(resources, compositor_id_, |
| 170 last_submitted_compositor_frame_sink_id_); | 170 last_submitted_compositor_frame_sink_id_); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void HardwareRenderer::SetBeginFrameSource( | 173 void HardwareRenderer::SetBeginFrameSource( |
| 174 cc::BeginFrameSource* begin_frame_source) { | 174 cc::BeginFrameSource* begin_frame_source) { |
| 175 // TODO(tansell): Hook this up. | 175 // TODO(tansell): Hook this up. |
| 176 } | 176 } |
| 177 | 177 |
| 178 void HardwareRenderer::SetBackingFrameBufferObject( | |
| 179 int framebuffer_binding_ext) { | |
| 180 surfaces_->SetBackingFrameBufferObject(framebuffer_binding_ext); | |
| 181 } | |
| 182 | |
| 183 void HardwareRenderer::ReturnResourcesInChildFrame() { | 178 void HardwareRenderer::ReturnResourcesInChildFrame() { |
| 184 if (child_frame_.get() && child_frame_->frame.get()) { | 179 if (child_frame_.get() && child_frame_->frame.get()) { |
| 185 cc::ReturnedResourceArray resources_to_return; | 180 cc::ReturnedResourceArray resources_to_return; |
| 186 cc::TransferableResource::ReturnResources( | 181 cc::TransferableResource::ReturnResources( |
| 187 child_frame_->frame->delegated_frame_data->resource_list, | 182 child_frame_->frame->delegated_frame_data->resource_list, |
| 188 &resources_to_return); | 183 &resources_to_return); |
| 189 | 184 |
| 190 // The child frame's compositor id is not necessarily same as | 185 // The child frame's compositor id is not necessarily same as |
| 191 // compositor_id_. | 186 // compositor_id_. |
| 192 ReturnResourcesToCompositor(resources_to_return, | 187 ReturnResourcesToCompositor(resources_to_return, |
| 193 child_frame_->compositor_id, | 188 child_frame_->compositor_id, |
| 194 child_frame_->compositor_frame_sink_id); | 189 child_frame_->compositor_frame_sink_id); |
| 195 } | 190 } |
| 196 child_frame_.reset(); | 191 child_frame_.reset(); |
| 197 } | 192 } |
| 198 | 193 |
| 199 void HardwareRenderer::ReturnResourcesToCompositor( | 194 void HardwareRenderer::ReturnResourcesToCompositor( |
| 200 const cc::ReturnedResourceArray& resources, | 195 const cc::ReturnedResourceArray& resources, |
| 201 const CompositorID& compositor_id, | 196 const CompositorID& compositor_id, |
| 202 uint32_t compositor_frame_sink_id) { | 197 uint32_t compositor_frame_sink_id) { |
| 203 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) | 198 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) |
| 204 return; | 199 return; |
| 205 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 200 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 206 compositor_frame_sink_id); | 201 compositor_frame_sink_id); |
| 207 } | 202 } |
| 208 | 203 |
| 209 } // namespace android_webview | 204 } // namespace android_webview |
| OLD | NEW |