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 20 matching lines...) Expand all Loading... |
31 #include "SkReadBuffer.h" | 31 #include "SkReadBuffer.h" |
32 #include "SkRect.h" | 32 #include "SkRect.h" |
33 #include "SkRectShaderImageFilter.h" | 33 #include "SkRectShaderImageFilter.h" |
34 #include "SkSurface.h" | 34 #include "SkSurface.h" |
35 #include "SkTableColorFilter.h" | 35 #include "SkTableColorFilter.h" |
36 #include "SkTileImageFilter.h" | 36 #include "SkTileImageFilter.h" |
37 #include "SkXfermodeImageFilter.h" | 37 #include "SkXfermodeImageFilter.h" |
38 #include "Test.h" | 38 #include "Test.h" |
39 | 39 |
40 #if SK_SUPPORT_GPU | 40 #if SK_SUPPORT_GPU |
41 #include "GrContextFactory.h" | 41 #include "GrContext.h" |
42 #include "SkGpuDevice.h" | 42 #include "SkGpuDevice.h" |
43 #endif | 43 #endif |
44 | 44 |
45 static const int kBitmapSize = 4; | 45 static const int kBitmapSize = 4; |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 class MatrixTestImageFilter : public SkImageFilter { | 49 class MatrixTestImageFilter : public SkImageFilter { |
50 public: | 50 public: |
51 MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expected
Matrix) | 51 MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expected
Matrix) |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 paint.setColor(SK_ColorRED); | 1231 paint.setColor(SK_ColorRED); |
1232 paint.setImageFilter(unflattenedFilter); | 1232 paint.setImageFilter(unflattenedFilter); |
1233 | 1233 |
1234 SkCanvas canvas(bm); | 1234 SkCanvas canvas(bm); |
1235 canvas.drawRect(SkRect::MakeWH(10, 10), paint); | 1235 canvas.drawRect(SkRect::MakeWH(10, 10), paint); |
1236 REPORTER_ASSERT(reporter, *bm.getAddr32(0, 0) == SkPreMultiplyColor(SK_Color
GREEN)); | 1236 REPORTER_ASSERT(reporter, *bm.getAddr32(0, 0) == SkPreMultiplyColor(SK_Color
GREEN)); |
1237 } | 1237 } |
1238 | 1238 |
1239 #if SK_SUPPORT_GPU | 1239 #if SK_SUPPORT_GPU |
1240 | 1240 |
1241 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { | 1241 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ImageFilterCropRect_Gpu, reporter, context) { |
1242 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | |
1243 if (nullptr == context) { | |
1244 return; | |
1245 } | |
1246 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1242 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1247 | 1243 |
1248 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1244 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1249 SkSurface::kNo_Budgeted
, | 1245 SkSurface::kNo_Budgeted
, |
1250 SkImageInfo::MakeN32Pre
mul(100, 100), | 1246 SkImageInfo::MakeN32Pre
mul(100, 100), |
1251 0, | 1247 0, |
1252 &props, | 1248 &props, |
1253 SkGpuDevice::kUninit_In
itContents)); | 1249 SkGpuDevice::kUninit_In
itContents)); |
1254 SkImageFilter::DeviceProxy proxy(device); | 1250 SkImageFilter::DeviceProxy proxy(device); |
1255 | 1251 |
1256 test_crop_rects(&proxy, reporter); | 1252 test_crop_rects(&proxy, reporter); |
1257 } | 1253 } |
1258 | 1254 |
1259 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { | 1255 DEF_GPUTEST_FOR_NATIVE_CONTEXT(HugeBlurImageFilter_Gpu, reporter, context) { |
1260 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | |
1261 if (nullptr == context) { | |
1262 return; | |
1263 } | |
1264 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1256 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1265 | 1257 |
1266 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1258 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1267 SkSurface::kNo_Budgeted
, | 1259 SkSurface::kNo_Budgeted
, |
1268 SkImageInfo::MakeN32Pre
mul(100, 100), | 1260 SkImageInfo::MakeN32Pre
mul(100, 100), |
1269 0, | 1261 0, |
1270 &props, | 1262 &props, |
1271 SkGpuDevice::kUninit_In
itContents)); | 1263 SkGpuDevice::kUninit_In
itContents)); |
1272 SkCanvas canvas(device); | 1264 SkCanvas canvas(device); |
1273 | 1265 |
1274 test_huge_blur(&canvas, reporter); | 1266 test_huge_blur(&canvas, reporter); |
1275 } | 1267 } |
1276 | 1268 |
1277 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 1269 DEF_GPUTEST_FOR_NATIVE_CONTEXT(XfermodeImageFilterCroppedInput_Gpu, reporter, co
ntext) { |
1278 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | |
1279 if (nullptr == context) { | |
1280 return; | |
1281 } | |
1282 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1270 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1283 | 1271 |
1284 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1272 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1285 SkSurface::kNo_Budgeted
, | 1273 SkSurface::kNo_Budgeted
, |
1286 SkImageInfo::MakeN32Pre
mul(1, 1), | 1274 SkImageInfo::MakeN32Pre
mul(1, 1), |
1287 0, | 1275 0, |
1288 &props, | 1276 &props, |
1289 SkGpuDevice::kUninit_In
itContents)); | 1277 SkGpuDevice::kUninit_In
itContents)); |
1290 SkCanvas canvas(device); | 1278 SkCanvas canvas(device); |
1291 | 1279 |
1292 test_xfermode_cropped_input(&canvas, reporter); | 1280 test_xfermode_cropped_input(&canvas, reporter); |
1293 } | 1281 } |
1294 | 1282 |
1295 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { | 1283 DEF_GPUTEST_FOR_NATIVE_CONTEXT(TestNegativeBlurSigma_Gpu, reporter, context) { |
1296 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | |
1297 if (nullptr == context) { | |
1298 return; | |
1299 } | |
1300 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1284 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1301 | 1285 |
1302 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1286 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1303 SkSurface::kNo_Budgeted
, | 1287 SkSurface::kNo_Budgeted
, |
1304 SkImageInfo::MakeN32Pre
mul(1, 1), | 1288 SkImageInfo::MakeN32Pre
mul(1, 1), |
1305 0, | 1289 0, |
1306 &props, | 1290 &props, |
1307 SkGpuDevice::kUninit_In
itContents)); | 1291 SkGpuDevice::kUninit_In
itContents)); |
1308 SkImageFilter::DeviceProxy proxy(device); | 1292 SkImageFilter::DeviceProxy proxy(device); |
1309 | 1293 |
1310 test_negative_blur_sigma(&proxy, reporter); | 1294 test_negative_blur_sigma(&proxy, reporter); |
1311 } | 1295 } |
1312 #endif | 1296 #endif |
OLD | NEW |