| 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/playback/drawing_display_item.h" | 5 #include "cc/playback/drawing_display_item.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // SkPicture always does a wrapping save/restore on the canvas, so it is not | 46 // SkPicture always does a wrapping save/restore on the canvas, so it is not |
| 47 // necessary here. | 47 // necessary here. |
| 48 if (callback) { | 48 if (callback) { |
| 49 picture_->playback(canvas, callback); | 49 picture_->playback(canvas, callback); |
| 50 } else { | 50 } else { |
| 51 // TODO(enne): switch this to playback once PaintRecord is real. | 51 // TODO(enne): switch this to playback once PaintRecord is real. |
| 52 canvas->drawPicture(ToSkPicture(picture_.get())); | 52 canvas->drawPicture(ToSkPicture(picture_.get())); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 void DrawingDisplayItem::AsValueInto( | |
| 57 const gfx::Rect& visual_rect, | |
| 58 base::trace_event::TracedValue* array) const { | |
| 59 array->BeginDictionary(); | |
| 60 array->SetString("name", "DrawingDisplayItem"); | |
| 61 | |
| 62 array->BeginArray("visualRect"); | |
| 63 array->AppendInteger(visual_rect.x()); | |
| 64 array->AppendInteger(visual_rect.y()); | |
| 65 array->AppendInteger(visual_rect.width()); | |
| 66 array->AppendInteger(visual_rect.height()); | |
| 67 array->EndArray(); | |
| 68 | |
| 69 array->BeginArray("cullRect"); | |
| 70 array->AppendInteger(picture_->cullRect().x()); | |
| 71 array->AppendInteger(picture_->cullRect().y()); | |
| 72 array->AppendInteger(picture_->cullRect().width()); | |
| 73 array->AppendInteger(picture_->cullRect().height()); | |
| 74 array->EndArray(); | |
| 75 | |
| 76 std::string b64_picture; | |
| 77 PictureDebugUtil::SerializeAsBase64(ToSkPicture(picture_.get()), | |
| 78 &b64_picture); | |
| 79 array->SetString("skp64", b64_picture); | |
| 80 array->EndDictionary(); | |
| 81 } | |
| 82 | |
| 83 void DrawingDisplayItem::CloneTo(DrawingDisplayItem* item) const { | 56 void DrawingDisplayItem::CloneTo(DrawingDisplayItem* item) const { |
| 84 item->SetNew(picture_); | 57 item->SetNew(picture_); |
| 85 } | 58 } |
| 86 | 59 |
| 87 size_t DrawingDisplayItem::ExternalMemoryUsage() const { | 60 size_t DrawingDisplayItem::ExternalMemoryUsage() const { |
| 88 return picture_->approximateBytesUsed(); | 61 return picture_->approximateBytesUsed(); |
| 89 } | 62 } |
| 90 | 63 |
| 91 DISABLE_CFI_PERF | 64 DISABLE_CFI_PERF |
| 92 int DrawingDisplayItem::ApproximateOpCount() const { | 65 int DrawingDisplayItem::ApproximateOpCount() const { |
| 93 return picture_->approximateOpCount(); | 66 return picture_->approximateOpCount(); |
| 94 } | 67 } |
| 95 | 68 |
| 96 } // namespace cc | 69 } // namespace cc |
| OLD | NEW |