Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(968)

Side by Side Diff: cc/output/begin_frame_args.h

Issue 735723005: cc: Adding creation location to debug BeginFrameArgs objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch without DEPS. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /**
danakj 2014/11/19 15:46:00 Use c++ style comments
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)
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
34 // You should be able to find all instances where a BeginFrame has been 51 // You should be able to find all instances where a BeginFrame has been
35 // created by searching for "BeginFrameArgs::Create". 52 // created by searching for "BeginFrameArgs::Create".
36 static BeginFrameArgs Create(base::TimeTicks frame_time, 53 // The location argument should **always** be BEGINFRAME_FROM_HERE macro.
danakj 2014/11/19 15:46:00 The **'s seem excessive?
54 static BeginFrameArgs Create(const tracked_objects::Location* location,
55 base::TimeTicks frame_time,
37 base::TimeTicks deadline, 56 base::TimeTicks deadline,
38 base::TimeDelta interval, 57 base::TimeDelta interval,
39 BeginFrameArgsType type); 58 BeginFrameArgsType type);
40 59
41 // This is the default delta that will be used to adjust the deadline when 60 // This is the default delta that will be used to adjust the deadline when
42 // proper draw-time estimations are not yet available. 61 // proper draw-time estimations are not yet available.
43 static base::TimeDelta DefaultEstimatedParentDrawTime(); 62 static base::TimeDelta DefaultEstimatedParentDrawTime();
44 63
45 // This is the default interval to use to avoid sprinkling the code with 64 // This is the default interval to use to avoid sprinkling the code with
46 // magic numbers. 65 // magic numbers.
47 static base::TimeDelta DefaultInterval(); 66 static base::TimeDelta DefaultInterval();
48 67
49 // This is the default amount of time after the frame_time to retroactively 68 // This is the default amount of time after the frame_time to retroactively
50 // send a BeginFrame that had been skipped. This only has an effect if the 69 // send a BeginFrame that had been skipped. This only has an effect if the
51 // deadline has passed, since the deadline is also used to trigger BeginFrame 70 // deadline has passed, since the deadline is also used to trigger BeginFrame
52 // retroactively. 71 // retroactively.
53 static base::TimeDelta DefaultRetroactiveBeginFramePeriod(); 72 static base::TimeDelta DefaultRetroactiveBeginFramePeriod();
54 73
55 bool IsValid() const { return interval >= base::TimeDelta(); } 74 bool IsValid() const { return interval >= base::TimeDelta(); }
56 75
57 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; 76 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
58 void AsValueInto(base::debug::TracedValue* dict) const; 77 void AsValueInto(base::debug::TracedValue* dict) const;
59 78
60 base::TimeTicks frame_time; 79 base::TimeTicks frame_time;
61 base::TimeTicks deadline; 80 base::TimeTicks deadline;
62 base::TimeDelta interval; 81 base::TimeDelta interval;
63 BeginFrameArgsType type; 82 BeginFrameArgsType type;
83 #ifndef NDEBUG
brianderson 2014/11/19 20:43:30 Do we have any kind of policy against differing st
danakj 2014/11/19 20:45:45 We've done this before, though we tend to do it by
mithro-old 2014/11/20 04:30:13 I would normally 100% agree that it is a bad idea
mithro-old 2014/11/20 04:30:13 What is the difference between DCHECK_IS_ON and ND
danakj 2014/11/20 16:02:20 You can build a release build with dchecks on via
84 tracked_objects::Location created_by;
85 #endif
64 86
65 private: 87 private:
66 BeginFrameArgs(base::TimeTicks frame_time, 88 BeginFrameArgs(base::TimeTicks frame_time,
67 base::TimeTicks deadline, 89 base::TimeTicks deadline,
68 base::TimeDelta interval, 90 base::TimeDelta interval,
69 BeginFrameArgsType type); 91 BeginFrameArgsType type);
70 }; 92 };
71 93
72 } // namespace cc 94 } // namespace cc
73 95
74 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_ 96 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698