diff options
author | bungeman <bungeman@google.com> | 2014-06-05 13:38:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-05 13:38:45 -0700 |
commit | 51daa25a2b16bca578e78b7ea1e5815b9abb8b0b (patch) | |
tree | 200975ffc55d044e7d22d1291152152e2423ce09 /src/utils | |
parent | c3b589a24eb4d567a906189f882c259ecf5c2f58 (diff) |
Split SkFontHost_win_dw.
Split SkFontHost_win_dw into FontMgr, Typeface, and ScalerContext.
This makes working on these files easier, and moves away from the legacy
FontHost naming.
R=reed@google.com
Author: bungeman@google.com
Review URL: https://codereview.chromium.org/314193002
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/win/SkDWrite.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/utils/win/SkDWrite.h b/src/utils/win/SkDWrite.h index 06e9c8bcb7..679447dfc6 100644 --- a/src/utils/win/SkDWrite.h +++ b/src/utils/win/SkDWrite.h @@ -5,6 +5,9 @@ * found in the LICENSE file. */ +#ifndef SkDWrite_DEFINED +#define SkDWrite_DEFINED + #include "SkTemplates.h" #include <dwrite.h> @@ -36,3 +39,38 @@ void sk_get_locale_string(IDWriteLocalizedStrings* names, const WCHAR* preferedL typedef decltype(GetUserDefaultLocaleName)* SkGetUserDefaultLocaleNameProc; HRESULT SkGetGetUserDefaultLocaleNameProc(SkGetUserDefaultLocaleNameProc* proc); + +//////////////////////////////////////////////////////////////////////////////// +// Table handling + +class AutoDWriteTable { +public: + AutoDWriteTable(IDWriteFontFace* fontFace, UINT32 beTag) : fFontFace(fontFace), fExists(FALSE) { + // Any errors are ignored, user must check fExists anyway. + fontFace->TryGetFontTable(beTag, + reinterpret_cast<const void **>(&fData), &fSize, &fLock, &fExists); + } + ~AutoDWriteTable() { + if (fExists) { + fFontFace->ReleaseFontTable(fLock); + } + } + + const uint8_t* fData; + UINT32 fSize; + BOOL fExists; +private: + // Borrowed reference, the user must ensure the fontFace stays alive. + IDWriteFontFace* fFontFace; + void* fLock; +}; +template<typename T> class AutoTDWriteTable : public AutoDWriteTable { +public: + static const UINT32 tag = DWRITE_MAKE_OPENTYPE_TAG(T::TAG0, T::TAG1, T::TAG2, T::TAG3); + AutoTDWriteTable(IDWriteFontFace* fontFace) : AutoDWriteTable(fontFace, tag) { } + + const T* get() const { return reinterpret_cast<const T*>(fData); } + const T* operator->() const { return reinterpret_cast<const T*>(fData); } +}; + +#endif |