prepare to combine SDFTSubRun with SDFTSubRunSlug
* use GrTextReferenceFrame instead of blob * use TransformedMaskVertexFiller * remove mask field - this was always A8 Change-Id: I645a68658c4f873301db51987739e9138f8d4822 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/502780 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
074a016b89
commit
eb50c2e30c
@ -1236,11 +1236,11 @@ void TransformedMaskSubRun::fillVertexData(void* vertexDst, int offset, int coun
|
||||
SkIRect clip) const {
|
||||
const SkMatrix positionMatrix = position_matrix(drawMatrix, drawOrigin);
|
||||
fVertexFiller.fillVertexData(fGlyphs.glyphs().subspan(offset, count),
|
||||
fVertexData.subspan(offset, count),
|
||||
color,
|
||||
positionMatrix,
|
||||
clip,
|
||||
vertexDst);
|
||||
fVertexData.subspan(offset, count),
|
||||
color,
|
||||
positionMatrix,
|
||||
clip,
|
||||
vertexDst);
|
||||
}
|
||||
|
||||
size_t TransformedMaskSubRun::vertexStride(const SkMatrix& drawMatrix) const {
|
||||
@ -1264,14 +1264,9 @@ const GrAtlasSubRun* TransformedMaskSubRun::testingOnly_atlasSubRun() const {
|
||||
// -- SDFTSubRun -----------------------------------------------------------------------------------
|
||||
class SDFTSubRun final : public GrSubRun, public GrBlobSubRun, public GrAtlasSubRun {
|
||||
public:
|
||||
struct VertexData {
|
||||
const SkPoint pos;
|
||||
// The rectangle of the glyphs in strike space.
|
||||
GrIRect16 rect;
|
||||
};
|
||||
using VertexData = TransformedMaskVertexFiller::PositionAndExtent;
|
||||
|
||||
SDFTSubRun(GrMaskFormat format,
|
||||
GrTextBlob* blob,
|
||||
SDFTSubRun(GrTextReferenceFrame* referenceFrame,
|
||||
SkScalar strikeToSource,
|
||||
SkRect vertexBounds,
|
||||
SkSpan<const VertexData> vertexData,
|
||||
@ -1280,12 +1275,12 @@ public:
|
||||
bool antiAliased,
|
||||
const GrSDFTMatrixRange& matrixRange);
|
||||
|
||||
static GrSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
static GrSubRunOwner Make(GrTextReferenceFrame* referenceFrame,
|
||||
const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkFont& runFont,
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale,
|
||||
const GrSDFTMatrixRange& matrixRange,
|
||||
GrTextBlob* blob,
|
||||
GrSubRunAllocator* alloc);
|
||||
|
||||
void draw(SkCanvas*,
|
||||
@ -1325,11 +1320,9 @@ private:
|
||||
// The rectangle that surrounds all the glyph bounding boxes in device space.
|
||||
SkRect deviceRect(const SkMatrix& drawMatrix, SkPoint drawOrigin) const;
|
||||
|
||||
const GrMaskFormat fMaskFormat;
|
||||
GrTextBlob* fBlob;
|
||||
GrTextReferenceFrame* const fReferenceFrame;
|
||||
|
||||
// The scale factor between the strike size, and the source size.
|
||||
const SkScalar fStrikeToSourceScale;
|
||||
const TransformedMaskVertexFiller fVertexFiller;
|
||||
|
||||
// The bounds in source space. The bounds are the joined rectangles of all the glyphs.
|
||||
const SkRect fVertexBounds;
|
||||
@ -1344,8 +1337,7 @@ private:
|
||||
const GrSDFTMatrixRange fMatrixRange;
|
||||
};
|
||||
|
||||
SDFTSubRun::SDFTSubRun(GrMaskFormat format,
|
||||
GrTextBlob* textBlob,
|
||||
SDFTSubRun::SDFTSubRun(GrTextReferenceFrame* referenceFrame,
|
||||
SkScalar strikeToSource,
|
||||
SkRect vertexBounds,
|
||||
SkSpan<const VertexData> vertexData,
|
||||
@ -1353,9 +1345,8 @@ SDFTSubRun::SDFTSubRun(GrMaskFormat format,
|
||||
bool useLCDText,
|
||||
bool antiAliased,
|
||||
const GrSDFTMatrixRange& matrixRange)
|
||||
: fMaskFormat{format}
|
||||
, fBlob{textBlob}
|
||||
, fStrikeToSourceScale{strikeToSource}
|
||||
: fReferenceFrame{referenceFrame}
|
||||
, fVertexFiller{kA8_GrMaskFormat, SK_DistanceFieldInset, strikeToSource}
|
||||
, fVertexBounds{vertexBounds}
|
||||
, fVertexData{vertexData}
|
||||
, fGlyphs{std::move(glyphs)}
|
||||
@ -1369,12 +1360,12 @@ bool has_some_antialiasing(const SkFont& font ) {
|
||||
|| edging == SkFont::Edging::kSubpixelAntiAlias;
|
||||
}
|
||||
|
||||
GrSubRunOwner SDFTSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
GrSubRunOwner SDFTSubRun::Make(GrTextReferenceFrame* referenceFrame,
|
||||
const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkFont& runFont,
|
||||
sk_sp<SkStrike>&& strike,
|
||||
SkScalar strikeToSourceScale,
|
||||
const GrSDFTMatrixRange& matrixRange,
|
||||
GrTextBlob* blob,
|
||||
GrSubRunAllocator* alloc) {
|
||||
SkRect bounds = SkRectPriv::MakeLargestInverted();
|
||||
auto mapper = [&](const auto& d) {
|
||||
@ -1394,8 +1385,7 @@ GrSubRunOwner SDFTSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
SkSpan<VertexData> vertexData = alloc->makePODArray<VertexData>(drawables, mapper);
|
||||
|
||||
return alloc->makeUnique<SDFTSubRun>(
|
||||
kA8_GrMaskFormat,
|
||||
blob,
|
||||
referenceFrame,
|
||||
strikeToSourceScale,
|
||||
bounds,
|
||||
vertexData,
|
||||
@ -1459,7 +1449,7 @@ SDFTSubRun::makeAtlasTextOp(const GrClip* clip,
|
||||
const SkMatrix& drawMatrix = viewMatrix.localToDevice();
|
||||
|
||||
GrPaint grPaint;
|
||||
SkPMColor4f drawingColor = calculate_colors(sdc, paint, viewMatrix, fMaskFormat, &grPaint);
|
||||
SkPMColor4f drawingColor = calculate_colors(sdc, paint, viewMatrix, kA8_GrMaskFormat, &grPaint);
|
||||
|
||||
auto [maskType, DFGPFlags, useGammaCorrectDistanceTable] =
|
||||
calculate_sdf_parameters(*sdc, drawMatrix, fUseLCDText, fAntiAliased);
|
||||
@ -1468,7 +1458,7 @@ SDFTSubRun::makeAtlasTextOp(const GrClip* clip,
|
||||
drawMatrix,
|
||||
drawOrigin,
|
||||
SkIRect::MakeEmpty(),
|
||||
sk_ref_sp<GrTextBlob>(fBlob),
|
||||
sk_ref_sp(fReferenceFrame),
|
||||
drawingColor,
|
||||
sdc->arenaAlloc());
|
||||
|
||||
@ -1497,8 +1487,7 @@ void SDFTSubRun::testingOnly_packedGlyphIDToGrGlyph(GrStrikeCache *cache) const
|
||||
|
||||
std::tuple<bool, int> SDFTSubRun::regenerateAtlas(
|
||||
int begin, int end, GrMeshDrawTarget *target) const {
|
||||
|
||||
return fGlyphs.regenerateAtlas(begin, end, fMaskFormat, SK_DistanceFieldInset, target);
|
||||
return fGlyphs.regenerateAtlas(begin, end, kA8_GrMaskFormat, SK_DistanceFieldInset, target);
|
||||
}
|
||||
|
||||
size_t SDFTSubRun::vertexStride(const SkMatrix& drawMatrix) const {
|
||||
@ -1512,16 +1501,12 @@ void SDFTSubRun::fillVertexData(
|
||||
SkIRect clip) const {
|
||||
const SkMatrix positionMatrix = position_matrix(drawMatrix, drawOrigin);
|
||||
|
||||
using Quad = Mask2DVertex[4];
|
||||
SkASSERT(sizeof(Mask2DVertex) == this->vertexStride(positionMatrix));
|
||||
fill_transformed_vertices_2D(
|
||||
SkMakeZip((Quad*)vertexDst,
|
||||
fGlyphs.glyphs().subspan(offset, count),
|
||||
fVertexData.subspan(offset, count)),
|
||||
SK_DistanceFieldInset,
|
||||
fStrikeToSourceScale,
|
||||
color,
|
||||
positionMatrix);
|
||||
fVertexFiller.fillVertexData(fGlyphs.glyphs().subspan(offset, count),
|
||||
fVertexData.subspan(offset, count),
|
||||
color,
|
||||
positionMatrix,
|
||||
clip,
|
||||
vertexDst);
|
||||
}
|
||||
|
||||
int SDFTSubRun::glyphCount() const {
|
||||
@ -1847,7 +1832,7 @@ void GrTextBlob::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawabl
|
||||
const GrSDFTMatrixRange& matrixRange) {
|
||||
fSubRunList.append(
|
||||
SDFTSubRun::Make(
|
||||
drawables, runFont, std::move(strike), strikeToSourceScale, matrixRange, this,&fAlloc));
|
||||
this, drawables, runFont, std::move(strike), strikeToSourceScale, matrixRange,&fAlloc));
|
||||
}
|
||||
|
||||
void GrTextBlob::processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
|
Loading…
Reference in New Issue
Block a user