| 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 | 8 |
| 9 #ifndef SkShader_DEFINED | 9 #ifndef SkShader_DEFINED |
| 10 #define SkShader_DEFINED | 10 #define SkShader_DEFINED |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 * the paint. | 338 * the paint. |
| 339 * | 339 * |
| 340 * @param src The bitmap to use inside the shader | 340 * @param src The bitmap to use inside the shader |
| 341 * @param tmx The tiling mode to use when sampling the bitmap in the x-dir
ection. | 341 * @param tmx The tiling mode to use when sampling the bitmap in the x-dir
ection. |
| 342 * @param tmy The tiling mode to use when sampling the bitmap in the y-dir
ection. | 342 * @param tmy The tiling mode to use when sampling the bitmap in the y-dir
ection. |
| 343 * @return Returns a new shader object. Note: this function never retur
ns null. | 343 * @return Returns a new shader object. Note: this function never retur
ns null. |
| 344 */ | 344 */ |
| 345 static SkShader* CreateBitmapShader(const SkBitmap& src, | 345 static SkShader* CreateBitmapShader(const SkBitmap& src, |
| 346 TileMode tmx, TileMode tmy); | 346 TileMode tmx, TileMode tmy); |
| 347 | 347 |
| 348 SkDEVCODE(virtual void toString(SkString* str) const;) | 348 SK_TO_STRING_VIRT() |
| 349 | |
| 350 SK_DEFINE_FLATTENABLE_TYPE(SkShader) | 349 SK_DEFINE_FLATTENABLE_TYPE(SkShader) |
| 351 | 350 |
| 352 protected: | 351 protected: |
| 353 enum MatrixClass { | 352 enum MatrixClass { |
| 354 kLinear_MatrixClass, // no perspective | 353 kLinear_MatrixClass, // no perspective |
| 355 kFixedStepInX_MatrixClass, // fast perspective, need to call fixedS
tepInX() each scanline | 354 kFixedStepInX_MatrixClass, // fast perspective, need to call fixedS
tepInX() each scanline |
| 356 kPerspective_MatrixClass // slow perspective, need to mappoints e
ach pixel | 355 kPerspective_MatrixClass // slow perspective, need to mappoints e
ach pixel |
| 357 }; | 356 }; |
| 358 static MatrixClass ComputeMatrixClass(const SkMatrix&); | 357 static MatrixClass ComputeMatrixClass(const SkMatrix&); |
| 359 | 358 |
| 360 // These can be called by your subclass after setContext() has been called | 359 // These can be called by your subclass after setContext() has been called |
| 361 uint8_t getPaintAlpha() const { return fPaintAlpha; } | 360 uint8_t getPaintAlpha() const { return fPaintAlpha; } |
| 362 const SkMatrix& getTotalInverse() const { return fTotalInverse; } | 361 const SkMatrix& getTotalInverse() const { return fTotalInverse; } |
| 363 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve
rseClass; } | 362 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve
rseClass; } |
| 364 | 363 |
| 365 SkShader(SkReadBuffer& ); | 364 SkShader(SkReadBuffer& ); |
| 366 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 365 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 367 private: | 366 private: |
| 368 SkMatrix fLocalMatrix; | 367 SkMatrix fLocalMatrix; |
| 369 SkMatrix fTotalInverse; | 368 SkMatrix fTotalInverse; |
| 370 uint8_t fPaintAlpha; | 369 uint8_t fPaintAlpha; |
| 371 uint8_t fTotalInverseClass; | 370 uint8_t fTotalInverseClass; |
| 372 SkDEBUGCODE(SkBool8 fInSetContext;) | 371 SkDEBUGCODE(SkBool8 fInSetContext;) |
| 373 | 372 |
| 374 typedef SkFlattenable INHERITED; | 373 typedef SkFlattenable INHERITED; |
| 375 }; | 374 }; |
| 376 | 375 |
| 377 #endif | 376 #endif |
| OLD | NEW |