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