OLD | NEW |
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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 SkXfermode* mode = SkXfermode::Create(gModes[i].fMode); | 173 SkXfermode* mode = SkXfermode::Create(gModes[i].fMode); |
174 SkAutoUnref aur(mode); | 174 SkAutoUnref aur(mode); |
175 SkRect r; | 175 SkRect r; |
176 r.set(x, y, x+w, y+h); | 176 r.set(x, y, x+w, y+h); |
177 | 177 |
178 SkPaint p; | 178 SkPaint p; |
179 p.setStyle(SkPaint::kFill_Style); | 179 p.setStyle(SkPaint::kFill_Style); |
180 p.setShader(s); | 180 p.setShader(s); |
181 canvas->drawRect(r, p); | 181 canvas->drawRect(r, p); |
182 | 182 |
183 canvas->saveLayer(&r, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag); | 183 canvas->saveLayer(&r, NULL); |
184 draw_mode(canvas, mode, twice ? 0x88 : 0xFF, r.fLeft, r.fTop); | 184 draw_mode(canvas, mode, twice ? 0x88 : 0xFF, r.fLeft, r.fTop); |
185 canvas->restore(); | 185 canvas->restore(); |
186 | 186 |
187 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); | 187 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); |
188 p.setStyle(SkPaint::kStroke_Style); | 188 p.setStyle(SkPaint::kStroke_Style); |
189 p.setShader(NULL); | 189 p.setShader(NULL); |
190 canvas->drawRect(r, p); | 190 canvas->drawRect(r, p); |
191 | 191 |
192 canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel), | 192 canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel), |
193 x + w/2, y - labelP.getTextSize()/2, labelP); | 193 x + w/2, y - labelP.getTextSize()/2, labelP); |
194 x += w + SkIntToScalar(10); | 194 x += w + SkIntToScalar(10); |
195 if ((i % W) == W - 1) { | 195 if ((i % W) == W - 1) { |
196 x = x0; | 196 x = x0; |
197 y += h + SkIntToScalar(30); | 197 y += h + SkIntToScalar(30); |
198 } | 198 } |
199 } | 199 } |
200 x0 += SkIntToScalar(400); | 200 x0 += SkIntToScalar(400); |
201 } | 201 } |
202 s->unref(); | 202 s->unref(); |
203 } | 203 } |
204 | 204 |
205 private: | 205 private: |
206 typedef SampleView INHERITED; | 206 typedef SampleView INHERITED; |
207 }; | 207 }; |
208 | 208 |
209 ////////////////////////////////////////////////////////////////////////////// | 209 ////////////////////////////////////////////////////////////////////////////// |
210 | 210 |
211 static SkView* MyFactory() { return new XfermodesBlurView; } | 211 static SkView* MyFactory() { return new XfermodesBlurView; } |
212 static SkViewRegister reg(MyFactory); | 212 static SkViewRegister reg(MyFactory); |
OLD | NEW |