forked from AuroraMiddleware/gtk
gtk: Add a GskRenderer to GtkWindow
Each top-level should have its own GskRenderer, to be used when drawing the render node tree.
This commit is contained in:
parent
074c77e7ac
commit
258af60c18
@ -30,6 +30,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <graphene.h>
|
||||||
|
|
||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
#include "gtkwindowprivate.h"
|
#include "gtkwindowprivate.h"
|
||||||
@ -270,6 +271,8 @@ struct _GtkWindowPrivate
|
|||||||
GdkWindow *hardcoded_window;
|
GdkWindow *hardcoded_window;
|
||||||
|
|
||||||
GtkCssNode *decoration_node;
|
GtkCssNode *decoration_node;
|
||||||
|
|
||||||
|
GskRenderer *renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GtkTargetEntry dnd_dest_targets [] = {
|
static const GtkTargetEntry dnd_dest_targets [] = {
|
||||||
@ -6839,6 +6842,16 @@ gtk_window_realize (GtkWidget *widget)
|
|||||||
|
|
||||||
_gtk_widget_get_allocation (widget, &allocation);
|
_gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
|
if (priv->renderer == NULL)
|
||||||
|
{
|
||||||
|
graphene_rect_t viewport;
|
||||||
|
|
||||||
|
priv->renderer = gsk_renderer_get_for_display (gtk_widget_get_display (widget));
|
||||||
|
|
||||||
|
graphene_rect_init (&viewport, 0, 0, allocation.width, allocation.height);
|
||||||
|
gsk_renderer_set_viewport (priv->renderer, &viewport);
|
||||||
|
}
|
||||||
|
|
||||||
if (gtk_widget_get_parent_window (widget))
|
if (gtk_widget_get_parent_window (widget))
|
||||||
{
|
{
|
||||||
gdk_window = gdk_window_new_child (gtk_widget_get_parent_window (widget),
|
gdk_window = gdk_window_new_child (gtk_widget_get_parent_window (widget),
|
||||||
@ -6857,6 +6870,9 @@ gtk_window_realize (GtkWidget *widget)
|
|||||||
popover_realize (popover->widget, popover, window);
|
popover_realize (popover->widget, popover, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gsk_renderer_set_window (priv->renderer, gdk_window);
|
||||||
|
gsk_renderer_realize (priv->renderer);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7051,6 +7067,11 @@ gtk_window_realize (GtkWidget *widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_scale_changed (window);
|
check_scale_changed (window);
|
||||||
|
|
||||||
|
/* Renderer */
|
||||||
|
gsk_renderer_set_window (priv->renderer, gdk_window);
|
||||||
|
gsk_renderer_set_use_alpha (priv->renderer, TRUE);
|
||||||
|
gsk_renderer_realize (priv->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -7078,6 +7099,9 @@ gtk_window_unrealize (GtkWidget *widget)
|
|||||||
GList *link;
|
GList *link;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
|
if (priv->renderer != NULL)
|
||||||
|
gsk_renderer_unrealize (priv->renderer);
|
||||||
|
|
||||||
/* On unrealize, we reset the size of the window such
|
/* On unrealize, we reset the size of the window such
|
||||||
* that we will re-apply the default sizing stuff
|
* that we will re-apply the default sizing stuff
|
||||||
* next time we show the window.
|
* next time we show the window.
|
||||||
@ -7224,6 +7248,21 @@ _gtk_window_set_allocation (GtkWindow *window,
|
|||||||
child_allocation.width = allocation->width;
|
child_allocation.width = allocation->width;
|
||||||
child_allocation.height = allocation->height;
|
child_allocation.height = allocation->height;
|
||||||
|
|
||||||
|
if (priv->renderer != NULL)
|
||||||
|
{
|
||||||
|
graphene_rect_t viewport;
|
||||||
|
graphene_matrix_t projection;
|
||||||
|
|
||||||
|
graphene_rect_init (&viewport, 0, 0, allocation->width, allocation->height);
|
||||||
|
gsk_renderer_set_viewport (priv->renderer, &viewport);
|
||||||
|
|
||||||
|
graphene_matrix_init_ortho (&projection,
|
||||||
|
0, allocation->width,
|
||||||
|
0, allocation->height,
|
||||||
|
-1, 1);
|
||||||
|
gsk_renderer_set_projection (priv->renderer, &projection);
|
||||||
|
}
|
||||||
|
|
||||||
get_shadow_width (window, &window_border);
|
get_shadow_width (window, &window_border);
|
||||||
|
|
||||||
if (_gtk_widget_get_realized (widget))
|
if (_gtk_widget_get_realized (widget))
|
||||||
@ -11735,3 +11774,11 @@ gtk_window_unexport_handle (GtkWindow *window)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GskRenderer *
|
||||||
|
gtk_window_get_renderer (GtkWindow *window)
|
||||||
|
{
|
||||||
|
GtkWindowPrivate *priv = window->priv;
|
||||||
|
|
||||||
|
return priv->renderer;
|
||||||
|
}
|
||||||
|
@ -142,6 +142,8 @@ gboolean gtk_window_export_handle (GtkWindow *window,
|
|||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
void gtk_window_unexport_handle (GtkWindow *window);
|
void gtk_window_unexport_handle (GtkWindow *window);
|
||||||
|
|
||||||
|
GskRenderer *gtk_window_get_renderer (GtkWindow *window);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_WINDOW_PRIVATE_H__ */
|
#endif /* __GTK_WINDOW_PRIVATE_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user