mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
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
This commit is contained in:
parent
81bb4f0051
commit
d992722c24
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user