| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | |
| 6 #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | |
| 7 | |
| 8 #include "base/location.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/time/time.h" | |
| 11 #include "base/values.h" | |
| 12 | |
| 13 namespace base { | |
| 14 namespace trace_event { | |
| 15 class ConvertableToTraceFormat; | |
| 16 class TracedValue; | |
| 17 } | |
| 18 } | |
| 19 | |
| 20 /** | |
| 21 * In debug builds we trace the creation origin of BeginFrameArgs objects. We | |
| 22 * reuse the tracked_objects::Location system to do that. | |
| 23 * | |
| 24 * However, in release builds we don't want this as it doubles the size of the | |
| 25 * BeginFrameArgs object. As well it adds a number of largish strings to the | |
| 26 * binary. Despite the argument being unused, most compilers are unable to | |
| 27 * optimise it away even when unused. Instead we use the BEGINFRAME_FROM_HERE | |
| 28 * macro to prevent the data even getting referenced. | |
| 29 */ | |
| 30 #ifdef NDEBUG | |
| 31 #define BEGINFRAME_FROM_HERE nullptr | |
| 32 #else | |
| 33 #define BEGINFRAME_FROM_HERE FROM_HERE | |
| 34 #endif | |
| 35 | |
| 36 namespace cc { | |
| 37 | |
| 38 struct BeginFrameArgs { | |
| 39 enum BeginFrameArgsType { | |
| 40 INVALID, | |
| 41 NORMAL, | |
| 42 SYNCHRONOUS, | |
| 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, | |
| 47 }; | |
| 48 static const char* TypeToString(BeginFrameArgsType type); | |
| 49 | |
| 50 // Creates an invalid set of values. | |
| 51 BeginFrameArgs(); | |
| 52 | |
| 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 | |
| 59 | |
| 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); | |
| 68 | |
| 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(); | |
| 72 | |
| 73 // This is the default interval to use to avoid sprinkling the code with | |
| 74 // magic numbers. | |
| 75 static base::TimeDelta DefaultInterval(); | |
| 76 | |
| 77 bool IsValid() const { return interval >= base::TimeDelta(); } | |
| 78 | |
| 79 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; | |
| 80 void AsValueInto(base::trace_event::TracedValue* dict) const; | |
| 81 | |
| 82 base::TimeTicks frame_time; | |
| 83 base::TimeTicks deadline; | |
| 84 base::TimeDelta interval; | |
| 85 BeginFrameArgsType type; | |
| 86 | |
| 87 private: | |
| 88 BeginFrameArgs(base::TimeTicks frame_time, | |
| 89 base::TimeTicks deadline, | |
| 90 base::TimeDelta interval, | |
| 91 BeginFrameArgsType type); | |
| 92 }; | |
| 93 | |
| 94 } // namespace cc | |
| 95 | |
| 96 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ | |
| OLD | NEW |