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 #include "cc/debug/frame_viewer_instrumentation.h"
8 namespace frame_viewer_instrumentation
{
10 const char kCategoryLayerTree
[] =
11 TRACE_DISABLED_BY_DEFAULT("cc.debug") ","
12 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") ","
13 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers");
17 const char kCategory
[] = "cc," TRACE_DISABLED_BY_DEFAULT("devtools.timeline");
18 const char kTileData
[] = "tileData";
19 const char kLayerId
[] = "layerId";
20 const char kTileId
[] = "tileId";
21 const char kTileResolution
[] = "tileResolution";
22 const char kSourceFrameNumber
[] = "sourceFrameNumber";
24 const char kAnalyzeTask
[] = "AnalyzeTask";
25 const char kRasterTask
[] = "RasterTask";
27 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> TileDataAsValue(
29 TileResolution tile_resolution
,
30 int source_frame_number
,
32 scoped_refptr
<base::trace_event::TracedValue
> res(
33 new base::trace_event::TracedValue());
34 TracedValue::SetIDRef(tile_id
, res
.get(), kTileId
);
35 res
->SetString(kTileResolution
, TileResolutionToString(tile_resolution
));
36 res
->SetInteger(kSourceFrameNumber
, source_frame_number
);
37 res
->SetInteger(kLayerId
, layer_id
);
43 ScopedAnalyzeTask::ScopedAnalyzeTask(const void* tile_id
,
44 TileResolution tile_resolution
,
45 int source_frame_number
,
48 kCategory
, kAnalyzeTask
, kTileData
,
49 TileDataAsValue(tile_id
, tile_resolution
, source_frame_number
, layer_id
));
52 ScopedAnalyzeTask::~ScopedAnalyzeTask() {
53 TRACE_EVENT_END0(kCategory
, kAnalyzeTask
);
56 ScopedRasterTask::ScopedRasterTask(const void* tile_id
,
57 TileResolution tile_resolution
,
58 int source_frame_number
,
61 kCategory
, kRasterTask
, kTileData
,
62 TileDataAsValue(tile_id
, tile_resolution
, source_frame_number
, layer_id
));
65 ScopedRasterTask::~ScopedRasterTask() {
66 TRACE_EVENT_END0(kCategory
, kRasterTask
);
69 bool IsTracingLayerTreeSnapshots() {
70 bool category_enabled
;
71 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kCategoryLayerTree
, &category_enabled
);
72 return category_enabled
;
75 } // namespace frame_viewer_instrumentation