[gtk/matthiasc/color-profile-rebased: 55/66] gsk: Support flipping gl textures
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profile-rebased: 55/66] gsk: Support flipping gl textures
- Date: Fri, 13 May 2022 04:00:03 +0000 (UTC)
commit 73a0c192e70250cfbe2bdf104150c752f046d593
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 8 14:47:45 2022 -0400
gsk: Support flipping gl textures
Add upside-down flipping to the list of supported
conversions when handling GL textures.
gsk/gl/gskglcommandqueueprivate.h | 1 +
gsk/gl/gskgldriver.c | 19 ++++++++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/gsk/gl/gskglcommandqueueprivate.h b/gsk/gl/gskglcommandqueueprivate.h
index a6ffc9f96d..5014806ca0 100644
--- a/gsk/gl/gskglcommandqueueprivate.h
+++ b/gsk/gl/gskglcommandqueueprivate.h
@@ -284,6 +284,7 @@ void gsk_gl_command_queue_execute (GskGLCommandQueue
typedef enum {
GSK_CONVERSION_LINEARIZE = 1 << 0,
GSK_CONVERSION_PREMULTIPLY = 1 << 1,
+ GSK_CONVERSION_FLIP = 1 << 2,
} GskConversion;
int gsk_gl_command_queue_upload_texture (GskGLCommandQueue *self,
diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c
index 391e8c054d..b595035026 100644
--- a/gsk/gl/gskgldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -686,17 +686,18 @@ gsk_gl_driver_cache_texture (GskGLDriver *self,
}
static void
-draw_offscreen (GskGLCommandQueue *command_queue,
- float min_x,
- float min_y,
- float max_x,
- float max_y)
+draw_rect (GskGLCommandQueue *command_queue,
+ float min_x,
+ float min_y,
+ float max_x,
+ float max_y,
+ gboolean flip)
{
GskGLDrawVertex *vertices = gsk_gl_command_queue_add_vertices (command_queue);
float min_u = 0;
- float min_v = 1;
float max_u = 1;
- float max_v = 0;
+ float min_v = flip ? 0 : 1;
+ float max_v = flip ? 1 : 0;
guint16 c = FP16_ZERO;
vertices[0] = (GskGLDrawVertex) { .position = { min_x, min_y }, .uv = { min_u, min_v }, .color = { c, c,
c, c } };
@@ -773,7 +774,7 @@ gsk_gl_driver_convert_texture (GskGLDriver *self,
int prev_fbo;
GskGLProgram *program;
- if (conversion == (GSK_CONVERSION_LINEARIZE | GSK_CONVERSION_PREMULTIPLY))
+ if ((conversion & (GSK_CONVERSION_LINEARIZE | GSK_CONVERSION_PREMULTIPLY)) == (GSK_CONVERSION_LINEARIZE |
GSK_CONVERSION_PREMULTIPLY))
program = self->linearize_premultiply_no_clip;
else if (conversion & GSK_CONVERSION_LINEARIZE)
program = self->linearize_no_clip;
@@ -805,7 +806,7 @@ gsk_gl_driver_convert_texture (GskGLDriver *self,
UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, GL_TEXTURE0, texture_id);
- draw_offscreen (self->command_queue, 0, 0, width, height);
+ draw_rect (self->command_queue, 0, 0, width, height, (conversion & GSK_CONVERSION_FLIP) != 0);
gsk_gl_command_queue_end_draw (self->command_queue);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]