2020-09-16 22:40:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************************************
|
|
|
|
*** This file was autogenerated from GrConditionalInUniform.fp; do not modify.
|
|
|
|
**************************************************************************************************/
|
|
|
|
#include "GrConditionalInUniform.h"
|
|
|
|
|
|
|
|
#include "src/core/SkUtils.h"
|
|
|
|
#include "src/gpu/GrTexture.h"
|
|
|
|
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
|
|
|
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
|
|
|
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
|
|
|
|
#include "src/sksl/SkSLCPP.h"
|
|
|
|
#include "src/sksl/SkSLUtil.h"
|
|
|
|
class GrGLSLConditionalInUniform : public GrGLSLFragmentProcessor {
|
|
|
|
public:
|
|
|
|
GrGLSLConditionalInUniform() {}
|
|
|
|
void emitCode(EmitArgs& args) override {
|
|
|
|
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
|
|
|
const GrConditionalInUniform& _outer = args.fFp.cast<GrConditionalInUniform>();
|
|
|
|
(void) _outer;
|
|
|
|
auto test = _outer.test;
|
|
|
|
(void) test;
|
|
|
|
auto color = _outer.color;
|
|
|
|
(void) color;
|
|
|
|
if (test) {
|
|
|
|
colorVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag, kHalf4_GrSLType, "color");
|
|
|
|
}
|
|
|
|
fragBuilder->codeAppendf(
|
|
|
|
R"SkSL(if (%s) {
|
2020-12-15 14:44:51 +00:00
|
|
|
return %s;
|
2020-09-16 22:40:38 +00:00
|
|
|
} else {
|
2020-12-15 14:44:51 +00:00
|
|
|
return half4(1.0);
|
2020-09-16 22:40:38 +00:00
|
|
|
}
|
|
|
|
)SkSL"
|
2020-12-15 14:44:51 +00:00
|
|
|
, (_outer.test ? "true" : "false"), colorVar.isValid() ? args.fUniformHandler->getUniformCStr(colorVar) : "half4(0)");
|
2020-09-16 22:40:38 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
|
|
|
|
const GrConditionalInUniform& _outer = _proc.cast<GrConditionalInUniform>();
|
|
|
|
{
|
|
|
|
if (colorVar.isValid()) {
|
|
|
|
const SkPMColor4f& colorValue = _outer.color;
|
|
|
|
if (colorPrev != colorValue) {
|
|
|
|
colorPrev = colorValue;
|
|
|
|
pdman.set4fv(colorVar, 1, colorValue.vec());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkPMColor4f colorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
|
|
|
UniformHandle colorVar;
|
|
|
|
};
|
2021-02-23 15:07:05 +00:00
|
|
|
std::unique_ptr<GrGLSLFragmentProcessor> GrConditionalInUniform::onMakeProgramImpl() const {
|
|
|
|
return std::make_unique<GrGLSLConditionalInUniform>();
|
2020-09-16 22:40:38 +00:00
|
|
|
}
|
|
|
|
void GrConditionalInUniform::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
|
2021-03-02 21:57:09 +00:00
|
|
|
b->addBits(1, (uint32_t) test, "test");
|
2020-09-16 22:40:38 +00:00
|
|
|
}
|
|
|
|
bool GrConditionalInUniform::onIsEqual(const GrFragmentProcessor& other) const {
|
|
|
|
const GrConditionalInUniform& that = other.cast<GrConditionalInUniform>();
|
|
|
|
(void) that;
|
|
|
|
if (test != that.test) return false;
|
|
|
|
if (color != that.color) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
GrConditionalInUniform::GrConditionalInUniform(const GrConditionalInUniform& src)
|
|
|
|
: INHERITED(kGrConditionalInUniform_ClassID, src.optimizationFlags())
|
|
|
|
, test(src.test)
|
|
|
|
, color(src.color) {
|
|
|
|
this->cloneAndRegisterAllChildProcessors(src);
|
|
|
|
}
|
|
|
|
std::unique_ptr<GrFragmentProcessor> GrConditionalInUniform::clone() const {
|
|
|
|
return std::make_unique<GrConditionalInUniform>(*this);
|
|
|
|
}
|
|
|
|
#if GR_TEST_UTILS
|
|
|
|
SkString GrConditionalInUniform::onDumpInfo() const {
|
|
|
|
return SkStringPrintf("(test=%s, color=half4(%f, %f, %f, %f))", (test ? "true" : "false"), color.fR, color.fG, color.fB, color.fA);
|
|
|
|
}
|
|
|
|
#endif
|