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

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

Issue 1823133002: Use sk_sp-based picture recording APIs in Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/DisplayItemListTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "third_party/skia/include/core/SkPaint.h" 13 #include "third_party/skia/include/core/SkPaint.h"
13 #include "third_party/skia/include/core/SkPicture.h" 14 #include "third_party/skia/include/core/SkPicture.h"
14 #include "third_party/skia/include/core/SkPictureRecorder.h" 15 #include "third_party/skia/include/core/SkPictureRecorder.h"
15 #include "wtf/Assertions.h" 16 #include "wtf/Assertions.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 class TestPaintArtifact::DummyRectClient : public DisplayItemClient { 20 class TestPaintArtifact::DummyRectClient : public DisplayItemClient {
20 USING_FAST_MALLOC(DummyRectClient); 21 USING_FAST_MALLOC(DummyRectClient);
21 public: 22 public:
22 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) {}
23 String debugName() const final { return "<dummy>"; } 24 String debugName() const final { return "<dummy>"; }
24 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); } 25 LayoutRect visualRect() const final { return enclosingLayoutRect(m_rect); }
25 PassRefPtr<SkPicture> makePicture() const; 26 PassRefPtr<SkPicture> makePicture() const;
26 private: 27 private:
27 FloatRect m_rect; 28 FloatRect m_rect;
28 Color m_color; 29 Color m_color;
29 }; 30 };
30 31
31 PassRefPtr<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const 32 PassRefPtr<SkPicture> TestPaintArtifact::DummyRectClient::makePicture() const
32 { 33 {
33 SkPictureRecorder recorder; 34 SkPictureRecorder recorder;
34 SkCanvas* canvas = recorder.beginRecording(m_rect); 35 SkCanvas* canvas = recorder.beginRecording(m_rect);
35 SkPaint paint; 36 SkPaint paint;
36 paint.setColor(m_color.rgb()); 37 paint.setColor(m_color.rgb());
37 canvas->drawRect(m_rect, paint); 38 canvas->drawRect(m_rect, paint);
38 return adoptRef(recorder.endRecordingAsPicture()); 39 return fromSkSp(recorder.finishRecordingAsPicture());
39 } 40 }
40 41
41 TestPaintArtifact::TestPaintArtifact() 42 TestPaintArtifact::TestPaintArtifact()
42 : m_displayItemList(0), m_built(false) 43 : m_displayItemList(0), m_built(false)
43 { 44 {
44 } 45 }
45 46
46 TestPaintArtifact::~TestPaintArtifact() 47 TestPaintArtifact::~TestPaintArtifact()
47 { 48 {
48 } 49 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return m_paintArtifact; 96 return m_paintArtifact;
96 97
97 if (!m_paintChunks.isEmpty()) 98 if (!m_paintChunks.isEmpty())
98 m_paintChunks.last().endIndex = m_displayItemList.size(); 99 m_paintChunks.last().endIndex = m_displayItemList.size();
99 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));
100 m_built = true; 101 m_built = true;
101 return m_paintArtifact; 102 return m_paintArtifact;
102 } 103 }
103 104
104 } // namespace blink 105 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/DisplayItemListTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698