[gtk/matthiasc/color-profiles: 105/111] ngl: Support flipping gl textures
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profiles: 105/111] ngl: Support flipping gl textures
- Date: Wed, 6 Oct 2021 06:20:01 +0000 (UTC)
commit 7bb503128eb8139978c83b1636eb48c72410c6cd
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 3 16:02:26 2021 -0400
ngl: Support flipping gl textures
Add upside-down flipping to the list of supported
conversions when handling GL textures.
gsk/ngl/gsknglcommandqueueprivate.h | 1 +
gsk/ngl/gskngldriver.c | 19 ++++++++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/gsk/ngl/gsknglcommandqueueprivate.h b/gsk/ngl/gsknglcommandqueueprivate.h
index 4e7ac594ad..1987229bd8 100644
--- a/gsk/ngl/gsknglcommandqueueprivate.h
+++ b/gsk/ngl/gsknglcommandqueueprivate.h
@@ -283,6 +283,7 @@ void gsk_ngl_command_queue_execute (GskNglCommandQue
typedef enum {
GSK_CONVERSION_LINEARIZE = 1 << 0,
GSK_CONVERSION_PREMULTIPLY = 1 << 1,
+ GSK_CONVERSION_FLIP = 1 << 2,
} GskConversion;
int gsk_ngl_command_queue_upload_texture (GskNglCommandQueue *self,
diff --git a/gsk/ngl/gskngldriver.c b/gsk/ngl/gskngldriver.c
index 8c94200d60..77b8e9a3ad 100644
--- a/gsk/ngl/gskngldriver.c
+++ b/gsk/ngl/gskngldriver.c
@@ -717,17 +717,18 @@ gsk_ngl_driver_cache_texture (GskNglDriver *self,
}
static void
-draw_offscreen (GskNglCommandQueue *command_queue,
- float min_x,
- float min_y,
- float max_x,
- float max_y)
+draw_rect (GskNglCommandQueue *command_queue,
+ float min_x,
+ float min_y,
+ float max_x,
+ float max_y,
+ gboolean flip)
{
GskNglDrawVertex *vertices = gsk_ngl_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[4] = { FP16_ZERO, FP16_ZERO, FP16_ZERO, FP16_ZERO };
vertices[0] = (GskNglDrawVertex) { .position = { min_x, min_y }, .uv = { min_u, min_v }, .color = { c[0],
c[1], c[2], c[3] } };
@@ -804,7 +805,7 @@ gsk_ngl_driver_convert_texture (GskNglDriver *self,
int prev_fbo;
GskNglProgram *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;
@@ -835,7 +836,7 @@ gsk_ngl_driver_convert_texture (GskNglDriver *self,
gsk_ngl_program_set_uniform_texture (program,
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_ngl_command_queue_end_draw (self->command_queue);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]