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.
5 #ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_
6 #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_
8 #include "base/location.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h"
11 #include "base/values.h"
12 #include "cc/base/cc_export.h"
16 class ConvertableToTraceFormat
;
22 * In debug builds we trace the creation origin of BeginFrameArgs objects. We
23 * reuse the tracked_objects::Location system to do that.
25 * However, in release builds we don't want this as it doubles the size of the
26 * BeginFrameArgs object. As well it adds a number of largish strings to the
27 * binary. Despite the argument being unused, most compilers are unable to
28 * optimise it away even when unused. Instead we use the BEGINFRAME_FROM_HERE
29 * macro to prevent the data even getting referenced.
32 #define BEGINFRAME_FROM_HERE nullptr
34 #define BEGINFRAME_FROM_HERE FROM_HERE
39 struct CC_EXPORT BeginFrameArgs
{
40 enum BeginFrameArgsType
{
46 static const char* TypeToString(BeginFrameArgsType type
);
48 // Creates an invalid set of values.
52 typedef const void* CreationLocation
;
54 typedef const tracked_objects::Location
& CreationLocation
;
55 tracked_objects::Location created_from
;
58 // You should be able to find all instances where a BeginFrame has been
59 // created by searching for "BeginFrameArgs::Create".
60 // The location argument should **always** be BEGINFRAME_FROM_HERE macro.
61 static BeginFrameArgs
Create(CreationLocation location
,
62 base::TimeTicks frame_time
,
63 base::TimeTicks deadline
,
64 base::TimeDelta interval
,
65 BeginFrameArgsType type
);
67 // This is the default delta that will be used to adjust the deadline when
68 // proper draw-time estimations are not yet available.
69 static base::TimeDelta
DefaultEstimatedParentDrawTime();
71 // This is the default interval to use to avoid sprinkling the code with
73 static base::TimeDelta
DefaultInterval();
75 // This is the default amount of time after the frame_time to retroactively
76 // send a BeginFrame that had been skipped. This only has an effect if the
77 // deadline has passed, since the deadline is also used to trigger BeginFrame
79 static base::TimeDelta
DefaultRetroactiveBeginFramePeriod();
81 bool IsValid() const { return interval
>= base::TimeDelta(); }
83 scoped_refptr
<base::debug::ConvertableToTraceFormat
> AsValue() const;
84 void AsValueInto(base::debug::TracedValue
* dict
) const;
86 base::TimeTicks frame_time
;
87 base::TimeTicks deadline
;
88 base::TimeDelta interval
;
89 BeginFrameArgsType type
;
92 BeginFrameArgs(base::TimeTicks frame_time
,
93 base::TimeTicks deadline
,
94 base::TimeDelta interval
,
95 BeginFrameArgsType type
);
100 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_