aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFUtils.h
Commit message (Collapse)AuthorAge
* SkUTFGravatar Hal Canary2018-07-31
| | | | | | | | | | | | | | | | | | | | | Create new header and namespace, `SkUTF` where we are putting all of our robust, well documented UTF-8, UTF-16, and UTF-32 functions: `SkUTF::{Count,Next,To}UTF{8,16,32}()`. SkUTF.h and SkUTF.cpp do not depend on the rest of Skia and are suitable for re-use in other modules. Some of the old UTF-{8,16} functions still live in SkUtils.h; their use will be phased out in future CLs. Also added more unit testing and cleaned up old tests. Removed functions that were unused outside of tests or used only once. Change-Id: Iaa59b8705abccf9c4ba082f855da368a0bad8380 Reviewed-on: https://skia-review.googlesource.com/143306 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkFloatToDecimal moved to src/utilsGravatar Hal Canary2018-01-03
| | | | | | | | | This change stages SkFloatToDecimal() for possible re-use by pdfium. Change-Id: Iedc0c78c8a633f0b0973365d2d8b540b5443590d Reviewed-on: https://skia-review.googlesource.com/90400 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Cary Clark <caryclark@google.com>
* SkPDF: Re-use Jpeg Image ShadersGravatar Hal Canary2017-07-18
| | | | | | | | | | | | | | | Also, de-dup shader better. - SkBitmapKeyFromImage function factors out image de-dup code. - SkPDFUtils::ToBitmap funtion factors out to-bitmap code - make_image_shader function now takes Image rather than Bitmap. All tests render the same. Some are significantly smaller PDFs. Change-Id: Id8dd36b31c8e573f44a5e9f6058d5a1d622b6385 Reviewed-on: https://skia-review.googlesource.com/24081 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Hal Canary <halcanary@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: clean up fRasterDpiGravatar Hal Canary2017-06-30
| | | | | | | | | | | | - PDFDevice no longer has a fRasterDpi; simply queries document. - #define DPI_FOR_RASTER_SCALE_ONE becomes constexpr float. - PDFShader::GetPDFShader no longer takes rasterScale or dpi - Remove un-needed factory functions. We're all adults here. Change-Id: Id2ce75d4e61af385763ccfb1db210465a1600067 Reviewed-on: https://skia-review.googlesource.com/21348 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkPDF: Clean upGravatar Hal Canary2017-06-28
| | | | | | | | | | | - Use clearMaskOnGraphicState() - SkPDFGraphicState::MakeNoSmaskGraphicState now moved to only caller. - Get rid of clunky SkPDFUtils::GetCachedT Change-Id: If76a1e915fc31e3ce2654fbe620ff44c1820c0e7 Reviewed-on: https://skia-review.googlesource.com/21142 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>
* SkPDF: Draw paths with mask filters; color filter.Gravatar Hal Canary2017-06-05
| | | | | | | | | | | | | | | Also: - drawPaint, drawPath w/ perspective shaders - text with mask filters, stroking, path effect. - SkPDFUtils::GetShaderLocalMatrix BUG=skia:237 BUG=skia:238 BUG=skia:5607 Change-Id: Iffeaf2d7abbde13fd2577ce9feaa178657f48364 Reviewed-on: https://skia-review.googlesource.com/18200 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@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: better tolerance path conversion to quadraticsGravatar Hal Canary2017-02-13
| | | | | | | | | BUG=chromium:691386 Change-Id: I2cb9be7dd606b2ba61ff609f9fd81a55655901f6 Reviewed-on: https://skia-review.googlesource.com/8381 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Cary Clark <caryclark@google.com>
* SkPDF: Implement /ActualText to make text extraction correct.Gravatar halcanary2016-09-16
| | | | | | | | | | | | | For old API: no change. For new API: LTR text is perfectly extracted, RTL needs better testing. CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN-Trybot,Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN-Trybot BUG=skia:5434 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2322403002 Review-Url: https://codereview.chromium.org/2322403002
* Revert of SkPDF: Implement /ActualText to make text extraction correct. ↵Gravatar halcanary2016-09-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (patchset #11 id:220001 of https://codereview.chromium.org/2322403002/ ) Reason for revert: MSAN, ASAN errors Original issue's description: > SkPDF: Implement /ActualText to make text extraction correct. > > For old API: no change. > > For new API: LTR text is perfectly extracted, RTL needs better testing. > > BUG=skia:5434 > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2322403002 > > Committed: https://skia.googlesource.com/skia/+/dbd16345a5b2b824f2696af791bb0f01304cf549 TBR=tomhudson@google.com,bungeman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:5434 Review-Url: https://codereview.chromium.org/2338213008
* SkPDF: Implement /ActualText to make text extraction correct.Gravatar halcanary2016-09-16
| | | | | | | | | | | For old API: no change. For new API: LTR text is perfectly extracted, RTL needs better testing. BUG=skia:5434 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2322403002 Review-Url: https://codereview.chromium.org/2322403002
* 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
* SkPDF: Join Positioned TextGravatar halcanary2016-07-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When N sequential positioned glyphs differ in positions by exactly the advances of the first (N-1) glyphs, join the glyphs into a string rather than changing the text matrix between each glyph draw. Decreases PDF output size by about ~1.4%. Potentially more on text-heavy pages. A single-typeface PDF of an 27kB ASCII document shaped with harfbuzz: before: 187743 Bytes after: 65513 Bytes difference: -65.1% Before: BT /F0 13 Tf 1 0 0 -1 143.5 61 Tm <0029> Tj 1 0 0 -1 150.634765 61 Tm <004C> Tj 1 0 0 -1 154.602050 61 Tm <0055> Tj 1 0 0 -1 160.245117 61 Tm <0048> Tj 1 0 0 -1 167.925781 61 Tm <004B> Tj 1 0 0 -1 176.469726 61 Tm <0052> Tj 1 0 0 -1 184.518554 61 Tm <0056> Tj 1 0 0 -1 190.980468 61 Tm <0048> Tj ET After: BT /F0 13 Tf 1 0 0 -1 0 0 Tm 143.5 -61 Td <0029004C0055> Tj 16.7451171 0 Td <0048004B005200560048> Tj ET Also: update the Text matrix with the `Td` operator, instead of overwriting it with the the `Tm` operator. In the worst case, when every glyph is positioned differently than it's advance, this still makes the command stream smaller: Before: ... 1 0 0 -1 58.328125 660 Tm <0055> Tj 1 0 0 -1 61.609375 660 Tm <004C> Tj 1 0 0 -1 63.828125 660 Tm <0056> Tj ... After: ... 3.140625 0 Td <0055> Tj 3.28125 0 Td <004C> Tj 2.21875 0 Td <0056> Tj ... GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2150393002 Review-Url: https://codereview.chromium.org/2150393002
* SkPDF: Fix encoding of unichr outside of basic planeGravatar halcanary2016-07-07
| | | | | | | | | | | | | | In ToUnicode table, write unicode codepoints as one or two UTF16BE values, rather than a single hex, as the standard requires. Factor out uint16 -> big-endian hex code. SkUtils is now a namespace. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2120533002 Review-Url: https://codereview.chromium.org/2120533002
* 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
* Style bikeshed - remove extraneous whitespaceGravatar halcanary2016-03-29
| | | | | | GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842753002 Review URL: https://codereview.chromium.org/1842753002
* 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: fix scalar serializationGravatar halcanary2016-02-24
| | | | | | | BUG=skia:4868 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1720863003 Review URL: https://codereview.chromium.org/1720863003
* SkPDF: when drawing stroked path, draw using SVG rules for zero-length segmentsGravatar halcanary2015-10-06
| | | | | | | | | | | | | | | | | | The "zeroPath" and emptystroke GMs capture this issue. This CL changes the following PDF GMs: emptystroke dashing4 lineclosepath dashing3 zeroPath linepath complexclip3_complex complexclip3_simple roundrects degeneratesegments filltypes strokerect pathfill inverse_paths desk_chalkboard.skp After this change, all PDF GMs look better (closer to 8888). The dashing4, emptystroke, and zeroPath GMs still need a lot of work to make them look right. BUG=538726 Review URL: https://codereview.chromium.org/1374383004
* SkPDF: Move utility fns to SkPDFUtilsGravatar halcanary2015-05-06
| | | | | | BUG=skia:3585 Review URL: https://codereview.chromium.org/1124193003
* My clang now doesn't complain about !"foo".Gravatar mtklein@google.com2013-08-22
| | | | | | | | | BUG= R=robertphillips@google.com Review URL: https://codereview.chromium.org/22875037 git-svn-id: http://skia.googlecode.com/svn/trunk@10874 2bbb7eff-a529-9590-31e7-b0007b416f81
* Implemented transparent gradientsGravatar commit-bot@chromium.org2013-07-23
| | | | | | | | | | R=vandebo@chromium.org, edisonn@google.com Author: richardlin@chromium.org Review URL: https://chromiumcodereview.appspot.com/18585002 git-svn-id: http://skia.googlecode.com/svn/trunk@10297 2bbb7eff-a529-9590-31e7-b0007b416f81
* Update SkFlattenable buffers to be more modular.Gravatar djsollen@google.com2012-08-07
| | | | | | | | | | | | | | | | | This CL is an effort to stage the conversion to named parameters for all SkFlattenable commands. This particular stage only does the following two things... 1. Move flattenable buffers from SkFlattenable.h into their own header. 2. Update and Add new read write methods for better clarity and convenience. BUG= Review URL: https://codereview.appspot.com/6448095 git-svn-id: http://skia.googlecode.com/svn/trunk@4980 2bbb7eff-a529-9590-31e7-b0007b416f81
* [PDF] Ensure that filling single line paths (with no area) does not draw ↵Gravatar vandebo@chromium.org2012-05-09
| | | | | | | | | | | | anything. Add a test to a gm to confirm the new behavior. Fixes http://crbug.com/123072 Review URL: https://codereview.appspot.com/6137060 git-svn-id: http://skia.googlecode.com/svn/trunk@3884 2bbb7eff-a529-9590-31e7-b0007b416f81
* [PDF] Move most of the headers to be private.Gravatar vandebo@chromium.org2012-03-22
| | | | | | | | | | Compute font stats in SkPDFDocument in order to make more of the headers private. Previous review: https://codereview.appspot.com/5868049/ Review URL: https://codereview.appspot.com/5875049 git-svn-id: http://skia.googlecode.com/svn/trunk@3470 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "[PDF] Move most of the headers to be private."Gravatar vandebo@chromium.org2012-03-21
| | | | | | | | | | This reverts r3457 TBR=epoger@google.com Review URL: https://codereview.appspot.com/5866051 git-svn-id: http://skia.googlecode.com/svn/trunk@3458 2bbb7eff-a529-9590-31e7-b0007b416f81
* [PDF] Move most of the headers to be private.Gravatar vandebo@chromium.org2012-03-21
| | | | | | | | | | Compute font stats in SkPDFDocument in order to make more of the headers private. Previous review: https://codereview.appspot.com/5865048/ Review URL: https://codereview.appspot.com/5868049 git-svn-id: http://skia.googlecode.com/svn/trunk@3457 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "[PDF] Move most of the headers to be private."Gravatar vandebo@chromium.org2012-03-21
| | | | | | | | | | This reverts r3453 TBR=epoger@google.com Review URL: https://codereview.appspot.com/5869048 git-svn-id: http://skia.googlecode.com/svn/trunk@3454 2bbb7eff-a529-9590-31e7-b0007b416f81
* [PDF] Move most of the headers to be private.Gravatar vandebo@chromium.org2012-03-21
Compute font stats in SkPDFDocument in order to make more of the headers private. Review URL: https://codereview.appspot.com/5865048 git-svn-id: http://skia.googlecode.com/svn/trunk@3453 2bbb7eff-a529-9590-31e7-b0007b416f81