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