[gtk/gl-linear: 7/8] gl: Use GL_LINEAR for some offscreen rendering
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gl-linear: 7/8] gl: Use GL_LINEAR for some offscreen rendering
- Date: Fri, 4 Sep 2020 11:59:43 +0000 (UTC)
commit 59a18ca198f71fbcbe343fb8f319913d18d40445
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Sep 2 18:01:06 2020 -0400
gl: Use GL_LINEAR for some offscreen rendering
When we are dealing with full 3D transforms,
use GL_LINEAR for interpolation, since that provides
better rendering. We still use GL_NEAREST for pixel
perfect results when the transforms are 2D.
gsk/gl/gskgldriver.c | 4 +++-
gsk/gl/gskgldriverprivate.h | 2 ++
gsk/gl/gskglrenderer.c | 20 +++++++++++++++++---
3 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c
index 8cd32d72ab..08e19a980f 100644
--- a/gsk/gl/gskgldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -594,6 +594,8 @@ void
gsk_gl_driver_create_render_target (GskGLDriver *self,
int width,
int height,
+ int min_filter,
+ int mag_filter,
int *out_texture_id,
int *out_render_target_id)
{
@@ -604,7 +606,7 @@ gsk_gl_driver_create_render_target (GskGLDriver *self,
texture = create_texture (self, width, height);
gsk_gl_driver_bind_source_texture (self, texture->texture_id);
- gsk_gl_driver_init_texture_empty (self, texture->texture_id, GL_NEAREST, GL_NEAREST);
+ gsk_gl_driver_init_texture_empty (self, texture->texture_id, min_filter, mag_filter);
glGenFramebuffers (1, &fbo_id);
glBindFramebuffer (GL_FRAMEBUFFER, fbo_id);
diff --git a/gsk/gl/gskgldriverprivate.h b/gsk/gl/gskgldriverprivate.h
index 83d0c46af9..22c5ef8cb3 100644
--- a/gsk/gl/gskgldriverprivate.h
+++ b/gsk/gl/gskgldriverprivate.h
@@ -45,6 +45,8 @@ int gsk_gl_driver_create_texture (GskGLDriver *driver
void gsk_gl_driver_create_render_target (GskGLDriver *driver,
int width,
int height,
+ int min_filter,
+ int mag_filter,
int *out_texture_id,
int *out_render_target_id);
void gsk_gl_driver_mark_texture_permanent (GskGLDriver *self,
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 5078aeef65..c45290b578 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -71,6 +71,7 @@ typedef enum
RESET_OPACITY = 1 << 2,
DUMP_FRAMEBUFFER = 1 << 3,
NO_CACHE_PLZ = 1 << 5,
+ LINEAR_FILTER = 1 << 6,
} OffscreenFlags;
static inline void
@@ -1054,7 +1055,7 @@ render_transform_node (GskGLRenderer *self,
&child->bounds,
child,
®ion, &is_offscreen,
- RESET_CLIP | RESET_OPACITY))
+ RESET_CLIP | RESET_OPACITY | LINEAR_FILTER))
{
/* For non-trivial transforms, we draw everything on a texture and then
* draw the texture transformed. */
@@ -1451,10 +1452,12 @@ blur_texture (GskGLRenderer *self,
gsk_gl_driver_create_render_target (self->gl_driver,
texture_to_blur_width, texture_to_blur_height,
+ GL_NEAREST, GL_NEAREST,
&pass1_texture_id, &pass1_render_target);
gsk_gl_driver_create_render_target (self->gl_driver,
texture_to_blur_width, texture_to_blur_height,
+ GL_NEAREST, GL_NEAREST,
&pass2_texture_id, &pass2_render_target);
graphene_matrix_init_ortho (&item_proj,
@@ -1696,6 +1699,7 @@ render_inset_shadow_node (GskGLRenderer *self,
gsk_gl_driver_create_render_target (self->gl_driver,
texture_width, texture_height,
+ GL_NEAREST, GL_NEAREST,
&texture_id, &render_target);
graphene_matrix_init_ortho (&item_proj,
@@ -1869,7 +1873,9 @@ render_outset_shadow_node (GskGLRenderer *self,
graphene_rect_t prev_viewport;
graphene_matrix_t item_proj;
- gsk_gl_driver_create_render_target (self->gl_driver, texture_width, texture_height,
+ gsk_gl_driver_create_render_target (self->gl_driver,
+ texture_width, texture_height,
+ GL_NEAREST, GL_NEAREST,
&texture_id, &render_target);
if (gdk_gl_context_has_debug (self->gl_context))
{
@@ -3349,6 +3355,7 @@ add_offscreen_ops (GskGLRenderer *self,
float prev_opacity = 1.0;
int texture_id = 0;
int max_texture_size;
+ int filter;
if (node_is_invisible (child_node))
{
@@ -3401,7 +3408,14 @@ add_offscreen_ops (GskGLRenderer *self,
width = ceilf (width * scale);
height = ceilf (height * scale);
- gsk_gl_driver_create_render_target (self->gl_driver, width, height, &texture_id, &render_target);
+ if (flags & LINEAR_FILTER)
+ filter = GL_LINEAR;
+ else
+ filter = GL_NEAREST;
+ gsk_gl_driver_create_render_target (self->gl_driver,
+ width, height,
+ filter, filter,
+ &texture_id, &render_target);
if (gdk_gl_context_has_debug (self->gl_context))
{
gdk_gl_context_label_object_printf (self->gl_context, GL_TEXTURE, texture_id,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]