remove forceW system

The SkAtlasTextTarget forced W for drawing using 3D vertices. Since it
is gone, the force W system is not needed.

Change-Id: Ic70b2f9aa5fd845dcfa7b06b5905afeb72f96441
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294600
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Herb Derby 2020-06-05 11:37:16 -04:00 committed by Skia Commit-Bot
parent 530fedf893
commit 692e59dca2
8 changed files with 15 additions and 34 deletions

View File

@ -328,7 +328,6 @@ void GrTextContext::drawGlyphRunList(GrRecordingContext* context,
cachedBlob = textBlobCache->find(key);
}
bool forceW = fOptions.fDistanceFieldVerticesAlwaysHaveW;
bool supportsSDFT = context->priv().caps()->shaderCaps()->supportsDistanceFieldText();
SkGlyphRunListPainter* painter = target->glyphPainter();
const SkMatrix& drawMatrix(matrixProvider.localToDevice());
@ -340,7 +339,7 @@ void GrTextContext::drawGlyphRunList(GrRecordingContext* context,
// but we'd have to clear the subrun information
textBlobCache->remove(cachedBlob.get());
cachedBlob = textBlobCache->makeCachedBlob(glyphRunList, key, blurRec, drawMatrix,
initialVertexColor, forceW);
initialVertexColor);
painter->processGlyphRunList(
glyphRunList, drawMatrix, props, supportsSDFT, fOptions, cachedBlob.get());
@ -350,9 +349,9 @@ void GrTextContext::drawGlyphRunList(GrRecordingContext* context,
} else {
if (canCache) {
cachedBlob = textBlobCache->makeCachedBlob(glyphRunList, key, blurRec, drawMatrix,
initialVertexColor, forceW);
initialVertexColor);
} else {
cachedBlob = GrTextBlob::Make(glyphRunList, drawMatrix, initialVertexColor, forceW);
cachedBlob = GrTextBlob::Make(glyphRunList, drawMatrix, initialVertexColor);
}
painter->processGlyphRunList(
glyphRunList, drawMatrix, props, supportsSDFT, fOptions, cachedBlob.get());
@ -396,7 +395,7 @@ std::unique_ptr<GrDrawOp> GrTextContext::createOp_TestingOnly(GrRecordingContext
auto glyphRunList = builder.useGlyphRunList();
sk_sp<GrTextBlob> blob;
if (!glyphRunList.empty()) {
blob = GrTextBlob::Make(glyphRunList, drawMatrix, color, false);
blob = GrTextBlob::Make(glyphRunList, drawMatrix, color);
SkGlyphRunListPainter* painter = rtc->textTarget()->glyphPainter();
painter->processGlyphRunList(
glyphRunList, drawMatrix, surfaceProps,

View File

@ -90,7 +90,6 @@ void GrRecordingContext::setupDrawingManager(bool sortOpsTasks, bool reduceOpsTa
GrTextContext::Options textContextOptions;
textContextOptions.fMaxDistanceFieldFontSize = this->options().fGlyphsAsPathsFontSize;
textContextOptions.fMinDistanceFieldFontSize = this->options().fMinDistanceFieldFontSize;
textContextOptions.fDistanceFieldVerticesAlwaysHaveW = false;
fDrawingManager.reset(new GrDrawingManager(this,
prcOptions,

View File

@ -288,9 +288,7 @@ auto GrTextBlob::SubRun::vertexData() const -> SkSpan<const VertexData> {
}
bool GrTextBlob::SubRun::hasW() const {
if (fType == kTransformedSDFT) {
return fBlob->hasPerspective() || fBlob->forceWForDistanceFields();
} else if (fType == kTransformedMask || fType == kTransformedPath) {
if (fType == kTransformedSDFT || fType == kTransformedMask || fType == kTransformedPath) {
return fBlob->hasPerspective();
}
@ -546,8 +544,7 @@ GrTextBlob::~GrTextBlob() = default;
sk_sp<GrTextBlob> GrTextBlob::Make(const SkGlyphRunList& glyphRunList,
const SkMatrix& drawMatrix,
GrColor color,
bool forceWForDistanceFields) {
GrColor color) {
// The difference in alignment from the storage of VertexData to SubRun;
constexpr size_t alignDiff = alignof(SubRun) - alignof(SubRun::VertexData);
constexpr size_t vertexDataToSubRunPadding = alignDiff > 0 ? alignDiff : 0;
@ -560,8 +557,7 @@ sk_sp<GrTextBlob> GrTextBlob::Make(const SkGlyphRunList& glyphRunList,
SkColor initialLuminance = SkPaintPriv::ComputeLuminanceColor(glyphRunList.paint());
sk_sp<GrTextBlob> blob{new (allocation) GrTextBlob{
arenaSize, drawMatrix, glyphRunList.origin(),
color, initialLuminance, forceWForDistanceFields}};
arenaSize, drawMatrix, glyphRunList.origin(), color, initialLuminance}};
return blob;
}
@ -731,12 +727,10 @@ GrTextBlob::GrTextBlob(size_t allocSize,
const SkMatrix& drawMatrix,
SkPoint origin,
GrColor color,
SkColor initialLuminance,
bool forceWForDistanceFields)
SkColor initialLuminance)
: fSize{allocSize}
, fInitialMatrix{drawMatrix}
, fInitialOrigin{origin}
, fForceWForDistanceFields{forceWForDistanceFields}
, fColor{color}
, fInitialLuminance{initialLuminance}
, fAlloc{SkTAddOffset<char>(this, sizeof(GrTextBlob)), allocSize, allocSize/2} { }
@ -783,8 +777,6 @@ void GrTextBlob::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawab
auto GrTextBlob::firstSubRun() const -> SubRun* { return fFirstSubRun; }
bool GrTextBlob::forceWForDistanceFields() const { return fForceWForDistanceFields; }
// -- GrTextBlob::VertexRegenerator ----------------------------------------------------------------
GrTextBlob::VertexRegenerator::VertexRegenerator(GrResourceProvider* resourceProvider,
GrTextBlob::SubRun* subRun,

View File

@ -99,8 +99,7 @@ public:
// adding SubRuns.
static sk_sp<GrTextBlob> Make(const SkGlyphRunList& glyphRunList,
const SkMatrix& drawMatrix,
GrColor color,
bool forceWForDistanceFields);
GrColor color);
// Key manipulation functions
void setupKey(const GrTextBlob::Key& key,
@ -159,8 +158,7 @@ private:
const SkMatrix& drawMatrix,
SkPoint origin,
GrColor color,
SkColor initialLuminance,
bool forceWForDistanceFields);
SkColor initialLuminance);
void insertSubRun(SubRun* subRun);
@ -191,9 +189,6 @@ private:
// blob.
const SkPoint fInitialOrigin;
// From the distance field options to force distance fields to have a W coordinate.
const bool fForceWForDistanceFields;
// The color of the text to draw for solid colors.
const GrColor fColor;
const SkColor fInitialLuminance;

View File

@ -28,8 +28,8 @@ GrTextBlobCache::~GrTextBlobCache() {
sk_sp<GrTextBlob>
GrTextBlobCache::makeCachedBlob(const SkGlyphRunList& glyphRunList, const GrTextBlob::Key& key,
const SkMaskFilterBase::BlurRec& blurRec,
const SkMatrix& viewMatrix, GrColor color, bool forceW) {
sk_sp<GrTextBlob> cacheBlob(GrTextBlob::Make(glyphRunList, viewMatrix, color, forceW));
const SkMatrix& viewMatrix, GrColor color) {
sk_sp<GrTextBlob> cacheBlob(GrTextBlob::Make(glyphRunList, viewMatrix, color));
cacheBlob->setupKey(key, blurRec, glyphRunList.paint());
this->add(cacheBlob);
glyphRunList.temporaryShuntBlobNotifyAddedToCache(fMessageBusID);

View File

@ -29,8 +29,7 @@ public:
const GrTextBlob::Key& key,
const SkMaskFilterBase::BlurRec& blurRec,
const SkMatrix& viewMatrix,
GrColor color,
bool forceW);
GrColor color);
sk_sp<GrTextBlob> find(const GrTextBlob::Key& key) const;

View File

@ -110,9 +110,8 @@ bool GrTextContext::CanDrawAsDistanceFields(const SkPaint& paint, const SkFont&
}
if (viewMatrix.hasPerspective()) {
if (!options.fDistanceFieldVerticesAlwaysHaveW) {
return false;
}
// Don't use SDF for perspective. Paths look better.
return false;
} else {
SkScalar maxScale = viewMatrix.getMaxScale();
SkScalar scaledTextSize = maxScale * font.getSize();

View File

@ -39,8 +39,6 @@ public:
* be rendered from outline as individual paths. Negative means use a default value.
*/
SkScalar fMaxDistanceFieldFontSize = -1.f;
/** Forces all distance field vertices to use 3 components, not just when in perspective. */
bool fDistanceFieldVerticesAlwaysHaveW = false;
};
static std::unique_ptr<GrTextContext> Make(const Options& options);