Revert "Remove unused fields from GrTextBlobKey"

This reverts commit 51b99659ed.

Reason for revert: These are important for the key.

Original change's description:
> Remove unused fields from GrTextBlobKey
> 
> Change-Id: Ibb42f943ffbed16867d714e9a1eee35d3f422b2a
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259282
> Commit-Queue: Herb Derby <herb@google.com>
> Auto-Submit: Herb Derby <herb@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com,herb@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: If34b4637136135d5d8a7b66c5b5ff1a24bd214c3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259807
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2019-12-13 16:28:42 +00:00 committed by Skia Commit-Bot
parent b26f813bd3
commit 5c7f38a67d
4 changed files with 23 additions and 0 deletions

View File

@ -300,21 +300,29 @@ void GrTextContext::drawGlyphRunList(
const SkMaskFilter* mf = blobPaint.getMaskFilter();
bool canCache = glyphRunList.canCache() && !(blobPaint.getPathEffect() ||
(mf && !as_MFB(mf)->asABlur(&blurRec)));
SkScalerContextFlags scalerContextFlags = ComputeScalerContextFlags(colorInfo);
sk_sp<GrTextBlob> cachedBlob;
GrTextBlob::Key key;
if (canCache) {
bool hasLCD = glyphRunList.anyRunsLCD();
// We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry
SkPixelGeometry pixelGeometry = hasLCD ? props.pixelGeometry() :
kUnknown_SkPixelGeometry;
// TODO we want to figure out a way to be able to use the canonical color on LCD text,
// see the note on ComputeCanonicalColor above. We pick a dummy value for LCD text to
// ensure we always match the same key
GrColor canonicalColor = hasLCD ? SK_ColorTRANSPARENT :
ComputeCanonicalColor(blobPaint, hasLCD);
key.fPixelGeometry = pixelGeometry;
key.fUniqueID = glyphRunList.uniqueID();
key.fStyle = blobPaint.getStyle();
key.fHasBlur = SkToBool(mf);
key.fCanonicalColor = canonicalColor;
key.fScalerContextFlags = scalerContextFlags;
cachedBlob = textBlobCache->find(key);
}

View File

@ -75,7 +75,9 @@ public:
// represents the bucket. This functionality is currently only supported for A8
SkColor fCanonicalColor;
SkPaint::Style fStyle;
SkPixelGeometry fPixelGeometry;
bool fHasBlur;
uint32_t fScalerContextFlags;
bool operator==(const Key& other) const;
};

View File

@ -75,6 +75,17 @@ SkColor GrTextContext::ComputeCanonicalColor(const SkPaint& paint, bool lcd) {
return canonicalColor;
}
SkScalerContextFlags GrTextContext::ComputeScalerContextFlags(const GrColorInfo& colorInfo) {
// If we're doing linear blending, then we can disable the gamma hacks.
// Otherwise, leave them on. In either case, we still want the contrast boost:
// TODO: Can we be even smarter about mask gamma based on the dest transfer function?
if (colorInfo.isLinearlyBlended()) {
return SkScalerContextFlags::kBoostContrast;
} else {
return SkScalerContextFlags::kFakeGammaAndBoostContrast;
}
}
void GrTextContext::SanitizeOptions(Options* options) {
if (options->fMaxDistanceFieldFontSize < 0.f) {
options->fMaxDistanceFieldFontSize = kDefaultMaxDistanceFieldFontSize;

View File

@ -79,6 +79,8 @@ private:
// sets up the descriptor on the blob and returns a detached cache. Client must attach
static SkColor ComputeCanonicalColor(const SkPaint&, bool lcd);
// Determines if we need to use fake gamma (and contrast boost):
static SkScalerContextFlags ComputeScalerContextFlags(const GrColorInfo&);
const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAdjustTable.get(); }