aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp21
-rw-r--r--src/gpu/effects/GrBicubicEffect.h10
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp38
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.h12
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.cpp106
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.h47
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.cpp15
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.fp27
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.h19
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp26
-rw-r--r--src/gpu/effects/GrTextureDomain.h4
-rw-r--r--src/gpu/effects/GrYUVEffect.cpp8
12 files changed, 143 insertions, 190 deletions
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index c8b302cbdd..7417e29f12 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -134,12 +134,12 @@ void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
- const SkShader::TileMode tileModes[2])
+ const GrSamplerState::WrapMode wrapModes[2])
: INHERITED{ModulateByConfigOptimizationFlags(proxy->config())}
, fCoordTransform(matrix, proxy.get())
, fDomain(GrTextureDomain::IgnoredDomain())
, fTextureSampler(std::move(proxy),
- GrSamplerParams(tileModes, GrSamplerParams::kNone_FilterMode))
+ GrSamplerState(wrapModes, GrSamplerState::Filter::kNearest))
, fColorSpaceXform(std::move(colorSpaceXform)) {
this->initClassID<GrBicubicEffect>();
this->addCoordTransform(&fCoordTransform);
@@ -192,8 +192,8 @@ std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTest
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(d->fRandom);
- static const SkShader::TileMode kClampClamp[] =
- { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
+ static const GrSamplerState::WrapMode kClampClamp[] = {GrSamplerState::WrapMode::kClamp,
+ GrSamplerState::WrapMode::kClamp};
return GrBicubicEffect::Make(d->textureProxy(texIdx), std::move(colorSpaceXform),
SkMatrix::I(), kClampClamp);
}
@@ -201,10 +201,9 @@ std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTest
//////////////////////////////////////////////////////////////////////////////
-bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix,
- GrSamplerParams::FilterMode* filterMode) {
+bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix, GrSamplerState::Filter* filterMode) {
if (matrix.isIdentity()) {
- *filterMode = GrSamplerParams::kNone_FilterMode;
+ *filterMode = GrSamplerState::Filter::kNearest;
return false;
}
@@ -212,22 +211,22 @@ bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix,
if (!matrix.getMinMaxScales(scales) || scales[0] < SK_Scalar1) {
// Bicubic doesn't handle arbitrary minimization well, as src texels can be skipped
// entirely,
- *filterMode = GrSamplerParams::kMipMap_FilterMode;
+ *filterMode = GrSamplerState::Filter::kMipMap;
return false;
}
// At this point if scales[1] == SK_Scalar1 then the matrix doesn't do any scaling.
if (scales[1] == SK_Scalar1) {
if (matrix.rectStaysRect() && SkScalarIsInt(matrix.getTranslateX()) &&
SkScalarIsInt(matrix.getTranslateY())) {
- *filterMode = GrSamplerParams::kNone_FilterMode;
+ *filterMode = GrSamplerState::Filter::kNearest;
} else {
// Use bilerp to handle rotation or fractional translation.
- *filterMode = GrSamplerParams::kBilerp_FilterMode;
+ *filterMode = GrSamplerState::Filter::kBilerp;
}
return false;
}
// When we use the bicubic filtering effect each sample is read from the texture using
// nearest neighbor sampling.
- *filterMode = GrSamplerParams::kNone_FilterMode;
+ *filterMode = GrSamplerState::Filter::kNearest;
return true;
}
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index 7812f3fcb0..b0a28d9b0d 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -36,9 +36,9 @@ public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
- const SkShader::TileMode tileModes[2]) {
+ const GrSamplerState::WrapMode wrapModes[2]) {
return std::unique_ptr<GrFragmentProcessor>(new GrBicubicEffect(
- std::move(proxy), std::move(colorSpaceXform), matrix, tileModes));
+ std::move(proxy), std::move(colorSpaceXform), matrix, wrapModes));
}
/**
@@ -60,11 +60,11 @@ public:
* kNearest).
*/
static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice,
- GrSamplerParams::FilterMode* filterMode);
+ GrSamplerState::Filter* filterMode);
private:
- GrBicubicEffect(sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>,
- const SkMatrix &matrix, const SkShader::TileMode tileModes[2]);
+ GrBicubicEffect(sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix& matrix,
+ const GrSamplerState::WrapMode wrapModes[2]);
GrBicubicEffect(sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>,
const SkMatrix &matrix, const SkRect& domain);
explicit GrBicubicEffect(const GrBicubicEffect&);
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index d87f7c06a0..c2cf8ebc22 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -122,16 +122,15 @@ private:
///////////////////////////////////////////////////////////////////////////////
-GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color,
- sk_sp<GrTextureProxy> proxy,
- const GrSamplerParams& params, GrMaskFormat format,
+GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, sk_sp<GrTextureProxy> proxy,
+ const GrSamplerState& params, GrMaskFormat format,
const SkMatrix& localMatrix, bool usesLocalCoords)
- : fColor(color)
- , fLocalMatrix(localMatrix)
- , fUsesLocalCoords(usesLocalCoords)
- , fTextureSampler(std::move(proxy), params)
- , fInColor(nullptr)
- , fMaskFormat(format) {
+ : fColor(color)
+ , fLocalMatrix(localMatrix)
+ , fUsesLocalCoords(usesLocalCoords)
+ , fTextureSampler(std::move(proxy), params)
+ , fInColor(nullptr)
+ , fMaskFormat(format) {
this->initClassID<GrBitmapTextGeoProc>();
fInPosition =
&this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, kHigh_GrSLPrecision);
@@ -161,22 +160,17 @@ GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLSLInstance(const GrShader
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
#if GR_TEST_UTILS
+
sk_sp<GrGeometryProcessor> GrBitmapTextGeoProc::TestCreate(GrProcessorTestData* d) {
int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
- static const SkShader::TileMode kTileModes[] = {
- SkShader::kClamp_TileMode,
- SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode,
- };
- SkShader::TileMode tileModes[] = {
- kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- };
- GrSamplerParams params(tileModes, d->fRandom->nextBool() ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
+ GrSamplerState::WrapMode wrapModes[2];
+ GrTest::TestWrapModes(d->fRandom, wrapModes);
+ GrSamplerState samplerState(wrapModes, d->fRandom->nextBool()
+ ? GrSamplerState::Filter::kBilerp
+ : GrSamplerState::Filter::kNearest);
GrMaskFormat format = kARGB_GrMaskFormat; // init to avoid warning
switch (d->fRandom->nextULessThan(3)) {
@@ -191,8 +185,8 @@ sk_sp<GrGeometryProcessor> GrBitmapTextGeoProc::TestCreate(GrProcessorTestData*
break;
}
- return GrBitmapTextGeoProc::Make(GrRandomColor(d->fRandom), std::move(proxy),
- params, format, GrTest::TestMatrix(d->fRandom),
+ return GrBitmapTextGeoProc::Make(GrRandomColor(d->fRandom), std::move(proxy), samplerState,
+ format, GrTest::TestMatrix(d->fRandom),
d->fRandom->nextBool());
}
#endif
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h
index 2664b2e00c..c919d1c87b 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.h
+++ b/src/gpu/effects/GrBitmapTextGeoProc.h
@@ -16,15 +16,14 @@ class GrInvariantOutput;
/**
* The output color of this effect is a modulation of the input color and a sample from a texture.
- * It allows explicit specification of the filtering and wrap modes (GrSamplerParams). The input
+ * It allows explicit specification of the filtering and wrap modes (GrSamplerState). The input
* coords are a custom attribute.
*/
class GrBitmapTextGeoProc : public GrGeometryProcessor {
public:
- static sk_sp<GrGeometryProcessor> Make(GrColor color,
- sk_sp<GrTextureProxy> proxy, const GrSamplerParams& p,
- GrMaskFormat format, const SkMatrix& localMatrix,
- bool usesLocalCoords) {
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, sk_sp<GrTextureProxy> proxy,
+ const GrSamplerState& p, GrMaskFormat format,
+ const SkMatrix& localMatrix, bool usesLocalCoords) {
return sk_sp<GrGeometryProcessor>(
new GrBitmapTextGeoProc(color, std::move(proxy), p, format,
localMatrix, usesLocalCoords));
@@ -48,8 +47,7 @@ public:
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps& caps) const override;
private:
- GrBitmapTextGeoProc(GrColor, sk_sp<GrTextureProxy>,
- const GrSamplerParams& params,
+ GrBitmapTextGeoProc(GrColor, sk_sp<GrTextureProxy>, const GrSamplerState& params,
GrMaskFormat format, const SkMatrix& localMatrix, bool usesLocalCoords);
GrColor fColor;
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 3078786e1f..81b33262da 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -236,21 +236,21 @@ private:
GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrColor color,
const SkMatrix& viewMatrix,
sk_sp<GrTextureProxy> proxy,
- const GrSamplerParams& params,
+ const GrSamplerState& params,
#ifdef SK_GAMMA_APPLY_TO_A8
float distanceAdjust,
#endif
uint32_t flags,
bool usesLocalCoords)
- : fColor(color)
- , fViewMatrix(viewMatrix)
- , fTextureSampler(std::move(proxy), params)
+ : fColor(color)
+ , fViewMatrix(viewMatrix)
+ , fTextureSampler(std::move(proxy), params)
#ifdef SK_GAMMA_APPLY_TO_A8
- , fDistanceAdjust(distanceAdjust)
+ , fDistanceAdjust(distanceAdjust)
#endif
- , fFlags(flags & kNonLCD_DistanceFieldEffectMask)
- , fInColor(nullptr)
- , fUsesLocalCoords(usesLocalCoords) {
+ , fFlags(flags & kNonLCD_DistanceFieldEffectMask)
+ , fInColor(nullptr)
+ , fUsesLocalCoords(usesLocalCoords) {
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
this->initClassID<GrDistanceFieldA8TextGeoProc>();
fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType,
@@ -281,17 +281,11 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT
: GrProcessorUnitTest::kAlphaTextureIdx;
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
- static const SkShader::TileMode kTileModes[] = {
- SkShader::kClamp_TileMode,
- SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode,
- };
- SkShader::TileMode tileModes[] = {
- kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- };
- GrSamplerParams params(tileModes, d->fRandom->nextBool() ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
+ GrSamplerState::WrapMode wrapModes[2];
+ GrTest::TestWrapModes(d->fRandom, wrapModes);
+ GrSamplerState samplerState(wrapModes, d->fRandom->nextBool()
+ ? GrSamplerState::Filter::kBilerp
+ : GrSamplerState::Filter::kNearest);
uint32_t flags = 0;
flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0;
@@ -300,13 +294,12 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT
}
return GrDistanceFieldA8TextGeoProc::Make(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- std::move(proxy), params,
+ GrTest::TestMatrix(d->fRandom), std::move(proxy),
+ samplerState,
#ifdef SK_GAMMA_APPLY_TO_A8
d->fRandom->nextF(),
#endif
- flags,
- d->fRandom->nextBool());
+ flags, d->fRandom->nextBool());
}
#endif
@@ -495,7 +488,7 @@ private:
GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(GrColor color,
const SkMatrix& viewMatrix,
sk_sp<GrTextureProxy> proxy,
- const GrSamplerParams& params,
+ const GrSamplerState& params,
uint32_t flags,
bool usesLocalCoords)
: fColor(color)
@@ -534,17 +527,11 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes
: GrProcessorUnitTest::kAlphaTextureIdx;
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
- static const SkShader::TileMode kTileModes[] = {
- SkShader::kClamp_TileMode,
- SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode,
- };
- SkShader::TileMode tileModes[] = {
- kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- };
- GrSamplerParams params(tileModes, d->fRandom->nextBool() ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
+ GrSamplerState::WrapMode wrapModes[2];
+ GrTest::TestWrapModes(d->fRandom, wrapModes);
+ GrSamplerState samplerState(wrapModes, d->fRandom->nextBool()
+ ? GrSamplerState::Filter::kBilerp
+ : GrSamplerState::Filter::kNearest);
uint32_t flags = 0;
flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0;
@@ -555,7 +542,7 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes
return GrDistanceFieldPathGeoProc::Make(GrRandomColor(d->fRandom),
GrTest::TestMatrix(d->fRandom),
std::move(proxy),
- params,
+ samplerState,
flags,
d->fRandom->nextBool());
}
@@ -806,18 +793,18 @@ private:
};
///////////////////////////////////////////////////////////////////////////////
-GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(
- GrColor color, const SkMatrix& viewMatrix,
- sk_sp<GrTextureProxy> proxy,
- const GrSamplerParams& params,
- DistanceAdjust distanceAdjust,
- uint32_t flags, bool usesLocalCoords)
- : fColor(color)
- , fViewMatrix(viewMatrix)
- , fTextureSampler(std::move(proxy), params)
- , fDistanceAdjust(distanceAdjust)
- , fFlags(flags & kLCD_DistanceFieldEffectMask)
- , fUsesLocalCoords(usesLocalCoords) {
+GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(GrColor color,
+ const SkMatrix& viewMatrix,
+ sk_sp<GrTextureProxy> proxy,
+ const GrSamplerState& params,
+ DistanceAdjust distanceAdjust,
+ uint32_t flags, bool usesLocalCoords)
+ : fColor(color)
+ , fViewMatrix(viewMatrix)
+ , fTextureSampler(std::move(proxy), params)
+ , fDistanceAdjust(distanceAdjust)
+ , fFlags(flags & kLCD_DistanceFieldEffectMask)
+ , fUsesLocalCoords(usesLocalCoords) {
SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag));
this->initClassID<GrDistanceFieldLCDTextGeoProc>();
fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType,
@@ -847,17 +834,11 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor
GrProcessorUnitTest::kAlphaTextureIdx;
sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
- static const SkShader::TileMode kTileModes[] = {
- SkShader::kClamp_TileMode,
- SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode,
- };
- SkShader::TileMode tileModes[] = {
- kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- };
- GrSamplerParams params(tileModes, d->fRandom->nextBool() ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
+ GrSamplerState::WrapMode wrapModes[2];
+ GrTest::TestWrapModes(d->fRandom, wrapModes);
+ GrSamplerState samplerState(wrapModes, d->fRandom->nextBool()
+ ? GrSamplerState::Filter::kBilerp
+ : GrSamplerState::Filter::kNearest);
DistanceAdjust wa = { 0.0f, 0.1f, -0.1f };
uint32_t flags = kUseLCD_DistanceFieldEffectFlag;
flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0;
@@ -866,10 +847,7 @@ sk_sp<GrGeometryProcessor> GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor
}
flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
return GrDistanceFieldLCDTextGeoProc::Make(GrRandomColor(d->fRandom),
- GrTest::TestMatrix(d->fRandom),
- std::move(proxy), params,
- wa,
- flags,
- d->fRandom->nextBool());
+ GrTest::TestMatrix(d->fRandom), std::move(proxy),
+ samplerState, wa, flags, d->fRandom->nextBool());
}
#endif
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h
index 344ac4a092..b1836dd9bb 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.h
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.h
@@ -45,7 +45,7 @@ enum GrDistanceFieldEffectFlags {
/**
* The output color of this effect is a modulation of the input color and a sample from a
* distance field texture (using a smoothed step function near 0.5).
- * It allows explicit specification of the filtering and wrap modes (GrSamplerParams). The input
+ * It allows explicit specification of the filtering and wrap modes (GrSamplerState). The input
* coords are a custom attribute. Gamma correction is handled via a texture LUT.
*/
class GrDistanceFieldA8TextGeoProc : public GrGeometryProcessor {
@@ -53,8 +53,8 @@ public:
#ifdef SK_GAMMA_APPLY_TO_A8
static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
sk_sp<GrTextureProxy> proxy,
- const GrSamplerParams& params,
- float lum, uint32_t flags, bool usesLocalCoords) {
+ const GrSamplerState& params, float lum, uint32_t flags,
+ bool usesLocalCoords) {
return sk_sp<GrGeometryProcessor>(
new GrDistanceFieldA8TextGeoProc(color, viewMatrix, std::move(proxy),
params, lum, flags, usesLocalCoords));
@@ -62,8 +62,8 @@ public:
#else
static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
sk_sp<GrTextureProxy> proxy,
- const GrSamplerParams& params,
- uint32_t flags, bool usesLocalCoords) {
+ const GrSamplerState& params, uint32_t flags,
+ bool usesLocalCoords) {
return sk_sp<GrGeometryProcessor>(
new GrDistanceFieldA8TextGeoProc(color, viewMatrix, std::move(proxy),
params, flags, usesLocalCoords));
@@ -90,8 +90,8 @@ public:
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix,
- sk_sp<GrTextureProxy> proxy, const GrSamplerParams& params,
+ GrDistanceFieldA8TextGeoProc(GrColor, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy,
+ const GrSamplerState& params,
#ifdef SK_GAMMA_APPLY_TO_A8
float distanceAdjust,
#endif
@@ -114,19 +114,18 @@ private:
typedef GrGeometryProcessor INHERITED;
};
-
/**
-* The output color of this effect is a modulation of the input color and a sample from a
-* distance field texture (using a smoothed step function near 0.5).
-* It allows explicit specification of the filtering and wrap modes (GrSamplerParams). The input
-* coords are a custom attribute. No gamma correct blending is applied. Used for paths only.
-*/
+ * The output color of this effect is a modulation of the input color and a sample from a
+ * distance field texture (using a smoothed step function near 0.5).
+ * It allows explicit specification of the filtering and wrap modes (GrSamplerState). The input
+ * coords are a custom attribute. No gamma correct blending is applied. Used for paths only.
+ */
class GrDistanceFieldPathGeoProc : public GrGeometryProcessor {
public:
- static sk_sp<GrGeometryProcessor> Make(GrColor color,
- const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy,
- const GrSamplerParams& params,
- uint32_t flags, bool usesLocalCoords) {
+ static sk_sp<GrGeometryProcessor> Make(GrColor color, const SkMatrix& viewMatrix,
+ sk_sp<GrTextureProxy> proxy,
+ const GrSamplerState& params, uint32_t flags,
+ bool usesLocalCoords) {
return sk_sp<GrGeometryProcessor>(
new GrDistanceFieldPathGeoProc(color, viewMatrix, std::move(proxy),
params, flags, usesLocalCoords));
@@ -149,9 +148,8 @@ public:
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix,
- sk_sp<GrTextureProxy>, const GrSamplerParams&, uint32_t flags,
- bool usesLocalCoords);
+ GrDistanceFieldPathGeoProc(GrColor, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy>,
+ const GrSamplerState&, uint32_t flags, bool usesLocalCoords);
GrColor fColor;
SkMatrix fViewMatrix;
@@ -170,7 +168,7 @@ private:
/**
* The output color of this effect is a modulation of the input color and samples from a
* distance field texture (using a smoothed step function near 0.5), adjusted for LCD displays.
- * It allows explicit specification of the filtering and wrap modes (GrSamplerParams). The input
+ * It allows explicit specification of the filtering and wrap modes (GrSamplerState). The input
* coords are a custom attribute. Gamma correction is handled via a texture LUT.
*/
class GrDistanceFieldLCDTextGeoProc : public GrGeometryProcessor {
@@ -193,7 +191,7 @@ public:
static sk_sp<GrGeometryProcessor> Make(GrColor color,
const SkMatrix& viewMatrix,
sk_sp<GrTextureProxy> proxy,
- const GrSamplerParams& params,
+ const GrSamplerState& params,
DistanceAdjust distanceAdjust,
uint32_t flags,
bool usesLocalCoords) {
@@ -221,9 +219,8 @@ public:
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
private:
- GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix,
- sk_sp<GrTextureProxy> proxy, const GrSamplerParams& params,
- DistanceAdjust wa, uint32_t flags,
+ GrDistanceFieldLCDTextGeoProc(GrColor, const SkMatrix& viewMatrix, sk_sp<GrTextureProxy> proxy,
+ const GrSamplerState& params, DistanceAdjust wa, uint32_t flags,
bool usesLocalCoords);
GrColor fColor;
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index ed2734b579..3301694004 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -88,16 +88,11 @@ std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(
GrProcessorTestData* testData) {
int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
- static const SkShader::TileMode kTileModes[] = {
- SkShader::kClamp_TileMode, SkShader::kRepeat_TileMode, SkShader::kMirror_TileMode,
- };
- SkShader::TileMode tileModes[] = {
- kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- };
- GrSamplerParams params(tileModes, testData->fRandom->nextBool()
- ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
+ GrSamplerState::WrapMode wrapModes[2];
+ GrTest::TestWrapModes(testData->fRandom, wrapModes);
+ GrSamplerState params(wrapModes, testData->fRandom->nextBool()
+ ? GrSamplerState::Filter::kBilerp
+ : GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom);
diff --git a/src/gpu/effects/GrSimpleTextureEffect.fp b/src/gpu/effects/GrSimpleTextureEffect.fp
index 80824fe076..a4275b566f 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.fp
+++ b/src/gpu/effects/GrSimpleTextureEffect.fp
@@ -10,7 +10,7 @@ in uniform colorSpaceXform colorXform;
in float4x4 matrix;
@constructorParams {
- GrSamplerParams samplerParams
+ GrSamplerState samplerParams
}
@coordTransform(image) {
@@ -27,23 +27,23 @@ in float4x4 matrix;
const SkMatrix& matrix) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
- GrSamplerParams(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode)));
+ GrSamplerState(GrSamplerState::WrapMode::kClamp, GrSamplerState::Filter::kNearest)));
}
/* clamp mode */
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
- GrSamplerParams::FilterMode filterMode) {
+ GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
- GrSamplerParams(SkShader::kClamp_TileMode, filterMode)));
+ GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
- const GrSamplerParams& p) {
+ const GrSamplerState& p) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p));
}
@@ -62,18 +62,11 @@ void main() {
@test(testData) {
int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: GrProcessorUnitTest::kAlphaTextureIdx;
- static const SkShader::TileMode kTileModes[] = {
- SkShader::kClamp_TileMode,
- SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode,
- };
- SkShader::TileMode tileModes[] = {
- kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- kTileModes[testData->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
- };
- GrSamplerParams params(tileModes, testData->fRandom->nextBool()
- ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
+ GrSamplerState::WrapMode wrapModes[2];
+ GrTest::TestWrapModes(testData->fRandom, wrapModes);
+ GrSamplerState params(wrapModes, testData->fRandom->nextBool()
+ ? GrSamplerState::Filter::kBilerp
+ : GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom);
diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
index 11564bb6e2..8d3fba12bb 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -24,26 +24,27 @@ public:
sk_sp<GrColorSpaceXform>
colorSpaceXform,
const SkMatrix& matrix) {
- return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(
- std::move(proxy), std::move(colorSpaceXform), matrix,
- GrSamplerParams(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode)));
+ return std::unique_ptr<GrFragmentProcessor>(
+ new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
+ GrSamplerState(GrSamplerState::WrapMode::kClamp,
+ GrSamplerState::Filter::kNearest)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform>
colorSpaceXform,
const SkMatrix& matrix,
- GrSamplerParams::FilterMode filterMode) {
- return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
- GrSamplerParams(SkShader::kClamp_TileMode, filterMode)));
+ GrSamplerState::Filter filter) {
+ return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(
+ std::move(proxy), std::move(colorSpaceXform), matrix,
+ GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform>
colorSpaceXform,
const SkMatrix& matrix,
- const GrSamplerParams& p) {
+ const GrSamplerState& p) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p));
}
@@ -53,7 +54,7 @@ public:
private:
GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, sk_sp<GrColorSpaceXform> colorXform,
- SkMatrix44 matrix, GrSamplerParams samplerParams)
+ SkMatrix44 matrix, GrSamplerState samplerParams)
: INHERITED((OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag |
(GrPixelConfigIsOpaque(image->config())
? kPreservesOpaqueInput_OptimizationFlag
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 5101762bd9..3bb96b23cd 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -212,7 +212,7 @@ std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode mode,
- GrSamplerParams::FilterMode filterMode) {
+ GrSamplerState::Filter filterMode) {
if (GrTextureDomain::kIgnore_Mode == mode ||
(GrTextureDomain::kClamp_Mode == mode && can_ignore_rect(proxy.get(), domain))) {
return GrSimpleTextureEffect::Make(std::move(proxy),
@@ -228,14 +228,14 @@ GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy,
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode mode,
- GrSamplerParams::FilterMode filterMode)
+ GrSamplerState::Filter filterMode)
: INHERITED(OptFlags(proxy->config(), mode))
, fCoordTransform(matrix, proxy.get())
, fTextureDomain(proxy.get(), domain, mode)
, fTextureSampler(std::move(proxy), filterMode)
, fColorSpaceXform(std::move(colorSpaceXform)) {
SkASSERT(mode != GrTextureDomain::kRepeat_Mode ||
- filterMode == GrSamplerParams::kNone_FilterMode);
+ filterMode == GrSamplerState::Filter::kNearest);
this->initClassID<GrTextureDomainEffect>();
this->addCoordTransform(&fCoordTransform);
this->addTextureSampler(&fTextureSampler);
@@ -325,13 +325,13 @@ std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcess
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false;
sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(d->fRandom);
- return GrTextureDomainEffect::Make(std::move(proxy),
- std::move(colorSpaceXform),
- matrix,
- domain,
- mode,
- bilerp ? GrSamplerParams::kBilerp_FilterMode
- : GrSamplerParams::kNone_FilterMode);
+ return GrTextureDomainEffect::Make(
+ std::move(proxy),
+ std::move(colorSpaceXform),
+ matrix,
+ domain,
+ mode,
+ bilerp ? GrSamplerState::Filter::kBilerp : GrSamplerState::Filter::kNearest);
}
#endif
@@ -343,11 +343,9 @@ std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor:
}
GrDeviceSpaceTextureDecalFragmentProcessor::GrDeviceSpaceTextureDecalFragmentProcessor(
- sk_sp<GrTextureProxy> proxy,
- const SkIRect& subset,
- const SkIPoint& deviceSpaceOffset)
+ sk_sp<GrTextureProxy> proxy, const SkIRect& subset, const SkIPoint& deviceSpaceOffset)
: INHERITED(kCompatibleWithCoverageAsAlpha_OptimizationFlag)
- , fTextureSampler(proxy, GrSamplerParams::ClampNoFilter())
+ , fTextureSampler(proxy, GrSamplerState::ClampNearest())
, fTextureDomain(proxy.get(), GrTextureDomain::MakeTexelDomain(subset),
GrTextureDomain::kDecal_Mode) {
this->addTextureSampler(&fTextureSampler);
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 0db7d2c202..ec0ef4ea8b 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -158,7 +158,7 @@ public:
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode,
- GrSamplerParams::FilterMode filterMode);
+ GrSamplerState::Filter filterMode);
const char* name() const override { return "TextureDomain"; }
@@ -186,7 +186,7 @@ private:
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode,
- GrSamplerParams::FilterMode);
+ GrSamplerState::Filter);
explicit GrTextureDomainEffect(const GrTextureDomainEffect&);
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 80e87c2391..5bf4a758ba 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -79,13 +79,13 @@ public:
SkMatrix::MakeScale(w[1] / w[0], h[1] / h[0]),
SkMatrix::MakeScale(w[2] / w[0], h[2] / h[0])
};
- GrSamplerParams::FilterMode uvFilterMode =
+ GrSamplerState::Filter uvFilterMode =
((sizes[1].fWidth != sizes[0].fWidth) ||
(sizes[1].fHeight != sizes[0].fHeight) ||
(sizes[2].fWidth != sizes[0].fWidth) ||
(sizes[2].fHeight != sizes[0].fHeight)) ?
- GrSamplerParams::kBilerp_FilterMode :
- GrSamplerParams::kNone_FilterMode;
+ GrSamplerState::Filter::kBilerp :
+ GrSamplerState::Filter::kNearest;
return std::unique_ptr<GrFragmentProcessor>(
new YUVtoRGBEffect(std::move(yProxy), std::move(uProxy), std::move(vProxy),
yuvMatrix, uvFilterMode, colorSpace, nv12));
@@ -159,7 +159,7 @@ public:
private:
YUVtoRGBEffect(sk_sp<GrTextureProxy> yProxy, sk_sp<GrTextureProxy> uProxy,
sk_sp<GrTextureProxy> vProxy, const SkMatrix yuvMatrix[3],
- GrSamplerParams::FilterMode uvFilterMode, SkYUVColorSpace colorSpace, bool nv12)
+ GrSamplerState::Filter uvFilterMode, SkYUVColorSpace colorSpace, bool nv12)
: INHERITED(kPreservesOpaqueInput_OptimizationFlag)
, fYTransform(yuvMatrix[0], yProxy.get())
, fYSampler(std::move(yProxy))