| 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 "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
| 11 #include "SkBlurImageFilter.h" | 11 #include "SkBlurImageFilter.h" |
| 12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
| 13 #include "SkColorFilterImageFilter.h" | 13 #include "SkColorFilterImageFilter.h" |
| 14 #include "SkColorMatrixFilter.h" | 14 #include "SkColorMatrixFilter.h" |
| 15 #include "SkComposeImageFilter.h" | 15 #include "SkComposeImageFilter.h" |
| 16 #include "SkDisplacementMapEffect.h" | 16 #include "SkDisplacementMapEffect.h" |
| 17 #include "SkDropShadowImageFilter.h" | 17 #include "SkDropShadowImageFilter.h" |
| 18 #include "SkFlattenableSerialization.h" | 18 #include "SkFlattenableSerialization.h" |
| 19 #include "SkGradientShader.h" | 19 #include "SkGradientShader.h" |
| 20 #include "SkImageSource.h" |
| 20 #include "SkLightingImageFilter.h" | 21 #include "SkLightingImageFilter.h" |
| 21 #include "SkMatrixConvolutionImageFilter.h" | 22 #include "SkMatrixConvolutionImageFilter.h" |
| 22 #include "SkMergeImageFilter.h" | 23 #include "SkMergeImageFilter.h" |
| 23 #include "SkMorphologyImageFilter.h" | 24 #include "SkMorphologyImageFilter.h" |
| 24 #include "SkOffsetImageFilter.h" | 25 #include "SkOffsetImageFilter.h" |
| 25 #include "SkPerlinNoiseShader.h" | 26 #include "SkPerlinNoiseShader.h" |
| 26 #include "SkPicture.h" | 27 #include "SkPicture.h" |
| 27 #include "SkPictureImageFilter.h" | 28 #include "SkPictureImageFilter.h" |
| 28 #include "SkPictureRecorder.h" | 29 #include "SkPictureRecorder.h" |
| 29 #include "SkPoint3.h" | 30 #include "SkPoint3.h" |
| 30 #include "SkReadBuffer.h" | 31 #include "SkReadBuffer.h" |
| 31 #include "SkRect.h" | 32 #include "SkRect.h" |
| 32 #include "SkRectShaderImageFilter.h" | 33 #include "SkRectShaderImageFilter.h" |
| 34 #include "SkSurface.h" |
| 33 #include "SkTableColorFilter.h" | 35 #include "SkTableColorFilter.h" |
| 34 #include "SkTileImageFilter.h" | 36 #include "SkTileImageFilter.h" |
| 35 #include "SkXfermodeImageFilter.h" | 37 #include "SkXfermodeImageFilter.h" |
| 36 #include "Test.h" | 38 #include "Test.h" |
| 37 | 39 |
| 38 #if SK_SUPPORT_GPU | 40 #if SK_SUPPORT_GPU |
| 39 #include "GrContextFactory.h" | 41 #include "GrContextFactory.h" |
| 40 #include "SkGpuDevice.h" | 42 #include "SkGpuDevice.h" |
| 41 #endif | 43 #endif |
| 42 | 44 |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 REPORTER_ASSERT(reporter, !identityCF->affectsTransparentBlack()); | 1207 REPORTER_ASSERT(reporter, !identityCF->affectsTransparentBlack()); |
| 1206 REPORTER_ASSERT(reporter, identityFilter->canComputeFastBounds()); | 1208 REPORTER_ASSERT(reporter, identityFilter->canComputeFastBounds()); |
| 1207 | 1209 |
| 1208 SkAutoTUnref<SkColorFilter> forceOpaqueCF( | 1210 SkAutoTUnref<SkColorFilter> forceOpaqueCF( |
| 1209 SkTableColorFilter::CreateARGB(allOne, identity, identity, identity)); | 1211 SkTableColorFilter::CreateARGB(allOne, identity, identity, identity)); |
| 1210 SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(for
ceOpaqueCF.get())); | 1212 SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(for
ceOpaqueCF.get())); |
| 1211 REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack()); | 1213 REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack()); |
| 1212 REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); | 1214 REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); |
| 1213 } | 1215 } |
| 1214 | 1216 |
| 1217 // Verify that SkImageSource survives serialization |
| 1218 DEF_TEST(ImageFilterImageSourceSerialization, reporter) { |
| 1219 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10)); |
| 1220 surface->getCanvas()->clear(SK_ColorGREEN); |
| 1221 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
| 1222 SkAutoTUnref<SkImageFilter> filter(SkImageSource::Create(image)); |
| 1223 |
| 1224 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter)); |
| 1225 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( |
| 1226 data->data(), data->size(), SkImageFilter::GetFlattenableType())); |
| 1227 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g
et()); |
| 1228 REPORTER_ASSERT(reporter, unflattenedFilter); |
| 1229 |
| 1230 SkBitmap bm; |
| 1231 bm.allocN32Pixels(10, 10); |
| 1232 SkPaint paint; |
| 1233 paint.setColor(SK_ColorRED); |
| 1234 paint.setImageFilter(unflattenedFilter); |
| 1235 |
| 1236 SkCanvas canvas(bm); |
| 1237 canvas.drawRect(SkRect::MakeWH(10, 10), paint); |
| 1238 REPORTER_ASSERT(reporter, *bm.getAddr32(0, 0) == SkPreMultiplyColor(SK_Color
GREEN)); |
| 1239 } |
| 1240 |
| 1215 #if SK_SUPPORT_GPU | 1241 #if SK_SUPPORT_GPU |
| 1216 | 1242 |
| 1217 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { | 1243 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { |
| 1218 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 1244 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
| 1219 if (nullptr == context) { | 1245 if (nullptr == context) { |
| 1220 return; | 1246 return; |
| 1221 } | 1247 } |
| 1222 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1248 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1223 | 1249 |
| 1224 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1250 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 SkSurface::kNo_Budgeted
, | 1305 SkSurface::kNo_Budgeted
, |
| 1280 SkImageInfo::MakeN32Pre
mul(1, 1), | 1306 SkImageInfo::MakeN32Pre
mul(1, 1), |
| 1281 0, | 1307 0, |
| 1282 &props, | 1308 &props, |
| 1283 SkGpuDevice::kUninit_In
itContents)); | 1309 SkGpuDevice::kUninit_In
itContents)); |
| 1284 SkImageFilter::Proxy proxy(device); | 1310 SkImageFilter::Proxy proxy(device); |
| 1285 | 1311 |
| 1286 test_negative_blur_sigma(&proxy, reporter); | 1312 test_negative_blur_sigma(&proxy, reporter); |
| 1287 } | 1313 } |
| 1288 #endif | 1314 #endif |
| OLD | NEW |