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 |
(...skipping 10 matching lines...) Expand all Loading... |
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. Static methods in this class manage | 23 once, we want to canonicalize them. Static methods in this class manage |
24 a weakly referenced set of SkPDFGraphicState objects: when the last | 24 a weakly referenced set of SkPDFGraphicState objects: when the last |
25 reference to a SkPDFGraphicState is removed, it removes itself from the | 25 reference to a SkPDFGraphicState is removed, it removes itself from the |
26 static set of objects. | 26 static set of objects. |
27 | 27 |
28 */ | 28 */ |
29 class SkPDFGraphicState : public SkPDFDict { | 29 class SkPDFGraphicState : public SkPDFDict { |
30 public: | 30 public: |
| 31 enum SkPDFSMaskMode { |
| 32 kAlpha_SMaskMode, |
| 33 kLuminosity_SMaskMode |
| 34 }; |
| 35 |
31 virtual ~SkPDFGraphicState(); | 36 virtual ~SkPDFGraphicState(); |
32 | 37 |
33 virtual void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, | 38 virtual void getResources(const SkTSet<SkPDFObject*>& knownResourceObjects, |
34 SkTSet<SkPDFObject*>* newResourceObjects); | 39 SkTSet<SkPDFObject*>* newResourceObjects); |
35 | 40 |
36 // Override emitObject and getOutputSize so that we can populate | 41 // Override emitObject and getOutputSize so that we can populate |
37 // the dictionary on demand. | 42 // the dictionary on demand. |
38 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, | 43 virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
39 bool indirect); | 44 bool indirect); |
40 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); | 45 virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect); |
41 | 46 |
42 /** Get the graphic state for the passed SkPaint. The reference count of | 47 /** Get the graphic state for the passed SkPaint. The reference count of |
43 * the object is incremented and it is the caller's responsibility to | 48 * the object is incremented and it is the caller's responsibility to |
44 * unreference it when done. This is needed to accommodate the weak | 49 * unreference it when done. This is needed to accommodate the weak |
45 * reference pattern used when the returned object is new and has no | 50 * reference pattern used when the returned object is new and has no |
46 * other references. | 51 * other references. |
47 * @param paint The SkPaint to emulate. | 52 * @param paint The SkPaint to emulate. |
48 */ | 53 */ |
49 static SkPDFGraphicState* GetGraphicStateForPaint(const SkPaint& paint); | 54 static SkPDFGraphicState* GetGraphicStateForPaint(const SkPaint& paint); |
50 | 55 |
51 /** Make a graphic state that only sets the passed soft mask. The | 56 /** Make a graphic state that only sets the passed soft mask. The |
52 * reference count of the object is incremented and it is the caller's | 57 * reference count of the object is incremented and it is the caller's |
53 * responsibility to unreference it when done. | 58 * responsibility to unreference it when done. |
54 * @param sMask The form xobject to use as a soft mask. | 59 * @param sMask The form xobject to use as a soft mask. |
55 * @param invert Indicates if the alpha of the sMask should be inverted. | 60 * @param invert Indicates if the alpha of the sMask should be inverted. |
| 61 * @param sMaskMode Whether to use alpha or luminosity for the sMask. |
56 */ | 62 */ |
57 static SkPDFGraphicState* GetSMaskGraphicState(SkPDFFormXObject* sMask, | 63 static SkPDFGraphicState* GetSMaskGraphicState(SkPDFFormXObject* sMask, |
58 bool invert); | 64 bool invert, |
| 65 SkPDFSMaskMode sMaskMode); |
59 | 66 |
60 /** Get a graphic state that only unsets the soft mask. The reference | 67 /** Get a graphic state that only unsets the soft mask. The reference |
61 * count of the object is incremented and it is the caller's responsibility | 68 * count of the object is incremented and it is the caller's responsibility |
62 * to unreference it when done. This is needed to accommodate the weak | 69 * to unreference it when done. This is needed to accommodate the weak |
63 * reference pattern used when the returned object is new and has no | 70 * reference pattern used when the returned object is new and has no |
64 * other references. | 71 * other references. |
65 */ | 72 */ |
66 static SkPDFGraphicState* GetNoSMaskGraphicState(); | 73 static SkPDFGraphicState* GetNoSMaskGraphicState(); |
67 | 74 |
68 private: | 75 private: |
(...skipping 24 matching lines...) Expand all Loading... |
93 explicit SkPDFGraphicState(const SkPaint& paint); | 100 explicit SkPDFGraphicState(const SkPaint& paint); |
94 | 101 |
95 void populateDict(); | 102 void populateDict(); |
96 | 103 |
97 static SkPDFObject* GetInvertFunction(); | 104 static SkPDFObject* GetInvertFunction(); |
98 | 105 |
99 static int Find(const SkPaint& paint); | 106 static int Find(const SkPaint& paint); |
100 }; | 107 }; |
101 | 108 |
102 #endif | 109 #endif |
OLD | NEW |