reorder template functions so it compiles in Lion

git-svn-id: http://skia.googlecode.com/svn/trunk@2672 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-11-14 13:12:47 +00:00
parent ed7f040853
commit b42403bdb9

View File

@ -30,6 +30,32 @@ namespace skia_advanced_typeface_metrics_utils {
const int16_t kInvalidAdvance = SK_MinS16;
const int16_t kDontCareAdvance = SK_MinS16 + 1;
template <typename Data>
void stripUninterestingTrailingAdvancesFromRange(
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range) {
SkASSERT(false);
}
template <>
void stripUninterestingTrailingAdvancesFromRange<int16_t>(
SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>* range) {
SkASSERT(range);
int expectedAdvanceCount = range->fEndId - range->fStartId + 1;
if (range->fAdvance.count() < expectedAdvanceCount) {
return;
}
for (int i = expectedAdvanceCount - 1; i >= 0; --i) {
if (range->fAdvance[i] != kDontCareAdvance &&
range->fAdvance[i] != kInvalidAdvance &&
range->fAdvance[i] != 0) {
range->fEndId = range->fStartId + i;
break;
}
}
}
template <typename Data>
void resetRange(SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range,
int startId) {
@ -46,6 +72,29 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* appendRange(
return nextSlot->get();
}
template <typename Data>
void zeroWildcardsInRange(
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range) {
SkASSERT(false);
}
template <>
void zeroWildcardsInRange<int16_t>(
SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>* range) {
SkASSERT(range);
if (range->fType != SkAdvancedTypefaceMetrics::WidthRange::kRange) {
return;
}
SkASSERT(range->fAdvance.count() == range->fEndId - range->fStartId + 1);
// Zero out wildcards.
for (int i = 0; i < range->fAdvance.count(); ++i) {
if (range->fAdvance[i] == kDontCareAdvance) {
range->fAdvance[i] = 0;
}
}
}
template <typename Data>
void finishRange(
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range,
@ -70,55 +119,6 @@ void finishRange(
zeroWildcardsInRange(range);
}
template <typename Data>
void stripUninterestingTrailingAdvancesFromRange(
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range) {
SkASSERT(false);
}
template <>
void stripUninterestingTrailingAdvancesFromRange<int16_t>(
SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>* range) {
SkASSERT(range);
int expectedAdvanceCount = range->fEndId - range->fStartId + 1;
if (range->fAdvance.count() < expectedAdvanceCount) {
return;
}
for (int i = expectedAdvanceCount - 1; i >= 0; --i) {
if (range->fAdvance[i] != kDontCareAdvance &&
range->fAdvance[i] != kInvalidAdvance &&
range->fAdvance[i] != 0) {
range->fEndId = range->fStartId + i;
break;
}
}
}
template <typename Data>
void zeroWildcardsInRange(
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* range) {
SkASSERT(false);
}
template <>
void zeroWildcardsInRange<int16_t>(
SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t>* range) {
SkASSERT(range);
if (range->fType != SkAdvancedTypefaceMetrics::WidthRange::kRange) {
return;
}
SkASSERT(range->fAdvance.count() == range->fEndId - range->fStartId + 1);
// Zero out wildcards.
for (int i = 0; i < range->fAdvance.count(); ++i) {
if (range->fAdvance[i] == kDontCareAdvance) {
range->fAdvance[i] = 0;
}
}
}
template <typename Data, typename FontHandle>
SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData(
FontHandle fontHandle,