| 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/paint/PaintFlags.h" |
| 13 #include "platform/graphics/paint/PaintRecord.h" |
| 14 #include "platform/graphics/paint/PaintRecorder.h" |
| 12 #include "platform/graphics/skia/SkiaUtils.h" | 15 #include "platform/graphics/skia/SkiaUtils.h" |
| 13 #include "third_party/skia/include/core/SkPaint.h" | |
| 14 #include "third_party/skia/include/core/SkPicture.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 | 24 |
| 25 public: | 25 public: |
| 26 DummyRectClient(const FloatRect& rect, Color color) | 26 DummyRectClient(const FloatRect& rect, Color color) |
| 27 : m_rect(rect), m_color(color) {} | 27 : m_rect(rect), m_color(color) {} |
| 28 String debugName() const final { return "<dummy>"; } | 28 String debugName() const final { return "<dummy>"; } |
| 29 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } | 29 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } |
| 30 sk_sp<SkPicture> makePicture() const; | 30 sk_sp<PaintRecord> makePicture() const; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 FloatRect m_rect; | 33 FloatRect m_rect; |
| 34 Color m_color; | 34 Color m_color; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 sk_sp<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const { | 37 sk_sp<PaintRecord> TestPaintArtifact::DummyRectClient::makePicture() const { |
| 38 SkPictureRecorder recorder; | 38 PaintRecorder recorder; |
| 39 SkCanvas* canvas = recorder.beginRecording(m_rect); | 39 PaintCanvas* canvas = recorder.beginRecording(m_rect); |
| 40 SkPaint paint; | 40 PaintFlags paint; |
| 41 paint.setColor(m_color.rgb()); | 41 paint.setColor(m_color.rgb()); |
| 42 canvas->drawRect(m_rect, paint); | 42 canvas->drawRect(m_rect, paint); |
| 43 return recorder.finishRecordingAsPicture(); | 43 return recorder.finishRecordingAsPicture(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 TestPaintArtifact::TestPaintArtifact() : m_displayItemList(0), m_built(false) {} | 46 TestPaintArtifact::TestPaintArtifact() : m_displayItemList(0), m_built(false) {} |
| 47 | 47 |
| 48 TestPaintArtifact::~TestPaintArtifact() {} | 48 TestPaintArtifact::~TestPaintArtifact() {} |
| 49 | 49 |
| 50 TestPaintArtifact& TestPaintArtifact::chunk( | 50 TestPaintArtifact& TestPaintArtifact::chunk( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 if (!m_paintChunks.isEmpty()) | 99 if (!m_paintChunks.isEmpty()) |
| 100 m_paintChunks.back().endIndex = m_displayItemList.size(); | 100 m_paintChunks.back().endIndex = m_displayItemList.size(); |
| 101 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), | 101 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), |
| 102 std::move(m_paintChunks), true); | 102 std::move(m_paintChunks), 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 |