mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
cogl/gl-framebuffer: Move struct fields into private
This makes it possible to make type derivable. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
parent
e3de0be678
commit
ece714c5c6
@ -135,18 +135,21 @@ typedef struct _CoglGlFbo
|
|||||||
int samples_per_pixel;
|
int samples_per_pixel;
|
||||||
} CoglGlFbo;
|
} CoglGlFbo;
|
||||||
|
|
||||||
struct _CoglGlFramebuffer
|
typedef struct _CoglGlFramebufferPrivate
|
||||||
{
|
{
|
||||||
CoglFramebufferDriver parent;
|
|
||||||
|
|
||||||
CoglGlFbo gl_fbo;
|
CoglGlFbo gl_fbo;
|
||||||
|
|
||||||
gboolean dirty_bitmasks;
|
gboolean dirty_bitmasks;
|
||||||
CoglFramebufferBits bits;
|
CoglFramebufferBits bits;
|
||||||
|
} CoglGlFramebufferPrivate;
|
||||||
|
|
||||||
|
struct _CoglGlFramebuffer
|
||||||
|
{
|
||||||
|
CoglFramebufferDriver parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer,
|
G_DEFINE_TYPE_WITH_PRIVATE (CoglGlFramebuffer, cogl_gl_framebuffer,
|
||||||
COGL_TYPE_FRAMEBUFFER_DRIVER)
|
COGL_TYPE_FRAMEBUFFER_DRIVER)
|
||||||
|
|
||||||
static CoglGlFramebuffer *
|
static CoglGlFramebuffer *
|
||||||
ensure_gl_framebuffer (CoglFramebuffer *framebuffer);
|
ensure_gl_framebuffer (CoglFramebuffer *framebuffer);
|
||||||
@ -360,10 +363,11 @@ _cogl_framebuffer_gl_bind (CoglFramebuffer *framebuffer, GLenum target)
|
|||||||
if (COGL_IS_OFFSCREEN (framebuffer))
|
if (COGL_IS_OFFSCREEN (framebuffer))
|
||||||
{
|
{
|
||||||
CoglGlFramebuffer *gl_framebuffer;
|
CoglGlFramebuffer *gl_framebuffer;
|
||||||
|
CoglGlFramebufferPrivate *priv;
|
||||||
|
|
||||||
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
||||||
GE (ctx, glBindFramebuffer (target,
|
priv = cogl_gl_framebuffer_get_instance_private (gl_framebuffer);
|
||||||
gl_framebuffer->gl_fbo.fbo_handle));
|
GE (ctx, glBindFramebuffer (target, priv->gl_fbo.fbo_handle));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -638,6 +642,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
|
|||||||
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
||||||
CoglOffscreenAllocateFlags allocate_flags;
|
CoglOffscreenAllocateFlags allocate_flags;
|
||||||
CoglGlFramebuffer *gl_framebuffer;
|
CoglGlFramebuffer *gl_framebuffer;
|
||||||
|
CoglGlFramebufferPrivate *priv;
|
||||||
CoglGlFbo *gl_fbo;
|
CoglGlFbo *gl_fbo;
|
||||||
const CoglFramebufferConfig *config;
|
const CoglFramebufferConfig *config;
|
||||||
int level_width;
|
int level_width;
|
||||||
@ -669,7 +674,8 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
|
|||||||
config = cogl_framebuffer_get_config (framebuffer);
|
config = cogl_framebuffer_get_config (framebuffer);
|
||||||
|
|
||||||
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
||||||
gl_fbo = &gl_framebuffer->gl_fbo;
|
priv = cogl_gl_framebuffer_get_instance_private (gl_framebuffer);
|
||||||
|
gl_fbo = &priv->gl_fbo;
|
||||||
|
|
||||||
if (((flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL) &&
|
if (((flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL) &&
|
||||||
try_creating_fbo (ctx,
|
try_creating_fbo (ctx,
|
||||||
@ -772,12 +778,14 @@ _cogl_offscreen_gl_free (CoglOffscreen *offscreen)
|
|||||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
|
||||||
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
||||||
CoglGlFramebuffer *gl_framebuffer;
|
CoglGlFramebuffer *gl_framebuffer;
|
||||||
|
CoglGlFramebufferPrivate *priv;
|
||||||
|
|
||||||
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
||||||
|
priv = cogl_gl_framebuffer_get_instance_private (gl_framebuffer);
|
||||||
|
|
||||||
delete_renderbuffers (ctx, gl_framebuffer->gl_fbo.renderbuffers);
|
delete_renderbuffers (ctx, priv->gl_fbo.renderbuffers);
|
||||||
|
|
||||||
GE (ctx, glDeleteFramebuffers (1, &gl_framebuffer->gl_fbo.fbo_handle));
|
GE (ctx, glDeleteFramebuffers (1, &priv->gl_fbo.fbo_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -845,7 +853,6 @@ ensure_gl_framebuffer (CoglFramebuffer *framebuffer)
|
|||||||
cogl_framebuffer_set_driver_private (framebuffer,
|
cogl_framebuffer_set_driver_private (framebuffer,
|
||||||
gl_framebuffer,
|
gl_framebuffer,
|
||||||
g_object_unref);
|
g_object_unref);
|
||||||
gl_framebuffer->dirty_bitmasks = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return gl_framebuffer;
|
return gl_framebuffer;
|
||||||
@ -856,10 +863,12 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
{
|
{
|
||||||
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
||||||
CoglGlFramebuffer *gl_framebuffer;
|
CoglGlFramebuffer *gl_framebuffer;
|
||||||
|
CoglGlFramebufferPrivate *priv;
|
||||||
|
|
||||||
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
||||||
|
priv = cogl_gl_framebuffer_get_instance_private (gl_framebuffer);
|
||||||
|
|
||||||
if (!gl_framebuffer->dirty_bitmasks)
|
if (!priv->dirty_bitmasks)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cogl_framebuffer_allocate (framebuffer, NULL);
|
cogl_framebuffer_allocate (framebuffer, NULL);
|
||||||
@ -904,7 +913,7 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
for (i = 0; i < G_N_ELEMENTS (params); i++)
|
for (i = 0; i < G_N_ELEMENTS (params); i++)
|
||||||
{
|
{
|
||||||
int *value =
|
int *value =
|
||||||
(int *) ((uint8_t *) &gl_framebuffer->bits + params[i].offset);
|
(int *) ((uint8_t *) &priv->bits + params[i].offset);
|
||||||
GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
||||||
params[i].attachment,
|
params[i].attachment,
|
||||||
params[i].pname,
|
params[i].pname,
|
||||||
@ -914,12 +923,12 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
else
|
else
|
||||||
#endif /* HAVE_COGL_GL */
|
#endif /* HAVE_COGL_GL */
|
||||||
{
|
{
|
||||||
GE( ctx, glGetIntegerv (GL_RED_BITS, &gl_framebuffer->bits.red) );
|
GE (ctx, glGetIntegerv (GL_RED_BITS, &priv->bits.red));
|
||||||
GE( ctx, glGetIntegerv (GL_GREEN_BITS, &gl_framebuffer->bits.green) );
|
GE (ctx, glGetIntegerv (GL_GREEN_BITS, &priv->bits.green));
|
||||||
GE( ctx, glGetIntegerv (GL_BLUE_BITS, &gl_framebuffer->bits.blue) );
|
GE (ctx, glGetIntegerv (GL_BLUE_BITS, &priv->bits.blue));
|
||||||
GE( ctx, glGetIntegerv (GL_ALPHA_BITS, &gl_framebuffer->bits.alpha) );
|
GE (ctx, glGetIntegerv (GL_ALPHA_BITS, &priv->bits.alpha));
|
||||||
GE( ctx, glGetIntegerv (GL_DEPTH_BITS, &gl_framebuffer->bits.depth) );
|
GE (ctx, glGetIntegerv (GL_DEPTH_BITS, &priv->bits.depth));
|
||||||
GE( ctx, glGetIntegerv (GL_STENCIL_BITS, &gl_framebuffer->bits.stencil) );
|
GE (ctx, glGetIntegerv (GL_STENCIL_BITS, &priv->bits.stencil));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we don't have alpha textures then the alpha bits are actually
|
/* If we don't have alpha textures then the alpha bits are actually
|
||||||
@ -928,22 +937,22 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
COGL_IS_OFFSCREEN (framebuffer) &&
|
COGL_IS_OFFSCREEN (framebuffer) &&
|
||||||
cogl_framebuffer_get_internal_format (framebuffer) == COGL_PIXEL_FORMAT_A_8)
|
cogl_framebuffer_get_internal_format (framebuffer) == COGL_PIXEL_FORMAT_A_8)
|
||||||
{
|
{
|
||||||
gl_framebuffer->bits.alpha = gl_framebuffer->bits.red;
|
priv->bits.alpha = priv->bits.red;
|
||||||
gl_framebuffer->bits.red = 0;
|
priv->bits.red = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
COGL_NOTE (OFFSCREEN,
|
COGL_NOTE (OFFSCREEN,
|
||||||
"RGBA/D/S Bits for framebuffer[%p, %s]: %d, %d, %d, %d, %d, %d",
|
"RGBA/D/S Bits for framebuffer[%p, %s]: %d, %d, %d, %d, %d, %d",
|
||||||
framebuffer,
|
framebuffer,
|
||||||
COGL_IS_OFFSCREEN (framebuffer) ? "offscreen" : "onscreen",
|
COGL_IS_OFFSCREEN (framebuffer) ? "offscreen" : "onscreen",
|
||||||
gl_framebuffer->bits.red,
|
priv->bits.red,
|
||||||
gl_framebuffer->bits.blue,
|
priv->bits.blue,
|
||||||
gl_framebuffer->bits.green,
|
priv->bits.green,
|
||||||
gl_framebuffer->bits.alpha,
|
priv->bits.alpha,
|
||||||
gl_framebuffer->bits.depth,
|
priv->bits.depth,
|
||||||
gl_framebuffer->bits.stencil);
|
priv->bits.stencil);
|
||||||
|
|
||||||
gl_framebuffer->dirty_bitmasks = FALSE;
|
priv->dirty_bitmasks = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -951,13 +960,15 @@ _cogl_framebuffer_gl_query_bits (CoglFramebuffer *framebuffer,
|
|||||||
CoglFramebufferBits *bits)
|
CoglFramebufferBits *bits)
|
||||||
{
|
{
|
||||||
CoglGlFramebuffer *gl_framebuffer;
|
CoglGlFramebuffer *gl_framebuffer;
|
||||||
|
CoglGlFramebufferPrivate *priv;
|
||||||
|
|
||||||
_cogl_framebuffer_init_bits (framebuffer);
|
_cogl_framebuffer_init_bits (framebuffer);
|
||||||
|
|
||||||
/* TODO: cache these in some driver specific location not
|
/* TODO: cache these in some driver specific location not
|
||||||
* directly as part of CoglFramebuffer. */
|
* directly as part of CoglFramebuffer. */
|
||||||
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
gl_framebuffer = ensure_gl_framebuffer (framebuffer);
|
||||||
*bits = gl_framebuffer->bits;
|
priv = cogl_gl_framebuffer_get_instance_private (gl_framebuffer);
|
||||||
|
*bits = priv->bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1356,6 +1367,10 @@ EXIT:
|
|||||||
static void
|
static void
|
||||||
cogl_gl_framebuffer_init (CoglGlFramebuffer *gl_framebuffer)
|
cogl_gl_framebuffer_init (CoglGlFramebuffer *gl_framebuffer)
|
||||||
{
|
{
|
||||||
|
CoglGlFramebufferPrivate *priv =
|
||||||
|
cogl_gl_framebuffer_get_instance_private (gl_framebuffer);
|
||||||
|
|
||||||
|
priv->dirty_bitmasks = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user