|
|
9501a8 |
From f86e33e1ea32c4208809e8de33bed05ddbce9a4c Mon Sep 17 00:00:00 2001
|
|
|
9501a8 |
From: Carlos Garnacho <carlosg@gnome.org>
|
|
|
9501a8 |
Date: Sun, 7 May 2017 03:00:10 +0200
|
|
|
9501a8 |
Subject: [PATCH 1/3] compositor: Avoid changing pipeline/source if shadow is
|
|
|
9501a8 |
not being painted
|
|
|
9501a8 |
|
|
|
9501a8 |
Avoids some context invalidations in cogl.
|
|
|
9501a8 |
|
|
|
9501a8 |
https://bugzilla.gnome.org/show_bug.cgi?id=782344
|
|
|
9501a8 |
---
|
|
|
9501a8 |
src/compositor/meta-shadow-factory.c | 15 ++++++++++++---
|
|
|
9501a8 |
1 file changed, 12 insertions(+), 3 deletions(-)
|
|
|
9501a8 |
|
|
|
9501a8 |
diff --git a/src/compositor/meta-shadow-factory.c b/src/compositor/meta-shadow-factory.c
|
|
|
9501a8 |
index cd006008b..19147ca9f 100644
|
|
|
9501a8 |
--- a/src/compositor/meta-shadow-factory.c
|
|
|
9501a8 |
+++ b/src/compositor/meta-shadow-factory.c
|
|
|
9501a8 |
@@ -220,9 +220,7 @@ meta_shadow_paint (MetaShadow *shadow,
|
|
|
9501a8 |
int dest_x[4];
|
|
|
9501a8 |
int dest_y[4];
|
|
|
9501a8 |
int n_x, n_y;
|
|
|
9501a8 |
-
|
|
|
9501a8 |
- cogl_pipeline_set_color4ub (shadow->pipeline,
|
|
|
9501a8 |
- opacity, opacity, opacity, opacity);
|
|
|
9501a8 |
+ gboolean source_updated = FALSE;
|
|
|
9501a8 |
|
|
|
9501a8 |
cogl_set_source (shadow->pipeline);
|
|
|
9501a8 |
|
|
|
9501a8 |
@@ -300,6 +298,17 @@ meta_shadow_paint (MetaShadow *shadow,
|
|
|
9501a8 |
else
|
|
|
9501a8 |
overlap = CAIRO_REGION_OVERLAP_IN;
|
|
|
9501a8 |
|
|
|
9501a8 |
+ if (overlap == CAIRO_REGION_OVERLAP_OUT)
|
|
|
9501a8 |
+ continue;
|
|
|
9501a8 |
+
|
|
|
9501a8 |
+ if (!source_updated)
|
|
|
9501a8 |
+ {
|
|
|
9501a8 |
+ cogl_pipeline_set_color4ub (shadow->pipeline,
|
|
|
9501a8 |
+ opacity, opacity, opacity, opacity);
|
|
|
9501a8 |
+ cogl_set_source (shadow->pipeline);
|
|
|
9501a8 |
+ source_updated = TRUE;
|
|
|
9501a8 |
+ }
|
|
|
9501a8 |
+
|
|
|
9501a8 |
/* There's quite a bit of overhead from allocating a new
|
|
|
9501a8 |
* region in order to find an exact intersection and
|
|
|
9501a8 |
* generating more geometry - we make the assumption that
|
|
|
9501a8 |
--
|
|
|
9501a8 |
2.23.0
|
|
|
9501a8 |
|
|
|
9501a8 |
|
|
|
9501a8 |
From f530bc4c3391cabe2b084cd59def00d81c13286c Mon Sep 17 00:00:00 2001
|
|
|
9501a8 |
From: Carlos Garnacho <carlosg@gnome.org>
|
|
|
9501a8 |
Date: Fri, 5 May 2017 14:15:30 +0200
|
|
|
9501a8 |
Subject: [PATCH 2/3] clutter: Avoid rounding compensation when invalidating 2D
|
|
|
9501a8 |
actors
|
|
|
9501a8 |
|
|
|
9501a8 |
This allows the redraw clip to be more constrained, so MetaCullable doesn't
|
|
|
9501a8 |
end up rendering portions of window shadows, frame and background when a
|
|
|
9501a8 |
window invalidates (part of) its contents.
|
|
|
9501a8 |
|
|
|
9501a8 |
https://bugzilla.gnome.org/show_bug.cgi?id=782344
|
|
|
9501a8 |
---
|
|
|
9501a8 |
clutter/clutter/clutter-paint-volume.c | 15 +++++++++++++++
|
|
|
9501a8 |
1 file changed, 15 insertions(+)
|
|
|
9501a8 |
|
|
|
9501a8 |
diff --git a/clutter/clutter/clutter-paint-volume.c b/clutter/clutter/clutter-paint-volume.c
|
|
|
9501a8 |
index b48f7f9d6..f3405138b 100644
|
|
|
9501a8 |
--- a/clutter/clutter/clutter-paint-volume.c
|
|
|
9501a8 |
+++ b/clutter/clutter/clutter-paint-volume.c
|
|
|
9501a8 |
@@ -1166,6 +1166,21 @@ _clutter_paint_volume_get_stage_paint_box (ClutterPaintVolume *pv,
|
|
|
9501a8 |
|
|
|
9501a8 |
_clutter_paint_volume_get_bounding_box (&projected_pv, box);
|
|
|
9501a8 |
|
|
|
9501a8 |
+ if (pv->is_2d && pv->actor &&
|
|
|
9501a8 |
+ clutter_actor_get_z_position (pv->actor) == 0)
|
|
|
9501a8 |
+ {
|
|
|
9501a8 |
+ /* If the volume/actor are perfectly 2D, take the bounding box as
|
|
|
9501a8 |
+ * good. We won't need to add any extra room for sub-pixel positioning
|
|
|
9501a8 |
+ * in this case.
|
|
|
9501a8 |
+ */
|
|
|
9501a8 |
+ clutter_paint_volume_free (&projected_pv);
|
|
|
9501a8 |
+ box->x1 = CLUTTER_NEARBYINT (box->x1);
|
|
|
9501a8 |
+ box->y1 = CLUTTER_NEARBYINT (box->y1);
|
|
|
9501a8 |
+ box->x2 = CLUTTER_NEARBYINT (box->x2);
|
|
|
9501a8 |
+ box->y2 = CLUTTER_NEARBYINT (box->y2);
|
|
|
9501a8 |
+ return;
|
|
|
9501a8 |
+ }
|
|
|
9501a8 |
+
|
|
|
9501a8 |
/* The aim here is that for a given rectangle defined with floating point
|
|
|
9501a8 |
* coordinates we want to determine a stable quantized size in pixels
|
|
|
9501a8 |
* that doesn't vary due to the original box's sub-pixel position.
|
|
|
9501a8 |
--
|
|
|
9501a8 |
2.23.0
|
|
|
9501a8 |
|
|
|
9501a8 |
|
|
|
9501a8 |
From 676369000658c6121d0c3b5e1286aa68dc79eb35 Mon Sep 17 00:00:00 2001
|
|
|
9501a8 |
From: Carlos Garnacho <carlosg@gnome.org>
|
|
|
9501a8 |
Date: Mon, 8 May 2017 15:10:58 +0200
|
|
|
9501a8 |
Subject: [PATCH 3/3] cogl: Ensure to only clear the depth buffer if depth
|
|
|
9501a8 |
testing is enabled
|
|
|
9501a8 |
|
|
|
9501a8 |
The depth buffer is marked as invalid when 1) the framebuffer is just created,
|
|
|
9501a8 |
and 2) whenever GL_DEPTH_TEST is enabled on it. This will ensure the
|
|
|
9501a8 |
framebuffers attached depth buffer (if any) is properly cleared before it's
|
|
|
9501a8 |
actually used, while saving needless clears while depth testing is disabled
|
|
|
9501a8 |
(the default).
|
|
|
9501a8 |
|
|
|
9501a8 |
https://bugzilla.gnome.org/show_bug.cgi?id=782344
|
|
|
9501a8 |
---
|
|
|
9501a8 |
cogl/cogl/cogl-framebuffer-private.h | 5 +++++
|
|
|
9501a8 |
cogl/cogl/cogl-framebuffer.c | 11 +++++++++++
|
|
|
9501a8 |
cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 6 +++++-
|
|
|
9501a8 |
3 files changed, 21 insertions(+), 1 deletion(-)
|
|
|
9501a8 |
|
|
|
9501a8 |
diff --git a/cogl/cogl/cogl-framebuffer-private.h b/cogl/cogl/cogl-framebuffer-private.h
|
|
|
9501a8 |
index 99ac2fba9..756e34dfe 100644
|
|
|
9501a8 |
--- a/cogl/cogl/cogl-framebuffer-private.h
|
|
|
9501a8 |
+++ b/cogl/cogl/cogl-framebuffer-private.h
|
|
|
9501a8 |
@@ -193,6 +193,11 @@ struct _CoglFramebuffer
|
|
|
9501a8 |
CoglFramebufferBits bits;
|
|
|
9501a8 |
|
|
|
9501a8 |
int samples_per_pixel;
|
|
|
9501a8 |
+
|
|
|
9501a8 |
+ /* Whether the depth buffer was enabled for this framebuffer,
|
|
|
9501a8 |
+ * usually means it needs to be cleared before being reused next.
|
|
|
9501a8 |
+ */
|
|
|
9501a8 |
+ CoglBool depth_buffer_clear_needed;
|
|
|
9501a8 |
};
|
|
|
9501a8 |
|
|
|
9501a8 |
typedef enum {
|
|
|
9501a8 |
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
|
|
|
9501a8 |
index 55b9e3756..6b105087d 100644
|
|
|
9501a8 |
--- a/cogl/cogl/cogl-framebuffer.c
|
|
|
9501a8 |
+++ b/cogl/cogl/cogl-framebuffer.c
|
|
|
9501a8 |
@@ -117,6 +117,7 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
|
|
|
9501a8 |
framebuffer->viewport_age_for_scissor_workaround = -1;
|
|
|
9501a8 |
framebuffer->dither_enabled = TRUE;
|
|
|
9501a8 |
framebuffer->depth_writing_enabled = TRUE;
|
|
|
9501a8 |
+ framebuffer->depth_buffer_clear_needed = TRUE;
|
|
|
9501a8 |
|
|
|
9501a8 |
framebuffer->modelview_stack = cogl_matrix_stack_new (ctx);
|
|
|
9501a8 |
framebuffer->projection_stack = cogl_matrix_stack_new (ctx);
|
|
|
9501a8 |
@@ -268,6 +269,13 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
|
|
|
9501a8 |
int scissor_y1;
|
|
|
9501a8 |
CoglBool saved_viewport_scissor_workaround;
|
|
|
9501a8 |
|
|
|
9501a8 |
+ if (!framebuffer->depth_buffer_clear_needed &&
|
|
|
9501a8 |
+ (buffers & COGL_BUFFER_BIT_DEPTH))
|
|
|
9501a8 |
+ buffers &= ~(COGL_BUFFER_BIT_DEPTH);
|
|
|
9501a8 |
+
|
|
|
9501a8 |
+ if (buffers == 0)
|
|
|
9501a8 |
+ return;
|
|
|
9501a8 |
+
|
|
|
9501a8 |
_cogl_clip_stack_get_bounds (clip_stack,
|
|
|
9501a8 |
&scissor_x0, &scissor_y0,
|
|
|
9501a8 |
&scissor_x1, &scissor_y1);
|
|
|
9501a8 |
@@ -415,6 +423,9 @@ cleared:
|
|
|
9501a8 |
_cogl_framebuffer_mark_mid_scene (framebuffer);
|
|
|
9501a8 |
_cogl_framebuffer_mark_clear_clip_dirty (framebuffer);
|
|
|
9501a8 |
|
|
|
9501a8 |
+ if (buffers & COGL_BUFFER_BIT_DEPTH)
|
|
|
9501a8 |
+ framebuffer->depth_buffer_clear_needed = FALSE;
|
|
|
9501a8 |
+
|
|
|
9501a8 |
if (buffers & COGL_BUFFER_BIT_COLOR && buffers & COGL_BUFFER_BIT_DEPTH)
|
|
|
9501a8 |
{
|
|
|
9501a8 |
/* For our fast-path for reading back a single pixel of simple
|
|
|
9501a8 |
diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
|
|
|
9501a8 |
index 178269646..4f1f69f96 100644
|
|
|
9501a8 |
--- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
|
|
|
9501a8 |
+++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c
|
|
|
9501a8 |
@@ -418,7 +418,11 @@ flush_depth_state (CoglContext *ctx,
|
|
|
9501a8 |
if (ctx->depth_test_enabled_cache != depth_state->test_enabled)
|
|
|
9501a8 |
{
|
|
|
9501a8 |
if (depth_state->test_enabled == TRUE)
|
|
|
9501a8 |
- GE (ctx, glEnable (GL_DEPTH_TEST));
|
|
|
9501a8 |
+ {
|
|
|
9501a8 |
+ GE (ctx, glEnable (GL_DEPTH_TEST));
|
|
|
9501a8 |
+ if (ctx->current_draw_buffer)
|
|
|
9501a8 |
+ ctx->current_draw_buffer->depth_buffer_clear_needed = TRUE;
|
|
|
9501a8 |
+ }
|
|
|
9501a8 |
else
|
|
|
9501a8 |
GE (ctx, glDisable (GL_DEPTH_TEST));
|
|
|
9501a8 |
ctx->depth_test_enabled_cache = depth_state->test_enabled;
|
|
|
9501a8 |
--
|
|
|
9501a8 |
2.23.0
|
|
|
9501a8 |
|