OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 virtual SkString onShortName() SK_OVERRIDE { | 46 virtual SkString onShortName() SK_OVERRIDE { |
47 return fName; | 47 return fName; |
48 } | 48 } |
49 | 49 |
50 virtual SkISize onISize() SK_OVERRIDE { | 50 virtual SkISize onISize() SK_OVERRIDE { |
51 return SkISize::Make(SkScalarCeilToInt(fRRect.rect().width()), | 51 return SkISize::Make(SkScalarCeilToInt(fRRect.rect().width()), |
52 SkScalarCeilToInt(fRRect.rect().height())); | 52 SkScalarCeilToInt(fRRect.rect().height())); |
53 } | 53 } |
54 | 54 |
55 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 55 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
56 SkLayerDrawLooper* looper = new SkLayerDrawLooper; | 56 SkLayerDrawLooper::Builder looperBuilder; |
57 { | 57 { |
58 SkLayerDrawLooper::LayerInfo info; | 58 SkLayerDrawLooper::LayerInfo info; |
59 info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit | 59 info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit |
60 | SkLayerDrawLooper::kColorFilter_Bit; | 60 | SkLayerDrawLooper::kColorFilter_Bit; |
61 info.fColorMode = SkXfermode::kSrc_Mode; | 61 info.fColorMode = SkXfermode::kSrc_Mode; |
62 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); | 62 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); |
63 info.fPostTranslate = false; | 63 info.fPostTranslate = false; |
64 SkPaint* paint = looper->addLayerOnTop(info); | 64 SkPaint* paint = looperBuilder.addLayerOnTop(info); |
65 SkMaskFilter* maskFilter = SkBlurMaskFilter::Create( | 65 SkMaskFilter* maskFilter = SkBlurMaskFilter::Create( |
66 SkBlurMaskFilter::kNormal_BlurStyle, | 66 SkBlurMaskFilter::kNormal_BlurStyle, |
67 SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf), | 67 SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf), |
68 SkBlurMaskFilter::kHighQuality_BlurFlag); | 68 SkBlurMaskFilter::kHighQuality_BlurFlag); |
69 paint->setMaskFilter(maskFilter)->unref(); | 69 paint->setMaskFilter(maskFilter)->unref(); |
70 SkColorFilter* colorFilter = SkColorFilter::CreateModeFilter(SK_Colo
rLTGRAY, | 70 SkColorFilter* colorFilter = SkColorFilter::CreateModeFilter(SK_Colo
rLTGRAY, |
71 SkXfermode::kSrcIn_Mode); | 71 SkXfermode::kSrcIn_Mode); |
72 paint->setColorFilter(colorFilter)->unref(); | 72 paint->setColorFilter(colorFilter)->unref(); |
73 paint->setColor(SK_ColorGRAY); | 73 paint->setColor(SK_ColorGRAY); |
74 } | 74 } |
75 { | 75 { |
76 SkLayerDrawLooper::LayerInfo info; | 76 SkLayerDrawLooper::LayerInfo info; |
77 looper->addLayerOnTop(info); | 77 looperBuilder.addLayerOnTop(info); |
78 } | 78 } |
79 SkPaint paint; | 79 SkPaint paint; |
80 canvas->drawRect(fRRect.rect(), paint); | 80 canvas->drawRect(fRRect.rect(), paint); |
81 | 81 |
82 paint.setLooper(looper)->unref(); | 82 paint.setLooper(looperBuilder.detachLooper())->unref(); |
83 paint.setColor(SK_ColorCYAN); | 83 paint.setColor(SK_ColorCYAN); |
84 paint.setAntiAlias(true); | 84 paint.setAntiAlias(true); |
85 | 85 |
86 canvas->drawRRect(fRRect, paint); | 86 canvas->drawRRect(fRRect, paint); |
87 } | 87 } |
88 | 88 |
89 private: | 89 private: |
90 SkString fName; | 90 SkString fName; |
91 SkRRect fRRect; | 91 SkRRect fRRect; |
92 | 92 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // TODO(scroggo): Disabled in an attempt to rememdy | 144 // TODO(scroggo): Disabled in an attempt to rememdy |
145 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: | 145 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: |
146 // ran wrong number of tests') | 146 // ran wrong number of tests') |
147 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) | 147 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) |
148 | 148 |
149 // Rounded rect with two opposite corners with large radii, the other two | 149 // Rounded rect with two opposite corners with large radii, the other two |
150 // small. | 150 // small. |
151 DEF_GM(return new BlurRoundRectGM(100, 100);) | 151 DEF_GM(return new BlurRoundRectGM(100, 100);) |
152 | 152 |
153 DEF_GM(return new SimpleBlurRoundRectGM();) | 153 DEF_GM(return new SimpleBlurRoundRectGM();) |
OLD | NEW |