From cb5701ecfa08563037c24cc7b8ed4bb2629ef70b Mon Sep 17 00:00:00 2001 From: Xin Qi Date: Thu, 27 Dec 2012 11:19:52 -0800 Subject: Several skia tunings for JB_2.5 * Optiming constructor of Paint object * Special copy path for small object * Global Language list instead of constructing a new obj everytime. Change-Id: I8d4687fffe055166a4758059872af09bfdc973d4 --- include/core/SkDraw.h | 2 ++ include/core/SkPaint.h | 28 ++++++++++++++++++++++++++-- include/core/SkRect.h | 11 +++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/core/SkDraw.h b/include/core/SkDraw.h index 8c659c2..ae323f2 100644 --- a/include/core/SkDraw.h +++ b/include/core/SkDraw.h @@ -104,6 +104,8 @@ private: void drawBitmapAsMask(const SkBitmap&, const SkPaint&) const; public: + //Be noted to update SkDraw::SkDraw() constructor code when struture is + //change! const SkBitmap* fBitmap; // required const SkMatrix* fMatrix; // required const SkRegion* fClip; // DEPRECATED diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index d2233f0..88f26f1 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -17,6 +17,7 @@ #include "SkString.h" #ifdef SK_BUILD_FOR_ANDROID +#include #include "SkLanguage.h" #endif @@ -42,6 +43,26 @@ typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**, typedef const SkGlyph& (*SkMeasureCacheProc)(SkGlyphCache*, const char**); +class SkLangList { + public: + SkLangList(); + + SkLanguage s; + SkLangList *next; +}; + +class SkLanguages { +public: + SkLanguages(); + SkLangList * setLanguage( const SkLanguage& locale ); + const SkLanguage& getLanguage( SkLangList * t ) const; + +private: + SkLangList * LocaleArray; + pthread_mutex_t update_mutex; +}; + + /** \class SkPaint The SkPaint class holds the style and color information about how to draw @@ -664,7 +685,8 @@ public: /** Return the paint's language value used for drawing text. @return the paint's language value used for drawing text. */ - const SkLanguage& getLanguage() const { return fLanguage; } + const SkLanguage& getLanguage() const; + /** Set the paint's language value used for drawing text. @param language set the paint's language value for drawing text. @@ -904,6 +926,8 @@ public: bool nothingToDraw() const; private: + //Be noted to update SkPaint::SkPaint(const SkPaint& src) copy + //constructor when struture is changed for fast path! SkTypeface* fTypeface; SkScalar fTextSize; SkScalar fTextScaleX; @@ -929,7 +953,7 @@ private: unsigned fTextEncoding : 2; // 3 values unsigned fHinting : 2; #ifdef SK_BUILD_FOR_ANDROID - SkLanguage fLanguage; + SkLangList* fpLanguage; FontVariant fFontVariant; #endif diff --git a/include/core/SkRect.h b/include/core/SkRect.h index 65e7611..64568c9 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -347,6 +347,16 @@ struct SK_API SkRect { */ bool isFinite() const { #ifdef SK_SCALAR_IS_FLOAT +#if defined(KRAIT_OPTIMIZATION) + if (SkScalarIsFinite(fBottom) && + SkScalarIsFinite(fRight) && + SkScalarIsFinite(fLeft) && + SkScalarIsFinite(fTop)) { + return true; + } else { + return false; + } +#else // x * 0 will be NaN iff x is infinity or NaN. // a + b will be NaN iff either a or b is NaN. float value = fLeft * 0 + fTop * 0 + fRight * 0 + fBottom * 0; @@ -354,6 +364,7 @@ struct SK_API SkRect { // value is either NaN or it is finite (zero). // value==value will be true iff value is not NaN return value == value; +#endif #else // use bit-or for speed, since we don't care about short-circuting the // tests, and we expect the common case will be that we need to check all. -- cgit v1.1