OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/testing/TestPaintArtifact.h" | 5 #include "platform/testing/TestPaintArtifact.h" |
6 | 6 |
7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "platform/graphics/paint/DisplayItemClient.h" | 8 #include "platform/graphics/paint/DisplayItemClient.h" |
9 #include "platform/graphics/paint/DrawingDisplayItem.h" | 9 #include "platform/graphics/paint/DrawingDisplayItem.h" |
10 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | 10 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" |
11 #include "platform/graphics/paint/PaintArtifact.h" | 11 #include "platform/graphics/paint/PaintArtifact.h" |
12 #include "platform/graphics/skia/SkiaUtils.h" | 12 #include "platform/graphics/skia/SkiaUtils.h" |
13 #include "third_party/skia/include/core/SkPaint.h" | 13 #include "third_party/skia/include/core/SkPaint.h" |
14 #include "third_party/skia/include/core/SkPicture.h" | 14 #include "third_party/skia/include/core/SkPicture.h" |
15 #include "third_party/skia/include/core/SkPictureRecorder.h" | 15 #include "third_party/skia/include/core/SkPictureRecorder.h" |
16 #include "wtf/Assertions.h" | 16 #include "wtf/Assertions.h" |
17 #include "wtf/PtrUtil.h" | 17 #include "wtf/PtrUtil.h" |
18 #include <memory> | 18 #include <memory> |
19 | 19 |
20 namespace blink { | 20 namespace blink { |
21 | 21 |
22 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { | 22 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { |
23 USING_FAST_MALLOC(DummyRectClient); | 23 USING_FAST_MALLOC(DummyRectClient); |
24 public: | 24 public: |
25 DummyRectClient(const FloatRect& rect, Color color) : m_rect(rect), m_color(
color) {} | 25 DummyRectClient(const FloatRect& rect, Color color) : m_rect(rect), m_color(
color) {} |
26 String debugName() const final { return "<dummy>"; } | 26 String debugName() const final { return "<dummy>"; } |
27 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } | 27 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } |
28 PassRefPtr<SkPicture> makePicture() const; | 28 sk_sp<SkPicture> makePicture() const; |
29 private: | 29 private: |
30 FloatRect m_rect; | 30 FloatRect m_rect; |
31 Color m_color; | 31 Color m_color; |
32 }; | 32 }; |
33 | 33 |
34 PassRefPtr<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const | 34 sk_sp<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const |
35 { | 35 { |
36 SkPictureRecorder recorder; | 36 SkPictureRecorder recorder; |
37 SkCanvas* canvas = recorder.beginRecording(m_rect); | 37 SkCanvas* canvas = recorder.beginRecording(m_rect); |
38 SkPaint paint; | 38 SkPaint paint; |
39 paint.setColor(m_color.rgb()); | 39 paint.setColor(m_color.rgb()); |
40 canvas->drawRect(m_rect, paint); | 40 canvas->drawRect(m_rect, paint); |
41 return fromSkSp(recorder.finishRecordingAsPicture()); | 41 return recorder.finishRecordingAsPicture(); |
42 } | 42 } |
43 | 43 |
44 TestPaintArtifact::TestPaintArtifact() | 44 TestPaintArtifact::TestPaintArtifact() |
45 : m_displayItemList(0), m_built(false) | 45 : m_displayItemList(0), m_built(false) |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 TestPaintArtifact::~TestPaintArtifact() | 49 TestPaintArtifact::~TestPaintArtifact() |
50 { | 50 { |
51 } | 51 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return m_paintArtifact; | 98 return m_paintArtifact; |
99 | 99 |
100 if (!m_paintChunks.isEmpty()) | 100 if (!m_paintChunks.isEmpty()) |
101 m_paintChunks.last().endIndex = m_displayItemList.size(); | 101 m_paintChunks.last().endIndex = m_displayItemList.size(); |
102 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), std::move(m_pa
intChunks), true); | 102 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), std::move(m_pa
intChunks), true); |
103 m_built = true; | 103 m_built = true; |
104 return m_paintArtifact; | 104 return m_paintArtifact; |
105 } | 105 } |
106 | 106 |
107 } // namespace blink | 107 } // namespace blink |
OLD | NEW |