Adds initial key systems support for Chromecast.
[chromium-blink-merge.git] / cc / debug / frame_viewer_instrumentation.h
blob9a6d459cf4919a521a34fdbd4b98b93b81c1634d
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"
11 namespace cc {
12 namespace frame_viewer_instrumentation {
13 namespace internal {
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(
27 const void* tile_id,
28 TileResolution tile_resolution,
29 int source_frame_number,
30 int layer_id) {
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);
37 return res;
40 } // namespace internal
42 class ScopedAnalyzeTask {
43 public:
44 ScopedAnalyzeTask(const void* tile_id,
45 TileResolution tile_resolution,
46 int source_frame_number,
47 int layer_id) {
48 TRACE_EVENT_BEGIN1(
49 internal::kCategory,
50 internal::kAnalyzeTask,
51 internal::kTileData,
52 internal::TileDataAsValue(
53 tile_id, tile_resolution, source_frame_number, layer_id));
55 ~ScopedAnalyzeTask() {
56 TRACE_EVENT_END0(internal::kCategory, internal::kAnalyzeTask);
59 private:
60 DISALLOW_COPY_AND_ASSIGN(ScopedAnalyzeTask);
63 class ScopedRasterTask {
64 public:
65 ScopedRasterTask(const void* tile_id,
66 TileResolution tile_resolution,
67 int source_frame_number,
68 int layer_id,
69 RasterMode raster_mode) {
70 TRACE_EVENT_BEGIN2(
71 internal::kCategory,
72 internal::kRasterTask,
73 internal::kTileData,
74 internal::TileDataAsValue(
75 tile_id, tile_resolution, source_frame_number, layer_id),
76 internal::kRasterMode,
77 RasterModeToString(raster_mode));
79 ~ScopedRasterTask() {
80 TRACE_EVENT_END0(internal::kCategory, internal::kRasterTask);
83 private:
84 DISALLOW_COPY_AND_ASSIGN(ScopedRasterTask);
87 } // namespace frame_viewer_instrumentation
88 } // namespace cc
90 #endif // CC_DEBUG_FRAME_VIEWER_INSTRUMENTATION_H_