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 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), | 1496 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), |
1497 "SwapBuffers"); | 1497 "SwapBuffers"); |
1498 } | 1498 } |
1499 renderer_->SwapBuffers(metadata); | 1499 renderer_->SwapBuffers(metadata); |
1500 return true; | 1500 return true; |
1501 } | 1501 } |
1502 | 1502 |
1503 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { | 1503 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { |
1504 if (output_surface_) | 1504 if (output_surface_) |
1505 output_surface_->SetNeedsBeginFrame(enable); | 1505 output_surface_->SetNeedsBeginFrame(enable); |
| 1506 else |
| 1507 DCHECK(!enable); |
1506 } | 1508 } |
1507 | 1509 |
1508 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1510 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1509 // Sample the frame time now. This time will be used for updating animations | 1511 // Sample the frame time now. This time will be used for updating animations |
1510 // when we draw. | 1512 // when we draw. |
1511 UpdateCurrentFrameTime(); | 1513 UpdateCurrentFrameTime(); |
1512 } | 1514 } |
1513 | 1515 |
1514 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { | 1516 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { |
1515 gfx::SizeF dip_size = | 1517 gfx::SizeF dip_size = |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 output_surface.get(), resource_provider.get(), skip_gl_renderer); | 1881 output_surface.get(), resource_provider.get(), skip_gl_renderer); |
1880 | 1882 |
1881 if (settings_.impl_side_painting) { | 1883 if (settings_.impl_side_painting) { |
1882 CreateAndSetTileManager( | 1884 CreateAndSetTileManager( |
1883 resource_provider.get(), | 1885 resource_provider.get(), |
1884 output_surface->context_provider().get(), | 1886 output_surface->context_provider().get(), |
1885 GetRendererCapabilities().using_map_image, | 1887 GetRendererCapabilities().using_map_image, |
1886 GetRendererCapabilities().allow_rasterize_on_demand); | 1888 GetRendererCapabilities().allow_rasterize_on_demand); |
1887 } | 1889 } |
1888 | 1890 |
1889 if (!settings_.throttle_frame_production) { | 1891 // Initialize vsync parameters to sane values. |
1890 // Disable VSync | 1892 const base::TimeDelta display_refresh_interval = |
1891 output_surface->SetThrottleFrameProduction(false); | 1893 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / |
1892 } else if (!settings_.begin_impl_frame_scheduling_enabled) { | 1894 settings_.refresh_rate); |
1893 // Setup BeginFrameEmulation if it's not supported natively | 1895 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); |
1894 const base::TimeDelta display_refresh_interval = | |
1895 base::TimeDelta::FromMicroseconds( | |
1896 base::Time::kMicrosecondsPerSecond / | |
1897 settings_.refresh_rate); | |
1898 | 1896 |
1899 output_surface->InitializeBeginFrameEmulation( | 1897 // TODO(brianderson): Don't use a hard-coded parent draw time. |
1900 proxy_->ImplThreadTaskRunner(), | 1898 base::TimeDelta parent_draw_time = |
1901 display_refresh_interval); | 1899 output_surface->capabilities().adjust_deadline_for_parent |
1902 } | 1900 ? BeginFrameArgs::DefaultDeadlineAdjustment() |
| 1901 : base::TimeDelta(); |
| 1902 client_->SetEstimatedParentDrawTime(parent_draw_time); |
1903 | 1903 |
1904 int max_frames_pending = | 1904 int max_frames_pending = |
1905 output_surface->capabilities().max_frames_pending; | 1905 output_surface->capabilities().max_frames_pending; |
1906 if (max_frames_pending <= 0) | 1906 if (max_frames_pending <= 0) |
1907 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 1907 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
1908 client_->SetMaxSwapsPendingOnImplThread(max_frames_pending); | 1908 client_->SetMaxSwapsPendingOnImplThread(max_frames_pending); |
1909 | 1909 |
1910 resource_provider_ = resource_provider.Pass(); | 1910 resource_provider_ = resource_provider.Pass(); |
1911 output_surface_ = output_surface.Pass(); | 1911 output_surface_ = output_surface.Pass(); |
1912 | 1912 |
1913 client_->OnCanDrawStateChanged(CanDraw()); | 1913 client_->OnCanDrawStateChanged(CanDraw()); |
1914 | 1914 |
1915 return true; | 1915 return true; |
1916 } | 1916 } |
1917 | 1917 |
| 1918 void LayerTreeHostImpl::CommitVSyncParameters(base::TimeTicks timebase, |
| 1919 base::TimeDelta interval) { |
| 1920 client_->CommitVSyncParameters(timebase, interval); |
| 1921 } |
| 1922 |
1918 void LayerTreeHostImpl::DeferredInitialize() { | 1923 void LayerTreeHostImpl::DeferredInitialize() { |
1919 DCHECK(output_surface_->capabilities().deferred_gl_initialization); | 1924 DCHECK(output_surface_->capabilities().deferred_gl_initialization); |
1920 DCHECK(settings_.impl_side_painting); | 1925 DCHECK(settings_.impl_side_painting); |
1921 DCHECK(output_surface_->context_provider()); | 1926 DCHECK(output_surface_->context_provider()); |
1922 | 1927 |
1923 ReleaseTreeResources(); | 1928 ReleaseTreeResources(); |
1924 renderer_.reset(); | 1929 renderer_.reset(); |
1925 | 1930 |
1926 resource_provider_->InitializeGL(); | 1931 resource_provider_->InitializeGL(); |
1927 | 1932 |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3051 swap_promise_monitor_.erase(monitor); | 3056 swap_promise_monitor_.erase(monitor); |
3052 } | 3057 } |
3053 | 3058 |
3054 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3059 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3055 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3060 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3056 for (; it != swap_promise_monitor_.end(); it++) | 3061 for (; it != swap_promise_monitor_.end(); it++) |
3057 (*it)->OnSetNeedsRedrawOnImpl(); | 3062 (*it)->OnSetNeedsRedrawOnImpl(); |
3058 } | 3063 } |
3059 | 3064 |
3060 } // namespace cc | 3065 } // namespace cc |
OLD | NEW |