aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/PDFBench.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-03-25 11:57:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-25 11:57:49 -0700
commita50151dcb5a0b8bfdef383e363e519c91d2d2c7a (patch)
tree65adb59528a3fa047f939129d6b3c764be202e1c /bench/PDFBench.cpp
parentb3c9e4faaaea99ca8c428f0cadc2945c330f1461 (diff)
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
Diffstat (limited to 'bench/PDFBench.cpp')
-rw-r--r--bench/PDFBench.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/bench/PDFBench.cpp b/bench/PDFBench.cpp
index 076f175b72..9da745c280 100644
--- a/bench/PDFBench.cpp
+++ b/bench/PDFBench.cpp
@@ -26,12 +26,12 @@ struct NullWStream : public SkWStream {
size_t fN;
};
-static void test_pdf_object_serialization(SkPDFObject* object) {
+static void test_pdf_object_serialization(const sk_sp<SkPDFObject> object) {
// SkDebugWStream wStream;
NullWStream wStream;
SkPDFSubstituteMap substitutes;
SkPDFObjNumMap objNumMap;
- objNumMap.addObjectRecursively(object, substitutes);
+ objNumMap.addObjectRecursively(object.get(), substitutes);
for (int i = 0; i < objNumMap.objects().count(); ++i) {
SkPDFObject* object = objNumMap.objects()[i].get();
wStream.writeDecAsText(i + 1);
@@ -67,8 +67,7 @@ protected:
return;
}
while (loops-- > 0) {
- SkAutoTUnref<SkPDFObject> object(
- SkPDFCreateBitmapObject(fImage.get(), nullptr));
+ auto object = SkPDFCreateBitmapObject(fImage, nullptr);
SkASSERT(object);
if (!object) {
return;
@@ -94,7 +93,7 @@ protected:
void onDelayedSetup() override {
sk_sp<SkImage> img(GetResourceAsImage("mandrill_512_q075.jpg"));
if (!img) { return; }
- SkAutoTUnref<SkData> encoded(img->refEncoded());
+ sk_sp<SkData> encoded(img->refEncoded());
SkASSERT(encoded);
if (!encoded) { return; }
fImage = img;
@@ -105,8 +104,7 @@ protected:
return;
}
while (loops-- > 0) {
- SkAutoTUnref<SkPDFObject> object(
- SkPDFCreateBitmapObject(fImage.get(), nullptr));
+ auto object = SkPDFCreateBitmapObject(fImage, nullptr);
SkASSERT(object);
if (!object) {
return;
@@ -138,7 +136,7 @@ protected:
SkASSERT(fAsset);
if (!fAsset) { return; }
while (loops-- > 0) {
- SkAutoTUnref<SkPDFObject> object(
+ sk_sp<SkPDFObject> object(
new SkPDFSharedStream(fAsset->duplicate()));
test_pdf_object_serialization(object);
}