Keep paint color range/precision into ops and GPs (using GrColor4h)
We still degrade to bytes when creating vertices (tagged TODO4F).
Note: Guarded for Chrome (by making GrColor4h a wrapper around
GrColor).
Bug: skia:
Change-Id: Id8a1d9eec7978d52b059cd9952666bc1217ee073
Reviewed-on: https://skia-review.googlesource.com/c/165527
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ccpr/GrCCDrawPathsOp.cpp b/src/gpu/ccpr/GrCCDrawPathsOp.cpp
index 3787971..ca671e2 100644
--- a/src/gpu/ccpr/GrCCDrawPathsOp.cpp
+++ b/src/gpu/ccpr/GrCCDrawPathsOp.cpp
@@ -120,7 +120,7 @@
: GrDrawOp(ClassID())
, fViewMatrixIfUsingLocalCoords(has_coord_transforms(paint) ? m : SkMatrix::I())
, fDraws(m, shape, strokeDevWidth, shapeConservativeIBounds, maskDevIBounds, maskVisibility,
- paint.getColor())
+ GrColor4h::FromFloats(paint.getColor4f().vec()))
, fProcessors(std::move(paint)) { // Paint must be moved after fetching its color above.
SkDEBUGCODE(fBaseInstance = -1);
// FIXME: intersect with clip bounds to (hopefully) improve batching.
@@ -139,7 +139,7 @@
float strokeDevWidth,
const SkIRect& shapeConservativeIBounds,
const SkIRect& maskDevIBounds, Visibility maskVisibility,
- GrColor color)
+ GrColor4h color)
: fMatrix(m)
, fShape(shape)
, fStrokeDevWidth(strokeDevWidth)
@@ -196,8 +196,11 @@
draw->fShape = GrShape(path, GrStyle(hairlineStroke, nullptr));
draw->fStrokeDevWidth = 1;
+
+ // TODO4F: Preserve float colors
// fShapeConservativeIBounds already accounted for this possibility of inflating the stroke.
- draw->fColor = GrColorMul(draw->fColor, coverageAsAlpha);
+ draw->fColor = GrColor4h::FromGrColor(
+ GrColorMul(draw->fColor.toGrColor(), coverageAsAlpha));
}
return RequiresDstTexture(analysis.requiresDstTexture());
@@ -322,8 +325,9 @@
if (auto proxy = draw.fCachedAtlasProxy.get()) {
SkASSERT(!cacheEntry->currFlushAtlas());
this->recordInstance(proxy, resources->nextPathInstanceIdx());
+ // TODO4F: Preserve float colors
resources->appendDrawPathInstance().set(*cacheEntry, draw.fCachedMaskShift,
- draw.fColor);
+ draw.fColor.toGrColor());
continue;
}
@@ -331,8 +335,9 @@
// drawn more than once during the same flush, with a compatible matrix?)
if (auto atlas = cacheEntry->currFlushAtlas()) {
this->recordInstance(atlas->textureProxy(), resources->nextPathInstanceIdx());
+ // TODO4F: Preserve float colors
resources->appendDrawPathInstance().set(
- *cacheEntry, draw.fCachedMaskShift, draw.fColor,
+ *cacheEntry, draw.fCachedMaskShift, draw.fColor.toGrColor(),
cacheEntry->hasCachedAtlas() ? DoEvenOddFill::kNo : doEvenOddFill);
continue;
}
@@ -348,8 +353,9 @@
atlas->getOrAssignUniqueKey(onFlushRP), newOffset,
atlas->refOrMakeCachedAtlasInfo(onFlushRP->contextUniqueID()));
this->recordInstance(atlas->textureProxy(), resources->nextPathInstanceIdx());
+ // TODO4F: Preserve float colors
resources->appendDrawPathInstance().set(*cacheEntry, draw.fCachedMaskShift,
- draw.fColor);
+ draw.fColor.toGrColor());
// Remember this atlas in case we encounter the path again during the same flush.
cacheEntry->setCurrFlushAtlas(atlas);
continue;
@@ -368,8 +374,9 @@
draw.fMaskDevIBounds, draw.fMatrix, draw.fShape, draw.fStrokeDevWidth,
&devBounds, &devBounds45, &devIBounds, &devToAtlasOffset)) {
this->recordInstance(atlas->textureProxy(), resources->nextPathInstanceIdx());
+ // TODO4F: Preserve float colors
resources->appendDrawPathInstance().set(devBounds, devBounds45, devToAtlasOffset,
- draw.fColor, doEvenOddFill);
+ draw.fColor.toGrColor(), doEvenOddFill);
// If we have a spot in the path cache, try to make a note of where this mask is so we
// can reuse it in the future.