From 89ab2406f7845b8e62fb8dd479e5fff5bf5ccf10 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Wed, 1 Nov 2017 10:14:57 -0400 Subject: 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 Commit-Queue: Florin Malita --- src/shaders/gradients/SkGradientShaderPriv.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/shaders/gradients/SkGradientShaderPriv.h') 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 fStorage; + + bool fColorsAreOpaque; typedef SkShaderBase INHERITED; }; -- cgit v1.2.3