Skip to content

Commit ba158b9

Browse files
Ben WagnerSkia Commit-Bot
authored andcommitted
Remove SkScalerContext::getGlyphCount.
Also remove the supporting SkScalerContext::generateGlyphCount. It was once a possibility that different strikes could have a different number of glyphs available. This generally does not happen, but if it did this would now be handled at the typeface level. Change-Id: I8db7f2726c565447c211a79fe3cdfec619a99a81 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345129 Reviewed-by: Herb Derby <[email protected]> Commit-Queue: Ben Wagner <[email protected]>
1 parent 7804758 commit ba158b9

15 files changed

+1
-56
lines changed

src/core/SkRemoteGlyphCache.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ class RemoteStrike final : public SkStrikeForGPU {
328328
void writeGlyphPath(const SkGlyph& glyph, Serializer* serializer) const;
329329
void ensureScalerContext();
330330

331-
const int fNumberOfGlyphs;
332331
const SkAutoDescriptor fDescriptor;
333332
const SkDiscardableHandleId fDiscardableHandleId;
334333

@@ -364,8 +363,7 @@ RemoteStrike::RemoteStrike(
364363
const SkDescriptor& descriptor,
365364
std::unique_ptr<SkScalerContext> context,
366365
uint32_t discardableHandleId)
367-
: fNumberOfGlyphs(context->getGlyphCount())
368-
, fDescriptor{descriptor}
366+
: fDescriptor{descriptor}
369367
, fDiscardableHandleId(discardableHandleId)
370368
, fRoundingSpec{context->isSubpixel(), context->computeAxisAlignmentForHText()}
371369
// N.B. context must come last because it is used above.

src/core/SkScalerContext.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,9 +1163,6 @@ SkScalerContext* SkScalerContext::MakeEmptyContext(
11631163
: SkScalerContext(std::move(typeface), effects, desc) {}
11641164

11651165
protected:
1166-
unsigned generateGlyphCount() override {
1167-
return 0;
1168-
}
11691166
bool generateAdvance(SkGlyph* glyph) override {
11701167
glyph->zeroMetrics();
11711168
return true;

src/core/SkScalerContext.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ class SkScalerContext {
284284
// DEPRECATED
285285
bool isVertical() const { return false; }
286286

287-
unsigned getGlyphCount() { return this->generateGlyphCount(); }
288287
SkGlyph makeGlyph(SkPackedGlyphID);
289288
void getImage(const SkGlyph&);
290289
bool SK_WARN_UNUSED_RESULT getPath(SkPackedGlyphID, SkPath*);
@@ -396,9 +395,6 @@ class SkScalerContext {
396395
/** Retrieves font metrics. */
397396
virtual void generateFontMetrics(SkFontMetrics*) = 0;
398397

399-
/** Returns the number of glyphs in the font. */
400-
virtual unsigned generateGlyphCount() = 0;
401-
402398
void forceGenerateImageFromPath() { fGenerateImageFromPath = true; }
403399
void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; }
404400

src/core/SkTypeface_remote.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ SkScalerContextProxy::SkScalerContextProxy(sk_sp<SkTypeface> tf,
1919
: SkScalerContext{std::move(tf), effects, desc}
2020
, fDiscardableManager{std::move(manager)} {}
2121

22-
unsigned SkScalerContextProxy::generateGlyphCount() {
23-
SK_ABORT("Should never be called.");
24-
}
25-
2622
bool SkScalerContextProxy::generateAdvance(SkGlyph* glyph) {
2723
return false;
2824
}

src/core/SkTypeface_remote.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class SkScalerContextProxy : public SkScalerContext {
2828
sk_sp<SkStrikeClient::DiscardableHandleManager> manager);
2929

3030
protected:
31-
unsigned generateGlyphCount() override;
3231
bool generateAdvance(SkGlyph* glyph) override;
3332
void generateMetrics(SkGlyph* glyph) override;
3433
void generateImage(const SkGlyph& glyph) override;

src/ports/SkFontHost_FreeType.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ class SkScalerContext_FreeType : public SkScalerContext_FreeType_Base {
535535
}
536536

537537
protected:
538-
unsigned generateGlyphCount() override;
539538
bool generateAdvance(SkGlyph* glyph) override;
540539
void generateMetrics(SkGlyph* glyph) override;
541540
void generateImage(const SkGlyph& glyph) override;
@@ -1097,10 +1096,6 @@ FT_Error SkScalerContext_FreeType::setupSize() {
10971096
return 0;
10981097
}
10991098

1100-
unsigned SkScalerContext_FreeType::generateGlyphCount() {
1101-
return fFace->num_glyphs;
1102-
}
1103-
11041099
bool SkScalerContext_FreeType::generateAdvance(SkGlyph* glyph) {
11051100
/* unhinted and light hinted text have linearly scaled advances
11061101
* which are very cheap to compute with some font formats...

src/ports/SkFontHost_win.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,6 @@ class SkScalerContext_GDI : public SkScalerContext {
563563
bool isValid() const;
564564

565565
protected:
566-
unsigned generateGlyphCount() override;
567566
bool generateAdvance(SkGlyph* glyph) override;
568567
void generateMetrics(SkGlyph* glyph) override;
569568
void generateImage(const SkGlyph& glyph) override;
@@ -594,7 +593,6 @@ class SkScalerContext_GDI : public SkScalerContext {
594593
HFONT fSavefont;
595594
HFONT fFont;
596595
SCRIPT_CACHE fSC;
597-
int fGlyphCount;
598596

599597
/** The total matrix which also removes EM scale. */
600598
SkMatrix fHiResMatrix;
@@ -639,7 +637,6 @@ SkScalerContext_GDI::SkScalerContext_GDI(sk_sp<LogFontTypeface> rawTypeface,
639637
, fSavefont(0)
640638
, fFont(0)
641639
, fSC(0)
642-
, fGlyphCount(-1)
643640
{
644641
LogFontTypeface* typeface = static_cast<LogFontTypeface*>(this->getTypeface());
645642

@@ -800,14 +797,6 @@ bool SkScalerContext_GDI::isValid() const {
800797
return fDDC && fFont;
801798
}
802799

803-
unsigned SkScalerContext_GDI::generateGlyphCount() {
804-
if (fGlyphCount < 0) {
805-
fGlyphCount = calculateGlyphCount(
806-
fDDC, static_cast<const LogFontTypeface*>(this->getTypeface())->fLogFont);
807-
}
808-
return fGlyphCount;
809-
}
810-
811800
bool SkScalerContext_GDI::generateAdvance(SkGlyph* glyph) {
812801
return false;
813802
}

src/ports/SkScalerContext_mac_ct.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ SkScalerContext_Mac::SkScalerContext_Mac(sk_sp<SkTypeface_Mac> typeface,
122122

123123
{
124124
CTFontRef ctFont = (CTFontRef)this->getTypeface()->internal_private_getCTFontRef();
125-
CFIndex numGlyphs = CTFontGetGlyphCount(ctFont);
126-
SkASSERT(numGlyphs >= 1 && numGlyphs <= 0xFFFF);
127-
fGlyphCount = SkToU16(numGlyphs);
128125

129126
// CT on (at least) 10.9 will size color glyphs down from the requested size, but not up.
130127
// As a result, it is necessary to know the actual device size and request that.
@@ -268,10 +265,6 @@ CGRGBPixel* SkScalerContext_Mac::Offscreen::getCG(const SkScalerContext_Mac& con
268265
return image;
269266
}
270267

271-
unsigned SkScalerContext_Mac::generateGlyphCount(void) {
272-
return fGlyphCount;
273-
}
274-
275268
bool SkScalerContext_Mac::generateAdvance(SkGlyph* glyph) {
276269
return false;
277270
}

src/ports/SkScalerContext_mac_ct.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class SkScalerContext_Mac : public SkScalerContext {
4444
SkScalerContext_Mac(sk_sp<SkTypeface_Mac>, const SkScalerContextEffects&, const SkDescriptor*);
4545

4646
protected:
47-
unsigned generateGlyphCount(void) override;
4847
bool generateAdvance(SkGlyph* glyph) override;
4948
void generateMetrics(SkGlyph* glyph) override;
5049
void generateImage(const SkGlyph& glyph) override;
@@ -106,7 +105,6 @@ class SkScalerContext_Mac : public SkScalerContext {
106105
CGAffineTransform fInvTransform;
107106

108107
SkUniqueCFRef<CGFontRef> fCGFont;
109-
uint16_t fGlyphCount;
110108
const bool fDoSubPosition;
111109

112110
friend class Offscreen;

src/ports/SkScalerContext_win_dw.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,6 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
382382
SkScalerContext_DW::~SkScalerContext_DW() {
383383
}
384384

385-
unsigned SkScalerContext_DW::generateGlyphCount() {
386-
return fGlyphCount;
387-
}
388-
389385
bool SkScalerContext_DW::generateAdvance(SkGlyph* glyph) {
390386
glyph->fAdvanceX = 0;
391387
glyph->fAdvanceY = 0;

0 commit comments

Comments
 (0)