Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / cc / debug / frame_viewer_instrumentation.cc
blobe12858371d612ad3624ad9bd3578b6de179f7875
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"
7 #include "cc/debug/traced_value.h"
9 namespace cc {
10 namespace frame_viewer_instrumentation {
12 const char kCategoryLayerTree[] =
13 TRACE_DISABLED_BY_DEFAULT("cc.debug") ","
14 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") ","
15 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers");
17 namespace {
19 const char kCategory[] = "cc," TRACE_DISABLED_BY_DEFAULT("devtools.timeline");
20 const char kTileData[] = "tileData";
21 const char kLayerId[] = "layerId";
22 const char kTileId[] = "tileId";
23 const char kTileResolution[] = "tileResolution";
24 const char kSourceFrameNumber[] = "sourceFrameNumber";
26 const char kAnalyzeTask[] = "AnalyzeTask";
27 const char kRasterTask[] = "RasterTask";
29 scoped_refptr<base::trace_event::ConvertableToTraceFormat> TileDataAsValue(
30 const void* tile_id,
31 TileResolution tile_resolution,
32 int source_frame_number,
33 int layer_id) {
34 scoped_refptr<base::trace_event::TracedValue> res(
35 new base::trace_event::TracedValue());
36 TracedValue::SetIDRef(tile_id, res.get(), kTileId);
37 res->SetString(kTileResolution, TileResolutionToString(tile_resolution));
38 res->SetInteger(kSourceFrameNumber, source_frame_number);
39 res->SetInteger(kLayerId, layer_id);
40 return res;
43 } // namespace
45 ScopedAnalyzeTask::ScopedAnalyzeTask(const void* tile_id,
46 TileResolution tile_resolution,
47 int source_frame_number,
48 int layer_id) {
49 TRACE_EVENT_BEGIN1(
50 kCategory, kAnalyzeTask, kTileData,
51 TileDataAsValue(tile_id, tile_resolution, source_frame_number, layer_id));
54 ScopedAnalyzeTask::~ScopedAnalyzeTask() {
55 TRACE_EVENT_END0(kCategory, kAnalyzeTask);
58 ScopedRasterTask::ScopedRasterTask(const void* tile_id,
59 TileResolution tile_resolution,
60 int source_frame_number,
61 int layer_id) {
62 TRACE_EVENT_BEGIN1(
63 kCategory, kRasterTask, kTileData,
64 TileDataAsValue(tile_id, tile_resolution, source_frame_number, layer_id));
67 ScopedRasterTask::~ScopedRasterTask() {
68 TRACE_EVENT_END0(kCategory, kRasterTask);
71 bool IsTracingLayerTreeSnapshots() {
72 bool category_enabled;
73 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kCategoryLayerTree, &category_enabled);
74 return category_enabled;
77 } // namespace frame_viewer_instrumentation
78 } // namespace cc