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

Unified Diff: src/pdf/SkPDFGraphicState.h

Issue 1046293002: SkPDF: SkPDFGraphicState Lookup hashtabled (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-04-01 (Wednesday) 16:16:21 EDT Created 5 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/SkPDFDevice.cpp ('k') | src/pdf/SkPDFGraphicState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFGraphicState.h
diff --git a/src/pdf/SkPDFGraphicState.h b/src/pdf/SkPDFGraphicState.h
index 85a324b1913801217f5573b303b32c27ef7ad9af..dddf439db31f18ecf8777f1f49d2c011632c3c34 100644
--- a/src/pdf/SkPDFGraphicState.h
+++ b/src/pdf/SkPDFGraphicState.h
@@ -13,19 +13,17 @@
#include "SkPaint.h"
#include "SkPDFTypes.h"
#include "SkTemplates.h"
+#include "SkChecksum.h"
+class SkPDFCanon;
class SkPDFFormXObject;
/** \class SkPDFGraphicState
SkPaint objects roughly correspond to graphic state dictionaries that can
be installed. So that a given dictionary is only output to the pdf file
- once, we want to canonicalize them. Static methods in this class manage
- a weakly referenced set of SkPDFGraphicState objects: when the last
- reference to a SkPDFGraphicState is removed, it removes itself from the
- static set of objects.
-
+ once, we want to canonicalize them.
*/
-class SkPDFGraphicState : public SkPDFDict {
+class SkPDFGraphicState : public SkPDFObject {
SK_DECLARE_INST_COUNT(SkPDFGraphicState)
public:
enum SkPDFSMaskMode {
@@ -33,8 +31,6 @@ public:
kLuminosity_SMaskMode
};
- virtual ~SkPDFGraphicState();
-
// Override emitObject so that we can populate the dictionary on
// demand.
virtual void emitObject(SkWStream* stream,
@@ -57,32 +53,37 @@ public:
* @param sMask The form xobject to use as a soft mask.
* @param invert Indicates if the alpha of the sMask should be inverted.
* @param sMaskMode Whether to use alpha or luminosity for the sMask.
+ *
+ * These are not de-duped.
*/
- static SkPDFGraphicState* GetSMaskGraphicState(SkPDFFormXObject* sMask,
- bool invert,
- SkPDFSMaskMode sMaskMode);
+ static SkPDFDict* GetSMaskGraphicState(SkPDFFormXObject* sMask,
+ bool invert,
+ SkPDFSMaskMode sMaskMode);
/** Get a graphic state that only unsets the soft mask. The reference
* count of the object is incremented and it is the caller's responsibility
* to unreference it when done. This is needed to accommodate the weak
* reference pattern used when the returned object is new and has no
* other references.
+ *
+ * The returned object is a singleton.
*/
- static SkPDFGraphicState* GetNoSMaskGraphicState();
-
- bool equals(const SkPaint&) const;
+ static SkPDFDict* GetNoSMaskGraphicState();
- // Only public for SK_DECLARE_STATIC_LAZY_PTR
- static SkPDFGraphicState* CreateNoSMaskGraphicState();
+ bool operator==(const SkPDFGraphicState& rhs) const {
+ return 0 == memcmp(&fStrokeWidth, &rhs.fStrokeWidth, 12);
+ }
+ uint32_t hash() const { return SkChecksum::Murmur3(&fStrokeWidth, 12); }
private:
- const SkPaint fPaint;
- bool fPopulated;
-
- SkPDFGraphicState();
- SkPDFGraphicState(const SkPaint& paint);
-
- void populateDict();
+ const SkScalar fStrokeWidth;
+ const SkScalar fStrokeMiter;
+ const uint8_t fAlpha;
+ const uint8_t fStrokeCap; // SkPaint::Cap
+ const uint8_t fStrokeJoin; // SkPaint::Join
+ const uint8_t fMode; // SkXfermode::Mode
+
+ SkPDFGraphicState(const SkPaint&);
typedef SkPDFDict INHERITED;
};
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/pdf/SkPDFGraphicState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698