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 |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 339 |
340 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 340 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
341 /** | 341 /** |
342 * If the shader is a custom shader which has data the caller might want, c
all this function | 342 * If the shader is a custom shader which has data the caller might want, c
all this function |
343 * to get that data. | 343 * to get that data. |
344 */ | 344 */ |
345 virtual bool asACustomShader(void** /* customData */) const { return false;
} | 345 virtual bool asACustomShader(void** /* customData */) const { return false;
} |
346 #endif | 346 #endif |
347 | 347 |
348 ////////////////////////////////////////////////////////////////////////// | 348 ////////////////////////////////////////////////////////////////////////// |
| 349 // Methods to create combinations or variants of shaders |
| 350 |
| 351 /** |
| 352 * Return a shader that will apply the specified localMatrix to this shader
. |
| 353 * The specified matrix will be applied before any matrix associated with t
his shader. |
| 354 */ |
| 355 SkShader* newWithLocalMatrix(const SkMatrix&) const; |
| 356 |
| 357 ////////////////////////////////////////////////////////////////////////// |
349 // Factory methods for stock shaders | 358 // Factory methods for stock shaders |
350 | 359 |
351 /** | 360 /** |
352 * Call this to create a new "empty" shader, that will not draw anything. | 361 * Call this to create a new "empty" shader, that will not draw anything. |
353 */ | 362 */ |
354 static SkShader* CreateEmptyShader(); | 363 static SkShader* CreateEmptyShader(); |
355 | 364 |
356 /** | 365 /** |
357 * Call this to create a new shader that just draws the specified color. Th
is should always | 366 * Call this to create a new shader that just draws the specified color. Th
is should always |
358 * draw the same as a paint with this color (and no shader). | 367 * draw the same as a paint with this color (and no shader). |
359 */ | 368 */ |
360 static SkShader* CreateColorShader(SkColor); | 369 static SkShader* CreateColorShader(SkColor); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 * and cropping). If null, the tile rect is considered equal to
the picture | 401 * and cropping). If null, the tile rect is considered equal to
the picture |
393 * bounds. | 402 * bounds. |
394 * @return Returns a new shader object. Note: this function never retur
ns null. | 403 * @return Returns a new shader object. Note: this function never retur
ns null. |
395 */ | 404 */ |
396 static SkShader* CreatePictureShader(const SkPicture* src, | 405 static SkShader* CreatePictureShader(const SkPicture* src, |
397 TileMode tmx, TileMode tmy, | 406 TileMode tmx, TileMode tmy, |
398 const SkMatrix* localMatrix, | 407 const SkMatrix* localMatrix, |
399 const SkRect* tile); | 408 const SkRect* tile); |
400 | 409 |
401 /** | 410 /** |
402 * Return a shader that will apply the specified localMatrix to the proxy s
hader. | |
403 * The specified matrix will be applied before any matrix associated with t
he proxy. | |
404 * | |
405 * Note: ownership of the proxy is not transferred (though a ref is taken). | |
406 */ | |
407 static SkShader* CreateLocalMatrixShader(SkShader* proxy, const SkMatrix& lo
calMatrix); | |
408 | |
409 /** | |
410 * If this shader can be represented by another shader + a localMatrix, ret
urn that shader | 411 * If this shader can be represented by another shader + a localMatrix, ret
urn that shader |
411 * and, if not NULL, the localMatrix. If not, return NULL and ignore the lo
calMatrix parameter. | 412 * and, if not NULL, the localMatrix. If not, return NULL and ignore the lo
calMatrix parameter. |
412 * | 413 * |
413 * Note: the returned shader (if not NULL) will have been ref'd, and it is
the responsibility | 414 * Note: the returned shader (if not NULL) will have been ref'd, and it is
the responsibility |
414 * of the caller to balance that with unref() when they are done. | 415 * of the caller to balance that with unref() when they are done. |
415 */ | 416 */ |
416 virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const; | 417 virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const; |
417 | 418 |
418 SK_TO_STRING_VIRT() | 419 SK_TO_STRING_VIRT() |
419 SK_DEFINE_FLATTENABLE_TYPE(SkShader) | 420 SK_DEFINE_FLATTENABLE_TYPE(SkShader) |
(...skipping 23 matching lines...) Expand all Loading... |
443 SkMatrix fLocalMatrix; | 444 SkMatrix fLocalMatrix; |
444 | 445 |
445 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 446 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
446 friend class SkLocalMatrixShader; | 447 friend class SkLocalMatrixShader; |
447 friend class SkBitmapProcShader; // for computeTotalInverse() | 448 friend class SkBitmapProcShader; // for computeTotalInverse() |
448 | 449 |
449 typedef SkFlattenable INHERITED; | 450 typedef SkFlattenable INHERITED; |
450 }; | 451 }; |
451 | 452 |
452 #endif | 453 #endif |
OLD | NEW |