| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray); | 133 SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray); |
| 134 domainAndRange->reserve(2); | 134 domainAndRange->reserve(2); |
| 135 domainAndRange->appendInt(0); | 135 domainAndRange->appendInt(0); |
| 136 domainAndRange->appendInt(1); | 136 domainAndRange->appendInt(1); |
| 137 | 137 |
| 138 static const char psInvert[] = "{1 exch sub}"; | 138 static const char psInvert[] = "{1 exch sub}"; |
| 139 // Do not copy the trailing '\0' into the SkData. | 139 // Do not copy the trailing '\0' into the SkData. |
| 140 SkAutoTUnref<SkData> psInvertStream( | 140 SkAutoTUnref<SkData> psInvertStream( |
| 141 SkData::NewWithoutCopy(psInvert, strlen(psInvert))); | 141 SkData::NewWithoutCopy(psInvert, strlen(psInvert))); |
| 142 | 142 |
| 143 SkPDFStream* invertFunction = SkNEW_ARGS( | 143 SkPDFStream* invertFunction = new SkPDFStream(psInvertStream.get()); |
| 144 SkPDFStream, (psInvertStream.get())); | |
| 145 invertFunction->insertInt("FunctionType", 4); | 144 invertFunction->insertInt("FunctionType", 4); |
| 146 invertFunction->insertObject("Domain", SkRef(domainAndRange.get())); | 145 invertFunction->insertObject("Domain", SkRef(domainAndRange.get())); |
| 147 invertFunction->insertObject("Range", domainAndRange.detach()); | 146 invertFunction->insertObject("Range", domainAndRange.detach()); |
| 148 return invertFunction; | 147 return invertFunction; |
| 149 } | 148 } |
| 150 | 149 |
| 151 template <typename T> void unref(T* ptr) { ptr->unref(); } | 150 template <typename T> void unref(T* ptr) { ptr->unref(); } |
| 152 } // namespace | 151 } // namespace |
| 153 | 152 |
| 154 SK_DECLARE_STATIC_LAZY_PTR(SkPDFObject, | 153 SK_DECLARE_STATIC_LAZY_PTR(SkPDFObject, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 191 |
| 193 // static | 192 // static |
| 194 SkPDFDict* SkPDFGraphicState::GetNoSMaskGraphicState() { | 193 SkPDFDict* SkPDFGraphicState::GetNoSMaskGraphicState() { |
| 195 return SkRef(noSMaskGraphicState.get()); | 194 return SkRef(noSMaskGraphicState.get()); |
| 196 } | 195 } |
| 197 | 196 |
| 198 void SkPDFGraphicState::emitObject( | 197 void SkPDFGraphicState::emitObject( |
| 199 SkWStream* stream, | 198 SkWStream* stream, |
| 200 const SkPDFObjNumMap& objNumMap, | 199 const SkPDFObjNumMap& objNumMap, |
| 201 const SkPDFSubstituteMap& substitutes) const { | 200 const SkPDFSubstituteMap& substitutes) const { |
| 202 SkAutoTUnref<SkPDFDict> dict(SkNEW_ARGS(SkPDFDict, ("ExtGState"))); | 201 SkAutoTUnref<SkPDFDict> dict(new SkPDFDict("ExtGState")); |
| 203 dict->insertName("Type", "ExtGState"); | 202 dict->insertName("Type", "ExtGState"); |
| 204 | 203 |
| 205 SkScalar alpha = SkIntToScalar(fAlpha) / 0xFF; | 204 SkScalar alpha = SkIntToScalar(fAlpha) / 0xFF; |
| 206 dict->insertScalar("CA", alpha); | 205 dict->insertScalar("CA", alpha); |
| 207 dict->insertScalar("ca", alpha); | 206 dict->insertScalar("ca", alpha); |
| 208 | 207 |
| 209 SkPaint::Cap strokeCap = (SkPaint::Cap)fStrokeCap; | 208 SkPaint::Cap strokeCap = (SkPaint::Cap)fStrokeCap; |
| 210 SkPaint::Join strokeJoin = (SkPaint::Join)fStrokeJoin; | 209 SkPaint::Join strokeJoin = (SkPaint::Join)fStrokeJoin; |
| 211 SkXfermode::Mode xferMode = (SkXfermode::Mode)fMode; | 210 SkXfermode::Mode xferMode = (SkXfermode::Mode)fMode; |
| 212 | 211 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 223 static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch"); | 222 static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch"); |
| 224 SkASSERT(strokeJoin >= 0 && strokeJoin <= 2); | 223 SkASSERT(strokeJoin >= 0 && strokeJoin <= 2); |
| 225 dict->insertInt("LJ", strokeJoin); | 224 dict->insertInt("LJ", strokeJoin); |
| 226 | 225 |
| 227 dict->insertScalar("LW", fStrokeWidth); | 226 dict->insertScalar("LW", fStrokeWidth); |
| 228 dict->insertScalar("ML", fStrokeMiter); | 227 dict->insertScalar("ML", fStrokeMiter); |
| 229 dict->insertBool("SA", true); // SA = Auto stroke adjustment. | 228 dict->insertBool("SA", true); // SA = Auto stroke adjustment. |
| 230 dict->insertName("BM", as_blend_mode(xferMode)); | 229 dict->insertName("BM", as_blend_mode(xferMode)); |
| 231 dict->emitObject(stream, objNumMap, substitutes); | 230 dict->emitObject(stream, objNumMap, substitutes); |
| 232 } | 231 } |
| OLD | NEW |