[mutter] cogl: correct check for COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl: correct check for COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL
- Date: Tue, 19 Nov 2019 21:45:05 +0000 (UTC)
commit d992722c24cbbeaedfcf97bb186689208de91869
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date: Fri Nov 15 21:34:12 2019 +0100
cogl: correct check for COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL
In _cogl_offscreen_gl_allocate we only want to perform certain actions if
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL is not set in create_flags.
We perfrom this check with:
if (!offscreen->create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL)
which is not correct as we negate the create_flags before the bitwise &.
It happens to work as intended though, as CoglOffscreenFlags only has one
element, and that element has the value 1. If the flag is not set then the
nagation of create_flags is true and the bitwise and with the element value
is true as well.
If any flag is set then the negation will give 0 and the bitwise & will be
false.
So while it works correctly it is fragile as either additional flags or a
change in the enum element value will break this check. This patch makes
things a bit more safe by adding parentheses to let the bitwise & happen
before the negation.
Definition of the enum:
typedef enum
{
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL = 1
} CoglOffscreenFlags;
https://gitlab.gnome.org/GNOME/mutter/merge_requests/938
cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index 343793999..b956a8314 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -865,7 +865,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
{
fb->samples_per_pixel = gl_framebuffer->samples_per_pixel;
- if (!offscreen->create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL)
+ if (!(offscreen->create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL))
{
/* Record that the last set of flags succeeded so that we can
try that set first next time */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]