Make SkAdvancedTypefaceMetrics private.

Review URL: https://codereview.chromium.org/1129283003
This commit is contained in:
reed 2015-05-12 09:50:04 -07:00 committed by Commit bot
parent 67d71c8982
commit 39a9a5069b
15 changed files with 55 additions and 56 deletions

View File

@ -18,6 +18,7 @@
'<(skia_src_path)/core/SkAAClip.cpp',
'<(skia_src_path)/core/SkAnnotation.cpp',
'<(skia_src_path)/core/SkAdvancedTypefaceMetrics.cpp',
'<(skia_src_path)/core/SkAdvancedTypefaceMetrics.h',
'<(skia_src_path)/core/SkAlphaRuns.cpp',
'<(skia_src_path)/core/SkAntiRun.h',
'<(skia_src_path)/core/SkBBHFactory.cpp',
@ -242,7 +243,6 @@
'<(skia_src_path)/pipe/SkGPipeRead.cpp',
'<(skia_src_path)/pipe/SkGPipeWrite.cpp',
'<(skia_include_path)/core/SkAdvancedTypefaceMetrics.h',
'<(skia_include_path)/core/SkBBHFactory.h',
'<(skia_include_path)/core/SkBitmap.h',
'<(skia_include_path)/core/SkBitmapDevice.h',

View File

@ -10,9 +10,10 @@
#ifndef SkTypeface_DEFINED
#define SkTypeface_DEFINED
#include "SkAdvancedTypefaceMetrics.h"
#include "SkFontStyle.h"
#include "SkLazyPtr.h"
#include "SkRect.h"
#include "SkString.h"
#include "SkWeakRefCnt.h"
class SkDescriptor;
@ -307,6 +308,16 @@ public:
}
protected:
// The type of advance data wanted.
enum PerGlyphInfo {
kNo_PerGlyphInfo = 0x0, // Don't populate any per glyph info.
kHAdvance_PerGlyphInfo = 0x1, // Populate horizontal advance data.
kVAdvance_PerGlyphInfo = 0x2, // Populate vertical advance data.
kGlyphNames_PerGlyphInfo = 0x4, // Populate glyph names (Type 1 only).
kToUnicode_PerGlyphInfo = 0x8 // Populate ToUnicode table, ignored
// for Type 1 fonts
};
/** uniqueID must be unique and non-zero
*/
SkTypeface(const SkFontStyle& style, SkFontID uniqueID, bool isFixedPitch = false);
@ -321,7 +332,7 @@ protected:
virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const = 0;
virtual void onFilterRec(SkScalerContextRec*) const = 0;
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
PerGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const = 0;
@ -368,7 +379,7 @@ private:
@return The returned object has already been referenced.
*/
SkAdvancedTypefaceMetrics* getAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
PerGlyphInfo,
const uint32_t* glyphIDs = NULL,
uint32_t glyphIDsCount = 0) const;

View File

