OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/in_process_view_renderer.h" | 5 #include "android_webview/browser/in_process_view_renderer.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "android_webview/browser/aw_gl_surface.h" | 9 #include "android_webview/browser/aw_gl_surface.h" |
10 #include "android_webview/browser/scoped_app_gl_state_restore.h" | 10 #include "android_webview/browser/scoped_app_gl_state_restore.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 content::WebContents* web_contents) | 205 content::WebContents* web_contents) |
206 : client_(client), | 206 : client_(client), |
207 java_helper_(java_helper), | 207 java_helper_(java_helper), |
208 web_contents_(web_contents), | 208 web_contents_(web_contents), |
209 compositor_(NULL), | 209 compositor_(NULL), |
210 visible_(false), | 210 visible_(false), |
211 dip_scale_(0.0), | 211 dip_scale_(0.0), |
212 page_scale_factor_(1.0), | 212 page_scale_factor_(1.0), |
213 on_new_picture_enable_(false), | 213 on_new_picture_enable_(false), |
214 compositor_needs_continuous_invalidate_(false), | 214 compositor_needs_continuous_invalidate_(false), |
215 need_fast_invalidate_(false), | |
216 block_invalidates_(false), | 215 block_invalidates_(false), |
217 width_(0), | 216 width_(0), |
218 height_(0), | 217 height_(0), |
219 attached_to_window_(false), | 218 attached_to_window_(false), |
220 hardware_initialized_(false), | 219 hardware_initialized_(false), |
221 hardware_failed_(false), | 220 hardware_failed_(false), |
222 last_egl_context_(NULL), | 221 last_egl_context_(NULL), |
223 manager_key_(g_view_renderer_manager.Get().NullKey()) { | 222 manager_key_(g_view_renderer_manager.Get().NullKey()) { |
224 CHECK(web_contents_); | 223 CHECK(web_contents_); |
225 web_contents_->SetUserData(kUserDataKey, new UserData(this)); | 224 web_contents_->SetUserData(kUserDataKey, new UserData(this)); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 void InProcessViewRenderer::SetContinuousInvalidate(bool invalidate) { | 632 void InProcessViewRenderer::SetContinuousInvalidate(bool invalidate) { |
634 if (compositor_needs_continuous_invalidate_ == invalidate) | 633 if (compositor_needs_continuous_invalidate_ == invalidate) |
635 return; | 634 return; |
636 | 635 |
637 TRACE_EVENT_INSTANT1("android_webview", | 636 TRACE_EVENT_INSTANT1("android_webview", |
638 "InProcessViewRenderer::SetContinuousInvalidate", | 637 "InProcessViewRenderer::SetContinuousInvalidate", |
639 TRACE_EVENT_SCOPE_THREAD, | 638 TRACE_EVENT_SCOPE_THREAD, |
640 "invalidate", | 639 "invalidate", |
641 invalidate); | 640 invalidate); |
642 compositor_needs_continuous_invalidate_ = invalidate; | 641 compositor_needs_continuous_invalidate_ = invalidate; |
643 need_fast_invalidate_ = compositor_needs_continuous_invalidate_; | |
644 EnsureContinuousInvalidation(NULL, false); | 642 EnsureContinuousInvalidation(NULL, false); |
645 } | 643 } |
646 | 644 |
647 void InProcessViewRenderer::SetDipScale(float dip_scale) { | 645 void InProcessViewRenderer::SetDipScale(float dip_scale) { |
648 dip_scale_ = dip_scale; | 646 dip_scale_ = dip_scale; |
649 CHECK(dip_scale_ > 0); | 647 CHECK(dip_scale_ > 0); |
650 } | 648 } |
651 | 649 |
652 void InProcessViewRenderer::SetPageScaleFactor(float page_scale_factor) { | 650 void InProcessViewRenderer::SetPageScaleFactor(float page_scale_factor) { |
653 page_scale_factor_ = page_scale_factor; | 651 page_scale_factor_ = page_scale_factor; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 738 |
741 // Unretained here is safe because the callback is cancelled when | 739 // Unretained here is safe because the callback is cancelled when |
742 // |fallback_tick_| is destroyed. | 740 // |fallback_tick_| is destroyed. |
743 fallback_tick_.Reset(base::Bind(&InProcessViewRenderer::FallbackTickFired, | 741 fallback_tick_.Reset(base::Bind(&InProcessViewRenderer::FallbackTickFired, |
744 base::Unretained(this))); | 742 base::Unretained(this))); |
745 | 743 |
746 // No need to reschedule fallback tick if compositor does not need to be | 744 // No need to reschedule fallback tick if compositor does not need to be |
747 // ticked. This can happen if this is reached because | 745 // ticked. This can happen if this is reached because |
748 // invalidate_ignore_compositor is true. | 746 // invalidate_ignore_compositor is true. |
749 if (compositor_needs_continuous_invalidate_) { | 747 if (compositor_needs_continuous_invalidate_) { |
750 int64 delay_in_ms = kFallbackTickTimeoutInMilliseconds; | |
751 if (need_fast_invalidate_) { | |
752 TRACE_EVENT_INSTANT0( | |
753 "android_webview", "FastFallbackTick", TRACE_EVENT_SCOPE_THREAD); | |
754 delay_in_ms = 0; | |
755 need_fast_invalidate_ = false; | |
756 } | |
757 base::MessageLoop::current()->PostDelayedTask( | 748 base::MessageLoop::current()->PostDelayedTask( |
758 FROM_HERE, | 749 FROM_HERE, |
759 fallback_tick_.callback(), | 750 fallback_tick_.callback(), |
760 base::TimeDelta::FromMilliseconds(delay_in_ms)); | 751 base::TimeDelta::FromMilliseconds( |
| 752 kFallbackTickTimeoutInMilliseconds)); |
761 } | 753 } |
762 } | 754 } |
763 } | 755 } |
764 | 756 |
765 void InProcessViewRenderer::FallbackTickFired() { | 757 void InProcessViewRenderer::FallbackTickFired() { |
766 TRACE_EVENT1("android_webview", | 758 TRACE_EVENT1("android_webview", |
767 "InProcessViewRenderer::FallbackTickFired", | 759 "InProcessViewRenderer::FallbackTickFired", |
768 "compositor_needs_continuous_invalidate_", | 760 "compositor_needs_continuous_invalidate_", |
769 compositor_needs_continuous_invalidate_); | 761 compositor_needs_continuous_invalidate_); |
770 | 762 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 base::StringAppendF(&str, | 812 base::StringAppendF(&str, |
821 "surface width height: [%d %d] ", | 813 "surface width height: [%d %d] ", |
822 draw_info->width, | 814 draw_info->width, |
823 draw_info->height); | 815 draw_info->height); |
824 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 816 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
825 } | 817 } |
826 return str; | 818 return str; |
827 } | 819 } |
828 | 820 |
829 } // namespace android_webview | 821 } // namespace android_webview |
OLD | NEW |