Index: src/effects/gradients/SkGradientShaderPriv.h |
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h |
index ec70929d43a6e663a68f11f5349959407986f50d..d4383d37d4642d074e04e5805415f43b5437e1d8 100644 |
--- a/src/effects/gradients/SkGradientShaderPriv.h |
+++ b/src/effects/gradients/SkGradientShaderPriv.h |
@@ -12,6 +12,7 @@ |
#include "SkGradientShader.h" |
#include "SkClampRange.h" |
#include "SkColorPriv.h" |
+#include "SkColorSpace.h" |
#include "SkReadBuffer.h" |
#include "SkWriteBuffer.h" |
#include "SkMallocPixelRef.h" |
@@ -84,6 +85,8 @@ public: |
const SkMatrix* fLocalMatrix; |
const SkColor* fColors; |
f(malita)
2016/09/14 23:32:23
Could we drop fColors from Descriptor? IIRC it's
|
+ const SkColor4f* fColors4f; |
+ sk_sp<SkColorSpace> fColorSpace; |
const SkScalar* fPos; |
int fCount; |
SkShader::TileMode fTileMode; |
@@ -241,13 +244,16 @@ private: |
enum { |
kColorStorageCount = 4, // more than this many colors, and we'll use sk_malloc for the space |
- kStorageSize = kColorStorageCount * (sizeof(SkColor) + sizeof(SkScalar) + sizeof(Rec)) |
+ kStorageSize = kColorStorageCount * |
+ (sizeof(SkColor) + sizeof(SkScalar) + sizeof(Rec) + sizeof(SkColor4f)) |
}; |
- SkColor fStorage[(kStorageSize + 3) >> 2]; |
+ SkColor fStorage[(kStorageSize + 3) >> 2]; |
public: |
- SkColor* fOrigColors; // original colors, before modulation by paint in context. |
- SkScalar* fOrigPos; // original positions |
- int fColorCount; |
+ SkColor* fOrigColors; // original colors, before modulation by paint in context. |
+ SkColor4f* fOrigColors4f; // original colors, as linear floats |
+ SkScalar* fOrigPos; // original positions |
+ int fColorCount; |
+ sk_sp<SkColorSpace> fColorSpace; // color space of gradient stops |
bool colorsAreOpaque() const { return fColorsAreOpaque; } |
@@ -255,7 +261,7 @@ public: |
Rec* getRecs() const { return fRecs; } |
private: |
- bool fColorsAreOpaque; |
+ bool fColorsAreOpaque; |
GradientShaderCache* refCache(U8CPU alpha, bool dither) const; |
mutable SkMutex fCacheMutex; |
@@ -288,6 +294,7 @@ static inline int next_dither_toggle16(int toggle) { |
#if SK_SUPPORT_GPU |
+#include "GrColorSpaceXform.h" |
#include "GrCoordTransform.h" |
#include "GrFragmentProcessor.h" |
#include "glsl/GrGLSLFragmentProcessor.h" |
@@ -327,16 +334,22 @@ public: |
CreateArgs(GrContext* context, |
const SkGradientShaderBase* shader, |
const SkMatrix* matrix, |
- SkShader::TileMode tileMode) |
+ SkShader::TileMode tileMode, |
+ sk_sp<GrColorSpaceXform> colorSpaceXform, |
+ bool gammaCorrect) |
: fContext(context) |
, fShader(shader) |
, fMatrix(matrix) |
- , fTileMode(tileMode) {} |
+ , fTileMode(tileMode) |
+ , fColorSpaceXform(std::move(colorSpaceXform)) |
+ , fGammaCorrect(gammaCorrect) {} |
GrContext* fContext; |
const SkGradientShaderBase* fShader; |
const SkMatrix* fMatrix; |
SkShader::TileMode fTileMode; |
+ sk_sp<GrColorSpaceXform> fColorSpaceXform; |
+ bool fGammaCorrect; |
}; |
class GLSLProcessor; |
@@ -384,6 +397,12 @@ public: |
return &fColors[pos]; |
} |
+ const SkColor4f* getColors4f(int pos) const { |
+ SkASSERT(fColorType != kTexture_ColorType); |
+ SkASSERT(pos < fColors4f.count()); |
+ return &fColors4f[pos]; |
+ } |
+ |
protected: |
/** Populates a pair of arrays with colors and stop info to construct a random gradient. |
The function decides whether stop values should be used or not. The return value indicates |
@@ -407,9 +426,15 @@ protected: |
private: |
static const GrCoordSet kCoordSet = kLocal_GrCoordSet; |
- SkTDArray<SkColor> fColors; |
- SkTDArray<SkScalar> fPositions; |
- SkShader::TileMode fTileMode; |
+ // If we're in legacy mode, then fColors will be populated. If we're gamma-correct, then |
+ // fColors4f and fColorSpaceXform will be populated. |
reed1
2016/09/14 19:03:53
not specific to this CL... but you went from 2 mal
Brian Osman
2016/09/14 20:30:20
Probably. Although we still only have 2 (only one
|
+ SkTDArray<SkColor> fColors; |
+ |
+ SkTDArray<SkColor4f> fColors4f; |
+ sk_sp<GrColorSpaceXform> fColorSpaceXform; |
+ |
+ SkTDArray<SkScalar> fPositions; |
+ SkShader::TileMode fTileMode; |
GrCoordTransform fCoordTransform; |
GrTextureAccess fTextureAccess; |