aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-02-20 05:57:11 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-20 05:57:11 -0800
commit07d5947b886bef06621e830e9f8bf253f9bad703 (patch)
treed7190444e341c554fe73652f57005b12cbb9a998
parentb92b706dfdd68958f0fec76f8f5e0b7590798907 (diff)
PDF: remove unused SkPDFDevice::setDCTEncoder()
All image compression currently uses (losseless) Deflate, not Jpeg. See http://crrev.com/935843007 Review URL: https://codereview.chromium.org/946493002
-rw-r--r--src/pdf/SkPDFDevice.cpp4
-rw-r--r--src/pdf/SkPDFDevice.h16
-rw-r--r--src/pdf/SkPDFImage.cpp51
-rw-r--r--src/pdf/SkPDFImage.h15
4 files changed, 14 insertions, 72 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index a15571a5b3..329d0971dd 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -727,7 +727,6 @@ SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
, fLastContentEntry(NULL)
, fLastMarginContentEntry(NULL)
, fClipStack(NULL)
- , fEncoder(NULL)
, fRasterDpi(72.0f)
{
const SkImageInfo info = make_content_info(contentSize, &initialTransform);
@@ -760,7 +759,6 @@ SkPDFDevice::SkPDFDevice(const SkISize& layerSize,
, fLastContentEntry(NULL)
, fLastMarginContentEntry(NULL)
, fClipStack(NULL)
- , fEncoder(NULL)
, fRasterDpi(72.0f)
{
fInitialTransform.reset();
@@ -2178,7 +2176,7 @@ void SkPDFDevice::internalDrawBitmap(const SkMatrix& origMatrix,
}
SkAutoTUnref<SkPDFObject> image(
- SkPDFCreateImageObject(*bitmap, subset, fEncoder));
+ SkPDFCreateImageObject(*bitmap, subset));
if (!image) {
return;
}
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index de405c1317..4c0f752405 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -126,21 +126,6 @@ public:
*/
SK_API void setDrawingArea(DrawingArea drawingArea);
- /** Sets the DCTEncoder for images.
- * @param encoder The encoder to encode a bitmap as JPEG (DCT).
- * Result of encodings are cached, if the encoder changes the
- * behaivor dynamically and an image is added to a second catalog,
- * we will likely use the result of the first encoding call.
- * By returning false from the encoder function, the encoder result
- * is not used.
- * Callers might not want to encode small images, as the time spent
- * encoding and decoding might not be worth the space savings,
- * if any at all.
- */
- void setDCTEncoder(SkData* (*encoder)(size_t*, const SkBitmap&)) {
- fEncoder = encoder;
- }
-
// PDF specific methods.
/** Returns the resource dictionary for this device.
@@ -245,7 +230,6 @@ private:
// Glyph ids used for each font on this device.
SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage;
- SkData* (*fEncoder)(size_t*, const SkBitmap&);
SkScalar fRasterDpi;
SkBitmap fLegacyBitmap;
diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp
index c7836e5585..788b64794a 100644
--- a/src/pdf/SkPDFImage.cpp
+++ b/src/pdf/SkPDFImage.cpp
@@ -20,8 +20,6 @@
#include "SkString.h"
#include "SkUnPreMultiply.h"
-static const int kNoColorTransform = 0;
-
static size_t get_uncompressed_size(const SkBitmap& bitmap,
const SkIRect& srcRect) {
switch (bitmap.colorType()) {
@@ -457,8 +455,7 @@ static SkBitmap unpremultiply_bitmap(const SkBitmap& bitmap,
// static
SkPDFImage* SkPDFImage::CreateImage(const SkBitmap& bitmap,
- const SkIRect& srcRect,
- SkData* (*encoder)(size_t*, const SkBitmap&)) {
+ const SkIRect& srcRect) {
if (bitmap.colorType() == kUnknown_SkColorType) {
return NULL;
}
@@ -484,22 +481,19 @@ SkPDFImage* SkPDFImage::CreateImage(const SkBitmap& bitmap,
if (kN32_SkColorType == colorType) {
image = SkNEW_ARGS(SkPDFImage, (NULL, bitmap, false,
SkIRect::MakeWH(srcRect.width(),
- srcRect.height()),
- encoder));
+ srcRect.height())));
} else {
SkBitmap unpremulBitmap = unpremultiply_bitmap(bitmap, srcRect);
image = SkNEW_ARGS(SkPDFImage, (NULL, unpremulBitmap, false,
SkIRect::MakeWH(srcRect.width(),
- srcRect.height()),
- encoder));
+ srcRect.height())));
}
} else {
- image = SkNEW_ARGS(SkPDFImage, (NULL, bitmap, false, srcRect, encoder));
+ image = SkNEW_ARGS(SkPDFImage, (NULL, bitmap, false, srcRect));
}
if (alphaData.get() != NULL) {
SkAutoTUnref<SkPDFImage> mask(
- SkNEW_ARGS(SkPDFImage, (alphaData.get(), bitmap,
- true, srcRect, NULL)));
+ SkNEW_ARGS(SkPDFImage, (alphaData.get(), bitmap, true, srcRect)));
image->insert("SMask", new SkPDFObjRef(mask))->unref();
}
return image;
@@ -510,11 +504,9 @@ SkPDFImage::~SkPDFImage() {}
SkPDFImage::SkPDFImage(SkStream* stream,
const SkBitmap& bitmap,
bool isAlpha,
- const SkIRect& srcRect,
- SkData* (*encoder)(size_t*, const SkBitmap&))
+ const SkIRect& srcRect)
: fIsAlpha(isAlpha),
- fSrcRect(srcRect),
- fEncoder(encoder) {
+ fSrcRect(srcRect) {
if (bitmap.isImmutable()) {
fBitmap = bitmap;
@@ -588,7 +580,6 @@ SkPDFImage::SkPDFImage(SkPDFImage& pdfImage)
fBitmap(pdfImage.fBitmap),
fIsAlpha(pdfImage.fIsAlpha),
fSrcRect(pdfImage.fSrcRect),
- fEncoder(pdfImage.fEncoder),
fStreamValid(pdfImage.fStreamValid) {
// Nothing to do here - the image params are already copied in SkPDFStream's
// constructor, and the bitmap will be regenerated and encoded in
@@ -598,25 +589,6 @@ SkPDFImage::SkPDFImage(SkPDFImage& pdfImage)
bool SkPDFImage::populate(SkPDFCatalog* catalog) {
if (getState() == kUnused_State) {
// Initializing image data for the first time.
- if (fEncoder && get_uncompressed_size(fBitmap, fSrcRect) > 1) {
- SkBitmap subset;
- // Extract subset
- if (!fBitmap.extractSubset(&subset, fSrcRect)) {
- return false;
- }
- size_t pixelRefOffset = 0;
- SkAutoTUnref<SkData> data(fEncoder(&pixelRefOffset, subset));
- if (data.get() && data->size() < get_uncompressed_size(fBitmap,
- fSrcRect)) {
- this->setData(data.get());
-
- insertName("Filter", "DCTDecode");
- insertInt("ColorTransform", kNoColorTransform);
- insertInt("Length", this->dataSize());
- setState(kCompressed_State);
- return true;
- }
- }
// Fallback method
if (!fStreamValid) {
SkAutoTDelete<SkStream> stream(
@@ -628,9 +600,6 @@ bool SkPDFImage::populate(SkPDFCatalog* catalog) {
}
#ifndef SK_NO_FLATE
else if (getState() == kNoCompression_State) {
-#else // SK_NO_FLATE
- else if (getState() == kNoCompression_State && fEncoder) {
-#endif // SK_NO_FLATE
// Compression has not been requested when the stream was first created,
// but the new catalog wants it compressed.
if (!getSubstitute()) {
@@ -640,6 +609,7 @@ bool SkPDFImage::populate(SkPDFCatalog* catalog) {
}
return false;
}
+#endif // SK_NO_FLATE
return true;
}
@@ -719,8 +689,7 @@ static bool is_jfif_jpeg(SkData* data) {
SkPDFObject* SkPDFCreateImageObject(
const SkBitmap& bitmap,
- const SkIRect& subset,
- SkData* (*encoder)(size_t*, const SkBitmap&)) {
+ const SkIRect& subset) {
if (SkPDFObject* pdfBitmap = SkPDFBitmap::Create(bitmap, subset)) {
return pdfBitmap;
}
@@ -733,5 +702,5 @@ SkPDFObject* SkPDFCreateImageObject(
}
}
#endif
- return SkPDFImage::CreateImage(bitmap, subset, encoder);
+ return SkPDFImage::CreateImage(bitmap, subset);
}
diff --git a/src/pdf/SkPDFImage.h b/src/pdf/SkPDFImage.h
index cfef38cbe2..8e36542f0b 100644
--- a/src/pdf/SkPDFImage.h
+++ b/src/pdf/SkPDFImage.h
@@ -23,13 +23,8 @@ struct SkIRect;
/**
* Return the mose efficient availible encoding of the given bitmap.
- *
- * If the bitmap has encoded JPEG data and that data can be embedded
- * into the PDF output stream directly, use that. Otherwise, fall
- * back on SkPDFImage::CreateImage.
*/
-SkPDFObject* SkPDFCreateImageObject(
- const SkBitmap&, const SkIRect& subset, SkData* (*)(size_t*, const SkBitmap&));
+SkPDFObject* SkPDFCreateImageObject(const SkBitmap&, const SkIRect& subset);
/** \class SkPDFImage
@@ -49,8 +44,7 @@ public:
* the given parameters.
*/
static SkPDFImage* CreateImage(const SkBitmap& bitmap,
- const SkIRect& srcRect,
- SkData* (*encoder)(size_t*, const SkBitmap&));
+ const SkIRect& srcRect);
virtual ~SkPDFImage();
@@ -62,7 +56,6 @@ private:
SkBitmap fBitmap;
bool fIsAlpha;
SkIRect fSrcRect;
- SkData* (*fEncoder)(size_t*, const SkBitmap&);
bool fStreamValid;
/** Create a PDF image XObject. Entries for the image properties are
@@ -77,11 +70,9 @@ private:
* @param isAlpha Whether or not this is the alpha of an image.
* @param srcRect The clipping applied to bitmap before generating
* imageData.
- * @param encoder A function used to encode the bitmap for compression.
- * May be NULL.
*/
SkPDFImage(SkStream* stream, const SkBitmap& bitmap, bool isAlpha,
- const SkIRect& srcRect, SkData* (*encoder)(size_t*, const SkBitmap&));
+ const SkIRect& srcRect);
/** Copy constructor, used to generate substitutes.
* @param image The SkPDFImage to copy.