Skia is crashing on Windows x64, with the following example:
SkColor colors2[] = { SK_ColorBLUE, SK_ColorRED };
SkPoint pts[] = { {0.0f, 0.0f}, {100.0f, 100.0f} };
int main()
{
auto rasterSurface = SkSurface::MakeRasterN32Premul(100, 100);
SkCanvas* canvas = rasterSurface->getCanvas();
auto paint = new SkPaint();
auto gradient = SkGradientShader::MakeLinear(
pts,
colors2,
NULL,
2,
SkTileMode::kClamp,
0,
NULL);
//_paint->setColor(0xff00ff00);
paint->setShader(gradient);
canvas->drawPaint(*paint);
canvas->flush();
}
The drawPaint is crashing, but only with a linear shader. If I create a paint with a solid color, it works.
The following is the stack trace:
0000000000000000() Unknown
> skia.dll!SkShaderBase::makeContext(const SkShaderBase::ContextRec & rec, SkArenaAlloc * alloc) Line 65 C++
skia.dll!SkBlitter::Choose(const SkPixmap & device, const SkMatrixProvider & matrixProvider, const SkPaint & origPaint, SkArenaAlloc * alloc, bool drawCoverage, sk_sp<SkShader> clipShader, const SkSurfaceProps & props) Line 796 C++
[Inline Frame] skia.dll!SkAutoBlitterChoose::choose(const SkDraw & draw, const SkMatrixProvider * matrixProvider, const SkPaint & paint, bool drawCoverage) Line 39 C++
[Inline Frame] skia.dll!SkAutoBlitterChoose::SkAutoBlitterChoose(const SkDraw & draw, const SkMatrixProvider * matrixProvider, const SkPaint & paint, bool drawCoverage) Line 27 C++
skia.dll!SkDraw::drawPaint(const SkPaint & paint) Line 89 C++
skia.dll!SkBitmapDevice::drawPaint(const SkPaint & paint) Line 336 C++
skia.dll!SkCanvas::internalDrawPaint(const SkPaint & paint) Line 2056 C++
skia.dll!SkCanvas::drawPaint(const SkPaint & paint) Line 1836 C++
ConsoleApplication2.exe!main() Line 34 C++
[External Code]
So what I think is happening, is SkShaderBase::onMakeContext is a virtual method, and somehow the vtable is getting corrupt and onMakeContext is a null pointer.