aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFCanon.h
Commit message (Collapse)AuthorAge
* SkTypes: more into SkMacrosGravatar Hal Canary2018-06-12
| | | | | | | | Change-Id: I4c9a2d81a1bc4ccebc78eea56c0de116b98d415e Reviewed-on: https://skia-review.googlesource.com/134330 Commit-Queue: Hal Canary <halcanary@google.com> Auto-Submit: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
* Revert "Revert "SkAdvancedTypefaceMetrics: factor out GlyphToUnicode""Gravatar Hal Canary2018-05-09
| | | | | | | | | This reverts commit 97c1108607584b6050a6880d6ce22846e4913a92. Change-Id: Ic3c6addc64ced39766bbee3e10b4d88faf61ba2f Reviewed-on: https://skia-review.googlesource.com/127021 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* Revert "SkAdvancedTypefaceMetrics: factor out GlyphToUnicode"Gravatar Greg Daniel2018-05-09
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 1c2bcd8b14e029a70e88b1e81acd29553cab0d1c. Reason for revert: breaking chrome roll Original change's description: > SkAdvancedTypefaceMetrics: factor out GlyphToUnicode > > Change-Id: Iedce8c1ea2c405d5ab64ccac353970d5cd2b9d63 > Reviewed-on: https://skia-review.googlesource.com/126507 > Commit-Queue: Hal Canary <halcanary@google.com> > Reviewed-by: Ben Wagner <bungeman@google.com> TBR=halcanary@google.com,bungeman@google.com,reed@google.com Change-Id: Ib1ff8484ffd09cdb88d461ac00745aa32c191124 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/127000 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
* SkAdvancedTypefaceMetrics: factor out GlyphToUnicodeGravatar Hal Canary2018-05-09
| | | | | | | Change-Id: Iedce8c1ea2c405d5ab64ccac353970d5cd2b9d63 Reviewed-on: https://skia-review.googlesource.com/126507 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
* SkAdvancedTypefaceMetrics: simplify moreGravatar Hal Canary2018-05-07
| | | | | | | Change-Id: I80c28c50aa96c28181d2fef13daad4a80ec91a12 Reviewed-on: https://skia-review.googlesource.com/120160 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* include/private/SkTemplates: Cleanup bare pointers.Gravatar Hal Canary2018-04-24
| | | | | | | | | | | | | | | | | include/private: - SkAutoTArray, SkAutoTMalloc no longer use bare pointers to owned memory, - SkTHash and SkAutoTArray are now std::move()able. - SkAutoTArray::swap no longer neccesary. - SkAutoTMalloc::operator=() defined. src/pdf: - SkPDFCanon and SkPDFObjectSerializer are now std::move()able. - `template <class T> static void renew(T* t) { t->~T(); new (t) T; }` is gone. Change-Id: I2f36a0780c47d1427a85da240121c898387fb4cf Reviewed-on: https://skia-review.googlesource.com/123401 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* bug fixes from PVS Studio (static analysis)Gravatar Mike Klein2018-01-26
| | | | | | | | | | | | | | | - Hal, please check out SkPDFCanon... was this unused? - Cary, please SkOpContour... is it right that allDone isn't necessary? - Brian, the rest? Bug: chromium:805881 Change-Id: I7cbbcf44f4460a114f4ed2a59ed3856203049cdc Reviewed-on: https://skia-review.googlesource.com/99960 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Revert "Revert "remove SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER dead code""Gravatar Mike Reed2017-12-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 800f5541bb0f4ea0f6923592355bdb64f156d8b3. Reason for revert: google3 updated Original change's description: > Revert "remove SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER dead code" > > This reverts commit 7f846f273ceaa5a3a8880e9af260f94bd1e614b6. > > Reason for revert: missed callsite in google3 > > Original change's description: > > remove SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER dead code > > > > Bug: skia: > > Change-Id: Ia88f3e2fdf6d5c6e5128eaefda0d68c7042ae7a2 > > Reviewed-on: https://skia-review.googlesource.com/85500 > > Commit-Queue: Mike Reed <reed@google.com> > > Reviewed-by: Hal Canary <halcanary@google.com> > > TBR=halcanary@google.com,reed@google.com > > Change-Id: I232dc24831bd8d52e9cbbc7ee58177af0617574a > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/85600 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Mike Reed <reed@google.com> TBR=halcanary@google.com,reed@google.com Change-Id: I6ccd032caf87020cba8d515ffb25d07b87267363 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/86101 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Revert "remove SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER dead code"Gravatar Mike Reed2017-12-15
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7f846f273ceaa5a3a8880e9af260f94bd1e614b6. Reason for revert: missed callsite in google3 Original change's description: > remove SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER dead code > > Bug: skia: > Change-Id: Ia88f3e2fdf6d5c6e5128eaefda0d68c7042ae7a2 > Reviewed-on: https://skia-review.googlesource.com/85500 > Commit-Queue: Mike Reed <reed@google.com> > Reviewed-by: Hal Canary <halcanary@google.com> TBR=halcanary@google.com,reed@google.com Change-Id: I232dc24831bd8d52e9cbbc7ee58177af0617574a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/85600 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* remove SK_SUPPORT_LEGACY_PDF_PIXELSERIALIZER dead codeGravatar Mike Reed2017-12-15
| | | | | | | | Bug: skia: Change-Id: Ia88f3e2fdf6d5c6e5128eaefda0d68c7042ae7a2 Reviewed-on: https://skia-review.googlesource.com/85500 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Hal Canary <halcanary@google.com>
* Moving extra options/parameters into PDFMetadataGravatar Mike Reed2017-12-14
| | | | | | | | Bug: skia: Change-Id: I29aa69e5765a7f8ba05b0361912d1f5276d77de3 Reviewed-on: https://skia-review.googlesource.com/84501 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Revert "Revert "SkPDF: Non-outline glyphs as images""Gravatar Hal Canary2017-07-18
| | | | | | | | | | | | | | | | | | | This reverts commit 63b6f8b93209e593f60b235577f5b3d660396d5f. SkPDF: Non-outline glyphs as images - Cache images in PDF Canon for de-duping - For now, rasterize at text scale. In the future, look at CTM and fRasterScale. Original CL: https://skia-review.googlesource.com/24080 BUG=chromium:705480 BUG=skia:3489 Reviewed-by: Ben Wagner <bungeman@google.com> Change-Id: I99783df72c945cfb4b24b6d4db99418aa34e0897 Reviewed-on: https://skia-review.googlesource.com/24322 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* Revert "SkPDF: Non-outline glyphs as images"Gravatar Mike Reed2017-07-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 3cf6b79e50f148cae7ed8c6ec0cd79f1ede71c95. Reason for revert: breaking build ../../../../../work/skia/src/pdf/SkPDFDevice.cpp: In member function 'void SkPDFDevice::internalDrawText(const void*, size_t, const SkScalar*, SkTextBlob::GlyphPositioning, SkPoint, const SkPaint&, const uint32_t*, uint32_t, const char*)': ../../../../../work/skia/src/pdf/SkPDFDevice.cpp:1578:31: error: missing initializer for member 'SkPoint::fX' [-Werror=missing-field-initializers] SkPoint xy = {}; ^ Original change's description: > SkPDF: Non-outline glyphs as images > > - Cache images in PDF Canon for de-duping > - For now, rasterize at text scale. in the future, look at CTM and > fRasterScale. > - add a test that works on MacOS > > BUG=chromium:705480 > BUG=skia:3489 > Change-Id: I4fbc42f218e5b81ea15ea6cdccc61c91e532f6d0 > Reviewed-on: https://skia-review.googlesource.com/24080 > Commit-Queue: Hal Canary <halcanary@google.com> > Reviewed-by: Ben Wagner <bungeman@google.com> TBR=halcanary@google.com,bungeman@google.com Change-Id: I3d8800fcb33817c6065da0860a534eb14350d132 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:705480, skia:3489 Reviewed-on: https://skia-review.googlesource.com/24160 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* SkPDF: Non-outline glyphs as imagesGravatar Hal Canary2017-07-17
| | | | | | | | | | | | | | - Cache images in PDF Canon for de-duping - For now, rasterize at text scale. in the future, look at CTM and fRasterScale. - add a test that works on MacOS BUG=chromium:705480 BUG=skia:3489 Change-Id: I4fbc42f218e5b81ea15ea6cdccc61c91e532f6d0 Reviewed-on: https://skia-review.googlesource.com/24080 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
* SkPDF: Change some identifiers.Gravatar Hal Canary2017-07-06
| | | | | | | | | | | s/SkPDFShader::GetPDFShader/SkPDFMakeShader/g s/SkPDFShader::State/SkPDFImageShaderKey/g s/state/key/g Change-Id: I86dc932c3407c73f387c972fb6674dc09ea0be3c Reviewed-on: https://skia-review.googlesource.com/21661 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkPDF: GradientShaderPatterns use one hashmap not two.Gravatar Hal Canary2017-07-05
| | | | | | | Change-Id: Icdebaf891884aa06bdc36ed930d7bab5400bd04f Reviewed-on: https://skia-review.googlesource.com/21529 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
* SkPDF: Refactor PDFShader to use ShTHashMap<>Gravatar Hal Canary2017-07-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | my tests run ~14% faster. - Split out gradient shaders from image shaders. new compilation unit: SkPDFGradientShader - Common functions InverseTransformBBox and PopulateTilingPatternDict moved to SkPDFUtils - Split SkPDFShader::State into image and gradient structures. - SkPDFCanon is now a simpler structure, with no logic of its own. I am considering just moving all of its fields into SkPDFDocument - SkPDFShader::State (the image/fallback shader) now is POD, making the use of a hashmap for canonicalization straightforward. Formerly, we used a linear search. - Do not bother trying to canonicalize the falback image shader. - SkPDFGradientShader::Key is not POD; comparison of two objects requires looking at the contents of two variable-sized arrays. We now pre-calculate the hash of the arrays using SkOpts::hash and store a hash for the object in the fHash field. Using that hash, we can now canonicalize using a hashmap instead of a linar search! - several static functions renamed to follow style guidelines - stop using codeFunction function pointer; I find that less clear than it could be. - operator==() for SkPDFShader::State and SkPDFGradientShader::Key is now much simpler and can now be inlined. - SkArrayEqual template in SkPDFUtils.h No change to PDF output. BUG=skia:3585 Change-Id: I354ad1b600be6d6749abccb58d13db257370bc0b Reviewed-on: https://skia-review.googlesource.com/21376 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>
* Revert "Revert "SkTypeface::getAdvancedMetrics(): cleanup""Gravatar Hal Canary2017-05-05
| | | | | | | | | | | | | | | | | | | This reverts commit 59ad782b2b05b07aa6eb961aa4d62e934093cbd1. - SkAdvancedTypefaceMetrics is a struct not a class - SkTypeface::PerGlyphInfo is gone - s/getAdvancedTypefaceMetrics/getAdvancedMetrics/g - s/onGetAdvancedTypefaceMetrics/onGetAdvancedMetrics/g - [on]getAdvancedMetrics now return unique_ptr rather than bare ptr. - [on]getAdvancedMetrics no longer has parameters. (Only caller always used same arguments.) - SkAdvancedTypefaceMetrics uses C++11 in-class member initializers. - SkAdvancedTypefaceMetrics no longer inherits from SkRefCnt Change-Id: I91b56e60f7d9de7d46c426c6bd34ce124e0cf00e Reviewed-on: https://skia-review.googlesource.com/15360 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* Revert "SkTypeface::getAdvancedMetrics(): cleanup"Gravatar Hal Canary2017-05-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit cef018896e5cad8eb46a536b60cdf79ebe2b0191. Reason for revert: broke chromium roll (windows). Original change's description: > SkTypeface::getAdvancedMetrics(): cleanup > > - SkAdvancedTypefaceMetrics is a struct not a class > - SkTypeface::PerGlyphInfo is gone > - s/getAdvancedTypefaceMetrics/getAdvancedMetrics/g > - s/onGetAdvancedTypefaceMetrics/onGetAdvancedMetrics/g > - [on]getAdvancedMetrics now return unique_ptr rather than bare ptr. > - [on]getAdvancedMetrics no longer has parameters. (Only caller always > used same arguments.) > - SkAdvancedTypefaceMetrics uses C++11 in-class member initializers. > - SkAdvancedTypefaceMetrics no longer inherits from SkRefCnt > > Change-Id: I37571ebcc383ba9eb21bc20c60c734e3ca317582 > Reviewed-on: https://skia-review.googlesource.com/15311 > Reviewed-by: Ben Wagner <bungeman@google.com> > Commit-Queue: Hal Canary <halcanary@google.com> > TBR=halcanary@google.com,bungeman@google.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I84c7d53df566aaf83427e3368edaa02b7b5a9cb8 Reviewed-on: https://skia-review.googlesource.com/15319 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkTypeface::getAdvancedMetrics(): cleanupGravatar Hal Canary2017-05-04
| | | | | | | | | | | | | | | | | - SkAdvancedTypefaceMetrics is a struct not a class - SkTypeface::PerGlyphInfo is gone - s/getAdvancedTypefaceMetrics/getAdvancedMetrics/g - s/onGetAdvancedTypefaceMetrics/onGetAdvancedMetrics/g - [on]getAdvancedMetrics now return unique_ptr rather than bare ptr. - [on]getAdvancedMetrics no longer has parameters. (Only caller always used same arguments.) - SkAdvancedTypefaceMetrics uses C++11 in-class member initializers. - SkAdvancedTypefaceMetrics no longer inherits from SkRefCnt Change-Id: I37571ebcc383ba9eb21bc20c60c734e3ca317582 Reviewed-on: https://skia-review.googlesource.com/15311 Reviewed-by: Ben Wagner <bungeman@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>
* SkPDF: cache metrics once.Gravatar halcanary2016-08-18
| | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: drawText can look up unicode mapping at draw time to see if ActualText should be used after crrev.com/2084533004 lands. For each SkTypeface, only call getAdvancedTypefaceMetrics() once per document. Cache the result in the SkPDFCanon, indexed by SkFontID. Also cache PDF FontDescriptors in the canon, also indexed by SkFontID (Type1 fonts only). Simplify PDF font lookup, map SkFontID+SkGlyphID into a uint64_t. Map that uint64_t to SkPDFFonts. Remove SkPDFCanon::findFont(), SkPDFCanon::addFont(), SkPDFFont::IsMatch(), and enum SkPDFFont::Match. SkPDFFont no longer holds on to ref of SkAdvancedTypefaceMetrics. Instead, SkPDFFont::GetFontResource() and SkPDFFont::getFontSubset() get metrics from canon. SkPDFFont multybite bool is now a function of type. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2253993002 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/2253993002
* Revert of SkPDF: cache metrics once. (patchset #4 id:60001 of ↵Gravatar robertphillips2016-08-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/2253993002/ ) Reason for revert: because Original issue's description: > SkPDF: cache metrics once. > > Motivation: drawText can look up unicode mapping at draw time to see > if ActualText should be used after crrev.com/2084533004 lands. > > For each SkTypeface, only call getAdvancedTypefaceMetrics() once per > document. Cache the result in the SkPDFCanon, indexed by SkFontID. > Also cache PDF FontDescriptors in the canon, also indexed by SkFontID > (Type1 fonts only). > > Simplify PDF font lookup, map SkFontID+SkGlyphID into a uint64_t. Map > that uint64_t to SkPDFFonts. Remove SkPDFCanon::findFont(), > SkPDFCanon::addFont(), SkPDFFont::IsMatch(), and enum SkPDFFont::Match. > > SkPDFFont no longer holds on to ref of SkAdvancedTypefaceMetrics. > Instead, SkPDFFont::GetFontResource() and SkPDFFont::getFontSubset() > get metrics from canon. > > SkPDFFont multybite bool is now a function of type. > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2253993002 > > Committed: https://skia.googlesource.com/skia/+/0a61270f4ba85d10659fb63a86817b435ec04c94 TBR=bungeman@google.com,halcanary@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/2251813006
* SkPDF: cache metrics once.Gravatar halcanary2016-08-17
| | | | | | | | | | | | | | | | | | | | | | | Motivation: drawText can look up unicode mapping at draw time to see if ActualText should be used after crrev.com/2084533004 lands. For each SkTypeface, only call getAdvancedTypefaceMetrics() once per document. Cache the result in the SkPDFCanon, indexed by SkFontID. Also cache PDF FontDescriptors in the canon, also indexed by SkFontID (Type1 fonts only). Simplify PDF font lookup, map SkFontID+SkGlyphID into a uint64_t. Map that uint64_t to SkPDFFonts. Remove SkPDFCanon::findFont(), SkPDFCanon::addFont(), SkPDFFont::IsMatch(), and enum SkPDFFont::Match. SkPDFFont no longer holds on to ref of SkAdvancedTypefaceMetrics. Instead, SkPDFFont::GetFontResource() and SkPDFFont::getFontSubset() get metrics from canon. SkPDFFont multybite bool is now a function of type. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2253993002 Review-Url: https://codereview.chromium.org/2253993002
* SkPDF: PDFShader code modernized.Gravatar halcanary2016-08-03
| | | | | | | | | | | | | | | | | | | | | | Motivation: reduce code complexity. SkCanon stores SkPDFShader::State next to SkDFObject, not inside. many places use sk_sp<T> rather than T* to represent ownership. SkPDFShader::State no longer holds bitmap. SkPDFShader::State gets move constructor, no longer heap-allocated. Classes removed: SkPDFFunctionShader SkPDFAlphaFunctionShader SkPDFImageShader BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2193973002 Review-Url: https://codereview.chromium.org/2193973002
* 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
* SkDocument/PDF: new APIGravatar halcanary2016-04-27
| | | | | | | | | | has a pdf/a switch. sets metadata in factory. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1916093002 Review URL: https://codereview.chromium.org/1916093002
* SkPDF: draw{Image,Bitmap} always serializes earlyGravatar halcanary2016-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, the PDFCanon held a map from BitmapKeys to SkImages for de-duping bitmaps. Even if the PDFDocument serialized images early, the Canon still held a ref to that image inside the map. With this change, the Canon holds a single map from BitmapKeys to PDFObjects. Now, Images are only held by the PDFObject, which the document serializes and drops early. This change also: - Moves SkBitmapKey into its own header (for possible reuse); it now can operate with images as well as bitmaps. - Creates SkImageBitmap, which wraps a pointer to a bitmap or an image and abstracts out some common tasks so that drawBitmap and drawImage behave the same. - Modifies SkPDFCreateBitmapObject to take and return a sk_sp<T>, not a T*. - Refactors SkPDFDevice::internalDrawImage to use bitmaps or images (via a SkImageBitmap). - Turns on pre-serialization of all images. BUG=skia:5087 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1829693002 Review URL: https://codereview.chromium.org/1829693002
* SkPDF: remove all globally references SkPDFObjectsGravatar halcanary2016-03-13
| | | | | | | | | | | | | | | | | Move these singletons into SkPDFCanon (there is still a single object per document; output PDF size will not change). Motivation: After this change, all indirectly-referenced SkPDFObjects are serialized exactly once. The next CL will add a memory saving feature: a method to purge an object's resources immediately after serialization. After that, further changes wil allow some objects to be serialized *before* SkDocument::close(), leading to potentially very large memory savings. BUG=skia:5087 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1788263002 Review URL: https://codereview.chromium.org/1788263002
* SkPDF: s/SkAutoTUnref/sk_sp/gGravatar halcanary2016-03-07
| | | | Review URL: https://codereview.chromium.org/1771073002
* SkPDF: AutoTUnref<T> changes in useGravatar halcanary2016-03-06
| | | | | | | | | | ::detach() -> ::release() ::operator T*() -> ::get() This makes all use of AutoTUnref work the same as sk_sp. GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1772493002 Review URL: https://codereview.chromium.org/1772493002
* SkDocument::setDCTEncoder() for old versions of webkitGravatar halcanary2015-12-10
| | | | Review URL: https://codereview.chromium.org/1505763003
* SkTHash: hash from fnptr to functor typeGravatar mtklein2015-10-15
| | | | | | | | Passing &SkGoodHash to SkTHashMap and SkTHashSet doesn't guarantee that it's actually instantiated. Using a functor does. BUG=skia: Review URL: https://codereview.chromium.org/1405053002
* SkPDF: fall back on paths for unembeddable fonts.Gravatar halcanary2015-10-12
| | | | | | | | Add GM, SkPDFFont::CanEmbedTypeface BUG=skia:3866 Review URL: https://codereview.chromium.org/1401763002
* 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: NULL->nullptrGravatar halcanary2015-08-27
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316233002 Review URL: https://codereview.chromium.org/1316233002
* SkPDF: SkPDFGraphicState Lookup hashtabledGravatar halcanary2015-04-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Release, running `dm --src skp --config pdf`, I get a speedup of about 1.2%. SkPDFGraphicState class: - Holds the subset of SkPaint that maps to a PDF Graphics State - These fields are easily comparable, making hashtable comparisons easy. SkPDFCanon: - findGraphicState() takes a SkPDFGraphicState, not a SkPaint - fGraphicStateRecords is a SkHashSet, not a SkTDArray SkPDFGraphicState: - mode_for_pdf() replaces logic inside equivalent(), but is only called once per lookup. - emitObject() no longer modifies the SkPDFGraphicState to cache the SkPDFDict stucture. (Since it is de-duped, this get no speedup). - Static Functions that don't use the canon return a plain SkPDFDict now. No need for fPopulated. SkTHash.h - SkHashSet::forall added SkPDFDevice; SkPDFShader - Updated for new SkPDFGraphicState interface. BUG=skia:3585 Review URL: https://codereview.chromium.org/1046293002
* PDF: Canon now owns a reference to all interned objectsGravatar halcanary2015-02-27
| | | | | | | | | | | | | Add SkPDFCanon::reset function to unref all objects. No longer possible to remove object from canon Motivation: this doesn't change these object's lifetime, (they will still be fully unrefed when SkDocument::close() is called, but we no longer have to remove them from the array when their destructor is called. Review URL: https://codereview.chromium.org/966863002
* PDF: Now threadsafe!Gravatar halcanary2015-02-20
| | | | | | | | | | | | | The PDF canvas is now just as threadsafe as any other Skia canvas. DM updated to thread PDF tests. SkDocument_PDF now owns SkPDFCanon, and pointers to that canon are passed around to all classes that need access to the canon. BUG=skia:2683 Review URL: https://codereview.chromium.org/944643002
* PDF : New factory function for SkPDFDeviceGravatar halcanary2015-02-20
| | | | | | SkPDFDevice now has factory function that matches what callers need. Review URL: https://codereview.chromium.org/941023005
* PDF: Add (low-memory) SkPDFBitmap classGravatar halcanary2015-02-18
| | | | | | | | | | | | | | | | | | | | | Also: Add SkDeflateWStream and associated unit tests. SkPDFBitmap is a replacement for SkPDFImage. As of now, it only supports 8888 bitmaps (the most common case). SkPDFBitmap takes very little extra memory (aside from refing the bitmap's pixels), and its emitObject() does not cache any data. The SkPDFBitmap::Create function will check the canon for duplicates. This can reduce the size of the output PDF. Motivation: this gives another ~40% decrease in PDF memory overhead TODO: Support other ColorTypes and scrap SkPDFImage. BUG=skia:3030 Review URL: https://codereview.chromium.org/918813002
* More changes to SkPDFShader to eliminate multiple inheritance!Gravatar halcanary2015-01-23
| | | | Review URL: https://codereview.chromium.org/873543002
* SkPDFCanonGravatar halcanary2015-01-21
SkPDFCanon's fields and methods will eventually become part of SkPDFDocument/SkDocument_PDF. For now, it exists as a singleton to preflight that transition. This replaces three global arrays in SkPDFFont, SkPDFShader, and SkPDFGraphicsContext. This code is still thread-unsafe (http://skbug.com/2683), but moving this functionality into SkPDFDocument will fix that. This CL does not change pdf output from either GMs or SKPs. This change also simplifies some code around the SkPDFCanon methods. BUG=skia:2683 Review URL: https://codereview.chromium.org/842253003