| 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 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { | 20 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { |
| 21 USING_FAST_MALLOC(DummyRectClient); | 21 USING_FAST_MALLOC(DummyRectClient); |
| 22 public: | 22 public: |
| 23 DummyRectClient(const FloatRect& rect, Color color) : m_rect(rect), m_color(
color) {} | 23 DummyRectClient(const FloatRect& rect, Color color) : m_rect(rect), m_color(
color) {} |
| 24 String debugName() const final { return "<dummy>"; } | 24 String debugName() const final { return "<dummy>"; } |
| 25 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } | 25 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } |
| 26 PassRefPtr<SkPicture> makePicture() const; | 26 PassRefPtr<SkPicture> makePicture() const; |
| 27 private: | 27 private: |
| 28 FloatRect m_rect; | 28 FloatRect m_rect; |
| 29 Color m_color; | 29 Color m_color; |
| 30 DISPLAY_ITEM_CACHE_STATUS_IMPLEMENTATION |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 PassRefPtr<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const | 33 PassRefPtr<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const |
| 33 { | 34 { |
| 34 SkPictureRecorder recorder; | 35 SkPictureRecorder recorder; |
| 35 SkCanvas* canvas = recorder.beginRecording(m_rect); | 36 SkCanvas* canvas = recorder.beginRecording(m_rect); |
| 36 SkPaint paint; | 37 SkPaint paint; |
| 37 paint.setColor(m_color.rgb()); | 38 paint.setColor(m_color.rgb()); |
| 38 canvas->drawRect(m_rect, paint); | 39 canvas->drawRect(m_rect, paint); |
| 39 return fromSkSp(recorder.finishRecordingAsPicture()); | 40 return fromSkSp(recorder.finishRecordingAsPicture()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return m_paintArtifact; | 97 return m_paintArtifact; |
| 97 | 98 |
| 98 if (!m_paintChunks.isEmpty()) | 99 if (!m_paintChunks.isEmpty()) |
| 99 m_paintChunks.last().endIndex = m_displayItemList.size(); | 100 m_paintChunks.last().endIndex = m_displayItemList.size(); |
| 100 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), std::move(m_pa
intChunks)); | 101 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), std::move(m_pa
intChunks)); |
| 101 m_built = true; | 102 m_built = true; |
| 102 return m_paintArtifact; | 103 return m_paintArtifact; |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace blink | 106 } // namespace blink |
| OLD | NEW |