///////////////////////////////////////////////////////////////////////////////
static void sk_memset_rect32(uint32_t* ptr, uint32_t value,
- size_t width, size_t height, size_t rowBytes) {
+ int width, int height, size_t rowBytes) {
SkASSERT(width);
SkASSERT(width * sizeof(uint32_t) <= rowBytes);
// so the performance impact isn't too bad.
static void populate_glyph_to_unicode_slow(CTFontRef ctFont, CFIndex glyphCount,
SkTDArray<SkUnichar>* glyphToUnicode) {
- glyphToUnicode->setCount(glyphCount);
+ glyphToUnicode->setCount(SkToInt(glyphCount));
SkUnichar* out = glyphToUnicode->begin();
sk_bzero(out, glyphCount * sizeof(SkUnichar));
UniChar unichar = 0;
length = 8192;
}
const UInt8* bits = CFDataGetBytePtr(bitmap);
- glyphToUnicode->setCount(glyphCount);
+ glyphToUnicode->setCount(SkToInt(glyphCount));
SkUnichar* out = glyphToUnicode->begin();
sk_bzero(out, glyphCount * sizeof(SkUnichar));
for (int i = 0; i < length; i++) {
} else {
info->fGlyphWidths.reset(
skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get(),
- glyphCount,
+ SkToInt(glyphCount),
glyphIDs,
glyphIDsCount,
&getWidthAdvance));
entry->tag = SkEndian_SwapBE32(tableTags[tableIndex]);
entry->checksum = SkEndian_SwapBE32(SkOTUtils::CalcTableChecksum((SK_OT_ULONG*)dataPtr,
tableSize));
- entry->offset = SkEndian_SwapBE32(dataPtr - dataStart);
- entry->logicalLength = SkEndian_SwapBE32(tableSize);
+ entry->offset = SkEndian_SwapBE32(SkToU32(dataPtr - dataStart));
+ entry->logicalLength = SkEndian_SwapBE32(SkToU32(tableSize));
dataPtr += (tableSize + 3) & ~3;
++entry;
if (NULL == cfArray) {
return 0;
}
- int count = CFArrayGetCount(cfArray);
+ int count = SkToInt(CFArrayGetCount(cfArray));
if (tags) {
for (int i = 0; i < count; ++i) {
uintptr_t fontTag = reinterpret_cast<uintptr_t>(CFArrayGetValueAtIndex(cfArray, i));
SkUnichar uni = SkUTF8_NextUnichar(&utf8);
utf16 += SkUTF16_FromUnichar(uni, utf16);
}
- srcCount = utf16 - src;
+ srcCount = SkToInt(utf16 - src);
break;
}
case kUTF16_Encoding: {
for (int i = 0; i < glyphCount; ++i) {
utf16 += SkUTF16_FromUnichar(utf32[i], utf16);
}
- srcCount = utf16 - src;
+ srcCount = SkToInt(utf16 - src);
break;
}
}
}
int SkTypeface_Mac::onCountGlyphs() const {
- return CTFontGetGlyphCount(fFontRef);
+ return SkToInt(CTFontGetGlyphCount(fFontRef));
}
///////////////////////////////////////////////////////////////////////////////
if (NULL == fArray) {
fArray = CFArrayCreate(NULL, NULL, 0, NULL);
}
- fCount = CFArrayGetCount(fArray);
+ fCount = SkToInt(CFArrayGetCount(fArray));
}
virtual ~SkFontStyleSet_Mac() {
};
class SkFontMgr_Mac : public SkFontMgr {
- int fCount;
CFArrayRef fNames;
+ int fCount;
CFStringRef stringAt(int index) const {
SkASSERT((unsigned)index < (unsigned)fCount);
return (CFStringRef)CFArrayGetValueAtIndex(fNames, index);
}
- void lazyInit() {
- if (NULL == fNames) {
- fNames = SkCTFontManagerCopyAvailableFontFamilyNames();
- fCount = fNames ? CFArrayGetCount(fNames) : 0;
- }
- }
-
static SkFontStyleSet* CreateSet(CFStringRef cfFamilyName) {
AutoCFRelease<CFMutableDictionaryRef> cfAttr(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
}
public:
- SkFontMgr_Mac() : fCount(0), fNames(NULL) {}
+ SkFontMgr_Mac()
+ : fNames(SkCTFontManagerCopyAvailableFontFamilyNames())
+ , fCount(fNames ? SkToInt(CFArrayGetCount(fNames)) : 0) {}
virtual ~SkFontMgr_Mac() {
CFSafeRelease(fNames);
}
protected:
- virtual int onCountFamilies() SK_OVERRIDE {
- this->lazyInit();
+ virtual int onCountFamilies() const SK_OVERRIDE {
return fCount;
}
- virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE {
- this->lazyInit();
+ virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE {
if ((unsigned)index < (unsigned)fCount) {
CFStringToSkString(this->stringAt(index), familyName);
} else {
}
}
- virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE {
- this->lazyInit();
+ virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE {
if ((unsigned)index >= (unsigned)fCount) {
return NULL;
}
return CreateSet(this->stringAt(index));
}
- virtual SkFontStyleSet* onMatchFamily(const char familyName[]) SK_OVERRIDE {
+ virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVERRIDE {
AutoCFRelease<CFStringRef> cfName(make_CFString(familyName));
return CreateSet(cfName);
}
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
- const SkFontStyle&) SK_OVERRIDE {
+ const SkFontStyle&) const SK_OVERRIDE {
return NULL;
}
virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
- const SkFontStyle&) SK_OVERRIDE {
+ const SkFontStyle&) const SK_OVERRIDE {
return NULL;
}
virtual SkTypeface* onCreateFromData(SkData* data,
- int ttcIndex) SK_OVERRIDE {
+ int ttcIndex) const SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data));
if (NULL == pr) {
return NULL;
}
virtual SkTypeface* onCreateFromStream(SkStream* stream,
- int ttcIndex) SK_OVERRIDE {
+ int ttcIndex) const SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(stream));
if (NULL == pr) {
return NULL;
}
virtual SkTypeface* onCreateFromFile(const char path[],
- int ttcIndex) SK_OVERRIDE {
+ int ttcIndex) const SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(CGDataProviderCreateWithFilename(path));
if (NULL == pr) {
return NULL;
}
virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
- unsigned styleBits) SK_OVERRIDE {
+ unsigned styleBits) const SK_OVERRIDE {
return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits);
}
};