| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "cc/playback/drawing_display_item.h" | |
| 6 | |
| 7 #include <stddef.h> | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/strings/stringprintf.h" | |
| 12 #include "base/trace_event/trace_event.h" | |
| 13 #include "base/trace_event/trace_event_argument.h" | |
| 14 #include "base/values.h" | |
| 15 #include "cc/debug/picture_debug_util.h" | |
| 16 #include "third_party/skia/include/core/SkCanvas.h" | |
| 17 #include "ui/gfx/skia_util.h" | |
| 18 | |
| 19 namespace cc { | |
| 20 | |
| 21 DrawingDisplayItem::DrawingDisplayItem() : DisplayItem(DRAWING) {} | |
| 22 | |
| 23 DrawingDisplayItem::DrawingDisplayItem(sk_sp<const PaintRecord> record) | |
| 24 : DisplayItem(DRAWING) { | |
| 25 SetNew(std::move(record)); | |
| 26 } | |
| 27 | |
| 28 DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) | |
| 29 : DisplayItem(DRAWING) { | |
| 30 item.CloneTo(this); | |
| 31 } | |
| 32 | |
| 33 DrawingDisplayItem::~DrawingDisplayItem() { | |
| 34 } | |
| 35 | |
| 36 void DrawingDisplayItem::SetNew(sk_sp<const PaintRecord> record) { | |
| 37 picture_ = std::move(record); | |
| 38 } | |
| 39 | |
| 40 DISABLE_CFI_PERF | |
| 41 void DrawingDisplayItem::Raster(SkCanvas* canvas, | |
| 42 SkPicture::AbortCallback* callback) const { | |
| 43 if (canvas->quickReject(picture_->cullRect())) | |
| 44 return; | |
| 45 | |
| 46 // SkPicture always does a wrapping save/restore on the canvas, so it is not | |
| 47 // necessary here. | |
| 48 if (callback) { | |
| 49 picture_->playback(canvas, callback); | |
| 50 } else { | |
| 51 // TODO(enne): switch this to playback once PaintRecord is real. | |
| 52 canvas->drawPicture(ToSkPicture(picture_.get())); | |
| 53 } | |
| 54 } | |
| 55 | |
| 56 void DrawingDisplayItem::CloneTo(DrawingDisplayItem* item) const { | |
| 57 item->SetNew(picture_); | |
| 58 } | |
| 59 | |
| 60 size_t DrawingDisplayItem::ExternalMemoryUsage() const { | |
| 61 return picture_->approximateBytesUsed(); | |
| 62 } | |
| 63 | |
| 64 DISABLE_CFI_PERF | |
| 65 int DrawingDisplayItem::ApproximateOpCount() const { | |
| 66 return picture_->approximateOpCount(); | |
| 67 } | |
| 68 | |
| 69 } // namespace cc | |
| OLD | NEW |