From c7ea0b3d54053ec1bcd9ce8de3d06d1999109900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sun, 18 Oct 2020 22:07:43 +0200 Subject: [PATCH] cogl/offscreen: Pass ColgOffscreenFlag when allocating So that the allocation functions don't need to peek at the cached flag struct field. Part-of: --- cogl/cogl/cogl-driver.h | 7 ++++--- cogl/cogl/cogl-offscreen.c | 4 +++- cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h | 5 +++-- cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 9 +++++---- cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h | 5 +++-- cogl/cogl/driver/nop/cogl-framebuffer-nop.c | 5 +++-- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h index d8f3cc18f..6cf8f7b73 100644 --- a/cogl/cogl/cogl-driver.h +++ b/cogl/cogl/cogl-driver.h @@ -32,7 +32,7 @@ #define __COGL_DRIVER_H #include "cogl-context.h" -#include "cogl-offscreen.h" +#include "cogl-offscreen-private.h" #include "cogl-framebuffer-private.h" #include "cogl-attribute-private.h" #include "cogl-sampler-cache-private.h" @@ -74,8 +74,9 @@ struct _CoglDriverVtable GError **error); gboolean - (* offscreen_allocate) (CoglOffscreen *offscreen, - GError **error); + (* offscreen_allocate) (CoglOffscreen *offscreen, + CoglOffscreenFlags flags, + GError **error); void (* offscreen_free) (CoglOffscreen *offscreen); diff --git a/cogl/cogl/cogl-offscreen.c b/cogl/cogl/cogl-offscreen.c index 20154d78c..c48f30d91 100644 --- a/cogl/cogl/cogl-offscreen.c +++ b/cogl/cogl/cogl-offscreen.c @@ -106,7 +106,9 @@ cogl_offscreen_allocate (CoglFramebuffer *framebuffer, texture_format = _cogl_texture_get_format (offscreen->texture); _cogl_framebuffer_set_internal_format (framebuffer, texture_format); - if (!ctx->driver_vtable->offscreen_allocate (offscreen, error)) + if (!ctx->driver_vtable->offscreen_allocate (offscreen, + offscreen->create_flags, + error)) return FALSE; return TRUE; diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h index 301bd8aba..08acf814b 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h @@ -40,8 +40,9 @@ G_DECLARE_FINAL_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer, GObject) gboolean -_cogl_offscreen_gl_allocate (CoglOffscreen *offscreen, - GError **error); +_cogl_offscreen_gl_allocate (CoglOffscreen *offscreen, + CoglOffscreenFlags flags, + GError **error); void _cogl_offscreen_gl_free (CoglOffscreen *offscreen); diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index 3aae555e6..d57de6203 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -707,8 +707,9 @@ try_creating_fbo (CoglContext *ctx, } gboolean -_cogl_offscreen_gl_allocate (CoglOffscreen *offscreen, - GError **error) +_cogl_offscreen_gl_allocate (CoglOffscreen *offscreen, + CoglOffscreenFlags flags, + GError **error) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen); CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); @@ -747,7 +748,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen, gl_framebuffer = ensure_gl_framebuffer (framebuffer); gl_fbo = &gl_framebuffer->gl_fbo; - if (((offscreen->create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL) && + if (((flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL) && try_creating_fbo (ctx, offscreen->texture, offscreen->texture_level, @@ -823,7 +824,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen, cogl_framebuffer_update_samples_per_pixel (framebuffer, gl_fbo->samples_per_pixel); - if (!(offscreen->create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL)) + if (!(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 */ diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h index 95b636517..1397ebf69 100644 --- a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h +++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h @@ -38,8 +38,9 @@ #include "cogl-context-private.h" gboolean -_cogl_offscreen_nop_allocate (CoglOffscreen *offscreen, - GError **error); +_cogl_offscreen_nop_allocate (CoglOffscreen *offscreen, + CoglOffscreenFlags flags, + GError **error); void _cogl_offscreen_nop_free (CoglOffscreen *offscreen); diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c index f9db69c91..602b80421 100644 --- a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c +++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c @@ -43,8 +43,9 @@ _cogl_framebuffer_nop_flush_state (CoglFramebuffer *draw_buffer, } gboolean -_cogl_offscreen_nop_allocate (CoglOffscreen *offscreen, - GError **error) +_cogl_offscreen_nop_allocate (CoglOffscreen *offscreen, + CoglOffscreenFlags flags, + GError **error) { return TRUE; }