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

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

Issue 655813004: Part 1: Refactor Android WebView graphics code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor
Patch Set: comments Created 6 years, 1 month 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 "android_webview/browser/aw_gl_surface.h" 7 #include "android_webview/browser/aw_gl_surface.h"
8 #include "android_webview/browser/deferred_gpu_command_service.h" 8 #include "android_webview/browser/deferred_gpu_command_service.h"
9 #include "android_webview/browser/parent_output_surface.h" 9 #include "android_webview/browser/parent_output_surface.h"
10 #include "android_webview/browser/shared_renderer_state.h" 10 #include "android_webview/browser/shared_renderer_state.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Check collection is empty. 118 // Check collection is empty.
119 cc::ReturnedResourceArray returned_resources; 119 cc::ReturnedResourceArray returned_resources;
120 resource_collection_->TakeUnusedResourcesForChildCompositor( 120 resource_collection_->TakeUnusedResourcesForChildCompositor(
121 &returned_resources); 121 &returned_resources);
122 DCHECK_EQ(0u, returned_resources.size()); 122 DCHECK_EQ(0u, returned_resources.size());
123 #endif // DCHECK_IS_ON 123 #endif // DCHECK_IS_ON
124 124
125 resource_collection_->SetClient(NULL); 125 resource_collection_->SetClient(NULL);
126 126
127 // Reset draw constraints. 127 // Reset draw constraints.
128 shared_renderer_state_->UpdateDrawConstraints( 128 shared_renderer_state_->UpdateDrawConstraintsOnRT(
129 ParentCompositorDrawConstraints()); 129 ParentCompositorDrawConstraints());
130 } 130 }
131 131
132 void HardwareRenderer::DidBeginMainFrame() { 132 void HardwareRenderer::DidBeginMainFrame() {
133 // This is called after OutputSurface is created, but before the impl frame 133 // This is called after OutputSurface is created, but before the impl frame
134 // starts. We set the draw constraints here. 134 // starts. We set the draw constraints here.
135 DCHECK(output_surface_); 135 DCHECK(output_surface_);
136 DCHECK(viewport_clip_valid_for_dcheck_); 136 DCHECK(viewport_clip_valid_for_dcheck_);
137 output_surface_->SetExternalStencilTest(stencil_enabled_); 137 output_surface_->SetExternalStencilTest(stencil_enabled_);
138 output_surface_->SetDrawConstraints(viewport_, clip_); 138 output_surface_->SetDrawConstraints(viewport_, clip_);
139 } 139 }
140 140
141 void HardwareRenderer::CommitFrame() { 141 void HardwareRenderer::CommitFrame() {
142 scroll_offset_ = shared_renderer_state_->GetScrollOffset(); 142 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT();
143 if (committed_frame_.get()) { 143 if (committed_frame_.get()) {
144 TRACE_EVENT_INSTANT0("android_webview", 144 TRACE_EVENT_INSTANT0("android_webview",
145 "EarlyOut_PreviousFrameUnconsumed", 145 "EarlyOut_PreviousFrameUnconsumed",
146 TRACE_EVENT_SCOPE_THREAD); 146 TRACE_EVENT_SCOPE_THREAD);
147 shared_renderer_state_->DidSkipCommitFrame(); 147 shared_renderer_state_->DidSkipCommitFrameOnRT();
148 return; 148 return;
149 } 149 }
150 150
151 committed_frame_ = shared_renderer_state_->PassCompositorFrame(); 151 committed_frame_ = shared_renderer_state_->PassCompositorFrame();
152 // Happens with empty global visible rect. 152 // Happens with empty global visible rect.
153 if (!committed_frame_.get()) 153 if (!committed_frame_.get())
154 return; 154 return;
155 155
156 DCHECK(!committed_frame_->gl_frame_data); 156 DCHECK(!committed_frame_->gl_frame_data);
157 DCHECK(!committed_frame_->software_frame_data); 157 DCHECK(!committed_frame_->software_frame_data);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // We need to watch if the current Android context has changed and enforce 200 // We need to watch if the current Android context has changed and enforce
201 // a clean-up in the compositor. 201 // a clean-up in the compositor.
202 EGLContext current_context = eglGetCurrentContext(); 202 EGLContext current_context = eglGetCurrentContext();
203 DCHECK(current_context) << "DrawGL called without EGLContext"; 203 DCHECK(current_context) << "DrawGL called without EGLContext";
204 204
205 // TODO(boliu): Handle context loss. 205 // TODO(boliu): Handle context loss.
206 if (last_egl_context_ != current_context) 206 if (last_egl_context_ != current_context)
207 DLOG(WARNING) << "EGLContextChanged"; 207 DLOG(WARNING) << "EGLContextChanged";
208 208
209 SetFrameData(); 209 SetFrameData();
210 if (shared_renderer_state_->ForceCommit()) { 210 if (shared_renderer_state_->ForceCommitOnRT()) {
211 CommitFrame(); 211 CommitFrame();
212 SetFrameData(); 212 SetFrameData();
213 } 213 }
214 214
215 gfx::Transform transform(gfx::Transform::kSkipInitialization); 215 gfx::Transform transform(gfx::Transform::kSkipInitialization);
216 transform.matrix().setColMajorf(draw_info->transform); 216 transform.matrix().setColMajorf(draw_info->transform);
217 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); 217 transform.Translate(scroll_offset_.x(), scroll_offset_.y());
218 218
219 // Need to post the new transform matrix back to child compositor 219 // Need to post the new transform matrix back to child compositor
220 // because there is no onDraw during a Render Thread animation, and child 220 // because there is no onDraw during a Render Thread animation, and child
221 // compositor might not have the tiles rasterized as the animation goes on. 221 // compositor might not have the tiles rasterized as the animation goes on.
222 ParentCompositorDrawConstraints draw_constraints( 222 ParentCompositorDrawConstraints draw_constraints(
223 draw_info->is_layer, transform, gfx::Rect(viewport_)); 223 draw_info->is_layer, transform, gfx::Rect(viewport_));
224 224
225 draw_constraints_ = draw_constraints; 225 draw_constraints_ = draw_constraints;
226 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositor( 226 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT(
227 draw_constraints); 227 draw_constraints);
228 228
229 if (!delegated_layer_.get()) 229 if (!delegated_layer_.get())
230 return; 230 return;
231 231
232 viewport_.SetSize(draw_info->width, draw_info->height); 232 viewport_.SetSize(draw_info->width, draw_info->height);
233 layer_tree_host_->SetViewportSize(viewport_); 233 layer_tree_host_->SetViewportSize(viewport_);
234 clip_.SetRect(draw_info->clip_left, 234 clip_.SetRect(draw_info->clip_left,
235 draw_info->clip_top, 235 draw_info->clip_top,
236 draw_info->clip_right - draw_info->clip_left, 236 draw_info->clip_right - draw_info->clip_left,
(...skipping 21 matching lines...) Expand all
258 scoped_ptr<ParentOutputSurface> output_surface_holder( 258 scoped_ptr<ParentOutputSurface> output_surface_holder(
259 new ParentOutputSurface(context_provider)); 259 new ParentOutputSurface(context_provider));
260 output_surface_ = output_surface_holder.get(); 260 output_surface_ = output_surface_holder.get();
261 layer_tree_host_->SetOutputSurface(output_surface_holder.Pass()); 261 layer_tree_host_->SetOutputSurface(output_surface_holder.Pass());
262 } 262 }
263 263
264 void HardwareRenderer::UnusedResourcesAreAvailable() { 264 void HardwareRenderer::UnusedResourcesAreAvailable() {
265 cc::ReturnedResourceArray returned_resources; 265 cc::ReturnedResourceArray returned_resources;
266 resource_collection_->TakeUnusedResourcesForChildCompositor( 266 resource_collection_->TakeUnusedResourcesForChildCompositor(
267 &returned_resources); 267 &returned_resources);
268 shared_renderer_state_->InsertReturnedResources(returned_resources); 268 shared_renderer_state_->InsertReturnedResourcesOnRT(returned_resources);
269 } 269 }
270 270
271 } // namespace android_webview 271 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/browser_view_renderer.cc ('k') | android_webview/browser/shared_renderer_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698