Index: include/core/SkPaint.h |
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h |
index 95fc0b87ad0be45dc85cd0569849c24e766d50d6..c750d0da322fe5aae9a56a5e2a0ceaf8e0cb0eb2 100644 |
--- a/include/core/SkPaint.h |
+++ b/include/core/SkPaint.h |
@@ -13,6 +13,7 @@ |
#include "SkColor.h" |
#include "SkDrawLooper.h" |
+#include "SkFont.h" |
#include "SkMatrix.h" |
#include "SkXfermode.h" |
#ifdef SK_BUILD_FOR_ANDROID |
@@ -1036,7 +1037,11 @@ public: |
static void Unflatten(SkReadBuffer& buffer, SkPaint* paint); |
}; |
+ SkFont* testing_getCachedFont() { return this->getCachedFont(); } |
+ |
private: |
+ SkFont* fCachedFont; |
+ |
SkTypeface* fTypeface; |
SkPathEffect* fPathEffect; |
SkShader* fShader; |
@@ -1074,6 +1079,19 @@ private: |
uint32_t getBitfields() const { return fBitfields; } |
void setBitfields(uint32_t bitfields); |
+ SkFont* getCachedFont() { |
+ if (NULL == fCachedFont) { |
+ fCachedFont = SkFont::Testing_CreateFromPaint(*this); |
+ } |
+ return fCachedFont; |
+ } |
+ void dirtyCachedFont(bool somethingChanged) { |
+ if (somethingChanged && fCachedFont) { |
+ fCachedFont->unref(); |
+ fCachedFont = NULL; |
+ } |
+ } |
+ |
SkDrawCacheProc getDrawCacheProc() const; |
SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir, |
bool needFullMetrics) const; |