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

Side by Side Diff: samplecode/SampleAvoid.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/SampleAll.cpp ('k') | samplecode/SamplePathEffects.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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 { 255-16, SkAvoidXfermode::kTargetColor_Mode, 1, 1 }, 71 { 255-16, SkAvoidXfermode::kTargetColor_Mode, 1, 1 },
72 }; 72 };
73 73
74 paint.setShader(NULL); 74 paint.setShader(NULL);
75 paint.setColor(SK_ColorMAGENTA); 75 paint.setColor(SK_ColorMAGENTA);
76 76
77 SkPaint frameP; 77 SkPaint frameP;
78 frameP.setStyle(SkPaint::kStroke_Style); 78 frameP.setStyle(SkPaint::kStroke_Style);
79 79
80 for (size_t i = 0; i < SK_ARRAY_COUNT(gData); i++) { 80 for (size_t i = 0; i < SK_ARRAY_COUNT(gData); i++) {
81 SkAvoidXfermode mode(SK_ColorGREEN, gData[i].fTolerance, 81 SkAutoTUnref<SkAvoidXfermode> mode(SkAvoidXfermode::Create(
82 gData[i].fMode); 82 SK_ColorGREEN, gData[i].fTolerance, gData[i].fMode));
83 paint.setXfermode(&mode); 83 paint.setXfermode(mode);
84 int div = 3; 84 int div = 3;
85 SkRect rr = { 0, 0, r.width()/div, r.height()/div }; 85 SkRect rr = { 0, 0, r.width()/div, r.height()/div };
86 rr.offset(r.width()/4 - rr.width()/2, r.height()/4 - rr.height()/2); 86 rr.offset(r.width()/4 - rr.width()/2, r.height()/4 - rr.height()/2);
87 rr.offset(r.width() * gData[i].fDX/2, r.height() * gData[i].fDY/2); 87 rr.offset(r.width() * gData[i].fDX/2, r.height() * gData[i].fDY/2);
88 canvas->drawRect(rr, paint); 88 canvas->drawRect(rr, paint);
89 paint.setXfermode(NULL); 89 paint.setXfermode(NULL);
90 90
91 canvas->drawRect(rr, frameP); 91 canvas->drawRect(rr, frameP);
92 } 92 }
93 } 93 }
94 94
95 private: 95 private:
96 typedef SampleView INHERITED; 96 typedef SampleView INHERITED;
97 }; 97 };
98 98
99 ////////////////////////////////////////////////////////////////////////////// 99 //////////////////////////////////////////////////////////////////////////////
100 100
101 static SkView* MyFactory() { 101 static SkView* MyFactory() {
102 return new AvoidView; 102 return new AvoidView;
103 } 103 }
104 104
105 static SkViewRegister reg(MyFactory); 105 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleAll.cpp ('k') | samplecode/SamplePathEffects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698