Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: src/pdf/SkPDFImage.cpp

Issue 25054002: Use SkPicture::ExtractBitmap callback in pdf too. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix return on another funtion with signature change Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFImage.h ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFImage.cpp
diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp
index fbd37ebd8eba82a4e76ae77c1db7f4e3a52dee6a..19ad79e4a5d6a9a04a30f08eb9ebf3b9ee248850 100644
--- a/src/pdf/SkPDFImage.cpp
+++ b/src/pdf/SkPDFImage.cpp
@@ -339,7 +339,7 @@ static SkPDFArray* make_indexed_color_space(SkColorTable* table) {
// static
SkPDFImage* SkPDFImage::CreateImage(const SkBitmap& bitmap,
const SkIRect& srcRect,
- EncodeToDCTStream encoder) {
+ SkPicture::EncodeBitmap encoder) {
if (bitmap.getConfig() == SkBitmap::kNo_Config) {
return NULL;
}
@@ -390,7 +390,7 @@ SkPDFImage::SkPDFImage(SkStream* stream,
const SkBitmap& bitmap,
bool isAlpha,
const SkIRect& srcRect,
- EncodeToDCTStream encoder)
+ SkPicture::EncodeBitmap encoder)
: fIsAlpha(isAlpha),
fSrcRect(srcRect),
fEncoder(encoder) {
@@ -482,19 +482,28 @@ bool SkPDFImage::populate(SkPDFCatalog* catalog) {
// Initializing image data for the first time.
SkDynamicMemoryWStream dctCompressedWStream;
if (!skip_compression(catalog) && fEncoder &&
- get_uncompressed_size(fBitmap, fSrcRect) > 1 &&
- fEncoder(&dctCompressedWStream, fBitmap, fSrcRect) &&
- dctCompressedWStream.getOffset() <
- get_uncompressed_size(fBitmap, fSrcRect)) {
- SkAutoTUnref<SkData> data(dctCompressedWStream.copyToData());
- SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, (data)));
- setData(stream.get());
-
- insertName("Filter", "DCTDecode");
- insertInt("ColorTransform", kNoColorTransform);
- insertInt("Length", getData()->getLength());
- setState(kCompressed_State);
- return true;
+ get_uncompressed_size(fBitmap, fSrcRect) > 1) {
+ SkBitmap subset;
+ // Extract subset
+ if (!fBitmap.extractSubset(&subset, fSrcRect)) {
+ // TODO(edisonn) It fails only for kA1_Config, if that is a
+ // major concern we will fix it later, so far it is NYI.
+ return false;
+ }
+ size_t pixelRefOffset = 0;
+ SkAutoTUnref<SkData> data(fEncoder(&pixelRefOffset, subset));
+ if (data.get() && data->size() < get_uncompressed_size(fBitmap,
+ fSrcRect)) {
+ SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream,
+ (data)));
+ setData(stream.get());
+
+ insertName("Filter", "DCTDecode");
+ insertInt("ColorTransform", kNoColorTransform);
+ insertInt("Length", getData()->getLength());
+ setState(kCompressed_State);
+ return true;
+ }
}
// Fallback method
if (!fStreamValid) {
« no previous file with comments | « src/pdf/SkPDFImage.h ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698