GNOME Bugzilla – Bug 613284
Replace GdkRegion with cairo_region_t
Last modified: 2011-02-04 16:12:18 UTC
I'm willing to do a patch, but was wondering what the scope should be: Should Gtk 3 remove GdkRegion completely or should we map GdkRegion onto cairo_region_t? Also, what about the GdkSpan stuff? That looks a lot like it should just go away, too. (Note: nothing about that is deprecated yet unfortunately.)
Created attachment 157012 [details] [review] Implement GdkRegion in terms of cairo_region_t Only changes in headers: GdkRegion and GdkRectangle are typedeffed to cairo_region_t and cairo_rectangle_int_t respectively. The region type was opaque anyway so it doesn't matter and the rectangle types are identical.
Created attachment 158315 [details] [review] Implement GdkRegion in terms of cairo_region_t Only changes in headers: GdkRegion and GdkRectangle are typedeffed to cairo_region_t and cairo_rectangle_int_t respectively. The region type was opaque anyway so it doesn't matter and the rectangle types are identical.
Created attachment 158316 [details] [review] Remove _gdk_region_new_from_yxbanded_rects() It was an internal function and we can use cairo_region_create_rectangles() instead.
Created attachment 158317 [details] [review] Deprecate the GdkRegion API Includes fixing all callers to use the cairo region API instead. This is usually just replacing the function names, the only difference is gdk_region_get_rectangles() being replaced by cairo_region_num_rectangles() and cairo_region_get_rectangle() which required a bit more work.
Created attachment 158318 [details] [review] s/GdkRegion/cairo_region_t/ in all of gtk
Here's an updated patch that almost completely deprecates GdkRegion and replaces it with cairo_region_t. Thre's a few caveats that I'm not sure how to handle: - GdkRectangle. It makes sense to typedef it to cairo_rectangle_int_t, but I'm not sure if GdkRectangle should go away or be a convenient wrapper about that ugly name. - Code might forward declare "typedef struct _GdkRegion GdkRegion" - C++ code likes to do that. Webkit does that for "typedef struct _GdkRectangle GdkRectangle". This will break with my patch. Do we consider this valid? (For Gtk 3.0 we should definitely get rid of GdkRegion, so it doesn't matter). - These patches pull in cairo.h into the gdk.h header while it was previously only inside gdkcairo.h. I don't think that's a problem, but thought I'd mention it. - Two functions aren't deprecated. I think gdk_region_polygon() should just go away (and the GtkMenu code be replaced) and gdk_region_rect_equal() should get an equivalent in Cairo. I'll take care of that in followup patches.
Review of attachment 158318 [details] [review]: ::: gdk/directfb/gdkdrawable-directfb.c @@ +544,3 @@ for (i = 0; i < clip.numRects; i++) { + cairo_region_tBox *box = &clip.rects[i]; ovekill?
Oh right: I didn't look at the DirectFB code at all. I still assume it'll die with Gtk 3 - if not, I'll go fix it.
This should be applied in 2.22 branch as some code will be deprecated. Target Milestone -> 2.22
These patches have landed in Gtk 3. After discussion with Matthias, I decided to not push them to Gtk 2.22 because that would mean Gtk 2.22 would depend on Cairo 1.10. Unfortunately we cannot deprecate GdkRegion in Gtk 2 that way, but as the transition is pretty much a search and replace job, we decided that is ok. I'll go ahead and deprecate the region APIs in Gtk2 that have no replacement in Cairo and can be safely deprecated and add a note to the documentation that GdkRegion will be replaced in Gtk 3 and then close this bug.
Benjamin, any work left here ?
I just looked at it again. I undeprecated gdk_region_xor() (as we have that in Cairo now) and added a blurb to the GdkRegion 2.22 docs. So I guess we can close this.