SkSL 'key' variables can now be controlled by 'when' expressions
Bug: skia:8880 Change-Id: I075ef57035b37250196d85bc6767eb877e445aa2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206698 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
80658204f4
commit
bcd51e8e6d
@ -22,12 +22,12 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrAARectEffect& _outer = args.fFp.cast<GrAARectEffect>();
|
||||
(void)_outer;
|
||||
auto edgeType = _outer.edgeType();
|
||||
auto edgeType = _outer.edgeType;
|
||||
(void)edgeType;
|
||||
auto rect = _outer.rect();
|
||||
auto rect = _outer.rect;
|
||||
(void)rect;
|
||||
prevRect = float4(-1.0);
|
||||
fRectUniformVar = args.fUniformHandler->addUniform(
|
||||
rectUniformVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, "rectUniform");
|
||||
fragBuilder->codeAppendf(
|
||||
"float4 prevRect = float4(%f, %f, %f, %f);\nhalf alpha;\n@switch (%d) {\n case "
|
||||
@ -41,18 +41,18 @@ public:
|
||||
prevRect.top(),
|
||||
prevRect.right(),
|
||||
prevRect.bottom(),
|
||||
(int)_outer.edgeType(),
|
||||
args.fUniformHandler->getUniformCStr(fRectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectUniformVar));
|
||||
(int)_outer.edgeType,
|
||||
args.fUniformHandler->getUniformCStr(rectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(rectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(rectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(rectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(rectUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(rectUniformVar));
|
||||
fragBuilder->codeAppendf(
|
||||
"max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));\n}\n@if (%d == 2 || %d == 3) {\n "
|
||||
"alpha = 1.0 - alpha;\n}\n%s = %s * alpha;\n",
|
||||
(int)_outer.edgeType(),
|
||||
(int)_outer.edgeType(),
|
||||
(int)_outer.edgeType,
|
||||
(int)_outer.edgeType,
|
||||
args.fOutputColor,
|
||||
args.fInputColor);
|
||||
}
|
||||
@ -61,11 +61,11 @@ private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrAARectEffect& _outer = _proc.cast<GrAARectEffect>();
|
||||
auto edgeType = _outer.edgeType();
|
||||
auto edgeType = _outer.edgeType;
|
||||
(void)edgeType;
|
||||
auto rect = _outer.rect();
|
||||
auto rect = _outer.rect;
|
||||
(void)rect;
|
||||
UniformHandle& rectUniform = fRectUniformVar;
|
||||
UniformHandle& rectUniform = rectUniformVar;
|
||||
(void)rectUniform;
|
||||
|
||||
const SkRect& newRect = GrProcessorEdgeTypeIsAA(edgeType) ? rect.makeInset(.5f, .5f) : rect;
|
||||
@ -75,26 +75,26 @@ private:
|
||||
}
|
||||
}
|
||||
SkRect prevRect = float4(0);
|
||||
UniformHandle fRectUniformVar;
|
||||
UniformHandle rectUniformVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrAARectEffect::onCreateGLSLInstance() const {
|
||||
return new GrGLSLAARectEffect();
|
||||
}
|
||||
void GrAARectEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fEdgeType);
|
||||
b->add32((int32_t)edgeType);
|
||||
}
|
||||
bool GrAARectEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrAARectEffect& that = other.cast<GrAARectEffect>();
|
||||
(void)that;
|
||||
if (fEdgeType != that.fEdgeType) return false;
|
||||
if (fRect != that.fRect) return false;
|
||||
if (edgeType != that.edgeType) return false;
|
||||
if (rect != that.rect) return false;
|
||||
return true;
|
||||
}
|
||||
GrAARectEffect::GrAARectEffect(const GrAARectEffect& src)
|
||||
: INHERITED(kGrAARectEffect_ClassID, src.optimizationFlags())
|
||||
, fEdgeType(src.fEdgeType)
|
||||
, fRect(src.fRect) {}
|
||||
, edgeType(src.edgeType)
|
||||
, rect(src.rect) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrAARectEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrAARectEffect(*this));
|
||||
}
|
||||
|
@ -15,27 +15,25 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrAARectEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
const GrClipEdgeType& edgeType() const { return fEdgeType; }
|
||||
const SkRect& rect() const { return fRect; }
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(GrClipEdgeType edgeType, SkRect rect) {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrAARectEffect(edgeType, rect));
|
||||
}
|
||||
GrAARectEffect(const GrAARectEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "AARectEffect"; }
|
||||
GrClipEdgeType edgeType;
|
||||
SkRect rect;
|
||||
|
||||
private:
|
||||
GrAARectEffect(GrClipEdgeType edgeType, SkRect rect)
|
||||
: INHERITED(kGrAARectEffect_ClassID,
|
||||
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
|
||||
, fEdgeType(edgeType)
|
||||
, fRect(rect) {}
|
||||
, edgeType(edgeType)
|
||||
, rect(rect) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
GrClipEdgeType fEdgeType;
|
||||
SkRect fRect;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -33,14 +33,14 @@ public:
|
||||
const GrAlphaThresholdFragmentProcessor& _outer =
|
||||
args.fFp.cast<GrAlphaThresholdFragmentProcessor>();
|
||||
(void)_outer;
|
||||
auto innerThreshold = _outer.innerThreshold();
|
||||
auto innerThreshold = _outer.innerThreshold;
|
||||
(void)innerThreshold;
|
||||
auto outerThreshold = _outer.outerThreshold();
|
||||
auto outerThreshold = _outer.outerThreshold;
|
||||
(void)outerThreshold;
|
||||
fInnerThresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf_GrSLType, "innerThreshold");
|
||||
fOuterThresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf_GrSLType, "outerThreshold");
|
||||
innerThresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
"innerThreshold");
|
||||
outerThresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
"outerThreshold");
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
"half4 color = %s;\nhalf4 mask_color = texture(%s, %s).%s;\nif (mask_color.w < "
|
||||
@ -52,12 +52,12 @@ public:
|
||||
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
|
||||
sk_TransformedCoords2D_0.c_str(),
|
||||
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
|
||||
args.fUniformHandler->getUniformCStr(fOuterThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(fOuterThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(fOuterThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(fInnerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(fInnerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(fInnerThresholdVar), args.fOutputColor);
|
||||
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(outerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(innerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(innerThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(innerThresholdVar), args.fOutputColor);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -66,12 +66,12 @@ private:
|
||||
const GrAlphaThresholdFragmentProcessor& _outer =
|
||||
_proc.cast<GrAlphaThresholdFragmentProcessor>();
|
||||
{
|
||||
pdman.set1f(fInnerThresholdVar, (_outer.innerThreshold()));
|
||||
pdman.set1f(fOuterThresholdVar, (_outer.outerThreshold()));
|
||||
pdman.set1f(innerThresholdVar, (_outer.innerThreshold));
|
||||
pdman.set1f(outerThresholdVar, (_outer.outerThreshold));
|
||||
}
|
||||
}
|
||||
UniformHandle fInnerThresholdVar;
|
||||
UniformHandle fOuterThresholdVar;
|
||||
UniformHandle innerThresholdVar;
|
||||
UniformHandle outerThresholdVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrAlphaThresholdFragmentProcessor::onCreateGLSLInstance() const {
|
||||
return new GrGLSLAlphaThresholdFragmentProcessor();
|
||||
@ -81,27 +81,27 @@ void GrAlphaThresholdFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps
|
||||
bool GrAlphaThresholdFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrAlphaThresholdFragmentProcessor& that = other.cast<GrAlphaThresholdFragmentProcessor>();
|
||||
(void)that;
|
||||
if (fMask != that.fMask) return false;
|
||||
if (fInnerThreshold != that.fInnerThreshold) return false;
|
||||
if (fOuterThreshold != that.fOuterThreshold) return false;
|
||||
if (mask != that.mask) return false;
|
||||
if (innerThreshold != that.innerThreshold) return false;
|
||||
if (outerThreshold != that.outerThreshold) return false;
|
||||
return true;
|
||||
}
|
||||
GrAlphaThresholdFragmentProcessor::GrAlphaThresholdFragmentProcessor(
|
||||
const GrAlphaThresholdFragmentProcessor& src)
|
||||
: INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID, src.optimizationFlags())
|
||||
, fMask(src.fMask)
|
||||
, fInnerThreshold(src.fInnerThreshold)
|
||||
, fOuterThreshold(src.fOuterThreshold)
|
||||
, fMaskCoordTransform(src.fMaskCoordTransform) {
|
||||
, maskCoordTransform(src.maskCoordTransform)
|
||||
, mask(src.mask)
|
||||
, innerThreshold(src.innerThreshold)
|
||||
, outerThreshold(src.outerThreshold) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
this->addCoordTransform(&fMaskCoordTransform);
|
||||
this->addCoordTransform(&maskCoordTransform);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(*this));
|
||||
}
|
||||
const GrFragmentProcessor::TextureSampler& GrAlphaThresholdFragmentProcessor::onTextureSampler(
|
||||
int index) const {
|
||||
return IthTextureSampler(index, fMask);
|
||||
return IthTextureSampler(index, mask);
|
||||
}
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor);
|
||||
#if GR_TEST_UTILS
|
||||
|
@ -16,8 +16,6 @@
|
||||
class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor {
|
||||
public:
|
||||
inline OptimizationFlags optFlags(float outerThreshold);
|
||||
float innerThreshold() const { return fInnerThreshold; }
|
||||
float outerThreshold() const { return fOuterThreshold; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> mask,
|
||||
float innerThreshold,
|
||||
@ -29,29 +27,29 @@ public:
|
||||
GrAlphaThresholdFragmentProcessor(const GrAlphaThresholdFragmentProcessor& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "AlphaThresholdFragmentProcessor"; }
|
||||
GrCoordTransform maskCoordTransform;
|
||||
TextureSampler mask;
|
||||
float innerThreshold;
|
||||
float outerThreshold;
|
||||
|
||||
private:
|
||||
GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> mask, float innerThreshold,
|
||||
float outerThreshold, const SkIRect& bounds)
|
||||
: INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID, kNone_OptimizationFlags)
|
||||
, fMask(std::move(mask))
|
||||
, fInnerThreshold(innerThreshold)
|
||||
, fOuterThreshold(outerThreshold)
|
||||
, fMaskCoordTransform(
|
||||
, maskCoordTransform(
|
||||
SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())),
|
||||
fMask.proxy()) {
|
||||
mask.get())
|
||||
, mask(std::move(mask))
|
||||
, innerThreshold(innerThreshold)
|
||||
, outerThreshold(outerThreshold) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
this->addCoordTransform(&fMaskCoordTransform);
|
||||
this->addCoordTransform(&maskCoordTransform);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
const TextureSampler& onTextureSampler(int) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
TextureSampler fMask;
|
||||
float fInnerThreshold;
|
||||
float fOuterThreshold;
|
||||
GrCoordTransform fMaskCoordTransform;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -23,14 +23,14 @@ public:
|
||||
const GrBlurredEdgeFragmentProcessor& _outer =
|
||||
args.fFp.cast<GrBlurredEdgeFragmentProcessor>();
|
||||
(void)_outer;
|
||||
auto mode = _outer.mode();
|
||||
auto mode = _outer.mode;
|
||||
(void)mode;
|
||||
fragBuilder->codeAppendf(
|
||||
"half factor = 1.0 - %s.w;\n@switch (%d) {\n case 0:\n factor = "
|
||||
"exp((-factor * factor) * 4.0) - 0.017999999999999999;\n break;\n case "
|
||||
"1:\n factor = smoothstep(1.0, 0.0, factor);\n break;\n}\n%s = "
|
||||
"half4(factor);\n",
|
||||
args.fInputColor, (int)_outer.mode(), args.fOutputColor);
|
||||
args.fInputColor, (int)_outer.mode, args.fOutputColor);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -42,18 +42,18 @@ GrGLSLFragmentProcessor* GrBlurredEdgeFragmentProcessor::onCreateGLSLInstance()
|
||||
}
|
||||
void GrBlurredEdgeFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fMode);
|
||||
b->add32((int32_t)mode);
|
||||
}
|
||||
bool GrBlurredEdgeFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrBlurredEdgeFragmentProcessor& that = other.cast<GrBlurredEdgeFragmentProcessor>();
|
||||
(void)that;
|
||||
if (fMode != that.fMode) return false;
|
||||
if (mode != that.mode) return false;
|
||||
return true;
|
||||
}
|
||||
GrBlurredEdgeFragmentProcessor::GrBlurredEdgeFragmentProcessor(
|
||||
const GrBlurredEdgeFragmentProcessor& src)
|
||||
: INHERITED(kGrBlurredEdgeFragmentProcessor_ClassID, src.optimizationFlags())
|
||||
, fMode(src.fMode) {}
|
||||
, mode(src.mode) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrBlurredEdgeFragmentProcessor::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(*this));
|
||||
}
|
||||
|
@ -16,23 +16,22 @@
|
||||
class GrBlurredEdgeFragmentProcessor : public GrFragmentProcessor {
|
||||
public:
|
||||
enum class Mode { kGaussian = 0, kSmoothStep = 1 };
|
||||
const Mode& mode() const { return fMode; }
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(Mode mode) {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(mode));
|
||||
}
|
||||
GrBlurredEdgeFragmentProcessor(const GrBlurredEdgeFragmentProcessor& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "BlurredEdgeFragmentProcessor"; }
|
||||
Mode mode;
|
||||
|
||||
private:
|
||||
GrBlurredEdgeFragmentProcessor(Mode mode)
|
||||
: INHERITED(kGrBlurredEdgeFragmentProcessor_ClassID, kNone_OptimizationFlags)
|
||||
, fMode(mode) {}
|
||||
, mode(mode) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
Mode fMode;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -264,24 +264,24 @@ public:
|
||||
const GrCircleBlurFragmentProcessor& _outer =
|
||||
args.fFp.cast<GrCircleBlurFragmentProcessor>();
|
||||
(void)_outer;
|
||||
auto circleRect = _outer.circleRect();
|
||||
auto circleRect = _outer.circleRect;
|
||||
(void)circleRect;
|
||||
auto textureRadius = _outer.textureRadius();
|
||||
auto textureRadius = _outer.textureRadius;
|
||||
(void)textureRadius;
|
||||
auto solidRadius = _outer.solidRadius();
|
||||
auto solidRadius = _outer.solidRadius;
|
||||
(void)solidRadius;
|
||||
fCircleDataVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
circleDataVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
"circleData");
|
||||
fragBuilder->codeAppendf(
|
||||
"half2 vec = half2(half((sk_FragCoord.x - float(%s.x)) * float(%s.w)), "
|
||||
"half((sk_FragCoord.y - float(%s.y)) * float(%s.w)));\nhalf dist = length(vec) + "
|
||||
"(0.5 - %s.z) * %s.w;\n%s = %s * texture(%s, float2(half2(dist, 0.5))).%s.w;\n",
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleDataVar), args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar),
|
||||
args.fUniformHandler->getUniformCStr(circleDataVar), args.fOutputColor,
|
||||
args.fInputColor,
|
||||
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
|
||||
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
|
||||
@ -291,22 +291,22 @@ private:
|
||||
void onSetData(const GrGLSLProgramDataManager& data,
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrCircleBlurFragmentProcessor& _outer = _proc.cast<GrCircleBlurFragmentProcessor>();
|
||||
auto circleRect = _outer.circleRect();
|
||||
auto circleRect = _outer.circleRect;
|
||||
(void)circleRect;
|
||||
auto textureRadius = _outer.textureRadius();
|
||||
auto textureRadius = _outer.textureRadius;
|
||||
(void)textureRadius;
|
||||
auto solidRadius = _outer.solidRadius();
|
||||
auto solidRadius = _outer.solidRadius;
|
||||
(void)solidRadius;
|
||||
GrSurfaceProxy& blurProfileSamplerProxy = *_outer.textureSampler(0).proxy();
|
||||
GrTexture& blurProfileSampler = *blurProfileSamplerProxy.peekTexture();
|
||||
(void)blurProfileSampler;
|
||||
UniformHandle& circleData = fCircleDataVar;
|
||||
UniformHandle& circleData = circleDataVar;
|
||||
(void)circleData;
|
||||
|
||||
data.set4f(circleData, circleRect.centerX(), circleRect.centerY(), solidRadius,
|
||||
1.f / textureRadius);
|
||||
}
|
||||
UniformHandle fCircleDataVar;
|
||||
UniformHandle circleDataVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrCircleBlurFragmentProcessor::onCreateGLSLInstance() const {
|
||||
return new GrGLSLCircleBlurFragmentProcessor();
|
||||
@ -316,19 +316,19 @@ void GrCircleBlurFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& ca
|
||||
bool GrCircleBlurFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrCircleBlurFragmentProcessor& that = other.cast<GrCircleBlurFragmentProcessor>();
|
||||
(void)that;
|
||||
if (fCircleRect != that.fCircleRect) return false;
|
||||
if (fTextureRadius != that.fTextureRadius) return false;
|
||||
if (fSolidRadius != that.fSolidRadius) return false;
|
||||
if (fBlurProfileSampler != that.fBlurProfileSampler) return false;
|
||||
if (circleRect != that.circleRect) return false;
|
||||
if (textureRadius != that.textureRadius) return false;
|
||||
if (solidRadius != that.solidRadius) return false;
|
||||
if (blurProfileSampler != that.blurProfileSampler) return false;
|
||||
return true;
|
||||
}
|
||||
GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(
|
||||
const GrCircleBlurFragmentProcessor& src)
|
||||
: INHERITED(kGrCircleBlurFragmentProcessor_ClassID, src.optimizationFlags())
|
||||
, fCircleRect(src.fCircleRect)
|
||||
, fTextureRadius(src.fTextureRadius)
|
||||
, fSolidRadius(src.fSolidRadius)
|
||||
, fBlurProfileSampler(src.fBlurProfileSampler) {
|
||||
, circleRect(src.circleRect)
|
||||
, textureRadius(src.textureRadius)
|
||||
, solidRadius(src.solidRadius)
|
||||
, blurProfileSampler(src.blurProfileSampler) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::clone() const {
|
||||
@ -336,7 +336,7 @@ std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::clone() cons
|
||||
}
|
||||
const GrFragmentProcessor::TextureSampler& GrCircleBlurFragmentProcessor::onTextureSampler(
|
||||
int index) const {
|
||||
return IthTextureSampler(index, fBlurProfileSampler);
|
||||
return IthTextureSampler(index, blurProfileSampler);
|
||||
}
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor);
|
||||
#if GR_TEST_UTILS
|
||||
|
@ -15,25 +15,25 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrCircleBlurFragmentProcessor : public GrFragmentProcessor {
|
||||
public:
|
||||
const SkRect& circleRect() const { return fCircleRect; }
|
||||
float textureRadius() const { return fTextureRadius; }
|
||||
float solidRadius() const { return fSolidRadius; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(GrProxyProvider*, const SkRect& circle,
|
||||
float sigma);
|
||||
GrCircleBlurFragmentProcessor(const GrCircleBlurFragmentProcessor& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "CircleBlurFragmentProcessor"; }
|
||||
SkRect circleRect;
|
||||
float textureRadius;
|
||||
float solidRadius;
|
||||
TextureSampler blurProfileSampler;
|
||||
|
||||
private:
|
||||
GrCircleBlurFragmentProcessor(SkRect circleRect, float textureRadius, float solidRadius,
|
||||
sk_sp<GrTextureProxy> blurProfileSampler)
|
||||
: INHERITED(kGrCircleBlurFragmentProcessor_ClassID,
|
||||
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
|
||||
, fCircleRect(circleRect)
|
||||
, fTextureRadius(textureRadius)
|
||||
, fSolidRadius(solidRadius)
|
||||
, fBlurProfileSampler(std::move(blurProfileSampler)) {
|
||||
, circleRect(circleRect)
|
||||
, textureRadius(textureRadius)
|
||||
, solidRadius(solidRadius)
|
||||
, blurProfileSampler(std::move(blurProfileSampler)) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
@ -41,10 +41,6 @@ private:
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
const TextureSampler& onTextureSampler(int) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkRect fCircleRect;
|
||||
float fTextureRadius;
|
||||
float fSolidRadius;
|
||||
TextureSampler fBlurProfileSampler;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,14 +22,14 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrCircleEffect& _outer = args.fFp.cast<GrCircleEffect>();
|
||||
(void)_outer;
|
||||
auto edgeType = _outer.edgeType();
|
||||
auto edgeType = _outer.edgeType;
|
||||
(void)edgeType;
|
||||
auto center = _outer.center();
|
||||
auto center = _outer.center;
|
||||
(void)center;
|
||||
auto radius = _outer.radius();
|
||||
auto radius = _outer.radius;
|
||||
(void)radius;
|
||||
prevRadius = -1.0;
|
||||
fCircleVar =
|
||||
circleVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "circle");
|
||||
fragBuilder->codeAppendf(
|
||||
"half2 prevCenter;\nhalf prevRadius = %f;\nhalf d;\n@if (%d == 2 || %d == 3) {\n "
|
||||
@ -38,28 +38,27 @@ public:
|
||||
"sk_FragCoord.xy) * float(%s.w))) * float(%s.z));\n}\n@if ((%d == 1 || %d == 3) || "
|
||||
"%d == 4) {\n d = clamp(d, 0.0, 1.0);\n} else {\n d = d > 0.5 ? 1.0 : "
|
||||
"0.0;\n}\n%s = %s * d;\n",
|
||||
prevRadius, (int)_outer.edgeType(), (int)_outer.edgeType(),
|
||||
args.fUniformHandler->getUniformCStr(fCircleVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleVar),
|
||||
args.fUniformHandler->getUniformCStr(fCircleVar), (int)_outer.edgeType(),
|
||||
(int)_outer.edgeType(), (int)_outer.edgeType(), args.fOutputColor,
|
||||
args.fInputColor);
|
||||
prevRadius, (int)_outer.edgeType, (int)_outer.edgeType,
|
||||
args.fUniformHandler->getUniformCStr(circleVar),
|
||||
args.fUniformHandler->getUniformCStr(circleVar),
|
||||
args.fUniformHandler->getUniformCStr(circleVar),
|
||||
args.fUniformHandler->getUniformCStr(circleVar),
|
||||
args.fUniformHandler->getUniformCStr(circleVar),
|
||||
args.fUniformHandler->getUniformCStr(circleVar), (int)_outer.edgeType,
|
||||
(int)_outer.edgeType, (int)_outer.edgeType, args.fOutputColor, args.fInputColor);
|
||||
}
|
||||
|
||||
private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrCircleEffect& _outer = _proc.cast<GrCircleEffect>();
|
||||
auto edgeType = _outer.edgeType();
|
||||
auto edgeType = _outer.edgeType;
|
||||
(void)edgeType;
|
||||
auto center = _outer.center();
|
||||
auto center = _outer.center;
|
||||
(void)center;
|
||||
auto radius = _outer.radius();
|
||||
auto radius = _outer.radius;
|
||||
(void)radius;
|
||||
UniformHandle& circle = fCircleVar;
|
||||
UniformHandle& circle = circleVar;
|
||||
(void)circle;
|
||||
|
||||
if (radius != prevRadius || center != prevCenter) {
|
||||
@ -80,28 +79,28 @@ private:
|
||||
}
|
||||
SkPoint prevCenter = half2(0);
|
||||
float prevRadius = 0;
|
||||
UniformHandle fCircleVar;
|
||||
UniformHandle circleVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrCircleEffect::onCreateGLSLInstance() const {
|
||||
return new GrGLSLCircleEffect();
|
||||
}
|
||||
void GrCircleEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fEdgeType);
|
||||
b->add32((int32_t)edgeType);
|
||||
}
|
||||
bool GrCircleEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrCircleEffect& that = other.cast<GrCircleEffect>();
|
||||
(void)that;
|
||||
if (fEdgeType != that.fEdgeType) return false;
|
||||
if (fCenter != that.fCenter) return false;
|
||||
if (fRadius != that.fRadius) return false;
|
||||
if (edgeType != that.edgeType) return false;
|
||||
if (center != that.center) return false;
|
||||
if (radius != that.radius) return false;
|
||||
return true;
|
||||
}
|
||||
GrCircleEffect::GrCircleEffect(const GrCircleEffect& src)
|
||||
: INHERITED(kGrCircleEffect_ClassID, src.optimizationFlags())
|
||||
, fEdgeType(src.fEdgeType)
|
||||
, fCenter(src.fCenter)
|
||||
, fRadius(src.fRadius) {}
|
||||
, edgeType(src.edgeType)
|
||||
, center(src.center)
|
||||
, radius(src.radius) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrCircleEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrCircleEffect(*this));
|
||||
}
|
||||
|
@ -15,10 +15,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrCircleEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
const GrClipEdgeType& edgeType() const { return fEdgeType; }
|
||||
const SkPoint& center() const { return fCenter; }
|
||||
float radius() const { return fRadius; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(GrClipEdgeType edgeType, SkPoint center,
|
||||
float radius) {
|
||||
// A radius below half causes the implicit insetting done by this processor to become
|
||||
@ -31,21 +27,21 @@ public:
|
||||
GrCircleEffect(const GrCircleEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "CircleEffect"; }
|
||||
GrClipEdgeType edgeType;
|
||||
SkPoint center;
|
||||
float radius;
|
||||
|
||||
private:
|
||||
GrCircleEffect(GrClipEdgeType edgeType, SkPoint center, float radius)
|
||||
: INHERITED(kGrCircleEffect_ClassID,
|
||||
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
|
||||
, fEdgeType(edgeType)
|
||||
, fCenter(center)
|
||||
, fRadius(radius) {}
|
||||
, edgeType(edgeType)
|
||||
, center(center)
|
||||
, radius(radius) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
GrClipEdgeType fEdgeType;
|
||||
SkPoint fCenter;
|
||||
float fRadius;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrConfigConversionEffect& _outer = args.fFp.cast<GrConfigConversionEffect>();
|
||||
(void)_outer;
|
||||
auto pmConversion = _outer.pmConversion();
|
||||
auto pmConversion = _outer.pmConversion;
|
||||
(void)pmConversion;
|
||||
|
||||
fragBuilder->forceHighPrecision();
|
||||
@ -31,7 +31,7 @@ public:
|
||||
"%s.xyz = floor((%s.xyz * %s.w) * 255.0 + 0.5) / 255.0;\n break;\n case "
|
||||
"1:\n %s.xyz = %s.w <= 0.0 ? half3(0.0) : floor((%s.xyz / %s.w) * 255.0 + "
|
||||
"0.5) / 255.0;\n break;\n}\n",
|
||||
args.fOutputColor, args.fInputColor, (int)_outer.pmConversion(), args.fOutputColor,
|
||||
args.fOutputColor, args.fInputColor, (int)_outer.pmConversion, args.fOutputColor,
|
||||
args.fOutputColor, args.fOutputColor, args.fOutputColor, args.fOutputColor,
|
||||
args.fOutputColor, args.fOutputColor);
|
||||
}
|
||||
@ -45,17 +45,17 @@ GrGLSLFragmentProcessor* GrConfigConversionEffect::onCreateGLSLInstance() const
|
||||
}
|
||||
void GrConfigConversionEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fPmConversion);
|
||||
b->add32((int32_t)pmConversion);
|
||||
}
|
||||
bool GrConfigConversionEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrConfigConversionEffect& that = other.cast<GrConfigConversionEffect>();
|
||||
(void)that;
|
||||
if (fPmConversion != that.fPmConversion) return false;
|
||||
if (pmConversion != that.pmConversion) return false;
|
||||
return true;
|
||||
}
|
||||
GrConfigConversionEffect::GrConfigConversionEffect(const GrConfigConversionEffect& src)
|
||||
: INHERITED(kGrConfigConversionEffect_ClassID, src.optimizationFlags())
|
||||
, fPmConversion(src.fPmConversion) {}
|
||||
, pmConversion(src.pmConversion) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrConfigConversionEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrConfigConversionEffect(*this));
|
||||
}
|
||||
|
@ -132,7 +132,6 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
const PMConversion& pmConversion() const { return fPmConversion; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp,
|
||||
PMConversion pmConversion) {
|
||||
@ -146,16 +145,16 @@ public:
|
||||
GrConfigConversionEffect(const GrConfigConversionEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "ConfigConversionEffect"; }
|
||||
PMConversion pmConversion;
|
||||
|
||||
private:
|
||||
GrConfigConversionEffect(PMConversion pmConversion)
|
||||
: INHERITED(kGrConfigConversionEffect_ClassID, kNone_OptimizationFlags)
|
||||
, fPmConversion(pmConversion) {}
|
||||
, pmConversion(pmConversion) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
PMConversion fPmConversion;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,21 +22,20 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrConstColorProcessor& _outer = args.fFp.cast<GrConstColorProcessor>();
|
||||
(void)_outer;
|
||||
auto color = _outer.color();
|
||||
auto color = _outer.color;
|
||||
(void)color;
|
||||
auto mode = _outer.mode();
|
||||
auto mode = _outer.mode;
|
||||
(void)mode;
|
||||
fColorVar =
|
||||
colorVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "color");
|
||||
fragBuilder->codeAppendf(
|
||||
"@switch (%d) {\n case 0:\n %s = %s;\n break;\n case 1:\n "
|
||||
" %s = %s * %s;\n break;\n case 2:\n %s = %s.w * %s;\n "
|
||||
"break;\n}\n",
|
||||
(int)_outer.mode(), args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(fColorVar), args.fOutputColor,
|
||||
args.fInputColor, args.fUniformHandler->getUniformCStr(fColorVar),
|
||||
(int)_outer.mode, args.fOutputColor, args.fUniformHandler->getUniformCStr(colorVar),
|
||||
args.fOutputColor, args.fInputColor, args.fUniformHandler->getUniformCStr(colorVar),
|
||||
args.fOutputColor, args.fInputColor,
|
||||
args.fUniformHandler->getUniformCStr(fColorVar));
|
||||
args.fUniformHandler->getUniformCStr(colorVar));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -44,34 +43,34 @@ private:
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrConstColorProcessor& _outer = _proc.cast<GrConstColorProcessor>();
|
||||
{
|
||||
const SkPMColor4f& colorValue = _outer.color();
|
||||
if (fColorPrev != colorValue) {
|
||||
fColorPrev = colorValue;
|
||||
pdman.set4fv(fColorVar, 1, colorValue.vec());
|
||||
const SkPMColor4f& colorValue = _outer.color;
|
||||
if (colorPrev != colorValue) {
|
||||
colorPrev = colorValue;
|
||||
pdman.set4fv(colorVar, 1, colorValue.vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
SkPMColor4f fColorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
UniformHandle fColorVar;
|
||||
SkPMColor4f colorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
UniformHandle colorVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrConstColorProcessor::onCreateGLSLInstance() const {
|
||||
return new GrGLSLConstColorProcessor();
|
||||
}
|
||||
void GrConstColorProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fMode);
|
||||
b->add32((int32_t)mode);
|
||||
}
|
||||
bool GrConstColorProcessor::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrConstColorProcessor& that = other.cast<GrConstColorProcessor>();
|
||||
(void)that;
|
||||
if (fColor != that.fColor) return false;
|
||||
if (fMode != that.fMode) return false;
|
||||
if (color != that.color) return false;
|
||||
if (mode != that.mode) return false;
|
||||
return true;
|
||||
}
|
||||
GrConstColorProcessor::GrConstColorProcessor(const GrConstColorProcessor& src)
|
||||
: INHERITED(kGrConstColorProcessor_ClassID, src.optimizationFlags())
|
||||
, fColor(src.fColor)
|
||||
, fMode(src.fMode) {}
|
||||
, color(src.color)
|
||||
, mode(src.mode) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrConstColorProcessor::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrConstColorProcessor(*this));
|
||||
}
|
||||
|
@ -49,13 +49,13 @@ void main() {
|
||||
}
|
||||
|
||||
SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override {
|
||||
switch (fMode) {
|
||||
switch (mode) {
|
||||
case InputMode::kIgnore:
|
||||
return fColor;
|
||||
return color;
|
||||
case InputMode::kModulateA:
|
||||
return fColor * input.fA;
|
||||
return color * input.fA;
|
||||
case InputMode::kModulateRGBA:
|
||||
return fColor * input;
|
||||
return color * input;
|
||||
}
|
||||
SK_ABORT("Unexpected mode");
|
||||
return SK_PMColor4fTRANSPARENT;
|
||||
|
@ -31,37 +31,35 @@ public:
|
||||
}
|
||||
|
||||
SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override {
|
||||
switch (fMode) {
|
||||
switch (mode) {
|
||||
case InputMode::kIgnore:
|
||||
return fColor;
|
||||
return color;
|
||||
case InputMode::kModulateA:
|
||||
return fColor * input.fA;
|
||||
return color * input.fA;
|
||||
case InputMode::kModulateRGBA:
|
||||
return fColor * input;
|
||||
return color * input;
|
||||
}
|
||||
SK_ABORT("Unexpected mode");
|
||||
return SK_PMColor4fTRANSPARENT;
|
||||
}
|
||||
const SkPMColor4f& color() const { return fColor; }
|
||||
const InputMode& mode() const { return fMode; }
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(SkPMColor4f color, InputMode mode) {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
|
||||
}
|
||||
GrConstColorProcessor(const GrConstColorProcessor& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "ConstColorProcessor"; }
|
||||
SkPMColor4f color;
|
||||
InputMode mode;
|
||||
|
||||
private:
|
||||
GrConstColorProcessor(SkPMColor4f color, InputMode mode)
|
||||
: INHERITED(kGrConstColorProcessor_ClassID, (OptimizationFlags)OptFlags(color, mode))
|
||||
, fColor(color)
|
||||
, fMode(mode) {}
|
||||
, color(color)
|
||||
, mode(mode) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkPMColor4f fColor;
|
||||
InputMode fMode;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,18 +22,18 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrEllipseEffect& _outer = args.fFp.cast<GrEllipseEffect>();
|
||||
(void)_outer;
|
||||
auto edgeType = _outer.edgeType();
|
||||
auto edgeType = _outer.edgeType;
|
||||
(void)edgeType;
|
||||
auto center = _outer.center();
|
||||
auto center = _outer.center;
|
||||
(void)center;
|
||||
auto radii = _outer.radii();
|
||||
auto radii = _outer.radii;
|
||||
(void)radii;
|
||||
prevRadii = float2(-1.0);
|
||||
medPrecision = !sk_Caps.floatIs32Bits;
|
||||
fEllipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
ellipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"ellipse");
|
||||
if (medPrecision) {
|
||||
fScaleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat2_GrSLType,
|
||||
scaleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat2_GrSLType,
|
||||
"scale");
|
||||
}
|
||||
fragBuilder->codeAppendf(
|
||||
@ -45,33 +45,32 @@ public:
|
||||
"1.1755e-38);\n}\nfloat approx_dist = implicit * inversesqrt(grad_dot);\n@if "
|
||||
"(medPrecision) {\n approx_dist *= %s.x;\n}\nhalf alpha;\n@switch ",
|
||||
prevRadii.fX, prevRadii.fY, (medPrecision ? "true" : "false"),
|
||||
args.fUniformHandler->getUniformCStr(fEllipseVar),
|
||||
fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "float2(0)",
|
||||
args.fUniformHandler->getUniformCStr(fEllipseVar),
|
||||
fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar)
|
||||
: "float2(0)");
|
||||
args.fUniformHandler->getUniformCStr(ellipseVar),
|
||||
scaleVar.isValid() ? args.fUniformHandler->getUniformCStr(scaleVar) : "float2(0)",
|
||||
args.fUniformHandler->getUniformCStr(ellipseVar),
|
||||
scaleVar.isValid() ? args.fUniformHandler->getUniformCStr(scaleVar) : "float2(0)");
|
||||
fragBuilder->codeAppendf(
|
||||
"(%d) {\n case 0:\n alpha = approx_dist > 0.0 ? 0.0 : 1.0;\n "
|
||||
"break;\n case 1:\n alpha = clamp(0.5 - half(approx_dist), 0.0, 1.0);\n "
|
||||
" break;\n case 2:\n alpha = approx_dist > 0.0 ? 1.0 : 0.0;\n "
|
||||
" break;\n case 3:\n alpha = clamp(0.5 + half(approx_dist), 0.0, 1.0);\n "
|
||||
" break;\n default:\n discard;\n}\n%s = %s * alpha;\n",
|
||||
(int)_outer.edgeType(), args.fOutputColor, args.fInputColor);
|
||||
(int)_outer.edgeType, args.fOutputColor, args.fInputColor);
|
||||
}
|
||||
|
||||
private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrEllipseEffect& _outer = _proc.cast<GrEllipseEffect>();
|
||||
auto edgeType = _outer.edgeType();
|
||||
auto edgeType = _outer.edgeType;
|
||||
(void)edgeType;
|
||||
auto center = _outer.center();
|
||||
auto center = _outer.center;
|
||||
(void)center;
|
||||
auto radii = _outer.radii();
|
||||
auto radii = _outer.radii;
|
||||
(void)radii;
|
||||
UniformHandle& ellipse = fEllipseVar;
|
||||
UniformHandle& ellipse = ellipseVar;
|
||||
(void)ellipse;
|
||||
UniformHandle& scale = fScaleVar;
|
||||
UniformHandle& scale = scaleVar;
|
||||
(void)scale;
|
||||
|
||||
if (radii != prevRadii || center != prevCenter) {
|
||||
@ -102,29 +101,29 @@ private:
|
||||
SkPoint prevCenter = float2(0);
|
||||
SkPoint prevRadii = float2(0);
|
||||
bool medPrecision = false;
|
||||
UniformHandle fEllipseVar;
|
||||
UniformHandle fScaleVar;
|
||||
UniformHandle ellipseVar;
|
||||
UniformHandle scaleVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrEllipseEffect::onCreateGLSLInstance() const {
|
||||
return new GrGLSLEllipseEffect();
|
||||
}
|
||||
void GrEllipseEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fEdgeType);
|
||||
b->add32((int32_t)edgeType);
|
||||
}
|
||||
bool GrEllipseEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrEllipseEffect& that = other.cast<GrEllipseEffect>();
|
||||
(void)that;
|
||||
if (fEdgeType != that.fEdgeType) return false;
|
||||
if (fCenter != that.fCenter) return false;
|
||||
if (fRadii != that.fRadii) return false;
|
||||
if (edgeType != that.edgeType) return false;
|
||||
if (center != that.center) return false;
|
||||
if (radii != that.radii) return false;
|
||||
return true;
|
||||
}
|
||||
GrEllipseEffect::GrEllipseEffect(const GrEllipseEffect& src)
|
||||
: INHERITED(kGrEllipseEffect_ClassID, src.optimizationFlags())
|
||||
, fEdgeType(src.fEdgeType)
|
||||
, fCenter(src.fCenter)
|
||||
, fRadii(src.fRadii) {}
|
||||
, edgeType(src.edgeType)
|
||||
, center(src.center)
|
||||
, radii(src.radii) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrEllipseEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrEllipseEffect(*this));
|
||||
}
|
||||
|
@ -17,10 +17,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrEllipseEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
const GrClipEdgeType& edgeType() const { return fEdgeType; }
|
||||
const SkPoint& center() const { return fCenter; }
|
||||
const SkPoint& radii() const { return fRadii; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(GrClipEdgeType edgeType, SkPoint center,
|
||||
SkPoint radii, const GrShaderCaps& caps) {
|
||||
// Small radii produce bad results on devices without full float.
|
||||
@ -40,21 +36,21 @@ public:
|
||||
GrEllipseEffect(const GrEllipseEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "EllipseEffect"; }
|
||||
GrClipEdgeType edgeType;
|
||||
SkPoint center;
|
||||
SkPoint radii;
|
||||
|
||||
private:
|
||||
GrEllipseEffect(GrClipEdgeType edgeType, SkPoint center, SkPoint radii)
|
||||
: INHERITED(kGrEllipseEffect_ClassID,
|
||||
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
|
||||
, fEdgeType(edgeType)
|
||||
, fCenter(center)
|
||||
, fRadii(radii) {}
|
||||
, edgeType(edgeType)
|
||||
, center(center)
|
||||
, radii(radii) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
GrClipEdgeType fEdgeType;
|
||||
SkPoint fCenter;
|
||||
SkPoint fRadii;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,29 +22,29 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrMagnifierEffect& _outer = args.fFp.cast<GrMagnifierEffect>();
|
||||
(void)_outer;
|
||||
auto bounds = _outer.bounds();
|
||||
auto bounds = _outer.bounds;
|
||||
(void)bounds;
|
||||
auto srcRect = _outer.srcRect();
|
||||
auto srcRect = _outer.srcRect;
|
||||
(void)srcRect;
|
||||
auto xInvZoom = _outer.xInvZoom();
|
||||
auto xInvZoom = _outer.xInvZoom;
|
||||
(void)xInvZoom;
|
||||
auto yInvZoom = _outer.yInvZoom();
|
||||
auto yInvZoom = _outer.yInvZoom;
|
||||
(void)yInvZoom;
|
||||
auto xInvInset = _outer.xInvInset();
|
||||
auto xInvInset = _outer.xInvInset;
|
||||
(void)xInvInset;
|
||||
auto yInvInset = _outer.yInvInset();
|
||||
auto yInvInset = _outer.yInvInset;
|
||||
(void)yInvInset;
|
||||
fBoundsUniformVar = args.fUniformHandler->addUniform(
|
||||
boundsUniformVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, "boundsUniform");
|
||||
fXInvZoomVar = args.fUniformHandler->addUniform(
|
||||
xInvZoomVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, "xInvZoom");
|
||||
fYInvZoomVar = args.fUniformHandler->addUniform(
|
||||
yInvZoomVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, "yInvZoom");
|
||||
fXInvInsetVar = args.fUniformHandler->addUniform(
|
||||
xInvInsetVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, "xInvInset");
|
||||
fYInvInsetVar = args.fUniformHandler->addUniform(
|
||||
yInvInsetVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat_GrSLType, "yInvInset");
|
||||
fOffsetVar =
|
||||
offsetVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType, "offset");
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
@ -56,13 +56,13 @@ public:
|
||||
"weight = min(dist * dist, 1.0);\n} else {\n float2 delta_squared = delta * "
|
||||
"delta;\n weight = min(min(delta_squared.x, delta_square",
|
||||
sk_TransformedCoords2D_0.c_str(),
|
||||
args.fUniformHandler->getUniformCStr(fOffsetVar),
|
||||
args.fUniformHandler->getUniformCStr(fXInvZoomVar),
|
||||
args.fUniformHandler->getUniformCStr(fYInvZoomVar),
|
||||
args.fUniformHandler->getUniformCStr(fBoundsUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(fBoundsUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(fXInvInsetVar),
|
||||
args.fUniformHandler->getUniformCStr(fYInvInsetVar));
|
||||
args.fUniformHandler->getUniformCStr(offsetVar),
|
||||
args.fUniformHandler->getUniformCStr(xInvZoomVar),
|
||||
args.fUniformHandler->getUniformCStr(yInvZoomVar),
|
||||
args.fUniformHandler->getUniformCStr(boundsUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(boundsUniformVar),
|
||||
args.fUniformHandler->getUniformCStr(xInvInsetVar),
|
||||
args.fUniformHandler->getUniformCStr(yInvInsetVar));
|
||||
fragBuilder->codeAppendf(
|
||||
"d.y), 1.0);\n}\n%s = texture(%s, mix(coord, zoom_coord, weight)).%s;\n",
|
||||
args.fOutputColor,
|
||||
@ -75,29 +75,29 @@ private:
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrMagnifierEffect& _outer = _proc.cast<GrMagnifierEffect>();
|
||||
{
|
||||
pdman.set1f(fXInvZoomVar, (_outer.xInvZoom()));
|
||||
pdman.set1f(fYInvZoomVar, (_outer.yInvZoom()));
|
||||
pdman.set1f(fXInvInsetVar, (_outer.xInvInset()));
|
||||
pdman.set1f(fYInvInsetVar, (_outer.yInvInset()));
|
||||
pdman.set1f(xInvZoomVar, (_outer.xInvZoom));
|
||||
pdman.set1f(yInvZoomVar, (_outer.yInvZoom));
|
||||
pdman.set1f(xInvInsetVar, (_outer.xInvInset));
|
||||
pdman.set1f(yInvInsetVar, (_outer.yInvInset));
|
||||
}
|
||||
GrSurfaceProxy& srcProxy = *_outer.textureSampler(0).proxy();
|
||||
GrTexture& src = *srcProxy.peekTexture();
|
||||
(void)src;
|
||||
auto bounds = _outer.bounds();
|
||||
auto bounds = _outer.bounds;
|
||||
(void)bounds;
|
||||
UniformHandle& boundsUniform = fBoundsUniformVar;
|
||||
UniformHandle& boundsUniform = boundsUniformVar;
|
||||
(void)boundsUniform;
|
||||
auto srcRect = _outer.srcRect();
|
||||
auto srcRect = _outer.srcRect;
|
||||
(void)srcRect;
|
||||
UniformHandle& xInvZoom = fXInvZoomVar;
|
||||
UniformHandle& xInvZoom = xInvZoomVar;
|
||||
(void)xInvZoom;
|
||||
UniformHandle& yInvZoom = fYInvZoomVar;
|
||||
UniformHandle& yInvZoom = yInvZoomVar;
|
||||
(void)yInvZoom;
|
||||
UniformHandle& xInvInset = fXInvInsetVar;
|
||||
UniformHandle& xInvInset = xInvInsetVar;
|
||||
(void)xInvInset;
|
||||
UniformHandle& yInvInset = fYInvInsetVar;
|
||||
UniformHandle& yInvInset = yInvInsetVar;
|
||||
(void)yInvInset;
|
||||
UniformHandle& offset = fOffsetVar;
|
||||
UniformHandle& offset = offsetVar;
|
||||
(void)offset;
|
||||
|
||||
SkScalar invW = 1.0f / src.width();
|
||||
@ -125,12 +125,12 @@ private:
|
||||
SkIntToScalar(src.height()) / bounds.height());
|
||||
}
|
||||
}
|
||||
UniformHandle fBoundsUniformVar;
|
||||
UniformHandle fOffsetVar;
|
||||
UniformHandle fXInvZoomVar;
|
||||
UniformHandle fYInvZoomVar;
|
||||
UniformHandle fXInvInsetVar;
|
||||
UniformHandle fYInvInsetVar;
|
||||
UniformHandle boundsUniformVar;
|
||||
UniformHandle offsetVar;
|
||||
UniformHandle xInvZoomVar;
|
||||
UniformHandle yInvZoomVar;
|
||||
UniformHandle xInvInsetVar;
|
||||
UniformHandle yInvInsetVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrMagnifierEffect::onCreateGLSLInstance() const {
|
||||
return new GrGLSLMagnifierEffect();
|
||||
@ -140,33 +140,33 @@ void GrMagnifierEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrMagnifierEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrMagnifierEffect& that = other.cast<GrMagnifierEffect>();
|
||||
(void)that;
|
||||
if (fSrc != that.fSrc) return false;
|
||||
if (fBounds != that.fBounds) return false;
|
||||
if (fSrcRect != that.fSrcRect) return false;
|
||||
if (fXInvZoom != that.fXInvZoom) return false;
|
||||
if (fYInvZoom != that.fYInvZoom) return false;
|
||||
if (fXInvInset != that.fXInvInset) return false;
|
||||
if (fYInvInset != that.fYInvInset) return false;
|
||||
if (src != that.src) return false;
|
||||
if (bounds != that.bounds) return false;
|
||||
if (srcRect != that.srcRect) return false;
|
||||
if (xInvZoom != that.xInvZoom) return false;
|
||||
if (yInvZoom != that.yInvZoom) return false;
|
||||
if (xInvInset != that.xInvInset) return false;
|
||||
if (yInvInset != that.yInvInset) return false;
|
||||
return true;
|
||||
}
|
||||
GrMagnifierEffect::GrMagnifierEffect(const GrMagnifierEffect& src)
|
||||
: INHERITED(kGrMagnifierEffect_ClassID, src.optimizationFlags())
|
||||
, fSrc(src.fSrc)
|
||||
, fBounds(src.fBounds)
|
||||
, fSrcRect(src.fSrcRect)
|
||||
, fXInvZoom(src.fXInvZoom)
|
||||
, fYInvZoom(src.fYInvZoom)
|
||||
, fXInvInset(src.fXInvInset)
|
||||
, fYInvInset(src.fYInvInset)
|
||||
, fSrcCoordTransform(src.fSrcCoordTransform) {
|
||||
, srcCoordTransform(src.srcCoordTransform)
|
||||
, src(src.src)
|
||||
, bounds(src.bounds)
|
||||
, srcRect(src.srcRect)
|
||||
, xInvZoom(src.xInvZoom)
|
||||
, yInvZoom(src.yInvZoom)
|
||||
, xInvInset(src.xInvInset)
|
||||
, yInvInset(src.yInvInset) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
this->addCoordTransform(&fSrcCoordTransform);
|
||||
this->addCoordTransform(&srcCoordTransform);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrMagnifierEffect(*this));
|
||||
}
|
||||
const GrFragmentProcessor::TextureSampler& GrMagnifierEffect::onTextureSampler(int index) const {
|
||||
return IthTextureSampler(index, fSrc);
|
||||
return IthTextureSampler(index, src);
|
||||
}
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
|
||||
#if GR_TEST_UTILS
|
||||
|
@ -15,12 +15,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrMagnifierEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
const SkIRect& bounds() const { return fBounds; }
|
||||
const SkRect& srcRect() const { return fSrcRect; }
|
||||
float xInvZoom() const { return fXInvZoom; }
|
||||
float yInvZoom() const { return fYInvZoom; }
|
||||
float xInvInset() const { return fXInvInset; }
|
||||
float yInvInset() const { return fYInvInset; }
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> src, SkIRect bounds,
|
||||
SkRect srcRect, float xInvZoom, float yInvZoom,
|
||||
float xInvInset, float yInvInset) {
|
||||
@ -30,35 +24,35 @@ public:
|
||||
GrMagnifierEffect(const GrMagnifierEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "MagnifierEffect"; }
|
||||
GrCoordTransform srcCoordTransform;
|
||||
TextureSampler src;
|
||||
SkIRect bounds;
|
||||
SkRect srcRect;
|
||||
float xInvZoom;
|
||||
float yInvZoom;
|
||||
float xInvInset;
|
||||
float yInvInset;
|
||||
|
||||
private:
|
||||
GrMagnifierEffect(sk_sp<GrTextureProxy> src, SkIRect bounds, SkRect srcRect, float xInvZoom,
|
||||
float yInvZoom, float xInvInset, float yInvInset)
|
||||
: INHERITED(kGrMagnifierEffect_ClassID, kNone_OptimizationFlags)
|
||||
, fSrc(std::move(src))
|
||||
, fBounds(bounds)
|
||||
, fSrcRect(srcRect)
|
||||
, fXInvZoom(xInvZoom)
|
||||
, fYInvZoom(yInvZoom)
|
||||
, fXInvInset(xInvInset)
|
||||
, fYInvInset(yInvInset)
|
||||
, fSrcCoordTransform(SkMatrix::I(), fSrc.proxy()) {
|
||||
, srcCoordTransform(SkMatrix::I(), src.get())
|
||||
, src(std::move(src))
|
||||
, bounds(bounds)
|
||||
, srcRect(srcRect)
|
||||
, xInvZoom(xInvZoom)
|
||||
, yInvZoom(yInvZoom)
|
||||
, xInvInset(xInvInset)
|
||||
, yInvInset(yInvInset) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
this->addCoordTransform(&fSrcCoordTransform);
|
||||
this->addCoordTransform(&srcCoordTransform);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
const TextureSampler& onTextureSampler(int) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
TextureSampler fSrc;
|
||||
SkIRect fBounds;
|
||||
SkRect fSrcRect;
|
||||
float fXInvZoom;
|
||||
float fYInvZoom;
|
||||
float fXInvInset;
|
||||
float fYInvInset;
|
||||
GrCoordTransform fSrcCoordTransform;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,34 +22,34 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrMixerEffect& _outer = args.fFp.cast<GrMixerEffect>();
|
||||
(void)_outer;
|
||||
auto weight = _outer.weight();
|
||||
auto weight = _outer.weight;
|
||||
(void)weight;
|
||||
fWeightVar =
|
||||
weightVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "weight");
|
||||
SkString _input0 = SkStringPrintf("%s", args.fInputColor);
|
||||
SkString _child0("_child0");
|
||||
this->emitChild(_outer.fp0_index(), _input0.c_str(), &_child0, args);
|
||||
this->emitChild(_outer.fp0_index, _input0.c_str(), &_child0, args);
|
||||
fragBuilder->codeAppendf("half4 in0 = %s;", _child0.c_str());
|
||||
SkString _input1 = SkStringPrintf("%s", args.fInputColor);
|
||||
SkString _child1("_child1");
|
||||
if (_outer.fp1_index() >= 0) {
|
||||
this->emitChild(_outer.fp1_index(), _input1.c_str(), &_child1, args);
|
||||
if (_outer.fp1_index >= 0) {
|
||||
this->emitChild(_outer.fp1_index, _input1.c_str(), &_child1, args);
|
||||
} else {
|
||||
fragBuilder->codeAppendf("half4 %s;", _child1.c_str());
|
||||
}
|
||||
fragBuilder->codeAppendf("\nhalf4 in1 = %s ? %s : %s;\n%s = mix(in0, in1, %s);\n",
|
||||
_outer.fp1_index() >= 0 ? "true" : "false", _child1.c_str(),
|
||||
_outer.fp1_index >= 0 ? "true" : "false", _child1.c_str(),
|
||||
args.fInputColor, args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(fWeightVar));
|
||||
args.fUniformHandler->getUniformCStr(weightVar));
|
||||
}
|
||||
|
||||
private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrMixerEffect& _outer = _proc.cast<GrMixerEffect>();
|
||||
{ pdman.set1f(fWeightVar, (_outer.weight())); }
|
||||
{ pdman.set1f(weightVar, (_outer.weight)); }
|
||||
}
|
||||
UniformHandle fWeightVar;
|
||||
UniformHandle weightVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrMixerEffect::onCreateGLSLInstance() const {
|
||||
return new GrGLSLMixerEffect();
|
||||
@ -59,17 +59,17 @@ void GrMixerEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrMixerEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrMixerEffect& that = other.cast<GrMixerEffect>();
|
||||
(void)that;
|
||||
if (fWeight != that.fWeight) return false;
|
||||
if (weight != that.weight) return false;
|
||||
return true;
|
||||
}
|
||||
GrMixerEffect::GrMixerEffect(const GrMixerEffect& src)
|
||||
: INHERITED(kGrMixerEffect_ClassID, src.optimizationFlags())
|
||||
, fFp0_index(src.fFp0_index)
|
||||
, fFp1_index(src.fFp1_index)
|
||||
, fWeight(src.fWeight) {
|
||||
this->registerChildProcessor(src.childProcessor(fFp0_index).clone());
|
||||
if (fFp1_index >= 0) {
|
||||
this->registerChildProcessor(src.childProcessor(fFp1_index).clone());
|
||||
, fp0_index(src.fp0_index)
|
||||
, fp1_index(src.fp1_index)
|
||||
, weight(src.weight) {
|
||||
this->registerChildProcessor(src.childProcessor(fp0_index).clone());
|
||||
if (fp1_index >= 0) {
|
||||
this->registerChildProcessor(src.childProcessor(fp1_index).clone());
|
||||
}
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {
|
||||
|
@ -44,10 +44,10 @@ in uniform half weight;
|
||||
? ConstantOutputForConstantInput(this->childProcessor(1), input)
|
||||
: input;
|
||||
return {
|
||||
c0.fR + (c1.fR - c0.fR) * fWeight,
|
||||
c0.fG + (c1.fG - c0.fG) * fWeight,
|
||||
c0.fB + (c1.fB - c0.fB) * fWeight,
|
||||
c0.fA + (c1.fA - c0.fA) * fWeight
|
||||
c0.fR + (c1.fR - c0.fR) * weight,
|
||||
c0.fG + (c1.fG - c0.fG) * weight,
|
||||
c0.fB + (c1.fB - c0.fB) * weight,
|
||||
c0.fA + (c1.fA - c0.fA) * weight
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -45,12 +45,9 @@ public:
|
||||
c1 = (this->numChildProcessors() > 1)
|
||||
? ConstantOutputForConstantInput(this->childProcessor(1), input)
|
||||
: input;
|
||||
return {c0.fR + (c1.fR - c0.fR) * fWeight, c0.fG + (c1.fG - c0.fG) * fWeight,
|
||||
c0.fB + (c1.fB - c0.fB) * fWeight, c0.fA + (c1.fA - c0.fA) * fWeight};
|
||||
return {c0.fR + (c1.fR - c0.fR) * weight, c0.fG + (c1.fG - c0.fG) * weight,
|
||||
c0.fB + (c1.fB - c0.fB) * weight, c0.fA + (c1.fA - c0.fA) * weight};
|
||||
}
|
||||
int fp0_index() const { return fFp0_index; }
|
||||
int fp1_index() const { return fFp1_index; }
|
||||
float weight() const { return fWeight; }
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp0,
|
||||
std::unique_ptr<GrFragmentProcessor>
|
||||
fp1,
|
||||
@ -61,6 +58,9 @@ public:
|
||||
GrMixerEffect(const GrMixerEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "MixerEffect"; }
|
||||
int fp0_index = -1;
|
||||
int fp1_index = -1;
|
||||
float weight;
|
||||
|
||||
private:
|
||||
GrMixerEffect(std::unique_ptr<GrFragmentProcessor> fp0,
|
||||
@ -68,12 +68,12 @@ private:
|
||||
fp1,
|
||||
float weight)
|
||||
: INHERITED(kGrMixerEffect_ClassID, (OptimizationFlags)OptFlags(fp0, fp1))
|
||||
, fWeight(weight) {
|
||||
, weight(weight) {
|
||||
SkASSERT(fp0);
|
||||
fFp0_index = this->numChildProcessors();
|
||||
fp0_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(fp0));
|
||||
if (fp1) {
|
||||
fFp1_index = this->numChildProcessors();
|
||||
fp1_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(fp1));
|
||||
}
|
||||
}
|
||||
@ -81,9 +81,6 @@ private:
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
int fFp0_index = -1;
|
||||
int fFp1_index = -1;
|
||||
float fWeight;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -62,17 +62,17 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrRRectBlurEffect& _outer = args.fFp.cast<GrRRectBlurEffect>();
|
||||
(void)_outer;
|
||||
auto sigma = _outer.sigma();
|
||||
auto sigma = _outer.sigma;
|
||||
(void)sigma;
|
||||
auto rect = _outer.rect();
|
||||
auto rect = _outer.rect;
|
||||
(void)rect;
|
||||
auto cornerRadius = _outer.cornerRadius();
|
||||
auto cornerRadius = _outer.cornerRadius;
|
||||
(void)cornerRadius;
|
||||
fCornerRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
cornerRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
"cornerRadius");
|
||||
fProxyRectVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
proxyRectVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"proxyRect");
|
||||
fBlurRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
blurRadiusVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
"blurRadius");
|
||||
fragBuilder->codeAppendf(
|
||||
"\nhalf2 translatedFragPos = half2(sk_FragCoord.xy - %s.xy);\nhalf threshold = %s "
|
||||
@ -82,11 +82,11 @@ public:
|
||||
"middle.x + threshold) {\n translatedFragPos.x -= middle.x - 1.0;\n}\nif "
|
||||
"(translatedFragPos.y > threshold && translatedFragPos.y < middle.y + threshold) "
|
||||
"{\n translatedFragPos.y = threshold;",
|
||||
args.fUniformHandler->getUniformCStr(fProxyRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fCornerRadiusVar),
|
||||
args.fUniformHandler->getUniformCStr(fBlurRadiusVar),
|
||||
args.fUniformHandler->getUniformCStr(fProxyRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fProxyRectVar));
|
||||
args.fUniformHandler->getUniformCStr(proxyRectVar),
|
||||
args.fUniformHandler->getUniformCStr(cornerRadiusVar),
|
||||
args.fUniformHandler->getUniformCStr(blurRadiusVar),
|
||||
args.fUniformHandler->getUniformCStr(proxyRectVar),
|
||||
args.fUniformHandler->getUniformCStr(proxyRectVar));
|
||||
fragBuilder->codeAppendf(
|
||||
"\n} else if (translatedFragPos.y >= middle.y + threshold) {\n "
|
||||
"translatedFragPos.y -= middle.y - 1.0;\n}\nhalf2 proxyDims = half2(2.0 * "
|
||||
@ -101,19 +101,19 @@ private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrRRectBlurEffect& _outer = _proc.cast<GrRRectBlurEffect>();
|
||||
{ pdman.set1f(fCornerRadiusVar, (_outer.cornerRadius())); }
|
||||
auto sigma = _outer.sigma();
|
||||
{ pdman.set1f(cornerRadiusVar, (_outer.cornerRadius)); }
|
||||
auto sigma = _outer.sigma;
|
||||
(void)sigma;
|
||||
auto rect = _outer.rect();
|
||||
auto rect = _outer.rect;
|
||||
(void)rect;
|
||||
UniformHandle& cornerRadius = fCornerRadiusVar;
|
||||
UniformHandle& cornerRadius = cornerRadiusVar;
|
||||
(void)cornerRadius;
|
||||
GrSurfaceProxy& ninePatchSamplerProxy = *_outer.textureSampler(0).proxy();
|
||||
GrTexture& ninePatchSampler = *ninePatchSamplerProxy.peekTexture();
|
||||
(void)ninePatchSampler;
|
||||
UniformHandle& proxyRect = fProxyRectVar;
|
||||
UniformHandle& proxyRect = proxyRectVar;
|
||||
(void)proxyRect;
|
||||
UniformHandle& blurRadius = fBlurRadiusVar;
|
||||
UniformHandle& blurRadius = blurRadiusVar;
|
||||
(void)blurRadius;
|
||||
|
||||
float blurRadiusValue = 3.f * SkScalarCeilToScalar(sigma - 1 / 6.0f);
|
||||
@ -123,9 +123,9 @@ private:
|
||||
outset.outset(blurRadiusValue, blurRadiusValue);
|
||||
pdman.set4f(proxyRect, outset.fLeft, outset.fTop, outset.fRight, outset.fBottom);
|
||||
}
|
||||
UniformHandle fProxyRectVar;
|
||||
UniformHandle fBlurRadiusVar;
|
||||
UniformHandle fCornerRadiusVar;
|
||||
UniformHandle proxyRectVar;
|
||||
UniformHandle blurRadiusVar;
|
||||
UniformHandle cornerRadiusVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrRRectBlurEffect::onCreateGLSLInstance() const {
|
||||
return new GrGLSLRRectBlurEffect();
|
||||
@ -135,25 +135,25 @@ void GrRRectBlurEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrRRectBlurEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrRRectBlurEffect& that = other.cast<GrRRectBlurEffect>();
|
||||
(void)that;
|
||||
if (fSigma != that.fSigma) return false;
|
||||
if (fRect != that.fRect) return false;
|
||||
if (fCornerRadius != that.fCornerRadius) return false;
|
||||
if (fNinePatchSampler != that.fNinePatchSampler) return false;
|
||||
if (sigma != that.sigma) return false;
|
||||
if (rect != that.rect) return false;
|
||||
if (cornerRadius != that.cornerRadius) return false;
|
||||
if (ninePatchSampler != that.ninePatchSampler) return false;
|
||||
return true;
|
||||
}
|
||||
GrRRectBlurEffect::GrRRectBlurEffect(const GrRRectBlurEffect& src)
|
||||
: INHERITED(kGrRRectBlurEffect_ClassID, src.optimizationFlags())
|
||||
, fSigma(src.fSigma)
|
||||
, fRect(src.fRect)
|
||||
, fCornerRadius(src.fCornerRadius)
|
||||
, fNinePatchSampler(src.fNinePatchSampler) {
|
||||
, sigma(src.sigma)
|
||||
, rect(src.rect)
|
||||
, cornerRadius(src.cornerRadius)
|
||||
, ninePatchSampler(src.ninePatchSampler) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrRRectBlurEffect(*this));
|
||||
}
|
||||
const GrFragmentProcessor::TextureSampler& GrRRectBlurEffect::onTextureSampler(int index) const {
|
||||
return IthTextureSampler(index, fNinePatchSampler);
|
||||
return IthTextureSampler(index, ninePatchSampler);
|
||||
}
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect);
|
||||
#if GR_TEST_UTILS
|
||||
|
@ -100,9 +100,6 @@ public:
|
||||
|
||||
return mask;
|
||||
}
|
||||
float sigma() const { return fSigma; }
|
||||
const SkRect& rect() const { return fRect; }
|
||||
float cornerRadius() const { return fCornerRadius; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(GrRecordingContext* context,
|
||||
float sigma,
|
||||
@ -112,16 +109,20 @@ public:
|
||||
GrRRectBlurEffect(const GrRRectBlurEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "RRectBlurEffect"; }
|
||||
float sigma;
|
||||
SkRect rect;
|
||||
float cornerRadius;
|
||||
TextureSampler ninePatchSampler;
|
||||
|
||||
private:
|
||||
GrRRectBlurEffect(float sigma, SkRect rect, float cornerRadius,
|
||||
sk_sp<GrTextureProxy> ninePatchSampler)
|
||||
: INHERITED(kGrRRectBlurEffect_ClassID,
|
||||
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
|
||||
, fSigma(sigma)
|
||||
, fRect(rect)
|
||||
, fCornerRadius(cornerRadius)
|
||||
, fNinePatchSampler(std::move(ninePatchSampler)) {
|
||||
, sigma(sigma)
|
||||
, rect(rect)
|
||||
, cornerRadius(cornerRadius)
|
||||
, ninePatchSampler(std::move(ninePatchSampler)) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
@ -129,10 +130,6 @@ private:
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
const TextureSampler& onTextureSampler(int) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
float fSigma;
|
||||
SkRect fRect;
|
||||
float fCornerRadius;
|
||||
TextureSampler fNinePatchSampler;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,26 +22,26 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrRectBlurEffect& _outer = args.fFp.cast<GrRectBlurEffect>();
|
||||
(void)_outer;
|
||||
auto rect = _outer.rect();
|
||||
auto rect = _outer.rect;
|
||||
(void)rect;
|
||||
auto sigma = _outer.sigma();
|
||||
auto sigma = _outer.sigma;
|
||||
(void)sigma;
|
||||
highPrecision = ((((abs(rect.left()) > 16000.0 || abs(rect.top()) > 16000.0) ||
|
||||
abs(rect.right()) > 16000.0) ||
|
||||
abs(rect.bottom()) > 16000.0) ||
|
||||
abs(rect.right() - rect.left()) > 16000.0) ||
|
||||
abs(rect.bottom() - rect.top()) > 16000.0;
|
||||
fRectVar =
|
||||
rectVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType, "rect");
|
||||
if (!highPrecision) {
|
||||
fProxyRectHalfVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
proxyRectHalfVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "proxyRectHalf");
|
||||
}
|
||||
if (highPrecision) {
|
||||
fProxyRectFloatVar = args.fUniformHandler->addUniform(
|
||||
proxyRectFloatVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kFloat4_GrSLType, "proxyRectFloat");
|
||||
}
|
||||
fProfileSizeVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
profileSizeVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
"profileSize");
|
||||
fragBuilder->codeAppendf(
|
||||
"/* key */ bool highPrecision = %s;\n@if (highPrecision) {\n float2 "
|
||||
@ -51,15 +51,15 @@ public:
|
||||
"1.0);\n float2 wh = smallDims - float2(center, center);\n half hcoord = "
|
||||
"half((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / float(%s));\n half "
|
||||
"hlookup = texture(%s, float2(float(hcoord), 0.5)).",
|
||||
(highPrecision ? "true" : "false"), args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
(highPrecision ? "true" : "false"), args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str());
|
||||
fragBuilder->codeAppendf(
|
||||
"%s.w;\n half vcoord = half((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y) "
|
||||
@ -70,27 +70,27 @@ public:
|
||||
"%s);\n half center = 2.0 * floor(%s / 2.0 + 0.25) - 1.0;\n half2 wh = "
|
||||
"smallDims - half2(center, center);\n half ",
|
||||
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
|
||||
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
|
||||
args.fOutputColor, args.fInputColor, args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fRectVar),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar));
|
||||
args.fOutputColor, args.fInputColor, args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(rectVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar));
|
||||
fragBuilder->codeAppendf(
|
||||
"hcoord = (abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / %s;\n half "
|
||||
"hlookup = texture(%s, float2(float(hcoord), 0.5)).%s.w;\n half vcoord = "
|
||||
"(abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y) / %s;\n half vlookup = "
|
||||
"texture(%s, float2(float(vcoord), 0.5)).%s.w;\n %s = (%s * hlookup) * "
|
||||
"vlookup;\n}\n",
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
|
||||
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
|
||||
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
|
||||
args.fUniformHandler->getUniformCStr(profileSizeVar),
|
||||
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
|
||||
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
|
||||
args.fOutputColor, args.fInputColor);
|
||||
@ -100,28 +100,28 @@ private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrRectBlurEffect& _outer = _proc.cast<GrRectBlurEffect>();
|
||||
{ pdman.set4fv(fRectVar, 1, reinterpret_cast<const float*>(&(_outer.rect()))); }
|
||||
UniformHandle& rect = fRectVar;
|
||||
{ pdman.set4fv(rectVar, 1, reinterpret_cast<const float*>(&(_outer.rect))); }
|
||||
UniformHandle& rect = rectVar;
|
||||
(void)rect;
|
||||
auto sigma = _outer.sigma();
|
||||
auto sigma = _outer.sigma;
|
||||
(void)sigma;
|
||||
GrSurfaceProxy& blurProfileProxy = *_outer.textureSampler(0).proxy();
|
||||
GrTexture& blurProfile = *blurProfileProxy.peekTexture();
|
||||
(void)blurProfile;
|
||||
UniformHandle& proxyRectHalf = fProxyRectHalfVar;
|
||||
UniformHandle& proxyRectHalf = proxyRectHalfVar;
|
||||
(void)proxyRectHalf;
|
||||
UniformHandle& proxyRectFloat = fProxyRectFloatVar;
|
||||
UniformHandle& proxyRectFloat = proxyRectFloatVar;
|
||||
(void)proxyRectFloat;
|
||||
UniformHandle& profileSize = fProfileSizeVar;
|
||||
UniformHandle& profileSize = profileSizeVar;
|
||||
(void)profileSize;
|
||||
|
||||
pdman.set1f(profileSize, SkScalarCeilToScalar(6 * sigma));
|
||||
}
|
||||
bool highPrecision = false;
|
||||
UniformHandle fProxyRectHalfVar;
|
||||
UniformHandle fProxyRectFloatVar;
|
||||
UniformHandle fProfileSizeVar;
|
||||
UniformHandle fRectVar;
|
||||
UniformHandle proxyRectHalfVar;
|
||||
UniformHandle proxyRectFloatVar;
|
||||
UniformHandle profileSizeVar;
|
||||
UniformHandle rectVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrRectBlurEffect::onCreateGLSLInstance() const {
|
||||
return new GrGLSLRectBlurEffect();
|
||||
@ -131,23 +131,23 @@ void GrRectBlurEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrRectBlurEffect& that = other.cast<GrRectBlurEffect>();
|
||||
(void)that;
|
||||
if (fRect != that.fRect) return false;
|
||||
if (fSigma != that.fSigma) return false;
|
||||
if (fBlurProfile != that.fBlurProfile) return false;
|
||||
if (rect != that.rect) return false;
|
||||
if (sigma != that.sigma) return false;
|
||||
if (blurProfile != that.blurProfile) return false;
|
||||
return true;
|
||||
}
|
||||
GrRectBlurEffect::GrRectBlurEffect(const GrRectBlurEffect& src)
|
||||
: INHERITED(kGrRectBlurEffect_ClassID, src.optimizationFlags())
|
||||
, fRect(src.fRect)
|
||||
, fSigma(src.fSigma)
|
||||
, fBlurProfile(src.fBlurProfile) {
|
||||
, rect(src.rect)
|
||||
, sigma(src.sigma)
|
||||
, blurProfile(src.blurProfile) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrRectBlurEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrRectBlurEffect(*this));
|
||||
}
|
||||
const GrFragmentProcessor::TextureSampler& GrRectBlurEffect::onTextureSampler(int index) const {
|
||||
return IthTextureSampler(index, fBlurProfile);
|
||||
return IthTextureSampler(index, blurProfile);
|
||||
}
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
|
||||
#if GR_TEST_UTILS
|
||||
|
@ -61,8 +61,6 @@ public:
|
||||
|
||||
return blurProfile;
|
||||
}
|
||||
const SkRect& rect() const { return fRect; }
|
||||
float sigma() const { return fSigma; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(GrProxyProvider* proxyProvider,
|
||||
const GrShaderCaps& caps, const SkRect& rect,
|
||||
@ -96,15 +94,18 @@ public:
|
||||
GrRectBlurEffect(const GrRectBlurEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "RectBlurEffect"; }
|
||||
SkRect rect;
|
||||
float sigma;
|
||||
TextureSampler blurProfile;
|
||||
|
||||
private:
|
||||
GrRectBlurEffect(SkRect rect, float sigma, sk_sp<GrTextureProxy> blurProfile,
|
||||
GrSamplerState samplerParams)
|
||||
: INHERITED(kGrRectBlurEffect_ClassID,
|
||||
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag)
|
||||
, fRect(rect)
|
||||
, fSigma(sigma)
|
||||
, fBlurProfile(std::move(blurProfile), samplerParams) {
|
||||
, rect(rect)
|
||||
, sigma(sigma)
|
||||
, blurProfile(std::move(blurProfile), samplerParams) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
@ -112,9 +113,6 @@ private:
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
const TextureSampler& onTextureSampler(int) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkRect fRect;
|
||||
float fSigma;
|
||||
TextureSampler fBlurProfile;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrSimpleTextureEffect& _outer = args.fFp.cast<GrSimpleTextureEffect>();
|
||||
(void)_outer;
|
||||
auto matrix = _outer.matrix();
|
||||
auto matrix = _outer.matrix;
|
||||
(void)matrix;
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
@ -44,24 +44,24 @@ void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrSimpleTextureEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrSimpleTextureEffect& that = other.cast<GrSimpleTextureEffect>();
|
||||
(void)that;
|
||||
if (fImage != that.fImage) return false;
|
||||
if (fMatrix != that.fMatrix) return false;
|
||||
if (image != that.image) return false;
|
||||
if (matrix != that.matrix) return false;
|
||||
return true;
|
||||
}
|
||||
GrSimpleTextureEffect::GrSimpleTextureEffect(const GrSimpleTextureEffect& src)
|
||||
: INHERITED(kGrSimpleTextureEffect_ClassID, src.optimizationFlags())
|
||||
, fImage(src.fImage)
|
||||
, fMatrix(src.fMatrix)
|
||||
, fImageCoordTransform(src.fImageCoordTransform) {
|
||||
, imageCoordTransform(src.imageCoordTransform)
|
||||
, image(src.image)
|
||||
, matrix(src.matrix) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
this->addCoordTransform(&fImageCoordTransform);
|
||||
this->addCoordTransform(&imageCoordTransform);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(*this));
|
||||
}
|
||||
const GrFragmentProcessor::TextureSampler& GrSimpleTextureEffect::onTextureSampler(
|
||||
int index) const {
|
||||
return IthTextureSampler(index, fImage);
|
||||
return IthTextureSampler(index, image);
|
||||
}
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
|
||||
#if GR_TEST_UTILS
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrSimpleTextureEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
const SkMatrix44& matrix() const { return fMatrix; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
|
||||
const SkMatrix& matrix) {
|
||||
return std::unique_ptr<GrFragmentProcessor>(
|
||||
@ -43,6 +41,9 @@ public:
|
||||
GrSimpleTextureEffect(const GrSimpleTextureEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "SimpleTextureEffect"; }
|
||||
GrCoordTransform imageCoordTransform;
|
||||
TextureSampler image;
|
||||
SkMatrix44 matrix;
|
||||
|
||||
private:
|
||||
GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix,
|
||||
@ -54,20 +55,17 @@ private:
|
||||
GrSamplerState::WrapMode::kClampToBorder ||
|
||||
samplerParams.wrapModeY() ==
|
||||
GrSamplerState::WrapMode::kClampToBorder))
|
||||
, fImage(std::move(image), samplerParams)
|
||||
, fMatrix(matrix)
|
||||
, fImageCoordTransform(matrix, fImage.proxy()) {
|
||||
, imageCoordTransform(matrix, image.get())
|
||||
, image(std::move(image), samplerParams)
|
||||
, matrix(matrix) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
this->addCoordTransform(&fImageCoordTransform);
|
||||
this->addCoordTransform(&imageCoordTransform);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
const TextureSampler& onTextureSampler(int) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
TextureSampler fImage;
|
||||
SkMatrix44 fMatrix;
|
||||
GrCoordTransform fImageCoordTransform;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,35 +22,35 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrClampedGradientEffect& _outer = args.fFp.cast<GrClampedGradientEffect>();
|
||||
(void)_outer;
|
||||
auto leftBorderColor = _outer.leftBorderColor();
|
||||
auto leftBorderColor = _outer.leftBorderColor;
|
||||
(void)leftBorderColor;
|
||||
auto rightBorderColor = _outer.rightBorderColor();
|
||||
auto rightBorderColor = _outer.rightBorderColor;
|
||||
(void)rightBorderColor;
|
||||
auto makePremul = _outer.makePremul();
|
||||
auto makePremul = _outer.makePremul;
|
||||
(void)makePremul;
|
||||
auto colorsAreOpaque = _outer.colorsAreOpaque();
|
||||
auto colorsAreOpaque = _outer.colorsAreOpaque;
|
||||
(void)colorsAreOpaque;
|
||||
fLeftBorderColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
leftBorderColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "leftBorderColor");
|
||||
fRightBorderColorVar = args.fUniformHandler->addUniform(
|
||||
kFragment_GrShaderFlag, kHalf4_GrSLType, "rightBorderColor");
|
||||
rightBorderColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "rightBorderColor");
|
||||
SkString _child1("_child1");
|
||||
this->emitChild(_outer.gradLayout_index(), &_child1, args);
|
||||
this->emitChild(_outer.gradLayout_index, &_child1, args);
|
||||
fragBuilder->codeAppendf(
|
||||
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else if (t.x < "
|
||||
"0.0) {\n %s = %s;\n} else if (t.x > 1.0) {\n %s = %s;\n} else {",
|
||||
_child1.c_str(),
|
||||
(_outer.childProcessor(_outer.gradLayout_index()).preservesOpaqueInput() ? "true"
|
||||
(_outer.childProcessor(_outer.gradLayout_index).preservesOpaqueInput() ? "true"
|
||||
: "false"),
|
||||
args.fOutputColor, args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(fLeftBorderColorVar), args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(fRightBorderColorVar));
|
||||
args.fUniformHandler->getUniformCStr(leftBorderColorVar), args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(rightBorderColorVar));
|
||||
SkString _input0("t");
|
||||
SkString _child0("_child0");
|
||||
this->emitChild(_outer.colorizer_index(), _input0.c_str(), &_child0, args);
|
||||
this->emitChild(_outer.colorizer_index, _input0.c_str(), &_child0, args);
|
||||
fragBuilder->codeAppendf("\n %s = %s;\n}\n@if (%s) {\n %s.xyz *= %s.w;\n}\n",
|
||||
args.fOutputColor, _child0.c_str(),
|
||||
(_outer.makePremul() ? "true" : "false"), args.fOutputColor,
|
||||
(_outer.makePremul ? "true" : "false"), args.fOutputColor,
|
||||
args.fOutputColor);
|
||||
}
|
||||
|
||||
@ -59,49 +59,49 @@ private:
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrClampedGradientEffect& _outer = _proc.cast<GrClampedGradientEffect>();
|
||||
{
|
||||
const SkPMColor4f& leftBorderColorValue = _outer.leftBorderColor();
|
||||
if (fLeftBorderColorPrev != leftBorderColorValue) {
|
||||
fLeftBorderColorPrev = leftBorderColorValue;
|
||||
pdman.set4fv(fLeftBorderColorVar, 1, leftBorderColorValue.vec());
|
||||
const SkPMColor4f& leftBorderColorValue = _outer.leftBorderColor;
|
||||
if (leftBorderColorPrev != leftBorderColorValue) {
|
||||
leftBorderColorPrev = leftBorderColorValue;
|
||||
pdman.set4fv(leftBorderColorVar, 1, leftBorderColorValue.vec());
|
||||
}
|
||||
const SkPMColor4f& rightBorderColorValue = _outer.rightBorderColor();
|
||||
if (fRightBorderColorPrev != rightBorderColorValue) {
|
||||
fRightBorderColorPrev = rightBorderColorValue;
|
||||
pdman.set4fv(fRightBorderColorVar, 1, rightBorderColorValue.vec());
|
||||
const SkPMColor4f& rightBorderColorValue = _outer.rightBorderColor;
|
||||
if (rightBorderColorPrev != rightBorderColorValue) {
|
||||
rightBorderColorPrev = rightBorderColorValue;
|
||||
pdman.set4fv(rightBorderColorVar, 1, rightBorderColorValue.vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
SkPMColor4f fLeftBorderColorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f fRightBorderColorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
UniformHandle fLeftBorderColorVar;
|
||||
UniformHandle fRightBorderColorVar;
|
||||
SkPMColor4f leftBorderColorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f rightBorderColorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
UniformHandle leftBorderColorVar;
|
||||
UniformHandle rightBorderColorVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrClampedGradientEffect::onCreateGLSLInstance() const {
|
||||
return new GrGLSLClampedGradientEffect();
|
||||
}
|
||||
void GrClampedGradientEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fMakePremul);
|
||||
b->add32((int32_t)makePremul);
|
||||
}
|
||||
bool GrClampedGradientEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrClampedGradientEffect& that = other.cast<GrClampedGradientEffect>();
|
||||
(void)that;
|
||||
if (fLeftBorderColor != that.fLeftBorderColor) return false;
|
||||
if (fRightBorderColor != that.fRightBorderColor) return false;
|
||||
if (fMakePremul != that.fMakePremul) return false;
|
||||
if (fColorsAreOpaque != that.fColorsAreOpaque) return false;
|
||||
if (leftBorderColor != that.leftBorderColor) return false;
|
||||
if (rightBorderColor != that.rightBorderColor) return false;
|
||||
if (makePremul != that.makePremul) return false;
|
||||
if (colorsAreOpaque != that.colorsAreOpaque) return false;
|
||||
return true;
|
||||
}
|
||||
GrClampedGradientEffect::GrClampedGradientEffect(const GrClampedGradientEffect& src)
|
||||
: INHERITED(kGrClampedGradientEffect_ClassID, src.optimizationFlags())
|
||||
, fColorizer_index(src.fColorizer_index)
|
||||
, fGradLayout_index(src.fGradLayout_index)
|
||||
, fLeftBorderColor(src.fLeftBorderColor)
|
||||
, fRightBorderColor(src.fRightBorderColor)
|
||||
, fMakePremul(src.fMakePremul)
|
||||
, fColorsAreOpaque(src.fColorsAreOpaque) {
|
||||
this->registerChildProcessor(src.childProcessor(fColorizer_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(fGradLayout_index).clone());
|
||||
, colorizer_index(src.colorizer_index)
|
||||
, gradLayout_index(src.gradLayout_index)
|
||||
, leftBorderColor(src.leftBorderColor)
|
||||
, rightBorderColor(src.rightBorderColor)
|
||||
, makePremul(src.makePremul)
|
||||
, colorsAreOpaque(src.colorsAreOpaque) {
|
||||
this->registerChildProcessor(src.childProcessor(colorizer_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(gradLayout_index).clone());
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrClampedGradientEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrClampedGradientEffect(*this));
|
||||
|
@ -15,12 +15,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrClampedGradientEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
int colorizer_index() const { return fColorizer_index; }
|
||||
int gradLayout_index() const { return fGradLayout_index; }
|
||||
const SkPMColor4f& leftBorderColor() const { return fLeftBorderColor; }
|
||||
const SkPMColor4f& rightBorderColor() const { return fRightBorderColor; }
|
||||
bool makePremul() const { return fMakePremul; }
|
||||
bool colorsAreOpaque() const { return fColorsAreOpaque; }
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(
|
||||
std::unique_ptr<GrFragmentProcessor> colorizer,
|
||||
std::unique_ptr<GrFragmentProcessor> gradLayout, SkPMColor4f leftBorderColor,
|
||||
@ -32,6 +26,12 @@ public:
|
||||
GrClampedGradientEffect(const GrClampedGradientEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "ClampedGradientEffect"; }
|
||||
int colorizer_index = -1;
|
||||
int gradLayout_index = -1;
|
||||
SkPMColor4f leftBorderColor;
|
||||
SkPMColor4f rightBorderColor;
|
||||
bool makePremul;
|
||||
bool colorsAreOpaque;
|
||||
|
||||
private:
|
||||
GrClampedGradientEffect(std::unique_ptr<GrFragmentProcessor> colorizer,
|
||||
@ -43,27 +43,21 @@ private:
|
||||
(colorsAreOpaque && gradLayout->preservesOpaqueInput()
|
||||
? kPreservesOpaqueInput_OptimizationFlag
|
||||
: kNone_OptimizationFlags))
|
||||
, fLeftBorderColor(leftBorderColor)
|
||||
, fRightBorderColor(rightBorderColor)
|
||||
, fMakePremul(makePremul)
|
||||
, fColorsAreOpaque(colorsAreOpaque) {
|
||||
, leftBorderColor(leftBorderColor)
|
||||
, rightBorderColor(rightBorderColor)
|
||||
, makePremul(makePremul)
|
||||
, colorsAreOpaque(colorsAreOpaque) {
|
||||
SkASSERT(colorizer);
|
||||
fColorizer_index = this->numChildProcessors();
|
||||
colorizer_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(colorizer));
|
||||
SkASSERT(gradLayout);
|
||||
fGradLayout_index = this->numChildProcessors();
|
||||
gradLayout_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(gradLayout));
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
int fColorizer_index = -1;
|
||||
int fGradLayout_index = -1;
|
||||
SkPMColor4f fLeftBorderColor;
|
||||
SkPMColor4f fRightBorderColor;
|
||||
bool fMakePremul;
|
||||
bool fColorsAreOpaque;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -23,35 +23,35 @@ public:
|
||||
const GrDualIntervalGradientColorizer& _outer =
|
||||
args.fFp.cast<GrDualIntervalGradientColorizer>();
|
||||
(void)_outer;
|
||||
auto scale01 = _outer.scale01();
|
||||
auto scale01 = _outer.scale01;
|
||||
(void)scale01;
|
||||
auto bias01 = _outer.bias01();
|
||||
auto bias01 = _outer.bias01;
|
||||
(void)bias01;
|
||||
auto scale23 = _outer.scale23();
|
||||
auto scale23 = _outer.scale23;
|
||||
(void)scale23;
|
||||
auto bias23 = _outer.bias23();
|
||||
auto bias23 = _outer.bias23;
|
||||
(void)bias23;
|
||||
auto threshold = _outer.threshold();
|
||||
auto threshold = _outer.threshold;
|
||||
(void)threshold;
|
||||
fScale01Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
scale01Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"scale01");
|
||||
fBias01Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
bias01Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"bias01");
|
||||
fScale23Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
scale23Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"scale23");
|
||||
fBias23Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
bias23Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"bias23");
|
||||
fThresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
thresholdVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
|
||||
"threshold");
|
||||
fragBuilder->codeAppendf(
|
||||
"half t = %s.x;\nfloat4 scale, bias;\nif (t < %s) {\n scale = %s;\n bias = "
|
||||
"%s;\n} else {\n scale = %s;\n bias = %s;\n}\n%s = half4(float(t) * scale + "
|
||||
"bias);\n",
|
||||
args.fInputColor, args.fUniformHandler->getUniformCStr(fThresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(fScale01Var),
|
||||
args.fUniformHandler->getUniformCStr(fBias01Var),
|
||||
args.fUniformHandler->getUniformCStr(fScale23Var),
|
||||
args.fUniformHandler->getUniformCStr(fBias23Var), args.fOutputColor);
|
||||
args.fInputColor, args.fUniformHandler->getUniformCStr(thresholdVar),
|
||||
args.fUniformHandler->getUniformCStr(scale01Var),
|
||||
args.fUniformHandler->getUniformCStr(bias01Var),
|
||||
args.fUniformHandler->getUniformCStr(scale23Var),
|
||||
args.fUniformHandler->getUniformCStr(bias23Var), args.fOutputColor);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -60,43 +60,43 @@ private:
|
||||
const GrDualIntervalGradientColorizer& _outer =
|
||||
_proc.cast<GrDualIntervalGradientColorizer>();
|
||||
{
|
||||
const SkPMColor4f& scale01Value = _outer.scale01();
|
||||
if (fScale01Prev != scale01Value) {
|
||||
fScale01Prev = scale01Value;
|
||||
pdman.set4fv(fScale01Var, 1, scale01Value.vec());
|
||||
const SkPMColor4f& scale01Value = _outer.scale01;
|
||||
if (scale01Prev != scale01Value) {
|
||||
scale01Prev = scale01Value;
|
||||
pdman.set4fv(scale01Var, 1, scale01Value.vec());
|
||||
}
|
||||
const SkPMColor4f& bias01Value = _outer.bias01();
|
||||
if (fBias01Prev != bias01Value) {
|
||||
fBias01Prev = bias01Value;
|
||||
pdman.set4fv(fBias01Var, 1, bias01Value.vec());
|
||||
const SkPMColor4f& bias01Value = _outer.bias01;
|
||||
if (bias01Prev != bias01Value) {
|
||||
bias01Prev = bias01Value;
|
||||
pdman.set4fv(bias01Var, 1, bias01Value.vec());
|
||||
}
|
||||
const SkPMColor4f& scale23Value = _outer.scale23();
|
||||
if (fScale23Prev != scale23Value) {
|
||||
fScale23Prev = scale23Value;
|
||||
pdman.set4fv(fScale23Var, 1, scale23Value.vec());
|
||||
const SkPMColor4f& scale23Value = _outer.scale23;
|
||||
if (scale23Prev != scale23Value) {
|
||||
scale23Prev = scale23Value;
|
||||
pdman.set4fv(scale23Var, 1, scale23Value.vec());
|
||||
}
|
||||
const SkPMColor4f& bias23Value = _outer.bias23();
|
||||
if (fBias23Prev != bias23Value) {
|
||||
fBias23Prev = bias23Value;
|
||||
pdman.set4fv(fBias23Var, 1, bias23Value.vec());
|
||||
const SkPMColor4f& bias23Value = _outer.bias23;
|
||||
if (bias23Prev != bias23Value) {
|
||||
bias23Prev = bias23Value;
|
||||
pdman.set4fv(bias23Var, 1, bias23Value.vec());
|
||||
}
|
||||
float thresholdValue = _outer.threshold();
|
||||
if (fThresholdPrev != thresholdValue) {
|
||||
fThresholdPrev = thresholdValue;
|
||||
pdman.set1f(fThresholdVar, thresholdValue);
|
||||
float thresholdValue = _outer.threshold;
|
||||
if (thresholdPrev != thresholdValue) {
|
||||
thresholdPrev = thresholdValue;
|
||||
pdman.set1f(thresholdVar, thresholdValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
SkPMColor4f fScale01Prev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f fBias01Prev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f fScale23Prev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f fBias23Prev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
float fThresholdPrev = SK_FloatNaN;
|
||||
UniformHandle fScale01Var;
|
||||
UniformHandle fBias01Var;
|
||||
UniformHandle fScale23Var;
|
||||
UniformHandle fBias23Var;
|
||||
UniformHandle fThresholdVar;
|
||||
SkPMColor4f scale01Prev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f bias01Prev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f scale23Prev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f bias23Prev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
float thresholdPrev = SK_FloatNaN;
|
||||
UniformHandle scale01Var;
|
||||
UniformHandle bias01Var;
|
||||
UniformHandle scale23Var;
|
||||
UniformHandle bias23Var;
|
||||
UniformHandle thresholdVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrDualIntervalGradientColorizer::onCreateGLSLInstance() const {
|
||||
return new GrGLSLDualIntervalGradientColorizer();
|
||||
@ -106,21 +106,21 @@ void GrDualIntervalGradientColorizer::onGetGLSLProcessorKey(const GrShaderCaps&
|
||||
bool GrDualIntervalGradientColorizer::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrDualIntervalGradientColorizer& that = other.cast<GrDualIntervalGradientColorizer>();
|
||||
(void)that;
|
||||
if (fScale01 != that.fScale01) return false;
|
||||
if (fBias01 != that.fBias01) return false;
|
||||
if (fScale23 != that.fScale23) return false;
|
||||
if (fBias23 != that.fBias23) return false;
|
||||
if (fThreshold != that.fThreshold) return false;
|
||||
if (scale01 != that.scale01) return false;
|
||||
if (bias01 != that.bias01) return false;
|
||||
if (scale23 != that.scale23) return false;
|
||||
if (bias23 != that.bias23) return false;
|
||||
if (threshold != that.threshold) return false;
|
||||
return true;
|
||||
}
|
||||
GrDualIntervalGradientColorizer::GrDualIntervalGradientColorizer(
|
||||
const GrDualIntervalGradientColorizer& src)
|
||||
: INHERITED(kGrDualIntervalGradientColorizer_ClassID, src.optimizationFlags())
|
||||
, fScale01(src.fScale01)
|
||||
, fBias01(src.fBias01)
|
||||
, fScale23(src.fScale23)
|
||||
, fBias23(src.fBias23)
|
||||
, fThreshold(src.fThreshold) {}
|
||||
, scale01(src.scale01)
|
||||
, bias01(src.bias01)
|
||||
, scale23(src.scale23)
|
||||
, bias23(src.bias23)
|
||||
, threshold(src.threshold) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrDualIntervalGradientColorizer::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrDualIntervalGradientColorizer(*this));
|
||||
}
|
||||
|
@ -15,37 +15,31 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrDualIntervalGradientColorizer : public GrFragmentProcessor {
|
||||
public:
|
||||
const SkPMColor4f& scale01() const { return fScale01; }
|
||||
const SkPMColor4f& bias01() const { return fBias01; }
|
||||
const SkPMColor4f& scale23() const { return fScale23; }
|
||||
const SkPMColor4f& bias23() const { return fBias23; }
|
||||
float threshold() const { return fThreshold; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const SkPMColor4f& c0, const SkPMColor4f& c1,
|
||||
const SkPMColor4f& c2, const SkPMColor4f& c3,
|
||||
float threshold);
|
||||
GrDualIntervalGradientColorizer(const GrDualIntervalGradientColorizer& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "DualIntervalGradientColorizer"; }
|
||||
SkPMColor4f scale01;
|
||||
SkPMColor4f bias01;
|
||||
SkPMColor4f scale23;
|
||||
SkPMColor4f bias23;
|
||||
float threshold;
|
||||
|
||||
private:
|
||||
GrDualIntervalGradientColorizer(SkPMColor4f scale01, SkPMColor4f bias01, SkPMColor4f scale23,
|
||||
SkPMColor4f bias23, float threshold)
|
||||
: INHERITED(kGrDualIntervalGradientColorizer_ClassID, kNone_OptimizationFlags)
|
||||
, fScale01(scale01)
|
||||
, fBias01(bias01)
|
||||
, fScale23(scale23)
|
||||
, fBias23(bias23)
|
||||
, fThreshold(threshold) {}
|
||||
, scale01(scale01)
|
||||
, bias01(bias01)
|
||||
, scale23(scale23)
|
||||
, bias23(bias23)
|
||||
, threshold(threshold) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkPMColor4f fScale01;
|
||||
SkPMColor4f fBias01;
|
||||
SkPMColor4f fScale23;
|
||||
SkPMColor4f fBias23;
|
||||
float fThreshold;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrLinearGradientLayout& _outer = args.fFp.cast<GrLinearGradientLayout>();
|
||||
(void)_outer;
|
||||
auto gradientMatrix = _outer.gradientMatrix();
|
||||
auto gradientMatrix = _outer.gradientMatrix;
|
||||
(void)gradientMatrix;
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
@ -42,13 +42,13 @@ void GrLinearGradientLayout::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrLinearGradientLayout::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrLinearGradientLayout& that = other.cast<GrLinearGradientLayout>();
|
||||
(void)that;
|
||||
if (fGradientMatrix != that.fGradientMatrix) return false;
|
||||
if (gradientMatrix != that.gradientMatrix) return false;
|
||||
return true;
|
||||
}
|
||||
GrLinearGradientLayout::GrLinearGradientLayout(const GrLinearGradientLayout& src)
|
||||
: INHERITED(kGrLinearGradientLayout_ClassID, src.optimizationFlags())
|
||||
, fGradientMatrix(src.fGradientMatrix)
|
||||
, fCoordTransform0(src.fCoordTransform0) {
|
||||
, fCoordTransform0(src.fCoordTransform0)
|
||||
, gradientMatrix(src.gradientMatrix) {
|
||||
this->addCoordTransform(&fCoordTransform0);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrLinearGradientLayout::clone() const {
|
||||
|
@ -18,28 +18,26 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrLinearGradientLayout : public GrFragmentProcessor {
|
||||
public:
|
||||
const SkMatrix44& gradientMatrix() const { return fGradientMatrix; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const SkLinearGradient& gradient,
|
||||
const GrFPArgs& args);
|
||||
GrLinearGradientLayout(const GrLinearGradientLayout& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "LinearGradientLayout"; }
|
||||
GrCoordTransform fCoordTransform0;
|
||||
SkMatrix44 gradientMatrix;
|
||||
|
||||
private:
|
||||
GrLinearGradientLayout(SkMatrix44 gradientMatrix)
|
||||
: INHERITED(kGrLinearGradientLayout_ClassID,
|
||||
(OptimizationFlags)kPreservesOpaqueInput_OptimizationFlag)
|
||||
, fGradientMatrix(gradientMatrix)
|
||||
, fCoordTransform0(gradientMatrix) {
|
||||
, fCoordTransform0(gradientMatrix)
|
||||
, gradientMatrix(gradientMatrix) {
|
||||
this->addCoordTransform(&fCoordTransform0);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkMatrix44 fGradientMatrix;
|
||||
GrCoordTransform fCoordTransform0;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrRadialGradientLayout& _outer = args.fFp.cast<GrRadialGradientLayout>();
|
||||
(void)_outer;
|
||||
auto gradientMatrix = _outer.gradientMatrix();
|
||||
auto gradientMatrix = _outer.gradientMatrix;
|
||||
(void)gradientMatrix;
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf("half t = half(length(%s));\n%s = half4(t, 1.0, 0.0, 0.0);\n",
|
||||
@ -41,13 +41,13 @@ void GrRadialGradientLayout::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrRadialGradientLayout::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrRadialGradientLayout& that = other.cast<GrRadialGradientLayout>();
|
||||
(void)that;
|
||||
if (fGradientMatrix != that.fGradientMatrix) return false;
|
||||
if (gradientMatrix != that.gradientMatrix) return false;
|
||||
return true;
|
||||
}
|
||||
GrRadialGradientLayout::GrRadialGradientLayout(const GrRadialGradientLayout& src)
|
||||
: INHERITED(kGrRadialGradientLayout_ClassID, src.optimizationFlags())
|
||||
, fGradientMatrix(src.fGradientMatrix)
|
||||
, fCoordTransform0(src.fCoordTransform0) {
|
||||
, fCoordTransform0(src.fCoordTransform0)
|
||||
, gradientMatrix(src.gradientMatrix) {
|
||||
this->addCoordTransform(&fCoordTransform0);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrRadialGradientLayout::clone() const {
|
||||
|
@ -18,28 +18,26 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrRadialGradientLayout : public GrFragmentProcessor {
|
||||
public:
|
||||
const SkMatrix44& gradientMatrix() const { return fGradientMatrix; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const SkRadialGradient& gradient,
|
||||
const GrFPArgs& args);
|
||||
GrRadialGradientLayout(const GrRadialGradientLayout& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "RadialGradientLayout"; }
|
||||
GrCoordTransform fCoordTransform0;
|
||||
SkMatrix44 gradientMatrix;
|
||||
|
||||
private:
|
||||
GrRadialGradientLayout(SkMatrix44 gradientMatrix)
|
||||
: INHERITED(kGrRadialGradientLayout_ClassID,
|
||||
(OptimizationFlags)kPreservesOpaqueInput_OptimizationFlag)
|
||||
, fGradientMatrix(gradientMatrix)
|
||||
, fCoordTransform0(gradientMatrix) {
|
||||
, fCoordTransform0(gradientMatrix)
|
||||
, gradientMatrix(gradientMatrix) {
|
||||
this->addCoordTransform(&fCoordTransform0);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkMatrix44 fGradientMatrix;
|
||||
GrCoordTransform fCoordTransform0;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -23,17 +23,17 @@ public:
|
||||
const GrSingleIntervalGradientColorizer& _outer =
|
||||
args.fFp.cast<GrSingleIntervalGradientColorizer>();
|
||||
(void)_outer;
|
||||
auto start = _outer.start();
|
||||
auto start = _outer.start;
|
||||
(void)start;
|
||||
auto end = _outer.end();
|
||||
auto end = _outer.end;
|
||||
(void)end;
|
||||
fStartVar =
|
||||
startVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "start");
|
||||
fEndVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "end");
|
||||
endVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "end");
|
||||
fragBuilder->codeAppendf("half t = %s.x;\n%s = (1.0 - t) * %s + t * %s;\n",
|
||||
args.fInputColor, args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(fStartVar),
|
||||
args.fUniformHandler->getUniformCStr(fEndVar));
|
||||
args.fUniformHandler->getUniformCStr(startVar),
|
||||
args.fUniformHandler->getUniformCStr(endVar));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -42,22 +42,22 @@ private:
|
||||
const GrSingleIntervalGradientColorizer& _outer =
|
||||
_proc.cast<GrSingleIntervalGradientColorizer>();
|
||||
{
|
||||
const SkPMColor4f& startValue = _outer.start();
|
||||
if (fStartPrev != startValue) {
|
||||
fStartPrev = startValue;
|
||||
pdman.set4fv(fStartVar, 1, startValue.vec());
|
||||
const SkPMColor4f& startValue = _outer.start;
|
||||
if (startPrev != startValue) {
|
||||
startPrev = startValue;
|
||||
pdman.set4fv(startVar, 1, startValue.vec());
|
||||
}
|
||||
const SkPMColor4f& endValue = _outer.end();
|
||||
if (fEndPrev != endValue) {
|
||||
fEndPrev = endValue;
|
||||
pdman.set4fv(fEndVar, 1, endValue.vec());
|
||||
const SkPMColor4f& endValue = _outer.end;
|
||||
if (endPrev != endValue) {
|
||||
endPrev = endValue;
|
||||
pdman.set4fv(endVar, 1, endValue.vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
SkPMColor4f fStartPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f fEndPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
UniformHandle fStartVar;
|
||||
UniformHandle fEndVar;
|
||||
SkPMColor4f startPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
SkPMColor4f endPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
UniformHandle startVar;
|
||||
UniformHandle endVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrSingleIntervalGradientColorizer::onCreateGLSLInstance() const {
|
||||
return new GrGLSLSingleIntervalGradientColorizer();
|
||||
@ -67,15 +67,15 @@ void GrSingleIntervalGradientColorizer::onGetGLSLProcessorKey(const GrShaderCaps
|
||||
bool GrSingleIntervalGradientColorizer::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrSingleIntervalGradientColorizer& that = other.cast<GrSingleIntervalGradientColorizer>();
|
||||
(void)that;
|
||||
if (fStart != that.fStart) return false;
|
||||
if (fEnd != that.fEnd) return false;
|
||||
if (start != that.start) return false;
|
||||
if (end != that.end) return false;
|
||||
return true;
|
||||
}
|
||||
GrSingleIntervalGradientColorizer::GrSingleIntervalGradientColorizer(
|
||||
const GrSingleIntervalGradientColorizer& src)
|
||||
: INHERITED(kGrSingleIntervalGradientColorizer_ClassID, src.optimizationFlags())
|
||||
, fStart(src.fStart)
|
||||
, fEnd(src.fEnd) {}
|
||||
, start(src.start)
|
||||
, end(src.end) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrSingleIntervalGradientColorizer::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrSingleIntervalGradientColorizer(*this));
|
||||
}
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrSingleIntervalGradientColorizer : public GrFragmentProcessor {
|
||||
public:
|
||||
const SkPMColor4f& start() const { return fStart; }
|
||||
const SkPMColor4f& end() const { return fEnd; }
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(SkPMColor4f start, SkPMColor4f end) {
|
||||
return std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrSingleIntervalGradientColorizer(start, end));
|
||||
@ -24,18 +22,18 @@ public:
|
||||
GrSingleIntervalGradientColorizer(const GrSingleIntervalGradientColorizer& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "SingleIntervalGradientColorizer"; }
|
||||
SkPMColor4f start;
|
||||
SkPMColor4f end;
|
||||
|
||||
private:
|
||||
GrSingleIntervalGradientColorizer(SkPMColor4f start, SkPMColor4f end)
|
||||
: INHERITED(kGrSingleIntervalGradientColorizer_ClassID, kNone_OptimizationFlags)
|
||||
, fStart(start)
|
||||
, fEnd(end) {}
|
||||
, start(start)
|
||||
, end(end) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkPMColor4f fStart;
|
||||
SkPMColor4f fEnd;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,14 +22,14 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrSweepGradientLayout& _outer = args.fFp.cast<GrSweepGradientLayout>();
|
||||
(void)_outer;
|
||||
auto gradientMatrix = _outer.gradientMatrix();
|
||||
auto gradientMatrix = _outer.gradientMatrix;
|
||||
(void)gradientMatrix;
|
||||
auto bias = _outer.bias();
|
||||
auto bias = _outer.bias;
|
||||
(void)bias;
|
||||
auto scale = _outer.scale();
|
||||
auto scale = _outer.scale;
|
||||
(void)scale;
|
||||
fBiasVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "bias");
|
||||
fScaleVar =
|
||||
biasVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "bias");
|
||||
scaleVar =
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "scale");
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
@ -39,8 +39,8 @@ public:
|
||||
"half4(t, 1.0, 0.0, 0.0);\n",
|
||||
sk_TransformedCoords2D_0.c_str(), sk_TransformedCoords2D_0.c_str(),
|
||||
sk_TransformedCoords2D_0.c_str(), sk_TransformedCoords2D_0.c_str(),
|
||||
sk_TransformedCoords2D_0.c_str(), args.fUniformHandler->getUniformCStr(fBiasVar),
|
||||
args.fUniformHandler->getUniformCStr(fScaleVar), args.fOutputColor);
|
||||
sk_TransformedCoords2D_0.c_str(), args.fUniformHandler->getUniformCStr(biasVar),
|
||||
args.fUniformHandler->getUniformCStr(scaleVar), args.fOutputColor);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -48,22 +48,22 @@ private:
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrSweepGradientLayout& _outer = _proc.cast<GrSweepGradientLayout>();
|
||||
{
|
||||
float biasValue = _outer.bias();
|
||||
if (fBiasPrev != biasValue) {
|
||||
fBiasPrev = biasValue;
|
||||
pdman.set1f(fBiasVar, biasValue);
|
||||
float biasValue = _outer.bias;
|
||||
if (biasPrev != biasValue) {
|
||||
biasPrev = biasValue;
|
||||
pdman.set1f(biasVar, biasValue);
|
||||
}
|
||||
float scaleValue = _outer.scale();
|
||||
if (fScalePrev != scaleValue) {
|
||||
fScalePrev = scaleValue;
|
||||
pdman.set1f(fScaleVar, scaleValue);
|
||||
float scaleValue = _outer.scale;
|
||||
if (scalePrev != scaleValue) {
|
||||
scalePrev = scaleValue;
|
||||
pdman.set1f(scaleVar, scaleValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
float fBiasPrev = SK_FloatNaN;
|
||||
float fScalePrev = SK_FloatNaN;
|
||||
UniformHandle fBiasVar;
|
||||
UniformHandle fScaleVar;
|
||||
float biasPrev = SK_FloatNaN;
|
||||
float scalePrev = SK_FloatNaN;
|
||||
UniformHandle biasVar;
|
||||
UniformHandle scaleVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrSweepGradientLayout::onCreateGLSLInstance() const {
|
||||
return new GrGLSLSweepGradientLayout();
|
||||
@ -73,17 +73,17 @@ void GrSweepGradientLayout::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrSweepGradientLayout::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrSweepGradientLayout& that = other.cast<GrSweepGradientLayout>();
|
||||
(void)that;
|
||||
if (fGradientMatrix != that.fGradientMatrix) return false;
|
||||
if (fBias != that.fBias) return false;
|
||||
if (fScale != that.fScale) return false;
|
||||
if (gradientMatrix != that.gradientMatrix) return false;
|
||||
if (bias != that.bias) return false;
|
||||
if (scale != that.scale) return false;
|
||||
return true;
|
||||
}
|
||||
GrSweepGradientLayout::GrSweepGradientLayout(const GrSweepGradientLayout& src)
|
||||
: INHERITED(kGrSweepGradientLayout_ClassID, src.optimizationFlags())
|
||||
, fGradientMatrix(src.fGradientMatrix)
|
||||
, fBias(src.fBias)
|
||||
, fScale(src.fScale)
|
||||
, fCoordTransform0(src.fCoordTransform0) {
|
||||
, fCoordTransform0(src.fCoordTransform0)
|
||||
, gradientMatrix(src.gradientMatrix)
|
||||
, bias(src.bias)
|
||||
, scale(src.scale) {
|
||||
this->addCoordTransform(&fCoordTransform0);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrSweepGradientLayout::clone() const {
|
||||
|
@ -18,34 +18,30 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrSweepGradientLayout : public GrFragmentProcessor {
|
||||
public:
|
||||
const SkMatrix44& gradientMatrix() const { return fGradientMatrix; }
|
||||
float bias() const { return fBias; }
|
||||
float scale() const { return fScale; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const SkSweepGradient& gradient,
|
||||
const GrFPArgs& args);
|
||||
GrSweepGradientLayout(const GrSweepGradientLayout& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "SweepGradientLayout"; }
|
||||
GrCoordTransform fCoordTransform0;
|
||||
SkMatrix44 gradientMatrix;
|
||||
float bias;
|
||||
float scale;
|
||||
|
||||
private:
|
||||
GrSweepGradientLayout(SkMatrix44 gradientMatrix, float bias, float scale)
|
||||
: INHERITED(kGrSweepGradientLayout_ClassID,
|
||||
(OptimizationFlags)kPreservesOpaqueInput_OptimizationFlag)
|
||||
, fGradientMatrix(gradientMatrix)
|
||||
, fBias(bias)
|
||||
, fScale(scale)
|
||||
, fCoordTransform0(gradientMatrix) {
|
||||
, fCoordTransform0(gradientMatrix)
|
||||
, gradientMatrix(gradientMatrix)
|
||||
, bias(bias)
|
||||
, scale(scale) {
|
||||
this->addCoordTransform(&fCoordTransform0);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkMatrix44 fGradientMatrix;
|
||||
float fBias;
|
||||
float fScale;
|
||||
GrCoordTransform fCoordTransform0;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -41,12 +41,12 @@ void GrTextureGradientColorizer::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
bool GrTextureGradientColorizer::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrTextureGradientColorizer& that = other.cast<GrTextureGradientColorizer>();
|
||||
(void)that;
|
||||
if (fGradient != that.fGradient) return false;
|
||||
if (gradient != that.gradient) return false;
|
||||
return true;
|
||||
}
|
||||
GrTextureGradientColorizer::GrTextureGradientColorizer(const GrTextureGradientColorizer& src)
|
||||
: INHERITED(kGrTextureGradientColorizer_ClassID, src.optimizationFlags())
|
||||
, fGradient(src.fGradient) {
|
||||
, gradient(src.gradient) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureGradientColorizer::clone() const {
|
||||
@ -54,5 +54,5 @@ std::unique_ptr<GrFragmentProcessor> GrTextureGradientColorizer::clone() const {
|
||||
}
|
||||
const GrFragmentProcessor::TextureSampler& GrTextureGradientColorizer::onTextureSampler(
|
||||
int index) const {
|
||||
return IthTextureSampler(index, fGradient);
|
||||
return IthTextureSampler(index, gradient);
|
||||
}
|
||||
|
@ -21,11 +21,12 @@ public:
|
||||
GrTextureGradientColorizer(const GrTextureGradientColorizer& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "TextureGradientColorizer"; }
|
||||
TextureSampler gradient;
|
||||
|
||||
private:
|
||||
GrTextureGradientColorizer(sk_sp<GrTextureProxy> gradient)
|
||||
: INHERITED(kGrTextureGradientColorizer_ClassID, kNone_OptimizationFlags)
|
||||
, fGradient(std::move(gradient), GrSamplerState::ClampBilerp()) {
|
||||
, gradient(std::move(gradient), GrSamplerState::ClampBilerp()) {
|
||||
this->setTextureSamplerCnt(1);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
@ -33,7 +34,6 @@ private:
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
const TextureSampler& onTextureSampler(int) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
TextureSampler fGradient;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,14 +22,14 @@ public:
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrTiledGradientEffect& _outer = args.fFp.cast<GrTiledGradientEffect>();
|
||||
(void)_outer;
|
||||
auto mirror = _outer.mirror();
|
||||
auto mirror = _outer.mirror;
|
||||
(void)mirror;
|
||||
auto makePremul = _outer.makePremul();
|
||||
auto makePremul = _outer.makePremul;
|
||||
(void)makePremul;
|
||||
auto colorsAreOpaque = _outer.colorsAreOpaque();
|
||||
auto colorsAreOpaque = _outer.colorsAreOpaque;
|
||||
(void)colorsAreOpaque;
|
||||
SkString _child1("_child1");
|
||||
this->emitChild(_outer.gradLayout_index(), &_child1, args);
|
||||
this->emitChild(_outer.gradLayout_index, &_child1, args);
|
||||
fragBuilder->codeAppendf(
|
||||
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else {\n @if "
|
||||
"(%s) {\n half t_1 = t.x - 1.0;\n half tiled_t = (t_1 - 2.0 * "
|
||||
@ -37,15 +37,15 @@ public:
|
||||
" tiled_t = clamp(tiled_t, -1.0, 1.0);\n }\n t.x = "
|
||||
"abs(tiled_t);\n } else {\n t.x = fract(t.x);\n }",
|
||||
_child1.c_str(),
|
||||
(_outer.childProcessor(_outer.gradLayout_index()).preservesOpaqueInput() ? "true"
|
||||
(_outer.childProcessor(_outer.gradLayout_index).preservesOpaqueInput() ? "true"
|
||||
: "false"),
|
||||
args.fOutputColor, (_outer.mirror() ? "true" : "false"));
|
||||
args.fOutputColor, (_outer.mirror ? "true" : "false"));
|
||||
SkString _input0("t");
|
||||
SkString _child0("_child0");
|
||||
this->emitChild(_outer.colorizer_index(), _input0.c_str(), &_child0, args);
|
||||
this->emitChild(_outer.colorizer_index, _input0.c_str(), &_child0, args);
|
||||
fragBuilder->codeAppendf("\n %s = %s;\n}\n@if (%s) {\n %s.xyz *= %s.w;\n}\n",
|
||||
args.fOutputColor, _child0.c_str(),
|
||||
(_outer.makePremul() ? "true" : "false"), args.fOutputColor,
|
||||
(_outer.makePremul ? "true" : "false"), args.fOutputColor,
|
||||
args.fOutputColor);
|
||||
}
|
||||
|
||||
@ -58,26 +58,26 @@ GrGLSLFragmentProcessor* GrTiledGradientEffect::onCreateGLSLInstance() const {
|
||||
}
|
||||
void GrTiledGradientEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fMirror);
|
||||
b->add32((int32_t)fMakePremul);
|
||||
b->add32((int32_t)mirror);
|
||||
b->add32((int32_t)makePremul);
|
||||
}
|
||||
bool GrTiledGradientEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrTiledGradientEffect& that = other.cast<GrTiledGradientEffect>();
|
||||
(void)that;
|
||||
if (fMirror != that.fMirror) return false;
|
||||
if (fMakePremul != that.fMakePremul) return false;
|
||||
if (fColorsAreOpaque != that.fColorsAreOpaque) return false;
|
||||
if (mirror != that.mirror) return false;
|
||||
if (makePremul != that.makePremul) return false;
|
||||
if (colorsAreOpaque != that.colorsAreOpaque) return false;
|
||||
return true;
|
||||
}
|
||||
GrTiledGradientEffect::GrTiledGradientEffect(const GrTiledGradientEffect& src)
|
||||
: INHERITED(kGrTiledGradientEffect_ClassID, src.optimizationFlags())
|
||||
, fColorizer_index(src.fColorizer_index)
|
||||
, fGradLayout_index(src.fGradLayout_index)
|
||||
, fMirror(src.fMirror)
|
||||
, fMakePremul(src.fMakePremul)
|
||||
, fColorsAreOpaque(src.fColorsAreOpaque) {
|
||||
this->registerChildProcessor(src.childProcessor(fColorizer_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(fGradLayout_index).clone());
|
||||
, colorizer_index(src.colorizer_index)
|
||||
, gradLayout_index(src.gradLayout_index)
|
||||
, mirror(src.mirror)
|
||||
, makePremul(src.makePremul)
|
||||
, colorsAreOpaque(src.colorsAreOpaque) {
|
||||
this->registerChildProcessor(src.childProcessor(colorizer_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(gradLayout_index).clone());
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrTiledGradientEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrTiledGradientEffect(*this));
|
||||
|
@ -15,11 +15,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrTiledGradientEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
int colorizer_index() const { return fColorizer_index; }
|
||||
int gradLayout_index() const { return fGradLayout_index; }
|
||||
bool mirror() const { return fMirror; }
|
||||
bool makePremul() const { return fMakePremul; }
|
||||
bool colorsAreOpaque() const { return fColorsAreOpaque; }
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(
|
||||
std::unique_ptr<GrFragmentProcessor> colorizer,
|
||||
std::unique_ptr<GrFragmentProcessor> gradLayout, bool mirror, bool makePremul,
|
||||
@ -30,6 +25,11 @@ public:
|
||||
GrTiledGradientEffect(const GrTiledGradientEffect& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "TiledGradientEffect"; }
|
||||
int colorizer_index = -1;
|
||||
int gradLayout_index = -1;
|
||||
bool mirror;
|
||||
bool makePremul;
|
||||
bool colorsAreOpaque;
|
||||
|
||||
private:
|
||||
GrTiledGradientEffect(std::unique_ptr<GrFragmentProcessor> colorizer,
|
||||
@ -40,25 +40,20 @@ private:
|
||||
(colorsAreOpaque && gradLayout->preservesOpaqueInput()
|
||||
? kPreservesOpaqueInput_OptimizationFlag
|
||||
: kNone_OptimizationFlags))
|
||||
, fMirror(mirror)
|
||||
, fMakePremul(makePremul)
|
||||
, fColorsAreOpaque(colorsAreOpaque) {
|
||||
, mirror(mirror)
|
||||
, makePremul(makePremul)
|
||||
, colorsAreOpaque(colorsAreOpaque) {
|
||||
SkASSERT(colorizer);
|
||||
fColorizer_index = this->numChildProcessors();
|
||||
colorizer_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(colorizer));
|
||||
SkASSERT(gradLayout);
|
||||
fGradLayout_index = this->numChildProcessors();
|
||||
gradLayout_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(gradLayout));
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
int fColorizer_index = -1;
|
||||
int fGradLayout_index = -1;
|
||||
bool fMirror;
|
||||
bool fMakePremul;
|
||||
bool fColorsAreOpaque;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -23,23 +23,23 @@ public:
|
||||
const GrTwoPointConicalGradientLayout& _outer =
|
||||
args.fFp.cast<GrTwoPointConicalGradientLayout>();
|
||||
(void)_outer;
|
||||
auto gradientMatrix = _outer.gradientMatrix();
|
||||
auto gradientMatrix = _outer.gradientMatrix;
|
||||
(void)gradientMatrix;
|
||||
auto type = _outer.type();
|
||||
auto type = _outer.type;
|
||||
(void)type;
|
||||
auto isRadiusIncreasing = _outer.isRadiusIncreasing();
|
||||
auto isRadiusIncreasing = _outer.isRadiusIncreasing;
|
||||
(void)isRadiusIncreasing;
|
||||
auto isFocalOnCircle = _outer.isFocalOnCircle();
|
||||
auto isFocalOnCircle = _outer.isFocalOnCircle;
|
||||
(void)isFocalOnCircle;
|
||||
auto isWellBehaved = _outer.isWellBehaved();
|
||||
auto isWellBehaved = _outer.isWellBehaved;
|
||||
(void)isWellBehaved;
|
||||
auto isSwapped = _outer.isSwapped();
|
||||
auto isSwapped = _outer.isSwapped;
|
||||
(void)isSwapped;
|
||||
auto isNativelyFocal = _outer.isNativelyFocal();
|
||||
auto isNativelyFocal = _outer.isNativelyFocal;
|
||||
(void)isNativelyFocal;
|
||||
auto focalParams = _outer.focalParams();
|
||||
auto focalParams = _outer.focalParams;
|
||||
(void)focalParams;
|
||||
fFocalParamsVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
|
||||
focalParamsVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
|
||||
"focalParams");
|
||||
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
fragBuilder->codeAppendf(
|
||||
@ -50,10 +50,10 @@ public:
|
||||
"0:\n {\n half r0 = %s.x;\n @if (%s) {\n "
|
||||
" t = length(p) - float(r0);\n } else {\n t = "
|
||||
"-length(p) - float(r0);\n ",
|
||||
sk_TransformedCoords2D_0.c_str(), (int)_outer.type(),
|
||||
args.fUniformHandler->getUniformCStr(fFocalParamsVar),
|
||||
args.fUniformHandler->getUniformCStr(fFocalParamsVar),
|
||||
(_outer.isRadiusIncreasing() ? "true" : "false"));
|
||||
sk_TransformedCoords2D_0.c_str(), (int)_outer.type,
|
||||
args.fUniformHandler->getUniformCStr(focalParamsVar),
|
||||
args.fUniformHandler->getUniformCStr(focalParamsVar),
|
||||
(_outer.isRadiusIncreasing ? "true" : "false"));
|
||||
fragBuilder->codeAppendf(
|
||||
" }\n }\n break;\n case 2:\n {\n half invR1 "
|
||||
"= %s.x;\n half fx = %s.y;\n float x_t = -1.0;\n "
|
||||
@ -62,12 +62,11 @@ public:
|
||||
" float temp = p.x * p.x - p.y * p.y;\n if (temp >= "
|
||||
"0.0) {\n @if (%s || !%s) {\n x_t = "
|
||||
"-sqrt(temp) - p.x * float(invR1)",
|
||||
args.fUniformHandler->getUniformCStr(fFocalParamsVar),
|
||||
args.fUniformHandler->getUniformCStr(fFocalParamsVar),
|
||||
(_outer.isFocalOnCircle() ? "true" : "false"),
|
||||
(_outer.isWellBehaved() ? "true" : "false"),
|
||||
(_outer.isSwapped() ? "true" : "false"),
|
||||
(_outer.isRadiusIncreasing() ? "true" : "false"));
|
||||
args.fUniformHandler->getUniformCStr(focalParamsVar),
|
||||
args.fUniformHandler->getUniformCStr(focalParamsVar),
|
||||
(_outer.isFocalOnCircle ? "true" : "false"),
|
||||
(_outer.isWellBehaved ? "true" : "false"), (_outer.isSwapped ? "true" : "false"),
|
||||
(_outer.isRadiusIncreasing ? "true" : "false"));
|
||||
fragBuilder->codeAppendf(
|
||||
";\n } else {\n x_t = sqrt(temp) - p.x * "
|
||||
"float(invR1);\n }\n }\n }\n "
|
||||
@ -76,16 +75,16 @@ public:
|
||||
"{\n t = x_t;\n } else {\n t "
|
||||
"= x_t + float(fx);\n }\n } else {\n @if "
|
||||
"(%s) {\n ",
|
||||
(_outer.isWellBehaved() ? "true" : "false"),
|
||||
(_outer.isRadiusIncreasing() ? "true" : "false"),
|
||||
(_outer.isNativelyFocal() ? "true" : "false"),
|
||||
(_outer.isNativelyFocal() ? "true" : "false"));
|
||||
(_outer.isWellBehaved ? "true" : "false"),
|
||||
(_outer.isRadiusIncreasing ? "true" : "false"),
|
||||
(_outer.isNativelyFocal ? "true" : "false"),
|
||||
(_outer.isNativelyFocal ? "true" : "false"));
|
||||
fragBuilder->codeAppendf(
|
||||
" t = -x_t;\n } else {\n t = -x_t + "
|
||||
"float(fx);\n }\n }\n @if (%s) {\n "
|
||||
" t = 1.0 - t;\n }\n }\n break;\n}\n%s = "
|
||||
"half4(half(t), v, 0.0, 0.0);\n",
|
||||
(_outer.isSwapped() ? "true" : "false"), args.fOutputColor);
|
||||
(_outer.isSwapped ? "true" : "false"), args.fOutputColor);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -94,53 +93,53 @@ private:
|
||||
const GrTwoPointConicalGradientLayout& _outer =
|
||||
_proc.cast<GrTwoPointConicalGradientLayout>();
|
||||
{
|
||||
const SkPoint& focalParamsValue = _outer.focalParams();
|
||||
if (fFocalParamsPrev != focalParamsValue) {
|
||||
fFocalParamsPrev = focalParamsValue;
|
||||
pdman.set2f(fFocalParamsVar, focalParamsValue.fX, focalParamsValue.fY);
|
||||
const SkPoint& focalParamsValue = _outer.focalParams;
|
||||
if (focalParamsPrev != focalParamsValue) {
|
||||
focalParamsPrev = focalParamsValue;
|
||||
pdman.set2f(focalParamsVar, focalParamsValue.fX, focalParamsValue.fY);
|
||||
}
|
||||
}
|
||||
}
|
||||
SkPoint fFocalParamsPrev = SkPoint::Make(SK_FloatNaN, SK_FloatNaN);
|
||||
UniformHandle fFocalParamsVar;
|
||||
SkPoint focalParamsPrev = SkPoint::Make(SK_FloatNaN, SK_FloatNaN);
|
||||
UniformHandle focalParamsVar;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrTwoPointConicalGradientLayout::onCreateGLSLInstance() const {
|
||||
return new GrGLSLTwoPointConicalGradientLayout();
|
||||
}
|
||||
void GrTwoPointConicalGradientLayout::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fType);
|
||||
b->add32((int32_t)fIsRadiusIncreasing);
|
||||
b->add32((int32_t)fIsFocalOnCircle);
|
||||
b->add32((int32_t)fIsWellBehaved);
|
||||
b->add32((int32_t)fIsSwapped);
|
||||
b->add32((int32_t)fIsNativelyFocal);
|
||||
b->add32((int32_t)type);
|
||||
b->add32((int32_t)isRadiusIncreasing);
|
||||
b->add32((int32_t)isFocalOnCircle);
|
||||
b->add32((int32_t)isWellBehaved);
|
||||
b->add32((int32_t)isSwapped);
|
||||
b->add32((int32_t)isNativelyFocal);
|
||||
}
|
||||
bool GrTwoPointConicalGradientLayout::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrTwoPointConicalGradientLayout& that = other.cast<GrTwoPointConicalGradientLayout>();
|
||||
(void)that;
|
||||
if (fGradientMatrix != that.fGradientMatrix) return false;
|
||||
if (fType != that.fType) return false;
|
||||
if (fIsRadiusIncreasing != that.fIsRadiusIncreasing) return false;
|
||||
if (fIsFocalOnCircle != that.fIsFocalOnCircle) return false;
|
||||
if (fIsWellBehaved != that.fIsWellBehaved) return false;
|
||||
if (fIsSwapped != that.fIsSwapped) return false;
|
||||
if (fIsNativelyFocal != that.fIsNativelyFocal) return false;
|
||||
if (fFocalParams != that.fFocalParams) return false;
|
||||
if (gradientMatrix != that.gradientMatrix) return false;
|
||||
if (type != that.type) return false;
|
||||
if (isRadiusIncreasing != that.isRadiusIncreasing) return false;
|
||||
if (isFocalOnCircle != that.isFocalOnCircle) return false;
|
||||
if (isWellBehaved != that.isWellBehaved) return false;
|
||||
if (isSwapped != that.isSwapped) return false;
|
||||
if (isNativelyFocal != that.isNativelyFocal) return false;
|
||||
if (focalParams != that.focalParams) return false;
|
||||
return true;
|
||||
}
|
||||
GrTwoPointConicalGradientLayout::GrTwoPointConicalGradientLayout(
|
||||
const GrTwoPointConicalGradientLayout& src)
|
||||
: INHERITED(kGrTwoPointConicalGradientLayout_ClassID, src.optimizationFlags())
|
||||
, fGradientMatrix(src.fGradientMatrix)
|
||||
, fType(src.fType)
|
||||
, fIsRadiusIncreasing(src.fIsRadiusIncreasing)
|
||||
, fIsFocalOnCircle(src.fIsFocalOnCircle)
|
||||
, fIsWellBehaved(src.fIsWellBehaved)
|
||||
, fIsSwapped(src.fIsSwapped)
|
||||
, fIsNativelyFocal(src.fIsNativelyFocal)
|
||||
, fFocalParams(src.fFocalParams)
|
||||
, fCoordTransform0(src.fCoordTransform0) {
|
||||
, fCoordTransform0(src.fCoordTransform0)
|
||||
, gradientMatrix(src.gradientMatrix)
|
||||
, type(src.type)
|
||||
, isRadiusIncreasing(src.isRadiusIncreasing)
|
||||
, isFocalOnCircle(src.isFocalOnCircle)
|
||||
, isWellBehaved(src.isWellBehaved)
|
||||
, isSwapped(src.isSwapped)
|
||||
, isNativelyFocal(src.isNativelyFocal)
|
||||
, focalParams(src.focalParams) {
|
||||
this->addCoordTransform(&fCoordTransform0);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrTwoPointConicalGradientLayout::clone() const {
|
||||
|
@ -19,20 +19,21 @@
|
||||
class GrTwoPointConicalGradientLayout : public GrFragmentProcessor {
|
||||
public:
|
||||
enum class Type { kFocal = 2, kRadial = 0, kStrip = 1 };
|
||||
const SkMatrix44& gradientMatrix() const { return fGradientMatrix; }
|
||||
const Type& type() const { return fType; }
|
||||
bool isRadiusIncreasing() const { return fIsRadiusIncreasing; }
|
||||
bool isFocalOnCircle() const { return fIsFocalOnCircle; }
|
||||
bool isWellBehaved() const { return fIsWellBehaved; }
|
||||
bool isSwapped() const { return fIsSwapped; }
|
||||
bool isNativelyFocal() const { return fIsNativelyFocal; }
|
||||
const SkPoint& focalParams() const { return fFocalParams; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const SkTwoPointConicalGradient& gradient,
|
||||
const GrFPArgs& args);
|
||||
GrTwoPointConicalGradientLayout(const GrTwoPointConicalGradientLayout& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "TwoPointConicalGradientLayout"; }
|
||||
GrCoordTransform fCoordTransform0;
|
||||
SkMatrix44 gradientMatrix;
|
||||
Type type;
|
||||
bool isRadiusIncreasing;
|
||||
bool isFocalOnCircle;
|
||||
bool isWellBehaved;
|
||||
bool isSwapped;
|
||||
bool isNativelyFocal;
|
||||
SkPoint focalParams;
|
||||
|
||||
private:
|
||||
GrTwoPointConicalGradientLayout(SkMatrix44 gradientMatrix, Type type, bool isRadiusIncreasing,
|
||||
@ -40,30 +41,21 @@ private:
|
||||
bool isNativelyFocal, SkPoint focalParams)
|
||||
: INHERITED(kGrTwoPointConicalGradientLayout_ClassID,
|
||||
(OptimizationFlags)kNone_OptimizationFlags)
|
||||
, fGradientMatrix(gradientMatrix)
|
||||
, fType(type)
|
||||
, fIsRadiusIncreasing(isRadiusIncreasing)
|
||||
, fIsFocalOnCircle(isFocalOnCircle)
|
||||
, fIsWellBehaved(isWellBehaved)
|
||||
, fIsSwapped(isSwapped)
|
||||
, fIsNativelyFocal(isNativelyFocal)
|
||||
, fFocalParams(focalParams)
|
||||
, fCoordTransform0(gradientMatrix) {
|
||||
, fCoordTransform0(gradientMatrix)
|
||||
, gradientMatrix(gradientMatrix)
|
||||
, type(type)
|
||||
, isRadiusIncreasing(isRadiusIncreasing)
|
||||
, isFocalOnCircle(isFocalOnCircle)
|
||||
, isWellBehaved(isWellBehaved)
|
||||
, isSwapped(isSwapped)
|
||||
, isNativelyFocal(isNativelyFocal)
|
||||
, focalParams(focalParams) {
|
||||
this->addCoordTransform(&fCoordTransform0);
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
SkMatrix44 fGradientMatrix;
|
||||
Type fType;
|
||||
bool fIsRadiusIncreasing;
|
||||
bool fIsFocalOnCircle;
|
||||
bool fIsWellBehaved;
|
||||
bool fIsSwapped;
|
||||
bool fIsNativelyFocal;
|
||||
SkPoint fFocalParams;
|
||||
GrCoordTransform fCoordTransform0;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -23,107 +23,107 @@ public:
|
||||
const GrUnrolledBinaryGradientColorizer& _outer =
|
||||
args.fFp.cast<GrUnrolledBinaryGradientColorizer>();
|
||||
(void)_outer;
|
||||
auto intervalCount = _outer.intervalCount();
|
||||
auto intervalCount = _outer.intervalCount;
|
||||
(void)intervalCount;
|
||||
auto scale0_1 = _outer.scale0_1();
|
||||
auto scale0_1 = _outer.scale0_1;
|
||||
(void)scale0_1;
|
||||
auto scale2_3 = _outer.scale2_3();
|
||||
auto scale2_3 = _outer.scale2_3;
|
||||
(void)scale2_3;
|
||||
auto scale4_5 = _outer.scale4_5();
|
||||
auto scale4_5 = _outer.scale4_5;
|
||||
(void)scale4_5;
|
||||
auto scale6_7 = _outer.scale6_7();
|
||||
auto scale6_7 = _outer.scale6_7;
|
||||
(void)scale6_7;
|
||||
auto scale8_9 = _outer.scale8_9();
|
||||
auto scale8_9 = _outer.scale8_9;
|
||||
(void)scale8_9;
|
||||
auto scale10_11 = _outer.scale10_11();
|
||||
auto scale10_11 = _outer.scale10_11;
|
||||
(void)scale10_11;
|
||||
auto scale12_13 = _outer.scale12_13();
|
||||
auto scale12_13 = _outer.scale12_13;
|
||||
(void)scale12_13;
|
||||
auto scale14_15 = _outer.scale14_15();
|
||||
auto scale14_15 = _outer.scale14_15;
|
||||
(void)scale14_15;
|
||||
auto bias0_1 = _outer.bias0_1();
|
||||
auto bias0_1 = _outer.bias0_1;
|
||||
(void)bias0_1;
|
||||
auto bias2_3 = _outer.bias2_3();
|
||||
auto bias2_3 = _outer.bias2_3;
|
||||
(void)bias2_3;
|
||||
auto bias4_5 = _outer.bias4_5();
|
||||
auto bias4_5 = _outer.bias4_5;
|
||||
(void)bias4_5;
|
||||
auto bias6_7 = _outer.bias6_7();
|
||||
auto bias6_7 = _outer.bias6_7;
|
||||
(void)bias6_7;
|
||||
auto bias8_9 = _outer.bias8_9();
|
||||
auto bias8_9 = _outer.bias8_9;
|
||||
(void)bias8_9;
|
||||
auto bias10_11 = _outer.bias10_11();
|
||||
auto bias10_11 = _outer.bias10_11;
|
||||
(void)bias10_11;
|
||||
auto bias12_13 = _outer.bias12_13();
|
||||
auto bias12_13 = _outer.bias12_13;
|
||||
(void)bias12_13;
|
||||
auto bias14_15 = _outer.bias14_15();
|
||||
auto bias14_15 = _outer.bias14_15;
|
||||
(void)bias14_15;
|
||||
auto thresholds1_7 = _outer.thresholds1_7();
|
||||
auto thresholds1_7 = _outer.thresholds1_7;
|
||||
(void)thresholds1_7;
|
||||
auto thresholds9_13 = _outer.thresholds9_13();
|
||||
auto thresholds9_13 = _outer.thresholds9_13;
|
||||
(void)thresholds9_13;
|
||||
fScale0_1Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
scale0_1Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"scale0_1");
|
||||
if (intervalCount > 1) {
|
||||
fScale2_3Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale2_3");
|
||||
scale2_3Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"scale2_3");
|
||||
}
|
||||
if (intervalCount > 2) {
|
||||
fScale4_5Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale4_5");
|
||||
scale4_5Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"scale4_5");
|
||||
}
|
||||
if (intervalCount > 3) {
|
||||
fScale6_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale6_7");
|
||||
scale6_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"scale6_7");
|
||||
}
|
||||
if (intervalCount > 4) {
|
||||
fScale8_9Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale8_9");
|
||||
scale8_9Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"scale8_9");
|
||||
}
|
||||
if (intervalCount > 5) {
|
||||
fScale10_11Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
scale10_11Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale10_11");
|
||||
}
|
||||
if (intervalCount > 6) {
|
||||
fScale12_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
scale12_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale12_13");
|
||||
}
|
||||
if (intervalCount > 7) {
|
||||
fScale14_15Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
scale14_15Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "scale14_15");
|
||||
}
|
||||
fBias0_1Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
bias0_1Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"bias0_1");
|
||||
if (intervalCount > 1) {
|
||||
fBias2_3Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
bias2_3Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"bias2_3");
|
||||
}
|
||||
if (intervalCount > 2) {
|
||||
fBias4_5Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
bias4_5Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"bias4_5");
|
||||
}
|
||||
if (intervalCount > 3) {
|
||||
fBias6_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
bias6_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"bias6_7");
|
||||
}
|
||||
if (intervalCount > 4) {
|
||||
fBias8_9Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
bias8_9Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
|
||||
"bias8_9");
|
||||
}
|
||||
if (intervalCount > 5) {
|
||||
fBias10_11Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
bias10_11Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "bias10_11");
|
||||
}
|
||||
if (intervalCount > 6) {
|
||||
fBias12_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
bias12_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "bias12_13");
|
||||
}
|
||||
if (intervalCount > 7) {
|
||||
fBias14_15Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
bias14_15Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "bias14_15");
|
||||
}
|
||||
fThresholds1_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "thresholds1_7");
|
||||
fThresholds9_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
thresholds1_7Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
"thresholds1_7");
|
||||
thresholds9_13Var = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||
kHalf4_GrSLType, "thresholds9_13");
|
||||
fragBuilder->codeAppendf(
|
||||
"half t = %s.x;\nfloat4 scale, bias;\nif (%d <= 4 || t < %s.w) {\n if (%d <= 2 "
|
||||
@ -133,50 +133,50 @@ public:
|
||||
"scale = %s;\n bias = %s;\n } else {\n scale = %s;\n "
|
||||
" bias = %s;\n }\n }\n} else {\n if (%d <= 6 || t < %s.y) "
|
||||
"{\n if (%d <= 5 || t <",
|
||||
args.fInputColor, _outer.intervalCount(),
|
||||
args.fUniformHandler->getUniformCStr(fThresholds1_7Var), _outer.intervalCount(),
|
||||
args.fUniformHandler->getUniformCStr(fThresholds1_7Var), _outer.intervalCount(),
|
||||
args.fUniformHandler->getUniformCStr(fThresholds1_7Var),
|
||||
args.fUniformHandler->getUniformCStr(fScale0_1Var),
|
||||
args.fUniformHandler->getUniformCStr(fBias0_1Var),
|
||||
fScale2_3Var.isValid() ? args.fUniformHandler->getUniformCStr(fScale2_3Var)
|
||||
args.fInputColor, _outer.intervalCount,
|
||||
args.fUniformHandler->getUniformCStr(thresholds1_7Var), _outer.intervalCount,
|
||||
args.fUniformHandler->getUniformCStr(thresholds1_7Var), _outer.intervalCount,
|
||||
args.fUniformHandler->getUniformCStr(thresholds1_7Var),
|
||||
args.fUniformHandler->getUniformCStr(scale0_1Var),
|
||||
args.fUniformHandler->getUniformCStr(bias0_1Var),
|
||||
scale2_3Var.isValid() ? args.fUniformHandler->getUniformCStr(scale2_3Var)
|
||||
: "float4(0)",
|
||||
fBias2_3Var.isValid() ? args.fUniformHandler->getUniformCStr(fBias2_3Var)
|
||||
bias2_3Var.isValid() ? args.fUniformHandler->getUniformCStr(bias2_3Var)
|
||||
: "float4(0)",
|
||||
_outer.intervalCount(), args.fUniformHandler->getUniformCStr(fThresholds1_7Var),
|
||||
fScale4_5Var.isValid() ? args.fUniformHandler->getUniformCStr(fScale4_5Var)
|
||||
_outer.intervalCount, args.fUniformHandler->getUniformCStr(thresholds1_7Var),
|
||||
scale4_5Var.isValid() ? args.fUniformHandler->getUniformCStr(scale4_5Var)
|
||||
: "float4(0)",
|
||||
fBias4_5Var.isValid() ? args.fUniformHandler->getUniformCStr(fBias4_5Var)
|
||||
bias4_5Var.isValid() ? args.fUniformHandler->getUniformCStr(bias4_5Var)
|
||||
: "float4(0)",
|
||||
fScale6_7Var.isValid() ? args.fUniformHandler->getUniformCStr(fScale6_7Var)
|
||||
scale6_7Var.isValid() ? args.fUniformHandler->getUniformCStr(scale6_7Var)
|
||||
: "float4(0)",
|
||||
fBias6_7Var.isValid() ? args.fUniformHandler->getUniformCStr(fBias6_7Var)
|
||||
bias6_7Var.isValid() ? args.fUniformHandler->getUniformCStr(bias6_7Var)
|
||||
: "float4(0)",
|
||||
_outer.intervalCount(), args.fUniformHandler->getUniformCStr(fThresholds9_13Var),
|
||||
_outer.intervalCount());
|
||||
_outer.intervalCount, args.fUniformHandler->getUniformCStr(thresholds9_13Var),
|
||||
_outer.intervalCount);
|
||||
fragBuilder->codeAppendf(
|
||||
" %s.x) {\n scale = %s;\n bias = %s;\n } else {\n "
|
||||
" scale = %s;\n bias = %s;\n }\n } else {\n if "
|
||||
"(%d <= 7 || t < %s.z) {\n scale = %s;\n bias = %s;\n "
|
||||
"} else {\n scale = %s;\n bias = %s;\n }\n "
|
||||
"}\n}\n%s = half4(float(t) * scale + bias);\n",
|
||||
args.fUniformHandler->getUniformCStr(fThresholds9_13Var),
|
||||
fScale8_9Var.isValid() ? args.fUniformHandler->getUniformCStr(fScale8_9Var)
|
||||
args.fUniformHandler->getUniformCStr(thresholds9_13Var),
|
||||
scale8_9Var.isValid() ? args.fUniformHandler->getUniformCStr(scale8_9Var)
|
||||
: "float4(0)",
|
||||
fBias8_9Var.isValid() ? args.fUniformHandler->getUniformCStr(fBias8_9Var)
|
||||
bias8_9Var.isValid() ? args.fUniformHandler->getUniformCStr(bias8_9Var)
|
||||
: "float4(0)",
|
||||
fScale10_11Var.isValid() ? args.fUniformHandler->getUniformCStr(fScale10_11Var)
|
||||
scale10_11Var.isValid() ? args.fUniformHandler->getUniformCStr(scale10_11Var)
|
||||
: "float4(0)",
|
||||
fBias10_11Var.isValid() ? args.fUniformHandler->getUniformCStr(fBias10_11Var)
|
||||
bias10_11Var.isValid() ? args.fUniformHandler->getUniformCStr(bias10_11Var)
|
||||
: "float4(0)",
|
||||
_outer.intervalCount(), args.fUniformHandler->getUniformCStr(fThresholds9_13Var),
|
||||
fScale12_13Var.isValid() ? args.fUniformHandler->getUniformCStr(fScale12_13Var)
|
||||
_outer.intervalCount, args.fUniformHandler->getUniformCStr(thresholds9_13Var),
|
||||
scale12_13Var.isValid() ? args.fUniformHandler->getUniformCStr(scale12_13Var)
|
||||
: "float4(0)",
|
||||
fBias12_13Var.isValid() ? args.fUniformHandler->getUniformCStr(fBias12_13Var)
|
||||
bias12_13Var.isValid() ? args.fUniformHandler->getUniformCStr(bias12_13Var)
|
||||
: "float4(0)",
|
||||
fScale14_15Var.isValid() ? args.fUniformHandler->getUniformCStr(fScale14_15Var)
|
||||
scale14_15Var.isValid() ? args.fUniformHandler->getUniformCStr(scale14_15Var)
|
||||
: "float4(0)",
|
||||
fBias14_15Var.isValid() ? args.fUniformHandler->getUniformCStr(fBias14_15Var)
|
||||
bias14_15Var.isValid() ? args.fUniformHandler->getUniformCStr(bias14_15Var)
|
||||
: "float4(0)",
|
||||
args.fOutputColor);
|
||||
}
|
||||
@ -187,128 +187,128 @@ private:
|
||||
const GrUnrolledBinaryGradientColorizer& _outer =
|
||||
_proc.cast<GrUnrolledBinaryGradientColorizer>();
|
||||
{
|
||||
pdman.set4fv(fScale0_1Var, 1, (_outer.scale0_1()).vec());
|
||||
if (fScale2_3Var.isValid()) {
|
||||
pdman.set4fv(fScale2_3Var, 1, (_outer.scale2_3()).vec());
|
||||
pdman.set4fv(scale0_1Var, 1, (_outer.scale0_1).vec());
|
||||
if (scale2_3Var.isValid()) {
|
||||
pdman.set4fv(scale2_3Var, 1, (_outer.scale2_3).vec());
|
||||
}
|
||||
if (fScale4_5Var.isValid()) {
|
||||
pdman.set4fv(fScale4_5Var, 1, (_outer.scale4_5()).vec());
|
||||
if (scale4_5Var.isValid()) {
|
||||
pdman.set4fv(scale4_5Var, 1, (_outer.scale4_5).vec());
|
||||
}
|
||||
if (fScale6_7Var.isValid()) {
|
||||
pdman.set4fv(fScale6_7Var, 1, (_outer.scale6_7()).vec());
|
||||
if (scale6_7Var.isValid()) {
|
||||
pdman.set4fv(scale6_7Var, 1, (_outer.scale6_7).vec());
|
||||
}
|
||||
if (fScale8_9Var.isValid()) {
|
||||
pdman.set4fv(fScale8_9Var, 1, (_outer.scale8_9()).vec());
|
||||
if (scale8_9Var.isValid()) {
|
||||
pdman.set4fv(scale8_9Var, 1, (_outer.scale8_9).vec());
|
||||
}
|
||||
if (fScale10_11Var.isValid()) {
|
||||
pdman.set4fv(fScale10_11Var, 1, (_outer.scale10_11()).vec());
|
||||
if (scale10_11Var.isValid()) {
|
||||
pdman.set4fv(scale10_11Var, 1, (_outer.scale10_11).vec());
|
||||
}
|
||||
if (fScale12_13Var.isValid()) {
|
||||
pdman.set4fv(fScale12_13Var, 1, (_outer.scale12_13()).vec());
|
||||
if (scale12_13Var.isValid()) {
|
||||
pdman.set4fv(scale12_13Var, 1, (_outer.scale12_13).vec());
|
||||
}
|
||||
if (fScale14_15Var.isValid()) {
|
||||
pdman.set4fv(fScale14_15Var, 1, (_outer.scale14_15()).vec());
|
||||
if (scale14_15Var.isValid()) {
|
||||
pdman.set4fv(scale14_15Var, 1, (_outer.scale14_15).vec());
|
||||
}
|
||||
pdman.set4fv(fBias0_1Var, 1, (_outer.bias0_1()).vec());
|
||||
if (fBias2_3Var.isValid()) {
|
||||
pdman.set4fv(fBias2_3Var, 1, (_outer.bias2_3()).vec());
|
||||
pdman.set4fv(bias0_1Var, 1, (_outer.bias0_1).vec());
|
||||
if (bias2_3Var.isValid()) {
|
||||
pdman.set4fv(bias2_3Var, 1, (_outer.bias2_3).vec());
|
||||
}
|
||||
if (fBias4_5Var.isValid()) {
|
||||
pdman.set4fv(fBias4_5Var, 1, (_outer.bias4_5()).vec());
|
||||
if (bias4_5Var.isValid()) {
|
||||
pdman.set4fv(bias4_5Var, 1, (_outer.bias4_5).vec());
|
||||
}
|
||||
if (fBias6_7Var.isValid()) {
|
||||
pdman.set4fv(fBias6_7Var, 1, (_outer.bias6_7()).vec());
|
||||
if (bias6_7Var.isValid()) {
|
||||
pdman.set4fv(bias6_7Var, 1, (_outer.bias6_7).vec());
|
||||
}
|
||||
if (fBias8_9Var.isValid()) {
|
||||
pdman.set4fv(fBias8_9Var, 1, (_outer.bias8_9()).vec());
|
||||
if (bias8_9Var.isValid()) {
|
||||
pdman.set4fv(bias8_9Var, 1, (_outer.bias8_9).vec());
|
||||
}
|
||||
if (fBias10_11Var.isValid()) {
|
||||
pdman.set4fv(fBias10_11Var, 1, (_outer.bias10_11()).vec());
|
||||
if (bias10_11Var.isValid()) {
|
||||
pdman.set4fv(bias10_11Var, 1, (_outer.bias10_11).vec());
|
||||
}
|
||||
if (fBias12_13Var.isValid()) {
|
||||
pdman.set4fv(fBias12_13Var, 1, (_outer.bias12_13()).vec());
|
||||
if (bias12_13Var.isValid()) {
|
||||
pdman.set4fv(bias12_13Var, 1, (_outer.bias12_13).vec());
|
||||
}
|
||||
if (fBias14_15Var.isValid()) {
|
||||
pdman.set4fv(fBias14_15Var, 1, (_outer.bias14_15()).vec());
|
||||
if (bias14_15Var.isValid()) {
|
||||
pdman.set4fv(bias14_15Var, 1, (_outer.bias14_15).vec());
|
||||
}
|
||||
pdman.set4fv(fThresholds1_7Var, 1,
|
||||
reinterpret_cast<const float*>(&(_outer.thresholds1_7())));
|
||||
pdman.set4fv(fThresholds9_13Var, 1,
|
||||
reinterpret_cast<const float*>(&(_outer.thresholds9_13())));
|
||||
pdman.set4fv(thresholds1_7Var, 1,
|
||||
reinterpret_cast<const float*>(&(_outer.thresholds1_7)));
|
||||
pdman.set4fv(thresholds9_13Var, 1,
|
||||
reinterpret_cast<const float*>(&(_outer.thresholds9_13)));
|
||||
}
|
||||
}
|
||||
UniformHandle fScale0_1Var;
|
||||
UniformHandle fScale2_3Var;
|
||||
UniformHandle fScale4_5Var;
|
||||
UniformHandle fScale6_7Var;
|
||||
UniformHandle fScale8_9Var;
|
||||
UniformHandle fScale10_11Var;
|
||||
UniformHandle fScale12_13Var;
|
||||
UniformHandle fScale14_15Var;
|
||||
UniformHandle fBias0_1Var;
|
||||
UniformHandle fBias2_3Var;
|
||||
UniformHandle fBias4_5Var;
|
||||
UniformHandle fBias6_7Var;
|
||||
UniformHandle fBias8_9Var;
|
||||
UniformHandle fBias10_11Var;
|
||||
UniformHandle fBias12_13Var;
|
||||
UniformHandle fBias14_15Var;
|
||||
UniformHandle fThresholds1_7Var;
|
||||
UniformHandle fThresholds9_13Var;
|
||||
UniformHandle scale0_1Var;
|
||||
UniformHandle scale2_3Var;
|
||||
UniformHandle scale4_5Var;
|
||||
UniformHandle scale6_7Var;
|
||||
UniformHandle scale8_9Var;
|
||||
UniformHandle scale10_11Var;
|
||||
UniformHandle scale12_13Var;
|
||||
UniformHandle scale14_15Var;
|
||||
UniformHandle bias0_1Var;
|
||||
UniformHandle bias2_3Var;
|
||||
UniformHandle bias4_5Var;
|
||||
UniformHandle bias6_7Var;
|
||||
UniformHandle bias8_9Var;
|
||||
UniformHandle bias10_11Var;
|
||||
UniformHandle bias12_13Var;
|
||||
UniformHandle bias14_15Var;
|
||||
UniformHandle thresholds1_7Var;
|
||||
UniformHandle thresholds9_13Var;
|
||||
};
|
||||
GrGLSLFragmentProcessor* GrUnrolledBinaryGradientColorizer::onCreateGLSLInstance() const {
|
||||
return new GrGLSLUnrolledBinaryGradientColorizer();
|
||||
}
|
||||
void GrUnrolledBinaryGradientColorizer::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {
|
||||
b->add32((int32_t)fIntervalCount);
|
||||
b->add32((int32_t)intervalCount);
|
||||
}
|
||||
bool GrUnrolledBinaryGradientColorizer::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrUnrolledBinaryGradientColorizer& that = other.cast<GrUnrolledBinaryGradientColorizer>();
|
||||
(void)that;
|
||||
if (fIntervalCount != that.fIntervalCount) return false;
|
||||
if (fScale0_1 != that.fScale0_1) return false;
|
||||
if (fScale2_3 != that.fScale2_3) return false;
|
||||
if (fScale4_5 != that.fScale4_5) return false;
|
||||
if (fScale6_7 != that.fScale6_7) return false;
|
||||
if (fScale8_9 != that.fScale8_9) return false;
|
||||
if (fScale10_11 != that.fScale10_11) return false;
|
||||
if (fScale12_13 != that.fScale12_13) return false;
|
||||
if (fScale14_15 != that.fScale14_15) return false;
|
||||
if (fBias0_1 != that.fBias0_1) return false;
|
||||
if (fBias2_3 != that.fBias2_3) return false;
|
||||
if (fBias4_5 != that.fBias4_5) return false;
|
||||
if (fBias6_7 != that.fBias6_7) return false;
|
||||
if (fBias8_9 != that.fBias8_9) return false;
|
||||
if (fBias10_11 != that.fBias10_11) return false;
|
||||
if (fBias12_13 != that.fBias12_13) return false;
|
||||
if (fBias14_15 != that.fBias14_15) return false;
|
||||
if (fThresholds1_7 != that.fThresholds1_7) return false;
|
||||
if (fThresholds9_13 != that.fThresholds9_13) return false;
|
||||
if (intervalCount != that.intervalCount) return false;
|
||||
if (scale0_1 != that.scale0_1) return false;
|
||||
if (scale2_3 != that.scale2_3) return false;
|
||||
if (scale4_5 != that.scale4_5) return false;
|
||||
if (scale6_7 != that.scale6_7) return false;
|
||||
if (scale8_9 != that.scale8_9) return false;
|
||||
if (scale10_11 != that.scale10_11) return false;
|
||||
if (scale12_13 != that.scale12_13) return false;
|
||||
if (scale14_15 != that.scale14_15) return false;
|
||||
if (bias0_1 != that.bias0_1) return false;
|
||||
if (bias2_3 != that.bias2_3) return false;
|
||||
if (bias4_5 != that.bias4_5) return false;
|
||||
if (bias6_7 != that.bias6_7) return false;
|
||||
if (bias8_9 != that.bias8_9) return false;
|
||||
if (bias10_11 != that.bias10_11) return false;
|
||||
if (bias12_13 != that.bias12_13) return false;
|
||||
if (bias14_15 != that.bias14_15) return false;
|
||||
if (thresholds1_7 != that.thresholds1_7) return false;
|
||||
if (thresholds9_13 != that.thresholds9_13) return false;
|
||||
return true;
|
||||
}
|
||||
GrUnrolledBinaryGradientColorizer::GrUnrolledBinaryGradientColorizer(
|
||||
const GrUnrolledBinaryGradientColorizer& src)
|
||||
: INHERITED(kGrUnrolledBinaryGradientColorizer_ClassID, src.optimizationFlags())
|
||||
, fIntervalCount(src.fIntervalCount)
|
||||
, fScale0_1(src.fScale0_1)
|
||||
, fScale2_3(src.fScale2_3)
|
||||
, fScale4_5(src.fScale4_5)
|
||||
, fScale6_7(src.fScale6_7)
|
||||
, fScale8_9(src.fScale8_9)
|
||||
, fScale10_11(src.fScale10_11)
|
||||
, fScale12_13(src.fScale12_13)
|
||||
, fScale14_15(src.fScale14_15)
|
||||
, fBias0_1(src.fBias0_1)
|
||||
, fBias2_3(src.fBias2_3)
|
||||
, fBias4_5(src.fBias4_5)
|
||||
, fBias6_7(src.fBias6_7)
|
||||
, fBias8_9(src.fBias8_9)
|
||||
, fBias10_11(src.fBias10_11)
|
||||
, fBias12_13(src.fBias12_13)
|
||||
, fBias14_15(src.fBias14_15)
|
||||
, fThresholds1_7(src.fThresholds1_7)
|
||||
, fThresholds9_13(src.fThresholds9_13) {}
|
||||
, intervalCount(src.intervalCount)
|
||||
, scale0_1(src.scale0_1)
|
||||
, scale2_3(src.scale2_3)
|
||||
, scale4_5(src.scale4_5)
|
||||
, scale6_7(src.scale6_7)
|
||||
, scale8_9(src.scale8_9)
|
||||
, scale10_11(src.scale10_11)
|
||||
, scale12_13(src.scale12_13)
|
||||
, scale14_15(src.scale14_15)
|
||||
, bias0_1(src.bias0_1)
|
||||
, bias2_3(src.bias2_3)
|
||||
, bias4_5(src.bias4_5)
|
||||
, bias6_7(src.bias6_7)
|
||||
, bias8_9(src.bias8_9)
|
||||
, bias10_11(src.bias10_11)
|
||||
, bias12_13(src.bias12_13)
|
||||
, bias14_15(src.bias14_15)
|
||||
, thresholds1_7(src.thresholds1_7)
|
||||
, thresholds9_13(src.thresholds9_13) {}
|
||||
std::unique_ptr<GrFragmentProcessor> GrUnrolledBinaryGradientColorizer::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrUnrolledBinaryGradientColorizer(*this));
|
||||
}
|
||||
|
@ -16,25 +16,6 @@
|
||||
class GrUnrolledBinaryGradientColorizer : public GrFragmentProcessor {
|
||||
public:
|
||||
static const int kMaxColorCount = 16;
|
||||
int32_t intervalCount() const { return fIntervalCount; }
|
||||
const SkPMColor4f& scale0_1() const { return fScale0_1; }
|
||||
const SkPMColor4f& scale2_3() const { return fScale2_3; }
|
||||
const SkPMColor4f& scale4_5() const { return fScale4_5; }
|
||||
const SkPMColor4f& scale6_7() const { return fScale6_7; }
|
||||
const SkPMColor4f& scale8_9() const { return fScale8_9; }
|
||||
const SkPMColor4f& scale10_11() const { return fScale10_11; }
|
||||
const SkPMColor4f& scale12_13() const { return fScale12_13; }
|
||||
const SkPMColor4f& scale14_15() const { return fScale14_15; }
|
||||
const SkPMColor4f& bias0_1() const { return fBias0_1; }
|
||||
const SkPMColor4f& bias2_3() const { return fBias2_3; }
|
||||
const SkPMColor4f& bias4_5() const { return fBias4_5; }
|
||||
const SkPMColor4f& bias6_7() const { return fBias6_7; }
|
||||
const SkPMColor4f& bias8_9() const { return fBias8_9; }
|
||||
const SkPMColor4f& bias10_11() const { return fBias10_11; }
|
||||
const SkPMColor4f& bias12_13() const { return fBias12_13; }
|
||||
const SkPMColor4f& bias14_15() const { return fBias14_15; }
|
||||
const SkRect& thresholds1_7() const { return fThresholds1_7; }
|
||||
const SkRect& thresholds9_13() const { return fThresholds9_13; }
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(const SkPMColor4f* colors,
|
||||
const SkScalar* positions,
|
||||
@ -42,6 +23,25 @@ public:
|
||||
GrUnrolledBinaryGradientColorizer(const GrUnrolledBinaryGradientColorizer& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "UnrolledBinaryGradientColorizer"; }
|
||||
int32_t intervalCount;
|
||||
SkPMColor4f scale0_1;
|
||||
SkPMColor4f scale2_3;
|
||||
SkPMColor4f scale4_5;
|
||||
SkPMColor4f scale6_7;
|
||||
SkPMColor4f scale8_9;
|
||||
SkPMColor4f scale10_11;
|
||||
SkPMColor4f scale12_13;
|
||||
SkPMColor4f scale14_15;
|
||||
SkPMColor4f bias0_1;
|
||||
SkPMColor4f bias2_3;
|
||||
SkPMColor4f bias4_5;
|
||||
SkPMColor4f bias6_7;
|
||||
SkPMColor4f bias8_9;
|
||||
SkPMColor4f bias10_11;
|
||||
SkPMColor4f bias12_13;
|
||||
SkPMColor4f bias14_15;
|
||||
SkRect thresholds1_7;
|
||||
SkRect thresholds9_13;
|
||||
|
||||
private:
|
||||
GrUnrolledBinaryGradientColorizer(int32_t intervalCount,
|
||||
@ -64,48 +64,29 @@ private:
|
||||
SkRect thresholds1_7,
|
||||
SkRect thresholds9_13)
|
||||
: INHERITED(kGrUnrolledBinaryGradientColorizer_ClassID, kNone_OptimizationFlags)
|
||||
, fIntervalCount(intervalCount)
|
||||
, fScale0_1(scale0_1)
|
||||
, fScale2_3(scale2_3)
|
||||
, fScale4_5(scale4_5)
|
||||
, fScale6_7(scale6_7)
|
||||
, fScale8_9(scale8_9)
|
||||
, fScale10_11(scale10_11)
|
||||
, fScale12_13(scale12_13)
|
||||
, fScale14_15(scale14_15)
|
||||
, fBias0_1(bias0_1)
|
||||
, fBias2_3(bias2_3)
|
||||
, fBias4_5(bias4_5)
|
||||
, fBias6_7(bias6_7)
|
||||
, fBias8_9(bias8_9)
|
||||
, fBias10_11(bias10_11)
|
||||
, fBias12_13(bias12_13)
|
||||
, fBias14_15(bias14_15)
|
||||
, fThresholds1_7(thresholds1_7)
|
||||
, fThresholds9_13(thresholds9_13) {}
|
||||
, intervalCount(intervalCount)
|
||||
, scale0_1(scale0_1)
|
||||
, scale2_3(scale2_3)
|
||||
, scale4_5(scale4_5)
|
||||
, scale6_7(scale6_7)
|
||||
, scale8_9(scale8_9)
|
||||
, scale10_11(scale10_11)
|
||||
, scale12_13(scale12_13)
|
||||
, scale14_15(scale14_15)
|
||||
, bias0_1(bias0_1)
|
||||
, bias2_3(bias2_3)
|
||||
, bias4_5(bias4_5)
|
||||
, bias6_7(bias6_7)
|
||||
, bias8_9(bias8_9)
|
||||
, bias10_11(bias10_11)
|
||||
, bias12_13(bias12_13)
|
||||
, bias14_15(bias14_15)
|
||||
, thresholds1_7(thresholds1_7)
|
||||
, thresholds9_13(thresholds9_13) {}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
int32_t fIntervalCount;
|
||||
SkPMColor4f fScale0_1;
|
||||
SkPMColor4f fScale2_3;
|
||||
SkPMColor4f fScale4_5;
|
||||
SkPMColor4f fScale6_7;
|
||||
SkPMColor4f fScale8_9;
|
||||
SkPMColor4f fScale10_11;
|
||||
SkPMColor4f fScale12_13;
|
||||
SkPMColor4f fScale14_15;
|
||||
SkPMColor4f fBias0_1;
|
||||
SkPMColor4f fBias2_3;
|
||||
SkPMColor4f fBias4_5;
|
||||
SkPMColor4f fBias6_7;
|
||||
SkPMColor4f fBias8_9;
|
||||
SkPMColor4f fBias10_11;
|
||||
SkPMColor4f fBias12_13;
|
||||
SkPMColor4f fBias14_15;
|
||||
SkRect fThresholds1_7;
|
||||
SkRect fThresholds9_13;
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
};
|
||||
#endif
|
||||
|
@ -101,7 +101,7 @@ void CPPCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
|
||||
default:
|
||||
SkASSERT(false);
|
||||
}
|
||||
fFormatArgs.push_back("_outer." + String(var->fName) + "_index() " + op + " 0 ? \"true\" "
|
||||
fFormatArgs.push_back("_outer." + String(var->fName) + "_index " + op + " 0 ? \"true\" "
|
||||
": \"false\"");
|
||||
} else {
|
||||
INHERITED::writeBinaryExpression(b, parentPrecedence);
|
||||
@ -321,7 +321,7 @@ void CPPCodeGenerator::writeVariableReference(const VariableReference& ref) {
|
||||
} else if (SectionAndParameterHelper::IsParameter(ref.fVariable)) {
|
||||
String name(ref.fVariable.fName);
|
||||
this->writeRuntimeValue(ref.fVariable.fType, ref.fVariable.fModifiers.fLayout,
|
||||
String::printf("_outer.%s()", name.c_str()).c_str());
|
||||
String::printf("_outer.%s", name.c_str()).c_str());
|
||||
} else {
|
||||
this->write(ref.fVariable.fName);
|
||||
}
|
||||
@ -360,7 +360,7 @@ void CPPCodeGenerator::writeFieldAccess(const FieldAccess& access) {
|
||||
|
||||
const Type::Field& field = fContext.fFragmentProcessor_Type->fields()[access.fFieldIndex];
|
||||
const Variable& var = ((const VariableReference&) *access.fBase).fVariable;
|
||||
String cppAccess = String::printf("_outer.childProcessor(_outer.%s_index()).%s()",
|
||||
String cppAccess = String::printf("_outer.childProcessor(_outer.%s_index).%s()",
|
||||
String(var.fName).c_str(),
|
||||
String(field.fName).c_str());
|
||||
|
||||
@ -442,9 +442,9 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
String childName = "_child" + to_string(index);
|
||||
addExtraEmitCodeLine("SkString " + childName + "(\"" + childName + "\");");
|
||||
if (c.fArguments[0]->fType.kind() == Type::kNullable_Kind) {
|
||||
addExtraEmitCodeLine("if (_outer." + String(child.fName) + "_index() >= 0) {\n ");
|
||||
addExtraEmitCodeLine("if (_outer." + String(child.fName) + "_index >= 0) {\n ");
|
||||
}
|
||||
addExtraEmitCodeLine("this->emitChild(_outer." + String(child.fName) + "_index()" +
|
||||
addExtraEmitCodeLine("this->emitChild(_outer." + String(child.fName) + "_index" +
|
||||
inputArg + ", &" + childName + ", args);");
|
||||
if (c.fArguments[0]->fType.kind() == Type::kNullable_Kind) {
|
||||
// Null FPs are not emitted, but their output can still be referenced in dependent
|
||||
@ -846,7 +846,7 @@ bool CPPCodeGenerator::writeEmitCode(std::vector<const Variable*>& uniforms) {
|
||||
const char* name = nameString.c_str();
|
||||
if (SectionAndParameterHelper::IsParameter(*decl.fVar) &&
|
||||
is_accessible(*decl.fVar)) {
|
||||
this->writef(" auto %s = _outer.%s();\n"
|
||||
this->writef(" auto %s = _outer.%s;\n"
|
||||
" (void) %s;\n",
|
||||
name, name, name);
|
||||
}
|
||||
@ -918,12 +918,12 @@ void CPPCodeGenerator::writeSetData(std::vector<const Variable*>& uniforms) {
|
||||
// Use AccessType since that will match the return type of _outer's public API.
|
||||
String valueType = HCodeGenerator::AccessType(fContext, u->fType,
|
||||
u->fModifiers.fLayout);
|
||||
this->writef("%s%s %s = _outer.%s();\n",
|
||||
this->writef("%s%s %s = _outer.%s;\n",
|
||||
indent.c_str(), valueType.c_str(), valueVar.c_str(), name);
|
||||
} else {
|
||||
// Not tracked and the mapper only needs to use the value once
|
||||
// so send it a safe expression instead of the variable name
|
||||
valueVar.appendf("(_outer.%s())", name);
|
||||
valueVar.appendf("(_outer.%s)", name);
|
||||
}
|
||||
|
||||
if (isTracked) {
|
||||
@ -979,7 +979,7 @@ void CPPCodeGenerator::writeSetData(std::vector<const Variable*>& uniforms) {
|
||||
fullName);
|
||||
wroteProcessor = true;
|
||||
}
|
||||
this->writef(" auto %s = _outer.%s();\n"
|
||||
this->writef(" auto %s = _outer.%s;\n"
|
||||
" (void) %s;\n",
|
||||
name, name, name);
|
||||
}
|
||||
@ -1023,6 +1023,12 @@ void CPPCodeGenerator::writeClone() {
|
||||
this->writef("%s::%s(const %s& src)\n"
|
||||
": INHERITED(k%s_ClassID, src.optimizationFlags())", fFullName.c_str(),
|
||||
fFullName.c_str(), fFullName.c_str(), fFullName.c_str());
|
||||
const auto transforms = fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION);
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
const Section& s = *transforms[i];
|
||||
String fieldName = HCodeGenerator::CoordTransformName(s.fArgument, i);
|
||||
this->writef("\n, %s(src.%s)", fieldName.c_str(), fieldName.c_str());
|
||||
}
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String fieldName = HCodeGenerator::FieldName(String(param->fName).c_str());
|
||||
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
@ -1035,12 +1041,6 @@ void CPPCodeGenerator::writeClone() {
|
||||
fieldName.c_str());
|
||||
}
|
||||
}
|
||||
const auto transforms = fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION);
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
const Section& s = *transforms[i];
|
||||
String fieldName = HCodeGenerator::CoordTransformName(s.fArgument, i);
|
||||
this->writef("\n, %s(src.%s)", fieldName.c_str(), fieldName.c_str());
|
||||
}
|
||||
this->writef(" {\n");
|
||||
int samplerCount = 0;
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
@ -1105,6 +1105,9 @@ void CPPCodeGenerator::writeGetKey() {
|
||||
}
|
||||
switch (param->fModifiers.fLayout.fKey) {
|
||||
case Layout::kKey_Key:
|
||||
if (param->fModifiers.fLayout.fWhen.size()) {
|
||||
this->writef("if (%s) ", param->fModifiers.fLayout.fWhen.c_str());
|
||||
}
|
||||
if (param->fType == *fContext.fFloat4x4_Type) {
|
||||
ABORT("no automatic key handling for float4x4\n");
|
||||
} else if (param->fType == *fContext.fFloat2_Type) {
|
||||
|
@ -236,6 +236,18 @@ void HCodeGenerator::writeConstructor() {
|
||||
}
|
||||
this->writef(")");
|
||||
this->writeSection(INITIALIZERS_SECTION, "\n , ");
|
||||
const auto transforms = fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION);
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
const Section& s = *transforms[i];
|
||||
String field = CoordTransformName(s.fArgument.c_str(), i);
|
||||
if (s.fArgument.size()) {
|
||||
this->writef("\n , %s(%s, %s.get())", field.c_str(), s.fText.c_str(),
|
||||
FieldName(s.fArgument.c_str()).c_str());
|
||||
}
|
||||
else {
|
||||
this->writef("\n , %s(%s)", field.c_str(), s.fText.c_str());
|
||||
}
|
||||
}
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String nameString(param->fName);
|
||||
const char* name = nameString.c_str();
|
||||
@ -255,18 +267,6 @@ void HCodeGenerator::writeConstructor() {
|
||||
this->writef("\n , %s(%s)", FieldName(name).c_str(), name);
|
||||
}
|
||||
}
|
||||
const auto transforms = fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION);
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
const Section& s = *transforms[i];
|
||||
String field = CoordTransformName(s.fArgument.c_str(), i);
|
||||
if (s.fArgument.size()) {
|
||||
this->writef("\n , %s(%s, %s.proxy())", field.c_str(), s.fText.c_str(),
|
||||
FieldName(s.fArgument.c_str()).c_str());
|
||||
}
|
||||
else {
|
||||
this->writef("\n , %s(%s)", field.c_str(), s.fText.c_str());
|
||||
}
|
||||
}
|
||||
this->writef(" {\n");
|
||||
this->writeSection(CONSTRUCTOR_CODE_SECTION);
|
||||
int samplerCount = 0;
|
||||
@ -301,6 +301,12 @@ void HCodeGenerator::writeConstructor() {
|
||||
|
||||
void HCodeGenerator::writeFields() {
|
||||
this->writeSection(FIELDS_SECTION);
|
||||
const auto transforms = fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION);
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
const Section& s = *transforms[i];
|
||||
this->writef(" GrCoordTransform %s;\n",
|
||||
CoordTransformName(s.fArgument.c_str(), i).c_str());
|
||||
}
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String name = FieldName(String(param->fName).c_str());
|
||||
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
@ -311,12 +317,6 @@ void HCodeGenerator::writeFields() {
|
||||
name.c_str());
|
||||
}
|
||||
}
|
||||
const auto transforms = fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION);
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
const Section& s = *transforms[i];
|
||||
this->writef(" GrCoordTransform %s;\n",
|
||||
CoordTransformName(s.fArgument.c_str(), i).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
String HCodeGenerator::GetHeader(const Program& program, ErrorReporter& errors) {
|
||||
@ -355,27 +355,13 @@ bool HCodeGenerator::generateCode() {
|
||||
}
|
||||
}
|
||||
this->writeSection(CLASS_SECTION);
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (param->fType.kind() == Type::kSampler_Kind) {
|
||||
continue;
|
||||
}
|
||||
String nameString(param->fName);
|
||||
const char* name = nameString.c_str();
|
||||
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
this->writef(" int %s_index() const { return %s_index; }\n", name,
|
||||
FieldName(name).c_str());
|
||||
} else {
|
||||
this->writef(" %s %s() const { return %s; }\n",
|
||||
AccessType(fContext, param->fType, param->fModifiers.fLayout).c_str(),
|
||||
name, FieldName(name).c_str());
|
||||
}
|
||||
}
|
||||
this->writeMake();
|
||||
this->writef(" %s(const %s& src);\n"
|
||||
" std::unique_ptr<GrFragmentProcessor> clone() const override;\n"
|
||||
" const char* name() const override { return \"%s\"; }\n"
|
||||
"private:\n",
|
||||
" const char* name() const override { return \"%s\"; }\n",
|
||||
fFullName.c_str(), fFullName.c_str(), fName.c_str());
|
||||
this->writeFields();
|
||||
this->writef("private:\n");
|
||||
this->writeConstructor();
|
||||
this->writef(" GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;\n"
|
||||
" void onGetGLSLProcessorKey(const GrShaderCaps&,"
|
||||
@ -388,7 +374,6 @@ bool HCodeGenerator::generateCode() {
|
||||
}
|
||||
}
|
||||
this->writef(" GR_DECLARE_FRAGMENT_PROCESSOR_TEST\n");
|
||||
this->writeFields();
|
||||
this->writef(" typedef GrFragmentProcessor INHERITED;\n"
|
||||
"};\n");
|
||||
this->writeSection(HEADER_END_SECTION);
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
static String AccessType(const Context& context, const Type& type, const Layout& layout);
|
||||
|
||||
static String FieldName(const char* varName) {
|
||||
return String::printf("f%c%s", toupper(varName[0]), varName + 1);
|
||||
return String(varName);
|
||||
}
|
||||
|
||||
static String CoordTransformName(const String& arg, int index) {
|
||||
|
@ -268,6 +268,18 @@ std::unique_ptr<VarDeclarations> IRGenerator::convertVarDeclarations(const ASTVa
|
||||
baseType->kind() == Type::Kind::kMatrix_Kind) {
|
||||
fErrors.error(decl.fOffset, "'in' variables may not have matrix type");
|
||||
}
|
||||
if (decl.fModifiers.fLayout.fWhen.length() && fKind != Program::kFragmentProcessor_Kind &&
|
||||
fKind != Program::kPipelineStage_Kind) {
|
||||
fErrors.error(decl.fOffset, "'when' is only permitted within fragment processors");
|
||||
}
|
||||
if (decl.fModifiers.fLayout.fKey) {
|
||||
if (fKind != Program::kFragmentProcessor_Kind && fKind != Program::kPipelineStage_Kind) {
|
||||
fErrors.error(decl.fOffset, "'key' is only permitted within fragment processors");
|
||||
}
|
||||
if ((decl.fModifiers.fFlags & Modifiers::kUniform_Flag) != 0) {
|
||||
fErrors.error(decl.fOffset, "'key' is not permitted on 'uniform' variables");
|
||||
}
|
||||
}
|
||||
for (const auto& varDecl : decl.fVars) {
|
||||
if (decl.fModifiers.fLayout.fLocation == 0 && decl.fModifiers.fLayout.fIndex == 0 &&
|
||||
(decl.fModifiers.fFlags & Modifiers::kOut_Flag) && fKind == Program::kFragment_Kind &&
|
||||
|
@ -88,8 +88,8 @@ DEF_TEST(SkSLFPHelloWorld, r) {
|
||||
" : INHERITED(kGrTest_ClassID, kNone_OptimizationFlags) {\n"
|
||||
" }\n"
|
||||
" GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;\n"
|
||||
" void onGetGLSLProcessorKey(const GrShaderCaps&,GrProcessorKeyBuilder*) "
|
||||
"const override;\n"
|
||||
" void onGetGLSLProcessorKey(const GrShaderCaps&,GrProcessorKeyBuilder*) const "
|
||||
"override;\n"
|
||||
" bool onIsEqual(const GrFragmentProcessor&) const override;\n"
|
||||
" GR_DECLARE_FRAGMENT_PROCESSOR_TEST\n"
|
||||
" typedef GrFragmentProcessor INHERITED;\n"
|
||||
@ -97,8 +97,6 @@ DEF_TEST(SkSLFPHelloWorld, r) {
|
||||
"#endif\n"
|
||||
},
|
||||
{
|
||||
"/* HEADER */\n"
|
||||
"\n"
|
||||
"/**************************************************************************************************\n"
|
||||
" *** This file was autogenerated from GrTest.fp; do not modify.\n"
|
||||
" **************************************************************************************************/\n"
|
||||
@ -151,17 +149,16 @@ DEF_TEST(SkSLFPInput, r) {
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
{
|
||||
"const SkPoint& point() const { return fPoint; }",
|
||||
"static std::unique_ptr<GrFragmentProcessor> Make(SkPoint point) {",
|
||||
"return std::unique_ptr<GrFragmentProcessor>(new GrTest(point));",
|
||||
"GrTest(SkPoint point)",
|
||||
", fPoint(point)"
|
||||
", point(point)"
|
||||
},
|
||||
{
|
||||
"fragBuilder->codeAppendf(\"%s = half4(half2(%f, %f), half2(%f, %f));\\n\", "
|
||||
"args.fOutputColor, _outer.point().fX, _outer.point().fY, "
|
||||
"_outer.point().fX, _outer.point().fY);",
|
||||
"if (fPoint != that.fPoint) return false;"
|
||||
"args.fOutputColor, _outer.point.fX, _outer.point.fY, "
|
||||
"_outer.point.fX, _outer.point.fY);",
|
||||
"if (point != that.point) return false;"
|
||||
});
|
||||
}
|
||||
|
||||
@ -176,7 +173,7 @@ DEF_TEST(SkSLFPUniform, r) {
|
||||
"static std::unique_ptr<GrFragmentProcessor> Make()"
|
||||
},
|
||||
{
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"colorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"\"color\");",
|
||||
});
|
||||
}
|
||||
@ -195,9 +192,9 @@ DEF_TEST(SkSLFPInUniform, r) {
|
||||
"static std::unique_ptr<GrFragmentProcessor> Make(SkRect color) {",
|
||||
},
|
||||
{
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"colorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"\"color\");",
|
||||
"pdman.set4fv(fColorVar, 1, reinterpret_cast<const float*>(&(_outer.color())));"
|
||||
"pdman.set4fv(colorVar, 1, reinterpret_cast<const float*>(&(_outer.color)));"
|
||||
});
|
||||
}
|
||||
|
||||
@ -213,9 +210,9 @@ DEF_TEST(SkSLFPInUniformCType, r) {
|
||||
"static std::unique_ptr<GrFragmentProcessor> Make(SkPMColor4f color) {",
|
||||
},
|
||||
{
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"colorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"\"color\");",
|
||||
"pdman.set4fv(fColorVar, 1, (_outer.color()).vec());"
|
||||
"pdman.set4fv(colorVar, 1, (_outer.color).vec());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -233,13 +230,13 @@ DEF_TEST(SkSLFPTrackedInUniform, r) {
|
||||
"static std::unique_ptr<GrFragmentProcessor> Make(SkRect color) {",
|
||||
},
|
||||
{
|
||||
"SkRect fColorPrev = SkRect::MakeEmpty();",
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"SkRect colorPrev = SkRect::MakeEmpty();",
|
||||
"colorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"\"color\");",
|
||||
"const SkRect& colorValue = _outer.color();",
|
||||
"if (fColorPrev.isEmpty() || fColorPrev != colorValue) {",
|
||||
"fColorPrev = colorValue;",
|
||||
"pdman.set4fv(fColorVar, 1, reinterpret_cast<const float*>(&colorValue));"
|
||||
"const SkRect& colorValue = _outer.color;",
|
||||
"if (colorPrev.isEmpty() || colorPrev != colorValue) {",
|
||||
"colorPrev = colorValue;",
|
||||
"pdman.set4fv(colorVar, 1, reinterpret_cast<const float*>(&colorValue));"
|
||||
});
|
||||
}
|
||||
|
||||
@ -256,10 +253,10 @@ DEF_TEST(SkSLFPNonInlinedInUniform, r) {
|
||||
"static std::unique_ptr<GrFragmentProcessor> Make(SkPoint point) {",
|
||||
},
|
||||
{
|
||||
"fPointVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType, "
|
||||
"pointVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType, "
|
||||
"\"point\");",
|
||||
"const SkPoint& pointValue = _outer.point();",
|
||||
"pdman.set2f(fPointVar, pointValue.fX, pointValue.fY);"
|
||||
"const SkPoint& pointValue = _outer.point;",
|
||||
"pdman.set2f(pointVar, pointValue.fX, pointValue.fY);"
|
||||
});
|
||||
}
|
||||
|
||||
@ -281,16 +278,16 @@ DEF_TEST(SkSLFPConditionalInUniform, r) {
|
||||
"static std::unique_ptr<GrFragmentProcessor> Make(bool test, SkPMColor4f color) {",
|
||||
},
|
||||
{
|
||||
"SkPMColor4f fColorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN}",
|
||||
"auto test = _outer.test();",
|
||||
"SkPMColor4f colorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN}",
|
||||
"auto test = _outer.test;",
|
||||
"if (test) {",
|
||||
"fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"colorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
|
||||
"\"color\");",
|
||||
"if (fColorVar.isValid()) {",
|
||||
"const SkPMColor4f& colorValue = _outer.color();",
|
||||
"if (fColorPrev != colorValue) {",
|
||||
"fColorPrev = colorValue;",
|
||||
"pdman.set4fv(fColorVar, 1, colorValue.vec());"
|
||||
"if (colorVar.isValid()) {",
|
||||
"const SkPMColor4f& colorValue = _outer.color;",
|
||||
"if (colorPrev != colorValue) {",
|
||||
"colorPrev = colorValue;",
|
||||
"pdman.set4fv(colorVar, 1, colorValue.vec());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -336,7 +333,7 @@ DEF_TEST(SkSLFPSections, r) {
|
||||
"Make(float w, int x, float y, std::vector<float> z )",
|
||||
"return std::unique_ptr<GrFragmentProcessor>(new GrTest(w, x, y, z));",
|
||||
"GrTest(float w, int x, float y, std::vector<float> z )",
|
||||
", fW(w) {"
|
||||
", w(w) {"
|
||||
},
|
||||
{});
|
||||
test(r,
|
||||
@ -379,8 +376,8 @@ DEF_TEST(SkSLFPSections, r) {
|
||||
"}",
|
||||
*SkSL::ShaderCapsFactory::Default(),
|
||||
{
|
||||
"GR_DECLARE_FRAGMENT_PROCESSOR_TEST\n"
|
||||
" fields section typedef GrFragmentProcessor INHERITED;"
|
||||
"const char* name() const override { return \"Test\"; }\n"
|
||||
" fields section private:"
|
||||
},
|
||||
{});
|
||||
test(r,
|
||||
@ -406,8 +403,8 @@ DEF_TEST(SkSLFPSections, r) {
|
||||
{
|
||||
"void onSetData(const GrGLSLProgramDataManager& varName, "
|
||||
"const GrFragmentProcessor& _proc) override {\n",
|
||||
"UniformHandle& calculated = fCalculatedVar;",
|
||||
"auto provided = _outer.provided();",
|
||||
"UniformHandle& calculated = calculatedVar;",
|
||||
"auto provided = _outer.provided;",
|
||||
"varName.set1f(calculated, provided * 2);"
|
||||
});
|
||||
test(r,
|
||||
@ -450,7 +447,7 @@ DEF_TEST(SkSLFPLayoutWhen, r) {
|
||||
{},
|
||||
{
|
||||
"if (someExpression(someOtherExpression())) {\n"
|
||||
" fSometimesVar = args.fUniformHandler->addUniform"
|
||||
" sometimesVar = args.fUniformHandler->addUniform"
|
||||
});
|
||||
|
||||
}
|
||||
@ -469,11 +466,11 @@ DEF_TEST(SkSLFPChildProcessors, r) {
|
||||
},
|
||||
{
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child1_index(), &_child0, args);",
|
||||
"this->emitChild(_outer.child1_index, &_child0, args);",
|
||||
"SkString _child1(\"_child1\");",
|
||||
"this->emitChild(_outer.child2_index(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild2_index).clone());"
|
||||
"this->emitChild(_outer.child2_index, &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -495,12 +492,12 @@ DEF_TEST(SkSLFPChildProcessorsWithInput, r) {
|
||||
{
|
||||
"SkString _input0(\"childIn\");",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child1_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->emitChild(_outer.child1_index, _input0.c_str(), &_child0, args);",
|
||||
"SkString _input1(\"childOut1\");",
|
||||
"SkString _child1(\"_child1\");",
|
||||
"this->emitChild(_outer.child2_index(), _input1.c_str(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild2_index).clone());"
|
||||
"this->emitChild(_outer.child2_index, _input1.c_str(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -517,8 +514,8 @@ DEF_TEST(SkSLFPChildProcessorWithInputExpression, r) {
|
||||
{
|
||||
"SkString _input0 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild_index).clone());",
|
||||
"this->emitChild(_outer.child_index, _input0.c_str(), &_child0, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(child_index).clone());",
|
||||
});
|
||||
}
|
||||
|
||||
@ -537,12 +534,12 @@ DEF_TEST(SkSLFPNestedChildProcessors, r) {
|
||||
{
|
||||
"SkString _input0 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child1_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->emitChild(_outer.child1_index, _input0.c_str(), &_child0, args);",
|
||||
"SkString _input1 = SkStringPrintf(\"%s * %s\", args.fInputColor, _child0.c_str());",
|
||||
"SkString _child1(\"_child1\");",
|
||||
"this->emitChild(_outer.child2_index(), _input1.c_str(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild2_index).clone());"
|
||||
"this->emitChild(_outer.child2_index, _input1.c_str(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -567,10 +564,10 @@ DEF_TEST(SkSLFPChildFPAndGlobal, r) {
|
||||
"(hasCap ? \"true\" : \"false\"));",
|
||||
"SkString _input0 = SkStringPrintf(\"%s\", args.fInputColor);",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->emitChild(_outer.child_index, _input0.c_str(), &_child0, args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}"
|
||||
"\\n\", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild_index).clone());"
|
||||
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -590,14 +587,14 @@ DEF_TEST(SkSLFPChildProcessorInlineFieldAccess, r) {
|
||||
},
|
||||
{
|
||||
"fragBuilder->codeAppendf(\"if (%s) {\", "
|
||||
"(_outer.childProcessor(_outer.child_index()).preservesOpaqueInput() ? "
|
||||
"(_outer.childProcessor(_outer.child_index).preservesOpaqueInput() ? "
|
||||
"\"true\" : \"false\"));",
|
||||
"SkString _input0 = SkStringPrintf(\"%s\", args.fInputColor);",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->emitChild(_outer.child_index, _input0.c_str(), &_child0, args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\""
|
||||
", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild_index).clone());"
|
||||
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -617,14 +614,14 @@ DEF_TEST(SkSLFPChildProcessorFieldAccess, r) {
|
||||
"this->registerChildProcessor(std::move(child));"
|
||||
},
|
||||
{
|
||||
"opaque = _outer.childProcessor(_outer.child_index()).preservesOpaqueInput();",
|
||||
"opaque = _outer.childProcessor(_outer.child_index).preservesOpaqueInput();",
|
||||
"fragBuilder->codeAppendf(\"bool opaque = %s;\\nif (opaque) {\", "
|
||||
"(opaque ? \"true\" : \"false\"));",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child_index(), &_child0, args);",
|
||||
"this->emitChild(_outer.child_index, &_child0, args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\""
|
||||
", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild_index).clone());"
|
||||
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -642,8 +639,8 @@ DEF_TEST(SkSLFPNullableChildProcessor, r) {
|
||||
{},
|
||||
{
|
||||
"SkString _child0(\"_child0\");",
|
||||
"if (_outer.child_index() >= 0) {",
|
||||
"this->emitChild(_outer.child_index(), &_child0, args);",
|
||||
"if (_outer.child_index >= 0) {",
|
||||
"this->emitChild(_outer.child_index, &_child0, args);",
|
||||
"} else {",
|
||||
"fragBuilder->codeAppendf(\"half4 %s;\", _child0.c_str());",
|
||||
"}",
|
||||
|
Loading…
Reference in New Issue
Block a user