SkRunFont is gone, there is only SkFont
Bug: skia: Change-Id: I720fd5d8b3755d4f19767db4077e0f3c43167cae Reviewed-on: https://skia-review.googlesource.com/c/174850 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
7c4a9b7c7e
commit
7b7ab595d9
@ -47,7 +47,7 @@ class SkMaskFilter;
|
||||
class SkPath;
|
||||
class SkPathEffect;
|
||||
struct SkPoint;
|
||||
class SkRunFont;
|
||||
class SkFont;
|
||||
class SkShader;
|
||||
class SkSurfaceProps;
|
||||
class SkTextBlob;
|
||||
@ -1279,7 +1279,7 @@ public:
|
||||
private:
|
||||
friend class SkGlyphRun;
|
||||
friend class SkGlyphRunBuilder;
|
||||
SkPaint(const SkPaint&, const SkRunFont&);
|
||||
SkPaint(const SkPaint&, const SkFont&);
|
||||
|
||||
sk_sp<SkTypeface> fTypeface;
|
||||
sk_sp<SkPathEffect> fPathEffect;
|
||||
|
@ -29,7 +29,7 @@ static SkTypeface::Encoding convert_encoding(SkTextEncoding encoding) {
|
||||
|
||||
// -- SkGlyphRun -----------------------------------------------------------------------------------
|
||||
SkGlyphRun::SkGlyphRun(const SkPaint& basePaint,
|
||||
const SkRunFont& runFont,
|
||||
const SkFont& runFont,
|
||||
SkSpan<const SkPoint> positions,
|
||||
SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkSpan<const char> text,
|
||||
@ -52,7 +52,7 @@ void SkGlyphRun::eachGlyphToGlyphRun(SkGlyphRun::PerGlyph perGlyph) {
|
||||
SkGlyphID glyphID;
|
||||
SkGlyphRun run{
|
||||
fRunPaint,
|
||||
SkRunFont{fRunPaint},
|
||||
SkFont::LEGACY_ExtractFromPaint(fRunPaint),
|
||||
SkSpan<const SkPoint>{&point, 1},
|
||||
SkSpan<const SkGlyphID>{&glyphID, 1},
|
||||
SkSpan<const char>{},
|
||||
@ -195,7 +195,7 @@ void SkGlyphRunBuilder::drawTextAtOrigin(
|
||||
|
||||
this->makeGlyphRun(
|
||||
paint,
|
||||
SkRunFont{paint},
|
||||
SkFont::LEGACY_ExtractFromPaint(paint),
|
||||
glyphIDs,
|
||||
positions,
|
||||
SkSpan<const char>{},
|
||||
@ -208,7 +208,8 @@ void SkGlyphRunBuilder::drawText(
|
||||
auto glyphIDs = textToGlyphIDs(paint, bytes, byteLength);
|
||||
if (!glyphIDs.empty()) {
|
||||
this->initialize(glyphIDs.size());
|
||||
this->simplifyDrawText(paint, SkRunFont{paint}, glyphIDs, origin, fPositions);
|
||||
this->simplifyDrawText(paint, SkFont::LEGACY_ExtractFromPaint(paint),
|
||||
glyphIDs, origin, fPositions);
|
||||
}
|
||||
|
||||
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
|
||||
@ -221,7 +222,7 @@ void SkGlyphRunBuilder::drawPosTextH(const SkPaint& paint, const void* bytes,
|
||||
if (!glyphIDs.empty()) {
|
||||
this->initialize(glyphIDs.size());
|
||||
this->simplifyDrawPosTextH(
|
||||
paint, SkRunFont{paint}, glyphIDs, xpos, constY, fPositions);
|
||||
paint, SkFont::LEGACY_ExtractFromPaint(paint), glyphIDs, xpos, constY, fPositions);
|
||||
}
|
||||
|
||||
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
|
||||
@ -232,7 +233,7 @@ void SkGlyphRunBuilder::drawPosText(const SkPaint& paint, const void* bytes,
|
||||
auto glyphIDs = textToGlyphIDs(paint, bytes, byteLength);
|
||||
if (!glyphIDs.empty()) {
|
||||
this->initialize(glyphIDs.size());
|
||||
this->simplifyDrawPosText(paint, SkRunFont{paint}, glyphIDs, pos);
|
||||
this->simplifyDrawPosText(paint, SkFont::LEGACY_ExtractFromPaint(paint), glyphIDs, pos);
|
||||
}
|
||||
|
||||
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
|
||||
@ -263,18 +264,18 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo
|
||||
switch (it.positioning()) {
|
||||
case SkTextBlobRunIterator::kDefault_Positioning: {
|
||||
this->simplifyDrawText(
|
||||
paint, it.runFont(), glyphIDs, offset, positions, text, clusters);
|
||||
paint, it.font(), glyphIDs, offset, positions, text, clusters);
|
||||
}
|
||||
break;
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning: {
|
||||
auto constY = offset.y();
|
||||
this->simplifyDrawPosTextH(
|
||||
paint, it.runFont(), glyphIDs, it.pos(), constY, positions, text, clusters);
|
||||
paint, it.font(), glyphIDs, it.pos(), constY, positions, text, clusters);
|
||||
}
|
||||
break;
|
||||
case SkTextBlobRunIterator::kFull_Positioning:
|
||||
this->simplifyDrawPosText(
|
||||
paint, it.runFont(), glyphIDs, (const SkPoint*)it.pos(), text, clusters);
|
||||
paint, it.font(), glyphIDs, (const SkPoint*)it.pos(), text, clusters);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -288,7 +289,7 @@ void SkGlyphRunBuilder::drawGlyphPos(
|
||||
const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs, const SkPoint* pos) {
|
||||
if (!glyphIDs.empty()) {
|
||||
this->initialize(glyphIDs.size());
|
||||
this->simplifyDrawPosText(paint, SkRunFont{paint}, glyphIDs, pos);
|
||||
this->simplifyDrawPosText(paint, SkFont::LEGACY_ExtractFromPaint(paint), glyphIDs, pos);
|
||||
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
|
||||
}
|
||||
}
|
||||
@ -329,7 +330,7 @@ SkSpan<const SkGlyphID> SkGlyphRunBuilder::textToGlyphIDs(
|
||||
|
||||
void SkGlyphRunBuilder::makeGlyphRun(
|
||||
const SkPaint& basePaint,
|
||||
const SkRunFont& runFont,
|
||||
const SkFont& runFont,
|
||||
SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkSpan<const SkPoint> positions,
|
||||
SkSpan<const char> text,
|
||||
@ -356,14 +357,16 @@ void SkGlyphRunBuilder::makeGlyphRunList(
|
||||
}
|
||||
|
||||
void SkGlyphRunBuilder::simplifyDrawText(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPaint& paint, const SkFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkPoint origin, SkPoint* positions,
|
||||
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
|
||||
SkASSERT(!glyphIDs.empty());
|
||||
|
||||
auto runSize = glyphIDs.size();
|
||||
|
||||
SkPaint runPaint{paint, runFont};
|
||||
SkPaint runPaint(paint);
|
||||
runFont.LEGACY_applyToPaint(&runPaint);
|
||||
runPaint.setTextEncoding(kGlyphID_SkTextEncoding);
|
||||
|
||||
if (!glyphIDs.empty()) {
|
||||
fScratchAdvances.resize(runSize);
|
||||
@ -391,7 +394,7 @@ void SkGlyphRunBuilder::simplifyDrawText(
|
||||
}
|
||||
|
||||
void SkGlyphRunBuilder::simplifyDrawPosTextH(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPaint& paint, const SkFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkScalar* xpos, SkScalar constY, SkPoint* positions,
|
||||
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
|
||||
|
||||
@ -404,7 +407,7 @@ void SkGlyphRunBuilder::simplifyDrawPosTextH(
|
||||
}
|
||||
|
||||
void SkGlyphRunBuilder::simplifyDrawPosText(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPaint& paint, const SkFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPoint* pos,
|
||||
SkSpan<const char> text, SkSpan<const uint32_t> clusters) {
|
||||
auto runSize = glyphIDs.size();
|
||||
|
@ -17,14 +17,14 @@
|
||||
#include "SkTemplates.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
class SkFont;
|
||||
class SkGlyph;
|
||||
class SkRunFont;
|
||||
|
||||
class SkGlyphRun {
|
||||
public:
|
||||
SkGlyphRun() = default;
|
||||
SkGlyphRun(const SkPaint& basePaint,
|
||||
const SkRunFont& runFont,
|
||||
const SkFont& runFont,
|
||||
SkSpan<const SkPoint> positions,
|
||||
SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkSpan<const char> text,
|
||||
@ -137,7 +137,7 @@ private:
|
||||
|
||||
void makeGlyphRun(
|
||||
const SkPaint& basePaint,
|
||||
const SkRunFont& runFont,
|
||||
const SkFont& runFont,
|
||||
SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkSpan<const SkPoint> positions,
|
||||
SkSpan<const char> text,
|
||||
@ -146,17 +146,17 @@ private:
|
||||
void makeGlyphRunList(const SkPaint& paint, const SkTextBlob* blob, SkPoint origin);
|
||||
|
||||
void simplifyDrawText(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPaint& paint, const SkFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
SkPoint origin, SkPoint* positions,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
|
||||
void simplifyDrawPosTextH(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPaint& paint, const SkFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkScalar* xpos, SkScalar constY, SkPoint* positions,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
|
||||
void simplifyDrawPosText(
|
||||
const SkPaint& paint, const SkRunFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPaint& paint, const SkFont& runFont, SkSpan<const SkGlyphID> glyphIDs,
|
||||
const SkPoint* pos,
|
||||
SkSpan<const char> text = SkSpan<const char>{},
|
||||
SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{});
|
||||
|
@ -23,13 +23,6 @@
|
||||
#include "text/GrTextBlobCache.h"
|
||||
#endif
|
||||
|
||||
SkRunFont::SkRunFont(const SkPaint& paint) : SkFont(SkFont::LEGACY_ExtractFromPaint(paint)) {}
|
||||
|
||||
void SkRunFont::applyToPaint(SkPaint* paint) const {
|
||||
this->LEGACY_applyToPaint(paint);
|
||||
paint->setTextEncoding(kGlyphID_SkTextEncoding);
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct RunFontStorageEquivalent {
|
||||
SkScalar fSize, fScaleX;
|
||||
@ -37,7 +30,7 @@ struct RunFontStorageEquivalent {
|
||||
SkScalar fSkewX;
|
||||
uint32_t fFlags;
|
||||
};
|
||||
static_assert(sizeof(SkRunFont) == sizeof(RunFontStorageEquivalent), "runfont_should_stay_packed");
|
||||
static_assert(sizeof(SkFont) == sizeof(RunFontStorageEquivalent), "runfont_should_stay_packed");
|
||||
}
|
||||
|
||||
size_t SkTextBlob::RunRecord::StorageSize(uint32_t glyphCount, uint32_t textSize,
|
||||
@ -74,7 +67,7 @@ const SkTextBlob::RunRecord* SkTextBlob::RunRecord::Next(const RunRecord* run) {
|
||||
|
||||
namespace {
|
||||
struct RunRecordStorageEquivalent {
|
||||
SkRunFont fFont;
|
||||
SkFont fFont;
|
||||
SkPoint fOffset;
|
||||
uint32_t fCount;
|
||||
uint32_t fFlags;
|
||||
@ -235,7 +228,8 @@ SkTextBlobRunIterator::GlyphPositioning SkTextBlobRunIterator::positioning() con
|
||||
void SkTextBlobRunIterator::applyFontToPaint(SkPaint* paint) const {
|
||||
SkASSERT(!this->done());
|
||||
|
||||
fCurrentRun->font().applyToPaint(paint);
|
||||
fCurrentRun->font().LEGACY_applyToPaint(paint);
|
||||
paint->setTextEncoding(kGlyphID_SkTextEncoding);
|
||||
}
|
||||
|
||||
bool SkTextBlobRunIterator::isLCD() const {
|
||||
@ -262,7 +256,8 @@ SkTextBlobBuilder::~SkTextBlobBuilder() {
|
||||
SkRect SkTextBlobBuilder::TightRunBounds(const SkTextBlob::RunRecord& run) {
|
||||
SkRect bounds;
|
||||
SkPaint paint;
|
||||
run.font().applyToPaint(&paint);
|
||||
run.font().LEGACY_applyToPaint(&paint);
|
||||
paint.setTextEncoding(kGlyphID_SkTextEncoding);
|
||||
|
||||
if (SkTextBlob::kDefault_Positioning == run.positioning()) {
|
||||
paint.measureText(run.glyphBuffer(), run.glyphCount() * sizeof(uint16_t), &bounds);
|
||||
|
@ -59,21 +59,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// TODO(fmalita): replace with SkFont.
|
||||
class SkRunFont : public SkFont {
|
||||
public:
|
||||
SkRunFont(const SkFont& font) : SkFont(font) {}
|
||||
SkRunFont(const SkPaint& paint);
|
||||
|
||||
void applyToPaint(SkPaint* paint) const;
|
||||
|
||||
bool operator==(const SkRunFont& other) const { return SkFont::operator==(other); }
|
||||
|
||||
bool operator!=(const SkRunFont& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Textblob data is laid out into externally-managed storage as follows:
|
||||
//
|
||||
@ -120,7 +105,7 @@ public:
|
||||
return fOffset;
|
||||
}
|
||||
|
||||
const SkRunFont& font() const {
|
||||
const SkFont& font() const {
|
||||
return fFont;
|
||||
}
|
||||
|
||||
@ -186,7 +171,7 @@ private:
|
||||
return fFlags & kExtended_Flag;
|
||||
}
|
||||
|
||||
SkRunFont fFont;
|
||||
SkFont fFont;
|
||||
uint32_t fCount;
|
||||
SkPoint fOffset;
|
||||
uint32_t fFlags;
|
||||
@ -195,9 +180,9 @@ private:
|
||||
};
|
||||
|
||||
// (paint->getFlags() & ~kFlagsMask) | fFlags
|
||||
inline SkPaint::SkPaint(const SkPaint& basePaint, const SkRunFont& runFont) : SkPaint(basePaint) {
|
||||
inline SkPaint::SkPaint(const SkPaint& basePaint, const SkFont& runFont) : SkPaint(basePaint) {
|
||||
fBitfields.fTextEncoding = (unsigned)kGlyphID_SkTextEncoding;
|
||||
runFont.applyToPaint(this);
|
||||
runFont.LEGACY_applyToPaint(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,10 +226,6 @@ public:
|
||||
SkASSERT(!this->done());
|
||||
return fCurrentRun->font();
|
||||
}
|
||||
const SkRunFont& runFont() const {
|
||||
SkASSERT(!this->done());
|
||||
return fCurrentRun->font();
|
||||
}
|
||||
void applyFontToPaint(SkPaint*) const;
|
||||
GlyphPositioning positioning() const;
|
||||
uint32_t* clusters() const {
|
||||
|
@ -488,7 +488,7 @@ DEF_TEST(SkPDF_Primitives_Color, reporter) {
|
||||
static SkGlyphRun make_run(size_t len, const SkGlyphID* glyphs, SkPoint* pos,
|
||||
SkPaint paint, const uint32_t* clusters,
|
||||
size_t utf8TextByteLength, const char* utf8Text) {
|
||||
return SkGlyphRun(paint, SkRunFont{paint},
|
||||
return SkGlyphRun(paint, SkFont::LEGACY_ExtractFromPaint(paint),
|
||||
SkSpan<const SkPoint>{pos, len},
|
||||
SkSpan<const SkGlyphID>{glyphs, len},
|
||||
SkSpan<const char>{utf8Text, utf8TextByteLength},
|
||||
|
Loading…
Reference in New Issue
Block a user