Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1813373002: Make SkComposeImageFilter::onFilterImage filter the bounds given to the inner filter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: skip innerClipBounds initialization per senorblanco Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkComposeImageFilter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 DEF_TEST(ComposedImageFilterOffset, reporter) { 1362 DEF_TEST(ComposedImageFilterOffset, reporter) {
1363 run_raster_test(reporter, 100, test_composed_imagefilter_offset); 1363 run_raster_test(reporter, 100, test_composed_imagefilter_offset);
1364 } 1364 }
1365 1365
1366 #if SK_SUPPORT_GPU 1366 #if SK_SUPPORT_GPU
1367 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ComposedImageFilterOffset_Gpu, reporter, context) { 1367 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ComposedImageFilterOffset_Gpu, reporter, context) {
1368 run_gpu_test(reporter, context, 100, test_composed_imagefilter_offset); 1368 run_gpu_test(reporter, context, 100, test_composed_imagefilter_offset);
1369 } 1369 }
1370 #endif 1370 #endif
1371 1371
1372 static void test_composed_imagefilter_bounds(SkImageFilter::Proxy* proxy,
1373 skiatest::Reporter* reporter,
1374 GrContext* context) {
1375 // The bounds passed to the inner filter must be filtered by the outer
1376 // filter, so that the inner filter produces the pixels that the outer
1377 // filter requires as input. This matters if the outer filter moves pixels.
1378 // Here, accounting for the outer offset is necessary so that the green
1379 // pixels of the picture are not clipped.
1380
1381 SkPictureRecorder recorder;
1382 SkCanvas* recordingCanvas = recorder.beginRecording(SkRect::MakeWH(200, 100) );
1383 recordingCanvas->clipRect(SkRect::MakeXYWH(100, 0, 100, 100));
1384 recordingCanvas->clear(SK_ColorGREEN);
1385 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
1386 sk_sp<SkImageFilter> pictureFilter(
1387 SkPictureImageFilter::Create(picture.get()));
1388 SkImageFilter::CropRect cropRect(SkRect::MakeWH(100, 100));
1389 sk_sp<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(-100, 0, nullp tr, &cropRect));
1390 sk_sp<SkImageFilter> composedFilter(
1391 SkComposeImageFilter::Create(offsetFilter.get(), pictureFilter.get()));
1392
1393 sk_sp<SkSpecialImage> sourceImage(create_empty_special_image(context, proxy, 100));
1394 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr );
1395 SkIPoint offset;
1396 sk_sp<SkSpecialImage> result(composedFilter->filterImage(sourceImage.get(), ctx, &offset));
1397 REPORTER_ASSERT(reporter, offset.isZero());
1398 REPORTER_ASSERT(reporter, result);
1399 REPORTER_ASSERT(reporter, result->subset().size() == SkISize::Make(100, 100) );
1400
1401 SkBitmap resultBM;
1402 TestingSpecialImageAccess::GetROPixels(result.get(), &resultBM);
1403 SkAutoLockPixels lock(resultBM);
1404 REPORTER_ASSERT(reporter, resultBM.getColor(50, 50) == SK_ColorGREEN);
1405 }
1406
1407 DEF_TEST(ComposedImageFilterBounds, reporter) {
1408 run_raster_test(reporter, 100, test_composed_imagefilter_bounds);
1409 }
1410
1411 #if SK_SUPPORT_GPU
1412 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ComposedImageFilterBounds_Gpu, reporter, context) {
1413 run_gpu_test(reporter, context, 100, test_composed_imagefilter_bounds);
1414 }
1415 #endif
1416
1372 static void test_partial_crop_rect(SkImageFilter::Proxy* proxy, 1417 static void test_partial_crop_rect(SkImageFilter::Proxy* proxy,
1373 skiatest::Reporter* reporter, 1418 skiatest::Reporter* reporter,
1374 GrContext* context) { 1419 GrContext* context) {
1375 sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100) ); 1420 sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100) );
1376 1421
1377 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30), 1422 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30),
1378 SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::k HasHeight_CropEdge); 1423 SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::k HasHeight_CropEdge);
1379 SkAutoTUnref<SkImageFilter> filter(make_grayscale(nullptr, &cropRect)); 1424 SkAutoTUnref<SkImageFilter> filter(make_grayscale(nullptr, &cropRect));
1380 SkIPoint offset; 1425 SkIPoint offset;
1381 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr ); 1426 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr );
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 test_xfermode_cropped_input(&canvas, reporter); 1599 test_xfermode_cropped_input(&canvas, reporter);
1555 } 1600 }
1556 1601
1557 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { 1602 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
1558 SkAutoTUnref<SkSurface> surface( 1603 SkAutoTUnref<SkSurface> surface(
1559 SkSurface::NewRenderTarget(context, SkBudgeted::kYes, 1604 SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
1560 SkImageInfo::MakeN32Premul(100, 100))); 1605 SkImageInfo::MakeN32Premul(100, 100)));
1561 test_large_blur_input(reporter, surface->getCanvas()); 1606 test_large_blur_input(reporter, surface->getCanvas());
1562 } 1607 }
1563 #endif 1608 #endif
OLDNEW
« no previous file with comments | « src/effects/SkComposeImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698