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 670979 - screen-grabber: Fix area screenshots
screen-grabber: Fix area screenshots
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2012-02-28 15:07 UTC by Florian Müllner
Modified: 2012-03-02 10:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screen-grabber: Fix area screenshots (1.62 KB, patch)
2012-02-28 15:07 UTC, Florian Müllner
needs-work Details | Review
screen-grabber: Fix area screenshots (1.59 KB, patch)
2012-02-28 17:16 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2012-02-28 15:07:06 UTC
Follow-up fix for bug 669366 - see patch. OpenGL makes me cry ...
Comment 1 Florian Müllner 2012-02-28 15:07:09 UTC
Created attachment 208587 [details] [review]
screen-grabber: Fix area screenshots

Our DBus API (and mostly every other API in existence) define an
area as the top-left corner and width/height; glReadPixels on the
other hand uses the bottom-left corner, so we have to transform the
coordinates before passing them to GL.
Comment 2 Owen Taylor 2012-02-28 16:25:36 UTC
Review of attachment 208587 [details] [review]:

::: src/shell-screen-grabber.c
@@ +170,3 @@
+       * top-left */
+      glGetIntegerv (GL_VIEWPORT, &vp_size);
+      y = vp_size[3] - vp_size[1] /* buffer height */ - height - y;

from 'man glGetInteger'

       GL_VIEWPORT              params  returns  four  values:  the x and y window coordinates of the viewport, followed by its width and
                                height.  Initially the x and y window coordinates are both set to 0, and the width and height are set  to
                                the width and height of the window into which the GL will do its rendering.  See glViewport.

So, vp_size[3] - vp_size[1] is definitely not 'buffer height'. You are making an implicit assumption here that the viewport hasn't been changed from the original value or this would be invalid (glReadPixels doesn't care about the size of the viewport), so you probably just want:

 y = vp_size[3] - (y + height);
Comment 3 Florian Müllner 2012-02-28 17:16:46 UTC
Created attachment 208614 [details] [review]
screen-grabber: Fix area screenshots

(In reply to comment #2)
> from 'man glGetInteger'
> 
>        GL_VIEWPORT              params  returns  four  values:  the x and y
> window coordinates of the viewport, followed by its width and
>                                 height.  Initially the x and y window
> coordinates are both set to 0, and the width and height are set  to
>                                 the width and height of the window into which
> the GL will do its rendering.  See glViewport.

Gah, you're right - sorry, only read `man glReadPixels` :(
Comment 4 drago01 2012-03-02 10:36:29 UTC
Review of attachment 208614 [details] [review]:

Looks good.
Comment 5 Florian Müllner 2012-03-02 10:51:18 UTC
Attachment 208614 [details] pushed as ca61287 - screen-grabber: Fix area screenshots