OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef SkPDFGraphicState_DEFINED | 9 #ifndef SkPDFGraphicState_DEFINED |
10 #define SkPDFGraphicState_DEFINED | 10 #define SkPDFGraphicState_DEFINED |
11 | 11 |
12 #include "SkPDFStream.h" | 12 #include "SkPDFStream.h" |
13 #include "SkChecksum.h" | 13 #include "SkChecksum.h" |
14 | 14 |
15 class SkPaint; | 15 class SkPaint; |
16 class SkPDFCanon; | 16 class SkPDFCanon; |
17 class SkPDFFormXObject; | |
18 | 17 |
19 /** \class SkPDFGraphicState | 18 /** \class SkPDFGraphicState |
20 SkPaint objects roughly correspond to graphic state dictionaries that can | 19 SkPaint objects roughly correspond to graphic state dictionaries that can |
21 be installed. So that a given dictionary is only output to the pdf file | 20 be installed. So that a given dictionary is only output to the pdf file |
22 once, we want to canonicalize them. | 21 once, we want to canonicalize them. |
23 */ | 22 */ |
24 class SkPDFGraphicState final : public SkPDFObject { | 23 class SkPDFGraphicState final : public SkPDFObject { |
25 | 24 |
26 public: | 25 public: |
27 enum SkPDFSMaskMode { | 26 enum SkPDFSMaskMode { |
(...skipping 17 matching lines...) Expand all Loading... |
45 static SkPDFGraphicState* GetGraphicStateForPaint(SkPDFCanon* canon, | 44 static SkPDFGraphicState* GetGraphicStateForPaint(SkPDFCanon* canon, |
46 const SkPaint& paint); | 45 const SkPaint& paint); |
47 | 46 |
48 /** Make a graphic state that only sets the passed soft mask. | 47 /** Make a graphic state that only sets the passed soft mask. |
49 * @param sMask The form xobject to use as a soft mask. | 48 * @param sMask The form xobject to use as a soft mask. |
50 * @param invert Indicates if the alpha of the sMask should be inverted. | 49 * @param invert Indicates if the alpha of the sMask should be inverted. |
51 * @param sMaskMode Whether to use alpha or luminosity for the sMask. | 50 * @param sMaskMode Whether to use alpha or luminosity for the sMask. |
52 * | 51 * |
53 * These are not de-duped. | 52 * These are not de-duped. |
54 */ | 53 */ |
55 static sk_sp<SkPDFDict> GetSMaskGraphicState(SkPDFFormXObject* sMask, | 54 static sk_sp<SkPDFDict> GetSMaskGraphicState(SkPDFObject* sMask, |
56 bool invert, | 55 bool invert, |
57 SkPDFSMaskMode sMaskMode, | 56 SkPDFSMaskMode sMaskMode, |
58 SkPDFCanon* canon); | 57 SkPDFCanon* canon); |
59 | 58 |
60 /** Make a graphic state that only unsets the soft mask. */ | 59 /** Make a graphic state that only unsets the soft mask. */ |
61 static sk_sp<SkPDFDict> MakeNoSmaskGraphicState(); | 60 static sk_sp<SkPDFDict> MakeNoSmaskGraphicState(); |
62 static sk_sp<SkPDFStream> MakeInvertFunction(); | 61 static sk_sp<SkPDFStream> MakeInvertFunction(); |
63 | 62 |
64 bool operator==(const SkPDFGraphicState& rhs) const { | 63 bool operator==(const SkPDFGraphicState& rhs) const { |
65 return 0 == memcmp(&fStrokeWidth, &rhs.fStrokeWidth, 12); | 64 return 0 == memcmp(&fStrokeWidth, &rhs.fStrokeWidth, 12); |
66 } | 65 } |
67 uint32_t hash() const { return SkChecksum::Murmur3(&fStrokeWidth, 12); } | 66 uint32_t hash() const { return SkChecksum::Murmur3(&fStrokeWidth, 12); } |
68 | 67 |
69 private: | 68 private: |
70 const SkScalar fStrokeWidth; | 69 const SkScalar fStrokeWidth; |
71 const SkScalar fStrokeMiter; | 70 const SkScalar fStrokeMiter; |
72 const uint8_t fAlpha; | 71 const uint8_t fAlpha; |
73 const uint8_t fStrokeCap; // SkPaint::Cap | 72 const uint8_t fStrokeCap; // SkPaint::Cap |
74 const uint8_t fStrokeJoin; // SkPaint::Join | 73 const uint8_t fStrokeJoin; // SkPaint::Join |
75 const uint8_t fMode; // SkXfermode::Mode | 74 const uint8_t fMode; // SkXfermode::Mode |
76 | 75 |
77 SkPDFGraphicState(const SkPaint&); | 76 SkPDFGraphicState(const SkPaint&); |
78 | 77 |
79 typedef SkPDFDict INHERITED; | 78 typedef SkPDFDict INHERITED; |
80 }; | 79 }; |
81 | 80 |
82 #endif | 81 #endif |
OLD | NEW |