reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 SkImageShader_DEFINED |
| 9 | #define SkImageShader_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkImage.h" |
| 12 | #include "src/shaders/SkBitmapProcShader.h" |
| 13 | #include "src/shaders/SkShaderBase.h" |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 14 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 15 | class SkImageShader : public SkShaderBase { |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 16 | public: |
Mike Klein | 1f31309 | 2018-01-03 10:30:21 -0500 | [diff] [blame] | 17 | static sk_sp<SkShader> Make(sk_sp<SkImage>, |
Mike Reed | e25b447 | 2019-04-02 17:49:12 -0400 | [diff] [blame] | 18 | SkTileMode tmx, |
| 19 | SkTileMode tmy, |
Mike Klein | 1f31309 | 2018-01-03 10:30:21 -0500 | [diff] [blame] | 20 | const SkMatrix* localMatrix, |
| 21 | bool clampAsIfUnpremul = false); |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 22 | |
| 23 | bool isOpaque() const override; |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 24 | |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 25 | #if SK_SUPPORT_GPU |
Mike Reed | e3429e6 | 2018-01-19 11:43:34 -0500 | [diff] [blame] | 26 | std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override; |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 27 | #endif |
| 28 | |
Mike Klein | 1f31309 | 2018-01-03 10:30:21 -0500 | [diff] [blame] | 29 | private: |
Mike Klein | 4fee323 | 2018-10-18 17:27:16 -0400 | [diff] [blame] | 30 | SK_FLATTENABLE_HOOKS(SkImageShader) |
| 31 | |
Mike Klein | 1f31309 | 2018-01-03 10:30:21 -0500 | [diff] [blame] | 32 | SkImageShader(sk_sp<SkImage>, |
Mike Reed | e25b447 | 2019-04-02 17:49:12 -0400 | [diff] [blame] | 33 | SkTileMode tmx, |
| 34 | SkTileMode tmy, |
Mike Klein | 1f31309 | 2018-01-03 10:30:21 -0500 | [diff] [blame] | 35 | const SkMatrix* localMatrix, |
| 36 | bool clampAsIfUnpremul); |
| 37 | |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 38 | void flatten(SkWriteBuffer&) const override; |
Mike Reed | e92aae6 | 2018-10-17 10:21:51 -0400 | [diff] [blame] | 39 | #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT |
Herb Derby | 83e939b | 2017-02-07 14:25:11 -0500 | [diff] [blame] | 40 | Context* onMakeContext(const ContextRec&, SkArenaAlloc* storage) const override; |
Mike Reed | e92aae6 | 2018-10-17 10:21:51 -0400 | [diff] [blame] | 41 | #endif |
Mike Reed | fae8fce | 2019-04-03 10:27:45 -0400 | [diff] [blame] | 42 | SkImage* onIsAImage(SkMatrix*, SkTileMode*) const override; |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 43 | |
Mike Reed | 1386b2d | 2019-03-13 21:15:05 -0400 | [diff] [blame] | 44 | bool onAppendStages(const SkStageRec&) const override; |
Mike Klein | 06a65e2 | 2016-11-17 12:39:09 -0500 | [diff] [blame] | 45 | |
Mike Reed | fae8fce | 2019-04-03 10:27:45 -0400 | [diff] [blame] | 46 | sk_sp<SkImage> fImage; |
| 47 | const SkTileMode fTileModeX; |
| 48 | const SkTileMode fTileModeY; |
| 49 | const bool fClampAsIfUnpremul; |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 50 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 51 | friend class SkShaderBase; |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 52 | typedef SkShaderBase INHERITED; |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | #endif |