aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFBitmap.cpp
Commit message (Collapse)AuthorAge
* 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: handle unpremul rightGravatar halcanary2016-06-03
| | | | | | | . GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2037083002 Review-Url: https://codereview.chromium.org/2037083002
* 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: 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: 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: 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
* SkPDF: Let client re-encode JPGs if they want toGravatar halcanary2016-02-25
| | | | | | GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1734223003 Review URL: https://codereview.chromium.org/1734223003
* SkDocument::setDCTEncoder() for old versions of webkitGravatar halcanary2015-12-10
| | | | Review URL: https://codereview.chromium.org/1505763003
* SkPDF: add `final` keyword to leaf classesGravatar halcanary2015-11-22
| | | | Review URL: https://codereview.chromium.org/1461403002
* SkPDF: Deal with missing ColorTable (don't assert)Gravatar halcanary2015-11-10
| | | | Review URL: https://codereview.chromium.org/1414083005
* SkPDF: images support 32-but-not-N32 colortypeGravatar halcanary2015-11-06
| | | | | | BUG=550559 Review URL: https://codereview.chromium.org/1407063005
* 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: NULL->nullptrGravatar halcanary2015-08-27
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316233002 Review URL: https://codereview.chromium.org/1316233002
* Style Change: SkNEW->new; SkDELETE->deleteGravatar halcanary2015-08-26
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316123003 Review URL: https://codereview.chromium.org/1316123003
* 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: Move SkFlate into src/pdf (part 1/3) [reland]Gravatar halcanary2015-08-12
| | | | | | | | Rename to SkDeflate so Chromium builders continue to work Next, we change remove SkFlate from Chromium build files, then we can delete SkFlate. Review URL: https://codereview.chromium.org/1285913002
* SkPDF: detect YUV-JPEG without relying on ImageGeneratorGravatar halcanary2015-05-07
| | | | | | | | | | | JPEG/JFIF References: * http://www.w3.org/Graphics/JPEG/itu-t81.pdf * http://www.w3.org/Graphics/JPEG/jfif3.pdf BUG=476721 BUG=446940 Review URL: https://codereview.chromium.org/1133443003
* SkPDF: clean up uses of deprecated calls in other SkPDF classesGravatar halcanary2015-04-27
| | | | | | BUG=skia:3585 Review URL: https://codereview.chromium.org/1107923002
* PDF: Correctly embed JPEG images directly into PDF output.Gravatar halcanary2015-04-17
| | | | | | | | | We only embed images with YUV planes. That should only grab the subset of color JPEGs supported by PDF. BUG=skia:3180 Review URL: https://codereview.chromium.org/1025773002
* 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
* C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla}Gravatar mtklein2015-03-25
| | | | | | | | | NOPRESUBMIT=true BUG=skia: DOCS_PREVIEW= https://skia.org/?cl=1037793002 Review URL: https://codereview.chromium.org/1037793002
* 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
* PDF: remove last use of SkPDFImageGravatar halcanary2015-03-20
| | | | | | | | Add a GM. BUG=skia:255 Review URL: https://codereview.chromium.org/950633003
* Revert of PDF: remove last use of SkPDFImage (patchset #5 id:120001 of ↵Gravatar reed2015-03-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/950633003/) Reason for revert: static void draw(SkCanvas* canvas, const SkPaint& p, const SkBitmap& src, SkColorType colorType, const char text[]) { SkASSERT(src.colorType() == colorType); canvas->drawBitmap(src, 0.0f, 0.0f); canvas->drawText(text, strlen(text), 0.0f, 12.0f, p); } This assert is firing, at least on macs, where all images get decoded into 32bit at the moment. Original issue's description: > PDF: remove last use of SkPDFImage > > Add a GM. > > BUG=skia:255 > > Committed: https://skia.googlesource.com/skia/+/86ad8d643624a55b02e529100bbe4e2940115fa1 TBR=mtklein@google.com,halcanary@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:255 Review URL: https://codereview.chromium.org/1024113002
* PDF: remove last use of SkPDFImageGravatar halcanary2015-03-20
| | | | | | | | Add a GM. BUG=skia:255 Review URL: https://codereview.chromium.org/950633003
* PDF: Switch some unit tests to higher level API.Gravatar halcanary2015-03-01
| | | | | | Also, clean up some headers. Review URL: https://codereview.chromium.org/968683002
* 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
* miniz support in SkFlate / PDFGravatar mtklein2015-02-26
| | | | | | | | | | | | | | | | | | | | | | | | | - Adds miniz.c v115_r4 (latest release) to third_party. - Merges SkDeflateWStream into SkFlate so including "miniz.c" links without duplicating symbols. The only interesting code change I've made is to remove the line fImpl->fZStream.data_type = Z_BINARY; from SkDeflateWStream::SkDeflateWStream(). miniz doesn't have Z_BINARY defined, and as far as I can tell, both zlib and miniz ignore data_type. We should be able to swap skflate.gyp's dependency between zlib.gyp:zlib and zlib.gyp:miniz at will (except of course on Windows) if we're interested in zlib itself. I've left android framework on its own zlib. I think this all means we can stop defining SK_NO_FLATE on Windows. I'll leave the possible cleanup of SK_NO_FLATE itself for another time. Might be we always want to keep this dependency optional. CQ_EXTRA_TRYBOTS=client.skia:Test-Win8-ShuttleA-HD7770-x86-Debug-Trybot BUG=skia: Review URL: https://codereview.chromium.org/957323003
* 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: why do we have flags no one uses (or can use)?Gravatar mtklein2015-02-19
| | | | | | BUG=skia: Review URL: https://codereview.chromium.org/936403002
* 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