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

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

Issue 2174203002: OnDrawHardware() implementation with async messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added flag to branch old and new implementation Created 4 years, 4 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/browser_view_renderer.h" 5 #include "android_webview/browser/browser_view_renderer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "android_webview/browser/browser_view_renderer_client.h" 9 #include "android_webview/browser/browser_view_renderer_client.h"
10 #include "android_webview/browser/child_frame.h" 10 #include "android_webview/browser/child_frame.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // If the WebView is on a layer, WebView does not know what transform is 229 // If the WebView is on a layer, WebView does not know what transform is
230 // applied onto the layer so global visible rect does not make sense here. 230 // applied onto the layer so global visible rect does not make sense here.
231 // In this case, just use the surface rect for tiling. 231 // In this case, just use the surface rect for tiling.
232 gfx::Rect viewport_rect_for_tile_priority; 232 gfx::Rect viewport_rect_for_tile_priority;
233 233
234 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. 234 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on.
235 if (!offscreen_pre_raster_ && !external_draw_constraints_.is_layer) { 235 if (!offscreen_pre_raster_ && !external_draw_constraints_.is_layer) {
236 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_; 236 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_;
237 } 237 }
238 238
239 // If AFLAG true, will use semi-asynchronous implementation.
240 bool AFLAG = false;
boliu 2016/08/11 19:23:39 Here is an example of an actual command line switc
ojars 2016/08/17 22:51:33 Done.
241 if (AFLAG) {
242 compositor_->DemandDrawHw_Async(size_, viewport_rect_for_tile_priority,
243 transform_for_tile_priority);
244
245 return current_compositor_frame_consumer_->HasFrameOnUI();
246 }
247
239 content::SynchronousCompositor::Frame frame = compositor_->DemandDrawHw( 248 content::SynchronousCompositor::Frame frame = compositor_->DemandDrawHw(
240 size_, viewport_rect_for_tile_priority, transform_for_tile_priority); 249 size_, viewport_rect_for_tile_priority, transform_for_tile_priority);
241 if (!frame.frame.get()) { 250 if (!frame.frame.get()) {
242 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", 251 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame",
243 TRACE_EVENT_SCOPE_THREAD); 252 TRACE_EVENT_SCOPE_THREAD);
244 return current_compositor_frame_consumer_->HasFrameOnUI(); 253 return current_compositor_frame_consumer_->HasFrameOnUI();
245 } 254 }
246 255
247 std::unique_ptr<ChildFrame> child_frame = base::WrapUnique(new ChildFrame( 256 std::unique_ptr<ChildFrame> child_frame = base::WrapUnique(new ChildFrame(
248 frame.output_surface_id, std::move(frame.frame), compositor_id_, 257 frame.output_surface_id, std::move(frame.frame), compositor_id_,
249 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority, 258 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority,
250 offscreen_pre_raster_, external_draw_constraints_.is_layer)); 259 offscreen_pre_raster_, external_draw_constraints_.is_layer));
251 260
252 ReturnUnusedResource( 261 ReturnUnusedResource(
253 current_compositor_frame_consumer_->PassUncommittedFrameOnUI()); 262 current_compositor_frame_consumer_->PassUncommittedFrameOnUI());
254 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame)); 263 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame));
255 return true; 264 return true;
256 } 265 }
257 266
267 void BrowserViewRenderer::OnDrawHardwareProcessFrame(
268 content::SynchronousCompositor::Frame frame) {
269 TRACE_EVENT0("android_webview",
270 "BrowserViewRenderer::OnDrawHardwareProcessFrame");
271
272 if (!frame.frame.get())
273 return;
274
275 gfx::Transform transform_for_tile_priority =
276 external_draw_constraints_.transform;
277
278 // If the WebView is on a layer, WebView does not know what transform is
279 // applied onto the layer so global visible rect does not make sense here.
280 // In this case, just use the surface rect for tiling.
281 gfx::Rect viewport_rect_for_tile_priority;
282
283 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on.
284 if (!offscreen_pre_raster_ && !external_draw_constraints_.is_layer) {
285 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_;
286 }
287
288 std::unique_ptr<ChildFrame> child_frame = base::WrapUnique(new ChildFrame(
289 frame.output_surface_id, std::move(frame.frame), compositor_id_,
290 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority,
291 offscreen_pre_raster_, external_draw_constraints_.is_layer));
292
293 ReturnUnusedResource(
294 current_compositor_frame_consumer_->PassUncommittedFrameOnUI());
295 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame));
296 }
297
258 void BrowserViewRenderer::OnParentDrawConstraintsUpdated( 298 void BrowserViewRenderer::OnParentDrawConstraintsUpdated(
259 CompositorFrameConsumer* compositor_frame_consumer) { 299 CompositorFrameConsumer* compositor_frame_consumer) {
260 DCHECK(compositor_frame_consumer); 300 DCHECK(compositor_frame_consumer);
261 if (compositor_frame_consumer != current_compositor_frame_consumer_) 301 if (compositor_frame_consumer != current_compositor_frame_consumer_)
262 return; 302 return;
263 PostInvalidate(compositor_); 303 PostInvalidate(compositor_);
264 external_draw_constraints_ = 304 external_draw_constraints_ =
265 current_compositor_frame_consumer_->GetParentDrawConstraintsOnUI(); 305 current_compositor_frame_consumer_->GetParentDrawConstraintsOnUI();
266 UpdateMemoryPolicy(); 306 UpdateMemoryPolicy();
267 } 307 }
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 base::StringAppendF(&str, 772 base::StringAppendF(&str,
733 "overscroll_rounding_error_: %s ", 773 "overscroll_rounding_error_: %s ",
734 overscroll_rounding_error_.ToString().c_str()); 774 overscroll_rounding_error_.ToString().c_str());
735 base::StringAppendF( 775 base::StringAppendF(
736 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); 776 &str, "on_new_picture_enable: %d ", on_new_picture_enable_);
737 base::StringAppendF(&str, "clear_view: %d ", clear_view_); 777 base::StringAppendF(&str, "clear_view: %d ", clear_view_);
738 return str; 778 return str;
739 } 779 }
740 780
741 } // namespace android_webview 781 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698