Replace GrColor4h with SkPMColor4f
- Mechanical replacement of GrColor4h (used throughout Ops) with
SkPMColor4f.
- API adaptation (to/FromGrColor -> to/From_BytesRGBA).
- Complete removal of FromFloats (source was already SkPMColor4f),
and toFloats (setting uniforms can directly access .vec()).
Bug: skia:
Change-Id: I37eece1fa7ed2545dc6843e840d4cc3c60f19747
Reviewed-on: https://skia-review.googlesource.com/c/166620
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 6f5395e..0f59eda 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -37,9 +37,7 @@
}
if (ce.color() != fColor) {
- float c[4];
- ce.color().toFloats(c);
- pdman.set4fv(fColorUniform, 1, c);
+ pdman.set4fv(fColorUniform, 1, ce.color().vec());
fColor = ce.color();
}
@@ -52,7 +50,7 @@
private:
SkMatrix fViewMatrix;
- GrColor4h fColor;
+ SkPMColor4f fColor;
uint8_t fCoverageScale;
GrClipEdgeType fEdgeType;
UniformHandle fColorUniform;
@@ -63,7 +61,7 @@
};
GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor)
- : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor4h_ILLEGAL), fCoverageScale(0xff) {
+ : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(SK_PMColor4fILLEGAL), fCoverageScale(0xff) {
const GrConicEffect& ce = processor.cast<GrConicEffect>();
fEdgeType = ce.getEdgeType();
}
@@ -232,7 +230,7 @@
return new GrGLConicEffect(*this);
}
-GrConicEffect::GrConicEffect(const GrColor4h& color, const SkMatrix& viewMatrix, uint8_t coverage,
+GrConicEffect::GrConicEffect(const SkPMColor4f& color, const SkMatrix& viewMatrix, uint8_t coverage,
GrClipEdgeType edgeType, const SkMatrix& localMatrix,
bool usesLocalCoords)
: INHERITED(kGrConicEffect_ClassID)
@@ -256,7 +254,7 @@
GrClipEdgeType edgeType =
static_cast<GrClipEdgeType>(
d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
- gp = GrConicEffect::Make(GrColor4h::FromGrColor(GrRandomColor(d->fRandom)),
+ gp = GrConicEffect::Make(SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
GrTest::TestMatrix(d->fRandom), edgeType, *d->caps(),
GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
} while (nullptr == gp);
@@ -290,9 +288,7 @@
}
if (qe.color() != fColor) {
- float c[4];
- qe.color().toFloats(c);
- pdman.set4fv(fColorUniform, 1, c);
+ pdman.set4fv(fColorUniform, 1, qe.color().vec());
fColor = qe.color();
}
@@ -305,7 +301,7 @@
private:
SkMatrix fViewMatrix;
- GrColor4h fColor;
+ SkPMColor4f fColor;
uint8_t fCoverageScale;
GrClipEdgeType fEdgeType;
UniformHandle fColorUniform;
@@ -316,7 +312,7 @@
};
GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor)
- : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor4h_ILLEGAL), fCoverageScale(0xff) {
+ : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(SK_PMColor4fILLEGAL), fCoverageScale(0xff) {
const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
fEdgeType = ce.getEdgeType();
}
@@ -434,7 +430,7 @@
return new GrGLQuadEffect(*this);
}
-GrQuadEffect::GrQuadEffect(const GrColor4h& color, const SkMatrix& viewMatrix, uint8_t coverage,
+GrQuadEffect::GrQuadEffect(const SkPMColor4f& color, const SkMatrix& viewMatrix, uint8_t coverage,
GrClipEdgeType edgeType, const SkMatrix& localMatrix,
bool usesLocalCoords)
: INHERITED(kGrQuadEffect_ClassID)
@@ -457,7 +453,7 @@
do {
GrClipEdgeType edgeType = static_cast<GrClipEdgeType>(
d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
- gp = GrQuadEffect::Make(GrColor4h::FromGrColor(GrRandomColor(d->fRandom)),
+ gp = GrQuadEffect::Make(SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
GrTest::TestMatrix(d->fRandom), edgeType, *d->caps(),
GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
} while (nullptr == gp);
@@ -498,9 +494,7 @@
}
if (ce.color() != fColor) {
- float c[4];
- ce.color().toFloats(c);
- pdman.set4fv(fColorUniform, 1, c);
+ pdman.set4fv(fColorUniform, 1, ce.color().vec());
fColor = ce.color();
}
@@ -510,7 +504,7 @@
private:
SkMatrix fViewMatrix;
SkMatrix fDevKLMMatrix;
- GrColor4h fColor;
+ SkPMColor4f fColor;
GrClipEdgeType fEdgeType;
UniformHandle fColorUniform;
UniformHandle fViewMatrixUniform;
@@ -522,7 +516,7 @@
GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor)
: fViewMatrix(SkMatrix::InvalidMatrix())
, fDevKLMMatrix(SkMatrix::InvalidMatrix())
- , fColor(GrColor4h_ILLEGAL) {
+ , fColor(SK_PMColor4fILLEGAL) {
const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
fEdgeType = ce.getEdgeType();
}
@@ -661,7 +655,7 @@
return new GrGLCubicEffect(*this);
}
-GrCubicEffect::GrCubicEffect(const GrColor4h& color, const SkMatrix& viewMatrix, const SkMatrix&
+GrCubicEffect::GrCubicEffect(const SkPMColor4f& color, const SkMatrix& viewMatrix, const SkMatrix&
devKLMMatrix, GrClipEdgeType edgeType)
: INHERITED(kGrCubicEffect_ClassID)
, fColor(color)
@@ -682,7 +676,7 @@
GrClipEdgeType edgeType =
static_cast<GrClipEdgeType>(
d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
- gp = GrCubicEffect::Make(GrColor4h::FromGrColor(GrRandomColor(d->fRandom)),
+ gp = GrCubicEffect::Make(SkPMColor4f::FromBytes_RGBA(GrRandomColor(d->fRandom)),
GrTest::TestMatrix(d->fRandom), GrTest::TestMatrix(d->fRandom),
d->fRandom->nextBool(), edgeType, *d->caps());
} while (nullptr == gp);