Index: src/pdf/SkPDFBitmap.cpp |
diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp |
index 0c53da69743c622249aa9a2cfb361c030a050862..4e49db518d802896ed069a75fe4f3f66d9bd0bb2 100644 |
--- a/src/pdf/SkPDFBitmap.cpp |
+++ b/src/pdf/SkPDFBitmap.cpp |
@@ -468,7 +468,8 @@ void PDFJpegBitmap::emitObject(SkWStream* stream, |
//////////////////////////////////////////////////////////////////////////////// |
-SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image) { |
+SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image, |
+ SkPixelSerializer* pixelSerializer) { |
SkAutoTUnref<SkData> data(image->refEncoded()); |
SkJFIFInfo info; |
if (data && SkIsJFIF(data, &info)) { |
@@ -481,6 +482,21 @@ SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image) { |
return new PDFJpegBitmap(info.fSize, data, yuv); |
} |
} |
+ |
+ if (pixelSerializer) { |
+ SkBitmap bm; |
+ SkAutoPixmapUnlock apu; |
+ if (as_IB(image)->getROPixels(&bm) && bm.requestLock(&apu)) { |
+ data.reset(pixelSerializer->encode(apu.pixmap())); |
+ if (data && SkIsJFIF(data, &info)) { |
+ bool yuv = info.fType == SkJFIFInfo::kYCbCr; |
+ if (info.fSize == image->dimensions()) { // Sanity check. |
+ return new PDFJpegBitmap(info.fSize, data, yuv); |
+ } |
+ } |
+ } |
+ } |
+ |
SkPDFObject* smask = |
image_compute_is_opaque(image) ? nullptr : new PDFAlphaBitmap(image); |
#ifdef SK_PDF_IMAGE_STATS |