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,
|
||||
GfxFormatToSkiaColorType(aFormat),
|
||||
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));
|
||||
if (!device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkBitmap bitmap = device->accessBitmap(true);
|
||||
SkBitmap bitmap;
|
||||
bitmap.setInfo(skiInfo, stride);
|
||||
if (!bitmap.allocPixels()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bitmap.eraseARGB(0, 0, 0, 0);
|
||||
|
||||
mCanvas.adopt(new SkCanvas(device.get()));
|
||||
mCanvas.adopt(new SkCanvas(bitmap));
|
||||
mSize = aSize;
|
||||
|
||||
mFormat = aFormat;
|
||||
|
Loading…
Reference in New Issue
Block a user