mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
cogl/framebuffer/gl: Move OpenGL driver fields to private struct
It's driver specific, so it shouldn't be kept in the generic data structure. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
This commit is contained in:
parent
e720ef1ceb
commit
209b78afd8
@ -173,16 +173,15 @@ struct _CoglFramebuffer
|
|||||||
int clear_clip_y1;
|
int clear_clip_y1;
|
||||||
gboolean clear_clip_dirty;
|
gboolean clear_clip_dirty;
|
||||||
|
|
||||||
/* driver specific */
|
|
||||||
gboolean dirty_bitmasks;
|
|
||||||
CoglFramebufferBits bits;
|
|
||||||
|
|
||||||
int samples_per_pixel;
|
int samples_per_pixel;
|
||||||
|
|
||||||
/* Whether the depth buffer was enabled for this framebuffer,
|
/* Whether the depth buffer was enabled for this framebuffer,
|
||||||
* usually means it needs to be cleared before being reused next.
|
* usually means it needs to be cleared before being reused next.
|
||||||
*/
|
*/
|
||||||
gboolean depth_buffer_clear_needed;
|
gboolean depth_buffer_clear_needed;
|
||||||
|
|
||||||
|
gpointer driver_private;
|
||||||
|
GDestroyNotify driver_private_destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -398,4 +397,12 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
|
|||||||
COGL_EXPORT int
|
COGL_EXPORT int
|
||||||
_cogl_framebuffer_get_stencil_bits (CoglFramebuffer *framebuffer);
|
_cogl_framebuffer_get_stencil_bits (CoglFramebuffer *framebuffer);
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
cogl_framebuffer_get_driver_private (CoglFramebuffer *framebuffer);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_framebuffer_set_driver_private (CoglFramebuffer *framebuffer,
|
||||||
|
gpointer driver_private,
|
||||||
|
GDestroyNotify desrtoy_notify);
|
||||||
|
|
||||||
#endif /* __COGL_FRAMEBUFFER_PRIVATE_H */
|
#endif /* __COGL_FRAMEBUFFER_PRIVATE_H */
|
||||||
|
@ -118,8 +118,6 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
|
|||||||
framebuffer->modelview_stack = cogl_matrix_stack_new (ctx);
|
framebuffer->modelview_stack = cogl_matrix_stack_new (ctx);
|
||||||
framebuffer->projection_stack = cogl_matrix_stack_new (ctx);
|
framebuffer->projection_stack = cogl_matrix_stack_new (ctx);
|
||||||
|
|
||||||
framebuffer->dirty_bitmasks = TRUE;
|
|
||||||
|
|
||||||
framebuffer->samples_per_pixel = 0;
|
framebuffer->samples_per_pixel = 0;
|
||||||
|
|
||||||
framebuffer->clip_stack = NULL;
|
framebuffer->clip_stack = NULL;
|
||||||
@ -192,6 +190,11 @@ _cogl_framebuffer_free (CoglFramebuffer *framebuffer)
|
|||||||
ctx->current_draw_buffer = NULL;
|
ctx->current_draw_buffer = NULL;
|
||||||
if (ctx->current_read_buffer == framebuffer)
|
if (ctx->current_read_buffer == framebuffer)
|
||||||
ctx->current_read_buffer = NULL;
|
ctx->current_read_buffer = NULL;
|
||||||
|
|
||||||
|
if (framebuffer->driver_private_destroy)
|
||||||
|
framebuffer->driver_private_destroy (framebuffer->driver_private);
|
||||||
|
framebuffer->driver_private_destroy = NULL;
|
||||||
|
framebuffer->driver_private = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CoglWinsysVtable *
|
const CoglWinsysVtable *
|
||||||
@ -2280,3 +2283,20 @@ cogl_framebuffer_draw_textured_rectangles (CoglFramebuffer *framebuffer,
|
|||||||
rects,
|
rects,
|
||||||
n_rectangles);
|
n_rectangles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
cogl_framebuffer_get_driver_private (CoglFramebuffer *framebuffer)
|
||||||
|
{
|
||||||
|
return framebuffer->driver_private;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_framebuffer_set_driver_private (CoglFramebuffer *framebuffer,
|
||||||
|
gpointer driver_private,
|
||||||
|
GDestroyNotify destroy_notify)
|
||||||
|
{
|
||||||
|
g_warn_if_fail (!framebuffer->driver_private);
|
||||||
|
|
||||||
|
framebuffer->driver_private = driver_private;
|
||||||
|
framebuffer->driver_private_destroy = destroy_notify;
|
||||||
|
}
|
||||||
|
@ -126,6 +126,11 @@
|
|||||||
#define GL_STENCIL 0x1802
|
#define GL_STENCIL 0x1802
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct _CoglFramebufferGl
|
||||||
|
{
|
||||||
|
gboolean dirty_bitmasks;
|
||||||
|
CoglFramebufferBits bits;
|
||||||
|
} CoglFramebufferGl;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer)
|
_cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer)
|
||||||
@ -921,12 +926,33 @@ _cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer,
|
|||||||
GE (ctx, glClear (gl_buffers));
|
GE (ctx, glClear (gl_buffers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CoglFramebufferGl *
|
||||||
|
ensure_framebuffer_gl (CoglFramebuffer *framebuffer)
|
||||||
|
{
|
||||||
|
CoglFramebufferGl *framebuffer_gl;
|
||||||
|
|
||||||
|
framebuffer_gl = cogl_framebuffer_get_driver_private (framebuffer);
|
||||||
|
if (!framebuffer_gl)
|
||||||
|
{
|
||||||
|
framebuffer_gl = g_new0 (CoglFramebufferGl, 1);
|
||||||
|
cogl_framebuffer_set_driver_private (framebuffer,
|
||||||
|
framebuffer_gl,
|
||||||
|
g_free);
|
||||||
|
framebuffer_gl->dirty_bitmasks = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return framebuffer_gl;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
_cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
_cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
CoglContext *ctx = framebuffer->context;
|
CoglContext *ctx = framebuffer->context;
|
||||||
|
CoglFramebufferGl *framebuffer_gl;
|
||||||
|
|
||||||
if (G_LIKELY (!framebuffer->dirty_bitmasks))
|
framebuffer_gl = ensure_framebuffer_gl (framebuffer);
|
||||||
|
|
||||||
|
if (!framebuffer_gl->dirty_bitmasks)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cogl_framebuffer_allocate (framebuffer, NULL);
|
cogl_framebuffer_allocate (framebuffer, NULL);
|
||||||
@ -970,7 +996,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 *) &framebuffer->bits + params[i].offset);
|
(int *) ((uint8_t *) &framebuffer_gl->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,
|
||||||
@ -980,12 +1006,12 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
else
|
else
|
||||||
#endif /* HAVE_COGL_GL */
|
#endif /* HAVE_COGL_GL */
|
||||||
{
|
{
|
||||||
GE( ctx, glGetIntegerv (GL_RED_BITS, &framebuffer->bits.red) );
|
GE( ctx, glGetIntegerv (GL_RED_BITS, &framebuffer_gl->bits.red) );
|
||||||
GE( ctx, glGetIntegerv (GL_GREEN_BITS, &framebuffer->bits.green) );
|
GE( ctx, glGetIntegerv (GL_GREEN_BITS, &framebuffer_gl->bits.green) );
|
||||||
GE( ctx, glGetIntegerv (GL_BLUE_BITS, &framebuffer->bits.blue) );
|
GE( ctx, glGetIntegerv (GL_BLUE_BITS, &framebuffer_gl->bits.blue) );
|
||||||
GE( ctx, glGetIntegerv (GL_ALPHA_BITS, &framebuffer->bits.alpha) );
|
GE( ctx, glGetIntegerv (GL_ALPHA_BITS, &framebuffer_gl->bits.alpha) );
|
||||||
GE( ctx, glGetIntegerv (GL_DEPTH_BITS, &framebuffer->bits.depth) );
|
GE( ctx, glGetIntegerv (GL_DEPTH_BITS, &framebuffer_gl->bits.depth) );
|
||||||
GE( ctx, glGetIntegerv (GL_STENCIL_BITS, &framebuffer->bits.stencil) );
|
GE( ctx, glGetIntegerv (GL_STENCIL_BITS, &framebuffer_gl->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
|
||||||
@ -994,8 +1020,8 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN &&
|
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN &&
|
||||||
framebuffer->internal_format == COGL_PIXEL_FORMAT_A_8)
|
framebuffer->internal_format == COGL_PIXEL_FORMAT_A_8)
|
||||||
{
|
{
|
||||||
framebuffer->bits.alpha = framebuffer->bits.red;
|
framebuffer_gl->bits.alpha = framebuffer_gl->bits.red;
|
||||||
framebuffer->bits.red = 0;
|
framebuffer_gl->bits.red = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
COGL_NOTE (OFFSCREEN,
|
COGL_NOTE (OFFSCREEN,
|
||||||
@ -1004,25 +1030,28 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN
|
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN
|
||||||
? "offscreen"
|
? "offscreen"
|
||||||
: "onscreen",
|
: "onscreen",
|
||||||
framebuffer->bits.red,
|
framebuffer_gl->bits.red,
|
||||||
framebuffer->bits.blue,
|
framebuffer_gl->bits.blue,
|
||||||
framebuffer->bits.green,
|
framebuffer_gl->bits.green,
|
||||||
framebuffer->bits.alpha,
|
framebuffer_gl->bits.alpha,
|
||||||
framebuffer->bits.depth,
|
framebuffer_gl->bits.depth,
|
||||||
framebuffer->bits.stencil);
|
framebuffer_gl->bits.stencil);
|
||||||
|
|
||||||
framebuffer->dirty_bitmasks = FALSE;
|
framebuffer_gl->dirty_bitmasks = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_framebuffer_gl_query_bits (CoglFramebuffer *framebuffer,
|
_cogl_framebuffer_gl_query_bits (CoglFramebuffer *framebuffer,
|
||||||
CoglFramebufferBits *bits)
|
CoglFramebufferBits *bits)
|
||||||
{
|
{
|
||||||
|
CoglFramebufferGl *framebuffer_gl;
|
||||||
|
|
||||||
_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. */
|
||||||
*bits = framebuffer->bits;
|
framebuffer_gl = ensure_framebuffer_gl (framebuffer);
|
||||||
|
*bits = framebuffer_gl->bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user