Avoid "drawable" when not referring to SkDrawable.

Change all use of "drawable" to "accepted" in glyph drawing code. To
improve uniformity "rejects" is also changed to "rejected".  This is
motivated by the desire to add SkDrawable backed glyph rendering, which
would make the use of "drawable" for both "glyphs which are drawable"
and "glyph which renders with SkDrawable" very confusing.

Change-Id: I6d080bc9ec25f81aa9479757d2cca47ae74f4db6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/504236
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2022-02-03 17:32:59 -05:00 committed by SkCQ
parent 40df2e3cf5
commit bee5ccd548
16 changed files with 260 additions and 263 deletions

View File

@ -237,13 +237,13 @@ public:
}
void prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) override;
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override;
void prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) override;
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override;
void prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) override;
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override;
void onAboutToExitScope() override {}
@ -258,7 +258,7 @@ public:
private:
template <typename Rejector>
void commonMaskLoop(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects, Rejector&& reject);
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected, Rejector&& reject);
// Same thing as MaskSummary, but for paths.
struct PathSummary {
@ -414,8 +414,8 @@ void RemoteStrike::writeGlyphPath(
template <typename Rejector>
void RemoteStrike::commonMaskLoop(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects, Rejector&& reject) {
drawables->forEachGlyphID(
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected, Rejector&& reject) {
accepted->forEachInput(
[&](size_t i, SkPackedGlyphID packedID, SkPoint position) {
SkGlyphDigest* digest = fSentGlyphs.find(packedID.value());
if (digest == nullptr) {
@ -430,14 +430,14 @@ void RemoteStrike::commonMaskLoop(
// Reject things that are too big.
if (reject(*digest)) {
rejects->reject(i);
rejected->reject(i);
}
});
}
void RemoteStrike::prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) {
for (auto [i, variant, _] : SkMakeEnumerate(drawables->input())) {
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
for (auto [i, variant, _] : SkMakeEnumerate(accepted->input())) {
SkPackedGlyphID packedID = variant.packedID();
if (fSentLowGlyphIDs.test(packedID)) {
#ifdef SK_DEBUG
@ -468,20 +468,20 @@ void RemoteStrike::prepareForMaskDrawing(
// Reject things that are too big.
// N.B. this must have the same behavior as SkScalerCache::prepareForMaskDrawing.
if (!digest->canDrawAsMask()) {
rejects->reject(i, digest->maxDimension());
rejected->reject(i, digest->maxDimension());
}
}
}
void RemoteStrike::prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) {
this->commonMaskLoop(drawables, rejects,
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
this->commonMaskLoop(accepted, rejected,
[](SkGlyphDigest digest){return !digest.canDrawAsSDFT();});
}
void RemoteStrike::prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) {
drawables->forEachGlyphID(
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
accepted->forEachInput(
[&](size_t i, SkPackedGlyphID packedID, SkPoint position) {
PathSummary* summary = fSentPaths.find(packedID);
if (summary == nullptr) {
@ -502,7 +502,7 @@ void RemoteStrike::prepareForPathDrawing(
}
if (summary->maxDimensionOrPath != PathSummary::kIsPath) {
rejects->reject(i, (int)summary->maxDimensionOrPath);
rejected->reject(i, (int)summary->maxDimensionOrPath);
}
});
}

View File

@ -82,7 +82,7 @@ public:
this->drawPath(src, paint, nullptr, false, !isHairline, customBlitter);
}
void paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint) const override;
void paintMasks(SkDrawableGlyphBuffer* accepted, const SkPaint& paint) const override;
static bool ComputeMaskBounds(const SkRect& devPathBounds, const SkIRect* clipBounds,
const SkMaskFilter* filter, const SkMatrix* filterMatrix,

View File

@ -35,7 +35,7 @@ static bool check_glyph_position(SkPoint position) {
lt(position.fY, INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/)));
}
void SkDraw::paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint) const {
void SkDraw::paintMasks(SkDrawableGlyphBuffer* accepted, const SkPaint& paint) const {
// The size used for a typical blitter.
SkSTArenaAlloc<3308> alloc;
@ -48,7 +48,7 @@ void SkDraw::paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint)
bool useRegion = fRC->isBW() && !fRC->isRect();
if (useRegion) {
for (auto [variant, pos] : drawables->drawable()) {
for (auto [variant, pos] : accepted->accepted()) {
SkGlyph* glyph = variant.glyph();
if (check_glyph_position(pos)) {
SkMask mask = glyph->mask(pos);
@ -75,7 +75,7 @@ void SkDraw::paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint)
} else {
SkIRect clipBounds = fRC->isBW() ? fRC->bwRgn().getBounds()
: fRC->aaRgn().getBounds();
for (auto [variant, pos] : drawables->drawable()) {
for (auto [variant, pos] : accepted->accepted()) {
SkGlyph* glyph = variant.glyph();
if (check_glyph_position(pos)) {
SkMask mask = glyph->mask(pos);

View File

@ -22,12 +22,12 @@ void SkDrawableGlyphBuffer::ensureSize(size_t size) {
}
fInputSize = 0;
fDrawableSize = 0;
fAcceptedSize = 0;
}
void SkDrawableGlyphBuffer::startSource(const SkZip<const SkGlyphID, const SkPoint>& source) {
fInputSize = source.size();
fDrawableSize = 0;
fAcceptedSize = 0;
auto positions = source.get<1>();
memcpy(fPositions, positions.data(), positions.size() * sizeof(SkPoint));
@ -45,7 +45,7 @@ void SkDrawableGlyphBuffer::startBitmapDevice(
SkPoint origin, const SkMatrix& viewMatrix,
const SkGlyphPositionRoundingSpec& roundingSpec) {
fInputSize = source.size();
fDrawableSize = 0;
fAcceptedSize = 0;
// Map the positions including subpixel position.
auto positions = source.get<1>();
@ -73,7 +73,7 @@ void SkDrawableGlyphBuffer::startGPUDevice(
const SkMatrix& drawMatrix,
const SkGlyphPositionRoundingSpec& roundingSpec) {
fInputSize = source.size();
fDrawableSize = 0;
fAcceptedSize = 0;
// Build up the mapping from source space to device space. Add the rounding constant
// halfSampleFreq so we just need to floor to get the device result.
@ -117,6 +117,6 @@ void SkDrawableGlyphBuffer::reset() {
fMaxSize = 0;
}
fInputSize = 0;
fDrawableSize = 0;
fAcceptedSize = 0;
}

View File

@ -17,7 +17,7 @@
class SkStrikeForGPU;
struct SkGlyphPositionRoundingSpec;
// SkSourceGlyphBuffer is the source of glyphs between the different stages of character drawing.
// SkSourceGlyphBuffer is the source of glyphs between the different stages of glyph drawing.
// It starts with the glyphs and positions from the SkGlyphRun as the first source. When glyphs
// are reject by a stage they become the source for the next stage.
class SkSourceGlyphBuffer {
@ -190,42 +190,40 @@ public:
return SkZip<SkGlyphVariant, SkPoint>{fInputSize, fMultiBuffer.get(), fPositions};
}
// Store the glyph in the next drawable slot, using the position information located at index
// from.
void push_back(SkGlyph* glyph, size_t from) {
// Store the glyph in the next slot, using the position information located at index from.
void accept(SkGlyph* glyph, size_t from) {
SkASSERT(fPhase == kProcess);
SkASSERT(fDrawableSize <= from);
fPositions[fDrawableSize] = fPositions[from];
fMultiBuffer[fDrawableSize] = glyph;
fDrawableSize++;
SkASSERT(fAcceptedSize <= from);
fPositions[fAcceptedSize] = fPositions[from];
fMultiBuffer[fAcceptedSize] = glyph;
fAcceptedSize++;
}
// Store the path in the next drawable slot, using the position information located at index
// from.
void push_back(const SkPath* path, size_t from) {
// Store the path in the next slot, using the position information located at index from.
void accept(const SkPath* path, size_t from) {
SkASSERT(fPhase == kProcess);
SkASSERT(fDrawableSize <= from);
fPositions[fDrawableSize] = fPositions[from];
fMultiBuffer[fDrawableSize] = path;
fDrawableSize++;
SkASSERT(fAcceptedSize <= from);
fPositions[fAcceptedSize] = fPositions[from];
fMultiBuffer[fAcceptedSize] = path;
fAcceptedSize++;
}
// The result after a series of push_backs of drawable SkGlyph* or SkPath*.
SkZip<SkGlyphVariant, SkPoint> drawable() {
// The result after a series of `accept` of accepted SkGlyph* or SkPath*.
SkZip<SkGlyphVariant, SkPoint> accepted() {
SkASSERT(fPhase == kProcess);
SkDEBUGCODE(fPhase = kDraw);
return SkZip<SkGlyphVariant, SkPoint>{fDrawableSize, fMultiBuffer.get(), fPositions};
return SkZip<SkGlyphVariant, SkPoint>{fAcceptedSize, fMultiBuffer.get(), fPositions};
}
bool drawableIsEmpty() const {
bool empty() const {
SkASSERT(fPhase == kProcess || fPhase == kDraw);
return fDrawableSize == 0;
return fAcceptedSize == 0;
}
void reset();
template <typename Fn>
void forEachGlyphID(Fn&& fn) {
void forEachInput(Fn&& fn) {
for (auto [i, packedID, pos] : SkMakeEnumerate(this->input())) {
fn(i, packedID.packedID(), pos);
}
@ -234,7 +232,7 @@ public:
private:
size_t fMaxSize{0};
size_t fInputSize{0};
size_t fDrawableSize{0};
size_t fAcceptedSize{0};
SkAutoTArray<SkGlyphVariant> fMultiBuffer;
SkAutoTMalloc<SkPoint> fPositions;

View File

@ -97,7 +97,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
for (auto& glyphRun : glyphRunList) {
const SkFont& runFont = glyphRun.font();
fRejects.setSource(glyphRun.source());
fRejected.setSource(glyphRun.source());
if (SkStrikeSpec::ShouldDrawAsPath(paint, runFont, deviceMatrix)) {
@ -106,9 +106,9 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
auto strike = strikeSpec.findOrCreateStrike();
fDrawable.startSource(fRejects.source());
strike->prepareForPathDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource();
fAccepted.startSource(fRejected.source());
strike->prepareForPathDrawing(&fAccepted, &fRejected);
fRejected.flipRejectsToSource();
// The paint we draw paths with must have the same anti-aliasing state as the runFont
// allowing the paths to have the same edging as the glyph masks.
@ -122,7 +122,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
|| pathPaint.getMaskFilter()
|| (stroking && !hairline);
if (!needsExactCTM) {
for (auto [variant, pos] : fDrawable.drawable()) {
for (auto [variant, pos] : fAccepted.accepted()) {
const SkPath* path = variant.path();
SkMatrix m;
SkPoint translate = drawOrigin + pos;
@ -133,7 +133,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
canvas->drawPath(*path, pathPaint);
}
} else {
for (auto [variant, pos] : fDrawable.drawable()) {
for (auto [variant, pos] : fAccepted.accepted()) {
const SkPath* path = variant.path();
SkMatrix m;
SkPoint translate = drawOrigin + pos;
@ -147,19 +147,19 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
}
}
}
if (!fRejects.source().empty() && !deviceMatrix.hasPerspective()) {
if (!fRejected.source().empty() && !deviceMatrix.hasPerspective()) {
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeMask(
runFont, paint, props, fScalerContextFlags, deviceMatrix);
auto strike = strikeSpec.findOrCreateStrike();
fDrawable.startBitmapDevice(
fRejects.source(), drawOrigin, deviceMatrix, strike->roundingSpec());
strike->prepareForDrawingMasksCPU(&fDrawable);
fRejects.flipRejectsToSource();
bitmapDevice->paintMasks(&fDrawable, paint);
fAccepted.startBitmapDevice(
fRejected.source(), drawOrigin, deviceMatrix, strike->roundingSpec());
strike->prepareForDrawingMasksCPU(&fAccepted);
fRejected.flipRejectsToSource();
bitmapDevice->paintMasks(&fAccepted, paint);
}
if (!fRejects.source().empty()) {
if (!fRejected.source().empty()) {
SkMatrix runMatrix = deviceMatrix;
runMatrix.preTranslate(drawOrigin.x(), drawOrigin.y());
std::vector<SkPoint> sourcePositions;
@ -169,8 +169,8 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
runFont, paint, props, fScalerContextFlags, SkMatrix::I());
SkBulkGlyphMetrics metrics{scaleStrikeSpec};
auto glyphIDs = fRejects.source().get<0>();
auto positions = fRejects.source().get<1>();
auto glyphIDs = fRejected.source().get<0>();
auto positions = fRejected.source().get<1>();
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(glyphIDs);
SkScalar maxScale = SK_ScalarMin;
@ -208,11 +208,11 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
auto strike = strikeSpec.findOrCreateStrike();
// Figure out all the positions and packed glyphIDs based on the device matrix.
fDrawable.startBitmapDevice(
fRejects.source(), drawOrigin, deviceMatrix, strike->roundingSpec());
fAccepted.startBitmapDevice(
fRejected.source(), drawOrigin, deviceMatrix, strike->roundingSpec());
strike->prepareForDrawingMasksCPU(&fDrawable);
auto variants = fDrawable.drawable().get<0>();
strike->prepareForDrawingMasksCPU(&fAccepted);
auto variants = fAccepted.accepted().get<0>();
for (auto [variant, srcPos] : SkMakeZip(variants, sourcePositions)) {
SkGlyph* glyph = variant.glyph();
SkMask mask = glyph->mask();
@ -241,7 +241,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
bm, translate, nullptr, SkSamplingOptions{SkFilterMode::kLinear},
paint);
}
fRejects.flipRejectsToSource();
fRejected.flipRejectsToSource();
}
// TODO: have the mask stage above reject the glyphs that are too big, and handle the
@ -276,7 +276,7 @@ void SkGlyphRunListPainter::processGlyphRun(SkGlyphRunPainterInterface* process,
drawMatrix[3], drawMatrix[4], drawMatrix[5]);
#endif
ScopedBuffers _ = this->ensureBuffers(glyphRun);
fRejects.setSource(glyphRun.source());
fRejected.setSource(glyphRun.source());
const SkFont& runFont = glyphRun.font();
// Only consider using direct or SDFT drawing if not drawing hairlines and not perspective.
@ -297,17 +297,17 @@ void SkGlyphRunListPainter::processGlyphRun(SkGlyphRunPainterInterface* process,
if (!SkScalarNearlyZero(strikeToSourceScale)) {
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startSource(fRejects.source());
fAccepted.startSource(fRejected.source());
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" glyphs:(x,y):\n %s\n", fDrawable.dumpInput().c_str());
msg.appendf(" glyphs:(x,y):\n %s\n", fAccepted.dumpInput().c_str());
#endif
strike->prepareForSDFTDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource();
strike->prepareForSDFTDrawing(&fAccepted, &fRejected);
fRejected.flipRejectsToSource();
if (process && !fDrawable.drawableIsEmpty()) {
if (process && !fAccepted.empty()) {
// processSourceSDFT must be called even if there are no glyphs to make sure
// runs are set correctly.
process->processSourceSDFT(fDrawable.drawable(),
process->processSourceSDFT(fAccepted.accepted(),
strike->getUnderlyingStrike(),
strikeToSourceScale,
runFont,
@ -316,7 +316,7 @@ void SkGlyphRunListPainter::processGlyphRun(SkGlyphRunPainterInterface* process,
}
}
if (!fRejects.source().empty()) {
if (!fRejected.source().empty()) {
// Process masks including ARGB - this should be the 99.99% case.
// This will handle medium size emoji that are sharing the run with SDFT drawn text.
// If things are too big they will be passed along to the drawing of last resort below.
@ -329,17 +329,17 @@ void SkGlyphRunListPainter::processGlyphRun(SkGlyphRunPainterInterface* process,
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startGPUDevice(fRejects.source(), drawMatrix, strike->roundingSpec());
fAccepted.startGPUDevice(fRejected.source(), drawMatrix, strike->roundingSpec());
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" glyphs:(x,y):\n %s\n", fDrawable.dumpInput().c_str());
msg.appendf(" glyphs:(x,y):\n %s\n", fAccepted.dumpInput().c_str());
#endif
strike->prepareForMaskDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource();
strike->prepareForMaskDrawing(&fAccepted, &fRejected);
fRejected.flipRejectsToSource();
if (process && !fDrawable.drawableIsEmpty()) {
if (process && !fAccepted.empty()) {
// processDeviceMasks must be called even if there are no glyphs to make sure runs
// are set correctly.
process->processDeviceMasks(fDrawable.drawable(), strike->getUnderlyingStrike());
process->processDeviceMasks(fAccepted.accepted(), strike->getUnderlyingStrike());
}
}
}
@ -349,7 +349,7 @@ void SkGlyphRunListPainter::processGlyphRun(SkGlyphRunPainterInterface* process,
// maxDimensionInSourceSpace is used to calculate the factor from strike space to source
// space.
SkScalar maxDimensionInSourceSpace = 0.0;
if (!fRejects.source().empty()) {
if (!fRejected.source().empty()) {
// Path case - handle big things without color and that have a path.
auto [strikeSpec, strikeToSourceScale] =
SkStrikeSpec::MakePath(runFont, runPaint, fDeviceProps, fScalerContextFlags);
@ -361,24 +361,24 @@ void SkGlyphRunListPainter::processGlyphRun(SkGlyphRunPainterInterface* process,
if (!SkScalarNearlyZero(strikeToSourceScale)) {
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startSource(fRejects.source());
fAccepted.startSource(fRejected.source());
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" glyphs:(x,y):\n %s\n", fDrawable.dumpInput().c_str());
msg.appendf(" glyphs:(x,y):\n %s\n", fAccepted.dumpInput().c_str());
#endif
strike->prepareForPathDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource();
auto [minHint, maxHint] = fRejects.maxDimensionHint();
strike->prepareForPathDrawing(&fAccepted, &fRejected);
fRejected.flipRejectsToSource();
auto [minHint, maxHint] = fRejected.maxDimensionHint();
maxDimensionInSourceSpace = SkScalarCeilToScalar(maxHint * strikeToSourceScale);
if (process && !fDrawable.drawableIsEmpty()) {
if (process && !fAccepted.empty()) {
// processSourcePaths must be called even if there are no glyphs to make sure
// runs are set correctly.
process->processSourcePaths(fDrawable.drawable(), runFont, strikeToSourceScale);
process->processSourcePaths(fAccepted.accepted(), runFont, strikeToSourceScale);
}
}
}
if (!fRejects.source().empty() && maxDimensionInSourceSpace != 0) {
if (!fRejected.source().empty() && maxDimensionInSourceSpace != 0) {
// Draw of last resort. Scale the bitmap to the screen.
auto [strikeSpec, strikeToSourceScale] = SkStrikeSpec::MakeSourceFallback(
runFont, runPaint, fDeviceProps,
@ -391,17 +391,17 @@ void SkGlyphRunListPainter::processGlyphRun(SkGlyphRunPainterInterface* process,
if (!SkScalarNearlyZero(strikeToSourceScale)) {
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startSource(fRejects.source());
fAccepted.startSource(fRejected.source());
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf("glyphs:(x,y):\n %s\n", fDrawable.dumpInput().c_str());
msg.appendf("glyphs:(x,y):\n %s\n", fAccepted.dumpInput().c_str());
#endif
strike->prepareForMaskDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource();
SkASSERT(fRejects.source().empty());
strike->prepareForMaskDrawing(&fAccepted, &fRejected);
fRejected.flipRejectsToSource();
SkASSERT(fRejected.source().empty());
if (process && !fDrawable.drawableIsEmpty()) {
if (process && !fAccepted.empty()) {
process->processSourceMasks(
fDrawable.drawable(), strike->getUnderlyingStrike(), strikeToSourceScale);
fAccepted.accepted(), strike->getUnderlyingStrike(), strikeToSourceScale);
}
}
}
@ -429,12 +429,12 @@ auto SkGlyphRunListPainter::ensureBuffers(const SkGlyphRun& glyphRun) -> ScopedB
SkGlyphRunListPainter::ScopedBuffers::ScopedBuffers(SkGlyphRunListPainter* painter, size_t size)
: fPainter{painter} {
fPainter->fDrawable.ensureSize(size);
fPainter->fAccepted.ensureSize(size);
}
SkGlyphRunListPainter::ScopedBuffers::~ScopedBuffers() {
fPainter->fDrawable.reset();
fPainter->fRejects.reset();
fPainter->fAccepted.reset();
fPainter->fRejected.reset();
}
SkVector SkGlyphPositionRoundingSpec::HalfAxisSampleFreq(

View File

@ -72,7 +72,7 @@ public:
BitmapDevicePainter(const BitmapDevicePainter&) = default;
virtual ~BitmapDevicePainter() = default;
virtual void paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint) const = 0;
virtual void paintMasks(SkDrawableGlyphBuffer* accepted, const SkPaint& paint) const = 0;
virtual void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
const SkSamplingOptions&, const SkPaint&) const = 0;
};
@ -115,8 +115,8 @@ private:
SkStrikeForGPUCacheInterface* const fStrikeCache;
SkDrawableGlyphBuffer fDrawable;
SkSourceGlyphBuffer fRejects;
SkDrawableGlyphBuffer fAccepted;
SkSourceGlyphBuffer fRejected;
};
// SkGlyphRunPainterInterface are all the ways that Ganesh generates glyphs. The first
@ -135,18 +135,18 @@ class SkGlyphRunPainterInterface {
public:
virtual ~SkGlyphRunPainterInterface() = default;
virtual void processDeviceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
virtual void processDeviceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike) = 0;
virtual void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
virtual void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) = 0;
virtual void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
virtual void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
SkScalar strikeToSourceScale) = 0;
virtual void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
virtual void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const SkFont& runFont,

View File

@ -50,8 +50,8 @@ public:
fOverdrawCanvas{overdrawCanvas},
fPainter{props, kN32_SkColorType, nullptr, SkStrikeCache::GlobalStrikeCache()} {}
void paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint) const override {
for (auto t : drawables->drawable()) {
void paintMasks(SkDrawableGlyphBuffer* accepted, const SkPaint& paint) const override {
for (auto t : accepted->accepted()) {
SkGlyphVariant glyph; SkPoint pos;
std::tie(glyph, pos) = t;
SkMask mask = glyph.glyph()->mask(pos);

View File

@ -164,9 +164,9 @@ std::tuple<SkSpan<const SkGlyph*>, size_t> SkScalerCache::prepareImages(
}
template <typename Fn>
size_t SkScalerCache::commonFilterLoop(SkDrawableGlyphBuffer* drawables, Fn&& fn) {
size_t SkScalerCache::commonFilterLoop(SkDrawableGlyphBuffer* accepted, Fn&& fn) {
size_t total = 0;
for (auto [i, packedID, pos] : SkMakeEnumerate(drawables->input())) {
for (auto [i, packedID, pos] : SkMakeEnumerate(accepted->input())) {
if (SkScalarsAreFinite(pos.x(), pos.y())) {
auto [digest, size] = this->digest(packedID);
total += size;
@ -178,16 +178,16 @@ size_t SkScalerCache::commonFilterLoop(SkDrawableGlyphBuffer* drawables, Fn&& fn
return total;
}
size_t SkScalerCache::prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* drawables) {
size_t SkScalerCache::prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* accepted) {
SkAutoMutexExclusive lock{fMu};
size_t imageDelta = 0;
size_t delta = this->commonFilterLoop(drawables,
size_t delta = this->commonFilterLoop(accepted,
[&](size_t i, SkGlyphDigest digest, SkPoint pos) SK_REQUIRES(fMu) {
// If the glyph is too large, then no image is created.
SkGlyph* glyph = fGlyphForIndex[digest.index()];
auto [image, imageSize] = this->prepareImage(glyph);
if (image != nullptr) {
drawables->push_back(glyph, i);
accepted->accept(glyph, i);
imageDelta += imageSize;
}
});
@ -197,15 +197,15 @@ size_t SkScalerCache::prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* drawables
// Note: this does not actually fill out the image. That happens at atlas building time.
size_t SkScalerCache::prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) {
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
SkAutoMutexExclusive lock{fMu};
size_t delta = this->commonFilterLoop(drawables,
size_t delta = this->commonFilterLoop(accepted,
[&](size_t i, SkGlyphDigest digest, SkPoint pos) SK_REQUIRES(fMu) {
// N.B. this must have the same behavior as RemoteStrike::prepareForMaskDrawing.
if (digest.canDrawAsMask()) {
drawables->push_back(fGlyphForIndex[digest.index()], i);
accepted->accept(fGlyphForIndex[digest.index()], i);
} else {
rejects->reject(i, digest.maxDimension());
rejected->reject(i, digest.maxDimension());
}
});
@ -213,15 +213,15 @@ size_t SkScalerCache::prepareForMaskDrawing(
}
size_t SkScalerCache::prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) {
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
SkAutoMutexExclusive lock{fMu};
size_t delta = this->commonFilterLoop(drawables,
size_t delta = this->commonFilterLoop(accepted,
[&](size_t i, SkGlyphDigest digest, SkPoint pos) SK_REQUIRES(fMu) {
if (digest.canDrawAsSDFT()) {
drawables->push_back(fGlyphForIndex[digest.index()], i);
accepted->accept(fGlyphForIndex[digest.index()], i);
} else {
// Assume whatever follows SDF doesn't care about the maximum rejected size.
rejects->reject(i);
rejected->reject(i);
}
});
@ -229,20 +229,20 @@ size_t SkScalerCache::prepareForSDFTDrawing(
}
size_t SkScalerCache::prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) {
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
SkAutoMutexExclusive lock{fMu};
size_t pathDelta = 0;
size_t delta = this->commonFilterLoop(drawables,
size_t delta = this->commonFilterLoop(accepted,
[&](size_t i, SkGlyphDigest digest, SkPoint pos) SK_REQUIRES(fMu) {
SkGlyph* glyph = fGlyphForIndex[digest.index()];
auto [path, pathSize] = this->preparePath(glyph);
pathDelta += pathSize;
if (path != nullptr) {
// Save off the path to draw later.
drawables->push_back(path, i);
accepted->accept(path, i);
} else {
// Glyph does not have a path.
rejects->reject(i, digest.maxDimension());
rejected->reject(i, digest.maxDimension());
}
});

View File

@ -61,7 +61,7 @@ public:
std::tuple<SkSpan<const SkGlyph*>, size_t> prepareImages(
SkSpan<const SkPackedGlyphID> glyphIDs, const SkGlyph* results[]) SK_EXCLUDES(fMu);
size_t prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* drawables) SK_EXCLUDES(fMu);
size_t prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* accepted) SK_EXCLUDES(fMu);
// SkStrikeForGPU APIs
const SkGlyphPositionRoundingSpec& roundingSpec() const {
@ -69,13 +69,13 @@ public:
}
size_t prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) SK_EXCLUDES(fMu);
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
size_t prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) SK_EXCLUDES(fMu);
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
size_t prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) SK_EXCLUDES(fMu);
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
void dump() const SK_EXCLUDES(fMu);
@ -83,7 +83,7 @@ public:
private:
template <typename Fn>
size_t commonFilterLoop(SkDrawableGlyphBuffer* drawables, Fn&& fn) SK_REQUIRES(fMu);
size_t commonFilterLoop(SkDrawableGlyphBuffer* accepted, Fn&& fn) SK_REQUIRES(fMu);
// Return a glyph. Create it if it doesn't exist, and initialize the glyph with metrics and
// advances using a scaler.

View File

@ -96,8 +96,8 @@ public:
return glyphs;
}
void prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* drawables) {
size_t increase = fScalerCache.prepareForDrawingMasksCPU(drawables);
void prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* accepted) {
size_t increase = fScalerCache.prepareForDrawingMasksCPU(accepted);
this->updateDelta(increase);
}
@ -118,20 +118,20 @@ public:
#endif
void prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawbles, SkSourceGlyphBuffer* rejects) override {
size_t increase = fScalerCache.prepareForMaskDrawing(drawbles, rejects);
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override {
size_t increase = fScalerCache.prepareForMaskDrawing(accepted, rejected);
this->updateDelta(increase);
}
void prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawbles, SkSourceGlyphBuffer* rejects) override {
size_t increase = fScalerCache.prepareForSDFTDrawing(drawbles, rejects);
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override {
size_t increase = fScalerCache.prepareForSDFTDrawing(accepted, rejected);
this->updateDelta(increase);
}
void prepareForPathDrawing(
SkDrawableGlyphBuffer* drawbles, SkSourceGlyphBuffer* rejects) override {
size_t increase = fScalerCache.prepareForPathDrawing(drawbles, rejects);
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override {
size_t increase = fScalerCache.prepareForPathDrawing(accepted, rejected);
this->updateDelta(increase);
}

View File

@ -33,13 +33,13 @@ public:
virtual const SkDescriptor& getDescriptor() const = 0;
virtual void prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0;
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) = 0;
virtual void prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0;
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) = 0;
virtual void prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) = 0;
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) = 0;
virtual const SkGlyphPositionRoundingSpec& roundingSpec() const = 0;

View File

@ -371,7 +371,7 @@ public:
PathOpSubmitter(PathOpSubmitter&& that);
static PathOpSubmitter Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
static PathOpSubmitter Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
bool isAntiAliased,
SkScalar strikeToSourceScale,
GrSubRunAllocator* alloc);
@ -412,17 +412,17 @@ PathOpSubmitter::PathOpSubmitter(PathOpSubmitter&& that)
, fPaths{that.fPaths}
, fPathData{std::move(that.fPathData)} {}
PathOpSubmitter PathOpSubmitter::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
PathOpSubmitter PathOpSubmitter::Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
bool isAntiAliased,
SkScalar strikeToSourceScale,
GrSubRunAllocator* alloc) {
auto pathData = alloc->makeUniqueArray<PathAndPosition>(
drawables.size(),
accepted.size(),
[&](int i){
auto [variant, pos] = drawables[i];
auto [variant, pos] = accepted[i];
return PathAndPosition{*variant.path(), pos};
});
SkSpan<PathAndPosition> paths{pathData.get(), drawables.size()};
SkSpan<PathAndPosition> paths{pathData.get(), accepted.size()};
return PathOpSubmitter{isAntiAliased, strikeToSourceScale, paths, std::move(pathData)};
}
@ -483,12 +483,12 @@ class PathSubRun final : public GrSubRun, public GrBlobSubRun {
public:
PathSubRun(PathOpSubmitter&& pathDrawing) : fPathDrawing(std::move(pathDrawing)) {}
static GrSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
static GrSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
bool isAntiAliased,
SkScalar strikeToSourceScale,
GrSubRunAllocator* alloc) {
return alloc->makeUnique<PathSubRun>(
PathOpSubmitter::Make(drawables, isAntiAliased, strikeToSourceScale, alloc));
PathOpSubmitter::Make(accepted, isAntiAliased, strikeToSourceScale, alloc));
}
void draw(SkCanvas* canvas,
@ -665,7 +665,7 @@ public:
bool glyphsOutOfBounds,
bool supportBilerpAtlas);
static GrSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
static GrSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
GrMaskFormat format,
GrTextBlob* blob,
@ -738,13 +738,13 @@ DirectMaskSubRun::DirectMaskSubRun(GrMaskFormat format,
, fSupportBilerpAtlas{supportBilerpAtlas}
, fGlyphs{std::move(glyphs)} {}
GrSubRunOwner DirectMaskSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
GrSubRunOwner DirectMaskSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
GrMaskFormat format,
GrTextBlob* blob,
GrSubRunAllocator* alloc) {
DevicePosition* glyphLeftTop = alloc->makePODArray<DevicePosition>(drawables.size());
GlyphVector::Variant* glyphIDs = alloc->makePODArray<GlyphVector::Variant>(drawables.size());
DevicePosition* glyphLeftTop = alloc->makePODArray<DevicePosition>(accepted.size());
GlyphVector::Variant* glyphIDs = alloc->makePODArray<GlyphVector::Variant>(accepted.size());
// Because this is the direct case, the maximum width or height is the size that fits in the
// atlas. This boundary is checked below to ensure that the call to SkGlyphRect below will
@ -753,7 +753,7 @@ GrSubRunOwner DirectMaskSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawa
std::numeric_limits<int16_t>::max() - SkStrikeCommon::kSkSideTooBigForAtlas;
SkGlyphRect runBounds = skglyph::empty_rect();
size_t goodPosCount = 0;
for (auto [variant, pos] : drawables) {
for (auto [variant, pos] : accepted) {
auto [x, y] = pos;
// Ensure that the .offset() call below does not overflow. And, at this point none of the
// rectangles are empty because they were culled before the run was created. Basically,
@ -776,7 +776,7 @@ GrSubRunOwner DirectMaskSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawa
// If some glyphs were excluded by the bounds, then this subrun can't be generally be used
// for other draws. Mark the subrun as not general.
bool glyphsExcluded = goodPosCount != drawables.size();
bool glyphsExcluded = goodPosCount != accepted.size();
SkSpan<const DevicePosition> leftTop{glyphLeftTop, goodPosCount};
return alloc->makeUnique<DirectMaskSubRun>(
format, blob, runBounds, leftTop,
@ -1067,7 +1067,7 @@ public:
GlyphVector&& glyphs);
static GrSubRunOwner Make(GrTextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
GrMaskFormat format,
@ -1137,7 +1137,7 @@ TransformedMaskSubRun::TransformedMaskSubRun(GrTextReferenceFrame* referenceFram
, fGlyphs{std::move(glyphs)} { }
GrSubRunOwner TransformedMaskSubRun::Make(GrTextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
GrMaskFormat format,
@ -1145,7 +1145,7 @@ GrSubRunOwner TransformedMaskSubRun::Make(GrTextReferenceFrame* referenceFrame,
SkRect bounds = SkRectPriv::MakeLargestInverted();
SkSpan<VertexData> vertexData = alloc->makePODArray<VertexData>(
drawables,
accepted,
[&](auto e) {
auto [variant, pos] = e;
SkGlyph* skGlyph = variant;
@ -1162,7 +1162,7 @@ GrSubRunOwner TransformedMaskSubRun::Make(GrTextReferenceFrame* referenceFrame,
return alloc->makeUnique<TransformedMaskSubRun>(
referenceFrame, format, strikeToSourceScale, bounds, vertexData,
GlyphVector::Make(std::move(strike), drawables.get<0>(), alloc));
GlyphVector::Make(std::move(strike), accepted.get<0>(), alloc));
}
void TransformedMaskSubRun::draw(SkCanvas*,
@ -1276,7 +1276,7 @@ public:
const GrSDFTMatrixRange& matrixRange);
static GrSubRunOwner Make(GrTextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
@ -1361,7 +1361,7 @@ bool has_some_antialiasing(const SkFont& font ) {
}
GrSubRunOwner SDFTSubRun::Make(GrTextReferenceFrame* referenceFrame,
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
@ -1382,14 +1382,14 @@ GrSubRunOwner SDFTSubRun::Make(GrTextReferenceFrame* referenceFrame,
return VertexData{pos, {l, t, r, b}};
};
SkSpan<VertexData> vertexData = alloc->makePODArray<VertexData>(drawables, mapper);
SkSpan<VertexData> vertexData = alloc->makePODArray<VertexData>(accepted, mapper);
return alloc->makeUnique<SDFTSubRun>(
referenceFrame,
strikeToSourceScale,
bounds,
vertexData,
GlyphVector::Make(std::move(strike), drawables.get<0>(), alloc),
GlyphVector::Make(std::move(strike), accepted.get<0>(), alloc),
runFont.getEdging() == SkFont::Edging::kSubpixelAntiAlias,
has_some_antialiasing(runFont),
matrixRange);
@ -1526,26 +1526,26 @@ const GrAtlasSubRun* SDFTSubRun::testingOnly_atlasSubRun() const {
template<typename AddSingleMaskFormat>
void add_multi_mask_format(
AddSingleMaskFormat addSingleMaskFormat,
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike) {
if (drawables.empty()) { return; }
if (accepted.empty()) { return; }
auto glyphSpan = drawables.get<0>();
auto glyphSpan = accepted.get<0>();
SkGlyph* glyph = glyphSpan[0];
GrMaskFormat format = GrGlyph::FormatFromSkGlyph(glyph->maskFormat());
size_t startIndex = 0;
for (size_t i = 1; i < drawables.size(); i++) {
for (size_t i = 1; i < accepted.size(); i++) {
glyph = glyphSpan[i];
GrMaskFormat nextFormat = GrGlyph::FormatFromSkGlyph(glyph->maskFormat());
if (format != nextFormat) {
auto glyphsWithSameFormat = drawables.subspan(startIndex, i - startIndex);
auto glyphsWithSameFormat = accepted.subspan(startIndex, i - startIndex);
// Take a ref on the strike. This should rarely happen.
addSingleMaskFormat(glyphsWithSameFormat, format, sk_sp<SkStrike>(strike));
format = nextFormat;
startIndex = i;
}
}
auto glyphsWithSameFormat = drawables.last(drawables.size() - startIndex);
auto glyphsWithSameFormat = accepted.last(accepted.size() - startIndex);
addSingleMaskFormat(glyphsWithSameFormat, format, std::move(strike));
}
@ -1802,54 +1802,53 @@ GrTextBlob::GrTextBlob(int allocSize,
, fInitialLuminance{initialLuminance} { }
void GrTextBlob::processDeviceMasks(
const SkZip<SkGlyphVariant, SkPoint>& drawables, sk_sp<SkStrike>&& strike) {
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike) {
SkASSERT(strike != nullptr);
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& drawable,
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& accepted,
GrMaskFormat format,
sk_sp<SkStrike>&& runStrike) {
GrSubRunOwner subRun = DirectMaskSubRun::Make(
drawable, std::move(runStrike), format, this, &fAlloc);
accepted, std::move(runStrike), format, this, &fAlloc);
if (subRun != nullptr) {
fSubRunList.append(std::move(subRun));
} else {
fSomeGlyphsExcluded = true;
}
};
add_multi_mask_format(addGlyphsWithSameFormat, drawables, std::move(strike));
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
}
void GrTextBlob::processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void GrTextBlob::processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
SkScalar strikeToSourceScale) {
fSubRunList.append(PathSubRun::Make(
drawables, has_some_antialiasing(runFont), strikeToSourceScale, &fAlloc));
accepted, has_some_antialiasing(runFont), strikeToSourceScale, &fAlloc));
}
void GrTextBlob::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void GrTextBlob::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) {
fSubRunList.append(
SDFTSubRun::Make(
this, drawables, runFont, std::move(strike), strikeToSourceScale, matrixRange,&fAlloc));
fSubRunList.append(SDFTSubRun::Make(
this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc));
}
void GrTextBlob::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void GrTextBlob::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& drawable,
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& accepted,
GrMaskFormat format,
sk_sp<SkStrike>&& runStrike) {
GrSubRunOwner subRun = TransformedMaskSubRun::Make(
this, drawable, std::move(runStrike), strikeToSourceScale, format, &fAlloc);
this, accepted, std::move(runStrike), strikeToSourceScale, format, &fAlloc);
if (subRun != nullptr) {
fSubRunList.append(std::move(subRun));
} else {
fSomeGlyphsExcluded = true;
}
};
add_multi_mask_format(addGlyphsWithSameFormat, drawables, std::move(strike));
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
}
// ----------------------------- Begin no cache implementation -------------------------------------
@ -1865,7 +1864,7 @@ public:
SkSpan<const DevicePosition> devicePositions,
GlyphVector&& glyphs);
static GrAtlasSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
static GrAtlasSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
GrMaskFormat format,
bool supportBilerpAtlas,
@ -1922,15 +1921,15 @@ DirectMaskSubRunNoCache::DirectMaskSubRunNoCache(GrMaskFormat format,
, fLeftTopDevicePos{devicePositions}
, fGlyphs{std::move(glyphs)} { }
GrAtlasSubRunOwner DirectMaskSubRunNoCache::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
GrAtlasSubRunOwner DirectMaskSubRunNoCache::Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
GrMaskFormat format,
bool supportBilerpAtlas,
GrSubRunAllocator* alloc) {
DevicePosition* glyphLeftTop = alloc->makePODArray<DevicePosition>(drawables.size());
DevicePosition* glyphLeftTop = alloc->makePODArray<DevicePosition>(accepted.size());
GlyphVector::Variant* glyphIDs = static_cast<GlyphVector::Variant*>(
alloc->alignedBytes(drawables.size() * sizeof(GlyphVector::Variant),
alloc->alignedBytes(accepted.size() * sizeof(GlyphVector::Variant),
alignof(GlyphVector::Variant)));
// Because this is the direct case, the maximum width or height is the size that fits in the
@ -1940,7 +1939,7 @@ GrAtlasSubRunOwner DirectMaskSubRunNoCache::Make(const SkZip<SkGlyphVariant, SkP
std::numeric_limits<int16_t>::max() - SkStrikeCommon::kSkSideTooBigForAtlas;
SkGlyphRect runBounds = skglyph::empty_rect();
size_t goodPosCount = 0;
for (auto [variant, pos] : drawables) {
for (auto [variant, pos] : accepted) {
auto [x, y] = pos;
// Ensure that the .offset() call below does not overflow. And, at this point none of the
// rectangles are empty because they were culled before the run was created. Basically,
@ -2117,7 +2116,7 @@ public:
SkSpan<const VertexData> vertexData,
GlyphVector&& glyphs);
static GrAtlasSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
static GrAtlasSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
GrMaskFormat format,
@ -2173,14 +2172,14 @@ TransformedMaskSubRunNoCache::TransformedMaskSubRunNoCache(GrMaskFormat format,
, fGlyphs{std::move(glyphs)} {}
GrAtlasSubRunOwner TransformedMaskSubRunNoCache::Make(
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
GrMaskFormat format,
GrSubRunAllocator* alloc) {
SkRect bounds = SkRectPriv::MakeLargestInverted();
auto initializer = [&](auto drawable) {
auto [variant, pos] = drawable;
auto initializer = [&](auto acceptedGlyph) {
auto [variant, pos] = acceptedGlyph;
SkGlyph* skGlyph = variant;
int16_t l = skGlyph->left(),
t = skGlyph->top(),
@ -2193,11 +2192,11 @@ GrAtlasSubRunOwner TransformedMaskSubRunNoCache::Make(
return VertexData{pos, {l, t, r, b}};
};
SkSpan<VertexData> vertexData = alloc->makePODArray<VertexData>(drawables, initializer);
SkSpan<VertexData> vertexData = alloc->makePODArray<VertexData>(accepted, initializer);
return alloc->makeUnique<TransformedMaskSubRunNoCache>(
format, strikeToSourceScale, bounds, vertexData,
GlyphVector::Make(std::move(strike), drawables.get<0>(), alloc));
GlyphVector::Make(std::move(strike), accepted.get<0>(), alloc));
}
std::tuple<const GrClip*, GrOp::Owner>
@ -2293,7 +2292,7 @@ public:
bool useLCDText,
bool antiAliased);
static GrAtlasSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
static GrAtlasSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
@ -2361,15 +2360,15 @@ SDFTSubRunNoCache::SDFTSubRunNoCache(GrMaskFormat format,
GrAtlasSubRunOwner SDFTSubRunNoCache::Make(
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
GrSubRunAllocator* alloc) {
SkRect bounds = SkRectPriv::MakeLargestInverted();
auto initializer = [&](auto drawable) {
auto [variant, pos] = drawable;
auto initializer = [&](auto acceptedGlyph) {
auto [variant, pos] = acceptedGlyph;
SkGlyph* skGlyph = variant;
int16_t l = skGlyph->left(),
t = skGlyph->top(),
@ -2382,14 +2381,14 @@ GrAtlasSubRunOwner SDFTSubRunNoCache::Make(
return VertexData{pos, {l, t, r, b}};
};
SkSpan<VertexData> vertexData = alloc->makePODArray<VertexData>(drawables, initializer);
SkSpan<VertexData> vertexData = alloc->makePODArray<VertexData>(accepted, initializer);
return alloc->makeUnique<SDFTSubRunNoCache>(
kA8_GrMaskFormat,
strikeToSourceScale,
bounds,
vertexData,
GlyphVector::Make(std::move(strike), drawables.get<0>(), alloc),
GlyphVector::Make(std::move(strike), accepted.get<0>(), alloc),
runFont.getEdging() == SkFont::Edging::kSubpixelAntiAlias,
has_some_antialiasing(runFont));
}
@ -2497,36 +2496,36 @@ GrSubRunNoCachePainter::GrSubRunNoCachePainter(SkCanvas* canvas,
, fPaint {paint} {}
void GrSubRunNoCachePainter::processDeviceMasks(
const SkZip<SkGlyphVariant, SkPoint>& drawables, sk_sp<SkStrike>&& strike) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& drawable,
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& accepted,
GrMaskFormat format,
sk_sp<SkStrike>&& runStrike) {
const bool padAtlas =
fSDC->recordingContext()->priv().options().fSupportBilerpFromGlyphAtlas;
this->draw(DirectMaskSubRunNoCache::Make(
drawable, std::move(runStrike), format, padAtlas, fAlloc));
accepted, std::move(runStrike), format, padAtlas, fAlloc));
};
add_multi_mask_format(addGlyphsWithSameFormat, drawables, std::move(strike));
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
}
void GrSubRunNoCachePainter::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void GrSubRunNoCachePainter::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& drawable,
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& accepted,
GrMaskFormat format,
sk_sp<SkStrike>&& runStrike) {
this->draw(TransformedMaskSubRunNoCache::Make(
drawable, std::move(runStrike), strikeToSourceScale, format, fAlloc));
accepted, std::move(runStrike), strikeToSourceScale, format, fAlloc));
};
add_multi_mask_format(addGlyphsWithSameFormat, drawables, std::move(strike));
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
}
void GrSubRunNoCachePainter::processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void GrSubRunNoCachePainter::processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
SkScalar strikeToSourceScale) {
PathOpSubmitter pathDrawing =
PathOpSubmitter::Make(drawables,
PathOpSubmitter::Make(accepted,
has_some_antialiasing(runFont),
strikeToSourceScale,
fAlloc);
@ -2534,16 +2533,16 @@ void GrSubRunNoCachePainter::processSourcePaths(const SkZip<SkGlyphVariant, SkPo
pathDrawing.submitOps(fCanvas, fClip, fViewMatrix, fGlyphRunList.origin(), fPaint, fSDC);
}
void GrSubRunNoCachePainter::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void GrSubRunNoCachePainter::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const SkFont& runFont,
const GrSDFTMatrixRange&) {
if (drawables.empty()) {
if (accepted.empty()) {
return;
}
this->draw(SDFTSubRunNoCache::Make(
drawables, runFont, std::move(strike), strikeToSourceScale, fAlloc));
accepted, runFont, std::move(strike), strikeToSourceScale, fAlloc));
}
void GrSubRunNoCachePainter::draw(GrAtlasSubRunOwner subRun) {
@ -2584,15 +2583,15 @@ public:
// SkGlyphRunPainterInterface
void processDeviceMasks(
const SkZip<SkGlyphVariant, SkPoint>& drawables, sk_sp<SkStrike>&& strike) override;
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike) override;
void processSourceMasks(
const SkZip<SkGlyphVariant, SkPoint>& drawables, sk_sp<SkStrike>&& strike,
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) override;
void processSourcePaths(
const SkZip<SkGlyphVariant, SkPoint>& drawables, const SkFont& runFont,
const SkZip<SkGlyphVariant, SkPoint>& accepted, const SkFont& runFont,
SkScalar strikeToSourceScale) override;
void processSourceSDFT(
const SkZip<SkGlyphVariant, SkPoint>& drawables, sk_sp<SkStrike>&& strike,
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale, const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) override;
@ -2646,7 +2645,7 @@ public:
GlyphVector&& glyphs);
static GrSubRunOwner Make(Slug* slug,
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
GrMaskFormat format,
GrSubRunAllocator* alloc);
@ -2716,14 +2715,14 @@ DirectMaskSubRunSlug::DirectMaskSubRunSlug(Slug* slug,
, fGlyphs{std::move(glyphs)} { }
GrSubRunOwner DirectMaskSubRunSlug::Make(Slug* slug,
const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
GrMaskFormat format,
GrSubRunAllocator* alloc) {
DevicePosition* glyphLeftTop = alloc->makePODArray<DevicePosition>(drawables.size());
DevicePosition* glyphLeftTop = alloc->makePODArray<DevicePosition>(accepted.size());
GlyphVector::Variant* glyphIDs = static_cast<GlyphVector::Variant*>(
alloc->alignedBytes(drawables.size() * sizeof(GlyphVector::Variant),
alloc->alignedBytes(accepted.size() * sizeof(GlyphVector::Variant),
alignof(GlyphVector::Variant)));
// Because this is the direct case, the maximum width or height is the size that fits in the
@ -2733,7 +2732,7 @@ GrSubRunOwner DirectMaskSubRunSlug::Make(Slug* slug,
std::numeric_limits<int16_t>::max() - SkStrikeCommon::kSkSideTooBigForAtlas;
SkGlyphRect runBounds = skglyph::empty_rect();
size_t goodPosCount = 0;
for (auto [variant, pos] : drawables) {
for (auto [variant, pos] : accepted) {
auto [x, y] = pos;
// Ensure that the .offset() call below does not overflow. And, at this point none of the
// rectangles are empty because they were culled before the run was created. Basically,
@ -3005,18 +3004,18 @@ DirectMaskSubRunSlug::deviceRectAndCheckTransform(const SkMatrix& positionMatrix
}
void Slug::processDeviceMasks(
const SkZip<SkGlyphVariant, SkPoint>& drawables, sk_sp<SkStrike>&& strike) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& drawable,
const SkZip<SkGlyphVariant, SkPoint>& accepted, sk_sp<SkStrike>&& strike) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& accepted,
GrMaskFormat format,
sk_sp<SkStrike>&& runStrike) {
GrSubRunOwner subRun = DirectMaskSubRunSlug::Make(
this, drawable, std::move(runStrike), format, &fAlloc);
this, accepted, std::move(runStrike), format, &fAlloc);
if (subRun != nullptr) {
fSubRuns.append(std::move(subRun));
}
};
add_multi_mask_format(addGlyphsWithSameFormat, drawables, std::move(strike));
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
}
sk_sp<Slug> Slug::Make(const SkMatrixProvider& viewMatrix,
@ -3066,37 +3065,37 @@ sk_sp<Slug> Slug::Make(const SkMatrixProvider& viewMatrix,
}
void Slug::processSourcePaths(const SkZip<SkGlyphVariant,
SkPoint>& drawables,
SkPoint>& accepted,
const SkFont& runFont,
SkScalar strikeToSourceScale) {
fSubRuns.append(PathSubRun::Make(
drawables, has_some_antialiasing(runFont), strikeToSourceScale, &fAlloc));
accepted, has_some_antialiasing(runFont), strikeToSourceScale, &fAlloc));
}
void Slug::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void Slug::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) {
fSubRuns.append(SDFTSubRun::Make(
this, drawables, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc));
this, accepted, runFont, std::move(strike), strikeToSourceScale, matrixRange, &fAlloc));
}
void Slug::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void Slug::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) {
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& drawable,
auto addGlyphsWithSameFormat = [&] (const SkZip<SkGlyphVariant, SkPoint>& accepted,
GrMaskFormat format,
sk_sp<SkStrike>&& runStrike) {
GrSubRunOwner subRun = TransformedMaskSubRun::Make(
this, drawable, std::move(runStrike), strikeToSourceScale, format, &fAlloc);
this, accepted, std::move(runStrike), strikeToSourceScale, format, &fAlloc);
if (subRun != nullptr) {
fSubRuns.append(std::move(subRun));
}
};
add_multi_mask_format(addGlyphsWithSameFormat, drawables, std::move(strike));
add_multi_mask_format(addGlyphsWithSameFormat, accepted, std::move(strike));
}
} // namespace

View File

@ -244,17 +244,17 @@ private:
SkColor initialLuminance);
// Methods to satisfy SkGlyphRunPainterInterface
void processDeviceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void processDeviceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike) override;
void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
SkScalar strikeToSourceScale) override;
void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const SkFont& runFont,
const GrSDFTMatrixRange& matrixRange) override;
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) override;
@ -291,15 +291,15 @@ public:
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList&,
const SkPaint&);
void processDeviceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void processDeviceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike) override;
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale) override;
void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& accepted,
const SkFont& runFont,
SkScalar strikeToSourceScale) override;
void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& accepted,
sk_sp<SkStrike>&& strike,
SkScalar strikeToSourceScale,
const SkFont& runFont,

View File

@ -158,22 +158,22 @@ DEF_TEST(SkDrawableGlyphBufferBasic, reporter) {
auto source = SkMakeZip(glyphIDs, positions);
{
SkDrawableGlyphBuffer drawable;
drawable.ensureSize(100);
drawable.startSource(source);
for (auto [i, packedID, pos] : SkMakeEnumerate(drawable.input())) {
SkDrawableGlyphBuffer accepted;
accepted.ensureSize(100);
accepted.startSource(source);
for (auto [i, packedID, pos] : SkMakeEnumerate(accepted.input())) {
REPORTER_ASSERT(reporter, packedID.packedID().glyphID() == glyphIDs[i]);
REPORTER_ASSERT(reporter, pos == positions[i]);
}
}
{
SkDrawableGlyphBuffer drawable;
drawable.ensureSize(100);
SkDrawableGlyphBuffer accepted;
accepted.ensureSize(100);
SkMatrix matrix = SkMatrix::Scale(0.5, 0.5);
SkGlyphPositionRoundingSpec rounding{true, kX_SkAxisAlignment};
drawable.startBitmapDevice(source, {100, 100}, matrix, rounding);
for (auto [i, packedID, pos] : SkMakeEnumerate(drawable.input())) {
accepted.startBitmapDevice(source, {100, 100}, matrix, rounding);
for (auto [i, packedID, pos] : SkMakeEnumerate(accepted.input())) {
REPORTER_ASSERT(reporter, glyphIDs[i] == packedID.packedID().glyphID());
REPORTER_ASSERT(reporter,
pos.x() == positions[i].x() * 0.5 + 50 + SkPackedGlyphID::kSubpixelRound);
@ -182,13 +182,13 @@ DEF_TEST(SkDrawableGlyphBufferBasic, reporter) {
}
{
SkDrawableGlyphBuffer drawable;
drawable.ensureSize(100);
drawable.startSource(source);
for (auto [i, packedID, pos] : SkMakeEnumerate(drawable.input())) {
drawable.push_back(&glyphs[i], i);
SkDrawableGlyphBuffer accepted;
accepted.ensureSize(100);
accepted.startSource(source);
for (auto [i, packedID, pos] : SkMakeEnumerate(accepted.input())) {
accepted.accept(&glyphs[i], i);
}
for (auto [i, glyph, pos] : SkMakeEnumerate(drawable.drawable())) {
for (auto [i, glyph, pos] : SkMakeEnumerate(accepted.accepted())) {
REPORTER_ASSERT(reporter, glyph.glyph() == &glyphs[i]);
}
}

View File

@ -63,17 +63,17 @@ DEF_TEST(SkScalerCacheMultiThread, Reporter) {
auto local = data.subspan(threadIndex * 2, data.size() - kThreadCount * 2);
for (int i = 0; i < 100; i++) {
SkDrawableGlyphBuffer drawable;
SkSourceGlyphBuffer rejects;
SkDrawableGlyphBuffer accepted;
SkSourceGlyphBuffer rejected;
drawable.ensureSize(glyphCount);
rejects.setSource(local);
accepted.ensureSize(glyphCount);
rejected.setSource(local);
drawable.startBitmapDevice(rejects.source(), {0, 0}, SkMatrix::I(),
accepted.startBitmapDevice(rejected.source(), {0, 0}, SkMatrix::I(),
scalerCache.roundingSpec());
scalerCache.prepareForMaskDrawing(&drawable, &rejects);
rejects.flipRejectsToSource();
drawable.reset();
scalerCache.prepareForMaskDrawing(&accepted, &rejected);
rejected.flipRejectsToSource();
accepted.reset();
}
};