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/drawing_display_item.h" | 5 #include "cc/resources/drawing_display_item.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
11 #include "cc/debug/picture_debug_util.h" | 11 #include "cc/debug/picture_debug_util.h" |
12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
13 #include "third_party/skia/include/core/SkDrawPictureCallback.h" | 13 #include "third_party/skia/include/core/SkDrawPictureCallback.h" |
14 #include "third_party/skia/include/core/SkMatrix.h" | 14 #include "third_party/skia/include/core/SkMatrix.h" |
15 #include "third_party/skia/include/core/SkPicture.h" | 15 #include "third_party/skia/include/core/SkPicture.h" |
16 #include "third_party/skia/include/utils/SkPictureUtils.h" | 16 #include "third_party/skia/include/utils/SkPictureUtils.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
20 DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<SkPicture> picture) | 20 DrawingDisplayItem::DrawingDisplayItem() { |
21 : picture_(picture) { | |
22 } | 21 } |
23 | 22 |
24 DrawingDisplayItem::~DrawingDisplayItem() { | 23 DrawingDisplayItem::~DrawingDisplayItem() { |
25 } | 24 } |
26 | 25 |
| 26 void DrawingDisplayItem::SetNew(skia::RefPtr<SkPicture> picture) { |
| 27 picture_ = picture.Pass(); |
| 28 } |
| 29 |
27 void DrawingDisplayItem::Raster(SkCanvas* canvas, | 30 void DrawingDisplayItem::Raster(SkCanvas* canvas, |
28 SkDrawPictureCallback* callback) const { | 31 SkDrawPictureCallback* callback) const { |
29 // SkPicture always does a wrapping save/restore on the canvas, so it is not | 32 // SkPicture always does a wrapping save/restore on the canvas, so it is not |
30 // necessary here. | 33 // necessary here. |
31 if (callback) | 34 if (callback) |
32 picture_->playback(canvas, callback); | 35 picture_->playback(canvas, callback); |
33 else | 36 else |
34 canvas->drawPicture(picture_.get()); | 37 canvas->drawPicture(picture_.get()); |
35 } | 38 } |
36 | 39 |
(...skipping 18 matching lines...) Expand all Loading... |
55 "cullRect", | 58 "cullRect", |
56 base::StringPrintf("[%f,%f,%f,%f]", picture_->cullRect().x(), | 59 base::StringPrintf("[%f,%f,%f,%f]", picture_->cullRect().x(), |
57 picture_->cullRect().y(), picture_->cullRect().width(), | 60 picture_->cullRect().y(), picture_->cullRect().width(), |
58 picture_->cullRect().height())); | 61 picture_->cullRect().height())); |
59 std::string b64_picture; | 62 std::string b64_picture; |
60 PictureDebugUtil::SerializeAsBase64(picture_.get(), &b64_picture); | 63 PictureDebugUtil::SerializeAsBase64(picture_.get(), &b64_picture); |
61 array->SetString("skp64", b64_picture); | 64 array->SetString("skp64", b64_picture); |
62 array->EndDictionary(); | 65 array->EndDictionary(); |
63 } | 66 } |
64 | 67 |
65 scoped_ptr<DrawingDisplayItem> DrawingDisplayItem::Clone() { | 68 void DrawingDisplayItem::CloneTo(DrawingDisplayItem* item) const { |
66 return Create(picture_); | 69 item->SetNew(picture_); |
67 } | 70 } |
68 | 71 |
69 } // namespace cc | 72 } // namespace cc |
OLD | NEW |