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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 paint.setColor(SK_ColorRED); | 1254 paint.setColor(SK_ColorRED); |
1255 paint.setImageFilter(unflattenedFilter); | 1255 paint.setImageFilter(unflattenedFilter); |
1256 | 1256 |
1257 SkCanvas canvas(bm); | 1257 SkCanvas canvas(bm); |
1258 canvas.drawRect(SkRect::MakeWH(10, 10), paint); | 1258 canvas.drawRect(SkRect::MakeWH(10, 10), paint); |
1259 REPORTER_ASSERT(reporter, *bm.getAddr32(0, 0) == SkPreMultiplyColor(SK_Color
GREEN)); | 1259 REPORTER_ASSERT(reporter, *bm.getAddr32(0, 0) == SkPreMultiplyColor(SK_Color
GREEN)); |
1260 } | 1260 } |
1261 | 1261 |
1262 #if SK_SUPPORT_GPU | 1262 #if SK_SUPPORT_GPU |
1263 | 1263 |
1264 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { | 1264 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ImageFilterCropRect_Gpu, reporter, context) { |
1265 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | |
1266 if (nullptr == context) { | |
1267 return; | |
1268 } | |
1269 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1265 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1270 | 1266 |
1271 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1267 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1272 SkSurface::kNo_Budgeted
, | 1268 SkSurface::kNo_Budgeted
, |
1273 SkImageInfo::MakeN32Pre
mul(100, 100), | 1269 SkImageInfo::MakeN32Pre
mul(100, 100), |
1274 0, | 1270 0, |
1275 &props, | 1271 &props, |
1276 SkGpuDevice::kUninit_In
itContents)); | 1272 SkGpuDevice::kUninit_In
itContents)); |
1277 SkImageFilter::DeviceProxy proxy(device); | 1273 SkImageFilter::DeviceProxy proxy(device); |
1278 | 1274 |
1279 test_crop_rects(&proxy, reporter); | 1275 test_crop_rects(&proxy, reporter); |
1280 } | 1276 } |
1281 | 1277 |
1282 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { | 1278 DEF_GPUTEST_FOR_NATIVE_CONTEXT(HugeBlurImageFilter_Gpu, reporter, context) { |
1283 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | |
1284 if (nullptr == context) { | |
1285 return; | |
1286 } | |
1287 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1279 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1288 | 1280 |
1289 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1281 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1290 SkSurface::kNo_Budgeted
, | 1282 SkSurface::kNo_Budgeted
, |
1291 SkImageInfo::MakeN32Pre
mul(100, 100), | 1283 SkImageInfo::MakeN32Pre
mul(100, 100), |
1292 0, | 1284 0, |
1293 &props, | 1285 &props, |
1294 SkGpuDevice::kUninit_In
itContents)); | 1286 SkGpuDevice::kUninit_In
itContents)); |
1295 SkCanvas canvas(device); | 1287 SkCanvas canvas(device); |
1296 | 1288 |
1297 test_huge_blur(&canvas, reporter); | 1289 test_huge_blur(&canvas, reporter); |
1298 } | 1290 } |
1299 | 1291 |
1300 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 1292 DEF_GPUTEST_FOR_NATIVE_CONTEXT(XfermodeImageFilterCroppedInput_Gpu, reporter, co
ntext) { |
1301 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | |
1302 if (nullptr == context) { | |
1303 return; | |
1304 } | |
1305 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1293 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1306 | 1294 |
1307 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1295 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1308 SkSurface::kNo_Budgeted
, | 1296 SkSurface::kNo_Budgeted
, |
1309 SkImageInfo::MakeN32Pre
mul(1, 1), | 1297 SkImageInfo::MakeN32Pre
mul(1, 1), |
1310 0, | 1298 0, |
1311 &props, | 1299 &props, |
1312 SkGpuDevice::kUninit_In
itContents)); | 1300 SkGpuDevice::kUninit_In
itContents)); |
1313 SkCanvas canvas(device); | 1301 SkCanvas canvas(device); |
1314 | 1302 |
1315 test_xfermode_cropped_input(&canvas, reporter); | 1303 test_xfermode_cropped_input(&canvas, reporter); |
1316 } | 1304 } |
1317 | 1305 |
1318 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { | 1306 DEF_GPUTEST_FOR_NATIVE_CONTEXT(TestNegativeBlurSigma_Gpu, reporter, context) { |
1319 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | |
1320 if (nullptr == context) { | |
1321 return; | |
1322 } | |
1323 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1307 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1324 | 1308 |
1325 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1309 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1326 SkSurface::kNo_Budgeted
, | 1310 SkSurface::kNo_Budgeted
, |
1327 SkImageInfo::MakeN32Pre
mul(1, 1), | 1311 SkImageInfo::MakeN32Pre
mul(1, 1), |
1328 0, | 1312 0, |
1329 &props, | 1313 &props, |
1330 SkGpuDevice::kUninit_In
itContents)); | 1314 SkGpuDevice::kUninit_In
itContents)); |
1331 SkImageFilter::DeviceProxy proxy(device); | 1315 SkImageFilter::DeviceProxy proxy(device); |
1332 | 1316 |
1333 test_negative_blur_sigma(&proxy, reporter); | 1317 test_negative_blur_sigma(&proxy, reporter); |
1334 } | 1318 } |
1335 #endif | 1319 #endif |
OLD | NEW |