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";
22 const char kAnalyzeTask
[] = "AnalyzeTask";
23 const char kRasterTask
[] = "RasterTask";
25 scoped_refptr
<base::debug::ConvertableToTraceFormat
> TileDataAsValue(
27 TileResolution tile_resolution
,
28 int source_frame_number
,
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
);
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 internal::TileDataAsValue(
52 tile_id
, tile_resolution
, source_frame_number
, layer_id
));
54 ~ScopedAnalyzeTask() {
55 TRACE_EVENT_END0(internal::kCategory
, internal::kAnalyzeTask
);
59 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask
);
62 class ScopedRasterTask
{
64 ScopedRasterTask(const void* tile_id
,
65 TileResolution tile_resolution
,
66 int source_frame_number
,
70 internal::kRasterTask
,
72 internal::TileDataAsValue(
73 tile_id
, tile_resolution
, source_frame_number
, layer_id
));
76 TRACE_EVENT_END0(internal::kCategory
, internal::kRasterTask
);
80 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask
);
83 } // namespace frame_viewer_instrumentation
86 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_