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 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1483 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), | 1483 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), |
1484 "SwapBuffers"); | 1484 "SwapBuffers"); |
1485 } | 1485 } |
1486 renderer_->SwapBuffers(metadata); | 1486 renderer_->SwapBuffers(metadata); |
1487 return true; | 1487 return true; |
1488 } | 1488 } |
1489 | 1489 |
1490 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { | 1490 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { |
1491 if (output_surface_) | 1491 if (output_surface_) |
1492 output_surface_->SetNeedsBeginFrame(enable); | 1492 output_surface_->SetNeedsBeginFrame(enable); |
1493 else | |
1494 DCHECK(!enable); | |
1493 } | 1495 } |
1494 | 1496 |
1495 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1497 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1496 // Sample the frame time now. This time will be used for updating animations | 1498 // Sample the frame time now. This time will be used for updating animations |
1497 // when we draw. | 1499 // when we draw. |
1498 UpdateCurrentFrameTime(); | 1500 UpdateCurrentFrameTime(); |
1499 } | 1501 } |
1500 | 1502 |
1501 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { | 1503 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { |
1502 gfx::SizeF dip_size = | 1504 gfx::SizeF dip_size = |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1849 return false; | 1851 return false; |
1850 | 1852 |
1851 if (settings_.impl_side_painting) { | 1853 if (settings_.impl_side_painting) { |
1852 CreateAndSetTileManager( | 1854 CreateAndSetTileManager( |
1853 resource_provider.get(), | 1855 resource_provider.get(), |
1854 output_surface->context_provider().get(), | 1856 output_surface->context_provider().get(), |
1855 GetRendererCapabilities().using_map_image, | 1857 GetRendererCapabilities().using_map_image, |
1856 GetRendererCapabilities().allow_rasterize_on_demand); | 1858 GetRendererCapabilities().allow_rasterize_on_demand); |
1857 } | 1859 } |
1858 | 1860 |
1859 if (!settings_.throttle_frame_production) { | 1861 // Initialize vsync parameters to sane values. |
1860 // Disable VSync | 1862 const base::TimeDelta display_refresh_interval = |
1861 output_surface->SetThrottleFrameProduction(false); | 1863 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / |
1862 } else if (!settings_.begin_impl_frame_scheduling_enabled) { | 1864 settings_.refresh_rate); |
1863 // Setup BeginFrameEmulation if it's not supported natively | 1865 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); |
1864 const base::TimeDelta display_refresh_interval = | |
1865 base::TimeDelta::FromMicroseconds( | |
1866 base::Time::kMicrosecondsPerSecond / | |
1867 settings_.refresh_rate); | |
1868 | 1866 |
1869 output_surface->InitializeBeginFrameEmulation( | 1867 // TODO(biranderson): Don't use a hard-coded parent draw time. |
Sami
2014/04/08 13:46:01
Hey no assigning TODOs to others :)
brianderson
2014/04/09 02:52:05
D'oh.
brianderson
2014/04/10 23:45:58
Done.
| |
1870 proxy_->ImplThreadTaskRunner(), | 1868 base::TimeDelta parent_draw_time = |
1871 display_refresh_interval); | 1869 output_surface->capabilities().adjust_deadline_for_parent |
1872 } | 1870 ? BeginFrameArgs::DefaultDeadlineAdjustment() |
1871 : base::TimeDelta(); | |
1872 client_->SetEstimatedParentDrawTime(parent_draw_time); | |
1873 | 1873 |
1874 int max_frames_pending = | 1874 int max_frames_pending = |
1875 output_surface->capabilities().max_frames_pending; | 1875 output_surface->capabilities().max_frames_pending; |
1876 if (max_frames_pending <= 0) | 1876 if (max_frames_pending <= 0) |
1877 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 1877 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
1878 client_->SetMaxSwapsPending(max_frames_pending); | 1878 client_->SetMaxSwapsPending(max_frames_pending); |
1879 | 1879 |
1880 resource_provider_ = resource_provider.Pass(); | 1880 resource_provider_ = resource_provider.Pass(); |
1881 output_surface_ = output_surface.Pass(); | 1881 output_surface_ = output_surface.Pass(); |
1882 | 1882 |
1883 client_->OnCanDrawStateChanged(CanDraw()); | 1883 client_->OnCanDrawStateChanged(CanDraw()); |
1884 | 1884 |
1885 return true; | 1885 return true; |
1886 } | 1886 } |
1887 | 1887 |
1888 void LayerTreeHostImpl::CommitVSyncParameters(base::TimeTicks timebase, | |
1889 base::TimeDelta interval) { | |
1890 client_->CommitVSyncParameters(timebase, interval); | |
1891 } | |
1892 | |
1888 bool LayerTreeHostImpl::DeferredInitialize( | 1893 bool LayerTreeHostImpl::DeferredInitialize( |
1889 scoped_refptr<ContextProvider> offscreen_context_provider) { | 1894 scoped_refptr<ContextProvider> offscreen_context_provider) { |
1890 DCHECK(output_surface_->capabilities().deferred_gl_initialization); | 1895 DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
1891 DCHECK(settings_.impl_side_painting); | 1896 DCHECK(settings_.impl_side_painting); |
1892 DCHECK(output_surface_->context_provider()); | 1897 DCHECK(output_surface_->context_provider()); |
1893 | 1898 |
1894 ReleaseTreeResources(); | 1899 ReleaseTreeResources(); |
1895 renderer_.reset(); | 1900 renderer_.reset(); |
1896 | 1901 |
1897 bool resource_provider_success = resource_provider_->InitializeGL(); | 1902 bool resource_provider_success = resource_provider_->InitializeGL(); |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3048 swap_promise_monitor_.erase(monitor); | 3053 swap_promise_monitor_.erase(monitor); |
3049 } | 3054 } |
3050 | 3055 |
3051 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3056 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3052 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3057 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3053 for (; it != swap_promise_monitor_.end(); it++) | 3058 for (; it != swap_promise_monitor_.end(); it++) |
3054 (*it)->OnSetNeedsRedrawOnImpl(); | 3059 (*it)->OnSetNeedsRedrawOnImpl(); |
3055 } | 3060 } |
3056 | 3061 |
3057 } // namespace cc | 3062 } // namespace cc |
OLD | NEW |