cogl/framebuffer: Move public struct fields to private struct

This will limit accidental manipulation of the framebuffer struct
fields, while also paving the way to change to GObject type hierarchy.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
This commit is contained in:
Jonas Ådahl 2020-10-12 23:31:38 +02:00 committed by Georges Basile Stavracas Neto
parent ffde1c0124
commit aa99e505ad
18 changed files with 934 additions and 510 deletions

View File

@ -259,7 +259,7 @@ emit_vertex_buffer_geometry (CoglFramebuffer *fb,
CoglPipeline *pipeline,
CoglPangoDisplayListNode *node)
{
CoglContext *ctx = fb->context;
CoglContext *ctx = cogl_framebuffer_get_context (fb);
/* It's expensive to go through the Cogl journal for large runs
* of text in part because the journal transforms the quads in software

View File

@ -587,12 +587,12 @@ _cogl_flush_attributes_state (CoglFramebuffer *framebuffer,
CoglAttribute **attributes,
int n_attributes)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglFlushLayerState layers_state;
CoglPipeline *copy = NULL;
if (!(flags & COGL_DRAW_SKIP_JOURNAL_FLUSH))
_cogl_journal_flush (framebuffer->journal);
_cogl_framebuffer_flush_journal (framebuffer);
layers_state.unit = 0;
layers_state.options.flags = 0;

View File

@ -428,7 +428,7 @@ void
_cogl_clip_stack_flush (CoglClipStack *stack,
CoglFramebuffer *framebuffer)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
ctx->driver_vtable->clip_stack_flush (stack, framebuffer);
}

View File

@ -45,7 +45,7 @@ cogl_fence_closure_get_user_data (CoglFenceClosure *closure)
static void
_cogl_fence_check (CoglFenceClosure *fence)
{
CoglContext *context = fence->framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (fence->framebuffer);
if (fence->type == FENCE_TYPE_WINSYS)
{
@ -95,10 +95,11 @@ _cogl_fence_poll_prepare (void *source)
* hit and the main loop might block forever */
for (l = context->framebuffers; l; l = l->next)
{
CoglFramebuffer *fb = l->data;
CoglFramebuffer *framebuffer = l->data;
CoglJournal *journal = cogl_framebuffer_get_journal (framebuffer);
if (!_cogl_list_empty (&fb->journal->pending_fences))
_cogl_framebuffer_flush_journal (fb);
if (!_cogl_list_empty (&journal->pending_fences))
_cogl_framebuffer_flush_journal (framebuffer);
}
if (!_cogl_list_empty (&context->fences))
@ -110,7 +111,7 @@ _cogl_fence_poll_prepare (void *source)
void
_cogl_fence_submit (CoglFenceClosure *fence)
{
CoglContext *context = fence->framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (fence->framebuffer);
const CoglWinsysVtable *winsys = _cogl_context_get_winsys (context);
fence->type = FENCE_TYPE_ERROR;
@ -156,8 +157,8 @@ cogl_framebuffer_add_fence_callback (CoglFramebuffer *framebuffer,
CoglFenceCallback callback,
void *user_data)
{
CoglContext *context = framebuffer->context;
CoglJournal *journal = framebuffer->journal;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglJournal *journal = cogl_framebuffer_get_journal (framebuffer);
CoglFenceClosure *fence;
if (!COGL_FLAGS_GET (context->features, COGL_FEATURE_ID_FENCE))
@ -184,7 +185,7 @@ void
cogl_framebuffer_cancel_fence_callback (CoglFramebuffer *framebuffer,
CoglFenceClosure *fence)
{
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
if (fence->type == FENCE_TYPE_PENDING)
{
@ -214,8 +215,8 @@ cogl_framebuffer_cancel_fence_callback (CoglFramebuffer *framebuffer,
void
_cogl_fence_cancel_fences_for_framebuffer (CoglFramebuffer *framebuffer)
{
CoglJournal *journal = framebuffer->journal;
CoglContext *context = framebuffer->context;
CoglJournal *journal = cogl_framebuffer_get_journal (framebuffer);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglFenceClosure *fence, *tmp;
while (!_cogl_list_empty (&journal->pending_fences))

View File

@ -119,69 +119,7 @@ typedef struct
struct _CoglFramebuffer
{
CoglObject _parent;
CoglContext *context;
CoglFramebufferType type;
/* The user configuration before allocation... */
CoglFramebufferConfig config;
int width;
int height;
/* Format of the pixels in the framebuffer (including the expected
premult state) */
CoglPixelFormat internal_format;
gboolean allocated;
CoglMatrixStack *modelview_stack;
CoglMatrixStack *projection_stack;
float viewport_x;
float viewport_y;
float viewport_width;
float viewport_height;
int viewport_age;
int viewport_age_for_scissor_workaround;
CoglClipStack *clip_stack;
gboolean dither_enabled;
gboolean depth_writing_enabled;
CoglStereoMode stereo_mode;
/* We journal the textured rectangles we want to submit to OpenGL so
* we have an opportunity to batch them together into less draw
* calls. */
CoglJournal *journal;
/* The scene of a given framebuffer may depend on images in other
* framebuffers... */
GList *deps;
/* As part of an optimization for reading-back single pixels from a
* framebuffer in some simple cases where the geometry is still
* available in the journal we need to track the bounds of the last
* region cleared, its color and we need to track when something
* does in fact draw to that region so it is no longer clear.
*/
float clear_color_red;
float clear_color_green;
float clear_color_blue;
float clear_color_alpha;
int clear_clip_x0;
int clear_clip_y0;
int clear_clip_x1;
int clear_clip_y1;
gboolean clear_clip_dirty;
int samples_per_pixel;
/* Whether the depth buffer was enabled for this framebuffer,
* usually means it needs to be cleared before being reused next.
*/
gboolean depth_buffer_clear_needed;
gpointer driver_private;
GDestroyNotify driver_private_destroy;
gpointer priv;
};
typedef enum
@ -224,6 +162,25 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
int width,
int height);
gboolean
cogl_framebuffer_is_allocated (CoglFramebuffer *framebuffer);
void
cogl_framebuffer_init_config (CoglFramebuffer *framebuffer,
const CoglFramebufferConfig *config);
const CoglFramebufferConfig *
cogl_framebuffer_get_config (CoglFramebuffer *framebuffer);
void
cogl_framebuffer_update_samples_per_pixel (CoglFramebuffer *framebuffer,
int samples_per_pixel);
void
cogl_framebuffer_update_size (CoglFramebuffer *framebuffer,
int width,
int height);
/* XXX: For a public api we might instead want a way to explicitly
* set the _premult status of a framebuffer or what components we
* care about instead of exposing the CoglPixelFormat
@ -240,6 +197,9 @@ void
_cogl_framebuffer_set_internal_format (CoglFramebuffer *framebuffer,
CoglPixelFormat internal_format);
CoglPixelFormat
cogl_framebuffer_get_internal_format (CoglFramebuffer *framebuffer);
void _cogl_framebuffer_free (CoglFramebuffer *framebuffer);
const CoglWinsysVtable *
@ -256,6 +216,9 @@ _cogl_framebuffer_clear_without_flush4f (CoglFramebuffer *framebuffer,
void
_cogl_framebuffer_mark_clear_clip_dirty (CoglFramebuffer *framebuffer);
void
cogl_framebuffer_set_depth_buffer_clear_needed (CoglFramebuffer *framebuffer);
/*
* _cogl_framebuffer_get_clip_stack:
* @framebuffer: A #CoglFramebuffer
@ -354,6 +317,13 @@ void
cogl_framebuffer_set_viewport4fv (CoglFramebuffer *framebuffer,
float *viewport);
void
cogl_framebuffer_get_viewport4f (CoglFramebuffer *framebuffer,
float *viewport_x,
float *viewport_y,
float *viewport_width,
float *viewport_height);
unsigned long
_cogl_framebuffer_compare (CoglFramebuffer *a,
CoglFramebuffer *b,
@ -397,6 +367,9 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
COGL_EXPORT int
_cogl_framebuffer_get_stencil_bits (CoglFramebuffer *framebuffer);
CoglJournal *
cogl_framebuffer_get_journal (CoglFramebuffer *framebuffer);
gpointer
cogl_framebuffer_get_driver_private (CoglFramebuffer *framebuffer);

File diff suppressed because it is too large Load Diff

View File

@ -567,7 +567,8 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
void *data)
{
CoglJournalFlushState *state = data;
CoglContext *ctx = state->journal->framebuffer->context;
CoglFramebuffer *framebuffer = state->journal->framebuffer;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
size_t stride;
int i;
CoglAttribute **attribute_entry;
@ -688,7 +689,7 @@ _cogl_journal_flush_clip_stacks_and_entries (CoglJournalEntry *batch_start,
{
CoglJournalFlushState *state = data;
CoglFramebuffer *framebuffer = state->journal->framebuffer;
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglMatrixStack *projection_stack;
COGL_STATIC_TIMER (time_flush_clip_stack_pipeline_entries,
@ -1032,7 +1033,7 @@ _cogl_journal_flush_dither_and_entries (CoglJournalEntry *batch_start,
{
CoglJournalFlushState *state = data;
CoglFramebuffer *framebuffer = state->journal->framebuffer;
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
COGL_STATIC_TIMER (time_flush_dither_and_entries,
"Journal Flush", /* parent */
@ -1075,7 +1076,7 @@ _cogl_journal_flush_viewport_and_entries (CoglJournalEntry *batch_start,
{
CoglJournalFlushState *state = data;
CoglFramebuffer *framebuffer = state->journal->framebuffer;
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
float current_viewport[4];
COGL_STATIC_TIMER (time_flush_viewport_and_entries,
@ -1123,8 +1124,8 @@ static CoglAttributeBuffer *
create_attribute_buffer (CoglJournal *journal,
size_t n_bytes)
{
CoglContext *ctx = cogl_framebuffer_get_context (journal->framebuffer);
CoglAttributeBuffer *vbo;
CoglContext *ctx = journal->framebuffer->context;
vbo = journal->vbo_pool[journal->next_vbo_in_pool];
@ -1383,7 +1384,7 @@ _cogl_journal_flush (CoglJournal *journal)
}
framebuffer = journal->framebuffer;
ctx = framebuffer->context;
ctx = cogl_framebuffer_get_context (framebuffer);
/* The entries in this journal may depend on images in other
* framebuffers which may require that we flush the journals

View File

@ -83,8 +83,7 @@ _cogl_onscreen_init_from_template (CoglOnscreen *onscreen,
_cogl_list_init (&onscreen->resize_closures);
_cogl_list_init (&onscreen->dirty_closures);
framebuffer->config = onscreen_template->config;
cogl_object_ref (framebuffer->config.swap_chain);
cogl_framebuffer_init_config (framebuffer, &onscreen_template->config);
}
CoglOnscreen *
@ -202,7 +201,8 @@ _cogl_dispatch_onscreen_cb (CoglContext *context)
static void
_cogl_onscreen_queue_dispatch_idle (CoglOnscreen *onscreen)
{
CoglContext *ctx = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
if (!ctx->onscreen_dispatch_idle)
{
@ -219,7 +219,8 @@ void
_cogl_onscreen_queue_dirty (CoglOnscreen *onscreen,
const CoglOnscreenDirtyInfo *info)
{
CoglContext *ctx = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglOnscreenQueuedDirty *qe = g_slice_new (CoglOnscreenQueuedDirty);
qe->onscreen = cogl_object_ref (onscreen);
@ -237,8 +238,8 @@ _cogl_onscreen_queue_full_dirty (CoglOnscreen *onscreen)
info.x = 0;
info.y = 0;
info.width = framebuffer->width;
info.height = framebuffer->height;
info.width = cogl_framebuffer_get_width (framebuffer);
info.height = cogl_framebuffer_get_height (framebuffer);
_cogl_onscreen_queue_dirty (onscreen, &info);
}
@ -248,7 +249,8 @@ _cogl_onscreen_queue_event (CoglOnscreen *onscreen,
CoglFrameEvent type,
CoglFrameInfo *info)
{
CoglContext *ctx = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglOnscreenEvent *event = g_slice_new (CoglOnscreenEvent);
@ -270,7 +272,7 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys;
g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
g_return_if_fail (cogl_is_onscreen (framebuffer));
info->frame_counter = onscreen->frame_counter;
g_queue_push_tail (&onscreen->pending_frame_infos, info);
@ -319,7 +321,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys;
g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
g_return_if_fail (cogl_is_onscreen (framebuffer));
info->frame_counter = onscreen->frame_counter;
g_queue_push_tail (&onscreen->pending_frame_infos, info);
@ -365,7 +367,7 @@ cogl_onscreen_get_buffer_age (CoglOnscreen *onscreen)
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys;
g_return_val_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN, 0);
g_return_val_if_fail (cogl_is_onscreen (framebuffer), 0);
winsys = _cogl_framebuffer_get_winsys (framebuffer);
@ -384,7 +386,7 @@ cogl_onscreen_direct_scanout (CoglOnscreen *onscreen,
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys;
g_warn_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
g_warn_if_fail (cogl_is_onscreen (framebuffer));
g_warn_if_fail (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT));
info->frame_counter = onscreen->frame_counter;
@ -442,7 +444,7 @@ cogl_onscreen_show (CoglOnscreen *onscreen)
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys;
if (!framebuffer->allocated)
if (!cogl_framebuffer_is_allocated (framebuffer))
{
if (!cogl_framebuffer_allocate (framebuffer, NULL))
return;
@ -458,7 +460,7 @@ cogl_onscreen_hide (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
if (framebuffer->allocated)
if (cogl_framebuffer_is_allocated (framebuffer))
{
const CoglWinsysVtable *winsys =
_cogl_framebuffer_get_winsys (framebuffer);
@ -487,23 +489,21 @@ _cogl_onscreen_notify_resize (CoglOnscreen *onscreen)
_cogl_closure_list_invoke (&onscreen->resize_closures,
CoglOnscreenResizeCallback,
onscreen,
framebuffer->width,
framebuffer->height);
cogl_framebuffer_get_width (framebuffer),
cogl_framebuffer_get_height (framebuffer));
}
void
_cogl_framebuffer_winsys_update_size (CoglFramebuffer *framebuffer,
int width, int height)
{
if (framebuffer->width == width && framebuffer->height == height)
if (cogl_framebuffer_get_width (framebuffer) == width &&
cogl_framebuffer_get_height (framebuffer) == height)
return;
framebuffer->width = width;
framebuffer->height = height;
cogl_framebuffer_update_size (framebuffer, width, height);
cogl_framebuffer_set_viewport (framebuffer, 0, 0, width, height);
if (!_cogl_has_private_feature (framebuffer->context,
if (!_cogl_has_private_feature (cogl_framebuffer_get_context (framebuffer),
COGL_PRIVATE_FEATURE_DIRTY_EVENTS))
_cogl_onscreen_queue_full_dirty (COGL_ONSCREEN (framebuffer));
}
@ -521,7 +521,7 @@ cogl_onscreen_set_resizable (CoglOnscreen *onscreen,
onscreen->resizable = resizable;
framebuffer = COGL_FRAMEBUFFER (onscreen);
if (framebuffer->allocated)
if (cogl_framebuffer_is_allocated (framebuffer))
{
winsys = _cogl_framebuffer_get_winsys (COGL_FRAMEBUFFER (onscreen));

View File

@ -123,7 +123,7 @@ log_quad_sub_textures_cb (CoglTexture *texture,
else
texture_override = texture;
_cogl_journal_log_quad (framebuffer->journal,
_cogl_journal_log_quad (cogl_framebuffer_get_journal (framebuffer),
quad_coords,
state->pipeline,
1, /* one layer */
@ -458,7 +458,7 @@ _cogl_multitexture_quad_single_primitive (CoglFramebuffer *framebuffer,
if (state.override_pipeline)
pipeline = state.override_pipeline;
_cogl_journal_log_quad (framebuffer->journal,
_cogl_journal_log_quad (cogl_framebuffer_get_journal (framebuffer),
position,
pipeline,
n_layers,
@ -631,7 +631,7 @@ _cogl_framebuffer_draw_multitextured_rectangles (
CoglMultiTexturedRect *rects,
int n_rects)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglPipeline *original_pipeline;
ValidateLayerState state;
int i;
@ -714,7 +714,7 @@ cogl_2d_primitives_immediate (CoglFramebuffer *framebuffer,
const CoglVertexP2 *vertices,
unsigned int n_vertices)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglAttributeBuffer *attribute_buffer;
CoglAttribute *attributes[1];
size_t vertices_size = sizeof (CoglVertexP2) * n_vertices;

View File

@ -186,7 +186,7 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
CoglAttribute **attributes,
int n_attributes)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
int i;
gboolean with_color_attrib = FALSE;
gboolean unknown_color_alpha = FALSE;

View File

@ -153,14 +153,14 @@ add_stencil_clip_region (CoglFramebuffer *framebuffer,
* the default [-1, -1, 1, 1] range.
*/
graphene_point3d_init (&p,
- framebuffer->viewport_x,
- framebuffer->viewport_y,
- cogl_framebuffer_get_viewport_x (framebuffer),
- cogl_framebuffer_get_viewport_y (framebuffer),
0);
graphene_matrix_init_translate (&matrix, &p);
graphene_matrix_scale (&matrix,
2.0 / framebuffer->viewport_width,
- 2.0 / framebuffer->viewport_height,
2.0 / cogl_framebuffer_get_viewport_width (framebuffer),
- 2.0 / cogl_framebuffer_get_viewport_height (framebuffer),
1);
graphene_matrix_translate (&matrix, &GRAPHENE_POINT3D_INIT (-1.f, 1.f, 0.f));
@ -398,7 +398,7 @@ void
_cogl_clip_stack_gl_flush (CoglClipStack *stack,
CoglFramebuffer *framebuffer)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
gboolean using_stencil_buffer = FALSE;
int scissor_x0;
int scissor_y0;

View File

@ -33,6 +33,7 @@
#include "cogl-context-private.h"
#include "cogl-framebuffer-private.h"
#include "cogl-framebuffer.h"
#include "cogl-texture-private.h"
#include "driver/gl/cogl-util-gl-private.h"
#include "driver/gl/cogl-framebuffer-gl-private.h"
@ -135,10 +136,17 @@ typedef struct _CoglFramebufferGl
static void
_cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer)
{
float viewport_x, viewport_y, viewport_width, viewport_height;
float gl_viewport_y;
g_return_if_fail (framebuffer->viewport_width >= 0);
g_return_if_fail (framebuffer->viewport_height >= 0);
cogl_framebuffer_get_viewport4f (framebuffer,
&viewport_x,
&viewport_y,
&viewport_width,
&viewport_height);
g_return_if_fail (viewport_width >= 0);
g_return_if_fail (viewport_height >= 0);
/* Convert the Cogl viewport y offset to an OpenGL viewport y offset
* NB: OpenGL defines its window and viewport origins to be bottom
@ -146,67 +154,73 @@ _cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer)
* NB: We render upside down to offscreen framebuffers so we don't
* need to convert the y offset in this case. */
if (cogl_is_offscreen (framebuffer))
gl_viewport_y = framebuffer->viewport_y;
gl_viewport_y = viewport_y;
else
gl_viewport_y = framebuffer->height -
(framebuffer->viewport_y + framebuffer->viewport_height);
gl_viewport_y =
cogl_framebuffer_get_height (framebuffer) -
(viewport_y + viewport_height);
COGL_NOTE (OPENGL, "Calling glViewport(%f, %f, %f, %f)",
framebuffer->viewport_x,
viewport_x,
gl_viewport_y,
framebuffer->viewport_width,
framebuffer->viewport_height);
viewport_width,
viewport_height);
GE (framebuffer->context,
glViewport (framebuffer->viewport_x,
GE (cogl_framebuffer_get_context (framebuffer),
glViewport (viewport_x,
gl_viewport_y,
framebuffer->viewport_width,
framebuffer->viewport_height));
viewport_width,
viewport_height));
}
static void
_cogl_framebuffer_gl_flush_clip_state (CoglFramebuffer *framebuffer)
{
_cogl_clip_stack_flush (framebuffer->clip_stack, framebuffer);
_cogl_clip_stack_flush (_cogl_framebuffer_get_clip_stack (framebuffer),
framebuffer);
}
static void
_cogl_framebuffer_gl_flush_dither_state (CoglFramebuffer *framebuffer)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
gboolean is_dither_enabled =
cogl_framebuffer_get_dither_enabled (framebuffer);
if (ctx->current_gl_dither_enabled != framebuffer->dither_enabled)
if (ctx->current_gl_dither_enabled != is_dither_enabled)
{
if (framebuffer->dither_enabled)
if (is_dither_enabled)
GE (ctx, glEnable (GL_DITHER));
else
GE (ctx, glDisable (GL_DITHER));
ctx->current_gl_dither_enabled = framebuffer->dither_enabled;
ctx->current_gl_dither_enabled = is_dither_enabled;
}
}
static void
_cogl_framebuffer_gl_flush_modelview_state (CoglFramebuffer *framebuffer)
{
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglMatrixEntry *modelview_entry =
_cogl_framebuffer_get_modelview_entry (framebuffer);
_cogl_context_set_current_modelview_entry (framebuffer->context,
modelview_entry);
_cogl_context_set_current_modelview_entry (ctx, modelview_entry);
}
static void
_cogl_framebuffer_gl_flush_projection_state (CoglFramebuffer *framebuffer)
{
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglMatrixEntry *projection_entry =
_cogl_framebuffer_get_projection_entry (framebuffer);
_cogl_context_set_current_projection_entry (framebuffer->context,
projection_entry);
_cogl_context_set_current_projection_entry (ctx, projection_entry);
}
static void
_cogl_framebuffer_gl_flush_front_face_winding_state (CoglFramebuffer *framebuffer)
{
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglPipelineCullFaceMode mode;
/* NB: The face winding state is actually owned by the current
@ -238,10 +252,10 @@ _cogl_framebuffer_gl_flush_front_face_winding_state (CoglFramebuffer *framebuffe
static void
_cogl_framebuffer_gl_flush_stereo_mode_state (CoglFramebuffer *framebuffer)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
GLenum draw_buffer = GL_BACK;
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
if (cogl_is_offscreen (framebuffer))
return;
if (!ctx->glDrawBuffer)
@ -251,7 +265,7 @@ _cogl_framebuffer_gl_flush_stereo_mode_state (CoglFramebuffer *framebuffer)
* must have already happened. If not it would override what we set here. */
g_assert (ctx->was_bound_to_onscreen);
switch (framebuffer->stereo_mode)
switch (cogl_framebuffer_get_stereo_mode (framebuffer))
{
case COGL_STEREO_BOTH:
draw_buffer = GL_BACK;
@ -274,9 +288,9 @@ _cogl_framebuffer_gl_flush_stereo_mode_state (CoglFramebuffer *framebuffer)
void
_cogl_framebuffer_gl_bind (CoglFramebuffer *framebuffer, GLenum target)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
if (cogl_is_offscreen (framebuffer))
{
CoglOffscreen *offscreen = COGL_OFFSCREEN (framebuffer);
GE (ctx, glBindFramebuffer (target,
@ -325,7 +339,7 @@ _cogl_framebuffer_gl_flush_state (CoglFramebuffer *draw_buffer,
CoglFramebuffer *read_buffer,
CoglFramebufferState state)
{
CoglContext *ctx = draw_buffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (draw_buffer);
unsigned long differences;
int bit;
@ -377,9 +391,9 @@ _cogl_framebuffer_gl_flush_state (CoglFramebuffer *draw_buffer,
return;
/* Lazily ensure the framebuffers have been allocated */
if (G_UNLIKELY (!draw_buffer->allocated))
if (G_UNLIKELY (!cogl_framebuffer_is_allocated (draw_buffer)))
cogl_framebuffer_allocate (draw_buffer, NULL);
if (G_UNLIKELY (!read_buffer->allocated))
if (G_UNLIKELY (!cogl_framebuffer_is_allocated (read_buffer)))
cogl_framebuffer_allocate (read_buffer, NULL);
/* We handle buffer binding separately since the method depends on whether
@ -622,15 +636,15 @@ delete_renderbuffers (CoglContext *ctx, GList *renderbuffers)
* modify anything in
*/
static gboolean
try_creating_fbo (CoglContext *ctx,
CoglTexture *texture,
int texture_level,
int texture_level_width,
int texture_level_height,
CoglTexture *depth_texture,
CoglFramebufferConfig *config,
CoglOffscreenAllocateFlags flags,
CoglGLFramebuffer *gl_framebuffer)
try_creating_fbo (CoglContext *ctx,
CoglTexture *texture,
int texture_level,
int texture_level_width,
int texture_level_height,
CoglTexture *depth_texture,
const CoglFramebufferConfig *config,
CoglOffscreenAllocateFlags flags,
CoglGLFramebuffer *gl_framebuffer)
{
GLuint tex_gl_handle;
GLenum tex_gl_target;
@ -739,10 +753,11 @@ gboolean
_cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
GError **error)
{
CoglFramebuffer *fb = COGL_FRAMEBUFFER (offscreen);
CoglContext *ctx = fb->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglOffscreenAllocateFlags flags;
CoglGLFramebuffer *gl_framebuffer = &offscreen->gl_framebuffer;
const CoglFramebufferConfig *config;
int level_width;
int level_height;
@ -769,6 +784,8 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
_cogl_texture_gl_flush_legacy_texobj_filters (offscreen->texture,
GL_NEAREST, GL_NEAREST);
config = cogl_framebuffer_get_config (framebuffer);
if (((offscreen->create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL) &&
try_creating_fbo (ctx,
offscreen->texture,
@ -776,7 +793,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
level_width,
level_height,
offscreen->depth_texture,
&fb->config,
config,
flags = 0,
gl_framebuffer)) ||
@ -787,7 +804,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
level_width,
level_height,
offscreen->depth_texture,
&fb->config,
config,
flags = ctx->last_offscreen_allocate_flags,
gl_framebuffer)) ||
@ -804,7 +821,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
level_width,
level_height,
offscreen->depth_texture,
&fb->config,
config,
flags = COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_STENCIL,
gl_framebuffer)) ||
@ -814,7 +831,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
level_width,
level_height,
offscreen->depth_texture,
&fb->config,
config,
flags = COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH |
COGL_OFFSCREEN_ALLOCATE_FLAG_STENCIL,
gl_framebuffer) ||
@ -825,7 +842,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
level_width,
level_height,
offscreen->depth_texture,
&fb->config,
config,
flags = COGL_OFFSCREEN_ALLOCATE_FLAG_STENCIL,
gl_framebuffer) ||
@ -835,7 +852,7 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
level_width,
level_height,
offscreen->depth_texture,
&fb->config,
config,
flags = COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH,
gl_framebuffer) ||
@ -845,11 +862,12 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
level_width,
level_height,
offscreen->depth_texture,
&fb->config,
config,
flags = 0,
gl_framebuffer))
{
fb->samples_per_pixel = gl_framebuffer->samples_per_pixel;
cogl_framebuffer_update_samples_per_pixel (framebuffer,
gl_framebuffer->samples_per_pixel);
if (!(offscreen->create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL))
{
@ -878,7 +896,8 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
void
_cogl_offscreen_gl_free (CoglOffscreen *offscreen)
{
CoglContext *ctx = COGL_FRAMEBUFFER (offscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
delete_renderbuffers (ctx, offscreen->gl_framebuffer.renderbuffers);
@ -893,7 +912,7 @@ _cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer,
float blue,
float alpha)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
GLbitfield gl_buffers = 0;
if (buffers & COGL_BUFFER_BIT_COLOR)
@ -904,13 +923,17 @@ _cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer,
if (buffers & COGL_BUFFER_BIT_DEPTH)
{
gboolean is_depth_writing_enabled;
gl_buffers |= GL_DEPTH_BUFFER_BIT;
if (ctx->depth_writing_enabled_cache != framebuffer->depth_writing_enabled)
is_depth_writing_enabled =
cogl_framebuffer_get_depth_write_enabled (framebuffer);
if (ctx->depth_writing_enabled_cache != is_depth_writing_enabled)
{
GE( ctx, glDepthMask (framebuffer->depth_writing_enabled));
GE( ctx, glDepthMask (is_depth_writing_enabled));
ctx->depth_writing_enabled_cache = framebuffer->depth_writing_enabled;
ctx->depth_writing_enabled_cache = is_depth_writing_enabled;
/* Make sure the DepthMask is updated when the next primitive is drawn */
ctx->current_pipeline_changes_since_flush |=
@ -947,7 +970,7 @@ ensure_framebuffer_gl (CoglFramebuffer *framebuffer)
static inline void
_cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglFramebufferGl *framebuffer_gl;
framebuffer_gl = ensure_framebuffer_gl (framebuffer);
@ -963,11 +986,11 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
#ifdef HAVE_COGL_GL
if ((ctx->driver == COGL_DRIVER_GL3 &&
framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN) ||
cogl_is_onscreen (framebuffer)) ||
(_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_QUERY_FRAMEBUFFER_BITS) &&
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN))
cogl_is_offscreen (framebuffer)))
{
gboolean is_offscreen = framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN;
gboolean is_offscreen = cogl_is_offscreen (framebuffer);
const struct {
GLenum attachment, pname;
size_t offset;
@ -1017,8 +1040,8 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
/* If we don't have alpha textures then the alpha bits are actually
* stored in the red component */
if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_ALPHA_TEXTURES) &&
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN &&
framebuffer->internal_format == COGL_PIXEL_FORMAT_A_8)
cogl_is_offscreen (framebuffer) &&
cogl_framebuffer_get_internal_format (framebuffer) == COGL_PIXEL_FORMAT_A_8)
{
framebuffer_gl->bits.alpha = framebuffer_gl->bits.red;
framebuffer_gl->bits.red = 0;
@ -1027,9 +1050,7 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
COGL_NOTE (OFFSCREEN,
"RGBA/D/S Bits for framebuffer[%p, %s]: %d, %d, %d, %d, %d, %d",
framebuffer,
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN
? "offscreen"
: "onscreen",
cogl_is_offscreen (framebuffer) ? "offscreen" : "onscreen",
framebuffer_gl->bits.red,
framebuffer_gl->bits.blue,
framebuffer_gl->bits.green,
@ -1057,27 +1078,27 @@ _cogl_framebuffer_gl_query_bits (CoglFramebuffer *framebuffer,
void
_cogl_framebuffer_gl_finish (CoglFramebuffer *framebuffer)
{
GE (framebuffer->context, glFinish ());
GE (cogl_framebuffer_get_context (framebuffer), glFinish ());
}
void
_cogl_framebuffer_gl_flush (CoglFramebuffer *framebuffer)
{
GE (framebuffer->context, glFlush ());
GE (cogl_framebuffer_get_context (framebuffer), glFlush ());
}
void
_cogl_framebuffer_gl_discard_buffers (CoglFramebuffer *framebuffer,
unsigned long buffers)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
if (ctx->glDiscardFramebuffer)
{
GLenum attachments[3];
int i = 0;
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN)
if (cogl_is_onscreen (framebuffer))
{
if (buffers & COGL_BUFFER_BIT_COLOR)
attachments[i++] = GL_COLOR;
@ -1116,7 +1137,7 @@ _cogl_framebuffer_gl_draw_attributes (CoglFramebuffer *framebuffer,
_cogl_flush_attributes_state (framebuffer, pipeline, flags,
attributes, n_attributes);
GE (framebuffer->context,
GE (cogl_framebuffer_get_context (framebuffer),
glDrawArrays ((GLenum)mode, first_vertex, n_vertices));
}
@ -1180,7 +1201,7 @@ _cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
break;
}
GE (framebuffer->context,
GE (cogl_framebuffer_get_context (framebuffer),
glDrawElements ((GLenum)mode,
n_vertices,
indices_gl_type,
@ -1197,11 +1218,13 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
CoglBitmap *bitmap,
GError **error)
{
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
int framebuffer_height = cogl_framebuffer_get_height (framebuffer);
int width = cogl_bitmap_get_width (bitmap);
int height = cogl_bitmap_get_height (bitmap);
CoglPixelFormat format = cogl_bitmap_get_format (bitmap);
CoglPixelFormat internal_format =
cogl_framebuffer_get_internal_format (framebuffer);
CoglPixelFormat required_format;
GLenum gl_intformat;
GLenum gl_format;
@ -1281,8 +1304,10 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
}
if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (read_format))
read_format = ((read_format & ~COGL_PREMULT_BIT) |
(framebuffer->internal_format & COGL_PREMULT_BIT));
{
read_format = ((read_format & ~COGL_PREMULT_BIT) |
(internal_format & COGL_PREMULT_BIT));
}
tmp_bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
width, height,
@ -1336,7 +1361,7 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
* converted to the right format below */
if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (format))
bmp_format = ((format & ~COGL_PREMULT_BIT) |
(framebuffer->internal_format & COGL_PREMULT_BIT));
(internal_format & COGL_PREMULT_BIT));
else
bmp_format = format;

View File

@ -259,7 +259,10 @@ flush_depth_state (CoglContext *ctx,
gboolean depth_writing_enabled = depth_state->write_enabled;
if (ctx->current_draw_buffer)
depth_writing_enabled &= ctx->current_draw_buffer->depth_writing_enabled;
{
depth_writing_enabled &=
cogl_framebuffer_get_depth_write_enabled (ctx->current_draw_buffer);
}
if (ctx->depth_test_enabled_cache != depth_state->test_enabled)
{
@ -267,7 +270,7 @@ flush_depth_state (CoglContext *ctx,
{
GE (ctx, glEnable (GL_DEPTH_TEST));
if (ctx->current_draw_buffer)
ctx->current_draw_buffer->depth_buffer_clear_needed = TRUE;
cogl_framebuffer_set_depth_buffer_clear_needed (ctx->current_draw_buffer);
}
else
GE (ctx, glDisable (GL_DEPTH_TEST));

View File

@ -87,9 +87,9 @@ typedef struct _CoglWinsysEGLVtable
(* onscreen_deinit) (CoglOnscreen *onscreen);
int
(* add_config_attributes) (CoglDisplay *display,
CoglFramebufferConfig *config,
EGLint *attributes);
(* add_config_attributes) (CoglDisplay *display,
const CoglFramebufferConfig *config,
EGLint *attributes);
gboolean
(* choose_config) (CoglDisplay *display,
EGLint *attributes,

View File

@ -81,7 +81,7 @@ find_onscreen_for_xid (CoglContext *context, uint32_t xid)
CoglOnscreenEGL *egl_onscreen;
CoglOnscreenXlib *xlib_onscreen;
if (framebuffer->type != COGL_FRAMEBUFFER_TYPE_ONSCREEN)
if (!cogl_is_onscreen (framebuffer))
continue;
egl_onscreen = COGL_ONSCREEN (framebuffer)->winsys;
@ -99,7 +99,7 @@ flush_pending_resize_notifications_cb (void *data,
{
CoglFramebuffer *framebuffer = data;
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN)
if (cogl_is_onscreen (framebuffer))
{
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
@ -319,9 +319,9 @@ error:
}
static int
_cogl_winsys_egl_add_config_attributes (CoglDisplay *display,
CoglFramebufferConfig *config,
EGLint *attributes)
_cogl_winsys_egl_add_config_attributes (CoglDisplay *display,
const CoglFramebufferConfig *config,
EGLint *attributes)
{
int i = 0;
@ -413,7 +413,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
GError **error)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *display = context->display;
CoglRenderer *renderer = display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
@ -513,7 +513,7 @@ static void
_cogl_winsys_egl_onscreen_deinit (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *renderer = context->display->renderer;
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (renderer);
@ -544,7 +544,8 @@ static void
_cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
gboolean visibility)
{
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *renderer = context->display->renderer;
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (renderer);
@ -562,7 +563,7 @@ _cogl_winsys_onscreen_set_resizable (CoglOnscreen *onscreen,
gboolean resizable)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (context->display->renderer);
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;

View File

@ -195,9 +195,9 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
}
static void
egl_attributes_from_framebuffer_config (CoglDisplay *display,
CoglFramebufferConfig *config,
EGLint *attributes)
egl_attributes_from_framebuffer_config (CoglDisplay *display,
const CoglFramebufferConfig *config,
EGLint *attributes)
{
CoglRenderer *renderer = display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
@ -548,11 +548,12 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
GError **error)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *display = context->display;
CoglDisplayEGL *egl_display = display->winsys;
CoglRenderer *renderer = display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
const CoglFramebufferConfig *config;
EGLint attributes[MAX_EGL_CONFIG_ATTRIBS];
EGLConfig egl_config;
EGLint config_count = 0;
@ -560,9 +561,8 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
g_return_val_if_fail (egl_display->egl_context, FALSE);
egl_attributes_from_framebuffer_config (display,
&framebuffer->config,
attributes);
config = cogl_framebuffer_get_config (framebuffer);
egl_attributes_from_framebuffer_config (display, config, attributes);
status = eglChooseConfig (egl_renderer->edpy,
attributes,
@ -578,14 +578,14 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
/* Update the real number of samples_per_pixel now that we have
* found an egl_config... */
if (framebuffer->config.samples_per_pixel)
if (config->samples_per_pixel)
{
EGLint samples;
status = eglGetConfigAttrib (egl_renderer->edpy,
egl_config,
EGL_SAMPLES, &samples);
g_return_val_if_fail (status == EGL_TRUE, TRUE);
framebuffer->samples_per_pixel = samples;
cogl_framebuffer_update_samples_per_pixel (framebuffer, samples);
}
onscreen->winsys = g_slice_new0 (CoglOnscreenEGL);
@ -606,7 +606,7 @@ static void
_cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglDisplayEGL *egl_display = context->display->winsys;
CoglRenderer *renderer = context->display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
@ -650,8 +650,8 @@ static gboolean
bind_onscreen_with_context (CoglOnscreen *onscreen,
EGLContext egl_context)
{
CoglFramebuffer *fb = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = fb->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
gboolean status = _cogl_winsys_egl_make_current (context->display,
@ -672,8 +672,8 @@ bind_onscreen_with_context (CoglOnscreen *onscreen,
static gboolean
bind_onscreen (CoglOnscreen *onscreen)
{
CoglFramebuffer *fb = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = fb->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglDisplayEGL *egl_display = context->display->winsys;
return bind_onscreen_with_context (onscreen, egl_display->egl_context);
@ -692,7 +692,8 @@ _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
static int
_cogl_winsys_onscreen_get_buffer_age (CoglOnscreen *onscreen)
{
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *renderer = context->display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
@ -729,11 +730,11 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
int n_rectangles,
CoglFrameInfo *info)
{
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *renderer = context->display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
int framebuffer_height = cogl_framebuffer_get_height (framebuffer);
int *rectangles = g_alloca (sizeof (int) * n_rectangles * 4);
int i;
@ -769,7 +770,8 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
int n_rectangles,
CoglFrameInfo *info)
{
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *renderer = context->display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
@ -788,7 +790,7 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
if (n_rectangles && egl_renderer->pf_eglSwapBuffersWithDamage)
{
CoglFramebuffer *fb = COGL_FRAMEBUFFER (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
size_t size = n_rectangles * sizeof (int) * 4;
int *flipped = alloca (size);
int i;
@ -798,7 +800,9 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
{
const int *rect = rectangles + 4 * i;
int *flip_rect = flipped + 4 * i;
flip_rect[1] = fb->height - rect[1] - rect[3];
flip_rect[1] =
cogl_framebuffer_get_height (framebuffer) - rect[1] - rect[3];
}
if (egl_renderer->pf_eglSwapBuffersWithDamage (egl_renderer->edpy,

View File

@ -178,7 +178,7 @@ find_onscreen_for_xid (CoglContext *context, uint32_t xid)
CoglFramebuffer *framebuffer = l->data;
CoglOnscreenXlib *xlib_onscreen;
if (framebuffer->type != COGL_FRAMEBUFFER_TYPE_ONSCREEN)
if (!cogl_is_onscreen (framebuffer))
continue;
/* Does the GLXEvent have the GLXDrawable or the X Window? */
@ -331,7 +331,7 @@ flush_pending_notifications_cb (void *data,
{
CoglFramebuffer *framebuffer = data;
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN)
if (cogl_is_onscreen (framebuffer))
{
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
CoglOnscreenGLX *glx_onscreen = onscreen->winsys;
@ -389,7 +389,8 @@ static void
set_sync_pending (CoglOnscreen *onscreen)
{
CoglOnscreenGLX *glx_onscreen = onscreen->winsys;
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *renderer = context->display->renderer;
CoglGLXRenderer *glx_renderer = renderer->winsys;
@ -412,7 +413,8 @@ static void
set_complete_pending (CoglOnscreen *onscreen)
{
CoglOnscreenGLX *glx_onscreen = onscreen->winsys;
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *renderer = context->display->renderer;
CoglGLXRenderer *glx_renderer = renderer->winsys;
@ -464,7 +466,7 @@ update_output (CoglOnscreen *onscreen)
{
CoglOnscreenXlib *xlib_onscreen = onscreen->winsys;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *display = context->display;
CoglOutput *output;
int width, height;
@ -631,7 +633,7 @@ update_all_outputs (CoglRenderer *renderer)
{
CoglFramebuffer *framebuffer = l->data;
if (framebuffer->type != COGL_FRAMEBUFFER_TYPE_ONSCREEN)
if (!cogl_is_onscreen (framebuffer))
continue;
update_output (COGL_ONSCREEN (framebuffer));
@ -855,9 +857,9 @@ update_winsys_features (CoglContext *context, GError **error)
}
static void
glx_attributes_from_framebuffer_config (CoglDisplay *display,
CoglFramebufferConfig *config,
int *attributes)
glx_attributes_from_framebuffer_config (CoglDisplay *display,
const CoglFramebufferConfig *config,
int *attributes)
{
CoglGLXRenderer *glx_renderer = display->renderer->winsys;
int i = 0;
@ -907,10 +909,10 @@ glx_attributes_from_framebuffer_config (CoglDisplay *display,
* we could overload as an indication of error, so we have to return
* an explicit boolean status. */
static gboolean
find_fbconfig (CoglDisplay *display,
CoglFramebufferConfig *config,
GLXFBConfig *config_ret,
GError **error)
find_fbconfig (CoglDisplay *display,
const CoglFramebufferConfig *config,
GLXFBConfig *config_ret,
GError **error)
{
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (display->renderer);
@ -1235,7 +1237,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
GError **error)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *display = context->display;
CoglGLXDisplay *glx_display = display->winsys;
CoglXlibRenderer *xlib_renderer =
@ -1244,12 +1246,14 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
Window xwin;
CoglOnscreenXlib *xlib_onscreen;
CoglOnscreenGLX *glx_onscreen;
const CoglFramebufferConfig *config;
GLXFBConfig fbconfig;
GError *fbconfig_error = NULL;
g_return_val_if_fail (glx_display->glx_context, FALSE);
if (!find_fbconfig (display, &framebuffer->config,
config = cogl_framebuffer_get_config (framebuffer);
if (!find_fbconfig (display, config,
&fbconfig,
&fbconfig_error))
{
@ -1263,7 +1267,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
/* Update the real number of samples_per_pixel now that we have
* found an fbconfig... */
if (framebuffer->config.samples_per_pixel)
if (config->samples_per_pixel)
{
int samples;
int status = glx_renderer->glXGetFBConfigAttrib (xlib_renderer->xdpy,
@ -1271,7 +1275,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
GLX_SAMPLES,
&samples);
g_return_val_if_fail (status == Success, TRUE);
framebuffer->samples_per_pixel = samples;
cogl_framebuffer_update_samples_per_pixel (framebuffer, samples);
}
/* FIXME: We need to explicitly Select for ConfigureNotify events.
@ -1384,7 +1388,7 @@ static void
_cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglContextGLX *glx_context = context->winsys;
CoglGLXDisplay *glx_display = context->display->winsys;
CoglXlibRenderer *xlib_renderer =
@ -1455,7 +1459,8 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
static void
_cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
{
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglContextGLX *glx_context = context->winsys;
CoglGLXDisplay *glx_display = context->display->winsys;
CoglXlibRenderer *xlib_renderer =
@ -1526,7 +1531,7 @@ static void
_cogl_winsys_wait_for_gpu (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
ctx->glFinish ();
}
@ -1535,7 +1540,7 @@ static void
_cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *ctx = framebuffer->context;
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglGLXRenderer *glx_renderer;
CoglXlibRenderer *xlib_renderer;
CoglGLXDisplay *glx_display;
@ -1598,7 +1603,7 @@ static int
_cogl_winsys_onscreen_get_buffer_age (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglXlibRenderer *xlib_renderer = _cogl_xlib_renderer_get_data (context->display->renderer);
CoglGLXRenderer *glx_renderer = context->display->renderer->winsys;
CoglOnscreenGLX *glx_onscreen = onscreen->winsys;
@ -1635,7 +1640,7 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
CoglFrameInfo *info)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (context->display->renderer);
CoglGLXRenderer *glx_renderer = context->display->renderer->winsys;
@ -1842,7 +1847,7 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
CoglFrameInfo *info)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (context->display->renderer);
CoglGLXRenderer *glx_renderer = context->display->renderer->winsys;
@ -1924,7 +1929,8 @@ static void
_cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
gboolean visibility)
{
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (context->display->renderer);
CoglOnscreenXlib *xlib_onscreen = onscreen->winsys;
@ -1940,7 +1946,7 @@ _cogl_winsys_onscreen_set_resizable (CoglOnscreen *onscreen,
gboolean resizable)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = framebuffer->context;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
CoglXlibRenderer *xlib_renderer =
_cogl_xlib_renderer_get_data (context->display->renderer);
CoglOnscreenXlib *xlib_onscreen = onscreen->winsys;

View File

@ -807,9 +807,9 @@ fail:
}
static int
meta_renderer_native_add_egl_config_attributes (CoglDisplay *cogl_display,
CoglFramebufferConfig *config,
EGLint *attributes)
meta_renderer_native_add_egl_config_attributes (CoglDisplay *cogl_display,
const CoglFramebufferConfig *config,
EGLint *attributes)
{
CoglRendererEGL *cogl_renderer_egl = cogl_display->renderer->winsys;
MetaRendererNativeGpuData *renderer_gpu_data = cogl_renderer_egl->platform;
@ -1726,7 +1726,7 @@ copy_shared_framebuffer_cpu (CoglOnscreen *onscreen,
MetaRendererNativeGpuData *renderer_gpu_data)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = framebuffer->context;
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
MetaDumbBuffer *dumb_fb;
CoglBitmap *dumb_bitmap;
CoglPixelFormat cogl_format;
@ -1869,7 +1869,8 @@ ensure_crtc_modes (CoglOnscreen *onscreen,
{
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
CoglContext *cogl_context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
MetaRendererNativeGpuData *renderer_gpu_data = cogl_renderer_egl->platform;
@ -1897,7 +1898,8 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
int n_rectangles,
CoglFrameInfo *frame_info)
{
CoglContext *cogl_context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
@ -2118,7 +2120,8 @@ meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaGpuKms *render_gpu = onscreen_native->render_gpu;
CoglContext *cogl_context = COGL_FRAMEBUFFER (onscreen)->context;
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
MetaRendererNativeGpuData *renderer_gpu_data = cogl_renderer_egl->platform;
@ -2217,7 +2220,7 @@ meta_renderer_native_create_surface_gbm (CoglOnscreen *onscreen,
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = framebuffer->context;
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *cogl_display = cogl_context->display;
CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
CoglRenderer *cogl_renderer = cogl_display->renderer;
@ -2305,7 +2308,7 @@ meta_renderer_native_create_surface_egl_device (CoglOnscreen *onscreen,
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
CoglContext *cogl_context = framebuffer->context;
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *cogl_display = cogl_context->display;
CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
CoglRenderer *cogl_renderer = cogl_display->renderer;
@ -2538,7 +2541,7 @@ meta_renderer_native_init_onscreen (CoglOnscreen *onscreen,
GError **error)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = framebuffer->context;
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *cogl_display = cogl_context->display;
CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
CoglOnscreenEGL *onscreen_egl;
@ -2644,7 +2647,7 @@ destroy_egl_surface (CoglOnscreen *onscreen)
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaEgl *egl = meta_onscreen_native_get_egl (onscreen_native);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = framebuffer->context;
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
@ -2660,7 +2663,7 @@ static void
meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *cogl_context = framebuffer->context;
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;