ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / cc / output / begin_frame_args.h
blob10f7f28aa346f1e1ad99cd23e8986d95f3921de5
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 SYNCHRONOUS,
44 MISSED,
45 // Not a real type, but used by the IPC system. Should always remain the
46 // *last* value in this enum.
47 BEGIN_FRAME_ARGS_TYPE_MAX,
49 static const char* TypeToString(BeginFrameArgsType type);
51 // Creates an invalid set of values.
52 BeginFrameArgs();
54 #ifdef NDEBUG
55 typedef const void* CreationLocation;
56 #else
57 typedef const tracked_objects::Location& CreationLocation;
58 tracked_objects::Location created_from;
59 #endif
61 // You should be able to find all instances where a BeginFrame has been
62 // created by searching for "BeginFrameArgs::Create".
63 // The location argument should **always** be BEGINFRAME_FROM_HERE macro.
64 static BeginFrameArgs Create(CreationLocation location,
65 base::TimeTicks frame_time,
66 base::TimeTicks deadline,
67 base::TimeDelta interval,
68 BeginFrameArgsType type);
70 // This is the default delta that will be used to adjust the deadline when
71 // proper draw-time estimations are not yet available.
72 static base::TimeDelta DefaultEstimatedParentDrawTime();
74 // This is the default interval to use to avoid sprinkling the code with
75 // magic numbers.
76 static base::TimeDelta DefaultInterval();
78 bool IsValid() const { return interval >= base::TimeDelta(); }
80 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
81 void AsValueInto(base::trace_event::TracedValue* dict) const;
83 base::TimeTicks frame_time;
84 base::TimeTicks deadline;
85 base::TimeDelta interval;
86 BeginFrameArgsType type;
88 private:
89 BeginFrameArgs(base::TimeTicks frame_time,
90 base::TimeTicks deadline,
91 base::TimeDelta interval,
92 BeginFrameArgsType type);
95 } // namespace cc
97 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_