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 |
11 | 11 |
12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
13 #include "SkFlattenable.h" | 13 #include "SkFlattenable.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 | 17 |
18 class SkPath; | 18 class SkPath; |
19 class SkPicture; | |
19 class GrContext; | 20 class GrContext; |
20 class GrEffectRef; | 21 class GrEffectRef; |
21 | 22 |
22 /** \class SkShader | 23 /** \class SkShader |
23 * | 24 * |
24 * Shaders specify the source color(s) for what is being drawn. If a paint | 25 * Shaders specify the source color(s) for what is being drawn. If a paint |
25 * has no shader, then the paint's color is used. If the paint has a | 26 * has no shader, then the paint's color is used. If the paint has a |
26 * shader, then the shader's color(s) are use instead, but they are | 27 * shader, then the shader's color(s) are use instead, but they are |
27 * modulated by the paint's alpha. This makes it easy to create a shader | 28 * modulated by the paint's alpha. This makes it easy to create a shader |
28 * once (e.g. bitmap tiling or gradient) and then change its transparency | 29 * once (e.g. bitmap tiling or gradient) and then change its transparency |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 * the paint. | 339 * the paint. |
339 * | 340 * |
340 * @param src The bitmap to use inside the shader | 341 * @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. | 342 * @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. | 343 * @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. | 344 * @return Returns a new shader object. Note: this function never retur ns null. |
344 */ | 345 */ |
345 static SkShader* CreateBitmapShader(const SkBitmap& src, | 346 static SkShader* CreateBitmapShader(const SkBitmap& src, |
346 TileMode tmx, TileMode tmy); | 347 TileMode tmx, TileMode tmy); |
347 | 348 |
349 /** Call this to create a new shader that will draw with the specified pictu re. | |
350 * | |
351 * @param src The picture to use inside the shader (if not NULL, its ref c ount | |
scroggo
2014/04/11 15:23:15
Is it part of the intended use case to allow the c
f(malita)
2014/04/11 16:05:18
The intent is to treat the picture (playback) as i
| |
352 * is incremented). | |
353 * @param tmx The tiling mode to use when sampling the bitmap in the x-dir ection. | |
354 * @param tmy The tiling mode to use when sampling the bitmap in the y-dir ection. | |
355 * @return Returns a new shader object. Note: this function never retur ns null. | |
356 */ | |
357 static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy); | |
358 | |
348 SK_TO_STRING_VIRT() | 359 SK_TO_STRING_VIRT() |
349 SK_DEFINE_FLATTENABLE_TYPE(SkShader) | 360 SK_DEFINE_FLATTENABLE_TYPE(SkShader) |
350 | 361 |
351 protected: | 362 protected: |
352 enum MatrixClass { | 363 enum MatrixClass { |
353 kLinear_MatrixClass, // no perspective | 364 kLinear_MatrixClass, // no perspective |
354 kFixedStepInX_MatrixClass, // fast perspective, need to call fixedS tepInX() each scanline | 365 kFixedStepInX_MatrixClass, // fast perspective, need to call fixedS tepInX() each scanline |
355 kPerspective_MatrixClass // slow perspective, need to mappoints e ach pixel | 366 kPerspective_MatrixClass // slow perspective, need to mappoints e ach pixel |
356 }; | 367 }; |
357 static MatrixClass ComputeMatrixClass(const SkMatrix&); | 368 static MatrixClass ComputeMatrixClass(const SkMatrix&); |
358 | 369 |
359 // These can be called by your subclass after setContext() has been called | 370 // These can be called by your subclass after setContext() has been called |
360 uint8_t getPaintAlpha() const { return fPaintAlpha; } | 371 uint8_t getPaintAlpha() const { return fPaintAlpha; } |
361 const SkMatrix& getTotalInverse() const { return fTotalInverse; } | 372 const SkMatrix& getTotalInverse() const { return fTotalInverse; } |
362 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; } | 373 MatrixClass getInverseClass() const { return (MatrixClass)fTotalInve rseClass; } |
363 | 374 |
364 SkShader(SkReadBuffer& ); | 375 SkShader(SkReadBuffer& ); |
365 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 376 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
366 private: | 377 private: |
367 SkMatrix fLocalMatrix; | 378 SkMatrix fLocalMatrix; |
368 SkMatrix fTotalInverse; | 379 SkMatrix fTotalInverse; |
369 uint8_t fPaintAlpha; | 380 uint8_t fPaintAlpha; |
370 uint8_t fTotalInverseClass; | 381 uint8_t fTotalInverseClass; |
371 SkDEBUGCODE(SkBool8 fInSetContext;) | 382 SkDEBUGCODE(SkBool8 fInSetContext;) |
372 | 383 |
373 typedef SkFlattenable INHERITED; | 384 typedef SkFlattenable INHERITED; |
374 }; | 385 }; |
375 | 386 |
376 #endif | 387 #endif |
OLD | NEW |