Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 221833009: cc: Move scheduling logic out of OutputSurface (Closed) Base URL: http://git.chromium.org/chromium/src.git@swapAck2Sched11
Patch Set: rebase; sami's comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), 1495 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id),
1496 "SwapBuffers"); 1496 "SwapBuffers");
1497 } 1497 }
1498 renderer_->SwapBuffers(metadata); 1498 renderer_->SwapBuffers(metadata);
1499 return true; 1499 return true;
1500 } 1500 }
1501 1501
1502 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { 1502 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) {
1503 if (output_surface_) 1503 if (output_surface_)
1504 output_surface_->SetNeedsBeginFrame(enable); 1504 output_surface_->SetNeedsBeginFrame(enable);
1505 else
1506 DCHECK(!enable);
1505 } 1507 }
1506 1508
1507 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { 1509 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
1508 // Sample the frame time now. This time will be used for updating animations 1510 // Sample the frame time now. This time will be used for updating animations
1509 // when we draw. 1511 // when we draw.
1510 UpdateCurrentFrameTime(); 1512 UpdateCurrentFrameTime();
1511 } 1513 }
1512 1514
1513 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { 1515 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const {
1514 gfx::SizeF dip_size = 1516 gfx::SizeF dip_size =
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 return false; 1880 return false;
1879 1881
1880 if (settings_.impl_side_painting) { 1882 if (settings_.impl_side_painting) {
1881 CreateAndSetTileManager( 1883 CreateAndSetTileManager(
1882 resource_provider.get(), 1884 resource_provider.get(),
1883 output_surface->context_provider().get(), 1885 output_surface->context_provider().get(),
1884 GetRendererCapabilities().using_map_image, 1886 GetRendererCapabilities().using_map_image,
1885 GetRendererCapabilities().allow_rasterize_on_demand); 1887 GetRendererCapabilities().allow_rasterize_on_demand);
1886 } 1888 }
1887 1889
1888 if (!settings_.throttle_frame_production) { 1890 // Initialize vsync parameters to sane values.
1889 // Disable VSync 1891 const base::TimeDelta display_refresh_interval =
1890 output_surface->SetThrottleFrameProduction(false); 1892 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond /
1891 } else if (!settings_.begin_impl_frame_scheduling_enabled) { 1893 settings_.refresh_rate);
1892 // Setup BeginFrameEmulation if it's not supported natively 1894 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval);
1893 const base::TimeDelta display_refresh_interval =
1894 base::TimeDelta::FromMicroseconds(
1895 base::Time::kMicrosecondsPerSecond /
1896 settings_.refresh_rate);
1897 1895
1898 output_surface->InitializeBeginFrameEmulation( 1896 // TODO(brianderson): Don't use a hard-coded parent draw time.
1899 proxy_->ImplThreadTaskRunner(), 1897 base::TimeDelta parent_draw_time =
1900 display_refresh_interval); 1898 output_surface->capabilities().adjust_deadline_for_parent
1901 } 1899 ? BeginFrameArgs::DefaultDeadlineAdjustment()
1900 : base::TimeDelta();
1901 client_->SetEstimatedParentDrawTime(parent_draw_time);
1902 1902
1903 int max_frames_pending = 1903 int max_frames_pending =
1904 output_surface->capabilities().max_frames_pending; 1904 output_surface->capabilities().max_frames_pending;
1905 if (max_frames_pending <= 0) 1905 if (max_frames_pending <= 0)
1906 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; 1906 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING;
1907 client_->SetMaxSwapsPending(max_frames_pending); 1907 client_->SetMaxSwapsPending(max_frames_pending);
1908 1908
1909 resource_provider_ = resource_provider.Pass(); 1909 resource_provider_ = resource_provider.Pass();
1910 output_surface_ = output_surface.Pass(); 1910 output_surface_ = output_surface.Pass();
1911 1911
1912 client_->OnCanDrawStateChanged(CanDraw()); 1912 client_->OnCanDrawStateChanged(CanDraw());
1913 1913
1914 return true; 1914 return true;
1915 } 1915 }
1916 1916
1917 void LayerTreeHostImpl::CommitVSyncParameters(base::TimeTicks timebase,
1918 base::TimeDelta interval) {
1919 client_->CommitVSyncParameters(timebase, interval);
1920 }
1921
1917 bool LayerTreeHostImpl::DeferredInitialize( 1922 bool LayerTreeHostImpl::DeferredInitialize(
1918 scoped_refptr<ContextProvider> offscreen_context_provider) { 1923 scoped_refptr<ContextProvider> offscreen_context_provider) {
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 bool resource_provider_success = resource_provider_->InitializeGL(); 1931 bool resource_provider_success = resource_provider_->InitializeGL();
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3080 swap_promise_monitor_.erase(monitor); 3085 swap_promise_monitor_.erase(monitor);
3081 } 3086 }
3082 3087
3083 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3088 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3084 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3089 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3085 for (; it != swap_promise_monitor_.end(); it++) 3090 for (; it != swap_promise_monitor_.end(); it++)
3086 (*it)->OnSetNeedsRedrawOnImpl(); 3091 (*it)->OnSetNeedsRedrawOnImpl();
3087 } 3092 }
3088 3093
3089 } // namespace cc 3094 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698