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

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

Issue 13471011: Fix build error when building Android in Release mode with -O2. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 8 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 | « no previous file | 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 "SkPDFShader.h" 10 #include "SkPDFShader.h"
(...skipping 25 matching lines...) Expand all
36 SkScalar inv = mag ? SkScalarInvert(mag) : 0; 36 SkScalar inv = mag ? SkScalarInvert(mag) : 0;
37 37
38 vec.scale(inv); 38 vec.scale(inv);
39 matrix->setSinCos(vec.fY, vec.fX); 39 matrix->setSinCos(vec.fY, vec.fX);
40 matrix->preTranslate(pts[0].fX, pts[0].fY); 40 matrix->preTranslate(pts[0].fX, pts[0].fY);
41 matrix->preScale(mag, mag); 41 matrix->preScale(mag, mag);
42 } 42 }
43 43
44 /* Assumes t + startOffset is on the stack and does a linear interpolation on t 44 /* Assumes t + startOffset is on the stack and does a linear interpolation on t
45 between startOffset and endOffset from prevColor to curColor (for each color 45 between startOffset and endOffset from prevColor to curColor (for each color
46 component), leaving the result in component order on the stack. 46 component), leaving the result in component order on the stack. It assumes
47 there are always 3 components per color.
47 @param range endOffset - startOffset 48 @param range endOffset - startOffset
48 @param curColor[components] The current color components. 49 @param curColor[components] The current color components.
49 @param prevColor[components] The previous color components. 50 @param prevColor[components] The previous color components.
50 @param result The result ps function. 51 @param result The result ps function.
51 */ 52 */
52 static void interpolateColorCode(SkScalar range, SkScalar* curColor, 53 static void interpolateColorCode(SkScalar range, SkScalar* curColor,
53 SkScalar* prevColor, int components, 54 SkScalar* prevColor, SkString* result) {
54 SkString* result) { 55 static const int kColorComponents = 3;
56
55 // Figure out how to scale each color component. 57 // Figure out how to scale each color component.
56 SkAutoSTMalloc<4, SkScalar> multiplierAlloc(components); 58 SkScalar multiplier[kColorComponents];
57 SkScalar *multiplier = multiplierAlloc.get(); 59 for (int i = 0; i < kColorComponents; i++) {
58 for (int i = 0; i < components; i++) {
59 multiplier[i] = SkScalarDiv(curColor[i] - prevColor[i], range); 60 multiplier[i] = SkScalarDiv(curColor[i] - prevColor[i], range);
60 } 61 }
61 62
62 // Calculate when we no longer need to keep a copy of the input parameter t. 63 // Calculate when we no longer need to keep a copy of the input parameter t.
63 // If the last component to use t is i, then dupInput[0..i - 1] = true 64 // If the last component to use t is i, then dupInput[0..i - 1] = true
64 // and dupInput[i .. components] = false. 65 // and dupInput[i .. components] = false.
65 SkAutoSTMalloc<4, bool> dupInputAlloc(components); 66 bool dupInput[kColorComponents];
66 bool *dupInput = dupInputAlloc.get(); 67 dupInput[kColorComponents - 1] = false;
67 dupInput[components - 1] = false; 68 for (int i = kColorComponents - 2; i >= 0; i--) {
68 for (int i = components - 2; i >= 0; i--) {
69 dupInput[i] = dupInput[i + 1] || multiplier[i + 1] != 0; 69 dupInput[i] = dupInput[i + 1] || multiplier[i + 1] != 0;
70 } 70 }
71 71
72 if (!dupInput[0] && multiplier[0] == 0) { 72 if (!dupInput[0] && multiplier[0] == 0) {
73 result->append("pop "); 73 result->append("pop ");
74 } 74 }
75 75
76 for (int i = 0; i < components; i++) { 76 for (int i = 0; i < kColorComponents; i++) {
77 // If the next components needs t and this component will consume a 77 // If the next components needs t and this component will consume a
78 // copy, make another copy. 78 // copy, make another copy.
79 if (dupInput[i] && multiplier[i] != 0) { 79 if (dupInput[i] && multiplier[i] != 0) {
80 result->append("dup "); 80 result->append("dup ");
81 } 81 }
82 82
83 if (multiplier[i] == 0) { 83 if (multiplier[i] == 0) {
84 result->appendScalar(prevColor[i]); 84 result->appendScalar(prevColor[i]);
85 result->append(" "); 85 result->append(" ");
86 } else { 86 } else {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 for (int i = 1 ; i < info.fColorCount; i++) { 152 for (int i = 1 ; i < info.fColorCount; i++) {
153 result->append("{dup "); 153 result->append("{dup ");
154 result->appendScalar(info.fColorOffsets[i]); 154 result->appendScalar(info.fColorOffsets[i]);
155 result->append(" le {"); 155 result->append(" le {");
156 if (info.fColorOffsets[i - 1] != 0) { 156 if (info.fColorOffsets[i - 1] != 0) {
157 result->appendScalar(info.fColorOffsets[i - 1]); 157 result->appendScalar(info.fColorOffsets[i - 1]);
158 result->append(" sub\n"); 158 result->append(" sub\n");
159 } 159 }
160 160
161 interpolateColorCode(info.fColorOffsets[i] - info.fColorOffsets[i - 1], 161 interpolateColorCode(info.fColorOffsets[i] - info.fColorOffsets[i - 1],
162 colorData[i], colorData[i - 1], kColorComponents, 162 colorData[i], colorData[i - 1], result);
163 result);
164 result->append("}\n"); 163 result->append("}\n");
165 } 164 }
166 165
167 // Clamp the final color. 166 // Clamp the final color.
168 result->append("{pop "); 167 result->append("{pop ");
169 result->appendScalar(colorData[info.fColorCount - 1][0]); 168 result->appendScalar(colorData[info.fColorCount - 1][0]);
170 result->append(" "); 169 result->append(" ");
171 result->appendScalar(colorData[info.fColorCount - 1][1]); 170 result->appendScalar(colorData[info.fColorCount - 1][1]);
172 result->append(" "); 171 result->append(" ");
173 result->appendScalar(colorData[info.fColorCount - 1][2]); 172 result->appendScalar(colorData[info.fColorCount - 1][2]);
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 fPixelGeneration = fImage.getGenerationID(); 954 fPixelGeneration = fImage.getGenerationID();
956 } else { 955 } else {
957 fColorData.set(sk_malloc_throw( 956 fColorData.set(sk_malloc_throw(
958 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); 957 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar))));
959 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); 958 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get());
960 fInfo.fColorOffsets = 959 fInfo.fColorOffsets =
961 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); 960 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount);
962 shader.asAGradient(&fInfo); 961 shader.asAGradient(&fInfo);
963 } 962 }
964 } 963 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698