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

Side by Side Diff: third_party/WebKit/Source/platform/mac/GraphicsContextCanvasTest.mm

Issue 2752593002: cc: Make PaintCanvas abstract (Closed)
Patch Set: Remove default parameters on virtual functions Created 3 years, 9 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/PaintCanvas.h ('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 (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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/mac/GraphicsContextCanvas.h" 5 #include "platform/mac/GraphicsContextCanvas.h"
6 #include "skia/ext/skia_utils_mac.h" 6 #include "skia/ext/skia_utils_mac.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 enum TestType { 11 enum TestType {
12 TestIdentity = 0, 12 TestIdentity = 0,
13 TestTranslate = 1, 13 TestTranslate = 1,
14 TestClip = 2, 14 TestClip = 2,
15 TestXClip = TestTranslate | TestClip, 15 TestXClip = TestTranslate | TestClip,
16 }; 16 };
17 17
18 void RunTest(TestType test) { 18 void RunTest(TestType test) {
19 const unsigned width = 2; 19 const unsigned width = 2;
20 const unsigned height = 2; 20 const unsigned height = 2;
21 const unsigned storageSize = width * height; 21 const unsigned storageSize = width * height;
22 const unsigned original[] = {0xFF333333, 0xFF666666, 0xFF999999, 0xFFCCCCCC}; 22 const unsigned original[] = {0xFF333333, 0xFF666666, 0xFF999999, 0xFFCCCCCC};
23 EXPECT_EQ(storageSize, sizeof(original) / sizeof(original[0])); 23 EXPECT_EQ(storageSize, sizeof(original) / sizeof(original[0]));
24 unsigned bits[storageSize]; 24 unsigned bits[storageSize];
25 memcpy(bits, original, sizeof(original)); 25 memcpy(bits, original, sizeof(original));
26 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 26 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
27 SkBitmap bitmap; 27 SkBitmap bitmap;
28 bitmap.installPixels(info, bits, info.minRowBytes()); 28 bitmap.installPixels(info, bits, info.minRowBytes());
29 29
30 PaintCanvas canvas(bitmap); 30 SkiaPaintCanvas canvas(bitmap);
31 if (test & TestTranslate) 31 if (test & TestTranslate)
32 canvas.translate(width / 2, 0); 32 canvas.translate(width / 2, 0);
33 if (test & TestClip) { 33 if (test & TestClip) {
34 SkRect clipRect = {0, height / 2, width, height}; 34 SkRect clipRect = {0, height / 2, width, height};
35 canvas.clipRect(clipRect); 35 canvas.clipRect(clipRect);
36 } 36 }
37 { 37 {
38 SkIRect clip = 38 SkIRect clip =
39 SkIRect::MakeSize(canvas.getBaseLayerSize()) 39 SkIRect::MakeSize(canvas.getBaseLayerSize())
40 .makeOffset( 40 .makeOffset(
(...skipping 25 matching lines...) Expand all
66 66
67 TEST(GraphicsContextCanvasTest, Clip) { 67 TEST(GraphicsContextCanvasTest, Clip) {
68 RunTest(TestClip); 68 RunTest(TestClip);
69 } 69 }
70 70
71 TEST(GraphicsContextCanvasTest, XClip) { 71 TEST(GraphicsContextCanvasTest, XClip) {
72 RunTest(TestXClip); 72 RunTest(TestXClip);
73 } 73 }
74 74
75 } // namespace 75 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/PaintCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698