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

Side by Side Diff: tests/PaintImageFilterTest.cpp

Issue 1842793002: Switch SkLocalMatrixImageFilter and SkPaintImageFilter over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Ooops 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 | « tests/ImageFilterTest.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 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkPaintImageFilter.h" 10 #include "SkPaintImageFilter.h"
(...skipping 20 matching lines...) Expand all
31 SkScalar radius = SkIntToScalar(5); 31 SkScalar radius = SkIntToScalar(5);
32 32
33 SkPaint gradientPaint; 33 SkPaint gradientPaint;
34 gradientPaint.setShader(SkGradientShader::MakeRadial( 34 gradientPaint.setShader(SkGradientShader::MakeRadial(
35 center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_Ti leMode)); 35 center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_Ti leMode));
36 36
37 // Test using the image filter 37 // Test using the image filter
38 { 38 {
39 SkPaint paint; 39 SkPaint paint;
40 SkImageFilter::CropRect cr(r); 40 SkImageFilter::CropRect cr(r);
41 paint.setImageFilter(SkPaintImageFilter::Create(gradientPaint, &cr))->un ref(); 41 paint.setImageFilter(SkPaintImageFilter::Make(gradientPaint, &cr));
42 canvasFilter.drawRect(r, paint); 42 canvasFilter.drawRect(r, paint);
43 } 43 }
44 44
45 // Test using the paint directly 45 // Test using the paint directly
46 { 46 {
47 canvasPaint.drawRect(r, gradientPaint); 47 canvasPaint.drawRect(r, gradientPaint);
48 } 48 }
49 49
50 // Assert that both paths yielded the same result 50 // Assert that both paths yielded the same result
51 for (int y = 0; y < r.height(); ++y) { 51 for (int y = 0; y < r.height(); ++y) {
(...skipping 25 matching lines...) Expand all
77 SkScalar radius = SkIntToScalar(5); 77 SkScalar radius = SkIntToScalar(5);
78 78
79 SkPaint gradientPaint; 79 SkPaint gradientPaint;
80 gradientPaint.setShader(SkGradientShader::MakeRadial( 80 gradientPaint.setShader(SkGradientShader::MakeRadial(
81 center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_Ti leMode)); 81 center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_Ti leMode));
82 82
83 // Test using the image filter 83 // Test using the image filter
84 { 84 {
85 SkPaint paint; 85 SkPaint paint;
86 SkImageFilter::CropRect cr(r); 86 SkImageFilter::CropRect cr(r);
87 paint.setImageFilter(SkPaintImageFilter::Create(gradientPaint, &cr))->un ref(); 87 paint.setImageFilter(SkPaintImageFilter::Make(gradientPaint, &cr));
88 canvasFilter.scale(SkIntToScalar(2), SkIntToScalar(2)); 88 canvasFilter.scale(SkIntToScalar(2), SkIntToScalar(2));
89 canvasFilter.drawRect(r, paint); 89 canvasFilter.drawRect(r, paint);
90 } 90 }
91 91
92 // Test using the paint directly 92 // Test using the paint directly
93 { 93 {
94 canvasPaint.scale(SkIntToScalar(2), SkIntToScalar(2)); 94 canvasPaint.scale(SkIntToScalar(2), SkIntToScalar(2));
95 canvasPaint.drawRect(r, gradientPaint); 95 canvasPaint.drawRect(r, gradientPaint);
96 } 96 }
97 97
98 // Assert that both paths yielded the same result 98 // Assert that both paths yielded the same result
99 for (int y = 0; y < r.height(); ++y) { 99 for (int y = 0; y < r.height(); ++y) {
100 const SkPMColor* filterPtr = filterResult.getAddr32(0, y); 100 const SkPMColor* filterPtr = filterResult.getAddr32(0, y);
101 const SkPMColor* paintPtr = paintResult.getAddr32(0, y); 101 const SkPMColor* paintPtr = paintResult.getAddr32(0, y);
102 for (int x = 0; x < r.width(); ++x, ++filterPtr, ++paintPtr) { 102 for (int x = 0; x < r.width(); ++x, ++filterPtr, ++paintPtr) {
103 REPORTER_ASSERT(reporter, *filterPtr == *paintPtr); 103 REPORTER_ASSERT(reporter, *filterPtr == *paintPtr);
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 DEF_TEST(PaintImageFilter, reporter) { 108 DEF_TEST(PaintImageFilter, reporter) {
109 test_unscaled(reporter); 109 test_unscaled(reporter);
110 test_scaled(reporter); 110 test_scaled(reporter);
111 } 111 }
OLDNEW
« no previous file with comments | « tests/ImageFilterTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698