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_ptr
<base::Value
> TileDataAsValue(const void* tile_id
,
27 TileResolution tile_resolution
,
28 int source_frame_number
,
30 scoped_ptr
<base::DictionaryValue
> res(new base::DictionaryValue
);
31 res
->Set(internal::kTileId
, TracedValue::CreateIDRef(tile_id
).release());
32 res
->Set(internal::kTileResolution
,
33 TileResolutionAsValue(tile_resolution
).release());
34 res
->SetInteger(internal::kSourceFrameNumber
, source_frame_number
);
35 res
->SetInteger(internal::kLayerId
, layer_id
);
36 return res
.PassAs
<base::Value
>();
39 } // namespace internal
41 class ScopedAnalyzeTask
{
43 ScopedAnalyzeTask(const void* tile_id
,
44 TileResolution tile_resolution
,
45 int source_frame_number
,
49 internal::kAnalyzeTask
,
51 TracedValue::FromValue(internal::TileDataAsValue(tile_id
,
54 layer_id
).release()));
56 ~ScopedAnalyzeTask() {
57 TRACE_EVENT_END0(internal::kCategory
, internal::kAnalyzeTask
);
61 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask
);
64 class ScopedRasterTask
{
66 ScopedRasterTask(const void* tile_id
,
67 TileResolution tile_resolution
,
68 int source_frame_number
,
70 RasterMode raster_mode
) {
73 internal::kRasterTask
,
75 TracedValue::FromValue(internal::TileDataAsValue(tile_id
,
79 internal::kRasterMode
,
80 TracedValue::FromValue(RasterModeAsValue(raster_mode
).release()));
83 TRACE_EVENT_END0(internal::kCategory
, internal::kRasterTask
);
87 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask
);
90 } // namespace frame_viewer_instrumentation
93 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_