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