OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | 5 #ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_ |
6 #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | 6 #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_ |
7 | 7 |
8 #include "base/location.h" | |
8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
10 #include "base/values.h" | 11 #include "base/values.h" |
11 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 namespace debug { | 15 namespace debug { |
15 class ConvertableToTraceFormat; | 16 class ConvertableToTraceFormat; |
16 class TracedValue; | 17 class TracedValue; |
17 } | 18 } |
18 } | 19 } |
19 | 20 |
21 /** | |
22 * In debug builds we trace the creation origin of BeginFrameArgs objects. We | |
23 * reuse the tracked_objects::Location system to do that. | |
24 * | |
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. | |
30 */ | |
31 #ifdef NDEBUG | |
32 #define BEGINFRAME_FROM_HERE nullptr | |
33 #else | |
34 #define BEGINFRAME_FROM_HERE (new FROM_HERE) | |
Sami
2014/11/20 11:36:13
Do we need to allocate FROM_HEREs on the heap? The
danakj
2014/11/20 16:02:20
I thought that too, but then you can't avoid alloc
mithro-old
2014/11/21 05:57:46
I originally thought that too but with the typedef
mithro-old
2014/11/21 05:57:46
Actually, with the typedef approach I just added,
| |
35 #endif | |
36 | |
20 namespace cc { | 37 namespace cc { |
21 | 38 |
22 struct CC_EXPORT BeginFrameArgs { | 39 struct CC_EXPORT BeginFrameArgs { |
23 enum BeginFrameArgsType { | 40 enum BeginFrameArgsType { |
24 INVALID, | 41 INVALID, |
25 NORMAL, | 42 NORMAL, |
26 SYNCHRONOUS, | 43 SYNCHRONOUS, |
27 MISSED, | 44 MISSED, |
28 }; | 45 }; |
46 static const char* TypeToString(BeginFrameArgsType type); | |
29 | 47 |
30 // Creates an invalid set of values. | 48 // Creates an invalid set of values. |
31 BeginFrameArgs(); | 49 BeginFrameArgs(); |
32 | 50 |
51 #ifdef NDEBUG | |
52 typedef const void* CreationLocation; | |
53 #else | |
54 typedef const tracked_objects::Location* CreationLocation; | |
55 tracked_objects::Location created_by; | |
Sami
2014/11/20 11:36:14
bikeshed: created_from?
mithro-old
2014/11/21 05:57:46
Done.
| |
56 #endif | |
57 | |
33 // You should be able to find all instances where a BeginFrame has been | 58 // You should be able to find all instances where a BeginFrame has been |
34 // created by searching for "BeginFrameArgs::Create". | 59 // created by searching for "BeginFrameArgs::Create". |
35 static BeginFrameArgs Create(base::TimeTicks frame_time, | 60 // The location argument should **always** be BEGINFRAME_FROM_HERE macro. |
61 static BeginFrameArgs Create(CreationLocation location, | |
62 base::TimeTicks frame_time, | |
36 base::TimeTicks deadline, | 63 base::TimeTicks deadline, |
37 base::TimeDelta interval); | 64 base::TimeDelta interval, |
38 static BeginFrameArgs CreateTyped(base::TimeTicks frame_time, | 65 BeginFrameArgsType type); |
39 base::TimeTicks deadline, | |
40 base::TimeDelta interval, | |
41 BeginFrameArgsType type); | |
42 static BeginFrameArgs CreateForSynchronousCompositor( | |
43 base::TimeTicks now = base::TimeTicks()); | |
44 | 66 |
45 // This is the default delta that will be used to adjust the deadline when | 67 // This is the default delta that will be used to adjust the deadline when |
46 // proper draw-time estimations are not yet available. | 68 // proper draw-time estimations are not yet available. |
47 static base::TimeDelta DefaultEstimatedParentDrawTime(); | 69 static base::TimeDelta DefaultEstimatedParentDrawTime(); |
48 | 70 |
49 // This is the default interval to use to avoid sprinkling the code with | 71 // This is the default interval to use to avoid sprinkling the code with |
50 // magic numbers. | 72 // magic numbers. |
51 static base::TimeDelta DefaultInterval(); | 73 static base::TimeDelta DefaultInterval(); |
52 | 74 |
53 // This is the default amount of time after the frame_time to retroactively | 75 // This is the default amount of time after the frame_time to retroactively |
(...skipping 15 matching lines...) Expand all Loading... | |
69 private: | 91 private: |
70 BeginFrameArgs(base::TimeTicks frame_time, | 92 BeginFrameArgs(base::TimeTicks frame_time, |
71 base::TimeTicks deadline, | 93 base::TimeTicks deadline, |
72 base::TimeDelta interval, | 94 base::TimeDelta interval, |
73 BeginFrameArgsType type); | 95 BeginFrameArgsType type); |
74 }; | 96 }; |
75 | 97 |
76 } // namespace cc | 98 } // namespace cc |
77 | 99 |
78 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | 100 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ |
OLD | NEW |