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

Side by Side Diff: tests/PaintImageFilterTest.cpp

Issue 1790353002: Revert of more shader-->sp conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « tests/ImageFilterTest.cpp ('k') | tests/PictureShaderTest.cpp » ('j') | 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 12 matching lines...) Expand all
23 23
24 paintResult.allocN32Pixels(w, h); 24 paintResult.allocN32Pixels(w, h);
25 SkCanvas canvasPaint(paintResult); 25 SkCanvas canvasPaint(paintResult);
26 canvasPaint.clear(0x00000000); 26 canvasPaint.clear(0x00000000);
27 27
28 SkPoint center = SkPoint::Make(SkIntToScalar(5), SkIntToScalar(5)); 28 SkPoint center = SkPoint::Make(SkIntToScalar(5), SkIntToScalar(5));
29 SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN}; 29 SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN};
30 SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1}; 30 SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1};
31 SkScalar radius = SkIntToScalar(5); 31 SkScalar radius = SkIntToScalar(5);
32 32
33 SkAutoTUnref<SkShader> s(SkGradientShader::CreateRadial(
34 center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_Ti leMode));
33 SkPaint gradientPaint; 35 SkPaint gradientPaint;
34 gradientPaint.setShader(SkGradientShader::MakeRadial( 36 gradientPaint.setShader(s);
35 center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_Ti leMode));
36 37
37 // Test using the image filter 38 // Test using the image filter
38 { 39 {
39 SkPaint paint; 40 SkPaint paint;
40 SkImageFilter::CropRect cr(r); 41 SkImageFilter::CropRect cr(r);
41 paint.setImageFilter(SkPaintImageFilter::Create(gradientPaint, &cr))->un ref(); 42 paint.setImageFilter(SkPaintImageFilter::Create(gradientPaint, &cr))->un ref();
42 canvasFilter.drawRect(r, paint); 43 canvasFilter.drawRect(r, paint);
43 } 44 }
44 45
45 // Test using the paint directly 46 // Test using the paint directly
(...skipping 23 matching lines...) Expand all
69 70
70 paintResult.allocN32Pixels(w, h); 71 paintResult.allocN32Pixels(w, h);
71 SkCanvas canvasPaint(paintResult); 72 SkCanvas canvasPaint(paintResult);
72 canvasPaint.clear(0x00000000); 73 canvasPaint.clear(0x00000000);
73 74
74 SkPoint center = SkPoint::Make(SkIntToScalar(5), SkIntToScalar(5)); 75 SkPoint center = SkPoint::Make(SkIntToScalar(5), SkIntToScalar(5));
75 SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN}; 76 SkColor colors[] = {SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN};
76 SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1}; 77 SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1};
77 SkScalar radius = SkIntToScalar(5); 78 SkScalar radius = SkIntToScalar(5);
78 79
80 SkAutoTUnref<SkShader> s(SkGradientShader::CreateRadial(
81 center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_Ti leMode));
79 SkPaint gradientPaint; 82 SkPaint gradientPaint;
80 gradientPaint.setShader(SkGradientShader::MakeRadial( 83 gradientPaint.setShader(s);
81 center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_Ti leMode));
82 84
83 // Test using the image filter 85 // Test using the image filter
84 { 86 {
85 SkPaint paint; 87 SkPaint paint;
86 SkImageFilter::CropRect cr(r); 88 SkImageFilter::CropRect cr(r);
87 paint.setImageFilter(SkPaintImageFilter::Create(gradientPaint, &cr))->un ref(); 89 paint.setImageFilter(SkPaintImageFilter::Create(gradientPaint, &cr))->un ref();
88 canvasFilter.scale(SkIntToScalar(2), SkIntToScalar(2)); 90 canvasFilter.scale(SkIntToScalar(2), SkIntToScalar(2));
89 canvasFilter.drawRect(r, paint); 91 canvasFilter.drawRect(r, paint);
90 } 92 }
91 93
(...skipping 10 matching lines...) Expand all
102 for (int x = 0; x < r.width(); ++x, ++filterPtr, ++paintPtr) { 104 for (int x = 0; x < r.width(); ++x, ++filterPtr, ++paintPtr) {
103 REPORTER_ASSERT(reporter, *filterPtr == *paintPtr); 105 REPORTER_ASSERT(reporter, *filterPtr == *paintPtr);
104 } 106 }
105 } 107 }
106 } 108 }
107 109
108 DEF_TEST(PaintImageFilter, reporter) { 110 DEF_TEST(PaintImageFilter, reporter) {
109 test_unscaled(reporter); 111 test_unscaled(reporter);
110 test_scaled(reporter); 112 test_scaled(reporter);
111 } 113 }
OLDNEW
« no previous file with comments | « tests/ImageFilterTest.cpp ('k') | tests/PictureShaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698