@ -74,16 +74,6 @@ public:
SkIRect fBBox; // The bounding box of all glyphs (in font units).
// The type of advance data wanted.
enum PerGlyphInfo {
kNo_PerGlyphInfo = 0x0, // Don't populate any per glyph info.
kHAdvance_PerGlyphInfo = 0x1, // Populate horizontal advance data.
kVAdvance_PerGlyphInfo = 0x2, // Populate vertical advance data.
kGlyphNames_PerGlyphInfo = 0x4, // Populate glyph names (Type 1 only).
kToUnicode_PerGlyphInfo = 0x8 // Populate ToUnicode table, ignored
// for Type 1 fonts
};
template <typename Data>
struct AdvanceMetric {
enum MetricType {

View File

@ -35,7 +35,7 @@ protected:
}
void onFilterRec(SkScalerContextRec*) const override { }
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
PerGlyphInfo,
const uint32_t*, uint32_t) const override { return NULL; }
void onGetFontDescriptor(SkFontDescriptor*, bool*) const override { }
virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
@ -265,7 +265,7 @@ void SkTypeface::getFamilyName(SkString* name) const {
}
SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo info,
PerGlyphInfo info,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const {
SkAdvancedTypefaceMetrics* result =

View File

@ -178,7 +178,7 @@ void SkGTypeface::onFilterRec(SkScalerContextRec* rec) const {
}
SkAdvancedTypefaceMetrics* SkGTypeface::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo info,
PerGlyphInfo info,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const {
return fProxy->getAdvancedTypefaceMetrics(info, glyphIDs, glyphIDsCount);

View File

@ -23,7 +23,7 @@ protected:
SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override;
void onFilterRec(SkScalerContextRec*) const override;
SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
PerGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const override;
SkStreamAsset* onOpenStream(int* ttcIndex) const override;

View File

@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
#include "SkAdvancedTypefaceMetrics.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkDescriptor.h"
@ -140,7 +141,7 @@ void SkTestTypeface::onFilterRec(SkScalerContextRec* rec) const {
}
SkAdvancedTypefaceMetrics* SkTestTypeface::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo ,
PerGlyphInfo ,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const {
// pdf only

View File

@ -69,7 +69,7 @@ protected:
SkScalerContext* onCreateScalerContext(const SkDescriptor* desc) const override;
void onFilterRec(SkScalerContextRec* rec) const override;
SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
PerGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const override;

View File

@ -829,13 +829,13 @@ SkPDFFont* SkPDFFont::GetFontResource(SkPDFCanon* canon,
return SkRef(relatedFont);
}
} else {
SkAdvancedTypefaceMetrics::PerGlyphInfo info;
info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo;
info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
info, SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo);
SkTypeface::PerGlyphInfo info;
info = SkTypeface::kGlyphNames_PerGlyphInfo;
info = SkTBitOr<SkTypeface::PerGlyphInfo>(
info, SkTypeface::kToUnicode_PerGlyphInfo);
#if !defined (SK_SFNTLY_SUBSETTER)
info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo);
info = SkTBitOr<SkTypeface::PerGlyphInfo>(
info, SkTypeface::kHAdvance_PerGlyphInfo);
#endif
fontMetrics.reset(
typeface->getAdvancedTypefaceMetrics(info, NULL, 0));
@ -1127,10 +1127,10 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
subset->exportTo(&glyphIDs);
}
SkAdvancedTypefaceMetrics::PerGlyphInfo info;
info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo;
info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>(
info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo);
SkTypeface::PerGlyphInfo info;
info = SkTypeface::kGlyphNames_PerGlyphInfo;
info = SkTBitOr<SkTypeface::PerGlyphInfo>(
info, SkTypeface::kHAdvance_PerGlyphInfo);
uint32_t* glyphs = (glyphIDs.count() == 0) ? NULL : glyphIDs.begin();
uint32_t glyphsCount = glyphs ? glyphIDs.count() : 0;
SkAutoTUnref<const SkAdvancedTypefaceMetrics> fontMetrics(

View File

@ -460,7 +460,7 @@ static void populate_glyph_to_unicode(FT_Face& face, SkTDArray<SkUnichar>* glyph
}
SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const {
#if defined(SK_BUILD_FOR_MAC)
@ -587,10 +587,10 @@ SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
face->bbox.xMax, face->bbox.yMin);
if (!FT_IS_SCALABLE(face)) {
perGlyphInfo = SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo;
perGlyphInfo = kNo_PerGlyphInfo;
}
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
if (perGlyphInfo & kHAdvance_PerGlyphInfo) {
if (FT_IS_FIXED_WIDTH(face)) {
appendRange(&info->fGlyphWidths, 0);
int16_t advance = face->max_advance_width;
@ -624,12 +624,12 @@ SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
}
}
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kVAdvance_PerGlyphInfo &&
if (perGlyphInfo & kVAdvance_PerGlyphInfo &&
FT_HAS_VERTICAL(face)) {
SkASSERT(false); // Not implemented yet.
}
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo &&
if (perGlyphInfo & kGlyphNames_PerGlyphInfo &&
info->fType == SkAdvancedTypefaceMetrics::kType1_Font) {
// Postscript fonts may contain more than 255 glyphs, so we end up
// using multiple font descriptions with a glyph ordering. Record
@ -643,7 +643,7 @@ SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
}
}
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo &&
if (perGlyphInfo & kToUnicode_PerGlyphInfo &&
info->fType != SkAdvancedTypefaceMetrics::kType1_Font &&
face->num_charmaps) {
populate_glyph_to_unicode(face, &(info->fGlyphToUnicode));

View File

@ -61,9 +61,8 @@ protected:
virtual SkScalerContext* onCreateScalerContext(
const SkDescriptor*) const override;
void onFilterRec(SkScalerContextRec*) const override;
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
const uint32_t*, uint32_t) const override;
SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
PerGlyphInfo, const uint32_t*, uint32_t) const override;
int onGetUPEM() const override;
virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count,
int32_t adjustments[]) const override;

