Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / cc / output / begin_frame_args.h
blobc22f7fdde97b701c3118769955025eab5e7a402d
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"
14 namespace base {
15 namespace trace_event {
16 class ConvertableToTraceFormat;
17 class TracedValue;
21 /**
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.
31 #ifdef NDEBUG
32 #define BEGINFRAME_FROM_HERE nullptr
33 #else
34 #define BEGINFRAME_FROM_HERE FROM_HERE
35 #endif
37 namespace cc {
39 struct CC_EXPORT BeginFrameArgs {
40 enum BeginFrameArgsType {
41 INVALID,
42 NORMAL,
43 MISSED,
44 // Not a real type, but used by the IPC system. Should always remain the
45 // *last* value in this enum.
46 BEGIN_FRAME_ARGS_TYPE_MAX,
48 static const char* TypeToString(BeginFrameArgsType type);
50 // Creates an invalid set of values.
51 BeginFrameArgs();
53 #ifdef NDEBUG
54 typedef const void* CreationLocation;
55 #else
56 typedef const tracked_objects::Location& CreationLocation;
57 tracked_objects::Location created_from;
58 #endif
60 // You should be able to find all instances where a BeginFrame has been
61 // created by searching for "BeginFrameArgs::Create".
62 // The location argument should **always** be BEGINFRAME_FROM_HERE macro.
63 static BeginFrameArgs Create(CreationLocation location,
64 base::TimeTicks frame_time,
65 base::TimeTicks deadline,
66 base::TimeDelta interval,
67 BeginFrameArgsType type);
69 // This is the default delta that will be used to adjust the deadline when
70 // proper draw-time estimations are not yet available.
71 static base::TimeDelta DefaultEstimatedParentDrawTime();
73 // This is the default interval to use to avoid sprinkling the code with
74 // magic numbers.
75 static base::TimeDelta DefaultInterval();
77 bool IsValid() const { return interval >= base::TimeDelta(); }
79 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
80 void AsValueInto(base::trace_event::TracedValue* dict) const;
82 base::TimeTicks frame_time;
83 base::TimeTicks deadline;
84 base::TimeDelta interval;
85 BeginFrameArgsType type;
87 private:
88 BeginFrameArgs(base::TimeTicks frame_time,
89 base::TimeTicks deadline,
90 base::TimeDelta interval,
91 BeginFrameArgsType type);
94 } // namespace cc
96 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_