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 "SkBicubicImageFilter.h" | |
9 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
10 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
11 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
12 #include "SkBlurImageFilter.h" | 11 #include "SkBlurImageFilter.h" |
13 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
14 #include "SkColorFilterImageFilter.h" | 13 #include "SkColorFilterImageFilter.h" |
15 #include "SkColorMatrixFilter.h" | 14 #include "SkColorMatrixFilter.h" |
16 #include "SkDeviceImageFilterProxy.h" | 15 #include "SkDeviceImageFilterProxy.h" |
17 #include "SkDisplacementMapEffect.h" | 16 #include "SkDisplacementMapEffect.h" |
18 #include "SkDropShadowImageFilter.h" | 17 #include "SkDropShadowImageFilter.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 SkPaint paint; | 176 SkPaint paint; |
178 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular( | 177 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular( |
179 location, target, specularExponent, 180, | 178 location, target, specularExponent, 180, |
180 0xFFFFFFFF, SK_Scalar1, SK_Scalar1, SK_Scalar1, | 179 0xFFFFFFFF, SK_Scalar1, SK_Scalar1, SK_Scalar1, |
181 bmSrc))->unref(); | 180 bmSrc))->unref(); |
182 SkCanvas canvas(result); | 181 SkCanvas canvas(result); |
183 SkRect r = SkRect::MakeWH(SkIntToScalar(kBitmapSize), | 182 SkRect r = SkRect::MakeWH(SkIntToScalar(kBitmapSize), |
184 SkIntToScalar(kBitmapSize)); | 183 SkIntToScalar(kBitmapSize)); |
185 canvas.drawRect(r, paint); | 184 canvas.drawRect(r, paint); |
186 } | 185 } |
187 | |
188 { | |
189 // This tests for scale bringing width to 0 | |
190 SkSize scale = SkSize::Make(-0.001f, SK_Scalar1); | |
191 SkAutoTUnref<SkImageFilter> bmSrc(SkBitmapSource::Create(bitmap)); | |
192 SkAutoTUnref<SkBicubicImageFilter> bicubic( | |
193 SkBicubicImageFilter::CreateMitchell(scale, bmSrc)); | |
194 SkBitmapDevice device(bitmap); | |
195 SkDeviceImageFilterProxy proxy(&device); | |
196 SkIPoint loc = SkIPoint::Make(0, 0); | |
197 // An empty input should early return and return false | |
198 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Creat
e(2)); | |
199 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeEmpty(), cach
e.get()); | |
200 REPORTER_ASSERT(reporter, | |
201 !bicubic->filterImage(&proxy, bitmap, ctx, &result,
&loc)); | |
202 } | |
203 } | 186 } |
204 } | 187 } |
205 | 188 |
206 static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter)
{ | 189 static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter)
{ |
207 // Check that all filters offset to their absolute crop rect, | 190 // Check that all filters offset to their absolute crop rect, |
208 // unaffected by the input crop rect. | 191 // unaffected by the input crop rect. |
209 // Tests pass by not asserting. | 192 // Tests pass by not asserting. |
210 SkBitmap bitmap; | 193 SkBitmap bitmap; |
211 bitmap.allocN32Pixels(100, 100); | 194 bitmap.allocN32Pixels(100, 100); |
212 bitmap.eraseARGB(0, 0, 0, 0); | 195 bitmap.eraseARGB(0, 0, 0, 0); |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 } | 734 } |
752 | 735 |
753 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 736 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
754 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 737 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
755 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 738 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
756 SkImageInfo::MakeN32Pre
mul(1, 1), | 739 SkImageInfo::MakeN32Pre
mul(1, 1), |
757 0)); | 740 0)); |
758 test_xfermode_cropped_input(device, reporter); | 741 test_xfermode_cropped_input(device, reporter); |
759 } | 742 } |
760 #endif | 743 #endif |
OLD | NEW |