Fix single leg Compose Shader crash.
R=halcanary@google.com BUG=skia:6291 Change-Id: Ifa63dce2b06662e7b535a4f04e1f3f772c099122 Reviewed-on: https://skia-review.googlesource.com/9027 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
33632d8eda
commit
e556bf76df
@ -69,12 +69,6 @@ void SkComposeShader::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.write32((int)fMode);
|
||||
}
|
||||
|
||||
template <typename T> void safe_call_destructor(T* obj) {
|
||||
if (obj) {
|
||||
obj->~T();
|
||||
}
|
||||
}
|
||||
|
||||
SkShader::Context* SkComposeShader::onMakeContext(
|
||||
const ContextRec& rec, SkArenaAlloc* alloc) const
|
||||
{
|
||||
@ -96,8 +90,6 @@ SkShader::Context* SkComposeShader::onMakeContext(
|
||||
SkShader::Context* contextA = fShaderA->makeContext(newRec, alloc);
|
||||
SkShader::Context* contextB = fShaderB->makeContext(newRec, alloc);
|
||||
if (!contextA || !contextB) {
|
||||
safe_call_destructor(contextA);
|
||||
safe_call_destructor(contextB);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,10 @@
|
||||
|
||||
#include "Test.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkImage.h"
|
||||
#include "SkPerlinNoiseShader.h"
|
||||
#include "SkRRect.h"
|
||||
#include "SkShader.h"
|
||||
#include "SkSurface.h"
|
||||
#include "SkData.h"
|
||||
@ -58,3 +61,21 @@ DEF_TEST(Shader_isABitmap, reporter) {
|
||||
check_isabitmap(reporter, shader0.get(), W, H, tmx, tmy, localM);
|
||||
check_isabitmap(reporter, shader1.get(), W, H, tmx, tmy, localM);
|
||||
}
|
||||
|
||||
// Make sure things are ok with just a single leg.
|
||||
DEF_TEST(ComposeShaderSingle, reporter) {
|
||||
SkBitmap srcBitmap;
|
||||
srcBitmap.allocN32Pixels(10, 10);
|
||||
srcBitmap.eraseColor(SK_ColorRED);
|
||||
SkCanvas canvas(srcBitmap);
|
||||
SkPaint p;
|
||||
p.setShader(
|
||||
SkShader::MakeComposeShader(
|
||||
SkShader::MakeEmptyShader(),
|
||||
SkPerlinNoiseShader::MakeFractalNoise(1.0f, 1.0f, 2, 0.0f),
|
||||
SkBlendMode::kClear));
|
||||
SkRRect rr;
|
||||
SkVector rd[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
|
||||
rr.setRectRadii({0, 0, 0, 0}, rd);
|
||||
canvas.drawRRect(rr, p);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user