| 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 FROM_HERE |
| 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 }; |
| 29 static const char* TypeToString(BeginFrameArgsType type); | 46 static const char* TypeToString(BeginFrameArgsType type); |
| 30 | 47 |
| 31 // Creates an invalid set of values. | 48 // Creates an invalid set of values. |
| 32 BeginFrameArgs(); | 49 BeginFrameArgs(); |
| 33 | 50 |
| 51 #ifdef NDEBUG |
| 52 typedef const void* CreationLocation; |
| 53 #else |
| 54 typedef const tracked_objects::Location& CreationLocation; |
| 55 tracked_objects::Location created_from; |
| 56 #endif |
| 57 |
| 34 // 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 |
| 35 // created by searching for "BeginFrameArgs::Create". | 59 // created by searching for "BeginFrameArgs::Create". |
| 36 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, |
| 37 base::TimeTicks deadline, | 63 base::TimeTicks deadline, |
| 38 base::TimeDelta interval, | 64 base::TimeDelta interval, |
| 39 BeginFrameArgsType type); | 65 BeginFrameArgsType type); |
| 40 | 66 |
| 41 // 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 |
| 42 // proper draw-time estimations are not yet available. | 68 // proper draw-time estimations are not yet available. |
| 43 static base::TimeDelta DefaultEstimatedParentDrawTime(); | 69 static base::TimeDelta DefaultEstimatedParentDrawTime(); |
| 44 | 70 |
| 45 // 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 |
| 46 // magic numbers. | 72 // magic numbers. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 65 private: | 91 private: |
| 66 BeginFrameArgs(base::TimeTicks frame_time, | 92 BeginFrameArgs(base::TimeTicks frame_time, |
| 67 base::TimeTicks deadline, | 93 base::TimeTicks deadline, |
| 68 base::TimeDelta interval, | 94 base::TimeDelta interval, |
| 69 BeginFrameArgsType type); | 95 BeginFrameArgsType type); |
| 70 }; | 96 }; |
| 71 | 97 |
| 72 } // namespace cc | 98 } // namespace cc |
| 73 | 99 |
| 74 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | 100 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ |
| OLD | NEW |