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

Unified Diff: tests/PDFPrimitivesTest.cpp

Issue 644323006: Fix image filters for PDF backend. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add a comment about rendering quality, and reference appropriate skbug Created 6 years, 2 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/pdf/SkPDFDevice.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PDFPrimitivesTest.cpp
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index b1d482ffa2d4ee662055d6cb427bfe0db6aa9c5f..05677cd1abf620878a59ae8135b78adae2523918 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -15,6 +15,7 @@
#include "SkPDFDevice.h"
#include "SkPDFStream.h"
#include "SkPDFTypes.h"
+#include "SkReadBuffer.h"
#include "SkScalar.h"
#include "SkStream.h"
#include "SkTypes.h"
@@ -428,3 +429,54 @@ DEF_TEST(PDFPrimitives, reporter) {
TestImages(reporter);
}
+
+namespace {
+
+class DummyImageFilter : public SkImageFilter {
+public:
+ DummyImageFilter(bool visited = false) : SkImageFilter(0, NULL), fVisited(visited) {}
+ virtual ~DummyImageFilter() SK_OVERRIDE {}
+ virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
+ SkBitmap* result, SkIPoint* offset) const {
+ fVisited = true;
+ offset->fX = offset->fY = 0;
+ *result = src;
+ return true;
+ }
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DummyImageFilter)
+#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
+ explicit DummyImageFilter(SkReadBuffer& buffer) : SkImageFilter(0, NULL) {
+ fVisited = buffer.readBool();
+ }
+#endif
+ bool visited() const { return fVisited; }
+
+private:
+ mutable bool fVisited;
+};
+
+SkFlattenable* DummyImageFilter::CreateProc(SkReadBuffer& buffer) {
+ SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
+ bool visited = buffer.readBool();
+ return SkNEW_ARGS(DummyImageFilter, (visited));
+}
+
+};
+
+// Check that PDF rendering of image filters successfully falls back to
+// CPU rasterization.
+DEF_TEST(PDFImageFilter, reporter) {
+ SkISize pageSize = SkISize::Make(100, 100);
+ SkAutoTUnref<SkPDFDevice> device(new SkPDFDevice(pageSize, pageSize, SkMatrix::I()));
+ SkCanvas canvas(device.get());
+ SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter());
+
+ // Filter just created; should be unvisited.
+ REPORTER_ASSERT(reporter, !filter->visited());
+ SkPaint paint;
+ paint.setImageFilter(filter.get());
+ canvas.drawRect(SkRect::MakeWH(100, 100), paint);
+
+ // Filter was used in rendering; should be visited.
+ REPORTER_ASSERT(reporter, filter->visited());
+}
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698