OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_ | 5 #ifndef CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_ |
6 #define CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_ | 6 #define CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_ |
7 | 7 |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/resources/tile.h" | 9 #include "cc/resources/tile.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 namespace frame_viewer_instrumentation { | 12 namespace frame_viewer_instrumentation { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 const char kCategory[] = "cc"; | 15 const char kCategory[] = "cc"; |
16 const char kTileData[] = "tileData"; | 16 const char kTileData[] = "tileData"; |
17 const char kLayerId[] = "layerId"; | 17 const char kLayerId[] = "layerId"; |
18 const char kTileId[] = "tileId"; | 18 const char kTileId[] = "tileId"; |
19 const char kTileResolution[] = "tileResolution"; | 19 const char kTileResolution[] = "tileResolution"; |
20 const char kSourceFrameNumber[] = "sourceFrameNumber"; | 20 const char kSourceFrameNumber[] = "sourceFrameNumber"; |
21 const char kRasterMode[] = "rasterMode"; | 21 const char kRasterMode[] = "rasterMode"; |
22 | 22 |
23 const char kAnalyzeTask[] = "AnalyzeTask"; | 23 const char kAnalyzeTask[] = "AnalyzeTask"; |
24 const char kRasterTask[] = "RasterTask"; | 24 const char kRasterTask[] = "RasterTask"; |
25 | 25 |
26 scoped_ptr<base::Value> TileDataAsValue(const void* tile_id, | 26 scoped_refptr<base::debug::ConvertableToTraceFormat> TileDataAsValue( |
27 TileResolution tile_resolution, | 27 const void* tile_id, |
28 int source_frame_number, | 28 TileResolution tile_resolution, |
29 int layer_id) { | 29 int source_frame_number, |
30 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); | 30 int layer_id) { |
31 res->Set(internal::kTileId, TracedValue::CreateIDRef(tile_id).release()); | 31 scoped_refptr<base::debug::TracedValue> res(new base::debug::TracedValue()); |
32 res->Set(internal::kTileResolution, | 32 TracedValue::SetIDRef(tile_id, res, internal::kTileId); |
33 TileResolutionAsValue(tile_resolution).release()); | 33 res->SetString(internal::kTileResolution, |
| 34 TileResolutionToString(tile_resolution)); |
34 res->SetInteger(internal::kSourceFrameNumber, source_frame_number); | 35 res->SetInteger(internal::kSourceFrameNumber, source_frame_number); |
35 res->SetInteger(internal::kLayerId, layer_id); | 36 res->SetInteger(internal::kLayerId, layer_id); |
36 return res.PassAs<base::Value>(); | 37 return res; |
37 } | 38 } |
38 | 39 |
39 } // namespace internal | 40 } // namespace internal |
40 | 41 |
41 class ScopedAnalyzeTask { | 42 class ScopedAnalyzeTask { |
42 public: | 43 public: |
43 ScopedAnalyzeTask(const void* tile_id, | 44 ScopedAnalyzeTask(const void* tile_id, |
44 TileResolution tile_resolution, | 45 TileResolution tile_resolution, |
45 int source_frame_number, | 46 int source_frame_number, |
46 int layer_id) { | 47 int layer_id) { |
47 TRACE_EVENT_BEGIN1( | 48 TRACE_EVENT_BEGIN1( |
48 internal::kCategory, | 49 internal::kCategory, |
49 internal::kAnalyzeTask, | 50 internal::kAnalyzeTask, |
50 internal::kTileData, | 51 internal::kTileData, |
51 TracedValue::FromValue(internal::TileDataAsValue(tile_id, | 52 internal::TileDataAsValue( |
52 tile_resolution, | 53 tile_id, tile_resolution, source_frame_number, layer_id)); |
53 source_frame_number, | |
54 layer_id).release())); | |
55 } | 54 } |
56 ~ScopedAnalyzeTask() { | 55 ~ScopedAnalyzeTask() { |
57 TRACE_EVENT_END0(internal::kCategory, internal::kAnalyzeTask); | 56 TRACE_EVENT_END0(internal::kCategory, internal::kAnalyzeTask); |
58 } | 57 } |
59 | 58 |
60 private: | 59 private: |
61 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask); | 60 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask); |
62 }; | 61 }; |
63 | 62 |
64 class ScopedRasterTask { | 63 class ScopedRasterTask { |
65 public: | 64 public: |
66 ScopedRasterTask(const void* tile_id, | 65 ScopedRasterTask(const void* tile_id, |
67 TileResolution tile_resolution, | 66 TileResolution tile_resolution, |
68 int source_frame_number, | 67 int source_frame_number, |
69 int layer_id, | 68 int layer_id, |
70 RasterMode raster_mode) { | 69 RasterMode raster_mode) { |
71 TRACE_EVENT_BEGIN2( | 70 TRACE_EVENT_BEGIN2( |
72 internal::kCategory, | 71 internal::kCategory, |
73 internal::kRasterTask, | 72 internal::kRasterTask, |
74 internal::kTileData, | 73 internal::kTileData, |
75 TracedValue::FromValue(internal::TileDataAsValue(tile_id, | 74 internal::TileDataAsValue( |
76 tile_resolution, | 75 tile_id, tile_resolution, source_frame_number, layer_id), |
77 source_frame_number, | |
78 layer_id).release()), | |
79 internal::kRasterMode, | 76 internal::kRasterMode, |
80 TracedValue::FromValue(RasterModeAsValue(raster_mode).release())); | 77 RasterModeToString(raster_mode)); |
81 } | 78 } |
82 ~ScopedRasterTask() { | 79 ~ScopedRasterTask() { |
83 TRACE_EVENT_END0(internal::kCategory, internal::kRasterTask); | 80 TRACE_EVENT_END0(internal::kCategory, internal::kRasterTask); |
84 } | 81 } |
85 | 82 |
86 private: | 83 private: |
87 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask); | 84 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask); |
88 }; | 85 }; |
89 | 86 |
90 } // namespace frame_viewer_instrumentation | 87 } // namespace frame_viewer_instrumentation |
91 } // namespace cc | 88 } // namespace cc |
92 | 89 |
93 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_ | 90 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_ |
OLD | NEW |