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" |
(...skipping 11 matching lines...) Expand all Loading... |
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 PassRefPtr<SkPicture> makePicture() const; |
29 private: | 29 private: |
30 FloatRect m_rect; | 30 FloatRect m_rect; |
31 Color m_color; | 31 Color m_color; |
32 DISPLAY_ITEM_CACHE_STATUS_IMPLEMENTATION | |
33 }; | 32 }; |
34 | 33 |
35 PassRefPtr<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const | 34 PassRefPtr<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const |
36 { | 35 { |
37 SkPictureRecorder recorder; | 36 SkPictureRecorder recorder; |
38 SkCanvas* canvas = recorder.beginRecording(m_rect); | 37 SkCanvas* canvas = recorder.beginRecording(m_rect); |
39 SkPaint paint; | 38 SkPaint paint; |
40 paint.setColor(m_color.rgb()); | 39 paint.setColor(m_color.rgb()); |
41 canvas->drawRect(m_rect, paint); | 40 canvas->drawRect(m_rect, paint); |
42 return fromSkSp(recorder.finishRecordingAsPicture()); | 41 return fromSkSp(recorder.finishRecordingAsPicture()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return m_paintArtifact; | 98 return m_paintArtifact; |
100 | 99 |
101 if (!m_paintChunks.isEmpty()) | 100 if (!m_paintChunks.isEmpty()) |
102 m_paintChunks.last().endIndex = m_displayItemList.size(); | 101 m_paintChunks.last().endIndex = m_displayItemList.size(); |
103 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); |
104 m_built = true; | 103 m_built = true; |
105 return m_paintArtifact; | 104 return m_paintArtifact; |
106 } | 105 } |
107 | 106 |
108 } // namespace blink | 107 } // namespace blink |
OLD | NEW |