| 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 "android_webview/browser/child_frame.h" |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 UpdateCompositorIsActive(); | 371 UpdateCompositorIsActive(); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void BrowserViewRenderer::SetViewVisibility(bool view_visible) { | 374 void BrowserViewRenderer::SetViewVisibility(bool view_visible) { |
| 375 TRACE_EVENT_INSTANT1("android_webview", | 375 TRACE_EVENT_INSTANT1("android_webview", |
| 376 "BrowserViewRenderer::SetViewVisibility", | 376 "BrowserViewRenderer::SetViewVisibility", |
| 377 TRACE_EVENT_SCOPE_THREAD, | 377 TRACE_EVENT_SCOPE_THREAD, |
| 378 "view_visible", | 378 "view_visible", |
| 379 view_visible); | 379 view_visible); |
| 380 view_visible_ = view_visible; | 380 view_visible_ = view_visible; |
| 381 if (!disable_page_visibility_) | |
| 382 UpdateCompositorIsActive(); | |
| 383 } | 381 } |
| 384 | 382 |
| 385 void BrowserViewRenderer::SetWindowVisibility(bool window_visible) { | 383 void BrowserViewRenderer::SetWindowVisibility(bool window_visible) { |
| 386 TRACE_EVENT_INSTANT1("android_webview", | 384 TRACE_EVENT_INSTANT1("android_webview", |
| 387 "BrowserViewRenderer::SetWindowVisibility", | 385 "BrowserViewRenderer::SetWindowVisibility", |
| 388 TRACE_EVENT_SCOPE_THREAD, | 386 TRACE_EVENT_SCOPE_THREAD, |
| 389 "window_visible", | 387 "window_visible", |
| 390 window_visible); | 388 window_visible); |
| 391 window_visible_ = window_visible; | 389 window_visible_ = window_visible; |
| 392 UpdateCompositorIsActive(); | 390 UpdateCompositorIsActive(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 443 |
| 446 bool BrowserViewRenderer::IsVisible() const { | 444 bool BrowserViewRenderer::IsVisible() const { |
| 447 // Ignore |window_visible_| if |attached_to_window_| is false. | 445 // Ignore |window_visible_| if |attached_to_window_| is false. |
| 448 return view_visible_ && (!attached_to_window_ || window_visible_); | 446 return view_visible_ && (!attached_to_window_ || window_visible_); |
| 449 } | 447 } |
| 450 | 448 |
| 451 bool BrowserViewRenderer::IsClientVisible() const { | 449 bool BrowserViewRenderer::IsClientVisible() const { |
| 452 if (disable_page_visibility_) | 450 if (disable_page_visibility_) |
| 453 return !is_paused_; | 451 return !is_paused_; |
| 454 | 452 |
| 455 return !is_paused_ && IsVisible(); | 453 return !is_paused_ && (!attached_to_window_ || window_visible_); |
| 456 } | 454 } |
| 457 | 455 |
| 458 gfx::Rect BrowserViewRenderer::GetScreenRect() const { | 456 gfx::Rect BrowserViewRenderer::GetScreenRect() const { |
| 459 return gfx::Rect(client_->GetLocationOnScreen(), size_); | 457 return gfx::Rect(client_->GetLocationOnScreen(), size_); |
| 460 } | 458 } |
| 461 | 459 |
| 462 void BrowserViewRenderer::DidInitializeCompositor( | 460 void BrowserViewRenderer::DidInitializeCompositor( |
| 463 content::SynchronousCompositor* compositor) { | 461 content::SynchronousCompositor* compositor) { |
| 464 TRACE_EVENT0("android_webview", | 462 TRACE_EVENT0("android_webview", |
| 465 "BrowserViewRenderer::DidInitializeCompositor"); | 463 "BrowserViewRenderer::DidInitializeCompositor"); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 | 720 |
| 723 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { | 721 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { |
| 724 DCHECK(compositor_); | 722 DCHECK(compositor_); |
| 725 CancelFallbackTick(); | 723 CancelFallbackTick(); |
| 726 ReturnResourceFromParent(); | 724 ReturnResourceFromParent(); |
| 727 return compositor_->DemandDrawSw(canvas); | 725 return compositor_->DemandDrawSw(canvas); |
| 728 } | 726 } |
| 729 | 727 |
| 730 void BrowserViewRenderer::UpdateCompositorIsActive() { | 728 void BrowserViewRenderer::UpdateCompositorIsActive() { |
| 731 if (compositor_) { | 729 if (compositor_) { |
| 732 if (disable_page_visibility_) | 730 compositor_->SetIsActive(!is_paused_ && |
| 733 compositor_->SetIsActive(!is_paused_ && | 731 (!attached_to_window_ || window_visible_)); |
| 734 (!attached_to_window_ || window_visible_)); | |
| 735 else | |
| 736 compositor_->SetIsActive(IsClientVisible()); | |
| 737 } | 732 } |
| 738 } | 733 } |
| 739 | 734 |
| 740 std::string BrowserViewRenderer::ToString() const { | 735 std::string BrowserViewRenderer::ToString() const { |
| 741 std::string str; | 736 std::string str; |
| 742 base::StringAppendF(&str, "is_paused: %d ", is_paused_); | 737 base::StringAppendF(&str, "is_paused: %d ", is_paused_); |
| 743 base::StringAppendF(&str, "view_visible: %d ", view_visible_); | 738 base::StringAppendF(&str, "view_visible: %d ", view_visible_); |
| 744 base::StringAppendF(&str, "window_visible: %d ", window_visible_); | 739 base::StringAppendF(&str, "window_visible: %d ", window_visible_); |
| 745 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); | 740 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); |
| 746 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); | 741 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); |
| 747 base::StringAppendF(&str, "fallback_tick_pending: %d ", | 742 base::StringAppendF(&str, "fallback_tick_pending: %d ", |
| 748 fallback_tick_pending_); | 743 fallback_tick_pending_); |
| 749 base::StringAppendF(&str, "view size: %s ", size_.ToString().c_str()); | 744 base::StringAppendF(&str, "view size: %s ", size_.ToString().c_str()); |
| 750 base::StringAppendF(&str, "attached_to_window: %d ", attached_to_window_); | 745 base::StringAppendF(&str, "attached_to_window: %d ", attached_to_window_); |
| 751 base::StringAppendF(&str, | 746 base::StringAppendF(&str, |
| 752 "global visible rect: %s ", | 747 "global visible rect: %s ", |
| 753 last_on_draw_global_visible_rect_.ToString().c_str()); | 748 last_on_draw_global_visible_rect_.ToString().c_str()); |
| 754 base::StringAppendF( | 749 base::StringAppendF( |
| 755 &str, "scroll_offset_dip: %s ", scroll_offset_dip_.ToString().c_str()); | 750 &str, "scroll_offset_dip: %s ", scroll_offset_dip_.ToString().c_str()); |
| 756 base::StringAppendF(&str, | 751 base::StringAppendF(&str, |
| 757 "overscroll_rounding_error_: %s ", | 752 "overscroll_rounding_error_: %s ", |
| 758 overscroll_rounding_error_.ToString().c_str()); | 753 overscroll_rounding_error_.ToString().c_str()); |
| 759 base::StringAppendF( | 754 base::StringAppendF( |
| 760 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 755 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
| 761 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 756 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
| 762 return str; | 757 return str; |
| 763 } | 758 } |
| 764 | 759 |
| 765 } // namespace android_webview | 760 } // namespace android_webview |
| OLD | NEW |