OLD | NEW |
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 Loading... |
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); |
OLD | NEW |