Remove public APIs that use SkDataTable.
Change-Id: Ibb8f987efc585713a6f8061c72fb416d07be13b1 Reviewed-on: https://skia-review.googlesource.com/7352 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
5b92e4ab8e
commit
9adfef8680
@ -109,9 +109,6 @@ public:
|
||||
*/
|
||||
static SkFontConfigInterface* GetSingletonDirectInterface();
|
||||
|
||||
// New APIS, which have default impls for now (which do nothing)
|
||||
|
||||
virtual sk_sp<SkDataTable> getFamilyNames() { return SkDataTable::MakeEmpty(); }
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "../private/SkMutex.h"
|
||||
#include "../private/SkOnce.h"
|
||||
#include "../private/SkTArray.h"
|
||||
#include "SkDataTable.h"
|
||||
#include "SkFontMgr.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkRemotableFontMgr.h"
|
||||
@ -95,10 +94,6 @@ private:
|
||||
mutable SkTArray<DataEntry> fDataCache;
|
||||
mutable SkMutex fDataCacheMutex;
|
||||
|
||||
mutable sk_sp<SkDataTable> fFamilyNames;
|
||||
mutable SkOnce fFamilyNamesInitOnce;
|
||||
static void set_up_family_names(const SkFontMgr_Indirect* self);
|
||||
|
||||
friend class SkStyleSet_Indirect;
|
||||
};
|
||||
|
||||
|
@ -55,15 +55,6 @@ private:
|
||||
|
||||
class SK_API SkRemotableFontMgr : public SkRefCnt {
|
||||
public:
|
||||
/**
|
||||
* Returns the names of the known fonts on the system.
|
||||
* Will not return NULL, will return an empty table if no families exist.
|
||||
*
|
||||
* The indexes may be used with getIndex(int) and
|
||||
* matchIndexStyle(int, SkFontStyle).
|
||||
*/
|
||||
virtual sk_sp<SkDataTable> getFamilyNames() const = 0;
|
||||
|
||||
/**
|
||||
* Returns all of the fonts with the given familyIndex.
|
||||
* Returns NULL if the index is out of bounds.
|
||||
|
@ -5,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkDataTable.h"
|
||||
#include "SkFontMgr.h"
|
||||
#include "SkFontMgr_indirect.h"
|
||||
#include "SkFontStyle.h"
|
||||
@ -60,30 +59,17 @@ private:
|
||||
sk_sp<SkRemotableFontIdentitySet> fData;
|
||||
};
|
||||
|
||||
void SkFontMgr_Indirect::set_up_family_names(const SkFontMgr_Indirect* self) {
|
||||
self->fFamilyNames = self->fProxy->getFamilyNames();
|
||||
}
|
||||
|
||||
int SkFontMgr_Indirect::onCountFamilies() const {
|
||||
fFamilyNamesInitOnce(SkFontMgr_Indirect::set_up_family_names, this);
|
||||
return fFamilyNames->count();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SkFontMgr_Indirect::onGetFamilyName(int index, SkString* familyName) const {
|
||||
fFamilyNamesInitOnce(SkFontMgr_Indirect::set_up_family_names, this);
|
||||
if (index >= fFamilyNames->count()) {
|
||||
familyName->reset();
|
||||
return;
|
||||
}
|
||||
familyName->set(fFamilyNames->atStr(index));
|
||||
SkFAIL("Not implemented");
|
||||
}
|
||||
|
||||
SkFontStyleSet* SkFontMgr_Indirect::onCreateStyleSet(int index) const {
|
||||
SkRemotableFontIdentitySet* set = fProxy->getIndex(index);
|
||||
if (nullptr == set) {
|
||||
return nullptr;
|
||||
}
|
||||
return new SkStyleSet_Indirect(this, index, set);
|
||||
SkFAIL("Not implemented");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkFontStyleSet* SkFontMgr_Indirect::onMatchFamily(const char familyName[]) const {
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "SkAutoMalloc.h"
|
||||
#include "SkBuffer.h"
|
||||
#include "SkDataTable.h"
|
||||
#include "SkFixed.h"
|
||||
#include "SkFontConfigInterface_direct.h"
|
||||
#include "SkFontStyle.h"
|
||||
@ -685,51 +684,3 @@ bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[],
|
||||
SkStreamAsset* SkFontConfigInterfaceDirect::openStream(const FontIdentity& identity) {
|
||||
return SkStream::MakeFromFile(identity.fString.c_str()).release();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool find_name(const SkTDArray<const char*>& list, const char* str) {
|
||||
int count = list.count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!strcmp(list[i], str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
sk_sp<SkDataTable> SkFontConfigInterfaceDirect::getFamilyNames() {
|
||||
FCLocker lock;
|
||||
|
||||
FcPattern* pat = FcPatternCreate();
|
||||
SkAutoTCallVProc<FcPattern, FcPatternDestroy> autoDestroyPat(pat);
|
||||
if (nullptr == pat) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, (char *)0);
|
||||
SkAutoTCallVProc<FcObjectSet, FcObjectSetDestroy> autoDestroyOs(os);
|
||||
if (nullptr == os) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FcFontSet* fs = FcFontList(nullptr, pat, os);
|
||||
SkAutoTCallVProc<FcFontSet, FcFontSetDestroy> autoDestroyFs(fs);
|
||||
if (nullptr == fs) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkTDArray<const char*> names;
|
||||
SkTDArray<size_t> sizes;
|
||||
for (int i = 0; i < fs->nfont; ++i) {
|
||||
FcPattern* match = fs->fonts[i];
|
||||
const char* famName = get_string(match, FC_FAMILY);
|
||||
if (famName && !find_name(names, famName)) {
|
||||
*names.append() = famName;
|
||||
*sizes.append() = strlen(famName) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return SkDataTable::MakeCopyArrays((const void*const*)names.begin(),
|
||||
sizes.begin(), names.count());
|
||||
}
|
||||
|
@ -24,9 +24,6 @@ public:
|
||||
|
||||
SkStreamAsset* openStream(const FontIdentity&) override;
|
||||
|
||||
// new APIs
|
||||
sk_sp<SkDataTable> getFamilyNames() override;
|
||||
|
||||
protected:
|
||||
virtual bool isAccessible(const char* filename);
|
||||
|
||||
|
@ -154,7 +154,6 @@ static bool find_by_FontIdentity(SkTypeface* cachedTypeface, void* ctx) {
|
||||
|
||||
class SkFontMgr_FCI : public SkFontMgr {
|
||||
sk_sp<SkFontConfigInterface> fFCI;
|
||||
sk_sp<SkDataTable> fFamilyNames;
|
||||
SkTypeface_FreeType::Scanner fScanner;
|
||||
|
||||
mutable SkMutex fMutex;
|
||||
@ -168,21 +167,21 @@ class SkFontMgr_FCI : public SkFontMgr {
|
||||
public:
|
||||
SkFontMgr_FCI(sk_sp<SkFontConfigInterface> fci)
|
||||
: fFCI(std::move(fci))
|
||||
, fFamilyNames(fFCI->getFamilyNames())
|
||||
, fCache(kMaxSize)
|
||||
{}
|
||||
|
||||
protected:
|
||||
int onCountFamilies() const override {
|
||||
return fFamilyNames->count();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void onGetFamilyName(int index, SkString* familyName) const override {
|
||||
familyName->set(fFamilyNames->atStr(index));
|
||||
SkFAIL("Not implemented.");
|
||||
}
|
||||
|
||||
SkFontStyleSet* onCreateStyleSet(int index) const override {
|
||||
return this->onMatchFamily(fFamilyNames->atStr(index));
|
||||
SkFAIL("Not implemented.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkFontStyleSet* onMatchFamily(const char familyName[]) const override {
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "SkDWrite.h"
|
||||
#include "SkDWriteFontFileStream.h"
|
||||
#include "SkDataTable.h"
|
||||
#include "SkHRESULT.h"
|
||||
#include "SkMutex.h"
|
||||
#include "SkRemotableFontMgr.h"
|
||||
@ -90,26 +89,6 @@ public:
|
||||
memcpy(fLocaleName.get(), localeName, localeNameLength * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
sk_sp<SkDataTable> getFamilyNames() const override {
|
||||
int count = fFontCollection->GetFontFamilyCount();
|
||||
|
||||
SkDataTableBuilder names(1024);
|
||||
for (int index = 0; index < count; ++index) {
|
||||
SkTScopedComPtr<IDWriteFontFamily> fontFamily;
|
||||
HRNM(fFontCollection->GetFontFamily(index, &fontFamily),
|
||||
"Could not get requested family.");
|
||||
|
||||
SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
|
||||
HRNM(fontFamily->GetFamilyNames(&familyNames), "Could not get family names.");
|
||||
|
||||
SkString familyName;
|
||||
sk_get_locale_string(familyNames.get(), fLocaleName.get(), &familyName);
|
||||
|
||||
names.appendString(familyName);
|
||||
}
|
||||
return names.detachDataTable();
|
||||
}
|
||||
|
||||
HRESULT FontToIdentity(IDWriteFont* font, SkFontIdentity* fontId) const {
|
||||
SkTScopedComPtr<IDWriteFontFace> fontFace;
|
||||
HRM(font->CreateFontFace(&fontFace), "Could not create font face.");
|
||||
|
Loading…
Reference in New Issue
Block a user