return GrColor4f(color.fR, color.fG, color.fB, color.fA);
}
+ bool operator==(const GrColor4f& other) const {
+ return
+ fRGBA[0] == other.fRGBA[0] &&
+ fRGBA[1] == other.fRGBA[1] &&
+ fRGBA[2] == other.fRGBA[2] &&
+ fRGBA[3] == other.fRGBA[3];
+ }
+ bool operator!=(const GrColor4f& other) const {
+ return !(*this == other);
+ }
+
GrColor toGrColor() const {
return GrColorPackRGBA(
SkTPin<unsigned>(static_cast<unsigned>(fRGBA[0] * 255.0f + 0.5f), 0, 255),
//////////////////////////////////////////////////////////////////////////////
sk_sp<GrFragmentProcessor> GrFragmentProcessor::OverrideInput(sk_sp<GrFragmentProcessor> fp,
- GrColor color) {
+ GrColor4f color) {
class ReplaceInputFragmentProcessor : public GrFragmentProcessor {
public:
- ReplaceInputFragmentProcessor(sk_sp<GrFragmentProcessor> child, GrColor color)
+ ReplaceInputFragmentProcessor(sk_sp<GrFragmentProcessor> child, GrColor4f color)
: fColor(color) {
this->initClassID<ReplaceInputFragmentProcessor>();
this->registerChildProcessor(std::move(child));
private:
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& fp) override {
- GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fColor;
+ GrColor4f color = fp.cast<ReplaceInputFragmentProcessor>().fColor;
if (!fHaveSetColor || color != fPreviousColor) {
- static const float scale = 1.f / 255.f;
- float floatColor[4] = {
- GrColorUnpackR(color) * scale,
- GrColorUnpackG(color) * scale,
- GrColorUnpackB(color) * scale,
- GrColorUnpackA(color) * scale,
- };
- pdman.set4fv(fColorUni, 1, floatColor);
+ pdman.set4fv(fColorUni, 1, color.fRGBA);
fPreviousColor = color;
fHaveSetColor = true;
}
}
GrGLSLProgramDataManager::UniformHandle fColorUni;
- bool fHaveSetColor;
- GrColor fPreviousColor;
+ bool fHaveSetColor;
+ GrColor4f fPreviousColor;
};
return new GLFP;
}
void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToOther(kRGBA_GrColorComponentFlags, fColor,
+ inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor(),
GrInvariantOutput::kWillNot_ReadInput);
this->childProcessor(0).computeInvariantOutput(inout);
}
- GrColor fColor;
+ GrColor4f fColor;
};
GrInvariantOutput childOut(0x0, kNone_GrColorComponentFlags, false);
// The geometry processor will insert the primitive color to start the color chain, so
// the GrPaint color will be ignored.
- GrColor shaderInput = origColor.opaque().toGrColor();
-
- // SRGBTODO: Preserve 4f on this code path
+ GrColor4f shaderInput = origColor.opaque();
shaderFP = GrFragmentProcessor::OverrideInput(shaderFP, shaderInput);
if (primitiveIsSrc) {
shaderFP = GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(shaderFP),