OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 ime_adapter_android_(this), | 385 ime_adapter_android_(this), |
386 cached_background_color_(SK_ColorWHITE), | 386 cached_background_color_(SK_ColorWHITE), |
387 last_output_surface_id_(kUndefinedOutputSurfaceId), | 387 last_output_surface_id_(kUndefinedOutputSurfaceId), |
388 gesture_provider_(CreateGestureProviderConfig(), this), | 388 gesture_provider_(CreateGestureProviderConfig(), this), |
389 stylus_text_selector_(this), | 389 stylus_text_selector_(this), |
390 accelerated_surface_route_id_(0), | 390 accelerated_surface_route_id_(0), |
391 using_browser_compositor_(CompositorImpl::IsInitialized()), | 391 using_browser_compositor_(CompositorImpl::IsInitialized()), |
392 frame_evictor_(new DelegatedFrameEvictor(this)), | 392 frame_evictor_(new DelegatedFrameEvictor(this)), |
393 locks_on_frame_count_(0), | 393 locks_on_frame_count_(0), |
394 observing_root_window_(false), | 394 observing_root_window_(false), |
395 should_unlock_surface_on_visibility_lost_or_activity_resumed_(false), | |
395 weak_ptr_factory_(this) { | 396 weak_ptr_factory_(this) { |
396 host_->SetView(this); | 397 host_->SetView(this); |
397 SetContentViewCore(content_view_core); | 398 SetContentViewCore(content_view_core); |
398 } | 399 } |
399 | 400 |
400 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 401 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
401 SetContentViewCore(NULL); | 402 SetContentViewCore(NULL); |
402 DCHECK(ack_callbacks_.empty()); | 403 DCHECK(ack_callbacks_.empty()); |
403 DCHECK(readbacks_waiting_for_frame_.empty()); | 404 DCHECK(readbacks_waiting_for_frame_.empty()); |
404 if (resource_collection_.get()) | 405 if (resource_collection_.get()) |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 return; | 702 return; |
702 // Validate the coordinates are within the viewport. | 703 // Validate the coordinates are within the viewport. |
703 gfx::Size viewport_size = content_view_core_->GetViewportSizeDip(); | 704 gfx::Size viewport_size = content_view_core_->GetViewportSizeDip(); |
704 if (x_dip < 0 || x_dip > viewport_size.width() || | 705 if (x_dip < 0 || x_dip > viewport_size.width() || |
705 y_dip < 0 || y_dip > viewport_size.height()) | 706 y_dip < 0 || y_dip > viewport_size.height()) |
706 return; | 707 return; |
707 content_view_core_->OnShowUnhandledTapUIIfNeeded(x_dip, y_dip); | 708 content_view_core_->OnShowUnhandledTapUIIfNeeded(x_dip, y_dip); |
708 } | 709 } |
709 | 710 |
710 void RenderWidgetHostViewAndroid::ReleaseLocksOnSurface() { | 711 void RenderWidgetHostViewAndroid::ReleaseLocksOnSurface() { |
712 should_unlock_surface_on_visibility_lost_or_activity_resumed_ = false; | |
711 if (!frame_evictor_->HasFrame()) { | 713 if (!frame_evictor_->HasFrame()) { |
712 DCHECK_EQ(locks_on_frame_count_, 0u); | 714 DCHECK_EQ(locks_on_frame_count_, 0u); |
713 return; | 715 return; |
714 } | 716 } |
715 while (locks_on_frame_count_ > 0) { | 717 while (locks_on_frame_count_ > 0) { |
716 UnlockCompositingSurface(); | 718 UnlockCompositingSurface(); |
717 } | 719 } |
718 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 720 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); |
719 } | 721 } |
720 | 722 |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1874 overscroll_controller_ = CreateOverscrollController(content_view_core_); | 1876 overscroll_controller_ = CreateOverscrollController(content_view_core_); |
1875 } | 1877 } |
1876 | 1878 |
1877 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1879 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
1878 DCHECK(content_view_core_); | 1880 DCHECK(content_view_core_); |
1879 DCHECK(using_browser_compositor_); | 1881 DCHECK(using_browser_compositor_); |
1880 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1882 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); |
1881 overscroll_controller_.reset(); | 1883 overscroll_controller_.reset(); |
1882 } | 1884 } |
1883 | 1885 |
1886 void RenderWidgetHostViewAndroid::OnVisibilityChanged(bool visible) { | |
1887 if (visible) | |
jdduke (slow)
2015/03/16 16:54:12
We never see this callback, as we stop observing t
no sievers
2015/03/17 21:37:47
Maybe that's ok. If somebody called Hide() we alre
| |
1888 return; | |
1889 | |
1890 if (should_unlock_surface_on_visibility_lost_or_activity_resumed_) { | |
no sievers
2015/03/17 21:37:47
nit: maybe |surface_locked_for_paused_activity_| o
| |
1891 should_unlock_surface_on_visibility_lost_or_activity_resumed_ = false; | |
1892 DCHECK_GT(locks_on_frame_count_, 0U); | |
1893 UnlockCompositingSurface(); | |
1894 } | |
1895 } | |
1896 | |
1884 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1897 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
1885 base::TimeDelta vsync_period) { | 1898 base::TimeDelta vsync_period) { |
1886 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); | 1899 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); |
1887 if (!host_) | 1900 if (!host_) |
1888 return; | 1901 return; |
1889 | 1902 |
1890 const uint32 current_vsync_requests = outstanding_vsync_requests_; | 1903 const uint32 current_vsync_requests = outstanding_vsync_requests_; |
1891 outstanding_vsync_requests_ = 0; | 1904 outstanding_vsync_requests_ = 0; |
1892 | 1905 |
1893 if (current_vsync_requests & FLUSH_INPUT) | 1906 if (current_vsync_requests & FLUSH_INPUT) |
1894 host_->FlushInput(); | 1907 host_->FlushInput(); |
1895 | 1908 |
1896 if (current_vsync_requests & BEGIN_FRAME || | 1909 if (current_vsync_requests & BEGIN_FRAME || |
1897 current_vsync_requests & PERSISTENT_BEGIN_FRAME) { | 1910 current_vsync_requests & PERSISTENT_BEGIN_FRAME) { |
1898 SendBeginFrame(frame_time, vsync_period); | 1911 SendBeginFrame(frame_time, vsync_period); |
1899 } | 1912 } |
1900 | 1913 |
1901 if (current_vsync_requests & PERSISTENT_BEGIN_FRAME) | 1914 if (current_vsync_requests & PERSISTENT_BEGIN_FRAME) |
1902 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); | 1915 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); |
1903 } | 1916 } |
1904 | 1917 |
1905 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) { | 1918 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) { |
1906 if (Animate(begin_frame_time)) | 1919 if (Animate(begin_frame_time)) |
1907 SetNeedsAnimate(); | 1920 SetNeedsAnimate(); |
1908 } | 1921 } |
1909 | 1922 |
1923 void RenderWidgetHostViewAndroid::OnActivityResumed() { | |
1924 if (should_unlock_surface_on_visibility_lost_or_activity_resumed_) { | |
1925 should_unlock_surface_on_visibility_lost_or_activity_resumed_ = false; | |
1926 DCHECK_GT(locks_on_frame_count_, 0U); | |
1927 UnlockCompositingSurface(); | |
1928 } | |
1929 } | |
1930 | |
1931 void RenderWidgetHostViewAndroid::OnActivityPaused() { | |
1932 if (IsShowing()) { | |
1933 DCHECK(!should_unlock_surface_on_visibility_lost_or_activity_resumed_); | |
1934 should_unlock_surface_on_visibility_lost_or_activity_resumed_ = true; | |
1935 LockCompositingSurface(); | |
1936 } | |
1937 } | |
1938 | |
1910 void RenderWidgetHostViewAndroid::OnLostResources() { | 1939 void RenderWidgetHostViewAndroid::OnLostResources() { |
1911 ReleaseLocksOnSurface(); | 1940 ReleaseLocksOnSurface(); |
1912 if (layer_.get()) | 1941 if (layer_.get()) |
1913 DestroyDelegatedContent(); | 1942 DestroyDelegatedContent(); |
1914 DCHECK(ack_callbacks_.empty()); | 1943 DCHECK(ack_callbacks_.empty()); |
1915 // We should not loose a frame if we have readback requests pending. | 1944 // We should not loose a frame if we have readback requests pending. |
1916 DCHECK(readbacks_waiting_for_frame_.empty()); | 1945 DCHECK(readbacks_waiting_for_frame_.empty()); |
1917 } | 1946 } |
1918 | 1947 |
1919 // static | 1948 // static |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2047 results->orientationAngle = display.RotationAsDegree(); | 2076 results->orientationAngle = display.RotationAsDegree(); |
2048 results->orientationType = | 2077 results->orientationType = |
2049 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2078 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
2050 gfx::DeviceDisplayInfo info; | 2079 gfx::DeviceDisplayInfo info; |
2051 results->depth = info.GetBitsPerPixel(); | 2080 results->depth = info.GetBitsPerPixel(); |
2052 results->depthPerComponent = info.GetBitsPerComponent(); | 2081 results->depthPerComponent = info.GetBitsPerComponent(); |
2053 results->isMonochrome = (results->depthPerComponent == 0); | 2082 results->isMonochrome = (results->depthPerComponent == 0); |
2054 } | 2083 } |
2055 | 2084 |
2056 } // namespace content | 2085 } // namespace content |
OLD | NEW |