| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 virtual bool asACustomShader(void** /* customData */) const { return false;
} | 316 virtual bool asACustomShader(void** /* customData */) const { return false;
} |
| 317 #endif | 317 #endif |
| 318 | 318 |
| 319 ////////////////////////////////////////////////////////////////////////// | 319 ////////////////////////////////////////////////////////////////////////// |
| 320 // Methods to create combinations or variants of shaders | 320 // Methods to create combinations or variants of shaders |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * Return a shader that will apply the specified localMatrix to this shader
. | 323 * Return a shader that will apply the specified localMatrix to this shader
. |
| 324 * The specified matrix will be applied before any matrix associated with t
his shader. | 324 * The specified matrix will be applied before any matrix associated with t
his shader. |
| 325 */ | 325 */ |
| 326 SkShader* newWithLocalMatrix(const SkMatrix&) const; | 326 sk_sp<SkShader> makeWithLocalMatrix(const SkMatrix&) const; |
| 327 | 327 |
| 328 /** | 328 /** |
| 329 * Create a new shader that produces the same colors as invoking this shade
r and then applying | 329 * Create a new shader that produces the same colors as invoking this shade
r and then applying |
| 330 * the colorfilter. | 330 * the colorfilter. |
| 331 */ | 331 */ |
| 332 SkShader* newWithColorFilter(SkColorFilter*) const; | 332 sk_sp<SkShader> makeWithColorFilter(SkColorFilter*) const; |
| 333 | 333 |
| 334 ////////////////////////////////////////////////////////////////////////// | 334 ////////////////////////////////////////////////////////////////////////// |
| 335 // Factory methods for stock shaders | 335 // Factory methods for stock shaders |
| 336 | 336 |
| 337 /** | 337 /** |
| 338 * Call this to create a new "empty" shader, that will not draw anything. | 338 * Call this to create a new "empty" shader, that will not draw anything. |
| 339 */ | 339 */ |
| 340 static sk_sp<SkShader> MakeEmptyShader(); | 340 static sk_sp<SkShader> MakeEmptyShader(); |
| 341 | 341 |
| 342 /** | 342 /** |
| 343 * Call this to create a new shader that just draws the specified color. Th
is should always | 343 * Call this to create a new shader that just draws the specified color. Th
is should always |
| 344 * draw the same as a paint with this color (and no shader). | 344 * draw the same as a paint with this color (and no shader). |
| 345 */ | 345 */ |
| 346 static sk_sp<SkShader> MakeColorShader(SkColor); | 346 static sk_sp<SkShader> MakeColorShader(SkColor); |
| 347 | 347 |
| 348 static sk_sp<SkShader> MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader
> src, | 348 static sk_sp<SkShader> MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader
> src, |
| 349 SkXfermode::Mode); | 349 SkXfermode::Mode); |
| 350 | 350 |
| 351 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR | 351 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR |
| 352 static SkShader* CreateEmptyShader() { return MakeEmptyShader().release(); } | 352 static SkShader* CreateEmptyShader() { return MakeEmptyShader().release(); } |
| 353 static SkShader* CreateColorShader(SkColor c) { return MakeColorShader(c).re
lease(); } | 353 static SkShader* CreateColorShader(SkColor c) { return MakeColorShader(c).re
lease(); } |
| 354 static SkShader* CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileM
ode tmy, | 354 static SkShader* CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileM
ode tmy, |
| 355 const SkMatrix* localMatrix = nullptr) { | 355 const SkMatrix* localMatrix = nullptr) { |
| 356 return MakeBitmapShader(src, tmx, tmy, localMatrix).release(); | 356 return MakeBitmapShader(src, tmx, tmy, localMatrix).release(); |
| 357 } | 357 } |
| 358 static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermod
e::Mode mode); | 358 static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermod
e::Mode mode); |
| 359 static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermod
e* xfer); | 359 static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermod
e* xfer); |
| 360 static SkShader* CreatePictureShader(const SkPicture* src, TileMode tmx, Til
eMode tmy, | 360 static SkShader* CreatePictureShader(const SkPicture* src, TileMode tmx, Til
eMode tmy, |
| 361 const SkMatrix* localMatrix, const SkRe
ct* tile); | 361 const SkMatrix* localMatrix, const SkRe
ct* tile); |
| 362 |
| 363 SkShader* newWithLocalMatrix(const SkMatrix& matrix) const { |
| 364 return this->makeWithLocalMatrix(matrix).release(); |
| 365 } |
| 366 SkShader* newWithColorFilter(SkColorFilter* filter) const { |
| 367 return this->makeWithColorFilter(filter).release(); |
| 368 } |
| 362 #endif | 369 #endif |
| 363 | 370 |
| 364 /** | 371 /** |
| 365 * Create a new compose shader, given shaders dst, src, and a combining xfe
rmode mode. | 372 * Create a new compose shader, given shaders dst, src, and a combining xfe
rmode mode. |
| 366 * The xfermode is called with the output of the two shaders, and its outpu
t is returned. | 373 * The xfermode is called with the output of the two shaders, and its outpu
t is returned. |
| 367 * If xfer is null, SkXfermode::kSrcOver_Mode is assumed. | 374 * If xfer is null, SkXfermode::kSrcOver_Mode is assumed. |
| 368 * | 375 * |
| 369 * The caller is responsible for managing its reference-count for the xfer
(if not null). | 376 * The caller is responsible for managing its reference-count for the xfer
(if not null). |
| 370 */ | 377 */ |
| 371 static sk_sp<SkShader> MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader
> src, | 378 static sk_sp<SkShader> MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader
> src, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 SkMatrix fLocalMatrix; | 457 SkMatrix fLocalMatrix; |
| 451 | 458 |
| 452 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. | 459 // So the SkLocalMatrixShader can whack fLocalMatrix in its SkReadBuffer con
structor. |
| 453 friend class SkLocalMatrixShader; | 460 friend class SkLocalMatrixShader; |
| 454 friend class SkBitmapProcShader; // for computeTotalInverse() | 461 friend class SkBitmapProcShader; // for computeTotalInverse() |
| 455 | 462 |
| 456 typedef SkFlattenable INHERITED; | 463 typedef SkFlattenable INHERITED; |
| 457 }; | 464 }; |
| 458 | 465 |
| 459 #endif | 466 #endif |
| OLD | NEW |