aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFGraphicState.h
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-06-28 16:04:20 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-30 16:47:14 +0000
commit80fa7cea93974b0480f35f7a5260ce78ba50420f (patch)
treeefd0f86808985a700b386d94482724538f4f9fba /src/pdf/SkPDFGraphicState.h
parenta062258e76e28ef0ec88ef827ae84a90730393cc (diff)
SkPDF: simplify SkPDFGraphicState
- Separate graphic state objects for Stroke and Fill. - SkPDFGraphicState::GetGraphicStateForPaint simplified. - No more SkPDFGraphicState objects.Simplify SkPDFCanon. All PDFs render the same. Most PDFs are slightly smaller, especially those from captured web pages. Change-Id: Id9605c1d7495645da558d5f378ba585cdc201bba Reviewed-on: https://skia-review.googlesource.com/21343 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'src/pdf/SkPDFGraphicState.h')
-rw-r--r--src/pdf/SkPDFGraphicState.h58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/pdf/SkPDFGraphicState.h b/src/pdf/SkPDFGraphicState.h
index 50b22686ac..4323252bcd 100644
--- a/src/pdf/SkPDFGraphicState.h
+++ b/src/pdf/SkPDFGraphicState.h
@@ -20,24 +20,15 @@ class SkPDFCanon;
be installed. So that a given dictionary is only output to the pdf file
once, we want to canonicalize them.
*/
-class SkPDFGraphicState final : public SkPDFObject {
-
-public:
+namespace SkPDFGraphicState {
enum SkPDFSMaskMode {
kAlpha_SMaskMode,
kLuminosity_SMaskMode
};
- // Override emitObject so that we can populate the dictionary on
- // demand.
- void emitObject(SkWStream* stream,
- const SkPDFObjNumMap& objNumMap) const override;
-
/** Get the graphic state for the passed SkPaint.
- * @param paint The SkPaint to emulate.
*/
- static sk_sp<SkPDFGraphicState> GetGraphicStateForPaint(SkPDFCanon* canon,
- const SkPaint& paint);
+ sk_sp<SkPDFDict> GetGraphicStateForPaint(SkPDFCanon*, const SkPaint&);
/** Make a graphic state that only sets the passed soft mask.
* @param sMask The form xobject to use as a soft mask.
@@ -46,29 +37,34 @@ public:
*
* These are not de-duped.
*/
- static sk_sp<SkPDFDict> GetSMaskGraphicState(sk_sp<SkPDFObject> sMask,
- bool invert,
- SkPDFSMaskMode sMaskMode,
- SkPDFCanon* canon);
-
- static sk_sp<SkPDFStream> MakeInvertFunction();
+ sk_sp<SkPDFDict> GetSMaskGraphicState(sk_sp<SkPDFObject> sMask,
+ bool invert,
+ SkPDFSMaskMode sMaskMode,
+ SkPDFCanon* canon);
- bool operator==(const SkPDFGraphicState& rhs) const {
- return 0 == memcmp(&fStrokeWidth, &rhs.fStrokeWidth, 12);
- }
- uint32_t hash() const { return SkOpts::hash(&fStrokeWidth, 12); }
+ sk_sp<SkPDFStream> MakeInvertFunction();
+}
-private:
- 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; // SkBlendMode
-
- SkPDFGraphicState(const SkPaint&);
+SK_BEGIN_REQUIRE_DENSE
+struct SkPDFStrokeGraphicState {
+ SkScalar fStrokeWidth;
+ SkScalar fStrokeMiter;
+ uint8_t fStrokeCap; // SkPaint::Cap
+ uint8_t fStrokeJoin; // SkPaint::Join
+ uint8_t fAlpha;
+ uint8_t fBlendMode;
+ bool operator==(const SkPDFStrokeGraphicState& o) const { return !memcmp(this, &o, sizeof(o)); }
+ bool operator!=(const SkPDFStrokeGraphicState& o) const { return !(*this == o); }
+};
+SK_END_REQUIRE_DENSE
- typedef SkPDFDict INHERITED;
+SK_BEGIN_REQUIRE_DENSE
+struct SkPDFFillGraphicState {
+ uint8_t fAlpha;
+ uint8_t fBlendMode;
+ bool operator==(const SkPDFFillGraphicState& o) const { return !memcmp(this, &o, sizeof(o)); }
+ bool operator!=(const SkPDFFillGraphicState& o) const { return !(*this == o); }
};
+SK_END_REQUIRE_DENSE
#endif