Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(908)

Side by Side Diff: third_party/WebKit/Source/platform/testing/TestPaintArtifact.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
19 17
20 namespace blink { 18 namespace blink {
21 19
22 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { 20 class TestPaintArtifact::DummyRectClient : public DisplayItemClient {
23 USING_FAST_MALLOC(DummyRectClient); 21 USING_FAST_MALLOC(DummyRectClient);
24 public: 22 public:
25 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) {}
26 String debugName() const final { return "<dummy>"; } 24 String debugName() const final { return "<dummy>"; }
27 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } 25 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); }
28 PassRefPtr<SkPicture> makePicture() const; 26 PassRefPtr<SkPicture> makePicture() const;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 m_paintChunks.last().endIndex = m_displayItemList.size(); 67 m_paintChunks.last().endIndex = m_displayItemList.size();
70 PaintChunk chunk; 68 PaintChunk chunk;
71 chunk.beginIndex = m_displayItemList.size(); 69 chunk.beginIndex = m_displayItemList.size();
72 chunk.properties = properties; 70 chunk.properties = properties;
73 m_paintChunks.append(chunk); 71 m_paintChunks.append(chunk);
74 return *this; 72 return *this;
75 } 73 }
76 74
77 TestPaintArtifact& TestPaintArtifact::rectDrawing(const FloatRect& bounds, Color color) 75 TestPaintArtifact& TestPaintArtifact::rectDrawing(const FloatRect& bounds, Color color)
78 { 76 {
79 std::unique_ptr<DummyRectClient> client = wrapUnique(new DummyRectClient(bou nds, color)); 77 OwnPtr<DummyRectClient> client = adoptPtr(new DummyRectClient(bounds, color) );
80 m_displayItemList.allocateAndConstruct<DrawingDisplayItem>( 78 m_displayItemList.allocateAndConstruct<DrawingDisplayItem>(
81 *client, DisplayItem::DrawingFirst, client->makePicture()); 79 *client, DisplayItem::DrawingFirst, client->makePicture());
82 m_dummyClients.append(std::move(client)); 80 m_dummyClients.append(std::move(client));
83 return *this; 81 return *this;
84 } 82 }
85 83
86 TestPaintArtifact& TestPaintArtifact::foreignLayer(const FloatPoint& location, c onst IntSize& size, scoped_refptr<cc::Layer> layer) 84 TestPaintArtifact& TestPaintArtifact::foreignLayer(const FloatPoint& location, c onst IntSize& size, scoped_refptr<cc::Layer> layer)
87 { 85 {
88 FloatRect floatBounds(location, FloatSize(size)); 86 FloatRect floatBounds(location, FloatSize(size));
89 std::unique_ptr<DummyRectClient> client = wrapUnique(new DummyRectClient(flo atBounds, Color::transparent)); 87 OwnPtr<DummyRectClient> client = adoptPtr(new DummyRectClient(floatBounds, C olor::transparent));
90 m_displayItemList.allocateAndConstruct<ForeignLayerDisplayItem>( 88 m_displayItemList.allocateAndConstruct<ForeignLayerDisplayItem>(
91 *client, DisplayItem::ForeignLayerFirst, std::move(layer), location, siz e); 89 *client, DisplayItem::ForeignLayerFirst, std::move(layer), location, siz e);
92 m_dummyClients.append(std::move(client)); 90 m_dummyClients.append(std::move(client));
93 return *this; 91 return *this;
94 } 92 }
95 93
96 const PaintArtifact& TestPaintArtifact::build() 94 const PaintArtifact& TestPaintArtifact::build()
97 { 95 {
98 if (m_built) 96 if (m_built)
99 return m_paintArtifact; 97 return m_paintArtifact;
100 98
101 if (!m_paintChunks.isEmpty()) 99 if (!m_paintChunks.isEmpty())
102 m_paintChunks.last().endIndex = m_displayItemList.size(); 100 m_paintChunks.last().endIndex = m_displayItemList.size();
103 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), std::move(m_pa intChunks), true); 101 m_paintArtifact = PaintArtifact(std::move(m_displayItemList), std::move(m_pa intChunks), true);
104 m_built = true; 102 m_built = true;
105 return m_paintArtifact; 103 return m_paintArtifact;
106 } 104 }
107 105
108 } // namespace blink 106 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698