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 { | |
14 | |
15 const char kCategory[] = "cc"; | |
16 const char kTileData[] = "tileData"; | |
17 const char kLayerId[] = "layerId"; | |
18 const char kTileId[] = "tileId"; | |
19 const char kTileResolution[] = "tileResolution"; | |
20 const char kSourceFrameNumber[] = "sourceFrameNumber"; | |
21 | |
22 const char kAnalyzeTask[] = "AnalyzeTask"; | |
23 const char kRasterTask[] = "RasterTask"; | |
24 | |
25 scoped_refptr<base::debug::ConvertableToTraceFormat> TileDataAsValue( | |
26 const void* tile_id, | |
27 TileResolution tile_resolution, | |
28 int source_frame_number, | |
29 int layer_id) { | |
30 scoped_refptr<base::debug::TracedValue> res(new base::debug::TracedValue()); | |
31 TracedValue::SetIDRef(tile_id, res.get(), internal::kTileId); | |
32 res->SetString(internal::kTileResolution, | |
33 TileResolutionToString(tile_resolution)); | |
34 res->SetInteger(internal::kSourceFrameNumber, source_frame_number); | |
35 res->SetInteger(internal::kLayerId, layer_id); | |
36 return res; | |
37 } | |
38 | |
39 } // namespace internal | |
40 | 13 |
41 class ScopedAnalyzeTask { | 14 class ScopedAnalyzeTask { |
42 public: | 15 public: |
43 ScopedAnalyzeTask(const void* tile_id, | 16 ScopedAnalyzeTask(const void* tile_id, |
44 TileResolution tile_resolution, | 17 TileResolution tile_resolution, |
45 int source_frame_number, | 18 int source_frame_number, |
46 int layer_id) { | 19 int layer_id); |
47 TRACE_EVENT_BEGIN1( | 20 ~ScopedAnalyzeTask(); |
48 internal::kCategory, | |
49 internal::kAnalyzeTask, | |
50 internal::kTileData, | |
51 internal::TileDataAsValue( | |
52 tile_id, tile_resolution, source_frame_number, layer_id)); | |
53 } | |
54 ~ScopedAnalyzeTask() { | |
55 TRACE_EVENT_END0(internal::kCategory, internal::kAnalyzeTask); | |
56 } | |
57 | 21 |
58 private: | 22 private: |
59 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask); | 23 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask); |
60 }; | 24 }; |
61 | 25 |
62 class ScopedRasterTask { | 26 class ScopedRasterTask { |
63 public: | 27 public: |
64 ScopedRasterTask(const void* tile_id, | 28 ScopedRasterTask(const void* tile_id, |
65 TileResolution tile_resolution, | 29 TileResolution tile_resolution, |
66 int source_frame_number, | 30 int source_frame_number, |
67 int layer_id) { | 31 int layer_id); |
68 TRACE_EVENT_BEGIN1( | 32 ~ScopedRasterTask(); |
69 internal::kCategory, | |
70 internal::kRasterTask, | |
71 internal::kTileData, | |
72 internal::TileDataAsValue( | |
73 tile_id, tile_resolution, source_frame_number, layer_id)); | |
74 } | |
75 ~ScopedRasterTask() { | |
76 TRACE_EVENT_END0(internal::kCategory, internal::kRasterTask); | |
77 } | |
78 | 33 |
79 private: | 34 private: |
80 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask); | 35 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask); |
81 }; | 36 }; |
82 | 37 |
83 } // namespace frame_viewer_instrumentation | 38 } // namespace frame_viewer_instrumentation |
84 } // namespace cc | 39 } // namespace cc |
85 | 40 |
86 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_ | 41 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_ |
OLD | NEW |