| 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 #ifndef SkShader_DEFINED | 8 #ifndef SkShader_DEFINED |
| 9 #define SkShader_DEFINED | 9 #define SkShader_DEFINED |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkFlattenable.h" | 12 #include "SkFlattenable.h" |
| 13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
| 14 #include "SkMask.h" | 14 #include "SkMask.h" |
| 15 #include "SkMatrix.h" | 15 #include "SkMatrix.h" |
| 16 #include "SkPaint.h" | 16 #include "SkPaint.h" |
| 17 #include "../gpu/GrColor.h" | 17 #include "../gpu/GrColor.h" |
| 18 | 18 |
| 19 class SkColorFilter; | 19 class SkColorFilter; |
| 20 class SkColorSpace; | 20 class SkColorSpace; |
| 21 class SkImage; |
| 21 class SkPath; | 22 class SkPath; |
| 22 class SkPicture; | 23 class SkPicture; |
| 23 class SkXfermode; | 24 class SkXfermode; |
| 24 class GrContext; | 25 class GrContext; |
| 25 class GrFragmentProcessor; | 26 class GrFragmentProcessor; |
| 26 | 27 |
| 27 /** \class SkShader | 28 /** \class SkShader |
| 28 * | 29 * |
| 29 * Shaders specify the source color(s) for what is being drawn. If a paint | 30 * Shaders specify the source color(s) for what is being drawn. If a paint |
| 30 * has no shader, then the paint's color is used. If the paint has a | 31 * has no shader, then the paint's color is used. If the paint has a |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 */ | 236 */ |
| 236 bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) co
nst { | 237 bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) co
nst { |
| 237 return this->onIsABitmap(outTexture, outMatrix, xy); | 238 return this->onIsABitmap(outTexture, outMatrix, xy); |
| 238 } | 239 } |
| 239 | 240 |
| 240 bool isABitmap() const { | 241 bool isABitmap() const { |
| 241 return this->isABitmap(nullptr, nullptr, nullptr); | 242 return this->isABitmap(nullptr, nullptr, nullptr); |
| 242 } | 243 } |
| 243 | 244 |
| 244 /** | 245 /** |
| 246 * Iff this shader is backed by a single SkImage, return its ptr (the calle
r must ref this |
| 247 * if they want to keep it longer than the lifetime of the shader). If not,
return nullptr. |
| 248 */ |
| 249 SkImage* isAImage(SkMatrix* localMatrix, TileMode xy[2]) const { |
| 250 return this->onIsAImage(localMatrix, xy); |
| 251 } |
| 252 |
| 253 bool isAImage() const { |
| 254 return this->isAImage(nullptr, nullptr) != nullptr; |
| 255 } |
| 256 |
| 257 /** |
| 245 * If the shader subclass can be represented as a gradient, asAGradient | 258 * If the shader subclass can be represented as a gradient, asAGradient |
| 246 * returns the matching GradientType enum (or kNone_GradientType if it | 259 * returns the matching GradientType enum (or kNone_GradientType if it |
| 247 * cannot). Also, if info is not null, asAGradient populates info with | 260 * cannot). Also, if info is not null, asAGradient populates info with |
| 248 * the relevant (see below) parameters for the gradient. fColorCount | 261 * the relevant (see below) parameters for the gradient. fColorCount |
| 249 * is both an input and output parameter. On input, it indicates how | 262 * is both an input and output parameter. On input, it indicates how |
| 250 * many entries in fColors and fColorOffsets can be used, if they are | 263 * many entries in fColors and fColorOffsets can be used, if they are |
| 251 * non-NULL. After asAGradient has run, fColorCount indicates how | 264 * non-NULL. After asAGradient has run, fColorCount indicates how |
| 252 * many color-offset pairs there are in the gradient. If there is | 265 * many color-offset pairs there are in the gradient. If there is |
| 253 * insufficient space to store all of the color-offset pairs, fColors | 266 * insufficient space to store all of the color-offset pairs, fColors |
| 254 * and fColorOffsets will not be altered. fColorOffsets specifies | 267 * and fColorOffsets will not be altered. fColorOffsets specifies |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 virtual size_t onContextSize(const ContextRec&) const; | 518 virtual size_t onContextSize(const ContextRec&) const; |
| 506 | 519 |
| 507 virtual bool onAsLuminanceColor(SkColor*) const { | 520 virtual bool onAsLuminanceColor(SkColor*) const { |
| 508 return false; | 521 return false; |
| 509 } | 522 } |
| 510 | 523 |
| 511 virtual bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode[2]) const { | 524 virtual bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode[2]) const { |
| 512 return false; | 525 return false; |
| 513 } | 526 } |
| 514 | 527 |
| 528 virtual SkImage* onIsAImage(SkMatrix*, TileMode[2]) const { |
| 529 return nullptr; |
| 530 } |
| 531 |
| 515 private: | 532 private: |
| 516 // This is essentially const, but not officially so it can be modified in | 533 // This is essentially const, but not officially so it can be modified in |
| 517 // constructors. | 534 // constructors. |
| 518 SkMatrix fLocalMatrix; | 535 SkMatrix fLocalMatrix; |
| 519 | 536 |
| 520 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 537 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
| 521 friend class SkLocalMatrixShader; | 538 friend class SkLocalMatrixShader; |
| 522 friend class SkBitmapProcShader; // for computeTotalInverse() | 539 friend class SkBitmapProcShader; // for computeTotalInverse() |
| 523 | 540 |
| 524 typedef SkFlattenable INHERITED; | 541 typedef SkFlattenable INHERITED; |
| 525 }; | 542 }; |
| 526 | 543 |
| 527 #endif | 544 #endif |
| OLD | NEW |