Commit Graph

19 Commits

Author SHA1 Message Date
halcanary
fa25106f02 SkPDF: PDFStream has-a not is-a PDFDict
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
2016-07-29 10:13:18 -07:00
halcanary
eb92cb3e84 SkPdf: smaller color serialization
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
2016-07-15 13:41:28 -07:00
halcanary
ee41b7556d SkPDF: alloc less memory for strings
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
2016-06-23 14:08:11 -07:00
halcanary
4b6566644f SkDocument/PDF: new API
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
2016-04-27 07:45:18 -07:00
halcanary
488165e689 SkPDF: PDF/A runtime switch
TODO: remove gyp variable and modify API  in SkDocument.h

SkMD5 now moved into core as pdf depends on it now.

BUG=skia:3110
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1891873002

Committed: https://skia.googlesource.com/skia/+/570f18b43417d73c3fbd113cc0b4258e08b14c82

Review URL: https://codereview.chromium.org/1891873002
2016-04-22 06:10:21 -07:00
halcanary
2299ffaaa1 Revert of SkPDF: PDF/A runtime switch (patchset #1 id:100001 of https://codereview.chromium.org/1891873002/ )
Reason for revert:
breaking something.

Original issue's description:
> SkPDF: PDF/A runtime switch
>
> TODO: remove gyp variable and modify API  in SkDocument.h
>
> BUG=skia:3110
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1891873002
>
> Committed: https://skia.googlesource.com/skia/+/570f18b43417d73c3fbd113cc0b4258e08b14c82

TBR=tomhudson@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:3110

Review URL: https://codereview.chromium.org/1892203002
2016-04-15 12:30:21 -07:00
halcanary
570f18b434 SkPDF: PDF/A runtime switch
TODO: remove gyp variable and modify API  in SkDocument.h

BUG=skia:3110
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1891873002

Review URL: https://codereview.chromium.org/1891873002
2016-04-15 11:59:31 -07:00
halcanary
cbc060a700 SkWStream::writeText inlined.
Motivation: This function is used throughout SkPDF.

Note that the compiler can usually inline the result of strlen() for literal strings.

Before:
    out/Release/nanobench -m WStreamWriteText -q
        Timer overhead: 24.2ns
        ! -> high variance, ? -> moderate variance
            micros   	bench
              6.10  	WStreamWriteText	nonrendering

After:
    out/Release/nanobench -m WStreamWriteText -q
        Timer overhead: 23.9ns
        ! -> high variance, ? -> moderate variance
            micros   	bench
              2.51  	WStreamWriteText	nonrendering

PDF runtime change: -0.8% ±0.04%.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1844343004

Review URL: https://codereview.chromium.org/1844343004
2016-04-11 19:41:48 -07:00
halcanary
a50151dcb5 SkPDF: draw{Image,Bitmap} always serializes early
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
2016-03-25 11:57:49 -07:00
reed
fe63045f07 move setshader to sk_sp, re-using SK_SUPPORT_LEGACY_CREATESHADER_PTR
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1829303002

Review URL: https://codereview.chromium.org/1829303002
2016-03-25 09:08:00 -07:00
halcanary
d11c7268a2 SkPDF: speed up SkPDFShader generation.
Stop using SkString::append() when SkDynamicMemoryWStream
works better.

Also add a bench to prove that this speeds things up:
    before:
        micros   	bench
         59.33 ?	PDFShader	nonrendering
    after:
        micros   	bench
         34.55 ?	PDFShader	nonrendering
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1833793002

Review URL: https://codereview.chromium.org/1833793002
2016-03-25 05:52:57 -07:00
halcanary
bae235eb07 SkPDF: add drop() virtual to release resources early.
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
2016-03-21 10:05:23 -07:00
reed
9ce9d6772d update callsites for Make image factories
not forced yet, as we still have the build-guard. waiting on chrome CL

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1810813003

TBR=

Review URL: https://codereview.chromium.org/1810813003
2016-03-17 10:51:11 -07:00
robertphillips
c5035e70cc Add SkSpecialImage::extractSubset & NewFromPixmap
This is calved off of: https://codereview.chromium.org/1785643003/ (Switch SkBlurImageFilter over to new onFilterImage interface)

This now relies on: https://codereview.chromium.org/1813483002/ (ImagePixelLocker now manually allocates SkPixmap) to clean up the uses of SkAutoPixmapStorage in Chromium

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1787883002

Committed: https://skia.googlesource.com/skia/+/250581493a0859987e482810879e85e5ac2dc002

Review URL: https://codereview.chromium.org/1787883002
2016-03-17 06:58:39 -07:00
robertphillips
19dea94f1d Revert of Add SkSpecialImage::extractSubset & NewFromPixmap (patchset #5 id:80001 of https://codereview.chromium.org/1787883002/ )
Reason for revert:
Need to wean ImagePixelLocker.h off of SkAutoPixmapStorage :(

Original issue's description:
> Add SkSpecialImage::extractSubset & NewFromPixmap
>
> This is calved off of: https://codereview.chromium.org/1785643003/ (Switch SkBlurImageFilter over to new onFilterImage interface)
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1787883002
>
> Committed: https://skia.googlesource.com/skia/+/250581493a0859987e482810879e85e5ac2dc002

TBR=bsalomon@google.com,reed@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/1808833002
2016-03-16 10:39:09 -07:00
robertphillips
250581493a Add SkSpecialImage::extractSubset & NewFromPixmap
This is calved off of: https://codereview.chromium.org/1785643003/ (Switch SkBlurImageFilter over to new onFilterImage interface)

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1787883002

Review URL: https://codereview.chromium.org/1787883002
2016-03-16 09:47:08 -07:00
halcanary
cf430139db SkPDF/Bench becnchmark new SkPDFUtils::FloatToDecimal function.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1735063004

Review URL: https://codereview.chromium.org/1735063004
2016-03-09 10:49:23 -08:00
halcanary
1e440510d8 SkPDF/Bench: add bench for SkPDFSharedStream (deflate)
Also, simplify gyp.

BUG=skia:5009
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1730833003

Review URL: https://codereview.chromium.org/1730833003
2016-02-24 15:17:20 -08:00
halcanary
1abea462c8 SkPDF/Bench: add bench for SkPDFCreateBitmapObject
BUG=skia:5009

Review URL: https://codereview.chromium.org/1729943003
2016-02-24 09:25:58 -08:00