| 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/browser_view_renderer.h" | 5 #include "android_webview/browser/browser_view_renderer.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/browser_view_renderer_client.h" | 7 #include "android_webview/browser/browser_view_renderer_client.h" |
| 8 #include "android_webview/browser/child_frame.h" |
| 8 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 14 #include "base/trace_event/trace_event_argument.h" | 15 #include "base/trace_event/trace_event_argument.h" |
| 15 #include "cc/output/compositor_frame.h" | 16 #include "cc/output/compositor_frame.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 view_visible_(false), | 92 view_visible_(false), |
| 92 window_visible_(false), | 93 window_visible_(false), |
| 93 attached_to_window_(false), | 94 attached_to_window_(false), |
| 94 hardware_enabled_(false), | 95 hardware_enabled_(false), |
| 95 dip_scale_(0.0), | 96 dip_scale_(0.0), |
| 96 page_scale_factor_(1.0), | 97 page_scale_factor_(1.0), |
| 97 on_new_picture_enable_(false), | 98 on_new_picture_enable_(false), |
| 98 clear_view_(false), | 99 clear_view_(false), |
| 99 offscreen_pre_raster_(false), | 100 offscreen_pre_raster_(false), |
| 100 compositor_needs_continuous_invalidate_(false), | 101 compositor_needs_continuous_invalidate_(false), |
| 101 invalidate_after_composite_(false), | |
| 102 block_invalidates_(false), | 102 block_invalidates_(false), |
| 103 fallback_tick_pending_(false) { | 103 fallback_tick_pending_(false) { |
| 104 } | 104 } |
| 105 | 105 |
| 106 BrowserViewRenderer::~BrowserViewRenderer() { | 106 BrowserViewRenderer::~BrowserViewRenderer() { |
| 107 } | 107 } |
| 108 | 108 |
| 109 void BrowserViewRenderer::RegisterWithWebContents( | 109 void BrowserViewRenderer::RegisterWithWebContents( |
| 110 content::WebContents* web_contents) { | 110 content::WebContents* web_contents) { |
| 111 web_contents->SetUserData(kBrowserViewRendererUserDataKey, | 111 web_contents->SetUserData(kBrowserViewRendererUserDataKey, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (!hardware_enabled_) { | 209 if (!hardware_enabled_) { |
| 210 TRACE_EVENT0("android_webview", "InitializeHwDraw"); | 210 TRACE_EVENT0("android_webview", "InitializeHwDraw"); |
| 211 hardware_enabled_ = compositor_->InitializeHwDraw(); | 211 hardware_enabled_ = compositor_->InitializeHwDraw(); |
| 212 } | 212 } |
| 213 if (!hardware_enabled_) { | 213 if (!hardware_enabled_) { |
| 214 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_HardwareNotEnabled", | 214 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_HardwareNotEnabled", |
| 215 TRACE_EVENT_SCOPE_THREAD); | 215 TRACE_EVENT_SCOPE_THREAD); |
| 216 return false; | 216 return false; |
| 217 } | 217 } |
| 218 | 218 |
| 219 ReturnResourceFromParent(); | 219 return CompositeHw(); |
| 220 if (shared_renderer_state_.HasCompositorFrameOnUI()) { | |
| 221 TRACE_EVENT_INSTANT0("android_webview", | |
| 222 "EarlyOut_PreviousFrameUnconsumed", | |
| 223 TRACE_EVENT_SCOPE_THREAD); | |
| 224 DidSkipCompositeInDraw(); | |
| 225 return true; | |
| 226 } | |
| 227 | |
| 228 scoped_ptr<cc::CompositorFrame> frame = CompositeHw(); | |
| 229 if (!frame.get()) { | |
| 230 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", | |
| 231 TRACE_EVENT_SCOPE_THREAD); | |
| 232 return false; | |
| 233 } | |
| 234 | |
| 235 shared_renderer_state_.SetCompositorFrameOnUI(frame.Pass(), false); | |
| 236 return true; | |
| 237 } | 220 } |
| 238 | 221 |
| 239 scoped_ptr<cc::CompositorFrame> BrowserViewRenderer::CompositeHw() { | 222 bool BrowserViewRenderer::CompositeHw() { |
| 223 ReturnResourceFromParent(); |
| 240 compositor_->SetMemoryPolicy(CalculateDesiredMemoryPolicy()); | 224 compositor_->SetMemoryPolicy(CalculateDesiredMemoryPolicy()); |
| 241 | 225 |
| 242 parent_draw_constraints_ = | 226 ParentCompositorDrawConstraints parent_draw_constraints = |
| 243 shared_renderer_state_.GetParentDrawConstraintsOnUI(); | 227 shared_renderer_state_.GetParentDrawConstraintsOnUI(); |
| 244 gfx::Size surface_size(size_); | 228 gfx::Size surface_size(size_); |
| 245 gfx::Rect viewport(surface_size); | 229 gfx::Rect viewport(surface_size); |
| 246 gfx::Rect clip = viewport; | 230 gfx::Rect clip = viewport; |
| 247 gfx::Transform transform_for_tile_priority = | 231 gfx::Transform transform_for_tile_priority = |
| 248 parent_draw_constraints_.transform; | 232 parent_draw_constraints.transform; |
| 249 | 233 |
| 250 // If the WebView is on a layer, WebView does not know what transform is | 234 // If the WebView is on a layer, WebView does not know what transform is |
| 251 // applied onto the layer so global visible rect does not make sense here. | 235 // applied onto the layer so global visible rect does not make sense here. |
| 252 // In this case, just use the surface rect for tiling. | 236 // In this case, just use the surface rect for tiling. |
| 253 gfx::Rect viewport_rect_for_tile_priority; | 237 gfx::Rect viewport_rect_for_tile_priority; |
| 254 | 238 |
| 255 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. | 239 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. |
| 256 if (!offscreen_pre_raster_) { | 240 if (!offscreen_pre_raster_) { |
| 257 if (parent_draw_constraints_.is_layer || | 241 if (parent_draw_constraints.is_layer) { |
| 258 last_on_draw_global_visible_rect_.IsEmpty()) { | 242 viewport_rect_for_tile_priority = parent_draw_constraints.surface_rect; |
| 259 viewport_rect_for_tile_priority = parent_draw_constraints_.surface_rect; | |
| 260 } else { | 243 } else { |
| 261 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_; | 244 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_; |
| 262 } | 245 } |
| 263 } | 246 } |
| 264 | 247 |
| 265 scoped_ptr<cc::CompositorFrame> frame = | 248 scoped_ptr<cc::CompositorFrame> frame = |
| 266 compositor_->DemandDrawHw(surface_size, | 249 compositor_->DemandDrawHw(surface_size, |
| 267 gfx::Transform(), | 250 gfx::Transform(), |
| 268 viewport, | 251 viewport, |
| 269 clip, | 252 clip, |
| 270 viewport_rect_for_tile_priority, | 253 viewport_rect_for_tile_priority, |
| 271 transform_for_tile_priority); | 254 transform_for_tile_priority); |
| 272 if (frame.get()) | 255 if (!frame.get()) { |
| 273 DidComposite(); | 256 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", |
| 274 return frame.Pass(); | 257 TRACE_EVENT_SCOPE_THREAD); |
| 258 return false; |
| 259 } |
| 260 |
| 261 scoped_ptr<ChildFrame> child_frame = make_scoped_ptr( |
| 262 new ChildFrame(frame.Pass(), viewport_rect_for_tile_priority, |
| 263 transform_for_tile_priority, offscreen_pre_raster_, |
| 264 parent_draw_constraints.is_layer)); |
| 265 |
| 266 DidComposite(); |
| 267 // Uncommitted frame can happen with consecutive fallback ticks. |
| 268 ReturnUnusedResource(shared_renderer_state_.PassUncommittedFrameOnUI()); |
| 269 shared_renderer_state_.SetCompositorFrameOnUI(child_frame.Pass()); |
| 270 return true; |
| 275 } | 271 } |
| 276 | 272 |
| 277 void BrowserViewRenderer::UpdateParentDrawConstraints() { | 273 void BrowserViewRenderer::UpdateParentDrawConstraints() { |
| 278 // Post an invalidate if the parent draw constraints are stale and there is | 274 EnsureContinuousInvalidation(true); |
| 279 // no pending invalidate. | |
| 280 bool needs_force_invalidate = | |
| 281 shared_renderer_state_.NeedsForceInvalidateOnNextDrawGLOnUI(); | |
| 282 if (needs_force_invalidate || | |
| 283 !parent_draw_constraints_.Equals( | |
| 284 shared_renderer_state_.GetParentDrawConstraintsOnUI())) { | |
| 285 shared_renderer_state_.SetForceInvalidateOnNextDrawGLOnUI(false); | |
| 286 EnsureContinuousInvalidation(true, needs_force_invalidate); | |
| 287 } | |
| 288 } | 275 } |
| 289 | 276 |
| 290 void BrowserViewRenderer::ReturnUnusedResource( | 277 void BrowserViewRenderer::ReturnUnusedResource( |
| 291 scoped_ptr<cc::CompositorFrame> frame) { | 278 scoped_ptr<ChildFrame> child_frame) { |
| 292 if (!frame.get()) | 279 if (!child_frame.get() || !child_frame->frame.get()) |
| 293 return; | 280 return; |
| 294 | 281 |
| 295 cc::CompositorFrameAck frame_ack; | 282 cc::CompositorFrameAck frame_ack; |
| 296 cc::TransferableResource::ReturnResources( | 283 cc::TransferableResource::ReturnResources( |
| 297 frame->delegated_frame_data->resource_list, &frame_ack.resources); | 284 child_frame->frame->delegated_frame_data->resource_list, |
| 285 &frame_ack.resources); |
| 298 if (compositor_ && !frame_ack.resources.empty()) | 286 if (compositor_ && !frame_ack.resources.empty()) |
| 299 compositor_->ReturnResources(frame_ack); | 287 compositor_->ReturnResources(frame_ack); |
| 300 } | 288 } |
| 301 | 289 |
| 302 void BrowserViewRenderer::ReturnResourceFromParent() { | 290 void BrowserViewRenderer::ReturnResourceFromParent() { |
| 303 cc::CompositorFrameAck frame_ack; | 291 cc::CompositorFrameAck frame_ack; |
| 304 shared_renderer_state_.SwapReturnedResourcesOnUI(&frame_ack.resources); | 292 shared_renderer_state_.SwapReturnedResourcesOnUI(&frame_ack.resources); |
| 305 if (compositor_ && !frame_ack.resources.empty()) { | 293 if (compositor_ && !frame_ack.resources.empty()) { |
| 306 compositor_->ReturnResources(frame_ack); | 294 compositor_->ReturnResources(frame_ack); |
| 307 } | 295 } |
| 308 } | 296 } |
| 309 | 297 |
| 310 void BrowserViewRenderer::DidSkipCommitFrame() { | |
| 311 // Treat it the same way as skipping onDraw. | |
| 312 DidSkipCompositeInDraw(); | |
| 313 } | |
| 314 | |
| 315 void BrowserViewRenderer::DetachFunctorFromView() { | 298 void BrowserViewRenderer::DetachFunctorFromView() { |
| 316 client_->DetachFunctorFromView(); | 299 client_->DetachFunctorFromView(); |
| 317 } | 300 } |
| 318 | 301 |
| 319 bool BrowserViewRenderer::OnDrawSoftware(SkCanvas* canvas) { | 302 bool BrowserViewRenderer::OnDrawSoftware(SkCanvas* canvas) { |
| 320 return CanOnDraw() && CompositeSW(canvas); | 303 return CanOnDraw() && CompositeSW(canvas); |
| 321 } | 304 } |
| 322 | 305 |
| 323 skia::RefPtr<SkPicture> BrowserViewRenderer::CapturePicture(int width, | 306 skia::RefPtr<SkPicture> BrowserViewRenderer::CapturePicture(int width, |
| 324 int height) { | 307 int height) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 349 | 332 |
| 350 void BrowserViewRenderer::ClearView() { | 333 void BrowserViewRenderer::ClearView() { |
| 351 TRACE_EVENT_INSTANT0("android_webview", | 334 TRACE_EVENT_INSTANT0("android_webview", |
| 352 "BrowserViewRenderer::ClearView", | 335 "BrowserViewRenderer::ClearView", |
| 353 TRACE_EVENT_SCOPE_THREAD); | 336 TRACE_EVENT_SCOPE_THREAD); |
| 354 if (clear_view_) | 337 if (clear_view_) |
| 355 return; | 338 return; |
| 356 | 339 |
| 357 clear_view_ = true; | 340 clear_view_ = true; |
| 358 // Always invalidate ignoring the compositor to actually clear the webview. | 341 // Always invalidate ignoring the compositor to actually clear the webview. |
| 359 EnsureContinuousInvalidation(true, false); | 342 EnsureContinuousInvalidation(true); |
| 360 } | 343 } |
| 361 | 344 |
| 362 void BrowserViewRenderer::SetOffscreenPreRaster(bool enable) { | 345 void BrowserViewRenderer::SetOffscreenPreRaster(bool enable) { |
| 363 // TODO(hush): anything to do when the setting is toggled? | 346 // TODO(hush): anything to do when the setting is toggled? |
| 364 offscreen_pre_raster_ = enable; | 347 offscreen_pre_raster_ = enable; |
| 365 } | 348 } |
| 366 | 349 |
| 367 void BrowserViewRenderer::SetIsPaused(bool paused) { | 350 void BrowserViewRenderer::SetIsPaused(bool paused) { |
| 368 TRACE_EVENT_INSTANT1("android_webview", | 351 TRACE_EVENT_INSTANT1("android_webview", |
| 369 "BrowserViewRenderer::SetIsPaused", | 352 "BrowserViewRenderer::SetIsPaused", |
| 370 TRACE_EVENT_SCOPE_THREAD, | 353 TRACE_EVENT_SCOPE_THREAD, |
| 371 "paused", | 354 "paused", |
| 372 paused); | 355 paused); |
| 373 is_paused_ = paused; | 356 is_paused_ = paused; |
| 374 EnsureContinuousInvalidation(false, false); | 357 EnsureContinuousInvalidation(false); |
| 375 } | 358 } |
| 376 | 359 |
| 377 void BrowserViewRenderer::SetViewVisibility(bool view_visible) { | 360 void BrowserViewRenderer::SetViewVisibility(bool view_visible) { |
| 378 TRACE_EVENT_INSTANT1("android_webview", | 361 TRACE_EVENT_INSTANT1("android_webview", |
| 379 "BrowserViewRenderer::SetViewVisibility", | 362 "BrowserViewRenderer::SetViewVisibility", |
| 380 TRACE_EVENT_SCOPE_THREAD, | 363 TRACE_EVENT_SCOPE_THREAD, |
| 381 "view_visible", | 364 "view_visible", |
| 382 view_visible); | 365 view_visible); |
| 383 view_visible_ = view_visible; | 366 view_visible_ = view_visible; |
| 384 } | 367 } |
| 385 | 368 |
| 386 void BrowserViewRenderer::SetWindowVisibility(bool window_visible) { | 369 void BrowserViewRenderer::SetWindowVisibility(bool window_visible) { |
| 387 TRACE_EVENT_INSTANT1("android_webview", | 370 TRACE_EVENT_INSTANT1("android_webview", |
| 388 "BrowserViewRenderer::SetWindowVisibility", | 371 "BrowserViewRenderer::SetWindowVisibility", |
| 389 TRACE_EVENT_SCOPE_THREAD, | 372 TRACE_EVENT_SCOPE_THREAD, |
| 390 "window_visible", | 373 "window_visible", |
| 391 window_visible); | 374 window_visible); |
| 392 window_visible_ = window_visible; | 375 window_visible_ = window_visible; |
| 393 EnsureContinuousInvalidation(false, false); | 376 EnsureContinuousInvalidation(false); |
| 394 } | 377 } |
| 395 | 378 |
| 396 void BrowserViewRenderer::OnSizeChanged(int width, int height) { | 379 void BrowserViewRenderer::OnSizeChanged(int width, int height) { |
| 397 TRACE_EVENT_INSTANT2("android_webview", | 380 TRACE_EVENT_INSTANT2("android_webview", |
| 398 "BrowserViewRenderer::OnSizeChanged", | 381 "BrowserViewRenderer::OnSizeChanged", |
| 399 TRACE_EVENT_SCOPE_THREAD, | 382 TRACE_EVENT_SCOPE_THREAD, |
| 400 "width", | 383 "width", |
| 401 width, | 384 width, |
| 402 "height", | 385 "height", |
| 403 height); | 386 height); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if (compositor_needs_continuous_invalidate_ == invalidate) | 447 if (compositor_needs_continuous_invalidate_ == invalidate) |
| 465 return; | 448 return; |
| 466 | 449 |
| 467 TRACE_EVENT_INSTANT1("android_webview", | 450 TRACE_EVENT_INSTANT1("android_webview", |
| 468 "BrowserViewRenderer::SetContinuousInvalidate", | 451 "BrowserViewRenderer::SetContinuousInvalidate", |
| 469 TRACE_EVENT_SCOPE_THREAD, | 452 TRACE_EVENT_SCOPE_THREAD, |
| 470 "invalidate", | 453 "invalidate", |
| 471 invalidate); | 454 invalidate); |
| 472 compositor_needs_continuous_invalidate_ = invalidate; | 455 compositor_needs_continuous_invalidate_ = invalidate; |
| 473 | 456 |
| 474 EnsureContinuousInvalidation(false, false); | 457 EnsureContinuousInvalidation(false); |
| 475 } | 458 } |
| 476 | 459 |
| 477 void BrowserViewRenderer::SetDipScale(float dip_scale) { | 460 void BrowserViewRenderer::SetDipScale(float dip_scale) { |
| 478 dip_scale_ = dip_scale; | 461 dip_scale_ = dip_scale; |
| 479 CHECK_GT(dip_scale_, 0.f); | 462 CHECK_GT(dip_scale_, 0.f); |
| 480 } | 463 } |
| 481 | 464 |
| 482 gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const { | 465 gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const { |
| 483 DCHECK_GT(dip_scale_, 0.f); | 466 DCHECK_GT(dip_scale_, 0.f); |
| 484 return gfx::ToCeiledVector2d(gfx::ScaleVector2d( | 467 return gfx::ToCeiledVector2d(gfx::ScaleVector2d( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 gfx::Vector2dF scaled_overscroll_delta = | 618 gfx::Vector2dF scaled_overscroll_delta = |
| 636 gfx::ScaleVector2d(latest_overscroll_delta, physical_pixel_scale); | 619 gfx::ScaleVector2d(latest_overscroll_delta, physical_pixel_scale); |
| 637 gfx::Vector2d rounded_overscroll_delta = gfx::ToRoundedVector2d( | 620 gfx::Vector2d rounded_overscroll_delta = gfx::ToRoundedVector2d( |
| 638 scaled_overscroll_delta + overscroll_rounding_error_); | 621 scaled_overscroll_delta + overscroll_rounding_error_); |
| 639 overscroll_rounding_error_ = | 622 overscroll_rounding_error_ = |
| 640 scaled_overscroll_delta - rounded_overscroll_delta; | 623 scaled_overscroll_delta - rounded_overscroll_delta; |
| 641 client_->DidOverscroll(rounded_overscroll_delta); | 624 client_->DidOverscroll(rounded_overscroll_delta); |
| 642 } | 625 } |
| 643 | 626 |
| 644 void BrowserViewRenderer::EnsureContinuousInvalidation( | 627 void BrowserViewRenderer::EnsureContinuousInvalidation( |
| 645 bool force_invalidate, | 628 bool force_invalidate) { |
| 646 bool skip_reschedule_tick) { | |
| 647 if (force_invalidate) | |
| 648 invalidate_after_composite_ = true; | |
| 649 | |
| 650 // This method should be called again when any of these conditions change. | 629 // This method should be called again when any of these conditions change. |
| 651 bool need_invalidate = | 630 bool need_invalidate = |
| 652 compositor_needs_continuous_invalidate_ || invalidate_after_composite_; | 631 compositor_needs_continuous_invalidate_ || force_invalidate; |
| 653 if (!need_invalidate || block_invalidates_) | 632 if (!need_invalidate || block_invalidates_) |
| 654 return; | 633 return; |
| 655 | 634 |
| 656 if (!compositor_needs_continuous_invalidate_ && invalidate_after_composite_) | |
| 657 invalidate_after_composite_ = false; | |
| 658 | |
| 659 // Always call view invalidate. We rely the Android framework to ignore the | 635 // Always call view invalidate. We rely the Android framework to ignore the |
| 660 // invalidate when it's not needed such as when view is not visible. | 636 // invalidate when it's not needed such as when view is not visible. |
| 661 client_->PostInvalidate(); | 637 client_->PostInvalidate(); |
| 662 | 638 |
| 663 // Stop fallback ticks when one of these is true. | 639 // Stop fallback ticks when one of these is true. |
| 664 // 1) Webview is paused. Also need to check we are not in clear view since | 640 // 1) Webview is paused. Also need to check we are not in clear view since |
| 665 // paused, offscreen still expect clear view to recover. | 641 // paused, offscreen still expect clear view to recover. |
| 666 // 2) If we are attached to window and the window is not visible (eg when | 642 // 2) If we are attached to window and the window is not visible (eg when |
| 667 // app is in the background). We are sure in this case the webview is used | 643 // app is in the background). We are sure in this case the webview is used |
| 668 // "on-screen" but that updates are not needed when in the background. | 644 // "on-screen" but that updates are not needed when in the background. |
| 669 bool throttle_fallback_tick = | 645 bool throttle_fallback_tick = |
| 670 (is_paused_ && !clear_view_) || (attached_to_window_ && !window_visible_); | 646 (is_paused_ && !clear_view_) || (attached_to_window_ && !window_visible_); |
| 671 if (throttle_fallback_tick) | 647 if (throttle_fallback_tick) |
| 672 return; | 648 return; |
| 673 | 649 |
| 674 block_invalidates_ = compositor_needs_continuous_invalidate_; | 650 block_invalidates_ = compositor_needs_continuous_invalidate_; |
| 675 if (skip_reschedule_tick && fallback_tick_pending_) | 651 if (fallback_tick_pending_) |
| 676 return; | 652 return; |
| 677 | 653 |
| 678 // Unretained here is safe because the callbacks are cancelled when | 654 // Unretained here is safe because the callbacks are cancelled when |
| 679 // they are destroyed. | 655 // they are destroyed. |
| 680 post_fallback_tick_.Reset(base::Bind(&BrowserViewRenderer::PostFallbackTick, | 656 post_fallback_tick_.Reset(base::Bind(&BrowserViewRenderer::PostFallbackTick, |
| 681 base::Unretained(this))); | 657 base::Unretained(this))); |
| 682 fallback_tick_fired_.Cancel(); | 658 fallback_tick_fired_.Cancel(); |
| 683 fallback_tick_pending_ = false; | 659 fallback_tick_pending_ = false; |
| 684 | 660 |
| 685 // No need to reschedule fallback tick if compositor does not need to be | 661 // No need to reschedule fallback tick if compositor does not need to be |
| (...skipping 25 matching lines...) Expand all Loading... |
| 711 "BrowserViewRenderer::FallbackTickFired", | 687 "BrowserViewRenderer::FallbackTickFired", |
| 712 "compositor_needs_continuous_invalidate_", | 688 "compositor_needs_continuous_invalidate_", |
| 713 compositor_needs_continuous_invalidate_); | 689 compositor_needs_continuous_invalidate_); |
| 714 | 690 |
| 715 // This should only be called if OnDraw or DrawGL did not come in time, which | 691 // This should only be called if OnDraw or DrawGL did not come in time, which |
| 716 // means block_invalidates_ must still be true. | 692 // means block_invalidates_ must still be true. |
| 717 DCHECK(block_invalidates_); | 693 DCHECK(block_invalidates_); |
| 718 fallback_tick_pending_ = false; | 694 fallback_tick_pending_ = false; |
| 719 if (compositor_needs_continuous_invalidate_ && compositor_) { | 695 if (compositor_needs_continuous_invalidate_ && compositor_) { |
| 720 if (hardware_enabled_) { | 696 if (hardware_enabled_) { |
| 721 ReturnResourceFromParent(); | 697 CompositeHw(); |
| 722 ReturnUnusedResource(shared_renderer_state_.PassUncommittedFrameOnUI()); | |
| 723 scoped_ptr<cc::CompositorFrame> frame = CompositeHw(); | |
| 724 if (frame.get()) { | |
| 725 shared_renderer_state_.SetCompositorFrameOnUI(frame.Pass(), true); | |
| 726 } | |
| 727 } else { | 698 } else { |
| 728 ForceFakeCompositeSW(); | 699 ForceFakeCompositeSW(); |
| 729 } | 700 } |
| 730 } else { | 701 } else { |
| 731 // Pretend we just composited to unblock further invalidates. | 702 // Pretend we just composited to unblock further invalidates. |
| 732 DidComposite(); | 703 DidComposite(); |
| 733 } | 704 } |
| 734 } | 705 } |
| 735 | 706 |
| 736 void BrowserViewRenderer::ForceFakeCompositeSW() { | 707 void BrowserViewRenderer::ForceFakeCompositeSW() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 748 bool result = compositor_->DemandDrawSw(canvas); | 719 bool result = compositor_->DemandDrawSw(canvas); |
| 749 DidComposite(); | 720 DidComposite(); |
| 750 return result; | 721 return result; |
| 751 } | 722 } |
| 752 | 723 |
| 753 void BrowserViewRenderer::DidComposite() { | 724 void BrowserViewRenderer::DidComposite() { |
| 754 block_invalidates_ = false; | 725 block_invalidates_ = false; |
| 755 post_fallback_tick_.Cancel(); | 726 post_fallback_tick_.Cancel(); |
| 756 fallback_tick_fired_.Cancel(); | 727 fallback_tick_fired_.Cancel(); |
| 757 fallback_tick_pending_ = false; | 728 fallback_tick_pending_ = false; |
| 758 EnsureContinuousInvalidation(false, false); | 729 EnsureContinuousInvalidation(false); |
| 759 } | |
| 760 | |
| 761 void BrowserViewRenderer::DidSkipCompositeInDraw() { | |
| 762 block_invalidates_ = false; | |
| 763 EnsureContinuousInvalidation(true, true); | |
| 764 } | 730 } |
| 765 | 731 |
| 766 std::string BrowserViewRenderer::ToString() const { | 732 std::string BrowserViewRenderer::ToString() const { |
| 767 std::string str; | 733 std::string str; |
| 768 base::StringAppendF(&str, "is_paused: %d ", is_paused_); | 734 base::StringAppendF(&str, "is_paused: %d ", is_paused_); |
| 769 base::StringAppendF(&str, "view_visible: %d ", view_visible_); | 735 base::StringAppendF(&str, "view_visible: %d ", view_visible_); |
| 770 base::StringAppendF(&str, "window_visible: %d ", window_visible_); | 736 base::StringAppendF(&str, "window_visible: %d ", window_visible_); |
| 771 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); | 737 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); |
| 772 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); | 738 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); |
| 773 base::StringAppendF(&str, | 739 base::StringAppendF(&str, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 784 base::StringAppendF(&str, | 750 base::StringAppendF(&str, |
| 785 "overscroll_rounding_error_: %s ", | 751 "overscroll_rounding_error_: %s ", |
| 786 overscroll_rounding_error_.ToString().c_str()); | 752 overscroll_rounding_error_.ToString().c_str()); |
| 787 base::StringAppendF( | 753 base::StringAppendF( |
| 788 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 754 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
| 789 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 755 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
| 790 return str; | 756 return str; |
| 791 } | 757 } |
| 792 | 758 |
| 793 } // namespace android_webview | 759 } // namespace android_webview |
| OLD | NEW |