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

Side by Side Diff: samplecode/SamplePathEffects.cpp

Issue 166583002: Factory methods for heap-allocated SkPathEffect and SkXfermode objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update experimental/PdfViewer Created 6 years, 10 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 | « samplecode/SampleAvoid.cpp ('k') | samplecode/SamplePathUtils.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 11 matching lines...) Expand all
22 22
23 #define CORNER_RADIUS 12 23 #define CORNER_RADIUS 12
24 static SkScalar gPhase; 24 static SkScalar gPhase;
25 25
26 static const int gXY[] = { 26 static const int gXY[] = {
27 4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4 27 4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4
28 }; 28 };
29 29
30 static SkPathEffect* make_pe(int flags) { 30 static SkPathEffect* make_pe(int flags) {
31 if (flags == 1) 31 if (flags == 1)
32 return new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS)); 32 return SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
33 33
34 SkPath path; 34 SkPath path;
35 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); 35 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
36 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) 36 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2)
37 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); 37 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
38 path.close(); 38 path.close();
39 path.offset(SkIntToScalar(-6), 0); 39 path.offset(SkIntToScalar(-6), 0);
40 40
41 SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), gPhase , SkPath1DPathEffect::kRotate_Style); 41 SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12), gP hase, SkPath1DPathEffect::kRotate_Style);
42 42
43 if (flags == 2) 43 if (flags == 2)
44 return outer; 44 return outer;
45 45
46 SkPathEffect* inner = new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS)); 46 SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS ));
47 47
48 SkPathEffect* pe = new SkComposePathEffect(outer, inner); 48 SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
49 outer->unref(); 49 outer->unref();
50 inner->unref(); 50 inner->unref();
51 return pe; 51 return pe;
52 } 52 }
53 53
54 static SkPathEffect* make_warp_pe() { 54 static SkPathEffect* make_warp_pe() {
55 SkPath path; 55 SkPath path;
56 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); 56 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
57 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) 57 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2)
58 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); 58 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
59 path.close(); 59 path.close();
60 path.offset(SkIntToScalar(-6), 0); 60 path.offset(SkIntToScalar(-6), 0);
61 61
62 SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), gPhase , SkPath1DPathEffect::kMorph_Style); 62 SkPathEffect* outer = SkPath1DPathEffect::Create(
63 SkPathEffect* inner = new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS)); 63 path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kMorph_Style);
64 SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS ));
64 65
65 SkPathEffect* pe = new SkComposePathEffect(outer, inner); 66 SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
66 outer->unref(); 67 outer->unref();
67 inner->unref(); 68 inner->unref();
68 return pe; 69 return pe;
69 } 70 }
70 71
71 /////////////////////////////////////////////////////////// 72 ///////////////////////////////////////////////////////////
72 73
73 #include "SkColorFilter.h" 74 #include "SkColorFilter.h"
74 #include "SkLayerRasterizer.h" 75 #include "SkLayerRasterizer.h"
75 76
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 182 }
182 183
183 private: 184 private:
184 typedef SampleView INHERITED; 185 typedef SampleView INHERITED;
185 }; 186 };
186 187
187 ////////////////////////////////////////////////////////////////////////////// 188 //////////////////////////////////////////////////////////////////////////////
188 189
189 static SkView* MyFactory() { return new PathEffectView; } 190 static SkView* MyFactory() { return new PathEffectView; }
190 static SkViewRegister reg(MyFactory); 191 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleAvoid.cpp ('k') | samplecode/SamplePathUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698