| 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 "SkOncePtr.h" | 9 #include "SkOncePtr.h" |
| 10 #include "SkPDFCanon.h" | 10 #include "SkPDFCanon.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray); | 132 SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray); |
| 133 domainAndRange->reserve(2); | 133 domainAndRange->reserve(2); |
| 134 domainAndRange->appendInt(0); | 134 domainAndRange->appendInt(0); |
| 135 domainAndRange->appendInt(1); | 135 domainAndRange->appendInt(1); |
| 136 | 136 |
| 137 static const char psInvert[] = "{1 exch sub}"; | 137 static const char psInvert[] = "{1 exch sub}"; |
| 138 // Do not copy the trailing '\0' into the SkData. | 138 // Do not copy the trailing '\0' into the SkData. |
| 139 SkAutoTUnref<SkData> psInvertStream( | 139 SkAutoTUnref<SkData> psInvertStream( |
| 140 SkData::NewWithoutCopy(psInvert, strlen(psInvert))); | 140 SkData::NewWithoutCopy(psInvert, strlen(psInvert))); |
| 141 | 141 |
| 142 SkPDFStream* invertFunction = new SkPDFStream(psInvertStream.get()); | 142 SkAutoTUnref<SkPDFStream> invertFunction(new SkPDFStream(psInvertStream.get(
))); |
| 143 invertFunction->insertInt("FunctionType", 4); | 143 invertFunction->insertInt("FunctionType", 4); |
| 144 invertFunction->insertObject("Domain", SkRef(domainAndRange.get())); | 144 invertFunction->insertObject("Domain", SkRef(domainAndRange.get())); |
| 145 invertFunction->insertObject("Range", domainAndRange.detach()); | 145 invertFunction->insertObject("Range", domainAndRange.release()); |
| 146 return invertFunction; | 146 return invertFunction.release(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, invertFunction); | 149 SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, invertFunction); |
| 150 | 150 |
| 151 // static | 151 // static |
| 152 SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask, | 152 SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask, |
| 153 bool invert, | 153 bool invert, |
| 154 SkPDFSMaskMode sMaskMode) { | 154 SkPDFSMaskMode sMaskMode) { |
| 155 // The practical chances of using the same mask more than once are unlikely | 155 // The practical chances of using the same mask more than once are unlikely |
| 156 // enough that it's not worth canonicalizing. | 156 // enough that it's not worth canonicalizing. |
| 157 SkAutoTUnref<SkPDFDict> sMaskDict(new SkPDFDict("Mask")); | 157 SkAutoTUnref<SkPDFDict> sMaskDict(new SkPDFDict("Mask")); |
| 158 if (sMaskMode == kAlpha_SMaskMode) { | 158 if (sMaskMode == kAlpha_SMaskMode) { |
| 159 sMaskDict->insertName("S", "Alpha"); | 159 sMaskDict->insertName("S", "Alpha"); |
| 160 } else if (sMaskMode == kLuminosity_SMaskMode) { | 160 } else if (sMaskMode == kLuminosity_SMaskMode) { |
| 161 sMaskDict->insertName("S", "Luminosity"); | 161 sMaskDict->insertName("S", "Luminosity"); |
| 162 } | 162 } |
| 163 sMaskDict->insertObjRef("G", SkRef(sMask)); | 163 sMaskDict->insertObjRef("G", SkRef(sMask)); |
| 164 if (invert) { | 164 if (invert) { |
| 165 sMaskDict->insertObjRef("TR", SkRef(invertFunction.get(create_invert_fun
ction))); | 165 sMaskDict->insertObjRef("TR", SkRef(invertFunction.get(create_invert_fun
ction))); |
| 166 } | 166 } |
| 167 | 167 |
| 168 SkPDFDict* result = new SkPDFDict("ExtGState"); | 168 SkAutoTUnref<SkPDFDict> result(new SkPDFDict("ExtGState")); |
| 169 result->insertObject("SMask", sMaskDict.detach()); | 169 result->insertObject("SMask", sMaskDict.release()); |
| 170 return result; | 170 return result.release(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 static SkPDFDict* create_no_smask_graphic_state() { | 173 static SkPDFDict* create_no_smask_graphic_state() { |
| 174 SkPDFDict* noSMaskGS = new SkPDFDict("ExtGState"); | 174 SkPDFDict* noSMaskGS = new SkPDFDict("ExtGState"); |
| 175 noSMaskGS->insertName("SMask", "None"); | 175 noSMaskGS->insertName("SMask", "None"); |
| 176 return noSMaskGS; | 176 return noSMaskGS; |
| 177 } | 177 } |
| 178 SK_DECLARE_STATIC_ONCE_PTR(SkPDFDict, noSMaskGraphicState); | 178 SK_DECLARE_STATIC_ONCE_PTR(SkPDFDict, noSMaskGraphicState); |
| 179 | 179 |
| 180 // static | 180 // static |
| (...skipping 29 matching lines...) Expand all Loading... |
| 210 static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch"); | 210 static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch"); |
| 211 SkASSERT(strokeJoin >= 0 && strokeJoin <= 2); | 211 SkASSERT(strokeJoin >= 0 && strokeJoin <= 2); |
| 212 dict->insertInt("LJ", strokeJoin); | 212 dict->insertInt("LJ", strokeJoin); |
| 213 | 213 |
| 214 dict->insertScalar("LW", fStrokeWidth); | 214 dict->insertScalar("LW", fStrokeWidth); |
| 215 dict->insertScalar("ML", fStrokeMiter); | 215 dict->insertScalar("ML", fStrokeMiter); |
| 216 dict->insertBool("SA", true); // SA = Auto stroke adjustment. | 216 dict->insertBool("SA", true); // SA = Auto stroke adjustment. |
| 217 dict->insertName("BM", as_blend_mode(xferMode)); | 217 dict->insertName("BM", as_blend_mode(xferMode)); |
| 218 dict->emitObject(stream, objNumMap, substitutes); | 218 dict->emitObject(stream, objNumMap, substitutes); |
| 219 } | 219 } |
| OLD | NEW |