Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Unified Diff: src/core/SkAdvancedTypefaceMetrics.cpp

Issue 1955053002: SkAdvancedTypefaceMetrics: getAdvanceData uses std::function (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typedef Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkAdvancedTypefaceMetrics.h ('k') | src/ports/SkFontHost_FreeType.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAdvancedTypefaceMetrics.cpp
diff --git a/src/core/SkAdvancedTypefaceMetrics.cpp b/src/core/SkAdvancedTypefaceMetrics.cpp
index fab5f5e462498a78055718385ca4369727de54df..ae8fc861c38806c6918eaeb152abcf9f91c3ab3a 100644
--- a/src/core/SkAdvancedTypefaceMetrics.cpp
+++ b/src/core/SkAdvancedTypefaceMetrics.cpp
@@ -9,24 +9,6 @@
#include "SkAdvancedTypefaceMetrics.h"
#include "SkTypes.h"
-#if defined(SK_BUILD_FOR_WIN)
-#include <dwrite.h>
-#endif
-
-// forward declare structs needed for getAdvanceData() template for freetype
-struct FT_FaceRec_;
-typedef struct FT_FaceRec_* FT_Face;
-
-#ifdef SK_BUILD_FOR_MAC
-#import <ApplicationServices/ApplicationServices.h>
-#endif
-
-#ifdef SK_BUILD_FOR_IOS
-#include <CoreText/CoreText.h>
-#include <CoreGraphics/CoreGraphics.h>
-#include <CoreFoundation/CoreFoundation.h>
-#endif
-
SkAdvancedTypefaceMetrics::~SkAdvancedTypefaceMetrics() {}
const int16_t kInvalidAdvance = SK_MinS16;
@@ -87,13 +69,11 @@ void SkAdvancedTypefaceMetrics::FinishRange(
zeroWildcardsInRange(range);
}
-template <typename FontHandle>
void SkAdvancedTypefaceMetrics::setGlyphWidths(
- FontHandle fontHandle,
int num_glyphs,
const uint32_t* subsetGlyphIDs,
uint32_t subsetGlyphIDsLength,
- bool (*getAdvance)(FontHandle fontHandle, int gId, int16_t* data)) {
+ SkAdvancedTypefaceMetrics::GetAdvance getAdvance) {
// Assuming that on average, the ASCII representation of an advance plus
// a space is 8 characters and the ASCII representation of a glyph id is 3
// characters, then the following cut offs for using different range types
@@ -135,7 +115,7 @@ void SkAdvancedTypefaceMetrics::setGlyphWidths(
if (!subsetGlyphIDs ||
(subsetIndex < subsetGlyphIDsLength &&
static_cast<uint32_t>(gId) == subsetGlyphIDs[subsetIndex])) {
- SkAssertResult(getAdvance(fontHandle, gId, &advance));
+ SkAssertResult(getAdvance(gId, &advance));
++subsetIndex;
} else {
advance = kDontCareAdvance;
@@ -212,41 +192,3 @@ void SkAdvancedTypefaceMetrics::setGlyphWidths(
fGlyphWidths.emplace_back(std::move(curRange));
}
}
-
-// Make AdvanceMetric template functions available for linking with typename
-// WidthRange and VerticalAdvanceRange.
-template void SkAdvancedTypefaceMetrics::setGlyphWidths(
- FT_Face face,
- int num_glyphs,
- const uint32_t* subsetGlyphIDs,
- uint32_t subsetGlyphIDsLength,
- bool (*getAdvance)(FT_Face face, int gId, int16_t* data));
-
-#if defined(SK_BUILD_FOR_WIN)
-template void SkAdvancedTypefaceMetrics::setGlyphWidths(
- HDC hdc,
- int num_glyphs,
- const uint32_t* subsetGlyphIDs,
- uint32_t subsetGlyphIDsLength,
- bool (*getAdvance)(HDC hdc, int gId, int16_t* data));
-template void SkAdvancedTypefaceMetrics::setGlyphWidths(
- IDWriteFontFace* fontFace,
- int num_glyphs,
- const uint32_t* subsetGlyphIDs,
- uint32_t subsetGlyphIDsLength,
- bool (*getAdvance)(IDWriteFontFace* fontFace, int gId, int16_t* data));
-#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
-template void SkAdvancedTypefaceMetrics::setGlyphWidths(
- CTFontRef ctFont,
- int num_glyphs,
- const uint32_t* subsetGlyphIDs,
- uint32_t subsetGlyphIDsLength,
- bool (*getAdvance)(CTFontRef ctFont, int gId, int16_t* data));
-#endif
-// additional declaration needed for testing with a face of an unknown type
-template void SkAdvancedTypefaceMetrics::setGlyphWidths(
- void* fontData,
- int num_glyphs,
- const uint32_t* subsetGlyphIDs,
- uint32_t subsetGlyphIDsLength,
- bool (*getAdvance)(void* fontData, int gId, int16_t* data));
« no previous file with comments | « src/core/SkAdvancedTypefaceMetrics.h ('k') | src/ports/SkFontHost_FreeType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698