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 "android_webview/common/aw_switches.h" | |
9 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
14 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
15 #include "base/trace_event/trace_event_argument.h" | 16 #include "base/trace_event/trace_event_argument.h" |
16 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 window_visible_(false), | 95 window_visible_(false), |
95 attached_to_window_(false), | 96 attached_to_window_(false), |
96 hardware_enabled_(false), | 97 hardware_enabled_(false), |
97 dip_scale_(0.f), | 98 dip_scale_(0.f), |
98 page_scale_factor_(1.f), | 99 page_scale_factor_(1.f), |
99 min_page_scale_factor_(0.f), | 100 min_page_scale_factor_(0.f), |
100 max_page_scale_factor_(0.f), | 101 max_page_scale_factor_(0.f), |
101 on_new_picture_enable_(false), | 102 on_new_picture_enable_(false), |
102 clear_view_(false), | 103 clear_view_(false), |
103 offscreen_pre_raster_(false), | 104 offscreen_pre_raster_(false), |
104 fallback_tick_pending_(false) {} | 105 fallback_tick_pending_(false), |
106 disable_page_visibility_( | |
107 !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
boliu
2015/09/29 01:00:42
again, do this in aw_contents.cc and pass it in, d
hush (inactive)
2015/09/29 01:38:59
BVR already depends on base::commandline in Browse
boliu
2015/09/29 01:40:23
Maybe that should be fixed too
hush (inactive)
2015/09/29 01:45:00
let's not change CalculateTileMemoryPolicy here si
| |
108 switches::kEnablePageVisibility)) {} | |
105 | 109 |
106 BrowserViewRenderer::~BrowserViewRenderer() { | 110 BrowserViewRenderer::~BrowserViewRenderer() { |
107 } | 111 } |
108 | 112 |
109 void BrowserViewRenderer::RegisterWithWebContents( | 113 void BrowserViewRenderer::RegisterWithWebContents( |
110 content::WebContents* web_contents) { | 114 content::WebContents* web_contents) { |
111 web_contents->SetUserData(kBrowserViewRendererUserDataKey, | 115 web_contents->SetUserData(kBrowserViewRendererUserDataKey, |
112 new BrowserViewRendererUserData(this)); | 116 new BrowserViewRendererUserData(this)); |
113 } | 117 } |
114 | 118 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 } | 440 } |
437 | 441 |
438 hardware_enabled_ = false; | 442 hardware_enabled_ = false; |
439 } | 443 } |
440 | 444 |
441 bool BrowserViewRenderer::IsVisible() const { | 445 bool BrowserViewRenderer::IsVisible() const { |
442 // Ignore |window_visible_| if |attached_to_window_| is false. | 446 // Ignore |window_visible_| if |attached_to_window_| is false. |
443 return view_visible_ && (!attached_to_window_ || window_visible_); | 447 return view_visible_ && (!attached_to_window_ || window_visible_); |
444 } | 448 } |
445 | 449 |
450 bool BrowserViewRenderer::IsClientVisible() const { | |
hush (inactive)
2015/09/29 00:55:09
this is for CVC's visibility. I didn't think of an
boliu
2015/09/29 01:00:42
Shouldn't paused be handled here as well then?
hush (inactive)
2015/09/29 01:38:59
Done.
| |
451 if (disable_page_visibility_) | |
452 return true; | |
453 | |
454 return IsVisible(); | |
455 } | |
456 | |
446 gfx::Rect BrowserViewRenderer::GetScreenRect() const { | 457 gfx::Rect BrowserViewRenderer::GetScreenRect() const { |
447 return gfx::Rect(client_->GetLocationOnScreen(), size_); | 458 return gfx::Rect(client_->GetLocationOnScreen(), size_); |
448 } | 459 } |
449 | 460 |
450 void BrowserViewRenderer::DidInitializeCompositor( | 461 void BrowserViewRenderer::DidInitializeCompositor( |
451 content::SynchronousCompositor* compositor) { | 462 content::SynchronousCompositor* compositor) { |
452 TRACE_EVENT0("android_webview", | 463 TRACE_EVENT0("android_webview", |
453 "BrowserViewRenderer::DidInitializeCompositor"); | 464 "BrowserViewRenderer::DidInitializeCompositor"); |
454 DCHECK(compositor); | 465 DCHECK(compositor); |
455 DCHECK(!compositor_); | 466 DCHECK(!compositor_); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 } | 719 } |
709 | 720 |
710 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { | 721 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { |
711 DCHECK(compositor_); | 722 DCHECK(compositor_); |
712 CancelFallbackTick(); | 723 CancelFallbackTick(); |
713 ReturnResourceFromParent(); | 724 ReturnResourceFromParent(); |
714 return compositor_->DemandDrawSw(canvas); | 725 return compositor_->DemandDrawSw(canvas); |
715 } | 726 } |
716 | 727 |
717 void BrowserViewRenderer::UpdateCompositorIsActive() { | 728 void BrowserViewRenderer::UpdateCompositorIsActive() { |
718 if (compositor_) | 729 if (compositor_) { |
719 compositor_->SetIsActive(!is_paused_ && | 730 if (disable_page_visibility_) |
720 (!attached_to_window_ || window_visible_)); | 731 compositor_->SetIsActive(!is_paused_ && |
732 (!attached_to_window_ || window_visible_)); | |
733 else | |
734 compositor_->SetIsActive(!is_paused_ && IsVisible()); | |
735 } | |
721 } | 736 } |
722 | 737 |
723 std::string BrowserViewRenderer::ToString() const { | 738 std::string BrowserViewRenderer::ToString() const { |
724 std::string str; | 739 std::string str; |
725 base::StringAppendF(&str, "is_paused: %d ", is_paused_); | 740 base::StringAppendF(&str, "is_paused: %d ", is_paused_); |
726 base::StringAppendF(&str, "view_visible: %d ", view_visible_); | 741 base::StringAppendF(&str, "view_visible: %d ", view_visible_); |
727 base::StringAppendF(&str, "window_visible: %d ", window_visible_); | 742 base::StringAppendF(&str, "window_visible: %d ", window_visible_); |
728 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); | 743 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); |
729 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); | 744 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); |
730 base::StringAppendF(&str, "fallback_tick_pending: %d ", | 745 base::StringAppendF(&str, "fallback_tick_pending: %d ", |
731 fallback_tick_pending_); | 746 fallback_tick_pending_); |
732 base::StringAppendF(&str, "view size: %s ", size_.ToString().c_str()); | 747 base::StringAppendF(&str, "view size: %s ", size_.ToString().c_str()); |
733 base::StringAppendF(&str, "attached_to_window: %d ", attached_to_window_); | 748 base::StringAppendF(&str, "attached_to_window: %d ", attached_to_window_); |
734 base::StringAppendF(&str, | 749 base::StringAppendF(&str, |
735 "global visible rect: %s ", | 750 "global visible rect: %s ", |
736 last_on_draw_global_visible_rect_.ToString().c_str()); | 751 last_on_draw_global_visible_rect_.ToString().c_str()); |
737 base::StringAppendF( | 752 base::StringAppendF( |
738 &str, "scroll_offset_dip: %s ", scroll_offset_dip_.ToString().c_str()); | 753 &str, "scroll_offset_dip: %s ", scroll_offset_dip_.ToString().c_str()); |
739 base::StringAppendF(&str, | 754 base::StringAppendF(&str, |
740 "overscroll_rounding_error_: %s ", | 755 "overscroll_rounding_error_: %s ", |
741 overscroll_rounding_error_.ToString().c_str()); | 756 overscroll_rounding_error_.ToString().c_str()); |
742 base::StringAppendF( | 757 base::StringAppendF( |
743 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 758 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
744 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 759 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
745 return str; | 760 return str; |
746 } | 761 } |
747 | 762 |
748 } // namespace android_webview | 763 } // namespace android_webview |
OLD | NEW |