Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: android_webview/browser/browser_view_renderer.cc

Issue 271163002: aw: Fix lost invalidate while playing video (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | android_webview/native/aw_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 base::AutoLock lock(render_thread_lock_);
667 block_invalidates_ = compositor_needs_continuous_invalidate_; 668 block_invalidates_ = compositor_needs_continuous_invalidate_;
668 669
669 // Unretained here is safe because the callback is cancelled when 670 // Unretained here is safe because the callback is cancelled when
670 // |fallback_tick_| is destroyed. 671 // |fallback_tick_| is destroyed.
671 fallback_tick_.Reset(base::Bind(&BrowserViewRenderer::FallbackTickFired, 672 fallback_tick_.Reset(base::Bind(&BrowserViewRenderer::FallbackTickFired,
672 base::Unretained(this))); 673 base::Unretained(this)));
673 674
674 // No need to reschedule fallback tick if compositor does not need to be 675 // 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 676 // ticked. This can happen if this is reached because force_invalidate is
676 // true. 677 // true.
(...skipping 29 matching lines...) Expand all
706 707
707 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) { 708 bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) {
708 DCHECK(has_compositor_); 709 DCHECK(has_compositor_);
709 bool result = shared_renderer_state_->GetCompositor()-> 710 bool result = shared_renderer_state_->GetCompositor()->
710 DemandDrawSw(canvas); 711 DemandDrawSw(canvas);
711 DidComposite(false); 712 DidComposite(false);
712 return result; 713 return result;
713 } 714 }
714 715
715 void BrowserViewRenderer::DidComposite(bool force_invalidate) { 716 void BrowserViewRenderer::DidComposite(bool force_invalidate) {
716 fallback_tick_.Cancel(); 717 {
717 block_invalidates_ = false; 718 base::AutoLock lock(render_thread_lock_);
718 EnsureContinuousInvalidation(force_invalidate); 719 fallback_tick_.Cancel();
mkosiba (inactive) 2014/05/12 14:29:51 this doesn't look threadsafe: from base/cancellab
boliu 2014/05/12 15:34:49 Hmm, good point. There is nothing protecting runni
720 block_invalidates_ = false;
721 }
722
723 if (ui_task_runner_->BelongsToCurrentThread()) {
724 EnsureContinuousInvalidation(force_invalidate);
725 return;
726 }
727 ui_task_runner_->PostTask(
728 FROM_HERE,
729 base::Bind(&BrowserViewRenderer::EnsureContinuousInvalidation,
730 ui_thread_weak_ptr_,
731 force_invalidate));
719 } 732 }
720 733
721 std::string BrowserViewRenderer::ToString(AwDrawGLInfo* draw_info) const { 734 std::string BrowserViewRenderer::ToString(AwDrawGLInfo* draw_info) const {
722 std::string str; 735 std::string str;
723 base::StringAppendF(&str, "is_paused: %d ", is_paused_); 736 base::StringAppendF(&str, "is_paused: %d ", is_paused_);
724 base::StringAppendF(&str, "view_visible: %d ", view_visible_); 737 base::StringAppendF(&str, "view_visible: %d ", view_visible_);
725 base::StringAppendF(&str, "window_visible: %d ", window_visible_); 738 base::StringAppendF(&str, "window_visible: %d ", window_visible_);
726 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); 739 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_);
727 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); 740 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_);
728 base::StringAppendF(&str, 741 base::StringAppendF(&str,
(...skipping 23 matching lines...) Expand all
752 base::StringAppendF(&str, 765 base::StringAppendF(&str,
753 "surface width height: [%d %d] ", 766 "surface width height: [%d %d] ",
754 draw_info->width, 767 draw_info->width,
755 draw_info->height); 768 draw_info->height);
756 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); 769 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer);
757 } 770 }
758 return str; 771 return str;
759 } 772 }
760 773
761 } // namespace android_webview 774 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | android_webview/native/aw_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698