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

Side by Side Diff: gm/testimagefilters.cpp

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 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/spritebitmap.cpp ('k') | gm/tileimagefilter.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 new SkDownSampleImageFilter(SK_Scalar1 / 5); } 24 static SkImageFilter* make0() { return SkDownSampleImageFilter::Create(SK_Scalar 1 / 5); }
25 static SkImageFilter* make1() { return new SkOffsetImageFilter(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 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorBLUE,
28 SkXfermode::kSrcIn_Mode) ; 28 SkXfermode::kSrcIn_Mode) ;
29 SkAutoUnref aur(cf); 29 SkAutoUnref aur(cf);
30 return SkColorFilterImageFilter::Create(cf); 30 return SkColorFilterImageFilter::Create(cf);
31 } 31 }
32 static SkImageFilter* make3() { 32 static SkImageFilter* make3() {
33 return new SkBlurImageFilter(8, 0); 33 return SkBlurImageFilter::Create(8, 0);
34 } 34 }
35 35
36 static SkImageFilter* make4() { 36 static SkImageFilter* make4() {
37 SkImageFilter* outer = new SkOffsetImageFilter(SkIntToScalar(16), SkIntToSca lar(16)); 37 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16));
38 SkImageFilter* inner = new SkDownSampleImageFilter(SK_Scalar1 / 5); 38 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
39 SkAutoUnref aur0(outer); 39 SkAutoUnref aur0(outer);
40 SkAutoUnref aur1(inner); 40 SkAutoUnref aur1(inner);
41 return new SkComposeImageFilter(outer, inner); 41 return SkComposeImageFilter::Create(outer, inner);
42 } 42 }
43 static SkImageFilter* make5() { 43 static SkImageFilter* make5() {
44 SkImageFilter* first = new SkOffsetImageFilter(SkIntToScalar(16), SkIntToSca lar(16)); 44 SkImageFilter* first = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16));
45 SkImageFilter* second = new SkDownSampleImageFilter(SK_Scalar1 / 5); 45 SkImageFilter* second = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
46 SkAutoUnref aur0(first); 46 SkAutoUnref aur0(first);
47 SkAutoUnref aur1(second); 47 SkAutoUnref aur1(second);
48 return new SkMergeImageFilter(first, second); 48 return SkMergeImageFilter::Create(first, second);
49 } 49 }
50 50
51 static SkImageFilter* make6() { 51 static SkImageFilter* make6() {
52 SkImageFilter* outer = new SkOffsetImageFilter(SkIntToScalar(16), SkIntToSca lar(16)); 52 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16));
53 SkImageFilter* inner = new SkDownSampleImageFilter(SK_Scalar1 / 5); 53 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
54 SkAutoUnref aur0(outer); 54 SkAutoUnref aur0(outer);
55 SkAutoUnref aur1(inner); 55 SkAutoUnref aur1(inner);
56 SkImageFilter* compose = new SkComposeImageFilter(outer, inner); 56 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner);
57 SkAutoUnref aur2(compose); 57 SkAutoUnref aur2(compose);
58 58
59 SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF, 59 SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF,
60 SkXfermode::kSrcIn_Mode) ; 60 SkXfermode::kSrcIn_Mode) ;
61 SkAutoUnref aur3(cf); 61 SkAutoUnref aur3(cf);
62 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf); 62 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf);
63 SkAutoUnref aur4(blue); 63 SkAutoUnref aur4(blue);
64 64
65 return new SkMergeImageFilter(compose, blue); 65 return SkMergeImageFilter::Create(compose, blue);
66 } 66 }
67 67
68 static SkImageFilter* make7() { 68 static SkImageFilter* make7() {
69 SkImageFilter* outer = new SkOffsetImageFilter(SkIntToScalar(16), SkIntToSca lar(16)); 69 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT oScalar(16));
70 SkImageFilter* inner = make3(); 70 SkImageFilter* inner = make3();
71 SkAutoUnref aur0(outer); 71 SkAutoUnref aur0(outer);
72 SkAutoUnref aur1(inner); 72 SkAutoUnref aur1(inner);
73 SkImageFilter* compose = new SkComposeImageFilter(outer, inner); 73 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner);
74 SkAutoUnref aur2(compose); 74 SkAutoUnref aur2(compose);
75 75
76 SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF, 76 SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF,
77 SkXfermode::kSrcIn_Mode) ; 77 SkXfermode::kSrcIn_Mode) ;
78 SkAutoUnref aur3(cf); 78 SkAutoUnref aur3(cf);
79 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf); 79 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf);
80 SkAutoUnref aur4(blue); 80 SkAutoUnref aur4(blue);
81 81
82 return new SkMergeImageFilter(compose, blue); 82 return SkMergeImageFilter::Create(compose, blue);
83 } 83 }
84 84
85 static void draw0(SkCanvas* canvas) { 85 static void draw0(SkCanvas* canvas) {
86 SkPaint p; 86 SkPaint p;
87 p.setAntiAlias(true); 87 p.setAntiAlias(true);
88 SkRect r = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT); 88 SkRect r = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT);
89 r.inset(SK_Scalar1 * 12, SK_Scalar1 * 12); 89 r.inset(SK_Scalar1 * 12, SK_Scalar1 * 12);
90 p.setColor(SK_ColorRED); 90 p.setColor(SK_ColorRED);
91 canvas->drawOval(r, p); 91 canvas->drawOval(r, p);
92 } 92 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 137
138 private: 138 private:
139 typedef GM INHERITED; 139 typedef GM INHERITED;
140 }; 140 };
141 141
142 ////////////////////////////////////////////////////////////////////////////// 142 //////////////////////////////////////////////////////////////////////////////
143 143
144 static skiagm::GM* MyFactory(void*) { return new TestImageFiltersGM; } 144 static skiagm::GM* MyFactory(void*) { return new TestImageFiltersGM; }
145 static skiagm::GMRegistry reg(MyFactory); 145 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/spritebitmap.cpp ('k') | gm/tileimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698