View File

@ -19,6 +19,7 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
#include "SkAdvancedTypefaceMetrics.h"
#include "SkCGUtils.h"
#include "SkColorPriv.h"
#include "SkDescriptor.h"
@ -453,7 +454,7 @@ protected:
void onFilterRec(SkScalerContextRec*) const override;
void onGetFontDescriptor(SkFontDescriptor*, bool*) const override;
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
PerGlyphInfo,
const uint32_t*, uint32_t) const override;
virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[],
int glyphCount) const override;
@ -1543,7 +1544,7 @@ static void CFStringToSkString(CFStringRef src, SkString* dst) {
}
SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const {
@ -1565,7 +1566,7 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag;
info->fStyle = 0;
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) {
if (perGlyphInfo & kToUnicode_PerGlyphInfo) {
populate_glyph_to_unicode(ctFont, glyphCount, &info->fGlyphToUnicode);
}
@ -1632,7 +1633,7 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
}
}
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
if (perGlyphInfo & kHAdvance_PerGlyphInfo) {
if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) {
skia_advanced_typeface_metrics_utils::appendRange(&info->fGlyphWidths, 0);
info->fGlyphWidths->fAdvance.append(1, &min_width);

View File

@ -1,4 +1,3 @@
/*
* Copyright 2006 The Android Open Source Project
*
@ -257,9 +256,8 @@ protected:
SkStreamAsset* onOpenStream(int* ttcIndex) const override;
SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override;
void onFilterRec(SkScalerContextRec*) const override;
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
const uint32_t*, uint32_t) const override;
SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
PerGlyphInfo, const uint32_t*, uint32_t) const override;
void onGetFontDescriptor(SkFontDescriptor*, bool*) const override;
virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
uint16_t glyphs[], int glyphCount) const override;
@ -1733,7 +1731,7 @@ static bool getWidthAdvance(HDC hdc, int gId, int16_t* advance) {
}
SkAdvancedTypefaceMetrics* LogFontTypeface::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const {
LOGFONT lf = fLogFont;
@ -1782,7 +1780,7 @@ SkAdvancedTypefaceMetrics* LogFontTypeface::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag);
}
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) {
if (perGlyphInfo & kToUnicode_PerGlyphInfo) {
populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode));
}
@ -1841,7 +1839,7 @@ SkAdvancedTypefaceMetrics* LogFontTypeface::onGetAdvancedTypefaceMetrics(
}
}
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
if (perGlyphInfo & kHAdvance_PerGlyphInfo) {
if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) {
appendRange(&info->fGlyphWidths, 0);
info->fGlyphWidths->fAdvance.append(1, &min_width);

View File

@ -322,7 +322,7 @@ static bool getWidthAdvance(IDWriteFontFace* fontFace, int gId, int16_t* advance
}
SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const {
@ -355,7 +355,7 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
hr = sk_wchar_to_skstring(familyName.get(), familyNameLen, &info->fFontName);
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) {
if (perGlyphInfo & kToUnicode_PerGlyphInfo) {
populate_glyph_to_unicode(fDWriteFontFace.get(), glyphCount, &(info->fGlyphToUnicode));
}
@ -442,7 +442,7 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
}
*/
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
if (perGlyphInfo & kHAdvance_PerGlyphInfo) {
if (fixedWidth) {
appendRange(&info->fGlyphWidths, 0);
int16_t advance;

View File

@ -99,9 +99,8 @@ protected:
SkStreamAsset* onOpenStream(int* ttcIndex) const override;
SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override;
void onFilterRec(SkScalerContextRec*) const override;
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
const uint32_t*, uint32_t) const override;
SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
PerGlyphInfo, const uint32_t*, uint32_t) const override;
void onGetFontDescriptor(SkFontDescriptor*, bool*) const override;
virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
uint16_t glyphs[], int glyphCount) const override;