| 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 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual SkString onShortName() SK_OVERRIDE { | 34 virtual SkString onShortName() SK_OVERRIDE { |
| 35 return SkString("drawlooper"); | 35 return SkString("drawlooper"); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 38 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 39 this->init(); | 39 this->init(); |
| 40 | 40 |
| 41 SkPaint paint; | 41 SkPaint paint; |
| 42 paint.setAntiAlias(true); |
| 42 paint.setTextSize(SkIntToScalar(72)); | 43 paint.setTextSize(SkIntToScalar(72)); |
| 43 paint.setLooper(fLooper); | 44 paint.setLooper(fLooper); |
| 44 | 45 |
| 45 canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50), | 46 canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50), |
| 46 SkIntToScalar(30), paint); | 47 SkIntToScalar(30), paint); |
| 47 | 48 |
| 48 canvas->drawRectCoords(SkIntToScalar(150), SkIntToScalar(50), | 49 canvas->drawRectCoords(SkIntToScalar(150), SkIntToScalar(50), |
| 49 SkIntToScalar(200), SkIntToScalar(100), paint); | 50 SkIntToScalar(200), SkIntToScalar(100), paint); |
| 50 | 51 |
| 51 canvas->drawText("Looper", 6, SkIntToScalar(230), SkIntToScalar(100), | 52 canvas->drawText("Looper", 6, SkIntToScalar(230), SkIntToScalar(100), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 67 } gParams[] = { | 68 } gParams[] = { |
| 68 { SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0
}, | 69 { SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0
}, |
| 69 { SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 }, | 70 { SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 }, |
| 70 { SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 }, | 71 { SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 }, |
| 71 { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToSca
lar(3) } | 72 { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToSca
lar(3) } |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 fLooper = new SkLayerDrawLooper; | 75 fLooper = new SkLayerDrawLooper; |
| 75 | 76 |
| 76 SkLayerDrawLooper::LayerInfo info; | 77 SkLayerDrawLooper::LayerInfo info; |
| 77 info.fFlagsMask = SkPaint::kAntiAlias_Flag; | |
| 78 info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMa
skFilter_Bit; | 78 info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMa
skFilter_Bit; |
| 79 info.fColorMode = SkXfermode::kSrc_Mode; | 79 info.fColorMode = SkXfermode::kSrc_Mode; |
| 80 | 80 |
| 81 for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) { | 81 for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) { |
| 82 info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset); | 82 info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset); |
| 83 SkPaint* paint = fLooper->addLayer(info); | 83 SkPaint* paint = fLooper->addLayer(info); |
| 84 paint->setAntiAlias(true); | |
| 85 paint->setColor(gParams[i].fColor); | 84 paint->setColor(gParams[i].fColor); |
| 86 paint->setStyle(gParams[i].fStyle); | 85 paint->setStyle(gParams[i].fStyle); |
| 87 paint->setStrokeWidth(gParams[i].fWidth); | 86 paint->setStrokeWidth(gParams[i].fWidth); |
| 88 if (gParams[i].fBlur > 0) { | 87 if (gParams[i].fBlur > 0) { |
| 89 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN
ormal_BlurStyle, | 88 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN
ormal_BlurStyle, |
| 90 SkBlurMask::ConvertRadiusToSigma(gParam
s[i].fBlur)); | 89 SkBlurMask::ConvertRadiusToSigma(gParam
s[i].fBlur)); |
| 91 paint->setMaskFilter(mf)->unref(); | 90 paint->setMaskFilter(mf)->unref(); |
| 92 } | 91 } |
| 93 } | 92 } |
| 94 } | 93 } |
| 95 | 94 |
| 96 typedef GM INHERITED; | 95 typedef GM INHERITED; |
| 97 }; | 96 }; |
| 98 | 97 |
| 99 ////////////////////////////////////////////////////////////////////////////// | 98 ////////////////////////////////////////////////////////////////////////////// |
| 100 | 99 |
| 101 static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; } | 100 static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; } |
| 102 static skiagm::GMRegistry reg(MyFactory); | 101 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |