| 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/shared_renderer_state.h" | 8 #include "android_webview/browser/shared_renderer_state.h" |
| 9 #include "android_webview/public/browser/draw_gl.h" | 9 #include "android_webview/public/browser/draw_gl.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 // 1) Webview is paused. Also need to check we are not in clear view since | 657 // 1) Webview is paused. Also need to check we are not in clear view since |
| 658 // paused, offscreen still expect clear view to recover. | 658 // paused, offscreen still expect clear view to recover. |
| 659 // 2) If we are attached to window and the window is not visible (eg when | 659 // 2) If we are attached to window and the window is not visible (eg when |
| 660 // app is in the background). We are sure in this case the webview is used | 660 // app is in the background). We are sure in this case the webview is used |
| 661 // "on-screen" but that updates are not needed when in the background. | 661 // "on-screen" but that updates are not needed when in the background. |
| 662 bool throttle_fallback_tick = | 662 bool throttle_fallback_tick = |
| 663 (is_paused_ && !clear_view_) || (attached_to_window_ && !window_visible_); | 663 (is_paused_ && !clear_view_) || (attached_to_window_ && !window_visible_); |
| 664 if (throttle_fallback_tick) | 664 if (throttle_fallback_tick) |
| 665 return; | 665 return; |
| 666 | 666 |
| 667 block_invalidates_ = compositor_needs_continuous_invalidate_; | 667 { |
| 668 base::AutoLock lock(render_thread_lock_); |
| 669 block_invalidates_ = compositor_needs_continuous_invalidate_; |
| 670 } |
| 668 | 671 |
| 669 // Unretained here is safe because the callback is cancelled when | 672 // Unretained here is safe because the callback is cancelled when |
| 670 // |fallback_tick_| is destroyed. | 673 // |fallback_tick_| is destroyed. |
| 671 fallback_tick_.Reset(base::Bind(&BrowserViewRenderer::FallbackTickFired, | 674 fallback_tick_.Reset(base::Bind(&BrowserViewRenderer::FallbackTickFired, |
| 672 base::Unretained(this))); | 675 base::Unretained(this))); |
| 673 | 676 |
| 674 // No need to reschedule fallback tick if compositor does not need to be | 677 // No need to reschedule fallback tick if compositor does not need to be |
| 675 // ticked. This can happen if this is reached because force_invalidate is | 678 // ticked. This can happen if this is reached because force_invalidate is |
| 676 // true. | 679 // true. |
| 677 if (compositor_needs_continuous_invalidate_) { | 680 if (compositor_needs_continuous_invalidate_) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 706 | 709 |
| 707 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { | 710 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { |
| 708 DCHECK(has_compositor_); | 711 DCHECK(has_compositor_); |
| 709 bool result = shared_renderer_state_->GetCompositor()-> | 712 bool result = shared_renderer_state_->GetCompositor()-> |
| 710 DemandDrawSw(canvas); | 713 DemandDrawSw(canvas); |
| 711 DidComposite(false); | 714 DidComposite(false); |
| 712 return result; | 715 return result; |
| 713 } | 716 } |
| 714 | 717 |
| 715 void BrowserViewRenderer::DidComposite(bool force_invalidate) { | 718 void BrowserViewRenderer::DidComposite(bool force_invalidate) { |
| 719 { |
| 720 base::AutoLock lock(render_thread_lock_); |
| 721 block_invalidates_ = false; |
| 722 } |
| 723 |
| 724 if (!ui_task_runner_->BelongsToCurrentThread()) { |
| 725 ui_task_runner_->PostTask( |
| 726 FROM_HERE, |
| 727 base::Bind(&BrowserViewRenderer::EnsureContinuousInvalidation, |
| 728 ui_thread_weak_ptr_, |
| 729 force_invalidate)); |
| 730 return; |
| 731 } |
| 732 |
| 716 fallback_tick_.Cancel(); | 733 fallback_tick_.Cancel(); |
| 717 block_invalidates_ = false; | |
| 718 EnsureContinuousInvalidation(force_invalidate); | 734 EnsureContinuousInvalidation(force_invalidate); |
| 719 } | 735 } |
| 720 | 736 |
| 721 std::string BrowserViewRenderer::ToString(AwDrawGLInfo* draw_info) const { | 737 std::string BrowserViewRenderer::ToString(AwDrawGLInfo* draw_info) const { |
| 722 std::string str; | 738 std::string str; |
| 723 base::StringAppendF(&str, "is_paused: %d ", is_paused_); | 739 base::StringAppendF(&str, "is_paused: %d ", is_paused_); |
| 724 base::StringAppendF(&str, "view_visible: %d ", view_visible_); | 740 base::StringAppendF(&str, "view_visible: %d ", view_visible_); |
| 725 base::StringAppendF(&str, "window_visible: %d ", window_visible_); | 741 base::StringAppendF(&str, "window_visible: %d ", window_visible_); |
| 726 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); | 742 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); |
| 727 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); | 743 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 752 base::StringAppendF(&str, | 768 base::StringAppendF(&str, |
| 753 "surface width height: [%d %d] ", | 769 "surface width height: [%d %d] ", |
| 754 draw_info->width, | 770 draw_info->width, |
| 755 draw_info->height); | 771 draw_info->height); |
| 756 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 772 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
| 757 } | 773 } |
| 758 return str; | 774 return str; |
| 759 } | 775 } |
| 760 | 776 |
| 761 } // namespace android_webview | 777 } // namespace android_webview |
| OLD | NEW |