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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 SkColor color) { | 771 SkColor color) { |
772 if (cached_background_color_ == color) | 772 if (cached_background_color_ == color) |
773 return; | 773 return; |
774 | 774 |
775 cached_background_color_ = color; | 775 cached_background_color_ = color; |
776 if (content_view_core_) | 776 if (content_view_core_) |
777 content_view_core_->OnBackgroundColorChanged(color); | 777 content_view_core_->OnBackgroundColorChanged(color); |
778 } | 778 } |
779 | 779 |
780 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames(bool enabled) { | 780 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames(bool enabled) { |
781 DCHECK(using_browser_compositor_); | |
782 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames", | 781 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames", |
783 "enabled", enabled); | 782 "enabled", enabled); |
784 if (enabled) | 783 if (enabled) |
785 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); | 784 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); |
786 else | 785 else |
787 outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME; | 786 outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME; |
788 } | 787 } |
789 | 788 |
790 void RenderWidgetHostViewAndroid::OnStartContentIntent( | 789 void RenderWidgetHostViewAndroid::OnStartContentIntent( |
791 const GURL& content_url) { | 790 const GURL& content_url) { |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1479 void RenderWidgetHostViewAndroid::HideInternal( | 1478 void RenderWidgetHostViewAndroid::HideInternal( |
1480 bool hide_frontbuffer, | 1479 bool hide_frontbuffer, |
1481 bool stop_observing_root_window) { | 1480 bool stop_observing_root_window) { |
1482 if (hide_frontbuffer) { | 1481 if (hide_frontbuffer) { |
1483 if (layer_.get() && locks_on_frame_count_ == 0) | 1482 if (layer_.get() && locks_on_frame_count_ == 0) |
1484 layer_->SetHideLayerAndSubtree(true); | 1483 layer_->SetHideLayerAndSubtree(true); |
1485 | 1484 |
1486 frame_evictor_->SetVisible(false); | 1485 frame_evictor_->SetVisible(false); |
1487 } | 1486 } |
1488 | 1487 |
1489 if (stop_observing_root_window) | 1488 if (stop_observing_root_window) |
jdduke (slow)
2015/03/30 22:30:42
Bo pointed out that WebView apps might conceivably
| |
1490 StopObservingRootWindow(); | 1489 StopObservingRootWindow(); |
1491 | 1490 |
1492 if (!host_ || host_->is_hidden()) | 1491 if (!host_ || host_->is_hidden()) |
1493 return; | 1492 return; |
1494 | 1493 |
1495 if (overscroll_controller_) | 1494 if (overscroll_controller_) |
1496 overscroll_controller_->Disable(); | 1495 overscroll_controller_->Disable(); |
1497 | 1496 |
1498 // We don't know if we will ever get a frame if we are hiding the renderer, so | 1497 // We don't know if we will ever get a frame if we are hiding the renderer, so |
1499 // we need to cancel all requests | 1498 // we need to cancel all requests |
(...skipping 24 matching lines...) Expand all Loading... | |
1524 | 1523 |
1525 if (!layer_.get()) | 1524 if (!layer_.get()) |
1526 return; | 1525 return; |
1527 | 1526 |
1528 content_view_core_->RemoveLayer(layer_); | 1527 content_view_core_->RemoveLayer(layer_); |
1529 if (overscroll_controller_) | 1528 if (overscroll_controller_) |
1530 overscroll_controller_->Disable(); | 1529 overscroll_controller_->Disable(); |
1531 } | 1530 } |
1532 | 1531 |
1533 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32 requests) { | 1532 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32 requests) { |
1534 // The synchronous compositor does not requre BeginFrame messages. | |
1535 if (!using_browser_compositor_) | |
1536 requests &= FLUSH_INPUT; | |
1537 | |
1538 bool should_request_vsync = !outstanding_vsync_requests_ && requests; | 1533 bool should_request_vsync = !outstanding_vsync_requests_ && requests; |
1539 outstanding_vsync_requests_ |= requests; | 1534 outstanding_vsync_requests_ |= requests; |
1540 | 1535 |
1541 // If the host has been hidden, defer vsync requests until it is shown | 1536 // If the host has been hidden, defer vsync requests until it is shown |
1542 // again via |Show()|. | 1537 // again via |Show()|. |
1543 if (!host_ || host_->is_hidden()) | 1538 if (!host_ || host_->is_hidden()) |
1544 return; | 1539 return; |
1545 | 1540 |
1546 // Note that if we're not currently observing the root window, outstanding | 1541 // Note that if we're not currently observing the root window, outstanding |
1547 // vsync requests will be pushed if/when we resume observing in | 1542 // vsync requests will be pushed if/when we resume observing in |
(...skipping 27 matching lines...) Expand all Loading... | |
1575 return; | 1570 return; |
1576 | 1571 |
1577 observing_root_window_ = false; | 1572 observing_root_window_ = false; |
1578 content_view_core_->GetWindowAndroid()->RemoveObserver(this); | 1573 content_view_core_->GetWindowAndroid()->RemoveObserver(this); |
1579 } | 1574 } |
1580 | 1575 |
1581 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, | 1576 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, |
1582 base::TimeDelta vsync_period) { | 1577 base::TimeDelta vsync_period) { |
1583 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", | 1578 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", |
1584 "frame_time_us", frame_time.ToInternalValue()); | 1579 "frame_time_us", frame_time.ToInternalValue()); |
1585 base::TimeTicks display_time = frame_time + vsync_period; | |
1586 | 1580 |
1587 base::TimeTicks deadline = | 1581 if (using_browser_compositor_) { |
1588 display_time - host_->GetEstimatedBrowserCompositeTime(); | 1582 base::TimeTicks display_time = frame_time + vsync_period; |
1589 | 1583 |
1590 host_->Send(new ViewMsg_BeginFrame( | 1584 base::TimeTicks deadline = |
1591 host_->GetRoutingID(), | 1585 display_time - host_->GetEstimatedBrowserCompositeTime(); |
1592 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, | 1586 |
1593 vsync_period, cc::BeginFrameArgs::NORMAL))); | 1587 host_->Send(new ViewMsg_BeginFrame( |
1588 host_->GetRoutingID(), | |
1589 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, | |
1590 vsync_period, cc::BeginFrameArgs::NORMAL))); | |
1591 } else { | |
1592 SynchronousCompositorImpl* compositor = SynchronousCompositorImpl::FromID( | |
jdduke (slow)
2015/04/01 16:01:14
Hmm, the other places we use SynchronousCompositor
sunnyps
2015/04/01 19:53:02
Done.
| |
1593 host_->GetProcess()->GetID(), host_->GetRoutingID()); | |
1594 | |
jdduke (slow)
2015/04/01 16:01:15
Can you add a note here briefly mentioning why the
sunnyps
2015/04/01 19:53:02
Done.
| |
1595 compositor->SendBeginFrame(cc::BeginFrameArgs::Create( | |
jdduke (slow)
2015/04/01 16:01:15
I'm sure this has already been covered, but why is
sunnyps
2015/04/01 19:53:01
Done.
| |
1596 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period, | |
1597 cc::BeginFrameArgs::NORMAL)); | |
1598 } | |
1594 } | 1599 } |
1595 | 1600 |
1596 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { | 1601 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { |
1597 bool needs_animate = false; | 1602 bool needs_animate = false; |
1598 if (overscroll_controller_) { | 1603 if (overscroll_controller_) { |
1599 needs_animate |= overscroll_controller_->Animate( | 1604 needs_animate |= overscroll_controller_->Animate( |
1600 frame_time, content_view_core_->GetLayer().get()); | 1605 frame_time, content_view_core_->GetLayer().get()); |
1601 } | 1606 } |
1602 if (selection_controller_) | 1607 if (selection_controller_) |
1603 needs_animate |= selection_controller_->Animate(frame_time); | 1608 needs_animate |= selection_controller_->Animate(frame_time); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1918 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1923 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); |
1919 overscroll_controller_.reset(); | 1924 overscroll_controller_.reset(); |
1920 } | 1925 } |
1921 | 1926 |
1922 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1927 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
1923 base::TimeDelta vsync_period) { | 1928 base::TimeDelta vsync_period) { |
1924 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); | 1929 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); |
1925 if (!host_ || host_->is_hidden()) | 1930 if (!host_ || host_->is_hidden()) |
1926 return; | 1931 return; |
1927 | 1932 |
1928 const uint32 current_vsync_requests = outstanding_vsync_requests_; | 1933 if (outstanding_vsync_requests_ & FLUSH_INPUT) { |
1929 outstanding_vsync_requests_ = 0; | 1934 outstanding_vsync_requests_ &= ~FLUSH_INPUT; |
1935 host_->FlushInput(); | |
1936 } | |
1930 | 1937 |
1931 if (current_vsync_requests & FLUSH_INPUT) | 1938 if (outstanding_vsync_requests_ & BEGIN_FRAME || |
1932 host_->FlushInput(); | 1939 outstanding_vsync_requests_ & PERSISTENT_BEGIN_FRAME) { |
1933 | 1940 outstanding_vsync_requests_ &= ~BEGIN_FRAME; |
1934 if (current_vsync_requests & BEGIN_FRAME || | |
1935 current_vsync_requests & PERSISTENT_BEGIN_FRAME) { | |
1936 SendBeginFrame(frame_time, vsync_period); | 1941 SendBeginFrame(frame_time, vsync_period); |
1937 } | 1942 } |
1938 | 1943 |
1939 if (current_vsync_requests & PERSISTENT_BEGIN_FRAME) | 1944 // This allows for SendBeginFrame to modify outstanding_vsync_requests. |
jdduke (slow)
2015/04/01 16:01:14
"allows for SendBeginFrame and FlushInput"
sunnyps
2015/04/01 19:53:02
Done.
| |
1940 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); | 1945 uint32 outstanding_vsync_requests = outstanding_vsync_requests_; |
1946 outstanding_vsync_requests_ = 0; | |
1947 RequestVSyncUpdate(outstanding_vsync_requests); | |
1941 } | 1948 } |
1942 | 1949 |
1943 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) { | 1950 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) { |
1944 if (Animate(begin_frame_time)) | 1951 if (Animate(begin_frame_time)) |
1945 SetNeedsAnimate(); | 1952 SetNeedsAnimate(); |
1946 } | 1953 } |
1947 | 1954 |
1948 void RenderWidgetHostViewAndroid::OnActivityPaused() { | 1955 void RenderWidgetHostViewAndroid::OnActivityPaused() { |
1949 TRACE_EVENT0("browser", "RenderWidgetHostViewAndroid::OnActivityPaused"); | 1956 TRACE_EVENT0("browser", "RenderWidgetHostViewAndroid::OnActivityPaused"); |
1950 DCHECK(is_showing_); | 1957 DCHECK(is_showing_); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2099 results->orientationAngle = display.RotationAsDegree(); | 2106 results->orientationAngle = display.RotationAsDegree(); |
2100 results->orientationType = | 2107 results->orientationType = |
2101 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2108 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
2102 gfx::DeviceDisplayInfo info; | 2109 gfx::DeviceDisplayInfo info; |
2103 results->depth = info.GetBitsPerPixel(); | 2110 results->depth = info.GetBitsPerPixel(); |
2104 results->depthPerComponent = info.GetBitsPerComponent(); | 2111 results->depthPerComponent = info.GetBitsPerComponent(); |
2105 results->isMonochrome = (results->depthPerComponent == 0); | 2112 results->isMonochrome = (results->depthPerComponent == 0); |
2106 } | 2113 } |
2107 | 2114 |
2108 } // namespace content | 2115 } // namespace content |
OLD | NEW |