4c5943781e
All layout(key) fields include the field name meta-data, and use as few bits as possible. Bug: skia:11372 Change-Id: Ie12b3e0d01148457e5ea078cbf7d0a4bff35302e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378596 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
63 lines
2.3 KiB
C++
63 lines
2.3 KiB
C++
|
|
|
|
/**************************************************************************************************
|
|
*** This file was autogenerated from GrKeyIn.fp; do not modify.
|
|
**************************************************************************************************/
|
|
#include "GrKeyIn.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 GrGLSLKeyIn : public GrGLSLFragmentProcessor {
|
|
public:
|
|
GrGLSLKeyIn() {}
|
|
void emitCode(EmitArgs& args) override {
|
|
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
|
const GrKeyIn& _outer = args.fFp.cast<GrKeyIn>();
|
|
(void) _outer;
|
|
auto color = _outer.color;
|
|
(void) color;
|
|
fragBuilder->codeAppendf(
|
|
R"SkSL(return half4(%f, %f, %f, %f);
|
|
)SkSL"
|
|
, _outer.color.left(), _outer.color.top(), _outer.color.right(), _outer.color.bottom());
|
|
}
|
|
private:
|
|
void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override {
|
|
}
|
|
};
|
|
std::unique_ptr<GrGLSLFragmentProcessor> GrKeyIn::onMakeProgramImpl() const {
|
|
return std::make_unique<GrGLSLKeyIn>();
|
|
}
|
|
void GrKeyIn::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
|
|
uint16_t red = SkFloatToHalf(color.fR);
|
|
uint16_t green = SkFloatToHalf(color.fG);
|
|
uint16_t blue = SkFloatToHalf(color.fB);
|
|
uint16_t alpha = SkFloatToHalf(color.fA);
|
|
b->add32(((uint32_t)red << 16) | green, "color.rg");
|
|
b->add32(((uint32_t)blue << 16) | alpha, "color.ba");
|
|
}
|
|
bool GrKeyIn::onIsEqual(const GrFragmentProcessor& other) const {
|
|
const GrKeyIn& that = other.cast<GrKeyIn>();
|
|
(void) that;
|
|
if (color != that.color) return false;
|
|
return true;
|
|
}
|
|
GrKeyIn::GrKeyIn(const GrKeyIn& src)
|
|
: INHERITED(kGrKeyIn_ClassID, src.optimizationFlags())
|
|
, color(src.color) {
|
|
this->cloneAndRegisterAllChildProcessors(src);
|
|
}
|
|
std::unique_ptr<GrFragmentProcessor> GrKeyIn::clone() const {
|
|
return std::make_unique<GrKeyIn>(*this);
|
|
}
|
|
#if GR_TEST_UTILS
|
|
SkString GrKeyIn::onDumpInfo() const {
|
|
return SkStringPrintf("(color=half4(%f, %f, %f, %f))", color.left(), color.top(), color.right(), color.bottom());
|
|
}
|
|
#endif
|