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
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index cfc2b54..095bbe9 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -9,6 +9,7 @@
#define SkPDFDevice_DEFINED
#include "SkBitmap.h"
+#include "SkBitmapKey.h"
#include "SkCanvas.h"
#include "SkClipStack.h"
#include "SkData.h"
@@ -317,11 +318,11 @@
int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID);
void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry);
- void internalDrawImage(const SkMatrix& matrix,
+
+ void internalDrawImage(const SkMatrix& origMatrix,
const SkClipStack* clipStack,
- const SkRegion& clipRegion,
- const SkImage* image,
- const SkIRect* srcRect,
+ const SkRegion& origClipRegion,
+ SkImageBitmap imageBitmap,
const SkPaint& paint);
/** Helper method for copyContentToData. It is responsible for copying the