diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2012-04-09 18:00:04 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2012-04-11 15:24:47 -0700 |
commit | 5c7fc8f96344cc7f780558c714d3e52f0669b0b8 (patch) | |
tree | bc2bfb36639e30950a2c0bb8cdafad1da3ce442e | |
parent | 55613bba538c7c23b2295cbafdb2243a4c4c3358 (diff) | |
download | external_skia-5c7fc8f96344cc7f780558c714d3e52f0669b0b8.zip external_skia-5c7fc8f96344cc7f780558c714d3e52f0669b0b8.tar.gz external_skia-5c7fc8f96344cc7f780558c714d3e52f0669b0b8.tar.bz2 |
Add SkPaint.setTextLocale()
- will be used for better CJK shaping
- forced to use a "placement new" operator because of use of sk_bzero / memcpy
in the Skia contructor and copy operator
Change-Id: If6f62634c9088d2401250c35239a1722102fe80c
-rw-r--r-- | include/core/SkPaint.h | 16 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 17 |
2 files changed, 33 insertions, 0 deletions
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 31bc30b..7be5ad2 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -13,6 +13,7 @@ #include "SkColor.h" #include "SkDrawLooper.h" #include "SkXfermode.h" +#include "SkString.h" class SkAutoGlyphCache; class SkColorFilter; @@ -654,6 +655,18 @@ 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. + */ + const SkString& getTextLocale() const { return fTextLocale; } + + /** Set the paint's text locale. + @param locale set the paint's locale value for drawing text. + */ + void setTextLocale(const SkString& locale); +#endif + /** Return the paint's text size. @return the paint's text size. */ @@ -888,6 +901,9 @@ private: unsigned fStyle : 2; unsigned fTextEncoding : 2; // 3 values unsigned fHinting : 2; +#ifdef SK_BUILD_FOR_ANDROID + SkString fTextLocale; +#endif SkDrawCacheProc getDrawCacheProc() const; SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir, diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index e93e8d6..82a1f57 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -7,6 +7,8 @@ */ +#include <new> + #include "SkPaint.h" #include "SkColorFilter.h" #include "SkFontHost.h" @@ -69,6 +71,7 @@ SkPaint::SkPaint() { fTextEncoding = kUTF8_TextEncoding; fHinting = SkPaintDefaults_Hinting; #ifdef SK_BUILD_FOR_ANDROID + new(&fTextLocale) SkString(); fGenerationID = 0; #endif } @@ -85,6 +88,9 @@ SkPaint::SkPaint(const SkPaint& src) { SkSafeRef(fRasterizer); SkSafeRef(fLooper); SkSafeRef(fImageFilter); +#ifdef SK_BUILD_FOR_ANDROID + new(&fTextLocale) SkString(src.fTextLocale); +#endif } SkPaint::~SkPaint() { @@ -123,10 +129,12 @@ SkPaint& SkPaint::operator=(const SkPaint& src) { SkSafeUnref(fImageFilter); #ifdef SK_BUILD_FOR_ANDROID + fTextLocale.~SkString(); uint32_t oldGenerationID = fGenerationID; #endif memcpy(this, &src, sizeof(src)); #ifdef SK_BUILD_FOR_ANDROID + new(&fTextLocale) SkString(src.fTextLocale); fGenerationID = oldGenerationID + 1; #endif @@ -357,6 +365,15 @@ void SkPaint::setTextEncoding(TextEncoding encoding) { } } +#ifdef SK_BUILD_FOR_ANDROID +void SkPaint::setTextLocale(const SkString& locale) { + if(!fTextLocale.equals(locale)) { + fTextLocale.set(locale); + GEN_ID_INC; + } +} +#endif + /////////////////////////////////////////////////////////////////////////////// SkTypeface* SkPaint::setTypeface(SkTypeface* font) { |