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

Side by Side Diff: gm/testimagefilters.cpp

Issue 1822623002: switch colorfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 | « gm/tablecolorfilter.cpp ('k') | gm/textbloblooper.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 2011 Google Inc. 2 * Copyright 2011 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 "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkShader.h" 12 #include "SkShader.h"
13 13
14 #include "SkBlurImageFilter.h" 14 #include "SkBlurImageFilter.h"
15 #include "SkColorFilterImageFilter.h" 15 #include "SkColorFilterImageFilter.h"
16 #include "SkComposeImageFilter.h" 16 #include "SkComposeImageFilter.h"
17 #include "SkMergeImageFilter.h" 17 #include "SkMergeImageFilter.h"
18 #include "SkOffsetImageFilter.h" 18 #include "SkOffsetImageFilter.h"
19 #include "SkTestImageFilters.h" 19 #include "SkTestImageFilters.h"
20 20
21 #define FILTER_WIDTH SkIntToScalar(150) 21 #define FILTER_WIDTH SkIntToScalar(150)
22 #define FILTER_HEIGHT SkIntToScalar(200) 22 #define FILTER_HEIGHT SkIntToScalar(200)
23 23
24 static SkImageFilter* make0() { return SkDownSampleImageFilter::Create(SK_Scalar 1 / 5); } 24 static SkImageFilter* make0() { return SkDownSampleImageFilter::Create(SK_Scalar 1 / 5); }
25 static SkImageFilter* make1() { return SkOffsetImageFilter::Create(SkIntToScalar (16), SkIntToScalar(16)); } 25 static SkImageFilter* make1() { return SkOffsetImageFilter::Create(SkIntToScalar (16), SkIntToScalar(16)); }
26 static SkImageFilter* make2() { 26 static SkImageFilter* make2() {
27 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorBLUE, 27 auto cf = SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod e);
28 SkXfermode::kSrcIn_Mode) ; 28 return SkColorFilterImageFilter::Create(cf.get());
29 SkAutoUnref aur(cf);
30 return SkColorFilterImageFilter::Create(cf);
31 } 29 }
32 static SkImageFilter* make3() { 30 static SkImageFilter* make3() {
33 return SkBlurImageFilter::Create(8, 0); 31 return SkBlurImageFilter::Create(8, 0);
34 } 32 }
35 33
36 static SkImageFilter* make4() { 34 static SkImageFilter* make4() {
37 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16)); 35 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16));
38 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); 36 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
39 SkAutoUnref aur0(outer); 37 SkAutoUnref aur0(outer);
40 SkAutoUnref aur1(inner); 38 SkAutoUnref aur1(inner);
41 return SkComposeImageFilter::Create(outer, inner); 39 return SkComposeImageFilter::Create(outer, inner);
42 } 40 }
43 static SkImageFilter* make5() { 41 static SkImageFilter* make5() {
44 SkImageFilter* first = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16)); 42 SkImageFilter* first = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16));
45 SkImageFilter* second = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); 43 SkImageFilter* second = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
46 SkAutoUnref aur0(first); 44 SkAutoUnref aur0(first);
47 SkAutoUnref aur1(second); 45 SkAutoUnref aur1(second);
48 return SkMergeImageFilter::Create(first, second); 46 return SkMergeImageFilter::Create(first, second);
49 } 47 }
50 48
51 static SkImageFilter* make6() { 49 static SkImageFilter* make6() {
52 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16)); 50 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16));
53 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); 51 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
54 SkAutoUnref aur0(outer); 52 SkAutoUnref aur0(outer);
55 SkAutoUnref aur1(inner); 53 SkAutoUnref aur1(inner);
56 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner); 54 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner);
57 SkAutoUnref aur2(compose); 55 SkAutoUnref aur2(compose);
58 56
59 SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF, 57 auto cf = SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode) ;
60 SkXfermode::kSrcIn_Mode) ; 58 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf.get());
61 SkAutoUnref aur3(cf);
62 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf);
63 SkAutoUnref aur4(blue); 59 SkAutoUnref aur4(blue);
64 60
65 return SkMergeImageFilter::Create(compose, blue); 61 return SkMergeImageFilter::Create(compose, blue);
66 } 62 }
67 63
68 static SkImageFilter* make7() { 64 static SkImageFilter* make7() {
69 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16)); 65 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16));
70 SkImageFilter* inner = make3(); 66 SkImageFilter* inner = make3();
71 SkAutoUnref aur0(outer); 67 SkAutoUnref aur0(outer);
72 SkAutoUnref aur1(inner); 68 SkAutoUnref aur1(inner);
73 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner); 69 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner);
74 SkAutoUnref aur2(compose); 70 SkAutoUnref aur2(compose);
75 71
76 SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF, 72 auto cf = SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode) ;
77 SkXfermode::kSrcIn_Mode) ; 73 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf.get());
78 SkAutoUnref aur3(cf);
79 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf);
80 SkAutoUnref aur4(blue); 74 SkAutoUnref aur4(blue);
81 75
82 return SkMergeImageFilter::Create(compose, blue); 76 return SkMergeImageFilter::Create(compose, blue);
83 } 77 }
84 78
85 static void draw0(SkCanvas* canvas) { 79 static void draw0(SkCanvas* canvas) {
86 SkPaint p; 80 SkPaint p;
87 p.setAntiAlias(true); 81 p.setAntiAlias(true);
88 SkRect r = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT); 82 SkRect r = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT);
89 r.inset(SK_Scalar1 * 12, SK_Scalar1 * 12); 83 r.inset(SK_Scalar1 * 12, SK_Scalar1 * 12);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 129 }
136 } 130 }
137 131
138 private: 132 private:
139 typedef GM INHERITED; 133 typedef GM INHERITED;
140 }; 134 };
141 135
142 ////////////////////////////////////////////////////////////////////////////// 136 //////////////////////////////////////////////////////////////////////////////
143 137
144 DEF_GM( return new TestImageFiltersGM; ) 138 DEF_GM( return new TestImageFiltersGM; )
OLDNEW
« no previous file with comments | « gm/tablecolorfilter.cpp ('k') | gm/textbloblooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698