aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PDFJpegEmbedTest.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-10-01 07:28:13 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-01 07:28:13 -0700
commit7a14b310d6c618fa2151d93a43b29f9599adc32a (patch)
tree0df57a285df727f8f892155ea4017eb7072c39ef /tests/PDFJpegEmbedTest.cpp
parent7bdd70ab9162980f3173c98c48234f9f345665a3 (diff)
SkPDF: Implement drawImage*() properly
drawImage calls now properly embeds the original jpeg. NOTE: drawBitmap*() calls no longer embed JPEG files when possible (this is in advance of eliminating bitmaps backed by encoded data). Chromium has already moved from drawBitmap to drawImage. Comparisons: control: total PDF drawImage/drawBitmap calls: 8010 total PDF jpeg images: 0 total PDF regular images: 3581 experiament: total PDF drawImage/drawBitmap calls: 8014 total PDF jpeg images: 271 total PDF regular images: 3311 total PDF regular images: 3582 (271 + 3311) When comparing rendered output there were perceptual differences in the following four GMs: colorcube, emboss, colormatrix, and tablecolorfilter. All of these differences were improvements (that is, closer to the 8888 rendering) due fixing a bug with colorfilters and forgetting to call notifyPixelsChanged. No SKPs had perceptual differences. Total PDF size dropped from 133964 kB to 126276 kB, a 5.7% improvement (mostly due to restoring use of JPG images in SKPs). BUG=skia:4370 Review URL: https://codereview.chromium.org/1372783003
Diffstat (limited to 'tests/PDFJpegEmbedTest.cpp')
-rw-r--r--tests/PDFJpegEmbedTest.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp
index 812fd3b2c3..5185eb7bd4 100644
--- a/tests/PDFJpegEmbedTest.cpp
+++ b/tests/PDFJpegEmbedTest.cpp
@@ -62,7 +62,7 @@ DEF_TEST(PDFJpegEmbedTest, r) {
if (!mandrillData || !cmykData) {
return;
}
-
+ ////////////////////////////////////////////////////////////////////////////
SkDynamicMemoryWStream pdf;
SkAutoTUnref<SkDocument> document(SkDocument::CreatePDF(&pdf));
SkCanvas* canvas = document->beginPage(642, 1028);
@@ -86,6 +86,30 @@ DEF_TEST(PDFJpegEmbedTest, r) {
// This JPEG uses a nonstandard colorspace - it can not be
// embedded into the PDF directly.
REPORTER_ASSERT(r, !is_subset_of(cmykData, pdfData));
+ ////////////////////////////////////////////////////////////////////////////
+ pdf.reset();
+ document.reset(SkDocument::CreatePDF(&pdf));
+ canvas = document->beginPage(642, 1028);
+
+ canvas->clear(SK_ColorLTGRAY);
+
+ SkAutoTUnref<SkImage> im1(SkImage::NewFromEncoded(mandrillData));
+ canvas->drawImage(im1, 65.0, 0.0, nullptr);
+ SkAutoTUnref<SkImage> im2(SkImage::NewFromEncoded(cmykData));
+ canvas->drawImage(im2, 0.0, 512.0, nullptr);
+
+ canvas->flush();
+ document->endPage();
+ document->close();
+ pdfData.reset(pdf.copyToData());
+ SkASSERT(pdfData);
+ pdf.reset();
+
+ REPORTER_ASSERT(r, is_subset_of(mandrillData, pdfData));
+
+ // This JPEG uses a nonstandard colorspace - it can not be
+ // embedded into the PDF directly.
+ REPORTER_ASSERT(r, !is_subset_of(cmykData, pdfData));
}
#include "SkJpegInfo.h"
@@ -121,7 +145,7 @@ DEF_TEST(JpegIdentification, r) {
}
if (r->verbose()) {
SkDebugf("\nJpegIdentification: %s [%d x %d]\n", kTests[i].path,
- info.fWidth, info.fHeight);
+ info.fSize.width(), info.fSize.height());
}
}
}