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

Unified Diff: src/pdf/SkPDFCanon.h

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/SkPDFBitmap.cpp ('k') | src/pdf/SkPDFCanon.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFCanon.h
diff --git a/src/pdf/SkPDFCanon.h b/src/pdf/SkPDFCanon.h
index 9ca8a261d6aee537d678eb130ed7fb18febd6c63..0af0bbf88aff3c6dd2312826d9947f670903cb8f 100644
--- a/src/pdf/SkPDFCanon.h
+++ b/src/pdf/SkPDFCanon.h
@@ -7,39 +7,26 @@
#ifndef SkPDFCanon_DEFINED
#define SkPDFCanon_DEFINED
-#include "SkBitmap.h"
#include "SkPDFGraphicState.h"
#include "SkPDFShader.h"
#include "SkPixelSerializer.h"
#include "SkTDArray.h"
#include "SkTHash.h"
+#include "SkBitmapKey.h"
class SkPDFFont;
class SkPaint;
class SkImage;
-class SkBitmapKey {
-public:
- SkBitmapKey() : fSubset(SkIRect::MakeEmpty()), fGenID(0) {}
- explicit SkBitmapKey(const SkBitmap& bm)
- : fSubset(bm.getSubset()), fGenID(bm.getGenerationID()) {}
- bool operator==(const SkBitmapKey& rhs) const {
- return fGenID == rhs.fGenID && fSubset == rhs.fSubset;
- }
-
-private:
- SkIRect fSubset;
- uint32_t fGenID;
-};
-
/**
- * The SkPDFCanon canonicalizes objects across PDF pages(SkPDFDevices).
+ * The SkPDFCanon canonicalizes objects across PDF pages
+ * (SkPDFDevices) and across draw calls.
*
* The PDF backend works correctly if:
* - There is no more than one SkPDFCanon for each thread.
* - Every SkPDFDevice is given a pointer to a SkPDFCanon on creation.
* - All SkPDFDevices in a document share the same SkPDFCanon.
- * The SkDocument_PDF class makes this happen by owning a single
+ * The SkPDFDocument class makes this happen by owning a single
* SkPDFCanon.
*
* The addFoo() methods will ref the Foo; the canon's destructor will
@@ -75,9 +62,8 @@ public:
const SkPDFGraphicState* findGraphicState(const SkPDFGraphicState&) const;
void addGraphicState(const SkPDFGraphicState*);
- SkPDFObject* findPDFBitmap(const SkImage* image) const;
- void addPDFBitmap(uint32_t imageUniqueID, SkPDFObject*);
- const SkImage* bitmapToImage(const SkBitmap&);
+ sk_sp<SkPDFObject> findPDFBitmap(SkBitmapKey key) const;
+ void addPDFBitmap(SkBitmapKey key, sk_sp<SkPDFObject>);
SkTHashMap<uint32_t, bool> fCanEmbedTypeface;
@@ -119,8 +105,8 @@ private:
};
SkTHashSet<WrapGS, WrapGS::Hash> fGraphicStateRecords;
- SkTHashMap<SkBitmapKey, const SkImage*> fBitmapToImageMap;
- SkTHashMap<uint32_t /*ImageUniqueID*/, SkPDFObject*> fPDFBitmapMap;
+ // TODO(halcanary): make SkTHashMap<K, sk_sp<V>> work correctly.
+ SkTHashMap<SkBitmapKey, SkPDFObject*> fPDFBitmapMap;
sk_sp<SkPixelSerializer> fPixelSerializer;
sk_sp<SkPDFStream> fInvertFunction;
« no previous file with comments | « src/pdf/SkPDFBitmap.cpp ('k') | src/pdf/SkPDFCanon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698