| Index: gm/gmmain.cpp
|
| diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
|
| index 2cd8f474f9302d9c65a4f9b7954cbe04a741d8d3..2144a60a8b0f70e42d91704b619b0f8a7a189bf2 100644
|
| --- a/gm/gmmain.cpp
|
| +++ b/gm/gmmain.cpp
|
| @@ -193,7 +193,7 @@ static PipeFlagComboData gPipeWritingFlagCombos[] = {
|
| | SkGPipeWriter::kSharedAddressSpace_Flag }
|
| };
|
|
|
| -static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, const SkIRect& rect);
|
| +static SkData* encode_to_dct_data(size_t* pixelRefOffset, const SkBitmap& bitmap);
|
|
|
| const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination()
|
| .plus(kMissingExpectations_ErrorType)
|
| @@ -633,7 +633,7 @@ public:
|
| SkScalarRoundToInt(content.height()));
|
| dev = new SkPDFDevice(pageSize, contentSize, initialTransform);
|
| }
|
| - dev->setDCTEncoder(encode_to_dct_stream);
|
| + dev->setDCTEncoder(encode_to_dct_data);
|
| SkAutoUnref aur(dev);
|
|
|
| SkCanvas c(dev);
|
| @@ -1423,32 +1423,33 @@ DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, "
|
| "which can be in range 0-100). N = -1 will disable JPEG compression. "
|
| "Default is N = 100, maximum quality.");
|
|
|
| -static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, const SkIRect& rect) {
|
| +static SkData* encode_to_dct_data(size_t* pixelRefOffset, const SkBitmap& bitmap) {
|
| // Filter output of warnings that JPEG is not available for the image.
|
| if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return false;
|
| if (FLAGS_pdfJpegQuality == -1) return false;
|
|
|
| - SkIRect bitmapBounds;
|
| - SkBitmap subset;
|
| - const SkBitmap* bitmapToUse = &bitmap;
|
| - bitmap.getBounds(&bitmapBounds);
|
| - if (rect != bitmapBounds) {
|
| - SkAssertResult(bitmap.extractSubset(&subset, rect));
|
| - bitmapToUse = ⊂
|
| - }
|
| -
|
| + SkBitmap bm = bitmap;
|
| #if defined(SK_BUILD_FOR_MAC)
|
| // Workaround bug #1043 where bitmaps with referenced pixels cause
|
| // CGImageDestinationFinalize to crash
|
| SkBitmap copy;
|
| bitmapToUse->deepCopyTo(©, bitmapToUse->config());
|
| - bitmapToUse = ©
|
| + bm = ©
|
| #endif
|
|
|
| - return SkImageEncoder::EncodeStream(stream,
|
| - *bitmapToUse,
|
| - SkImageEncoder::kJPEG_Type,
|
| - FLAGS_pdfJpegQuality);
|
| + SkPixelRef* pr = bm.pixelRef();
|
| + if (pr != NULL) {
|
| + SkData* data = pr->refEncodedData();
|
| + if (data != NULL) {
|
| + *pixelRefOffset = bm.pixelRefOffset();
|
| + return data;
|
| + }
|
| + }
|
| +
|
| + *pixelRefOffset = 0;
|
| + return SkImageEncoder::EncodeData(bm,
|
| + SkImageEncoder::kJPEG_Type,
|
| + FLAGS_pdfJpegQuality);
|
| }
|
|
|
| static int findConfig(const char config[]) {
|
|
|