Avoid double-destruction of Sk3DShaderContext-wrapped objects

Sk3DShaderContext creates its nested shader context on a SkArenaAlloc,
which handles destruction when going out of scope.

Hence, the explicit context dtor call in ~Sk3DShaderContext() is
incorrect (likely left over from before SkArenaAlloc).

BUG=chromium:787712

Change-Id: I176222e449151dcce532a839ef9587d06f61d297
Reviewed-on: https://skia-review.googlesource.com/77203
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
Florin Malita 2017-11-28 17:54:23 -05:00 committed by Skia Commit-Bot
parent 7b8e30a196
commit 1ba5bfe590
2 changed files with 18 additions and 6 deletions

View File

@ -715,11 +715,7 @@ public:
}
}
~Sk3DShaderContext() override {
if (fProxyContext) {
fProxyContext->~Context();
}
}
~Sk3DShaderContext() override = default;
void set3DMask(const SkMask* mask) override { fMask = mask; }
@ -790,7 +786,7 @@ public:
private:
// Unowned.
const SkMask* fMask;
// Memory is unowned, but we need to call the destructor.
// Memory is unowned.
Context* fProxyContext;
SkPMColor fPMColor;

View File

@ -15,6 +15,8 @@
#include "SkMath.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPerlinNoiseShader.h"
#include "SkSurface.h"
#include "Test.h"
#if SK_SUPPORT_GPU
@ -651,4 +653,18 @@ DEF_TEST(BlurredRRectNinePatchComputation, reporter) {
}
// https://crbugs.com/787712
DEF_TEST(EmbossPerlinCrash, reporter) {
SkPaint p;
static constexpr SkEmbossMaskFilter::Light light = {
{ 1, 1, 1 }, 0, 127, 127
};
p.setMaskFilter(SkEmbossMaskFilter::Make(1, light));
p.setShader(SkPerlinNoiseShader::MakeFractalNoise(1.0f, 1.0f, 2, 0.0f));
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100);
surface->getCanvas()->drawPaint(p);
}
///////////////////////////////////////////////////////////////////////////////////////////