Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: android_webview/browser/hardware_renderer.cc

Issue 2347563003: Added FrameFuture class (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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_ =
67 child_frame->frame_future->getFrame()->output_surface_id;
67 ReturnResourcesInChildFrame(); 68 ReturnResourcesInChildFrame();
68 child_frame_ = std::move(child_frame); 69 child_frame_ = std::move(child_frame);
69 DCHECK(child_frame_->frame.get()); 70 DCHECK(child_frame_->frame_future->getFrame()->frame.get());
70 DCHECK(!child_frame_->frame->gl_frame_data); 71 DCHECK(!child_frame_->frame_future->getFrame()->frame->gl_frame_data);
71 } 72 }
72 73
73 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info, 74 void HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info,
74 const ScopedAppGLStateRestore& gl_state) { 75 const ScopedAppGLStateRestore& gl_state) {
75 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); 76 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL");
76 77
77 // 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
78 // a clean-up in the compositor. 79 // a clean-up in the compositor.
79 EGLContext current_context = eglGetCurrentContext(); 80 EGLContext current_context = eglGetCurrentContext();
80 DCHECK(current_context) << "DrawGL called without EGLContext"; 81 DCHECK(current_context) << "DrawGL called without EGLContext";
81 82
82 // TODO(boliu): Handle context loss. 83 // TODO(boliu): Handle context loss.
83 if (last_egl_context_ != current_context) 84 if (last_egl_context_ != current_context)
84 DLOG(WARNING) << "EGLContextChanged"; 85 DLOG(WARNING) << "EGLContextChanged";
85 86
86 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it 87 // SurfaceFactory::SubmitCompositorFrame might call glFlush. So calling it
87 // during "kModeSync" stage (which does not allow GL) might result in extra 88 // during "kModeSync" stage (which does not allow GL) might result in extra
88 // kModeProcess. Instead, submit the frame in "kModeDraw" stage to avoid 89 // kModeProcess. Instead, submit the frame in "kModeDraw" stage to avoid
89 // unnecessary kModeProcess. 90 // unnecessary kModeProcess.
90 if (child_frame_.get() && child_frame_->frame.get()) { 91 if (child_frame_.get() &&
92 child_frame_->frame_future->getFrame()->frame.get()) {
91 if (!compositor_id_.Equals(child_frame_->compositor_id) || 93 if (!compositor_id_.Equals(child_frame_->compositor_id) ||
92 last_submitted_output_surface_id_ != child_frame_->output_surface_id) { 94 last_submitted_output_surface_id_ !=
95 child_frame_->frame_future->getFrame()->output_surface_id) {
93 if (!child_id_.is_null()) 96 if (!child_id_.is_null())
94 DestroySurface(); 97 DestroySurface();
95 98
96 // This will return all the resources to the previous compositor. 99 // This will return all the resources to the previous compositor.
97 surface_factory_.reset(); 100 surface_factory_.reset();
98 compositor_id_ = child_frame_->compositor_id; 101 compositor_id_ = child_frame_->compositor_id;
99 last_submitted_output_surface_id_ = child_frame_->output_surface_id; 102 last_submitted_output_surface_id_ =
103 child_frame_->frame_future->getFrame()->output_surface_id;
100 surface_factory_.reset( 104 surface_factory_.reset(
101 new cc::SurfaceFactory(surfaces_->GetSurfaceManager(), this)); 105 new cc::SurfaceFactory(surfaces_->GetSurfaceManager(), this));
102 } 106 }
103 107
104 std::unique_ptr<cc::CompositorFrame> child_compositor_frame = 108 std::unique_ptr<cc::CompositorFrame> child_compositor_frame =
105 std::move(child_frame_->frame); 109 std::move(child_frame_->frame_future->getFrame()->frame);
106 110
107 gfx::Size frame_size = 111 gfx::Size frame_size =
108 child_compositor_frame->delegated_frame_data->render_pass_list.back() 112 child_compositor_frame->delegated_frame_data->render_pass_list.back()
109 ->output_rect.size(); 113 ->output_rect.size();
110 bool size_changed = frame_size != frame_size_; 114 bool size_changed = frame_size != frame_size_;
111 frame_size_ = frame_size; 115 frame_size_ = frame_size;
112 if (child_id_.is_null() || size_changed) { 116 if (child_id_.is_null() || size_changed) {
113 if (!child_id_.is_null()) 117 if (!child_id_.is_null())
114 DestroySurface(); 118 DestroySurface();
115 AllocateSurface(); 119 AllocateSurface();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 cc::BeginFrameSource* begin_frame_source) { 175 cc::BeginFrameSource* begin_frame_source) {
172 // TODO(tansell): Hook this up. 176 // TODO(tansell): Hook this up.
173 } 177 }
174 178
175 void HardwareRenderer::SetBackingFrameBufferObject( 179 void HardwareRenderer::SetBackingFrameBufferObject(
176 int framebuffer_binding_ext) { 180 int framebuffer_binding_ext) {
177 surfaces_->SetBackingFrameBufferObject(framebuffer_binding_ext); 181 surfaces_->SetBackingFrameBufferObject(framebuffer_binding_ext);
178 } 182 }
179 183
180 void HardwareRenderer::ReturnResourcesInChildFrame() { 184 void HardwareRenderer::ReturnResourcesInChildFrame() {
181 if (child_frame_.get() && child_frame_->frame.get()) { 185 if (child_frame_.get() &&
186 child_frame_->frame_future->getFrame()->frame.get()) {
182 cc::ReturnedResourceArray resources_to_return; 187 cc::ReturnedResourceArray resources_to_return;
183 cc::TransferableResource::ReturnResources( 188 cc::TransferableResource::ReturnResources(
184 child_frame_->frame->delegated_frame_data->resource_list, 189 child_frame_->frame_future->getFrame()
190 ->frame->delegated_frame_data->resource_list,
185 &resources_to_return); 191 &resources_to_return);
186 192
187 // The child frame's compositor id is not necessarily same as 193 // The child frame's compositor id is not necessarily same as
188 // compositor_id_. 194 // compositor_id_.
189 ReturnResourcesToCompositor(resources_to_return, 195 ReturnResourcesToCompositor(
190 child_frame_->compositor_id, 196 resources_to_return, child_frame_->compositor_id,
191 child_frame_->output_surface_id); 197 child_frame_->frame_future->getFrame()->output_surface_id);
192 } 198 }
193 child_frame_.reset(); 199 child_frame_.reset();
194 } 200 }
195 201
196 void HardwareRenderer::ReturnResourcesToCompositor( 202 void HardwareRenderer::ReturnResourcesToCompositor(
197 const cc::ReturnedResourceArray& resources, 203 const cc::ReturnedResourceArray& resources,
198 const CompositorID& compositor_id, 204 const CompositorID& compositor_id,
199 uint32_t output_surface_id) { 205 uint32_t output_surface_id) {
200 if (output_surface_id != last_committed_output_surface_id_) 206 if (output_surface_id != last_committed_output_surface_id_)
201 return; 207 return;
202 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, 208 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id,
203 output_surface_id); 209 output_surface_id);
204 } 210 }
205 211
206 } // namespace android_webview 212 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698