Chromium Code Reviews| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 } | 77 } |
| 78 | 78 |
| 79 // static | 79 // static |
| 80 BrowserViewRenderer* BrowserViewRenderer::FromWebContents( | 80 BrowserViewRenderer* BrowserViewRenderer::FromWebContents( |
| 81 content::WebContents* web_contents) { | 81 content::WebContents* web_contents) { |
| 82 return BrowserViewRendererUserData::GetBrowserViewRenderer(web_contents); | 82 return BrowserViewRendererUserData::GetBrowserViewRenderer(web_contents); |
| 83 } | 83 } |
| 84 | 84 |
| 85 BrowserViewRenderer::BrowserViewRenderer( | 85 BrowserViewRenderer::BrowserViewRenderer( |
| 86 BrowserViewRendererClient* client, | 86 BrowserViewRendererClient* client, |
| 87 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) | 87 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| 88 bool disable_page_visibility) | |
| 88 : client_(client), | 89 : client_(client), |
| 89 shared_renderer_state_(ui_task_runner, this), | 90 shared_renderer_state_(ui_task_runner, this), |
| 90 ui_task_runner_(ui_task_runner), | 91 ui_task_runner_(ui_task_runner), |
| 92 disable_page_visibility_(disable_page_visibility), | |
| 91 compositor_(NULL), | 93 compositor_(NULL), |
| 92 is_paused_(false), | 94 is_paused_(false), |
| 93 view_visible_(false), | 95 view_visible_(false), |
| 94 window_visible_(false), | 96 window_visible_(false), |
| 95 attached_to_window_(false), | 97 attached_to_window_(false), |
| 96 hardware_enabled_(false), | 98 hardware_enabled_(false), |
| 97 dip_scale_(0.f), | 99 dip_scale_(0.f), |
| 98 page_scale_factor_(1.f), | 100 page_scale_factor_(1.f), |
| 99 min_page_scale_factor_(0.f), | 101 min_page_scale_factor_(0.f), |
| 100 max_page_scale_factor_(0.f), | 102 max_page_scale_factor_(0.f), |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 } | 438 } |
| 437 | 439 |
| 438 hardware_enabled_ = false; | 440 hardware_enabled_ = false; |
| 439 } | 441 } |
| 440 | 442 |
| 441 bool BrowserViewRenderer::IsVisible() const { | 443 bool BrowserViewRenderer::IsVisible() const { |
| 442 // Ignore |window_visible_| if |attached_to_window_| is false. | 444 // Ignore |window_visible_| if |attached_to_window_| is false. |
| 443 return view_visible_ && (!attached_to_window_ || window_visible_); | 445 return view_visible_ && (!attached_to_window_ || window_visible_); |
| 444 } | 446 } |
| 445 | 447 |
| 448 bool BrowserViewRenderer::IsClientVisible() const { | |
| 449 if (disable_page_visibility_) | |
| 450 return !is_paused_; | |
| 451 | |
| 452 return !is_paused_ && IsVisible(); | |
| 453 } | |
| 454 | |
| 446 gfx::Rect BrowserViewRenderer::GetScreenRect() const { | 455 gfx::Rect BrowserViewRenderer::GetScreenRect() const { |
| 447 return gfx::Rect(client_->GetLocationOnScreen(), size_); | 456 return gfx::Rect(client_->GetLocationOnScreen(), size_); |
| 448 } | 457 } |
| 449 | 458 |
| 450 void BrowserViewRenderer::DidInitializeCompositor( | 459 void BrowserViewRenderer::DidInitializeCompositor( |
| 451 content::SynchronousCompositor* compositor) { | 460 content::SynchronousCompositor* compositor) { |
| 452 TRACE_EVENT0("android_webview", | 461 TRACE_EVENT0("android_webview", |
| 453 "BrowserViewRenderer::DidInitializeCompositor"); | 462 "BrowserViewRenderer::DidInitializeCompositor"); |
| 454 DCHECK(compositor); | 463 DCHECK(compositor); |
| 455 DCHECK(!compositor_); | 464 DCHECK(!compositor_); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 } | 717 } |
| 709 | 718 |
| 710 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { | 719 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { |
| 711 DCHECK(compositor_); | 720 DCHECK(compositor_); |
| 712 CancelFallbackTick(); | 721 CancelFallbackTick(); |
| 713 ReturnResourceFromParent(); | 722 ReturnResourceFromParent(); |
| 714 return compositor_->DemandDrawSw(canvas); | 723 return compositor_->DemandDrawSw(canvas); |
| 715 } | 724 } |
| 716 | 725 |
| 717 void BrowserViewRenderer::UpdateCompositorIsActive() { | 726 void BrowserViewRenderer::UpdateCompositorIsActive() { |
| 718 if (compositor_) | 727 if (compositor_) { |
| 719 compositor_->SetIsActive(!is_paused_ && | 728 if (disable_page_visibility_) |
| 720 (!attached_to_window_ || window_visible_)); | 729 compositor_->SetIsActive(!is_paused_ && |
| 730 (!attached_to_window_ || window_visible_)); | |
| 731 else | |
| 732 compositor_->SetIsActive(!is_paused_ && IsVisible()); | |
|
boliu
2015/09/29 01:47:27
IsClientVisible here
hush (inactive)
2015/09/29 01:56:52
Done.
| |
| 733 } | |
| 721 } | 734 } |
| 722 | 735 |
| 723 std::string BrowserViewRenderer::ToString() const { | 736 std::string BrowserViewRenderer::ToString() const { |
| 724 std::string str; | 737 std::string str; |
| 725 base::StringAppendF(&str, "is_paused: %d ", is_paused_); | 738 base::StringAppendF(&str, "is_paused: %d ", is_paused_); |
| 726 base::StringAppendF(&str, "view_visible: %d ", view_visible_); | 739 base::StringAppendF(&str, "view_visible: %d ", view_visible_); |
| 727 base::StringAppendF(&str, "window_visible: %d ", window_visible_); | 740 base::StringAppendF(&str, "window_visible: %d ", window_visible_); |
| 728 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); | 741 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); |
| 729 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); | 742 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); |
| 730 base::StringAppendF(&str, "fallback_tick_pending: %d ", | 743 base::StringAppendF(&str, "fallback_tick_pending: %d ", |
| 731 fallback_tick_pending_); | 744 fallback_tick_pending_); |
| 732 base::StringAppendF(&str, "view size: %s ", size_.ToString().c_str()); | 745 base::StringAppendF(&str, "view size: %s ", size_.ToString().c_str()); |
| 733 base::StringAppendF(&str, "attached_to_window: %d ", attached_to_window_); | 746 base::StringAppendF(&str, "attached_to_window: %d ", attached_to_window_); |
| 734 base::StringAppendF(&str, | 747 base::StringAppendF(&str, |
| 735 "global visible rect: %s ", | 748 "global visible rect: %s ", |
| 736 last_on_draw_global_visible_rect_.ToString().c_str()); | 749 last_on_draw_global_visible_rect_.ToString().c_str()); |
| 737 base::StringAppendF( | 750 base::StringAppendF( |
| 738 &str, "scroll_offset_dip: %s ", scroll_offset_dip_.ToString().c_str()); | 751 &str, "scroll_offset_dip: %s ", scroll_offset_dip_.ToString().c_str()); |
| 739 base::StringAppendF(&str, | 752 base::StringAppendF(&str, |
| 740 "overscroll_rounding_error_: %s ", | 753 "overscroll_rounding_error_: %s ", |
| 741 overscroll_rounding_error_.ToString().c_str()); | 754 overscroll_rounding_error_.ToString().c_str()); |
| 742 base::StringAppendF( | 755 base::StringAppendF( |
| 743 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 756 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
| 744 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 757 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
| 745 return str; | 758 return str; |
| 746 } | 759 } |
| 747 | 760 |
| 748 } // namespace android_webview | 761 } // namespace android_webview |
| OLD | NEW |