OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1466 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1466 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
1467 return false; | 1467 return false; |
1468 } | 1468 } |
1469 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); | 1469 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); |
1470 active_tree()->FinishSwapPromises(&metadata); | 1470 active_tree()->FinishSwapPromises(&metadata); |
1471 renderer_->SwapBuffers(metadata); | 1471 renderer_->SwapBuffers(metadata); |
1472 return true; | 1472 return true; |
1473 } | 1473 } |
1474 | 1474 |
1475 void LayerTreeHostImpl::SetNeedsBeginImplFrame(bool enable) { | 1475 void LayerTreeHostImpl::SetNeedsBeginImplFrame(bool enable) { |
1476 if (output_surface_) | 1476 if (begin_frame_source_) |
1477 begin_frame_source_->SetActive(enable); | |
1478 else if (output_surface_) | |
1477 output_surface_->SetNeedsBeginImplFrame(enable); | 1479 output_surface_->SetNeedsBeginImplFrame(enable); |
1478 } | 1480 } |
1479 | 1481 |
1480 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { | 1482 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { |
1481 gfx::SizeF dip_size = | 1483 gfx::SizeF dip_size = |
1482 gfx::ScaleSize(device_viewport_size_, 1.f / device_scale_factor()); | 1484 gfx::ScaleSize(device_viewport_size_, 1.f / device_scale_factor()); |
1483 | 1485 |
1484 float top_offset = | 1486 float top_offset = |
1485 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; | 1487 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; |
1486 | 1488 |
(...skipping 28 matching lines...) Expand all Loading... | |
1515 float LayerTreeHostImpl::VerticalAdjust() const { | 1517 float LayerTreeHostImpl::VerticalAdjust() const { |
1516 if (!active_tree_->InnerViewportContainerLayer()) | 1518 if (!active_tree_->InnerViewportContainerLayer()) |
1517 return 0; | 1519 return 0; |
1518 | 1520 |
1519 return active_tree_->InnerViewportContainerLayer()->BoundsDelta().y(); | 1521 return active_tree_->InnerViewportContainerLayer()->BoundsDelta().y(); |
1520 } | 1522 } |
1521 | 1523 |
1522 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1524 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1523 if (resource_provider_) | 1525 if (resource_provider_) |
1524 resource_provider_->DidLoseOutputSurface(); | 1526 resource_provider_->DidLoseOutputSurface(); |
1527 if (begin_frame_source_) | |
1528 begin_frame_source_->SetActive(false); | |
1525 // TODO(jamesr): The renderer_ check is needed to make some of the | 1529 // TODO(jamesr): The renderer_ check is needed to make some of the |
1526 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1530 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
1527 // important) in production. We should adjust the test to not need this. | 1531 // important) in production. We should adjust the test to not need this. |
1528 if (renderer_) | 1532 if (renderer_) |
1529 client_->DidLoseOutputSurfaceOnImplThread(); | 1533 client_->DidLoseOutputSurfaceOnImplThread(); |
1530 #ifndef NDEBUG | 1534 #ifndef NDEBUG |
1531 did_lose_called_ = true; | 1535 did_lose_called_ = true; |
1532 #endif | 1536 #endif |
1533 } | 1537 } |
1534 | 1538 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1828 return false; | 1832 return false; |
1829 | 1833 |
1830 if (settings_.impl_side_painting) { | 1834 if (settings_.impl_side_painting) { |
1831 CreateAndSetTileManager( | 1835 CreateAndSetTileManager( |
1832 resource_provider.get(), | 1836 resource_provider.get(), |
1833 output_surface->context_provider().get(), | 1837 output_surface->context_provider().get(), |
1834 GetRendererCapabilities().using_map_image, | 1838 GetRendererCapabilities().using_map_image, |
1835 GetRendererCapabilities().allow_rasterize_on_demand); | 1839 GetRendererCapabilities().allow_rasterize_on_demand); |
1836 } | 1840 } |
1837 | 1841 |
1838 // Setup BeginImplFrameEmulation if it's not supported natively | 1842 if (!settings_.throttle_frame_production) { |
1839 if (!settings_.begin_impl_frame_scheduling_enabled) { | 1843 // Disable VSync |
1844 output_surface->SetThrottleFrameProduction(false); | |
Sami
2014/03/14 15:34:58
Should this also disable the swap limit in the sch
| |
1845 } else if (!settings_.begin_impl_frame_scheduling_enabled) { | |
1846 // Setup BeginImplFrameEmulation if it's not supported natively | |
1840 const base::TimeDelta display_refresh_interval = | 1847 const base::TimeDelta display_refresh_interval = |
1841 base::TimeDelta::FromMicroseconds( | 1848 base::TimeDelta::FromMicroseconds( |
1842 base::Time::kMicrosecondsPerSecond / | 1849 base::Time::kMicrosecondsPerSecond / |
1843 settings_.refresh_rate); | 1850 settings_.refresh_rate); |
1844 | 1851 |
1845 output_surface->InitializeBeginImplFrameEmulation( | 1852 begin_frame_source_.reset(new BeginFrameSource( |
1846 proxy_->ImplThreadTaskRunner(), | 1853 display_refresh_interval, proxy_->ImplThreadTaskRunner())); |
1847 settings_.throttle_frame_production, | 1854 |
1848 display_refresh_interval); | 1855 begin_frame_source_->SetClient(this); |
1856 begin_frame_source_->SetDeadlineAdjustment( | |
1857 capabilities_.adjust_deadline_for_parent | |
1858 ? BeginFrameArgs::DefaultDeadlineAdjustment() | |
1859 : base::TimeDelta()); | |
1849 } | 1860 } |
1850 | 1861 |
1851 int max_frames_pending = | 1862 int max_frames_pending = |
1852 output_surface->capabilities().max_frames_pending; | 1863 output_surface->capabilities().max_frames_pending; |
1853 if (max_frames_pending <= 0) | 1864 if (max_frames_pending <= 0) |
1854 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 1865 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
1855 output_surface->SetMaxFramesPending(max_frames_pending); | 1866 client_->SetMaxSwapsPending(max_frames_pending); |
1856 | 1867 |
1857 resource_provider_ = resource_provider.Pass(); | 1868 resource_provider_ = resource_provider.Pass(); |
1858 output_surface_ = output_surface.Pass(); | 1869 output_surface_ = output_surface.Pass(); |
1859 | 1870 |
1860 client_->OnCanDrawStateChanged(CanDraw()); | 1871 client_->OnCanDrawStateChanged(CanDraw()); |
1861 | 1872 |
1862 return true; | 1873 return true; |
1863 } | 1874 } |
1864 | 1875 |
1876 bool LayerTreeHostImpl::CommitVSyncParameters(base::TimeTicks timebase, | |
1877 base::TimeDelta interval) { | |
1878 if (begin_frame_source_) | |
1879 begin_frame_source_->SetTimebaseAndInterval(timebase, interval); | |
1880 } | |
1881 | |
1865 bool LayerTreeHostImpl::DeferredInitialize( | 1882 bool LayerTreeHostImpl::DeferredInitialize( |
1866 scoped_refptr<ContextProvider> offscreen_context_provider) { | 1883 scoped_refptr<ContextProvider> offscreen_context_provider) { |
1867 DCHECK(output_surface_->capabilities().deferred_gl_initialization); | 1884 DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
1868 DCHECK(settings_.impl_side_painting); | 1885 DCHECK(settings_.impl_side_painting); |
1869 DCHECK(output_surface_->context_provider()); | 1886 DCHECK(output_surface_->context_provider()); |
1870 | 1887 |
1871 ReleaseTreeResources(); | 1888 ReleaseTreeResources(); |
1872 renderer_.reset(); | 1889 renderer_.reset(); |
1873 | 1890 |
1874 bool resource_provider_success = resource_provider_->InitializeGL(); | 1891 bool resource_provider_success = resource_provider_->InitializeGL(); |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3018 swap_promise_monitor_.erase(monitor); | 3035 swap_promise_monitor_.erase(monitor); |
3019 } | 3036 } |
3020 | 3037 |
3021 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3038 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3022 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3039 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3023 for (; it != swap_promise_monitor_.end(); it++) | 3040 for (; it != swap_promise_monitor_.end(); it++) |
3024 (*it)->OnSetNeedsRedrawOnImpl(); | 3041 (*it)->OnSetNeedsRedrawOnImpl(); |
3025 } | 3042 } |
3026 | 3043 |
3027 } // namespace cc | 3044 } // namespace cc |
OLD | NEW |