mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 998042 - 4-byte align Skia surfaces to interoperate with Cairo r=jrmuizel
This commit is contained in:
parent
e5a53c61f3
commit
dd33849286
@ -837,20 +837,18 @@ DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
|
|||||||
aSize.width, aSize.height,
|
aSize.width, aSize.height,
|
||||||
GfxFormatToSkiaColorType(aFormat),
|
GfxFormatToSkiaColorType(aFormat),
|
||||||
alphaType);
|
alphaType);
|
||||||
|
// we need to have surfaces that have a stride aligned to 4 for interop with cairo
|
||||||
|
int stride = (BytesPerPixel(aFormat)*aSize.width + (4-1)) & -4;
|
||||||
|
|
||||||
SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(skiInfo));
|
SkBitmap bitmap;
|
||||||
if (!device) {
|
bitmap.setInfo(skiInfo, stride);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkBitmap bitmap = device->accessBitmap(true);
|
|
||||||
if (!bitmap.allocPixels()) {
|
if (!bitmap.allocPixels()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap.eraseARGB(0, 0, 0, 0);
|
bitmap.eraseARGB(0, 0, 0, 0);
|
||||||
|
|
||||||
mCanvas.adopt(new SkCanvas(device.get()));
|
mCanvas.adopt(new SkCanvas(bitmap));
|
||||||
mSize = aSize;
|
mSize = aSize;
|
||||||
|
|
||||||
mFormat = aFormat;
|
mFormat = aFormat;
|
||||||
|
Loading…
Reference in New Issue
Block a user