summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2014-12-15 22:31:48 +0100
committerAlexander Larsson <alexl@redhat.com>2014-12-15 22:31:48 +0100
commita1a01983f717a464e89ff2b569a5c61a2e3239c3 (patch)
tree058eb07447c5e95f83b2a74ac94d13dc3dfc0342 /gdk
parent2693496b56092cba65a49fb6f4199f5efbd5e5e2 (diff)
downloadgtk+-a1a01983f717a464e89ff2b569a5c61a2e3239c3.tar.gz
gdk: Fix scissoring with scaled windows
Make sure the window scale is always taken into acount when setting up the scissor regions.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkgl.c8
-rw-r--r--gdk/x11/gdkglcontext-x11.c18
2 files changed, 13 insertions, 13 deletions
diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
index 67fafab73a..bc08bbcdbb 100644
--- a/gdk/gdkgl.c
+++ b/gdk/gdkgl.c
@@ -702,11 +702,13 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
n_rects = cairo_region_num_rectangles (region);
+#define FLIP_Y(_y) (unscaled_window_height - (_y))
+
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (region, i, &rect);
- glScissor (rect.x * window_scale, unscaled_window_height - (rect.y + rect.height) * window_scale,
+ glScissor (rect.x * window_scale, FLIP_Y ((rect.y + rect.height) * window_scale),
rect.width * window_scale, rect.height * window_scale);
e = rect;
@@ -726,8 +728,6 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
cairo_surface_unmap_image (surface, image);
-#define FLIP_Y(_y) (unscaled_window_height - (_y))
-
if (use_texture_rectangle)
{
umax = rect.width * sx;
@@ -741,7 +741,7 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
{
GdkTexturedQuad quad = {
- rect.x * window_scale, FLIP_Y(rect.y),
+ rect.x * window_scale, FLIP_Y(rect.y * window_scale),
(rect.x + rect.width) * window_scale, FLIP_Y((rect.y + rect.height) * window_scale),
0, 0,
umax, vmax,
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index 566473a512..d686768ee5 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -424,7 +424,7 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
cairo_rectangle_int_t rect;
int n_rects, i;
GdkWindow *window;
- int window_height;
+ int unscaled_window_height;
int window_scale;
unsigned int texture_id;
gboolean use_texture_rectangle;
@@ -448,7 +448,7 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
window = gdk_gl_context_get_window (paint_context)->impl_window;
window_scale = gdk_window_get_scale_factor (window);
- window_height = gdk_window_get_height (window);
+ gdk_window_get_unscaled_size (window, NULL, &unscaled_window_height);
sx = sy = 1;
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
@@ -476,11 +476,11 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
n_rects = cairo_region_num_rectangles (region);
quads = g_new (GdkTexturedQuad, n_rects);
-#define FLIP_Y(_y) (window_height - (_y))
+#define FLIP_Y(_y) (unscaled_window_height - (_y))
cairo_region_get_extents (region, &rect);
- glScissor (rect.x * window_scale, FLIP_Y(rect.y) * window_scale,
- (rect.x + rect.width) * window_scale, FLIP_Y (rect.y + rect.height) * window_scale);
+ glScissor (rect.x * window_scale, FLIP_Y((rect.y + rect.height) * window_scale),
+ rect.width * window_scale, rect.height * window_scale);
for (i = 0; i < n_rects; i++)
{
@@ -506,8 +506,8 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
{
GdkTexturedQuad quad = {
- rect.x * window_scale, FLIP_Y(rect.y) * window_scale,
- (rect.x + rect.width) * window_scale, FLIP_Y(rect.y + rect.height) * window_scale,
+ rect.x * window_scale, FLIP_Y(rect.y * window_scale),
+ (rect.x + rect.width) * window_scale, FLIP_Y((rect.y + rect.height) * window_scale),
uscale * src_x, vscale * src_y,
uscale * (src_x + src_width), vscale * (src_y + src_height),
};
@@ -518,11 +518,11 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
#undef FLIP_Y
- glDisable (GL_SCISSOR_TEST);
-
gdk_gl_texture_quads (paint_context, target, n_rects, quads);
g_free (quads);
+ glDisable (GL_SCISSOR_TEST);
+
glXReleaseTexImageEXT (glx_pixmap->display, glx_pixmap->drawable,
GLX_FRONT_LEFT_EXT);