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 776132 - Mention the difference between gdk_window_create_similar_image_surface and cairo_surface_create_similar_image
Mention the difference between gdk_window_create_similar_image_surface and ca...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
3.22.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-12-15 12:16 UTC by Debarshi Ray
Modified: 2016-12-17 21:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Mention that gdk_window_create_similar_image_surface inherits the scale (956 bytes, patch)
2016-12-15 12:18 UTC, Debarshi Ray
none Details | Review
Mention that gdk_window_create_similar_image_surface inherits the scale (969 bytes, patch)
2016-12-15 13:43 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2016-12-15 12:16:12 UTC
Commit ae5fe1aa218c30afb419d64aa121f3c575fe2f95 improved the gdk_window_create_similar_image_surface documentation by making it clear that the height and width are in pixels, not device-space units, and that they are not multiplied by the scaling factor.

That's good, but it is still confusing if you are dealing with all of these:
 (a) cairo_surface_create_similar
 (b) cairo_surface_create_similar_image
 (c) gdk_window_create_similar_image_surface

(a) inherits the device scale, (b) doesn't and (c) does. I think (b) and (c) sound deceptively similar that it is worth mentioning this. Never mind that the documentation for (b) is wrong about the units of its parameters.

I filed a cairo bug here:
https://bugs.freedesktop.org/show_bug.cgi?id=99094

Some conversation on #gtk+ about why (b) doesn't inherit the scale:

11:23 <rishi> alex: Hey! Why doesn't cairo_surface_create_similar_image         
      inherit the device scale?
11:23 <Company> rishi: because an image has pixels
11:24 <Company> rishi: and you can't have a 100px image have 100px with a 2x    
      scale
11:24 <rishi> Company: But an image surface can have a device scale.
11:25 <rishi> So, if I want to create a similar image surface, I'd expect the   
      scale to be copied.
11:25 <Company> rishi: but if you want 100px, we don't know if you really mean  
      100px at 2x scale or if you mean 200px
11:27 <Company> it's always wrong in 50% of cases
11:27 <rishi> Company: Note the *similar*. Otherwise I'd have used              
      cairo_image_surface_create.
11:27 <alex> If you loaded a jpg, and you want to show it, you don't want the   
      scale applied
11:27 <rishi> Either way, it would be good if this was explicitly mentioned.
11:27 <alex> similar just means "same backend"
11:27 <Company> rishi: push a doc fix!
11:27 <alex> or "efficient format for that backend"
11:28 <rishi> Because cairo_image_surface_create inherits the scale.
11:28 <rishi> Company: Yeah, I was going to do that. :)
11:28 <Company> rishi: what create_similar() does is usually shm-map the image  
      memory, so it can easier be copied to X, but that's about it
11:29 <alex> cairo_image_surface_create inherit scales from what?
11:29 <Company> cairo_image_surface_create() can't inherit anything
11:29 <rishi> alex: From the given surface.
11:30 <alex> it doesn't take an image
11:30 <Company> rishi probably means create_similar() on an image surface
11:30 <rishi> Oh, no. Wait.
11:30 <alex> surface
11:30 <rishi> I meant cairo_surface_create_similar.
11:30 <Company> but that's different
11:30 <alex> that is very different
11:30 <alex> thats an "abstract" surface
11:30 <Company> the equivalent is gdk_window_create_similar()
11:30 <Company> but create_image_surface() is about pixels
11:31 <alex> not something you can rely on to shove exact pixels into
11:31 <rishi> Company: alex: I know that it is different *after* reading the    
      code. :)
Comment 1 Debarshi Ray 2016-12-15 12:18:35 UTC
Created attachment 342018 [details] [review]
Mention that gdk_window_create_similar_image_surface inherits the scale
Comment 2 Emmanuele Bassi (:ebassi) 2016-12-15 13:28:00 UTC
Review of attachment 342018 [details] [review]:

::: gdk/gdkwindow.c
@@ +10188,3 @@
  * ]|
  *
+ * Not that unlike cairo_surface_create_similar_image(), the new

"Note"

@@ +10189,3 @@
  *
+ * Not that unlike cairo_surface_create_similar_image(), the new
+ * surface's device scale is set to @scale, or to that of @window if

"or to the scale factor of @window"
Comment 3 Debarshi Ray 2016-12-15 13:43:17 UTC
Created attachment 342027 [details] [review]
Mention that gdk_window_create_similar_image_surface inherits the scale
Comment 4 Matthias Clasen 2016-12-17 14:13:52 UTC
Review of attachment 342027 [details] [review]:

ok
Comment 5 Debarshi Ray 2016-12-17 21:51:16 UTC
Comment on attachment 342027 [details] [review]
Mention that gdk_window_create_similar_image_surface inherits the scale

Pushed to master and gtk-3-22.