| 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 #include "wtf/PtrUtil.h" |
| 18 #include <memory> |
| 17 | 19 |
| 18 namespace blink { | 20 namespace blink { |
| 19 | 21 |
| 20 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { | 22 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { |
| 21 USING_FAST_MALLOC(DummyRectClient); | 23 USING_FAST_MALLOC(DummyRectClient); |
| 22 public: | 24 public: |
| 23 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) {} |
| 24 String debugName() const final { return "<dummy>"; } | 26 String debugName() const final { return "<dummy>"; } |
| 25 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } | 27 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } |
| 26 PassRefPtr<SkPicture> makePicture() const; | 28 PassRefPtr<SkPicture> makePicture() const; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 m_paintChunks.last().endIndex = m_displayItemList.size(); | 69 m_paintChunks.last().endIndex = m_displayItemList.size(); |
| 68 PaintChunk chunk; | 70 PaintChunk chunk; |
| 69 chunk.beginIndex = m_displayItemList.size(); | 71 chunk.beginIndex = m_displayItemList.size(); |
| 70 chunk.properties = properties; | 72 chunk.properties = properties; |
| 71 m_paintChunks.append(chunk); | 73 m_paintChunks.append(chunk); |
| 72 return *this; | 74 return *this; |
| 73 } | 75 } |
| 74 | 76 |
| 75 TestPaintArtifact& TestPaintArtifact::rectDrawing(const FloatRect& bounds, Color
color) | 77 TestPaintArtifact& TestPaintArtifact::rectDrawing(const FloatRect& bounds, Color
color) |
| 76 { | 78 { |
| 77 OwnPtr<DummyRectClient> client = adoptPtr(new DummyRectClient(bounds, color)
); | 79 std::unique_ptr<DummyRectClient> client = wrapUnique(new DummyRectClient(bou
nds, color)); |
| 78 m_displayItemList.allocateAndConstruct<DrawingDisplayItem>( | 80 m_displayItemList.allocateAndConstruct<DrawingDisplayItem>( |
| 79 *client, DisplayItem::DrawingFirst, client->makePicture()); | 81 *client, DisplayItem::DrawingFirst, client->makePicture()); |
| 80 m_dummyClients.append(std::move(client)); | 82 m_dummyClients.append(std::move(client)); |
| 81 return *this; | 83 return *this; |
| 82 } | 84 } |
| 83 | 85 |
| 84 TestPaintArtifact& TestPaintArtifact::foreignLayer(const FloatPoint& location, c
onst IntSize& size, scoped_refptr<cc::Layer> layer) | 86 TestPaintArtifact& TestPaintArtifact::foreignLayer(const FloatPoint& location, c
onst IntSize& size, scoped_refptr<cc::Layer> layer) |
| 85 { | 87 { |
| 86 FloatRect floatBounds(location, FloatSize(size)); | 88 FloatRect floatBounds(location, FloatSize(size)); |
| 87 OwnPtr<DummyRectClient> client = adoptPtr(new DummyRectClient(floatBounds, C
olor::transparent)); | 89 std::unique_ptr<DummyRectClient> client = wrapUnique(new DummyRectClient(flo
atBounds, Color::transparent)); |
| 88 m_displayItemList.allocateAndConstruct<ForeignLayerDisplayItem>( | 90 m_displayItemList.allocateAndConstruct<ForeignLayerDisplayItem>( |
| 89 *client, DisplayItem::ForeignLayerFirst, std::move(layer), location, siz
e); | 91 *client, DisplayItem::ForeignLayerFirst, std::move(layer), location, siz
e); |
| 90 m_dummyClients.append(std::move(client)); | 92 m_dummyClients.append(std::move(client)); |
| 91 return *this; | 93 return *this; |
| 92 } | 94 } |
| 93 | 95 |
| 94 const PaintArtifact& TestPaintArtifact::build() | 96 const PaintArtifact& TestPaintArtifact::build() |
| 95 { | 97 { |
| 96 if (m_built) | 98 if (m_built) |
| 97 return m_paintArtifact; | 99 return m_paintArtifact; |
| 98 | 100 |
| 99 if (!m_paintChunks.isEmpty()) | 101 if (!m_paintChunks.isEmpty()) |
| 100 m_paintChunks.last().endIndex = m_displayItemList.size(); | 102 m_paintChunks.last().endIndex = m_displayItemList.size(); |
| 101 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), std::move(m_pa
intChunks), true); | 103 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), std::move(m_pa
intChunks), true); |
| 102 m_built = true; | 104 m_built = true; |
| 103 return m_paintArtifact; | 105 return m_paintArtifact; |
| 104 } | 106 } |
| 105 | 107 |
| 106 } // namespace blink | 108 } // namespace blink |
| OLD | NEW |