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"
15 namespace trace_event
{
16 class ConvertableToTraceFormat
;
20 // TODO(ssid): remove these aliases after the tracing clients are moved to the
21 // new trace_event namespace. See crbug.com/451032. ETA: March 2015
23 using ::base::trace_event::ConvertableToTraceFormat
;
24 using ::base::trace_event::TracedValue
;
29 * In debug builds we trace the creation origin of BeginFrameArgs objects. We
30 * reuse the tracked_objects::Location system to do that.
32 * However, in release builds we don't want this as it doubles the size of the
33 * BeginFrameArgs object. As well it adds a number of largish strings to the
34 * binary. Despite the argument being unused, most compilers are unable to
35 * optimise it away even when unused. Instead we use the BEGINFRAME_FROM_HERE
36 * macro to prevent the data even getting referenced.
39 #define BEGINFRAME_FROM_HERE nullptr
41 #define BEGINFRAME_FROM_HERE FROM_HERE
46 struct CC_EXPORT BeginFrameArgs
{
47 enum BeginFrameArgsType
{
52 // Not a real type, but used by the IPC system. Should always remain the
53 // *last* value in this enum.
54 BEGIN_FRAME_ARGS_TYPE_MAX
,
56 static const char* TypeToString(BeginFrameArgsType type
);
58 // Creates an invalid set of values.
62 typedef const void* CreationLocation
;
64 typedef const tracked_objects::Location
& CreationLocation
;
65 tracked_objects::Location created_from
;
68 // You should be able to find all instances where a BeginFrame has been
69 // created by searching for "BeginFrameArgs::Create".
70 // The location argument should **always** be BEGINFRAME_FROM_HERE macro.
71 static BeginFrameArgs
Create(CreationLocation location
,
72 base::TimeTicks frame_time
,
73 base::TimeTicks deadline
,
74 base::TimeDelta interval
,
75 BeginFrameArgsType type
);
77 // This is the default delta that will be used to adjust the deadline when
78 // proper draw-time estimations are not yet available.
79 static base::TimeDelta
DefaultEstimatedParentDrawTime();
81 // This is the default interval to use to avoid sprinkling the code with
83 static base::TimeDelta
DefaultInterval();
85 bool IsValid() const { return interval
>= base::TimeDelta(); }
87 scoped_refptr
<base::debug::ConvertableToTraceFormat
> AsValue() const;
88 void AsValueInto(base::debug::TracedValue
* dict
) const;
90 base::TimeTicks frame_time
;
91 base::TimeTicks deadline
;
92 base::TimeDelta interval
;
93 BeginFrameArgsType type
;
96 BeginFrameArgs(base::TimeTicks frame_time
,
97 base::TimeTicks deadline
,
98 base::TimeDelta interval
,
99 BeginFrameArgsType type
);
104 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_