| 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 "SkPDFFormXObject.h" | 9 #include "SkPDFFormXObject.h" |
| 10 #include "SkPDFGraphicState.h" | 10 #include "SkPDFGraphicState.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 invertFunction = new SkPDFStream(psData); | 130 invertFunction = new SkPDFStream(psData); |
| 131 invertFunction->insertInt("FunctionType", 4); | 131 invertFunction->insertInt("FunctionType", 4); |
| 132 invertFunction->insert("Domain", domainAndRange.get()); | 132 invertFunction->insert("Domain", domainAndRange.get()); |
| 133 invertFunction->insert("Range", domainAndRange.get()); | 133 invertFunction->insert("Range", domainAndRange.get()); |
| 134 } | 134 } |
| 135 return invertFunction; | 135 return invertFunction; |
| 136 } | 136 } |
| 137 | 137 |
| 138 // static | 138 // static |
| 139 SkPDFGraphicState* SkPDFGraphicState::GetSMaskGraphicState( | 139 SkPDFGraphicState* SkPDFGraphicState::GetSMaskGraphicState( |
| 140 SkPDFFormXObject* sMask, bool invert) { | 140 SkPDFFormXObject* sMask, bool invert, SkPDFSMaskMode sMaskMode) { |
| 141 // The practical chances of using the same mask more than once are unlikely | 141 // The practical chances of using the same mask more than once are unlikely |
| 142 // enough that it's not worth canonicalizing. | 142 // enough that it's not worth canonicalizing. |
| 143 SkAutoMutexAcquire lock(CanonicalPaintsMutex()); | 143 SkAutoMutexAcquire lock(CanonicalPaintsMutex()); |
| 144 | 144 |
| 145 SkAutoTUnref<SkPDFDict> sMaskDict(new SkPDFDict("Mask")); | 145 SkAutoTUnref<SkPDFDict> sMaskDict(new SkPDFDict("Mask")); |
| 146 sMaskDict->insertName("S", "Alpha"); | 146 if (sMaskMode == kAlpha_SMaskMode) { |
| 147 sMaskDict->insertName("S", "Alpha"); |
| 148 } else if (sMaskMode == kLuminosity_SMaskMode) { |
| 149 sMaskDict->insertName("S", "Luminosity"); |
| 150 } |
| 147 sMaskDict->insert("G", new SkPDFObjRef(sMask))->unref(); | 151 sMaskDict->insert("G", new SkPDFObjRef(sMask))->unref(); |
| 148 | 152 |
| 149 SkPDFGraphicState* result = new SkPDFGraphicState; | 153 SkPDFGraphicState* result = new SkPDFGraphicState; |
| 150 result->fPopulated = true; | 154 result->fPopulated = true; |
| 151 result->fSMask = true; | 155 result->fSMask = true; |
| 152 result->insertName("Type", "ExtGState"); | 156 result->insertName("Type", "ExtGState"); |
| 153 result->insert("SMask", sMaskDict.get()); | 157 result->insert("SMask", sMaskDict.get()); |
| 154 result->fResources.push(sMask); | 158 result->fResources.push(sMask); |
| 155 sMask->ref(); | 159 sMask->ref(); |
| 156 | 160 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 279 } |
| 276 if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || | 280 if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || |
| 277 blend_mode_from_xfermode(bXfermodeName) == NULL) { | 281 blend_mode_from_xfermode(bXfermodeName) == NULL) { |
| 278 bXfermodeName = SkXfermode::kSrcOver_Mode; | 282 bXfermodeName = SkXfermode::kSrcOver_Mode; |
| 279 } | 283 } |
| 280 const char* bXfermodeString = blend_mode_from_xfermode(bXfermodeName); | 284 const char* bXfermodeString = blend_mode_from_xfermode(bXfermodeName); |
| 281 SkASSERT(bXfermodeString != NULL); | 285 SkASSERT(bXfermodeString != NULL); |
| 282 | 286 |
| 283 return strcmp(aXfermodeString, bXfermodeString) == 0; | 287 return strcmp(aXfermodeString, bXfermodeString) == 0; |
| 284 } | 288 } |
| OLD | NEW |