From 8d2fb470729b7a9987aec8c5354ca7a4940ae3be Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Mon, 30 Jan 2017 11:33:46 -0500 Subject: [PATCH] Implement onAppendStages for SkPictureShader BUG=skia: Change-Id: Ibc525a666f17fed1d987c0316b1963ebed7de343 Reviewed-on: https://skia-review.googlesource.com/7739 Commit-Queue: Yuqian Li Reviewed-by: Mike Klein --- src/core/SkPictureShader.cpp | 10 ++++++++++ src/core/SkPictureShader.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index 1f20623..af66eb2 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -7,6 +7,7 @@ #include "SkPictureShader.h" +#include "SkArenaAlloc.h" #include "SkBitmap.h" #include "SkBitmapProcShader.h" #include "SkCanvas.h" @@ -255,6 +256,15 @@ SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* return PictureShaderContext::Create(storage, *this, rec, bitmapShader); } +bool SkPictureShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* cs, SkArenaAlloc* alloc, + const SkMatrix& ctm, const SkPaint& paint, + const SkMatrix* localMatrix) const { + // Keep bitmapShader alive by using alloc instead of stack memory + auto& bitmapShader = *alloc->make>(); + bitmapShader = this->refBitmapShader(ctm, localMatrix, cs); + return bitmapShader && bitmapShader->appendStages(p, cs, alloc, ctm, paint); +} + ///////////////////////////////////////////////////////////////////////////////////////// SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage, diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h index 6de7e4a..ff83fa3 100644 --- a/src/core/SkPictureShader.h +++ b/src/core/SkPictureShader.h @@ -36,6 +36,8 @@ protected: void flatten(SkWriteBuffer&) const override; size_t onContextSize(const ContextRec&) const override; Context* onCreateContext(const ContextRec&, void* storage) const override; + bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, + const SkMatrix&, const SkPaint&, const SkMatrix*) const override; private: SkPictureShader(sk_sp, TileMode, TileMode, const SkMatrix*, const SkRect*); -- 2.7.4