Use the projection to flip around the content

Since we use an FBO to render the contents of the render node tree, the
coordinate space is going to be flipped in GL. We can undo the flip by
using an appropriate projection matrix, instead of changing the sampling
coordinates in the shaders and updating all our coordinates at render
time.
This commit is contained in:
Emmanuele Bassi 2016-08-02 16:58:47 +01:00
parent 6c92846936
commit 1ab1fd4391
5 changed files with 11 additions and 11 deletions

View File

@ -618,7 +618,6 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
else
item.parent_data = NULL;
/* Select the render target; -1 is the default */
if (render_node_needs_render_target (node))
{
item.render_data.render_target_id =
@ -839,7 +838,6 @@ gsk_gl_renderer_render (GskRenderer *renderer,
glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
glBlendEquation (GL_FUNC_ADD);
/* Transparent pass: back-to-front */
GSK_NOTE (OPENGL, g_print ("Rendering %u items\n", self->render_items->len));
for (i = 0; i < self->render_items->len; i++)
{
@ -851,7 +849,7 @@ gsk_gl_renderer_render (GskRenderer *renderer,
/* Draw the output of the GL rendering to the window */
gsk_gl_driver_end_frame (self->gl_driver);
gpu_time = gsk_gl_profiler_end_gpu_region (self->gl_profiler);
GSK_NOTE (OPENGL, g_print ("GPU time: %" G_GUINT64_FORMAT " nsec\n", gpu_time));
GSK_NOTE (OPENGL, g_print ("GPU time: %g usec\n", (double) gpu_time / 1000.0));
out:
/* XXX: Add GdkDrawingContext API */

View File

@ -28,8 +28,8 @@ vec3 BlendLighten(vec3 Cb, vec3 Cs) {
}
void main() {
vec4 Cb = Texture(uSource, vUv);
vec4 Cs = Texture(uMask, vUv);
vec4 Cs = Texture(uSource, vUv);
vec4 Cb = Texture(uMask, vUv);
vec3 res;
if (uBlendMode == 0) {

View File

@ -2,5 +2,5 @@ void main() {
gl_Position = uMVP * vec4(aPosition, 0.0, 1.0);
// Flip the sampling
vUv = vec2(aUv.x, 1.0 - aUv.y);
vUv = vec2(aUv.x, aUv.y);
}

View File

@ -2,5 +2,5 @@ void main() {
gl_Position = uMVP * vec4(aPosition, 0.0, 1.0);
// Flip the sampling
vUv = vec2(aUv.x, 1.0 - aUv.y);
vUv = vec2(aUv.x, aUv.y);
}

View File

@ -161,6 +161,9 @@
* instead.
*/
#define ORTHO_NEAR_PLANE -10000
#define ORTHO_FAR_PLANE 10000
typedef struct _GtkWindowPopover GtkWindowPopover;
struct _GtkWindowPopover
@ -446,8 +449,6 @@ static void gtk_window_real_activate_focus (GtkWindow *window);
static void gtk_window_keys_changed (GtkWindow *window);
static gboolean gtk_window_enable_debugging (GtkWindow *window,
gboolean toggle);
static gint gtk_window_draw (GtkWidget *widget,
cairo_t *cr);
static GskRenderNode *gtk_window_get_render_node (GtkWidget *widget,
GskRenderer *renderer);
static void gtk_window_unset_transient_for (GtkWindow *window);
@ -7263,8 +7264,9 @@ _gtk_window_set_allocation (GtkWindow *window,
graphene_matrix_init_ortho (&projection,
0, allocation->width * scale,
0, allocation->height * scale,
-1, 1);
allocation->height * scale, 0,
ORTHO_NEAR_PLANE,
ORTHO_FAR_PLANE);
gsk_renderer_set_projection (priv->renderer, &projection);
graphene_matrix_init_translate (&modelview,