rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 SkGradientShaderPriv_DEFINED |
| 9 | #define SkGradientShaderPriv_DEFINED |
| 10 | |
reed | a6cac4c | 2014-08-21 10:50:25 -0700 | [diff] [blame] | 11 | #include "SkGradientBitmapCache.h" |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 12 | #include "SkGradientShader.h" |
Hal Canary | 95e3c05 | 2017-01-11 12:44:43 -0500 | [diff] [blame] | 13 | |
Herb Derby | 83e939b | 2017-02-07 14:25:11 -0500 | [diff] [blame] | 14 | #include "SkArenaAlloc.h" |
Hal Canary | 95e3c05 | 2017-01-11 12:44:43 -0500 | [diff] [blame] | 15 | #include "SkAutoMalloc.h" |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 16 | #include "SkClampRange.h" |
Cary Clark | a4083c9 | 2017-09-15 11:59:23 -0400 | [diff] [blame] | 17 | #include "SkColorData.h" |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 18 | #include "SkColorSpace.h" |
Cary Clark | 9480d82 | 2017-10-19 18:01:13 -0400 | [diff] [blame] | 19 | #include "SkMatrixPriv.h" |
Kevin Lubick | c456b73 | 2017-01-11 17:21:57 +0000 | [diff] [blame] | 20 | #include "SkOnce.h" |
Mike Klein | a377184 | 2017-05-04 19:38:48 -0400 | [diff] [blame] | 21 | #include "SkPM4fPriv.h" |
| 22 | #include "SkRasterPipeline.h" |
Hal Canary | 95e3c05 | 2017-01-11 12:44:43 -0500 | [diff] [blame] | 23 | #include "SkReadBuffer.h" |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 24 | #include "SkShaderBase.h" |
Hal Canary | 95e3c05 | 2017-01-11 12:44:43 -0500 | [diff] [blame] | 25 | #include "SkUtils.h" |
| 26 | #include "SkWriteBuffer.h" |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 27 | |
humper@google.com | 05af1af | 2013-01-07 16:47:43 +0000 | [diff] [blame] | 28 | static inline void sk_memset32_dither(uint32_t dst[], uint32_t v0, uint32_t v1, |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 29 | int count) { |
| 30 | if (count > 0) { |
| 31 | if (v0 == v1) { |
| 32 | sk_memset32(dst, v0, count); |
| 33 | } else { |
| 34 | int pairs = count >> 1; |
| 35 | for (int i = 0; i < pairs; i++) { |
| 36 | *dst++ = v0; |
| 37 | *dst++ = v1; |
| 38 | } |
| 39 | if (count & 1) { |
| 40 | *dst = v0; |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // Clamp |
| 47 | |
humper@google.com | 05af1af | 2013-01-07 16:47:43 +0000 | [diff] [blame] | 48 | static inline SkFixed clamp_tileproc(SkFixed x) { |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 49 | return SkClampMax(x, 0xFFFF); |
| 50 | } |
| 51 | |
| 52 | // Repeat |
| 53 | |
humper@google.com | 05af1af | 2013-01-07 16:47:43 +0000 | [diff] [blame] | 54 | static inline SkFixed repeat_tileproc(SkFixed x) { |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 55 | return x & 0xFFFF; |
| 56 | } |
| 57 | |
| 58 | // Mirror |
| 59 | |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 60 | static inline SkFixed mirror_tileproc(SkFixed x) { |
caryclark | 3127c99 | 2015-12-09 12:02:30 -0800 | [diff] [blame] | 61 | int s = SkLeftShift(x, 15) >> 31; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 62 | return (x ^ s) & 0xFFFF; |
| 63 | } |
| 64 | |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 65 | /////////////////////////////////////////////////////////////////////////////// |
| 66 | |
| 67 | typedef SkFixed (*TileProc)(SkFixed); |
| 68 | |
| 69 | /////////////////////////////////////////////////////////////////////////////// |
| 70 | |
| 71 | static const TileProc gTileProcs[] = { |
| 72 | clamp_tileproc, |
| 73 | repeat_tileproc, |
| 74 | mirror_tileproc |
| 75 | }; |
| 76 | |
| 77 | /////////////////////////////////////////////////////////////////////////////// |
| 78 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 79 | class SkGradientShaderBase : public SkShaderBase { |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 80 | public: |
reed@google.com | 437d6eb | 2013-05-23 19:03:05 +0000 | [diff] [blame] | 81 | struct Descriptor { |
| 82 | Descriptor() { |
| 83 | sk_bzero(this, sizeof(*this)); |
| 84 | fTileMode = SkShader::kClamp_TileMode; |
| 85 | } |
skia.committer@gmail.com | 3e2345a | 2013-05-24 07:01:26 +0000 | [diff] [blame] | 86 | |
reed | addf2ed | 2014-08-11 08:28:24 -0700 | [diff] [blame] | 87 | const SkMatrix* fLocalMatrix; |
brianosman | e25d71c | 2016-09-28 11:27:28 -0700 | [diff] [blame] | 88 | const SkColor4f* fColors; |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 89 | sk_sp<SkColorSpace> fColorSpace; |
reed@google.com | 437d6eb | 2013-05-23 19:03:05 +0000 | [diff] [blame] | 90 | const SkScalar* fPos; |
| 91 | int fCount; |
| 92 | SkShader::TileMode fTileMode; |
commit-bot@chromium.org | 6c5aea2 | 2014-04-22 16:25:15 +0000 | [diff] [blame] | 93 | uint32_t fGradFlags; |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 94 | |
| 95 | void flatten(SkWriteBuffer&) const; |
| 96 | }; |
| 97 | |
| 98 | class DescriptorScope : public Descriptor { |
| 99 | public: |
| 100 | DescriptorScope() {} |
mtklein | 88fd0fb | 2014-12-01 06:56:38 -0800 | [diff] [blame] | 101 | |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 102 | bool unflatten(SkReadBuffer&); |
| 103 | |
| 104 | // fColors and fPos always point into local memory, so they can be safely mutated |
| 105 | // |
brianosman | e25d71c | 2016-09-28 11:27:28 -0700 | [diff] [blame] | 106 | SkColor4f* mutableColors() { return const_cast<SkColor4f*>(fColors); } |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 107 | SkScalar* mutablePos() { return const_cast<SkScalar*>(fPos); } |
| 108 | |
| 109 | private: |
| 110 | enum { |
| 111 | kStorageCount = 16 |
| 112 | }; |
brianosman | e25d71c | 2016-09-28 11:27:28 -0700 | [diff] [blame] | 113 | SkColor4f fColorStorage[kStorageCount]; |
reed | 9fa60da | 2014-08-21 07:59:51 -0700 | [diff] [blame] | 114 | SkScalar fPosStorage[kStorageCount]; |
| 115 | SkMatrix fLocalMatrixStorage; |
| 116 | SkAutoMalloc fDynamicStorage; |
reed@google.com | 437d6eb | 2013-05-23 19:03:05 +0000 | [diff] [blame] | 117 | }; |
| 118 | |
mtklein | cc695fe | 2014-12-10 10:29:19 -0800 | [diff] [blame] | 119 | SkGradientShaderBase(const Descriptor& desc, const SkMatrix& ptsToUnit); |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 120 | ~SkGradientShaderBase() override; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 121 | |
brianosman | 93110a8 | 2016-09-15 08:40:21 -0700 | [diff] [blame] | 122 | // The cache is initialized on-demand when getCache32 is called. |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 123 | class GradientShaderCache : public SkRefCnt { |
| 124 | public: |
Florin Malita | cc58664 | 2017-10-24 16:18:59 -0400 | [diff] [blame] | 125 | GradientShaderCache(const SkGradientShaderBase& shader); |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 126 | ~GradientShaderCache(); |
| 127 | |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 128 | const SkPMColor* getCache32(); |
| 129 | |
Mike Reed | 6b3155c | 2017-04-03 14:41:44 -0400 | [diff] [blame] | 130 | SkPixelRef* getCache32PixelRef() const { return fCache32PixelRef.get(); } |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 131 | |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 132 | private: |
brianosman | 93110a8 | 2016-09-15 08:40:21 -0700 | [diff] [blame] | 133 | // Working pointer. If it's nullptr, we need to recompute the cache values. |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 134 | SkPMColor* fCache32; |
| 135 | |
Mike Reed | 6b3155c | 2017-04-03 14:41:44 -0400 | [diff] [blame] | 136 | sk_sp<SkPixelRef> fCache32PixelRef; |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 137 | const SkGradientShaderBase& fShader; |
| 138 | |
brianosman | 93110a8 | 2016-09-15 08:40:21 -0700 | [diff] [blame] | 139 | // Make sure we only initialize the cache once. |
| 140 | SkOnce fCache32InitOnce; |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 141 | |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 142 | static void initCache32(GradientShaderCache* cache); |
| 143 | |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 144 | static void Build32bitCache(SkPMColor[], SkColor c0, SkColor c1, int count, |
Florin Malita | cc58664 | 2017-10-24 16:18:59 -0400 | [diff] [blame] | 145 | uint32_t gradFlags); |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 148 | class GradientShaderBaseContext : public Context { |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 149 | public: |
commit-bot@chromium.org | e901b6d | 2014-05-01 19:31:31 +0000 | [diff] [blame] | 150 | GradientShaderBaseContext(const SkGradientShaderBase& shader, const ContextRec&); |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 151 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 152 | uint32_t getFlags() const override { return fFlags; } |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 153 | |
fmalita | 088e21b | 2016-10-05 09:28:42 -0700 | [diff] [blame] | 154 | bool isValid() const; |
| 155 | |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 156 | protected: |
| 157 | SkMatrix fDstToIndex; |
Cary Clark | 9480d82 | 2017-10-19 18:01:13 -0400 | [diff] [blame] | 158 | SkMatrixPriv::MapXYProc fDstToIndexProc; |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 159 | uint8_t fDstToIndexClass; |
| 160 | uint8_t fFlags; |
| 161 | |
Hal Canary | 67b39de | 2016-11-07 11:47:44 -0500 | [diff] [blame] | 162 | sk_sp<GradientShaderCache> fCache; |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 163 | |
| 164 | private: |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 165 | typedef Context INHERITED; |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame] | 166 | }; |
| 167 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 168 | bool isOpaque() const override; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 169 | |
brianosman | d454609 | 2016-09-22 12:31:58 -0700 | [diff] [blame] | 170 | enum class GradientBitmapType : uint8_t { |
| 171 | kLegacy, |
| 172 | kSRGB, |
| 173 | kHalfFloat, |
| 174 | }; |
| 175 | |
| 176 | void getGradientTableBitmap(SkBitmap*, GradientBitmapType bitmapType) const; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 177 | |
| 178 | enum { |
| 179 | /// Seems like enough for visual accuracy. TODO: if pos[] deserves |
| 180 | /// it, use a larger cache. |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 181 | kCache32Bits = 8, |
reed@google.com | 6004029 | 2013-02-04 18:21:23 +0000 | [diff] [blame] | 182 | kCache32Count = (1 << kCache32Bits), |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 183 | kCache32Shift = 16 - kCache32Bits, |
| 184 | kSqrt32Shift = 8 - kCache32Bits, |
| 185 | |
| 186 | /// This value is used to *read* the dither cache; it may be 0 |
| 187 | /// if dithering is disabled. |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 188 | kDitherStride32 = kCache32Count, |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 189 | }; |
| 190 | |
commit-bot@chromium.org | 6c5aea2 | 2014-04-22 16:25:15 +0000 | [diff] [blame] | 191 | uint32_t getGradFlags() const { return fGradFlags; } |
commit-bot@chromium.org | 53783b0 | 2014-04-17 21:09:49 +0000 | [diff] [blame] | 192 | |
Florin Malita | 0e36b3f | 2017-06-05 23:33:45 -0400 | [diff] [blame] | 193 | SkColor4f getXformedColor(size_t index, SkColorSpace*) const; |
| 194 | |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 195 | protected: |
Mike Klein | a377184 | 2017-05-04 19:38:48 -0400 | [diff] [blame] | 196 | struct Rec { |
| 197 | SkFixed fPos; // 0...1 |
| 198 | uint32_t fScale; // (1 << 24) / range |
| 199 | }; |
| 200 | |
fmalita | bc590c0 | 2016-02-22 09:12:33 -0800 | [diff] [blame] | 201 | class GradientShaderBase4fContext; |
| 202 | |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 203 | SkGradientShaderBase(SkReadBuffer& ); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 204 | void flatten(SkWriteBuffer&) const override; |
commit-bot@chromium.org | 0f10f7b | 2014-03-13 18:02:17 +0000 | [diff] [blame] | 205 | SK_TO_STRING_OVERRIDE() |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 206 | |
Florin Malita | 5f379a8 | 2017-10-18 16:22:35 -0400 | [diff] [blame] | 207 | void commonAsAGradient(GradientInfo*) const; |
skia.committer@gmail.com | d3b28e8 | 2014-04-22 03:05:17 +0000 | [diff] [blame] | 208 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 209 | bool onAsLuminanceColor(SkColor*) const override; |
reed | 8367b8c | 2014-08-22 08:30:20 -0700 | [diff] [blame] | 210 | |
brianosman | d454609 | 2016-09-22 12:31:58 -0700 | [diff] [blame] | 211 | void initLinearBitmap(SkBitmap* bitmap) const; |
| 212 | |
Mike Reed | 1d8c42e | 2017-08-29 14:58:19 -0400 | [diff] [blame] | 213 | bool onAppendStages(const StageRec&) const override; |
Mike Klein | a377184 | 2017-05-04 19:38:48 -0400 | [diff] [blame] | 214 | |
Florin Malita | 50b2084 | 2017-07-29 19:08:28 -0400 | [diff] [blame] | 215 | virtual void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline, |
| 216 | SkRasterPipeline* postPipeline) const = 0; |
Mike Klein | a377184 | 2017-05-04 19:38:48 -0400 | [diff] [blame] | 217 | |
fmalita | 088e21b | 2016-10-05 09:28:42 -0700 | [diff] [blame] | 218 | template <typename T, typename... Args> |
Herb Derby | 83e939b | 2017-02-07 14:25:11 -0500 | [diff] [blame] | 219 | static Context* CheckedMakeContext(SkArenaAlloc* alloc, Args&&... args) { |
| 220 | auto* ctx = alloc->make<T>(std::forward<Args>(args)...); |
fmalita | 088e21b | 2016-10-05 09:28:42 -0700 | [diff] [blame] | 221 | if (!ctx->isValid()) { |
fmalita | 088e21b | 2016-10-05 09:28:42 -0700 | [diff] [blame] | 222 | return nullptr; |
| 223 | } |
| 224 | return ctx; |
| 225 | } |
| 226 | |
Mike Klein | a377184 | 2017-05-04 19:38:48 -0400 | [diff] [blame] | 227 | const SkMatrix fPtsToUnit; |
| 228 | TileMode fTileMode; |
| 229 | TileProc fTileProc; |
| 230 | uint8_t fGradFlags; |
| 231 | Rec* fRecs; |
| 232 | |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 233 | private: |
| 234 | enum { |
| 235 | kColorStorageCount = 4, // more than this many colors, and we'll use sk_malloc for the space |
| 236 | |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 237 | kStorageSize = kColorStorageCount * |
| 238 | (sizeof(SkColor) + sizeof(SkScalar) + sizeof(Rec) + sizeof(SkColor4f)) |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 239 | }; |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 240 | SkColor fStorage[(kStorageSize + 3) >> 2]; |
reed | f3182eb | 2015-11-17 08:12:19 -0800 | [diff] [blame] | 241 | public: |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 242 | SkColor* fOrigColors; // original colors, before modulation by paint in context. |
| 243 | SkColor4f* fOrigColors4f; // original colors, as linear floats |
| 244 | SkScalar* fOrigPos; // original positions |
| 245 | int fColorCount; |
| 246 | sk_sp<SkColorSpace> fColorSpace; // color space of gradient stops |
reed | f3182eb | 2015-11-17 08:12:19 -0800 | [diff] [blame] | 247 | |
| 248 | bool colorsAreOpaque() const { return fColorsAreOpaque; } |
| 249 | |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 250 | TileMode getTileMode() const { return fTileMode; } |
| 251 | Rec* getRecs() const { return fRecs; } |
| 252 | |
reed | f3182eb | 2015-11-17 08:12:19 -0800 | [diff] [blame] | 253 | private: |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 254 | bool fColorsAreOpaque; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 255 | |
Florin Malita | cc58664 | 2017-10-24 16:18:59 -0400 | [diff] [blame] | 256 | sk_sp<GradientShaderCache> refCache() const; |
Hal Canary | 67b39de | 2016-11-07 11:47:44 -0500 | [diff] [blame] | 257 | mutable SkMutex fCacheMutex; |
| 258 | mutable sk_sp<GradientShaderCache> fCache; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 259 | |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 260 | void initCommon(); |
| 261 | |
Florin Malita | 4aed138 | 2017-05-25 10:38:07 -0400 | [diff] [blame] | 262 | typedef SkShaderBase INHERITED; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 263 | }; |
| 264 | |
Mike Klein | a377184 | 2017-05-04 19:38:48 -0400 | [diff] [blame] | 265 | |
reed@google.com | 55853db | 2013-02-01 19:34:59 +0000 | [diff] [blame] | 266 | static inline int init_dither_toggle(int x, int y) { |
reed@google.com | 6004029 | 2013-02-04 18:21:23 +0000 | [diff] [blame] | 267 | x &= 1; |
| 268 | y = (y & 1) << 1; |
| 269 | return (x | y) * SkGradientShaderBase::kDitherStride32; |
reed@google.com | 55853db | 2013-02-01 19:34:59 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | static inline int next_dither_toggle(int toggle) { |
| 273 | return toggle ^ SkGradientShaderBase::kDitherStride32; |
| 274 | } |
| 275 | |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 276 | /////////////////////////////////////////////////////////////////////////////// |
| 277 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 278 | #if SK_SUPPORT_GPU |
| 279 | |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 280 | #include "GrColorSpaceXform.h" |
bsalomon@google.com | 77af680 | 2013-10-02 13:04:56 +0000 | [diff] [blame] | 281 | #include "GrCoordTransform.h" |
bsalomon | 6251d17 | 2014-10-15 10:50:36 -0700 | [diff] [blame] | 282 | #include "GrFragmentProcessor.h" |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 283 | #include "glsl/GrGLSLFragmentProcessor.h" |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 284 | #include "glsl/GrGLSLProgramDataManager.h" |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 285 | |
egdaniel | 605dd0f | 2014-11-12 08:35:25 -0800 | [diff] [blame] | 286 | class GrInvariantOutput; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 287 | |
| 288 | /* |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 289 | * The interpretation of the texture matrix depends on the sample mode. The |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 290 | * texture matrix is applied both when the texture coordinates are explicit |
| 291 | * and when vertex positions are used as texture coordinates. In the latter |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 292 | * case the texture matrix is applied to the pre-view-matrix position |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 293 | * values. |
| 294 | * |
| 295 | * Normal SampleMode |
| 296 | * The post-matrix texture coordinates are in normalize space with (0,0) at |
| 297 | * the top-left and (1,1) at the bottom right. |
| 298 | * RadialGradient |
| 299 | * The matrix specifies the radial gradient parameters. |
| 300 | * (0,0) in the post-matrix space is center of the radial gradient. |
| 301 | * Radial2Gradient |
| 302 | * Matrix transforms to space where first circle is centered at the |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 303 | * origin. The second circle will be centered (x, 0) where x may be |
| 304 | * 0 and is provided by setRadial2Params. The post-matrix space is |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 305 | * normalized such that 1 is the second radius - first radius. |
| 306 | * SweepGradient |
| 307 | * The angle from the origin of texture coordinates in post-matrix space |
| 308 | * determines the gradient value. |
| 309 | */ |
| 310 | |
rileya@google.com | b3e50f2 | 2012-08-20 17:43:08 +0000 | [diff] [blame] | 311 | class GrTextureStripAtlas; |
| 312 | |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 313 | // Base class for Gr gradient effects |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 314 | class GrGradientEffect : public GrFragmentProcessor { |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 315 | public: |
brianosman | 9557c27 | 2016-09-15 06:59:15 -0700 | [diff] [blame] | 316 | struct CreateArgs { |
| 317 | CreateArgs(GrContext* context, |
| 318 | const SkGradientShaderBase* shader, |
| 319 | const SkMatrix* matrix, |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 320 | SkShader::TileMode tileMode, |
Brian Osman | 5911a7c | 2017-10-25 12:52:31 -0400 | [diff] [blame^] | 321 | const SkColorSpace* dstColorSpace) |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 322 | : fContext(context) |
| 323 | , fShader(shader) |
| 324 | , fMatrix(matrix) |
Brian Osman | 5911a7c | 2017-10-25 12:52:31 -0400 | [diff] [blame^] | 325 | , fDstColorSpace(dstColorSpace) { |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 326 | switch (tileMode) { |
| 327 | case SkShader::kClamp_TileMode: |
| 328 | fWrapMode = GrSamplerState::WrapMode::kClamp; |
| 329 | break; |
| 330 | case SkShader::kRepeat_TileMode: |
| 331 | fWrapMode = GrSamplerState::WrapMode::kRepeat; |
| 332 | break; |
| 333 | case SkShader::kMirror_TileMode: |
| 334 | fWrapMode = GrSamplerState::WrapMode::kMirrorRepeat; |
| 335 | break; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | CreateArgs(GrContext* context, |
| 340 | const SkGradientShaderBase* shader, |
| 341 | const SkMatrix* matrix, |
| 342 | GrSamplerState::WrapMode wrapMode, |
Brian Osman | 5911a7c | 2017-10-25 12:52:31 -0400 | [diff] [blame^] | 343 | const SkColorSpace* dstColorSpace) |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 344 | : fContext(context) |
| 345 | , fShader(shader) |
| 346 | , fMatrix(matrix) |
| 347 | , fWrapMode(wrapMode) |
Brian Osman | 5911a7c | 2017-10-25 12:52:31 -0400 | [diff] [blame^] | 348 | , fDstColorSpace(dstColorSpace) {} |
brianosman | 9557c27 | 2016-09-15 06:59:15 -0700 | [diff] [blame] | 349 | |
| 350 | GrContext* fContext; |
| 351 | const SkGradientShaderBase* fShader; |
| 352 | const SkMatrix* fMatrix; |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 353 | GrSamplerState::WrapMode fWrapMode; |
Brian Osman | 5911a7c | 2017-10-25 12:52:31 -0400 | [diff] [blame^] | 354 | const SkColorSpace* fDstColorSpace; |
brianosman | 9557c27 | 2016-09-15 06:59:15 -0700 | [diff] [blame] | 355 | }; |
| 356 | |
fmenozzi | 55d318d | 2016-08-09 08:05:57 -0700 | [diff] [blame] | 357 | class GLSLProcessor; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 358 | |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 359 | ~GrGradientEffect() override; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 360 | |
rileya@google.com | b3e50f2 | 2012-08-20 17:43:08 +0000 | [diff] [blame] | 361 | bool useAtlas() const { return SkToBool(-1 != fRow); } |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 362 | SkScalar getYCoord() const { return fYCoord; } |
rileya@google.com | b3e50f2 | 2012-08-20 17:43:08 +0000 | [diff] [blame] | 363 | |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 364 | enum ColorType { |
| 365 | kTwo_ColorType, |
Brian Osman | a8e5744 | 2017-09-11 17:21:35 -0400 | [diff] [blame] | 366 | kThree_ColorType, // 0, t, 1 |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 367 | kTexture_ColorType, |
Brian Salomon | 466ad99 | 2016-10-13 16:08:36 -0400 | [diff] [blame] | 368 | kSingleHardStop_ColorType, // 0, t, t, 1 |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 369 | kHardStopLeftEdged_ColorType, // 0, 0, 1 |
| 370 | kHardStopRightEdged_ColorType, // 0, 1, 1 |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 371 | }; |
| 372 | |
| 373 | ColorType getColorType() const { return fColorType; } |
| 374 | |
| 375 | // Determines the type of gradient, one of: |
| 376 | // - Two-color |
| 377 | // - Symmetric three-color |
| 378 | // - Texture |
| 379 | // - Centered hard stop |
| 380 | // - Left-edged hard stop |
| 381 | // - Right-edged hard stop |
| 382 | ColorType determineColorType(const SkGradientShaderBase& shader); |
bsalomon@google.com | 82d1223 | 2013-09-09 15:36:26 +0000 | [diff] [blame] | 383 | |
| 384 | enum PremulType { |
| 385 | kBeforeInterp_PremulType, |
| 386 | kAfterInterp_PremulType, |
| 387 | }; |
| 388 | |
| 389 | PremulType getPremulType() const { return fPremulType; } |
| 390 | |
Brian Osman | d43f7b6 | 2017-10-19 15:42:01 -0400 | [diff] [blame] | 391 | const GrColor4f* getColors4f(int pos) const { |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 392 | SkASSERT(fColorType != kTexture_ColorType); |
| 393 | SkASSERT(pos < fColors4f.count()); |
| 394 | return &fColors4f[pos]; |
| 395 | } |
| 396 | |
bsalomon@google.com | d472620 | 2012-08-03 14:34:46 +0000 | [diff] [blame] | 397 | protected: |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 398 | GrGradientEffect(ClassID classID, const CreateArgs&, bool isOpaque); |
Brian Salomon | f8480b9 | 2017-07-27 15:45:59 -0400 | [diff] [blame] | 399 | explicit GrGradientEffect(const GrGradientEffect&); // facilitates clone() implementations |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 400 | |
Brian Osman | 5911a7c | 2017-10-25 12:52:31 -0400 | [diff] [blame^] | 401 | // Helper function used by derived class factories to handle color space transformation and |
| 402 | // modulation by input alpha. |
| 403 | static std::unique_ptr<GrFragmentProcessor> AdjustFP( |
| 404 | std::unique_ptr<GrGradientEffect> gradientFP, const CreateArgs& args) { |
| 405 | if (!gradientFP->isValid()) { |
| 406 | return nullptr; |
| 407 | } |
| 408 | std::unique_ptr<GrFragmentProcessor> fp; |
| 409 | // With analytic gradients, we pre-convert the stops to the destination color space, so no |
| 410 | // xform is needed. With texture-based gradients, we leave the data in the source color |
| 411 | // space (to avoid clamping if we can't use F16)... Add an extra FP to do the xform. |
| 412 | if (kTexture_ColorType == gradientFP->getColorType()) { |
| 413 | fp = GrColorSpaceXformEffect::Make(std::move(gradientFP), |
| 414 | args.fShader->fColorSpace.get(), |
| 415 | args.fDstColorSpace); |
| 416 | } else { |
| 417 | fp = std::move(gradientFP); |
| 418 | } |
| 419 | return GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp)); |
| 420 | } |
| 421 | |
| 422 | #if GR_TEST_UTILS |
Brian Osman | e75c19f | 2016-10-10 11:26:43 -0400 | [diff] [blame] | 423 | /** Helper struct that stores (and populates) parameters to construct a random gradient. |
Brian Osman | a219653 | 2016-10-17 12:48:13 -0400 | [diff] [blame] | 424 | If fUseColors4f is true, then the SkColor4f factory should be called, with fColors4f and |
| 425 | fColorSpace. Otherwise, the SkColor factory should be called, with fColors. fColorCount |
| 426 | will be the number of color stops in either case, and fColors and fStops can be passed to |
| 427 | the gradient factory. (The constructor may decide not to use stops, in which case fStops |
| 428 | will be nullptr). */ |
Brian Osman | 3f74860 | 2016-10-03 18:29:03 -0400 | [diff] [blame] | 429 | struct RandomGradientParams { |
Brian Salomon | 5d4cd9e | 2017-02-09 11:16:46 -0500 | [diff] [blame] | 430 | static const int kMaxRandomGradientColors = 5; |
Brian Osman | e75c19f | 2016-10-10 11:26:43 -0400 | [diff] [blame] | 431 | |
Brian Osman | 3f74860 | 2016-10-03 18:29:03 -0400 | [diff] [blame] | 432 | RandomGradientParams(SkRandom* r); |
| 433 | |
Brian Osman | a219653 | 2016-10-17 12:48:13 -0400 | [diff] [blame] | 434 | bool fUseColors4f; |
Brian Osman | 3f74860 | 2016-10-03 18:29:03 -0400 | [diff] [blame] | 435 | SkColor fColors[kMaxRandomGradientColors]; |
Brian Osman | a219653 | 2016-10-17 12:48:13 -0400 | [diff] [blame] | 436 | SkColor4f fColors4f[kMaxRandomGradientColors]; |
| 437 | sk_sp<SkColorSpace> fColorSpace; |
Brian Osman | 3f74860 | 2016-10-03 18:29:03 -0400 | [diff] [blame] | 438 | SkScalar fStopStorage[kMaxRandomGradientColors]; |
| 439 | SkShader::TileMode fTileMode; |
| 440 | int fColorCount; |
| 441 | SkScalar* fStops; |
| 442 | }; |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 443 | #endif |
bsalomon@google.com | d472620 | 2012-08-03 14:34:46 +0000 | [diff] [blame] | 444 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 445 | bool onIsEqual(const GrFragmentProcessor&) const override; |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 446 | |
commit-bot@chromium.org | 5fd7d5c | 2013-10-04 01:20:09 +0000 | [diff] [blame] | 447 | const GrCoordTransform& getCoordTransform() const { return fCoordTransform; } |
| 448 | |
Brian Salomon | 6af2701 | 2017-06-09 08:21:42 -0400 | [diff] [blame] | 449 | /** Checks whether the constructor failed to fully initialize the processor. */ |
Brian Salomon | 06e547c | 2017-06-09 16:11:32 -0400 | [diff] [blame] | 450 | bool isValid() const { |
| 451 | return fColorType != kTexture_ColorType || fTextureSampler.isInitialized(); |
| 452 | } |
Brian Salomon | 6af2701 | 2017-06-09 08:21:42 -0400 | [diff] [blame] | 453 | |
bsalomon@google.com | d472620 | 2012-08-03 14:34:46 +0000 | [diff] [blame] | 454 | private: |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 455 | static OptimizationFlags OptFlags(bool isOpaque); |
| 456 | |
Brian Osman | d43f7b6 | 2017-10-19 15:42:01 -0400 | [diff] [blame] | 457 | SkTDArray<GrColor4f> fColors4f; |
brianosman | b9c5137 | 2016-09-15 11:09:45 -0700 | [diff] [blame] | 458 | |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 459 | SkTDArray<SkScalar> fPositions; |
| 460 | GrSamplerState::WrapMode fWrapMode; |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 461 | |
bsalomon@google.com | 77af680 | 2013-10-02 13:04:56 +0000 | [diff] [blame] | 462 | GrCoordTransform fCoordTransform; |
Brian Salomon | 0bbecb2 | 2016-11-17 11:38:22 -0500 | [diff] [blame] | 463 | TextureSampler fTextureSampler; |
bsalomon@google.com | 8171288 | 2012-11-01 17:12:34 +0000 | [diff] [blame] | 464 | SkScalar fYCoord; |
rileya@google.com | b3e50f2 | 2012-08-20 17:43:08 +0000 | [diff] [blame] | 465 | GrTextureStripAtlas* fAtlas; |
| 466 | int fRow; |
bsalomon@google.com | 371e105 | 2013-01-11 21:08:55 +0000 | [diff] [blame] | 467 | bool fIsOpaque; |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 468 | ColorType fColorType; |
| 469 | PremulType fPremulType; // This is already baked into the table for texture gradients, and |
| 470 | // only changes behavior for gradients that don't use a texture. |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 471 | typedef GrFragmentProcessor INHERITED; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 472 | |
| 473 | }; |
| 474 | |
| 475 | /////////////////////////////////////////////////////////////////////////////// |
| 476 | |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 477 | // Base class for GL gradient effects |
fmenozzi | 55d318d | 2016-08-09 08:05:57 -0700 | [diff] [blame] | 478 | class GrGradientEffect::GLSLProcessor : public GrGLSLFragmentProcessor { |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 479 | public: |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 480 | GLSLProcessor() { |
| 481 | fCachedYCoord = SK_ScalarMax; |
| 482 | } |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 483 | |
wangyix | b1daa86 | 2015-08-18 11:29:31 -0700 | [diff] [blame] | 484 | protected: |
Brian Salomon | ab015ef | 2017-04-04 10:15:51 -0400 | [diff] [blame] | 485 | void onSetData(const GrGLSLProgramDataManager&, const GrFragmentProcessor&) override; |
rileya@google.com | b3e50f2 | 2012-08-20 17:43:08 +0000 | [diff] [blame] | 486 | |
bsalomon@google.com | f78df33 | 2012-10-29 12:43:38 +0000 | [diff] [blame] | 487 | protected: |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 488 | /** |
| 489 | * Subclasses must call this. It will return a key for the part of the shader code controlled |
| 490 | * by the base class. The subclasses must stick it in their key and then pass it to the below |
| 491 | * emit* functions from their emitCode function. |
| 492 | */ |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 493 | static uint32_t GenBaseGradientKey(const GrProcessor&); |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 494 | |
| 495 | // Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses |
| 496 | // should call this method from their emitCode(). |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 497 | void emitUniforms(GrGLSLUniformHandler*, const GrGradientEffect&); |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 498 | |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 499 | // Emit code that gets a fragment's color from an expression for t; has branches for |
| 500 | // several control flows inside -- 2-color gradients, 3-color symmetric gradients, 4+ |
| 501 | // color gradients that use the traditional texture lookup, as well as several varieties |
| 502 | // of hard stop gradients |
cdalton | 8528541 | 2016-02-18 12:37:07 -0800 | [diff] [blame] | 503 | void emitColor(GrGLSLFPFragmentBuilder* fragBuilder, |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame] | 504 | GrGLSLUniformHandler* uniformHandler, |
Brian Salomon | 1edc5b9 | 2016-11-29 13:43:46 -0500 | [diff] [blame] | 505 | const GrShaderCaps* shaderCaps, |
joshualitt | 60030bc | 2014-11-25 14:21:55 -0800 | [diff] [blame] | 506 | const GrGradientEffect&, |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 507 | const char* gradientTValue, |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 508 | const char* outputColor, |
| 509 | const char* inputColor, |
bsalomon | b58a2b4 | 2016-09-26 06:55:02 -0700 | [diff] [blame] | 510 | const TextureSamplers&); |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 511 | |
| 512 | private: |
Florin Malita | b81a8b9 | 2017-08-08 12:14:17 -0400 | [diff] [blame] | 513 | void emitAnalyticalColor(GrGLSLFPFragmentBuilder* fragBuilder, |
| 514 | GrGLSLUniformHandler* uniformHandler, |
| 515 | const GrShaderCaps* shaderCaps, |
| 516 | const GrGradientEffect&, |
| 517 | const char* gradientTValue, |
| 518 | const char* outputColor, |
| 519 | const char* inputColor); |
| 520 | |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 521 | enum { |
Brian Osman | fe3e858 | 2017-10-20 11:27:49 -0400 | [diff] [blame] | 522 | // First bit for premul before/after interpolation |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 523 | kPremulBeforeInterpKey = 1, |
bsalomon@google.com | 82d1223 | 2013-09-09 15:36:26 +0000 | [diff] [blame] | 524 | |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 525 | // Next three bits for 2/3 color type or different special |
Brian Osman | fe3e858 | 2017-10-20 11:27:49 -0400 | [diff] [blame] | 526 | // hard stop cases ('none' means using texture atlas) |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 527 | kTwoColorKey = 2, |
| 528 | kThreeColorKey = 4, |
Brian Salomon | f8480b9 | 2017-07-27 15:45:59 -0400 | [diff] [blame] | 529 | |
Brian Osman | 2ab4b2b | 2017-09-12 11:20:56 -0400 | [diff] [blame] | 530 | kHardStopCenteredKey = 6, |
| 531 | kHardStopZeroZeroOneKey = 8, |
| 532 | kHardStopZeroOneOneKey = 10, |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 533 | |
| 534 | // Next two bits for tile mode |
| 535 | kClampTileMode = 16, |
| 536 | kRepeatTileMode = 32, |
| 537 | kMirrorTileMode = 48, |
| 538 | |
| 539 | // Lower six bits for premul, 2/3 color type, and tile mode |
| 540 | kReservedBits = 6, |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 541 | }; |
| 542 | |
bsalomon@google.com | 8171288 | 2012-11-01 17:12:34 +0000 | [diff] [blame] | 543 | SkScalar fCachedYCoord; |
fmenozzi | cd9a1d0 | 2016-08-15 07:03:47 -0700 | [diff] [blame] | 544 | GrGLSLProgramDataManager::UniformHandle fColorsUni; |
Brian Osman | a8e5744 | 2017-09-11 17:21:35 -0400 | [diff] [blame] | 545 | GrGLSLProgramDataManager::UniformHandle fExtraStopT; |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 546 | GrGLSLProgramDataManager::UniformHandle fFSYUni; |
rileya@google.com | b3e50f2 | 2012-08-20 17:43:08 +0000 | [diff] [blame] | 547 | |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 548 | typedef GrGLSLFragmentProcessor INHERITED; |
rileya@google.com | 1c6d64b | 2012-07-27 15:49:05 +0000 | [diff] [blame] | 549 | }; |
| 550 | |
| 551 | #endif |
| 552 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 553 | #endif |