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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItemListTest.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
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/graphics/paint/DisplayItemList.h" 5 #include "platform/graphics/paint/DisplayItemList.h"
6 6
7 #include "SkPictureRecorder.h" 7 #include "SkPictureRecorder.h"
8 #include "SkTypes.h" 8 #include "SkTypes.h"
9 #include "platform/graphics/paint/DrawingDisplayItem.h" 9 #include "platform/graphics/paint/DrawingDisplayItem.h"
10 #include "platform/graphics/paint/SubsequenceDisplayItem.h" 10 #include "platform/graphics/paint/SubsequenceDisplayItem.h"
11 #include "platform/graphics/paint/TransformDisplayItem.h" 11 #include "platform/graphics/paint/TransformDisplayItem.h"
12 #include "platform/graphics/skia/SkiaUtils.h"
12 #include "platform/transforms/AffineTransform.h" 13 #include "platform/transforms/AffineTransform.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace blink { 16 namespace blink {
16 namespace { 17 namespace {
17 18
18 #define EXPECT_RECT_EQ(expected, actual) \ 19 #define EXPECT_RECT_EQ(expected, actual) \
19 do { \ 20 do { \
20 const IntRect& actualRect = actual; \ 21 const IntRect& actualRect = actual; \
21 EXPECT_EQ(expected.x(), actualRect.x()); \ 22 EXPECT_EQ(expected.x(), actualRect.x()); \
(...skipping 18 matching lines...) Expand all
40 DisplayItemList m_list; 41 DisplayItemList m_list;
41 TestDisplayItemClient m_client; 42 TestDisplayItemClient m_client;
42 }; 43 };
43 44
44 static PassRefPtr<SkPicture> createRectPicture(const IntRect& bounds) 45 static PassRefPtr<SkPicture> createRectPicture(const IntRect& bounds)
45 { 46 {
46 SkPictureRecorder recorder; 47 SkPictureRecorder recorder;
47 SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height()); 48 SkCanvas* canvas = recorder.beginRecording(bounds.width(), bounds.height());
48 canvas->drawRect(SkRect::MakeXYWH(bounds.x(), bounds.y(), bounds.width(), bo unds.height()), 49 canvas->drawRect(SkRect::MakeXYWH(bounds.x(), bounds.y(), bounds.width(), bo unds.height()),
49 SkPaint()); 50 SkPaint());
50 return adoptRef(recorder.endRecordingAsPicture()); 51 return fromSkSp(recorder.finishRecordingAsPicture());
51 } 52 }
52 53
53 TEST_F(DisplayItemListTest, AppendVisualRect_Simple) 54 TEST_F(DisplayItemListTest, AppendVisualRect_Simple)
54 { 55 {
55 // One drawing: D. 56 // One drawing: D.
56 57
57 IntRect drawingBounds(5, 6, 7, 8); 58 IntRect drawingBounds(5, 6, 7, 8);
58 m_list.allocateAndConstruct<DrawingDisplayItem>( 59 m_list.allocateAndConstruct<DrawingDisplayItem>(
59 m_client, DisplayItem::Type::DocumentBackground, createRectPicture(drawi ngBounds), true); 60 m_client, DisplayItem::Type::DocumentBackground, createRectPicture(drawi ngBounds), true);
60 m_list.appendVisualRect(drawingBounds); 61 m_list.appendVisualRect(drawingBounds);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 EXPECT_RECT_EQ(drawingABounds, m_list.visualRect(1)); 361 EXPECT_RECT_EQ(drawingABounds, m_list.visualRect(1));
361 IntRect mergedTransformBounds(1, 2, 8, 8); 362 IntRect mergedTransformBounds(1, 2, 8, 8);
362 EXPECT_RECT_EQ(mergedTransformBounds, m_list.visualRect(2)); 363 EXPECT_RECT_EQ(mergedTransformBounds, m_list.visualRect(2));
363 EXPECT_RECT_EQ(drawingBBounds, m_list.visualRect(3)); 364 EXPECT_RECT_EQ(drawingBBounds, m_list.visualRect(3));
364 EXPECT_RECT_EQ(mergedTransformBounds, m_list.visualRect(4)); 365 EXPECT_RECT_EQ(mergedTransformBounds, m_list.visualRect(4));
365 EXPECT_RECT_EQ(mergedSubsequenceBounds, m_list.visualRect(5)); 366 EXPECT_RECT_EQ(mergedSubsequenceBounds, m_list.visualRect(5));
366 } 367 }
367 368
368 } // namespace 369 } // namespace
369 } // namespace blink 370 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698