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
3 // found in the LICENSE file.
5 #ifndef CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_
6 #define CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_
8 #include "base/debug/trace_event.h"
9 #include "cc/resources/tile.h"
12 namespace frame_viewer_instrumentation
{
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 const char kRasterMode
[] = "rasterMode";
23 const char kAnalyzeTask
[] = "AnalyzeTask";
24 const char kRasterTask
[] = "RasterTask";
26 scoped_refptr
<base::debug::ConvertableToTraceFormat
> TileDataAsValue(
28 TileResolution tile_resolution
,
29 int source_frame_number
,
31 scoped_refptr
<base::debug::TracedValue
> res(new base::debug::TracedValue());
32 TracedValue::SetIDRef(tile_id
, res
.get(), internal::kTileId
);
33 res
->SetString(internal::kTileResolution
,
34 TileResolutionToString(tile_resolution
));
35 res
->SetInteger(internal::kSourceFrameNumber
, source_frame_number
);
36 res
->SetInteger(internal::kLayerId
, layer_id
);
40 } // namespace internal
42 class ScopedAnalyzeTask
{
44 ScopedAnalyzeTask(const void* tile_id
,
45 TileResolution tile_resolution
,
46 int source_frame_number
,
50 internal::kAnalyzeTask
,
52 internal::TileDataAsValue(
53 tile_id
, tile_resolution
, source_frame_number
, layer_id
));
55 ~ScopedAnalyzeTask() {
56 TRACE_EVENT_END0(internal::kCategory
, internal::kAnalyzeTask
);
60 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask
);
63 class ScopedRasterTask
{
65 ScopedRasterTask(const void* tile_id
,
66 TileResolution tile_resolution
,
67 int source_frame_number
,
69 RasterMode raster_mode
) {
72 internal::kRasterTask
,
74 internal::TileDataAsValue(
75 tile_id
, tile_resolution
, source_frame_number
, layer_id
),
76 internal::kRasterMode
,
77 RasterModeToString(raster_mode
));
80 TRACE_EVENT_END0(internal::kCategory
, internal::kRasterTask
);
84 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask
);
87 } // namespace frame_viewer_instrumentation
90 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_