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_BASE_DEVTOOLS_INSTRUMENTATION_H_ | 5 #ifndef CC_BASE_DEVTOOLS_INSTRUMENTATION_H_ |
6 #define CC_BASE_DEVTOOLS_INSTRUMENTATION_H_ | 6 #define CC_BASE_DEVTOOLS_INSTRUMENTATION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 ~ScopedLayerTask() { TRACE_EVENT_END0(internal::kCategory, event_name_); } | 50 ~ScopedLayerTask() { TRACE_EVENT_END0(internal::kCategory, event_name_); } |
51 | 51 |
52 private: | 52 private: |
53 const char* event_name_; | 53 const char* event_name_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTask); | 55 DISALLOW_COPY_AND_ASSIGN(ScopedLayerTask); |
56 }; | 56 }; |
57 | 57 |
58 class CC_BASE_EXPORT ScopedImageDecodeTask { | 58 class CC_BASE_EXPORT ScopedImageDecodeTask { |
59 public: | 59 public: |
60 enum Type { SOFTWARE, GPU }; | 60 enum DecodeType { kSoftware, kGpu }; |
61 enum TaskType { kInRaster, kOutOfRaster }; | |
61 | 62 |
62 ScopedImageDecodeTask(const void* imagePtr, Type type) | 63 ScopedImageDecodeTask(const void* image_ptr, |
63 : type_(type), start_time_(base::TimeTicks::Now()) { | 64 DecodeType decode_type, |
65 TaskType task_type) | |
66 : decode_type_(decode_type), | |
67 task_type_(task_type), | |
68 start_time_(base::TimeTicks::Now()) { | |
64 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kImageDecodeTask, | 69 TRACE_EVENT_BEGIN1(internal::kCategory, internal::kImageDecodeTask, |
65 internal::kPixelRefId, | 70 internal::kPixelRefId, |
66 reinterpret_cast<uint64_t>(imagePtr)); | 71 reinterpret_cast<uint64_t>(image_ptr)); |
67 } | 72 } |
68 ~ScopedImageDecodeTask() { | 73 ~ScopedImageDecodeTask() { |
69 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask); | 74 TRACE_EVENT_END0(internal::kCategory, internal::kImageDecodeTask); |
70 base::TimeDelta duration = base::TimeTicks::Now() - start_time_; | 75 base::TimeDelta duration = base::TimeTicks::Now() - start_time_; |
71 switch (type_) { | 76 switch (task_type_) { |
72 case SOFTWARE: | 77 case kInRaster: |
73 UMA_HISTOGRAM_COUNTS_1M("Renderer4.ImageDecodeTaskDurationUs.Software", | 78 switch (decode_type_) { |
74 duration.InMicroseconds()); | 79 case kSoftware: |
80 UMA_HISTOGRAM_COUNTS_1M( | |
81 "Renderer4.ImageDecodeTaskDurationUs.Software", | |
82 duration.InMicroseconds()); | |
83 break; | |
84 case kGpu: | |
85 UMA_HISTOGRAM_COUNTS_1M("Renderer4.ImageDecodeTaskDurationUs.Gpu", | |
86 duration.InMicroseconds()); | |
87 break; | |
88 } | |
75 break; | 89 break; |
76 case GPU: | 90 case kOutOfRaster: |
77 UMA_HISTOGRAM_COUNTS_1M("Renderer4.ImageDecodeTaskDurationUs.Gpu", | 91 switch (decode_type_) { |
78 duration.InMicroseconds()); | 92 case kSoftware: |
93 UMA_HISTOGRAM_COUNTS_1M( | |
94 "Renderer4.ImageDecodeTaskDurationUs.OutOfRaster.Software", | |
95 duration.InMicroseconds()); | |
96 break; | |
97 case kGpu: | |
98 UMA_HISTOGRAM_COUNTS_1M( | |
99 "Renderer4.ImageDecodeTaskDurationUs.OutOfRaster.Gpu", | |
100 duration.InMicroseconds()); | |
101 break; | |
102 } | |
79 break; | 103 break; |
80 } | 104 } |
81 } | 105 } |
Ilya Sherman
2017/06/01 23:50:50
Why is there so much non-trivial code implemented
Khushal
2017/06/02 00:17:22
I guess it was just following the rest of the styl
| |
82 | 106 |
83 private: | 107 private: |
84 const Type type_; | 108 const DecodeType decode_type_; |
109 const TaskType task_type_; | |
85 const base::TimeTicks start_time_; | 110 const base::TimeTicks start_time_; |
86 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask); | 111 DISALLOW_COPY_AND_ASSIGN(ScopedImageDecodeTask); |
87 }; | 112 }; |
88 | 113 |
89 class CC_BASE_EXPORT ScopedLayerTreeTask { | 114 class CC_BASE_EXPORT ScopedLayerTreeTask { |
90 public: | 115 public: |
91 ScopedLayerTreeTask(const char* event_name, | 116 ScopedLayerTreeTask(const char* event_name, |
92 int layer_id, | 117 int layer_id, |
93 int layer_tree_host_id) | 118 int layer_tree_host_id) |
94 : event_name_(event_name) { | 119 : event_name_(event_name) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 TRACE_EVENT_INSTANT2( | 207 TRACE_EVENT_INSTANT2( |
183 internal::kCategoryFrame, internal::kNeedsBeginFrameChanged, | 208 internal::kCategoryFrame, internal::kNeedsBeginFrameChanged, |
184 TRACE_EVENT_SCOPE_THREAD, internal::kLayerTreeId, layer_tree_host_id, | 209 TRACE_EVENT_SCOPE_THREAD, internal::kLayerTreeId, layer_tree_host_id, |
185 internal::kData, NeedsBeginFrameData(new_value)); | 210 internal::kData, NeedsBeginFrameData(new_value)); |
186 } | 211 } |
187 | 212 |
188 } // namespace devtools_instrumentation | 213 } // namespace devtools_instrumentation |
189 } // namespace cc | 214 } // namespace cc |
190 | 215 |
191 #endif // CC_BASE_DEVTOOLS_INSTRUMENTATION_H_ | 216 #endif // CC_BASE_DEVTOOLS_INSTRUMENTATION_H_ |
OLD | NEW |