18ab2030e3
Rename factory function from createGLSLInstance() to makeProgramImpl() Bug: b/180759848 Bug: skia:11358 Change-Id: I095bdf1f26db5a8192fa8ab59000db4a1d561d96 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/373738 Reviewed-by: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
68 lines
2.7 KiB
C++
68 lines
2.7 KiB
C++
|
|
|
|
/**************************************************************************************************
|
|
*** This file was autogenerated from GrTrackedInUniform.fp; do not modify.
|
|
**************************************************************************************************/
|
|
#include "GrTrackedInUniform.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 GrGLSLTrackedInUniform : public GrGLSLFragmentProcessor {
|
|
public:
|
|
GrGLSLTrackedInUniform() {}
|
|
void emitCode(EmitArgs& args) override {
|
|
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
|
const GrTrackedInUniform& _outer = args.fFp.cast<GrTrackedInUniform>();
|
|
(void) _outer;
|
|
auto color = _outer.color;
|
|
(void) color;
|
|
colorVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag, kHalf4_GrSLType, "color");
|
|
fragBuilder->codeAppendf(
|
|
R"SkSL(return %s;
|
|
)SkSL"
|
|
, args.fUniformHandler->getUniformCStr(colorVar));
|
|
}
|
|
private:
|
|
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
|
|
const GrTrackedInUniform& _outer = _proc.cast<GrTrackedInUniform>();
|
|
{
|
|
const SkRect& colorValue = _outer.color;
|
|
if (colorPrev.isEmpty() || colorPrev != colorValue) {
|
|
colorPrev = colorValue;
|
|
pdman.set4fv(colorVar, 1, reinterpret_cast<const float*>(&colorValue));
|
|
}
|
|
}
|
|
}
|
|
SkRect colorPrev = SkRect::MakeEmpty();
|
|
UniformHandle colorVar;
|
|
};
|
|
std::unique_ptr<GrGLSLFragmentProcessor> GrTrackedInUniform::onMakeProgramImpl() const {
|
|
return std::make_unique<GrGLSLTrackedInUniform>();
|
|
}
|
|
void GrTrackedInUniform::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
|
|
}
|
|
bool GrTrackedInUniform::onIsEqual(const GrFragmentProcessor& other) const {
|
|
const GrTrackedInUniform& that = other.cast<GrTrackedInUniform>();
|
|
(void) that;
|
|
if (color != that.color) return false;
|
|
return true;
|
|
}
|
|
GrTrackedInUniform::GrTrackedInUniform(const GrTrackedInUniform& src)
|
|
: INHERITED(kGrTrackedInUniform_ClassID, src.optimizationFlags())
|
|
, color(src.color) {
|
|
this->cloneAndRegisterAllChildProcessors(src);
|
|
}
|
|
std::unique_ptr<GrFragmentProcessor> GrTrackedInUniform::clone() const {
|
|
return std::make_unique<GrTrackedInUniform>(*this);
|
|
}
|
|
#if GR_TEST_UTILS
|
|
SkString GrTrackedInUniform::onDumpInfo() const {
|
|
return SkStringPrintf("(color=half4(%f, %f, %f, %f))", color.left(), color.top(), color.right(), color.bottom());
|
|
}
|
|
#endif
|