Closed Bug 516973 Opened 15 years ago Closed 15 years ago

Mismatch between Cairo and Thebes surface types

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a1

People

(Reporter: steffen.imhof, Assigned: steffen.imhof)

Details

Attachments

(1 file)

In gfxASurface::GetType() there is a quite optimistic cast from one surface type enum into the other:
   
   return (gfxSurfaceType)cairo_surface_get_type(mSurface);

That only works as long as both enums have an identical list of values. Which is currently not the case. Observe:

typedef enum _cairo_surface_type {      typedef enum {

    CAIRO_SURFACE_TYPE_IMAGE,                SurfaceTypeImage,
    CAIRO_SURFACE_TYPE_PDF,                  SurfaceTypePDF,
    CAIRO_SURFACE_TYPE_PS,                   SurfaceTypePS,
    CAIRO_SURFACE_TYPE_XLIB,                 SurfaceTypeXlib,
    CAIRO_SURFACE_TYPE_XCB,                  SurfaceTypeXcb,
    CAIRO_SURFACE_TYPE_GLITZ,                SurfaceTypeGlitz,
    CAIRO_SURFACE_TYPE_QUARTZ,               SurfaceTypeQuartz,
    CAIRO_SURFACE_TYPE_WIN32,                SurfaceTypeWin32,
    CAIRO_SURFACE_TYPE_BEOS,                 SurfaceTypeBeOS,
    CAIRO_SURFACE_TYPE_DIRECTFB,             SurfaceTypeDirectFB,
    CAIRO_SURFACE_TYPE_SVG,                  SurfaceTypeSVG,
    CAIRO_SURFACE_TYPE_OS2,                  SurfaceTypeOS2,
    CAIRO_SURFACE_TYPE_WIN32_PRINTING,       SurfaceTypeWin32Printing,
    CAIRO_SURFACE_TYPE_QUARTZ_IMAGE,         SurfaceTypeQuartzImage,
    CAIRO_SURFACE_TYPE_SCRIPT,               SurfaceTypeQPainter,
    CAIRO_SURFACE_TYPE_QT,                   SurfaceTypeDDraw
    CAIRO_SURFACE_TYPE_META,
    CAIRO_SURFACE_TYPE_DDRAW                 } gfxSurfaceType;

} cairo_surface_type_t;


This leads for example to non-rendering native widgets in the Qt build, because the surface type returned by gfxASurface is wrong.

One could simply bring both enums in sync again, but I think a better long-term solution would be to have a real mapping, so that errors like that don't creep in silently.
Sounds like this crept in with the latest cairo update, and jeff didn't update the gfxSurfaceType list.

We can't have a direct mapping in the enum, since we can't include the cairo.h header in the (public) thebes header.   However, gfxASurface.cpp should have some static asserts for each of the enums, to ensure that their values are equal to the cairo enum.
Assignee: nobody → jmuizelaar
I like the idea of the compile time asserts.

The main issue must have crept in by a cairo update a good while ago. It is  broken in the 1.9.2 branch, too. (Which is where I stumbled upon it, I just used the latest trunk code to write this bug.)

So maybe we want to just fix the enum values in the 1.9.2 branch and implement compile time asserts in the trunk to prevent future problems.
I attached the patch I'm currently using on the 1.9.2 branch.
Attachment #401169 - Flags: review?(jmuizelaar)
Comment on attachment 401169 [details] [diff] [review]
Patch for trunk that only adds the missing enum value to gfxASurface

This puts enums in sync on 1.9.2 right? If so, this looks good to me.
Attachment #401169 - Flags: review?(jmuizelaar) → review+
Yeah, though we should do the static asserts on 1.9.2 as well -- otherwise if we end up taking a cairo update down the line, this might bite us.
I assume this patch won't make it into 1.9.2 anymore.

Steffen, does this patch apply cleanly to mozilla-central? Is it needed for mozilla-central?
As of today (revision a43e2f7eda8f) this applies on trunk without any problems.
And it is needed for mozilla-central, too.
Attachment #401169 - Attachment description: Patch for 1.9.2 branch that only adds the missing enum value to gfxASurface → Patch for trunk that only adds the missing enum value to gfxASurface
let's rename the patch to make sure it gets to "trunk" and add checkin-needed keyword.
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/8e7933e5525e
Assignee: jmuizelaar → steffen.imhof
Status: NEW → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: