OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/display_item_list.h" | 5 #include "cc/resources/display_item_list.h" |
6 | 6 |
| 7 #include <string> |
| 8 |
7 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
8 #include "base/debug/trace_event_argument.h" | 10 #include "base/debug/trace_event_argument.h" |
| 11 #include "cc/base/math_util.h" |
| 12 #include "cc/debug/picture_debug_util.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
| 14 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 15 #include "ui/gfx/skia_util.h" |
10 | 16 |
11 namespace cc { | 17 namespace cc { |
12 | 18 |
13 DisplayItemList::DisplayItemList() | 19 DisplayItemList::DisplayItemList() |
14 : is_suitable_for_gpu_rasterization_(true), approximate_op_count_(0) { | 20 : is_suitable_for_gpu_rasterization_(true), approximate_op_count_(0) { |
15 } | 21 } |
16 | 22 |
17 scoped_refptr<DisplayItemList> DisplayItemList::Create() { | 23 scoped_refptr<DisplayItemList> DisplayItemList::Create() { |
18 return make_scoped_refptr(new DisplayItemList()); | 24 return make_scoped_refptr(new DisplayItemList()); |
19 } | 25 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 63 } |
58 | 64 |
59 return total_size; | 65 return total_size; |
60 } | 66 } |
61 | 67 |
62 scoped_refptr<base::debug::ConvertableToTraceFormat> DisplayItemList::AsValue() | 68 scoped_refptr<base::debug::ConvertableToTraceFormat> DisplayItemList::AsValue() |
63 const { | 69 const { |
64 scoped_refptr<base::debug::TracedValue> state = | 70 scoped_refptr<base::debug::TracedValue> state = |
65 new base::debug::TracedValue(); | 71 new base::debug::TracedValue(); |
66 | 72 |
67 // TODO(ajuma): Include the value of each item. | |
68 state->SetInteger("length", items_.size()); | 73 state->SetInteger("length", items_.size()); |
| 74 state->SetValue("params.layer_rect", |
| 75 MathUtil::AsValue(layer_rect_).release()); |
| 76 |
| 77 SkPictureRecorder recorder; |
| 78 SkCanvas* canvas = |
| 79 recorder.beginRecording(layer_rect_.width(), layer_rect_.height()); |
| 80 canvas->translate(-layer_rect_.x(), -layer_rect_.y()); |
| 81 canvas->clipRect(gfx::RectToSkRect(layer_rect_)); |
| 82 for (size_t i = 0; i < items_.size(); ++i) |
| 83 items_[i]->RasterForTracing(canvas); |
| 84 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
| 85 |
| 86 std::string b64_picture; |
| 87 PictureDebugUtil::SerializeAsBase64(picture.get(), &b64_picture); |
| 88 state->SetString("skp64", b64_picture); |
| 89 |
69 return state; | 90 return state; |
70 } | 91 } |
71 | 92 |
72 void DisplayItemList::EmitTraceSnapshot() const { | 93 void DisplayItemList::EmitTraceSnapshot() const { |
73 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 94 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
74 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( | 95 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT( |
75 "devtools.timeline.picture"), | 96 "devtools.timeline.picture"), |
76 "cc::DisplayItemList", this, AsValue()); | 97 "cc::DisplayItemList", this, AsValue()); |
77 } | 98 } |
78 | 99 |
79 } // namespace cc | 100 } // namespace cc |
OLD | NEW |