diff options
author | 2017-11-01 10:14:57 -0400 | |
---|---|---|
committer | 2017-11-01 17:35:10 +0000 | |
commit | 89ab2406f7845b8e62fb8dd479e5fff5bf5ccf10 (patch) | |
tree | 06b1998554a8ee1d56872ba51c2f3dd40572186c /src/shaders/gradients/SkGradientShaderPriv.h | |
parent | 85e98387a32e3e6e6c05986b23b47aee8c8c4aa7 (diff) |
Gradient cleanup pass
1) replace manual storage management with SkAutoSTMalloc
2) simplify explicit positions processing (remove redundant branch)
Change-Id: I7841e2018ac421768ed1d61c4e3ef6a1d28f6244
Reviewed-on: https://skia-review.googlesource.com/66146
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/shaders/gradients/SkGradientShaderPriv.h')
-rw-r--r-- | src/shaders/gradients/SkGradientShaderPriv.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/shaders/gradients/SkGradientShaderPriv.h b/src/shaders/gradients/SkGradientShaderPriv.h index 7084dc67b8..0ef86265a4 100644 --- a/src/shaders/gradients/SkGradientShaderPriv.h +++ b/src/shaders/gradients/SkGradientShaderPriv.h @@ -117,14 +117,6 @@ protected: TileMode fTileMode; uint8_t fGradFlags; -private: - enum { - kColorStorageCount = 4, // more than this many colors, and we'll use sk_malloc for the space - - kStorageSize = kColorStorageCount * (sizeof(SkColor4f) + sizeof(SkScalar)) - }; - SkColor4f fStorage[(kStorageSize + sizeof(SkColor4f) - 1) / sizeof(SkColor4f)]; - public: SkScalar getPos(int i) const { SkASSERT(i < fColorCount); @@ -146,7 +138,13 @@ public: TileMode getTileMode() const { return fTileMode; } private: - bool fColorsAreOpaque; + // Reserve inline space for up to 4 stops. + static constexpr size_t kInlineStopCount = 4; + static constexpr size_t kInlineStorageSize = (sizeof(SkColor4f) + sizeof(SkScalar)) + * kInlineStopCount; + SkAutoSTMalloc<kInlineStorageSize, uint8_t> fStorage; + + bool fColorsAreOpaque; typedef SkShaderBase INHERITED; }; |