After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 613284 - Replace GdkRegion with cairo_region_t
Replace GdkRegion with cairo_region_t
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
2.21.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
deprecations
Depends on:
Blocks:
 
 
Reported: 2010-03-18 23:01 UTC by Benjamin Otte (Company)
Modified: 2011-02-04 16:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Implement GdkRegion in terms of cairo_region_t (59.45 KB, patch)
2010-03-24 19:10 UTC, Benjamin Otte (Company)
none Details | Review
Implement GdkRegion in terms of cairo_region_t (59.39 KB, patch)
2010-04-09 18:02 UTC, Benjamin Otte (Company)
none Details | Review
Remove _gdk_region_new_from_yxbanded_rects() (2.41 KB, patch)
2010-04-09 18:02 UTC, Benjamin Otte (Company)
none Details | Review
Deprecate the GdkRegion API (134.69 KB, patch)
2010-04-09 18:02 UTC, Benjamin Otte (Company)
none Details | Review
s/GdkRegion/cairo_region_t/ in all of gtk (101.87 KB, patch)
2010-04-09 18:02 UTC, Benjamin Otte (Company)
none Details | Review

Description Benjamin Otte (Company) 2010-03-18 23:01:48 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.)
Comment 1 Benjamin Otte (Company) 2010-03-24 19:10:02 UTC
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.
Comment 2 Benjamin Otte (Company) 2010-04-09 18:02:06 UTC
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.
Comment 3 Benjamin Otte (Company) 2010-04-09 18:02:09 UTC
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.
Comment 4 Benjamin Otte (Company) 2010-04-09 18:02:13 UTC
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.
Comment 5 Benjamin Otte (Company) 2010-04-09 18:02:17 UTC
Created attachment 158318 [details] [review]
s/GdkRegion/cairo_region_t/ in all of gtk
Comment 6 Benjamin Otte (Company) 2010-04-09 18:33:55 UTC
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.
Comment 7 Hiroyuki Ikezoe 2010-04-11 07:13:01 UTC
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?
Comment 8 Benjamin Otte (Company) 2010-04-12 11:58:55 UTC
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.
Comment 9 Javier Jardón (IRC: jjardon) 2010-05-02 13:26:23 UTC
This should be applied in 2.22 branch as some code will be deprecated.

Target Milestone -> 2.22
Comment 10 Benjamin Otte (Company) 2010-06-29 15:27:12 UTC
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.
Comment 11 Matthias Clasen 2010-08-10 03:21:54 UTC
Benjamin, any work left here ?
Comment 12 Benjamin Otte (Company) 2010-08-10 16:29:54 UTC
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.