mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1023194 - Fix stride calculation on 16 bit images, r=seth
This commit is contained in:
parent
54ba3c6c85
commit
2667ce024f
@ -36,6 +36,13 @@ VolatileBufferRelease(void *vbuf)
|
||||
delete static_cast<VolatileBufferPtr<unsigned char>*>(vbuf);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
VolatileSurfaceStride(const IntSize& size, SurfaceFormat format)
|
||||
{
|
||||
// Stride must be a multiple of four or cairo will complain.
|
||||
return (size.width * BytesPerPixel(format) + 0x3) & ~0x3;
|
||||
}
|
||||
|
||||
static TemporaryRef<DataSourceSurface>
|
||||
CreateLockedSurface(VolatileBuffer *vbuf,
|
||||
const IntSize& size,
|
||||
@ -45,7 +52,7 @@ CreateLockedSurface(VolatileBuffer *vbuf,
|
||||
new VolatileBufferPtr<unsigned char>(vbuf);
|
||||
MOZ_ASSERT(!vbufptr->WasBufferPurged(), "Expected image data!");
|
||||
|
||||
int32_t stride = size.width * BytesPerPixel(format);
|
||||
int32_t stride = VolatileSurfaceStride(size, format);
|
||||
RefPtr<DataSourceSurface> surf =
|
||||
Factory::CreateWrappingDataSourceSurface(*vbufptr, stride, size, format);
|
||||
if (!surf) {
|
||||
@ -60,7 +67,7 @@ CreateLockedSurface(VolatileBuffer *vbuf,
|
||||
static TemporaryRef<VolatileBuffer>
|
||||
AllocateBufferForImage(const IntSize& size, SurfaceFormat format)
|
||||
{
|
||||
int32_t stride = size.width * BytesPerPixel(format);
|
||||
int32_t stride = VolatileSurfaceStride(size, format);
|
||||
RefPtr<VolatileBuffer> buf = new VolatileBuffer();
|
||||
if (buf->Init(stride * size.height,
|
||||
1 << gfxAlphaRecovery::GoodAlignmentLog2()))
|
||||
|
Loading…
Reference in New Issue
Block a user