[gtk+] gsk: Drop the GskRenderer::scale-factor property
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gsk: Drop the GskRenderer::scale-factor property
- Date: Sat, 28 Oct 2017 15:50:36 +0000 (UTC)
commit dc0570cc17375d980ea7d38d99c9480839edc57f
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 28 11:49:39 2017 -0400
gsk: Drop the GskRenderer::scale-factor property
This is can always be obtained from the window that is already
associated with the renderer, no need to maintain a separate
property for it.
gsk/gskglrenderer.c | 9 +++--
gsk/gskrenderer.c | 77 +------------------------------------------------
gsk/gskrenderer.h | 5 ---
gsk/gskvulkanrender.c | 2 +-
gtk/gtkwindow.c | 9 +-----
5 files changed, 8 insertions(+), 94 deletions(-)
---
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index ee9ac46..979e72f 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -731,8 +731,9 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
memset (&item, 0, sizeof (RenderItem));
- scale_factor = gsk_renderer_get_scale_factor (GSK_RENDERER (self));
- if (scale_factor < 1)
+ if (gsk_renderer_get_window (GSK_RENDERER (self)))
+ scale_factor = gdk_window_get_scale_factor (gsk_renderer_get_window (GSK_RENDERER (self)));
+ else
scale_factor = 1;
item.node = node;
@@ -1067,7 +1068,7 @@ gsk_gl_renderer_setup_render_mode (GskGLRenderer *self)
GdkDrawingContext *context = gsk_renderer_get_drawing_context (GSK_RENDERER (self));
GdkWindow *window = gsk_renderer_get_window (GSK_RENDERER (self));
GdkRectangle extents;
- int scale_factor = gsk_renderer_get_scale_factor (GSK_RENDERER (self));
+ int scale_factor = gdk_window_get_scale_factor (window);
cairo_region_get_extents (gdk_drawing_context_get_clip (context), &extents);
@@ -1221,7 +1222,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
gdk_gl_context_make_current (self->gl_context);
gsk_renderer_get_viewport (renderer, &viewport);
- scale_factor = gsk_renderer_get_scale_factor (renderer);
+ scale_factor = gdk_window_get_scale_factor (gsk_renderer_get_window (renderer));
gsk_gl_renderer_do_render (renderer, root, &viewport, scale_factor);
diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c
index e4ab4e9..f998c9d 100644
--- a/gsk/gskrenderer.c
+++ b/gsk/gskrenderer.c
@@ -76,8 +76,6 @@ typedef struct
GskProfiler *profiler;
- int scale_factor;
-
gboolean is_realized : 1;
} GskRendererPrivate;
@@ -85,7 +83,6 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GskRenderer, gsk_renderer, G_TYPE_OBJECT)
enum {
PROP_VIEWPORT = 1,
- PROP_SCALE_FACTOR,
PROP_WINDOW,
PROP_DISPLAY,
PROP_DRAWING_CONTEXT,
@@ -157,7 +154,7 @@ gsk_renderer_real_create_cairo_surface (GskRenderer *self,
int height)
{
GskRendererPrivate *priv = gsk_renderer_get_instance_private (self);
- int scale_factor = priv->scale_factor > 0 ? priv->scale_factor : 1;
+ int scale_factor = priv->window ? gdk_window_get_scale_factor (priv->window) : 1;
int real_width = width * scale_factor;
int real_height = height * scale_factor;
@@ -197,10 +194,6 @@ gsk_renderer_set_property (GObject *gobject,
gsk_renderer_set_viewport (self, g_value_get_boxed (value));
break;
- case PROP_SCALE_FACTOR:
- gsk_renderer_set_scale_factor (self, g_value_get_int (value));
- break;
-
case PROP_DISPLAY:
/* Construct-only */
priv->display = g_value_dup_object (value);
@@ -227,10 +220,6 @@ gsk_renderer_get_property (GObject *gobject,
g_value_set_boxed (value, &priv->viewport);
break;
- case PROP_SCALE_FACTOR:
- g_value_set_int (value, priv->scale_factor);
- break;
-
case PROP_WINDOW:
g_value_set_object (value, priv->window);
break;
@@ -325,23 +314,6 @@ gsk_renderer_class_init (GskRendererClass *klass)
G_PARAM_STATIC_STRINGS);
/**
- * GskRenderer:scale-factor:
- *
- * The scale factor used when rendering.
- *
- * Since: 3.90
- */
- gsk_renderer_properties[PROP_SCALE_FACTOR] =
- g_param_spec_int ("scale-factor",
- "Scale Factor",
- "The scaling factor of the renderer",
- 1, G_MAXINT,
- 1,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS |
- G_PARAM_EXPLICIT_NOTIFY);
-
- /**
* GskRenderer:drawing-context:
*
* The drawing context used when rendering.
@@ -365,8 +337,6 @@ gsk_renderer_init (GskRenderer *self)
GskRendererPrivate *priv = gsk_renderer_get_instance_private (self);
priv->profiler = gsk_profiler_new ();
-
- priv->scale_factor = 1;
}
/**
@@ -424,51 +394,6 @@ gsk_renderer_get_viewport (GskRenderer *renderer,
}
/**
- * gsk_renderer_set_scale_factor:
- * @renderer: a #GskRenderer
- * @scale_factor: the new scale factor
- *
- * Sets the scale factor for the renderer.
- *
- * Since: 3.90
- */
-void
-gsk_renderer_set_scale_factor (GskRenderer *renderer,
- int scale_factor)
-{
- GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer);
-
- g_return_if_fail (GSK_IS_RENDERER (renderer));
-
- if (priv->scale_factor != scale_factor)
- {
- priv->scale_factor = scale_factor;
-
- g_object_notify_by_pspec (G_OBJECT (renderer), gsk_renderer_properties[PROP_SCALE_FACTOR]);
- }
-}
-
-/**
- * gsk_renderer_get_scale_factor:
- * @renderer: a #GskRenderer
- *
- * Gets the scale factor for the @renderer.
- *
- * Returns: the scale factor
- *
- * Since: 3.90
- */
-int
-gsk_renderer_get_scale_factor (GskRenderer *renderer)
-{
- GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer);
-
- g_return_val_if_fail (GSK_IS_RENDERER (renderer), 1);
-
- return priv->scale_factor;
-}
-
-/**
* gsk_renderer_get_window:
* @renderer: a #GskRenderer
*
diff --git a/gsk/gskrenderer.h b/gsk/gskrenderer.h
index 0873cf7..ab51bc1 100644
--- a/gsk/gskrenderer.h
+++ b/gsk/gskrenderer.h
@@ -48,11 +48,6 @@ GDK_AVAILABLE_IN_3_90
void gsk_renderer_get_viewport (GskRenderer *renderer,
graphene_rect_t *viewport);
GDK_AVAILABLE_IN_3_90
-void gsk_renderer_set_scale_factor (GskRenderer *renderer,
- int scale_factor);
-GDK_AVAILABLE_IN_3_90
-int gsk_renderer_get_scale_factor (GskRenderer *renderer);
-GDK_AVAILABLE_IN_3_90
GdkWindow * gsk_renderer_get_window (GskRenderer *renderer);
GDK_AVAILABLE_IN_3_90
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index ad4d164..e94185d 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -83,7 +83,7 @@ gsk_vulkan_render_setup (GskVulkanRender *self,
}
else
{
- self->scale_factor = gsk_renderer_get_scale_factor (self->renderer);
+ self->scale_factor = gdk_window_get_scale_factor (gsk_renderer_get_window (self->renderer));
self->viewport = GRAPHENE_RECT_INIT (0, 0,
gdk_window_get_width (window) * self->scale_factor,
gdk_window_get_height (window) * self->scale_factor);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 68de62e..1943657 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6876,10 +6876,7 @@ gtk_window_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
if (priv->renderer == NULL)
- {
- priv->renderer = gsk_renderer_new_for_window (gdk_window);
- gsk_renderer_set_scale_factor (priv->renderer, gtk_widget_get_scale_factor (widget));
- }
+ priv->renderer = gsk_renderer_new_for_window (gdk_window);
if (priv->transient_parent &&
_gtk_widget_get_realized (GTK_WIDGET (priv->transient_parent)))
@@ -7120,10 +7117,6 @@ _gtk_window_set_allocation (GtkWindow *window,
if (priv->renderer != NULL)
{
graphene_rect_t viewport;
- int scale;
-
- scale = gtk_widget_get_scale_factor (widget);
- gsk_renderer_set_scale_factor (priv->renderer, scale);
graphene_rect_init (&viewport, 0, 0, allocation->width, allocation->height);
gsk_renderer_set_viewport (priv->renderer, &viewport);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]