| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 fLocalMatrix.reset(); | 53 fLocalMatrix.reset(); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 SkShader::~SkShader() { | 57 SkShader::~SkShader() { |
| 58 dec_shader_counter(); | 58 dec_shader_counter(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void SkShader::flatten(SkWriteBuffer& buffer) const { | 61 void SkShader::flatten(SkWriteBuffer& buffer) const { |
| 62 this->INHERITED::flatten(buffer); | 62 this->INHERITED::flatten(buffer); |
| 63 bool hasLocalM = !fLocalMatrix.isIdentity(); | 63 bool hasLocalM = this->hasLocalMatrix(); |
| 64 buffer.writeBool(hasLocalM); | 64 buffer.writeBool(hasLocalM); |
| 65 if (hasLocalM) { | 65 if (hasLocalM) { |
| 66 buffer.writeMatrix(fLocalMatrix); | 66 buffer.writeMatrix(fLocalMatrix); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse
) const { | 70 bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse
) const { |
| 71 SkMatrix total; | 71 const SkMatrix* m = rec.fMatrix; |
| 72 total.setConcat(*rec.fMatrix, fLocalMatrix); | 72 SkMatrix total; |
| 73 | 73 |
| 74 const SkMatrix* m = &total; | 74 if (this->hasLocalMatrix()) { |
| 75 total.setConcat(*m, this->getLocalMatrix()); |
| 76 m = &total; |
| 77 } |
| 75 if (rec.fLocalMatrix) { | 78 if (rec.fLocalMatrix) { |
| 76 total.setConcat(*m, *rec.fLocalMatrix); | 79 total.setConcat(*m, *rec.fLocalMatrix); |
| 77 m = &total; | 80 m = &total; |
| 78 } | 81 } |
| 79 return m->invert(totalInverse); | 82 return m->invert(totalInverse); |
| 80 } | 83 } |
| 81 | 84 |
| 82 SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage)
const { | 85 SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage)
const { |
| 83 if (!this->computeTotalInverse(rec, NULL)) { | 86 if (!this->computeTotalInverse(rec, NULL)) { |
| 84 return NULL; | 87 return NULL; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL); | 228 return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL); |
| 226 } | 229 } |
| 227 | 230 |
| 228 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t
my, | 231 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t
my, |
| 229 const SkMatrix* localMatrix) { | 232 const SkMatrix* localMatrix) { |
| 230 return SkPictureShader::Create(src, tmx, tmy, localMatrix); | 233 return SkPictureShader::Create(src, tmx, tmy, localMatrix); |
| 231 } | 234 } |
| 232 | 235 |
| 233 #ifndef SK_IGNORE_TO_STRING | 236 #ifndef SK_IGNORE_TO_STRING |
| 234 void SkShader::toString(SkString* str) const { | 237 void SkShader::toString(SkString* str) const { |
| 235 if (!fLocalMatrix.isIdentity()) { | 238 if (this->hasLocalMatrix()) { |
| 236 str->append(" "); | 239 str->append(" "); |
| 237 fLocalMatrix.toString(str); | 240 this->getLocalMatrix().toString(str); |
| 238 } | 241 } |
| 239 } | 242 } |
| 240 #endif | 243 #endif |
| 241 | 244 |
| 242 ////////////////////////////////////////////////////////////////////////////// | 245 ////////////////////////////////////////////////////////////////////////////// |
| 243 | 246 |
| 244 #include "SkColorShader.h" | 247 #include "SkColorShader.h" |
| 245 #include "SkUtils.h" | 248 #include "SkUtils.h" |
| 246 | 249 |
| 247 SkColorShader::SkColorShader(SkColor c) | 250 SkColorShader::SkColorShader(SkColor c) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 #include "SkEmptyShader.h" | 363 #include "SkEmptyShader.h" |
| 361 | 364 |
| 362 void SkEmptyShader::toString(SkString* str) const { | 365 void SkEmptyShader::toString(SkString* str) const { |
| 363 str->append("SkEmptyShader: ("); | 366 str->append("SkEmptyShader: ("); |
| 364 | 367 |
| 365 this->INHERITED::toString(str); | 368 this->INHERITED::toString(str); |
| 366 | 369 |
| 367 str->append(")"); | 370 str->append(")"); |
| 368 } | 371 } |
| 369 #endif | 372 #endif |
| OLD | NEW |