diff options
author | 2017-02-07 17:28:15 +0000 | |
---|---|---|
committer | 2017-02-07 17:28:21 +0000 | |
commit | dd8b72ae7319598cfc1024901e860c52f06e6ae1 (patch) | |
tree | b6e94e11c082c691512f8989ae55794fa2e6b756 /src/core/SkNormalMapSource.cpp | |
parent | 1f2fff2544a9dc6a0f169a017d374eca9f04c6b5 (diff) |
Revert "Use SkArenaAlloc instead of SkSmallAllocator in the SkAutoBlitterChoose code."
This reverts commit 2b57b7f7a7fc97db57f190b5a8ebcf68e177ee2d.
Reason for revert: Android compile failing
Original change's description:
> Use SkArenaAlloc instead of SkSmallAllocator in the SkAutoBlitterChoose code.
>
>
> TBR=reed@google.com
> Change-Id: Iefb044bf7657fbf982f23aa91a3f4d013ce2c626
> Reviewed-on: https://skia-review.googlesource.com/7786
> Reviewed-by: Mike Klein <mtklein@chromium.org>
> Reviewed-by: Herb Derby <herb@google.com>
> Commit-Queue: Herb Derby <herb@google.com>
>
TBR=mtklein@chromium.org,mtklein@google.com,herb@google.com,reed@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: Id09c35377dddae0811d998b7d0c34c422325a5bc
Reviewed-on: https://skia-review.googlesource.com/8129
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/core/SkNormalMapSource.cpp')
-rw-r--r-- | src/core/SkNormalMapSource.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/core/SkNormalMapSource.cpp b/src/core/SkNormalMapSource.cpp index 2d3d24181d..3a9f9cf76f 100644 --- a/src/core/SkNormalMapSource.cpp +++ b/src/core/SkNormalMapSource.cpp @@ -7,7 +7,6 @@ #include "SkNormalMapSource.h" -#include "SkArenaAlloc.h" #include "SkLightingShader.h" #include "SkMatrix.h" #include "SkNormalSource.h" @@ -137,29 +136,42 @@ sk_sp<GrFragmentProcessor> SkNormalMapSourceImpl::asFragmentProcessor( //////////////////////////////////////////////////////////////////////////// SkNormalMapSourceImpl::Provider::Provider(const SkNormalMapSourceImpl& source, - SkShader::Context* mapContext) + SkShader::Context* mapContext, + SkPaint* overridePaint) : fSource(source) - , fMapContext(mapContext) {} + , fMapContext(mapContext) + , fOverridePaint(overridePaint) {} + +SkNormalMapSourceImpl::Provider::~Provider() { + fMapContext->~Context(); + fOverridePaint->~SkPaint(); +} SkNormalSource::Provider* SkNormalMapSourceImpl::asProvider(const SkShader::ContextRec &rec, - SkArenaAlloc* alloc) const { + void *storage) const { SkMatrix normTotalInv; if (!this->computeNormTotalInverse(rec, &normTotalInv)) { return nullptr; } // Overriding paint's alpha because we need the normal map's RGB channels to be unpremul'd - SkPaint overridePaint {*(rec.fPaint)}; - overridePaint.setAlpha(0xFF); - SkShader::ContextRec overrideRec(overridePaint, *(rec.fMatrix), rec.fLocalMatrix, + void* paintStorage = (char*)storage + sizeof(Provider); + SkPaint* overridePaint = new (paintStorage) SkPaint(*(rec.fPaint)); + overridePaint->setAlpha(0xFF); + SkShader::ContextRec overrideRec(*overridePaint, *(rec.fMatrix), rec.fLocalMatrix, rec.fPreferredDstType, rec.fDstColorSpace); - SkShader::Context* context = fMapShader->makeContext(overrideRec, alloc); + void* mapContextStorage = (char*) paintStorage + sizeof(SkPaint); + SkShader::Context* context = fMapShader->createContext(overrideRec, mapContextStorage); if (!context) { return nullptr; } - return alloc->make<Provider>(*this, context); + return new (storage) Provider(*this, context, overridePaint); +} + +size_t SkNormalMapSourceImpl::providerSize(const SkShader::ContextRec& rec) const { + return sizeof(Provider) + sizeof(SkPaint) + fMapShader->contextSize(rec); } bool SkNormalMapSourceImpl::computeNormTotalInverse(const SkShader::ContextRec& rec, |