aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkShader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkShader.cpp')
-rw-r--r--src/core/SkShader.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 9da760f843..9f97a7a74a 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -90,11 +90,23 @@ bool SkShader::asLuminanceColor(SkColor* colorPtr) const {
return false;
}
-SkShader::Context* SkShader::makeContext(const ContextRec& rec, SkArenaAlloc* alloc) const {
+SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage) const {
if (!this->computeTotalInverse(rec, nullptr)) {
return nullptr;
}
- return this->onMakeContext(rec, alloc);
+ return this->onCreateContext(rec, storage);
+}
+
+SkShader::Context* SkShader::onCreateContext(const ContextRec& rec, void*) const {
+ return nullptr;
+}
+
+size_t SkShader::contextSize(const ContextRec& rec) const {
+ return this->onContextSize(rec);
+}
+
+size_t SkShader::onContextSize(const ContextRec&) const {
+ return 0;
}
SkShader::Context::Context(const SkShader& shader, const ContextRec& rec)
@@ -274,7 +286,16 @@ bool SkShader::onAppendStages(SkRasterPipeline* p,
}
ContextRec rec(*opaquePaint, ctm, localM, ContextRec::kPM4f_DstType, cs);
- if (auto* ctx = this->makeContext(rec, alloc)) {
+ if (auto* ctx = this->createContext(rec,
+ alloc->makeArrayDefault<char>(this->contextSize(rec)))) {
+ struct ContextDestroyer {
+ ContextDestroyer(Context* ctx) : fContext(ctx) {}
+ ~ContextDestroyer() { fContext->~Context(); }
+
+ Context* fContext;
+ };
+
+ alloc->make<ContextDestroyer>(ctx);
p->append(SkRasterPipeline::shader_adapter, ctx);
// Legacy shaders aren't aware of color spaces. We can pretty