| 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 "gm.h" | 8 #include "gm.h" |
| 9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
| 10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } gParams[] = { | 67 } gParams[] = { |
| 68 { SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0
}, | 68 { SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0
}, |
| 69 { SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 }, | 69 { SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 }, |
| 70 { SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 }, | 70 { SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 }, |
| 71 { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToSca
lar(3) } | 71 { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToSca
lar(3) } |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 fLooper = new SkLayerDrawLooper; | 74 fLooper = new SkLayerDrawLooper; |
| 75 | 75 |
| 76 SkLayerDrawLooper::LayerInfo info; | 76 SkLayerDrawLooper::LayerInfo info; |
| 77 #ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS |
| 77 info.fFlagsMask = SkPaint::kAntiAlias_Flag; | 78 info.fFlagsMask = SkPaint::kAntiAlias_Flag; |
| 79 // I presume we can live w/o this feature...? |
| 80 #endif |
| 78 info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMa
skFilter_Bit; | 81 info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMa
skFilter_Bit; |
| 79 info.fColorMode = SkXfermode::kSrc_Mode; | 82 info.fColorMode = SkXfermode::kSrc_Mode; |
| 80 | 83 |
| 81 for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) { | 84 for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) { |
| 82 info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset); | 85 info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset); |
| 83 SkPaint* paint = fLooper->addLayer(info); | 86 SkPaint* paint = fLooper->addLayer(info); |
| 84 paint->setAntiAlias(true); | 87 paint->setAntiAlias(true); |
| 85 paint->setColor(gParams[i].fColor); | 88 paint->setColor(gParams[i].fColor); |
| 86 paint->setStyle(gParams[i].fStyle); | 89 paint->setStyle(gParams[i].fStyle); |
| 87 paint->setStrokeWidth(gParams[i].fWidth); | 90 paint->setStrokeWidth(gParams[i].fWidth); |
| 88 if (gParams[i].fBlur > 0) { | 91 if (gParams[i].fBlur > 0) { |
| 89 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN
ormal_BlurStyle, | 92 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN
ormal_BlurStyle, |
| 90 SkBlurMask::ConvertRadiusToSigma(gParam
s[i].fBlur)); | 93 SkBlurMask::ConvertRadiusToSigma(gParam
s[i].fBlur)); |
| 91 paint->setMaskFilter(mf)->unref(); | 94 paint->setMaskFilter(mf)->unref(); |
| 92 } | 95 } |
| 93 } | 96 } |
| 94 } | 97 } |
| 95 | 98 |
| 96 typedef GM INHERITED; | 99 typedef GM INHERITED; |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 ////////////////////////////////////////////////////////////////////////////// | 102 ////////////////////////////////////////////////////////////////////////////// |
| 100 | 103 |
| 101 static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; } | 104 static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; } |
| 102 static skiagm::GMRegistry reg(MyFactory); | 105 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |