Index: tests/ImageFilterTest.cpp |
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp |
index 8c3206680adc42e0c6745f0a3c811a08d2269072..8444bd38c327d7a0a6e46eabc4bcff282799643f 100644 |
--- a/tests/ImageFilterTest.cpp |
+++ b/tests/ImageFilterTest.cpp |
@@ -17,6 +17,7 @@ |
#include "SkDropShadowImageFilter.h" |
#include "SkFlattenableSerialization.h" |
#include "SkGradientShader.h" |
+#include "SkImageSource.h" |
#include "SkLightingImageFilter.h" |
#include "SkMatrixConvolutionImageFilter.h" |
#include "SkMergeImageFilter.h" |
@@ -30,6 +31,7 @@ |
#include "SkReadBuffer.h" |
#include "SkRect.h" |
#include "SkRectShaderImageFilter.h" |
+#include "SkSurface.h" |
#include "SkTableColorFilter.h" |
#include "SkTileImageFilter.h" |
#include "SkXfermodeImageFilter.h" |
@@ -1212,6 +1214,30 @@ DEF_TEST(ImageFilterCanComputeFastBounds, reporter) { |
REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); |
} |
+// Verify that SkImageSource survives serialization |
+DEF_TEST(ImageFilterImageSourceSerialization, reporter) { |
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10)); |
+ surface->getCanvas()->clear(SK_ColorGREEN); |
+ SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
+ SkAutoTUnref<SkImageFilter> filter(SkImageSource::Create(image)); |
+ |
+ SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter)); |
+ SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( |
+ data->data(), data->size(), SkImageFilter::GetFlattenableType())); |
+ SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.get()); |
+ REPORTER_ASSERT(reporter, unflattenedFilter); |
+ |
+ SkBitmap bm; |
+ bm.allocN32Pixels(10, 10); |
+ SkPaint paint; |
+ paint.setColor(SK_ColorRED); |
+ paint.setImageFilter(unflattenedFilter); |
+ |
+ SkCanvas canvas(bm); |
+ canvas.drawRect(SkRect::MakeWH(10, 10), paint); |
+ REPORTER_ASSERT(reporter, *bm.getAddr32(0, 0) == SkPreMultiplyColor(SK_ColorGREEN)); |
+} |
+ |
#if SK_SUPPORT_GPU |
DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { |