diff options
author | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-03-30 18:36:29 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-03-30 18:36:29 +0000 |
commit | 325cb9aa17b94258b362082eb3a799524f4345f3 (patch) | |
tree | ba2f296cc1337cb858ee2ea1289e153dc512588a /include | |
parent | e733071abeb9cce9f524f5a85851bc7fbb8d867b (diff) |
Improve the SkAdvancedTypefaceMetrics interface w.r.t. vertical advances.
Add a template function to type safe-combine bits of a bit field.
Review URL: http://codereview.appspot.com/4313053
git-svn-id: http://skia.googlecode.com/svn/trunk@1020 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkAdvancedTypefaceMetrics.h | 8 | ||||
-rw-r--r-- | include/core/SkFontHost.h | 8 | ||||
-rw-r--r-- | include/core/SkTypeface.h | 9 | ||||
-rw-r--r-- | include/core/SkTypes.h | 7 |
4 files changed, 26 insertions, 6 deletions
diff --git a/include/core/SkAdvancedTypefaceMetrics.h b/include/core/SkAdvancedTypefaceMetrics.h index 033e738c8a..f536a5603f 100644 --- a/include/core/SkAdvancedTypefaceMetrics.h +++ b/include/core/SkAdvancedTypefaceMetrics.h @@ -76,6 +76,14 @@ public: SkIRect fBBox; // The bounding box of all glyphs (in font units). + // The type of advance data wanted. + enum PerGlyphInfo { + kNo_PerGlyphInfo = 0x0, // Don't populate any per glyph info. + kHAdvance_PerGlyphInfo = 0x1, // Populate horizontal advance data. + kVAdvance_PerGlyphInfo = 0x2, // Populate vertical advance data. + kGlyphNames_PerGlyphInfo = 0x4, // Populate glyph names (Type 1 only). + }; + template <typename Data> struct AdvanceMetric { enum MetricType { diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h index 3c6925130b..72faed76c7 100644 --- a/include/core/SkFontHost.h +++ b/include/core/SkFontHost.h @@ -177,14 +177,14 @@ public: /////////////////////////////////////////////////////////////////////////// /** Retrieve detailed typeface metrics. Used by the PDF backend. - @param perGlyphInfo Indicate if the glyph specific information. - @param perGlyphInfo Indicate if the glyph specific information (advances - and names) should be populated. + @param perGlyphInfo Indicate what glyph specific information (advances, + names, etc.) should be populated. @return The returned object has already been referenced. NULL is returned if the font is not found. */ static SkAdvancedTypefaceMetrics* GetAdvancedTypefaceMetrics( - SkFontID fontID, bool perGlyphInfo); + SkFontID fontID, + SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo); /** Return the number of tables in the font */ diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h index c3b0f50d18..abbde04a17 100644 --- a/include/core/SkTypeface.h +++ b/include/core/SkTypeface.h @@ -17,6 +17,7 @@ #ifndef SkTypeface_DEFINED #define SkTypeface_DEFINED +#include "SkAdvancedTypefaceMetrics.h" #include "SkRefCnt.h" class SkStream; @@ -136,11 +137,15 @@ public: static SkTypeface* Deserialize(SkStream*); /** Retrieve detailed typeface metrics. Used by the PDF backend. - @param perGlyphInfo Indicate if the glyph specific information (advances - and names) should be populated. + @param perGlyphInfo Indicate what glyph specific information (advances, + names, etc.) should be populated. @return The returned object has already been referenced. */ SkAdvancedTypefaceMetrics* getAdvancedTypefaceMetrics( + SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) const; + + // Temporary: for transition purposes. + SkAdvancedTypefaceMetrics* getAdvancedTypefaceMetrics( bool perGlyphInfo) const; protected: diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index 1290935dee..1a3a2e5099 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -318,6 +318,13 @@ static inline uint32_t SkSetClearMask(uint32_t bits, bool cond, /////////////////////////////////////////////////////////////////////////////// +/** Use to combine multiple bits in a bitmask in a type safe way. + */ +template <typename T> +T SkTBitOr(T a, T b) { + return (T)(a | b); +} + /** * Use to cast a pointer to a different type, and maintaining strict-aliasing */ |