blob: ca0f417e391c131b7344137bb65c0548c1776e3d [file] [log] [blame]
rileya@google.com1c6d64b2012-07-27 15:49:05 +00001/*
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
11#include "SkGradientShader.h"
12#include "SkClampRange.h"
13#include "SkColorPriv.h"
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000014#include "SkReadBuffer.h"
15#include "SkWriteBuffer.h"
rileya@google.com1c6d64b2012-07-27 15:49:05 +000016#include "SkMallocPixelRef.h"
rileya@google.com1c6d64b2012-07-27 15:49:05 +000017#include "SkUtils.h"
18#include "SkTemplates.h"
19#include "SkBitmapCache.h"
20#include "SkShader.h"
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +000021#include "SkOnce.h"
rileya@google.com1c6d64b2012-07-27 15:49:05 +000022
humper@google.com05af1af2013-01-07 16:47:43 +000023static inline void sk_memset32_dither(uint32_t dst[], uint32_t v0, uint32_t v1,
rileya@google.com1c6d64b2012-07-27 15:49:05 +000024 int count) {
25 if (count > 0) {
26 if (v0 == v1) {
27 sk_memset32(dst, v0, count);
28 } else {
29 int pairs = count >> 1;
30 for (int i = 0; i < pairs; i++) {
31 *dst++ = v0;
32 *dst++ = v1;
33 }
34 if (count & 1) {
35 *dst = v0;
36 }
37 }
38 }
39}
40
41// Clamp
42
humper@google.com05af1af2013-01-07 16:47:43 +000043static inline SkFixed clamp_tileproc(SkFixed x) {
rileya@google.com1c6d64b2012-07-27 15:49:05 +000044 return SkClampMax(x, 0xFFFF);
45}
46
47// Repeat
48
humper@google.com05af1af2013-01-07 16:47:43 +000049static inline SkFixed repeat_tileproc(SkFixed x) {
rileya@google.com1c6d64b2012-07-27 15:49:05 +000050 return x & 0xFFFF;
51}
52
53// Mirror
54
55// Visual Studio 2010 (MSC_VER=1600) optimizes bit-shift code incorrectly.
56// See http://code.google.com/p/skia/issues/detail?id=472
57#if defined(_MSC_VER) && (_MSC_VER >= 1600)
58#pragma optimize("", off)
59#endif
60
61static inline SkFixed mirror_tileproc(SkFixed x) {
62 int s = x << 15 >> 31;
63 return (x ^ s) & 0xFFFF;
64}
65
66#if defined(_MSC_VER) && (_MSC_VER >= 1600)
67#pragma optimize("", on)
68#endif
69
70///////////////////////////////////////////////////////////////////////////////
71
72typedef SkFixed (*TileProc)(SkFixed);
73
74///////////////////////////////////////////////////////////////////////////////
75
76static const TileProc gTileProcs[] = {
77 clamp_tileproc,
78 repeat_tileproc,
79 mirror_tileproc
80};
81
82///////////////////////////////////////////////////////////////////////////////
83
84class SkGradientShaderBase : public SkShader {
85public:
reed@google.com437d6eb2013-05-23 19:03:05 +000086 struct Descriptor {
87 Descriptor() {
88 sk_bzero(this, sizeof(*this));
89 fTileMode = SkShader::kClamp_TileMode;
90 }
skia.committer@gmail.com3e2345a2013-05-24 07:01:26 +000091
reed@google.com437d6eb2013-05-23 19:03:05 +000092 const SkColor* fColors;
93 const SkScalar* fPos;
94 int fCount;
95 SkShader::TileMode fTileMode;
commit-bot@chromium.org6c5aea22014-04-22 16:25:15 +000096 uint32_t fGradFlags;
reed@google.com437d6eb2013-05-23 19:03:05 +000097 };
98
99public:
commit-bot@chromium.org9c9005a2014-04-28 14:55:39 +0000100 SkGradientShaderBase(const Descriptor& desc, const SkMatrix* localMatrix);
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000101 virtual ~SkGradientShaderBase();
102
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000103 // The cache is initialized on-demand when getCache16/32 is called.
104 class GradientShaderCache : public SkRefCnt {
105 public:
106 GradientShaderCache(U8CPU alpha, const SkGradientShaderBase& shader);
107 ~GradientShaderCache();
108
109 const uint16_t* getCache16();
110 const SkPMColor* getCache32();
111
112 SkMallocPixelRef* getCache32PixelRef() const { return fCache32PixelRef; }
113
114 unsigned getAlpha() const { return fCacheAlpha; }
115
116 private:
117 // Working pointers. If either is NULL, we need to recompute the corresponding cache values.
118 uint16_t* fCache16;
119 SkPMColor* fCache32;
120
121 uint16_t* fCache16Storage; // Storage for fCache16, allocated on demand.
122 SkMallocPixelRef* fCache32PixelRef;
123 const unsigned fCacheAlpha; // The alpha value we used when we computed the cache.
124 // Larger than 8bits so we can store uninitialized
125 // value.
126
127 const SkGradientShaderBase& fShader;
128
129 // Make sure we only initialize the caches once.
130 bool fCache16Inited, fCache32Inited;
131 SkMutex fCache16Mutex, fCache32Mutex;
132
133 static void initCache16(GradientShaderCache* cache);
134 static void initCache32(GradientShaderCache* cache);
135
136 static void Build16bitCache(uint16_t[], SkColor c0, SkColor c1, int count);
137 static void Build32bitCache(SkPMColor[], SkColor c0, SkColor c1, int count,
138 U8CPU alpha, uint32_t gradFlags);
139 };
140
141 class GradientShaderBaseContext : public SkShader::Context {
142 public:
commit-bot@chromium.orge901b6d2014-05-01 19:31:31 +0000143 GradientShaderBaseContext(const SkGradientShaderBase& shader, const ContextRec&);
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000144
145 virtual uint32_t getFlags() const SK_OVERRIDE { return fFlags; }
146
147 protected:
148 SkMatrix fDstToIndex;
149 SkMatrix::MapXYProc fDstToIndexProc;
150 uint8_t fDstToIndexClass;
151 uint8_t fFlags;
152
153 SkAutoTUnref<GradientShaderCache> fCache;
154
155 private:
156 typedef SkShader::Context INHERITED;
157 };
158
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000159 virtual bool isOpaque() const SK_OVERRIDE;
160
161 void getGradientTableBitmap(SkBitmap*) const;
162
163 enum {
164 /// Seems like enough for visual accuracy. TODO: if pos[] deserves
165 /// it, use a larger cache.
166 kCache16Bits = 8,
reed@google.com3c2102c2013-02-01 12:59:40 +0000167 kCache16Count = (1 << kCache16Bits),
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000168 kCache16Shift = 16 - kCache16Bits,
169 kSqrt16Shift = 8 - kCache16Bits,
170
171 /// Seems like enough for visual accuracy. TODO: if pos[] deserves
172 /// it, use a larger cache.
173 kCache32Bits = 8,
reed@google.com60040292013-02-04 18:21:23 +0000174 kCache32Count = (1 << kCache32Bits),
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000175 kCache32Shift = 16 - kCache32Bits,
176 kSqrt32Shift = 8 - kCache32Bits,
177
178 /// This value is used to *read* the dither cache; it may be 0
179 /// if dithering is disabled.
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000180 kDitherStride32 = kCache32Count,
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000181 kDitherStride16 = kCache16Count,
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000182 };
183
commit-bot@chromium.org996402b2014-04-18 14:42:11 +0000184 enum GpuColorType {
185 kTwo_GpuColorType,
186 kThree_GpuColorType, // Symmetric three color
187 kTexture_GpuColorType
188 };
189
190 // Determines and returns the gradient is a two color gradient, symmetric three color gradient
191 // or other (texture gradient). If it is two or symmetric three color, the colors array will
192 // also be filled with the gradient colors
193 GpuColorType getGpuColorType(SkColor colors[3]) const;
194
commit-bot@chromium.org6c5aea22014-04-22 16:25:15 +0000195 uint32_t getGradFlags() const { return fGradFlags; }
commit-bot@chromium.org53783b02014-04-17 21:09:49 +0000196
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000197protected:
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +0000198 SkGradientShaderBase(SkReadBuffer& );
199 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +0000200 SK_TO_STRING_OVERRIDE()
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000201
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000202 SkMatrix fPtsToUnit; // set by subclass
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000203 TileMode fTileMode;
204 TileProc fTileProc;
205 int fColorCount;
reed@google.com3d3a8602013-05-24 14:58:44 +0000206 uint8_t fGradFlags;
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000207
208 struct Rec {
209 SkFixed fPos; // 0...1
210 uint32_t fScale; // (1 << 24) / range
211 };
212 Rec* fRecs;
213
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000214 void commonAsAGradient(GradientInfo*, bool flipGrad = false) const;
skia.committer@gmail.comd3b28e82014-04-22 03:05:17 +0000215
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000216 /*
217 * Takes in pointers to gradient color and Rec info as colorSrc and recSrc respectively.
218 * Count is the number of colors in the gradient
219 * It will then flip all the color and rec information and return in their respective Dst
220 * pointers. It is assumed that space has already been allocated for the Dst pointers.
221 * The rec src and dst are only assumed to be valid if count > 2
222 */
223 static void FlipGradientColors(SkColor* colorDst, Rec* recDst,
224 SkColor* colorSrc, Rec* recSrc,
225 int count);
226
227 // V23_COMPATIBILITY_CODE
228 // Used for 2-pt conical gradients since we sort start/end cirlces by radius
229 // Assumes space has already been allocated for fOrigColors
230 void flipGradientColors();
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000231
232private:
233 enum {
234 kColorStorageCount = 4, // more than this many colors, and we'll use sk_malloc for the space
235
236 kStorageSize = kColorStorageCount * (sizeof(SkColor) + sizeof(Rec))
237 };
238 SkColor fStorage[(kStorageSize + 3) >> 2];
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000239 SkColor* fOrigColors; // original colors, before modulation by paint in context.
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000240 bool fColorsAreOpaque;
241
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000242 GradientShaderCache* refCache(U8CPU alpha) const;
243 mutable SkMutex fCacheMutex;
244 mutable SkAutoTUnref<GradientShaderCache> fCache;
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000245
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000246 void initCommon();
247
248 typedef SkShader INHERITED;
249};
250
reed@google.com55853db2013-02-01 19:34:59 +0000251static inline int init_dither_toggle(int x, int y) {
reed@google.com60040292013-02-04 18:21:23 +0000252 x &= 1;
253 y = (y & 1) << 1;
254 return (x | y) * SkGradientShaderBase::kDitherStride32;
reed@google.com55853db2013-02-01 19:34:59 +0000255}
256
257static inline int next_dither_toggle(int toggle) {
258 return toggle ^ SkGradientShaderBase::kDitherStride32;
259}
260
261static inline int init_dither_toggle16(int x, int y) {
262 return ((x ^ y) & 1) * SkGradientShaderBase::kDitherStride16;
263}
264
265static inline int next_dither_toggle16(int toggle) {
266 return toggle ^ SkGradientShaderBase::kDitherStride16;
267}
268
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000269///////////////////////////////////////////////////////////////////////////////
270
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000271#if SK_SUPPORT_GPU
272
bsalomon@google.com77af6802013-10-02 13:04:56 +0000273#include "GrCoordTransform.h"
bsalomon@google.comd698f772012-10-25 13:22:00 +0000274#include "gl/GrGLEffect.h"
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000275
bsalomon@google.com08283af2012-10-26 13:01:20 +0000276class GrEffectStage;
bsalomon@google.com396e61f2012-10-25 19:00:29 +0000277class GrBackendEffectFactory;
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000278
279/*
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +0000280 * The interpretation of the texture matrix depends on the sample mode. The
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000281 * texture matrix is applied both when the texture coordinates are explicit
282 * and when vertex positions are used as texture coordinates. In the latter
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000283 * case the texture matrix is applied to the pre-view-matrix position
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000284 * values.
285 *
286 * Normal SampleMode
287 * The post-matrix texture coordinates are in normalize space with (0,0) at
288 * the top-left and (1,1) at the bottom right.
289 * RadialGradient
290 * The matrix specifies the radial gradient parameters.
291 * (0,0) in the post-matrix space is center of the radial gradient.
292 * Radial2Gradient
293 * Matrix transforms to space where first circle is centered at the
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000294 * origin. The second circle will be centered (x, 0) where x may be
295 * 0 and is provided by setRadial2Params. The post-matrix space is
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000296 * normalized such that 1 is the second radius - first radius.
297 * SweepGradient
298 * The angle from the origin of texture coordinates in post-matrix space
299 * determines the gradient value.
300 */
301
rileya@google.comb3e50f22012-08-20 17:43:08 +0000302 class GrTextureStripAtlas;
303
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000304// Base class for Gr gradient effects
bsalomon@google.coma469c282012-10-24 18:28:34 +0000305class GrGradientEffect : public GrEffect {
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000306public:
307
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +0000308 GrGradientEffect(GrContext* ctx,
309 const SkGradientShaderBase& shader,
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +0000310 const SkMatrix& matrix,
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +0000311 SkShader::TileMode tileMode);
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000312
313 virtual ~GrGradientEffect();
314
rileya@google.comb3e50f22012-08-20 17:43:08 +0000315 bool useAtlas() const { return SkToBool(-1 != fRow); }
bsalomon@google.com81712882012-11-01 17:12:34 +0000316 SkScalar getYCoord() const { return fYCoord; };
rileya@google.comb3e50f22012-08-20 17:43:08 +0000317
bsalomon@google.com68b58c92013-01-17 16:50:08 +0000318 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
skia.committer@gmail.com9a070f22013-09-10 07:01:44 +0000319
commit-bot@chromium.org996402b2014-04-18 14:42:11 +0000320 SkGradientShaderBase::GpuColorType getColorType() const { return fColorType; }
bsalomon@google.com82d12232013-09-09 15:36:26 +0000321
322 enum PremulType {
323 kBeforeInterp_PremulType,
324 kAfterInterp_PremulType,
325 };
326
327 PremulType getPremulType() const { return fPremulType; }
328
329 const SkColor* getColors(int pos) const {
commit-bot@chromium.org996402b2014-04-18 14:42:11 +0000330 SkASSERT(fColorType != SkGradientShaderBase::kTexture_GpuColorType);
bsalomon@google.com82d12232013-09-09 15:36:26 +0000331 SkASSERT((pos-1) <= fColorType);
332 return &fColors[pos];
333 }
bsalomon@google.com371e1052013-01-11 21:08:55 +0000334
bsalomon@google.comd4726202012-08-03 14:34:46 +0000335protected:
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000336
bsalomon@google.comd4726202012-08-03 14:34:46 +0000337 /** Populates a pair of arrays with colors and stop info to construct a random gradient.
338 The function decides whether stop values should be used or not. The return value indicates
339 the number of colors, which will be capped by kMaxRandomGradientColors. colors should be
340 sized to be at least kMaxRandomGradientColors. stops is a pointer to an array of at least
341 size kMaxRandomGradientColors. It may be updated to NULL, indicating that NULL should be
342 passed to the gradient factory rather than the array.
343 */
344 static const int kMaxRandomGradientColors = 4;
commit-bot@chromium.orge0e7cfe2013-09-09 20:09:12 +0000345 static int RandomGradientParams(SkRandom* r,
bsalomon@google.comd4726202012-08-03 14:34:46 +0000346 SkColor colors[kMaxRandomGradientColors],
347 SkScalar** stops,
348 SkShader::TileMode* tm);
349
bsalomon@google.com8a252f72013-01-22 20:35:13 +0000350 virtual bool onIsEqual(const GrEffect& effect) const SK_OVERRIDE;
bsalomon@google.com68b58c92013-01-17 16:50:08 +0000351
commit-bot@chromium.org5fd7d5c2013-10-04 01:20:09 +0000352 const GrCoordTransform& getCoordTransform() const { return fCoordTransform; }
353
bsalomon@google.comd4726202012-08-03 14:34:46 +0000354private:
bsalomon@google.com77af6802013-10-02 13:04:56 +0000355 static const GrCoordSet kCoordSet = kLocal_GrCoordSet;
bsalomon@google.com68b58c92013-01-17 16:50:08 +0000356
bsalomon@google.com77af6802013-10-02 13:04:56 +0000357 GrCoordTransform fCoordTransform;
bsalomon@google.com6d003d12012-09-11 15:45:20 +0000358 GrTextureAccess fTextureAccess;
bsalomon@google.com81712882012-11-01 17:12:34 +0000359 SkScalar fYCoord;
rileya@google.comb3e50f22012-08-20 17:43:08 +0000360 GrTextureStripAtlas* fAtlas;
361 int fRow;
bsalomon@google.com371e1052013-01-11 21:08:55 +0000362 bool fIsOpaque;
commit-bot@chromium.org996402b2014-04-18 14:42:11 +0000363 SkGradientShaderBase::GpuColorType fColorType;
364 SkColor fColors[3]; // More than 3 colors we use texture
bsalomon@google.com82d12232013-09-09 15:36:26 +0000365 PremulType fPremulType; // This only changes behavior for two and three color special cases.
366 // It is already baked into to the table for texture gradients.
bsalomon@google.coma469c282012-10-24 18:28:34 +0000367 typedef GrEffect INHERITED;
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000368
369};
370
371///////////////////////////////////////////////////////////////////////////////
372
bsalomon@google.com8ea78d82012-10-24 20:11:30 +0000373// Base class for GL gradient effects
bsalomon@google.comf78df332012-10-29 12:43:38 +0000374class GrGLGradientEffect : public GrGLEffect {
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000375public:
bsalomon@google.com0707c292012-10-25 21:45:42 +0000376 GrGLGradientEffect(const GrBackendEffectFactory& factory);
377 virtual ~GrGLGradientEffect();
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000378
kkinnunen7510b222014-07-30 00:04:16 -0700379 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
rileya@google.comb3e50f22012-08-20 17:43:08 +0000380
bsalomon@google.comf78df332012-10-29 12:43:38 +0000381protected:
bsalomon63e99f72014-07-21 08:03:14 -0700382 /**
383 * Subclasses must call this. It will return a key for the part of the shader code controlled
384 * by the base class. The subclasses must stick it in their key and then pass it to the below
385 * emit* functions from their emitCode function.
386 */
387 static uint32_t GenBaseGradientKey(const GrDrawEffect&);
388
389 // Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
390 // should call this method from their emitCode().
391 void emitUniforms(GrGLShaderBuilder* builder, uint32_t baseKey);
392
393
394 // emit code that gets a fragment's color from an expression for t; Has branches for 3 separate
395 // control flows inside -- 2 color gradients, 3 color symmetric gradients (both using
396 // native GLSL mix), and 4+ color gradients that use the traditional texture lookup.
397 void emitColor(GrGLShaderBuilder* builder,
398 const char* gradientTValue,
399 uint32_t baseKey,
400 const char* outputColor,
401 const char* inputColor,
402 const TextureSamplerArray& samplers);
403
404private:
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +0000405 enum {
bsalomon@google.com82d12232013-09-09 15:36:26 +0000406 kPremulTypeKeyBitCnt = 1,
bsalomon@google.com77af6802013-10-02 13:04:56 +0000407 kPremulTypeMask = 1,
bsalomon@google.com82d12232013-09-09 15:36:26 +0000408 kPremulBeforeInterpKey = kPremulTypeMask,
409
bsalomon@google.com77af6802013-10-02 13:04:56 +0000410 kTwoColorKey = 2 << kPremulTypeKeyBitCnt,
411 kThreeColorKey = 3 << kPremulTypeKeyBitCnt,
bsalomon@google.com82d12232013-09-09 15:36:26 +0000412 kColorKeyMask = kTwoColorKey | kThreeColorKey,
413 kColorKeyBitCnt = 2,
414
415 // Subclasses must shift any key bits they produce up by this amount
416 // and combine with the result of GenBaseGradientKey.
bsalomon@google.com77af6802013-10-02 13:04:56 +0000417 kBaseKeyBitCnt = (kPremulTypeKeyBitCnt + kColorKeyBitCnt)
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +0000418 };
bsalomon63e99f72014-07-21 08:03:14 -0700419 GR_STATIC_ASSERT(kBaseKeyBitCnt <= 32);
bsalomon@google.comd8b5fac2012-11-01 17:02:46 +0000420
bsalomon63e99f72014-07-21 08:03:14 -0700421 static SkGradientShaderBase::GpuColorType ColorTypeFromKey(uint32_t baseKey){
422 if (kTwoColorKey == (baseKey & kColorKeyMask)) {
commit-bot@chromium.org996402b2014-04-18 14:42:11 +0000423 return SkGradientShaderBase::kTwo_GpuColorType;
bsalomon63e99f72014-07-21 08:03:14 -0700424 } else if (kThreeColorKey == (baseKey & kColorKeyMask)) {
commit-bot@chromium.org996402b2014-04-18 14:42:11 +0000425 return SkGradientShaderBase::kThree_GpuColorType;
426 } else {return SkGradientShaderBase::kTexture_GpuColorType;}
bsalomon@google.com82d12232013-09-09 15:36:26 +0000427 }
428
bsalomon63e99f72014-07-21 08:03:14 -0700429 static GrGradientEffect::PremulType PremulTypeFromKey(uint32_t baseKey){
430 if (kPremulBeforeInterpKey == (baseKey & kPremulTypeMask)) {
bsalomon@google.com82d12232013-09-09 15:36:26 +0000431 return GrGradientEffect::kBeforeInterp_PremulType;
432 } else {
433 return GrGradientEffect::kAfterInterp_PremulType;
434 }
435 }
436
bsalomon@google.com81712882012-11-01 17:12:34 +0000437 SkScalar fCachedYCoord;
kkinnunen7510b222014-07-30 00:04:16 -0700438 GrGLProgramDataManager::UniformHandle fFSYUni;
439 GrGLProgramDataManager::UniformHandle fColorStartUni;
440 GrGLProgramDataManager::UniformHandle fColorMidUni;
441 GrGLProgramDataManager::UniformHandle fColorEndUni;
rileya@google.comb3e50f22012-08-20 17:43:08 +0000442
bsalomon@google.comf78df332012-10-29 12:43:38 +0000443 typedef GrGLEffect INHERITED;
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000444};
445
446#endif
447
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000448#endif