SkPDF: Let client re-encode JPGs if they want to

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1734223003

Review URL: https://codereview.chromium.org/1734223003
This commit is contained in:
halcanary 2016-02-25 17:21:40 -08:00 committed by Commit bot
parent a705641cf6
commit 7363e13a07

View File

@ -472,7 +472,12 @@ SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image,
SkPixelSerializer* pixelSerializer) {
SkAutoTUnref<SkData> data(image->refEncoded());
SkJFIFInfo info;
if (data && SkIsJFIF(data, &info)) {
if (data && SkIsJFIF(data, &info) &&
(!pixelSerializer ||
pixelSerializer->useEncodedData(data->data(), data->size()))) {
// If there is a SkPixelSerializer, give it a chance to
// re-encode the JPEG with more compression by returning false
// from useEncodedData.
bool yuv = info.fType == SkJFIFInfo::kYCbCr;
if (info.fSize == image->dimensions()) { // Sanity check.
// hold on to data, not image.