1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "cc/output/begin_frame_args.h" 6 7 namespace cc { 8 9 BeginFrameArgs::BeginFrameArgs() 10 : frame_time(base::TimeTicks()), 11 deadline(base::TimeTicks()), 12 interval(base::TimeDelta::FromMicroseconds(-1)) { 13 } 14 15 BeginFrameArgs::BeginFrameArgs(base::TimeTicks frame_time, 16 base::TimeTicks deadline, 17 base::TimeDelta interval) 18 : frame_time(frame_time), 19 deadline(deadline), 20 interval(interval) 21 {} 22 23 BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time, 24 base::TimeTicks deadline, 25 base::TimeDelta interval) { 26 return BeginFrameArgs(frame_time, deadline, interval); 27 } 28 29 BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor() { 30 // For WebView/SynchronousCompositor, we always want to draw immediately, 31 // so we set the deadline to 0 and guess that the interval is 16 milliseconds. 32 return BeginFrameArgs(base::TimeTicks::Now(), 33 base::TimeTicks(), 34 DefaultInterval()); 35 } 36 37 BeginFrameArgs BeginFrameArgs::CreateForTesting() { 38 base::TimeTicks now = base::TimeTicks::Now(); 39 return BeginFrameArgs(now, 40 now + (DefaultInterval() / 2), 41 DefaultInterval()); 42 } 43 44 BeginFrameArgs BeginFrameArgs::CreateExpiredForTesting() { 45 base::TimeTicks now = base::TimeTicks::Now(); 46 return BeginFrameArgs(now, 47 now - DefaultInterval(), 48 DefaultInterval()); 49 } 50 51 base::TimeDelta BeginFrameArgs::DefaultDeadlineAdjustment() { 52 // Using a large deadline adjustment will effectively revert BeginFrame 53 // scheduling to the hard vsync scheduling we used to have. 54 return base::TimeDelta::FromSeconds(-1); 55 } 56 57 base::TimeDelta BeginFrameArgs::DefaultInterval() { 58 return base::TimeDelta::FromMicroseconds(16666); 59 } 60 61 base::TimeDelta BeginFrameArgs::DefaultRetroactiveBeginFramePeriod() { 62 return base::TimeDelta::FromMicroseconds(4444); 63 } 64 65 66 } // namespace cc 67