OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 #include "SkData.h" | 8 #include "SkData.h" |
9 #include "SkLazyPtr.h" | 9 #include "SkLazyPtr.h" |
10 #include "SkPDFCanon.h" | 10 #include "SkPDFCanon.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 | 110 |
111 bool SkPDFGraphicState::equals(const SkPaint& paint) const { | 111 bool SkPDFGraphicState::equals(const SkPaint& paint) const { |
112 return equivalent(paint, fPaint); | 112 return equivalent(paint, fPaint); |
113 } | 113 } |
114 | 114 |
115 SkPDFGraphicState::~SkPDFGraphicState() { | 115 SkPDFGraphicState::~SkPDFGraphicState() { |
116 SkAutoMutexAcquire lock(SkPDFCanon::GetPaintMutex()); | 116 SkAutoMutexAcquire lock(SkPDFCanon::GetPaintMutex()); |
117 if (!fSMask) { | 117 if (!fSMask) { |
118 SkPDFCanon::GetCanon().removeGraphicState(this); | 118 SkPDFCanon::GetCanon().removeGraphicState(this); |
119 } | 119 } |
120 fResources.unrefAll(); | |
121 } | |
122 | |
123 void SkPDFGraphicState::getResources( | |
124 const SkTSet<SkPDFObject*>& knownResourceObjects, | |
125 SkTSet<SkPDFObject*>* newResourceObjects) { | |
126 GetResourcesHelper(&fResources, knownResourceObjects, newResourceObjects); | |
127 } | 120 } |
128 | 121 |
129 void SkPDFGraphicState::emitObject(SkWStream* stream, SkPDFCatalog* catalog) { | 122 void SkPDFGraphicState::emitObject(SkWStream* stream, SkPDFCatalog* catalog) { |
130 populateDict(); | 123 populateDict(); |
131 SkPDFDict::emitObject(stream, catalog); | 124 SkPDFDict::emitObject(stream, catalog); |
132 } | 125 } |
133 | 126 |
134 // static | 127 // static |
135 SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint( | 128 SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint( |
136 const SkPaint& paint) { | 129 const SkPaint& paint) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 } else if (sMaskMode == kLuminosity_SMaskMode) { | 182 } else if (sMaskMode == kLuminosity_SMaskMode) { |
190 sMaskDict->insertName("S", "Luminosity"); | 183 sMaskDict->insertName("S", "Luminosity"); |
191 } | 184 } |
192 sMaskDict->insert("G", new SkPDFObjRef(sMask))->unref(); | 185 sMaskDict->insert("G", new SkPDFObjRef(sMask))->unref(); |
193 | 186 |
194 SkPDFGraphicState* result = new SkPDFGraphicState; | 187 SkPDFGraphicState* result = new SkPDFGraphicState; |
195 result->fPopulated = true; | 188 result->fPopulated = true; |
196 result->fSMask = true; | 189 result->fSMask = true; |
197 result->insertName("Type", "ExtGState"); | 190 result->insertName("Type", "ExtGState"); |
198 result->insert("SMask", sMaskDict.get()); | 191 result->insert("SMask", sMaskDict.get()); |
199 result->fResources.push(sMask); | |
200 sMask->ref(); | |
201 | 192 |
202 if (invert) { | 193 if (invert) { |
203 SkPDFObject* invertFunction = GetInvertFunction(); | 194 SkPDFObject* invertFunction = GetInvertFunction(); |
204 result->fResources.push(invertFunction); | |
205 invertFunction->ref(); | |
206 sMaskDict->insert("TR", new SkPDFObjRef(invertFunction))->unref(); | 195 sMaskDict->insert("TR", new SkPDFObjRef(invertFunction))->unref(); |
mtklein
2015/01/26 23:38:59
Might move the call to GetInvertFunction() right i
hal.canary
2015/02/09 23:35:01
Done.
| |
207 } | 196 } |
208 | 197 |
209 return result; | 198 return result; |
210 } | 199 } |
211 | 200 |
212 SkPDFGraphicState* SkPDFGraphicState::CreateNoSMaskGraphicState() { | 201 SkPDFGraphicState* SkPDFGraphicState::CreateNoSMaskGraphicState() { |
213 SkPDFGraphicState* noSMaskGS = SkNEW(SkPDFGraphicState); | 202 SkPDFGraphicState* noSMaskGS = SkNEW(SkPDFGraphicState); |
214 noSMaskGS->fPopulated = true; | 203 noSMaskGS->fPopulated = true; |
215 noSMaskGS->fSMask = true; | 204 noSMaskGS->fSMask = true; |
216 noSMaskGS->insertName("Type", "ExtGState"); | 205 noSMaskGS->insertName("Type", "ExtGState"); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 fPaint.getXfermode()->asMode(&xfermode); | 262 fPaint.getXfermode()->asMode(&xfermode); |
274 // If we don't support the mode, just use kSrcOver_Mode. | 263 // If we don't support the mode, just use kSrcOver_Mode. |
275 if (xfermode < 0 || xfermode > SkXfermode::kLastMode || | 264 if (xfermode < 0 || xfermode > SkXfermode::kLastMode || |
276 as_blend_mode(xfermode) == NULL) { | 265 as_blend_mode(xfermode) == NULL) { |
277 xfermode = SkXfermode::kSrcOver_Mode; | 266 xfermode = SkXfermode::kSrcOver_Mode; |
278 NOT_IMPLEMENTED("unsupported xfermode", false); | 267 NOT_IMPLEMENTED("unsupported xfermode", false); |
279 } | 268 } |
280 insertName("BM", as_blend_mode(xfermode)); | 269 insertName("BM", as_blend_mode(xfermode)); |
281 } | 270 } |
282 } | 271 } |
OLD | NEW |