diff options
author | Herb Derby <herb@google.com> | 2018-01-23 13:39:21 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-23 21:55:50 +0000 |
commit | 980a48de64baf2f974f6c99096391280d1c1d22c (patch) | |
tree | 8268924145dd50b4e6ce3e2e01bb36fb536ca948 /src/core/SkScalerContext.h | |
parent | 27059d36d63284b1af2c25e0e5a52c17485c54d7 (diff) |
Move glyph cache and descriptor functions off of SkPaint
BUG=skia:7515
Change-Id: If17b157db1077a9a3c0f9efd03929f62a3486419
Reviewed-on: https://skia-review.googlesource.com/98841
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkScalerContext.h')
-rw-r--r-- | src/core/SkScalerContext.h | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h index 90cac5dc96..05d12637b2 100644 --- a/src/core/SkScalerContext.h +++ b/src/core/SkScalerContext.h @@ -8,6 +8,8 @@ #ifndef SkScalerContext_DEFINED #define SkScalerContext_DEFINED +#include <memory> + #include "SkGlyph.h" #include "SkMask.h" #include "SkMaskFilter.h" @@ -17,6 +19,7 @@ #include "SkTypeface.h" #include "SkWriteBuffer.h" +class SkAutoDescriptor; class SkDescriptor; class SkMaskFilter; class SkPathEffect; @@ -46,7 +49,6 @@ enum SkAxisAlignment { kY_SkAxisAlignment }; - /* * To allow this to be forward-declared, it must be its own typename, rather * than a nested struct inside SkScalerContext (where it started). @@ -280,11 +282,14 @@ public: SkScalerContextRec* rec, SkScalerContextEffects* effects); - template <typename A> - static auto CreateDescriptorGivenRecAndEffects( - const SkScalerContextRec &rec, - const SkScalerContextEffects &effects, - A alloc) -> decltype(alloc((size_t)0)); + static SkDescriptor* AutoDescriptorGivenRecAndEffects( + const SkScalerContextRec& rec, + const SkScalerContextEffects& effects, + SkAutoDescriptor* ad); + + static std::unique_ptr<SkDescriptor> DescriptorGivenRecAndEffects( + const SkScalerContextRec& rec, + const SkScalerContextEffects& effects); static SkMaskGamma::PreBlend GetMaskPreBlend(const SkScalerContextRec& rec); @@ -300,6 +305,12 @@ public: */ SkAxisAlignment computeAxisAlignmentForHText(); + static SkDescriptor* CreateDescriptorAndEffectsUsingPaint( + const SkPaint& paint, const SkSurfaceProps* surfaceProps, + SkScalerContextFlags scalerContextFlags, + const SkMatrix* deviceMatrix, SkAutoDescriptor* ad, + SkScalerContextEffects* effects); + protected: SkScalerContextRec fRec; @@ -353,16 +364,6 @@ protected: void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; } private: - static size_t CalculateSizeAndFlatten(const SkScalerContextRec& rec, - const SkScalerContextEffects& effects, - SkBinaryWriteBuffer* pathEffectBuffer, - SkBinaryWriteBuffer* maskFilterBuffer); - static void GenerateDescriptor(const SkScalerContextRec& rec, - const SkScalerContextEffects& effects, - SkBinaryWriteBuffer* pathEffectBuffer, - SkBinaryWriteBuffer* maskFilterBuffer, - SkDescriptor* desc); - friend class SkRandomScalerContext; // For debug purposes // never null @@ -389,22 +390,6 @@ private: const SkMaskGamma::PreBlend fPreBlendForFilter; }; -template <typename A> -inline auto SkScalerContext::CreateDescriptorGivenRecAndEffects( - const SkScalerContextRec &rec, - const SkScalerContextEffects &effects, - A alloc) -> decltype(alloc((size_t)0)) { - - SkBinaryWriteBuffer peBuffer, mfBuffer; - - auto desc = alloc(CalculateSizeAndFlatten(rec, effects, &peBuffer, &mfBuffer)); - - GenerateDescriptor(rec, effects, &peBuffer, &mfBuffer, &(*desc)); - - return desc; -} - - #define kRec_SkDescriptorTag SkSetFourByteTag('s', 'r', 'e', 'c') #define kPathEffect_SkDescriptorTag SkSetFourByteTag('p', 't', 'h', 'e') #define kMaskFilter_SkDescriptorTag SkSetFourByteTag('m', 's', 'k', 'f') |