Index: src/effects/gradients/SkGradientShaderPriv.h |
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h |
index f850994761e02eea77aac6e6516794a60c00a55f..61a44184ff27d006accd60dc6babdac4156398df 100644 |
--- a/src/effects/gradients/SkGradientShaderPriv.h |
+++ b/src/effects/gradients/SkGradientShaderPriv.h |
@@ -115,7 +115,6 @@ public: |
SkAutoMalloc fDynamicStorage; |
}; |
-public: |
SkGradientShaderBase(const Descriptor& desc, const SkMatrix& ptsToUnit); |
virtual ~SkGradientShaderBase(); |
@@ -159,6 +158,8 @@ public: |
uint32_t getFlags() const override { return fFlags; } |
+ bool isValid() const; |
+ |
protected: |
SkMatrix fDstToIndex; |
SkMatrix::MapXYProc fDstToIndexProc; |
@@ -233,6 +234,16 @@ protected: |
SkColor* colorSrc, Rec* recSrc, |
int count); |
+ template <typename T, typename... Args> |
+ static Context* CheckedCreateContext(void* storage, Args&&... args) { |
+ auto* ctx = new (storage) T(std::forward<Args>(args)...); |
+ if (!ctx->isValid()) { |
+ ctx->~T(); |
+ return nullptr; |
+ } |
+ return ctx; |
+ } |
+ |
private: |
enum { |
kColorStorageCount = 4, // more than this many colors, and we'll use sk_malloc for the space |