diff options
author | Herb Derby <herb@google.com> | 2018-02-07 17:47:59 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-14 18:50:39 +0000 |
commit | 67c47f23290f3f947f35deb1145883d57d2c8c61 (patch) | |
tree | 32a69de5d6a4fa97ea2a145ea342393406b460c2 /src/core/SkTypeface_remote.h | |
parent | 8b6a9ae7010b11b9d43d518257d7514619bd0fbb (diff) |
Add glyph cache warming - prototype
A system for prewarming the cache using a single "RPC"
This improve performance by ~5X.
This is a checkin of rough code so I can use small
changes clean it up.
BUG=skia:7515
Change-Id: Id0192b4f533c257b0a7eea0170b1e25c336d6432
Reviewed-on: https://skia-review.googlesource.com/105440
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkTypeface_remote.h')
-rw-r--r-- | src/core/SkTypeface_remote.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/core/SkTypeface_remote.h b/src/core/SkTypeface_remote.h index b8d972f1c9..750ec21ebe 100644 --- a/src/core/SkTypeface_remote.h +++ b/src/core/SkTypeface_remote.h @@ -12,6 +12,7 @@ #include "SkDescriptor.h" #include "SkFontDescriptor.h" #include "SkFontStyle.h" +#include "SkPaint.h" #include "SkScalerContext.h" #include "SkTypeface.h" @@ -27,14 +28,6 @@ public: const SkTypefaceProxy& tf, const SkScalerContextRec& rec, SkPaint::FontMetrics*) = 0; - virtual void generateMetrics( - const SkTypefaceProxy& tf, - const SkScalerContextRec& rec, - SkGlyph* glyph) = 0; - virtual void generateImage( - const SkTypefaceProxy& tf, - const SkScalerContextRec& rec, - const SkGlyph& glyph) = 0; virtual void generateMetricsAndImage( const SkTypefaceProxy& tf, const SkScalerContextRec& rec, @@ -54,6 +47,11 @@ public: const SkDescriptor* desc, SkRemoteScalerContext* rsc); + void setFontMetrics(const SkPaint::FontMetrics& fontMetrics) { + fFontMetrics = fontMetrics; + fHaveFontMetrics = true; + } + protected: unsigned generateGlyphCount(void) override { SK_ABORT("Should never be called."); return 0;} uint16_t generateCharToGlyph(SkUnichar uni) override { @@ -72,10 +70,13 @@ private: static constexpr size_t kMinGlyphCount = 8; static constexpr size_t kMinGlyphImageSize = 16 /* height */ * 8 /* width */; static constexpr size_t kMinAllocAmount = kMinGlyphImageSize * kMinGlyphCount; - SkArenaAlloc fAlloc{kMinAllocAmount}; SkTypefaceProxy* typefaceProxy(); + + SkArenaAlloc fAlloc{kMinAllocAmount}; SkRemoteScalerContext* const fRemote; + bool fHaveFontMetrics{false}; + SkPaint::FontMetrics fFontMetrics; typedef SkScalerContext INHERITED; }; @@ -90,6 +91,10 @@ public: , fFontId{fontId} , fRsc{rsc} { } SkFontID fontID() const {return fFontId;} + static SkTypefaceProxy* DownCast(SkTypeface* typeface) { + // TODO: how to check the safty of the down cast. + return (SkTypefaceProxy*) typeface; + } protected: int onGetUPEM() const override { SK_ABORT("Should never be called."); return 0; } |