| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ReturnResourcesInChildFrame(); | 54 ReturnResourcesInChildFrame(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void HardwareRenderer::CommitFrame() { | 57 void HardwareRenderer::CommitFrame() { |
| 58 TRACE_EVENT0("android_webview", "CommitFrame"); | 58 TRACE_EVENT0("android_webview", "CommitFrame"); |
| 59 scroll_offset_ = render_thread_manager_->GetScrollOffsetOnRT(); | 59 scroll_offset_ = render_thread_manager_->GetScrollOffsetOnRT(); |
| 60 std::unique_ptr<ChildFrame> child_frame = | 60 std::unique_ptr<ChildFrame> child_frame = |
| 61 render_thread_manager_->PassFrameOnRT(); | 61 render_thread_manager_->PassFrameOnRT(); |
| 62 if (!child_frame.get()) | 62 if (!child_frame.get()) |
| 63 return; | 63 return; |
| 64 | |
| 65 last_committed_compositor_frame_sink_id_ = | |
| 66 child_frame->compositor_frame_sink_id; | |
| 67 ReturnResourcesInChildFrame(); | 64 ReturnResourcesInChildFrame(); |
| 65 frame_future_ = render_thread_manager_->PassFrameFutureOnRT(); |
| 68 child_frame_ = std::move(child_frame); | 66 child_frame_ = std::move(child_frame); |
| 69 DCHECK(child_frame_->frame.get()); | |
| 70 } | 67 } |
| 71 | 68 |
| 72 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info) { | 69 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
| 73 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); | 70 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); |
| 74 | 71 |
| 72 if (frame_future_) { |
| 73 TRACE_EVENT0("android_webview", "GetFrame"); |
| 74 DCHECK(child_frame_); |
| 75 DCHECK(!child_frame_->frame); |
| 76 |
| 77 std::unique_ptr<content::SynchronousCompositor::Frame> frame = |
| 78 frame_future_->getFrame(); |
| 79 if (frame) { |
| 80 child_frame_->compositor_frame_sink_id = frame->compositor_frame_sink_id; |
| 81 child_frame_->frame = std::move(frame->frame); |
| 82 } else { |
| 83 child_frame_.reset(); |
| 84 } |
| 85 frame_future_ = nullptr; |
| 86 } |
| 87 |
| 88 if (child_frame_) { |
| 89 last_committed_compositor_frame_sink_id_ = |
| 90 child_frame_->compositor_frame_sink_id; |
| 91 } |
| 92 |
| 75 // We need to watch if the current Android context has changed and enforce | 93 // We need to watch if the current Android context has changed and enforce |
| 76 // a clean-up in the compositor. | 94 // a clean-up in the compositor. |
| 77 EGLContext current_context = eglGetCurrentContext(); | 95 EGLContext current_context = eglGetCurrentContext(); |
| 78 DCHECK(current_context) << "DrawGL called without EGLContext"; | 96 DCHECK(current_context) << "DrawGL called without EGLContext"; |
| 79 | 97 |
| 80 // TODO(boliu): Handle context loss. | 98 // TODO(boliu): Handle context loss. |
| 81 if (last_egl_context_ != current_context) | 99 if (last_egl_context_ != current_context) |
| 82 DLOG(WARNING) << "EGLContextChanged"; | 100 DLOG(WARNING) << "EGLContextChanged"; |
| 83 | 101 |
| 84 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it | 102 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 const cc::ReturnedResourceArray& resources, | 218 const cc::ReturnedResourceArray& resources, |
| 201 const CompositorID& compositor_id, | 219 const CompositorID& compositor_id, |
| 202 uint32_t compositor_frame_sink_id) { | 220 uint32_t compositor_frame_sink_id) { |
| 203 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) | 221 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) |
| 204 return; | 222 return; |
| 205 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 223 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
| 206 compositor_frame_sink_id); | 224 compositor_frame_sink_id); |
| 207 } | 225 } |
| 208 | 226 |
| 209 } // namespace android_webview | 227 } // namespace android_webview |
| OLD | NEW |