| 1 |
|
| 2 |
|
| 3 |
e |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "config.h" |
| 20 |
|
| 21 |
#include "gdkconfig.h" |
| 22 |
|
| 23 |
#include "gdkdrawcontext-broadway.h" |
| 24 |
#include "gdktextureprivate.h" |
| 25 |
#include "gdkprivate-broadway.h" |
| 26 |
|
| 27 |
G_DEFINE_TYPE (GdkBroadwayDrawContext, gdk_broadway_draw_context, GDK_TYPE_DRAW_CONTEXT) |
| 28 |
|
| 29 |
static void |
| 30 |
gdk_broadway_draw_context_dispose (GObject *object) |
| 31 |
{ |
| 32 |
G_OBJECT_CLASS (gdk_broadway_draw_context_parent_class)->dispose (object); |
| 33 |
} |
| 34 |
|
| 35 |
static void |
| 36 |
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context, |
| 37 |
gpointer context_data, |
| 38 |
GdkMemoryDepth depth, |
| 39 |
cairo_region_t *region, |
| 40 |
GdkColorState **out_color_state, |
| 41 |
GdkMemoryDepth *out_depth) |
| 42 |
{ |
| 43 |
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context); |
| 44 |
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self)); |
| 45 |
|
| 46 |
cairo_region_union_rectangle (region, |
| 47 |
&(cairo_rectangle_int_t) { |
| 48 |
0, 0, |
| 49 |
gdk_surface_get_width (surface), |
| 50 |
gdk_surface_get_height (surface) |
| 51 |
}); |
| 52 |
|
| 53 |
g_assert (self->nodes == NULL); |
| 54 |
g_assert (self->node_textures == NULL); |
| 55 |
|
| 56 |
self->nodes = g_array_new (FALSE, FALSE, sizeof(guint32)); |
| 57 |
self->node_textures = g_ptr_array_new_with_free_func (g_object_unref); |
| 58 |
|
| 59 |
*out_color_state = GDK_COLOR_STATE_SRGB; |
| 60 |
*out_depth = gdk_color_state_get_depth (GDK_COLOR_STATE_SRGB); |
| 61 |
} |
| 62 |
|
| 63 |
static void |
| 64 |
gdk_broadway_draw_context_end_frame (GdkDrawContext *draw_context, |
| 65 |
gpointer context_data, |
| 66 |
cairo_region_t *painted) |
| 67 |
{ |
| 68 |
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context); |
| 69 |
GdkSurface *surface = gdk_draw_context_get_surface (draw_context); |
| 70 |
|
| 71 |
gdk_broadway_surface_set_nodes (surface, self->nodes, self->node_textures); |
| 72 |
|
| 73 |
g_array_unref (self->nodes); |
| 74 |
self->nodes = NULL; |
| 75 |
|
| 76 |
|
| 77 |
g_ptr_array_unref (self->node_textures); |
| 78 |
self->node_textures = NULL; |
| 79 |
} |
| 80 |
|
| 81 |
static void |
| 82 |
gdk_broadway_draw_context_surface_resized (GdkDrawContext *draw_context) |
| 83 |
{ |
| 84 |
} |
| 85 |
|
| 86 |
static void |
| 87 |
gdk_broadway_draw_context_class_init (GdkBroadwayDrawContextClass *klass) |
| 88 |
{ |
| 89 |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 90 |
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass); |
| 91 |
|
| 92 |
gobject_class->dispose = gdk_broadway_draw_context_dispose; |
| 93 |
|
| 94 |
draw_context_class->begin_frame = gdk_broadway_draw_context_begin_frame; |
| 95 |
draw_context_class->end_frame = gdk_broadway_draw_context_end_frame; |
| 96 |
draw_context_class->surface_resized = gdk_broadway_draw_context_surface_resized; |
| 97 |
} |
| 98 |
|
| 99 |
static void |
| 100 |
gdk_broadway_draw_context_init (GdkBroadwayDrawContext *self) |
| 101 |
{ |
| 102 |
} |
| 103 |
|
| 104 |
GdkBroadwayDrawContext * |
| 105 |
gdk_broadway_draw_context_context (GdkSurface *surface) |
| 106 |
{ |
| 107 |
return g_object_new (GDK_TYPE_BROADWAY_DRAW_CONTEXT, |
| 108 |
"surface", surface, |
| 109 |
NULL); |
| 110 |
} |