Motivation: as we implement more features in PDF, it would be nice to more easily see what is happening in the output. This change serializes page content as plain text rather than compressed text, but it has to be explicitly enabled with a GYP_DEFINE change:
export GYP_DEFINES='skia_pdf_less_compression=1'
bin/sync-and-gyp
ninja -C out/Debug dm
out/Debug/dm --config pdf --src gm -w /tmp
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=
1840103002
Review URL: https://codereview.chromium.org/
1840103002
'product_name': 'skia_pdf',
'type': 'static_library',
'standalone_static_library': 1,
- 'variables': { 'skia_pdf_use_sfntly%': 1, },
+ 'variables': {
+ 'skia_pdf_use_sfntly%': 1,
+ 'skia_pdf_less_compression%': 0, # enable for debugging only
+ },
'dependencies': [
'skia_lib.gyp:skia_lib',
'zlib.gyp:zlib',
{ 'dependencies': [ 'sfntly.gyp:sfntly' ] }
],
[ 'skia_pdf_generate_pdfa', { 'defines': ['SK_PDF_GENERATE_PDFA'] } ],
+ [ 'skia_pdf_less_compression',
+ {'defines': ['SK_PDF_LESS_COMPRESSION'] }
+ ],
[ 'skia_android_framework', {
# Add SFTNLY support for PDF (which in turns depends on ICU)
'include_dirs': [
stream->writeText("\nendstream");
}
+
void SkPDFStream::setData(SkStream* stream) {
SkASSERT(!fCompressedData); // Only call this function once.
SkASSERT(stream);
// Code assumes that the stream starts at the beginning.
+ #ifdef SK_PDF_LESS_COMPRESSION
+ std::unique_ptr<SkStreamRewindable> duplicate(stream->duplicate());
+ if (duplicate && duplicate->hasLength()) {
+ this->insertInt("Length", duplicate->getLength());
+ fCompressedData.reset(duplicate.release());
+ return;
+ }
+ #endif
+
SkDynamicMemoryWStream compressedData;
SkDeflateWStream deflateWStream(&compressedData);
SkStreamCopy(&deflateWStream, stream);
SkDEBUGCODE(fDumped = true;)
}
+#ifdef SK_PDF_LESS_COMPRESSION
+void SkPDFSharedStream::emitObject(
+ SkWStream* stream,
+ const SkPDFObjNumMap& objNumMap,
+ const SkPDFSubstituteMap& substitutes) const {
+ SkASSERT(!fDumped);
+ std::unique_ptr<SkStreamAsset> dup(fAsset->duplicate());
+ SkASSERT(dup && dup->hasLength());
+ size_t length = dup->getLength();
+ stream->writeText("<<");
+ fDict->emitAll(stream, objNumMap, substitutes);
+ stream->writeText("\n");
+ SkPDFUnion::Name("Length").emitObject(
+ stream, objNumMap, substitutes);
+ stream->writeText(" ");
+ SkPDFUnion::Int(length).emitObject(
+ stream, objNumMap, substitutes);
+ stream->writeText("\n>>stream\n");
+ SkStreamCopy(stream, dup.get());
+ stream->writeText("\nendstream");
+}
+#else
void SkPDFSharedStream::emitObject(
SkWStream* stream,
const SkPDFObjNumMap& objNumMap,
buffer.writeToStream(stream);
stream->writeText("\nendstream");
}
+#endif
void SkPDFSharedStream::addResources(
SkPDFObjNumMap* catalog, const SkPDFSubstituteMap& substitutes) const {