mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 980035 - Support 16bit volatile buffer backed decoded images, r=seth
This commit is contained in:
parent
bdfa6cf0c7
commit
fd158d8b34
@ -346,8 +346,33 @@ nsresult imgFrame::Optimize()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
gfxImageFormat optFormat =
|
||||
gfxPlatform::GetPlatform()->
|
||||
OptimalFormatForContent(gfxASurface::ContentFromFormat(mFormat));
|
||||
|
||||
if (optFormat == gfxImageFormat::RGB16_565) {
|
||||
RefPtr<VolatileBuffer> buf =
|
||||
LockedImageSurface::AllocateBuffer(mSize, optFormat);
|
||||
if (!buf)
|
||||
return NS_OK;
|
||||
|
||||
nsRefPtr<gfxImageSurface> surf =
|
||||
LockedImageSurface::CreateSurface(buf, mSize, optFormat);
|
||||
|
||||
gfxContext ctx(surf);
|
||||
ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx.SetSource(mImageSurface);
|
||||
ctx.Paint();
|
||||
|
||||
mImageSurface = surf;
|
||||
mVBuf = buf;
|
||||
mFormat = optFormat;
|
||||
}
|
||||
#else
|
||||
if (mOptSurface == nullptr)
|
||||
mOptSurface = gfxPlatform::GetPlatform()->OptimizeImage(mImageSurface, mFormat);
|
||||
#endif
|
||||
|
||||
if (mOptSurface) {
|
||||
mVBuf = nullptr;
|
||||
@ -632,25 +657,37 @@ nsresult imgFrame::LockImageData()
|
||||
mImageSurface = LockedImageSurface::CreateSurface(mVBuf, mSize, mFormat);
|
||||
if (!mImageSurface || mImageSurface->CairoStatus())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
} else if (mOptSurface || mSinglePixel) {
|
||||
}
|
||||
if (mOptSurface || mSinglePixel || mFormat == gfxImageFormat::RGB16_565) {
|
||||
gfxImageFormat format = mFormat;
|
||||
if (mFormat == gfxImageFormat::RGB16_565)
|
||||
format = gfxImageFormat::ARGB32;
|
||||
|
||||
// Recover the pixels
|
||||
mVBuf = LockedImageSurface::AllocateBuffer(mSize, mFormat);
|
||||
if (!mVBuf) {
|
||||
RefPtr<VolatileBuffer> buf =
|
||||
LockedImageSurface::AllocateBuffer(mSize, format);
|
||||
if (!buf) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mImageSurface = LockedImageSurface::CreateSurface(mVBuf, mSize, mFormat);
|
||||
if (!mImageSurface || mImageSurface->CairoStatus())
|
||||
RefPtr<gfxImageSurface> surf =
|
||||
LockedImageSurface::CreateSurface(buf, mSize, mFormat);
|
||||
if (!surf || surf->CairoStatus())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
gfxContext context(mImageSurface);
|
||||
gfxContext context(surf);
|
||||
context.SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
if (mSinglePixel)
|
||||
context.SetDeviceColor(mSinglePixelColor);
|
||||
else if (mFormat == gfxImageFormat::RGB16_565)
|
||||
context.SetSource(mImageSurface);
|
||||
else
|
||||
context.SetSource(mOptSurface);
|
||||
context.Paint();
|
||||
|
||||
mFormat = format;
|
||||
mVBuf = buf;
|
||||
mImageSurface = surf;
|
||||
mOptSurface = nullptr;
|
||||
#ifdef USE_WIN_SURFACE
|
||||
mWinSurface = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user