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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 SkColor color) { | 803 SkColor color) { |
804 if (cached_background_color_ == color) | 804 if (cached_background_color_ == color) |
805 return; | 805 return; |
806 | 806 |
807 cached_background_color_ = color; | 807 cached_background_color_ = color; |
808 if (content_view_core_) | 808 if (content_view_core_) |
809 content_view_core_->OnBackgroundColorChanged(color); | 809 content_view_core_->OnBackgroundColorChanged(color); |
810 } | 810 } |
811 | 811 |
812 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames(bool enabled) { | 812 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames(bool enabled) { |
813 DCHECK(using_browser_compositor_); | |
814 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames", | 813 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames", |
815 "enabled", enabled); | 814 "enabled", enabled); |
816 if (enabled) | 815 if (enabled) |
817 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); | 816 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); |
818 else | 817 else |
819 outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME; | 818 outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME; |
820 } | 819 } |
821 | 820 |
822 void RenderWidgetHostViewAndroid::OnStartContentIntent( | 821 void RenderWidgetHostViewAndroid::OnStartContentIntent( |
823 const GURL& content_url) { | 822 const GURL& content_url) { |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 | 1504 |
1506 if (!layer_.get()) | 1505 if (!layer_.get()) |
1507 return; | 1506 return; |
1508 | 1507 |
1509 content_view_core_->RemoveLayer(layer_); | 1508 content_view_core_->RemoveLayer(layer_); |
1510 if (overscroll_controller_) | 1509 if (overscroll_controller_) |
1511 overscroll_controller_->Disable(); | 1510 overscroll_controller_->Disable(); |
1512 } | 1511 } |
1513 | 1512 |
1514 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32 requests) { | 1513 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32 requests) { |
1515 // The synchronous compositor does not requre BeginFrame messages. | |
1516 if (!using_browser_compositor_) | |
1517 requests &= FLUSH_INPUT; | |
1518 | |
1519 bool should_request_vsync = !outstanding_vsync_requests_ && requests; | 1514 bool should_request_vsync = !outstanding_vsync_requests_ && requests; |
1520 outstanding_vsync_requests_ |= requests; | 1515 outstanding_vsync_requests_ |= requests; |
1521 // Note that if we're not currently observing the root window, outstanding | 1516 // Note that if we're not currently observing the root window, outstanding |
1522 // vsync requests will be pushed if/when we resume observing in | 1517 // vsync requests will be pushed if/when we resume observing in |
1523 // |StartObservingRootWindow()|. | 1518 // |StartObservingRootWindow()|. |
1524 if (observing_root_window_ && should_request_vsync) | 1519 if (observing_root_window_ && should_request_vsync) |
1525 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); | 1520 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); |
1526 } | 1521 } |
1527 | 1522 |
1528 void RenderWidgetHostViewAndroid::StartObservingRootWindow() { | 1523 void RenderWidgetHostViewAndroid::StartObservingRootWindow() { |
(...skipping 20 matching lines...) Expand all Loading... |
1549 return; | 1544 return; |
1550 | 1545 |
1551 observing_root_window_ = false; | 1546 observing_root_window_ = false; |
1552 content_view_core_->GetWindowAndroid()->RemoveObserver(this); | 1547 content_view_core_->GetWindowAndroid()->RemoveObserver(this); |
1553 } | 1548 } |
1554 | 1549 |
1555 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, | 1550 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, |
1556 base::TimeDelta vsync_period) { | 1551 base::TimeDelta vsync_period) { |
1557 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", | 1552 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", |
1558 "frame_time_us", frame_time.ToInternalValue()); | 1553 "frame_time_us", frame_time.ToInternalValue()); |
1559 base::TimeTicks display_time = frame_time + vsync_period; | |
1560 | 1554 |
1561 base::TimeTicks deadline = | 1555 if (using_browser_compositor_) { |
1562 display_time - host_->GetEstimatedBrowserCompositeTime(); | 1556 base::TimeTicks display_time = frame_time + vsync_period; |
1563 | 1557 |
1564 host_->Send(new ViewMsg_BeginFrame( | 1558 base::TimeTicks deadline = |
1565 host_->GetRoutingID(), | 1559 display_time - host_->GetEstimatedBrowserCompositeTime(); |
1566 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, | 1560 |
1567 vsync_period, cc::BeginFrameArgs::NORMAL))); | 1561 host_->Send(new ViewMsg_BeginFrame( |
| 1562 host_->GetRoutingID(), |
| 1563 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, |
| 1564 vsync_period, cc::BeginFrameArgs::NORMAL))); |
| 1565 } else { |
| 1566 SynchronousCompositorImpl* compositor = SynchronousCompositorImpl::FromID( |
| 1567 host_->GetProcess()->GetID(), host_->GetRoutingID()); |
| 1568 |
| 1569 compositor->SendBeginFrame(cc::BeginFrameArgs::Create( |
| 1570 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period, |
| 1571 cc::BeginFrameArgs::NORMAL)); |
| 1572 } |
1568 } | 1573 } |
1569 | 1574 |
1570 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { | 1575 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { |
1571 bool needs_animate = false; | 1576 bool needs_animate = false; |
1572 if (overscroll_controller_) { | 1577 if (overscroll_controller_) { |
1573 needs_animate |= overscroll_controller_->Animate( | 1578 needs_animate |= overscroll_controller_->Animate( |
1574 frame_time, content_view_core_->GetLayer().get()); | 1579 frame_time, content_view_core_->GetLayer().get()); |
1575 } | 1580 } |
1576 if (selection_controller_) | 1581 if (selection_controller_) |
1577 needs_animate |= selection_controller_->Animate(frame_time); | 1582 needs_animate |= selection_controller_->Animate(frame_time); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1885 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); |
1881 overscroll_controller_.reset(); | 1886 overscroll_controller_.reset(); |
1882 } | 1887 } |
1883 | 1888 |
1884 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1889 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
1885 base::TimeDelta vsync_period) { | 1890 base::TimeDelta vsync_period) { |
1886 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); | 1891 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); |
1887 if (!host_) | 1892 if (!host_) |
1888 return; | 1893 return; |
1889 | 1894 |
1890 const uint32 current_vsync_requests = outstanding_vsync_requests_; | 1895 if (outstanding_vsync_requests_ & FLUSH_INPUT) { |
1891 outstanding_vsync_requests_ = 0; | 1896 outstanding_vsync_requests_ &= ~FLUSH_INPUT; |
| 1897 host_->FlushInput(); |
| 1898 } |
1892 | 1899 |
1893 if (current_vsync_requests & FLUSH_INPUT) | 1900 if (outstanding_vsync_requests_ & BEGIN_FRAME || |
1894 host_->FlushInput(); | 1901 outstanding_vsync_requests_ & PERSISTENT_BEGIN_FRAME) { |
1895 | 1902 outstanding_vsync_requests_ &= ~BEGIN_FRAME; |
1896 if (current_vsync_requests & BEGIN_FRAME || | |
1897 current_vsync_requests & PERSISTENT_BEGIN_FRAME) { | |
1898 SendBeginFrame(frame_time, vsync_period); | 1903 SendBeginFrame(frame_time, vsync_period); |
1899 } | 1904 } |
1900 | 1905 |
1901 if (current_vsync_requests & PERSISTENT_BEGIN_FRAME) | 1906 // This allows for SendBeginFrame to modify outstanding_vsync_requests. |
1902 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); | 1907 uint32 outstanding_vsync_requests = outstanding_vsync_requests_; |
| 1908 outstanding_vsync_requests_ = 0; |
| 1909 RequestVSyncUpdate(outstanding_vsync_requests); |
1903 } | 1910 } |
1904 | 1911 |
1905 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) { | 1912 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) { |
1906 if (Animate(begin_frame_time)) | 1913 if (Animate(begin_frame_time)) |
1907 SetNeedsAnimate(); | 1914 SetNeedsAnimate(); |
1908 } | 1915 } |
1909 | 1916 |
1910 void RenderWidgetHostViewAndroid::OnLostResources() { | 1917 void RenderWidgetHostViewAndroid::OnLostResources() { |
1911 ReleaseLocksOnSurface(); | 1918 ReleaseLocksOnSurface(); |
1912 if (layer_.get()) | 1919 if (layer_.get()) |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 results->orientationAngle = display.RotationAsDegree(); | 2054 results->orientationAngle = display.RotationAsDegree(); |
2048 results->orientationType = | 2055 results->orientationType = |
2049 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2056 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
2050 gfx::DeviceDisplayInfo info; | 2057 gfx::DeviceDisplayInfo info; |
2051 results->depth = info.GetBitsPerPixel(); | 2058 results->depth = info.GetBitsPerPixel(); |
2052 results->depthPerComponent = info.GetBitsPerComponent(); | 2059 results->depthPerComponent = info.GetBitsPerComponent(); |
2053 results->isMonochrome = (results->depthPerComponent == 0); | 2060 results->isMonochrome = (results->depthPerComponent == 0); |
2054 } | 2061 } |
2055 | 2062 |
2056 } // namespace content | 2063 } // namespace content |
OLD | NEW |