[PDF] Make stream compression optional on a per device basis.
There are a lot of small pieces to make this change work:
- SkPDFDocument (and SkPDFCatalog) take flags to disable compression (and font embedding - not implemented yet, can disable font subsetting for now).
- SkPDFStream now defers compression until the size/emit step.
- Classes that *had* a stream (because they didn't know the stream size at construction time) now *are* streams to make the substitution work correctly.
- The SkPDFShader implementation got pulled apart into two classes, one that is a SkPDFDict, and one that is a SkPDFStream (making the common ancestor SkPDFObject).
- Added helper methods in SkPDFObject for children that have simple resource lists.
- Added an iterator to SkPDFDict so that a substitute SkPDFStream can get a copy of the stream dictionary.
- Change SkPDFDocument to have a pointer to an SkPDFCatalog to remove a new circular header reference.
Review URL: http://codereview.appspot.com/4700045
git-svn-id: http://skia.googlecode.com/svn/trunk@1911 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp
index be69f7f..ebbcd11 100644
--- a/src/pdf/SkPDFImage.cpp
+++ b/src/pdf/SkPDFImage.cpp
@@ -281,38 +281,14 @@
return mask;
}
-void SkPDFImage::emitObject(SkWStream* stream, SkPDFCatalog* catalog,
- bool indirect) {
- if (indirect)
- return emitIndirectObject(stream, catalog);
-
- fStream->emitObject(stream, catalog, indirect);
-}
-
-size_t SkPDFImage::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- if (indirect)
- return getIndirectOutputSize(catalog);
-
- return fStream->getOutputSize(catalog, indirect);
-}
-
void SkPDFImage::getResources(SkTDArray<SkPDFObject*>* resourceList) {
- if (fResources.count()) {
- resourceList->setReserve(resourceList->count() + fResources.count());
- for (int i = 0; i < fResources.count(); i++) {
- resourceList->push(fResources[i]);
- fResources[i]->ref();
- fResources[i]->getResources(resourceList);
- }
- }
+ GetResourcesHelper(&fResources, resourceList);
}
SkPDFImage::SkPDFImage(SkStream* imageData, const SkBitmap& bitmap,
const SkIRect& srcRect, bool doingAlpha,
const SkPaint& paint) {
- fStream = new SkPDFStream(imageData);
- fStream->unref(); // SkRefPtr and new both took a reference.
-
+ this->setData(imageData);
SkBitmap::Config config = bitmap.getConfig();
bool alphaOnly = (config == SkBitmap::kA1_Config ||
config == SkBitmap::kA8_Config);
@@ -372,11 +348,3 @@
insert("Decode", decodeValue.get());
}
}
-
-SkPDFObject* SkPDFImage::insert(SkPDFName* key, SkPDFObject* value) {
- return fStream->insert(key, value);
-}
-
-SkPDFObject* SkPDFImage::insert(const char key[], SkPDFObject* value) {
- return fStream->insert(key, value);
-}