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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( | 53 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( |
54 ParentCompositorDrawConstraints()); | 54 ParentCompositorDrawConstraints()); |
55 ReturnResourcesInChildFrame(); | 55 ReturnResourcesInChildFrame(); |
56 } | 56 } |
57 | 57 |
58 void HardwareRenderer::CommitFrame() { | 58 void HardwareRenderer::CommitFrame() { |
59 TRACE_EVENT0("android_webview", "CommitFrame"); | 59 TRACE_EVENT0("android_webview", "CommitFrame"); |
60 scroll_offset_ = render_thread_manager_->GetScrollOffsetOnRT(); | 60 scroll_offset_ = render_thread_manager_->GetScrollOffsetOnRT(); |
61 std::unique_ptr<ChildFrame> child_frame = | 61 std::unique_ptr<ChildFrame> child_frame = |
62 render_thread_manager_->PassFrameOnRT(); | 62 render_thread_manager_->PassFrameOnRT(); |
| 63 frame_future_ = render_thread_manager_->PassFrameFutureOnRT(); |
63 if (!child_frame.get()) | 64 if (!child_frame.get()) |
64 return; | 65 return; |
65 | |
66 last_committed_compositor_frame_sink_id_ = | |
67 child_frame->compositor_frame_sink_id; | |
68 ReturnResourcesInChildFrame(); | 66 ReturnResourcesInChildFrame(); |
69 child_frame_ = std::move(child_frame); | 67 child_frame_ = std::move(child_frame); |
70 DCHECK(child_frame_->frame.get()); | |
71 DCHECK(!child_frame_->frame->gl_frame_data); | |
72 } | 68 } |
73 | 69 |
74 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info) { | 70 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
75 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); | 71 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); |
76 | 72 |
| 73 if (frame_future_.get() && child_frame_.get() && !child_frame_->frame.get()) { |
| 74 std::unique_ptr<content::SynchronousCompositor::Frame> frame; |
| 75 { |
| 76 TRACE_EVENT0("android_webview", "GetFrame"); |
| 77 frame = frame_future_->getFrame(); |
| 78 } |
| 79 |
| 80 std::unique_ptr<cc::CompositorFrame> compositor_frame = |
| 81 std::move(frame->frame); |
| 82 |
| 83 child_frame_ = base::MakeUnique<ChildFrame>( |
| 84 frame->compositor_frame_sink_id, std::move(compositor_frame), |
| 85 child_frame_->compositor_id, |
| 86 child_frame_->viewport_rect_for_tile_priority_empty, |
| 87 child_frame_->transform_for_tile_priority, |
| 88 child_frame_->offscreen_pre_raster, child_frame_->is_layer); |
| 89 |
| 90 last_committed_compositor_frame_sink_id_ = |
| 91 child_frame_->compositor_frame_sink_id; |
| 92 // DCHECK(child_frame_->frame.get()); |
| 93 // DCHECK(!child_frame_->frame->gl_frame_data); |
| 94 frame_future_ = nullptr; |
| 95 } |
| 96 |
77 // We need to watch if the current Android context has changed and enforce | 97 // We need to watch if the current Android context has changed and enforce |
78 // a clean-up in the compositor. | 98 // a clean-up in the compositor. |
79 EGLContext current_context = eglGetCurrentContext(); | 99 EGLContext current_context = eglGetCurrentContext(); |
80 DCHECK(current_context) << "DrawGL called without EGLContext"; | 100 DCHECK(current_context) << "DrawGL called without EGLContext"; |
81 | 101 |
82 // TODO(boliu): Handle context loss. | 102 // TODO(boliu): Handle context loss. |
83 if (last_egl_context_ != current_context) | 103 if (last_egl_context_ != current_context) |
84 DLOG(WARNING) << "EGLContextChanged"; | 104 DLOG(WARNING) << "EGLContextChanged"; |
85 | 105 |
86 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it | 106 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 const cc::ReturnedResourceArray& resources, | 213 const cc::ReturnedResourceArray& resources, |
194 const CompositorID& compositor_id, | 214 const CompositorID& compositor_id, |
195 uint32_t compositor_frame_sink_id) { | 215 uint32_t compositor_frame_sink_id) { |
196 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) | 216 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) |
197 return; | 217 return; |
198 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, | 218 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, |
199 compositor_frame_sink_id); | 219 compositor_frame_sink_id); |
200 } | 220 } |
201 | 221 |
202 } // namespace android_webview | 222 } // namespace android_webview |
OLD | NEW |