OLD | NEW |
---|---|
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 between startOffset and endOffset from prevColor to curColor (for each color | 48 between startOffset and endOffset from prevColor to curColor (for each color |
49 component), leaving the result in component order on the stack. It assumes | 49 component), leaving the result in component order on the stack. It assumes |
50 there are always 3 components per color. | 50 there are always 3 components per color. |
51 @param range endOffset - startOffset | 51 @param range endOffset - startOffset |
52 @param curColor[components] The current color components. | 52 @param curColor[components] The current color components. |
53 @param prevColor[components] The previous color components. | 53 @param prevColor[components] The previous color components. |
54 @param result The result ps function. | 54 @param result The result ps function. |
55 */ | 55 */ |
56 static void interpolateColorCode(SkScalar range, SkScalar* curColor, | 56 static void interpolateColorCode(SkScalar range, SkScalar* curColor, |
57 SkScalar* prevColor, SkString* result) { | 57 SkScalar* prevColor, SkString* result) { |
58 if (range == SkIntToScalar(0)) { | |
vandebo (ex-Chrome)
2013/09/12 21:37:05
This should go to a different CL.
You can't just
edisonn
2013/09/17 15:14:23
Done.
| |
59 return; | |
60 } | |
61 | |
58 static const int kColorComponents = 3; | 62 static const int kColorComponents = 3; |
59 | 63 |
60 // Figure out how to scale each color component. | 64 // Figure out how to scale each color component. |
61 SkScalar multiplier[kColorComponents]; | 65 SkScalar multiplier[kColorComponents]; |
62 for (int i = 0; i < kColorComponents; i++) { | 66 for (int i = 0; i < kColorComponents; i++) { |
63 multiplier[i] = SkScalarDiv(curColor[i] - prevColor[i], range); | 67 multiplier[i] = SkScalarDiv(curColor[i] - prevColor[i], range); |
64 } | 68 } |
65 | 69 |
66 // Calculate when we no longer need to keep a copy of the input parameter t. | 70 // Calculate when we no longer need to keep a copy of the input parameter t. |
67 // If the last component to use t is i, then dupInput[0..i - 1] = true | 71 // If the last component to use t is i, then dupInput[0..i - 1] = true |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 ShaderCanonicalEntry entry(shader, NULL); | 575 ShaderCanonicalEntry entry(shader, NULL); |
572 int index = CanonicalShaders().find(entry); | 576 int index = CanonicalShaders().find(entry); |
573 SkASSERT(index >= 0); | 577 SkASSERT(index >= 0); |
574 CanonicalShaders().removeShuffle(index); | 578 CanonicalShaders().removeShuffle(index); |
575 } | 579 } |
576 | 580 |
577 // static | 581 // static |
578 SkPDFObject* SkPDFShader::GetPDFShader(const SkShader& shader, | 582 SkPDFObject* SkPDFShader::GetPDFShader(const SkShader& shader, |
579 const SkMatrix& matrix, | 583 const SkMatrix& matrix, |
580 const SkIRect& surfaceBBox) { | 584 const SkIRect& surfaceBBox) { |
585 if (matrix.hasPerspective() || shader.getLocalMatrix().hasPerspective()) { | |
586 NOT_IMPLEMENTED(true, false); // just report that PDF does not supports perspective | |
587 // TODO(edisonn): update the shape when p ossible | |
588 // or dump in an image otherwise | |
589 return NULL; | |
590 } | |
591 | |
581 SkAutoMutexAcquire lock(CanonicalShadersMutex()); | 592 SkAutoMutexAcquire lock(CanonicalShadersMutex()); |
582 return GetPDFShaderByState( | 593 return GetPDFShaderByState( |
583 SkNEW_ARGS(State, (shader, matrix, surfaceBBox))); | 594 SkNEW_ARGS(State, (shader, matrix, surfaceBBox))); |
584 } | 595 } |
585 | 596 |
586 // static | 597 // static |
587 SkTDArray<SkPDFShader::ShaderCanonicalEntry>& SkPDFShader::CanonicalShaders() { | 598 SkTDArray<SkPDFShader::ShaderCanonicalEntry>& SkPDFShader::CanonicalShaders() { |
588 // This initialization is only thread safe with gcc. | 599 // This initialization is only thread safe with gcc. |
589 static SkTDArray<ShaderCanonicalEntry> gCanonicalShaders; | 600 static SkTDArray<ShaderCanonicalEntry> gCanonicalShaders; |
590 return gCanonicalShaders; | 601 return gCanonicalShaders; |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1210 return false; | 1221 return false; |
1211 } | 1222 } |
1212 | 1223 |
1213 void SkPDFShader::State::AllocateGradientInfoStorage() { | 1224 void SkPDFShader::State::AllocateGradientInfoStorage() { |
1214 fColorData.set(sk_malloc_throw( | 1225 fColorData.set(sk_malloc_throw( |
1215 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); | 1226 fInfo.fColorCount * (sizeof(SkColor) + sizeof(SkScalar)))); |
1216 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); | 1227 fInfo.fColors = reinterpret_cast<SkColor*>(fColorData.get()); |
1217 fInfo.fColorOffsets = | 1228 fInfo.fColorOffsets = |
1218 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); | 1229 reinterpret_cast<SkScalar*>(fInfo.fColors + fInfo.fColorCount); |
1219 } | 1230 } |
OLD | NEW |