Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: src/pdf/SkPDFGraphicState.cpp

Issue 2193973002: SkPDF: PDFShader code modernized. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-08-02 (Tuesday) 17:24:52 EDT Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFGraphicState.h ('k') | src/pdf/SkPDFShader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Do not copy the trailing '\0' into the SkData. 137 // Do not copy the trailing '\0' into the SkData.
138 auto invertFunction = sk_make_sp<SkPDFStream>( 138 auto invertFunction = sk_make_sp<SkPDFStream>(
139 SkData::MakeWithoutCopy(psInvert, strlen(psInvert))); 139 SkData::MakeWithoutCopy(psInvert, strlen(psInvert)));
140 invertFunction->dict()->insertInt("FunctionType", 4); 140 invertFunction->dict()->insertInt("FunctionType", 4);
141 invertFunction->dict()->insertObject("Domain", domainAndRange); 141 invertFunction->dict()->insertObject("Domain", domainAndRange);
142 invertFunction->dict()->insertObject("Range", std::move(domainAndRange)); 142 invertFunction->dict()->insertObject("Range", std::move(domainAndRange));
143 return invertFunction; 143 return invertFunction;
144 } 144 }
145 145
146 sk_sp<SkPDFDict> SkPDFGraphicState::GetSMaskGraphicState( 146 sk_sp<SkPDFDict> SkPDFGraphicState::GetSMaskGraphicState(
147 SkPDFObject* sMask, 147 sk_sp<SkPDFObject> sMask,
148 bool invert, 148 bool invert,
149 SkPDFSMaskMode sMaskMode, 149 SkPDFSMaskMode sMaskMode,
150 SkPDFCanon* canon) { 150 SkPDFCanon* canon) {
151 // The practical chances of using the same mask more than once are unlikely 151 // The practical chances of using the same mask more than once are unlikely
152 // enough that it's not worth canonicalizing. 152 // enough that it's not worth canonicalizing.
153 auto sMaskDict = sk_make_sp<SkPDFDict>("Mask"); 153 auto sMaskDict = sk_make_sp<SkPDFDict>("Mask");
154 if (sMaskMode == kAlpha_SMaskMode) { 154 if (sMaskMode == kAlpha_SMaskMode) {
155 sMaskDict->insertName("S", "Alpha"); 155 sMaskDict->insertName("S", "Alpha");
156 } else if (sMaskMode == kLuminosity_SMaskMode) { 156 } else if (sMaskMode == kLuminosity_SMaskMode) {
157 sMaskDict->insertName("S", "Luminosity"); 157 sMaskDict->insertName("S", "Luminosity");
158 } 158 }
159 sMaskDict->insertObjRef("G", sk_ref_sp(sMask)); 159 sMaskDict->insertObjRef("G", std::move(sMask));
160 if (invert) { 160 if (invert) {
161 // Instead of calling SkPDFGraphicState::MakeInvertFunction, 161 // Instead of calling SkPDFGraphicState::MakeInvertFunction,
162 // let the canon deduplicate this object. 162 // let the canon deduplicate this object.
163 sMaskDict->insertObjRef("TR", canon->makeInvertFunction()); 163 sMaskDict->insertObjRef("TR", canon->makeInvertFunction());
164 } 164 }
165 165
166 auto result = sk_make_sp<SkPDFDict>("ExtGState"); 166 auto result = sk_make_sp<SkPDFDict>("ExtGState");
167 result->insertObject("SMask", std::move(sMaskDict)); 167 result->insertObject("SMask", std::move(sMaskDict));
168 return result; 168 return result;
169 } 169 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch"); 202 static_assert(SkPaint::kJoinCount == 3, "paint_join_mismatch");
203 SkASSERT(strokeJoin >= 0 && strokeJoin <= 2); 203 SkASSERT(strokeJoin >= 0 && strokeJoin <= 2);
204 dict->insertInt("LJ", strokeJoin); 204 dict->insertInt("LJ", strokeJoin);
205 205
206 dict->insertScalar("LW", fStrokeWidth); 206 dict->insertScalar("LW", fStrokeWidth);
207 dict->insertScalar("ML", fStrokeMiter); 207 dict->insertScalar("ML", fStrokeMiter);
208 dict->insertBool("SA", true); // SA = Auto stroke adjustment. 208 dict->insertBool("SA", true); // SA = Auto stroke adjustment.
209 dict->insertName("BM", as_blend_mode(xferMode)); 209 dict->insertName("BM", as_blend_mode(xferMode));
210 dict->emitObject(stream, objNumMap, substitutes); 210 dict->emitObject(stream, objNumMap, substitutes);
211 } 211 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFGraphicState.h ('k') | src/pdf/SkPDFShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698