aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFTypes.cpp
Commit message (Collapse)AuthorAge
* Revert "Revert "SkTypes: extract SkTo""Gravatar Hal Canary2018-06-14
| | | | | | | | | | | | | | | | This reverts commit fdcfb8b7c23fbf18f872d2c31d27978235033876. > Original change's description: > > SkTypes: extract SkTo > > > > Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 > > Reviewed-on: https://skia-review.googlesource.com/133620 > > Reviewed-by: Mike Klein <mtklein@google.com> Change-Id: Ida74fbc5c21248a724a5edbf9fae18a33bcb23aa Reviewed-on: https://skia-review.googlesource.com/134506 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* Revert "SkTypes: extract SkTo"Gravatar Hal Canary2018-06-13
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2a2f67592602b18527bc3fd449132d420cd5b62e. Reason for revert: this appears to be what is holding up the Chrome roll. Original change's description: > SkTypes: extract SkTo > > Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 > Reviewed-on: https://skia-review.googlesource.com/133620 > Reviewed-by: Mike Klein <mtklein@google.com> TBR=mtklein@google.com,halcanary@google.com No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Iafd738aedfb679a23c061a51afe4b98a8d4cdfae Reviewed-on: https://skia-review.googlesource.com/134504 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkTypes: extract SkToGravatar Hal Canary2018-06-12
| | | | | | Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 Reviewed-on: https://skia-review.googlesource.com/133620 Reviewed-by: Mike Klein <mtklein@google.com>
* trim #include <new> from SkPostConfig.hGravatar Mike Klein2018-06-11
| | | | | | | Change-Id: I693ddcd4ade101ba4eb4102e03adce183aa1d672 Reviewed-on: https://skia-review.googlesource.com/133829 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* SkPDF: use std::aligned_storage for typed unionGravatar Hal Canary2018-04-16
| | | | | | | Change-Id: I38e063cf7557aab1cffbaa126aea4dc7142d914c Reviewed-on: https://skia-review.googlesource.com/121583 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
* SkPDF: consolidate two functions in SkPDFObjNumMapGravatar Hal Canary2017-10-10
| | | | | | | Change-Id: Id815920e664ba986258867b7c35a7618a6927b0f Reviewed-on: https://skia-review.googlesource.com/54360 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkPDF: simplify SkPDFGraphicStateGravatar Hal Canary2017-06-30
| | | | | | | | | | | | | | - Separate graphic state objects for Stroke and Fill. - SkPDFGraphicState::GetGraphicStateForPaint simplified. - No more SkPDFGraphicState objects.Simplify SkPDFCanon. All PDFs render the same. Most PDFs are slightly smaller, especially those from captured web pages. Change-Id: Id9605c1d7495645da558d5f378ba585cdc201bba Reviewed-on: https://skia-review.googlesource.com/21343 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkPDF: implement SkPDFArray::reserve.Gravatar Hal Canary2017-06-23
| | | | | | | | | | SkTArray::reserve() was implemented here: https://skia.googlesource.com/skia/+/06ca8ec%5E%21/#F28 Change-Id: Ibe78cd686506ccb424a827b37bca9c2904565f85 Reviewed-on: https://skia-review.googlesource.com/20518 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* factor out hexadecimal constants.Gravatar Hal Canary2017-06-19
| | | | | | | | | | Now we don't have to rely on the linker to de-duplicate so many gHex[] constants. Change-Id: Ia86d3a92648415afdb8d29499b4faded5ed05c7d Reviewed-on: https://skia-review.googlesource.com/20180 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
* SkStream: DynamicMemoryWStream gets writeToAndResetGravatar Hal Canary2017-05-24
| | | | | | | | | | | | | This is similar to copyToAndReset(). Also use this in SkPDF, for minor memory savings: Single-threaded DM's peak RSS drops from 239MB to 228MB. Change-Id: I352a980e6dd54eb05d74cd057bd50e02312753b0 Reviewed-on: https://skia-review.googlesource.com/17714 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* src/pdf: code cleanupGravatar Hal Canary2017-05-04
| | | | | | | | | | | | | * SkPDFCanon: remove unnecessary abstraction * Make use of SkTHashMap<K, sk_sp<T>>. * Remove unncessary struct constructors. * More factory fns return sk_sp<T> * SkPDFUtility::GetCachedT<T> factored out. Change-Id: I4055a131b43fe2588fd042b769cd09fff8a3466c Reviewed-on: https://skia-review.googlesource.com/13655 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkDynamicMemoryWStream::detachAsStream() returns unique_ptrGravatar Hal Canary2017-03-15
| | | | | | | | https://crrev.com/2747183002 must land first. Change-Id: I65d1285a24d63c2c2f18662d511dea1c399511e1 Reviewed-on: https://skia-review.googlesource.com/9682 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
* SkMakeUnique.h defines skstd::make_unique<T>(Args...)Gravatar halcanary2016-09-02
| | | | | | | BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2293963002 Review-Url: https://codereview.chromium.org/2293963002
* SkPDF: in-place font subsettingGravatar halcanary2016-08-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: gross code simplification, also no bitset lookups at draw time. SkPDFFont owns its glyph useage bitset. SkPDFSubstituteMap goes away. SkPDFObject interface is simplified. SkPDFDocument tracks font usage (as hash set), not glyph usage. SkPDFFont gets a simpler constructor. SkPDFFont has first and last glyph set in constructor, not adjusted later. SkPDFFont implementations are simplified. SkPDFGlyphSet is replaced with simple SkBitSet. SkPDFFont sizes its SkBitSets based on glyph count. SkPDFGlyphSetMap goes away. SkBitSet is now non-copyable. SkBitSet now how utility methods to match old SkPDFGlyphSet. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2253283004 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Win-MSVC-GCE-CPU-AVX2-x86_64-Release-GDI-Trybot,Test-Win-MSVC-GCE-CPU-AVX2-x86_64-Debug-GDI-Trybot Review-Url: https://codereview.chromium.org/2253283004
* SkPDF: Subset Type3 (fallback) fontGravatar halcanary2016-08-12
| | | | | | | | | | | | | | | | | | | Motivation: significant file-size reduction. Also: SkPDFFont::subsetFont() returns a sk_sp<SkPDFObject> rather than a SkPDFFont*. SkPDFType3Font constructor no longer populates font info; relies on subsetting. SkPDFFont::Create is easier to read Also: SkPDFType3Font are scaled by emSize rather than 1000. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2231483002 Committed: https://skia.googlesource.com/skia/+/88b138da99328b04cae9a8ee19c3882b8847a550 Review-Url: https://codereview.chromium.org/2231483002
* Revert of SkPDF: Subset Type3 (fallback) font (patchset #8 id:200001 of ↵Gravatar halcanary2016-08-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/2231483002/ ) Reason for revert: internal failing Original issue's description: > SkPDF: Subset Type3 (fallback) font > > Motivation: significant file-size reduction. > > Also: SkPDFFont::subsetFont() returns a sk_sp<SkPDFObject> > rather than a SkPDFFont*. > > SkPDFType3Font constructor no longer populates font info; > relies on subsetting. > > SkPDFFont::Create is easier to read > > Also: SkPDFType3Font are scaled by emSize rather than 1000. > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2231483002 > > Committed: https://skia.googlesource.com/skia/+/88b138da99328b04cae9a8ee19c3882b8847a550 TBR=bungeman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2232283003
* SkPDF: Subset Type3 (fallback) fontGravatar halcanary2016-08-11
| | | | | | | | | | | | | | | | | | Motivation: significant file-size reduction. Also: SkPDFFont::subsetFont() returns a sk_sp<SkPDFObject> rather than a SkPDFFont*. SkPDFType3Font constructor no longer populates font info; relies on subsetting. SkPDFFont::Create is easier to read Also: SkPDFType3Font are scaled by emSize rather than 1000. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2231483002 Review-Url: https://codereview.chromium.org/2231483002
* std::move(SkTDArray)Gravatar halcanary2016-08-08
| | | | | | | | | Since we don't support MSVC2013 anymore, we can be more succinct when defining move constructors of compound types. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2227673002 Review-Url: https://codereview.chromium.org/2227673002
* SkPDF: PDFStream has-a not is-a PDFDictGravatar halcanary2016-07-29
| | | | | | | | | | | | | | | Motivation: SkPDFStream and SkPDFSharedStream now work the same. Also: - move SkPDFStream into SkPDFTypes (it's a fundamental PDF type). - minor refactor of SkPDFSharedStream - SkPDFSharedStream takes unique_ptr to represent ownership BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2190883003 Review-Url: https://codereview.chromium.org/2190883003
* SkPdf: smaller color serializationGravatar halcanary2016-07-15
| | | | | | | | | | | | | | SkPDFUtils now has a special function (SkPDFUtils::AppendColorComponent) just for writing out (color/255) as a decimal with three digits of precision. SkPDFUnion now has a type to represent a color component. It holds a utint_8, but calls into AppendColorComponent to serialize. Added a unit test that tests all possible input values. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2151863003 Review-Url: https://codereview.chromium.org/2151863003
* Remove unnecessary includes in src/pdf/Gravatar martina.kollarova2016-06-29
| | | | | | | | | Use forward declaration more. BUG=None GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2110033002 Review-Url: https://codereview.chromium.org/2110033002
* SkPDF: alloc less memory for stringsGravatar halcanary2016-06-23
| | | | | | | | | | | | | | | | | before: micros bench 250.98 WritePDFText nonrendering after: micros bench 107.10 WritePDFText nonrendering Also, be slightly more space-efficient in encoding strings. Also, add a bench. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2099463002 Review-Url: https://codereview.chromium.org/2099463002
* SkPDF: skia_pdf_less_compression - for debugging onlyGravatar halcanary2016-03-29
| | | | | | | | | | | | | 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
* SkPDF s/SkAutoTDelete/std::unique_ptr/Gravatar halcanary2016-03-28
| | | | | | GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1837553002 Review URL: https://codereview.chromium.org/1837553002
* SkPDF: add drop() virtual to release resources early.Gravatar halcanary2016-03-21
| | | | | | | | | | | | | | | | | | | Call drop() after calling emitObject() on top-level objects. In Debug mode, assert that each object is emited exactly once by asserting that emitObject is never called after drop(). Same for addResources(). To make sure that top level objects don't get deleted prematurely, SkPDFObjNumMap takes a reference. Motivation: save RAM. Allow even earlier serialization with later changes. Also: Switch some SkTDArrays to SkTArrays. BUG=skia:5087 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1790023003 Review URL: https://codereview.chromium.org/1790023003
* SkPDF: Add sk_sp setters; .release() becomes std::move()Gravatar halcanary2016-03-08
| | | | | | | | | | | | | | | | Note to reviewers: Start with changes to SkPDFTypes.h Many places that had a bare pointer owning a reference are refactored to use a sk_sp. There remain several places where a non-owning pointer `T*` should be replaced with `const sk_sp<T>&` to eliminate the common pattern `sk_sp<T>(SkRef(x))`. Committed: https://skia.googlesource.com/skia/+/9904c9212074279380e21f96575078734dbbd308 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1775043002 Review URL: https://codereview.chromium.org/1775043002
* Revert of SkPDF: Add sk_sp setters; .release() becomes std::move() (patchset ↵Gravatar halcanary2016-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | #2 id:20001 of https://codereview.chromium.org/1775043002/ ) Reason for revert: https://build.chromium.org/p/client.skia/builders/Linux%20Builder/builds/6405/steps/compile/logs/stdio Original issue's description: > SkPDF: Add sk_sp setters; .release() becomes std::move() > > Note to reviewers: Start with changes to SkPDFTypes.h > > Many places that had a bare pointer owning a reference are refactored to > use a sk_sp. > > There remain several places where a non-owning pointer `T*` should be > replaced with `const sk_sp<T>&` to eliminate the common pattern > `sk_sp<T>(SkRef(x))`. > > Committed: https://skia.googlesource.com/skia/+/9904c9212074279380e21f96575078734dbbd308 TBR=bungeman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1775143002
* SkPDF: Add sk_sp setters; .release() becomes std::move()Gravatar halcanary2016-03-08
| | | | | | | | | | | | | Note to reviewers: Start with changes to SkPDFTypes.h Many places that had a bare pointer owning a reference are refactored to use a sk_sp. There remain several places where a non-owning pointer `T*` should be replaced with `const sk_sp<T>&` to eliminate the common pattern `sk_sp<T>(SkRef(x))`. Review URL: https://codereview.chromium.org/1775043002
* SkPDF: Optionally output PDF/A-2b archive format.Gravatar halcanary2015-10-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: this format does not yet pass validation tests. Add skia_pdf_generate_pdfa GYP flag. Default to off for now. PDF/A files are not reproducable, so they make correctness testing harder. Turn the Metadata struct into te SkPDFMetadata struct. This splits out a lot of functionality around both kinds of metadata. When PDF/A is used, add an ID entry to the trailer. Add SkPDFObjNumMap::addObjectRecursively. Test with GYP_DEFINES=skia_pdf_generate_pdfa=1 bin/sync-and-gyp ninja -C out/Release dm out/Release/dm --config pdf --src skp gm -w /tmp/dm With skia_pdf_generate_pdfa=0, all PDFs generated from GMs and SKPs are identical. With skia_pdf_generate_pdfa=1, all PDFs generated from GMs and SKPs render identically in Pdfium. BUG=skia:3110 Review URL: https://codereview.chromium.org/1394263003
* Revert of SkPDF: Optionally output PDF/A-2b archive format. (patchset #5 ↵Gravatar bungeman2015-10-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | id:80001 of https://codereview.chromium.org/1394263003/ ) Reason for revert: SkMD5 is not really part of the Skia library. This is breaking the roll by using it, since Chromium doesn't build it. Original issue's description: > SkPDF: Optionally output PDF/A-2b archive format. > > Note: this format does not yet pass validation tests. > > Add skia_pdf_generate_pdfa GYP flag. Default to off for now. > PDF/A files are not reproducable, so they make correctness > testing harder. > > Turn the Metadata struct into te SkPDFMetadata struct. This > splits out a lot of functionality around both kinds of metadata. > > When PDF/A is used, add an ID entry to the trailer. > > Add SkPDFObjNumMap::addObjectRecursively. > > Test with > > GYP_DEFINES=skia_pdf_generate_pdfa=1 bin/sync-and-gyp > ninja -C out/Release dm > out/Release/dm --config pdf --src skp gm -w /tmp/dm > > With skia_pdf_generate_pdfa=0, all PDFs generated from GMs and > SKPs are identical. With skia_pdf_generate_pdfa=1, all PDFs > generated from GMs and SKPs render identically in Pdfium. > > BUG=skia:3110 > > Committed: https://skia.googlesource.com/skia/+/939c0fe51f157104758bcb268643c8b6d317a530 TBR=tomhudson@google.com,halcanary@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:3110 Review URL: https://codereview.chromium.org/1398193002
* SkPDF: Optionally output PDF/A-2b archive format.Gravatar halcanary2015-10-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: this format does not yet pass validation tests. Add skia_pdf_generate_pdfa GYP flag. Default to off for now. PDF/A files are not reproducable, so they make correctness testing harder. Turn the Metadata struct into te SkPDFMetadata struct. This splits out a lot of functionality around both kinds of metadata. When PDF/A is used, add an ID entry to the trailer. Add SkPDFObjNumMap::addObjectRecursively. Test with GYP_DEFINES=skia_pdf_generate_pdfa=1 bin/sync-and-gyp ninja -C out/Release dm out/Release/dm --config pdf --src skp gm -w /tmp/dm With skia_pdf_generate_pdfa=0, all PDFs generated from GMs and SKPs are identical. With skia_pdf_generate_pdfa=1, all PDFs generated from GMs and SKPs render identically in Pdfium. BUG=skia:3110 Review URL: https://codereview.chromium.org/1394263003
* SkPDF: Implement drawImage*() properlyGravatar halcanary2015-10-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | drawImage calls now properly embeds the original jpeg. NOTE: drawBitmap*() calls no longer embed JPEG files when possible (this is in advance of eliminating bitmaps backed by encoded data). Chromium has already moved from drawBitmap to drawImage. Comparisons: control: total PDF drawImage/drawBitmap calls: 8010 total PDF jpeg images: 0 total PDF regular images: 3581 experiament: total PDF drawImage/drawBitmap calls: 8014 total PDF jpeg images: 271 total PDF regular images: 3311 total PDF regular images: 3582 (271 + 3311) When comparing rendered output there were perceptual differences in the following four GMs: colorcube, emboss, colormatrix, and tablecolorfilter. All of these differences were improvements (that is, closer to the 8888 rendering) due fixing a bug with colorfilters and forgetting to call notifyPixelsChanged. No SKPs had perceptual differences. Total PDF size dropped from 133964 kB to 126276 kB, a 5.7% improvement (mostly due to restoring use of JPG images in SKPs). BUG=skia:4370 Review URL: https://codereview.chromium.org/1372783003
* Style Change: SkNEW->new; SkDELETE->deleteGravatar halcanary2015-08-26
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316123003 Review URL: https://codereview.chromium.org/1316123003
* SkPDF: Memory improvements for PDF StreamsGravatar halcanary2015-08-20
| | | | | | | | | ΔMEM = -15% ΔCPU = -7% BUG=skia:3030 Review URL: https://codereview.chromium.org/1227913008
* SkPDF: Simplify PDFStream / emitObject() constGravatar halcanary2015-08-19
| | | | | | | | | | Compress SkPDFStream's data on setData(), not emitObject(); no longer stateful. SkPDFObject::emitObject is now const. This makes it easier to reason about state. Minimal performance gains. Review URL: https://codereview.chromium.org/1304493002
* SkPDF: fix name escape codeGravatar halcanary2015-06-08
| | | | | | BUG=494913 Review URL: https://codereview.chromium.org/1152283014
* SkPDF: Move utility fns to SkPDFUtilsGravatar halcanary2015-05-06
| | | | | | BUG=skia:3585 Review URL: https://codereview.chromium.org/1124193003
* SkPDF: Remove unused deprecated functions in SkPDFTypesGravatar halcanary2015-05-05
| | | | | | | | | | | | | depends on: http://crrev.com/1107923002 http://crrev.com/1103163002 http://crrev.com/1110533002 http://crrev.com/1107913002 http://crrev.com/1106163002 BUG=skia:3585 Review URL: https://codereview.chromium.org/1113583002
* SkPDF: clean up uses of deprecated calls in other SkPDF classesGravatar halcanary2015-04-27
| | | | | | BUG=skia:3585 Review URL: https://codereview.chromium.org/1107923002
* SkPDF: Refactor SkPDFObject heiararchy.Gravatar halcanary2015-04-25
| | | | | | | | | | | Flatten and use a tagged union type Δmemory ~= -2.4% ± 0.5% Δtime ~= -1.2% ± 0.2% BUG=skia:3585 Review URL: https://codereview.chromium.org/1069103003
* SkPDF: Remove Array's unused set(i) and get(i) (leaving only append())Gravatar halcanary2015-04-08
| | | | | | BUG=skia:3585 Review URL: https://codereview.chromium.org/1071583003
* SkPDF: SkPDFString is no longer aware of wide strings.Gravatar halcanary2015-04-07
| | | | | | | | | | | | Since wide strings are only used in SkPDFDevice, I have moved the function that manages them to that directory. Motivation: The SkPDFString will be refactored later along with the other SkPFObject heirarchy. BUG=skia:3585 Review URL: https://codereview.chromium.org/1064013003
* SkPDF: Factor SkPDFCatalog into SkPDFObjNumMap and SkPDFSubstituteMapGravatar halcanary2015-03-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: Keep separate features separate. Also, future linearization work will need to have several objNumMap objects share a substituteMap. Also "catalog" has a specific meaning in PDF. This catalog did not map to that catalog. - Modify SkPDFObject::emitObject and SkPDFObject::addResources interface to requiore SkPDFObjNumMap and SkPDFSubstituteMap. - SkPDFObjNumMap const in SkPDFObject::emitObject. - Remove SkPDFCatalog.cpp/.h - Modify SkDocument_PDF.cpp to use new functions - Fold in SkPDFStream::populate - Fold in SkPDFBitmap::emitDict - Move SkPDFObjNumMap and SkPDFSubstituteMap to SkPDFTypes.h - Note (via assert) that SkPDFArray & SkPDFDict don't need to check substitutes. - Remove extra space from SkPDFDict serialization. - SkPDFBitmap SkPDFType0Font SkPDFGraphicState SkPDFStream updated to new interface. - PDFPrimitivesTest updated for new interface. BUG=skia:3585 Review URL: https://codereview.chromium.org/1049753002
* SkPDF SkPDFObject::addResources signature simplifiedGravatar halcanary2015-03-25
| | | | | | | | | | - SkPDFcatalog keeps a ordered list of object pointers - Elimiante SkTSet template class - SkPDFObject::addResources signature changes BUG=skia:3585 Review URL: https://codereview.chromium.org/1038523004
* SKPDF: refactor pdfcatalog and pdfdocumentGravatar halcanary2015-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SkPDFCatalog: - remove first-page-specific code (no longer needed, never used) (e.g. addObject()). - Make use of SkHashMap for lookups (simplifies code). - inline all small methods - emitXrefTable moved to SkPDFDocument.cpp - no longer store offsets in this data structure (moved to SkPDFDocument.cpp) - setFileOffset gone. - own substitute refs directly. SkPDFDocument::EmitPDF() - All sites that call into SkPDFCatalog modified. - catalog.addObject only called in a single place, after the resouceSet is built - offsets moved to local array. SkPDFPage: - finalizePage no longer deals with SkPDFCatalog or resource sets. - GeneratePageTree no longer deals with SkPDFCatalog SkPDFObjRef - emitObject respects the substitution map Unit Tests: - respect SkPDFCatalog::addObject signature change. SkTHash: - #include SkChecksum for SkGoodHash - Copyright notice added Review URL: https://codereview.chromium.org/1033543002
* PDF: remove unnecessary mutexes.Gravatar halcanary2015-02-20
| | | | | | | | We now force all SkPDFObjects to stay on one thread. TBR=mtklein@google.com Review URL: https://codereview.chromium.org/942153002
* Simplify reference management in SkPDFGravatar halcanary2015-02-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, SkPDFObject subclasses were required to track their resources separately from the document structure. (An object has a resource if it depends, via an indirect reference, on another object). This led to a lot of extra code to duplicate effort. I replace the getResources() function with the much simpler addResources() function. I only define a non-trivial addResources() method on arrays, dictionaries, and indirect object references. All other specialized classes simply rely on their parent class's implementation. SkPDFObject::addResources() works by recursively walking the directed graph of object (direct and indirect) references and adding resources to a set. It doesn't matter that there are closed loops in the graph, since we check the set before walking down a branch. - Add SkPDFObject::addResources() virtual function, with four implementations - Remove SkPDFObject::getResources() virtual function and all implementations. - Remove SkPDFObject::GetResourcesHelper() - Remove SkPDFObject::AddResourceHelper() - In SkPDFCatalog::findObjectIndex(), add an object to the catalog if it doesn't exist yet. - SkPDFCatalog::setSubstitute() no longer sets up resources - SkPDFDocument.cpp no longer needs the Streamer object - SkPDFDocument.cpp calls fDocCatalog->addResources to build the resource list. - SkPDFFont::addResource() removed - All SkPDF-::fResource sets removed (they are redundant). - removed SkPDFImage::addSMask() function - SkPDFResourceDict::getReferencedResources() removed. Motivation: this removes quite a bit of code and makes the objects slightly slimmer in memory. Most importantly, this will lead the way towards removing SkPDFObject's inheritance from SkRefCnt, which will greatly simplify everything. Testing: I usually test changes to the PDF backend by comparing checksums of PDF files rendered from GMs and SKPs before and after the change. This change both re-orders and re-numbers the indirect PDF objects. I used the qpdf program to normalize the PDFs and then compared the normalized outputs from before and after the change; they matched. Review URL: https://codereview.chromium.org/870333002
* Cleanup SkPDFObject::emit*Gravatar halcanary2015-01-23
| | | | Review URL: https://codereview.chromium.org/869783003
* In SkPDFDocument::emitPDF(), stop pre-calculating file offsets.Gravatar halcanary2015-01-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add Streamer utility class which measures the current pdf offset by calling SkWStream::bytesWritten(). Calls SkPDFCatalog::setFileOffset() and SkPDFObject::emit() at the same time to guarantee that everything works out. * SkPDFCatalog::setFileOffset() no longer calculates the object's size. * SkPDFCatalog::setSubstituteResourcesOffsets() removed. * SkPDFCatalog::emitSubstituteResources() removed and getSubstituteList() made public in its place. * Remove SkPDFPage::getPageSize and SkPDFPage::emitPage. Replace with SkPDFPage::getContentStream(). * SkPDFObject::getOutputSize no longer virtual, only used in unit tests. All SkPDFObject subclasses getOutputSize() overrides removed. * SkPDFObject::getIndirectOutputSize removed. * PDFPrimitivesTest updated for new functions. Review URL: https://codereview.chromium.org/846023003
* Change function signature of SkPDFObject::emitObject.Gravatar halcanary2015-01-12
| | | | | | | | | | | | | Replace virutal SkPDFObject::emitObject(s, c, true) with non-virtual SkPDFObject::emitIndirectObject(s, c), since none of the subclasses do (or should do) anything different. Replace object->emitObject(s, c, false) with object->emitObject(s, c) This is one step in simplifying the SkPDFObject interface to allow for the next step in refactoring. Review URL: https://codereview.chromium.org/827733004