Index: include/core/SkPaint.h |
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h |
index a6c9bd4d198112e8f88e60ff5de8db16cbb68c72..06a3eb0e475a4a57af7d9b9b42e97a9904c2a40e 100644 |
--- a/include/core/SkPaint.h |
+++ b/include/core/SkPaint.h |
@@ -13,6 +13,7 @@ |
#include "SkColor.h" |
#include "SkDrawLooper.h" |
+#include "SkMatrix.h" |
#include "SkXfermode.h" |
#ifdef SK_BUILD_FOR_ANDROID |
#include "SkPaintOptionsAndroid.h" |
@@ -30,7 +31,6 @@ struct SkRect; |
class SkGlyphCache; |
class SkImageFilter; |
class SkMaskFilter; |
-class SkMatrix; |
class SkPath; |
class SkPathEffect; |
struct SkPoint; |
@@ -935,6 +935,22 @@ public: |
const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage, |
Style) const; |
+ /** |
+ * Return a matrix that applies the paint's text values: size, scale, skew |
+ */ |
+ static SkMatrix* SetTextMatrix(SkMatrix* matrix, SkScalar size, |
+ SkScalar scaleX, SkScalar skewX) { |
+ matrix->setScale(size * scaleX, size); |
+ if (skewX) { |
+ matrix->postSkew(skewX, 0); |
+ } |
+ return matrix; |
+ } |
+ |
+ SkMatrix* setTextMatrix(SkMatrix* matrix) const { |
+ return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX); |
+ } |
+ |
SkDEVCODE(void toString(SkString*) const;) |
private: |
@@ -989,8 +1005,31 @@ private: |
static void Term(); |
enum { |
- kCanonicalTextSizeForPaths = 64 |
+ /* This is the size we use when we ask for a glyph's path. We then |
+ * post-transform it as we draw to match the request. |
+ * This is done to try to re-use cache entries for the path. |
+ */ |
+ kCanonicalTextSizeForPaths = 64, |
+ |
+ /* |
+ * Above this size (taking into account CTM and textSize), we never use |
+ * the cache for bits or metrics (we might overflow), so we just ask |
+ * for a caononical size and post-transform that. |
+ */ |
+ kMaxSizeForGlyphCache = 256, |
bungeman-skia
2013/06/04 14:27:58
It seems odd that these two numbers would be diffe
reed1
2013/06/04 15:58:22
update comment.
|
}; |
+ |
+ static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM); |
+ |
+ bool tooBigToUseCache() const; |
+ bool tooBigToUseCache(const SkMatrix& ctm) const; |
+ |
+ static SkScalar MaxCacheSize2() { |
+ static const SkScalar kMaxSize = SkIntToScalar(kMaxSizeForGlyphCache); |
+ static const SkScalar kMag2Max = kMaxSize * kMaxSize; |
+ return kMag2Max; |
+ } |
+ |
friend class SkAutoGlyphCache; |
friend class SkCanvas; |
friend class SkDraw; |