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

Unified Diff: tests/ImageFilterTest.cpp

Issue 371523002: Fix SkColorFilterImageFilter matrix optimization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkColorFilterImageFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageFilterTest.cpp
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index d3471ad019e46820a423b156fa3f7d8b6b176bb4..3f71b015c56cb18803b5d202236de5d31fbde399 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -158,6 +158,33 @@ DEF_TEST(ImageFilter, reporter) {
}
{
+ // Check that two non-commutative matrices are concatenated in
+ // the correct order.
+ SkScalar blueToRedMatrix[20] = { 0 };
+ blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1;
+ SkScalar redToGreenMatrix[20] = { 0 };
+ redToGreenMatrix[5] = redToGreenMatrix[18] = SK_Scalar1;
+ SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueToRedMatrix));
+ SkAutoTUnref<SkImageFilter> filter1(SkColorFilterImageFilter::Create(blueToRed.get()));
+ SkAutoTUnref<SkColorFilter> redToGreen(SkColorMatrixFilter::Create(redToGreenMatrix));
+ SkAutoTUnref<SkImageFilter> filter2(SkColorFilterImageFilter::Create(redToGreen.get(), filter1.get()));
+
+ SkBitmap result;
+ result.allocN32Pixels(kBitmapSize, kBitmapSize);
+
+ SkPaint paint;
+ paint.setColor(SK_ColorBLUE);
+ paint.setImageFilter(filter2.get());
+ SkCanvas canvas(result);
+ canvas.clear(0x0);
+ SkRect rect = SkRect::Make(SkIRect::MakeWH(kBitmapSize, kBitmapSize));
+ canvas.drawRect(rect, paint);
+ uint32_t pixel = *result.getAddr32(0, 0);
+ // The result here should be green, since we have effectively shifted blue to green.
+ REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
+ }
+
+ {
// Tests pass by not asserting
SkBitmap bitmap, result;
make_small_bitmap(bitmap);
« no previous file with comments | « src/effects/SkColorFilterImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698