| 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 "skia/ext/cdl_paint.h" |
| 15 #include "third_party/skia/include/core/SkPictureRecorder.h" | 15 #include "skia/ext/cdl_picture.h" |
| 16 #include "skia/ext/cdl_picture_recorder.h" |
| 16 #include "wtf/Assertions.h" | 17 #include "wtf/Assertions.h" |
| 17 #include "wtf/PtrUtil.h" | 18 #include "wtf/PtrUtil.h" |
| 18 #include <memory> | 19 #include <memory> |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { | 23 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { |
| 23 USING_FAST_MALLOC(DummyRectClient); | 24 USING_FAST_MALLOC(DummyRectClient); |
| 24 | 25 |
| 25 public: | 26 public: |
| 26 DummyRectClient(const FloatRect& rect, Color color) | 27 DummyRectClient(const FloatRect& rect, Color color) |
| 27 : m_rect(rect), m_color(color) {} | 28 : m_rect(rect), m_color(color) {} |
| 28 String debugName() const final { return "<dummy>"; } | 29 String debugName() const final { return "<dummy>"; } |
| 29 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } | 30 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } |
| 30 sk_sp<SkPicture> makePicture() const; | 31 sk_sp<CdlPicture> makePicture() const; |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 FloatRect m_rect; | 34 FloatRect m_rect; |
| 34 Color m_color; | 35 Color m_color; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 sk_sp<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const { | 38 sk_sp<CdlPicture> TestPaintArtifact::DummyRectClient::makePicture() const { |
| 38 SkPictureRecorder recorder; | 39 CdlPictureRecorder recorder; |
| 39 SkCanvas* canvas = recorder.beginRecording(m_rect); | 40 CdlCanvas* canvas = recorder.beginRecording(m_rect); |
| 40 SkPaint paint; | 41 CdlPaint paint; |
| 41 paint.setColor(m_color.rgb()); | 42 paint.setColor(m_color.rgb()); |
| 42 canvas->drawRect(m_rect, paint); | 43 canvas->drawRect(m_rect, paint); |
| 43 return recorder.finishRecordingAsPicture(); | 44 return recorder.finishRecordingAsPicture(); |
| 44 } | 45 } |
| 45 | 46 |
| 46 TestPaintArtifact::TestPaintArtifact() : m_displayItemList(0), m_built(false) {} | 47 TestPaintArtifact::TestPaintArtifact() : m_displayItemList(0), m_built(false) {} |
| 47 | 48 |
| 48 TestPaintArtifact::~TestPaintArtifact() {} | 49 TestPaintArtifact::~TestPaintArtifact() {} |
| 49 | 50 |
| 50 TestPaintArtifact& TestPaintArtifact::chunk( | 51 TestPaintArtifact& TestPaintArtifact::chunk( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 102 |
| 102 if (!m_paintChunks.isEmpty()) | 103 if (!m_paintChunks.isEmpty()) |
| 103 m_paintChunks.back().endIndex = m_displayItemList.size(); | 104 m_paintChunks.back().endIndex = m_displayItemList.size(); |
| 104 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), | 105 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), |
| 105 std::move(m_paintChunks), true); | 106 std::move(m_paintChunks), true); |
| 106 m_built = true; | 107 m_built = true; |
| 107 return m_paintArtifact; | 108 return m_paintArtifact; |
| 108 } | 109 } |
| 109 | 110 |
| 110 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |