aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ops
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-06-15 15:06:48 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-15 20:12:35 +0000
commit08a50e02dba37427e7d479d2222b08259d226d50 (patch)
treeea806d959ba170f263c5055ff0c4173c548d86e8 /src/gpu/ops
parent397ee0e4aa571caeb90817022d8213c82ddc843f (diff)
Include sRGB -> Linear in the cached "from sRGB" xform
This simplifies the handling of paint color conversion, as well as GrDrawVerticesOp and the default geometry processor. We don't need to track "linearize" separate from the color space xform. We only supply an xform if needed. The linearize is now done automatically by the xform, though we aren't converting to destination gamma. https://skia-review.googlesource.com/c/skia/+/132090 will fix that. Change-Id: I0af3f29c123c3dadb818f87c5d295bc78e2ff079 Reviewed-on: https://skia-review.googlesource.com/135141 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu/ops')
-rw-r--r--src/gpu/ops/GrDrawVerticesOp.cpp30
-rw-r--r--src/gpu/ops/GrDrawVerticesOp.h7
2 files changed, 12 insertions, 25 deletions
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index 4103387551..c968611152 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -16,21 +16,19 @@ std::unique_ptr<GrDrawOp> GrDrawVerticesOp::Make(GrContext* context,
sk_sp<SkVertices> vertices,
const SkMatrix& viewMatrix,
GrAAType aaType,
- bool gammaCorrect,
sk_sp<GrColorSpaceXform> colorSpaceXform,
GrPrimitiveType* overridePrimType) {
SkASSERT(vertices);
GrPrimitiveType primType = overridePrimType ? *overridePrimType
: SkVertexModeToGrPrimitiveType(vertices->mode());
return Helper::FactoryHelper<GrDrawVerticesOp>(context, std::move(paint), std::move(vertices),
- primType, aaType, gammaCorrect,
- std::move(colorSpaceXform), viewMatrix);
+ primType, aaType, std::move(colorSpaceXform),
+ viewMatrix);
}
GrDrawVerticesOp::GrDrawVerticesOp(const Helper::MakeArgs& helperArgs, GrColor color,
sk_sp<SkVertices> vertices, GrPrimitiveType primitiveType,
- GrAAType aaType, bool gammaCorrect,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
+ GrAAType aaType, sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& viewMatrix)
: INHERITED(ClassID())
, fHelper(helperArgs, aaType)
@@ -42,9 +40,6 @@ GrDrawVerticesOp::GrDrawVerticesOp(const Helper::MakeArgs& helperArgs, GrColor c
fIndexCount = vertices->indexCount();
fColorArrayType = vertices->hasColors() ? ColorArrayType::kSkColor
: ColorArrayType::kPremulGrColor;
- // GrColor is linearized (and gamut converted) during paint conversion, but SkColors need to be
- // handled in the shader
- fLinearizeColors = gammaCorrect && vertices->hasColors();
Mesh& mesh = fMeshes.push_back();
mesh.fColor = color;
@@ -98,7 +93,6 @@ GrDrawOp::RequiresDstTexture GrDrawVerticesOp::finalize(const GrCaps& caps,
fMeshes.front().fIgnoreColors = true;
fFlags &= ~kRequiresPerVertexColors_Flag;
fColorArrayType = ColorArrayType::kPremulGrColor;
- fLinearizeColors = false;
}
if (!fHelper.usesLocalCoords()) {
fMeshes[0].fIgnoreTexCoords = true;
@@ -128,11 +122,12 @@ sk_sp<GrGeometryProcessor> GrDrawVerticesOp::makeGP(bool* hasColorAttribute,
Color color(fMeshes[0].fColor);
if (this->requiresPerVertexColors()) {
- color.fType = (fColorArrayType == ColorArrayType::kPremulGrColor)
- ? Color::kPremulGrColorAttribute_Type
- : Color::kUnpremulSkColorAttribute_Type;
- color.fLinearize = fLinearizeColors;
- color.fColorSpaceXform = fColorSpaceXform;
+ if (fColorArrayType == ColorArrayType::kPremulGrColor) {
+ color.fType = Color::kPremulGrColorAttribute_Type;
+ } else {
+ color.fType = Color::kUnpremulSkColorAttribute_Type;
+ color.fColorSpaceXform = fColorSpaceXform;
+ }
*hasColorAttribute = true;
} else {
*hasColorAttribute = false;
@@ -272,10 +267,6 @@ bool GrDrawVerticesOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
return false;
}
- if (fLinearizeColors != that->fLinearizeColors) {
- return false;
- }
-
if (fVertexCount + that->fVertexCount > SkTo<int>(UINT16_MAX)) {
return false;
}
@@ -390,7 +381,6 @@ GR_DRAW_OP_TEST_DEFINE(GrDrawVerticesOp) {
bool hasTexCoords = random->nextBool();
bool hasIndices = random->nextBool();
bool hasColors = random->nextBool();
- bool linearizeColors = random->nextBool();
uint32_t vertexCount = seed_vertices(type) + (primitiveCount - 1) * primitive_vertices(type);
@@ -420,7 +410,7 @@ GR_DRAW_OP_TEST_DEFINE(GrDrawVerticesOp) {
aaType = GrAAType::kMSAA;
}
return GrDrawVerticesOp::Make(context, std::move(paint), std::move(vertices), viewMatrix,
- aaType, linearizeColors, std::move(colorSpaceXform), &type);
+ aaType, std::move(colorSpaceXform), &type);
}
#endif
diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h
index dccb5ecccb..6d35c0d0e9 100644
--- a/src/gpu/ops/GrDrawVerticesOp.h
+++ b/src/gpu/ops/GrDrawVerticesOp.h
@@ -33,20 +33,18 @@ public:
* Draw a SkVertices. The GrPaint param's color is used if the vertices lack per-vertex color.
* If the vertices lack local coords then the vertex positions are used as local coords. The
* primitive type drawn is derived from the SkVertices object, unless overridePrimType is
- * specified. If gammaCorrect is true, the vertex colors will be linearized in the shader to get
- * correct rendering.
+ * specified.
*/
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
GrPaint&&,
sk_sp<SkVertices>,
const SkMatrix& viewMatrix,
GrAAType,
- bool gammaCorrect,
sk_sp<GrColorSpaceXform>,
GrPrimitiveType* overridePrimType = nullptr);
GrDrawVerticesOp(const Helper::MakeArgs& helperArgs, GrColor, sk_sp<SkVertices>,
- GrPrimitiveType, GrAAType, bool gammaCorrect, sk_sp<GrColorSpaceXform>,
+ GrPrimitiveType, GrAAType, sk_sp<GrColorSpaceXform>,
const SkMatrix& viewMatrix);
const char* name() const override { return "DrawVerticesOp"; }
@@ -130,7 +128,6 @@ private:
int fVertexCount;
int fIndexCount;
ColorArrayType fColorArrayType;
- bool fLinearizeColors;
sk_sp<GrColorSpaceXform> fColorSpaceXform;
typedef GrMeshDrawOp INHERITED;