diff options
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkBitmap.h | 14 | ||||
-rw-r--r-- | include/core/SkFontHost.h | 9 | ||||
-rw-r--r-- | include/core/SkLanguage.h | 70 | ||||
-rw-r--r-- | include/core/SkPaint.h | 39 | ||||
-rw-r--r-- | include/core/SkScalerContext.h | 16 |
5 files changed, 140 insertions, 8 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 57b80e5..2d5fc41 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -513,6 +513,16 @@ public: */ int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy); +#ifdef SK_BUILD_FOR_ANDROID + bool hasHardwareMipMap() const { + return fHasHardwareMipMap; + } + + void setHasHardwareMipMap(bool hasHardwareMipMap) { + fHasHardwareMipMap = hasHardwareMipMap; + } +#endif + bool extractAlpha(SkBitmap* dst) const { return this->extractAlpha(dst, NULL, NULL, NULL); } @@ -614,6 +624,10 @@ private: uint8_t fFlags; uint8_t fBytesPerPixel; // based on config +#ifdef SK_BUILD_FOR_ANDROID + bool fHasHardwareMipMap; +#endif + /* Internal computations for safe size. */ static Sk64 ComputeSafeSize64(Config config, diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h index 25c9ecb..ace08d8 100644 --- a/include/core/SkFontHost.h +++ b/include/core/SkFontHost.h @@ -154,6 +154,15 @@ public: */ static SkFontID NextLogicalFont(SkFontID currFontID, SkFontID origFontID); +#ifdef SK_BUILD_FOR_ANDROID + /* + * This Android-only version of NextLogicalFont allows us to pass in an + * entire Rec structure so that a caller can change fallback behavior + */ + static SkFontID NextLogicalFont(const SkScalerContext::Rec& rec); +#endif + + /////////////////////////////////////////////////////////////////////////// /** Given a filled-out rec, the fonthost may decide to modify it to reflect diff --git a/include/core/SkLanguage.h b/include/core/SkLanguage.h new file mode 100644 index 0000000..923008e --- /dev/null +++ b/include/core/SkLanguage.h @@ -0,0 +1,70 @@ + +/* + * Copyright 2012 The Android Open Source Project + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#ifndef SkLanguage_DEFINED +#define SkLanguage_DEFINED + +#include "SkTypes.h" + +#ifdef SK_BUILD_FOR_ANDROID + +#include "SkString.h" + +struct SkLanguageInfo { + SkLanguageInfo(const char* tag) : fTag(tag) { } + SkString fTag; //! BCP 47 language identifier +}; + +/** \class SkLanguage + + The SkLanguage class represents a human written language, and is used by + text draw operations to determine which glyph to draw when drawing + characters with variants (ie Han-derived characters). +*/ +class SkLanguage { +public: + SkLanguage() : fInfo(getInfo("")) { } + SkLanguage(const char* tag) : fInfo(getInfo(tag)) { } + SkLanguage(const SkLanguage& b) : fInfo(b.fInfo) { } + + /** Gets a BCP 47 language identifier for this SkLanguage. + @return a BCP 47 language identifier representing this language + */ + const SkString& getTag() const { return fInfo->fTag; } + + /** Performs BCP 47 fallback to return an SkLanguage one step more general. + @return an SkLanguage one step more general + */ + SkLanguage getParent() const; + + bool operator==(const SkLanguage& b) const { + return fInfo == b.fInfo; + } + bool operator!=(const SkLanguage& b) const { + return fInfo != b.fInfo; + } + bool operator<(const SkLanguage& b) const { + return fInfo < b.fInfo; + } + bool operator>(const SkLanguage& b) const { + return fInfo > b.fInfo; + } + SkLanguage& operator=(const SkLanguage& b) { + fInfo = b.fInfo; + return *this; + } + +private: + const SkLanguageInfo* fInfo; + + static const SkLanguageInfo* getInfo(const char* tag); +}; + +#endif // #ifdef SK_BUILD_FOR_ANDROID +#endif // #ifndef SkLanguage_DEFINED diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 30ff663..d2233f0 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -10,11 +10,16 @@ #ifndef SkPaint_DEFINED #define SkPaint_DEFINED +#include "SkTypes.h" #include "SkColor.h" #include "SkDrawLooper.h" #include "SkXfermode.h" #include "SkString.h" +#ifdef SK_BUILD_FOR_ANDROID +#include "SkLanguage.h" +#endif + class SkAutoGlyphCache; class SkColorFilter; class SkDescriptor; @@ -656,15 +661,34 @@ public: void setTextAlign(Align align); #ifdef SK_BUILD_FOR_ANDROID - /** Return the paint's text locale value. - @return the paint's text locale value used for drawing text. + /** Return the paint's language value used for drawing text. + @return the paint's language value used for drawing text. */ - const SkString& getTextLocale() const { return fTextLocale; } + const SkLanguage& getLanguage() const { return fLanguage; } + + /** Set the paint's language value used for drawing text. + @param language set the paint's language value for drawing text. + */ + void setLanguage(const SkLanguage& language); + + + enum FontVariant { + kDefault_Variant, // Currently setting yourself to Default gives you Compact Variant + kCompact_Variant, + kElegant_Variant, + kLast_Variant = kElegant_Variant, + }; + + /** Return the font variant + @return the font variant used by this paint object + */ + FontVariant getFontVariant() const { return fFontVariant; } + - /** Set the paint's text locale. - @param locale set the paint's locale value for drawing text. + /** Set the font variant + @param fontVariant set the paint's font variant for choosing fonts */ - void setTextLocale(const SkString& locale); + void setFontVariant(FontVariant fontVariant); #endif /** Return the paint's text size. @@ -905,7 +929,8 @@ private: unsigned fTextEncoding : 2; // 3 values unsigned fHinting : 2; #ifdef SK_BUILD_FOR_ANDROID - SkString fTextLocale; + SkLanguage fLanguage; + FontVariant fFontVariant; #endif SkDrawCacheProc getDrawCacheProc() const; diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h index 29679d6..4a0c70d 100644 --- a/include/core/SkScalerContext.h +++ b/include/core/SkScalerContext.h @@ -15,6 +15,11 @@ #include "SkPaint.h" #include "SkPath.h" #include "SkPoint.h" +#include "SkTypeface.h" + +#ifdef SK_BUILD_FOR_ANDROID +#include "SkLanguage.h" +#endif //#define SK_USE_COLOR_LUMINANCE @@ -209,6 +214,10 @@ public: #ifdef SK_USE_COLOR_LUMINANCE uint32_t fLumBits; #endif +#ifdef SK_BUILD_FOR_ANDROID + SkLanguage fLanguage; + SkPaint::FontVariant fFontVariant; +#endif uint8_t fMaskFormat; uint8_t fStrokeJoin; uint16_t fFlags; @@ -233,7 +242,6 @@ public: SkMask::Format getFormat() const { return static_cast<SkMask::Format>(fMaskFormat); } - #ifdef SK_USE_COLOR_LUMINANCE SkColor getLuminanceColor() const { return fLumBits; @@ -299,6 +307,10 @@ public: SkPaint::FontMetrics* mY); #ifdef SK_BUILD_FOR_ANDROID + // This function must be public for SkTypeface_android.h, but should not be + // called by other callers + SkFontID findTypefaceIdForChar(SkUnichar uni); + unsigned getBaseGlyphCount(SkUnichar charCode); #endif @@ -325,6 +337,8 @@ protected: void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } private: + SkScalerContext* getContextFromChar(SkUnichar uni, unsigned& glyphID); + SkPathEffect* fPathEffect; SkMaskFilter* fMaskFilter; SkRasterizer* fRasterizer; |