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 "SkPDFFormXObject.h" | 8 #include "SkPDFFormXObject.h" |
9 #include "SkPDFGraphicState.h" | 9 #include "SkPDFGraphicState.h" |
10 #include "SkPDFUtils.h" | 10 #include "SkPDFUtils.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 invertFunction = new SkPDFStream(psInvertStream.get()); | 131 invertFunction = new SkPDFStream(psInvertStream.get()); |
132 invertFunction->insertInt("FunctionType", 4); | 132 invertFunction->insertInt("FunctionType", 4); |
133 invertFunction->insert("Domain", domainAndRange.get()); | 133 invertFunction->insert("Domain", domainAndRange.get()); |
134 invertFunction->insert("Range", domainAndRange.get()); | 134 invertFunction->insert("Range", domainAndRange.get()); |
135 } | 135 } |
136 return invertFunction; | 136 return invertFunction; |
137 } | 137 } |
138 | 138 |
139 // static | 139 // static |
140 SkPDFGraphicState* SkPDFGraphicState::GetSMaskGraphicState( | 140 SkPDFGraphicState* SkPDFGraphicState::GetSMaskGraphicState( |
141 SkPDFFormXObject* sMask, bool invert) { | 141 SkPDFFormXObject* sMask, bool invert, bool alpha) { |
142 // The practical chances of using the same mask more than once are unlikely | 142 // The practical chances of using the same mask more than once are unlikely |
143 // enough that it's not worth canonicalizing. | 143 // enough that it's not worth canonicalizing. |
144 SkAutoMutexAcquire lock(CanonicalPaintsMutex()); | 144 SkAutoMutexAcquire lock(CanonicalPaintsMutex()); |
145 | 145 |
146 SkAutoTUnref<SkPDFDict> sMaskDict(new SkPDFDict("Mask")); | 146 SkAutoTUnref<SkPDFDict> sMaskDict(new SkPDFDict("Mask")); |
147 sMaskDict->insertName("S", "Alpha"); | 147 if (alpha) { |
148 sMaskDict->insertName("S", "Alpha"); | |
149 } else { | |
150 sMaskDict->insertName("S", "Luminosity"); | |
151 } | |
148 sMaskDict->insert("G", new SkPDFObjRef(sMask))->unref(); | 152 sMaskDict->insert("G", new SkPDFObjRef(sMask))->unref(); |
149 | 153 |
150 SkPDFGraphicState* result = new SkPDFGraphicState; | 154 SkPDFGraphicState* result = new SkPDFGraphicState; |
151 result->fPopulated = true; | 155 result->fPopulated = true; |
152 result->fSMask = true; | 156 result->fSMask = true; |
153 result->insertName("Type", "ExtGState"); | 157 result->insertName("Type", "ExtGState"); |
154 result->insert("SMask", sMaskDict.get()); | 158 result->insert("SMask", sMaskDict.get()); |
155 result->fResources.push(sMask); | 159 result->fResources.push(sMask); |
156 sMask->ref(); | 160 sMask->ref(); |
157 | 161 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 fPopulated(false), | 200 fPopulated(false), |
197 fSMask(false) { | 201 fSMask(false) { |
198 } | 202 } |
199 | 203 |
200 // populateDict and operator== have to stay in sync with each other. | 204 // populateDict and operator== have to stay in sync with each other. |
201 void SkPDFGraphicState::populateDict() { | 205 void SkPDFGraphicState::populateDict() { |
202 if (!fPopulated) { | 206 if (!fPopulated) { |
203 fPopulated = true; | 207 fPopulated = true; |
204 insertName("Type", "ExtGState"); | 208 insertName("Type", "ExtGState"); |
205 | 209 |
210 // do a SMask if paint involves a gradient alpha | |
vandebo (ex-Chrome)
2013/07/03 17:07:01
How would paint involve a gradient alpha? We have
ducky
2013/07/03 23:32:09
That wasn't supposed to be there. I somehow missed
| |
211 //TODO ADD STUFF HERE | |
206 SkAutoTUnref<SkPDFScalar> alpha( | 212 SkAutoTUnref<SkPDFScalar> alpha( |
207 new SkPDFScalar(SkScalarDiv(fPaint.getAlpha(), 0xFF))); | 213 new SkPDFScalar(SkScalarDiv(fPaint.getAlpha(), 0xFF))); |
208 insert("CA", alpha.get()); | 214 insert("CA", alpha.get()); |
209 insert("ca", alpha.get()); | 215 insert("ca", alpha.get()); |
210 | 216 |
211 SK_COMPILE_ASSERT(SkPaint::kButt_Cap == 0, paint_cap_mismatch); | 217 SK_COMPILE_ASSERT(SkPaint::kButt_Cap == 0, paint_cap_mismatch); |
212 SK_COMPILE_ASSERT(SkPaint::kRound_Cap == 1, paint_cap_mismatch); | 218 SK_COMPILE_ASSERT(SkPaint::kRound_Cap == 1, paint_cap_mismatch); |
213 SK_COMPILE_ASSERT(SkPaint::kSquare_Cap == 2, paint_cap_mismatch); | 219 SK_COMPILE_ASSERT(SkPaint::kSquare_Cap == 2, paint_cap_mismatch); |
214 SK_COMPILE_ASSERT(SkPaint::kCapCount == 3, paint_cap_mismatch); | 220 SK_COMPILE_ASSERT(SkPaint::kCapCount == 3, paint_cap_mismatch); |
215 SkASSERT(fPaint.getStrokeCap() >= 0 && fPaint.getStrokeCap() <= 2); | 221 SkASSERT(fPaint.getStrokeCap() >= 0 && fPaint.getStrokeCap() <= 2); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 } | 282 } |
277 if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || | 283 if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || |
278 blend_mode_from_xfermode(bXfermodeName) == NULL) { | 284 blend_mode_from_xfermode(bXfermodeName) == NULL) { |
279 bXfermodeName = SkXfermode::kSrcOver_Mode; | 285 bXfermodeName = SkXfermode::kSrcOver_Mode; |
280 } | 286 } |
281 const char* bXfermodeString = blend_mode_from_xfermode(bXfermodeName); | 287 const char* bXfermodeString = blend_mode_from_xfermode(bXfermodeName); |
282 SkASSERT(bXfermodeString != NULL); | 288 SkASSERT(bXfermodeString != NULL); |
283 | 289 |
284 return strcmp(aXfermodeString, bXfermodeString) == 0; | 290 return strcmp(aXfermodeString, bXfermodeString) == 0; |
285 } | 291 } |
OLD | NEW |