Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: src/pdf/SkPDFCanon.cpp

Issue 1829693002: SkPDF: draw{Image,Bitmap} always serializes early (Closed) Base URL: https://skia.googlesource.com/skia.git@r1823683005
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFCanon.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFCanon.cpp
diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp
index 48f3aef69e411c675aa752c481eca1396cfa0dc9..c981217123bbfe23ee8f4b51faa0103e2b277d01 100644
--- a/src/pdf/SkPDFCanon.cpp
+++ b/src/pdf/SkPDFCanon.cpp
@@ -27,11 +27,7 @@ void SkPDFCanon::reset() {
fGraphicStateRecords.foreach ([](WrapGS w) { w.fPtr->unref(); });
fGraphicStateRecords.reset();
- fBitmapToImageMap.foreach(
- [](SkBitmapKey, const SkImage** p) { SkSafeUnref(*p); });
- fBitmapToImageMap.reset();
-
- fPDFBitmapMap.foreach([](uint32_t, SkPDFObject** p) { SkSafeUnref(*p); });
+ fPDFBitmapMap.foreach([](SkBitmapKey, SkPDFObject** p) { (*p)->unref(); });
fPDFBitmapMap.reset();
}
@@ -127,28 +123,16 @@ void SkPDFCanon::addGraphicState(const SkPDFGraphicState* state) {
////////////////////////////////////////////////////////////////////////////////
-SkPDFObject* SkPDFCanon::findPDFBitmap(const SkImage* image) const {
- SkPDFObject** ptr = fPDFBitmapMap.find(image->uniqueID());
- return ptr ? *ptr : nullptr;
+sk_sp<SkPDFObject> SkPDFCanon::findPDFBitmap(SkBitmapKey key) const {
+ SkPDFObject** ptr = fPDFBitmapMap.find(key);
+ return ptr ? sk_ref_sp(*ptr) : sk_sp<SkPDFObject>();
}
-void SkPDFCanon::addPDFBitmap(uint32_t imageUniqueID, SkPDFObject* pdfBitmap) {
- fPDFBitmapMap.set(imageUniqueID, SkRef(pdfBitmap));
+void SkPDFCanon::addPDFBitmap(SkBitmapKey key, sk_sp<SkPDFObject> pdfBitmap) {
+ fPDFBitmapMap.set(key, pdfBitmap.release());
}
-const SkImage* SkPDFCanon::bitmapToImage(const SkBitmap& bm) {
- // reference remains owned by the fBitmapToImageMap!
- SkBitmapKey key(bm);
- if (const SkImage** img = fBitmapToImageMap.find(key)) {
- return *img;
- }
- if (SkImage* image = SkImage::MakeFromBitmap(bm).release()) {
- return *fBitmapToImageMap.set(key, image);
- }
- SkBitmap n32bitmap; // SkImage::NewFromBitmap can be finicky.
- bm.copyTo(&n32bitmap, kN32_SkColorType);
- return *fBitmapToImageMap.set(key, SkImage::MakeFromBitmap(n32bitmap).release());
-}
+////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPDFStream> SkPDFCanon::makeInvertFunction() {
if (fInvertFunction) {
« no previous file with comments | « src/pdf/SkPDFCanon.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698