[gtk/ngl-is-the-new-gl: 1/2] Rename ngl to gl
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ngl-is-the-new-gl: 1/2] Rename ngl to gl
- Date: Thu, 7 Oct 2021 04:52:22 +0000 (UTC)
commit c229c3f745386cbfabb88ba15876bfbcb0e336c9
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 6 23:15:25 2021 -0400
Rename ngl to gl
We have only one gl renderer now, and it is
a bit odd for it not be called gl.
demos/node-editor/node-editor-window.c | 4 +-
gdk/gdkmemoryformat.c | 2 +-
gdk/gdkmemorytexture.c | 2 +-
gdk/loaders/gdkpng.c | 2 +-
gsk/{ngl => gl}/fp16.c | 0
gsk/{ngl => gl}/fp16i.c | 0
gsk/{ngl => gl}/fp16private.h | 0
.../gskglattachmentstate.c} | 32 +-
.../gskglattachmentstateprivate.h} | 48 +-
gsk/{ngl/gsknglbuffer.c => gl/gskglbuffer.c} | 18 +-
.../gskglbufferprivate.h} | 34 +-
.../gskglcommandqueue.c} | 480 ++--
gsk/gl/gskglcommandqueueprivate.h | 362 +++
gsk/{ngl/gsknglcompiler.c => gl/gskglcompiler.c} | 180 +-
gsk/gl/gskglcompilerprivate.h | 70 +
gsk/{ngl/gskngldriver.c => gl/gskgldriver.c} | 722 +++---
gsk/gl/gskgldriverprivate.h | 251 +++
.../gskglglyphlibrary.c} | 164 +-
gsk/gl/gskglglyphlibraryprivate.h | 103 +
.../gskngliconlibrary.c => gl/gskgliconlibrary.c} | 62 +-
gsk/gl/gskgliconlibraryprivate.h | 60 +
gsk/{ngl => gl}/gskglprofiler.c | 0
gsk/{ngl => gl}/gskglprofilerprivate.h | 0
gsk/{ngl/gsknglprogram.c => gl/gskglprogram.c} | 74 +-
gsk/gl/gskglprogramprivate.h | 282 +++
gsk/gl/gskglprograms.defs | 84 +
gsk/{ngl/gsknglrenderer.c => gl/gskglrenderer.c} | 158 +-
gsk/gl/gskglrenderer.h | 46 +
.../gskglrendererprivate.h} | 16 +-
gsk/{ngl/gsknglrenderjob.c => gl/gskglrenderjob.c} | 2318 ++++++++++----------
gsk/gl/gskglrenderjobprivate.h | 39 +
.../gskglshadowlibrary.c} | 88 +-
gsk/gl/gskglshadowlibraryprivate.h | 44 +
gsk/{ngl/gskngltexture.c => gl/gskgltexture.c} | 40 +-
.../gskgltexturelibrary.c} | 184 +-
gsk/gl/gskgltexturelibraryprivate.h | 208 ++
.../gskgltextureprivate.h} | 44 +-
gsk/gl/gskgltypesprivate.h | 66 +
.../gskgluniformstate.c} | 78 +-
gsk/gl/gskgluniformstateprivate.h | 836 +++++++
gsk/{ngl => gl}/inlinearray.h | 0
gsk/{ngl => gl}/ninesliceprivate.h | 22 +-
gsk/{ngl => gl}/resources/blend.glsl | 0
gsk/{ngl => gl}/resources/blit.glsl | 0
gsk/{ngl => gl}/resources/blur.glsl | 0
gsk/{ngl => gl}/resources/border.glsl | 0
gsk/{ngl => gl}/resources/color.glsl | 0
gsk/{ngl => gl}/resources/color_matrix.glsl | 0
gsk/{ngl => gl}/resources/coloring.glsl | 0
gsk/{ngl => gl}/resources/conic_gradient.glsl | 0
gsk/{ngl => gl}/resources/cross_fade.glsl | 0
gsk/{ngl => gl}/resources/custom.glsl | 0
gsk/{ngl => gl}/resources/filled_border.glsl | 0
gsk/{ngl => gl}/resources/inset_shadow.glsl | 0
gsk/{ngl => gl}/resources/linear_gradient.glsl | 0
gsk/{ngl => gl}/resources/outset_shadow.glsl | 0
gsk/{ngl => gl}/resources/preamble.fs.glsl | 0
gsk/{ngl => gl}/resources/preamble.glsl | 0
gsk/{ngl => gl}/resources/preamble.vs.glsl | 0
gsk/{ngl => gl}/resources/radial_gradient.glsl | 0
gsk/{ngl => gl}/resources/repeat.glsl | 0
.../resources/unblurred_outset_shadow.glsl | 0
gsk/{ngl => gl}/stb_rect_pack.c | 0
gsk/{ngl => gl}/stb_rect_pack.h | 0
gsk/gskglshader.c | 6 +-
gsk/gskrenderer.c | 18 +-
gsk/meson.build | 82 +-
gsk/ngl/gsknglcommandqueueprivate.h | 362 ---
gsk/ngl/gsknglcompilerprivate.h | 70 -
gsk/ngl/gskngldriverprivate.h | 251 ---
gsk/ngl/gsknglglyphlibraryprivate.h | 103 -
gsk/ngl/gskngliconlibraryprivate.h | 60 -
gsk/ngl/gsknglprogramprivate.h | 282 ---
gsk/ngl/gsknglprograms.defs | 84 -
gsk/ngl/gsknglrenderer.h | 46 -
gsk/ngl/gsknglrenderjobprivate.h | 39 -
gsk/ngl/gsknglshadowlibraryprivate.h | 44 -
gsk/ngl/gskngltexturelibraryprivate.h | 208 --
gsk/ngl/gskngltypesprivate.h | 66 -
gsk/ngl/gskngluniformstateprivate.h | 836 -------
gtk/gtktestutils.c | 2 +-
gtk/inspector/general.c | 2 -
testsuite/gdk/memorytexture.c | 4 +-
testsuite/gdk/texture-threads.c | 4 +-
testsuite/gsk/half-float.c | 2 +-
85 files changed, 4895 insertions(+), 4899 deletions(-)
---
diff --git a/demos/node-editor/node-editor-window.c b/demos/node-editor/node-editor-window.c
index 866b51c284..4a22a0b9d8 100644
--- a/demos/node-editor/node-editor-window.c
+++ b/demos/node-editor/node-editor-window.c
@@ -24,7 +24,7 @@
#include "gtkrendererpaintableprivate.h"
#include "gsk/gskrendernodeparserprivate.h"
-#include "gsk/ngl/gsknglrenderer.h"
+#include "gsk/gl/gskglrenderer.h"
#ifdef GDK_WINDOWING_BROADWAY
#include "gsk/broadway/gskbroadwayrenderer.h"
#endif
@@ -872,7 +872,7 @@ node_editor_window_realize (GtkWidget *widget)
"Default");
#endif
node_editor_window_add_renderer (self,
- gsk_ngl_renderer_new (),
+ gsk_gl_renderer_new (),
"OpenGL");
#ifdef GDK_RENDERING_VULKAN
node_editor_window_add_renderer (self,
diff --git a/gdk/gdkmemoryformat.c b/gdk/gdkmemoryformat.c
index 5af2bb8516..abbe8c03f7 100644
--- a/gdk/gdkmemoryformat.c
+++ b/gdk/gdkmemoryformat.c
@@ -21,7 +21,7 @@
#include "gdkmemoryformatprivate.h"
-#include "gsk/ngl/fp16private.h"
+#include "gsk/gl/fp16private.h"
#include <epoxy/gl.h>
diff --git a/gdk/gdkmemorytexture.c b/gdk/gdkmemorytexture.c
index 52723ef805..e658ad97ee 100644
--- a/gdk/gdkmemorytexture.c
+++ b/gdk/gdkmemorytexture.c
@@ -22,7 +22,7 @@
#include "gdkmemorytextureprivate.h"
#include "gdkmemoryformatprivate.h"
-#include "gsk/ngl/fp16private.h"
+#include "gsk/gl/fp16private.h"
/**
* GdkMemoryTexture:
diff --git a/gdk/loaders/gdkpng.c b/gdk/loaders/gdkpng.c
index 9bdc5e3a43..69f85eaa98 100644
--- a/gdk/loaders/gdkpng.c
+++ b/gdk/loaders/gdkpng.c
@@ -25,7 +25,7 @@
#include "gdkprofilerprivate.h"
#include "gdktexture.h"
#include "gdktextureprivate.h"
-#include "gsk/ngl/fp16private.h"
+#include "gsk/gl/fp16private.h"
#include <png.h>
#include <stdio.h>
diff --git a/gsk/ngl/fp16.c b/gsk/gl/fp16.c
similarity index 100%
rename from gsk/ngl/fp16.c
rename to gsk/gl/fp16.c
diff --git a/gsk/ngl/fp16i.c b/gsk/gl/fp16i.c
similarity index 100%
rename from gsk/ngl/fp16i.c
rename to gsk/gl/fp16i.c
diff --git a/gsk/ngl/fp16private.h b/gsk/gl/fp16private.h
similarity index 100%
rename from gsk/ngl/fp16private.h
rename to gsk/gl/fp16private.h
diff --git a/gsk/ngl/gsknglattachmentstate.c b/gsk/gl/gskglattachmentstate.c
similarity index 72%
rename from gsk/ngl/gsknglattachmentstate.c
rename to gsk/gl/gskglattachmentstate.c
index bf37087a69..b05cc975a1 100644
--- a/gsk/ngl/gsknglattachmentstate.c
+++ b/gsk/gl/gskglattachmentstate.c
@@ -1,4 +1,4 @@
-/* gsknglattachmentstate.c
+/* gskglattachmentstate.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -20,14 +20,14 @@
#include "config.h"
-#include "gsknglattachmentstateprivate.h"
+#include "gskglattachmentstateprivate.h"
-GskNglAttachmentState *
-gsk_ngl_attachment_state_new (void)
+GskGLAttachmentState *
+gsk_gl_attachment_state_new (void)
{
- GskNglAttachmentState *self;
+ GskGLAttachmentState *self;
- self = g_atomic_rc_box_new0 (GskNglAttachmentState);
+ self = g_atomic_rc_box_new0 (GskGLAttachmentState);
self->fbo.changed = FALSE;
self->fbo.id = 0;
@@ -49,25 +49,25 @@ gsk_ngl_attachment_state_new (void)
return self;
}
-GskNglAttachmentState *
-gsk_ngl_attachment_state_ref (GskNglAttachmentState *self)
+GskGLAttachmentState *
+gsk_gl_attachment_state_ref (GskGLAttachmentState *self)
{
return g_atomic_rc_box_acquire (self);
}
void
-gsk_ngl_attachment_state_unref (GskNglAttachmentState *self)
+gsk_gl_attachment_state_unref (GskGLAttachmentState *self)
{
g_atomic_rc_box_release (self);
}
void
-gsk_ngl_attachment_state_bind_texture (GskNglAttachmentState *self,
- GLenum target,
- GLenum texture,
- guint id)
+gsk_gl_attachment_state_bind_texture (GskGLAttachmentState *self,
+ GLenum target,
+ GLenum texture,
+ guint id)
{
- GskNglBindTexture *attach;
+ GskGLBindTexture *attach;
g_assert (self != NULL);
g_assert (target == GL_TEXTURE_1D ||
@@ -93,8 +93,8 @@ gsk_ngl_attachment_state_bind_texture (GskNglAttachmentState *self,
}
void
-gsk_ngl_attachment_state_bind_framebuffer (GskNglAttachmentState *self,
- guint id)
+gsk_gl_attachment_state_bind_framebuffer (GskGLAttachmentState *self,
+ guint id)
{
g_assert (self != NULL);
diff --git a/gsk/ngl/gsknglattachmentstateprivate.h b/gsk/gl/gskglattachmentstateprivate.h
similarity index 51%
rename from gsk/ngl/gsknglattachmentstateprivate.h
rename to gsk/gl/gskglattachmentstateprivate.h
index b43e91e09c..4052fa22c2 100644
--- a/gsk/ngl/gsknglattachmentstateprivate.h
+++ b/gsk/gl/gskglattachmentstateprivate.h
@@ -1,4 +1,4 @@
-/* gsknglattachmentstateprivate.h
+/* gskglattachmentstateprivate.h
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -18,18 +18,18 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#ifndef __GSK_NGL_ATTACHMENT_STATE_PRIVATE_H__
-#define __GSK_NGL_ATTACHMENT_STATE_PRIVATE_H__
+#ifndef __GSK_GL_ATTACHMENT_STATE_PRIVATE_H__
+#define __GSK_GL_ATTACHMENT_STATE_PRIVATE_H__
-#include "gskngltypesprivate.h"
+#include "gskgltypesprivate.h"
G_BEGIN_DECLS
-typedef struct _GskNglAttachmentState GskNglAttachmentState;
-typedef struct _GskNglBindFramebuffer GskNglBindFramebuffer;
-typedef struct _GskNglBindTexture GskNglBindTexture;
+typedef struct _GskGLAttachmentState GskGLAttachmentState;
+typedef struct _GskGLBindFramebuffer GskGLBindFramebuffer;
+typedef struct _GskGLBindTexture GskGLBindTexture;
-struct _GskNglBindTexture
+struct _GskGLBindTexture
{
guint changed : 1;
guint initial : 1;
@@ -38,34 +38,34 @@ struct _GskNglBindTexture
guint id;
};
-G_STATIC_ASSERT (sizeof (GskNglBindTexture) == 12);
+G_STATIC_ASSERT (sizeof (GskGLBindTexture) == 12);
-struct _GskNglBindFramebuffer
+struct _GskGLBindFramebuffer
{
guint changed : 1;
guint id : 31;
};
-G_STATIC_ASSERT (sizeof (GskNglBindFramebuffer) == 4);
+G_STATIC_ASSERT (sizeof (GskGLBindFramebuffer) == 4);
-struct _GskNglAttachmentState
+struct _GskGLAttachmentState
{
- GskNglBindFramebuffer fbo;
+ GskGLBindFramebuffer fbo;
/* Increase if shaders add more textures */
- GskNglBindTexture textures[4];
+ GskGLBindTexture textures[4];
guint n_changed;
};
-GskNglAttachmentState *gsk_ngl_attachment_state_new (void);
-GskNglAttachmentState *gsk_ngl_attachment_state_ref (GskNglAttachmentState *self);
-void gsk_ngl_attachment_state_unref (GskNglAttachmentState *self);
-void gsk_ngl_attachment_state_bind_texture (GskNglAttachmentState *self,
- GLenum target,
- GLenum texture,
- guint id);
-void gsk_ngl_attachment_state_bind_framebuffer (GskNglAttachmentState *self,
- guint id);
+GskGLAttachmentState *gsk_gl_attachment_state_new (void);
+GskGLAttachmentState *gsk_gl_attachment_state_ref (GskGLAttachmentState *self);
+void gsk_gl_attachment_state_unref (GskGLAttachmentState *self);
+void gsk_gl_attachment_state_bind_texture (GskGLAttachmentState *self,
+ GLenum target,
+ GLenum texture,
+ guint id);
+void gsk_gl_attachment_state_bind_framebuffer (GskGLAttachmentState *self,
+ guint id);
G_END_DECLS
-#endif /* __GSK_NGL_ATTACHMENT_STATE_PRIVATE_H__ */
+#endif /* __GSK_GL_ATTACHMENT_STATE_PRIVATE_H__ */
diff --git a/gsk/ngl/gsknglbuffer.c b/gsk/gl/gskglbuffer.c
similarity index 80%
rename from gsk/ngl/gsknglbuffer.c
rename to gsk/gl/gskglbuffer.c
index 6855f1cd53..63aabd1dc3 100644
--- a/gsk/ngl/gsknglbuffer.c
+++ b/gsk/gl/gskglbuffer.c
@@ -1,4 +1,4 @@
-/* gsknglbufferprivate.h
+/* gskglbufferprivate.h
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -22,21 +22,21 @@
#include <string.h>
-#include "gsknglbufferprivate.h"
+#include "gskglbufferprivate.h"
/**
- * gsk_ngl_buffer_init:
+ * gsk_gl_buffer_init:
* @target: the target buffer such as %GL_ARRAY_BUFFER or %GL_UNIFORM_BUFFER
* @element_size: the size of elements within the buffer
*
- * Creates a new `GskNglBuffer` which can be used to deliver data to shaders
+ * Creates a new `GskGLBuffer` which can be used to deliver data to shaders
* within a GLSL program. You can use this to store vertices such as with
* %GL_ARRAY_BUFFER or uniform data with %GL_UNIFORM_BUFFER.
*/
void
-gsk_ngl_buffer_init (GskNglBuffer *self,
- GLenum target,
- guint element_size)
+gsk_gl_buffer_init (GskGLBuffer *self,
+ GLenum target,
+ guint element_size)
{
memset (self, 0, sizeof *self);
@@ -48,7 +48,7 @@ gsk_ngl_buffer_init (GskNglBuffer *self,
}
GLuint
-gsk_ngl_buffer_submit (GskNglBuffer *buffer)
+gsk_gl_buffer_submit (GskGLBuffer *buffer)
{
GLuint id;
@@ -63,7 +63,7 @@ gsk_ngl_buffer_submit (GskNglBuffer *buffer)
}
void
-gsk_ngl_buffer_destroy (GskNglBuffer *buffer)
+gsk_gl_buffer_destroy (GskGLBuffer *buffer)
{
g_clear_pointer (&buffer->buffer, g_free);
}
diff --git a/gsk/ngl/gsknglbufferprivate.h b/gsk/gl/gskglbufferprivate.h
similarity index 68%
rename from gsk/ngl/gsknglbufferprivate.h
rename to gsk/gl/gskglbufferprivate.h
index cbd21c83da..3f783898f0 100644
--- a/gsk/ngl/gsknglbufferprivate.h
+++ b/gsk/gl/gskglbufferprivate.h
@@ -1,4 +1,4 @@
-/* gsknglbufferprivate.h
+/* gskglbufferprivate.h
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -18,14 +18,14 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#ifndef __GSK_NGL_BUFFER_PRIVATE_H__
-#define __GSK_NGL_BUFFER_PRIVATE_H__
+#ifndef __GSK_GL_BUFFER_PRIVATE_H__
+#define __GSK_GL_BUFFER_PRIVATE_H__
-#include "gskngltypesprivate.h"
+#include "gskgltypesprivate.h"
G_BEGIN_DECLS
-typedef struct _GskNglBuffer
+typedef struct _GskGLBuffer
{
guint8 *buffer;
gsize buffer_pos;
@@ -33,17 +33,17 @@ typedef struct _GskNglBuffer
guint count;
GLenum target;
gsize element_size;
-} GskNglBuffer;
+} GskGLBuffer;
-void gsk_ngl_buffer_init (GskNglBuffer *self,
- GLenum target,
- guint element_size);
-void gsk_ngl_buffer_destroy (GskNglBuffer *buffer);
-GLuint gsk_ngl_buffer_submit (GskNglBuffer *buffer);
+void gsk_gl_buffer_init (GskGLBuffer *self,
+ GLenum target,
+ guint element_size);
+void gsk_gl_buffer_destroy (GskGLBuffer *buffer);
+GLuint gsk_gl_buffer_submit (GskGLBuffer *buffer);
static inline gpointer
-gsk_ngl_buffer_advance (GskNglBuffer *buffer,
- guint count)
+gsk_gl_buffer_advance (GskGLBuffer *buffer,
+ guint count)
{
gpointer ret;
gsize to_alloc = count * buffer->element_size;
@@ -64,19 +64,19 @@ gsk_ngl_buffer_advance (GskNglBuffer *buffer,
}
static inline void
-gsk_ngl_buffer_retract (GskNglBuffer *buffer,
- guint count)
+gsk_gl_buffer_retract (GskGLBuffer *buffer,
+ guint count)
{
buffer->buffer_pos -= count * buffer->element_size;
buffer->count -= count;
}
static inline guint
-gsk_ngl_buffer_get_offset (GskNglBuffer *buffer)
+gsk_gl_buffer_get_offset (GskGLBuffer *buffer)
{
return buffer->count;
}
G_END_DECLS
-#endif /* __GSK_NGL_BUFFER_PRIVATE_H__ */
+#endif /* __GSK_GL_BUFFER_PRIVATE_H__ */
diff --git a/gsk/ngl/gsknglcommandqueue.c b/gsk/gl/gskglcommandqueue.c
similarity index 69%
rename from gsk/ngl/gsknglcommandqueue.c
rename to gsk/gl/gskglcommandqueue.c
index 8dde9ff269..13256cb235 100644
--- a/gsk/ngl/gsknglcommandqueue.c
+++ b/gsk/gl/gskglcommandqueue.c
@@ -1,4 +1,4 @@
-/* gsknglcommandqueue.c
+/* gskglcommandqueue.c
*
* Copyright 2017 Timm Bäder <mail baedert org>
* Copyright 2018 Matthias Clasen <mclasen redhat com>
@@ -32,19 +32,19 @@
#include <gsk/gskdebugprivate.h>
#include <gsk/gskroundedrectprivate.h>
-#include "gsknglattachmentstateprivate.h"
-#include "gsknglbufferprivate.h"
-#include "gsknglcommandqueueprivate.h"
-#include "gskngluniformstateprivate.h"
+#include "gskglattachmentstateprivate.h"
+#include "gskglbufferprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskgluniformstateprivate.h"
#include "inlinearray.h"
-G_DEFINE_TYPE (GskNglCommandQueue, gsk_ngl_command_queue, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GskGLCommandQueue, gsk_gl_command_queue, G_TYPE_OBJECT)
G_GNUC_UNUSED static inline void
-print_uniform (GskNglUniformFormat format,
- guint array_count,
- gconstpointer valueptr)
+print_uniform (GskGLUniformFormat format,
+ guint array_count,
+ gconstpointer valueptr)
{
const union {
graphene_matrix_t matrix[0];
@@ -56,46 +56,46 @@ print_uniform (GskNglUniformFormat format,
switch (format)
{
- case GSK_NGL_UNIFORM_FORMAT_1F:
+ case GSK_GL_UNIFORM_FORMAT_1F:
g_printerr ("1f<%f>", data->fval[0]);
break;
- case GSK_NGL_UNIFORM_FORMAT_2F:
+ case GSK_GL_UNIFORM_FORMAT_2F:
g_printerr ("2f<%f,%f>", data->fval[0], data->fval[1]);
break;
- case GSK_NGL_UNIFORM_FORMAT_3F:
+ case GSK_GL_UNIFORM_FORMAT_3F:
g_printerr ("3f<%f,%f,%f>", data->fval[0], data->fval[1], data->fval[2]);
break;
- case GSK_NGL_UNIFORM_FORMAT_4F:
+ case GSK_GL_UNIFORM_FORMAT_4F:
g_printerr ("4f<%f,%f,%f,%f>", data->fval[0], data->fval[1], data->fval[2], data->fval[3]);
break;
- case GSK_NGL_UNIFORM_FORMAT_1I:
- case GSK_NGL_UNIFORM_FORMAT_TEXTURE:
+ case GSK_GL_UNIFORM_FORMAT_1I:
+ case GSK_GL_UNIFORM_FORMAT_TEXTURE:
g_printerr ("1i<%d>", data->ival[0]);
break;
- case GSK_NGL_UNIFORM_FORMAT_1UI:
+ case GSK_GL_UNIFORM_FORMAT_1UI:
g_printerr ("1ui<%u>", data->uval[0]);
break;
- case GSK_NGL_UNIFORM_FORMAT_COLOR: {
+ case GSK_GL_UNIFORM_FORMAT_COLOR: {
char *str = gdk_rgba_to_string (valueptr);
g_printerr ("%s", str);
g_free (str);
break;
}
- case GSK_NGL_UNIFORM_FORMAT_ROUNDED_RECT: {
+ case GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT: {
char *str = gsk_rounded_rect_to_string (valueptr);
g_printerr ("%s", str);
g_free (str);
break;
}
- case GSK_NGL_UNIFORM_FORMAT_MATRIX: {
+ case GSK_GL_UNIFORM_FORMAT_MATRIX: {
float mat[16];
graphene_matrix_to_float (&data->matrix[0], mat);
g_printerr ("matrix<");
@@ -105,10 +105,10 @@ print_uniform (GskNglUniformFormat format,
break;
}
- case GSK_NGL_UNIFORM_FORMAT_1FV:
- case GSK_NGL_UNIFORM_FORMAT_2FV:
- case GSK_NGL_UNIFORM_FORMAT_3FV:
- case GSK_NGL_UNIFORM_FORMAT_4FV:
+ case GSK_GL_UNIFORM_FORMAT_1FV:
+ case GSK_GL_UNIFORM_FORMAT_2FV:
+ case GSK_GL_UNIFORM_FORMAT_3FV:
+ case GSK_GL_UNIFORM_FORMAT_4FV:
/* non-V variants are -4 from V variants */
format -= 4;
g_printerr ("[");
@@ -117,42 +117,42 @@ print_uniform (GskNglUniformFormat format,
print_uniform (format, 0, valueptr);
if (i + 1 != array_count)
g_printerr (",");
- valueptr = ((guint8*)valueptr + gsk_ngl_uniform_format_size (format));
+ valueptr = ((guint8*)valueptr + gsk_gl_uniform_format_size (format));
}
g_printerr ("]");
break;
- case GSK_NGL_UNIFORM_FORMAT_2I:
+ case GSK_GL_UNIFORM_FORMAT_2I:
g_printerr ("2i<%d,%d>", data->ival[0], data->ival[1]);
break;
- case GSK_NGL_UNIFORM_FORMAT_3I:
+ case GSK_GL_UNIFORM_FORMAT_3I:
g_printerr ("3i<%d,%d,%d>", data->ival[0], data->ival[1], data->ival[2]);
break;
- case GSK_NGL_UNIFORM_FORMAT_4I:
+ case GSK_GL_UNIFORM_FORMAT_4I:
g_printerr ("3i<%d,%d,%d,%d>", data->ival[0], data->ival[1], data->ival[2], data->ival[3]);
break;
- case GSK_NGL_UNIFORM_FORMAT_LAST:
+ case GSK_GL_UNIFORM_FORMAT_LAST:
default:
g_assert_not_reached ();
}
}
G_GNUC_UNUSED static inline void
-gsk_ngl_command_queue_print_batch (GskNglCommandQueue *self,
- const GskNglCommandBatch *batch)
+gsk_gl_command_queue_print_batch (GskGLCommandQueue *self,
+ const GskGLCommandBatch *batch)
{
static const char *command_kinds[] = { "Clear", "Draw", };
guint framebuffer_id;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (batch != NULL);
- if (batch->any.kind == GSK_NGL_COMMAND_KIND_CLEAR)
+ if (batch->any.kind == GSK_GL_COMMAND_KIND_CLEAR)
framebuffer_id = batch->clear.framebuffer;
- else if (batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW)
+ else if (batch->any.kind == GSK_GL_COMMAND_KIND_DRAW)
framebuffer_id = batch->draw.framebuffer;
else
return;
@@ -162,28 +162,28 @@ gsk_ngl_command_queue_print_batch (GskNglCommandQueue *self,
g_printerr (" Viewport: %dx%d\n", batch->any.viewport.width, batch->any.viewport.height);
g_printerr (" Framebuffer: %d\n", framebuffer_id);
- if (batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW)
+ if (batch->any.kind == GSK_GL_COMMAND_KIND_DRAW)
{
g_printerr (" Program: %d\n", batch->any.program);
g_printerr (" Vertices: %d\n", batch->draw.vbo_count);
for (guint i = 0; i < batch->draw.bind_count; i++)
{
- const GskNglCommandBind *bind = &self->batch_binds.items[batch->draw.bind_offset + i];
+ const GskGLCommandBind *bind = &self->batch_binds.items[batch->draw.bind_offset + i];
g_printerr (" Bind[%d]: %u\n", bind->texture, bind->id);
}
for (guint i = 0; i < batch->draw.uniform_count; i++)
{
- const GskNglCommandUniform *uniform = &self->batch_uniforms.items[batch->draw.uniform_offset + i];
+ const GskGLCommandUniform *uniform = &self->batch_uniforms.items[batch->draw.uniform_offset + i];
g_printerr (" Uniform[%02d]: ", uniform->location);
print_uniform (uniform->info.format,
uniform->info.array_count,
- gsk_ngl_uniform_state_get_uniform_data (self->uniforms, uniform->info.offset));
+ gsk_gl_uniform_state_get_uniform_data (self->uniforms, uniform->info.offset));
g_printerr ("\n");
}
}
- else if (batch->any.kind == GSK_NGL_COMMAND_KIND_CLEAR)
+ else if (batch->any.kind == GSK_GL_COMMAND_KIND_CLEAR)
{
g_printerr (" Bits: 0x%x\n", batch->clear.bits);
}
@@ -192,18 +192,18 @@ gsk_ngl_command_queue_print_batch (GskNglCommandQueue *self,
}
G_GNUC_UNUSED static inline void
-gsk_ngl_command_queue_capture_png (GskNglCommandQueue *self,
- const char *filename,
- guint width,
- guint height,
- gboolean flip_y)
+gsk_gl_command_queue_capture_png (GskGLCommandQueue *self,
+ const char *filename,
+ guint width,
+ guint height,
+ gboolean flip_y)
{
guint stride;
guint8 *data;
GBytes *bytes;
GdkTexture *texture;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (filename != NULL);
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
@@ -233,7 +233,7 @@ gsk_ngl_command_queue_capture_png (GskNglCommandQueue *self,
}
static inline gboolean
-will_ignore_batch (GskNglCommandQueue *self)
+will_ignore_batch (GskGLCommandQueue *self)
{
if G_LIKELY (self->batches.len < G_MAXINT16)
return FALSE;
@@ -248,10 +248,10 @@ will_ignore_batch (GskNglCommandQueue *self)
}
static inline guint
-snapshot_attachments (const GskNglAttachmentState *state,
- GskNglCommandBinds *array)
+snapshot_attachments (const GskGLAttachmentState *state,
+ GskGLCommandBinds *array)
{
- GskNglCommandBind *bind = gsk_ngl_command_binds_append_n (array, G_N_ELEMENTS (state->textures));
+ GskGLCommandBind *bind = gsk_gl_command_binds_append_n (array, G_N_ELEMENTS (state->textures));
guint count = 0;
for (guint i = 0; i < G_N_ELEMENTS (state->textures); i++)
@@ -271,16 +271,16 @@ snapshot_attachments (const GskNglAttachmentState *state,
}
static inline guint
-snapshot_uniforms (GskNglUniformState *state,
- GskNglUniformProgram *program,
- GskNglCommandUniforms *array)
+snapshot_uniforms (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ GskGLCommandUniforms *array)
{
- GskNglCommandUniform *uniform = gsk_ngl_command_uniforms_append_n (array, program->n_mappings);
+ GskGLCommandUniform *uniform = gsk_gl_command_uniforms_append_n (array, program->n_mappings);
guint count = 0;
for (guint i = 0; i < program->n_mappings; i++)
{
- const GskNglUniformMapping *mapping = &program->mappings[i];
+ const GskGLUniformMapping *mapping = &program->mappings[i];
if (!mapping->info.initial && mapping->location > -1)
{
@@ -297,9 +297,9 @@ snapshot_uniforms (GskNglUniformState *state,
}
static inline gboolean
-snapshots_equal (GskNglCommandQueue *self,
- GskNglCommandBatch *first,
- GskNglCommandBatch *second)
+snapshots_equal (GskGLCommandQueue *self,
+ GskGLCommandBatch *first,
+ GskGLCommandBatch *second)
{
if (first->draw.bind_count != second->draw.bind_count ||
first->draw.uniform_count != second->draw.uniform_count)
@@ -307,8 +307,8 @@ snapshots_equal (GskNglCommandQueue *self,
for (guint i = 0; i < first->draw.bind_count; i++)
{
- const GskNglCommandBind *fb = &self->batch_binds.items[first->draw.bind_offset+i];
- const GskNglCommandBind *sb = &self->batch_binds.items[second->draw.bind_offset+i];
+ const GskGLCommandBind *fb = &self->batch_binds.items[first->draw.bind_offset+i];
+ const GskGLCommandBind *sb = &self->batch_binds.items[second->draw.bind_offset+i];
if (fb->id != sb->id || fb->texture != sb->texture)
return FALSE;
@@ -316,8 +316,8 @@ snapshots_equal (GskNglCommandQueue *self,
for (guint i = 0; i < first->draw.uniform_count; i++)
{
- const GskNglCommandUniform *fu = &self->batch_uniforms.items[first->draw.uniform_offset+i];
- const GskNglCommandUniform *su = &self->batch_uniforms.items[second->draw.uniform_offset+i];
+ const GskGLCommandUniform *fu = &self->batch_uniforms.items[first->draw.uniform_offset+i];
+ const GskGLCommandUniform *su = &self->batch_uniforms.items[second->draw.uniform_offset+i];
gconstpointer fdata;
gconstpointer sdata;
gsize len;
@@ -330,47 +330,47 @@ snapshots_equal (GskNglCommandQueue *self,
fu->info.array_count != su->info.array_count)
return FALSE;
- fdata = gsk_ngl_uniform_state_get_uniform_data (self->uniforms, fu->info.offset);
- sdata = gsk_ngl_uniform_state_get_uniform_data (self->uniforms, su->info.offset);
+ fdata = gsk_gl_uniform_state_get_uniform_data (self->uniforms, fu->info.offset);
+ sdata = gsk_gl_uniform_state_get_uniform_data (self->uniforms, su->info.offset);
switch (fu->info.format)
{
- case GSK_NGL_UNIFORM_FORMAT_1F:
- case GSK_NGL_UNIFORM_FORMAT_1FV:
- case GSK_NGL_UNIFORM_FORMAT_1I:
- case GSK_NGL_UNIFORM_FORMAT_TEXTURE:
- case GSK_NGL_UNIFORM_FORMAT_1UI:
+ case GSK_GL_UNIFORM_FORMAT_1F:
+ case GSK_GL_UNIFORM_FORMAT_1FV:
+ case GSK_GL_UNIFORM_FORMAT_1I:
+ case GSK_GL_UNIFORM_FORMAT_TEXTURE:
+ case GSK_GL_UNIFORM_FORMAT_1UI:
len = 4;
break;
- case GSK_NGL_UNIFORM_FORMAT_2F:
- case GSK_NGL_UNIFORM_FORMAT_2FV:
- case GSK_NGL_UNIFORM_FORMAT_2I:
+ case GSK_GL_UNIFORM_FORMAT_2F:
+ case GSK_GL_UNIFORM_FORMAT_2FV:
+ case GSK_GL_UNIFORM_FORMAT_2I:
len = 8;
break;
- case GSK_NGL_UNIFORM_FORMAT_3F:
- case GSK_NGL_UNIFORM_FORMAT_3FV:
- case GSK_NGL_UNIFORM_FORMAT_3I:
+ case GSK_GL_UNIFORM_FORMAT_3F:
+ case GSK_GL_UNIFORM_FORMAT_3FV:
+ case GSK_GL_UNIFORM_FORMAT_3I:
len = 12;
break;
- case GSK_NGL_UNIFORM_FORMAT_4F:
- case GSK_NGL_UNIFORM_FORMAT_4FV:
- case GSK_NGL_UNIFORM_FORMAT_4I:
+ case GSK_GL_UNIFORM_FORMAT_4F:
+ case GSK_GL_UNIFORM_FORMAT_4FV:
+ case GSK_GL_UNIFORM_FORMAT_4I:
len = 16;
break;
- case GSK_NGL_UNIFORM_FORMAT_MATRIX:
+ case GSK_GL_UNIFORM_FORMAT_MATRIX:
len = sizeof (float) * 16;
break;
- case GSK_NGL_UNIFORM_FORMAT_ROUNDED_RECT:
+ case GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT:
len = sizeof (float) * 12;
break;
- case GSK_NGL_UNIFORM_FORMAT_COLOR:
+ case GSK_GL_UNIFORM_FORMAT_COLOR:
len = sizeof (float) * 4;
break;
@@ -388,64 +388,64 @@ snapshots_equal (GskNglCommandQueue *self,
}
static void
-gsk_ngl_command_queue_dispose (GObject *object)
+gsk_gl_command_queue_dispose (GObject *object)
{
- GskNglCommandQueue *self = (GskNglCommandQueue *)object;
+ GskGLCommandQueue *self = (GskGLCommandQueue *)object;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_clear_object (&self->profiler);
g_clear_object (&self->gl_profiler);
g_clear_object (&self->context);
- g_clear_pointer (&self->attachments, gsk_ngl_attachment_state_unref);
- g_clear_pointer (&self->uniforms, gsk_ngl_uniform_state_unref);
+ g_clear_pointer (&self->attachments, gsk_gl_attachment_state_unref);
+ g_clear_pointer (&self->uniforms, gsk_gl_uniform_state_unref);
- gsk_ngl_command_batches_clear (&self->batches);
- gsk_ngl_command_binds_clear (&self->batch_binds);
- gsk_ngl_command_uniforms_clear (&self->batch_uniforms);
+ gsk_gl_command_batches_clear (&self->batches);
+ gsk_gl_command_binds_clear (&self->batch_binds);
+ gsk_gl_command_uniforms_clear (&self->batch_uniforms);
- gsk_ngl_buffer_destroy (&self->vertices);
+ gsk_gl_buffer_destroy (&self->vertices);
- G_OBJECT_CLASS (gsk_ngl_command_queue_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gsk_gl_command_queue_parent_class)->dispose (object);
}
static void
-gsk_ngl_command_queue_class_init (GskNglCommandQueueClass *klass)
+gsk_gl_command_queue_class_init (GskGLCommandQueueClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = gsk_ngl_command_queue_dispose;
+ object_class->dispose = gsk_gl_command_queue_dispose;
}
static void
-gsk_ngl_command_queue_init (GskNglCommandQueue *self)
+gsk_gl_command_queue_init (GskGLCommandQueue *self)
{
self->max_texture_size = -1;
- gsk_ngl_command_batches_init (&self->batches, 128);
- gsk_ngl_command_binds_init (&self->batch_binds, 1024);
- gsk_ngl_command_uniforms_init (&self->batch_uniforms, 2048);
+ gsk_gl_command_batches_init (&self->batches, 128);
+ gsk_gl_command_binds_init (&self->batch_binds, 1024);
+ gsk_gl_command_uniforms_init (&self->batch_uniforms, 2048);
- gsk_ngl_buffer_init (&self->vertices, GL_ARRAY_BUFFER, sizeof (GskNglDrawVertex));
+ gsk_gl_buffer_init (&self->vertices, GL_ARRAY_BUFFER, sizeof (GskGLDrawVertex));
}
-GskNglCommandQueue *
-gsk_ngl_command_queue_new (GdkGLContext *context,
- GskNglUniformState *uniforms)
+GskGLCommandQueue *
+gsk_gl_command_queue_new (GdkGLContext *context,
+ GskGLUniformState *uniforms)
{
- GskNglCommandQueue *self;
+ GskGLCommandQueue *self;
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
self = g_object_new (GSK_TYPE_GL_COMMAND_QUEUE, NULL);
self->context = g_object_ref (context);
- self->attachments = gsk_ngl_attachment_state_new ();
+ self->attachments = gsk_gl_attachment_state_new ();
/* Use shared uniform state if we're provided one */
if (uniforms != NULL)
- self->uniforms = gsk_ngl_uniform_state_ref (uniforms);
+ self->uniforms = gsk_gl_uniform_state_ref (uniforms);
else
- self->uniforms = gsk_ngl_uniform_state_new ();
+ self->uniforms = gsk_gl_uniform_state_new ();
/* Determine max texture size immediately and restore context */
gdk_gl_context_make_current (context);
@@ -454,14 +454,14 @@ gsk_ngl_command_queue_new (GdkGLContext *context,
return g_steal_pointer (&self);
}
-static inline GskNglCommandBatch *
-begin_next_batch (GskNglCommandQueue *self)
+static inline GskGLCommandBatch *
+begin_next_batch (GskGLCommandQueue *self)
{
- GskNglCommandBatch *batch;
+ GskGLCommandBatch *batch;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
- /* GskNglCommandBatch contains an embedded linked list using integers into the
+ /* GskGLCommandBatch contains an embedded linked list using integers into the
* self->batches array. We can't use pointer because the batches could be
* realloc()'d at runtime.
*
@@ -474,7 +474,7 @@ begin_next_batch (GskNglCommandQueue *self)
* proper order.
*/
- batch = gsk_ngl_command_batches_append (&self->batches);
+ batch = gsk_gl_command_batches_append (&self->batches);
batch->any.next_batch_index = -1;
batch->any.prev_batch_index = self->tail_batch_index;
@@ -482,11 +482,11 @@ begin_next_batch (GskNglCommandQueue *self)
}
static void
-enqueue_batch (GskNglCommandQueue *self)
+enqueue_batch (GskGLCommandQueue *self)
{
guint index;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->batches.len > 0);
/* Batches are linked lists but using indexes into the batches array instead
@@ -503,7 +503,7 @@ enqueue_batch (GskNglCommandQueue *self)
if (self->tail_batch_index != -1)
{
- GskNglCommandBatch *prev = &self->batches.items[self->tail_batch_index];
+ GskGLCommandBatch *prev = &self->batches.items[self->tail_batch_index];
prev->any.next_batch_index = index;
}
@@ -512,23 +512,23 @@ enqueue_batch (GskNglCommandQueue *self)
}
static void
-discard_batch (GskNglCommandQueue *self)
+discard_batch (GskGLCommandQueue *self)
{
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->batches.len > 0);
self->batches.len--;
}
void
-gsk_ngl_command_queue_begin_draw (GskNglCommandQueue *self,
- GskNglUniformProgram *program,
- guint width,
- guint height)
+gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
+ GskGLUniformProgram *program,
+ guint width,
+ guint height)
{
- GskNglCommandBatch *batch;
+ GskGLCommandBatch *batch;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->in_draw == FALSE);
g_assert (width <= G_MAXUINT16);
g_assert (height <= G_MAXUINT16);
@@ -542,7 +542,7 @@ gsk_ngl_command_queue_begin_draw (GskNglCommandQueue *self,
self->program_info = program;
batch = begin_next_batch (self);
- batch->any.kind = GSK_NGL_COMMAND_KIND_DRAW;
+ batch->any.kind = GSK_GL_COMMAND_KIND_DRAW;
batch->any.program = program->program_id;
batch->any.next_batch_index = -1;
batch->any.viewport.width = width;
@@ -553,7 +553,7 @@ gsk_ngl_command_queue_begin_draw (GskNglCommandQueue *self,
batch->draw.bind_count = 0;
batch->draw.bind_offset = self->batch_binds.len;
batch->draw.vbo_count = 0;
- batch->draw.vbo_offset = gsk_ngl_buffer_get_offset (&self->vertices);
+ batch->draw.vbo_offset = gsk_gl_buffer_get_offset (&self->vertices);
self->fbo_max = MAX (self->fbo_max, batch->draw.framebuffer);
@@ -561,21 +561,21 @@ gsk_ngl_command_queue_begin_draw (GskNglCommandQueue *self,
}
void
-gsk_ngl_command_queue_end_draw (GskNglCommandQueue *self)
+gsk_gl_command_queue_end_draw (GskGLCommandQueue *self)
{
- GskNglCommandBatch *last_batch;
- GskNglCommandBatch *batch;
+ GskGLCommandBatch *last_batch;
+ GskGLCommandBatch *batch;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->batches.len > 0);
if (will_ignore_batch (self))
return;
- batch = gsk_ngl_command_batches_tail (&self->batches);
+ batch = gsk_gl_command_batches_tail (&self->batches);
g_assert (self->in_draw == TRUE);
- g_assert (batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW);
+ g_assert (batch->any.kind == GSK_GL_COMMAND_KIND_DRAW);
if G_UNLIKELY (batch->draw.vbo_count == 0)
{
@@ -614,7 +614,7 @@ gsk_ngl_command_queue_end_draw (GskNglCommandQueue *self)
/* Do simple chaining of draw to last batch. */
if (last_batch != NULL &&
- last_batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW &&
+ last_batch->any.kind == GSK_GL_COMMAND_KIND_DRAW &&
last_batch->any.program == batch->any.program &&
last_batch->any.viewport.width == batch->any.viewport.width &&
last_batch->any.viewport.height == batch->any.viewport.height &&
@@ -636,52 +636,52 @@ gsk_ngl_command_queue_end_draw (GskNglCommandQueue *self)
}
/**
- * gsk_ngl_command_queue_split_draw:
- * @self a `GskNglCommandQueue`
+ * gsk_gl_command_queue_split_draw:
+ * @self a `GskGLCommandQueue`
*
- * This function is like calling gsk_ngl_command_queue_end_draw() followed by
- * a gsk_ngl_command_queue_begin_draw() with the same parameters as a
+ * This function is like calling gsk_gl_command_queue_end_draw() followed by
+ * a gsk_gl_command_queue_begin_draw() with the same parameters as a
* previous begin draw (if shared uniforms where not changed further).
*
* This is useful to avoid comparisons inside of loops where we know shared
* uniforms are not changing.
*
- * This generally should just be called from gsk_ngl_program_split_draw()
+ * This generally should just be called from gsk_gl_program_split_draw()
* as that is where the begin/end flow happens from the render job.
*/
void
-gsk_ngl_command_queue_split_draw (GskNglCommandQueue *self)
+gsk_gl_command_queue_split_draw (GskGLCommandQueue *self)
{
- GskNglCommandBatch *batch;
- GskNglUniformProgram *program;
+ GskGLCommandBatch *batch;
+ GskGLUniformProgram *program;
guint width;
guint height;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->batches.len > 0);
g_assert (self->in_draw == TRUE);
program = self->program_info;
- batch = gsk_ngl_command_batches_tail (&self->batches);
+ batch = gsk_gl_command_batches_tail (&self->batches);
- g_assert (batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW);
+ g_assert (batch->any.kind == GSK_GL_COMMAND_KIND_DRAW);
width = batch->any.viewport.width;
height = batch->any.viewport.height;
- gsk_ngl_command_queue_end_draw (self);
- gsk_ngl_command_queue_begin_draw (self, program, width, height);
+ gsk_gl_command_queue_end_draw (self);
+ gsk_gl_command_queue_begin_draw (self, program, width, height);
}
void
-gsk_ngl_command_queue_clear (GskNglCommandQueue *self,
+gsk_gl_command_queue_clear (GskGLCommandQueue *self,
guint clear_bits,
const graphene_rect_t *viewport)
{
- GskNglCommandBatch *batch;
+ GskGLCommandBatch *batch;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->in_draw == FALSE);
if (will_ignore_batch (self))
@@ -691,7 +691,7 @@ gsk_ngl_command_queue_clear (GskNglCommandQueue *self,
clear_bits = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
batch = begin_next_batch (self);
- batch->any.kind = GSK_NGL_COMMAND_KIND_CLEAR;
+ batch->any.kind = GSK_GL_COMMAND_KIND_CLEAR;
batch->any.viewport.width = viewport->size.width;
batch->any.viewport.height = viewport->size.height;
batch->clear.bits = clear_bits;
@@ -707,27 +707,27 @@ gsk_ngl_command_queue_clear (GskNglCommandQueue *self,
}
GdkGLContext *
-gsk_ngl_command_queue_get_context (GskNglCommandQueue *self)
+gsk_gl_command_queue_get_context (GskGLCommandQueue *self)
{
- g_return_val_if_fail (GSK_IS_NGL_COMMAND_QUEUE (self), NULL);
+ g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self), NULL);
return self->context;
}
void
-gsk_ngl_command_queue_make_current (GskNglCommandQueue *self)
+gsk_gl_command_queue_make_current (GskGLCommandQueue *self)
{
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (GDK_IS_GL_CONTEXT (self->context));
gdk_gl_context_make_current (self->context);
}
void
-gsk_ngl_command_queue_delete_program (GskNglCommandQueue *self,
- guint program)
+gsk_gl_command_queue_delete_program (GskGLCommandQueue *self,
+ guint program)
{
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
glDeleteProgram (program);
}
@@ -791,8 +791,8 @@ apply_framebuffer (int *framebuffer,
}
static inline void
-gsk_ngl_command_queue_unlink (GskNglCommandQueue *self,
- GskNglCommandBatch *batch)
+gsk_gl_command_queue_unlink (GskGLCommandQueue *self,
+ GskGLCommandBatch *batch)
{
if (batch->any.prev_batch_index == -1)
self->head_batch_index = batch->any.next_batch_index;
@@ -809,9 +809,9 @@ gsk_ngl_command_queue_unlink (GskNglCommandQueue *self,
}
static inline void
-gsk_ngl_command_queue_insert_before (GskNglCommandQueue *self,
- GskNglCommandBatch *batch,
- GskNglCommandBatch *sibling)
+gsk_gl_command_queue_insert_before (GskGLCommandQueue *self,
+ GskGLCommandBatch *batch,
+ GskGLCommandBatch *sibling)
{
int sibling_index;
int index;
@@ -821,8 +821,8 @@ gsk_ngl_command_queue_insert_before (GskNglCommandQueue *self,
g_assert (sibling >= self->batches.items);
g_assert (sibling < &self->batches.items[self->batches.len]);
- index = gsk_ngl_command_batches_index_of (&self->batches, batch);
- sibling_index = gsk_ngl_command_batches_index_of (&self->batches, sibling);
+ index = gsk_gl_command_batches_index_of (&self->batches, batch);
+ sibling_index = gsk_gl_command_batches_index_of (&self->batches, sibling);
batch->any.next_batch_index = sibling_index;
batch->any.prev_batch_index = sibling->any.prev_batch_index;
@@ -837,13 +837,13 @@ gsk_ngl_command_queue_insert_before (GskNglCommandQueue *self,
}
static void
-gsk_ngl_command_queue_sort_batches (GskNglCommandQueue *self)
+gsk_gl_command_queue_sort_batches (GskGLCommandQueue *self)
{
int *seen;
int *seen_free = NULL;
int index;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->tail_batch_index >= 0);
g_assert (self->fbo_max >= 0);
@@ -868,7 +868,7 @@ gsk_ngl_command_queue_sort_batches (GskNglCommandQueue *self)
while (index >= 0)
{
- GskNglCommandBatch *batch = &self->batches.items[index];
+ GskGLCommandBatch *batch = &self->batches.items[index];
int cur_index = index;
int fbo = -1;
@@ -877,11 +877,11 @@ gsk_ngl_command_queue_sort_batches (GskNglCommandQueue *self)
switch (batch->any.kind)
{
- case GSK_NGL_COMMAND_KIND_DRAW:
+ case GSK_GL_COMMAND_KIND_DRAW:
fbo = batch->draw.framebuffer;
break;
- case GSK_NGL_COMMAND_KIND_CLEAR:
+ case GSK_GL_COMMAND_KIND_CLEAR:
fbo = batch->clear.framebuffer;
break;
@@ -905,16 +905,16 @@ gsk_ngl_command_queue_sort_batches (GskNglCommandQueue *self)
if (seen[fbo] != -1 && seen[fbo] != batch->any.next_batch_index)
{
int mru_index = seen[fbo];
- GskNglCommandBatch *mru = &self->batches.items[mru_index];
+ GskGLCommandBatch *mru = &self->batches.items[mru_index];
g_assert (mru_index > -1);
- gsk_ngl_command_queue_unlink (self, batch);
+ gsk_gl_command_queue_unlink (self, batch);
g_assert (batch->any.prev_batch_index == -1);
g_assert (batch->any.next_batch_index == -1);
- gsk_ngl_command_queue_insert_before (self, batch, mru);
+ gsk_gl_command_queue_insert_before (self, batch, mru);
g_assert (batch->any.prev_batch_index > -1 ||
self->head_batch_index == cur_index);
@@ -931,8 +931,8 @@ gsk_ngl_command_queue_sort_batches (GskNglCommandQueue *self)
}
/**
- * gsk_ngl_command_queue_execute:
- * @self: a `GskNglCommandQueue`
+ * gsk_gl_command_queue_execute:
+ * @self: a `GskGLCommandQueue`
* @surface_height: the height of the backing surface
* @scale_factor: the scale factor of the backing surface
* #scissor: (nullable): the scissor clip if any
@@ -940,10 +940,10 @@ gsk_ngl_command_queue_sort_batches (GskNglCommandQueue *self)
* Executes all of the batches in the command queue.
*/
void
-gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
- guint surface_height,
- guint scale_factor,
- const cairo_region_t *scissor)
+gsk_gl_command_queue_execute (GskGLCommandQueue *self,
+ guint surface_height,
+ guint scale_factor,
+ const cairo_region_t *scissor)
{
G_GNUC_UNUSED guint count = 0;
graphene_rect_t scissor_test;
@@ -963,7 +963,7 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
int next_batch_index;
int active = -1;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->in_draw == FALSE);
if (self->batches.len == 0)
@@ -972,9 +972,9 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
for (guint i = 0; i < G_N_ELEMENTS (textures); i++)
textures[i] = -1;
- gsk_ngl_command_queue_sort_batches (self);
+ gsk_gl_command_queue_sort_batches (self);
- gsk_ngl_command_queue_make_current (self);
+ gsk_gl_command_queue_make_current (self);
#ifdef G_ENABLE_DEBUG
gsk_gl_profiler_begin_gpu_region (self->gl_profiler);
@@ -992,31 +992,31 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
glGenVertexArrays (1, &vao_id);
glBindVertexArray (vao_id);
- vbo_id = gsk_ngl_buffer_submit (&self->vertices);
+ vbo_id = gsk_gl_buffer_submit (&self->vertices);
/* 0 = position location */
glEnableVertexAttribArray (0);
glVertexAttribPointer (0, 2, GL_FLOAT, GL_FALSE,
- sizeof (GskNglDrawVertex),
- (void *) G_STRUCT_OFFSET (GskNglDrawVertex, position));
+ sizeof (GskGLDrawVertex),
+ (void *) G_STRUCT_OFFSET (GskGLDrawVertex, position));
/* 1 = texture coord location */
glEnableVertexAttribArray (1);
glVertexAttribPointer (1, 2, GL_FLOAT, GL_FALSE,
- sizeof (GskNglDrawVertex),
- (void *) G_STRUCT_OFFSET (GskNglDrawVertex, uv));
+ sizeof (GskGLDrawVertex),
+ (void *) G_STRUCT_OFFSET (GskGLDrawVertex, uv));
/* 2 = color location */
glEnableVertexAttribArray (2);
glVertexAttribPointer (2, 4, GL_HALF_FLOAT, GL_FALSE,
- sizeof (GskNglDrawVertex),
- (void *) G_STRUCT_OFFSET (GskNglDrawVertex, color));
+ sizeof (GskGLDrawVertex),
+ (void *) G_STRUCT_OFFSET (GskGLDrawVertex, color));
/* 3 = color2 location */
glEnableVertexAttribArray (3);
glVertexAttribPointer (3, 4, GL_HALF_FLOAT, GL_FALSE,
- sizeof (GskNglDrawVertex),
- (void *) G_STRUCT_OFFSET (GskNglDrawVertex, color2));
+ sizeof (GskGLDrawVertex),
+ (void *) G_STRUCT_OFFSET (GskGLDrawVertex, color2));
/* Setup initial scissor clip */
if (scissor != NULL)
@@ -1036,7 +1036,7 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
while (next_batch_index >= 0)
{
- const GskNglCommandBatch *batch = &self->batches.items[next_batch_index];
+ const GskGLCommandBatch *batch = &self->batches.items[next_batch_index];
g_assert (next_batch_index >= 0);
g_assert (next_batch_index < self->batches.len);
@@ -1046,7 +1046,7 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
switch (batch->any.kind)
{
- case GSK_NGL_COMMAND_KIND_CLEAR:
+ case GSK_GL_COMMAND_KIND_CLEAR:
if (apply_framebuffer (&framebuffer, batch->clear.framebuffer))
{
apply_scissor (&scissor_state, framebuffer, &scissor_test, has_scissor);
@@ -1062,7 +1062,7 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
glClear (batch->clear.bits);
break;
- case GSK_NGL_COMMAND_KIND_DRAW:
+ case GSK_GL_COMMAND_KIND_DRAW:
if (batch->any.program != program)
{
program = batch->any.program;
@@ -1084,7 +1084,7 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
if G_UNLIKELY (batch->draw.bind_count > 0)
{
- const GskNglCommandBind *bind = &self->batch_binds.items[batch->draw.bind_offset];
+ const GskGLCommandBind *bind = &self->batch_binds.items[batch->draw.bind_offset];
for (guint i = 0; i < batch->draw.bind_count; i++)
{
@@ -1108,10 +1108,10 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
if (batch->draw.uniform_count > 0)
{
- const GskNglCommandUniform *u = &self->batch_uniforms.items[batch->draw.uniform_offset];
+ const GskGLCommandUniform *u = &self->batch_uniforms.items[batch->draw.uniform_offset];
for (guint i = 0; i < batch->draw.uniform_count; i++, u++)
- gsk_ngl_uniform_state_apply (self->uniforms, program, u->location, u->info);
+ gsk_gl_uniform_state_apply (self->uniforms, program, u->location, u->info);
n_uniforms += batch->draw.uniform_count;
}
@@ -1125,20 +1125,20 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
}
#if 0
- if (batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW ||
- batch->any.kind == GSK_NGL_COMMAND_KIND_CLEAR)
+ if (batch->any.kind == GSK_GL_COMMAND_KIND_DRAW ||
+ batch->any.kind == GSK_GL_COMMAND_KIND_CLEAR)
{
char filename[128];
g_snprintf (filename, sizeof filename,
"capture%03u_batch%03d_kind%u_program%u_u%u_b%u_fb%u_ctx%p.png",
count, next_batch_index,
batch->any.kind, batch->any.program,
- batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW ? batch->draw.uniform_count : 0,
- batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW ? batch->draw.bind_count : 0,
+ batch->any.kind == GSK_GL_COMMAND_KIND_DRAW ? batch->draw.uniform_count : 0,
+ batch->any.kind == GSK_GL_COMMAND_KIND_DRAW ? batch->draw.bind_count : 0,
framebuffer,
gdk_gl_context_get_current ());
- gsk_ngl_command_queue_capture_png (self, filename, width, height, TRUE);
- gsk_ngl_command_queue_print_batch (self, batch);
+ gsk_gl_command_queue_capture_png (self, filename, width, height, TRUE);
+ gsk_gl_command_queue_print_batch (self, batch);
}
#endif
@@ -1171,12 +1171,12 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
}
void
-gsk_ngl_command_queue_begin_frame (GskNglCommandQueue *self)
+gsk_gl_command_queue_begin_frame (GskGLCommandQueue *self)
{
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (self->batches.len == 0);
- gsk_ngl_command_queue_make_current (self);
+ gsk_gl_command_queue_make_current (self);
self->fbo_max = 0;
self->tail_batch_index = -1;
@@ -1185,8 +1185,8 @@ gsk_ngl_command_queue_begin_frame (GskNglCommandQueue *self)
}
/**
- * gsk_ngl_command_queue_end_frame:
- * @self: a `GskNglCommandQueue`
+ * gsk_gl_command_queue_end_frame:
+ * @self: a `GskGLCommandQueue`
*
* This function performs cleanup steps that need to be done after
* a frame has finished. This is not performed as part of the command
@@ -1197,12 +1197,12 @@ gsk_ngl_command_queue_begin_frame (GskNglCommandQueue *self)
* has been called to swap the OpenGL framebuffers.
*/
void
-gsk_ngl_command_queue_end_frame (GskNglCommandQueue *self)
+gsk_gl_command_queue_end_frame (GskGLCommandQueue *self)
{
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
- gsk_ngl_command_queue_make_current (self);
- gsk_ngl_uniform_state_end_frame (self->uniforms);
+ gsk_gl_command_queue_make_current (self);
+ gsk_gl_uniform_state_end_frame (self->uniforms);
/* Reset attachments so we don't hold on to any textures
* that might be released after the frame.
@@ -1229,25 +1229,25 @@ gsk_ngl_command_queue_end_frame (GskNglCommandQueue *self)
}
gboolean
-gsk_ngl_command_queue_create_render_target (GskNglCommandQueue *self,
- int width,
- int height,
- int format,
- int min_filter,
- int mag_filter,
- guint *out_fbo_id,
- guint *out_texture_id)
+gsk_gl_command_queue_create_render_target (GskGLCommandQueue *self,
+ int width,
+ int height,
+ int format,
+ int min_filter,
+ int mag_filter,
+ guint *out_fbo_id,
+ guint *out_texture_id)
{
GLuint fbo_id = 0;
GLint texture_id;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (width > 0);
g_assert (height > 0);
g_assert (out_fbo_id != NULL);
g_assert (out_texture_id != NULL);
- texture_id = gsk_ngl_command_queue_create_texture (self,
+ texture_id = gsk_gl_command_queue_create_texture (self,
width, height,
format,
min_filter, mag_filter);
@@ -1259,7 +1259,7 @@ gsk_ngl_command_queue_create_render_target (GskNglCommandQueue *self,
return FALSE;
}
- fbo_id = gsk_ngl_command_queue_create_framebuffer (self);
+ fbo_id = gsk_gl_command_queue_create_framebuffer (self);
glBindFramebuffer (GL_FRAMEBUFFER, fbo_id);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0);
@@ -1272,16 +1272,16 @@ gsk_ngl_command_queue_create_render_target (GskNglCommandQueue *self,
}
int
-gsk_ngl_command_queue_create_texture (GskNglCommandQueue *self,
- int width,
- int height,
- int format,
- int min_filter,
- int mag_filter)
+gsk_gl_command_queue_create_texture (GskGLCommandQueue *self,
+ int width,
+ int height,
+ int format,
+ int min_filter,
+ int mag_filter)
{
GLuint texture_id = 0;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
if G_UNLIKELY (self->max_texture_size == -1)
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &self->max_texture_size);
@@ -1312,11 +1312,11 @@ gsk_ngl_command_queue_create_texture (GskNglCommandQueue *self,
}
guint
-gsk_ngl_command_queue_create_framebuffer (GskNglCommandQueue *self)
+gsk_gl_command_queue_create_framebuffer (GskGLCommandQueue *self)
{
GLuint fbo_id;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
glGenFramebuffers (1, &fbo_id);
@@ -1324,14 +1324,14 @@ gsk_ngl_command_queue_create_framebuffer (GskNglCommandQueue *self)
}
int
-gsk_ngl_command_queue_upload_texture (GskNglCommandQueue *self,
- GdkTexture *texture,
- guint x_offset,
- guint y_offset,
- guint width,
- guint height,
- int min_filter,
- int mag_filter)
+gsk_gl_command_queue_upload_texture (GskGLCommandQueue *self,
+ GdkTexture *texture,
+ guint x_offset,
+ guint y_offset,
+ guint width,
+ guint height,
+ int min_filter,
+ int mag_filter)
{
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
cairo_surface_t *surface = NULL;
@@ -1341,7 +1341,7 @@ gsk_ngl_command_queue_upload_texture (GskNglCommandQueue *self,
gsize bpp;
int texture_id;
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (!GDK_IS_GL_TEXTURE (texture));
g_assert (x_offset + width <= gdk_texture_get_width (texture));
g_assert (y_offset + height <= gdk_texture_get_height (texture));
@@ -1357,7 +1357,7 @@ gsk_ngl_command_queue_upload_texture (GskNglCommandQueue *self,
height = MAX (height, self->max_texture_size);
}
- texture_id = gsk_ngl_command_queue_create_texture (self, width, height, GL_RGBA8, min_filter, mag_filter);
+ texture_id = gsk_gl_command_queue_create_texture (self, width, height, GL_RGBA8, min_filter, mag_filter);
if (texture_id == -1)
return texture_id;
@@ -1407,11 +1407,11 @@ gsk_ngl_command_queue_upload_texture (GskNglCommandQueue *self,
}
void
-gsk_ngl_command_queue_set_profiler (GskNglCommandQueue *self,
- GskProfiler *profiler)
+gsk_gl_command_queue_set_profiler (GskGLCommandQueue *self,
+ GskProfiler *profiler)
{
#ifdef G_ENABLE_DEBUG
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
g_assert (GSK_IS_PROFILER (profiler));
if (g_set_object (&self->profiler, profiler))
diff --git a/gsk/gl/gskglcommandqueueprivate.h b/gsk/gl/gskglcommandqueueprivate.h
new file mode 100644
index 0000000000..c4da7231c9
--- /dev/null
+++ b/gsk/gl/gskglcommandqueueprivate.h
@@ -0,0 +1,362 @@
+/* gskglcommandqueueprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_COMMAND_QUEUE_PRIVATE_H__
+#define __GSK_GL_COMMAND_QUEUE_PRIVATE_H__
+
+#include <gsk/gskprofilerprivate.h>
+
+#include "gskgltypesprivate.h"
+#include "gskglbufferprivate.h"
+#include "gskglattachmentstateprivate.h"
+#include "gskgluniformstateprivate.h"
+
+#include "inlinearray.h"
+
+#include "gskglprofilerprivate.h"
+
+G_BEGIN_DECLS
+
+#define GSK_TYPE_GL_COMMAND_QUEUE (gsk_gl_command_queue_get_type())
+
+G_DECLARE_FINAL_TYPE (GskGLCommandQueue, gsk_gl_command_queue, GSK, GL_COMMAND_QUEUE, GObject)
+
+typedef enum _GskGLCommandKind
+{
+ /* The batch will perform a glClear() */
+ GSK_GL_COMMAND_KIND_CLEAR,
+
+ /* The batch will perform a glDrawArrays() */
+ GSK_GL_COMMAND_KIND_DRAW,
+} GskGLCommandKind;
+
+typedef struct _GskGLCommandBind
+{
+ /* @texture is the value passed to glActiveTexture(), the "slot" the
+ * texture will be placed into. We always use GL_TEXTURE_2D so we don't
+ * waste any bits here to indicate that.
+ */
+ guint texture : 5;
+
+ /* The identifier for the texture created with glGenTextures(). */
+ guint id : 27;
+} GskGLCommandBind;
+
+G_STATIC_ASSERT (sizeof (GskGLCommandBind) == 4);
+
+typedef struct _GskGLCommandBatchAny
+{
+ /* A GskGLCommandKind indicating what the batch will do */
+ guint kind : 8;
+
+ /* The program's identifier to use for determining if we can merge two
+ * batches together into a single set of draw operations. We put this
+ * here instead of the GskGLCommandDraw so that we can use the extra
+ * bits here without making the structure larger.
+ */
+ guint program : 24;
+
+ /* The index of the next batch following this one. This is used
+ * as a sort of integer-based linked list to simplify out-of-order
+ * batching without moving memory around. -1 indicates last batch.
+ */
+ gint16 next_batch_index;
+
+ /* Same but for reverse direction as we sort in reverse to get the
+ * batches ordered by framebuffer.
+ */
+ gint16 prev_batch_index;
+
+ /* The viewport size of the batch. We check this as we process
+ * batches to determine if we need to resize the viewport.
+ */
+ struct {
+ guint16 width;
+ guint16 height;
+ } viewport;
+} GskGLCommandBatchAny;
+
+G_STATIC_ASSERT (sizeof (GskGLCommandBatchAny) == 12);
+
+typedef struct _GskGLCommandDraw
+{
+ GskGLCommandBatchAny head;
+
+ /* There doesn't seem to be a limit on the framebuffer identifier that
+ * can be returned, so we have to use a whole unsigned for the framebuffer
+ * we are drawing to. When processing batches, we check to see if this
+ * changes and adjust the render target accordingly. Some sorting is
+ * performed to reduce the amount we change framebuffers.
+ */
+ guint framebuffer;
+
+ /* The number of uniforms to change. This must be less than or equal to
+ * GL_MAX_UNIFORM_LOCATIONS but only guaranteed up to 1024 by any OpenGL
+ * implementation to be conformant.
+ */
+ guint uniform_count : 11;
+
+ /* The number of textures to bind, which is only guaranteed up to 16
+ * by the OpenGL specification to be conformant.
+ */
+ guint bind_count : 5;
+
+ /* GL_MAX_ELEMENTS_VERTICES specifies 33000 for this which requires 16-bit
+ * to address all possible counts <= GL_MAX_ELEMENTS_VERTICES.
+ */
+ guint vbo_count : 16;
+
+ /* The offset within the VBO containing @vbo_count vertices to send with
+ * glDrawArrays().
+ */
+ guint vbo_offset;
+
+ /* The offset within the array of uniform changes to be made containing
+ * @uniform_count `GskGLCommandUniform` elements to apply.
+ */
+ guint uniform_offset;
+
+ /* The offset within the array of bind changes to be made containing
+ * @bind_count `GskGLCommandBind` elements to apply.
+ */
+ guint bind_offset;
+} GskGLCommandDraw;
+
+G_STATIC_ASSERT (sizeof (GskGLCommandDraw) == 32);
+
+typedef struct _GskGLCommandClear
+{
+ GskGLCommandBatchAny any;
+ guint bits;
+ guint framebuffer;
+} GskGLCommandClear;
+
+G_STATIC_ASSERT (sizeof (GskGLCommandClear) == 20);
+
+typedef struct _GskGLCommandUniform
+{
+ GskGLUniformInfo info;
+ guint location;
+} GskGLCommandUniform;
+
+G_STATIC_ASSERT (sizeof (GskGLCommandUniform) == 8);
+
+typedef union _GskGLCommandBatch
+{
+ GskGLCommandBatchAny any;
+ GskGLCommandDraw draw;
+ GskGLCommandClear clear;
+} GskGLCommandBatch;
+
+G_STATIC_ASSERT (sizeof (GskGLCommandBatch) == 32);
+
+DEFINE_INLINE_ARRAY (GskGLCommandBatches, gsk_gl_command_batches, GskGLCommandBatch)
+DEFINE_INLINE_ARRAY (GskGLCommandBinds, gsk_gl_command_binds, GskGLCommandBind)
+DEFINE_INLINE_ARRAY (GskGLCommandUniforms, gsk_gl_command_uniforms, GskGLCommandUniform)
+
+struct _GskGLCommandQueue
+{
+ GObject parent_instance;
+
+ /* The GdkGLContext we make current before executing GL commands. */
+ GdkGLContext *context;
+
+ /* Array of GskGLCommandBatch which is a fixed size structure that will
+ * point into offsets of other arrays so that all similar data is stored
+ * together. The idea here is that we reduce the need for pointers so that
+ * using g_realloc()'d arrays is fine.
+ */
+ GskGLCommandBatches batches;
+
+ /* Contains array of vertices and some wrapper code to help upload them
+ * to the GL driver. We can also tweak this to use double buffered arrays
+ * if we find that to be faster on some hardware and/or drivers.
+ */
+ GskGLBuffer vertices;
+
+ /* The GskGLAttachmentState contains information about our FBO and texture
+ * attachments as we process incoming operations. We snapshot them into
+ * various batches so that we can compare differences between merge
+ * candidates.
+ */
+ GskGLAttachmentState *attachments;
+
+ /* The uniform state across all programs. We snapshot this into batches so
+ * that we can compare uniform state between batches to give us more
+ * chances at merging draw commands.
+ */
+ GskGLUniformState *uniforms;
+
+ /* Current program if we are in a draw so that we can send commands
+ * to the uniform state as needed.
+ */
+ GskGLUniformProgram *program_info;
+
+ /* The profiler instance to deliver timing/etc data */
+ GskProfiler *profiler;
+ GskGLProfiler *gl_profiler;
+
+ /* Array of GskGLCommandBind which denote what textures need to be attached
+ * to which slot. GskGLCommandDraw.bind_offset and bind_count reference this
+ * array to determine what to attach.
+ */
+ GskGLCommandBinds batch_binds;
+
+ /* Array of GskGLCommandUniform denoting which uniforms must be updated
+ * before the glDrawArrays() may be called. These are referenced from the
+ * GskGLCommandDraw.uniform_offset and uniform_count fields.
+ */
+ GskGLCommandUniforms batch_uniforms;
+
+ /* Discovered max texture size when loading the command queue so that we
+ * can either scale down or slice textures to fit within this size. Assumed
+ * to be both height and width.
+ */
+ int max_texture_size;
+
+ /* The index of the last batch in @batches, which may not be the element
+ * at the end of the array, as batches can be reordered. This is used to
+ * update the "next" index when adding a new batch.
+ */
+ gint16 tail_batch_index;
+ gint16 head_batch_index;
+
+ /* Max framebuffer we used, so we can sort items faster */
+ guint fbo_max;
+
+ /* Various GSK and GDK metric counter ids */
+ struct {
+ GQuark n_frames;
+ GQuark cpu_time;
+ GQuark gpu_time;
+ guint n_binds;
+ guint n_fbos;
+ guint n_uniforms;
+ guint n_uploads;
+ guint n_programs;
+ guint queue_depth;
+ } metrics;
+
+ /* Counter for uploads on the frame */
+ guint n_uploads;
+
+ /* If we're inside a begin/end_frame pair */
+ guint in_frame : 1;
+
+ /* If we're inside of a begin_draw()/end_draw() pair. */
+ guint in_draw : 1;
+
+ /* If we've warned about truncating batches */
+ guint have_truncated : 1;
+};
+
+GskGLCommandQueue *gsk_gl_command_queue_new (GdkGLContext *context,
+ GskGLUniformState *uniforms);
+void gsk_gl_command_queue_set_profiler (GskGLCommandQueue *self,
+ GskProfiler *profiler);
+GdkGLContext *gsk_gl_command_queue_get_context (GskGLCommandQueue *self);
+void gsk_gl_command_queue_make_current (GskGLCommandQueue *self);
+void gsk_gl_command_queue_begin_frame (GskGLCommandQueue *self);
+void gsk_gl_command_queue_end_frame (GskGLCommandQueue *self);
+void gsk_gl_command_queue_execute (GskGLCommandQueue *self,
+ guint surface_height,
+ guint scale_factor,
+ const cairo_region_t *scissor);
+int gsk_gl_command_queue_upload_texture (GskGLCommandQueue *self,
+ GdkTexture *texture,
+ guint x_offset,
+ guint y_offset,
+ guint width,
+ guint height,
+ int min_filter,
+ int mag_filter);
+int gsk_gl_command_queue_create_texture (GskGLCommandQueue *self,
+ int width,
+ int height,
+ int format,
+ int min_filter,
+ int mag_filter);
+guint gsk_gl_command_queue_create_framebuffer (GskGLCommandQueue *self);
+gboolean gsk_gl_command_queue_create_render_target (GskGLCommandQueue *self,
+ int width,
+ int height,
+ int format,
+ int min_filter,
+ int mag_filter,
+ guint *out_fbo_id,
+ guint *out_texture_id);
+void gsk_gl_command_queue_delete_program (GskGLCommandQueue *self,
+ guint program_id);
+void gsk_gl_command_queue_clear (GskGLCommandQueue *self,
+ guint clear_bits,
+ const graphene_rect_t *viewport);
+void gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
+ GskGLUniformProgram *program_info,
+ guint width,
+ guint height);
+void gsk_gl_command_queue_end_draw (GskGLCommandQueue *self);
+void gsk_gl_command_queue_split_draw (GskGLCommandQueue *self);
+
+static inline GskGLCommandBatch *
+gsk_gl_command_queue_get_batch (GskGLCommandQueue *self)
+{
+ return gsk_gl_command_batches_tail (&self->batches);
+}
+
+static inline GskGLDrawVertex *
+gsk_gl_command_queue_add_vertices (GskGLCommandQueue *self)
+{
+ gsk_gl_command_queue_get_batch (self)->draw.vbo_count += GSK_GL_N_VERTICES;
+ return gsk_gl_buffer_advance (&self->vertices, GSK_GL_N_VERTICES);
+}
+
+static inline GskGLDrawVertex *
+gsk_gl_command_queue_add_n_vertices (GskGLCommandQueue *self,
+ guint count)
+{
+ /* This is a batch form of gsk_gl_command_queue_add_vertices(). Note that
+ * it does *not* add the count to .draw.vbo_count as the caller is responsible
+ * for that.
+ */
+ return gsk_gl_buffer_advance (&self->vertices, GSK_GL_N_VERTICES * count);
+}
+
+static inline void
+gsk_gl_command_queue_retract_n_vertices (GskGLCommandQueue *self,
+ guint count)
+{
+ /* Like gsk_gl_command_queue_add_n_vertices(), this does not tweak
+ * the draw vbo_count.
+ */
+ gsk_gl_buffer_retract (&self->vertices, GSK_GL_N_VERTICES * count);
+}
+
+static inline guint
+gsk_gl_command_queue_bind_framebuffer (GskGLCommandQueue *self,
+ guint framebuffer)
+{
+ guint ret = self->attachments->fbo.id;
+ gsk_gl_attachment_state_bind_framebuffer (self->attachments, framebuffer);
+ return ret;
+}
+
+G_END_DECLS
+
+#endif /* __GSK_GL_COMMAND_QUEUE_PRIVATE_H__ */
diff --git a/gsk/ngl/gsknglcompiler.c b/gsk/gl/gskglcompiler.c
similarity index 76%
rename from gsk/ngl/gsknglcompiler.c
rename to gsk/gl/gskglcompiler.c
index 8b1791f130..c885df8f45 100644
--- a/gsk/ngl/gsknglcompiler.c
+++ b/gsk/gl/gskglcompiler.c
@@ -1,4 +1,4 @@
-/* gsknglcompiler.c
+/* gskglcompiler.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -24,20 +24,20 @@
#include <gio/gio.h>
#include <string.h>
-#include "gsknglcommandqueueprivate.h"
-#include "gsknglcompilerprivate.h"
-#include "gsknglprogramprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskglcompilerprivate.h"
+#include "gskglprogramprivate.h"
#define SHADER_VERSION_GLES 100
#define SHADER_VERSION_GL2_LEGACY 110
#define SHADER_VERSION_GL3_LEGACY 130
#define SHADER_VERSION_GL3 150
-struct _GskNglCompiler
+struct _GskGLCompiler
{
GObject parent_instance;
- GskNglDriver *driver;
+ GskGLDriver *driver;
GBytes *all_preamble;
GBytes *fragment_preamble;
@@ -57,20 +57,20 @@ struct _GskNglCompiler
guint debug_shaders : 1;
};
-typedef struct _GskNglProgramAttrib
+typedef struct _GskGLProgramAttrib
{
const char *name;
guint location;
-} GskNglProgramAttrib;
+} GskGLProgramAttrib;
static GBytes *empty_bytes;
-G_DEFINE_TYPE (GskNglCompiler, gsk_ngl_compiler, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GskGLCompiler, gsk_gl_compiler, G_TYPE_OBJECT)
static void
-gsk_ngl_compiler_finalize (GObject *object)
+gsk_gl_compiler_finalize (GObject *object)
{
- GskNglCompiler *self = (GskNglCompiler *)object;
+ GskGLCompiler *self = (GskGLCompiler *)object;
g_clear_pointer (&self->all_preamble, g_bytes_unref);
g_clear_pointer (&self->fragment_preamble, g_bytes_unref);
@@ -82,24 +82,24 @@ gsk_ngl_compiler_finalize (GObject *object)
g_clear_pointer (&self->attrib_locations, g_array_unref);
g_clear_object (&self->driver);
- G_OBJECT_CLASS (gsk_ngl_compiler_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gsk_gl_compiler_parent_class)->finalize (object);
}
static void
-gsk_ngl_compiler_class_init (GskNglCompilerClass *klass)
+gsk_gl_compiler_class_init (GskGLCompilerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gsk_ngl_compiler_finalize;
+ object_class->finalize = gsk_gl_compiler_finalize;
empty_bytes = g_bytes_new (NULL, 0);
}
static void
-gsk_ngl_compiler_init (GskNglCompiler *self)
+gsk_gl_compiler_init (GskGLCompiler *self)
{
self->glsl_version = 150;
- self->attrib_locations = g_array_new (FALSE, FALSE, sizeof (GskNglProgramAttrib));
+ self->attrib_locations = g_array_new (FALSE, FALSE, sizeof (GskGLProgramAttrib));
self->all_preamble = g_bytes_ref (empty_bytes);
self->vertex_preamble = g_bytes_ref (empty_bytes);
self->fragment_preamble = g_bytes_ref (empty_bytes);
@@ -109,21 +109,21 @@ gsk_ngl_compiler_init (GskNglCompiler *self)
self->fragment_suffix = g_bytes_ref (empty_bytes);
}
-GskNglCompiler *
-gsk_ngl_compiler_new (GskNglDriver *driver,
- gboolean debug_shaders)
+GskGLCompiler *
+gsk_gl_compiler_new (GskGLDriver *driver,
+ gboolean debug_shaders)
{
- GskNglCompiler *self;
+ GskGLCompiler *self;
GdkGLContext *context;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), NULL);
g_return_val_if_fail (driver->shared_command_queue != NULL, NULL);
self = g_object_new (GSK_TYPE_GL_COMPILER, NULL);
self->driver = g_object_ref (driver);
self->debug_shaders = !!debug_shaders;
- context = gsk_ngl_command_queue_get_context (self->driver->shared_command_queue);
+ context = gsk_gl_command_queue_get_context (self->driver->shared_command_queue);
if (gdk_gl_context_get_use_es (context))
{
@@ -149,19 +149,19 @@ gsk_ngl_compiler_new (GskNglDriver *driver,
self->gl3 = TRUE;
}
- gsk_ngl_command_queue_make_current (self->driver->shared_command_queue);
+ gsk_gl_command_queue_make_current (self->driver->shared_command_queue);
return g_steal_pointer (&self);
}
void
-gsk_ngl_compiler_bind_attribute (GskNglCompiler *self,
- const char *name,
- guint location)
+gsk_gl_compiler_bind_attribute (GskGLCompiler *self,
+ const char *name,
+ guint location)
{
- GskNglProgramAttrib attrib;
+ GskGLProgramAttrib attrib;
- g_return_if_fail (GSK_IS_NGL_COMPILER (self));
+ g_return_if_fail (GSK_IS_GL_COMPILER (self));
g_return_if_fail (name != NULL);
g_return_if_fail (location < 32);
@@ -172,28 +172,28 @@ gsk_ngl_compiler_bind_attribute (GskNglCompiler *self,
}
void
-gsk_ngl_compiler_clear_attributes (GskNglCompiler *self)
+gsk_gl_compiler_clear_attributes (GskGLCompiler *self)
{
- g_return_if_fail (GSK_IS_NGL_COMPILER (self));
+ g_return_if_fail (GSK_IS_GL_COMPILER (self));
g_array_set_size (self->attrib_locations, 0);
}
void
-gsk_ngl_compiler_set_preamble (GskNglCompiler *self,
- GskNglCompilerKind kind,
- GBytes *preamble_bytes)
+gsk_gl_compiler_set_preamble (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ GBytes *preamble_bytes)
{
GBytes **loc = NULL;
- g_return_if_fail (GSK_IS_NGL_COMPILER (self));
+ g_return_if_fail (GSK_IS_GL_COMPILER (self));
g_return_if_fail (preamble_bytes != NULL);
- if (kind == GSK_NGL_COMPILER_ALL)
+ if (kind == GSK_GL_COMPILER_ALL)
loc = &self->all_preamble;
- else if (kind == GSK_NGL_COMPILER_FRAGMENT)
+ else if (kind == GSK_GL_COMPILER_FRAGMENT)
loc = &self->fragment_preamble;
- else if (kind == GSK_NGL_COMPILER_VERTEX)
+ else if (kind == GSK_GL_COMPILER_VERTEX)
loc = &self->vertex_preamble;
else
g_return_if_reached ();
@@ -208,17 +208,17 @@ gsk_ngl_compiler_set_preamble (GskNglCompiler *self,
}
void
-gsk_ngl_compiler_set_preamble_from_resource (GskNglCompiler *self,
- GskNglCompilerKind kind,
- const char *resource_path)
+gsk_gl_compiler_set_preamble_from_resource (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ const char *resource_path)
{
GError *error = NULL;
GBytes *bytes;
- g_return_if_fail (GSK_IS_NGL_COMPILER (self));
- g_return_if_fail (kind == GSK_NGL_COMPILER_ALL ||
- kind == GSK_NGL_COMPILER_VERTEX ||
- kind == GSK_NGL_COMPILER_FRAGMENT);
+ g_return_if_fail (GSK_IS_GL_COMPILER (self));
+ g_return_if_fail (kind == GSK_GL_COMPILER_ALL ||
+ kind == GSK_GL_COMPILER_VERTEX ||
+ kind == GSK_GL_COMPILER_FRAGMENT);
g_return_if_fail (resource_path != NULL);
bytes = g_resources_lookup_data (resource_path,
@@ -228,23 +228,23 @@ gsk_ngl_compiler_set_preamble_from_resource (GskNglCompiler *self,
if (bytes == NULL)
g_warning ("Cannot set shader from resource: %s", error->message);
else
- gsk_ngl_compiler_set_preamble (self, kind, bytes);
+ gsk_gl_compiler_set_preamble (self, kind, bytes);
g_clear_pointer (&bytes, g_bytes_unref);
g_clear_error (&error);
}
void
-gsk_ngl_compiler_set_source (GskNglCompiler *self,
- GskNglCompilerKind kind,
- GBytes *source_bytes)
+gsk_gl_compiler_set_source (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ GBytes *source_bytes)
{
GBytes **loc = NULL;
- g_return_if_fail (GSK_IS_NGL_COMPILER (self));
- g_return_if_fail (kind == GSK_NGL_COMPILER_ALL ||
- kind == GSK_NGL_COMPILER_VERTEX ||
- kind == GSK_NGL_COMPILER_FRAGMENT);
+ g_return_if_fail (GSK_IS_GL_COMPILER (self));
+ g_return_if_fail (kind == GSK_GL_COMPILER_ALL ||
+ kind == GSK_GL_COMPILER_VERTEX ||
+ kind == GSK_GL_COMPILER_FRAGMENT);
if (source_bytes == NULL)
source_bytes = empty_bytes;
@@ -256,7 +256,7 @@ gsk_ngl_compiler_set_source (GskNglCompiler *self,
* use GBytes which reference the original bytes instead of
* copying them.
*/
- if (kind == GSK_NGL_COMPILER_ALL)
+ if (kind == GSK_GL_COMPILER_ALL)
{
gsize len = 0;
const char *source;
@@ -305,8 +305,8 @@ gsk_ngl_compiler_set_source (GskNglCompiler *self,
fragment_shader_start - source,
endpos - fragment_shader_start);
- gsk_ngl_compiler_set_source (self, GSK_NGL_COMPILER_VERTEX, vertex_bytes);
- gsk_ngl_compiler_set_source (self, GSK_NGL_COMPILER_FRAGMENT, fragment_bytes);
+ gsk_gl_compiler_set_source (self, GSK_GL_COMPILER_VERTEX, vertex_bytes);
+ gsk_gl_compiler_set_source (self, GSK_GL_COMPILER_FRAGMENT, fragment_bytes);
g_bytes_unref (fragment_bytes);
g_bytes_unref (vertex_bytes);
@@ -314,9 +314,9 @@ gsk_ngl_compiler_set_source (GskNglCompiler *self,
return;
}
- if (kind == GSK_NGL_COMPILER_FRAGMENT)
+ if (kind == GSK_GL_COMPILER_FRAGMENT)
loc = &self->fragment_source;
- else if (kind == GSK_NGL_COMPILER_VERTEX)
+ else if (kind == GSK_GL_COMPILER_VERTEX)
loc = &self->vertex_source;
else
g_return_if_reached ();
@@ -329,17 +329,17 @@ gsk_ngl_compiler_set_source (GskNglCompiler *self,
}
void
-gsk_ngl_compiler_set_source_from_resource (GskNglCompiler *self,
- GskNglCompilerKind kind,
- const char *resource_path)
+gsk_gl_compiler_set_source_from_resource (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ const char *resource_path)
{
GError *error = NULL;
GBytes *bytes;
- g_return_if_fail (GSK_IS_NGL_COMPILER (self));
- g_return_if_fail (kind == GSK_NGL_COMPILER_ALL ||
- kind == GSK_NGL_COMPILER_VERTEX ||
- kind == GSK_NGL_COMPILER_FRAGMENT);
+ g_return_if_fail (GSK_IS_GL_COMPILER (self));
+ g_return_if_fail (kind == GSK_GL_COMPILER_ALL ||
+ kind == GSK_GL_COMPILER_VERTEX ||
+ kind == GSK_GL_COMPILER_FRAGMENT);
g_return_if_fail (resource_path != NULL);
bytes = g_resources_lookup_data (resource_path,
@@ -349,30 +349,30 @@ gsk_ngl_compiler_set_source_from_resource (GskNglCompiler *self,
if (bytes == NULL)
g_warning ("Cannot set shader from resource: %s", error->message);
else
- gsk_ngl_compiler_set_source (self, kind, bytes);
+ gsk_gl_compiler_set_source (self, kind, bytes);
g_clear_pointer (&bytes, g_bytes_unref);
g_clear_error (&error);
}
void
-gsk_ngl_compiler_set_suffix (GskNglCompiler *self,
- GskNglCompilerKind kind,
- GBytes *suffix_bytes)
+gsk_gl_compiler_set_suffix (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ GBytes *suffix_bytes)
{
GBytes **loc;
- g_return_if_fail (GSK_IS_NGL_COMPILER (self));
- g_return_if_fail (kind == GSK_NGL_COMPILER_VERTEX ||
- kind == GSK_NGL_COMPILER_FRAGMENT);
+ g_return_if_fail (GSK_IS_GL_COMPILER (self));
+ g_return_if_fail (kind == GSK_GL_COMPILER_VERTEX ||
+ kind == GSK_GL_COMPILER_FRAGMENT);
g_return_if_fail (suffix_bytes != NULL);
if (suffix_bytes == NULL)
suffix_bytes = empty_bytes;
- if (kind == GSK_NGL_COMPILER_FRAGMENT)
+ if (kind == GSK_GL_COMPILER_FRAGMENT)
loc = &self->fragment_suffix;
- else if (kind == GSK_NGL_COMPILER_VERTEX)
+ else if (kind == GSK_GL_COMPILER_VERTEX)
loc = &self->vertex_suffix;
else
g_return_if_reached ();
@@ -385,16 +385,16 @@ gsk_ngl_compiler_set_suffix (GskNglCompiler *self,
}
void
-gsk_ngl_compiler_set_suffix_from_resource (GskNglCompiler *self,
- GskNglCompilerKind kind,
- const char *resource_path)
+gsk_gl_compiler_set_suffix_from_resource (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ const char *resource_path)
{
GError *error = NULL;
GBytes *bytes;
- g_return_if_fail (GSK_IS_NGL_COMPILER (self));
- g_return_if_fail (kind == GSK_NGL_COMPILER_VERTEX ||
- kind == GSK_NGL_COMPILER_FRAGMENT);
+ g_return_if_fail (GSK_IS_GL_COMPILER (self));
+ g_return_if_fail (kind == GSK_GL_COMPILER_VERTEX ||
+ kind == GSK_GL_COMPILER_FRAGMENT);
g_return_if_fail (resource_path != NULL);
bytes = g_resources_lookup_data (resource_path,
@@ -404,7 +404,7 @@ gsk_ngl_compiler_set_suffix_from_resource (GskNglCompiler *self,
if (bytes == NULL)
g_warning ("Cannot set suffix from resource: %s", error->message);
else
- gsk_ngl_compiler_set_suffix (self, kind, bytes);
+ gsk_gl_compiler_set_suffix (self, kind, bytes);
g_clear_pointer (&bytes, g_bytes_unref);
g_clear_error (&error);
@@ -520,11 +520,11 @@ get_shader_string (GBytes *bytes)
return str ? str : "";
}
-GskNglProgram *
-gsk_ngl_compiler_compile (GskNglCompiler *self,
- const char *name,
- const char *clip,
- GError **error)
+GskGLProgram *
+gsk_gl_compiler_compile (GskGLCompiler *self,
+ const char *name,
+ const char *clip,
+ GError **error)
{
char version[32];
const char *debug = "";
@@ -536,7 +536,7 @@ gsk_ngl_compiler_compile (GskNglCompiler *self,
int fragment_id;
int status;
- g_return_val_if_fail (GSK_IS_NGL_COMPILER (self), NULL);
+ g_return_val_if_fail (GSK_IS_GL_COMPILER (self), NULL);
g_return_val_if_fail (self->all_preamble != NULL, NULL);
g_return_val_if_fail (self->fragment_preamble != NULL, NULL);
g_return_val_if_fail (self->vertex_preamble != NULL, NULL);
@@ -544,7 +544,7 @@ gsk_ngl_compiler_compile (GskNglCompiler *self,
g_return_val_if_fail (self->vertex_source != NULL, NULL);
g_return_val_if_fail (self->driver != NULL, NULL);
- gsk_ngl_command_queue_make_current (self->driver->command_queue);
+ gsk_gl_command_queue_make_current (self->driver->command_queue);
g_snprintf (version, sizeof version, "#version %d\n", self->glsl_version);
@@ -633,9 +633,9 @@ gsk_ngl_compiler_compile (GskNglCompiler *self,
for (guint i = 0; i < self->attrib_locations->len; i++)
{
- const GskNglProgramAttrib *attrib;
+ const GskGLProgramAttrib *attrib;
- attrib = &g_array_index (self->attrib_locations, GskNglProgramAttrib, i);
+ attrib = &g_array_index (self->attrib_locations, GskGLProgramAttrib, i);
glBindAttribLocation (program_id, attrib->location, attrib->name);
}
@@ -679,5 +679,5 @@ gsk_ngl_compiler_compile (GskNglCompiler *self,
return NULL;
}
- return gsk_ngl_program_new (self->driver, name, program_id);
+ return gsk_gl_program_new (self->driver, name, program_id);
}
diff --git a/gsk/gl/gskglcompilerprivate.h b/gsk/gl/gskglcompilerprivate.h
new file mode 100644
index 0000000000..54f3e00836
--- /dev/null
+++ b/gsk/gl/gskglcompilerprivate.h
@@ -0,0 +1,70 @@
+/* gskglcompilerprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_COMPILER_PRIVATE_H__
+#define __GSK_GL_COMPILER_PRIVATE_H__
+
+#include "gskgltypesprivate.h"
+
+G_BEGIN_DECLS
+
+typedef enum _GskGLCompilerKind
+{
+ GSK_GL_COMPILER_ALL,
+ GSK_GL_COMPILER_FRAGMENT,
+ GSK_GL_COMPILER_VERTEX,
+} GskGLCompilerKind;
+
+#define GSK_TYPE_GL_COMPILER (gsk_gl_compiler_get_type())
+
+G_DECLARE_FINAL_TYPE (GskGLCompiler, gsk_gl_compiler, GSK, GL_COMPILER, GObject)
+
+GskGLCompiler * gsk_gl_compiler_new (GskGLDriver *driver,
+ gboolean debug);
+void gsk_gl_compiler_set_preamble (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ GBytes *preamble_bytes);
+void gsk_gl_compiler_set_preamble_from_resource (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ const char *resource_path);
+void gsk_gl_compiler_set_source (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ GBytes *source_bytes);
+void gsk_gl_compiler_set_source_from_resource (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ const char *resource_path);
+void gsk_gl_compiler_set_suffix (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ GBytes *suffix_bytes);
+void gsk_gl_compiler_set_suffix_from_resource (GskGLCompiler *self,
+ GskGLCompilerKind kind,
+ const char *resource_path);
+void gsk_gl_compiler_bind_attribute (GskGLCompiler *self,
+ const char *name,
+ guint location);
+void gsk_gl_compiler_clear_attributes (GskGLCompiler *self);
+GskGLProgram * gsk_gl_compiler_compile (GskGLCompiler *self,
+ const char *name,
+ const char *clip,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* __GSK_GL_COMPILER_PRIVATE_H__ */
diff --git a/gsk/ngl/gskngldriver.c b/gsk/gl/gskgldriver.c
similarity index 59%
rename from gsk/ngl/gskngldriver.c
rename to gsk/gl/gskgldriver.c
index 87f2864241..63763a8641 100644
--- a/gsk/ngl/gskngldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -1,4 +1,4 @@
-/* gskngldriver.c
+/* gskgldriver.c
*
* Copyright 2017 Timm Bäder <mail baedert org>
* Copyright 2018 Matthias Clasen <mclasen redhat com>
@@ -31,20 +31,20 @@
#include <gsk/gskglshaderprivate.h>
#include <gsk/gskrendererprivate.h>
-#include "gsknglcommandqueueprivate.h"
-#include "gsknglcompilerprivate.h"
-#include "gskngldriverprivate.h"
-#include "gsknglglyphlibraryprivate.h"
-#include "gskngliconlibraryprivate.h"
-#include "gsknglprogramprivate.h"
-#include "gsknglshadowlibraryprivate.h"
-#include "gskngltextureprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskglcompilerprivate.h"
+#include "gskgldriverprivate.h"
+#include "gskglglyphlibraryprivate.h"
+#include "gskgliconlibraryprivate.h"
+#include "gskglprogramprivate.h"
+#include "gskglshadowlibraryprivate.h"
+#include "gskgltextureprivate.h"
#include "fp16private.h"
#define ATLAS_SIZE 512
#define MAX_OLD_RATIO 0.5
-G_DEFINE_TYPE (GskNglDriver, gsk_ngl_driver, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GskGLDriver, gsk_gl_driver, G_TYPE_OBJECT)
static guint
texture_key_hash (gconstpointer v)
@@ -81,12 +81,12 @@ texture_key_equal (gconstpointer v1,
}
static void
-remove_texture_key_for_id (GskNglDriver *self,
- guint texture_id)
+remove_texture_key_for_id (GskGLDriver *self,
+ guint texture_id)
{
GskTextureKey *key;
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
g_assert (texture_id > 0);
/* g_hash_table_remove() will cause @key to be freed */
@@ -98,37 +98,37 @@ remove_texture_key_for_id (GskNglDriver *self,
}
static void
-gsk_ngl_texture_destroyed (gpointer data)
+gsk_gl_texture_destroyed (gpointer data)
{
- ((GskNglTexture *)data)->user = NULL;
+ ((GskGLTexture *)data)->user = NULL;
}
static void
-gsk_ngl_driver_autorelease_texture (GskNglDriver *self,
- guint texture_id)
+gsk_gl_driver_autorelease_texture (GskGLDriver *self,
+ guint texture_id)
{
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
g_array_append_val (self->texture_pool, texture_id);
}
static guint
-gsk_ngl_driver_collect_unused_textures (GskNglDriver *self,
- gint64 watermark)
+gsk_gl_driver_collect_unused_textures (GskGLDriver *self,
+ gint64 watermark)
{
GHashTableIter iter;
gpointer k, v;
guint old_size;
guint collected;
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
old_size = g_hash_table_size (self->textures);
g_hash_table_iter_init (&iter, self->textures);
while (g_hash_table_iter_next (&iter, &k, &v))
{
- GskNglTexture *t = v;
+ GskGLTexture *t = v;
if (t->user || t->permanent)
continue;
@@ -142,9 +142,9 @@ gsk_ngl_driver_collect_unused_textures (GskNglDriver *self,
g_assert (t->link.data == t);
remove_texture_key_for_id (self, t->texture_id);
- gsk_ngl_driver_autorelease_texture (self, t->texture_id);
+ gsk_gl_driver_autorelease_texture (self, t->texture_id);
t->texture_id = 0;
- gsk_ngl_texture_free (t);
+ gsk_gl_texture_free (t);
}
}
@@ -154,7 +154,7 @@ gsk_ngl_driver_collect_unused_textures (GskNglDriver *self,
}
static void
-gsk_ngl_texture_atlas_free (GskNglTextureAtlas *atlas)
+gsk_gl_texture_atlas_free (GskGLTextureAtlas *atlas)
{
if (atlas->texture_id != 0)
{
@@ -163,29 +163,29 @@ gsk_ngl_texture_atlas_free (GskNglTextureAtlas *atlas)
}
g_clear_pointer (&atlas->nodes, g_free);
- g_slice_free (GskNglTextureAtlas, atlas);
+ g_slice_free (GskGLTextureAtlas, atlas);
}
-GskNglTextureAtlas *
-gsk_ngl_driver_create_atlas (GskNglDriver *self)
+GskGLTextureAtlas *
+gsk_gl_driver_create_atlas (GskGLDriver *self)
{
- GskNglTextureAtlas *atlas;
+ GskGLTextureAtlas *atlas;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), NULL);
- atlas = g_slice_new0 (GskNglTextureAtlas);
+ atlas = g_slice_new0 (GskGLTextureAtlas);
atlas->width = ATLAS_SIZE;
atlas->height = ATLAS_SIZE;
/* TODO: We might want to change the strategy about the amount of
* nodes here? stb_rect_pack.h says width is optimal. */
atlas->nodes = g_malloc0_n (atlas->width, sizeof (struct stbrp_node));
stbrp_init_target (&atlas->context, atlas->width, atlas->height, atlas->nodes, atlas->width);
- atlas->texture_id = gsk_ngl_command_queue_create_texture (self->command_queue,
- atlas->width,
- atlas->height,
- GL_RGBA8,
- GL_LINEAR,
- GL_LINEAR);
+ atlas->texture_id = gsk_gl_command_queue_create_texture (self->command_queue,
+ atlas->width,
+ atlas->height,
+ GL_RGBA8,
+ GL_LINEAR,
+ GL_LINEAR);
gdk_gl_context_label_object_printf (gdk_gl_context_get_current (),
GL_TEXTURE, atlas->texture_id,
@@ -200,53 +200,53 @@ gsk_ngl_driver_create_atlas (GskNglDriver *self)
static void
remove_program (gpointer data)
{
- GskNglProgram *program = data;
+ GskGLProgram *program = data;
- g_assert (!program || GSK_IS_NGL_PROGRAM (program));
+ g_assert (!program || GSK_IS_GL_PROGRAM (program));
if (program != NULL)
{
- gsk_ngl_program_delete (program);
+ gsk_gl_program_delete (program);
g_object_unref (program);
}
}
static void
-gsk_ngl_driver_shader_weak_cb (gpointer data,
- GObject *where_object_was)
+gsk_gl_driver_shader_weak_cb (gpointer data,
+ GObject *where_object_was)
{
- GskNglDriver *self = data;
+ GskGLDriver *self = data;
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
if (self->shader_cache != NULL)
g_hash_table_remove (self->shader_cache, where_object_was);
}
static void
-gsk_ngl_driver_dispose (GObject *object)
+gsk_gl_driver_dispose (GObject *object)
{
- GskNglDriver *self = (GskNglDriver *)object;
+ GskGLDriver *self = (GskGLDriver *)object;
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
g_assert (self->in_frame == FALSE);
-#define GSK_NGL_NO_UNIFORMS
-#define GSK_NGL_ADD_UNIFORM(pos, KEY, name)
-#define GSK_NGL_DEFINE_PROGRAM(name, resource, uniforms) \
- GSK_NGL_DELETE_PROGRAM(name); \
- GSK_NGL_DELETE_PROGRAM(name ## _no_clip); \
- GSK_NGL_DELETE_PROGRAM(name ## _rect_clip);
-#define GSK_NGL_DELETE_PROGRAM(name) \
- G_STMT_START { \
- if (self->name) \
- gsk_ngl_program_delete (self->name); \
- g_clear_object (&self->name); \
+#define GSK_GL_NO_UNIFORMS
+#define GSK_GL_ADD_UNIFORM(pos, KEY, name)
+#define GSK_GL_DEFINE_PROGRAM(name, resource, uniforms) \
+ GSK_GL_DELETE_PROGRAM(name); \
+ GSK_GL_DELETE_PROGRAM(name ## _no_clip); \
+ GSK_GL_DELETE_PROGRAM(name ## _rect_clip);
+#define GSK_GL_DELETE_PROGRAM(name) \
+ G_STMT_START { \
+ if (self->name) \
+ gsk_gl_program_delete (self->name); \
+ g_clear_object (&self->name); \
} G_STMT_END;
-# include "gsknglprograms.defs"
-#undef GSK_NGL_NO_UNIFORMS
-#undef GSK_NGL_ADD_UNIFORM
-#undef GSK_NGL_DEFINE_PROGRAM
+# include "gskglprograms.defs"
+#undef GSK_GL_NO_UNIFORMS
+#undef GSK_GL_ADD_UNIFORM
+#undef GSK_GL_DEFINE_PROGRAM
if (self->shader_cache != NULL)
{
@@ -258,7 +258,7 @@ gsk_ngl_driver_dispose (GObject *object)
{
GskGLShader *shader = k;
g_object_weak_unref (G_OBJECT (shader),
- gsk_ngl_driver_shader_weak_cb,
+ gsk_gl_driver_shader_weak_cb,
self);
g_hash_table_iter_remove (&iter);
}
@@ -268,8 +268,8 @@ gsk_ngl_driver_dispose (GObject *object)
if (self->command_queue != NULL)
{
- gsk_ngl_command_queue_make_current (self->command_queue);
- gsk_ngl_driver_collect_unused_textures (self, 0);
+ gsk_gl_command_queue_make_current (self->command_queue);
+ gsk_gl_driver_collect_unused_textures (self, 0);
g_clear_object (&self->command_queue);
}
@@ -302,23 +302,23 @@ gsk_ngl_driver_dispose (GObject *object)
g_clear_object (&self->command_queue);
g_clear_object (&self->shared_command_queue);
- G_OBJECT_CLASS (gsk_ngl_driver_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gsk_gl_driver_parent_class)->dispose (object);
}
static void
-gsk_ngl_driver_class_init (GskNglDriverClass *klass)
+gsk_gl_driver_class_init (GskGLDriverClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = gsk_ngl_driver_dispose;
+ object_class->dispose = gsk_gl_driver_dispose;
}
static void
-gsk_ngl_driver_init (GskNglDriver *self)
+gsk_gl_driver_init (GskGLDriver *self)
{
self->autorelease_framebuffers = g_array_new (FALSE, FALSE, sizeof (guint));
self->textures = g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify)gsk_ngl_texture_free);
+ (GDestroyNotify)gsk_gl_texture_free);
self->texture_id_to_key = g_hash_table_new (NULL, NULL);
self->key_to_texture_id = g_hash_table_new_full (texture_key_hash,
texture_key_equal,
@@ -327,77 +327,77 @@ gsk_ngl_driver_init (GskNglDriver *self)
self->shader_cache = g_hash_table_new_full (NULL, NULL, NULL, remove_program);
self->texture_pool = g_array_new (FALSE, FALSE, sizeof (guint));
self->render_targets = g_ptr_array_new ();
- self->atlases = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_ngl_texture_atlas_free);
+ self->atlases = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_gl_texture_atlas_free);
}
static gboolean
-gsk_ngl_driver_load_programs (GskNglDriver *self,
- GError **error)
+gsk_gl_driver_load_programs (GskGLDriver *self,
+ GError **error)
{
- GskNglCompiler *compiler;
+ GskGLCompiler *compiler;
gboolean ret = FALSE;
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
- g_assert (GSK_IS_NGL_DRIVER (self));
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (self->command_queue));
+ g_assert (GSK_IS_GL_DRIVER (self));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (self->command_queue));
- compiler = gsk_ngl_compiler_new (self, self->debug);
+ compiler = gsk_gl_compiler_new (self, self->debug);
/* Setup preambles that are shared by all shaders */
- gsk_ngl_compiler_set_preamble_from_resource (compiler,
- GSK_NGL_COMPILER_ALL,
+ gsk_gl_compiler_set_preamble_from_resource (compiler,
+ GSK_GL_COMPILER_ALL,
"/org/gtk/libgsk/ngl/preamble.glsl");
- gsk_ngl_compiler_set_preamble_from_resource (compiler,
- GSK_NGL_COMPILER_VERTEX,
+ gsk_gl_compiler_set_preamble_from_resource (compiler,
+ GSK_GL_COMPILER_VERTEX,
"/org/gtk/libgsk/ngl/preamble.vs.glsl");
- gsk_ngl_compiler_set_preamble_from_resource (compiler,
- GSK_NGL_COMPILER_FRAGMENT,
+ gsk_gl_compiler_set_preamble_from_resource (compiler,
+ GSK_GL_COMPILER_FRAGMENT,
"/org/gtk/libgsk/ngl/preamble.fs.glsl");
/* Setup attributes that are provided via VBO */
- gsk_ngl_compiler_bind_attribute (compiler, "aPosition", 0);
- gsk_ngl_compiler_bind_attribute (compiler, "aUv", 1);
- gsk_ngl_compiler_bind_attribute (compiler, "aColor", 2);
- gsk_ngl_compiler_bind_attribute (compiler, "aColor2", 3);
+ gsk_gl_compiler_bind_attribute (compiler, "aPosition", 0);
+ gsk_gl_compiler_bind_attribute (compiler, "aUv", 1);
+ gsk_gl_compiler_bind_attribute (compiler, "aColor", 2);
+ gsk_gl_compiler_bind_attribute (compiler, "aColor2", 3);
/* Use XMacros to register all of our programs and their uniforms */
-#define GSK_NGL_NO_UNIFORMS
-#define GSK_NGL_ADD_UNIFORM(pos, KEY, name) \
- gsk_ngl_program_add_uniform (program, #name, UNIFORM_##KEY);
-#define GSK_NGL_DEFINE_PROGRAM(name, resource, uniforms) \
- gsk_ngl_compiler_set_source_from_resource (compiler, GSK_NGL_COMPILER_ALL, resource); \
- GSK_NGL_COMPILE_PROGRAM(name ## _no_clip, uniforms, "#define NO_CLIP 1\n"); \
- GSK_NGL_COMPILE_PROGRAM(name ## _rect_clip, uniforms, "#define RECT_CLIP 1\n"); \
- GSK_NGL_COMPILE_PROGRAM(name, uniforms, "");
-#define GSK_NGL_COMPILE_PROGRAM(name, uniforms, clip) \
- G_STMT_START { \
- GskNglProgram *program; \
- gboolean have_alpha; \
- gboolean have_source; \
- \
- if (!(program = gsk_ngl_compiler_compile (compiler, #name, clip, error))) \
- goto failure; \
- \
- have_alpha = gsk_ngl_program_add_uniform (program, "u_alpha", UNIFORM_SHARED_ALPHA); \
- have_source = gsk_ngl_program_add_uniform (program, "u_source", UNIFORM_SHARED_SOURCE); \
- gsk_ngl_program_add_uniform (program, "u_clip_rect", UNIFORM_SHARED_CLIP_RECT); \
- gsk_ngl_program_add_uniform (program, "u_viewport", UNIFORM_SHARED_VIEWPORT); \
- gsk_ngl_program_add_uniform (program, "u_projection", UNIFORM_SHARED_PROJECTION); \
- gsk_ngl_program_add_uniform (program, "u_modelview", UNIFORM_SHARED_MODELVIEW); \
- \
- uniforms \
- \
- gsk_ngl_program_uniforms_added (program, have_source); \
- if (have_alpha) \
- gsk_ngl_program_set_uniform1f (program, UNIFORM_SHARED_ALPHA, 0, 1.0f); \
- \
- *(GskNglProgram **)(((guint8 *)self) + G_STRUCT_OFFSET (GskNglDriver, name)) = \
- g_steal_pointer (&program); \
+#define GSK_GL_NO_UNIFORMS
+#define GSK_GL_ADD_UNIFORM(pos, KEY, name) \
+ gsk_gl_program_add_uniform (program, #name, UNIFORM_##KEY);
+#define GSK_GL_DEFINE_PROGRAM(name, resource, uniforms) \
+ gsk_gl_compiler_set_source_from_resource (compiler, GSK_GL_COMPILER_ALL, resource); \
+ GSK_GL_COMPILE_PROGRAM(name ## _no_clip, uniforms, "#define NO_CLIP 1\n"); \
+ GSK_GL_COMPILE_PROGRAM(name ## _rect_clip, uniforms, "#define RECT_CLIP 1\n"); \
+ GSK_GL_COMPILE_PROGRAM(name, uniforms, "");
+#define GSK_GL_COMPILE_PROGRAM(name, uniforms, clip) \
+ G_STMT_START { \
+ GskGLProgram *program; \
+ gboolean have_alpha; \
+ gboolean have_source; \
+ \
+ if (!(program = gsk_gl_compiler_compile (compiler, #name, clip, error))) \
+ goto failure; \
+ \
+ have_alpha = gsk_gl_program_add_uniform (program, "u_alpha", UNIFORM_SHARED_ALPHA); \
+ have_source = gsk_gl_program_add_uniform (program, "u_source", UNIFORM_SHARED_SOURCE); \
+ gsk_gl_program_add_uniform (program, "u_clip_rect", UNIFORM_SHARED_CLIP_RECT); \
+ gsk_gl_program_add_uniform (program, "u_viewport", UNIFORM_SHARED_VIEWPORT); \
+ gsk_gl_program_add_uniform (program, "u_projection", UNIFORM_SHARED_PROJECTION); \
+ gsk_gl_program_add_uniform (program, "u_modelview", UNIFORM_SHARED_MODELVIEW); \
+ \
+ uniforms \
+ \
+ gsk_gl_program_uniforms_added (program, have_source); \
+ if (have_alpha) \
+ gsk_gl_program_set_uniform1f (program, UNIFORM_SHARED_ALPHA, 0, 1.0f); \
+ \
+ *(GskGLProgram **)(((guint8 *)self) + G_STRUCT_OFFSET (GskGLDriver, name)) = \
+ g_steal_pointer (&program); \
} G_STMT_END;
-# include "gsknglprograms.defs"
-#undef GSK_NGL_DEFINE_PROGRAM_CLIP
-#undef GSK_NGL_DEFINE_PROGRAM
-#undef GSK_NGL_ADD_UNIFORM
+# include "gskglprograms.defs"
+#undef GSK_GL_DEFINE_PROGRAM_CLIP
+#undef GSK_GL_DEFINE_PROGRAM
+#undef GSK_GL_ADD_UNIFORM
ret = TRUE;
@@ -410,60 +410,60 @@ failure:
}
/**
- * gsk_ngl_driver_autorelease_framebuffer:
- * @self: a `GskNglDriver`
+ * gsk_gl_driver_autorelease_framebuffer:
+ * @self: a `GskGLDriver`
* @framebuffer_id: the id of the OpenGL framebuffer
*
* Marks @framebuffer_id to be deleted when the current frame has cmopleted.
*/
static void
-gsk_ngl_driver_autorelease_framebuffer (GskNglDriver *self,
- guint framebuffer_id)
+gsk_gl_driver_autorelease_framebuffer (GskGLDriver *self,
+ guint framebuffer_id)
{
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
g_array_append_val (self->autorelease_framebuffers, framebuffer_id);
}
-static GskNglDriver *
-gsk_ngl_driver_new (GskNglCommandQueue *command_queue,
- gboolean debug_shaders,
- GError **error)
+static GskGLDriver *
+gsk_gl_driver_new (GskGLCommandQueue *command_queue,
+ gboolean debug_shaders,
+ GError **error)
{
- GskNglDriver *self;
+ GskGLDriver *self;
GdkGLContext *context;
gint64 before G_GNUC_UNUSED;
- g_return_val_if_fail (GSK_IS_NGL_COMMAND_QUEUE (command_queue), NULL);
+ g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (command_queue), NULL);
before = GDK_PROFILER_CURRENT_TIME;
- context = gsk_ngl_command_queue_get_context (command_queue);
+ context = gsk_gl_command_queue_get_context (command_queue);
gdk_gl_context_make_current (context);
- self = g_object_new (GSK_TYPE_NGL_DRIVER, NULL);
+ self = g_object_new (GSK_TYPE_GL_DRIVER, NULL);
self->command_queue = g_object_ref (command_queue);
self->shared_command_queue = g_object_ref (command_queue);
self->debug = !!debug_shaders;
- if (!gsk_ngl_driver_load_programs (self, error))
+ if (!gsk_gl_driver_load_programs (self, error))
{
g_object_unref (self);
return NULL;
}
- self->glyphs = gsk_ngl_glyph_library_new (self);
- self->icons = gsk_ngl_icon_library_new (self);
- self->shadows = gsk_ngl_shadow_library_new (self);
+ self->glyphs = gsk_gl_glyph_library_new (self);
+ self->icons = gsk_gl_icon_library_new (self);
+ self->shadows = gsk_gl_shadow_library_new (self);
- gdk_profiler_end_mark (before, "create GskNglDriver", NULL);
+ gdk_profiler_end_mark (before, "create GskGLDriver", NULL);
return g_steal_pointer (&self);
}
/**
- * gsk_ngl_driver_for_display:
+ * gsk_gl_driver_for_display:
* @display: A #GdkDisplay that is known to support GL
* @debug_shaders: if debug information for shaders should be displayed
* @error: location for error information
@@ -471,21 +471,21 @@ gsk_ngl_driver_new (GskNglCommandQueue *command_queue,
* Retrieves a driver for a shared display. Generally this is shared across all GL
* contexts for a display so that fewer programs are necessary for driving output.
*
- * Returns: (transfer full): a `GskNglDriver` if successful; otherwise %NULL and
+ * Returns: (transfer full): a `GskGLDriver` if successful; otherwise %NULL and
* @error is set.
*/
-GskNglDriver *
-gsk_ngl_driver_for_display (GdkDisplay *display,
- gboolean debug_shaders,
- GError **error)
+GskGLDriver *
+gsk_gl_driver_for_display (GdkDisplay *display,
+ gboolean debug_shaders,
+ GError **error)
{
GdkGLContext *context;
- GskNglCommandQueue *command_queue = NULL;
- GskNglDriver *driver;
+ GskGLCommandQueue *command_queue = NULL;
+ GskGLDriver *driver;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
- if ((driver = g_object_get_data (G_OBJECT (display), "GSK_NGL_DRIVER")))
+ if ((driver = g_object_get_data (G_OBJECT (display), "GSK_GL_DRIVER")))
return g_object_ref (driver);
context = gdk_display_get_gl_context (display);
@@ -499,13 +499,13 @@ gsk_ngl_driver_for_display (GdkDisplay *display,
* shared context, all other contexts sharing with it will have access
* to those programs.
*/
- command_queue = gsk_ngl_command_queue_new (context, NULL);
+ command_queue = gsk_gl_command_queue_new (context, NULL);
- if (!(driver = gsk_ngl_driver_new (command_queue, debug_shaders, error)))
+ if (!(driver = gsk_gl_driver_new (command_queue, debug_shaders, error)))
goto failure;
g_object_set_data_full (G_OBJECT (display),
- "GSK_NGL_DRIVER",
+ "GSK_GL_DRIVER",
g_object_ref (driver),
g_object_unref);
@@ -516,23 +516,23 @@ failure:
}
static GPtrArray *
-gsk_ngl_driver_compact_atlases (GskNglDriver *self)
+gsk_gl_driver_compact_atlases (GskGLDriver *self)
{
GPtrArray *removed = NULL;
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
for (guint i = self->atlases->len; i > 0; i--)
{
- GskNglTextureAtlas *atlas = g_ptr_array_index (self->atlases, i - 1);
+ GskGLTextureAtlas *atlas = g_ptr_array_index (self->atlases, i - 1);
- if (gsk_ngl_texture_atlas_get_unused_ratio (atlas) > MAX_OLD_RATIO)
+ if (gsk_gl_texture_atlas_get_unused_ratio (atlas) > MAX_OLD_RATIO)
{
GSK_NOTE (GLYPH_CACHE,
g_message ("Dropping atlas %d (%g.2%% old)", i,
- 100.0 * gsk_ngl_texture_atlas_get_unused_ratio (atlas)));
+ 100.0 * gsk_gl_texture_atlas_get_unused_ratio (atlas)));
if (removed == NULL)
- removed = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_ngl_texture_atlas_free);
+ removed = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_gl_texture_atlas_free);
g_ptr_array_add (removed, g_ptr_array_steal_index (self->atlases, i - 1));
}
}
@@ -547,9 +547,9 @@ gsk_ngl_driver_compact_atlases (GskNglDriver *self)
}
/**
- * gsk_ngl_driver_begin_frame:
- * @self: a `GskNglDriver`
- * @command_queue: A `GskNglCommandQueue` from the renderer
+ * gsk_gl_driver_begin_frame:
+ * @self: a `GskGLDriver`
+ * @command_queue: A `GskGLCommandQueue` from the renderer
*
* Begin a new frame.
*
@@ -558,14 +558,14 @@ gsk_ngl_driver_compact_atlases (GskNglDriver *self)
* target context to be drawn into (the context of the renderer's surface).
*/
void
-gsk_ngl_driver_begin_frame (GskNglDriver *self,
- GskNglCommandQueue *command_queue)
+gsk_gl_driver_begin_frame (GskGLDriver *self,
+ GskGLCommandQueue *command_queue)
{
gint64 last_frame_id;
GPtrArray *removed;
- g_return_if_fail (GSK_IS_NGL_DRIVER (self));
- g_return_if_fail (GSK_IS_NGL_COMMAND_QUEUE (command_queue));
+ g_return_if_fail (GSK_IS_GL_DRIVER (self));
+ g_return_if_fail (GSK_IS_GL_COMMAND_QUEUE (command_queue));
g_return_if_fail (self->in_frame == FALSE);
last_frame_id = self->current_frame_id;
@@ -575,56 +575,56 @@ gsk_ngl_driver_begin_frame (GskNglDriver *self,
g_set_object (&self->command_queue, command_queue);
- gsk_ngl_command_queue_begin_frame (self->command_queue);
+ gsk_gl_command_queue_begin_frame (self->command_queue);
/* Compact atlases with too many freed pixels */
- removed = gsk_ngl_driver_compact_atlases (self);
+ removed = gsk_gl_driver_compact_atlases (self);
/* Mark unused pixel regions of the atlases */
- gsk_ngl_texture_library_begin_frame (GSK_NGL_TEXTURE_LIBRARY (self->icons),
+ gsk_gl_texture_library_begin_frame (GSK_GL_TEXTURE_LIBRARY (self->icons),
self->current_frame_id,
removed);
- gsk_ngl_texture_library_begin_frame (GSK_NGL_TEXTURE_LIBRARY (self->glyphs),
+ gsk_gl_texture_library_begin_frame (GSK_GL_TEXTURE_LIBRARY (self->glyphs),
self->current_frame_id,
removed);
/* Cleanup old shadows */
- gsk_ngl_shadow_library_begin_frame (self->shadows);
+ gsk_gl_shadow_library_begin_frame (self->shadows);
/* Remove all textures that are from a previous frame or are no
* longer used by linked GdkTexture. We do this at the beginning
* of the following frame instead of the end so that we reduce chances
* we block on any resources while delivering our frames.
*/
- gsk_ngl_driver_collect_unused_textures (self, last_frame_id - 1);
+ gsk_gl_driver_collect_unused_textures (self, last_frame_id - 1);
/* Now free atlas textures */
g_clear_pointer (&removed, g_ptr_array_unref);
}
/**
- * gsk_ngl_driver_end_frame:
- * @self: a `GskNglDriver`
+ * gsk_gl_driver_end_frame:
+ * @self: a `GskGLDriver`
*
* Clean up resources from drawing the current frame.
*
* Temporary resources used while drawing will be released.
*/
void
-gsk_ngl_driver_end_frame (GskNglDriver *self)
+gsk_gl_driver_end_frame (GskGLDriver *self)
{
- g_return_if_fail (GSK_IS_NGL_DRIVER (self));
+ g_return_if_fail (GSK_IS_GL_DRIVER (self));
g_return_if_fail (self->in_frame == TRUE);
- gsk_ngl_command_queue_make_current (self->command_queue);
- gsk_ngl_command_queue_end_frame (self->command_queue);
+ gsk_gl_command_queue_make_current (self->command_queue);
+ gsk_gl_command_queue_end_frame (self->command_queue);
self->in_frame = FALSE;
}
/**
- * gsk_ngl_driver_after_frame:
- * @self: a `GskNglDriver`
+ * gsk_gl_driver_after_frame:
+ * @self: a `GskGLDriver`
*
* This function does post-frame cleanup operations.
*
@@ -632,9 +632,9 @@ gsk_ngl_driver_end_frame (GskNglDriver *self)
* after the frame has swapped buffers.
*/
void
-gsk_ngl_driver_after_frame (GskNglDriver *self)
+gsk_gl_driver_after_frame (GskGLDriver *self)
{
- g_return_if_fail (GSK_IS_NGL_DRIVER (self));
+ g_return_if_fail (GSK_IS_GL_DRIVER (self));
g_return_if_fail (self->in_frame == FALSE);
/* Release any render targets (possibly adding them to
@@ -643,11 +643,11 @@ gsk_ngl_driver_after_frame (GskNglDriver *self)
*/
while (self->render_targets->len > 0)
{
- GskNglRenderTarget *render_target = g_ptr_array_index (self->render_targets, self->render_targets->len
- 1);
+ GskGLRenderTarget *render_target = g_ptr_array_index (self->render_targets, self->render_targets->len
- 1);
- gsk_ngl_driver_autorelease_framebuffer (self, render_target->framebuffer_id);
- gsk_ngl_driver_autorelease_texture (self, render_target->texture_id);
- g_slice_free (GskNglRenderTarget, render_target);
+ gsk_gl_driver_autorelease_framebuffer (self, render_target->framebuffer_id);
+ gsk_gl_driver_autorelease_texture (self, render_target->texture_id);
+ g_slice_free (GskGLRenderTarget, render_target);
self->render_targets->len--;
}
@@ -676,36 +676,36 @@ gsk_ngl_driver_after_frame (GskNglDriver *self)
}
GdkGLContext *
-gsk_ngl_driver_get_context (GskNglDriver *self)
+gsk_gl_driver_get_context (GskGLDriver *self)
{
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), NULL);
- g_return_val_if_fail (GSK_IS_NGL_COMMAND_QUEUE (self->command_queue), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), NULL);
+ g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self->command_queue), NULL);
- return gsk_ngl_command_queue_get_context (self->command_queue);
+ return gsk_gl_command_queue_get_context (self->command_queue);
}
/**
- * gsk_ngl_driver_cache_texture:
- * @self: a `GskNglDriver`
+ * gsk_gl_driver_cache_texture:
+ * @self: a `GskGLDriver`
* @key: the key for the texture
* @texture_id: the id of the texture to be cached
*
* Inserts @texture_id into the texture cache using @key.
*
* Textures can be looked up by @key after calling this function using
- * gsk_ngl_driver_lookup_texture().
+ * gsk_gl_driver_lookup_texture().
*
* Textures that have not been used within a number of frames will be
* purged from the texture cache automatically.
*/
void
-gsk_ngl_driver_cache_texture (GskNglDriver *self,
- const GskTextureKey *key,
- guint texture_id)
+gsk_gl_driver_cache_texture (GskGLDriver *self,
+ const GskTextureKey *key,
+ guint texture_id)
{
GskTextureKey *k;
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
g_assert (key != NULL);
g_assert (texture_id > 0);
g_assert (g_hash_table_contains (self->textures, GUINT_TO_POINTER (texture_id)));
@@ -717,7 +717,7 @@ gsk_ngl_driver_cache_texture (GskNglDriver *self,
}
/**
- * gsk_ngl_driver_load_texture:
+ * gsk_gl_driver_load_texture:
* @self: a `GdkTexture`
* @texture: a `GdkTexture`
* @min_filter: GL_NEAREST or GL_LINEAR
@@ -740,22 +740,22 @@ gsk_ngl_driver_cache_texture (GskNglDriver *self,
* Returns: a texture identifier
*/
guint
-gsk_ngl_driver_load_texture (GskNglDriver *self,
- GdkTexture *texture,
- int min_filter,
- int mag_filter)
+gsk_gl_driver_load_texture (GskGLDriver *self,
+ GdkTexture *texture,
+ int min_filter,
+ int mag_filter)
{
GdkGLContext *context;
GdkTexture *downloaded_texture;
- GskNglTexture *t;
+ GskGLTexture *t;
guint texture_id;
int height;
int width;
int format;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), 0);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), 0);
g_return_val_if_fail (GDK_IS_TEXTURE (texture), 0);
- g_return_val_if_fail (GSK_IS_NGL_COMMAND_QUEUE (self->command_queue), 0);
+ g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self->command_queue), 0);
context = self->command_queue->context;
@@ -793,7 +793,7 @@ gsk_ngl_driver_load_texture (GskNglDriver *self,
width = gdk_texture_get_width (texture);
height = gdk_texture_get_height (texture);
- texture_id = gsk_ngl_command_queue_upload_texture (self->command_queue,
+ texture_id = gsk_gl_command_queue_upload_texture (self->command_queue,
downloaded_texture,
0,
0,
@@ -802,13 +802,13 @@ gsk_ngl_driver_load_texture (GskNglDriver *self,
min_filter,
mag_filter);
- t = gsk_ngl_texture_new (texture_id,
+ t = gsk_gl_texture_new (texture_id,
width, height, format, min_filter, mag_filter,
self->current_frame_id);
g_hash_table_insert (self->textures, GUINT_TO_POINTER (texture_id), t);
- if (gdk_texture_set_render_data (texture, self, t, gsk_ngl_texture_destroyed))
+ if (gdk_texture_set_render_data (texture, self, t, gsk_gl_texture_destroyed))
t->user = texture;
gdk_gl_context_label_object_printf (context, GL_TEXTURE, t->texture_id,
@@ -820,8 +820,8 @@ gsk_ngl_driver_load_texture (GskNglDriver *self,
}
/**
- * gsk_ngl_driver_create_texture:
- * @self: a `GskNglDriver`
+ * gsk_gl_driver_create_texture:
+ * @self: a `GskGLDriver`
* @width: the width of the texture
* @height: the height of the texture
* @format: format for the texture
@@ -834,30 +834,30 @@ gsk_ngl_driver_load_texture (GskNglDriver *self,
*
* Typical examples for @format are GK_RGBA8, GL_RGBA16F or GL_RGBA32F.
*
- * Use gsk_ngl_driver_release_texture() to release this texture back into
+ * Use gsk_gl_driver_release_texture() to release this texture back into
* the pool so it may be reused later in the pipeline.
*
- * Returns: a `GskNglTexture` which can be returned to the pool with
- * gsk_ngl_driver_release_texture().
+ * Returns: a `GskGLTexture` which can be returned to the pool with
+ * gsk_gl_driver_release_texture().
*/
-GskNglTexture *
-gsk_ngl_driver_create_texture (GskNglDriver *self,
- float width,
- float height,
- int format,
- int min_filter,
- int mag_filter)
+GskGLTexture *
+gsk_gl_driver_create_texture (GskGLDriver *self,
+ float width,
+ float height,
+ int format,
+ int min_filter,
+ int mag_filter)
{
- GskNglTexture *texture;
+ GskGLTexture *texture;
guint texture_id;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), NULL);
- texture_id = gsk_ngl_command_queue_create_texture (self->command_queue,
+ texture_id = gsk_gl_command_queue_create_texture (self->command_queue,
width, height,
format,
min_filter, mag_filter);
- texture = gsk_ngl_texture_new (texture_id,
+ texture = gsk_gl_texture_new (texture_id,
width, height,
format,
min_filter, mag_filter,
@@ -870,9 +870,9 @@ gsk_ngl_driver_create_texture (GskNglDriver *self,
}
/**
- * gsk_ngl_driver_release_texture:
- * @self: a `GskNglDriver`
- * @texture: a `GskNglTexture`
+ * gsk_gl_driver_release_texture:
+ * @self: a `GskGLDriver`
+ * @texture: a `GskGLTexture`
*
* Releases @texture back into the pool so that it can be used later
* in the command stream by future batches. This helps reduce VRAM
@@ -882,28 +882,28 @@ gsk_ngl_driver_create_texture (GskNglDriver *self,
* to free additional VRAM back to the system.
*/
void
-gsk_ngl_driver_release_texture (GskNglDriver *self,
- GskNglTexture *texture)
+gsk_gl_driver_release_texture (GskGLDriver *self,
+ GskGLTexture *texture)
{
guint texture_id;
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
g_assert (texture != NULL);
texture_id = texture->texture_id;
texture->texture_id = 0;
- gsk_ngl_texture_free (texture);
+ gsk_gl_texture_free (texture);
if (texture_id > 0)
remove_texture_key_for_id (self, texture_id);
g_hash_table_steal (self->textures, GUINT_TO_POINTER (texture_id));
- gsk_ngl_driver_autorelease_texture (self, texture_id);
+ gsk_gl_driver_autorelease_texture (self, texture_id);
}
/**
- * gsk_ngl_driver_create_render_target:
- * @self: a `GskNglDriver`
+ * gsk_gl_driver_create_render_target:
+ * @self: a `GskGLDriver`
* @width: the width for the render target
* @height: the height for the render target
* @format: the format to use
@@ -917,7 +917,7 @@ gsk_ngl_driver_release_texture (GskNglDriver *self,
*
* Typical examples for @format are GK_RGBA8, GL_RGBA16F or GL_RGBA32F.
*
- * Use gsk_ngl_driver_release_render_target() when you are finished with
+ * Use gsk_gl_driver_release_render_target() when you are finished with
* the render target to release it. You may steal the texture from the
* render target when releasing it.
*
@@ -925,19 +925,19 @@ gsk_ngl_driver_release_texture (GskNglDriver *self,
* @out_texture_id are undefined.
*/
gboolean
-gsk_ngl_driver_create_render_target (GskNglDriver *self,
- int width,
- int height,
- int format,
- int min_filter,
- int mag_filter,
- GskNglRenderTarget **out_render_target)
+gsk_gl_driver_create_render_target (GskGLDriver *self,
+ int width,
+ int height,
+ int format,
+ int min_filter,
+ int mag_filter,
+ GskGLRenderTarget **out_render_target)
{
guint framebuffer_id;
guint texture_id;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), FALSE);
- g_return_val_if_fail (GSK_IS_NGL_COMMAND_QUEUE (self->command_queue), FALSE);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), FALSE);
+ g_return_val_if_fail (GSK_IS_GL_COMMAND_QUEUE (self->command_queue), FALSE);
g_return_val_if_fail (out_render_target != NULL, FALSE);
#if 0
@@ -945,7 +945,7 @@ gsk_ngl_driver_create_render_target (GskNglDriver *self,
{
for (guint i = self->render_targets->len; i > 0; i--)
{
- GskNglRenderTarget *render_target = g_ptr_array_index (self->render_targets, i-1);
+ GskGLRenderTarget *render_target = g_ptr_array_index (self->render_targets, i-1);
if (render_target->width == width &&
render_target->height == height &&
@@ -959,15 +959,15 @@ gsk_ngl_driver_create_render_target (GskNglDriver *self,
}
#endif
- if (gsk_ngl_command_queue_create_render_target (self->command_queue,
+ if (gsk_gl_command_queue_create_render_target (self->command_queue,
width, height,
format,
min_filter, mag_filter,
&framebuffer_id, &texture_id))
{
- GskNglRenderTarget *render_target;
+ GskGLRenderTarget *render_target;
- render_target = g_slice_new0 (GskNglRenderTarget);
+ render_target = g_slice_new0 (GskGLRenderTarget);
render_target->min_filter = min_filter;
render_target->mag_filter = mag_filter;
render_target->format = format;
@@ -987,10 +987,10 @@ gsk_ngl_driver_create_render_target (GskNglDriver *self,
}
/**
- * gsk_ngl_driver_release_render_target:
- * @self: a `GskNglDriver`
- * @render_target: a `GskNglRenderTarget` created with
- * gsk_ngl_driver_create_render_target().
+ * gsk_gl_driver_release_render_target:
+ * @self: a `GskGLDriver`
+ * @render_target: a `GskGLRenderTarget` created with
+ * gsk_gl_driver_create_render_target().
* @release_texture: if the texture should also be released
*
* Releases a render target that was previously created. An attempt may
@@ -1007,13 +1007,13 @@ gsk_ngl_driver_create_render_target (GskNglDriver *self,
* Returns: a texture id if @release_texture is %FALSE, otherwise zero.
*/
guint
-gsk_ngl_driver_release_render_target (GskNglDriver *self,
- GskNglRenderTarget *render_target,
- gboolean release_texture)
+gsk_gl_driver_release_render_target (GskGLDriver *self,
+ GskGLRenderTarget *render_target,
+ gboolean release_texture)
{
guint texture_id;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), 0);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), 0);
g_return_val_if_fail (render_target != NULL, 0);
if (release_texture)
@@ -1023,11 +1023,11 @@ gsk_ngl_driver_release_render_target (GskNglDriver *self,
}
else
{
- GskNglTexture *texture;
+ GskGLTexture *texture;
texture_id = render_target->texture_id;
- texture = gsk_ngl_texture_new (render_target->texture_id,
+ texture = gsk_gl_texture_new (render_target->texture_id,
render_target->width,
render_target->height,
render_target->format,
@@ -1038,8 +1038,8 @@ gsk_ngl_driver_release_render_target (GskNglDriver *self,
GUINT_TO_POINTER (texture_id),
g_steal_pointer (&texture));
- gsk_ngl_driver_autorelease_framebuffer (self, render_target->framebuffer_id);
- g_slice_free (GskNglRenderTarget, render_target);
+ gsk_gl_driver_autorelease_framebuffer (self, render_target->framebuffer_id);
+ g_slice_free (GskGLRenderTarget, render_target);
}
@@ -1047,8 +1047,8 @@ gsk_ngl_driver_release_render_target (GskNglDriver *self,
}
/**
- * gsk_ngl_driver_lookup_shader:
- * @self: a `GskNglDriver`
+ * gsk_gl_driver_lookup_shader:
+ * @self: a `GskGLDriver`
* @shader: the shader to lookup or load
* @error: a location for a `GError`
*
@@ -1058,12 +1058,12 @@ gsk_ngl_driver_release_render_target (GskNglDriver *self,
*
* Returns: (nullable) (transfer none): a `GskGLShader`
*/
-GskNglProgram *
-gsk_ngl_driver_lookup_shader (GskNglDriver *self,
- GskGLShader *shader,
- GError **error)
+GskGLProgram *
+gsk_gl_driver_lookup_shader (GskGLDriver *self,
+ GskGLShader *shader,
+ GError **error)
{
- GskNglProgram *program;
+ GskGLProgram *program;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (shader != NULL, NULL);
@@ -1073,87 +1073,87 @@ gsk_ngl_driver_lookup_shader (GskNglDriver *self,
if (program == NULL)
{
const GskGLUniform *uniforms;
- GskNglCompiler *compiler;
+ GskGLCompiler *compiler;
GBytes *suffix;
int n_required_textures;
int n_uniforms;
uniforms = gsk_gl_shader_get_uniforms (shader, &n_uniforms);
- if (n_uniforms > GSK_NGL_PROGRAM_MAX_CUSTOM_ARGS)
+ if (n_uniforms > GSK_GL_PROGRAM_MAX_CUSTOM_ARGS)
{
g_set_error (error,
GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
"Tried to use %d uniforms, while only %d is supported",
n_uniforms,
- GSK_NGL_PROGRAM_MAX_CUSTOM_ARGS);
+ GSK_GL_PROGRAM_MAX_CUSTOM_ARGS);
return NULL;
}
n_required_textures = gsk_gl_shader_get_n_textures (shader);
- if (n_required_textures > GSK_NGL_PROGRAM_MAX_CUSTOM_TEXTURES)
+ if (n_required_textures > GSK_GL_PROGRAM_MAX_CUSTOM_TEXTURES)
{
g_set_error (error,
GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
"Tried to use %d textures, while only %d is supported",
n_required_textures,
- GSK_NGL_PROGRAM_MAX_CUSTOM_TEXTURES);
+ GSK_GL_PROGRAM_MAX_CUSTOM_TEXTURES);
return NULL;
}
- compiler = gsk_ngl_compiler_new (self, FALSE);
+ compiler = gsk_gl_compiler_new (self, FALSE);
suffix = gsk_gl_shader_get_source (shader);
- gsk_ngl_compiler_set_preamble_from_resource (compiler,
- GSK_NGL_COMPILER_ALL,
- "/org/gtk/libgsk/ngl/preamble.glsl");
- gsk_ngl_compiler_set_preamble_from_resource (compiler,
- GSK_NGL_COMPILER_VERTEX,
- "/org/gtk/libgsk/ngl/preamble.vs.glsl");
- gsk_ngl_compiler_set_preamble_from_resource (compiler,
- GSK_NGL_COMPILER_FRAGMENT,
- "/org/gtk/libgsk/ngl/preamble.fs.glsl");
- gsk_ngl_compiler_set_source_from_resource (compiler,
- GSK_NGL_COMPILER_ALL,
- "/org/gtk/libgsk/ngl/custom.glsl");
- gsk_ngl_compiler_set_suffix (compiler, GSK_NGL_COMPILER_FRAGMENT, suffix);
+ gsk_gl_compiler_set_preamble_from_resource (compiler,
+ GSK_GL_COMPILER_ALL,
+ "/org/gtk/libgsk/ngl/preamble.glsl");
+ gsk_gl_compiler_set_preamble_from_resource (compiler,
+ GSK_GL_COMPILER_VERTEX,
+ "/org/gtk/libgsk/ngl/preamble.vs.glsl");
+ gsk_gl_compiler_set_preamble_from_resource (compiler,
+ GSK_GL_COMPILER_FRAGMENT,
+ "/org/gtk/libgsk/ngl/preamble.fs.glsl");
+ gsk_gl_compiler_set_source_from_resource (compiler,
+ GSK_GL_COMPILER_ALL,
+ "/org/gtk/libgsk/ngl/custom.glsl");
+ gsk_gl_compiler_set_suffix (compiler, GSK_GL_COMPILER_FRAGMENT, suffix);
/* Setup attributes that are provided via VBO */
- gsk_ngl_compiler_bind_attribute (compiler, "aPosition", 0);
- gsk_ngl_compiler_bind_attribute (compiler, "aUv", 1);
- gsk_ngl_compiler_bind_attribute (compiler, "aColor", 2);
- gsk_ngl_compiler_bind_attribute (compiler, "aColor2", 3);
+ gsk_gl_compiler_bind_attribute (compiler, "aPosition", 0);
+ gsk_gl_compiler_bind_attribute (compiler, "aUv", 1);
+ gsk_gl_compiler_bind_attribute (compiler, "aColor", 2);
+ gsk_gl_compiler_bind_attribute (compiler, "aColor2", 3);
- if ((program = gsk_ngl_compiler_compile (compiler, NULL, "", error)))
+ if ((program = gsk_gl_compiler_compile (compiler, NULL, "", error)))
{
gboolean have_alpha;
- gsk_ngl_program_add_uniform (program, "u_source", UNIFORM_SHARED_SOURCE);
- gsk_ngl_program_add_uniform (program, "u_clip_rect", UNIFORM_SHARED_CLIP_RECT);
- gsk_ngl_program_add_uniform (program, "u_viewport", UNIFORM_SHARED_VIEWPORT);
- gsk_ngl_program_add_uniform (program, "u_projection", UNIFORM_SHARED_PROJECTION);
- gsk_ngl_program_add_uniform (program, "u_modelview", UNIFORM_SHARED_MODELVIEW);
- have_alpha = gsk_ngl_program_add_uniform (program, "u_alpha", UNIFORM_SHARED_ALPHA);
+ gsk_gl_program_add_uniform (program, "u_source", UNIFORM_SHARED_SOURCE);
+ gsk_gl_program_add_uniform (program, "u_clip_rect", UNIFORM_SHARED_CLIP_RECT);
+ gsk_gl_program_add_uniform (program, "u_viewport", UNIFORM_SHARED_VIEWPORT);
+ gsk_gl_program_add_uniform (program, "u_projection", UNIFORM_SHARED_PROJECTION);
+ gsk_gl_program_add_uniform (program, "u_modelview", UNIFORM_SHARED_MODELVIEW);
+ have_alpha = gsk_gl_program_add_uniform (program, "u_alpha", UNIFORM_SHARED_ALPHA);
- gsk_ngl_program_add_uniform (program, "u_size", UNIFORM_CUSTOM_SIZE);
- gsk_ngl_program_add_uniform (program, "u_texture1", UNIFORM_CUSTOM_TEXTURE1);
- gsk_ngl_program_add_uniform (program, "u_texture2", UNIFORM_CUSTOM_TEXTURE2);
- gsk_ngl_program_add_uniform (program, "u_texture3", UNIFORM_CUSTOM_TEXTURE3);
- gsk_ngl_program_add_uniform (program, "u_texture4", UNIFORM_CUSTOM_TEXTURE4);
+ gsk_gl_program_add_uniform (program, "u_size", UNIFORM_CUSTOM_SIZE);
+ gsk_gl_program_add_uniform (program, "u_texture1", UNIFORM_CUSTOM_TEXTURE1);
+ gsk_gl_program_add_uniform (program, "u_texture2", UNIFORM_CUSTOM_TEXTURE2);
+ gsk_gl_program_add_uniform (program, "u_texture3", UNIFORM_CUSTOM_TEXTURE3);
+ gsk_gl_program_add_uniform (program, "u_texture4", UNIFORM_CUSTOM_TEXTURE4);
/* Custom arguments (max is 8) */
for (guint i = 0; i < n_uniforms; i++)
- gsk_ngl_program_add_uniform (program, uniforms[i].name, UNIFORM_CUSTOM_ARG0+i);
+ gsk_gl_program_add_uniform (program, uniforms[i].name, UNIFORM_CUSTOM_ARG0+i);
- gsk_ngl_program_uniforms_added (program, TRUE);
+ gsk_gl_program_uniforms_added (program, TRUE);
if (have_alpha)
- gsk_ngl_program_set_uniform1f (program, UNIFORM_SHARED_ALPHA, 0, 1.0f);
+ gsk_gl_program_set_uniform1f (program, UNIFORM_SHARED_ALPHA, 0, 1.0f);
g_hash_table_insert (self->shader_cache, shader, program);
g_object_weak_ref (G_OBJECT (shader),
- gsk_ngl_driver_shader_weak_cb,
+ gsk_gl_driver_shader_weak_cb,
self);
}
@@ -1165,13 +1165,13 @@ gsk_ngl_driver_lookup_shader (GskNglDriver *self,
#ifdef G_ENABLE_DEBUG
static void
-write_atlas_to_png (GskNglDriver *driver,
- GskNglTextureAtlas *atlas,
- const char *filename)
+write_atlas_to_png (GskGLDriver *driver,
+ GskGLTextureAtlas *atlas,
+ const char *filename)
{
GdkTexture *texture;
- texture = gdk_gl_texture_new (gsk_ngl_driver_get_context (driver),
+ texture = gdk_gl_texture_new (gsk_gl_driver_get_context (driver),
atlas->texture_id,
atlas->width, atlas->height,
NULL, NULL);
@@ -1180,17 +1180,17 @@ write_atlas_to_png (GskNglDriver *driver,
}
void
-gsk_ngl_driver_save_atlases_to_png (GskNglDriver *self,
- const char *directory)
+gsk_gl_driver_save_atlases_to_png (GskGLDriver *self,
+ const char *directory)
{
- g_return_if_fail (GSK_IS_NGL_DRIVER (self));
+ g_return_if_fail (GSK_IS_GL_DRIVER (self));
if (directory == NULL)
directory = ".";
for (guint i = 0; i < self->atlases->len; i++)
{
- GskNglTextureAtlas *atlas = g_ptr_array_index (self->atlases, i);
+ GskGLTextureAtlas *atlas = g_ptr_array_index (self->atlases, i);
char *filename = g_strdup_printf ("%s%sframe-%d-atlas-%d.png",
directory,
G_DIR_SEPARATOR_S,
@@ -1202,25 +1202,25 @@ gsk_ngl_driver_save_atlases_to_png (GskNglDriver *self,
}
#endif
-GskNglCommandQueue *
-gsk_ngl_driver_create_command_queue (GskNglDriver *self,
+GskGLCommandQueue *
+gsk_gl_driver_create_command_queue (GskGLDriver *self,
GdkGLContext *context)
{
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), NULL);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
- return gsk_ngl_command_queue_new (context, self->shared_command_queue->uniforms);
+ return gsk_gl_command_queue_new (context, self->shared_command_queue->uniforms);
}
void
-gsk_ngl_driver_add_texture_slices (GskNglDriver *self,
- GdkTexture *texture,
- GskNglTextureSlice **out_slices,
- guint *out_n_slices)
+gsk_gl_driver_add_texture_slices (GskGLDriver *self,
+ GdkTexture *texture,
+ GskGLTextureSlice **out_slices,
+ guint *out_n_slices)
{
int max_texture_size;
- GskNglTextureSlice *slices;
- GskNglTexture *t;
+ GskGLTextureSlice *slices;
+ GskGLTexture *t;
guint n_slices;
guint cols;
guint rows;
@@ -1228,7 +1228,7 @@ gsk_ngl_driver_add_texture_slices (GskNglDriver *self,
int tex_height;
int x = 0, y = 0;
- g_assert (GSK_IS_NGL_DRIVER (self));
+ g_assert (GSK_IS_GL_DRIVER (self));
g_assert (GDK_IS_TEXTURE (texture));
g_assert (out_slices != NULL);
g_assert (out_n_slices != NULL);
@@ -1249,7 +1249,7 @@ gsk_ngl_driver_add_texture_slices (GskNglDriver *self,
}
n_slices = cols * rows;
- slices = g_new0 (GskNglTextureSlice, n_slices);
+ slices = g_new0 (GskGLTextureSlice, n_slices);
for (guint col = 0; col < cols; col ++)
{
@@ -1261,11 +1261,11 @@ gsk_ngl_driver_add_texture_slices (GskNglDriver *self,
int slice_index = (col * rows) + row;
guint texture_id;
- texture_id = gsk_ngl_command_queue_upload_texture (self->command_queue,
- texture,
- x, y,
- slice_width, slice_height,
- GL_NEAREST, GL_NEAREST);
+ texture_id = gsk_gl_command_queue_upload_texture (self->command_queue,
+ texture,
+ x, y,
+ slice_width, slice_height,
+ GL_NEAREST, GL_NEAREST);
slices[slice_index].rect.x = x;
slices[slice_index].rect.y = y;
@@ -1281,29 +1281,29 @@ gsk_ngl_driver_add_texture_slices (GskNglDriver *self,
}
/* Allocate one Texture for the entire thing. */
- t = gsk_ngl_texture_new (0,
- tex_width, tex_height,
- GL_RGBA8,
- GL_NEAREST, GL_NEAREST,
- self->current_frame_id);
-
- /* Use gsk_ngl_texture_free() as destroy notify here since we are
- * not inserting this GskNglTexture into self->textures!
+ t = gsk_gl_texture_new (0,
+ tex_width, tex_height,
+ GL_RGBA8,
+ GL_NEAREST, GL_NEAREST,
+ self->current_frame_id);
+
+ /* Use gsk_gl_texture_free() as destroy notify here since we are
+ * not inserting this GskGLTexture into self->textures!
*/
gdk_texture_set_render_data (texture, self, t,
- (GDestroyNotify)gsk_ngl_texture_free);
+ (GDestroyNotify)gsk_gl_texture_free);
t->slices = *out_slices = slices;
t->n_slices = *out_n_slices = n_slices;
}
-GskNglTexture *
-gsk_ngl_driver_mark_texture_permanent (GskNglDriver *self,
- guint texture_id)
+GskGLTexture *
+gsk_gl_driver_mark_texture_permanent (GskGLDriver *self,
+ guint texture_id)
{
- GskNglTexture *t;
+ GskGLTexture *t;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), NULL);
g_return_val_if_fail (texture_id > 0, NULL);
if ((t = g_hash_table_lookup (self->textures, GUINT_TO_POINTER (texture_id))))
@@ -1313,30 +1313,30 @@ gsk_ngl_driver_mark_texture_permanent (GskNglDriver *self,
}
void
-gsk_ngl_driver_release_texture_by_id (GskNglDriver *self,
- guint texture_id)
+gsk_gl_driver_release_texture_by_id (GskGLDriver *self,
+ guint texture_id)
{
- GskNglTexture *texture;
+ GskGLTexture *texture;
- g_return_if_fail (GSK_IS_NGL_DRIVER (self));
+ g_return_if_fail (GSK_IS_GL_DRIVER (self));
g_return_if_fail (texture_id > 0);
remove_texture_key_for_id (self, texture_id);
if ((texture = g_hash_table_lookup (self->textures, GUINT_TO_POINTER (texture_id))))
- gsk_ngl_driver_release_texture (self, texture);
+ gsk_gl_driver_release_texture (self, texture);
}
-typedef struct _GskNglTextureState
+typedef struct _GskGLTextureState
{
GdkGLContext *context;
GLuint texture_id;
-} GskNglTextureState;
+} GskGLTextureState;
static void
create_texture_from_texture_destroy (gpointer data)
{
- GskNglTextureState *state = data;
+ GskGLTextureState *state = data;
g_assert (state != NULL);
g_assert (GDK_IS_GL_CONTEXT (state->context));
@@ -1344,18 +1344,18 @@ create_texture_from_texture_destroy (gpointer data)
gdk_gl_context_make_current (state->context);
glDeleteTextures (1, &state->texture_id);
g_clear_object (&state->context);
- g_slice_free (GskNglTextureState, state);
+ g_slice_free (GskGLTextureState, state);
}
GdkTexture *
-gsk_ngl_driver_create_gdk_texture (GskNglDriver *self,
- guint texture_id)
+gsk_gl_driver_create_gdk_texture (GskGLDriver *self,
+ guint texture_id)
{
- GskNglTextureState *state;
- GskNglTexture *texture;
+ GskGLTextureState *state;
+ GskGLTexture *texture;
int width, height;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (self), NULL);
g_return_val_if_fail (self->command_queue != NULL, NULL);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (self->command_queue->context), NULL);
g_return_val_if_fail (texture_id > 0, NULL);
@@ -1365,7 +1365,7 @@ gsk_ngl_driver_create_gdk_texture (GskNglDriver *self,
if (!(texture = g_hash_table_lookup (self->textures, GUINT_TO_POINTER (texture_id))))
g_return_val_if_reached (NULL);
- state = g_slice_new0 (GskNglTextureState);
+ state = g_slice_new0 (GskGLTextureState);
state->texture_id = texture_id;
state->context = g_object_ref (self->command_queue->context);
@@ -1375,7 +1375,7 @@ gsk_ngl_driver_create_gdk_texture (GskNglDriver *self,
height = texture->height;
texture->texture_id = 0;
- gsk_ngl_texture_free (texture);
+ gsk_gl_texture_free (texture);
return gdk_gl_texture_new (self->command_queue->context,
texture_id,
diff --git a/gsk/gl/gskgldriverprivate.h b/gsk/gl/gskgldriverprivate.h
new file mode 100644
index 0000000000..4500962ed8
--- /dev/null
+++ b/gsk/gl/gskgldriverprivate.h
@@ -0,0 +1,251 @@
+/* gskgldriverprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This file is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This file is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_DRIVER_PRIVATE_H__
+#define __GSK_GL_DRIVER_PRIVATE_H__
+
+#include <gdk/gdkgltextureprivate.h>
+
+#include "gskgltypesprivate.h"
+#include "gskgltextureprivate.h"
+
+G_BEGIN_DECLS
+
+enum {
+ UNIFORM_SHARED_ALPHA,
+ UNIFORM_SHARED_SOURCE,
+ UNIFORM_SHARED_CLIP_RECT,
+ UNIFORM_SHARED_VIEWPORT,
+ UNIFORM_SHARED_PROJECTION,
+ UNIFORM_SHARED_MODELVIEW,
+
+ UNIFORM_SHARED_LAST
+};
+
+enum {
+ UNIFORM_CUSTOM_SIZE = UNIFORM_SHARED_LAST,
+ UNIFORM_CUSTOM_TEXTURE1,
+ UNIFORM_CUSTOM_TEXTURE2,
+ UNIFORM_CUSTOM_TEXTURE3,
+ UNIFORM_CUSTOM_TEXTURE4,
+ UNIFORM_CUSTOM_ARG0,
+ UNIFORM_CUSTOM_ARG1,
+ UNIFORM_CUSTOM_ARG2,
+ UNIFORM_CUSTOM_ARG3,
+ UNIFORM_CUSTOM_ARG4,
+ UNIFORM_CUSTOM_ARG5,
+ UNIFORM_CUSTOM_ARG6,
+ UNIFORM_CUSTOM_ARG7,
+
+ UNIFORM_CUSTOM_LAST
+};
+
+typedef struct {
+ gconstpointer pointer;
+ float scale_x;
+ float scale_y;
+ int filter;
+ int pointer_is_child;
+ graphene_rect_t parent_rect; /* Valid when pointer_is_child */
+} GskTextureKey;
+
+#define GSK_GL_NO_UNIFORMS CONCAT_EXPANDED(UNIFORM_INVALID_,__COUNTER__)
+#define CONCAT_EXPANDED(a,b) CONCAT_EXPANDED2(a,b)
+#define CONCAT_EXPANDED2(a,b) a##b
+#define GSK_GL_ADD_UNIFORM(pos, KEY, name) UNIFORM_##KEY = UNIFORM_SHARED_LAST + pos,
+#define GSK_GL_DEFINE_PROGRAM(name, resource, uniforms) enum { uniforms };
+# include "gskglprograms.defs"
+#undef GSK_GL_DEFINE_PROGRAM
+#undef GSK_GL_ADD_UNIFORM
+#undef GSK_GL_NO_UNIFORMS
+#undef CONCAT_EXPANDED
+#undef CONCAT_EXPANDED2
+
+#define GSK_TYPE_GL_DRIVER (gsk_gl_driver_get_type())
+
+G_DECLARE_FINAL_TYPE (GskGLDriver, gsk_gl_driver, GSK, GL_DRIVER, GObject)
+
+struct _GskGLRenderTarget
+{
+ guint framebuffer_id;
+ guint texture_id;
+ int min_filter;
+ int mag_filter;
+ int format;
+ int width;
+ int height;
+};
+
+struct _GskGLDriver
+{
+ GObject parent_instance;
+
+ GskGLCommandQueue *shared_command_queue;
+ GskGLCommandQueue *command_queue;
+
+ GskGLGlyphLibrary *glyphs;
+ GskGLIconLibrary *icons;
+ GskGLShadowLibrary *shadows;
+
+ GArray *texture_pool;
+ GHashTable *textures;
+ GHashTable *key_to_texture_id;
+ GHashTable *texture_id_to_key;
+
+ GPtrArray *atlases;
+
+ GHashTable *shader_cache;
+
+ GArray *autorelease_framebuffers;
+ GPtrArray *render_targets;
+
+#define GSK_GL_NO_UNIFORMS
+#define GSK_GL_ADD_UNIFORM(pos, KEY, name)
+#define GSK_GL_DEFINE_PROGRAM(name, resource, uniforms) \
+ GskGLProgram *name ## _no_clip; \
+ GskGLProgram *name ## _rect_clip; \
+ GskGLProgram *name;
+# include "gskglprograms.defs"
+#undef GSK_GL_NO_UNIFORMS
+#undef GSK_GL_ADD_UNIFORM
+#undef GSK_GL_DEFINE_PROGRAM
+
+ gint64 current_frame_id;
+
+ /* Used to reduce number of comparisons */
+ guint stamps[UNIFORM_SHARED_LAST];
+
+ guint debug : 1;
+ guint in_frame : 1;
+};
+
+GskGLDriver * gsk_gl_driver_for_display (GdkDisplay *display,
+ gboolean debug_shaders,
+ GError **error);
+GskGLCommandQueue * gsk_gl_driver_create_command_queue (GskGLDriver *self,
+ GdkGLContext *context);
+GdkGLContext * gsk_gl_driver_get_context (GskGLDriver *self);
+gboolean gsk_gl_driver_create_render_target (GskGLDriver *self,
+ int width,
+ int height,
+ int format,
+ int min_filter,
+ int mag_filter,
+ GskGLRenderTarget **render_target);
+guint gsk_gl_driver_release_render_target (GskGLDriver *self,
+ GskGLRenderTarget *render_target,
+ gboolean release_texture);
+void gsk_gl_driver_begin_frame (GskGLDriver *self,
+ GskGLCommandQueue *command_queue);
+void gsk_gl_driver_end_frame (GskGLDriver *self);
+void gsk_gl_driver_after_frame (GskGLDriver *self);
+GdkTexture * gsk_gl_driver_create_gdk_texture (GskGLDriver *self,
+ guint texture_id);
+void gsk_gl_driver_cache_texture (GskGLDriver *self,
+ const GskTextureKey *key,
+ guint texture_id);
+guint gsk_gl_driver_load_texture (GskGLDriver *self,
+ GdkTexture *texture,
+ int min_filter,
+ int mag_filter);
+GskGLTexture * gsk_gl_driver_create_texture (GskGLDriver *self,
+ float width,
+ float height,
+ int format,
+ int min_filter,
+ int mag_filter);
+void gsk_gl_driver_release_texture (GskGLDriver *self,
+ GskGLTexture *texture);
+void gsk_gl_driver_release_texture_by_id (GskGLDriver *self,
+ guint texture_id);
+GskGLTexture * gsk_gl_driver_mark_texture_permanent (GskGLDriver *self,
+ guint texture_id);
+void gsk_gl_driver_add_texture_slices (GskGLDriver *self,
+ GdkTexture *texture,
+ GskGLTextureSlice **out_slices,
+ guint *out_n_slices);
+GskGLProgram * gsk_gl_driver_lookup_shader (GskGLDriver *self,
+ GskGLShader *shader,
+ GError **error);
+GskGLTextureAtlas * gsk_gl_driver_create_atlas (GskGLDriver *self);
+
+#ifdef G_ENABLE_DEBUG
+void gsk_gl_driver_save_atlases_to_png (GskGLDriver *self,
+ const char *directory);
+#endif
+
+static inline GskGLTexture *
+gsk_gl_driver_get_texture_by_id (GskGLDriver *self,
+ guint texture_id)
+{
+ return g_hash_table_lookup (self->textures, GUINT_TO_POINTER (texture_id));
+}
+
+/**
+ * gsk_gl_driver_lookup_texture:
+ * @self: a `GskGLDriver`
+ * @key: the key for the texture
+ *
+ * Looks up a texture in the texture cache by @key.
+ *
+ * If the texture could not be found, then zero is returned.
+ *
+ * Returns: a positive integer if the texture was found; otherwise 0.
+ */
+static inline guint
+gsk_gl_driver_lookup_texture (GskGLDriver *self,
+ const GskTextureKey *key)
+{
+ gpointer id;
+
+ if (g_hash_table_lookup_extended (self->key_to_texture_id, key, NULL, &id))
+ {
+ GskGLTexture *texture = g_hash_table_lookup (self->textures, id);
+
+ if (texture != NULL)
+ texture->last_used_in_frame = self->current_frame_id;
+
+ return GPOINTER_TO_UINT (id);
+ }
+
+ return 0;
+}
+
+static inline void
+gsk_gl_driver_slice_texture (GskGLDriver *self,
+ GdkTexture *texture,
+ GskGLTextureSlice **out_slices,
+ guint *out_n_slices)
+{
+ GskGLTexture *t;
+
+ if ((t = gdk_texture_get_render_data (texture, self)))
+ {
+ *out_slices = t->slices;
+ *out_n_slices = t->n_slices;
+ return;
+ }
+
+ gsk_gl_driver_add_texture_slices (self, texture, out_slices, out_n_slices);
+}
+
+G_END_DECLS
+
+#endif /* __GSK_GL_DRIVER_PRIVATE_H__ */
diff --git a/gsk/ngl/gsknglglyphlibrary.c b/gsk/gl/gskglglyphlibrary.c
similarity index 56%
rename from gsk/ngl/gsknglglyphlibrary.c
rename to gsk/gl/gskglglyphlibrary.c
index ede4f19105..fd4518d341 100644
--- a/gsk/ngl/gsknglglyphlibrary.c
+++ b/gsk/gl/gskglglyphlibrary.c
@@ -1,4 +1,4 @@
-/* gsknglglyphlibrary.c
+/* gskglglyphlibrary.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -24,18 +24,18 @@
#include <gdk/gdkmemoryformatprivate.h>
#include <gdk/gdkprofilerprivate.h>
-#include "gsknglcommandqueueprivate.h"
-#include "gskngldriverprivate.h"
-#include "gsknglglyphlibraryprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskgldriverprivate.h"
+#include "gskglglyphlibraryprivate.h"
#define MAX_GLYPH_SIZE 128
-G_DEFINE_TYPE (GskNglGlyphLibrary, gsk_ngl_glyph_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
+G_DEFINE_TYPE (GskGLGlyphLibrary, gsk_gl_glyph_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
-GskNglGlyphLibrary *
-gsk_ngl_glyph_library_new (GskNglDriver *driver)
+GskGLGlyphLibrary *
+gsk_gl_glyph_library_new (GskGLDriver *driver)
{
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), NULL);
return g_object_new (GSK_TYPE_GL_GLYPH_LIBRARY,
"driver", driver,
@@ -43,13 +43,13 @@ gsk_ngl_glyph_library_new (GskNglDriver *driver)
}
static guint
-gsk_ngl_glyph_key_hash (gconstpointer data)
+gsk_gl_glyph_key_hash (gconstpointer data)
{
- const GskNglGlyphKey *key = data;
+ const GskGLGlyphKey *key = data;
/* We do not store the hash within the key because GHashTable will already
* store the hash value for us and so this is called only a single time per
- * cached item. This saves an extra 4 bytes per GskNglGlyphKey which means on
+ * cached item. This saves an extra 4 bytes per GskGLGlyphKey which means on
* 64-bit, we fit nicely within 2 pointers (the smallest allocation size
* for GSlice).
*/
@@ -62,83 +62,83 @@ gsk_ngl_glyph_key_hash (gconstpointer data)
}
static gboolean
-gsk_ngl_glyph_key_equal (gconstpointer v1,
- gconstpointer v2)
+gsk_gl_glyph_key_equal (gconstpointer v1,
+ gconstpointer v2)
{
- return memcmp (v1, v2, sizeof (GskNglGlyphKey)) == 0;
+ return memcmp (v1, v2, sizeof (GskGLGlyphKey)) == 0;
}
static void
-gsk_ngl_glyph_key_free (gpointer data)
+gsk_gl_glyph_key_free (gpointer data)
{
- GskNglGlyphKey *key = data;
+ GskGLGlyphKey *key = data;
g_clear_object (&key->font);
- g_slice_free (GskNglGlyphKey, key);
+ g_slice_free (GskGLGlyphKey, key);
}
static void
-gsk_ngl_glyph_value_free (gpointer data)
+gsk_gl_glyph_value_free (gpointer data)
{
- g_slice_free (GskNglGlyphValue, data);
+ g_slice_free (GskGLGlyphValue, data);
}
static void
-gsk_ngl_glyph_library_begin_frame (GskNglTextureLibrary *library,
- gint64 frame_id,
- GPtrArray *removed_atlases)
+gsk_gl_glyph_library_begin_frame (GskGLTextureLibrary *library,
+ gint64 frame_id,
+ GPtrArray *removed_atlases)
{
- GskNglGlyphLibrary *self = (GskNglGlyphLibrary *)library;
+ GskGLGlyphLibrary *self = (GskGLGlyphLibrary *)library;
memset (self->front, 0, sizeof self->front);
}
static void
-gsk_ngl_glyph_library_finalize (GObject *object)
+gsk_gl_glyph_library_finalize (GObject *object)
{
- GskNglGlyphLibrary *self = (GskNglGlyphLibrary *)object;
+ GskGLGlyphLibrary *self = (GskGLGlyphLibrary *)object;
g_clear_pointer (&self->surface_data, g_free);
- G_OBJECT_CLASS (gsk_ngl_glyph_library_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gsk_gl_glyph_library_parent_class)->finalize (object);
}
static void
-gsk_ngl_glyph_library_class_init (GskNglGlyphLibraryClass *klass)
+gsk_gl_glyph_library_class_init (GskGLGlyphLibraryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GskNglTextureLibraryClass *library_class = GSK_NGL_TEXTURE_LIBRARY_CLASS (klass);
+ GskGLTextureLibraryClass *library_class = GSK_GL_TEXTURE_LIBRARY_CLASS (klass);
- object_class->finalize = gsk_ngl_glyph_library_finalize;
+ object_class->finalize = gsk_gl_glyph_library_finalize;
- library_class->begin_frame = gsk_ngl_glyph_library_begin_frame;
+ library_class->begin_frame = gsk_gl_glyph_library_begin_frame;
}
static void
-gsk_ngl_glyph_library_init (GskNglGlyphLibrary *self)
+gsk_gl_glyph_library_init (GskGLGlyphLibrary *self)
{
- GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self;
+ GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
tl->max_entry_size = MAX_GLYPH_SIZE;
- gsk_ngl_texture_library_set_funcs (tl,
- gsk_ngl_glyph_key_hash,
- gsk_ngl_glyph_key_equal,
- gsk_ngl_glyph_key_free,
- gsk_ngl_glyph_value_free);
+ gsk_gl_texture_library_set_funcs (tl,
+ gsk_gl_glyph_key_hash,
+ gsk_gl_glyph_key_equal,
+ gsk_gl_glyph_key_free,
+ gsk_gl_glyph_value_free);
}
static cairo_surface_t *
-gsk_ngl_glyph_library_create_surface (GskNglGlyphLibrary *self,
- int stride,
- int width,
- int height,
- int uwidth,
- int uheight)
+gsk_gl_glyph_library_create_surface (GskGLGlyphLibrary *self,
+ int stride,
+ int width,
+ int height,
+ int uwidth,
+ int uheight)
{
cairo_surface_t *surface;
gsize n_bytes;
- g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
+ g_assert (GSK_IS_GL_GLYPH_LIBRARY (self));
g_assert (width > 0);
g_assert (height > 0);
@@ -162,8 +162,8 @@ gsk_ngl_glyph_library_create_surface (GskNglGlyphLibrary *self,
static void
render_glyph (cairo_surface_t *surface,
const cairo_scaled_font_t *scaled_font,
- const GskNglGlyphKey *key,
- const GskNglGlyphValue *value)
+ const GskGLGlyphKey *key,
+ const GskGLGlyphValue *value)
{
cairo_t *cr;
cairo_glyph_t glyph;
@@ -186,17 +186,17 @@ render_glyph (cairo_surface_t *surface,
}
static void
-gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
- const GskNglGlyphKey *key,
- const GskNglGlyphValue *value,
- int x,
- int y,
- int width,
- int height,
- int uwidth,
- int uheight)
+gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary *self,
+ const GskGLGlyphKey *key,
+ const GskGLGlyphValue *value,
+ int x,
+ int y,
+ int width,
+ int height,
+ int uwidth,
+ int uheight)
{
- GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self;
+ GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
cairo_scaled_font_t *scaled_font;
cairo_surface_t *surface;
@@ -207,7 +207,7 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
guint texture_id;
gsize stride;
- g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
+ g_assert (GSK_IS_GL_GLYPH_LIBRARY (self));
g_assert (key != NULL);
g_assert (value != NULL);
@@ -222,10 +222,10 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
"Uploading glyph %d",
key->glyph);
- surface = gsk_ngl_glyph_library_create_surface (self, stride, width, height, uwidth, uheight);
+ surface = gsk_gl_glyph_library_create_surface (self, stride, width, height, uwidth, uheight);
render_glyph (surface, scaled_font, key, value);
- texture_id = GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
+ texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
g_assert (texture_id > 0);
@@ -272,19 +272,19 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
}
gboolean
-gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
- GskNglGlyphKey *key,
- const GskNglGlyphValue **out_value)
+gsk_gl_glyph_library_add (GskGLGlyphLibrary *self,
+ GskGLGlyphKey *key,
+ const GskGLGlyphValue **out_value)
{
- GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self;
+ GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
PangoRectangle ink_rect;
- GskNglGlyphValue *value;
+ GskGLGlyphValue *value;
int width;
int height;
guint packed_x;
guint packed_y;
- g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
+ g_assert (GSK_IS_GL_GLYPH_LIBRARY (self));
g_assert (key != NULL);
g_assert (out_value != NULL);
@@ -299,28 +299,28 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
width = (int) ceil (ink_rect.width * key->scale / 1024.0);
height = (int) ceil (ink_rect.height * key->scale / 1024.0);
- value = gsk_ngl_texture_library_pack (tl,
- key,
- sizeof *value,
- width,
- height,
- 1,
- &packed_x, &packed_y);
+ value = gsk_gl_texture_library_pack (tl,
+ key,
+ sizeof *value,
+ width,
+ height,
+ 1,
+ &packed_x, &packed_y);
memcpy (&value->ink_rect, &ink_rect, sizeof ink_rect);
if (key->scale > 0 && width > 0 && height > 0)
- gsk_ngl_glyph_library_upload_glyph (self,
- key,
- value,
- packed_x + 1,
- packed_y + 1,
- width,
- height,
- ink_rect.width,
- ink_rect.height);
+ gsk_gl_glyph_library_upload_glyph (self,
+ key,
+ value,
+ packed_x + 1,
+ packed_y + 1,
+ width,
+ height,
+ ink_rect.width,
+ ink_rect.height);
*out_value = value;
- return GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (value) != 0;
+ return GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (value) != 0;
}
diff --git a/gsk/gl/gskglglyphlibraryprivate.h b/gsk/gl/gskglglyphlibraryprivate.h
new file mode 100644
index 0000000000..2ed051358e
--- /dev/null
+++ b/gsk/gl/gskglglyphlibraryprivate.h
@@ -0,0 +1,103 @@
+/* gskglglyphlibraryprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_GLYPH_LIBRARY_PRIVATE_H__
+#define __GSK_GL_GLYPH_LIBRARY_PRIVATE_H__
+
+#include <pango/pango.h>
+
+#include "gskgltexturelibraryprivate.h"
+
+G_BEGIN_DECLS
+
+#define GSK_TYPE_GL_GLYPH_LIBRARY (gsk_gl_glyph_library_get_type())
+
+typedef struct _GskGLGlyphKey
+{
+ PangoFont *font;
+ PangoGlyph glyph;
+ guint xshift : 2;
+ guint yshift : 2;
+ guint scale : 28; /* times 1024 */
+} GskGLGlyphKey;
+
+typedef struct _GskGLGlyphValue
+{
+ GskGLTextureAtlasEntry entry;
+ PangoRectangle ink_rect;
+} GskGLGlyphValue;
+
+#if GLIB_SIZEOF_VOID_P == 8
+G_STATIC_ASSERT (sizeof (GskGLGlyphKey) == 16);
+#elif GLIB_SIZEOF_VOID_P == 4
+G_STATIC_ASSERT (sizeof (GskGLGlyphKey) == 12);
+#endif
+
+G_DECLARE_FINAL_TYPE (GskGLGlyphLibrary, gsk_gl_glyph_library, GSK, GL_GLYPH_LIBRARY, GskGLTextureLibrary)
+
+struct _GskGLGlyphLibrary
+{
+ GskGLTextureLibrary parent_instance;
+ guint8 *surface_data;
+ gsize surface_data_len;
+ struct {
+ GskGLGlyphKey key;
+ const GskGLGlyphValue *value;
+ } front[256];
+};
+
+GskGLGlyphLibrary *gsk_gl_glyph_library_new (GskGLDriver *driver);
+gboolean gsk_gl_glyph_library_add (GskGLGlyphLibrary *self,
+ GskGLGlyphKey *key,
+ const GskGLGlyphValue **out_value);
+
+static inline guint
+gsk_gl_glyph_library_lookup_or_add (GskGLGlyphLibrary *self,
+ const GskGLGlyphKey *key,
+ const GskGLGlyphValue **out_value)
+{
+ GskGLTextureAtlasEntry *entry;
+ guint front_index = ((key->glyph << 2) | key->xshift) & 0xFF;
+
+ if (memcmp (key, &self->front[front_index], sizeof *key) == 0)
+ {
+ *out_value = self->front[front_index].value;
+ }
+ else if (gsk_gl_texture_library_lookup ((GskGLTextureLibrary *)self, key, &entry))
+ {
+ *out_value = (GskGLGlyphValue *)entry;
+ self->front[front_index].key = *key;
+ self->front[front_index].value = *out_value;
+ }
+ else
+ {
+ GskGLGlyphKey *k = g_slice_copy (sizeof *key, key);
+ g_object_ref (k->font);
+ gsk_gl_glyph_library_add (self, k, out_value);
+ self->front[front_index].key = *key;
+ self->front[front_index].value = *out_value;
+ }
+
+ return GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (*out_value);
+}
+
+G_END_DECLS
+
+#endif /* __GSK_GL_GLYPH_LIBRARY_PRIVATE_H__ */
diff --git a/gsk/ngl/gskngliconlibrary.c b/gsk/gl/gskgliconlibrary.c
similarity index 77%
rename from gsk/ngl/gskngliconlibrary.c
rename to gsk/gl/gskgliconlibrary.c
index cfc662a9e6..f4686fd877 100644
--- a/gsk/ngl/gskngliconlibrary.c
+++ b/gsk/gl/gskgliconlibrary.c
@@ -1,4 +1,4 @@
-/* gskngliconlibrary.c
+/* gskgliconlibrary.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -25,21 +25,21 @@
#include <gdk/gdkprofilerprivate.h>
#include <gdk/gdktextureprivate.h>
-#include "gsknglcommandqueueprivate.h"
-#include "gskngldriverprivate.h"
-#include "gskngliconlibraryprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskgldriverprivate.h"
+#include "gskgliconlibraryprivate.h"
-struct _GskNglIconLibrary
+struct _GskGLIconLibrary
{
- GskNglTextureLibrary parent_instance;
+ GskGLTextureLibrary parent_instance;
};
-G_DEFINE_TYPE (GskNglIconLibrary, gsk_ngl_icon_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
+G_DEFINE_TYPE (GskGLIconLibrary, gsk_gl_icon_library, GSK_TYPE_GL_TEXTURE_LIBRARY)
-GskNglIconLibrary *
-gsk_ngl_icon_library_new (GskNglDriver *driver)
+GskGLIconLibrary *
+gsk_gl_icon_library_new (GskGLDriver *driver)
{
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), NULL);
return g_object_new (GSK_TYPE_GL_ICON_LIBRARY,
"driver", driver,
@@ -47,39 +47,39 @@ gsk_ngl_icon_library_new (GskNglDriver *driver)
}
static void
-gsk_ngl_icon_data_free (gpointer data)
+gsk_gl_icon_data_free (gpointer data)
{
- GskNglIconData *icon_data = data;
+ GskGLIconData *icon_data = data;
g_clear_object (&icon_data->source_texture);
- g_slice_free (GskNglIconData, icon_data);
+ g_slice_free (GskGLIconData, icon_data);
}
static void
-gsk_ngl_icon_library_class_init (GskNglIconLibraryClass *klass)
+gsk_gl_icon_library_class_init (GskGLIconLibraryClass *klass)
{
}
static void
-gsk_ngl_icon_library_init (GskNglIconLibrary *self)
+gsk_gl_icon_library_init (GskGLIconLibrary *self)
{
- GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self;
+ GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
tl->max_entry_size = 128;
- gsk_ngl_texture_library_set_funcs (tl,
- NULL, NULL, NULL,
- gsk_ngl_icon_data_free);
+ gsk_gl_texture_library_set_funcs (tl,
+ NULL, NULL, NULL,
+ gsk_gl_icon_data_free);
}
void
-gsk_ngl_icon_library_add (GskNglIconLibrary *self,
- GdkTexture *key,
- const GskNglIconData **out_value)
+gsk_gl_icon_library_add (GskGLIconLibrary *self,
+ GdkTexture *key,
+ const GskGLIconData **out_value)
{
- GskNglTextureLibrary *tl = (GskNglTextureLibrary *)self;
+ GskGLTextureLibrary *tl = (GskGLTextureLibrary *)self;
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
cairo_surface_t *surface;
- GskNglIconData *icon_data;
+ GskGLIconData *icon_data;
guint8 *pixel_data;
guint8 *surface_data;
guint8 *free_data = NULL;
@@ -91,18 +91,18 @@ gsk_ngl_icon_library_add (GskNglIconLibrary *self,
int height;
guint texture_id;
- g_assert (GSK_IS_NGL_ICON_LIBRARY (self));
+ g_assert (GSK_IS_GL_ICON_LIBRARY (self));
g_assert (GDK_IS_TEXTURE (key));
g_assert (out_value != NULL);
width = key->width;
height = key->height;
- icon_data = gsk_ngl_texture_library_pack (tl,
- key,
- sizeof (GskNglIconData),
- width, height, 1,
- &packed_x, &packed_y);
+ icon_data = gsk_gl_texture_library_pack (tl,
+ key,
+ sizeof (GskGLIconData),
+ width, height, 1,
+ &packed_x, &packed_y);
icon_data->source_texture = g_object_ref (key);
/* actually upload the texture */
@@ -128,7 +128,7 @@ gsk_ngl_icon_library_add (GskNglIconLibrary *self,
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
- texture_id = GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
+ texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
glBindTexture (GL_TEXTURE_2D, texture_id);
diff --git a/gsk/gl/gskgliconlibraryprivate.h b/gsk/gl/gskgliconlibraryprivate.h
new file mode 100644
index 0000000000..8c34aec2f1
--- /dev/null
+++ b/gsk/gl/gskgliconlibraryprivate.h
@@ -0,0 +1,60 @@
+/* gskgliconlibraryprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_ICON_LIBRARY_PRIVATE_H__
+#define __GSK_GL_ICON_LIBRARY_PRIVATE_H__
+
+#include <pango/pango.h>
+
+#include "gskgltexturelibraryprivate.h"
+
+G_BEGIN_DECLS
+
+#define GSK_TYPE_GL_ICON_LIBRARY (gsk_gl_icon_library_get_type())
+
+typedef struct _GskGLIconData
+{
+ GskGLTextureAtlasEntry entry;
+ GdkTexture *source_texture;
+} GskGLIconData;
+
+G_DECLARE_FINAL_TYPE (GskGLIconLibrary, gsk_gl_icon_library, GSK, GL_ICON_LIBRARY, GskGLTextureLibrary)
+
+GskGLIconLibrary *gsk_gl_icon_library_new (GskGLDriver *driver);
+void gsk_gl_icon_library_add (GskGLIconLibrary *self,
+ GdkTexture *key,
+ const GskGLIconData **out_value);
+
+static inline void
+gsk_gl_icon_library_lookup_or_add (GskGLIconLibrary *self,
+ GdkTexture *key,
+ const GskGLIconData **out_value)
+{
+ GskGLTextureAtlasEntry *entry;
+
+ if G_LIKELY (gsk_gl_texture_library_lookup ((GskGLTextureLibrary *)self, key, &entry))
+ *out_value = (GskGLIconData *)entry;
+ else
+ gsk_gl_icon_library_add (self, key, out_value);
+}
+
+G_END_DECLS
+
+#endif /* __GSK_GL_ICON_LIBRARY_PRIVATE_H__ */
diff --git a/gsk/ngl/gskglprofiler.c b/gsk/gl/gskglprofiler.c
similarity index 100%
rename from gsk/ngl/gskglprofiler.c
rename to gsk/gl/gskglprofiler.c
diff --git a/gsk/ngl/gskglprofilerprivate.h b/gsk/gl/gskglprofilerprivate.h
similarity index 100%
rename from gsk/ngl/gskglprofilerprivate.h
rename to gsk/gl/gskglprofilerprivate.h
diff --git a/gsk/ngl/gsknglprogram.c b/gsk/gl/gskglprogram.c
similarity index 65%
rename from gsk/ngl/gsknglprogram.c
rename to gsk/gl/gskglprogram.c
index 7e00fa4913..66171b5bfb 100644
--- a/gsk/ngl/gsknglprogram.c
+++ b/gsk/gl/gskglprogram.c
@@ -1,4 +1,4 @@
-/* gsknglprogram.c
+/* gskglprogram.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -20,20 +20,20 @@
#include "config.h"
-#include "gsknglcommandqueueprivate.h"
-#include "gsknglprogramprivate.h"
-#include "gskngluniformstateprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskglprogramprivate.h"
+#include "gskgluniformstateprivate.h"
-G_DEFINE_TYPE (GskNglProgram, gsk_ngl_program, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GskGLProgram, gsk_gl_program, G_TYPE_OBJECT)
-GskNglProgram *
-gsk_ngl_program_new (GskNglDriver *driver,
- const char *name,
- int program_id)
+GskGLProgram *
+gsk_gl_program_new (GskGLDriver *driver,
+ const char *name,
+ int program_id)
{
- GskNglProgram *self;
+ GskGLProgram *self;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), NULL);
g_return_val_if_fail (program_id >= -1, NULL);
self = g_object_new (GSK_TYPE_GL_PROGRAM, NULL);
@@ -46,9 +46,9 @@ gsk_ngl_program_new (GskNglDriver *driver,
}
static void
-gsk_ngl_program_finalize (GObject *object)
+gsk_gl_program_finalize (GObject *object)
{
- GskNglProgram *self = (GskNglProgram *)object;
+ GskGLProgram *self = (GskGLProgram *)object;
if (self->id >= 0)
g_warning ("Leaking GLSL program %d (%s)",
@@ -58,19 +58,19 @@ gsk_ngl_program_finalize (GObject *object)
g_clear_pointer (&self->name, g_free);
g_clear_object (&self->driver);
- G_OBJECT_CLASS (gsk_ngl_program_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gsk_gl_program_parent_class)->finalize (object);
}
static void
-gsk_ngl_program_class_init (GskNglProgramClass *klass)
+gsk_gl_program_class_init (GskGLProgramClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gsk_ngl_program_finalize;
+ object_class->finalize = gsk_gl_program_finalize;
}
static void
-gsk_ngl_program_init (GskNglProgram *self)
+gsk_gl_program_init (GskGLProgram *self)
{
self->id = -1;
@@ -79,8 +79,8 @@ gsk_ngl_program_init (GskNglProgram *self)
}
/**
- * gsk_ngl_program_add_uniform:
- * @self: a `GskNglProgram`
+ * gsk_gl_program_add_uniform:
+ * @self: a `GskGLProgram`
* @name: the name of the uniform such as "u_source"
* @key: the identifier to use for the uniform
*
@@ -93,26 +93,26 @@ gsk_ngl_program_init (GskNglProgram *self)
* program and then register each of them like:
*
* ```
- * gsk_ngl_program_add_uniform (program, "u_source", UNIFORM_SOURCE);
+ * gsk_gl_program_add_uniform (program, "u_source", UNIFORM_SOURCE);
* ```
*
* That allows you to set values for the program with something
* like the following:
*
* ```
- * gsk_ngl_program_set_uniform1i (program, UNIFORM_SOURCE, 1);
+ * gsk_gl_program_set_uniform1i (program, UNIFORM_SOURCE, 1);
* ```
*
* Returns: %TRUE if the uniform was found; otherwise %FALSE
*/
gboolean
-gsk_ngl_program_add_uniform (GskNglProgram *self,
- const char *name,
- guint key)
+gsk_gl_program_add_uniform (GskGLProgram *self,
+ const char *name,
+ guint key)
{
GLint location;
- g_return_val_if_fail (GSK_IS_NGL_PROGRAM (self), FALSE);
+ g_return_val_if_fail (GSK_IS_GL_PROGRAM (self), FALSE);
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (key < G_N_ELEMENTS (self->mappings), FALSE);
@@ -133,41 +133,41 @@ gsk_ngl_program_add_uniform (GskNglProgram *self,
}
/**
- * gsk_ngl_program_delete:
- * @self: a `GskNglProgram`
+ * gsk_gl_program_delete:
+ * @self: a `GskGLProgram`
*
* Deletes the GLSL program.
*/
void
-gsk_ngl_program_delete (GskNglProgram *self)
+gsk_gl_program_delete (GskGLProgram *self)
{
- g_return_if_fail (GSK_IS_NGL_PROGRAM (self));
+ g_return_if_fail (GSK_IS_GL_PROGRAM (self));
g_return_if_fail (self->driver->command_queue != NULL);
- gsk_ngl_command_queue_delete_program (self->driver->command_queue, self->id);
+ gsk_gl_command_queue_delete_program (self->driver->command_queue, self->id);
self->id = -1;
}
/**
- * gsk_ngl_program_uniforms_added:
- * @self: a `GskNglProgram`
+ * gsk_gl_program_uniforms_added:
+ * @self: a `GskGLProgram`
* @has_attachments: if any uniform is for a bind/texture attachment
*
* This function should be called after all of the uniforms ahve
- * been added with gsk_ngl_program_add_uniform().
+ * been added with gsk_gl_program_add_uniform().
*
* This function will setup the uniform state so that the program
* has fast access to the data buffers without as many lookups at
* runtime for comparison data.
*/
void
-gsk_ngl_program_uniforms_added (GskNglProgram *self,
- gboolean has_attachments)
+gsk_gl_program_uniforms_added (GskGLProgram *self,
+ gboolean has_attachments)
{
- g_return_if_fail (GSK_IS_NGL_PROGRAM (self));
+ g_return_if_fail (GSK_IS_GL_PROGRAM (self));
g_return_if_fail (self->uniforms == NULL);
self->uniforms = self->driver->command_queue->uniforms;
- self->program_info = gsk_ngl_uniform_state_get_program (self->uniforms, self->id, self->mappings,
self->n_mappings);
+ self->program_info = gsk_gl_uniform_state_get_program (self->uniforms, self->id, self->mappings,
self->n_mappings);
self->program_info->has_attachments = has_attachments;
}
diff --git a/gsk/gl/gskglprogramprivate.h b/gsk/gl/gskglprogramprivate.h
new file mode 100644
index 0000000000..7693ed9a62
--- /dev/null
+++ b/gsk/gl/gskglprogramprivate.h
@@ -0,0 +1,282 @@
+/* gskglprogramprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_PROGRAM_PRIVATE_H__
+#define __GSK_GL_PROGRAM_PRIVATE_H__
+
+#include "gskgltypesprivate.h"
+
+#include "gskglattachmentstateprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskgldriverprivate.h"
+
+G_BEGIN_DECLS
+
+#define GSK_TYPE_GL_PROGRAM (gsk_gl_program_get_type())
+#define GSK_GL_PROGRAM_MAX_CUSTOM_TEXTURES 4
+#define GSK_GL_PROGRAM_MAX_CUSTOM_ARGS 8
+
+G_DECLARE_FINAL_TYPE (GskGLProgram, gsk_gl_program, GSK, GL_PROGRAM, GObject)
+
+struct _GskGLProgram
+{
+ GObject parent_instance;
+
+ int id;
+ char *name;
+ GskGLDriver *driver;
+
+ /* Cached pointer to avoid lots of pointer chasing/lookups */
+ GskGLUniformState *uniforms;
+ GskGLUniformProgram *program_info;
+
+ /* Static array for key->location transforms */
+ GskGLUniformMapping mappings[32];
+ guint n_mappings;
+};
+
+GskGLProgram * gsk_gl_program_new (GskGLDriver *driver,
+ const char *name,
+ int program_id);
+gboolean gsk_gl_program_add_uniform (GskGLProgram *self,
+ const char *name,
+ guint key);
+void gsk_gl_program_uniforms_added (GskGLProgram *self,
+ gboolean has_attachments);
+void gsk_gl_program_delete (GskGLProgram *self);
+
+static inline void
+gsk_gl_program_set_uniform1fv (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ guint count,
+ const float *values)
+{
+ gsk_gl_uniform_state_set1fv (self->uniforms, self->program_info,
+ key,
+ stamp,
+ count,
+ values);
+}
+
+static inline void
+gsk_gl_program_set_uniform2fv (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ guint count,
+ const float *values)
+{
+ gsk_gl_uniform_state_set2fv (self->uniforms, self->program_info,
+ key,
+ stamp,
+ count,
+ values);
+}
+
+static inline void
+gsk_gl_program_set_uniform4fv (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ guint count,
+ const float *values)
+{
+ gsk_gl_uniform_state_set4fv (self->uniforms, self->program_info,
+ key,
+ stamp,
+ count,
+ values);
+}
+
+static inline void
+gsk_gl_program_set_uniform_rounded_rect (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ const GskRoundedRect *rounded_rect)
+{
+ gsk_gl_uniform_state_set_rounded_rect (self->uniforms, self->program_info,
+ key,
+ stamp,
+ rounded_rect);
+}
+
+static inline void
+gsk_gl_program_set_uniform1i (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ int value0)
+{
+ gsk_gl_uniform_state_set1i (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ value0);
+}
+
+static inline void
+gsk_gl_program_set_uniform2i (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ int value0,
+ int value1)
+{
+ gsk_gl_uniform_state_set2i (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ value0, value1);
+}
+
+static inline void
+gsk_gl_program_set_uniform3i (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ int value0,
+ int value1,
+ int value2)
+{
+ gsk_gl_uniform_state_set3i (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ value0, value1, value2);
+}
+
+static inline void
+gsk_gl_program_set_uniform4i (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ int value0,
+ int value1,
+ int value2,
+ int value3)
+{
+ gsk_gl_uniform_state_set4i (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ value0, value1, value2, value3);
+}
+
+static inline void
+gsk_gl_program_set_uniform1f (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ float value0)
+{
+ gsk_gl_uniform_state_set1f (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ value0);
+}
+
+static inline void
+gsk_gl_program_set_uniform2f (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ float value0,
+ float value1)
+{
+ gsk_gl_uniform_state_set2f (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ value0, value1);
+}
+
+static inline void
+gsk_gl_program_set_uniform3f (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ float value0,
+ float value1,
+ float value2)
+{
+ gsk_gl_uniform_state_set3f (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ value0, value1, value2);
+}
+
+static inline void
+gsk_gl_program_set_uniform4f (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ float value0,
+ float value1,
+ float value2,
+ float value3)
+{
+ gsk_gl_uniform_state_set4f (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ value0, value1, value2, value3);
+}
+
+static inline void
+gsk_gl_program_set_uniform_color (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ const GdkRGBA *color)
+{
+ gsk_gl_uniform_state_set_color (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ color);
+}
+
+static inline void
+gsk_gl_program_set_uniform_texture (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ GLenum texture_target,
+ GLenum texture_slot,
+ guint texture_id)
+{
+ gsk_gl_attachment_state_bind_texture (self->driver->command_queue->attachments,
+ texture_target,
+ texture_slot,
+ texture_id);
+ gsk_gl_uniform_state_set_texture (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ texture_slot);
+}
+
+static inline void
+gsk_gl_program_set_uniform_matrix (GskGLProgram *self,
+ guint key,
+ guint stamp,
+ const graphene_matrix_t *matrix)
+{
+ gsk_gl_uniform_state_set_matrix (self->uniforms,
+ self->program_info,
+ key,
+ stamp,
+ matrix);
+}
+
+G_END_DECLS
+
+#endif /* __GSK_GL_PROGRAM_PRIVATE_H__ */
diff --git a/gsk/gl/gskglprograms.defs b/gsk/gl/gskglprograms.defs
new file mode 100644
index 0000000000..eb243fa865
--- /dev/null
+++ b/gsk/gl/gskglprograms.defs
@@ -0,0 +1,84 @@
+GSK_GL_DEFINE_PROGRAM (blend,
+ "/org/gtk/libgsk/ngl/blend.glsl",
+ GSK_GL_ADD_UNIFORM (1, BLEND_SOURCE2, u_source2)
+ GSK_GL_ADD_UNIFORM (2, BLEND_MODE, u_mode))
+
+GSK_GL_DEFINE_PROGRAM (blit,
+ "/org/gtk/libgsk/ngl/blit.glsl",
+ GSK_GL_NO_UNIFORMS)
+
+GSK_GL_DEFINE_PROGRAM (blur,
+ "/org/gtk/libgsk/ngl/blur.glsl",
+ GSK_GL_ADD_UNIFORM (1, BLUR_RADIUS, u_blur_radius)
+ GSK_GL_ADD_UNIFORM (2, BLUR_SIZE, u_blur_size)
+ GSK_GL_ADD_UNIFORM (3, BLUR_DIR, u_blur_dir))
+
+GSK_GL_DEFINE_PROGRAM (border,
+ "/org/gtk/libgsk/ngl/border.glsl",
+ GSK_GL_ADD_UNIFORM (1, BORDER_WIDTHS, u_widths)
+ GSK_GL_ADD_UNIFORM (2, BORDER_OUTLINE_RECT, u_outline_rect))
+
+GSK_GL_DEFINE_PROGRAM (color,
+ "/org/gtk/libgsk/ngl/color.glsl",
+ GSK_GL_NO_UNIFORMS)
+
+GSK_GL_DEFINE_PROGRAM (coloring,
+ "/org/gtk/libgsk/ngl/coloring.glsl",
+ GSK_GL_NO_UNIFORMS)
+
+GSK_GL_DEFINE_PROGRAM (color_matrix,
+ "/org/gtk/libgsk/ngl/color_matrix.glsl",
+ GSK_GL_ADD_UNIFORM (1, COLOR_MATRIX_COLOR_MATRIX, u_color_matrix)
+ GSK_GL_ADD_UNIFORM (2, COLOR_MATRIX_COLOR_OFFSET, u_color_offset))
+
+GSK_GL_DEFINE_PROGRAM (conic_gradient,
+ "/org/gtk/libgsk/ngl/conic_gradient.glsl",
+ GSK_GL_ADD_UNIFORM (1, CONIC_GRADIENT_COLOR_STOPS, u_color_stops)
+ GSK_GL_ADD_UNIFORM (2, CONIC_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
+ GSK_GL_ADD_UNIFORM (3, CONIC_GRADIENT_GEOMETRY, u_geometry))
+
+GSK_GL_DEFINE_PROGRAM (cross_fade,
+ "/org/gtk/libgsk/ngl/cross_fade.glsl",
+ GSK_GL_ADD_UNIFORM (1, CROSS_FADE_PROGRESS, u_progress)
+ GSK_GL_ADD_UNIFORM (2, CROSS_FADE_SOURCE2, u_source2))
+
+GSK_GL_DEFINE_PROGRAM (filled_border,
+ "/org/gtk/libgsk/ngl/filled_border.glsl",
+ GSK_GL_ADD_UNIFORM (1, FILLED_BORDER_WIDTHS, u_widths)
+ GSK_GL_ADD_UNIFORM (2, FILLED_BORDER_OUTLINE_RECT, u_outline_rect))
+
+GSK_GL_DEFINE_PROGRAM (inset_shadow,
+ "/org/gtk/libgsk/ngl/inset_shadow.glsl",
+ GSK_GL_ADD_UNIFORM (1, INSET_SHADOW_SPREAD, u_spread)
+ GSK_GL_ADD_UNIFORM (2, INSET_SHADOW_OFFSET, u_offset)
+ GSK_GL_ADD_UNIFORM (3, INSET_SHADOW_OUTLINE_RECT, u_outline_rect))
+
+GSK_GL_DEFINE_PROGRAM (linear_gradient,
+ "/org/gtk/libgsk/ngl/linear_gradient.glsl",
+ GSK_GL_ADD_UNIFORM (1, LINEAR_GRADIENT_COLOR_STOPS, u_color_stops)
+ GSK_GL_ADD_UNIFORM (2, LINEAR_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
+ GSK_GL_ADD_UNIFORM (3, LINEAR_GRADIENT_POINTS, u_points)
+ GSK_GL_ADD_UNIFORM (4, LINEAR_GRADIENT_REPEAT, u_repeat))
+
+GSK_GL_DEFINE_PROGRAM (outset_shadow,
+ "/org/gtk/libgsk/ngl/outset_shadow.glsl",
+ GSK_GL_ADD_UNIFORM (1, OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
+
+GSK_GL_DEFINE_PROGRAM (radial_gradient,
+ "/org/gtk/libgsk/ngl/radial_gradient.glsl",
+ GSK_GL_ADD_UNIFORM (1, RADIAL_GRADIENT_COLOR_STOPS, u_color_stops)
+ GSK_GL_ADD_UNIFORM (2, RADIAL_GRADIENT_NUM_COLOR_STOPS, u_num_color_stops)
+ GSK_GL_ADD_UNIFORM (3, RADIAL_GRADIENT_REPEAT, u_repeat)
+ GSK_GL_ADD_UNIFORM (4, RADIAL_GRADIENT_RANGE, u_range)
+ GSK_GL_ADD_UNIFORM (5, RADIAL_GRADIENT_GEOMETRY, u_geometry))
+
+GSK_GL_DEFINE_PROGRAM (repeat,
+ "/org/gtk/libgsk/ngl/repeat.glsl",
+ GSK_GL_ADD_UNIFORM (1, REPEAT_CHILD_BOUNDS, u_child_bounds)
+ GSK_GL_ADD_UNIFORM (2, REPEAT_TEXTURE_RECT, u_texture_rect))
+
+GSK_GL_DEFINE_PROGRAM (unblurred_outset_shadow,
+ "/org/gtk/libgsk/ngl/unblurred_outset_shadow.glsl",
+ GSK_GL_ADD_UNIFORM (1, UNBLURRED_OUTSET_SHADOW_SPREAD, u_spread)
+ GSK_GL_ADD_UNIFORM (2, UNBLURRED_OUTSET_SHADOW_OFFSET, u_offset)
+ GSK_GL_ADD_UNIFORM (3, UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
diff --git a/gsk/ngl/gsknglrenderer.c b/gsk/gl/gskglrenderer.c
similarity index 59%
rename from gsk/ngl/gsknglrenderer.c
rename to gsk/gl/gskglrenderer.c
index eea48b6e6d..e5613709a7 100644
--- a/gsk/ngl/gsknglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -1,4 +1,4 @@
-/* gsknglrenderer.c
+/* gskglrenderer.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -28,18 +28,18 @@
#include <gsk/gskrendererprivate.h>
#include <gsk/gskrendernodeprivate.h>
-#include "gsknglcommandqueueprivate.h"
-#include "gskngldriverprivate.h"
-#include "gsknglprogramprivate.h"
-#include "gsknglrenderjobprivate.h"
-#include "gsknglrendererprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskgldriverprivate.h"
+#include "gskglprogramprivate.h"
+#include "gskglrenderjobprivate.h"
+#include "gskglrendererprivate.h"
-struct _GskNglRendererClass
+struct _GskGLRendererClass
{
GskRendererClass parent_class;
};
-struct _GskNglRenderer
+struct _GskGLRenderer
{
GskRenderer parent_instance;
@@ -55,45 +55,45 @@ struct _GskNglRenderer
* contexts from other renderers on the display, texture atlases,
* programs, and other objects are available to them all.
*/
- GskNglCommandQueue *command_queue;
+ GskGLCommandQueue *command_queue;
/* The driver manages our program state and command queues. It also
* deals with caching textures, shaders, shadows, glyph, and icon
* caches through various helpers.
*/
- GskNglDriver *driver;
+ GskGLDriver *driver;
};
-G_DEFINE_TYPE (GskNglRenderer, gsk_ngl_renderer, GSK_TYPE_RENDERER)
+G_DEFINE_TYPE (GskGLRenderer, gsk_gl_renderer, GSK_TYPE_RENDERER)
/**
- * gsk_ngl_renderer_new:
+ * gsk_gl_renderer_new:
*
* Creates a new `GskRenderer` using the new OpenGL renderer.
*
- * Returns: a new NGL renderer
+ * Returns: a new GL renderer
*
* Since: 4.2
*/
GskRenderer *
-gsk_ngl_renderer_new (void)
+gsk_gl_renderer_new (void)
{
- return g_object_new (GSK_TYPE_NGL_RENDERER, NULL);
+ return g_object_new (GSK_TYPE_GL_RENDERER, NULL);
}
static gboolean
-gsk_ngl_renderer_realize (GskRenderer *renderer,
- GdkSurface *surface,
- GError **error)
+gsk_gl_renderer_realize (GskRenderer *renderer,
+ GdkSurface *surface,
+ GError **error)
{
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
- GskNglRenderer *self = (GskNglRenderer *)renderer;
+ GskGLRenderer *self = (GskGLRenderer *)renderer;
GdkGLContext *context = NULL;
- GskNglDriver *driver = NULL;
+ GskGLDriver *driver = NULL;
gboolean ret = FALSE;
gboolean debug_shaders = FALSE;
- g_assert (GSK_IS_NGL_RENDERER (self));
+ g_assert (GSK_IS_GL_RENDERER (self));
g_assert (GDK_IS_SURFACE (surface));
if (self->context != NULL)
@@ -112,15 +112,15 @@ gsk_ngl_renderer_realize (GskRenderer *renderer,
debug_shaders = TRUE;
#endif
- if (!(driver = gsk_ngl_driver_for_display (gdk_surface_get_display (surface), debug_shaders, error)))
+ if (!(driver = gsk_gl_driver_for_display (gdk_surface_get_display (surface), debug_shaders, error)))
goto failure;
- self->command_queue = gsk_ngl_driver_create_command_queue (driver, context);
+ self->command_queue = gsk_gl_driver_create_command_queue (driver, context);
self->context = g_steal_pointer (&context);
self->driver = g_steal_pointer (&driver);
- gsk_ngl_command_queue_set_profiler (self->command_queue,
- gsk_renderer_get_profiler (renderer));
+ gsk_gl_command_queue_set_profiler (self->command_queue,
+ gsk_renderer_get_profiler (renderer));
ret = TRUE;
@@ -128,17 +128,17 @@ failure:
g_clear_object (&driver);
g_clear_object (&context);
- gdk_profiler_end_mark (start_time, "realize GskNglRenderer", NULL);
+ gdk_profiler_end_mark (start_time, "realize GskGLRenderer", NULL);
return ret;
}
static void
-gsk_ngl_renderer_unrealize (GskRenderer *renderer)
+gsk_gl_renderer_unrealize (GskRenderer *renderer)
{
- GskNglRenderer *self = (GskNglRenderer *)renderer;
+ GskGLRenderer *self = (GskGLRenderer *)renderer;
- g_assert (GSK_IS_NGL_RENDERER (renderer));
+ g_assert (GSK_IS_GL_RENDERER (renderer));
gdk_gl_context_make_current (self->context);
@@ -181,18 +181,18 @@ get_render_region (GdkSurface *surface,
}
static void
-gsk_ngl_renderer_render (GskRenderer *renderer,
- GskRenderNode *root,
- const cairo_region_t *update_area)
+gsk_gl_renderer_render (GskRenderer *renderer,
+ GskRenderNode *root,
+ const cairo_region_t *update_area)
{
- GskNglRenderer *self = (GskNglRenderer *)renderer;
+ GskGLRenderer *self = (GskGLRenderer *)renderer;
cairo_region_t *render_region;
graphene_rect_t viewport;
- GskNglRenderJob *job;
+ GskGLRenderJob *job;
GdkSurface *surface;
float scale_factor;
- g_assert (GSK_IS_NGL_RENDERER (renderer));
+ g_assert (GSK_IS_GL_RENDERER (renderer));
g_assert (root != NULL);
surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self->context));
@@ -211,39 +211,39 @@ gsk_ngl_renderer_render (GskRenderer *renderer,
/* Must be called *AFTER* gdk_draw_context_begin_frame() */
render_region = get_render_region (surface, self->context);
- gsk_ngl_driver_begin_frame (self->driver, self->command_queue);
- job = gsk_ngl_render_job_new (self->driver, &viewport, scale_factor, render_region, 0);
+ gsk_gl_driver_begin_frame (self->driver, self->command_queue);
+ job = gsk_gl_render_job_new (self->driver, &viewport, scale_factor, render_region, 0);
#ifdef G_ENABLE_DEBUG
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
- gsk_ngl_render_job_set_debug_fallback (job, TRUE);
+ gsk_gl_render_job_set_debug_fallback (job, TRUE);
#endif
- gsk_ngl_render_job_render (job, root);
- gsk_ngl_driver_end_frame (self->driver);
- gsk_ngl_render_job_free (job);
+ gsk_gl_render_job_render (job, root);
+ gsk_gl_driver_end_frame (self->driver);
+ gsk_gl_render_job_free (job);
gdk_gl_context_make_current (self->context);
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->context));
- gsk_ngl_driver_after_frame (self->driver);
+ gsk_gl_driver_after_frame (self->driver);
cairo_region_destroy (render_region);
}
static GdkTexture *
-gsk_ngl_renderer_render_texture (GskRenderer *renderer,
- GskRenderNode *root,
- const graphene_rect_t *viewport)
+gsk_gl_renderer_render_texture (GskRenderer *renderer,
+ GskRenderNode *root,
+ const graphene_rect_t *viewport)
{
- GskNglRenderer *self = (GskNglRenderer *)renderer;
- GskNglRenderTarget *render_target;
- GskNglRenderJob *job;
+ GskGLRenderer *self = (GskGLRenderer *)renderer;
+ GskGLRenderTarget *render_target;
+ GskGLRenderJob *job;
GdkTexture *texture = NULL;
guint texture_id;
int width;
int height;
int format;
- g_assert (GSK_IS_NGL_RENDERER (renderer));
+ g_assert (GSK_IS_GL_RENDERER (renderer));
g_assert (root != NULL);
width = ceilf (viewport->size.width);
@@ -251,72 +251,72 @@ gsk_ngl_renderer_render_texture (GskRenderer *renderer,
format = gsk_render_node_prefers_high_depth (root) ? GL_RGBA32F : GL_RGBA8;
- if (gsk_ngl_driver_create_render_target (self->driver,
- width, height,
- format,
- GL_NEAREST, GL_NEAREST,
- &render_target))
+ if (gsk_gl_driver_create_render_target (self->driver,
+ width, height,
+ format,
+ GL_NEAREST, GL_NEAREST,
+ &render_target))
{
- gsk_ngl_driver_begin_frame (self->driver, self->command_queue);
- job = gsk_ngl_render_job_new (self->driver, viewport, 1, NULL, render_target->framebuffer_id);
+ gsk_gl_driver_begin_frame (self->driver, self->command_queue);
+ job = gsk_gl_render_job_new (self->driver, viewport, 1, NULL, render_target->framebuffer_id);
#ifdef G_ENABLE_DEBUG
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
- gsk_ngl_render_job_set_debug_fallback (job, TRUE);
+ gsk_gl_render_job_set_debug_fallback (job, TRUE);
#endif
- gsk_ngl_render_job_render_flipped (job, root);
- texture_id = gsk_ngl_driver_release_render_target (self->driver, render_target, FALSE);
- texture = gsk_ngl_driver_create_gdk_texture (self->driver, texture_id);
- gsk_ngl_driver_end_frame (self->driver);
- gsk_ngl_render_job_free (job);
+ gsk_gl_render_job_render_flipped (job, root);
+ texture_id = gsk_gl_driver_release_render_target (self->driver, render_target, FALSE);
+ texture = gsk_gl_driver_create_gdk_texture (self->driver, texture_id);
+ gsk_gl_driver_end_frame (self->driver);
+ gsk_gl_render_job_free (job);
- gsk_ngl_driver_after_frame (self->driver);
+ gsk_gl_driver_after_frame (self->driver);
}
return g_steal_pointer (&texture);
}
static void
-gsk_ngl_renderer_dispose (GObject *object)
+gsk_gl_renderer_dispose (GObject *object)
{
#ifdef G_ENABLE_DEBUG
- GskNglRenderer *self = (GskNglRenderer *)object;
+ GskGLRenderer *self = (GskGLRenderer *)object;
g_assert (self->driver == NULL);
#endif
- G_OBJECT_CLASS (gsk_ngl_renderer_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gsk_gl_renderer_parent_class)->dispose (object);
}
static void
-gsk_ngl_renderer_class_init (GskNglRendererClass *klass)
+gsk_gl_renderer_class_init (GskGLRendererClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GskRendererClass *renderer_class = GSK_RENDERER_CLASS (klass);
- object_class->dispose = gsk_ngl_renderer_dispose;
+ object_class->dispose = gsk_gl_renderer_dispose;
- renderer_class->realize = gsk_ngl_renderer_realize;
- renderer_class->unrealize = gsk_ngl_renderer_unrealize;
- renderer_class->render = gsk_ngl_renderer_render;
- renderer_class->render_texture = gsk_ngl_renderer_render_texture;
+ renderer_class->realize = gsk_gl_renderer_realize;
+ renderer_class->unrealize = gsk_gl_renderer_unrealize;
+ renderer_class->render = gsk_gl_renderer_render;
+ renderer_class->render_texture = gsk_gl_renderer_render_texture;
}
static void
-gsk_ngl_renderer_init (GskNglRenderer *self)
+gsk_gl_renderer_init (GskGLRenderer *self)
{
}
gboolean
-gsk_ngl_renderer_try_compile_gl_shader (GskNglRenderer *renderer,
- GskGLShader *shader,
- GError **error)
+gsk_gl_renderer_try_compile_gl_shader (GskGLRenderer *renderer,
+ GskGLShader *shader,
+ GError **error)
{
- GskNglProgram *program;
+ GskGLProgram *program;
- g_return_val_if_fail (GSK_IS_NGL_RENDERER (renderer), FALSE);
+ g_return_val_if_fail (GSK_IS_GL_RENDERER (renderer), FALSE);
g_return_val_if_fail (shader != NULL, FALSE);
- program = gsk_ngl_driver_lookup_shader (renderer->driver, shader, error);
+ program = gsk_gl_driver_lookup_shader (renderer->driver, shader, error);
return program != NULL;
}
diff --git a/gsk/gl/gskglrenderer.h b/gsk/gl/gskglrenderer.h
new file mode 100644
index 0000000000..50fa134d2d
--- /dev/null
+++ b/gsk/gl/gskglrenderer.h
@@ -0,0 +1,46 @@
+/* gskglrenderer.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_RENDERER_H__
+#define __GSK_GL_RENDERER_H__
+
+#include <gsk/gskrenderer.h>
+
+G_BEGIN_DECLS
+
+#define GSK_TYPE_GL_RENDERER (gsk_gl_renderer_get_type())
+
+#define GSK_GL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_GL_RENDERER,
GskGLRenderer))
+#define GSK_IS_GL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_GL_RENDERER))
+#define GSK_GL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSK_TYPE_GL_RENDERER,
GskGLRendererClass))
+#define GSK_IS_GL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSK_TYPE_GL_RENDERER))
+#define GSK_GL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_GL_RENDERER,
GskGLRendererClass))
+
+typedef struct _GskGLRenderer GskGLRenderer;
+typedef struct _GskGLRendererClass GskGLRendererClass;
+
+GDK_AVAILABLE_IN_4_2
+GType gsk_gl_renderer_get_type (void) G_GNUC_CONST;
+GDK_AVAILABLE_IN_4_2
+GskRenderer *gsk_gl_renderer_new (void);
+
+G_END_DECLS
+
+#endif /* __GSK_GL_RENDERER__ */
diff --git a/gsk/ngl/gsknglrendererprivate.h b/gsk/gl/gskglrendererprivate.h
similarity index 67%
rename from gsk/ngl/gsknglrendererprivate.h
rename to gsk/gl/gskglrendererprivate.h
index a0a861f0aa..df23e0705f 100644
--- a/gsk/ngl/gsknglrendererprivate.h
+++ b/gsk/gl/gskglrendererprivate.h
@@ -1,4 +1,4 @@
-/* gsknglrendererprivate.h
+/* gskglrendererprivate.h
*
* Copyright 2021 Christian Hergert <chergert redhat com>
*
@@ -18,17 +18,17 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#ifndef __GSK_NGL_RENDERER_PRIVATE_H__
-#define __GSK_NGL_RENDERER_PRIVATE_H__
+#ifndef __GSK_GL_RENDERER_PRIVATE_H__
+#define __GSK_GL_RENDERER_PRIVATE_H__
-#include "gsknglrenderer.h"
+#include "gskglrenderer.h"
G_BEGIN_DECLS
-gboolean gsk_ngl_renderer_try_compile_gl_shader (GskNglRenderer *renderer,
- GskGLShader *shader,
- GError **error);
+gboolean gsk_gl_renderer_try_compile_gl_shader (GskGLRenderer *renderer,
+ GskGLShader *shader,
+ GError **error);
G_END_DECLS
-#endif /* __GSK_NGL_RENDERER_PRIVATE_H__ */
+#endif /* __GSK_GL_RENDERER_PRIVATE_H__ */
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/gl/gskglrenderjob.c
similarity index 55%
rename from gsk/ngl/gsknglrenderjob.c
rename to gsk/gl/gskglrenderjob.c
index e3436e10f4..b35b1158ac 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/gl/gskglrenderjob.c
@@ -1,4 +1,4 @@
-/* gsknglrenderjob.c
+/* gskglrenderjob.c
*
* Copyright 2017 Timm Bäder <mail baedert org>
* Copyright 2018 Matthias Clasen <mclasen redhat com>
@@ -34,13 +34,13 @@
#include <math.h>
#include <string.h>
-#include "gsknglcommandqueueprivate.h"
-#include "gskngldriverprivate.h"
-#include "gsknglglyphlibraryprivate.h"
-#include "gskngliconlibraryprivate.h"
-#include "gsknglprogramprivate.h"
-#include "gsknglrenderjobprivate.h"
-#include "gsknglshadowlibraryprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskgldriverprivate.h"
+#include "gskglglyphlibraryprivate.h"
+#include "gskgliconlibraryprivate.h"
+#include "gskglprogramprivate.h"
+#include "gskglrenderjobprivate.h"
+#include "gskglshadowlibraryprivate.h"
#include "ninesliceprivate.h"
#include "fp16private.h"
@@ -51,7 +51,7 @@
#define SHADOW_EXTRA_SIZE 4
/* Make sure gradient stops fits in packed array_count */
-G_STATIC_ASSERT ((MAX_GRADIENT_STOPS * 5) < (1 << GSK_NGL_UNIFORM_ARRAY_BITS));
+G_STATIC_ASSERT ((MAX_GRADIENT_STOPS * 5) < (1 << GSK_GL_UNIFORM_ARRAY_BITS));
#define rounded_rect_top_left(r) \
(GRAPHENE_RECT_INIT(r->bounds.origin.x, \
@@ -77,14 +77,14 @@ G_STATIC_ASSERT ((MAX_GRADIENT_STOPS * 5) < (1 << GSK_NGL_UNIFORM_ARRAY_BITS));
#define ALPHA_IS_CLEAR(alpha) ((alpha) < ((float) 0x00ff / (float) 0xffff))
#define RGBA_IS_CLEAR(rgba) ALPHA_IS_CLEAR((rgba)->alpha)
-typedef struct _GskNglRenderClip
+typedef struct _GskGLRenderClip
{
GskRoundedRect rect;
guint is_rectilinear : 1;
guint is_fully_contained : 1;
-} GskNglRenderClip;
+} GskGLRenderClip;
-typedef struct _GskNglRenderModelview
+typedef struct _GskGLRenderModelview
{
GskTransform *transform;
float scale_x;
@@ -94,25 +94,25 @@ typedef struct _GskNglRenderModelview
float offset_x_before;
float offset_y_before;
graphene_matrix_t matrix;
-} GskNglRenderModelview;
+} GskGLRenderModelview;
-struct _GskNglRenderJob
+struct _GskGLRenderJob
{
/* The context containing the framebuffer we are drawing to. Generally this
* is the context of the surface but may be a shared context if rendering to
- * an offscreen texture such as gsk_ngl_renderer_render_texture().
+ * an offscreen texture such as gsk_gl_renderer_render_texture().
*/
GdkGLContext *context;
/* The driver to be used. This is shared among all the renderers on a given
* GdkDisplay and uses the shared GL context to send commands.
*/
- GskNglDriver *driver;
+ GskGLDriver *driver;
/* The command queue (which is just a faster pointer to the driver's
* command queue.
*/
- GskNglCommandQueue *command_queue;
+ GskGLCommandQueue *command_queue;
/* The region that we are clipping. Normalized to a single rectangle region. */
cairo_region_t *region;
@@ -132,12 +132,12 @@ struct _GskNglRenderJob
/* The current projection, updated as we process nodes */
graphene_matrix_t projection;
- /* An array of GskNglRenderModelview updated as nodes are processed. The
+ /* An array of GskGLRenderModelview updated as nodes are processed. The
* current modelview is the last element.
*/
GArray *modelview;
- /* An array of GskNglRenderClip updated as nodes are processed. The
+ /* An array of GskGLRenderClip updated as nodes are processed. The
* current clip is the last element.
*/
GArray *clip;
@@ -156,9 +156,9 @@ struct _GskNglRenderJob
float scale_y;
/* Cached pointers */
- const GskNglRenderClip *current_clip;
- const GskNglRenderModelview *current_modelview;
- GskNglProgram *current_program;
+ const GskGLRenderClip *current_clip;
+ const GskGLRenderModelview *current_modelview;
+ GskGLProgram *current_program;
/* If we should be rendering red zones over fallback nodes */
guint debug_fallback : 1;
@@ -169,7 +169,7 @@ struct _GskNglRenderJob
int target_format;
};
-typedef struct _GskNglRenderOffscreen
+typedef struct _GskGLRenderOffscreen
{
/* The bounds to render */
const graphene_rect_t *bounds;
@@ -195,16 +195,16 @@ typedef struct _GskNglRenderOffscreen
/* Return location for whether we created a texture */
guint was_offscreen : 1;
-} GskNglRenderOffscreen;
+} GskGLRenderOffscreen;
-static void gsk_ngl_render_job_visit_node (GskNglRenderJob *job,
- const GskRenderNode *node);
-static gboolean gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
- const GskRenderNode *node,
- GskNglRenderOffscreen *offscreen);
+static void gsk_gl_render_job_visit_node (GskGLRenderJob *job,
+ const GskRenderNode *node);
+static gboolean gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
+ const GskRenderNode *node,
+ GskGLRenderOffscreen *offscreen);
static inline int
-get_target_format (GskNglRenderJob *job,
+get_target_format (GskGLRenderJob *job,
const GskRenderNode *node)
{
if (gsk_render_node_prefers_high_depth (node))
@@ -214,7 +214,7 @@ get_target_format (GskNglRenderJob *job,
}
static inline void
-init_full_texture_region (GskNglRenderOffscreen *offscreen)
+init_full_texture_region (GskGLRenderOffscreen *offscreen)
{
offscreen->area.x = 0;
offscreen->area.y = 0;
@@ -427,8 +427,8 @@ init_projection_matrix (graphene_matrix_t *projection,
}
static inline float
-gsk_ngl_render_job_set_alpha (GskNglRenderJob *job,
- float alpha)
+gsk_gl_render_job_set_alpha (GskGLRenderJob *job,
+ float alpha)
{
if (job->alpha != alpha)
{
@@ -442,7 +442,7 @@ gsk_ngl_render_job_set_alpha (GskNglRenderJob *job,
}
static void
-extract_matrix_metadata (GskNglRenderModelview *modelview)
+extract_matrix_metadata (GskGLRenderModelview *modelview)
{
gsk_transform_to_matrix (modelview->transform, &modelview->matrix);
@@ -512,10 +512,10 @@ extract_matrix_metadata (GskNglRenderModelview *modelview)
}
static void
-gsk_ngl_render_job_set_modelview (GskNglRenderJob *job,
- GskTransform *transform)
+gsk_gl_render_job_set_modelview (GskGLRenderJob *job,
+ GskTransform *transform)
{
- GskNglRenderModelview *modelview;
+ GskGLRenderModelview *modelview;
g_assert (job != NULL);
g_assert (job->modelview != NULL);
@@ -525,7 +525,7 @@ gsk_ngl_render_job_set_modelview (GskNglRenderJob *job,
g_array_set_size (job->modelview, job->modelview->len + 1);
modelview = &g_array_index (job->modelview,
- GskNglRenderModelview,
+ GskGLRenderModelview,
job->modelview->len - 1);
modelview->transform = transform;
@@ -544,10 +544,10 @@ gsk_ngl_render_job_set_modelview (GskNglRenderJob *job,
}
static void
-gsk_ngl_render_job_push_modelview (GskNglRenderJob *job,
- GskTransform *transform)
+gsk_gl_render_job_push_modelview (GskGLRenderJob *job,
+ GskTransform *transform)
{
- GskNglRenderModelview *modelview;
+ GskGLRenderModelview *modelview;
g_assert (job != NULL);
g_assert (job->modelview != NULL);
@@ -558,16 +558,16 @@ gsk_ngl_render_job_push_modelview (GskNglRenderJob *job,
g_array_set_size (job->modelview, job->modelview->len + 1);
modelview = &g_array_index (job->modelview,
- GskNglRenderModelview,
+ GskGLRenderModelview,
job->modelview->len - 1);
if G_LIKELY (job->modelview->len > 1)
{
- GskNglRenderModelview *last;
+ GskGLRenderModelview *last;
GskTransform *t = NULL;
last = &g_array_index (job->modelview,
- GskNglRenderModelview,
+ GskGLRenderModelview,
job->modelview->len - 2);
/* Multiply given matrix with our previous modelview */
@@ -598,9 +598,9 @@ gsk_ngl_render_job_push_modelview (GskNglRenderJob *job,
}
static void
-gsk_ngl_render_job_pop_modelview (GskNglRenderJob *job)
+gsk_gl_render_job_pop_modelview (GskGLRenderJob *job)
{
- const GskNglRenderModelview *head;
+ const GskGLRenderModelview *head;
g_assert (job != NULL);
g_assert (job->modelview);
@@ -619,7 +619,7 @@ gsk_ngl_render_job_pop_modelview (GskNglRenderJob *job)
if (job->modelview->len >= 1)
{
- head = &g_array_index (job->modelview, GskNglRenderModelview, job->modelview->len - 1);
+ head = &g_array_index (job->modelview, GskGLRenderModelview, job->modelview->len - 1);
job->scale_x = head->scale_x;
job->scale_y = head->scale_y;
@@ -633,10 +633,10 @@ gsk_ngl_render_job_pop_modelview (GskNglRenderJob *job)
}
static void
-gsk_ngl_render_job_push_clip (GskNglRenderJob *job,
- const GskRoundedRect *rect)
+gsk_gl_render_job_push_clip (GskGLRenderJob *job,
+ const GskRoundedRect *rect)
{
- GskNglRenderClip *clip;
+ GskGLRenderClip *clip;
g_assert (job != NULL);
g_assert (job->clip != NULL);
@@ -646,7 +646,7 @@ gsk_ngl_render_job_push_clip (GskNglRenderJob *job,
g_array_set_size (job->clip, job->clip->len + 1);
- clip = &g_array_index (job->clip, GskNglRenderClip, job->clip->len - 1);
+ 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;
@@ -655,10 +655,10 @@ gsk_ngl_render_job_push_clip (GskNglRenderJob *job,
}
static void
-gsk_ngl_render_job_push_contained_clip (GskNglRenderJob *job)
+gsk_gl_render_job_push_contained_clip (GskGLRenderJob *job)
{
- GskNglRenderClip *clip;
- GskNglRenderClip *old_clip;
+ GskGLRenderClip *clip;
+ GskGLRenderClip *old_clip;
g_assert (job != NULL);
g_assert (job->clip != NULL);
@@ -666,11 +666,11 @@ gsk_ngl_render_job_push_contained_clip (GskNglRenderJob *job)
job->driver->stamps[UNIFORM_SHARED_CLIP_RECT]++;
- old_clip = &g_array_index (job->clip, GskNglRenderClip, job->clip->len - 1);
+ old_clip = &g_array_index (job->clip, GskGLRenderClip, job->clip->len - 1);
g_array_set_size (job->clip, job->clip->len + 1);
- clip = &g_array_index (job->clip, GskNglRenderClip, job->clip->len - 1);
+ 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;
@@ -680,7 +680,7 @@ gsk_ngl_render_job_push_contained_clip (GskNglRenderJob *job)
}
static void
-gsk_ngl_render_job_pop_clip (GskNglRenderJob *job)
+gsk_gl_render_job_pop_clip (GskGLRenderJob *job)
{
g_assert (job != NULL);
g_assert (job->clip != NULL);
@@ -692,9 +692,9 @@ gsk_ngl_render_job_pop_clip (GskNglRenderJob *job)
}
static inline void
-gsk_ngl_render_job_offset (GskNglRenderJob *job,
- float offset_x,
- float offset_y)
+gsk_gl_render_job_offset (GskGLRenderJob *job,
+ float offset_x,
+ float offset_y)
{
if (offset_x || offset_y)
{
@@ -704,17 +704,17 @@ gsk_ngl_render_job_offset (GskNglRenderJob *job,
}
static inline void
-gsk_ngl_render_job_set_projection (GskNglRenderJob *job,
- const graphene_matrix_t *projection)
+gsk_gl_render_job_set_projection (GskGLRenderJob *job,
+ const graphene_matrix_t *projection)
{
memcpy (&job->projection, projection, sizeof job->projection);
job->driver->stamps[UNIFORM_SHARED_PROJECTION]++;
}
static inline void
-gsk_ngl_render_job_set_projection_from_rect (GskNglRenderJob *job,
- const graphene_rect_t *rect,
- graphene_matrix_t *prev_projection)
+gsk_gl_render_job_set_projection_from_rect (GskGLRenderJob *job,
+ const graphene_rect_t *rect,
+ graphene_matrix_t *prev_projection)
{
if (prev_projection)
memcpy (prev_projection, &job->projection, sizeof *prev_projection);
@@ -723,10 +723,10 @@ gsk_ngl_render_job_set_projection_from_rect (GskNglRenderJob *job,
}
static inline void
-gsk_ngl_render_job_set_projection_for_size (GskNglRenderJob *job,
- float width,
- float height,
- graphene_matrix_t *prev_projection)
+gsk_gl_render_job_set_projection_for_size (GskGLRenderJob *job,
+ float width,
+ float height,
+ graphene_matrix_t *prev_projection)
{
if (prev_projection)
memcpy (prev_projection, &job->projection, sizeof *prev_projection);
@@ -736,9 +736,9 @@ gsk_ngl_render_job_set_projection_for_size (GskNglRenderJob *job,
}
static inline void
-gsk_ngl_render_job_set_viewport (GskNglRenderJob *job,
- const graphene_rect_t *viewport,
- graphene_rect_t *prev_viewport)
+gsk_gl_render_job_set_viewport (GskGLRenderJob *job,
+ const graphene_rect_t *viewport,
+ graphene_rect_t *prev_viewport)
{
if (prev_viewport)
memcpy (prev_viewport, &job->viewport, sizeof *prev_viewport);
@@ -747,10 +747,10 @@ gsk_ngl_render_job_set_viewport (GskNglRenderJob *job,
}
static inline void
-gsk_ngl_render_job_set_viewport_for_size (GskNglRenderJob *job,
- float width,
- float height,
- graphene_rect_t *prev_viewport)
+gsk_gl_render_job_set_viewport_for_size (GskGLRenderJob *job,
+ float width,
+ float height,
+ graphene_rect_t *prev_viewport)
{
if (prev_viewport)
memcpy (prev_viewport, &job->viewport, sizeof *prev_viewport);
@@ -762,9 +762,9 @@ gsk_ngl_render_job_set_viewport_for_size (GskNglRenderJob *job,
}
static inline void
-gsk_ngl_render_job_transform_bounds (GskNglRenderJob *job,
- const graphene_rect_t *rect,
- graphene_rect_t *out_rect)
+gsk_gl_render_job_transform_bounds (GskGLRenderJob *job,
+ const graphene_rect_t *rect,
+ graphene_rect_t *out_rect)
{
GskTransform *transform;
GskTransformCategory category;
@@ -824,9 +824,9 @@ gsk_ngl_render_job_transform_bounds (GskNglRenderJob *job,
}
static inline void
-gsk_ngl_render_job_transform_rounded_rect (GskNglRenderJob *job,
- const GskRoundedRect *rect,
- GskRoundedRect *out_rect)
+gsk_gl_render_job_transform_rounded_rect (GskGLRenderJob *job,
+ const GskRoundedRect *rect,
+ GskRoundedRect *out_rect)
{
out_rect->bounds.origin.x = job->offset_x + rect->bounds.origin.x;
out_rect->bounds.origin.y = job->offset_y + rect->bounds.origin.y;
@@ -865,9 +865,9 @@ interval_contains (float p1, float w1,
}
static inline gboolean
-gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
- const graphene_rect_t *bounds,
- gboolean *pushed_clip)
+gsk_gl_render_job_update_clip (GskGLRenderJob *job,
+ const graphene_rect_t *bounds,
+ gboolean *pushed_clip)
{
graphene_rect_t transformed_bounds;
gboolean no_clip = FALSE;
@@ -881,7 +881,7 @@ gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
return TRUE;
}
- gsk_ngl_render_job_transform_bounds (job, bounds, &transformed_bounds);
+ gsk_gl_render_job_transform_bounds (job, bounds, &transformed_bounds);
if (!rect_intersects (&job->current_clip->rect.bounds, &transformed_bounds))
{
@@ -920,7 +920,7 @@ gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
* for child nodes.
*/
- gsk_ngl_render_job_push_contained_clip (job);
+ gsk_gl_render_job_push_contained_clip (job);
*pushed_clip = TRUE;
}
@@ -931,7 +931,7 @@ gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
/* The clip gets simpler for this node */
graphene_rect_intersection (&job->current_clip->rect.bounds, &transformed_bounds, &rect);
- gsk_ngl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT_FROM_RECT (rect));
+ gsk_gl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT_FROM_RECT (rect));
*pushed_clip = TRUE;
}
@@ -948,33 +948,33 @@ rgba_to_half (const GdkRGBA *rgba,
/* fill_vertex_data */
static void
-gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
- float min_x,
- float min_y,
- float max_x,
- float max_y,
- float min_u,
- float min_v,
- float max_u,
- float max_v,
- guint16 c[4])
+gsk_gl_render_job_draw_coords (GskGLRenderJob *job,
+ float min_x,
+ float min_y,
+ float max_x,
+ float max_y,
+ float min_u,
+ float min_v,
+ float max_u,
+ float max_v,
+ guint16 c[4])
{
- GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
-
- vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .uv = { min_u, min_v }, .color = { c[0],
c[1], c[2], c[3] } };
- vertices[1] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { min_u, max_v }, .color = { c[0],
c[1], c[2], c[3] } };
- vertices[2] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { max_u, min_v }, .color = { c[0],
c[1], c[2], c[3] } };
- vertices[3] = (GskNglDrawVertex) { .position = { max_x, max_y }, .uv = { max_u, max_v }, .color = { c[0],
c[1], c[2], c[3] } };
- vertices[4] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { min_u, max_v }, .color = { c[0],
c[1], c[2], c[3] } };
- vertices[5] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { max_u, min_v }, .color = { c[0],
c[1], c[2], c[3] } };
+ GskGLDrawVertex *vertices = gsk_gl_command_queue_add_vertices (job->command_queue);
+
+ vertices[0] = (GskGLDrawVertex) { .position = { min_x, min_y }, .uv = { min_u, min_v }, .color = { c[0],
c[1], c[2], c[3] } };
+ vertices[1] = (GskGLDrawVertex) { .position = { min_x, max_y }, .uv = { min_u, max_v }, .color = { c[0],
c[1], c[2], c[3] } };
+ vertices[2] = (GskGLDrawVertex) { .position = { max_x, min_y }, .uv = { max_u, min_v }, .color = { c[0],
c[1], c[2], c[3] } };
+ vertices[3] = (GskGLDrawVertex) { .position = { max_x, max_y }, .uv = { max_u, max_v }, .color = { c[0],
c[1], c[2], c[3] } };
+ vertices[4] = (GskGLDrawVertex) { .position = { min_x, max_y }, .uv = { min_u, max_v }, .color = { c[0],
c[1], c[2], c[3] } };
+ vertices[5] = (GskGLDrawVertex) { .position = { max_x, min_y }, .uv = { max_u, min_v }, .color = { c[0],
c[1], c[2], c[3] } };
}
/* load_vertex_data_with_region */
static inline void
-gsk_ngl_render_job_draw_offscreen_with_color (GskNglRenderJob *job,
- const graphene_rect_t *bounds,
- const GskNglRenderOffscreen *offscreen,
- guint16 color[4])
+gsk_gl_render_job_draw_offscreen_with_color (GskGLRenderJob *job,
+ const graphene_rect_t *bounds,
+ const GskGLRenderOffscreen *offscreen,
+ guint16 color[4])
{
float min_x = job->offset_x + bounds->origin.x;
float min_y = job->offset_y + bounds->origin.y;
@@ -983,77 +983,77 @@ gsk_ngl_render_job_draw_offscreen_with_color (GskNglRenderJob *job,
float y1 = offscreen->was_offscreen ? offscreen->area.y2 : offscreen->area.y;
float y2 = offscreen->was_offscreen ? offscreen->area.y : offscreen->area.y2;
- gsk_ngl_render_job_draw_coords (job,
- min_x, min_y, max_x, max_y,
- offscreen->area.x, y1, offscreen->area.x2, y2,
- color);
+ gsk_gl_render_job_draw_coords (job,
+ min_x, min_y, max_x, max_y,
+ offscreen->area.x, y1, offscreen->area.x2, y2,
+ color);
}
static inline void
-gsk_ngl_render_job_draw_offscreen (GskNglRenderJob *job,
- const graphene_rect_t *bounds,
- const GskNglRenderOffscreen *offscreen)
+gsk_gl_render_job_draw_offscreen (GskGLRenderJob *job,
+ const graphene_rect_t *bounds,
+ const GskGLRenderOffscreen *offscreen)
{
- gsk_ngl_render_job_draw_offscreen_with_color (job, bounds, offscreen,
- (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
+ gsk_gl_render_job_draw_offscreen_with_color (job, bounds, offscreen,
+ (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
}
/* load_float_vertex_data */
static inline void
-gsk_ngl_render_job_draw_with_color (GskNglRenderJob *job,
- float x,
- float y,
- float width,
- float height,
- guint16 color[4])
+gsk_gl_render_job_draw_with_color (GskGLRenderJob *job,
+ float x,
+ float y,
+ float width,
+ float height,
+ guint16 color[4])
{
float min_x = job->offset_x + x;
float min_y = job->offset_y + y;
float max_x = min_x + width;
float max_y = min_y + height;
- gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 0, 1, 1, color);
+ gsk_gl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 0, 1, 1, color);
}
static inline void
-gsk_ngl_render_job_draw (GskNglRenderJob *job,
- float x,
- float y,
- float width,
- float height)
+gsk_gl_render_job_draw (GskGLRenderJob *job,
+ float x,
+ float y,
+ float width,
+ float height)
{
- gsk_ngl_render_job_draw_with_color (job, x, y, width, height,
- (guint16[]) { FP_ZERO, FP_ZERO, FP_ZERO, FP_ZERO });
+ gsk_gl_render_job_draw_with_color (job, x, y, width, height,
+ (guint16[]) { FP_ZERO, FP_ZERO, FP_ZERO, FP_ZERO });
}
/* load_vertex_data */
static inline void
-gsk_ngl_render_job_draw_rect_with_color (GskNglRenderJob *job,
- const graphene_rect_t *bounds,
- guint16 color[4])
+gsk_gl_render_job_draw_rect_with_color (GskGLRenderJob *job,
+ const graphene_rect_t *bounds,
+ guint16 color[4])
{
- gsk_ngl_render_job_draw_with_color (job,
- bounds->origin.x,
- bounds->origin.y,
- bounds->size.width,
- bounds->size.height,
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ bounds->origin.x,
+ bounds->origin.y,
+ bounds->size.width,
+ bounds->size.height,
+ color);
}
static inline void
-gsk_ngl_render_job_draw_rect (GskNglRenderJob *job,
- const graphene_rect_t *bounds)
+gsk_gl_render_job_draw_rect (GskGLRenderJob *job,
+ const graphene_rect_t *bounds)
{
- gsk_ngl_render_job_draw (job,
- bounds->origin.x,
- bounds->origin.y,
- bounds->size.width,
- bounds->size.height);
+ gsk_gl_render_job_draw (job,
+ bounds->origin.x,
+ bounds->origin.y,
+ bounds->size.width,
+ bounds->size.height);
}
/* load_offscreen_vertex_data */
static inline void
-gsk_ngl_render_job_draw_offscreen_rect (GskNglRenderJob *job,
- const graphene_rect_t *bounds)
+gsk_gl_render_job_draw_offscreen_rect (GskGLRenderJob *job,
+ const graphene_rect_t *bounds)
{
float min_x = job->offset_x + bounds->origin.x;
float min_y = job->offset_y + bounds->origin.y;
@@ -1061,53 +1061,53 @@ gsk_ngl_render_job_draw_offscreen_rect (GskNglRenderJob *job,
float max_y = min_y + bounds->size.height;
guint16 color[4] = { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO };
- gsk_ngl_render_job_draw_coords (job,
- min_x, min_y, max_x, max_y,
- 0, 1, 1, 0,
- color);
+ gsk_gl_render_job_draw_coords (job,
+ min_x, min_y, max_x, max_y,
+ 0, 1, 1, 0,
+ color);
}
static inline void
-gsk_ngl_render_job_begin_draw (GskNglRenderJob *job,
- GskNglProgram *program)
+gsk_gl_render_job_begin_draw (GskGLRenderJob *job,
+ GskGLProgram *program)
{
job->current_program = program;
- gsk_ngl_command_queue_begin_draw (job->command_queue,
- program->program_info,
- job->viewport.size.width,
- job->viewport.size.height);
-
- gsk_ngl_uniform_state_set4fv (program->uniforms,
- program->program_info,
- UNIFORM_SHARED_VIEWPORT,
- job->driver->stamps[UNIFORM_SHARED_VIEWPORT],
- 1,
- (const float *)&job->viewport);
-
- gsk_ngl_uniform_state_set_matrix (program->uniforms,
- program->program_info,
- UNIFORM_SHARED_MODELVIEW,
- job->driver->stamps[UNIFORM_SHARED_MODELVIEW],
- &job->current_modelview->matrix);
-
- gsk_ngl_uniform_state_set_matrix (program->uniforms,
- program->program_info,
- UNIFORM_SHARED_PROJECTION,
- job->driver->stamps[UNIFORM_SHARED_PROJECTION],
- &job->projection);
-
- gsk_ngl_uniform_state_set_rounded_rect (program->uniforms,
- program->program_info,
- UNIFORM_SHARED_CLIP_RECT,
- job->driver->stamps[UNIFORM_SHARED_CLIP_RECT],
- &job->current_clip->rect);
+ gsk_gl_command_queue_begin_draw (job->command_queue,
+ program->program_info,
+ job->viewport.size.width,
+ job->viewport.size.height);
- gsk_ngl_uniform_state_set1f (program->uniforms,
+ gsk_gl_uniform_state_set4fv (program->uniforms,
program->program_info,
- UNIFORM_SHARED_ALPHA,
- job->driver->stamps[UNIFORM_SHARED_ALPHA],
- job->alpha);
+ UNIFORM_SHARED_VIEWPORT,
+ job->driver->stamps[UNIFORM_SHARED_VIEWPORT],
+ 1,
+ (const float *)&job->viewport);
+
+ gsk_gl_uniform_state_set_matrix (program->uniforms,
+ program->program_info,
+ UNIFORM_SHARED_MODELVIEW,
+ job->driver->stamps[UNIFORM_SHARED_MODELVIEW],
+ &job->current_modelview->matrix);
+
+ gsk_gl_uniform_state_set_matrix (program->uniforms,
+ program->program_info,
+ UNIFORM_SHARED_PROJECTION,
+ job->driver->stamps[UNIFORM_SHARED_PROJECTION],
+ &job->projection);
+
+ gsk_gl_uniform_state_set_rounded_rect (program->uniforms,
+ program->program_info,
+ UNIFORM_SHARED_CLIP_RECT,
+ job->driver->stamps[UNIFORM_SHARED_CLIP_RECT],
+ &job->current_clip->rect);
+
+ gsk_gl_uniform_state_set1f (program->uniforms,
+ program->program_info,
+ UNIFORM_SHARED_ALPHA,
+ job->driver->stamps[UNIFORM_SHARED_ALPHA],
+ job->alpha);
}
#define CHOOSE_PROGRAM(job,name) \
@@ -1118,22 +1118,22 @@ gsk_ngl_render_job_begin_draw (GskNglRenderJob *job,
: job->driver->name))
static inline void
-gsk_ngl_render_job_split_draw (GskNglRenderJob *job)
+gsk_gl_render_job_split_draw (GskGLRenderJob *job)
{
- gsk_ngl_command_queue_split_draw (job->command_queue);
+ gsk_gl_command_queue_split_draw (job->command_queue);
}
static inline void
-gsk_ngl_render_job_end_draw (GskNglRenderJob *job)
+gsk_gl_render_job_end_draw (GskGLRenderJob *job)
{
- gsk_ngl_command_queue_end_draw (job->command_queue);
+ gsk_gl_command_queue_end_draw (job->command_queue);
job->current_program = NULL;
}
static inline void
-gsk_ngl_render_job_visit_as_fallback (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_as_fallback (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
float scale_x = job->scale_x;
float scale_y = job->scale_y;
@@ -1156,16 +1156,16 @@ gsk_ngl_render_job_visit_as_fallback (GskNglRenderJob *job,
key.scale_y = scale_y;
key.filter = GL_NEAREST;
- cached_id = gsk_ngl_driver_lookup_texture (job->driver, &key);
+ cached_id = gsk_gl_driver_lookup_texture (job->driver, &key);
if (cached_id != 0)
{
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D, GL_TEXTURE0, cached_id);
- gsk_ngl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D, GL_TEXTURE0, cached_id);
+ gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
+ gsk_gl_render_job_end_draw (job);
return;
}
@@ -1224,8 +1224,8 @@ gsk_ngl_render_job_visit_as_fallback (GskNglRenderJob *job,
/* Create texture to upload */
texture = gdk_texture_new_for_surface (surface);
- texture_id = gsk_ngl_driver_load_texture (job->driver, texture,
- GL_NEAREST, GL_NEAREST);
+ texture_id = gsk_gl_driver_load_texture (job->driver, texture,
+ GL_NEAREST, GL_NEAREST);
if (gdk_gl_context_has_debug (job->command_queue->context))
gdk_gl_context_label_object_printf (job->command_queue->context, GL_TEXTURE, texture_id,
@@ -1237,29 +1237,29 @@ gsk_ngl_render_job_visit_as_fallback (GskNglRenderJob *job,
cairo_surface_destroy (surface);
cairo_surface_destroy (rendered_surface);
- gsk_ngl_driver_cache_texture (job->driver, &key, texture_id);
+ gsk_gl_driver_cache_texture (job->driver, &key, texture_id);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- texture_id);
- gsk_ngl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ texture_id);
+ gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
+ gsk_gl_render_job_end_draw (job);
}
static guint
-blur_offscreen (GskNglRenderJob *job,
- GskNglRenderOffscreen *offscreen,
+blur_offscreen (GskGLRenderJob *job,
+ GskGLRenderOffscreen *offscreen,
int texture_to_blur_width,
int texture_to_blur_height,
float blur_radius_x,
float blur_radius_y)
{
const GskRoundedRect new_clip = GSK_ROUNDED_RECT_INIT (0, 0, texture_to_blur_width,
texture_to_blur_height);
- GskNglRenderTarget *pass1;
- GskNglRenderTarget *pass2;
+ GskGLRenderTarget *pass1;
+ GskGLRenderTarget *pass2;
graphene_matrix_t prev_projection;
graphene_rect_t prev_viewport;
guint prev_fbo;
@@ -1270,100 +1270,100 @@ blur_offscreen (GskNglRenderJob *job,
g_assert (offscreen->area.x2 > offscreen->area.x);
g_assert (offscreen->area.y2 > offscreen->area.y);
- if (!gsk_ngl_driver_create_render_target (job->driver,
- MAX (texture_to_blur_width, 1),
- MAX (texture_to_blur_height, 1),
- job->target_format,
- GL_NEAREST, GL_NEAREST,
- &pass1))
+ if (!gsk_gl_driver_create_render_target (job->driver,
+ MAX (texture_to_blur_width, 1),
+ MAX (texture_to_blur_height, 1),
+ job->target_format,
+ GL_NEAREST, GL_NEAREST,
+ &pass1))
return 0;
if (texture_to_blur_width <= 0 || texture_to_blur_height <= 0)
- return gsk_ngl_driver_release_render_target (job->driver, pass1, FALSE);
+ return gsk_gl_driver_release_render_target (job->driver, pass1, FALSE);
- if (!gsk_ngl_driver_create_render_target (job->driver,
- texture_to_blur_width,
- texture_to_blur_height,
- job->target_format,
- GL_NEAREST, GL_NEAREST,
- &pass2))
- return gsk_ngl_driver_release_render_target (job->driver, pass1, FALSE);
+ if (!gsk_gl_driver_create_render_target (job->driver,
+ texture_to_blur_width,
+ texture_to_blur_height,
+ job->target_format,
+ GL_NEAREST, GL_NEAREST,
+ &pass2))
+ return gsk_gl_driver_release_render_target (job->driver, pass1, FALSE);
- gsk_ngl_render_job_set_viewport (job, &new_clip.bounds, &prev_viewport);
- gsk_ngl_render_job_set_projection_from_rect (job, &new_clip.bounds, &prev_projection);
- gsk_ngl_render_job_set_modelview (job, NULL);
- gsk_ngl_render_job_push_clip (job, &new_clip);
+ gsk_gl_render_job_set_viewport (job, &new_clip.bounds, &prev_viewport);
+ gsk_gl_render_job_set_projection_from_rect (job, &new_clip.bounds, &prev_projection);
+ gsk_gl_render_job_set_modelview (job, NULL);
+ gsk_gl_render_job_push_clip (job, &new_clip);
/* Bind new framebuffer and clear it */
- prev_fbo = gsk_ngl_command_queue_bind_framebuffer (job->command_queue, pass1->framebuffer_id);
- gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
+ prev_fbo = gsk_gl_command_queue_bind_framebuffer (job->command_queue, pass1->framebuffer_id);
+ gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
/* Begin drawing the first horizontal pass, using offscreen as the
* source texture for the program.
*/
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blur));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen->texture_id);
- gsk_ngl_program_set_uniform1f (job->current_program,
- UNIFORM_BLUR_RADIUS, 0,
- blur_radius_x);
- gsk_ngl_program_set_uniform2f (job->current_program,
- UNIFORM_BLUR_SIZE, 0,
- texture_to_blur_width,
- texture_to_blur_height);
- gsk_ngl_program_set_uniform2f (job->current_program,
- UNIFORM_BLUR_DIR, 0,
- 1, 0);
- gsk_ngl_render_job_draw_coords (job,
- 0, 0, texture_to_blur_width, texture_to_blur_height,
- 0, 1, 1, 0,
- (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blur));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen->texture_id);
+ gsk_gl_program_set_uniform1f (job->current_program,
+ UNIFORM_BLUR_RADIUS, 0,
+ blur_radius_x);
+ gsk_gl_program_set_uniform2f (job->current_program,
+ UNIFORM_BLUR_SIZE, 0,
+ texture_to_blur_width,
+ texture_to_blur_height);
+ gsk_gl_program_set_uniform2f (job->current_program,
+ UNIFORM_BLUR_DIR, 0,
+ 1, 0);
+ gsk_gl_render_job_draw_coords (job,
+ 0, 0, texture_to_blur_width, texture_to_blur_height,
+ 0, 1, 1, 0,
+ (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
+ gsk_gl_render_job_end_draw (job);
/* Bind second pass framebuffer and clear it */
- gsk_ngl_command_queue_bind_framebuffer (job->command_queue, pass2->framebuffer_id);
- gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
+ gsk_gl_command_queue_bind_framebuffer (job->command_queue, pass2->framebuffer_id);
+ gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
/* Draw using blur program with first pass as source texture */
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blur));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- pass1->texture_id);
- gsk_ngl_program_set_uniform1f (job->current_program,
- UNIFORM_BLUR_RADIUS, 0,
- blur_radius_y);
- gsk_ngl_program_set_uniform2f (job->current_program,
- UNIFORM_BLUR_SIZE, 0,
- texture_to_blur_width,
- texture_to_blur_height);
- gsk_ngl_program_set_uniform2f (job->current_program,
- UNIFORM_BLUR_DIR, 0,
- 0, 1);
- gsk_ngl_render_job_draw_coords (job,
- 0, 0, texture_to_blur_width, texture_to_blur_height,
- 0, 1, 1, 0,
- (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
- gsk_ngl_render_job_end_draw (job);
-
- gsk_ngl_render_job_pop_modelview (job);
- gsk_ngl_render_job_pop_clip (job);
- gsk_ngl_render_job_set_viewport (job, &prev_viewport, NULL);
- gsk_ngl_render_job_set_projection (job, &prev_projection);
- gsk_ngl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
-
- gsk_ngl_driver_release_render_target (job->driver, pass1, TRUE);
-
- return gsk_ngl_driver_release_render_target (job->driver, pass2, FALSE);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blur));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ pass1->texture_id);
+ gsk_gl_program_set_uniform1f (job->current_program,
+ UNIFORM_BLUR_RADIUS, 0,
+ blur_radius_y);
+ gsk_gl_program_set_uniform2f (job->current_program,
+ UNIFORM_BLUR_SIZE, 0,
+ texture_to_blur_width,
+ texture_to_blur_height);
+ gsk_gl_program_set_uniform2f (job->current_program,
+ UNIFORM_BLUR_DIR, 0,
+ 0, 1);
+ gsk_gl_render_job_draw_coords (job,
+ 0, 0, texture_to_blur_width, texture_to_blur_height,
+ 0, 1, 1, 0,
+ (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
+ gsk_gl_render_job_end_draw (job);
+
+ gsk_gl_render_job_pop_modelview (job);
+ gsk_gl_render_job_pop_clip (job);
+ gsk_gl_render_job_set_viewport (job, &prev_viewport, NULL);
+ gsk_gl_render_job_set_projection (job, &prev_projection);
+ gsk_gl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
+
+ gsk_gl_driver_release_render_target (job->driver, pass1, TRUE);
+
+ return gsk_gl_driver_release_render_target (job->driver, pass2, FALSE);
}
static void
-blur_node (GskNglRenderJob *job,
- GskNglRenderOffscreen *offscreen,
+blur_node (GskGLRenderJob *job,
+ GskGLRenderOffscreen *offscreen,
const GskRenderNode *node,
float blur_radius,
float *min_x,
@@ -1395,7 +1395,7 @@ blur_node (GskNglRenderJob *job,
offscreen->reset_clip = TRUE;
offscreen->force_offscreen = TRUE;
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, node, offscreen))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, node, offscreen))
g_assert_not_reached ();
/* Ensure that we actually got a real texture_id */
@@ -1419,13 +1419,13 @@ blur_node (GskNglRenderJob *job,
#define ATLAS_SIZE 512
static inline void
-gsk_ngl_render_job_visit_color_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_color_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GdkRGBA *rgba;
guint16 color[4];
- GskNglProgram *program;
- GskNglCommandBatch *batch;
+ GskGLProgram *program;
+ GskGLCommandBatch *batch;
rgba = gsk_color_node_get_color (node);
if (RGBA_IS_CLEAR (rgba))
@@ -1437,17 +1437,17 @@ gsk_ngl_render_job_visit_color_node (GskNglRenderJob *job,
* rendering a solid color.
*/
program = CHOOSE_PROGRAM (job, coloring);
- batch = gsk_ngl_command_queue_get_batch (job->command_queue);
+ batch = gsk_gl_command_queue_get_batch (job->command_queue);
/* Limit the size, or we end up with a coordinate overflow somwhere. */
if (node->bounds.size.width < 300 &&
node->bounds.size.height < 300 &&
- batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW &&
+ batch->any.kind == GSK_GL_COMMAND_KIND_DRAW &&
batch->any.program == program->id)
{
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
- gsk_ngl_render_job_begin_draw (job, program);
+ gsk_gl_render_job_begin_draw (job, program);
/* The top left few pixels in our atlases are always
* solid white, so we can use it here, without
@@ -1459,24 +1459,24 @@ gsk_ngl_render_job_visit_color_node (GskNglRenderJob *job,
offscreen.area.x2 = 2.f / ATLAS_SIZE;
offscreen.area.y2 = 2.f / ATLAS_SIZE;
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &node->bounds,
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &node->bounds,
+ &offscreen,
+ color);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_end_draw (job);
}
else
{
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
- gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, color);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
+ gsk_gl_render_job_draw_rect_with_color (job, &node->bounds, color);
+ gsk_gl_render_job_end_draw (job);
}
}
static inline void
-gsk_ngl_render_job_visit_linear_gradient_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_linear_gradient_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskColorStop *stops = gsk_linear_gradient_node_get_color_stops (node, NULL);
const graphene_point_t *start = gsk_linear_gradient_node_get_start (node);
@@ -1490,27 +1490,27 @@ gsk_ngl_render_job_visit_linear_gradient_node (GskNglRenderJob *job,
g_assert (n_color_stops < MAX_GRADIENT_STOPS);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, linear_gradient));
- gsk_ngl_program_set_uniform1i (job->current_program,
- UNIFORM_LINEAR_GRADIENT_NUM_COLOR_STOPS, 0,
- n_color_stops);
- gsk_ngl_program_set_uniform1fv (job->current_program,
- UNIFORM_LINEAR_GRADIENT_COLOR_STOPS, 0,
- n_color_stops * 5,
- (const float *)stops);
- gsk_ngl_program_set_uniform4f (job->current_program,
- UNIFORM_LINEAR_GRADIENT_POINTS, 0,
- x1, y1, x2 - x1, y2 - y1);
- gsk_ngl_program_set_uniform1i (job->current_program,
- UNIFORM_LINEAR_GRADIENT_REPEAT, 0,
- repeat);
- gsk_ngl_render_job_draw_rect (job, &node->bounds);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, linear_gradient));
+ gsk_gl_program_set_uniform1i (job->current_program,
+ UNIFORM_LINEAR_GRADIENT_NUM_COLOR_STOPS, 0,
+ n_color_stops);
+ gsk_gl_program_set_uniform1fv (job->current_program,
+ UNIFORM_LINEAR_GRADIENT_COLOR_STOPS, 0,
+ n_color_stops * 5,
+ (const float *)stops);
+ gsk_gl_program_set_uniform4f (job->current_program,
+ UNIFORM_LINEAR_GRADIENT_POINTS, 0,
+ x1, y1, x2 - x1, y2 - y1);
+ gsk_gl_program_set_uniform1i (job->current_program,
+ UNIFORM_LINEAR_GRADIENT_REPEAT, 0,
+ repeat);
+ gsk_gl_render_job_draw_rect (job, &node->bounds);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_conic_gradient_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_conic_gradient_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
static const float scale = 0.5f * M_1_PI;
@@ -1522,27 +1522,27 @@ gsk_ngl_render_job_visit_conic_gradient_node (GskNglRenderJob *job,
g_assert (n_color_stops < MAX_GRADIENT_STOPS);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, conic_gradient));
- gsk_ngl_program_set_uniform1i (job->current_program,
- UNIFORM_CONIC_GRADIENT_NUM_COLOR_STOPS, 0,
- n_color_stops);
- gsk_ngl_program_set_uniform1fv (job->current_program,
- UNIFORM_CONIC_GRADIENT_COLOR_STOPS, 0,
- n_color_stops * 5,
- (const float *)stops);
- gsk_ngl_program_set_uniform4f (job->current_program,
- UNIFORM_CONIC_GRADIENT_GEOMETRY, 0,
- job->offset_x + center->x,
- job->offset_y + center->y,
- scale,
- bias);
- gsk_ngl_render_job_draw_rect (job, &node->bounds);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, conic_gradient));
+ gsk_gl_program_set_uniform1i (job->current_program,
+ UNIFORM_CONIC_GRADIENT_NUM_COLOR_STOPS, 0,
+ n_color_stops);
+ gsk_gl_program_set_uniform1fv (job->current_program,
+ UNIFORM_CONIC_GRADIENT_COLOR_STOPS, 0,
+ n_color_stops * 5,
+ (const float *)stops);
+ gsk_gl_program_set_uniform4f (job->current_program,
+ UNIFORM_CONIC_GRADIENT_GEOMETRY, 0,
+ job->offset_x + center->x,
+ job->offset_y + center->y,
+ scale,
+ bias);
+ gsk_gl_render_job_draw_rect (job, &node->bounds);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_radial_gradient_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_radial_gradient_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
int n_color_stops = gsk_radial_gradient_node_get_n_color_stops (node);
const GskColorStop *stops = gsk_radial_gradient_node_get_color_stops (node, NULL);
@@ -1557,39 +1557,39 @@ gsk_ngl_render_job_visit_radial_gradient_node (GskNglRenderJob *job,
g_assert (n_color_stops < MAX_GRADIENT_STOPS);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, radial_gradient));
- gsk_ngl_program_set_uniform1i (job->current_program,
- UNIFORM_RADIAL_GRADIENT_NUM_COLOR_STOPS, 0,
- n_color_stops);
- gsk_ngl_program_set_uniform1fv (job->current_program,
- UNIFORM_RADIAL_GRADIENT_COLOR_STOPS, 0,
- n_color_stops * 5,
- (const float *)stops);
- gsk_ngl_program_set_uniform1i (job->current_program,
- UNIFORM_RADIAL_GRADIENT_REPEAT, 0,
- repeat);
- gsk_ngl_program_set_uniform2f (job->current_program,
- UNIFORM_RADIAL_GRADIENT_RANGE, 0,
- scale, bias);
- gsk_ngl_program_set_uniform4f (job->current_program,
- UNIFORM_RADIAL_GRADIENT_GEOMETRY, 0,
- job->offset_x + center->x,
- job->offset_y + center->y,
- 1.0f / (hradius * job->scale_x),
- 1.0f / (vradius * job->scale_y));
- gsk_ngl_render_job_draw_rect (job, &node->bounds);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, radial_gradient));
+ gsk_gl_program_set_uniform1i (job->current_program,
+ UNIFORM_RADIAL_GRADIENT_NUM_COLOR_STOPS, 0,
+ n_color_stops);
+ gsk_gl_program_set_uniform1fv (job->current_program,
+ UNIFORM_RADIAL_GRADIENT_COLOR_STOPS, 0,
+ n_color_stops * 5,
+ (const float *)stops);
+ gsk_gl_program_set_uniform1i (job->current_program,
+ UNIFORM_RADIAL_GRADIENT_REPEAT, 0,
+ repeat);
+ gsk_gl_program_set_uniform2f (job->current_program,
+ UNIFORM_RADIAL_GRADIENT_RANGE, 0,
+ scale, bias);
+ gsk_gl_program_set_uniform4f (job->current_program,
+ UNIFORM_RADIAL_GRADIENT_GEOMETRY, 0,
+ job->offset_x + center->x,
+ job->offset_y + center->y,
+ 1.0f / (hradius * job->scale_x),
+ 1.0f / (vradius * job->scale_y));
+ gsk_gl_render_job_draw_rect (job, &node->bounds);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_clipped_child (GskNglRenderJob *job,
- const GskRenderNode *child,
- const graphene_rect_t *clip)
+gsk_gl_render_job_visit_clipped_child (GskGLRenderJob *job,
+ const GskRenderNode *child,
+ const graphene_rect_t *clip)
{
graphene_rect_t transformed_clip;
GskRoundedRect intersection;
- gsk_ngl_render_job_transform_bounds (job, clip, &transformed_clip);
+ gsk_gl_render_job_transform_bounds (job, clip, &transformed_clip);
if (job->current_clip->is_rectilinear)
{
@@ -1598,55 +1598,55 @@ gsk_ngl_render_job_visit_clipped_child (GskNglRenderJob *job,
&job->current_clip->rect.bounds,
&intersection.bounds);
- gsk_ngl_render_job_push_clip (job, &intersection);
- gsk_ngl_render_job_visit_node (job, child);
- gsk_ngl_render_job_pop_clip (job);
+ gsk_gl_render_job_push_clip (job, &intersection);
+ gsk_gl_render_job_visit_node (job, child);
+ gsk_gl_render_job_pop_clip (job);
}
else if (intersect_rounded_rectilinear (&transformed_clip,
&job->current_clip->rect,
&intersection))
{
- gsk_ngl_render_job_push_clip (job, &intersection);
- gsk_ngl_render_job_visit_node (job, child);
- gsk_ngl_render_job_pop_clip (job);
+ gsk_gl_render_job_push_clip (job, &intersection);
+ gsk_gl_render_job_visit_node (job, child);
+ gsk_gl_render_job_pop_clip (job);
}
else
{
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
offscreen.bounds = clip;
offscreen.force_offscreen = TRUE;
offscreen.reset_clip = TRUE;
offscreen.do_not_cache = TRUE;
- gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen);
+ gsk_gl_render_job_visit_node_with_offscreen (job, child, &offscreen);
g_assert (offscreen.texture_id);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
- gsk_ngl_render_job_draw_offscreen_rect (job, clip);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
+ gsk_gl_render_job_draw_offscreen_rect (job, clip);
+ gsk_gl_render_job_end_draw (job);
}
}
static inline void
-gsk_ngl_render_job_visit_clip_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_clip_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const graphene_rect_t *clip = gsk_clip_node_get_clip (node);
const GskRenderNode *child = gsk_clip_node_get_child (node);
- gsk_ngl_render_job_visit_clipped_child (job, child, clip);
+ gsk_gl_render_job_visit_clipped_child (job, child, clip);
}
static inline void
-gsk_ngl_render_job_visit_rounded_clip_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_rounded_clip_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRenderNode *child = gsk_rounded_clip_node_get_child (node);
const GskRoundedRect *clip = gsk_rounded_clip_node_get_clip (node);
@@ -1658,7 +1658,7 @@ gsk_ngl_render_job_visit_rounded_clip_node (GskNglRenderJob *job,
if (node_is_invisible (child))
return;
- gsk_ngl_render_job_transform_bounds (job, &clip->bounds, &transformed_clip.bounds);
+ gsk_gl_render_job_transform_bounds (job, &clip->bounds, &transformed_clip.bounds);
for (guint i = 0; i < G_N_ELEMENTS (transformed_clip.corner); i++)
{
@@ -1674,9 +1674,9 @@ gsk_ngl_render_job_visit_rounded_clip_node (GskNglRenderJob *job,
&transformed_clip,
&intersected_clip))
{
- gsk_ngl_render_job_push_clip (job, &intersected_clip);
- gsk_ngl_render_job_visit_node (job, child);
- gsk_ngl_render_job_pop_clip (job);
+ gsk_gl_render_job_push_clip (job, &intersected_clip);
+ gsk_gl_render_job_visit_node (job, child);
+ gsk_gl_render_job_pop_clip (job);
return;
}
}
@@ -1699,43 +1699,43 @@ gsk_ngl_render_job_visit_rounded_clip_node (GskNglRenderJob *job,
*/
if (rounded_inner_rect_contains_rect (&transformed_clip, &job->current_clip->rect.bounds))
{
- gsk_ngl_render_job_visit_node (job, child);
+ gsk_gl_render_job_visit_node (job, child);
return;
}
- gsk_ngl_render_job_push_clip (job, &transformed_clip);
- gsk_ngl_render_job_visit_node (job, child);
- gsk_ngl_render_job_pop_clip (job);
+ gsk_gl_render_job_push_clip (job, &transformed_clip);
+ gsk_gl_render_job_visit_node (job, child);
+ gsk_gl_render_job_pop_clip (job);
}
else
{
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
offscreen.bounds = &node->bounds;
offscreen.force_offscreen = TRUE;
offscreen.reset_clip = FALSE;
- gsk_ngl_render_job_push_clip (job, &transformed_clip);
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
+ gsk_gl_render_job_push_clip (job, &transformed_clip);
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, child, &offscreen))
g_assert_not_reached ();
- gsk_ngl_render_job_pop_clip (job);
+ gsk_gl_render_job_pop_clip (job);
g_assert (offscreen.texture_id);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
- gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
+ gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
+ gsk_gl_render_job_end_draw (job);
}
}
static inline void
-gsk_ngl_render_job_visit_rect_border_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_rect_border_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GdkRGBA *colors = gsk_border_node_get_colors (node);
const float *widths = gsk_border_node_get_widths (node);
@@ -1743,46 +1743,46 @@ gsk_ngl_render_job_visit_rect_border_node (GskNglRenderJob *job,
const graphene_size_t *size = &node->bounds.size;
guint16 color[4];
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
if (widths[0] > 0)
{
rgba_to_half (&colors[0], color);
- gsk_ngl_render_job_draw_rect_with_color (job,
- &GRAPHENE_RECT_INIT (origin->x, origin->y, size->width -
widths[1], widths[0]),
- color);
+ gsk_gl_render_job_draw_rect_with_color (job,
+ &GRAPHENE_RECT_INIT (origin->x, origin->y, size->width -
widths[1], widths[0]),
+ color);
}
if (widths[1] > 0)
{
rgba_to_half (&colors[1], color);
- gsk_ngl_render_job_draw_rect_with_color (job,
- &GRAPHENE_RECT_INIT (origin->x + size->width - widths[1],
origin->y, widths[1], size->height - widths[2]),
- color);
+ gsk_gl_render_job_draw_rect_with_color (job,
+ &GRAPHENE_RECT_INIT (origin->x + size->width - widths[1],
origin->y, widths[1], size->height - widths[2]),
+ color);
}
if (widths[2] > 0)
{
rgba_to_half (&colors[2], color);
- gsk_ngl_render_job_draw_rect_with_color (job,
- &GRAPHENE_RECT_INIT (origin->x + widths[3], origin->y +
size->height - widths[2], size->width - widths[3], widths[2]),
- color);
+ gsk_gl_render_job_draw_rect_with_color (job,
+ &GRAPHENE_RECT_INIT (origin->x + widths[3], origin->y +
size->height - widths[2], size->width - widths[3], widths[2]),
+ color);
}
if (widths[3] > 0)
{
rgba_to_half (&colors[3], color);
- gsk_ngl_render_job_draw_rect_with_color (job,
- &GRAPHENE_RECT_INIT (origin->x, origin->y + widths[0],
widths[3], size->height - widths[0]),
- color);
+ gsk_gl_render_job_draw_rect_with_color (job,
+ &GRAPHENE_RECT_INIT (origin->x, origin->y + widths[0],
widths[3], size->height - widths[0]),
+ color);
}
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_border_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRoundedRect *rounded_outline = gsk_border_node_get_outline (node);
const GdkRGBA *colors = gsk_border_node_get_colors (node);
@@ -1824,79 +1824,79 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
sizes[3].w = MAX (widths[3], rounded_outline->corner[3].width);
}
- gsk_ngl_render_job_transform_rounded_rect (job, rounded_outline, &outline);
+ gsk_gl_render_job_transform_rounded_rect (job, rounded_outline, &outline);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, border));
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, border));
- gsk_ngl_program_set_uniform4fv (job->current_program,
- UNIFORM_BORDER_WIDTHS, 0,
- 1,
- widths);
- gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
- UNIFORM_BORDER_OUTLINE_RECT, 0,
- &outline);
+ gsk_gl_program_set_uniform4fv (job->current_program,
+ UNIFORM_BORDER_WIDTHS, 0,
+ 1,
+ widths);
+ gsk_gl_program_set_uniform_rounded_rect (job->current_program,
+ UNIFORM_BORDER_OUTLINE_RECT, 0,
+ &outline);
if (widths[0] > 0)
{
- GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
+ GskGLDrawVertex *vertices = gsk_gl_command_queue_add_vertices (job->command_queue);
rgba_to_half (&colors[0], color);
- vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .uv = { 0,
1 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[1] = (GskNglDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 0,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[2] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { 1,
1 }, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[0] = (GskGLDrawVertex) { .position = { min_x, min_y }, .uv = { 0, 1
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[1] = (GskGLDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 0, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[2] = (GskGLDrawVertex) { .position = { max_x, min_y }, .uv = { 1, 1
}, .color = { color[0], color[1], color[2], color[3] } };
- vertices[3] = (GskNglDrawVertex) { .position = { max_x - sizes[1].w, min_y + sizes[1].h }, .uv = { 1,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[4] = (GskNglDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 0,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[5] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { 1,
1 }, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[3] = (GskGLDrawVertex) { .position = { max_x - sizes[1].w, min_y + sizes[1].h }, .uv = { 1, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[4] = (GskGLDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 0, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[5] = (GskGLDrawVertex) { .position = { max_x, min_y }, .uv = { 1, 1
}, .color = { color[0], color[1], color[2], color[3] } };
}
if (widths[1] > 0)
{
- GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
+ GskGLDrawVertex *vertices = gsk_gl_command_queue_add_vertices (job->command_queue);
rgba_to_half (&colors[1], color);
- vertices[0] = (GskNglDrawVertex) { .position = { max_x - sizes[1].w, min_y + sizes[1].h }, .uv = { 0,
1 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[1] = (GskNglDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 0,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[2] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { 1,
1 }, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[0] = (GskGLDrawVertex) { .position = { max_x - sizes[1].w, min_y + sizes[1].h }, .uv = { 0, 1
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[1] = (GskGLDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 0, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[2] = (GskGLDrawVertex) { .position = { max_x, min_y }, .uv = { 1, 1
}, .color = { color[0], color[1], color[2], color[3] } };
- vertices[3] = (GskNglDrawVertex) { .position = { max_x, max_y }, .uv = { 1,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[4] = (GskNglDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 0,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[5] = (GskNglDrawVertex) { .position = { max_x, min_y }, .uv = { 1,
1 }, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[3] = (GskGLDrawVertex) { .position = { max_x, max_y }, .uv = { 1, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[4] = (GskGLDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 0, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[5] = (GskGLDrawVertex) { .position = { max_x, min_y }, .uv = { 1, 1
}, .color = { color[0], color[1], color[2], color[3] } };
}
if (widths[2] > 0)
{
- GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
+ GskGLDrawVertex *vertices = gsk_gl_command_queue_add_vertices (job->command_queue);
rgba_to_half (&colors[2], color);
- vertices[0] = (GskNglDrawVertex) { .position = { min_x + sizes[3].w, max_y - sizes[3].h }, .uv = { 0,
1 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[1] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { 0,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[2] = (GskNglDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 1,
1 }, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[0] = (GskGLDrawVertex) { .position = { min_x + sizes[3].w, max_y - sizes[3].h }, .uv = { 0, 1
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[1] = (GskGLDrawVertex) { .position = { min_x, max_y }, .uv = { 0, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[2] = (GskGLDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 1, 1
}, .color = { color[0], color[1], color[2], color[3] } };
- vertices[3] = (GskNglDrawVertex) { .position = { max_x, max_y }, .uv = { 1,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[4] = (GskNglDrawVertex) { .position = { min_x , max_y }, .uv = { 0,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[5] = (GskNglDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 1,
1 }, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[3] = (GskGLDrawVertex) { .position = { max_x, max_y }, .uv = { 1, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[4] = (GskGLDrawVertex) { .position = { min_x , max_y }, .uv = { 0, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[5] = (GskGLDrawVertex) { .position = { max_x - sizes[2].w, max_y - sizes[2].h }, .uv = { 1, 1
}, .color = { color[0], color[1], color[2], color[3] } };
}
if (widths[3] > 0)
{
- GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
+ GskGLDrawVertex *vertices = gsk_gl_command_queue_add_vertices (job->command_queue);
rgba_to_half (&colors[3], color);
- vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .uv = { 0,
1 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[1] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { 0,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[2] = (GskNglDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 1,
1 }, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[0] = (GskGLDrawVertex) { .position = { min_x, min_y }, .uv = { 0, 1
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[1] = (GskGLDrawVertex) { .position = { min_x, max_y }, .uv = { 0, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[2] = (GskGLDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 1, 1
}, .color = { color[0], color[1], color[2], color[3] } };
- vertices[3] = (GskNglDrawVertex) { .position = { min_x + sizes[3].w, max_y - sizes[3].h }, .uv = { 1,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[4] = (GskNglDrawVertex) { .position = { min_x, max_y }, .uv = { 0,
0 }, .color = { color[0], color[1], color[2], color[3] } };
- vertices[5] = (GskNglDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 1,
1 }, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[3] = (GskGLDrawVertex) { .position = { min_x + sizes[3].w, max_y - sizes[3].h }, .uv = { 1, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[4] = (GskGLDrawVertex) { .position = { min_x, max_y }, .uv = { 0, 0
}, .color = { color[0], color[1], color[2], color[3] } };
+ vertices[5] = (GskGLDrawVertex) { .position = { min_x + sizes[0].w, min_y + sizes[0].h }, .uv = { 1, 1
}, .color = { color[0], color[1], color[2], color[3] } };
}
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_end_draw (job);
}
/* A special case for a pattern that occurs frequently with CSS
@@ -1906,9 +1906,9 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
* this using the filled_border shader.
*/
static void
-gsk_ngl_render_job_visit_css_background (GskNglRenderJob *job,
- const GskRenderNode *node,
- const GskRenderNode *node2)
+gsk_gl_render_job_visit_css_background (GskGLRenderJob *job,
+ const GskRenderNode *node,
+ const GskRenderNode *node2)
{
const GskRenderNode *child = gsk_rounded_clip_node_get_child (node);
const GskRoundedRect *rounded_outline = gsk_border_node_get_outline (node2);
@@ -1918,7 +1918,7 @@ gsk_ngl_render_job_visit_css_background (GskNglRenderJob *job,
float max_x = min_x + node2->bounds.size.width;
float max_y = min_y + node2->bounds.size.height;
GskRoundedRect outline;
- GskNglDrawVertex *vertices;
+ GskGLDrawVertex *vertices;
guint16 color[4];
guint16 color2[4];
@@ -1928,28 +1928,28 @@ gsk_ngl_render_job_visit_css_background (GskNglRenderJob *job,
rgba_to_half (&gsk_border_node_get_colors (node2)[0], color);
rgba_to_half (gsk_color_node_get_color (child), color2);
- gsk_ngl_render_job_transform_rounded_rect (job, rounded_outline, &outline);
+ gsk_gl_render_job_transform_rounded_rect (job, rounded_outline, &outline);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, filled_border));
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, filled_border));
- gsk_ngl_program_set_uniform4fv (job->current_program,
- UNIFORM_FILLED_BORDER_WIDTHS, 0,
- 1,
- widths);
- gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
- UNIFORM_FILLED_BORDER_OUTLINE_RECT, 0,
- &outline);
+ gsk_gl_program_set_uniform4fv (job->current_program,
+ UNIFORM_FILLED_BORDER_WIDTHS, 0,
+ 1,
+ widths);
+ gsk_gl_program_set_uniform_rounded_rect (job->current_program,
+ UNIFORM_FILLED_BORDER_OUTLINE_RECT, 0,
+ &outline);
- vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
+ vertices = gsk_gl_command_queue_add_vertices (job->command_queue);
- vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
- vertices[1] = (GskNglDrawVertex) { .position = { min_x, max_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
- vertices[2] = (GskNglDrawVertex) { .position = { max_x, min_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
- vertices[3] = (GskNglDrawVertex) { .position = { max_x, max_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
- vertices[4] = (GskNglDrawVertex) { .position = { min_x, max_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
- vertices[5] = (GskNglDrawVertex) { .position = { max_x, min_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
+ vertices[0] = (GskGLDrawVertex) { .position = { min_x, min_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
+ vertices[1] = (GskGLDrawVertex) { .position = { min_x, max_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
+ vertices[2] = (GskGLDrawVertex) { .position = { max_x, min_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
+ vertices[3] = (GskGLDrawVertex) { .position = { max_x, max_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
+ vertices[4] = (GskGLDrawVertex) { .position = { min_x, max_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
+ vertices[5] = (GskGLDrawVertex) { .position = { max_x, min_y }, .color = { color[0], color[1], color[2],
color[3] }, .color2 = { color2[0], color2[1], color2[2], color2[3] } };
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_end_draw (job);
}
/* Returns TRUE if applying @transform to @bounds
@@ -1984,8 +1984,8 @@ result_is_axis_aligned (GskTransform *transform,
}
static inline void
-gsk_ngl_render_job_visit_transform_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_transform_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
GskTransform *transform = gsk_transform_node_get_transform (node);
const GskTransformCategory category = gsk_transform_get_category (transform);
@@ -1994,7 +1994,7 @@ gsk_ngl_render_job_visit_transform_node (GskNglRenderJob *job,
switch (category)
{
case GSK_TRANSFORM_CATEGORY_IDENTITY:
- gsk_ngl_render_job_visit_node (job, child);
+ gsk_gl_render_job_visit_node (job, child);
break;
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
@@ -2002,17 +2002,17 @@ gsk_ngl_render_job_visit_transform_node (GskNglRenderJob *job,
float dx, dy;
gsk_transform_node_get_translate (node, &dx, &dy);
- gsk_ngl_render_job_offset (job, dx, dy);
- gsk_ngl_render_job_visit_node (job, child);
- gsk_ngl_render_job_offset (job, -dx, -dy);
+ gsk_gl_render_job_offset (job, dx, dy);
+ gsk_gl_render_job_visit_node (job, child);
+ gsk_gl_render_job_offset (job, -dx, -dy);
}
break;
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
{
- gsk_ngl_render_job_push_modelview (job, transform);
- gsk_ngl_render_job_visit_node (job, child);
- gsk_ngl_render_job_pop_modelview (job);
+ gsk_gl_render_job_push_modelview (job, transform);
+ gsk_gl_render_job_visit_node (job, child);
+ gsk_gl_render_job_pop_modelview (job);
}
break;
@@ -2022,13 +2022,13 @@ gsk_ngl_render_job_visit_transform_node (GskNglRenderJob *job,
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
if (node_supports_transform (child))
{
- gsk_ngl_render_job_push_modelview (job, transform);
- gsk_ngl_render_job_visit_node (job, child);
- gsk_ngl_render_job_pop_modelview (job);
+ gsk_gl_render_job_push_modelview (job, transform);
+ gsk_gl_render_job_visit_node (job, child);
+ gsk_gl_render_job_pop_modelview (job);
}
else
{
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
float sx = 1, sy = 1;
offscreen.bounds = &child->bounds;
@@ -2058,36 +2058,36 @@ gsk_ngl_render_job_visit_transform_node (GskNglRenderJob *job,
GskTransform *scale;
scale = gsk_transform_translate (gsk_transform_scale (NULL, sx, sy), &GRAPHENE_POINT_INIT
(tx, ty));
- gsk_ngl_render_job_push_modelview (job, scale);
+ gsk_gl_render_job_push_modelview (job, scale);
transform = gsk_transform_transform (gsk_transform_invert (scale), transform);
}
}
- if (gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
+ if (gsk_gl_render_job_visit_node_with_offscreen (job, child, &offscreen))
{
/* For non-trivial transforms, we draw everything on a texture and then
* draw the texture transformed. */
if (transform)
- gsk_ngl_render_job_push_modelview (job, transform);
+ gsk_gl_render_job_push_modelview (job, transform);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
- gsk_ngl_render_job_draw_offscreen (job, &child->bounds, &offscreen);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
+ gsk_gl_render_job_draw_offscreen (job, &child->bounds, &offscreen);
+ gsk_gl_render_job_end_draw (job);
if (transform)
- gsk_ngl_render_job_pop_modelview (job);
+ gsk_gl_render_job_pop_modelview (job);
}
if (category == GSK_TRANSFORM_CATEGORY_2D)
{
if (sx != 1 || sy != 1)
{
- gsk_ngl_render_job_pop_modelview (job);
+ gsk_gl_render_job_pop_modelview (job);
gsk_transform_unref (transform);
}
}
@@ -2100,34 +2100,34 @@ gsk_ngl_render_job_visit_transform_node (GskNglRenderJob *job,
}
static inline void
-gsk_ngl_render_job_visit_unblurred_inset_shadow_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_unblurred_inset_shadow_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRoundedRect *outline = gsk_inset_shadow_node_get_outline (node);
GskRoundedRect transformed_outline;
guint16 color[4];
- gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
-
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
- gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
- UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
- &transformed_outline);
- gsk_ngl_program_set_uniform1f (job->current_program,
- UNIFORM_INSET_SHADOW_SPREAD, 0,
- gsk_inset_shadow_node_get_spread (node));
- gsk_ngl_program_set_uniform2f (job->current_program,
- UNIFORM_INSET_SHADOW_OFFSET, 0,
- gsk_inset_shadow_node_get_dx (node),
- gsk_inset_shadow_node_get_dy (node));
+ gsk_gl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
+
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
+ gsk_gl_program_set_uniform_rounded_rect (job->current_program,
+ UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
+ &transformed_outline);
+ gsk_gl_program_set_uniform1f (job->current_program,
+ UNIFORM_INSET_SHADOW_SPREAD, 0,
+ gsk_inset_shadow_node_get_spread (node));
+ gsk_gl_program_set_uniform2f (job->current_program,
+ UNIFORM_INSET_SHADOW_OFFSET, 0,
+ gsk_inset_shadow_node_get_dx (node),
+ gsk_inset_shadow_node_get_dy (node));
rgba_to_half (gsk_inset_shadow_node_get_color (node), color);
- gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, color);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_draw_rect_with_color (job, &node->bounds, color);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_blurred_inset_shadow_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRoundedRect *node_outline = gsk_inset_shadow_node_get_outline (node);
float blur_radius = gsk_inset_shadow_node_get_blur_radius (node);
@@ -2141,7 +2141,7 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
float texture_height;
int blurred_texture_id;
GskTextureKey key;
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
guint16 color[4];
g_assert (blur_radius > 0);
@@ -2155,14 +2155,14 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
key.scale_y = scale_y;
key.filter = GL_NEAREST;
- blurred_texture_id = gsk_ngl_driver_lookup_texture (job->driver, &key);
+ blurred_texture_id = gsk_gl_driver_lookup_texture (job->driver, &key);
if (blurred_texture_id == 0)
{
float spread = gsk_inset_shadow_node_get_spread (node) + half_blur_extra;
GskRoundedRect transformed_outline;
GskRoundedRect outline_to_blur;
- GskNglRenderTarget *render_target;
+ GskGLRenderTarget *render_target;
graphene_matrix_t prev_projection;
graphene_rect_t prev_viewport;
guint prev_fbo;
@@ -2194,46 +2194,46 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
outline_to_blur.corner[i].height *= scale_y;
}
- if (!gsk_ngl_driver_create_render_target (job->driver,
- texture_width, texture_height,
- get_target_format (job, node),
- GL_NEAREST, GL_NEAREST,
- &render_target))
+ if (!gsk_gl_driver_create_render_target (job->driver,
+ texture_width, texture_height,
+ get_target_format (job, node),
+ GL_NEAREST, GL_NEAREST,
+ &render_target))
g_assert_not_reached ();
- gsk_ngl_render_job_set_viewport_for_size (job, texture_width, texture_height, &prev_viewport);
- gsk_ngl_render_job_set_projection_for_size (job, texture_width, texture_height, &prev_projection);
- gsk_ngl_render_job_set_modelview (job, NULL);
- gsk_ngl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT (0, 0, texture_width, texture_height));
+ gsk_gl_render_job_set_viewport_for_size (job, texture_width, texture_height, &prev_viewport);
+ gsk_gl_render_job_set_projection_for_size (job, texture_width, texture_height, &prev_projection);
+ gsk_gl_render_job_set_modelview (job, NULL);
+ gsk_gl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT (0, 0, texture_width, texture_height));
- prev_fbo = gsk_ngl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
- gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
+ prev_fbo = gsk_gl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
+ gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
- gsk_ngl_render_job_transform_rounded_rect (job, &outline_to_blur, &transformed_outline);
+ gsk_gl_render_job_transform_rounded_rect (job, &outline_to_blur, &transformed_outline);
/* Actual inset shadow outline drawing */
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
- gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
- UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
- &transformed_outline);
- gsk_ngl_program_set_uniform1f (job->current_program,
- UNIFORM_INSET_SHADOW_SPREAD, 0,
- spread * MAX (scale_x, scale_y));
- gsk_ngl_program_set_uniform2f (job->current_program,
- UNIFORM_INSET_SHADOW_OFFSET, 0,
- offset_x * scale_x,
- offset_y * scale_y);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
+ gsk_gl_program_set_uniform_rounded_rect (job->current_program,
+ UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
+ &transformed_outline);
+ gsk_gl_program_set_uniform1f (job->current_program,
+ UNIFORM_INSET_SHADOW_SPREAD, 0,
+ spread * MAX (scale_x, scale_y));
+ gsk_gl_program_set_uniform2f (job->current_program,
+ UNIFORM_INSET_SHADOW_OFFSET, 0,
+ offset_x * scale_x,
+ offset_y * scale_y);
rgba_to_half (gsk_inset_shadow_node_get_color (node), color);
- gsk_ngl_render_job_draw_with_color (job,
- 0, 0, texture_width, texture_height,
- color);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_draw_with_color (job,
+ 0, 0, texture_width, texture_height,
+ color);
+ gsk_gl_render_job_end_draw (job);
- gsk_ngl_render_job_pop_modelview (job);
- gsk_ngl_render_job_pop_clip (job);
- gsk_ngl_render_job_set_projection (job, &prev_projection);
- gsk_ngl_render_job_set_viewport (job, &prev_viewport, NULL);
- gsk_ngl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
+ gsk_gl_render_job_pop_modelview (job);
+ gsk_gl_render_job_pop_clip (job);
+ gsk_gl_render_job_set_projection (job, &prev_projection);
+ gsk_gl_render_job_set_viewport (job, &prev_viewport, NULL);
+ gsk_gl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
offscreen.texture_id = render_target->texture_id;
init_full_texture_region (&offscreen);
@@ -2245,9 +2245,9 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
blur_radius * scale_x,
blur_radius * scale_y);
- gsk_ngl_driver_release_render_target (job->driver, render_target, TRUE);
+ gsk_gl_driver_release_render_target (job->driver, render_target, TRUE);
- gsk_ngl_driver_cache_texture (job->driver, &key, blurred_texture_id);
+ gsk_gl_driver_cache_texture (job->driver, &key, blurred_texture_id);
}
g_assert (blurred_texture_id != 0);
@@ -2265,7 +2265,7 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
{
GskRoundedRect node_clip;
- gsk_ngl_render_job_transform_bounds (job, &node_outline->bounds, &node_clip.bounds);
+ gsk_gl_render_job_transform_bounds (job, &node_outline->bounds, &node_clip.bounds);
for (guint i = 0; i < 4; i ++)
{
@@ -2273,7 +2273,7 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
node_clip.corner[i].height = node_outline->corner[i].height * scale_y;
}
- gsk_ngl_render_job_push_clip (job, &node_clip);
+ gsk_gl_render_job_push_clip (job, &node_clip);
}
offscreen.was_offscreen = TRUE;
@@ -2282,23 +2282,23 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
offscreen.area.x2 = tx2;
offscreen.area.y2 = ty2;
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- blurred_texture_id);
- gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ blurred_texture_id);
+ gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
+ gsk_gl_render_job_end_draw (job);
if (needs_clip)
- gsk_ngl_render_job_pop_clip (job);
+ gsk_gl_render_job_pop_clip (job);
}
}
static inline void
-gsk_ngl_render_job_visit_unblurred_outset_shadow_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_unblurred_outset_shadow_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRoundedRect *outline = gsk_outset_shadow_node_get_outline (node);
GskRoundedRect transformed_outline;
@@ -2322,67 +2322,67 @@ gsk_ngl_render_job_visit_unblurred_outset_shadow_node (GskNglRenderJob *job,
rgba_to_half (gsk_outset_shadow_node_get_color (node), color);
- gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
+ gsk_gl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, unblurred_outset_shadow));
- gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
- UNIFORM_UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, 0,
- &transformed_outline);
- gsk_ngl_program_set_uniform1f (job->current_program,
- UNIFORM_UNBLURRED_OUTSET_SHADOW_SPREAD, 0,
- spread);
- gsk_ngl_program_set_uniform2f (job->current_program,
- UNIFORM_UNBLURRED_OUTSET_SHADOW_OFFSET, 0,
- dx, dy);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, unblurred_outset_shadow));
+ gsk_gl_program_set_uniform_rounded_rect (job->current_program,
+ UNIFORM_UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, 0,
+ &transformed_outline);
+ gsk_gl_program_set_uniform1f (job->current_program,
+ UNIFORM_UNBLURRED_OUTSET_SHADOW_SPREAD, 0,
+ spread);
+ gsk_gl_program_set_uniform2f (job->current_program,
+ UNIFORM_UNBLURRED_OUTSET_SHADOW_OFFSET, 0,
+ dx, dy);
/* Corners... */
if (corner_sizes[0][0] > 0 && corner_sizes[0][1] > 0) /* Top left */
- gsk_ngl_render_job_draw_with_color (job,
- x, y, corner_sizes[0][0], corner_sizes[0][1],
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ x, y, corner_sizes[0][0], corner_sizes[0][1],
+ color);
if (corner_sizes[1][0] > 0 && corner_sizes[1][1] > 0) /* Top right */
- gsk_ngl_render_job_draw_with_color (job,
- x + w - corner_sizes[1][0], y,
- corner_sizes[1][0], corner_sizes[1][1],
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ x + w - corner_sizes[1][0], y,
+ corner_sizes[1][0], corner_sizes[1][1],
+ color);
if (corner_sizes[2][0] > 0 && corner_sizes[2][1] > 0) /* Bottom right */
- gsk_ngl_render_job_draw_with_color (job,
- x + w - corner_sizes[2][0], y + h - corner_sizes[2][1],
- corner_sizes[2][0], corner_sizes[2][1],
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ x + w - corner_sizes[2][0], y + h - corner_sizes[2][1],
+ corner_sizes[2][0], corner_sizes[2][1],
+ color);
if (corner_sizes[3][0] > 0 && corner_sizes[3][1] > 0) /* Bottom left */
- gsk_ngl_render_job_draw_with_color (job,
- x, y + h - corner_sizes[3][1],
- corner_sizes[3][0], corner_sizes[3][1],
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ x, y + h - corner_sizes[3][1],
+ corner_sizes[3][0], corner_sizes[3][1],
+ color);
/* Edges... */;
if (edge_sizes[0] > 0) /* Top */
- gsk_ngl_render_job_draw_with_color (job,
- x + corner_sizes[0][0], y,
- w - corner_sizes[0][0] - corner_sizes[1][0], edge_sizes[0],
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ x + corner_sizes[0][0], y,
+ w - corner_sizes[0][0] - corner_sizes[1][0], edge_sizes[0],
+ color);
if (edge_sizes[1] > 0) /* Right */
- gsk_ngl_render_job_draw_with_color (job,
- x + w - edge_sizes[1], y + corner_sizes[1][1],
- edge_sizes[1], h - corner_sizes[1][1] - corner_sizes[2][1],
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ x + w - edge_sizes[1], y + corner_sizes[1][1],
+ edge_sizes[1], h - corner_sizes[1][1] - corner_sizes[2][1],
+ color);
if (edge_sizes[2] > 0) /* Bottom */
- gsk_ngl_render_job_draw_with_color (job,
- x + corner_sizes[3][0], y + h - edge_sizes[2],
- w - corner_sizes[3][0] - corner_sizes[2][0], edge_sizes[2],
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ x + corner_sizes[3][0], y + h - edge_sizes[2],
+ w - corner_sizes[3][0] - corner_sizes[2][0], edge_sizes[2],
+ color);
if (edge_sizes[3] > 0) /* Left */
- gsk_ngl_render_job_draw_with_color (job,
- x, y + corner_sizes[0][1],
- edge_sizes[3], h - corner_sizes[0][1] - corner_sizes[3][1],
- color);
+ gsk_gl_render_job_draw_with_color (job,
+ x, y + corner_sizes[0][1],
+ edge_sizes[3], h - corner_sizes[0][1] - corner_sizes[3][1],
+ color);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRoundedRect *outline = gsk_outset_shadow_node_get_outline (node);
float scale_x = job->scale_x;
@@ -2397,7 +2397,7 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
float dy = gsk_outset_shadow_node_get_dy (node);
GskRoundedRect scaled_outline;
GskRoundedRect transformed_outline;
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
int texture_width, texture_height;
int blurred_texture_id;
int cached_tid;
@@ -2455,21 +2455,21 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
scaled_outline.corner[i].height *= scale_y;
}
- cached_tid = gsk_ngl_shadow_library_lookup (job->driver->shadows, &scaled_outline, blur_radius);
+ cached_tid = gsk_gl_shadow_library_lookup (job->driver->shadows, &scaled_outline, blur_radius);
if (cached_tid == 0)
{
GdkGLContext *context = job->command_queue->context;
- GskNglRenderTarget *render_target;
+ GskGLRenderTarget *render_target;
graphene_matrix_t prev_projection;
graphene_rect_t prev_viewport;
guint prev_fbo;
- gsk_ngl_driver_create_render_target (job->driver,
- texture_width, texture_height,
- get_target_format (job, node),
- GL_NEAREST, GL_NEAREST,
- &render_target);
+ gsk_gl_driver_create_render_target (job->driver,
+ texture_width, texture_height,
+ get_target_format (job, node),
+ GL_NEAREST, GL_NEAREST,
+ &render_target);
if (gdk_gl_context_has_debug (context))
{
@@ -2478,38 +2478,38 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
render_target->texture_id,
"Outset Shadow Temp %d",
render_target->texture_id);
- gdk_gl_context_label_object_printf (context,
- GL_FRAMEBUFFER,
- render_target->framebuffer_id,
- "Outset Shadow FB Temp %d",
- render_target->framebuffer_id);
+ gdk_gl_context_label_object_printf (context,
+ GL_FRAMEBUFFER,
+ render_target->framebuffer_id,
+ "Outset Shadow FB Temp %d",
+ render_target->framebuffer_id);
}
/* Change state for offscreen */
- gsk_ngl_render_job_set_projection_for_size (job, texture_width, texture_height, &prev_projection);
- gsk_ngl_render_job_set_viewport_for_size (job, texture_width, texture_height, &prev_viewport);
- gsk_ngl_render_job_set_modelview (job, NULL);
- gsk_ngl_render_job_push_clip (job, &scaled_outline);
+ gsk_gl_render_job_set_projection_for_size (job, texture_width, texture_height, &prev_projection);
+ gsk_gl_render_job_set_viewport_for_size (job, texture_width, texture_height, &prev_viewport);
+ gsk_gl_render_job_set_modelview (job, NULL);
+ gsk_gl_render_job_push_clip (job, &scaled_outline);
/* Bind render target and clear it */
- prev_fbo = gsk_ngl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
- gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
+ prev_fbo = gsk_gl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
+ gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
/* Draw the outline using color program */
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
- gsk_ngl_render_job_draw_with_color (job, 0, 0, texture_width, texture_height,
- (guint16[]){ FP16_ONE, FP16_ONE, FP16_ONE, FP16_ONE });
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
+ gsk_gl_render_job_draw_with_color (job, 0, 0, texture_width, texture_height,
+ (guint16[]){ FP16_ONE, FP16_ONE, FP16_ONE, FP16_ONE });
+ gsk_gl_render_job_end_draw (job);
/* Reset state from offscreen */
- gsk_ngl_render_job_pop_clip (job);
- gsk_ngl_render_job_pop_modelview (job);
- gsk_ngl_render_job_set_viewport (job, &prev_viewport, NULL);
- gsk_ngl_render_job_set_projection (job, &prev_projection);
+ gsk_gl_render_job_pop_clip (job);
+ gsk_gl_render_job_pop_modelview (job);
+ gsk_gl_render_job_set_viewport (job, &prev_viewport, NULL);
+ gsk_gl_render_job_set_projection (job, &prev_projection);
/* Now blur the outline */
init_full_texture_region (&offscreen);
- offscreen.texture_id = gsk_ngl_driver_release_render_target (job->driver, render_target, FALSE);
+ offscreen.texture_id = gsk_gl_driver_release_render_target (job->driver, render_target, FALSE);
blurred_texture_id = blur_offscreen (job,
&offscreen,
texture_width,
@@ -2517,19 +2517,19 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
blur_radius * scale_x,
blur_radius * scale_y);
- gsk_ngl_shadow_library_insert (job->driver->shadows,
- &scaled_outline,
- blur_radius,
- blurred_texture_id);
+ gsk_gl_shadow_library_insert (job->driver->shadows,
+ &scaled_outline,
+ blur_radius,
+ blurred_texture_id);
- gsk_ngl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
+ gsk_gl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
}
else
{
blurred_texture_id = cached_tid;
}
- gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
+ gsk_gl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
if (!do_slicing)
{
@@ -2540,38 +2540,38 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
offscreen.texture_id = blurred_texture_id;
init_full_texture_region (&offscreen);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- blurred_texture_id);
- gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
- UNIFORM_OUTSET_SHADOW_OUTLINE_RECT, 0,
- &transformed_outline);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (min_x,
- min_y,
- texture_width / scale_x,
- texture_height / scale_y),
- &offscreen,
- color);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ blurred_texture_id);
+ gsk_gl_program_set_uniform_rounded_rect (job->current_program,
+ UNIFORM_OUTSET_SHADOW_OUTLINE_RECT, 0,
+ &transformed_outline);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (min_x,
+ min_y,
+ texture_width / scale_x,
+ texture_height / scale_y),
+ &offscreen,
+ color);
+ gsk_gl_render_job_end_draw (job);
return;
}
/* slicing */
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- blurred_texture_id);
- gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
- UNIFORM_OUTSET_SHADOW_OUTLINE_RECT, 0,
- &transformed_outline);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ blurred_texture_id);
+ gsk_gl_program_set_uniform_rounded_rect (job->current_program,
+ UNIFORM_OUTSET_SHADOW_OUTLINE_RECT, 0,
+ &transformed_outline);
{
float min_x = floorf (outline->bounds.origin.x - spread - half_blur_extra + dx);
@@ -2580,13 +2580,13 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
half_blur_extra + dx + spread);
float max_y = ceilf (outline->bounds.origin.y + outline->bounds.size.height +
half_blur_extra + dy + spread);
- const GskNglTextureNineSlice *slices;
+ const GskGLTextureNineSlice *slices;
float left_width, center_width, right_width;
float top_height, center_height, bottom_height;
- GskNglTexture *texture;
+ GskGLTexture *texture;
- texture = gsk_ngl_driver_get_texture_by_id (job->driver, blurred_texture_id);
- slices = gsk_ngl_texture_get_nine_slice (texture, &scaled_outline, extra_blur_pixels_x,
extra_blur_pixels_y);
+ texture = gsk_gl_driver_get_texture_by_id (job->driver, blurred_texture_id);
+ slices = gsk_gl_texture_get_nine_slice (texture, &scaled_outline, extra_blur_pixels_x,
extra_blur_pixels_y);
offscreen.was_offscreen = TRUE;
@@ -2606,104 +2606,104 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
if (nine_slice_is_visible (&slices[NINE_SLICE_TOP_LEFT]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_LEFT].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (min_x,
- min_y,
- left_width,
- top_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (min_x,
+ min_y,
+ left_width,
+ top_height),
+ &offscreen,
+ color);
}
/* Top center */
if (nine_slice_is_visible (&slices[NINE_SLICE_TOP_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_CENTER].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (min_x + left_width,
- min_y,
- center_width,
- top_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (min_x + left_width,
+ min_y,
+ center_width,
+ top_height),
+ &offscreen,
+ color);
}
/* Top right */
if (nine_slice_is_visible (&slices[NINE_SLICE_TOP_RIGHT]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_TOP_RIGHT].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (max_x - right_width,
- min_y,
- right_width,
- top_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (max_x - right_width,
+ min_y,
+ right_width,
+ top_height),
+ &offscreen,
+ color);
}
/* Bottom right */
if (nine_slice_is_visible (&slices[NINE_SLICE_BOTTOM_RIGHT]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_RIGHT].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (max_x - right_width,
- max_y - bottom_height,
- right_width,
- bottom_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (max_x - right_width,
+ max_y - bottom_height,
+ right_width,
+ bottom_height),
+ &offscreen,
+ color);
}
/* Bottom left */
if (nine_slice_is_visible (&slices[NINE_SLICE_BOTTOM_LEFT]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_LEFT].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (min_x,
- max_y - bottom_height,
- left_width,
- bottom_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (min_x,
+ max_y - bottom_height,
+ left_width,
+ bottom_height),
+ &offscreen,
+ color);
}
/* Left side */
if (nine_slice_is_visible (&slices[NINE_SLICE_LEFT_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_LEFT_CENTER].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (min_x,
- min_y + top_height,
- left_width,
- center_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (min_x,
+ min_y + top_height,
+ left_width,
+ center_height),
+ &offscreen,
+ color);
}
/* Right side */
if (nine_slice_is_visible (&slices[NINE_SLICE_RIGHT_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_RIGHT_CENTER].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (max_x - right_width,
- min_y + top_height,
- right_width,
- center_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (max_x - right_width,
+ min_y + top_height,
+ right_width,
+ center_height),
+ &offscreen,
+ color);
}
/* Bottom side */
if (nine_slice_is_visible (&slices[NINE_SLICE_BOTTOM_CENTER]))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_BOTTOM_CENTER].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (min_x + left_width,
- max_y - bottom_height,
- center_width,
- bottom_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (min_x + left_width,
+ max_y - bottom_height,
+ center_width,
+ bottom_height),
+ &offscreen,
+ color);
}
/* Middle */
@@ -2715,18 +2715,18 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
center_height)))
{
memcpy (&offscreen.area, &slices[NINE_SLICE_CENTER].area, sizeof offscreen.area);
- gsk_ngl_render_job_draw_offscreen_with_color (job,
- &GRAPHENE_RECT_INIT (min_x + left_width,
- min_y + top_height,
- center_width,
- center_height),
- &offscreen,
- color);
+ gsk_gl_render_job_draw_offscreen_with_color (job,
+ &GRAPHENE_RECT_INIT (min_x + left_width,
+ min_y + top_height,
+ center_width,
+ center_height),
+ &offscreen,
+ color);
}
}
}
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_end_draw (job);
}
static inline gboolean G_GNUC_PURE
@@ -2745,14 +2745,14 @@ equal_texture_nodes (const GskRenderNode *node1,
}
static inline void
-gsk_ngl_render_job_visit_cross_fade_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_cross_fade_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRenderNode *start_node = gsk_cross_fade_node_get_start_child (node);
const GskRenderNode *end_node = gsk_cross_fade_node_get_end_child (node);
float progress = gsk_cross_fade_node_get_progress (node);
- GskNglRenderOffscreen offscreen_start = {0};
- GskNglRenderOffscreen offscreen_end = {0};
+ GskGLRenderOffscreen offscreen_start = {0};
+ GskGLRenderOffscreen offscreen_end = {0};
g_assert (progress > 0.0);
g_assert (progress < 1.0);
@@ -2765,40 +2765,40 @@ gsk_ngl_render_job_visit_cross_fade_node (GskNglRenderJob *job,
offscreen_end.reset_clip = TRUE;
offscreen_end.bounds = &node->bounds;
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, start_node, &offscreen_start))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, start_node, &offscreen_start))
{
- gsk_ngl_render_job_visit_node (job, end_node);
+ gsk_gl_render_job_visit_node (job, end_node);
return;
}
g_assert (offscreen_start.texture_id);
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, end_node, &offscreen_end))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, end_node, &offscreen_end))
{
- float prev_alpha = gsk_ngl_render_job_set_alpha (job, job->alpha * progress);
- gsk_ngl_render_job_visit_node (job, start_node);
- gsk_ngl_render_job_set_alpha (job, prev_alpha);
+ float prev_alpha = gsk_gl_render_job_set_alpha (job, job->alpha * progress);
+ gsk_gl_render_job_visit_node (job, start_node);
+ gsk_gl_render_job_set_alpha (job, prev_alpha);
return;
}
g_assert (offscreen_end.texture_id);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, cross_fade));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen_start.texture_id);
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_CROSS_FADE_SOURCE2, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE1,
- offscreen_end.texture_id);
- gsk_ngl_program_set_uniform1f (job->current_program,
- UNIFORM_CROSS_FADE_PROGRESS, 0,
- progress);
- gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen_end);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, cross_fade));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen_start.texture_id);
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_CROSS_FADE_SOURCE2, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE1,
+ offscreen_end.texture_id);
+ gsk_gl_program_set_uniform1f (job->current_program,
+ UNIFORM_CROSS_FADE_PROGRESS, 0,
+ progress);
+ gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen_end);
+ gsk_gl_render_job_end_draw (job);
}
static gboolean
@@ -2854,8 +2854,8 @@ is_non_branching (const GskRenderNode *node)
}
static inline void
-gsk_ngl_render_job_visit_opacity_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_opacity_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRenderNode *child = gsk_opacity_node_get_child (node);
float opacity = gsk_opacity_node_get_opacity (node);
@@ -2863,7 +2863,7 @@ gsk_ngl_render_job_visit_opacity_node (GskNglRenderJob *job,
if (!ALPHA_IS_CLEAR (new_alpha))
{
- float prev_alpha = gsk_ngl_render_job_set_alpha (job, new_alpha);
+ float prev_alpha = gsk_gl_render_job_set_alpha (job, new_alpha);
/* Handle a few easy cases without offscreen. We bail out
* as soon as we see nodes with multiple children - in theory,
@@ -2871,34 +2871,34 @@ gsk_ngl_render_job_visit_opacity_node (GskNglRenderJob *job,
*/
if (is_non_branching (child))
{
- gsk_ngl_render_job_visit_node (job, child);
- gsk_ngl_render_job_set_alpha (job, prev_alpha);
+ gsk_gl_render_job_visit_node (job, child);
+ gsk_gl_render_job_set_alpha (job, prev_alpha);
}
else
{
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
offscreen.bounds = &child->bounds;
offscreen.force_offscreen = TRUE;
offscreen.reset_clip = TRUE;
/* Note: offscreen rendering resets alpha to 1.0 */
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, child, &offscreen))
return;
g_assert (offscreen.texture_id);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
- gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
+ gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
+ gsk_gl_render_job_end_draw (job);
}
- gsk_ngl_render_job_set_alpha (job, prev_alpha);
+ gsk_gl_render_job_set_alpha (job, prev_alpha);
}
}
@@ -2927,10 +2927,10 @@ compute_phase_and_pos (float value, float *pos)
}
static inline void
-gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
- const GskRenderNode *node,
- const GdkRGBA *color,
- gboolean force_color)
+gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
+ const GskRenderNode *node,
+ const GdkRGBA *color,
+ gboolean force_color)
{
const PangoFont *font = gsk_text_node_get_font (node);
const PangoGlyphInfo *glyphs = gsk_text_node_get_glyphs (node, NULL);
@@ -2939,12 +2939,12 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
guint num_glyphs = gsk_text_node_get_num_glyphs (node);
float x = offset->x + job->offset_x;
float y = offset->y + job->offset_y;
- GskNglGlyphLibrary *library = job->driver->glyphs;
- GskNglCommandBatch *batch;
+ GskGLGlyphLibrary *library = job->driver->glyphs;
+ GskGLCommandBatch *batch;
int x_position = 0;
- GskNglGlyphKey lookup;
+ GskGLGlyphKey lookup;
guint last_texture = 0;
- GskNglDrawVertex *vertices;
+ GskGLDrawVertex *vertices;
guint used = 0;
guint16 nc[4] = { FP16_MINUS_ONE, FP16_MINUS_ONE, FP16_MINUS_ONE, FP16_MINUS_ONE };
guint16 cc[4];
@@ -2968,15 +2968,15 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
yshift = compute_phase_and_pos (y, &ypos);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
- batch = gsk_ngl_command_queue_get_batch (job->command_queue);
- vertices = gsk_ngl_command_queue_add_n_vertices (job->command_queue, num_glyphs);
+ batch = gsk_gl_command_queue_get_batch (job->command_queue);
+ vertices = gsk_gl_command_queue_add_n_vertices (job->command_queue, num_glyphs);
/* We use one quad per character */
for (i = 0, gi = glyphs; i < num_glyphs; i++, gi++)
{
- const GskNglGlyphValue *glyph;
+ const GskGLGlyphValue *glyph;
float glyph_x, glyph_y, glyph_x2, glyph_y2;
float tx, ty, tx2, ty2;
float cx;
@@ -3009,11 +3009,11 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
x_position += gi->geometry.width;
- texture_id = gsk_ngl_glyph_library_lookup_or_add (library, &lookup, &glyph);
+ texture_id = gsk_gl_glyph_library_lookup_or_add (library, &lookup, &glyph);
if G_UNLIKELY (texture_id == 0)
continue;
- if G_UNLIKELY (last_texture != texture_id || batch->draw.vbo_count + GSK_NGL_N_VERTICES > 0xffff)
+ if G_UNLIKELY (last_texture != texture_id || batch->draw.vbo_count + GSK_GL_N_VERTICES > 0xffff)
{
if G_LIKELY (last_texture != 0)
{
@@ -3024,16 +3024,16 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
* of the new batch as otherwise it will point at the end of our
* vbo array.
*/
- gsk_ngl_render_job_split_draw (job);
- batch = gsk_ngl_command_queue_get_batch (job->command_queue);
+ gsk_gl_render_job_split_draw (job);
+ batch = gsk_gl_command_queue_get_batch (job->command_queue);
batch->draw.vbo_offset = vbo_offset;
}
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- texture_id);
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ texture_id);
last_texture = texture_id;
}
@@ -3047,27 +3047,27 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
glyph_x2 = glyph_x + glyph->ink_rect.width;
glyph_y2 = glyph_y + glyph->ink_rect.height;
- *(vertices++) = (GskNglDrawVertex) { .position = { glyph_x, glyph_y }, .uv = { tx, ty }, .color =
{ c[0], c[1], c[2], c[3] } };
- *(vertices++) = (GskNglDrawVertex) { .position = { glyph_x, glyph_y2 }, .uv = { tx, ty2 }, .color =
{ c[0], c[1], c[2], c[3] } };
- *(vertices++) = (GskNglDrawVertex) { .position = { glyph_x2, glyph_y }, .uv = { tx2, ty }, .color =
{ c[0], c[1], c[2], c[3] } };
+ *(vertices++) = (GskGLDrawVertex) { .position = { glyph_x, glyph_y }, .uv = { tx, ty }, .color = {
c[0], c[1], c[2], c[3] } };
+ *(vertices++) = (GskGLDrawVertex) { .position = { glyph_x, glyph_y2 }, .uv = { tx, ty2 }, .color = {
c[0], c[1], c[2], c[3] } };
+ *(vertices++) = (GskGLDrawVertex) { .position = { glyph_x2, glyph_y }, .uv = { tx2, ty }, .color = {
c[0], c[1], c[2], c[3] } };
- *(vertices++) = (GskNglDrawVertex) { .position = { glyph_x2, glyph_y2 }, .uv = { tx2, ty2 }, .color =
{ c[0], c[1], c[2], c[3] } };
- *(vertices++) = (GskNglDrawVertex) { .position = { glyph_x, glyph_y2 }, .uv = { tx, ty2 }, .color =
{ c[0], c[1], c[2], c[3] } };
- *(vertices++) = (GskNglDrawVertex) { .position = { glyph_x2, glyph_y }, .uv = { tx2, ty }, .color =
{ c[0], c[1], c[2], c[3] } };
+ *(vertices++) = (GskGLDrawVertex) { .position = { glyph_x2, glyph_y2 }, .uv = { tx2, ty2 }, .color = {
c[0], c[1], c[2], c[3] } };
+ *(vertices++) = (GskGLDrawVertex) { .position = { glyph_x, glyph_y2 }, .uv = { tx, ty2 }, .color = {
c[0], c[1], c[2], c[3] } };
+ *(vertices++) = (GskGLDrawVertex) { .position = { glyph_x2, glyph_y }, .uv = { tx2, ty }, .color = {
c[0], c[1], c[2], c[3] } };
- batch->draw.vbo_count += GSK_NGL_N_VERTICES;
+ batch->draw.vbo_count += GSK_GL_N_VERTICES;
used++;
}
if (used != num_glyphs)
- gsk_ngl_command_queue_retract_n_vertices (job->command_queue, num_glyphs - used);
+ gsk_gl_command_queue_retract_n_vertices (job->command_queue, num_glyphs - used);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_shadow_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_shadow_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const gsize n_shadows = gsk_shadow_node_get_n_shadows (node);
const GskRenderNode *original_child = gsk_shadow_node_get_child (node);
@@ -3084,7 +3084,7 @@ gsk_ngl_render_job_visit_shadow_node (GskNglRenderJob *job,
const GskShadow *shadow = gsk_shadow_node_get_shadow (node, i);
const float dx = shadow->dx;
const float dy = shadow->dy;
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
graphene_rect_t bounds;
guint16 color[4];
@@ -3099,9 +3099,9 @@ gsk_ngl_render_job_visit_shadow_node (GskNglRenderJob *job,
{
if (dx != 0 || dy != 0)
{
- gsk_ngl_render_job_offset (job, dx, dy);
- gsk_ngl_render_job_visit_text_node (job, shadow_child, &shadow->color, TRUE);
- gsk_ngl_render_job_offset (job, -dx, -dy);
+ gsk_gl_render_job_offset (job, dx, dy);
+ gsk_gl_render_job_visit_text_node (job, shadow_child, &shadow->color, TRUE);
+ gsk_gl_render_job_offset (job, -dx, -dy);
}
continue;
}
@@ -3139,36 +3139,36 @@ gsk_ngl_render_job_visit_shadow_node (GskNglRenderJob *job,
offscreen.reset_clip = TRUE;
offscreen.do_not_cache = TRUE;
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, shadow_child, &offscreen))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, shadow_child, &offscreen))
g_assert_not_reached ();
bounds = shadow_child->bounds;
}
- gsk_ngl_render_job_offset (job, dx, dy);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
+ gsk_gl_render_job_offset (job, dx, dy);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
rgba_to_half (&shadow->color, color);
- gsk_ngl_render_job_draw_offscreen_with_color (job, &bounds, &offscreen, color);
- gsk_ngl_render_job_end_draw (job);
- gsk_ngl_render_job_offset (job, -dx, -dy);
+ gsk_gl_render_job_draw_offscreen_with_color (job, &bounds, &offscreen, color);
+ gsk_gl_render_job_end_draw (job);
+ gsk_gl_render_job_offset (job, -dx, -dy);
}
/* Now draw the child normally */
- gsk_ngl_render_job_visit_node (job, original_child);
+ gsk_gl_render_job_visit_node (job, original_child);
}
static inline void
-gsk_ngl_render_job_visit_blur_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_blur_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRenderNode *child = gsk_blur_node_get_child (node);
float blur_radius = gsk_blur_node_get_radius (node);
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
GskTextureKey key;
gboolean cache_texture;
float min_x;
@@ -3187,7 +3187,7 @@ gsk_ngl_render_job_visit_blur_node (GskNglRenderJob *job,
key.scale_y = job->scale_y;
key.filter = GL_NEAREST;
- offscreen.texture_id = gsk_ngl_driver_lookup_texture (job->driver, &key);
+ offscreen.texture_id = gsk_gl_driver_lookup_texture (job->driver, &key);
cache_texture = offscreen.texture_id == 0;
blur_node (job,
@@ -3199,29 +3199,29 @@ gsk_ngl_render_job_visit_blur_node (GskNglRenderJob *job,
g_assert (offscreen.texture_id != 0);
if (cache_texture)
- gsk_ngl_driver_cache_texture (job->driver, &key, offscreen.texture_id);
-
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
- gsk_ngl_render_job_draw_coords (job,
- min_x, min_y, max_x, max_y,
- 0, 1, 1, 0,
- (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO } );
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_driver_cache_texture (job->driver, &key, offscreen.texture_id);
+
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
+ gsk_gl_render_job_draw_coords (job,
+ min_x, min_y, max_x, max_y,
+ 0, 1, 1, 0,
+ (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO } );
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_blend_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_blend_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRenderNode *top_child = gsk_blend_node_get_top_child (node);
const GskRenderNode *bottom_child = gsk_blend_node_get_bottom_child (node);
- GskNglRenderOffscreen top_offscreen = {0};
- GskNglRenderOffscreen bottom_offscreen = {0};
+ GskGLRenderOffscreen top_offscreen = {0};
+ GskGLRenderOffscreen bottom_offscreen = {0};
top_offscreen.bounds = &node->bounds;
top_offscreen.force_offscreen = TRUE;
@@ -3233,53 +3233,53 @@ gsk_ngl_render_job_visit_blend_node (GskNglRenderJob *job,
/* TODO: We create 2 textures here as big as the blend node, but both the
* start and the end node might be a lot smaller than that. */
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, bottom_child, &bottom_offscreen))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, bottom_child, &bottom_offscreen))
{
- gsk_ngl_render_job_visit_node (job, top_child);
+ gsk_gl_render_job_visit_node (job, top_child);
return;
}
g_assert (bottom_offscreen.was_offscreen);
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, top_child, &top_offscreen))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, top_child, &top_offscreen))
{
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- bottom_offscreen.texture_id);
- gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &bottom_offscreen);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ bottom_offscreen.texture_id);
+ gsk_gl_render_job_draw_offscreen (job, &node->bounds, &bottom_offscreen);
+ gsk_gl_render_job_end_draw (job);
return;
}
g_assert (top_offscreen.was_offscreen);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blend));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- bottom_offscreen.texture_id);
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_BLEND_SOURCE2, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE1,
- top_offscreen.texture_id);
- gsk_ngl_program_set_uniform1i (job->current_program,
- UNIFORM_BLEND_MODE, 0,
- gsk_blend_node_get_blend_mode (node));
- gsk_ngl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blend));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ bottom_offscreen.texture_id);
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_BLEND_SOURCE2, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE1,
+ top_offscreen.texture_id);
+ gsk_gl_program_set_uniform1i (job->current_program,
+ UNIFORM_BLEND_MODE, 0,
+ gsk_blend_node_get_blend_mode (node));
+ gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_color_matrix_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_color_matrix_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRenderNode *child = gsk_color_matrix_node_get_child (node);
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
float offset[4];
if (node_is_invisible (child))
@@ -3288,52 +3288,52 @@ gsk_ngl_render_job_visit_color_matrix_node (GskNglRenderJob *job,
offscreen.bounds = &node->bounds;
offscreen.reset_clip = TRUE;
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, child, &offscreen))
g_assert_not_reached ();
g_assert (offscreen.texture_id > 0);
graphene_vec4_to_float (gsk_color_matrix_node_get_color_offset (node), offset);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color_matrix));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
- gsk_ngl_program_set_uniform_matrix (job->current_program,
- UNIFORM_COLOR_MATRIX_COLOR_MATRIX, 0,
- gsk_color_matrix_node_get_color_matrix (node));
- gsk_ngl_program_set_uniform4fv (job->current_program,
- UNIFORM_COLOR_MATRIX_COLOR_OFFSET, 0,
- 1,
- offset);
- gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color_matrix));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
+ gsk_gl_program_set_uniform_matrix (job->current_program,
+ UNIFORM_COLOR_MATRIX_COLOR_MATRIX, 0,
+ gsk_color_matrix_node_get_color_matrix (node));
+ gsk_gl_program_set_uniform4fv (job->current_program,
+ UNIFORM_COLOR_MATRIX_COLOR_OFFSET, 0,
+ 1,
+ offset);
+ gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_gl_shader_node_fallback (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_gl_shader_node_fallback (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
guint16 pink[4] = { 15360, 13975, 14758, 15360 }; /* 255 105 180 */
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
- gsk_ngl_render_job_draw_rect_with_color (job, &node->bounds, pink);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
+ gsk_gl_render_job_draw_rect_with_color (job, &node->bounds, pink);
+ gsk_gl_render_job_end_draw (job);
}
static inline void
-gsk_ngl_render_job_visit_gl_shader_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_gl_shader_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
GError *error = NULL;
GskGLShader *shader;
- GskNglProgram *program;
+ GskGLProgram *program;
int n_children;
shader = gsk_gl_shader_node_get_shader (node);
- program = gsk_ngl_driver_lookup_shader (job->driver, shader, &error);
+ program = gsk_gl_driver_lookup_shader (job->driver, shader, &error);
n_children = gsk_gl_shader_node_get_n_children (node);
if G_UNLIKELY (program == NULL)
@@ -3343,12 +3343,12 @@ gsk_ngl_render_job_visit_gl_shader_node (GskNglRenderJob *job,
g_object_set_data (G_OBJECT (shader), "gsk-did-warn", GUINT_TO_POINTER (1));
g_warning ("Failed to compile gl shader: %s", error->message);
}
- gsk_ngl_render_job_visit_gl_shader_node_fallback (job, node);
+ gsk_gl_render_job_visit_gl_shader_node_fallback (job, node);
g_clear_error (&error);
}
else
{
- GskNglRenderOffscreen offscreens[4] = {{0}};
+ GskGLRenderOffscreen offscreens[4] = {{0}};
const GskGLUniform *uniforms;
const guint8 *base;
GBytes *args;
@@ -3364,7 +3364,7 @@ gsk_ngl_render_job_visit_gl_shader_node (GskNglRenderJob *job,
offscreens[i].force_offscreen = TRUE;
offscreens[i].reset_clip = TRUE;
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreens[i]))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, child, &offscreens[i]))
return;
}
@@ -3372,17 +3372,17 @@ gsk_ngl_render_job_visit_gl_shader_node (GskNglRenderJob *job,
base = g_bytes_get_data (args, NULL);
uniforms = gsk_gl_shader_get_uniforms (shader, &n_uniforms);
- gsk_ngl_render_job_begin_draw (job, program);
+ gsk_gl_render_job_begin_draw (job, program);
for (guint i = 0; i < n_children; i++)
- gsk_ngl_program_set_uniform_texture (program,
- UNIFORM_CUSTOM_TEXTURE1 + i, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0 + i,
- offscreens[i].texture_id);
- gsk_ngl_program_set_uniform2f (program,
- UNIFORM_CUSTOM_SIZE, 0,
- node->bounds.size.width,
- node->bounds.size.height);
+ gsk_gl_program_set_uniform_texture (program,
+ UNIFORM_CUSTOM_TEXTURE1 + i, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0 + i,
+ offscreens[i].texture_id);
+ gsk_gl_program_set_uniform2f (program,
+ UNIFORM_CUSTOM_SIZE, 0,
+ node->bounds.size.width,
+ node->bounds.size.height);
for (guint i = 0; i < n_uniforms; i++)
{
const GskGLUniform *u = &uniforms[i];
@@ -3394,75 +3394,75 @@ gsk_ngl_render_job_visit_gl_shader_node (GskNglRenderJob *job,
case GSK_GL_UNIFORM_TYPE_NONE:
break;
case GSK_GL_UNIFORM_TYPE_FLOAT:
- gsk_ngl_uniform_state_set1fv (job->command_queue->uniforms,
- program->program_info,
- UNIFORM_CUSTOM_ARG0 + i,
- 0, 1, (const float *)data);
- break;
- case GSK_GL_UNIFORM_TYPE_INT:
- gsk_ngl_uniform_state_set1i (job->command_queue->uniforms,
+ gsk_gl_uniform_state_set1fv (job->command_queue->uniforms,
program->program_info,
UNIFORM_CUSTOM_ARG0 + i,
- 0, *(const gint32 *)data);
+ 0, 1, (const float *)data);
+ break;
+ case GSK_GL_UNIFORM_TYPE_INT:
+ gsk_gl_uniform_state_set1i (job->command_queue->uniforms,
+ program->program_info,
+ UNIFORM_CUSTOM_ARG0 + i,
+ 0, *(const gint32 *)data);
break;
case GSK_GL_UNIFORM_TYPE_UINT:
case GSK_GL_UNIFORM_TYPE_BOOL:
- gsk_ngl_uniform_state_set1ui (job->command_queue->uniforms,
- program->program_info,
- UNIFORM_CUSTOM_ARG0 + i,
- 0, *(const guint32 *)data);
+ gsk_gl_uniform_state_set1ui (job->command_queue->uniforms,
+ program->program_info,
+ UNIFORM_CUSTOM_ARG0 + i,
+ 0, *(const guint32 *)data);
break;
case GSK_GL_UNIFORM_TYPE_VEC2:
- gsk_ngl_uniform_state_set2fv (job->command_queue->uniforms,
- program->program_info,
- UNIFORM_CUSTOM_ARG0 + i,
- 0, 1, (const float *)data);
+ gsk_gl_uniform_state_set2fv (job->command_queue->uniforms,
+ program->program_info,
+ UNIFORM_CUSTOM_ARG0 + i,
+ 0, 1, (const float *)data);
break;
case GSK_GL_UNIFORM_TYPE_VEC3:
- gsk_ngl_uniform_state_set3fv (job->command_queue->uniforms,
- program->program_info,
- UNIFORM_CUSTOM_ARG0 + i,
- 0, 1, (const float *)data);
+ gsk_gl_uniform_state_set3fv (job->command_queue->uniforms,
+ program->program_info,
+ UNIFORM_CUSTOM_ARG0 + i,
+ 0, 1, (const float *)data);
break;
case GSK_GL_UNIFORM_TYPE_VEC4:
- gsk_ngl_uniform_state_set4fv (job->command_queue->uniforms,
- program->program_info,
- UNIFORM_CUSTOM_ARG0 + i,
- 0, 1, (const float *)data);
+ gsk_gl_uniform_state_set4fv (job->command_queue->uniforms,
+ program->program_info,
+ UNIFORM_CUSTOM_ARG0 + i,
+ 0, 1, (const float *)data);
break;
}
}
- gsk_ngl_render_job_draw_offscreen_rect (job, &node->bounds);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_draw_offscreen_rect (job, &node->bounds);
+ gsk_gl_render_job_end_draw (job);
}
}
static void
-gsk_ngl_render_job_upload_texture (GskNglRenderJob *job,
- GdkTexture *texture,
- GskNglRenderOffscreen *offscreen)
+gsk_gl_render_job_upload_texture (GskGLRenderJob *job,
+ GdkTexture *texture,
+ GskGLRenderOffscreen *offscreen)
{
- if (gsk_ngl_texture_library_can_cache ((GskNglTextureLibrary *)job->driver->icons,
+ if (gsk_gl_texture_library_can_cache ((GskGLTextureLibrary *)job->driver->icons,
texture->width,
texture->height) &&
!GDK_IS_GL_TEXTURE (texture))
{
- const GskNglIconData *icon_data;
+ const GskGLIconData *icon_data;
- gsk_ngl_icon_library_lookup_or_add (job->driver->icons, texture, &icon_data);
- offscreen->texture_id = GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
+ gsk_gl_icon_library_lookup_or_add (job->driver->icons, texture, &icon_data);
+ offscreen->texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (icon_data);
memcpy (&offscreen->area, &icon_data->entry.area, sizeof offscreen->area);
}
else
{
- offscreen->texture_id = gsk_ngl_driver_load_texture (job->driver, texture, GL_LINEAR, GL_LINEAR);
+ offscreen->texture_id = gsk_gl_driver_load_texture (job->driver, texture, GL_LINEAR, GL_LINEAR);
init_full_texture_region (offscreen);
}
}
static inline void
-gsk_ngl_render_job_visit_texture_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_texture_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
GdkTexture *texture = gsk_texture_node_get_texture (node);
int max_texture_size = job->command_queue->max_texture_size;
@@ -3470,21 +3470,21 @@ gsk_ngl_render_job_visit_texture_node (GskNglRenderJob *job,
if G_LIKELY (texture->width <= max_texture_size &&
texture->height <= max_texture_size)
{
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
- gsk_ngl_render_job_upload_texture (job, texture, &offscreen);
+ gsk_gl_render_job_upload_texture (job, texture, &offscreen);
g_assert (offscreen.texture_id);
g_assert (offscreen.was_offscreen == FALSE);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
- gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
+ gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
+ gsk_gl_render_job_end_draw (job);
}
else
{
@@ -3494,19 +3494,19 @@ gsk_ngl_render_job_visit_texture_node (GskNglRenderJob *job,
float max_y = min_y + node->bounds.size.height;
float scale_x = (max_x - min_x) / texture->width;
float scale_y = (max_y - min_y) / texture->height;
- GskNglTextureSlice *slices = NULL;
+ GskGLTextureSlice *slices = NULL;
guint n_slices = 0;
- gsk_ngl_driver_slice_texture (job->driver, texture, &slices, &n_slices);
+ gsk_gl_driver_slice_texture (job->driver, texture, &slices, &n_slices);
g_assert (slices != NULL);
g_assert (n_slices > 0);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
for (guint i = 0; i < n_slices; i ++)
{
- const GskNglTextureSlice *slice = &slices[i];
+ const GskGLTextureSlice *slice = &slices[i];
float x1, x2, y1, y2;
x1 = min_x + (scale_x * slice->rect.x);
@@ -3515,30 +3515,30 @@ gsk_ngl_render_job_visit_texture_node (GskNglRenderJob *job,
y2 = y1 + (slice->rect.height * scale_y);
if (i > 0)
- gsk_ngl_render_job_split_draw (job);
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- slice->texture_id);
-
- gsk_ngl_render_job_draw_coords (job,
- x1, y1, x2, y2,
- 0, 0, 1, 1,
- (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
+ gsk_gl_render_job_split_draw (job);
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ slice->texture_id);
+
+ gsk_gl_render_job_draw_coords (job,
+ x1, y1, x2, y2,
+ 0, 0, 1, 1,
+ (guint16[]) { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO });
}
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_end_draw (job);
}
}
static inline void
-gsk_ngl_render_job_visit_repeat_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_repeat_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
const GskRenderNode *child = gsk_repeat_node_get_child (node);
const graphene_rect_t *child_bounds = gsk_repeat_node_get_child_bounds (node);
- GskNglRenderOffscreen offscreen = {0};
+ GskGLRenderOffscreen offscreen = {0};
if (node_is_invisible (child))
return;
@@ -3546,7 +3546,7 @@ gsk_ngl_render_job_visit_repeat_node (GskNglRenderJob *job,
if (!graphene_rect_equal (child_bounds, &child->bounds))
{
/* TODO: implement these repeat nodes. */
- gsk_ngl_render_job_visit_as_fallback (job, node);
+ gsk_gl_render_job_visit_as_fallback (job, node);
return;
}
@@ -3555,93 +3555,93 @@ gsk_ngl_render_job_visit_repeat_node (GskNglRenderJob *job,
* of the child texture... */
if (rect_contains_rect (child_bounds, &node->bounds))
{
- gsk_ngl_render_job_visit_clipped_child (job, child, &node->bounds);
+ gsk_gl_render_job_visit_clipped_child (job, child, &node->bounds);
return;
}
offscreen.bounds = &child->bounds;
offscreen.reset_clip = TRUE;
- if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
+ if (!gsk_gl_render_job_visit_node_with_offscreen (job, child, &offscreen))
g_assert_not_reached ();
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, repeat));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- offscreen.texture_id);
- gsk_ngl_program_set_uniform4f (job->current_program,
- UNIFORM_REPEAT_CHILD_BOUNDS, 0,
- (node->bounds.origin.x - child_bounds->origin.x) / child_bounds->size.width,
- (node->bounds.origin.y - child_bounds->origin.y) /
child_bounds->size.height,
- node->bounds.size.width / child_bounds->size.width,
- node->bounds.size.height / child_bounds->size.height);
- gsk_ngl_program_set_uniform4f (job->current_program,
- UNIFORM_REPEAT_TEXTURE_RECT, 0,
- offscreen.area.x,
- offscreen.was_offscreen ? offscreen.area.y2 : offscreen.area.y,
- offscreen.area.x2,
- offscreen.was_offscreen ? offscreen.area.y : offscreen.area.y2);
- gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, repeat));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ offscreen.texture_id);
+ gsk_gl_program_set_uniform4f (job->current_program,
+ UNIFORM_REPEAT_CHILD_BOUNDS, 0,
+ (node->bounds.origin.x - child_bounds->origin.x) / child_bounds->size.width,
+ (node->bounds.origin.y - child_bounds->origin.y) / child_bounds->size.height,
+ node->bounds.size.width / child_bounds->size.width,
+ node->bounds.size.height / child_bounds->size.height);
+ gsk_gl_program_set_uniform4f (job->current_program,
+ UNIFORM_REPEAT_TEXTURE_RECT, 0,
+ offscreen.area.x,
+ offscreen.was_offscreen ? offscreen.area.y2 : offscreen.area.y,
+ offscreen.area.x2,
+ offscreen.was_offscreen ? offscreen.area.y : offscreen.area.y2);
+ gsk_gl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
+ gsk_gl_render_job_end_draw (job);
}
static void
-gsk_ngl_render_job_visit_node (GskNglRenderJob *job,
- const GskRenderNode *node)
+gsk_gl_render_job_visit_node (GskGLRenderJob *job,
+ const GskRenderNode *node)
{
gboolean has_clip;
g_assert (job != NULL);
g_assert (node != NULL);
- g_assert (GSK_IS_NGL_DRIVER (job->driver));
- g_assert (GSK_IS_NGL_COMMAND_QUEUE (job->command_queue));
+ g_assert (GSK_IS_GL_DRIVER (job->driver));
+ g_assert (GSK_IS_GL_COMMAND_QUEUE (job->command_queue));
if (node_is_invisible (node))
return;
- if (!gsk_ngl_render_job_update_clip (job, &node->bounds, &has_clip))
+ if (!gsk_gl_render_job_update_clip (job, &node->bounds, &has_clip))
return;
switch (gsk_render_node_get_node_type (node))
{
case GSK_BLEND_NODE:
- gsk_ngl_render_job_visit_blend_node (job, node);
+ gsk_gl_render_job_visit_blend_node (job, node);
break;
case GSK_BLUR_NODE:
if (gsk_blur_node_get_radius (node) > 0)
- gsk_ngl_render_job_visit_blur_node (job, node);
+ gsk_gl_render_job_visit_blur_node (job, node);
else
- gsk_ngl_render_job_visit_node (job, gsk_blur_node_get_child (node));
+ gsk_gl_render_job_visit_node (job, gsk_blur_node_get_child (node));
break;
case GSK_BORDER_NODE:
if (gsk_border_node_get_uniform_color (node) &&
gsk_rounded_rect_is_rectilinear (gsk_border_node_get_outline (node)))
- gsk_ngl_render_job_visit_rect_border_node (job, node);
+ gsk_gl_render_job_visit_rect_border_node (job, node);
else
- gsk_ngl_render_job_visit_border_node (job, node);
+ gsk_gl_render_job_visit_border_node (job, node);
break;
case GSK_CLIP_NODE:
- gsk_ngl_render_job_visit_clip_node (job, node);
+ gsk_gl_render_job_visit_clip_node (job, node);
break;
case GSK_COLOR_NODE:
- gsk_ngl_render_job_visit_color_node (job, node);
+ gsk_gl_render_job_visit_color_node (job, node);
break;
case GSK_COLOR_MATRIX_NODE:
- gsk_ngl_render_job_visit_color_matrix_node (job, node);
+ gsk_gl_render_job_visit_color_matrix_node (job, node);
break;
case GSK_CONIC_GRADIENT_NODE:
if (gsk_conic_gradient_node_get_n_color_stops (node) < MAX_GRADIENT_STOPS)
- gsk_ngl_render_job_visit_conic_gradient_node (job, node);
+ gsk_gl_render_job_visit_conic_gradient_node (job, node);
else
- gsk_ngl_render_job_visit_as_fallback (job, node);
+ gsk_gl_render_job_visit_as_fallback (job, node);
break;
case GSK_CONTAINER_NODE:
@@ -3667,13 +3667,13 @@ gsk_ngl_render_job_visit_node (GskNglRenderJob *job,
rounded_rect_equal (gsk_rounded_clip_node_get_clip (child),
gsk_border_node_get_outline (child2)))
{
- gsk_ngl_render_job_visit_css_background (job, child, child2);
+ gsk_gl_render_job_visit_css_background (job, child, child2);
i++; /* skip the border node */
continue;
}
}
- gsk_ngl_render_job_visit_node (job, child);
+ gsk_gl_render_job_visit_node (job, child);
}
}
break;
@@ -3685,86 +3685,86 @@ gsk_ngl_render_job_visit_node (GskNglRenderJob *job,
float progress = gsk_cross_fade_node_get_progress (node);
if (progress <= 0.0f)
- gsk_ngl_render_job_visit_node (job, gsk_cross_fade_node_get_start_child (node));
+ gsk_gl_render_job_visit_node (job, gsk_cross_fade_node_get_start_child (node));
else if (progress >= 1.0f || equal_texture_nodes (start_node, end_node))
- gsk_ngl_render_job_visit_node (job, gsk_cross_fade_node_get_end_child (node));
+ gsk_gl_render_job_visit_node (job, gsk_cross_fade_node_get_end_child (node));
else
- gsk_ngl_render_job_visit_cross_fade_node (job, node);
+ gsk_gl_render_job_visit_cross_fade_node (job, node);
}
break;
case GSK_DEBUG_NODE:
/* Debug nodes are ignored because draws get reordered anyway */
- gsk_ngl_render_job_visit_node (job, gsk_debug_node_get_child (node));
+ gsk_gl_render_job_visit_node (job, gsk_debug_node_get_child (node));
break;
case GSK_GL_SHADER_NODE:
- gsk_ngl_render_job_visit_gl_shader_node (job, node);
+ gsk_gl_render_job_visit_gl_shader_node (job, node);
break;
case GSK_INSET_SHADOW_NODE:
if (gsk_inset_shadow_node_get_blur_radius (node) > 0)
- gsk_ngl_render_job_visit_blurred_inset_shadow_node (job, node);
+ gsk_gl_render_job_visit_blurred_inset_shadow_node (job, node);
else
- gsk_ngl_render_job_visit_unblurred_inset_shadow_node (job, node);
+ gsk_gl_render_job_visit_unblurred_inset_shadow_node (job, node);
break;
case GSK_LINEAR_GRADIENT_NODE:
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
if (gsk_linear_gradient_node_get_n_color_stops (node) < MAX_GRADIENT_STOPS)
- gsk_ngl_render_job_visit_linear_gradient_node (job, node);
+ gsk_gl_render_job_visit_linear_gradient_node (job, node);
else
- gsk_ngl_render_job_visit_as_fallback (job, node);
+ gsk_gl_render_job_visit_as_fallback (job, node);
break;
case GSK_OPACITY_NODE:
- gsk_ngl_render_job_visit_opacity_node (job, node);
+ gsk_gl_render_job_visit_opacity_node (job, node);
break;
case GSK_OUTSET_SHADOW_NODE:
if (gsk_outset_shadow_node_get_blur_radius (node) > 0)
- gsk_ngl_render_job_visit_blurred_outset_shadow_node (job, node);
+ gsk_gl_render_job_visit_blurred_outset_shadow_node (job, node);
else
- gsk_ngl_render_job_visit_unblurred_outset_shadow_node (job, node);
+ gsk_gl_render_job_visit_unblurred_outset_shadow_node (job, node);
break;
case GSK_RADIAL_GRADIENT_NODE:
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
if (gsk_radial_gradient_node_get_n_color_stops (node) < MAX_GRADIENT_STOPS)
- gsk_ngl_render_job_visit_radial_gradient_node (job, node);
+ gsk_gl_render_job_visit_radial_gradient_node (job, node);
else
- gsk_ngl_render_job_visit_as_fallback (job, node);
+ gsk_gl_render_job_visit_as_fallback (job, node);
break;
case GSK_REPEAT_NODE:
- gsk_ngl_render_job_visit_repeat_node (job, node);
+ gsk_gl_render_job_visit_repeat_node (job, node);
break;
case GSK_ROUNDED_CLIP_NODE:
- gsk_ngl_render_job_visit_rounded_clip_node (job, node);
+ gsk_gl_render_job_visit_rounded_clip_node (job, node);
break;
case GSK_SHADOW_NODE:
- gsk_ngl_render_job_visit_shadow_node (job, node);
+ gsk_gl_render_job_visit_shadow_node (job, node);
break;
case GSK_TEXT_NODE:
- gsk_ngl_render_job_visit_text_node (job,
- node,
- gsk_text_node_get_color (node),
- FALSE);
+ gsk_gl_render_job_visit_text_node (job,
+ node,
+ gsk_text_node_get_color (node),
+ FALSE);
break;
case GSK_TEXTURE_NODE:
- gsk_ngl_render_job_visit_texture_node (job, node);
+ gsk_gl_render_job_visit_texture_node (job, node);
break;
case GSK_TRANSFORM_NODE:
- gsk_ngl_render_job_visit_transform_node (job, node);
+ gsk_gl_render_job_visit_transform_node (job, node);
break;
case GSK_CAIRO_NODE:
- gsk_ngl_render_job_visit_as_fallback (job, node);
+ gsk_gl_render_job_visit_as_fallback (job, node);
break;
case GSK_NOT_A_RENDER_NODE:
@@ -3774,13 +3774,13 @@ gsk_ngl_render_job_visit_node (GskNglRenderJob *job,
}
if (has_clip)
- gsk_ngl_render_job_pop_clip (job);
+ gsk_gl_render_job_pop_clip (job);
}
static gboolean
-gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
- const GskRenderNode *node,
- GskNglRenderOffscreen *offscreen)
+gsk_gl_render_job_visit_node_with_offscreen (GskGLRenderJob *job,
+ const GskRenderNode *node,
+ GskGLRenderOffscreen *offscreen)
{
GskTextureKey key;
guint cached_id;
@@ -3805,7 +3805,7 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
offscreen->force_offscreen == FALSE)
{
GdkTexture *texture = gsk_texture_node_get_texture (node);
- gsk_ngl_render_job_upload_texture (job, texture, offscreen);
+ gsk_gl_render_job_upload_texture (job, texture, offscreen);
g_assert (offscreen->was_offscreen == FALSE);
return TRUE;
}
@@ -3820,7 +3820,7 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
key.scale_y = job->scale_y;
key.filter = filter;
- cached_id = gsk_ngl_driver_lookup_texture (job->driver, &key);
+ cached_id = gsk_gl_driver_lookup_texture (job->driver, &key);
if (cached_id != 0)
{
@@ -3864,7 +3864,7 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
downscale_y = -downscale_y;
}
- GskNglRenderTarget *render_target;
+ GskGLRenderTarget *render_target;
graphene_matrix_t prev_projection;
graphene_rect_t prev_viewport;
graphene_rect_t viewport;
@@ -3873,11 +3873,11 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
float prev_alpha;
guint prev_fbo;
- if (!gsk_ngl_driver_create_render_target (job->driver,
- scaled_width, scaled_height,
- get_target_format (job, node),
- filter, filter,
- &render_target))
+ if (!gsk_gl_driver_create_render_target (job->driver,
+ scaled_width, scaled_height,
+ get_target_format (job, node),
+ filter, filter,
+ &render_target))
g_assert_not_reached ();
if (gdk_gl_context_has_debug (job->command_queue->context))
@@ -3899,57 +3899,57 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
if (downscale_x != 1 || downscale_y != 1)
{
GskTransform *transform = gsk_transform_scale (NULL, downscale_x, downscale_y);
- gsk_ngl_render_job_push_modelview (job, transform);
+ gsk_gl_render_job_push_modelview (job, transform);
gsk_transform_unref (transform);
}
- gsk_ngl_render_job_transform_bounds (job, offscreen->bounds, &viewport);
+ gsk_gl_render_job_transform_bounds (job, offscreen->bounds, &viewport);
/* Code above will scale the size with the scale we use in the render ops,
* but for the viewport size, we need our own size limited by the texture size */
viewport.size.width = scaled_width;
viewport.size.height = scaled_height;
- gsk_ngl_render_job_set_viewport (job, &viewport, &prev_viewport);
- gsk_ngl_render_job_set_projection_from_rect (job, &job->viewport, &prev_projection);
- prev_alpha = gsk_ngl_render_job_set_alpha (job, 1.0f);
+ gsk_gl_render_job_set_viewport (job, &viewport, &prev_viewport);
+ gsk_gl_render_job_set_projection_from_rect (job, &job->viewport, &prev_projection);
+ prev_alpha = gsk_gl_render_job_set_alpha (job, 1.0f);
- prev_fbo = gsk_ngl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
- gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
+ prev_fbo = gsk_gl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
+ gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
if (offscreen->reset_clip)
- gsk_ngl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT_FROM_RECT (job->viewport));
+ gsk_gl_render_job_push_clip (job, &GSK_ROUNDED_RECT_INIT_FROM_RECT (job->viewport));
- gsk_ngl_render_job_visit_node (job, node);
+ gsk_gl_render_job_visit_node (job, node);
if (offscreen->reset_clip)
- gsk_ngl_render_job_pop_clip (job);
+ gsk_gl_render_job_pop_clip (job);
if (downscale_x != 1 || downscale_y != 1)
- gsk_ngl_render_job_pop_modelview (job);
- gsk_ngl_render_job_set_viewport (job, &prev_viewport, NULL);
- gsk_ngl_render_job_set_projection (job, &prev_projection);
- gsk_ngl_render_job_set_alpha (job, prev_alpha);
- gsk_ngl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
+ gsk_gl_render_job_pop_modelview (job);
+ gsk_gl_render_job_set_viewport (job, &prev_viewport, NULL);
+ gsk_gl_render_job_set_projection (job, &prev_projection);
+ gsk_gl_render_job_set_alpha (job, prev_alpha);
+ gsk_gl_command_queue_bind_framebuffer (job->command_queue, prev_fbo);
job->offset_x = offset_x;
job->offset_y = offset_y;
offscreen->was_offscreen = TRUE;
- offscreen->texture_id = gsk_ngl_driver_release_render_target (job->driver,
- render_target,
- FALSE);
+ offscreen->texture_id = gsk_gl_driver_release_render_target (job->driver,
+ render_target,
+ FALSE);
init_full_texture_region (offscreen);
if (!offscreen->do_not_cache)
- gsk_ngl_driver_cache_texture (job->driver, &key, offscreen->texture_id);
+ gsk_gl_driver_cache_texture (job->driver, &key, offscreen->texture_id);
return TRUE;
}
void
-gsk_ngl_render_job_render_flipped (GskNglRenderJob *job,
- GskRenderNode *root)
+gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
+ GskRenderNode *root)
{
graphene_matrix_t proj;
guint framebuffer_id;
@@ -3958,7 +3958,7 @@ gsk_ngl_render_job_render_flipped (GskNglRenderJob *job,
g_return_if_fail (job != NULL);
g_return_if_fail (root != NULL);
- g_return_if_fail (GSK_IS_NGL_DRIVER (job->driver));
+ g_return_if_fail (GSK_IS_GL_DRIVER (job->driver));
surface_height = job->viewport.size.height;
@@ -3971,7 +3971,7 @@ gsk_ngl_render_job_render_flipped (GskNglRenderJob *job,
ORTHO_FAR_PLANE);
graphene_matrix_scale (&proj, 1, -1, 1);
- if (!gsk_ngl_command_queue_create_render_target (job->command_queue,
+ if (!gsk_gl_command_queue_create_render_target (job->command_queue,
MAX (1, job->viewport.size.width),
MAX (1, job->viewport.size.height),
job->target_format,
@@ -3980,29 +3980,29 @@ gsk_ngl_render_job_render_flipped (GskNglRenderJob *job,
return;
/* Setup drawing to our offscreen texture/framebuffer which is flipped */
- gsk_ngl_command_queue_bind_framebuffer (job->command_queue, framebuffer_id);
- gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
+ gsk_gl_command_queue_bind_framebuffer (job->command_queue, framebuffer_id);
+ gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
/* Visit all nodes creating batches */
gdk_gl_context_push_debug_group (job->command_queue->context, "Building command queue");
- gsk_ngl_render_job_visit_node (job, root);
+ gsk_gl_render_job_visit_node (job, root);
gdk_gl_context_pop_debug_group (job->command_queue->context);
/* Now draw to our real destination, but flipped */
- gsk_ngl_render_job_set_alpha (job, 1.0f);
- gsk_ngl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
- gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
- gsk_ngl_program_set_uniform_texture (job->current_program,
- UNIFORM_SHARED_SOURCE, 0,
- GL_TEXTURE_2D,
- GL_TEXTURE0,
- texture_id);
- gsk_ngl_render_job_draw_rect (job, &job->viewport);
- gsk_ngl_render_job_end_draw (job);
+ gsk_gl_render_job_set_alpha (job, 1.0f);
+ gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
+ gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
+ gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+ gsk_gl_program_set_uniform_texture (job->current_program,
+ UNIFORM_SHARED_SOURCE, 0,
+ GL_TEXTURE_2D,
+ GL_TEXTURE0,
+ texture_id);
+ gsk_gl_render_job_draw_rect (job, &job->viewport);
+ gsk_gl_render_job_end_draw (job);
gdk_gl_context_push_debug_group (job->command_queue->context, "Executing command queue");
- gsk_ngl_command_queue_execute (job->command_queue, surface_height, 1, NULL);
+ gsk_gl_command_queue_execute (job->command_queue, surface_height, 1, NULL);
gdk_gl_context_pop_debug_group (job->command_queue->context);
glDeleteFramebuffers (1, &framebuffer_id);
@@ -4010,8 +4010,8 @@ gsk_ngl_render_job_render_flipped (GskNglRenderJob *job,
}
void
-gsk_ngl_render_job_render (GskNglRenderJob *job,
- GskRenderNode *root)
+gsk_gl_render_job_render (GskGLRenderJob *job,
+ GskRenderNode *root)
{
G_GNUC_UNUSED gint64 start_time;
guint scale_factor;
@@ -4019,21 +4019,21 @@ gsk_ngl_render_job_render (GskNglRenderJob *job,
g_return_if_fail (job != NULL);
g_return_if_fail (root != NULL);
- g_return_if_fail (GSK_IS_NGL_DRIVER (job->driver));
+ g_return_if_fail (GSK_IS_GL_DRIVER (job->driver));
scale_factor = MAX (job->scale_x, job->scale_y);
surface_height = job->viewport.size.height;
- gsk_ngl_command_queue_make_current (job->command_queue);
+ gsk_gl_command_queue_make_current (job->command_queue);
/* Build the command queue using the shared GL context for all renderers
* on the same display.
*/
start_time = GDK_PROFILER_CURRENT_TIME;
gdk_gl_context_push_debug_group (job->command_queue->context, "Building command queue");
- gsk_ngl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
- gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
- gsk_ngl_render_job_visit_node (job, root);
+ gsk_gl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
+ gsk_gl_command_queue_clear (job->command_queue, 0, &job->viewport);
+ gsk_gl_render_job_visit_node (job, root);
gdk_gl_context_pop_debug_group (job->command_queue->context);
gdk_profiler_add_mark (start_time, GDK_PROFILER_CURRENT_TIME-start_time, "Build GL command queue", "");
@@ -4041,7 +4041,7 @@ gsk_ngl_render_job_render (GskNglRenderJob *job,
/* At this point the atlases have uploaded content while we processed
* nodes but have not necessarily been used by the commands in the queue.
*/
- gsk_ngl_driver_save_atlases_to_png (job->driver, NULL);
+ gsk_gl_driver_save_atlases_to_png (job->driver, NULL);
#endif
/* But now for executing the command queue, we want to use the context
@@ -4049,16 +4049,16 @@ gsk_ngl_render_job_render (GskNglRenderJob *job,
* is bound to that context.
*/
start_time = GDK_PROFILER_CURRENT_TIME;
- gsk_ngl_command_queue_make_current (job->command_queue);
+ gsk_gl_command_queue_make_current (job->command_queue);
gdk_gl_context_push_debug_group (job->command_queue->context, "Executing command queue");
- gsk_ngl_command_queue_execute (job->command_queue, surface_height, scale_factor, job->region);
+ gsk_gl_command_queue_execute (job->command_queue, surface_height, scale_factor, job->region);
gdk_gl_context_pop_debug_group (job->command_queue->context);
gdk_profiler_add_mark (start_time, GDK_PROFILER_CURRENT_TIME-start_time, "Execute GL command queue", "");
}
void
-gsk_ngl_render_job_set_debug_fallback (GskNglRenderJob *job,
- gboolean debug_fallback)
+gsk_gl_render_job_set_debug_fallback (GskGLRenderJob *job,
+ gboolean debug_fallback)
{
g_return_if_fail (job != NULL);
@@ -4081,26 +4081,26 @@ get_framebuffer_format (guint framebuffer)
return GL_RGBA8;
}
-GskNglRenderJob *
-gsk_ngl_render_job_new (GskNglDriver *driver,
- const graphene_rect_t *viewport,
- float scale_factor,
- const cairo_region_t *region,
- guint framebuffer)
+GskGLRenderJob *
+gsk_gl_render_job_new (GskGLDriver *driver,
+ const graphene_rect_t *viewport,
+ float scale_factor,
+ const cairo_region_t *region,
+ guint framebuffer)
{
const graphene_rect_t *clip_rect = viewport;
graphene_rect_t transformed_extents;
- GskNglRenderJob *job;
+ GskGLRenderJob *job;
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), NULL);
g_return_val_if_fail (viewport != NULL, NULL);
g_return_val_if_fail (scale_factor > 0, NULL);
- job = g_slice_new0 (GskNglRenderJob);
+ job = g_slice_new0 (GskGLRenderJob);
job->driver = g_object_ref (driver);
job->command_queue = job->driver->command_queue;
- job->clip = g_array_sized_new (FALSE, FALSE, sizeof (GskNglRenderClip), 16);
- job->modelview = g_array_sized_new (FALSE, FALSE, sizeof (GskNglRenderModelview), 16);
+ job->clip = g_array_sized_new (FALSE, FALSE, sizeof (GskGLRenderClip), 16);
+ job->modelview = g_array_sized_new (FALSE, FALSE, sizeof (GskGLRenderModelview), 16);
job->framebuffer = framebuffer;
job->offset_x = 0;
job->offset_y = 0;
@@ -4109,9 +4109,9 @@ gsk_ngl_render_job_new (GskNglDriver *driver,
job->viewport = *viewport;
job->target_format = get_framebuffer_format (framebuffer);
- gsk_ngl_render_job_set_alpha (job, 1.0f);
- gsk_ngl_render_job_set_projection_from_rect (job, viewport, NULL);
- gsk_ngl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_factor, scale_factor));
+ gsk_gl_render_job_set_alpha (job, 1.0f);
+ gsk_gl_render_job_set_projection_from_rect (job, viewport, NULL);
+ gsk_gl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_factor, scale_factor));
/* Setup our initial clip. If region is NULL then we are drawing the
* whole viewport. Otherwise, we need to convert the region to a
@@ -4123,34 +4123,34 @@ gsk_ngl_render_job_new (GskNglDriver *driver,
cairo_rectangle_int_t extents;
cairo_region_get_extents (region, &extents);
- gsk_ngl_render_job_transform_bounds (job,
- &GRAPHENE_RECT_INIT (extents.x,
- extents.y,
- extents.width,
- extents.height),
- &transformed_extents);
+ gsk_gl_render_job_transform_bounds (job,
+ &GRAPHENE_RECT_INIT (extents.x,
+ extents.y,
+ extents.width,
+ extents.height),
+ &transformed_extents);
clip_rect = &transformed_extents;
job->region = cairo_region_create_rectangle (&extents);
}
- gsk_ngl_render_job_push_clip (job,
- &GSK_ROUNDED_RECT_INIT (clip_rect->origin.x,
- clip_rect->origin.y,
- clip_rect->size.width,
- clip_rect->size.height));
+ gsk_gl_render_job_push_clip (job,
+ &GSK_ROUNDED_RECT_INIT (clip_rect->origin.x,
+ clip_rect->origin.y,
+ clip_rect->size.width,
+ clip_rect->size.height));
return job;
}
void
-gsk_ngl_render_job_free (GskNglRenderJob *job)
+gsk_gl_render_job_free (GskGLRenderJob *job)
{
job->current_modelview = NULL;
job->current_clip = NULL;
while (job->modelview->len > 0)
{
- GskNglRenderModelview *modelview = &g_array_index (job->modelview, GskNglRenderModelview,
job->modelview->len-1);
+ GskGLRenderModelview *modelview = &g_array_index (job->modelview, GskGLRenderModelview,
job->modelview->len-1);
g_clear_pointer (&modelview->transform, gsk_transform_unref);
job->modelview->len--;
}
@@ -4159,5 +4159,5 @@ gsk_ngl_render_job_free (GskNglRenderJob *job)
g_clear_pointer (&job->region, cairo_region_destroy);
g_clear_pointer (&job->modelview, g_array_unref);
g_clear_pointer (&job->clip, g_array_unref);
- g_slice_free (GskNglRenderJob, job);
+ g_slice_free (GskGLRenderJob, job);
}
diff --git a/gsk/gl/gskglrenderjobprivate.h b/gsk/gl/gskglrenderjobprivate.h
new file mode 100644
index 0000000000..4e92b1b40c
--- /dev/null
+++ b/gsk/gl/gskglrenderjobprivate.h
@@ -0,0 +1,39 @@
+/* gskglrenderjobprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_RENDER_JOB_H__
+#define __GSK_GL_RENDER_JOB_H__
+
+#include "gskgltypesprivate.h"
+
+GskGLRenderJob *gsk_gl_render_job_new (GskGLDriver *driver,
+ const graphene_rect_t *viewport,
+ float scale_factor,
+ const cairo_region_t *region,
+ guint framebuffer);
+void gsk_gl_render_job_free (GskGLRenderJob *job);
+void gsk_gl_render_job_render (GskGLRenderJob *job,
+ GskRenderNode *root);
+void gsk_gl_render_job_render_flipped (GskGLRenderJob *job,
+ GskRenderNode *root);
+void gsk_gl_render_job_set_debug_fallback (GskGLRenderJob *job,
+ gboolean debug_fallback);
+
+#endif /* __GSK_GL_RENDER_JOB_H__ */
diff --git a/gsk/ngl/gsknglshadowlibrary.c b/gsk/gl/gskglshadowlibrary.c
similarity index 65%
rename from gsk/ngl/gsknglshadowlibrary.c
rename to gsk/gl/gskglshadowlibrary.c
index 64fb45b9be..86e4e5a476 100644
--- a/gsk/ngl/gsknglshadowlibrary.c
+++ b/gsk/gl/gskglshadowlibrary.c
@@ -1,4 +1,4 @@
-/* gsknglshadowlibrary.c
+/* gskglshadowlibrary.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -22,15 +22,15 @@
#include <string.h>
-#include "gskngldriverprivate.h"
-#include "gsknglshadowlibraryprivate.h"
+#include "gskgldriverprivate.h"
+#include "gskglshadowlibraryprivate.h"
#define MAX_UNUSED_FRAMES (16 * 5)
-struct _GskNglShadowLibrary
+struct _GskGLShadowLibrary
{
GObject parent_instance;
- GskNglDriver *driver;
+ GskGLDriver *driver;
GArray *shadows;
};
@@ -42,7 +42,7 @@ typedef struct _Shadow
gint64 last_used_in_frame;
} Shadow;
-G_DEFINE_TYPE (GskNglShadowLibrary, gsk_ngl_shadow_library, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GskGLShadowLibrary, gsk_gl_shadow_library, G_TYPE_OBJECT)
enum {
PROP_0,
@@ -52,10 +52,10 @@ enum {
static GParamSpec *properties [N_PROPS];
-GskNglShadowLibrary *
-gsk_ngl_shadow_library_new (GskNglDriver *driver)
+GskGLShadowLibrary *
+gsk_gl_shadow_library_new (GskGLDriver *driver)
{
- g_return_val_if_fail (GSK_IS_NGL_DRIVER (driver), NULL);
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), NULL);
return g_object_new (GSK_TYPE_GL_SHADOW_LIBRARY,
"driver", driver,
@@ -63,29 +63,29 @@ gsk_ngl_shadow_library_new (GskNglDriver *driver)
}
static void
-gsk_ngl_shadow_library_dispose (GObject *object)
+gsk_gl_shadow_library_dispose (GObject *object)
{
- GskNglShadowLibrary *self = (GskNglShadowLibrary *)object;
+ GskGLShadowLibrary *self = (GskGLShadowLibrary *)object;
for (guint i = 0; i < self->shadows->len; i++)
{
const Shadow *shadow = &g_array_index (self->shadows, Shadow, i);
- gsk_ngl_driver_release_texture_by_id (self->driver, shadow->texture_id);
+ gsk_gl_driver_release_texture_by_id (self->driver, shadow->texture_id);
}
g_clear_pointer (&self->shadows, g_array_unref);
g_clear_object (&self->driver);
- G_OBJECT_CLASS (gsk_ngl_shadow_library_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gsk_gl_shadow_library_parent_class)->dispose (object);
}
static void
-gsk_ngl_shadow_library_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gsk_gl_shadow_library_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GskNglShadowLibrary *self = GSK_NGL_SHADOW_LIBRARY (object);
+ GskGLShadowLibrary *self = GSK_GL_SHADOW_LIBRARY (object);
switch (prop_id)
{
@@ -99,12 +99,12 @@ gsk_ngl_shadow_library_get_property (GObject *object,
}
static void
-gsk_ngl_shadow_library_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gsk_gl_shadow_library_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GskNglShadowLibrary *self = GSK_NGL_SHADOW_LIBRARY (object);
+ GskGLShadowLibrary *self = GSK_GL_SHADOW_LIBRARY (object);
switch (prop_id)
{
@@ -118,43 +118,43 @@ gsk_ngl_shadow_library_set_property (GObject *object,
}
static void
-gsk_ngl_shadow_library_class_init (GskNglShadowLibraryClass *klass)
+gsk_gl_shadow_library_class_init (GskGLShadowLibraryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = gsk_ngl_shadow_library_dispose;
- object_class->get_property = gsk_ngl_shadow_library_get_property;
- object_class->set_property = gsk_ngl_shadow_library_set_property;
+ object_class->dispose = gsk_gl_shadow_library_dispose;
+ object_class->get_property = gsk_gl_shadow_library_get_property;
+ object_class->set_property = gsk_gl_shadow_library_set_property;
properties [PROP_DRIVER] =
g_param_spec_object ("driver",
"Driver",
"Driver",
- GSK_TYPE_NGL_DRIVER,
+ GSK_TYPE_GL_DRIVER,
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
-gsk_ngl_shadow_library_init (GskNglShadowLibrary *self)
+gsk_gl_shadow_library_init (GskGLShadowLibrary *self)
{
self->shadows = g_array_new (FALSE, FALSE, sizeof (Shadow));
}
void
-gsk_ngl_shadow_library_insert (GskNglShadowLibrary *self,
- const GskRoundedRect *outline,
- float blur_radius,
- guint texture_id)
+gsk_gl_shadow_library_insert (GskGLShadowLibrary *self,
+ const GskRoundedRect *outline,
+ float blur_radius,
+ guint texture_id)
{
Shadow *shadow;
- g_assert (GSK_IS_NGL_SHADOW_LIBRARY (self));
+ g_assert (GSK_IS_GL_SHADOW_LIBRARY (self));
g_assert (outline != NULL);
g_assert (texture_id != 0);
- gsk_ngl_driver_mark_texture_permanent (self->driver, texture_id);
+ gsk_gl_driver_mark_texture_permanent (self->driver, texture_id);
g_array_set_size (self->shadows, self->shadows->len + 1);
@@ -166,13 +166,13 @@ gsk_ngl_shadow_library_insert (GskNglShadowLibrary *self,
}
guint
-gsk_ngl_shadow_library_lookup (GskNglShadowLibrary *self,
- const GskRoundedRect *outline,
- float blur_radius)
+gsk_gl_shadow_library_lookup (GskGLShadowLibrary *self,
+ const GskRoundedRect *outline,
+ float blur_radius)
{
Shadow *ret = NULL;
- g_assert (GSK_IS_NGL_SHADOW_LIBRARY (self));
+ g_assert (GSK_IS_GL_SHADOW_LIBRARY (self));
g_assert (outline != NULL);
/* Ensure GskRoundedRect is 12 packed floats without padding
@@ -204,7 +204,7 @@ gsk_ngl_shadow_library_lookup (GskNglShadowLibrary *self,
#if 0
static void
-write_shadow_to_png (GskNglDriver *driver,
+write_shadow_to_png (GskGLDriver *driver,
const Shadow *shadow)
{
int width = shadow->outline.bounds.size.width + (shadow->outline.bounds.origin.x * 2);
@@ -213,7 +213,7 @@ write_shadow_to_png (GskNglDriver *driver,
width, height, shadow->texture_id);
GdkTexture *texture;
- texture = gdk_gl_texture_new (gsk_ngl_driver_get_context (driver),
+ texture = gdk_gl_texture_new (gsk_gl_driver_get_context (driver),
shadow->texture_id,
width, height,
NULL, NULL);
@@ -225,13 +225,13 @@ write_shadow_to_png (GskNglDriver *driver,
#endif
void
-gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self)
+gsk_gl_shadow_library_begin_frame (GskGLShadowLibrary *self)
{
gint64 watermark;
int i;
int p;
- g_return_if_fail (GSK_IS_NGL_SHADOW_LIBRARY (self));
+ g_return_if_fail (GSK_IS_GL_SHADOW_LIBRARY (self));
#if 0
for (i = 0, p = self->shadows->len; i < p; i++)
@@ -249,7 +249,7 @@ gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self)
if (shadow->last_used_in_frame < watermark)
{
- gsk_ngl_driver_release_texture_by_id (self->driver, shadow->texture_id);
+ gsk_gl_driver_release_texture_by_id (self->driver, shadow->texture_id);
g_array_remove_index_fast (self->shadows, i);
p--;
i--;
diff --git a/gsk/gl/gskglshadowlibraryprivate.h b/gsk/gl/gskglshadowlibraryprivate.h
new file mode 100644
index 0000000000..a328674731
--- /dev/null
+++ b/gsk/gl/gskglshadowlibraryprivate.h
@@ -0,0 +1,44 @@
+/* gskglshadowlibraryprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_SHADOW_LIBRARY_PRIVATE_H__
+#define __GSK_GL_SHADOW_LIBRARY_PRIVATE_H__
+
+#include "gskgltexturelibraryprivate.h"
+
+G_BEGIN_DECLS
+
+#define GSK_TYPE_GL_SHADOW_LIBRARY (gsk_gl_shadow_library_get_type())
+
+G_DECLARE_FINAL_TYPE (GskGLShadowLibrary, gsk_gl_shadow_library, GSK, GL_SHADOW_LIBRARY, GObject)
+
+GskGLShadowLibrary * gsk_gl_shadow_library_new (GskGLDriver *driver);
+void gsk_gl_shadow_library_begin_frame (GskGLShadowLibrary *self);
+guint gsk_gl_shadow_library_lookup (GskGLShadowLibrary *self,
+ const GskRoundedRect *outline,
+ float blur_radius);
+void gsk_gl_shadow_library_insert (GskGLShadowLibrary *self,
+ const GskRoundedRect *outline,
+ float blur_radius,
+ guint texture_id);
+
+G_END_DECLS
+
+#endif /* __GSK_GL_SHADOW_LIBRARY_PRIVATE_H__ */
diff --git a/gsk/ngl/gskngltexture.c b/gsk/gl/gskgltexture.c
similarity index 72%
rename from gsk/ngl/gskngltexture.c
rename to gsk/gl/gskgltexture.c
index c70d4d91b2..6ff56e6978 100644
--- a/gsk/ngl/gskngltexture.c
+++ b/gsk/gl/gskgltexture.c
@@ -1,4 +1,4 @@
-/* gskngltexture.c
+/* gskgltexture.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -22,11 +22,11 @@
#include <gdk/gdktextureprivate.h>
-#include "gskngltextureprivate.h"
+#include "gskgltextureprivate.h"
#include "ninesliceprivate.h"
void
-gsk_ngl_texture_free (GskNglTexture *texture)
+gsk_gl_texture_free (GskGLTexture *texture)
{
if (texture != NULL)
{
@@ -51,22 +51,22 @@ gsk_ngl_texture_free (GskNglTexture *texture)
g_clear_pointer (&texture->slices, g_free);
g_clear_pointer (&texture->nine_slice, g_free);
- g_slice_free (GskNglTexture, texture);
+ g_slice_free (GskGLTexture, texture);
}
}
-GskNglTexture *
-gsk_ngl_texture_new (guint texture_id,
- int width,
- int height,
- int format,
- int min_filter,
- int mag_filter,
- gint64 frame_id)
+GskGLTexture *
+gsk_gl_texture_new (guint texture_id,
+ int width,
+ int height,
+ int format,
+ int min_filter,
+ int mag_filter,
+ gint64 frame_id)
{
- GskNglTexture *texture;
+ GskGLTexture *texture;
- texture = g_slice_new0 (GskNglTexture);
+ texture = g_slice_new0 (GskGLTexture);
texture->texture_id = texture_id;
texture->link.data = texture;
texture->min_filter = min_filter;
@@ -79,18 +79,18 @@ gsk_ngl_texture_new (guint texture_id,
return texture;
}
-const GskNglTextureNineSlice *
-gsk_ngl_texture_get_nine_slice (GskNglTexture *texture,
- const GskRoundedRect *outline,
- float extra_pixels_x,
- float extra_pixels_y)
+const GskGLTextureNineSlice *
+gsk_gl_texture_get_nine_slice (GskGLTexture *texture,
+ const GskRoundedRect *outline,
+ float extra_pixels_x,
+ float extra_pixels_y)
{
g_assert (texture != NULL);
g_assert (outline != NULL);
if G_UNLIKELY (texture->nine_slice == NULL)
{
- texture->nine_slice = g_new0 (GskNglTextureNineSlice, 9);
+ texture->nine_slice = g_new0 (GskGLTextureNineSlice, 9);
nine_slice_rounded_rect (texture->nine_slice, outline);
nine_slice_grow (texture->nine_slice, extra_pixels_x, extra_pixels_y);
diff --git a/gsk/ngl/gskngltexturelibrary.c b/gsk/gl/gskgltexturelibrary.c
similarity index 59%
rename from gsk/ngl/gskngltexturelibrary.c
rename to gsk/gl/gskgltexturelibrary.c
index 03b8e252f7..3d32c95945 100644
--- a/gsk/ngl/gskngltexturelibrary.c
+++ b/gsk/gl/gskgltexturelibrary.c
@@ -1,4 +1,4 @@
-/* gskngltexturelibrary.c
+/* gskgltexturelibrary.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -23,13 +23,13 @@
#include <gdk/gdkglcontextprivate.h>
#include <gsk/gskdebugprivate.h>
-#include "gsknglcommandqueueprivate.h"
-#include "gskngldriverprivate.h"
-#include "gskngltexturelibraryprivate.h"
+#include "gskglcommandqueueprivate.h"
+#include "gskgldriverprivate.h"
+#include "gskgltexturelibraryprivate.h"
#define MAX_FRAME_AGE 60
-G_DEFINE_ABSTRACT_TYPE (GskNglTextureLibrary, gsk_ngl_texture_library, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE (GskGLTextureLibrary, gsk_gl_texture_library, G_TYPE_OBJECT)
enum {
PROP_0,
@@ -40,30 +40,30 @@ enum {
static GParamSpec *properties [N_PROPS];
static void
-gsk_ngl_texture_library_constructed (GObject *object)
+gsk_gl_texture_library_constructed (GObject *object)
{
- G_OBJECT_CLASS (gsk_ngl_texture_library_parent_class)->constructed (object);
+ G_OBJECT_CLASS (gsk_gl_texture_library_parent_class)->constructed (object);
- g_assert (GSK_NGL_TEXTURE_LIBRARY (object)->hash_table != NULL);
+ g_assert (GSK_GL_TEXTURE_LIBRARY (object)->hash_table != NULL);
}
static void
-gsk_ngl_texture_library_dispose (GObject *object)
+gsk_gl_texture_library_dispose (GObject *object)
{
- GskNglTextureLibrary *self = (GskNglTextureLibrary *)object;
+ GskGLTextureLibrary *self = (GskGLTextureLibrary *)object;
g_clear_object (&self->driver);
- G_OBJECT_CLASS (gsk_ngl_texture_library_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gsk_gl_texture_library_parent_class)->dispose (object);
}
static void
-gsk_ngl_texture_library_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gsk_gl_texture_library_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GskNglTextureLibrary *self = GSK_NGL_TEXTURE_LIBRARY (object);
+ GskGLTextureLibrary *self = GSK_GL_TEXTURE_LIBRARY (object);
switch (prop_id)
{
@@ -77,12 +77,12 @@ gsk_ngl_texture_library_get_property (GObject *object,
}
static void
-gsk_ngl_texture_library_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gsk_gl_texture_library_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GskNglTextureLibrary *self = GSK_NGL_TEXTURE_LIBRARY (object);
+ GskGLTextureLibrary *self = GSK_GL_TEXTURE_LIBRARY (object);
switch (prop_id)
{
@@ -96,38 +96,38 @@ gsk_ngl_texture_library_set_property (GObject *object,
}
static void
-gsk_ngl_texture_library_class_init (GskNglTextureLibraryClass *klass)
+gsk_gl_texture_library_class_init (GskGLTextureLibraryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->constructed = gsk_ngl_texture_library_constructed;
- object_class->dispose = gsk_ngl_texture_library_dispose;
- object_class->get_property = gsk_ngl_texture_library_get_property;
- object_class->set_property = gsk_ngl_texture_library_set_property;
+ object_class->constructed = gsk_gl_texture_library_constructed;
+ object_class->dispose = gsk_gl_texture_library_dispose;
+ object_class->get_property = gsk_gl_texture_library_get_property;
+ object_class->set_property = gsk_gl_texture_library_set_property;
properties [PROP_DRIVER] =
g_param_spec_object ("driver",
"Driver",
"Driver",
- GSK_TYPE_NGL_DRIVER,
+ GSK_TYPE_GL_DRIVER,
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
-gsk_ngl_texture_library_init (GskNglTextureLibrary *self)
+gsk_gl_texture_library_init (GskGLTextureLibrary *self)
{
}
void
-gsk_ngl_texture_library_set_funcs (GskNglTextureLibrary *self,
- GHashFunc hash_func,
- GEqualFunc equal_func,
- GDestroyNotify key_destroy,
- GDestroyNotify value_destroy)
+gsk_gl_texture_library_set_funcs (GskGLTextureLibrary *self,
+ GHashFunc hash_func,
+ GEqualFunc equal_func,
+ GDestroyNotify key_destroy,
+ GDestroyNotify value_destroy)
{
- g_return_if_fail (GSK_IS_NGL_TEXTURE_LIBRARY (self));
+ g_return_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self));
g_return_if_fail (self->hash_table == NULL);
self->hash_table = g_hash_table_new_full (hash_func, equal_func,
@@ -135,20 +135,20 @@ gsk_ngl_texture_library_set_funcs (GskNglTextureLibrary *self,
}
void
-gsk_ngl_texture_library_begin_frame (GskNglTextureLibrary *self,
- gint64 frame_id,
- GPtrArray *removed_atlases)
+gsk_gl_texture_library_begin_frame (GskGLTextureLibrary *self,
+ gint64 frame_id,
+ GPtrArray *removed_atlases)
{
GHashTableIter iter;
- g_return_if_fail (GSK_IS_NGL_TEXTURE_LIBRARY (self));
+ g_return_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self));
- if (GSK_NGL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame)
- GSK_NGL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame (self, frame_id, removed_atlases);
+ if (GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame)
+ GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->begin_frame (self, frame_id, removed_atlases);
if (removed_atlases != NULL)
{
- GskNglTextureAtlasEntry *entry;
+ GskGLTextureAtlasEntry *entry;
guint dropped = 0;
g_hash_table_iter_init (&iter, self->hash_table);
@@ -158,7 +158,7 @@ gsk_ngl_texture_library_begin_frame (GskNglTextureLibrary *self,
{
for (guint i = 0; i < removed_atlases->len; i++)
{
- GskNglTextureAtlas *atlas = g_ptr_array_index (removed_atlases, i);
+ GskGLTextureAtlas *atlas = g_ptr_array_index (removed_atlases, i);
if (atlas == entry->atlas)
{
@@ -178,7 +178,7 @@ gsk_ngl_texture_library_begin_frame (GskNglTextureLibrary *self,
if (frame_id % MAX_FRAME_AGE == 0)
{
- GskNglTextureAtlasEntry *entry;
+ GskGLTextureAtlasEntry *entry;
int atlased = 0;
int dropped = 0;
@@ -187,13 +187,13 @@ gsk_ngl_texture_library_begin_frame (GskNglTextureLibrary *self,
{
if (!entry->is_atlased && !entry->accessed)
{
- gsk_ngl_driver_release_texture (self->driver, entry->texture);
+ gsk_gl_driver_release_texture (self->driver, entry->texture);
g_hash_table_iter_remove (&iter);
dropped++;
continue;
}
- gsk_ngl_texture_atlas_entry_mark_unused (entry);
+ gsk_gl_texture_atlas_entry_mark_unused (entry);
entry->accessed = FALSE;
if (entry->is_atlased)
atlased++;
@@ -210,14 +210,14 @@ gsk_ngl_texture_library_begin_frame (GskNglTextureLibrary *self,
}
}
-static GskNglTexture *
-gsk_ngl_texture_library_pack_one (GskNglTextureLibrary *self,
- guint width,
- guint height)
+static GskGLTexture *
+gsk_gl_texture_library_pack_one (GskGLTextureLibrary *self,
+ guint width,
+ guint height)
{
- GskNglTexture *texture;
+ GskGLTexture *texture;
- g_assert (GSK_IS_NGL_TEXTURE_LIBRARY (self));
+ g_assert (GSK_IS_GL_TEXTURE_LIBRARY (self));
if (width > self->driver->command_queue->max_texture_size ||
height > self->driver->command_queue->max_texture_size)
@@ -228,18 +228,18 @@ gsk_ngl_texture_library_pack_one (GskNglTextureLibrary *self,
height = MIN (height, self->driver->command_queue->max_texture_size);
}
- texture = gsk_ngl_driver_create_texture (self->driver, width, height, GL_RGBA8, GL_LINEAR, GL_LINEAR);
+ texture = gsk_gl_driver_create_texture (self->driver, width, height, GL_RGBA8, GL_LINEAR, GL_LINEAR);
texture->permanent = TRUE;
return texture;
}
static inline gboolean
-gsk_ngl_texture_atlas_pack (GskNglTextureAtlas *self,
- int width,
- int height,
- int *out_x,
- int *out_y)
+gsk_gl_texture_atlas_pack (GskGLTextureAtlas *self,
+ int width,
+ int height,
+ int *out_x,
+ int *out_y)
{
stbrp_rect rect;
@@ -258,8 +258,8 @@ gsk_ngl_texture_atlas_pack (GskNglTextureAtlas *self,
}
static void
-gsk_ngl_texture_atlas_initialize (GskNglDriver *driver,
- GskNglTextureAtlas *atlas)
+gsk_gl_texture_atlas_initialize (GskGLDriver *driver,
+ GskGLTextureAtlas *atlas)
{
/* Insert a single pixel at 0,0 for use in coloring */
@@ -272,7 +272,7 @@ gsk_ngl_texture_atlas_initialize (GskNglDriver *driver,
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
"Initializing Atlas");
- packed = gsk_ngl_texture_atlas_pack (atlas, 3, 3, &x, &y);
+ packed = gsk_gl_texture_atlas_pack (atlas, 3, 3, &x, &y);
g_assert (packed);
g_assert (x == 0 && y == 0);
@@ -303,21 +303,21 @@ gsk_ngl_texture_atlas_initialize (GskNglDriver *driver,
}
static void
-gsk_ngl_texture_atlases_pack (GskNglDriver *driver,
- int width,
- int height,
- GskNglTextureAtlas **out_atlas,
- int *out_x,
- int *out_y)
+gsk_gl_texture_atlases_pack (GskGLDriver *driver,
+ int width,
+ int height,
+ GskGLTextureAtlas **out_atlas,
+ int *out_x,
+ int *out_y)
{
- GskNglTextureAtlas *atlas = NULL;
+ GskGLTextureAtlas *atlas = NULL;
int x, y;
for (guint i = 0; i < driver->atlases->len; i++)
{
atlas = g_ptr_array_index (driver->atlases, i);
- if (gsk_ngl_texture_atlas_pack (atlas, width, height, &x, &y))
+ if (gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y))
break;
atlas = NULL;
@@ -326,12 +326,12 @@ gsk_ngl_texture_atlases_pack (GskNglDriver *driver,
if (atlas == NULL)
{
/* No atlas has enough space, so create a new one... */
- atlas = gsk_ngl_driver_create_atlas (driver);
+ atlas = gsk_gl_driver_create_atlas (driver);
- gsk_ngl_texture_atlas_initialize (driver, atlas);
+ gsk_gl_texture_atlas_initialize (driver, atlas);
/* Pack it onto that one, which surely has enough space... */
- if (!gsk_ngl_texture_atlas_pack (atlas, width, height, &x, &y))
+ if (!gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y))
g_assert_not_reached ();
}
@@ -341,21 +341,21 @@ gsk_ngl_texture_atlases_pack (GskNglDriver *driver,
}
gpointer
-gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
- gpointer key,
- gsize valuelen,
- guint width,
- guint height,
- int padding,
- guint *out_packed_x,
- guint *out_packed_y)
+gsk_gl_texture_library_pack (GskGLTextureLibrary *self,
+ gpointer key,
+ gsize valuelen,
+ guint width,
+ guint height,
+ int padding,
+ guint *out_packed_x,
+ guint *out_packed_y)
{
- GskNglTextureAtlasEntry *entry;
- GskNglTextureAtlas *atlas = NULL;
+ GskGLTextureAtlasEntry *entry;
+ GskGLTextureAtlas *atlas = NULL;
- g_assert (GSK_IS_NGL_TEXTURE_LIBRARY (self));
+ g_assert (GSK_IS_GL_TEXTURE_LIBRARY (self));
g_assert (key != NULL);
- g_assert (valuelen > sizeof (GskNglTextureAtlasEntry));
+ g_assert (valuelen > sizeof (GskGLTextureAtlasEntry));
g_assert (out_packed_x != NULL);
g_assert (out_packed_y != NULL);
@@ -385,12 +385,12 @@ gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
int packed_x;
int packed_y;
- gsk_ngl_texture_atlases_pack (self->driver,
- padding + width + padding,
- padding + height + padding,
- &atlas,
- &packed_x,
- &packed_y);
+ gsk_gl_texture_atlases_pack (self->driver,
+ padding + width + padding,
+ padding + height + padding,
+ &atlas,
+ &packed_x,
+ &packed_y);
entry->atlas = atlas;
entry->is_atlased = TRUE;
@@ -404,9 +404,9 @@ gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
}
else
{
- GskNglTexture *texture = gsk_ngl_texture_library_pack_one (self,
- padding + width + padding,
- padding + height + padding);
+ GskGLTexture *texture = gsk_gl_texture_library_pack_one (self,
+ padding + width + padding,
+ padding + height + padding);
entry->texture = texture;
entry->is_atlased = FALSE;
diff --git a/gsk/gl/gskgltexturelibraryprivate.h b/gsk/gl/gskgltexturelibraryprivate.h
new file mode 100644
index 0000000000..a784449889
--- /dev/null
+++ b/gsk/gl/gskgltexturelibraryprivate.h
@@ -0,0 +1,208 @@
+/* gskgltexturelibraryprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This file is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This file is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_TEXTURE_LIBRARY_PRIVATE_H__
+#define __GSK_GL_TEXTURE_LIBRARY_PRIVATE_H__
+
+#include "gskgltypesprivate.h"
+#include "gskgltextureprivate.h"
+
+#include "stb_rect_pack.h"
+
+G_BEGIN_DECLS
+
+#define GSK_TYPE_GL_TEXTURE_LIBRARY (gsk_gl_texture_library_get_type ())
+#define GSK_GL_TEXTURE_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GSK_TYPE_GL_TEXTURE_LIBRARY, GskGLTextureLibrary))
+#define GSK_IS_GL_TEXTURE_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GSK_TYPE_GL_TEXTURE_LIBRARY))
+#define GSK_GL_TEXTURE_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GSK_TYPE_GL_TEXTURE_LIBRARY, GskGLTextureLibraryClass))
+#define GSK_IS_GL_TEXTURE_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GSK_TYPE_GL_TEXTURE_LIBRARY))
+#define GSK_GL_TEXTURE_LIBRARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GSK_TYPE_GL_TEXTURE_LIBRARY, GskGLTextureLibraryClass))
+
+typedef struct _GskGLTextureAtlas
+{
+ struct stbrp_context context;
+ struct stbrp_node *nodes;
+
+ int width;
+ int height;
+
+ guint texture_id;
+
+ /* Pixels of rects that have been used at some point,
+ * But are now unused.
+ */
+ int unused_pixels;
+
+ void *user_data;
+} GskGLTextureAtlas;
+
+typedef struct _GskGLTextureAtlasEntry
+{
+ /* A backreference to either the atlas or texture containing
+ * the contents of the atlas entry. For larger items, no atlas
+ * is used and instead a direct texture.
+ */
+ union {
+ GskGLTextureAtlas *atlas;
+ GskGLTexture *texture;
+ };
+
+ /* The area within the atlas translated to 0..1 bounds */
+ struct {
+ float x;
+ float y;
+ float x2;
+ float y2;
+ } area;
+
+ /* Number of pixels in the entry, used to calculate usage
+ * of an atlas while processing.
+ */
+ guint n_pixels : 29;
+
+ /* If entry has marked pixels as used in the atlas this frame */
+ guint used : 1;
+
+ /* If entry was accessed this frame */
+ guint accessed : 1;
+
+ /* When true, backref is an atlas, otherwise texture */
+ guint is_atlased : 1;
+} GskGLTextureAtlasEntry;
+
+typedef struct _GskGLTextureLibrary
+{
+ GObject parent_instance;
+ GskGLDriver *driver;
+ GHashTable *hash_table;
+ guint max_entry_size;
+} GskGLTextureLibrary;
+
+typedef struct _GskGLTextureLibraryClass
+{
+ GObjectClass parent_class;
+
+ void (*begin_frame) (GskGLTextureLibrary *library,
+ gint64 frame_id,
+ GPtrArray *removed_atlases);
+} GskGLTextureLibraryClass;
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GskGLTextureLibrary, g_object_unref)
+
+GType gsk_gl_texture_library_get_type (void) G_GNUC_CONST;
+void gsk_gl_texture_library_set_funcs (GskGLTextureLibrary *self,
+ GHashFunc hash_func,
+ GEqualFunc equal_func,
+ GDestroyNotify key_destroy,
+ GDestroyNotify value_destroy);
+void gsk_gl_texture_library_begin_frame (GskGLTextureLibrary *self,
+ gint64 frame_id,
+ GPtrArray *removed_atlases);
+gpointer gsk_gl_texture_library_pack (GskGLTextureLibrary *self,
+ gpointer key,
+ gsize valuelen,
+ guint width,
+ guint height,
+ int padding,
+ guint *out_packed_x,
+ guint *out_packed_y);
+
+static inline void
+gsk_gl_texture_atlas_mark_unused (GskGLTextureAtlas *self,
+ int n_pixels)
+{
+ g_assert (n_pixels >= 0);
+
+ self->unused_pixels += n_pixels;
+}
+
+static inline void
+gsk_gl_texture_atlas_entry_mark_used (GskGLTextureAtlasEntry *entry)
+{
+ if (entry->used == TRUE || entry->is_atlased == FALSE)
+ return;
+
+ entry->atlas->unused_pixels -= entry->n_pixels;
+ entry->used = TRUE;
+}
+
+static inline void
+gsk_gl_texture_atlas_entry_mark_unused (GskGLTextureAtlasEntry *entry)
+{
+ if (entry->used == FALSE || entry->is_atlased == FALSE)
+ return;
+
+ entry->atlas->unused_pixels += entry->n_pixels;
+ entry->used = FALSE;
+}
+
+static inline gboolean
+gsk_gl_texture_library_lookup (GskGLTextureLibrary *self,
+ gconstpointer key,
+ GskGLTextureAtlasEntry **out_entry)
+{
+ GskGLTextureAtlasEntry *entry = g_hash_table_lookup (self->hash_table, key);
+
+ if G_LIKELY (entry != NULL && entry->accessed && entry->used)
+ {
+ *out_entry = entry;
+ return TRUE;
+ }
+
+ if (entry != NULL)
+ {
+ gsk_gl_texture_atlas_entry_mark_used (entry);
+ entry->accessed = TRUE;
+ *out_entry = entry;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static inline guint
+GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (gconstpointer d)
+{
+ const GskGLTextureAtlasEntry *e = d;
+
+ return e->is_atlased ? e->atlas->texture_id
+ : e->texture ? e->texture->texture_id : 0;
+}
+
+static inline double
+gsk_gl_texture_atlas_get_unused_ratio (const GskGLTextureAtlas *self)
+{
+ if (self->unused_pixels > 0)
+ return (double)(self->unused_pixels) / (double)(self->width * self->height);
+ return 0.0;
+}
+
+static inline gboolean
+gsk_gl_texture_library_can_cache (GskGLTextureLibrary *self,
+ int width,
+ int height)
+{
+ g_assert (self->max_entry_size > 0);
+ return width <= self->max_entry_size && height <= self->max_entry_size;
+}
+
+G_END_DECLS
+
+#endif /* __GSK_GL_TEXTURE_LIBRARY_PRIVATE_H__ */
diff --git a/gsk/ngl/gskngltextureprivate.h b/gsk/gl/gskgltextureprivate.h
similarity index 51%
rename from gsk/ngl/gskngltextureprivate.h
rename to gsk/gl/gskgltextureprivate.h
index 55ef48c4d3..c8605cec27 100644
--- a/gsk/ngl/gskngltextureprivate.h
+++ b/gsk/gl/gskgltextureprivate.h
@@ -1,4 +1,4 @@
-/* gskngltextureprivate.h
+/* gskgltextureprivate.h
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -18,20 +18,20 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#ifndef _GSK_NGL_TEXTURE_PRIVATE_H__
-#define _GSK_NGL_TEXTURE_PRIVATE_H__
+#ifndef _GSK_GL_TEXTURE_PRIVATE_H__
+#define _GSK_GL_TEXTURE_PRIVATE_H__
-#include "gskngltypesprivate.h"
+#include "gskgltypesprivate.h"
G_BEGIN_DECLS
-struct _GskNglTextureSlice
+struct _GskGLTextureSlice
{
cairo_rectangle_int_t rect;
guint texture_id;
};
-struct _GskNglTextureNineSlice
+struct _GskGLTextureNineSlice
{
cairo_rectangle_int_t rect;
struct {
@@ -42,7 +42,7 @@ struct _GskNglTextureNineSlice
} area;
};
-struct _GskNglTexture
+struct _GskGLTexture
{
/* Used to insert into queue */
GList link;
@@ -54,10 +54,10 @@ struct _GskNglTexture
GdkTexture *user;
/* Only used by nine-slice textures */
- GskNglTextureNineSlice *nine_slice;
+ GskGLTextureNineSlice *nine_slice;
/* Only used by sliced textures */
- GskNglTextureSlice *slices;
+ GskGLTextureSlice *slices;
guint n_slices;
/* The actual GL texture identifier in some shared context */
@@ -73,19 +73,19 @@ struct _GskNglTexture
guint permanent : 1;
};
-GskNglTexture *gsk_ngl_texture_new (guint texture_id,
- int width,
- int height,
- int format,
- int min_filter,
- int mag_filter,
- gint64 frame_id);
-const GskNglTextureNineSlice *gsk_ngl_texture_get_nine_slice (GskNglTexture *texture,
- const GskRoundedRect *outline,
- float extra_pixels_x,
- float extra_pixels_y);
-void gsk_ngl_texture_free (GskNglTexture *texture);
+GskGLTexture * gsk_gl_texture_new (guint texture_id,
+ int width,
+ int height,
+ int format,
+ int min_filter,
+ int mag_filter,
+ gint64 frame_id);
+const GskGLTextureNineSlice * gsk_gl_texture_get_nine_slice (GskGLTexture *texture,
+ const GskRoundedRect *outline,
+ float extra_pixels_x,
+ float extra_pixels_y);
+void gsk_gl_texture_free (GskGLTexture *texture);
G_END_DECLS
-#endif /* _GSK_NGL_TEXTURE_PRIVATE_H__ */
+#endif /* _GSK_GL_TEXTURE_PRIVATE_H__ */
diff --git a/gsk/gl/gskgltypesprivate.h b/gsk/gl/gskgltypesprivate.h
new file mode 100644
index 0000000000..1250756fb7
--- /dev/null
+++ b/gsk/gl/gskgltypesprivate.h
@@ -0,0 +1,66 @@
+/* gskgltypesprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GSK_GL_TYPES_PRIVATE_H__
+#define __GSK_GL_TYPES_PRIVATE_H__
+
+#include <epoxy/gl.h>
+#include <graphene.h>
+#include <gdk/gdk.h>
+#include <gsk/gsk.h>
+
+G_BEGIN_DECLS
+
+#define GSK_GL_N_VERTICES 6
+
+typedef struct _GskGLAttachmentState GskGLAttachmentState;
+typedef struct _GskGLBuffer GskGLBuffer;
+typedef struct _GskGLCommandQueue GskGLCommandQueue;
+typedef struct _GskGLCompiler GskGLCompiler;
+typedef struct _GskGLDrawVertex GskGLDrawVertex;
+typedef struct _GskGLRenderTarget GskGLRenderTarget;
+typedef struct _GskGLGlyphLibrary GskGLGlyphLibrary;
+typedef struct _GskGLIconLibrary GskGLIconLibrary;
+typedef struct _GskGLProgram GskGLProgram;
+typedef struct _GskGLRenderJob GskGLRenderJob;
+typedef struct _GskGLShadowLibrary GskGLShadowLibrary;
+typedef struct _GskGLTexture GskGLTexture;
+typedef struct _GskGLTextureSlice GskGLTextureSlice;
+typedef struct _GskGLTextureAtlas GskGLTextureAtlas;
+typedef struct _GskGLTextureLibrary GskGLTextureLibrary;
+typedef struct _GskGLTextureNineSlice GskGLTextureNineSlice;
+typedef struct _GskGLUniformInfo GskGLUniformInfo;
+typedef struct _GskGLUniformProgram GskGLUniformProgram;
+typedef struct _GskGLUniformState GskGLUniformState;
+typedef struct _GskGLDriver GskGLDriver;
+
+struct _GskGLDrawVertex
+{
+ float position[2];
+ union {
+ float uv[2];
+ guint16 color2[4];
+ };
+ guint16 color[4];
+};
+
+G_END_DECLS
+
+#endif /* __GSK_GL_TYPES_PRIVATE_H__ */
diff --git a/gsk/ngl/gskngluniformstate.c b/gsk/gl/gskgluniformstate.c
similarity index 73%
rename from gsk/ngl/gskngluniformstate.c
rename to gsk/gl/gskgluniformstate.c
index 9a70088779..77cd45a859 100644
--- a/gsk/ngl/gskngluniformstate.c
+++ b/gsk/gl/gskgluniformstate.c
@@ -1,4 +1,4 @@
-/* gskngluniformstate.c
+/* gskgluniformstate.c
*
* Copyright 2020 Christian Hergert <chergert redhat com>
*
@@ -23,7 +23,7 @@
#include <gsk/gskroundedrectprivate.h>
#include <string.h>
-#include "gskngluniformstateprivate.h"
+#include "gskgluniformstateprivate.h"
static const guint8 uniform_sizes[] = {
0,
@@ -54,12 +54,12 @@ static const guint8 uniform_sizes[] = {
0,
};
-GskNglUniformState *
-gsk_ngl_uniform_state_new (void)
+GskGLUniformState *
+gsk_gl_uniform_state_new (void)
{
- GskNglUniformState *state;
+ GskGLUniformState *state;
- state = g_atomic_rc_box_new0 (GskNglUniformState);
+ state = g_atomic_rc_box_new0 (GskGLUniformState);
state->programs = g_hash_table_new_full (NULL, NULL, NULL, g_free);
state->values_len = 4096;
state->values_pos = 0;
@@ -70,41 +70,41 @@ gsk_ngl_uniform_state_new (void)
return g_steal_pointer (&state);
}
-GskNglUniformState *
-gsk_ngl_uniform_state_ref (GskNglUniformState *state)
+GskGLUniformState *
+gsk_gl_uniform_state_ref (GskGLUniformState *state)
{
return g_atomic_rc_box_acquire (state);
}
static void
-gsk_ngl_uniform_state_finalize (gpointer data)
+gsk_gl_uniform_state_finalize (gpointer data)
{
- GskNglUniformState *state = data;
+ GskGLUniformState *state = data;
g_clear_pointer (&state->programs, g_hash_table_unref);
g_clear_pointer (&state->values_buf, g_free);
}
void
-gsk_ngl_uniform_state_unref (GskNglUniformState *state)
+gsk_gl_uniform_state_unref (GskGLUniformState *state)
{
- g_atomic_rc_box_release_full (state, gsk_ngl_uniform_state_finalize);
+ g_atomic_rc_box_release_full (state, gsk_gl_uniform_state_finalize);
}
gpointer
-gsk_ngl_uniform_state_init_value (GskNglUniformState *state,
- GskNglUniformProgram *program,
- GskNglUniformFormat format,
- guint array_count,
- guint key,
- GskNglUniformMapping **infoptr)
+gsk_gl_uniform_state_init_value (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ GskGLUniformFormat format,
+ guint array_count,
+ guint key,
+ GskGLUniformMapping **infoptr)
{
- GskNglUniformMapping *mapping;
+ GskGLUniformMapping *mapping;
guint offset;
g_assert (state != NULL);
g_assert (array_count < 32);
- g_assert ((int)format >= 0 && format < GSK_NGL_UNIFORM_FORMAT_LAST);
+ g_assert ((int)format >= 0 && format < GSK_GL_UNIFORM_FORMAT_LAST);
g_assert (format > 0);
g_assert (program != NULL);
g_assert (key < program->n_mappings);
@@ -122,7 +122,7 @@ gsk_ngl_uniform_state_init_value (GskNglUniformState *state,
if G_LIKELY (array_count <= mapping->info.array_count)
{
*infoptr = mapping;
- return GSK_NGL_UNIFORM_VALUE (state->values_buf, mapping->info.offset);
+ return GSK_GL_UNIFORM_VALUE (state->values_buf, mapping->info.offset);
}
/* We found the uniform, but there is not enough space for the
@@ -152,12 +152,12 @@ gsk_ngl_uniform_state_init_value (GskNglUniformState *state,
setup_info:
- gsk_ngl_uniform_state_realloc (state,
- uniform_sizes[format] * MAX (1, array_count),
- &offset);
+ gsk_gl_uniform_state_realloc (state,
+ uniform_sizes[format] * MAX (1, array_count),
+ &offset);
/* we have 21 bits for offset */
- g_assert (offset < (1 << GSK_NGL_UNIFORM_OFFSET_BITS));
+ g_assert (offset < (1 << GSK_GL_UNIFORM_OFFSET_BITS));
mapping->info.format = format;
mapping->info.offset = offset;
@@ -167,14 +167,14 @@ setup_info:
*infoptr = mapping;
- return GSK_NGL_UNIFORM_VALUE (state->values_buf, mapping->info.offset);
+ return GSK_GL_UNIFORM_VALUE (state->values_buf, mapping->info.offset);
}
void
-gsk_ngl_uniform_state_end_frame (GskNglUniformState *state)
+gsk_gl_uniform_state_end_frame (GskGLUniformState *state)
{
GHashTableIter iter;
- GskNglUniformProgram *program;
+ GskGLUniformProgram *program;
guint allocator = 0;
g_return_if_fail (state != NULL);
@@ -190,7 +190,7 @@ gsk_ngl_uniform_state_end_frame (GskNglUniformState *state)
{
for (guint j = 0; j < program->n_mappings; j++)
{
- GskNglUniformMapping *mapping = &program->mappings[j];
+ GskGLUniformMapping *mapping = &program->mappings[j];
guint size;
/* Skip unused uniform mappings */
@@ -201,7 +201,7 @@ gsk_ngl_uniform_state_end_frame (GskNglUniformState *state)
size = uniform_sizes[mapping->info.format] * MAX (1, mapping->info.array_count);
/* Adjust alignment for value */
- allocator += gsk_ngl_uniform_state_align (allocator, size);
+ allocator += gsk_gl_uniform_state_align (allocator, size);
/* Offset is in slots of 4 bytes */
mapping->info.offset = allocator / 4;
@@ -231,21 +231,21 @@ gsk_ngl_uniform_state_end_frame (GskNglUniformState *state)
}
gsize
-gsk_ngl_uniform_format_size (GskNglUniformFormat format)
+gsk_gl_uniform_format_size (GskGLUniformFormat format)
{
g_assert (format > 0);
- g_assert (format < GSK_NGL_UNIFORM_FORMAT_LAST);
+ g_assert (format < GSK_GL_UNIFORM_FORMAT_LAST);
return uniform_sizes[format];
}
-GskNglUniformProgram *
-gsk_ngl_uniform_state_get_program (GskNglUniformState *state,
- guint program,
- const GskNglUniformMapping *mappings,
- guint n_mappings)
+GskGLUniformProgram *
+gsk_gl_uniform_state_get_program (GskGLUniformState *state,
+ guint program,
+ const GskGLUniformMapping *mappings,
+ guint n_mappings)
{
- GskNglUniformProgram *ret;
+ GskGLUniformProgram *ret;
g_return_val_if_fail (state != NULL, NULL);
g_return_val_if_fail (program > 0, NULL);
@@ -256,7 +256,7 @@ gsk_ngl_uniform_state_get_program (GskNglUniformState *state,
if (ret == NULL)
{
- ret = g_new0 (GskNglUniformProgram, 1);
+ ret = g_new0 (GskGLUniformProgram, 1);
ret->program_id = program;
ret->n_mappings = n_mappings;
diff --git a/gsk/gl/gskgluniformstateprivate.h b/gsk/gl/gskgluniformstateprivate.h
new file mode 100644
index 0000000000..af5c82ab07
--- /dev/null
+++ b/gsk/gl/gskgluniformstateprivate.h
@@ -0,0 +1,836 @@
+/* gskgluniformstateprivate.h
+ *
+ * Copyright 2020 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef GSK_GL_UNIFORM_STATE_PRIVATE_H
+#define GSK_GL_UNIFORM_STATE_PRIVATE_H
+
+#include "gskgltypesprivate.h"
+
+G_BEGIN_DECLS
+
+typedef struct { float v0; } Uniform1f;
+typedef struct { float v0; float v1; } Uniform2f;
+typedef struct { float v0; float v1; float v2; } Uniform3f;
+typedef struct { float v0; float v1; float v2; float v3; } Uniform4f;
+
+typedef struct { int v0; } Uniform1i;
+typedef struct { int v0; int v1; } Uniform2i;
+typedef struct { int v0; int v1; int v2; } Uniform3i;
+typedef struct { int v0; int v1; int v2; int v3; } Uniform4i;
+
+typedef struct { guint v0; } Uniform1ui;
+
+#define GSK_GL_UNIFORM_ARRAY_BITS 5
+#define GSK_GL_UNIFORM_FORMAT_BITS 5
+#define GSK_GL_UNIFORM_OFFSET_BITS 21
+
+typedef struct _GskGLUniformInfo
+{
+ guint initial : 1;
+ guint format : GSK_GL_UNIFORM_FORMAT_BITS;
+ guint array_count : GSK_GL_UNIFORM_ARRAY_BITS;
+ guint offset : GSK_GL_UNIFORM_OFFSET_BITS;
+} GskGLUniformInfo;
+
+G_STATIC_ASSERT (sizeof (GskGLUniformInfo) == 4);
+
+typedef struct _GskGLUniformMapping
+{
+ const char *name;
+ GskGLUniformInfo info;
+ guint stamp;
+ int location;
+} GskGLUniformMapping;
+
+typedef struct _GskGLUniformProgram
+{
+ guint program_id;
+ guint n_uniforms : 12;
+ guint has_attachments : 1;
+ guint n_mappings;
+ GskGLUniformMapping mappings[32];
+} GskGLUniformProgram;
+
+typedef struct _GskGLUniformState
+{
+ GHashTable *programs;
+ guint8 *values_buf;
+ guint values_pos;
+ guint values_len;
+ GskGLUniformInfo apply_hash[512];
+} GskGLUniformState;
+
+typedef enum _GskGLUniformKind
+{
+ GSK_GL_UNIFORM_FORMAT_1F = 1,
+ GSK_GL_UNIFORM_FORMAT_2F,
+ GSK_GL_UNIFORM_FORMAT_3F,
+ GSK_GL_UNIFORM_FORMAT_4F,
+
+ GSK_GL_UNIFORM_FORMAT_1FV,
+ GSK_GL_UNIFORM_FORMAT_2FV,
+ GSK_GL_UNIFORM_FORMAT_3FV,
+ GSK_GL_UNIFORM_FORMAT_4FV,
+
+ GSK_GL_UNIFORM_FORMAT_1I,
+ GSK_GL_UNIFORM_FORMAT_2I,
+ GSK_GL_UNIFORM_FORMAT_3I,
+ GSK_GL_UNIFORM_FORMAT_4I,
+
+ GSK_GL_UNIFORM_FORMAT_1UI,
+
+ GSK_GL_UNIFORM_FORMAT_TEXTURE,
+
+ GSK_GL_UNIFORM_FORMAT_MATRIX,
+ GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT,
+ GSK_GL_UNIFORM_FORMAT_COLOR,
+
+ GSK_GL_UNIFORM_FORMAT_LAST
+} GskGLUniformFormat;
+
+G_STATIC_ASSERT (GSK_GL_UNIFORM_FORMAT_LAST < (1 << GSK_GL_UNIFORM_FORMAT_BITS));
+
+GskGLUniformState *gsk_gl_uniform_state_new (void);
+GskGLUniformState *gsk_gl_uniform_state_ref (GskGLUniformState *state);
+void gsk_gl_uniform_state_unref (GskGLUniformState *state);
+GskGLUniformProgram *gsk_gl_uniform_state_get_program (GskGLUniformState *state,
+ guint program,
+ const GskGLUniformMapping *mappings,
+ guint n_mappings);
+void gsk_gl_uniform_state_end_frame (GskGLUniformState *state);
+gsize gsk_gl_uniform_format_size (GskGLUniformFormat format);
+gpointer gsk_gl_uniform_state_init_value (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ GskGLUniformFormat format,
+ guint array_count,
+ guint key,
+ GskGLUniformMapping **out_mapping);
+
+#define GSK_GL_UNIFORM_VALUE(base, offset) ((gpointer)((base) + ((offset) * 4)))
+#define gsk_gl_uniform_state_get_uniform_data(state,offset) GSK_GL_UNIFORM_VALUE((state)->values_buf, offset)
+
+static inline gpointer
+gsk_gl_uniform_state_get_value (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ GskGLUniformFormat format,
+ guint array_count,
+ guint key,
+ guint stamp,
+ GskGLUniformMapping **out_mapping)
+{
+ GskGLUniformMapping *mapping;
+
+ g_assert (key < G_N_ELEMENTS (program->mappings));
+ g_assert (key < program->n_mappings);
+
+ mapping = &program->mappings[key];
+
+ /* Short-circuit if the program optimized the uniform out */
+ if (mapping->location == -1)
+ return NULL;
+
+ /* If the stamp is the same, then we can ignore the request
+ * and short-circuit as early as possible. This requires the
+ * caller to increment their private stamp when they change
+ * internal state.
+ *
+ * This is generally used for the shared uniforms like projection,
+ * modelview, clip, etc to avoid so many comparisons which cost
+ * considerable CPU.
+ */
+ if (stamp != 0 && stamp == mapping->stamp)
+ return NULL;
+
+ if G_LIKELY (format == mapping->info.format && array_count <= mapping->info.array_count)
+ {
+ *out_mapping = mapping;
+ return GSK_GL_UNIFORM_VALUE (state->values_buf, mapping->info.offset);
+ }
+
+ return gsk_gl_uniform_state_init_value (state, program, format, array_count, key, out_mapping);
+}
+
+G_GNUC_PURE static inline guint
+gsk_gl_uniform_state_align (guint current_pos,
+ guint size)
+{
+ guint align = size > 8 ? 16 : (size > 4 ? 8 : 4);
+ guint masked = current_pos & (align - 1);
+
+ g_assert (size > 0);
+ g_assert (align == 4 || align == 8 || align == 16);
+ g_assert (masked < align);
+
+ return align - masked;
+}
+
+static inline gpointer
+gsk_gl_uniform_state_realloc (GskGLUniformState *state,
+ guint size,
+ guint *offset)
+{
+ guint padding = gsk_gl_uniform_state_align (state->values_pos, size);
+
+ if G_UNLIKELY (state->values_len - padding - size < state->values_pos)
+ {
+ state->values_len *= 2;
+ state->values_buf = g_realloc (state->values_buf, state->values_len);
+ }
+
+ /* offsets are in slots of 4 to use fewer bits */
+ g_assert ((state->values_pos + padding) % 4 == 0);
+ *offset = (state->values_pos + padding) / 4;
+ state->values_pos += padding + size;
+
+ return GSK_GL_UNIFORM_VALUE (state->values_buf, *offset);
+}
+
+#define GSK_GL_UNIFORM_STATE_REPLACE(info, u, type, count) \
+ G_STMT_START { \
+ if ((info)->info.initial && count == (info)->info.array_count) \
+ { \
+ u = GSK_GL_UNIFORM_VALUE (state->values_buf, (info)->info.offset); \
+ } \
+ else \
+ { \
+ guint offset; \
+ u = gsk_gl_uniform_state_realloc (state, sizeof(type) * MAX (1, count), &offset); \
+ g_assert (offset < (1 << GSK_GL_UNIFORM_OFFSET_BITS)); \
+ (info)->info.offset = offset; \
+ /* We might have increased array length */ \
+ (info)->info.array_count = count; \
+ } \
+ } G_STMT_END
+
+static inline void
+gsk_gl_uniform_info_changed (GskGLUniformMapping *info,
+ guint stamp)
+{
+ info->stamp = stamp;
+ info->info.initial = FALSE;
+}
+
+static inline void
+gsk_gl_uniform_state_set1f (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ float value0)
+{
+ Uniform1f *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != 0);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_1F, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform1f , 1);
+ u->v0 = value0;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set2f (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ float value0,
+ float value1)
+{
+ Uniform2f *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_2F, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0 || u->v1 != value1)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform2f, 1);
+ u->v0 = value0;
+ u->v1 = value1;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set3f (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ float value0,
+ float value1,
+ float value2)
+{
+ Uniform3f *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_3F, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0 || u->v1 != value1 || u->v2 != value2)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform3f, 1);
+ u->v0 = value0;
+ u->v1 = value1;
+ u->v2 = value2;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set4f (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ float value0,
+ float value1,
+ float value2,
+ float value3)
+{
+ Uniform4f *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_4F, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0 || u->v1 != value1 || u->v2 != value2 || u->v3 != value3)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform4f, 1);
+ u->v0 = value0;
+ u->v1 = value1;
+ u->v2 = value2;
+ u->v3 = value3;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set1ui (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ guint value0)
+{
+ Uniform1ui *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_1UI, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform1ui, 1);
+ u->v0 = value0;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set1i (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ int value0)
+{
+ Uniform1i *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_1I, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform1i, 1);
+ u->v0 = value0;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set2i (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ int value0,
+ int value1)
+{
+ Uniform2i *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_2I, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0 || u->v1 != value1)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform2i, 1);
+ u->v0 = value0;
+ u->v1 = value1;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set3i (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ int value0,
+ int value1,
+ int value2)
+{
+ Uniform3i *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_3I, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0 || u->v1 != value1 || u->v2 != value2)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform3i, 1);
+ u->v0 = value0;
+ u->v1 = value1;
+ u->v2 = value2;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set4i (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ int value0,
+ int value1,
+ int value2,
+ int value3)
+{
+ Uniform4i *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_4I, 1, key, stamp, &info)))
+ {
+ if (info->info.initial || u->v0 != value0 || u->v1 != value1 || u->v2 != value2 || u->v3 != value3)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform4i, 1);
+ u->v0 = value0;
+ u->v1 = value1;
+ u->v2 = value2;
+ u->v3 = value3;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set_rounded_rect (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ const GskRoundedRect *rounded_rect)
+{
+ GskRoundedRect *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+ g_assert (rounded_rect != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT, 1, key,
stamp, &info)))
+ {
+ if (info->info.initial || memcmp (u, rounded_rect, sizeof *u) != 0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, GskRoundedRect, 1);
+ memcpy (u, rounded_rect, sizeof *rounded_rect);
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set_matrix (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ const graphene_matrix_t *matrix)
+{
+ graphene_matrix_t *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+ g_assert (matrix != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_MATRIX, 1, key, stamp,
&info)))
+ {
+ if (info->info.initial || memcmp (u, matrix, sizeof *u) != 0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, graphene_matrix_t, 1);
+ memcpy (u, matrix, sizeof *matrix);
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+/**
+ * gsk_gl_uniform_state_set_texture:
+ * @state: a `GskGLUniformState`
+ * @program: the program id
+ * @location: the location of the texture
+ * @texture_slot: a texturing slot such as GL_TEXTURE0
+ *
+ * Sets the uniform expecting a texture to @texture_slot. This API
+ * expects a texture slot such as GL_TEXTURE0 to reduce chances of
+ * miss-use by the caller.
+ *
+ * The value stored to the uniform is in the form of 0 for GL_TEXTURE0,
+ * 1 for GL_TEXTURE1, and so on.
+ */
+static inline void
+gsk_gl_uniform_state_set_texture (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ guint texture_slot)
+{
+ GskGLUniformMapping *info;
+ guint *u;
+
+ g_assert (texture_slot >= GL_TEXTURE0);
+ g_assert (texture_slot < GL_TEXTURE16);
+
+ texture_slot -= GL_TEXTURE0;
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_TEXTURE, 1, key, stamp,
&info)))
+ {
+ if (info->info.initial || *u != texture_slot)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, guint, 1);
+ *u = texture_slot;
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+/**
+ * gsk_gl_uniform_state_set_color:
+ * @state: a `GskGLUniformState`
+ * @program: a program id > 0
+ * @location: the uniform location
+ * @color: a color to set or %NULL for transparent
+ *
+ * Sets a uniform to the color described by @color. This is a convenience
+ * function to allow callers to avoid having to translate colors to floats
+ * in other portions of the renderer.
+ */
+static inline void
+gsk_gl_uniform_state_set_color (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ const GdkRGBA *color)
+{
+ static const GdkRGBA transparent = {0};
+ GskGLUniformMapping *info;
+ GdkRGBA *u;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_COLOR, 1, key, stamp,
&info)))
+ {
+ if (color == NULL)
+ color = &transparent;
+
+ if (info->info.initial || memcmp (color, u, sizeof *u) != 0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, GdkRGBA, 1);
+ memcpy (u, color, sizeof *color);
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set1fv (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ guint count,
+ const float *value)
+{
+ Uniform1f *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+ g_assert (count > 0);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_1FV, count, key, stamp,
&info)))
+ {
+ if (info->info.initial || count != info->info.array_count || memcmp (u, value, sizeof *u * count) != 0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform1f, count);
+ memcpy (u, value, sizeof (Uniform1f) * count);
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set2fv (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ guint count,
+ const float *value)
+{
+ Uniform2f *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+ g_assert (count > 0);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_2FV, count, key, stamp,
&info)))
+ {
+ if (info->info.initial || count != info->info.array_count || memcmp (u, value, sizeof *u * count) != 0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform2f, count);
+ memcpy (u, value, sizeof (Uniform2f) * count);
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set3fv (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ guint count,
+ const float *value)
+{
+ Uniform3f *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+ g_assert (count > 0);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_3FV, count, key, stamp,
&info)))
+ {
+ if (info->info.initial || count != info->info.array_count || memcmp (u, value, sizeof *u * count) != 0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform3f, count);
+ memcpy (u, value, sizeof (Uniform3f) * count);
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline void
+gsk_gl_uniform_state_set4fv (GskGLUniformState *state,
+ GskGLUniformProgram *program,
+ guint key,
+ guint stamp,
+ guint count,
+ const float *value)
+{
+ Uniform4f *u;
+ GskGLUniformMapping *info;
+
+ g_assert (state != NULL);
+ g_assert (program != NULL);
+ g_assert (count > 0);
+
+ if ((u = gsk_gl_uniform_state_get_value (state, program, GSK_GL_UNIFORM_FORMAT_4FV, count, key, stamp,
&info)))
+ {
+ if (info->info.initial || count != info->info.array_count || memcmp (u, value, sizeof *u * count) != 0)
+ {
+ GSK_GL_UNIFORM_STATE_REPLACE (info, u, Uniform4f, count);
+ memcpy (u, value, sizeof (Uniform4f) * count);
+ gsk_gl_uniform_info_changed (info, stamp);
+ }
+ }
+}
+
+static inline guint
+gsk_gl_uniform_state_fmix (guint program,
+ guint location)
+{
+ guint h = (program << 16) | location;
+
+ h ^= h >> 16;
+ h *= 0x85ebca6b;
+ h ^= h >> 13;
+ h *= 0xc2b2ae35;
+ h ^= h >> 16;
+
+ return h;
+}
+
+/*
+ * gsk_gl_uniform_state_apply:
+ * @state: the uniform state
+ * @program: the program id
+ * @location: the location of the uniform
+ * @offset: the offset of the data within the buffer
+ * @info: the uniform info
+ *
+ * This function can be used to apply state that was previously recorded
+ * by the `GskGLUniformState`.
+ *
+ * It is specifically useful from the `GskGLCommandQueue` to execute uniform
+ * changes but only when they have changed from the current value.
+ */
+static inline void
+gsk_gl_uniform_state_apply (GskGLUniformState *state,
+ guint program,
+ guint location,
+ GskGLUniformInfo info)
+{
+ guint index = gsk_gl_uniform_state_fmix (program, location) % G_N_ELEMENTS (state->apply_hash);
+ gconstpointer dataptr = GSK_GL_UNIFORM_VALUE (state->values_buf, info.offset);
+
+ /* aligned, can treat as unsigned */
+ if (*(guint *)&info == *(guint *)&state->apply_hash[index])
+ return;
+
+ state->apply_hash[index] = info;
+
+ /* TODO: We could do additional comparisons here to make sure we are
+ * changing state.
+ */
+
+ switch (info.format)
+ {
+ case GSK_GL_UNIFORM_FORMAT_1F:
+ glUniform1fv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_2F:
+ glUniform2fv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_3F:
+ glUniform3fv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_4F:
+ glUniform4fv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_1FV:
+ glUniform1fv (location, info.array_count, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_2FV:
+ glUniform2fv (location, info.array_count, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_3FV:
+ glUniform3fv (location, info.array_count, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_4FV:
+ glUniform4fv (location, info.array_count, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_1I:
+ case GSK_GL_UNIFORM_FORMAT_TEXTURE:
+ glUniform1iv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_2I:
+ glUniform2iv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_3I:
+ glUniform3iv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_4I:
+ glUniform4iv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_1UI:
+ glUniform1uiv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_MATRIX: {
+ float mat[16];
+ graphene_matrix_to_float (dataptr, mat);
+ glUniformMatrix4fv (location, 1, GL_FALSE, mat);
+#if 0
+ /* TODO: If Graphene can give us a peek here on platforms
+ * where the format is float[16] (most/all x86_64?) then
+ * We can avoid the SIMD operation to convert the format.
+ */
+ G_STATIC_ASSERT (sizeof (graphene_matrix_t) == 16*4);
+ glUniformMatrix4fv (location, 1, GL_FALSE, dataptr);
+#endif
+ }
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_COLOR:
+ glUniform4fv (location, 1, dataptr);
+ break;
+
+ case GSK_GL_UNIFORM_FORMAT_ROUNDED_RECT:
+ glUniform4fv (location, 3, dataptr);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+G_END_DECLS
+
+#endif /* GSK_GL_UNIFORM_STATE_PRIVATE_H */
diff --git a/gsk/ngl/inlinearray.h b/gsk/gl/inlinearray.h
similarity index 100%
rename from gsk/ngl/inlinearray.h
rename to gsk/gl/inlinearray.h
diff --git a/gsk/ngl/ninesliceprivate.h b/gsk/gl/ninesliceprivate.h
similarity index 93%
rename from gsk/ngl/ninesliceprivate.h
rename to gsk/gl/ninesliceprivate.h
index b2b787b0c1..1ad905929d 100644
--- a/gsk/ngl/ninesliceprivate.h
+++ b/gsk/gl/ninesliceprivate.h
@@ -22,7 +22,7 @@
#ifndef __NINE_SLICE_PRIVATE_H__
#define __NINE_SLICE_PRIVATE_H__
-#include "gskngltextureprivate.h"
+#include "gskgltextureprivate.h"
#if 0
# define DEBUG_NINE_SLICE
@@ -43,14 +43,14 @@ enum {
};
static inline bool G_GNUC_PURE
-nine_slice_is_visible (const GskNglTextureNineSlice *slice)
+nine_slice_is_visible (const GskGLTextureNineSlice *slice)
{
return slice->rect.width > 0 && slice->rect.height > 0;
}
static inline void
-nine_slice_rounded_rect (GskNglTextureNineSlice *slices,
- const GskRoundedRect *rect)
+nine_slice_rounded_rect (GskGLTextureNineSlice *slices,
+ const GskRoundedRect *rect)
{
const graphene_point_t *origin = &rect->bounds.origin;
const graphene_size_t *size = &rect->bounds.size;
@@ -130,16 +130,16 @@ nine_slice_rounded_rect (GskNglTextureNineSlice *slices,
}
static inline void
-nine_slice_to_texture_coords (GskNglTextureNineSlice *slices,
- int texture_width,
- int texture_height)
+nine_slice_to_texture_coords (GskGLTextureNineSlice *slices,
+ int texture_width,
+ int texture_height)
{
float fw = texture_width;
float fh = texture_height;
for (guint i = 0; i < 9; i++)
{
- GskNglTextureNineSlice *slice = &slices[i];
+ GskGLTextureNineSlice *slice = &slices[i];
slice->area.x = slice->rect.x / fw;
slice->area.y = 1.0 - ((slice->rect.y + slice->rect.height) / fh);
@@ -158,9 +158,9 @@ nine_slice_to_texture_coords (GskNglTextureNineSlice *slices,
}
static inline void
-nine_slice_grow (GskNglTextureNineSlice *slices,
- int amount_x,
- int amount_y)
+nine_slice_grow (GskGLTextureNineSlice *slices,
+ int amount_x,
+ int amount_y)
{
if (amount_x == 0 && amount_y == 0)
return;
diff --git a/gsk/ngl/resources/blend.glsl b/gsk/gl/resources/blend.glsl
similarity index 100%
rename from gsk/ngl/resources/blend.glsl
rename to gsk/gl/resources/blend.glsl
diff --git a/gsk/ngl/resources/blit.glsl b/gsk/gl/resources/blit.glsl
similarity index 100%
rename from gsk/ngl/resources/blit.glsl
rename to gsk/gl/resources/blit.glsl
diff --git a/gsk/ngl/resources/blur.glsl b/gsk/gl/resources/blur.glsl
similarity index 100%
rename from gsk/ngl/resources/blur.glsl
rename to gsk/gl/resources/blur.glsl
diff --git a/gsk/ngl/resources/border.glsl b/gsk/gl/resources/border.glsl
similarity index 100%
rename from gsk/ngl/resources/border.glsl
rename to gsk/gl/resources/border.glsl
diff --git a/gsk/ngl/resources/color.glsl b/gsk/gl/resources/color.glsl
similarity index 100%
rename from gsk/ngl/resources/color.glsl
rename to gsk/gl/resources/color.glsl
diff --git a/gsk/ngl/resources/color_matrix.glsl b/gsk/gl/resources/color_matrix.glsl
similarity index 100%
rename from gsk/ngl/resources/color_matrix.glsl
rename to gsk/gl/resources/color_matrix.glsl
diff --git a/gsk/ngl/resources/coloring.glsl b/gsk/gl/resources/coloring.glsl
similarity index 100%
rename from gsk/ngl/resources/coloring.glsl
rename to gsk/gl/resources/coloring.glsl
diff --git a/gsk/ngl/resources/conic_gradient.glsl b/gsk/gl/resources/conic_gradient.glsl
similarity index 100%
rename from gsk/ngl/resources/conic_gradient.glsl
rename to gsk/gl/resources/conic_gradient.glsl
diff --git a/gsk/ngl/resources/cross_fade.glsl b/gsk/gl/resources/cross_fade.glsl
similarity index 100%
rename from gsk/ngl/resources/cross_fade.glsl
rename to gsk/gl/resources/cross_fade.glsl
diff --git a/gsk/ngl/resources/custom.glsl b/gsk/gl/resources/custom.glsl
similarity index 100%
rename from gsk/ngl/resources/custom.glsl
rename to gsk/gl/resources/custom.glsl
diff --git a/gsk/ngl/resources/filled_border.glsl b/gsk/gl/resources/filled_border.glsl
similarity index 100%
rename from gsk/ngl/resources/filled_border.glsl
rename to gsk/gl/resources/filled_border.glsl
diff --git a/gsk/ngl/resources/inset_shadow.glsl b/gsk/gl/resources/inset_shadow.glsl
similarity index 100%
rename from gsk/ngl/resources/inset_shadow.glsl
rename to gsk/gl/resources/inset_shadow.glsl
diff --git a/gsk/ngl/resources/linear_gradient.glsl b/gsk/gl/resources/linear_gradient.glsl
similarity index 100%
rename from gsk/ngl/resources/linear_gradient.glsl
rename to gsk/gl/resources/linear_gradient.glsl
diff --git a/gsk/ngl/resources/outset_shadow.glsl b/gsk/gl/resources/outset_shadow.glsl
similarity index 100%
rename from gsk/ngl/resources/outset_shadow.glsl
rename to gsk/gl/resources/outset_shadow.glsl
diff --git a/gsk/ngl/resources/preamble.fs.glsl b/gsk/gl/resources/preamble.fs.glsl
similarity index 100%
rename from gsk/ngl/resources/preamble.fs.glsl
rename to gsk/gl/resources/preamble.fs.glsl
diff --git a/gsk/ngl/resources/preamble.glsl b/gsk/gl/resources/preamble.glsl
similarity index 100%
rename from gsk/ngl/resources/preamble.glsl
rename to gsk/gl/resources/preamble.glsl
diff --git a/gsk/ngl/resources/preamble.vs.glsl b/gsk/gl/resources/preamble.vs.glsl
similarity index 100%
rename from gsk/ngl/resources/preamble.vs.glsl
rename to gsk/gl/resources/preamble.vs.glsl
diff --git a/gsk/ngl/resources/radial_gradient.glsl b/gsk/gl/resources/radial_gradient.glsl
similarity index 100%
rename from gsk/ngl/resources/radial_gradient.glsl
rename to gsk/gl/resources/radial_gradient.glsl
diff --git a/gsk/ngl/resources/repeat.glsl b/gsk/gl/resources/repeat.glsl
similarity index 100%
rename from gsk/ngl/resources/repeat.glsl
rename to gsk/gl/resources/repeat.glsl
diff --git a/gsk/ngl/resources/unblurred_outset_shadow.glsl b/gsk/gl/resources/unblurred_outset_shadow.glsl
similarity index 100%
rename from gsk/ngl/resources/unblurred_outset_shadow.glsl
rename to gsk/gl/resources/unblurred_outset_shadow.glsl
diff --git a/gsk/ngl/stb_rect_pack.c b/gsk/gl/stb_rect_pack.c
similarity index 100%
rename from gsk/ngl/stb_rect_pack.c
rename to gsk/gl/stb_rect_pack.c
diff --git a/gsk/ngl/stb_rect_pack.h b/gsk/gl/stb_rect_pack.h
similarity index 100%
rename from gsk/ngl/stb_rect_pack.h
rename to gsk/gl/stb_rect_pack.h
diff --git a/gsk/gskglshader.c b/gsk/gskglshader.c
index af6704a556..9394c278cc 100644
--- a/gsk/gskglshader.c
+++ b/gsk/gskglshader.c
@@ -139,7 +139,7 @@
#include "gskglshaderprivate.h"
#include "gskdebugprivate.h"
-#include "ngl/gsknglrendererprivate.h"
+#include "gl/gskglrendererprivate.h"
static GskGLUniformType
uniform_type_from_glsl (const char *str)
@@ -543,8 +543,8 @@ gsk_gl_shader_compile (GskGLShader *shader,
{
g_return_val_if_fail (GSK_IS_GL_SHADER (shader), FALSE);
- if (GSK_IS_NGL_RENDERER (renderer))
- return gsk_ngl_renderer_try_compile_gl_shader (GSK_NGL_RENDERER (renderer), shader, error);
+ if (GSK_IS_GL_RENDERER (renderer))
+ return gsk_gl_renderer_try_compile_gl_shader (GSK_GL_RENDERER (renderer), shader, error);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"The renderer does not support gl shaders");
diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c
index 77fc9a0dfa..12f05817a7 100644
--- a/gsk/gskrenderer.c
+++ b/gsk/gskrenderer.c
@@ -38,7 +38,7 @@
#include "gskcairorenderer.h"
#include "gskdebugprivate.h"
-#include "ngl/gsknglrenderer.h"
+#include "gl/gskglrenderer.h"
#include "gskprofilerprivate.h"
#include "gskrendernodeprivate.h"
@@ -504,9 +504,8 @@ get_renderer_for_name (const char *renderer_name)
#endif
else if (g_ascii_strcasecmp (renderer_name, "cairo") == 0)
return GSK_TYPE_CAIRO_RENDERER;
- else if (g_ascii_strcasecmp (renderer_name, "opengl") == 0 ||
- g_ascii_strcasecmp (renderer_name, "ngl") == 0)
- return GSK_TYPE_NGL_RENDERER;
+ else if (g_ascii_strcasecmp (renderer_name, "gl") == 0)
+ return GSK_TYPE_GL_RENDERER;
#ifdef GDK_RENDERING_VULKAN
else if (g_ascii_strcasecmp (renderer_name, "vulkan") == 0)
return GSK_TYPE_VULKAN_RENDERER;
@@ -520,8 +519,7 @@ get_renderer_for_name (const char *renderer_name)
g_print ("broadway - Disabled during GTK build\n");
#endif
g_print (" cairo - Use the Cairo fallback renderer\n");
- g_print (" opengl - Use the default OpenGL renderer\n");
- g_print (" ngl - An OpenGL renderer\n");
+ g_print (" gl - Use the OpenGL renderer\n");
#ifdef GDK_RENDERING_VULKAN
g_print (" vulkan - Use the Vulkan renderer\n");
#else
@@ -567,11 +565,11 @@ get_renderer_for_backend (GdkSurface *surface)
{
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_SURFACE (surface))
- return GSK_TYPE_NGL_RENDERER;
+ return GSK_TYPE_GL_RENDERER;
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_SURFACE (surface))
- return GSK_TYPE_NGL_RENDERER;
+ return GSK_TYPE_GL_RENDERER;
#endif
#ifdef GDK_WINDOWING_BROADWAY
if (GDK_IS_BROADWAY_SURFACE (surface))
@@ -579,7 +577,7 @@ get_renderer_for_backend (GdkSurface *surface)
#endif
#ifdef GDK_WINDOWING_MACOS
if (GDK_IS_MACOS_SURFACE (surface))
- return GSK_TYPE_NGL_RENDERER;
+ return GSK_TYPE_GL_RENDERER;
#endif
#ifdef GDK_WINDOWING_WIN32
if (GDK_IS_WIN32_SURFACE (surface))
@@ -589,7 +587,7 @@ get_renderer_for_backend (GdkSurface *surface)
if (!(GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES) ||
GDK_WIN32_DISPLAY (display)->running_on_arm64))
- return GSK_TYPE_NGL_RENDERER;
+ return GSK_TYPE_GL_RENDERER;
}
#endif
diff --git a/gsk/meson.build b/gsk/meson.build
index 4f984bf58c..b65b4261db 100644
--- a/gsk/meson.build
+++ b/gsk/meson.build
@@ -1,24 +1,24 @@
-gsk_private_ngl_shaders = [
- 'ngl/resources/preamble.glsl',
- 'ngl/resources/preamble.fs.glsl',
- 'ngl/resources/preamble.vs.glsl',
- 'ngl/resources/border.glsl',
- 'ngl/resources/blit.glsl',
- 'ngl/resources/coloring.glsl',
- 'ngl/resources/color.glsl',
- 'ngl/resources/linear_gradient.glsl',
- 'ngl/resources/radial_gradient.glsl',
- 'ngl/resources/conic_gradient.glsl',
- 'ngl/resources/color_matrix.glsl',
- 'ngl/resources/blur.glsl',
- 'ngl/resources/inset_shadow.glsl',
- 'ngl/resources/outset_shadow.glsl',
- 'ngl/resources/unblurred_outset_shadow.glsl',
- 'ngl/resources/cross_fade.glsl',
- 'ngl/resources/blend.glsl',
- 'ngl/resources/repeat.glsl',
- 'ngl/resources/custom.glsl',
- 'ngl/resources/filled_border.glsl',
+gsk_private_gl_shaders = [
+ 'gl/resources/preamble.glsl',
+ 'gl/resources/preamble.fs.glsl',
+ 'gl/resources/preamble.vs.glsl',
+ 'gl/resources/border.glsl',
+ 'gl/resources/blit.glsl',
+ 'gl/resources/coloring.glsl',
+ 'gl/resources/color.glsl',
+ 'gl/resources/linear_gradient.glsl',
+ 'gl/resources/radial_gradient.glsl',
+ 'gl/resources/conic_gradient.glsl',
+ 'gl/resources/color_matrix.glsl',
+ 'gl/resources/blur.glsl',
+ 'gl/resources/inset_shadow.glsl',
+ 'gl/resources/outset_shadow.glsl',
+ 'gl/resources/unblurred_outset_shadow.glsl',
+ 'gl/resources/cross_fade.glsl',
+ 'gl/resources/blend.glsl',
+ 'gl/resources/repeat.glsl',
+ 'gl/resources/custom.glsl',
+ 'gl/resources/filled_border.glsl',
]
gsk_public_sources = files([
@@ -31,7 +31,7 @@ gsk_public_sources = files([
'gskrendernodeparser.c',
'gskroundedrect.c',
'gsktransform.c',
- 'ngl/gsknglrenderer.c',
+ 'gl/gskglrenderer.c',
])
gsk_private_sources = files([
@@ -39,26 +39,26 @@ gsk_private_sources = files([
'gskdebug.c',
'gskprivate.c',
'gskprofiler.c',
- 'ngl/gsknglattachmentstate.c',
- 'ngl/gsknglbuffer.c',
- 'ngl/gsknglcommandqueue.c',
- 'ngl/gsknglcompiler.c',
- 'ngl/gskngldriver.c',
- 'ngl/gsknglglyphlibrary.c',
- 'ngl/gskngliconlibrary.c',
- 'ngl/gsknglprogram.c',
- 'ngl/gsknglrenderjob.c',
- 'ngl/gsknglshadowlibrary.c',
- 'ngl/gskngltexturelibrary.c',
- 'ngl/gskngluniformstate.c',
- 'ngl/gskngltexture.c',
- 'ngl/gskglprofiler.c',
- 'ngl/stb_rect_pack.c',
- 'ngl/fp16.c',
+ 'gl/gskglattachmentstate.c',
+ 'gl/gskglbuffer.c',
+ 'gl/gskglcommandqueue.c',
+ 'gl/gskglcompiler.c',
+ 'gl/gskgldriver.c',
+ 'gl/gskglglyphlibrary.c',
+ 'gl/gskgliconlibrary.c',
+ 'gl/gskglprogram.c',
+ 'gl/gskglrenderjob.c',
+ 'gl/gskglshadowlibrary.c',
+ 'gl/gskgltexturelibrary.c',
+ 'gl/gskgluniformstate.c',
+ 'gl/gskgltexture.c',
+ 'gl/gskglprofiler.c',
+ 'gl/stb_rect_pack.c',
+ 'gl/fp16.c',
])
gsk_f16c_sources = files([
- 'ngl/fp16i.c',
+ 'gl/fp16i.c',
])
gsk_public_headers = files([
@@ -75,7 +75,7 @@ gsk_public_headers = files([
install_headers(gsk_public_headers, 'gsk.h', subdir: 'gtk-4.0/gsk')
gsk_public_gl_headers = files([
- 'ngl/gsknglrenderer.h',
+ 'gl/gskglrenderer.h',
])
install_headers(gsk_public_gl_headers, subdir: 'gtk-4.0/gsk/gl')
gsk_public_headers += gsk_public_gl_headers
@@ -145,7 +145,7 @@ gsk_resources_xml = configure_file(output: 'gsk.resources.xml',
command: [
find_program('gen-gsk-gresources-xml.py'),
'@OUTPUT@',
- gsk_private_ngl_shaders,
+ gsk_private_gl_shaders,
gsk_private_vulkan_compiled_shaders,
gsk_private_vulkan_shaders
],
diff --git a/gtk/gtktestutils.c b/gtk/gtktestutils.c
index 9d9df66289..3955e57be5 100644
--- a/gtk/gtktestutils.c
+++ b/gtk/gtktestutils.c
@@ -40,7 +40,7 @@
#include <gtk/gtk.h>
#define GTK_COMPILATION
-#include <gsk/ngl/gsknglrenderer.h>
+#include <gsk/gl/gskglrenderer.h>
#ifdef GDK_WINDOWING_BROADWAY
#include <gsk/broadway/gskbroadwayrenderer.h>
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index 852ecc90ee..4c486c60dc 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -158,8 +158,6 @@ init_version (GtkInspectorGeneral *gen)
renderer = "Vulkan";
else if (strcmp (G_OBJECT_TYPE_NAME (gsk_renderer), "GskGLRenderer") == 0)
renderer = "GL";
- else if (strcmp (G_OBJECT_TYPE_NAME (gsk_renderer), "GskNglRenderer") == 0)
- renderer = "NGL";
else if (strcmp (G_OBJECT_TYPE_NAME (gsk_renderer), "GskCairoRenderer") == 0)
renderer = "Cairo";
else
diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c
index 488aec4d6c..d80d1127c8 100644
--- a/testsuite/gdk/memorytexture.c
+++ b/testsuite/gdk/memorytexture.c
@@ -1,6 +1,6 @@
#include <gtk/gtk.h>
-#include "gsk/ngl/gsknglrenderer.h"
+#include "gsk/gl/gskglrenderer.h"
#define N 20
@@ -712,7 +712,7 @@ main (int argc, char *argv[])
add_test ("/memorytexture/download_float_4x4", test_download_float_4x4);
surface = gdk_surface_new_toplevel (gdk_display_get_default());
- gl_renderer = gsk_ngl_renderer_new ();
+ gl_renderer = gsk_gl_renderer_new ();
if (!gsk_renderer_realize (gl_renderer, surface, NULL))
{
g_clear_object (&gl_renderer);
diff --git a/testsuite/gdk/texture-threads.c b/testsuite/gdk/texture-threads.c
index ca970ab3e2..11598812bf 100644
--- a/testsuite/gdk/texture-threads.c
+++ b/testsuite/gdk/texture-threads.c
@@ -1,6 +1,6 @@
#include <gtk/gtk.h>
-#include "gsk/ngl/gsknglrenderer.h"
+#include "gsk/gl/gskglrenderer.h"
/* This function will be called from a thread and/or the main loop.
* Textures are threadsafe after all. */
@@ -73,7 +73,7 @@ texture_threads (void)
/* 1. Get a GL renderer */
surface = gdk_surface_new_toplevel (gdk_display_get_default());
- gl_renderer = gsk_ngl_renderer_new ();
+ gl_renderer = gsk_gl_renderer_new ();
g_assert_true (gsk_renderer_realize (gl_renderer, surface, NULL));
/* 2. Get a GL texture */
diff --git a/testsuite/gsk/half-float.c b/testsuite/gsk/half-float.c
index ba56992f21..5f74072a84 100644
--- a/testsuite/gsk/half-float.c
+++ b/testsuite/gsk/half-float.c
@@ -1,6 +1,6 @@
#include <gtk/gtk.h>
-#include "gsk/ngl/fp16private.h"
+#include "gsk/gl/fp16private.h"
static void
test_constants (void)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]