mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1049138 - Use the cairo surface format to determine gfx format when able r=jmuizelaar
--HG-- extra : histedit_source : 9027bee76ab792d29a920bffb6443f40e6a35e13
This commit is contained in:
parent
71ebf71a67
commit
25c96c2585
@ -654,10 +654,9 @@ DrawTargetCairo::Snapshot()
|
||||
|
||||
IntSize size = GetSize();
|
||||
|
||||
cairo_content_t content = cairo_surface_get_content(mSurface);
|
||||
mSnapshot = new SourceSurfaceCairo(mSurface,
|
||||
size,
|
||||
CairoContentToGfxFormat(content),
|
||||
GfxFormatForCairoSurface(mSurface),
|
||||
this);
|
||||
return mSnapshot;
|
||||
}
|
||||
@ -1503,7 +1502,7 @@ DrawTargetCairo::InitAlreadyReferenced(cairo_surface_t* aSurface, const IntSize&
|
||||
mContext = cairo_create(aSurface);
|
||||
mSurface = aSurface;
|
||||
mSize = aSize;
|
||||
mFormat = aFormat ? *aFormat : CairoContentToGfxFormat(cairo_surface_get_content(aSurface));
|
||||
mFormat = aFormat ? *aFormat : GfxFormatForCairoSurface(aSurface);
|
||||
|
||||
// Cairo image surface have a bug where they will allocate a mask surface (for clipping)
|
||||
// the size of the clip extents, and don't take the surface extents into account.
|
||||
|
@ -216,6 +216,35 @@ CairoContentToGfxFormat(cairo_content_t content)
|
||||
return SurfaceFormat::B8G8R8A8;
|
||||
}
|
||||
|
||||
static inline SurfaceFormat
|
||||
CairoFormatToGfxFormat(cairo_format_t format)
|
||||
{
|
||||
switch (format) {
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
return SurfaceFormat::B8G8R8A8;
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
return SurfaceFormat::B8G8R8X8;
|
||||
case CAIRO_FORMAT_A8:
|
||||
return SurfaceFormat::A8;
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
return SurfaceFormat::R5G6B5;
|
||||
default:
|
||||
gfxWarning() << "Unknown cairo format";
|
||||
MOZ_ASSERT(false, "Unknown cairo format");
|
||||
return SurfaceFormat::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static inline SurfaceFormat
|
||||
GfxFormatForCairoSurface(cairo_surface_t* surface)
|
||||
{
|
||||
if (cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE) {
|
||||
return CairoFormatToGfxFormat(cairo_image_surface_get_format(surface));
|
||||
}
|
||||
|
||||
return CairoContentToGfxFormat(cairo_surface_get_content(surface));
|
||||
}
|
||||
|
||||
static inline void
|
||||
GfxMatrixToCairoMatrix(const Matrix& mat, cairo_matrix_t& retval)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user