| 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 "SkPaint.h" | 9 #include "SkPaint.h" |
| 10 #include "SkPDFCanon.h" | 10 #include "SkPDFCanon.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 sk_sp<SkPDFDict> SkPDFGraphicState::MakeNoSmaskGraphicState() { | 171 sk_sp<SkPDFDict> SkPDFGraphicState::MakeNoSmaskGraphicState() { |
| 172 auto noSMaskGS = sk_make_sp<SkPDFDict>("ExtGState"); | 172 auto noSMaskGS = sk_make_sp<SkPDFDict>("ExtGState"); |
| 173 noSMaskGS->insertName("SMask", "None"); | 173 noSMaskGS->insertName("SMask", "None"); |
| 174 return noSMaskGS; | 174 return noSMaskGS; |
| 175 } | 175 } |
| 176 | 176 |
| 177 void SkPDFGraphicState::emitObject( | 177 void SkPDFGraphicState::emitObject( |
| 178 SkWStream* stream, | 178 SkWStream* stream, |
| 179 const SkPDFObjNumMap& objNumMap, | 179 const SkPDFObjNumMap& objNumMap) const { |
| 180 const SkPDFSubstituteMap& substitutes) const { | |
| 181 auto dict = sk_make_sp<SkPDFDict>("ExtGState"); | 180 auto dict = sk_make_sp<SkPDFDict>("ExtGState"); |
| 182 dict->insertName("Type", "ExtGState"); | 181 dict->insertName("Type", "ExtGState"); |
| 183 | 182 |
| 184 SkScalar alpha = SkIntToScalar(fAlpha) / 0xFF; | 183 SkScalar alpha = SkIntToScalar(fAlpha) / 0xFF; |
| 185 dict->insertScalar("CA", alpha); | 184 dict->insertScalar("CA", alpha); |
| 186 dict->insertScalar("ca", alpha); | 185 dict->insertScalar("ca", alpha); |
| 187 | 186 |
| 188 SkPaint::Cap strokeCap = (SkPaint::Cap)fStrokeCap; | 187 SkPaint::Cap strokeCap = (SkPaint::Cap)fStrokeCap; |
| 189 SkPaint::Join strokeJoin = (SkPaint::Join)fStrokeJoin; | 188 SkPaint::Join strokeJoin = (SkPaint::Join)fStrokeJoin; |
| 190 SkXfermode::Mode xferMode = (SkXfermode::Mode)fMode; | 189 SkXfermode::Mode xferMode = (SkXfermode::Mode)fMode; |
| 191 | 190 |
| 192 static_assert(SkPaint::kButt_Cap == 0, "paint_cap_mismatch"); | 191 static_assert(SkPaint::kButt_Cap == 0, "paint_cap_mismatch"); |
| 193 static_assert(SkPaint::kRound_Cap == 1, "paint_cap_mismatch"); | 192 static_assert(SkPaint::kRound_Cap == 1, "paint_cap_mismatch"); |
| 194 static_assert(SkPaint::kSquare_Cap == 2, "paint_cap_mismatch"); | 193 static_assert(SkPaint::kSquare_Cap == 2, "paint_cap_mismatch"); |
| 195 static_assert(SkPaint::kCapCount == 3, "paint_cap_mismatch"); | 194 static_assert(SkPaint::kCapCount == 3, "paint_cap_mismatch"); |
| 196 SkASSERT(strokeCap >= 0 && strokeCap <= 2); | 195 SkASSERT(strokeCap >= 0 && strokeCap <= 2); |
| 197 dict->insertInt("LC", strokeCap); | 196 dict->insertInt("LC", strokeCap); |
| 198 | 197 |
| 199 static_assert(SkPaint::kMiter_Join == 0, "paint_join_mismatch"); | 198 static_assert(SkPaint::kMiter_Join == 0, "paint_join_mismatch"); |
| 200 static_assert(SkPaint::kRound_Join == 1, "paint_join_mismatch"); | 199 static_assert(SkPaint::kRound_Join == 1, "paint_join_mismatch"); |
| 201 static_assert(SkPaint::kBevel_Join == 2, "paint_join_mismatch"); | 200 static_assert(SkPaint::kBevel_Join == 2, "paint_join_mismatch"); |
| 202 static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch"); | 201 static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch"); |
| 203 SkASSERT(strokeJoin >= 0 && strokeJoin <= 2); | 202 SkASSERT(strokeJoin >= 0 && strokeJoin <= 2); |
| 204 dict->insertInt("LJ", strokeJoin); | 203 dict->insertInt("LJ", strokeJoin); |
| 205 | 204 |
| 206 dict->insertScalar("LW", fStrokeWidth); | 205 dict->insertScalar("LW", fStrokeWidth); |
| 207 dict->insertScalar("ML", fStrokeMiter); | 206 dict->insertScalar("ML", fStrokeMiter); |
| 208 dict->insertBool("SA", true); // SA = Auto stroke adjustment. | 207 dict->insertBool("SA", true); // SA = Auto stroke adjustment. |
| 209 dict->insertName("BM", as_blend_mode(xferMode)); | 208 dict->insertName("BM", as_blend_mode(xferMode)); |
| 210 dict->emitObject(stream, objNumMap, substitutes); | 209 dict->emitObject(stream, objNumMap); |
| 211 } | 210 } |
| OLD | NEW |