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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
10 #include "SkBlurImageFilter.h" | 10 #include "SkBlurImageFilter.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 SkPaint greenPaint; | 132 SkPaint greenPaint; |
133 greenPaint.setColor(SK_ColorGREEN); | 133 greenPaint.setColor(SK_ColorGREEN); |
134 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)
), greenPaint); | 134 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)
), greenPaint); |
135 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); | 135 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); |
136 sk_sp<SkImageFilter> pictureFilter(SkPictureImageFilter::Make(picture)); | 136 sk_sp<SkImageFilter> pictureFilter(SkPictureImageFilter::Make(picture)); |
137 sk_sp<SkShader> shader(SkPerlinNoiseShader::MakeTurbulence(SK_Scalar1, S
K_Scalar1, 1, 0)); | 137 sk_sp<SkShader> shader(SkPerlinNoiseShader::MakeTurbulence(SK_Scalar1, S
K_Scalar1, 1, 0)); |
138 | 138 |
139 SkPaint paint; | 139 SkPaint paint; |
140 paint.setShader(shader); | 140 paint.setShader(shader); |
141 SkAutoTUnref<SkImageFilter> paintFilter(SkPaintImageFilter::Create(paint
)); | 141 sk_sp<SkImageFilter> paintFilter(SkPaintImageFilter::Make(paint)); |
142 | 142 |
143 sk_sp<SkShader> greenColorShader(SkShader::MakeColorShader(SK_ColorGREEN
)); | 143 sk_sp<SkShader> greenColorShader(SkShader::MakeColorShader(SK_ColorGREEN
)); |
144 SkPaint greenColorShaderPaint; | 144 SkPaint greenColorShaderPaint; |
145 greenColorShaderPaint.setShader(greenColorShader); | 145 greenColorShaderPaint.setShader(greenColorShader); |
146 SkImageFilter::CropRect leftSideCropRect(SkRect::MakeXYWH(0, 0, 32, 64))
; | 146 SkImageFilter::CropRect leftSideCropRect(SkRect::MakeXYWH(0, 0, 32, 64))
; |
147 SkAutoTUnref<SkImageFilter> paintFilterLeft(SkPaintImageFilter::Create( | 147 sk_sp<SkImageFilter> paintFilterLeft(SkPaintImageFilter::Make(greenColor
ShaderPaint, |
148 greenColorShaderPaint, &leftSideCropRect)); | 148 &leftSideC
ropRect)); |
149 SkImageFilter::CropRect rightSideCropRect(SkRect::MakeXYWH(32, 0, 32, 64
)); | 149 SkImageFilter::CropRect rightSideCropRect(SkRect::MakeXYWH(32, 0, 32, 64
)); |
150 SkAutoTUnref<SkImageFilter> paintFilterRight(SkPaintImageFilter::Create( | 150 sk_sp<SkImageFilter> paintFilterRight(SkPaintImageFilter::Make(greenColo
rShaderPaint, |
151 greenColorShaderPaint, &rightSideCropRect)); | 151 &rightSid
eCropRect)); |
152 | 152 |
153 this->addFilter("color filter", | 153 this->addFilter("color filter", |
154 SkColorFilterImageFilter::Create(cf.get(), input, cropRect)); | 154 SkColorFilterImageFilter::Create(cf.get(), input, cropRect)); |
155 this->addFilter("displacement map", SkDisplacementMapEffect::Create( | 155 this->addFilter("displacement map", SkDisplacementMapEffect::Create( |
156 SkDisplacementMapEffect::kR_ChannelSelectorType, | 156 SkDisplacementMapEffect::kR_ChannelSelectorType, |
157 SkDisplacementMapEffect::kB_ChannelSelectorType, | 157 SkDisplacementMapEffect::kB_ChannelSelectorType, |
158 20.0f, gradientSource.get(), input, cropRect)); | 158 20.0f, gradientSource.get(), input, cropRect)); |
159 this->addFilter("blur", SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1
, input, cropRect)); | 159 this->addFilter("blur", SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1
, input, cropRect)); |
160 this->addFilter("drop shadow", SkDropShadowImageFilter::Create( | 160 this->addFilter("drop shadow", SkDropShadowImageFilter::Create( |
161 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, | 161 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, |
162 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
input, cropRect)); | 162 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
input, cropRect)); |
163 this->addFilter("diffuse lighting", SkLightingImageFilter::CreatePointLi
tDiffuse( | 163 this->addFilter("diffuse lighting", SkLightingImageFilter::CreatePointLi
tDiffuse( |
164 location, SK_ColorGREEN, 0, 0, input, cropRect)); | 164 location, SK_ColorGREEN, 0, 0, input, cropRect)); |
165 this->addFilter("specular lighting", | 165 this->addFilter("specular lighting", |
166 SkLightingImageFilter::CreatePointLitSpecular(location, SK_Col
orGREEN, 0, 0, 0, | 166 SkLightingImageFilter::CreatePointLitSpecular(location, SK_Col
orGREEN, 0, 0, 0, |
167 input, cropRect)
); | 167 input, cropRect)
); |
168 this->addFilter("matrix convolution", | 168 this->addFilter("matrix convolution", |
169 SkMatrixConvolutionImageFilter::Create( | 169 SkMatrixConvolutionImageFilter::Create( |
170 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), | 170 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), |
171 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false, i
nput, cropRect)); | 171 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false, i
nput, cropRect)); |
172 this->addFilter("merge", SkMergeImageFilter::Create(input, input, SkXfer
mode::kSrcOver_Mode, | 172 this->addFilter("merge", SkMergeImageFilter::Create(input, input, SkXfer
mode::kSrcOver_Mode, |
173 cropRect)); | 173 cropRect)); |
174 this->addFilter("merge with disjoint inputs", SkMergeImageFilter::Create
( | 174 this->addFilter("merge with disjoint inputs", SkMergeImageFilter::Create
( |
175 paintFilterLeft, paintFilterRight, SkXfermode::kSrcOver_Mode,
cropRect)); | 175 paintFilterLeft.get(), paintFilterRight.get(), |
| 176 SkXfermode::kSrcOver_Mode, cropRect)); |
176 this->addFilter("offset", | 177 this->addFilter("offset", |
177 SkOffsetImageFilter::Create(SK_Scalar1, SK_Scalar1, inpu
t, cropRect)); | 178 SkOffsetImageFilter::Create(SK_Scalar1, SK_Scalar1, inpu
t, cropRect)); |
178 this->addFilter("dilate", SkDilateImageFilter::Create(3, 2, input, cropR
ect)); | 179 this->addFilter("dilate", SkDilateImageFilter::Create(3, 2, input, cropR
ect)); |
179 this->addFilter("erode", SkErodeImageFilter::Create(2, 3, input, cropRec
t)); | 180 this->addFilter("erode", SkErodeImageFilter::Create(2, 3, input, cropRec
t)); |
180 this->addFilter("tile", SkTileImageFilter::Create( | 181 this->addFilter("tile", SkTileImageFilter::Create( |
181 SkRect::MakeXYWH(0, 0, 50, 50), | 182 SkRect::MakeXYWH(0, 0, 50, 50), |
182 cropRect ? cropRect->rect() : SkRect::MakeXYWH(0, 0, 100, 100), | 183 cropRect ? cropRect->rect() : SkRect::MakeXYWH(0, 0, 100, 100), |
183 input)); | 184 input)); |
184 if (!cropRect) { | 185 if (!cropRect) { |
185 this->addFilter("matrix", SkImageFilter::CreateMatrixFilter( | 186 this->addFilter("matrix", SkImageFilter::CreateMatrixFilter( |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 | 1586 |
1586 test_xfermode_cropped_input(&canvas, reporter); | 1587 test_xfermode_cropped_input(&canvas, reporter); |
1587 } | 1588 } |
1588 | 1589 |
1589 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { | 1590 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { |
1590 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, | 1591 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, |
1591 SkImageInfo::MakeN32Premul(100, 100
))); | 1592 SkImageInfo::MakeN32Premul(100, 100
))); |
1592 test_large_blur_input(reporter, surface->getCanvas()); | 1593 test_large_blur_input(reporter, surface->getCanvas()); |
1593 } | 1594 } |
1594 #endif | 1595 #endif |
OLD | NEW |