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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 static uint16_t gBG[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF }; | 36 static uint16_t gBG[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF }; |
37 | 37 |
38 class XfermodesBlurView : public SampleView { | 38 class XfermodesBlurView : public SampleView { |
39 SkBitmap fBG; | 39 SkBitmap fBG; |
40 SkBitmap fSrcB, fDstB; | 40 SkBitmap fSrcB, fDstB; |
41 | 41 |
42 void draw_mode(SkCanvas* canvas, sk_sp<SkXfermode> mode, int alpha, | 42 void draw_mode(SkCanvas* canvas, sk_sp<SkXfermode> mode, int alpha, |
43 SkScalar x, SkScalar y) { | 43 SkScalar x, SkScalar y) { |
44 SkPaint p; | 44 SkPaint p; |
45 SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, | 45 p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, |
46 SkBlurMask::ConvertRadiusToSigma(SkIntToS
calar(5)), | 46 SkBlurMask::ConvertRadiusToSigma(
5), |
47 SkBlurMaskFilter::kNone_BlurFlag); | 47 SkBlurMaskFilter::kNone_BlurFlag)
); |
48 p.setMaskFilter(mf)->unref(); | |
49 | 48 |
50 SkScalar ww = SkIntToScalar(W); | 49 SkScalar ww = SkIntToScalar(W); |
51 SkScalar hh = SkIntToScalar(H); | 50 SkScalar hh = SkIntToScalar(H); |
52 | 51 |
53 // draw a circle covering the upper | 52 // draw a circle covering the upper |
54 // left three quarters of the canvas | 53 // left three quarters of the canvas |
55 p.setColor(0xFFCC44FF); | 54 p.setColor(0xFFCC44FF); |
56 SkRect r; | 55 SkRect r; |
57 r.set(0, 0, ww*3/4, hh*3/4); | 56 r.set(0, 0, ww*3/4, hh*3/4); |
58 r.offset(x, y); | 57 r.offset(x, y); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 193 } |
195 | 194 |
196 private: | 195 private: |
197 typedef SampleView INHERITED; | 196 typedef SampleView INHERITED; |
198 }; | 197 }; |
199 | 198 |
200 ////////////////////////////////////////////////////////////////////////////// | 199 ////////////////////////////////////////////////////////////////////////////// |
201 | 200 |
202 static SkView* MyFactory() { return new XfermodesBlurView; } | 201 static SkView* MyFactory() { return new XfermodesBlurView; } |
203 static SkViewRegister reg(MyFactory); | 202 static SkViewRegister reg(MyFactory); |
OLD | NEW |