| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SKIA_EXT_CDL_SHADER_H_ |
| 9 #define SKIA_EXT_CDL_SHADER_H_ |
| 10 |
| 11 #include "cdl_common.h" |
| 12 |
| 13 #if CDL_ENABLED |
| 14 |
| 15 #include "third_party/skia/include/core/SkMatrix.h" |
| 16 #include "third_party/skia/include/core/SkRefCnt.h" |
| 17 #include "third_party/skia/include/core/SkShader.h" |
| 18 |
| 19 class CdlPicture; |
| 20 |
| 21 class SK_API CdlShader : public SkRefCnt { |
| 22 public: |
| 23 CdlShader(const SkMatrix* local_matrix = NULL); |
| 24 ~CdlShader() override; |
| 25 |
| 26 static sk_sp<CdlShader> WrapSkShader(sk_sp<SkShader> shader); |
| 27 |
| 28 static sk_sp<CdlShader> MakeImageShader(sk_sp<SkImage>, |
| 29 SkShader::TileMode tx, |
| 30 SkShader::TileMode ty, |
| 31 const SkMatrix* local_matrix); |
| 32 |
| 33 static sk_sp<CdlShader> MakePictureShader(sk_sp<CdlPicture> picture, |
| 34 SkShader::TileMode tmx, |
| 35 SkShader::TileMode tmy, |
| 36 const SkMatrix* local_matrix, |
| 37 const SkRect* tile); |
| 38 |
| 39 const SkMatrix& getLocalMatrix() const { return local_matrix_; } |
| 40 |
| 41 virtual sk_sp<SkShader> createSkShader() = 0; |
| 42 virtual bool isOpaque() const; |
| 43 |
| 44 private: |
| 45 SkMatrix local_matrix_; |
| 46 }; |
| 47 |
| 48 inline SK_API sk_sp<CdlShader> WrapSkShader(sk_sp<SkShader> shader) { |
| 49 return CdlShader::WrapSkShader(shader); |
| 50 } |
| 51 |
| 52 inline SK_API sk_sp<CdlShader> MakeCdlImageShader(sk_sp<SkImage> image, |
| 53 SkShader::TileMode tx, |
| 54 SkShader::TileMode ty, |
| 55 const SkMatrix* local_matrix) { |
| 56 return CdlShader::MakeImageShader(image, tx, ty, local_matrix); |
| 57 } |
| 58 |
| 59 #else // CDL_ENABLED |
| 60 |
| 61 #include "third_party/skia/include/core/SkImage.h" |
| 62 #include "third_party/skia/include/core/SkShader.h" |
| 63 |
| 64 inline SK_API sk_sp<CdlShader> WrapSkShader(sk_sp<SkShader> shader) { |
| 65 return shader; |
| 66 } |
| 67 |
| 68 inline SK_API sk_sp<CdlShader> MakeCdlImageShader(sk_sp<SkImage> image, |
| 69 SkShader::TileMode tx, |
| 70 SkShader::TileMode ty, |
| 71 const SkMatrix* local_matrix) { |
| 72 return image->makeShader(tx, ty, local_matrix); |
| 73 } |
| 74 |
| 75 #endif // CDL_ENABLED |
| 76 |
| 77 #endif // SKIA_EXT_CDL_SHADER_H_ |
| OLD | NEW |