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( void prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) override; SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override;
void prepareForSDFTDrawing( void prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) override; SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override;
void prepareForPathDrawing( void prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) override; SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) override;
void onAboutToExitScope() override {} void onAboutToExitScope() override {}
@ -258,7 +258,7 @@ public:
private: private:
template <typename Rejector> template <typename Rejector>
void commonMaskLoop( void commonMaskLoop(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects, Rejector&& reject); SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected, Rejector&& reject);
// Same thing as MaskSummary, but for paths. // Same thing as MaskSummary, but for paths.
struct PathSummary { struct PathSummary {
@ -414,8 +414,8 @@ void RemoteStrike::writeGlyphPath(
template <typename Rejector> template <typename Rejector>
void RemoteStrike::commonMaskLoop( void RemoteStrike::commonMaskLoop(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects, Rejector&& reject) { SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected, Rejector&& reject) {
drawables->forEachGlyphID( accepted->forEachInput(
[&](size_t i, SkPackedGlyphID packedID, SkPoint position) { [&](size_t i, SkPackedGlyphID packedID, SkPoint position) {
SkGlyphDigest* digest = fSentGlyphs.find(packedID.value()); SkGlyphDigest* digest = fSentGlyphs.find(packedID.value());
if (digest == nullptr) { if (digest == nullptr) {
@ -430,14 +430,14 @@ void RemoteStrike::commonMaskLoop(
// Reject things that are too big. // Reject things that are too big.
if (reject(*digest)) { if (reject(*digest)) {
rejects->reject(i); rejected->reject(i);
} }
}); });
} }
void RemoteStrike::prepareForMaskDrawing( void RemoteStrike::prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) { SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
for (auto [i, variant, _] : SkMakeEnumerate(drawables->input())) { for (auto [i, variant, _] : SkMakeEnumerate(accepted->input())) {
SkPackedGlyphID packedID = variant.packedID(); SkPackedGlyphID packedID = variant.packedID();
if (fSentLowGlyphIDs.test(packedID)) { if (fSentLowGlyphIDs.test(packedID)) {
#ifdef SK_DEBUG #ifdef SK_DEBUG
@ -468,20 +468,20 @@ void RemoteStrike::prepareForMaskDrawing(
// Reject things that are too big. // Reject things that are too big.
// N.B. this must have the same behavior as SkScalerCache::prepareForMaskDrawing. // N.B. this must have the same behavior as SkScalerCache::prepareForMaskDrawing.
if (!digest->canDrawAsMask()) { if (!digest->canDrawAsMask()) {
rejects->reject(i, digest->maxDimension()); rejected->reject(i, digest->maxDimension());
} }
} }
} }
void RemoteStrike::prepareForSDFTDrawing( void RemoteStrike::prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) { SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
this->commonMaskLoop(drawables, rejects, this->commonMaskLoop(accepted, rejected,
[](SkGlyphDigest digest){return !digest.canDrawAsSDFT();}); [](SkGlyphDigest digest){return !digest.canDrawAsSDFT();});
} }
void RemoteStrike::prepareForPathDrawing( void RemoteStrike::prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) { SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
drawables->forEachGlyphID( accepted->forEachInput(
[&](size_t i, SkPackedGlyphID packedID, SkPoint position) { [&](size_t i, SkPackedGlyphID packedID, SkPoint position) {
PathSummary* summary = fSentPaths.find(packedID); PathSummary* summary = fSentPaths.find(packedID);
if (summary == nullptr) { if (summary == nullptr) {
@ -502,7 +502,7 @@ void RemoteStrike::prepareForPathDrawing(
} }
if (summary->maxDimensionOrPath != PathSummary::kIsPath) { 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); 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, static bool ComputeMaskBounds(const SkRect& devPathBounds, const SkIRect* clipBounds,
const SkMaskFilter* filter, const SkMatrix* filterMatrix, 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*/))); 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. // The size used for a typical blitter.
SkSTArenaAlloc<3308> alloc; SkSTArenaAlloc<3308> alloc;
@ -48,7 +48,7 @@ void SkDraw::paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint)
bool useRegion = fRC->isBW() && !fRC->isRect(); bool useRegion = fRC->isBW() && !fRC->isRect();
if (useRegion) { if (useRegion) {
for (auto [variant, pos] : drawables->drawable()) { for (auto [variant, pos] : accepted->accepted()) {
SkGlyph* glyph = variant.glyph(); SkGlyph* glyph = variant.glyph();
if (check_glyph_position(pos)) { if (check_glyph_position(pos)) {
SkMask mask = glyph->mask(pos); SkMask mask = glyph->mask(pos);
@ -75,7 +75,7 @@ void SkDraw::paintMasks(SkDrawableGlyphBuffer* drawables, const SkPaint& paint)
} else { } else {
SkIRect clipBounds = fRC->isBW() ? fRC->bwRgn().getBounds() SkIRect clipBounds = fRC->isBW() ? fRC->bwRgn().getBounds()
: fRC->aaRgn().getBounds(); : fRC->aaRgn().getBounds();
for (auto [variant, pos] : drawables->drawable()) { for (auto [variant, pos] : accepted->accepted()) {
SkGlyph* glyph = variant.glyph(); SkGlyph* glyph = variant.glyph();
if (check_glyph_position(pos)) { if (check_glyph_position(pos)) {
SkMask mask = glyph->mask(pos); SkMask mask = glyph->mask(pos);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -164,9 +164,9 @@ std::tuple<SkSpan<const SkGlyph*>, size_t> SkScalerCache::prepareImages(
} }
template <typename Fn> template <typename Fn>
size_t SkScalerCache::commonFilterLoop(SkDrawableGlyphBuffer* drawables, Fn&& fn) { size_t SkScalerCache::commonFilterLoop(SkDrawableGlyphBuffer* accepted, Fn&& fn) {
size_t total = 0; 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())) { if (SkScalarsAreFinite(pos.x(), pos.y())) {
auto [digest, size] = this->digest(packedID); auto [digest, size] = this->digest(packedID);
total += size; total += size;
@ -178,16 +178,16 @@ size_t SkScalerCache::commonFilterLoop(SkDrawableGlyphBuffer* drawables, Fn&& fn
return total; return total;
} }
size_t SkScalerCache::prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* drawables) { size_t SkScalerCache::prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* accepted) {
SkAutoMutexExclusive lock{fMu}; SkAutoMutexExclusive lock{fMu};
size_t imageDelta = 0; 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) { [&](size_t i, SkGlyphDigest digest, SkPoint pos) SK_REQUIRES(fMu) {
// If the glyph is too large, then no image is created. // If the glyph is too large, then no image is created.
SkGlyph* glyph = fGlyphForIndex[digest.index()]; SkGlyph* glyph = fGlyphForIndex[digest.index()];
auto [image, imageSize] = this->prepareImage(glyph); auto [image, imageSize] = this->prepareImage(glyph);
if (image != nullptr) { if (image != nullptr) {
drawables->push_back(glyph, i); accepted->accept(glyph, i);
imageDelta += imageSize; 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. // Note: this does not actually fill out the image. That happens at atlas building time.
size_t SkScalerCache::prepareForMaskDrawing( size_t SkScalerCache::prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) { SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
SkAutoMutexExclusive lock{fMu}; 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) { [&](size_t i, SkGlyphDigest digest, SkPoint pos) SK_REQUIRES(fMu) {
// N.B. this must have the same behavior as RemoteStrike::prepareForMaskDrawing. // N.B. this must have the same behavior as RemoteStrike::prepareForMaskDrawing.
if (digest.canDrawAsMask()) { if (digest.canDrawAsMask()) {
drawables->push_back(fGlyphForIndex[digest.index()], i); accepted->accept(fGlyphForIndex[digest.index()], i);
} else { } else {
rejects->reject(i, digest.maxDimension()); rejected->reject(i, digest.maxDimension());
} }
}); });
@ -213,15 +213,15 @@ size_t SkScalerCache::prepareForMaskDrawing(
} }
size_t SkScalerCache::prepareForSDFTDrawing( size_t SkScalerCache::prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) { SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
SkAutoMutexExclusive lock{fMu}; 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) { [&](size_t i, SkGlyphDigest digest, SkPoint pos) SK_REQUIRES(fMu) {
if (digest.canDrawAsSDFT()) { if (digest.canDrawAsSDFT()) {
drawables->push_back(fGlyphForIndex[digest.index()], i); accepted->accept(fGlyphForIndex[digest.index()], i);
} else { } else {
// Assume whatever follows SDF doesn't care about the maximum rejected size. // 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( size_t SkScalerCache::prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) { SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) {
SkAutoMutexExclusive lock{fMu}; SkAutoMutexExclusive lock{fMu};
size_t pathDelta = 0; 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) { [&](size_t i, SkGlyphDigest digest, SkPoint pos) SK_REQUIRES(fMu) {
SkGlyph* glyph = fGlyphForIndex[digest.index()]; SkGlyph* glyph = fGlyphForIndex[digest.index()];
auto [path, pathSize] = this->preparePath(glyph); auto [path, pathSize] = this->preparePath(glyph);
pathDelta += pathSize; pathDelta += pathSize;
if (path != nullptr) { if (path != nullptr) {
// Save off the path to draw later. // Save off the path to draw later.
drawables->push_back(path, i); accepted->accept(path, i);
} else { } else {
// Glyph does not have a path. // 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( std::tuple<SkSpan<const SkGlyph*>, size_t> prepareImages(
SkSpan<const SkPackedGlyphID> glyphIDs, const SkGlyph* results[]) SK_EXCLUDES(fMu); 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 // SkStrikeForGPU APIs
const SkGlyphPositionRoundingSpec& roundingSpec() const { const SkGlyphPositionRoundingSpec& roundingSpec() const {
@ -69,13 +69,13 @@ public:
} }
size_t prepareForMaskDrawing( size_t prepareForMaskDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) SK_EXCLUDES(fMu); SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
size_t prepareForSDFTDrawing( size_t prepareForSDFTDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) SK_EXCLUDES(fMu); SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
size_t prepareForPathDrawing( size_t prepareForPathDrawing(
SkDrawableGlyphBuffer* drawables, SkSourceGlyphBuffer* rejects) SK_EXCLUDES(fMu); SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
void dump() const SK_EXCLUDES(fMu); void dump() const SK_EXCLUDES(fMu);
@ -83,7 +83,7 @@ public:
private: private:
template <typename Fn> 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 // Return a glyph. Create it if it doesn't exist, and initialize the glyph with metrics and
// advances using a scaler. // advances using a scaler.

View File

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

View File

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

View File

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

View File

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

View File

@ -158,22 +158,22 @@ DEF_TEST(SkDrawableGlyphBufferBasic, reporter) {
auto source = SkMakeZip(glyphIDs, positions); auto source = SkMakeZip(glyphIDs, positions);
{ {
SkDrawableGlyphBuffer drawable; SkDrawableGlyphBuffer accepted;
drawable.ensureSize(100); accepted.ensureSize(100);
drawable.startSource(source); accepted.startSource(source);
for (auto [i, packedID, pos] : SkMakeEnumerate(drawable.input())) { for (auto [i, packedID, pos] : SkMakeEnumerate(accepted.input())) {
REPORTER_ASSERT(reporter, packedID.packedID().glyphID() == glyphIDs[i]); REPORTER_ASSERT(reporter, packedID.packedID().glyphID() == glyphIDs[i]);
REPORTER_ASSERT(reporter, pos == positions[i]); REPORTER_ASSERT(reporter, pos == positions[i]);
} }
} }
{ {
SkDrawableGlyphBuffer drawable; SkDrawableGlyphBuffer accepted;
drawable.ensureSize(100); accepted.ensureSize(100);
SkMatrix matrix = SkMatrix::Scale(0.5, 0.5); SkMatrix matrix = SkMatrix::Scale(0.5, 0.5);
SkGlyphPositionRoundingSpec rounding{true, kX_SkAxisAlignment}; SkGlyphPositionRoundingSpec rounding{true, kX_SkAxisAlignment};
drawable.startBitmapDevice(source, {100, 100}, matrix, rounding); accepted.startBitmapDevice(source, {100, 100}, matrix, rounding);
for (auto [i, packedID, pos] : SkMakeEnumerate(drawable.input())) { for (auto [i, packedID, pos] : SkMakeEnumerate(accepted.input())) {
REPORTER_ASSERT(reporter, glyphIDs[i] == packedID.packedID().glyphID()); REPORTER_ASSERT(reporter, glyphIDs[i] == packedID.packedID().glyphID());
REPORTER_ASSERT(reporter, REPORTER_ASSERT(reporter,
pos.x() == positions[i].x() * 0.5 + 50 + SkPackedGlyphID::kSubpixelRound); pos.x() == positions[i].x() * 0.5 + 50 + SkPackedGlyphID::kSubpixelRound);
@ -182,13 +182,13 @@ DEF_TEST(SkDrawableGlyphBufferBasic, reporter) {
} }
{ {
SkDrawableGlyphBuffer drawable; SkDrawableGlyphBuffer accepted;
drawable.ensureSize(100); accepted.ensureSize(100);
drawable.startSource(source); accepted.startSource(source);
for (auto [i, packedID, pos] : SkMakeEnumerate(drawable.input())) { for (auto [i, packedID, pos] : SkMakeEnumerate(accepted.input())) {
drawable.push_back(&glyphs[i], i); 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]); 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); auto local = data.subspan(threadIndex * 2, data.size() - kThreadCount * 2);
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
SkDrawableGlyphBuffer drawable; SkDrawableGlyphBuffer accepted;
SkSourceGlyphBuffer rejects; SkSourceGlyphBuffer rejected;
drawable.ensureSize(glyphCount); accepted.ensureSize(glyphCount);
rejects.setSource(local); rejected.setSource(local);
drawable.startBitmapDevice(rejects.source(), {0, 0}, SkMatrix::I(), accepted.startBitmapDevice(rejected.source(), {0, 0}, SkMatrix::I(),
scalerCache.roundingSpec()); scalerCache.roundingSpec());
scalerCache.prepareForMaskDrawing(&drawable, &rejects); scalerCache.prepareForMaskDrawing(&accepted, &rejected);
rejects.flipRejectsToSource(); rejected.flipRejectsToSource();
drawable.reset(); accepted.reset();
} }
}; };