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