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

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

Issue 18585002: Implemented transparent gradients (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Merge new SkPDFResourceDict method names Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/pdf/SkPDFUtils.h ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkData.h" 10 #include "SkData.h"
11 #include "SkGeometry.h" 11 #include "SkGeometry.h"
12 #include "SkPaint.h" 12 #include "SkPaint.h"
13 #include "SkPath.h" 13 #include "SkPath.h"
14 #include "SkPDFResourceDict.h" 14 #include "SkPDFResourceDict.h"
15 #include "SkPDFUtils.h" 15 #include "SkPDFUtils.h"
16 #include "SkStream.h" 16 #include "SkStream.h"
17 #include "SkString.h" 17 #include "SkString.h"
18 #include "SkPDFTypes.h" 18 #include "SkPDFTypes.h"
19 19
20 //static
21 SkPDFArray* SkPDFUtils::RectToArray(const SkRect& rect) {
22 SkPDFArray* result = new SkPDFArray();
23 result->reserve(4);
24 result->appendScalar(rect.fLeft);
25 result->appendScalar(rect.fTop);
26 result->appendScalar(rect.fRight);
27 result->appendScalar(rect.fBottom);
28 return result;
29 }
30
20 // static 31 // static
21 SkPDFArray* SkPDFUtils::MatrixToArray(const SkMatrix& matrix) { 32 SkPDFArray* SkPDFUtils::MatrixToArray(const SkMatrix& matrix) {
22 SkScalar values[6]; 33 SkScalar values[6];
23 if (!matrix.asAffine(values)) { 34 if (!matrix.asAffine(values)) {
24 SkMatrix::SetAffineIdentity(values); 35 SkMatrix::SetAffineIdentity(values);
25 } 36 }
26 37
27 SkPDFArray* result = new SkPDFArray; 38 SkPDFArray* result = new SkPDFArray;
28 result->reserve(6); 39 result->reserve(6);
29 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { 40 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 226 }
216 227
217 // static 228 // static
218 void SkPDFUtils::ApplyGraphicState(int objectIndex, SkWStream* content) { 229 void SkPDFUtils::ApplyGraphicState(int objectIndex, SkWStream* content) {
219 content->writeText("/"); 230 content->writeText("/");
220 content->writeText(SkPDFResourceDict::getResourceName( 231 content->writeText(SkPDFResourceDict::getResourceName(
221 SkPDFResourceDict::kExtGState_ResourceType, 232 SkPDFResourceDict::kExtGState_ResourceType,
222 objectIndex).c_str()); 233 objectIndex).c_str());
223 content->writeText(" gs\n"); 234 content->writeText(" gs\n");
224 } 235 }
236
237 // static
238 void SkPDFUtils::ApplyPattern(int objectIndex, SkWStream* content) {
239 // Select Pattern color space (CS, cs) and set pattern object as current
240 // color (SCN, scn)
241 SkString resourceName = SkPDFResourceDict::getResourceName(
242 SkPDFResourceDict::kPattern_ResourceType,
243 objectIndex);
244 content->writeText("/Pattern CS/Pattern cs/");
245 content->writeText(resourceName.c_str());
246 content->writeText(" SCN/");
247 content->writeText(resourceName.c_str());
248 content->writeText(" scn\n");
249 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698