| 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 "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
| 10 #include "SkMallocPixelRef.h" | 10 #include "SkMallocPixelRef.h" |
| 11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
| 12 #include "SkPicture.h" | 12 #include "SkPicture.h" |
| 13 #include "SkPictureShader.h" | 13 #include "SkPictureShader.h" |
| 14 #include "SkScalar.h" | 14 #include "SkScalar.h" |
| 15 #include "SkShader.h" | 15 #include "SkShader.h" |
| 16 #include "SkWriteBuffer.h" | 16 #include "SkWriteBuffer.h" |
| 17 | 17 |
| 18 SkShader::SkShader() { | 18 SkShader::SkShader(const SkMatrix* localMatrix) { |
| 19 fLocalMatrix.reset(); | 19 if (localMatrix) { |
| 20 fLocalMatrix = *localMatrix; |
| 21 } else { |
| 22 fLocalMatrix.reset(); |
| 23 } |
| 20 } | 24 } |
| 21 | 25 |
| 22 SkShader::SkShader(SkReadBuffer& buffer) | 26 SkShader::SkShader(SkReadBuffer& buffer) |
| 23 : INHERITED(buffer) { | 27 : INHERITED(buffer) { |
| 24 if (buffer.readBool()) { | 28 if (buffer.readBool()) { |
| 25 buffer.readMatrix(&fLocalMatrix); | 29 buffer.readMatrix(&fLocalMatrix); |
| 26 } else { | 30 } else { |
| 27 fLocalMatrix.reset(); | 31 fLocalMatrix.reset(); |
| 28 } | 32 } |
| 29 } | 33 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 177 } |
| 174 | 178 |
| 175 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { | 179 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { |
| 176 return kNone_GradientType; | 180 return kNone_GradientType; |
| 177 } | 181 } |
| 178 | 182 |
| 179 GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&) const { | 183 GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&) const { |
| 180 return NULL; | 184 return NULL; |
| 181 } | 185 } |
| 182 | 186 |
| 183 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, | 187 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMo
de tmy, |
| 184 TileMode tmx, TileMode tmy) { | 188 const SkMatrix* localMatrix) { |
| 185 return ::CreateBitmapShader(src, tmx, tmy, NULL); | 189 return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL); |
| 186 } | 190 } |
| 187 | 191 |
| 188 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t
my) { | 192 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t
my) { |
| 189 return SkPictureShader::Create(src, tmx, tmy); | 193 return SkPictureShader::Create(src, tmx, tmy); |
| 190 } | 194 } |
| 191 | 195 |
| 196 SkShader* SkShader::CreateLocalMatrixWrapper(SkShader* shader, const SkMatrix& l
ocalMatrix) { |
| 197 if (shader) { |
| 198 return SkLocalMatrixShaderWrapper::Create(shader, localMatrix); |
| 199 } else { |
| 200 return NULL; |
| 201 } |
| 202 } |
| 203 |
| 192 #ifndef SK_IGNORE_TO_STRING | 204 #ifndef SK_IGNORE_TO_STRING |
| 193 void SkShader::toString(SkString* str) const { | 205 void SkShader::toString(SkString* str) const { |
| 194 if (this->hasLocalMatrix()) { | 206 if (this->hasLocalMatrix()) { |
| 195 str->append(" "); | 207 str->append(" "); |
| 196 this->getLocalMatrix().toString(str); | 208 this->getLocalMatrix().toString(str); |
| 197 } | 209 } |
| 198 } | 210 } |
| 199 #endif | 211 #endif |
| 200 | 212 |
| 201 ////////////////////////////////////////////////////////////////////////////// | 213 ////////////////////////////////////////////////////////////////////////////// |
| 202 | 214 |
| 215 SkLocalMatrixShaderWrapper::SkLocalMatrixShaderWrapper(SkShader* shader, |
| 216 const SkMatrix& localMatr
ix) |
| 217 : INHERITED(&localMatrix) |
| 218 , fShader(shader) |
| 219 { |
| 220 SkASSERT(shader); |
| 221 shader->ref(); |
| 222 } |
| 223 |
| 224 SkLocalMatrixShaderWrapper::SkLocalMatrixShaderWrapper(SkReadBuffer& buffer) |
| 225 : INHERITED(buffer) |
| 226 { |
| 227 fShader.reset(buffer.readShader()); |
| 228 } |
| 229 |
| 230 void SkLocalMatrixShaderWrapper::flatten(SkWriteBuffer& buffer) { |
| 231 this->INHERITED::flatten(buffer); |
| 232 buffer.writeFlattenable(fShader); |
| 233 } |
| 234 |
| 235 |
| 236 ////////////////////////////////////////////////////////////////////////////// |
| 237 |
| 203 #include "SkColorShader.h" | 238 #include "SkColorShader.h" |
| 204 #include "SkUtils.h" | 239 #include "SkUtils.h" |
| 205 | 240 |
| 206 SkColorShader::SkColorShader() | 241 SkColorShader::SkColorShader(const SkMatrix* localMatrix) |
| 207 : fColor() | 242 : INHERITED(localMatrix) |
| 243 , fColor() |
| 208 , fInheritColor(true) { | 244 , fInheritColor(true) { |
| 209 } | 245 } |
| 210 | 246 |
| 211 SkColorShader::SkColorShader(SkColor c) | 247 SkColorShader::SkColorShader(SkColor c, const SkMatrix* localMatrix) |
| 212 : fColor(c) | 248 : INHERITED(localMatrix) |
| 249 , fColor(c) |
| 213 , fInheritColor(false) { | 250 , fInheritColor(false) { |
| 214 } | 251 } |
| 215 | 252 |
| 216 bool SkColorShader::isOpaque() const { | 253 bool SkColorShader::isOpaque() const { |
| 217 if (fInheritColor) { | 254 if (fInheritColor) { |
| 218 return true; // using paint's alpha | 255 return true; // using paint's alpha |
| 219 } | 256 } |
| 220 return SkColorGetA(fColor) == 255; | 257 return SkColorGetA(fColor) == 255; |
| 221 } | 258 } |
| 222 | 259 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 #include "SkEmptyShader.h" | 383 #include "SkEmptyShader.h" |
| 347 | 384 |
| 348 void SkEmptyShader::toString(SkString* str) const { | 385 void SkEmptyShader::toString(SkString* str) const { |
| 349 str->append("SkEmptyShader: ("); | 386 str->append("SkEmptyShader: ("); |
| 350 | 387 |
| 351 this->INHERITED::toString(str); | 388 this->INHERITED::toString(str); |
| 352 | 389 |
| 353 str->append(")"); | 390 str->append(")"); |
| 354 } | 391 } |
| 355 #endif | 392 #endif |
| OLD | NEW |