guint is_fully_contained : 1;
} GskGLRenderClip;
+#define GDK_ARRAY_NAME clips
+#define GDK_ARRAY_TYPE_NAME Clips
+#define GDK_ARRAY_ELEMENT_TYPE GskGLRenderClip
+#define GDK_ARRAY_BY_VALUE 1
+#define GDK_ARRAY_PREALLOC 16
+#define GDK_ARRAY_NO_MEMSET
+#include "gdk/gdkarrayimpl.c"
+
typedef struct _GskGLRenderModelview
{
GskTransform *transform;
/* An array of GskGLRenderClip updated as nodes are processed. The
* current clip is the last element.
*/
- GArray *clip;
+ Clips clip;
/* Our current alpha state as we process nodes */
float alpha;
const GskRenderNode *node,
GskGLRenderOffscreen *offscreen);
+static inline GskGLRenderClip *
+clips_grow_one (Clips *clips)
+{
+ guint len = clips_get_size (clips);
+ clips_set_size (clips, len + 1);
+ return clips_get (clips, len);
+}
+
static inline int
get_target_format (GskGLRenderJob *job,
const GskRenderNode *node)
GskGLRenderClip *clip;
g_assert (job != NULL);
- g_assert (job->clip != NULL);
g_assert (rect != NULL);
job->driver->stamps[UNIFORM_SHARED_CLIP_RECT]++;
- g_array_set_size (job->clip, job->clip->len + 1);
+ clip = clips_grow_one (&job->clip);
- clip = &g_array_index (job->clip, GskGLRenderClip, job->clip->len - 1);
memcpy (&clip->rect, rect, sizeof *rect);
clip->is_rectilinear = gsk_rounded_rect_is_rectilinear (rect);
clip->is_fully_contained = FALSE;
GskGLRenderClip *old_clip;
g_assert (job != NULL);
- g_assert (job->clip != NULL);
- g_assert (job->clip->len > 0);
+ g_assert (clips_get_size (&job->clip) > 0);
job->driver->stamps[UNIFORM_SHARED_CLIP_RECT]++;
- old_clip = &g_array_index (job->clip, GskGLRenderClip, job->clip->len - 1);
-
- g_array_set_size (job->clip, job->clip->len + 1);
+ clip = clips_grow_one (&job->clip);
+ old_clip = clips_get (&job->clip, clips_get_size (&job->clip) - 2);
- clip = &g_array_index (job->clip, GskGLRenderClip, job->clip->len - 1);
memcpy (&clip->rect.bounds, &old_clip->rect.bounds, sizeof (graphene_rect_t));
memset (clip->rect.corner, 0, sizeof clip->rect.corner);
clip->is_rectilinear = TRUE;
gsk_gl_render_job_pop_clip (GskGLRenderJob *job)
{
g_assert (job != NULL);
- g_assert (job->clip != NULL);
- g_assert (job->clip->len > 0);
+ g_assert (clips_get_size (&job->clip) > 0);
job->driver->stamps[UNIFORM_SHARED_CLIP_RECT]++;
job->current_clip--;
- job->clip->len--;
+ job->clip.end--;
}
static inline void
* which both have rounded corners.
*/
- if (job->clip->len <= 1)
+ if (clips_get_size (&job->clip) <= 1)
need_offscreen = FALSE;
else if (gsk_rounded_rect_contains_rect (&job->current_clip->rect, &transformed_clip.bounds))
need_offscreen = FALSE;
job = g_new0 (GskGLRenderJob, 1);
job->driver = g_object_ref (driver);
job->command_queue = job->driver->command_queue;
- job->clip = g_array_sized_new (FALSE, FALSE, sizeof (GskGLRenderClip), 16);
+ clips_init (&job->clip);
job->modelview = g_array_sized_new (FALSE, FALSE, sizeof (GskGLRenderModelview), 16);
job->framebuffer = framebuffer;
job->clear_framebuffer = !!clear_framebuffer;
g_clear_object (&job->driver);
g_clear_pointer (&job->region, cairo_region_destroy);
g_clear_pointer (&job->modelview, g_array_unref);
- g_clear_pointer (&job->clip, g_array_unref);
+ clips_clear (&job->clip);
g_free (job);
}