mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
Use fractional scale for the GL renderer
This commit combines changes in the Wayland backend, the GL context frontend, and the GL renderer to switch them all to use the fractional scale. In the Wayland backend, we now use the fractional scale to size the EGL window. In the GL frontend code, we use the fractional scale to scale the damage region and surface in begin/end_frame. And in the GL renderer, we replace gdk_surface_get_scale_factor() with gdk_surface_get_scale().
This commit is contained in:
parent
519cde95f0
commit
fa58dd9256
@ -94,6 +94,8 @@
|
||||
#include <epoxy/egl.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define DEFAULT_ALLOWED_APIS GDK_GL_API_GL | GDK_GL_API_GLES
|
||||
|
||||
typedef struct {
|
||||
@ -586,8 +588,8 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
|
||||
cairo_region_union (region, damage);
|
||||
cairo_region_destroy (damage);
|
||||
|
||||
ww = gdk_surface_get_width (surface) * gdk_surface_get_scale_factor (surface);
|
||||
wh = gdk_surface_get_height (surface) * gdk_surface_get_scale_factor (surface);
|
||||
ww = (int) ceil (gdk_surface_get_width (surface) * gdk_surface_get_scale (surface));
|
||||
wh = (int) ceil (gdk_surface_get_height (surface) * gdk_surface_get_scale (surface));
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
@ -631,7 +633,7 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
|
||||
EGLint *heap_rects = NULL;
|
||||
int i, j, n_rects = cairo_region_num_rectangles (painted);
|
||||
int surface_height = gdk_surface_get_height (surface);
|
||||
int scale = gdk_surface_get_scale_factor (surface);
|
||||
double scale = gdk_surface_get_scale (surface);
|
||||
EGLint *rects;
|
||||
|
||||
if (n_rects < G_N_ELEMENTS (stack_rects) / 4)
|
||||
@ -644,10 +646,10 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (painted, i, &rect);
|
||||
rects[j++] = rect.x * scale;
|
||||
rects[j++] = (surface_height - rect.height - rect.y) * scale;
|
||||
rects[j++] = rect.width * scale;
|
||||
rects[j++] = rect.height * scale;
|
||||
rects[j++] = (int) floor (rect.x * scale);
|
||||
rects[j++] = (int) floor ((surface_height - rect.height - rect.y) * scale);
|
||||
rects[j++] = (int) ceil (rect.width * scale);
|
||||
rects[j++] = (int) ceil (rect.height * scale);
|
||||
}
|
||||
priv->eglSwapBuffersWithDamage (gdk_display_get_egl_display (display), egl_surface, rects, n_rects);
|
||||
g_free (heap_rects);
|
||||
|
@ -259,8 +259,9 @@ gdk_wayland_surface_update_size (GdkSurface *surface,
|
||||
|
||||
if (impl->display_server.egl_window)
|
||||
wl_egl_window_resize (impl->display_server.egl_window,
|
||||
width * gdk_fractional_scale_to_int (scale),
|
||||
height * gdk_fractional_scale_to_int (scale), 0, 0);
|
||||
gdk_fractional_scale_scale (scale, width),
|
||||
gdk_fractional_scale_scale (scale, height),
|
||||
0, 0);
|
||||
|
||||
gdk_surface_invalidate_rect (surface, NULL);
|
||||
|
||||
@ -1364,8 +1365,8 @@ gdk_wayland_surface_ensure_wl_egl_window (GdkSurface *surface)
|
||||
{
|
||||
impl->display_server.egl_window =
|
||||
wl_egl_window_create (impl->display_server.wl_surface,
|
||||
surface->width * gdk_fractional_scale_to_int (&impl->scale),
|
||||
surface->height * gdk_fractional_scale_to_int (&impl->scale));
|
||||
gdk_fractional_scale_scale (&impl->scale, surface->width),
|
||||
gdk_fractional_scale_scale (&impl->scale, surface->height));
|
||||
gdk_surface_set_egl_native_window (surface, impl->display_server.egl_window);
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
|
||||
g_assert (root != NULL);
|
||||
|
||||
surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self->context));
|
||||
scale = gdk_surface_get_scale_factor (surface);
|
||||
scale = gdk_surface_get_scale (surface);
|
||||
|
||||
viewport.origin.x = 0;
|
||||
viewport.origin.y = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user