OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkBitmapProcShader.h" | 8 #include "SkBitmapProcShader.h" |
9 #include "SkEmptyShader.h" | 9 #include "SkEmptyShader.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse
) const { | 48 bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse
) const { |
49 const SkMatrix* m = rec.fMatrix; | 49 const SkMatrix* m = rec.fMatrix; |
50 SkMatrix total; | 50 SkMatrix total; |
51 | 51 |
52 if (this->hasLocalMatrix()) { | 52 if (this->hasLocalMatrix()) { |
53 total.setConcat(*m, this->getLocalMatrix()); | 53 total.setConcat(*m, this->getLocalMatrix()); |
54 m = &total; | 54 m = &total; |
55 } | 55 } |
| 56 if (rec.fLocalMatrix) { |
| 57 total.setConcat(*m, *rec.fLocalMatrix); |
| 58 m = &total; |
| 59 } |
56 return m->invert(totalInverse); | 60 return m->invert(totalInverse); |
57 } | 61 } |
58 | 62 |
59 SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage)
const { | 63 SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage)
const { |
60 if (!this->computeTotalInverse(rec, NULL)) { | 64 if (!this->computeTotalInverse(rec, NULL)) { |
61 return NULL; | 65 return NULL; |
62 } | 66 } |
63 return this->onCreateContext(rec, storage); | 67 return this->onCreateContext(rec, storage); |
64 } | 68 } |
65 | 69 |
66 SkShader::Context* SkShader::onCreateContext(const ContextRec&, void*) const { | 70 SkShader::Context* SkShader::onCreateContext(const ContextRec& rec, void*) const
{ |
67 return NULL; | 71 return NULL; |
68 } | 72 } |
69 | 73 |
70 size_t SkShader::contextSize() const { | 74 size_t SkShader::contextSize() const { |
71 return 0; | 75 return 0; |
72 } | 76 } |
73 | 77 |
74 SkShader::Context::Context(const SkShader& shader, const ContextRec& rec) | 78 SkShader::Context::Context(const SkShader& shader, const ContextRec& rec) |
75 : fShader(shader) | 79 : fShader(shader), fCTM(*rec.fMatrix) |
76 { | 80 { |
77 // Because the context parameters must be valid at this point, we know that
the matrix is | 81 // Because the context parameters must be valid at this point, we know that
the matrix is |
78 // invertible. | 82 // invertible. |
79 SkAssertResult(fShader.computeTotalInverse(rec, &fTotalInverse)); | 83 SkAssertResult(fShader.computeTotalInverse(rec, &fTotalInverse)); |
80 fTotalInverseClass = (uint8_t)ComputeMatrixClass(fTotalInverse); | 84 fTotalInverseClass = (uint8_t)ComputeMatrixClass(fTotalInverse); |
81 | 85 |
82 fPaintAlpha = rec.fPaint->getAlpha(); | 86 fPaintAlpha = rec.fPaint->getAlpha(); |
83 } | 87 } |
84 | 88 |
85 SkShader::Context::~Context() {} | 89 SkShader::Context::~Context() {} |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 #include "SkEmptyShader.h" | 337 #include "SkEmptyShader.h" |
334 | 338 |
335 void SkEmptyShader::toString(SkString* str) const { | 339 void SkEmptyShader::toString(SkString* str) const { |
336 str->append("SkEmptyShader: ("); | 340 str->append("SkEmptyShader: ("); |
337 | 341 |
338 this->INHERITED::toString(str); | 342 this->INHERITED::toString(str); |
339 | 343 |
340 str->append(")"); | 344 str->append(")"); |
341 } | 345 } |
342 #endif | 346 #endif |
OLD | NEW |