cogl: deprecate cogl_draw_buffer API and replace with a cogl_framebuffer API

cogl_push_draw_buffer, cogl_set_draw_buffer and cogl_pop_draw_buffer are now
deprecated and new code should use the new cogl_framebuffer_* API instead.

Code that previously did:
    cogl_push_draw_buffer ();
    cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, buffer);
    /* draw */
    cogl_pop_draw_buffer ();
should now be re-written as:
    cogl_push_framebuffer (buffer);
    /* draw */
    cogl_pop_framebuffer ();

As can be seen from the example above the rename has been used as an
opportunity to remove the redundant target argument from
cogl_set_draw_buffer; it now only takes one call to redirect to an offscreen
buffer, and finally the term framebuffer may be a bit more familiar to
anyone coming from an OpenGL background.
This commit is contained in:
Robert Bragg 2009-11-26 19:06:35 +00:00
parent 7fee8a309b
commit 944423a8d9
14 changed files with 414 additions and 353 deletions

View File

@ -131,8 +131,8 @@ libclutter_cogl_la_SOURCES = \
$(srcdir)/cogl-spans.c \ $(srcdir)/cogl-spans.c \
$(srcdir)/cogl-journal-private.h \ $(srcdir)/cogl-journal-private.h \
$(srcdir)/cogl-journal.c \ $(srcdir)/cogl-journal.c \
$(srcdir)/cogl-draw-buffer-private.h \ $(srcdir)/cogl-framebuffer-private.h \
$(srcdir)/cogl-draw-buffer.c \ $(srcdir)/cogl-framebuffer.c \
$(srcdir)/cogl-matrix-mesa.h \ $(srcdir)/cogl-matrix-mesa.h \
$(srcdir)/cogl-matrix-mesa.c \ $(srcdir)/cogl-matrix-mesa.c \
$(NULL) $(NULL)

View File

@ -35,7 +35,7 @@
#include "cogl-primitives.h" #include "cogl-primitives.h"
#include "cogl-context.h" #include "cogl-context.h"
#include "cogl-internal.h" #include "cogl-internal.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
void _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, void _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
floatVec2 nodes_max, floatVec2 nodes_max,
@ -132,11 +132,11 @@ set_clip_plane (GLint plane_num,
GLdouble plane[4]; GLdouble plane[4];
#endif #endif
GLfloat angle; GLfloat angle;
CoglHandle draw_buffer = _cogl_get_draw_buffer (); CoglHandle framebuffer = _cogl_get_framebuffer ();
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (draw_buffer); _cogl_framebuffer_get_modelview_stack (framebuffer);
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_draw_buffer_get_projection_stack (draw_buffer); _cogl_framebuffer_get_projection_stack (framebuffer);
CoglMatrix inverse_projection; CoglMatrix inverse_projection;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -184,12 +184,12 @@ set_clip_planes (float x_1,
float x_2, float x_2,
float y_2) float y_2)
{ {
CoglHandle draw_buffer = _cogl_get_draw_buffer (); CoglHandle framebuffer = _cogl_get_framebuffer ();
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (draw_buffer); _cogl_framebuffer_get_modelview_stack (framebuffer);
CoglMatrix modelview_matrix; CoglMatrix modelview_matrix;
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_draw_buffer_get_projection_stack (draw_buffer); _cogl_framebuffer_get_projection_stack (framebuffer);
CoglMatrix projection_matrix; CoglMatrix projection_matrix;
float vertex_tl[4] = { x_1, y_1, 0, 1.0 }; float vertex_tl[4] = { x_1, y_1, 0, 1.0 };
@ -236,7 +236,7 @@ add_stencil_clip_rectangle (float x_1,
gboolean first) gboolean first)
{ {
CoglHandle current_source; CoglHandle current_source;
CoglHandle draw_buffer = _cogl_get_draw_buffer (); CoglHandle framebuffer = _cogl_get_framebuffer ();
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -244,7 +244,7 @@ add_stencil_clip_rectangle (float x_1,
* batched geometry before we start... */ * batched geometry before we start... */
_cogl_journal_flush (); _cogl_journal_flush ();
_cogl_draw_buffer_flush_state (draw_buffer, 0); _cogl_framebuffer_flush_state (framebuffer, 0);
/* temporarily swap in our special stenciling material */ /* temporarily swap in our special stenciling material */
current_source = cogl_handle_ref (ctx->source_material); current_source = cogl_handle_ref (ctx->source_material);
@ -267,9 +267,9 @@ add_stencil_clip_rectangle (float x_1,
else else
{ {
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (draw_buffer); _cogl_framebuffer_get_modelview_stack (framebuffer);
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_draw_buffer_get_projection_stack (draw_buffer); _cogl_framebuffer_get_projection_stack (framebuffer);
/* Add one to every pixel of the stencil buffer in the /* Add one to every pixel of the stencil buffer in the
rectangle */ rectangle */
@ -341,10 +341,10 @@ cogl_clip_push_window_rectangle (int x_offset,
int width, int width,
int height) int height)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
CoglClipStackState *clip_state; CoglClipStackState *clip_state;
CoglClipStack *stack; CoglClipStack *stack;
int draw_buffer_height; int framebuffer_height;
CoglClipStackEntryWindowRect *entry; CoglClipStackEntryWindowRect *entry;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -353,12 +353,12 @@ cogl_clip_push_window_rectangle (int x_offset,
* it before making modifications */ * it before making modifications */
_cogl_journal_flush (); _cogl_journal_flush ();
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
stack = clip_state->stacks->data; stack = clip_state->stacks->data;
draw_buffer_height = _cogl_draw_buffer_get_height (draw_buffer); framebuffer_height = _cogl_framebuffer_get_height (framebuffer);
entry = g_slice_new (CoglClipStackEntryWindowRect); entry = g_slice_new (CoglClipStackEntryWindowRect);
@ -372,15 +372,15 @@ cogl_clip_push_window_rectangle (int x_offset,
entry->type = COGL_CLIP_STACK_WINDOW_RECT; entry->type = COGL_CLIP_STACK_WINDOW_RECT;
entry->x0 = x_offset; entry->x0 = x_offset;
entry->x1 = x_offset + width; entry->x1 = x_offset + width;
if (cogl_is_offscreen (draw_buffer)) if (cogl_is_offscreen (framebuffer))
{ {
entry->y0 = y_offset; entry->y0 = y_offset;
entry->y1 = y_offset + height; entry->y1 = y_offset + height;
} }
else else
{ {
entry->y0 = draw_buffer_height - y_offset - height; entry->y0 = framebuffer_height - y_offset - height;
entry->y1 = draw_buffer_height - y_offset; entry->y1 = framebuffer_height - y_offset;
} }
/* Store it in the stack */ /* Store it in the stack */
@ -400,7 +400,7 @@ cogl_clip_push_window_rect (float x_offset,
} }
/* Scale from OpenGL normalized device coordinates (ranging from -1 to 1) /* Scale from OpenGL normalized device coordinates (ranging from -1 to 1)
* to Cogl window/draw-buffer coordinates (ranging from 0 to buffer-size) with * to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with
* (0,0) being top left. */ * (0,0) being top left. */
#define VIEWPORT_TRANSFORM_X(x, vp_origin_x, vp_width) \ #define VIEWPORT_TRANSFORM_X(x, vp_origin_x, vp_width) \
( ( ((x) + 1.0) * ((vp_width) / 2.0) ) + (vp_origin_x) ) ( ( ((x) + 1.0) * ((vp_width) / 2.0) ) + (vp_origin_x) )
@ -492,7 +492,7 @@ cogl_clip_push_rectangle (float x_1,
float x_2, float x_2,
float y_2) float y_2)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
CoglClipStackState *clip_state; CoglClipStackState *clip_state;
CoglClipStack *stack; CoglClipStack *stack;
CoglClipStackEntryRect *entry; CoglClipStackEntryRect *entry;
@ -508,8 +508,8 @@ cogl_clip_push_rectangle (float x_1,
if (try_pushing_rect_as_window_rect (x_1, y_1, x_2, y_2)) if (try_pushing_rect_as_window_rect (x_1, y_1, x_2, y_2))
return; return;
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
stack = clip_state->stacks->data; stack = clip_state->stacks->data;
@ -546,7 +546,7 @@ cogl_clip_push (float x_offset,
void void
cogl_clip_push_from_path_preserve (void) cogl_clip_push_from_path_preserve (void)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
CoglClipStackState *clip_state; CoglClipStackState *clip_state;
CoglClipStack *stack; CoglClipStack *stack;
CoglClipStackEntryPath *entry; CoglClipStackEntryPath *entry;
@ -557,8 +557,8 @@ cogl_clip_push_from_path_preserve (void)
* it before making modifications */ * it before making modifications */
_cogl_journal_flush (); _cogl_journal_flush ();
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
stack = clip_state->stacks->data; stack = clip_state->stacks->data;
@ -623,13 +623,13 @@ _cogl_clip_pop_real (CoglClipStackState *clip_state)
void void
cogl_clip_pop (void) cogl_clip_pop (void)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
CoglClipStackState *clip_state; CoglClipStackState *clip_state;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
_cogl_clip_pop_real (clip_state); _cogl_clip_pop_real (clip_state);
} }
@ -647,7 +647,7 @@ _cogl_flush_clip_state (CoglClipStackState *clip_state)
gint scissor_x1 = G_MAXINT; gint scissor_x1 = G_MAXINT;
gint scissor_y1 = G_MAXINT; gint scissor_y1 = G_MAXINT;
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
if (!clip_state->stack_dirty) if (!clip_state->stack_dirty)
return; return;
@ -776,7 +776,7 @@ cogl_clip_ensure (void)
{ {
CoglClipStackState *clip_state; CoglClipStackState *clip_state;
clip_state = _cogl_draw_buffer_get_clip_state (_cogl_get_draw_buffer ()); clip_state = _cogl_framebuffer_get_clip_state (_cogl_get_framebuffer ());
_cogl_flush_clip_state (clip_state); _cogl_flush_clip_state (clip_state);
} }
@ -799,13 +799,13 @@ _cogl_clip_stack_save_real (CoglClipStackState *clip_state)
void void
cogl_clip_stack_save (void) cogl_clip_stack_save (void)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
CoglClipStackState *clip_state; CoglClipStackState *clip_state;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
_cogl_clip_stack_save_real (clip_state); _cogl_clip_stack_save_real (clip_state);
} }
@ -838,13 +838,13 @@ _cogl_clip_stack_restore_real (CoglClipStackState *clip_state)
void void
cogl_clip_stack_restore (void) cogl_clip_stack_restore (void)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
CoglClipStackState *clip_state; CoglClipStackState *clip_state;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
_cogl_clip_stack_restore_real (clip_state); _cogl_clip_stack_restore_real (clip_state);
} }

View File

@ -32,7 +32,7 @@
#include "cogl-journal-private.h" #include "cogl-journal-private.h"
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-material-private.h" #include "cogl-material-private.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
#include <string.h> #include <string.h>
@ -98,12 +98,13 @@ cogl_create_context (void)
sizeof (CoglLayerInfo)); sizeof (CoglLayerInfo));
_context->n_texcoord_arrays_enabled = 0; _context->n_texcoord_arrays_enabled = 0;
_context->draw_buffer_stack = _cogl_create_draw_buffer_stack (); _context->framebuffer_stack = _cogl_create_framebuffer_stack ();
window_buffer = _cogl_onscreen_new (); window_buffer = _cogl_onscreen_new ();
/* XXX: When setting up the window buffer, cogl_set_draw_buffer cogl_set_framebuffer (window_buffer);
* assumes that the handle can be found in ctx->window_buffer */ /* XXX: the deprecated _cogl_set_draw_buffer API expects to
* find the window buffer here... */
_context->window_buffer = window_buffer; _context->window_buffer = window_buffer;
cogl_set_draw_buffer (COGL_WINDOW_BUFFER, 0/* ignored */);
_context->dirty_bound_framebuffer = TRUE; _context->dirty_bound_framebuffer = TRUE;
_context->dirty_gl_viewport = TRUE; _context->dirty_gl_viewport = TRUE;
@ -158,7 +159,7 @@ _cogl_destroy_context ()
_cogl_destroy_texture_units (); _cogl_destroy_texture_units ();
_cogl_free_draw_buffer_stack (_context->draw_buffer_stack); _cogl_free_framebuffer_stack (_context->framebuffer_stack);
if (_context->path_nodes) if (_context->path_nodes)
g_array_free (_context->path_nodes, TRUE); g_array_free (_context->path_nodes, TRUE);

View File

@ -86,8 +86,8 @@ typedef struct
GArray *current_layers; GArray *current_layers;
guint n_texcoord_arrays_enabled; guint n_texcoord_arrays_enabled;
/* Draw Buffers */ /* Framebuffers */
GSList *draw_buffer_stack; GSList *framebuffer_stack;
CoglHandle window_buffer; CoglHandle window_buffer;
gboolean dirty_bound_framebuffer; gboolean dirty_bound_framebuffer;
gboolean dirty_gl_viewport; gboolean dirty_gl_viewport;

View File

@ -21,22 +21,22 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifndef __COGL_DRAW_BUFFER_PRIVATE_H #ifndef __COGL_FRAMEBUFFER_PRIVATE_H
#define __COGL_DRAW_BUFFER_PRIVATE_H #define __COGL_FRAMEBUFFER_PRIVATE_H
#include "cogl-handle.h" #include "cogl-handle.h"
#include "cogl-matrix-stack.h" #include "cogl-matrix-stack.h"
#include "cogl-clip-stack.h" #include "cogl-clip-stack.h"
typedef enum _CoglDrawBufferType { typedef enum _CoglFramebufferType {
COGL_DRAW_BUFFER_TYPE_ONSCREEN, COGL_FRAMEBUFFER_TYPE_ONSCREEN,
COGL_DRAW_BUFFER_TYPE_OFFSCREEN COGL_FRAMEBUFFER_TYPE_OFFSCREEN
} CoglDrawBufferType; } CoglFramebufferType;
typedef struct typedef struct
{ {
CoglHandleObject _parent; CoglHandleObject _parent;
CoglDrawBufferType type; CoglFramebufferType type;
int width; int width;
int height; int height;
@ -48,19 +48,13 @@ typedef struct
int viewport_height; int viewport_height;
CoglClipStackState clip_state; CoglClipStackState clip_state;
} CoglDrawBuffer; } CoglFramebuffer;
#define COGL_DRAW_BUFFER(X) ((CoglDrawBuffer *)(X)) #define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X))
typedef struct _CoglDrawBufferStackEntry
{
CoglBufferTarget target;
CoglHandle draw_buffer;
} CoglDrawBufferStackEntry;
typedef struct _CoglOffscreen typedef struct _CoglOffscreen
{ {
CoglDrawBuffer _parent; CoglFramebuffer _parent;
GLuint fbo_handle; GLuint fbo_handle;
GLuint gl_stencil_handle; GLuint gl_stencil_handle;
} CoglOffscreen; } CoglOffscreen;
@ -69,65 +63,62 @@ typedef struct _CoglOffscreen
typedef struct _CoglOnscreen typedef struct _CoglOnscreen
{ {
CoglDrawBuffer _parent; CoglFramebuffer _parent;
} CoglOnscreen; } CoglOnscreen;
#define COGL_ONSCREEN(X) ((CoglOnscreen *)(X)) #define COGL_ONSCREEN(X) ((CoglOnscreen *)(X))
void void
_cogl_draw_buffer_state_init (void); _cogl_framebuffer_state_init (void);
int int
_cogl_draw_buffer_get_width (CoglHandle handle); _cogl_framebuffer_get_width (CoglHandle handle);
int int
_cogl_draw_buffer_get_height (CoglHandle handle); _cogl_framebuffer_get_height (CoglHandle handle);
CoglClipStackState * CoglClipStackState *
_cogl_draw_buffer_get_clip_state (CoglHandle handle); _cogl_framebuffer_get_clip_state (CoglHandle handle);
void void
_cogl_draw_buffer_set_viewport (CoglHandle handle, _cogl_framebuffer_set_viewport (CoglHandle handle,
int x, int x,
int y, int y,
int width, int width,
int height); int height);
int int
_cogl_draw_buffer_get_viewport_x (CoglHandle handle); _cogl_framebuffer_get_viewport_x (CoglHandle handle);
int int
_cogl_draw_buffer_get_viewport_y (CoglHandle handle); _cogl_framebuffer_get_viewport_y (CoglHandle handle);
int int
_cogl_draw_buffer_get_viewport_width (CoglHandle handle); _cogl_framebuffer_get_viewport_width (CoglHandle handle);
int int
_cogl_draw_buffer_get_viewport_height (CoglHandle handle); _cogl_framebuffer_get_viewport_height (CoglHandle handle);
void void
_cogl_draw_buffer_get_viewport4fv (CoglHandle handle, int *viewport); _cogl_framebuffer_get_viewport4fv (CoglHandle handle, int *viewport);
CoglMatrixStack * CoglMatrixStack *
_cogl_draw_buffer_get_modelview_stack (CoglHandle handle); _cogl_framebuffer_get_modelview_stack (CoglHandle handle);
CoglMatrixStack * CoglMatrixStack *
_cogl_draw_buffer_get_projection_stack (CoglHandle handle); _cogl_framebuffer_get_projection_stack (CoglHandle handle);
typedef enum _CoglDrawBufferFlushFlags typedef enum _CoglFramebufferFlushFlags
{ {
/* XXX: When using this, that imples you are going to manually load the /* XXX: When using this, that imples you are going to manually load the
* modelview matrix (via glLoadMatrix). _cogl_matrix_stack_flush_to_gl wont * modelview matrix (via glLoadMatrix). _cogl_matrix_stack_flush_to_gl wont
* be called for draw_buffer->modelview_stack, and the modelview_stack will * be called for framebuffer->modelview_stack, and the modelview_stack will
* also be marked as dirty. */ * also be marked as dirty. */
COGL_DRAW_BUFFER_FLUSH_SKIP_MODELVIEW = 1L<<0, COGL_FRAMEBUFFER_FLUSH_SKIP_MODELVIEW = 1L<<0,
} CoglDrawBufferFlushFlags; } CoglFramebufferFlushFlags;
void void
_cogl_draw_buffer_flush_state (CoglHandle handle, _cogl_framebuffer_flush_state (CoglHandle handle,
CoglDrawBufferFlushFlags flags); CoglFramebufferFlushFlags flags);
CoglHandle CoglHandle
_cogl_onscreen_new (void); _cogl_onscreen_new (void);
gboolean
cogl_is_offscreen (CoglHandle handle);
CoglHandle CoglHandle
_cogl_get_draw_buffer (void); _cogl_get_framebuffer (void);
GSList * GSList *
_cogl_create_draw_buffer_stack (void); _cogl_create_framebuffer_stack (void);
void void
_cogl_free_draw_buffer_stack (GSList *stack); _cogl_free_framebuffer_stack (GSList *stack);
#endif /* __COGL_DRAW_BUFFER_PRIVATE_H */ #endif /* __COGL_FRAMEBUFFER_PRIVATE_H */

View File

@ -31,7 +31,7 @@
#include "cogl-handle.h" #include "cogl-handle.h"
#include "cogl-util.h" #include "cogl-util.h"
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
#include "cogl-clip-stack.h" #include "cogl-clip-stack.h"
#ifdef HAVE_COGL_GLES2 #ifdef HAVE_COGL_GLES2
@ -72,7 +72,7 @@
#define GL_STENCIL_INDEX8 0x8D48 #define GL_STENCIL_INDEX8 0x8D48
#endif #endif
static void _cogl_draw_buffer_free (CoglDrawBuffer *draw_buffer); static void _cogl_framebuffer_free (CoglFramebuffer *framebuffer);
static void _cogl_onscreen_free (CoglOnscreen *onscreen); static void _cogl_onscreen_free (CoglOnscreen *onscreen);
static void _cogl_offscreen_free (CoglOffscreen *offscreen); static void _cogl_offscreen_free (CoglOffscreen *offscreen);
@ -81,12 +81,12 @@ COGL_HANDLE_DEFINE (Offscreen, offscreen);
/* XXX: /* XXX:
* The CoglHandle macros don't support any form of inheritance, so for * The CoglHandle macros don't support any form of inheritance, so for
* now we implement the CoglHandle support for the CoglDrawBuffer * now we implement the CoglHandle support for the CoglFramebuffer
* abstract class manually. * abstract class manually.
*/ */
gboolean gboolean
cogl_is_draw_buffer (CoglHandle handle) cogl_is_framebuffer (CoglHandle handle)
{ {
CoglHandleObject *obj = (CoglHandleObject *)handle; CoglHandleObject *obj = (CoglHandleObject *)handle;
@ -98,138 +98,138 @@ cogl_is_draw_buffer (CoglHandle handle)
} }
static void static void
_cogl_draw_buffer_init (CoglDrawBuffer *draw_buffer, _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
CoglDrawBufferType type, CoglFramebufferType type,
int width, int width,
int height) int height)
{ {
draw_buffer->type = type; framebuffer->type = type;
draw_buffer->width = width; framebuffer->width = width;
draw_buffer->height = height; framebuffer->height = height;
draw_buffer->viewport_x = 0; framebuffer->viewport_x = 0;
draw_buffer->viewport_y = 0; framebuffer->viewport_y = 0;
draw_buffer->viewport_width = width; framebuffer->viewport_width = width;
draw_buffer->viewport_height = height; framebuffer->viewport_height = height;
draw_buffer->modelview_stack = _cogl_matrix_stack_new (); framebuffer->modelview_stack = _cogl_matrix_stack_new ();
draw_buffer->projection_stack = _cogl_matrix_stack_new (); framebuffer->projection_stack = _cogl_matrix_stack_new ();
/* Initialise the clip stack */ /* Initialise the clip stack */
_cogl_clip_stack_state_init (&draw_buffer->clip_state); _cogl_clip_stack_state_init (&framebuffer->clip_state);
} }
void void
_cogl_draw_buffer_free (CoglDrawBuffer *draw_buffer) _cogl_framebuffer_free (CoglFramebuffer *framebuffer)
{ {
_cogl_clip_stack_state_destroy (&draw_buffer->clip_state); _cogl_clip_stack_state_destroy (&framebuffer->clip_state);
_cogl_matrix_stack_destroy (draw_buffer->modelview_stack); _cogl_matrix_stack_destroy (framebuffer->modelview_stack);
draw_buffer->modelview_stack = NULL; framebuffer->modelview_stack = NULL;
_cogl_matrix_stack_destroy (draw_buffer->projection_stack); _cogl_matrix_stack_destroy (framebuffer->projection_stack);
draw_buffer->projection_stack = NULL; framebuffer->projection_stack = NULL;
} }
int int
_cogl_draw_buffer_get_width (CoglHandle handle) _cogl_framebuffer_get_width (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return draw_buffer->width; return framebuffer->width;
} }
int int
_cogl_draw_buffer_get_height (CoglHandle handle) _cogl_framebuffer_get_height (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return draw_buffer->height; return framebuffer->height;
} }
CoglClipStackState * CoglClipStackState *
_cogl_draw_buffer_get_clip_state (CoglHandle handle) _cogl_framebuffer_get_clip_state (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return &draw_buffer->clip_state; return &framebuffer->clip_state;
} }
void void
_cogl_draw_buffer_set_viewport (CoglHandle handle, _cogl_framebuffer_set_viewport (CoglHandle handle,
int x, int x,
int y, int y,
int width, int width,
int height) int height)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (draw_buffer->viewport_x == x && if (framebuffer->viewport_x == x &&
draw_buffer->viewport_y == y && framebuffer->viewport_y == y &&
draw_buffer->viewport_width == width && framebuffer->viewport_width == width &&
draw_buffer->viewport_height == height) framebuffer->viewport_height == height)
return; return;
_cogl_journal_flush (); _cogl_journal_flush ();
draw_buffer->viewport_x = x; framebuffer->viewport_x = x;
draw_buffer->viewport_y = y; framebuffer->viewport_y = y;
draw_buffer->viewport_width = width; framebuffer->viewport_width = width;
draw_buffer->viewport_height = height; framebuffer->viewport_height = height;
if (_cogl_get_draw_buffer () == draw_buffer) if (_cogl_get_framebuffer () == framebuffer)
ctx->dirty_gl_viewport = TRUE; ctx->dirty_gl_viewport = TRUE;
} }
int int
_cogl_draw_buffer_get_viewport_x (CoglHandle handle) _cogl_framebuffer_get_viewport_x (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return draw_buffer->viewport_x; return framebuffer->viewport_x;
} }
int int
_cogl_draw_buffer_get_viewport_y (CoglHandle handle) _cogl_framebuffer_get_viewport_y (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return draw_buffer->viewport_y; return framebuffer->viewport_y;
} }
int int
_cogl_draw_buffer_get_viewport_width (CoglHandle handle) _cogl_framebuffer_get_viewport_width (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return draw_buffer->viewport_width; return framebuffer->viewport_width;
} }
int int
_cogl_draw_buffer_get_viewport_height (CoglHandle handle) _cogl_framebuffer_get_viewport_height (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return draw_buffer->viewport_height; return framebuffer->viewport_height;
} }
void void
_cogl_draw_buffer_get_viewport4fv (CoglHandle handle, int *viewport) _cogl_framebuffer_get_viewport4fv (CoglHandle handle, int *viewport)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
viewport[0] = draw_buffer->viewport_x; viewport[0] = framebuffer->viewport_x;
viewport[1] = draw_buffer->viewport_y; viewport[1] = framebuffer->viewport_y;
viewport[2] = draw_buffer->viewport_width; viewport[2] = framebuffer->viewport_width;
viewport[3] = draw_buffer->viewport_height; viewport[3] = framebuffer->viewport_height;
} }
CoglMatrixStack * CoglMatrixStack *
_cogl_draw_buffer_get_modelview_stack (CoglHandle handle) _cogl_framebuffer_get_modelview_stack (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return draw_buffer->modelview_stack; return framebuffer->modelview_stack;
} }
CoglMatrixStack * CoglMatrixStack *
_cogl_draw_buffer_get_projection_stack (CoglHandle handle) _cogl_framebuffer_get_projection_stack (CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle);
return draw_buffer->projection_stack; return framebuffer->projection_stack;
} }
CoglHandle CoglHandle
@ -278,7 +278,7 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
GE (glBindRenderbuffer (GL_RENDERBUFFER, 0)); GE (glBindRenderbuffer (GL_RENDERBUFFER, 0));
/* We are about to generate and bind a new fbo, so when next flushing the /* We are about to generate and bind a new fbo, so when next flushing the
* journal, we will need to rebind the current draw buffer... */ * journal, we will need to rebind the current framebuffer... */
ctx->dirty_bound_framebuffer = 1; ctx->dirty_bound_framebuffer = 1;
/* Generate framebuffer */ /* Generate framebuffer */
@ -329,8 +329,8 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
offscreen = g_new0 (CoglOffscreen, 1); offscreen = g_new0 (CoglOffscreen, 1);
_cogl_draw_buffer_init (COGL_DRAW_BUFFER (offscreen), _cogl_framebuffer_init (COGL_FRAMEBUFFER (offscreen),
COGL_DRAW_BUFFER_TYPE_OFFSCREEN, COGL_FRAMEBUFFER_TYPE_OFFSCREEN,
width, width,
height); height);
@ -341,9 +341,9 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
* users of the API are hopefully setting up the modelview from scratch * users of the API are hopefully setting up the modelview from scratch
* anyway */ * anyway */
#if 0 #if 0
cogl_matrix_translate (&draw_buffer->modelview, -1.0f, -1.0f, 0.0f); cogl_matrix_translate (&framebuffer->modelview, -1.0f, -1.0f, 0.0f);
cogl_matrix_scale (&draw_buffer->modelview, cogl_matrix_scale (&framebuffer->modelview,
2.0f / draw_buffer->width, 2.0f / draw_buffer->height, 1.0f); 2.0f / framebuffer->width, 2.0f / framebuffer->height, 1.0f);
#endif #endif
return _cogl_offscreen_handle_new (offscreen); return _cogl_offscreen_handle_new (offscreen);
@ -355,7 +355,7 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* Chain up to parent */ /* Chain up to parent */
_cogl_draw_buffer_free (COGL_DRAW_BUFFER (offscreen)); _cogl_framebuffer_free (COGL_FRAMEBUFFER (offscreen));
if (offscreen->gl_stencil_handle) if (offscreen->gl_stencil_handle)
GE (glDeleteRenderbuffers (1, &offscreen->gl_stencil_handle)); GE (glDeleteRenderbuffers (1, &offscreen->gl_stencil_handle));
@ -369,12 +369,12 @@ _cogl_onscreen_new (void)
CoglOnscreen *onscreen; CoglOnscreen *onscreen;
/* XXX: Until we have full winsys support in Cogl then we can't fully /* XXX: Until we have full winsys support in Cogl then we can't fully
* implement CoglOnscreen draw buffers, since we can't, e.g. keep track of * implement CoglOnscreen framebuffers, since we can't, e.g. keep track of
* the window size. */ * the window size. */
onscreen = g_new0 (CoglOnscreen, 1); onscreen = g_new0 (CoglOnscreen, 1);
_cogl_draw_buffer_init (COGL_DRAW_BUFFER (onscreen), _cogl_framebuffer_init (COGL_FRAMEBUFFER (onscreen),
COGL_DRAW_BUFFER_TYPE_ONSCREEN, COGL_FRAMEBUFFER_TYPE_ONSCREEN,
0xdeadbeef, /* width */ 0xdeadbeef, /* width */
0xdeadbeef); /* height */ 0xdeadbeef); /* height */
@ -387,7 +387,7 @@ _cogl_onscreen_free (CoglOnscreen *onscreen)
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* Chain up to parent */ /* Chain up to parent */
_cogl_draw_buffer_free (COGL_DRAW_BUFFER (onscreen)); _cogl_framebuffer_free (COGL_FRAMEBUFFER (onscreen));
g_free (onscreen); g_free (onscreen);
} }
@ -395,17 +395,17 @@ _cogl_onscreen_free (CoglOnscreen *onscreen)
void void
_cogl_onscreen_clutter_backend_set_size (int width, int height) _cogl_onscreen_clutter_backend_set_size (int width, int height)
{ {
CoglDrawBuffer *draw_buffer; CoglFramebuffer *framebuffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
draw_buffer = COGL_DRAW_BUFFER (ctx->window_buffer); framebuffer = COGL_FRAMEBUFFER (ctx->window_buffer);
if (draw_buffer->width == width && draw_buffer->height == height) if (framebuffer->width == width && framebuffer->height == height)
return; return;
draw_buffer->width = width; framebuffer->width = width;
draw_buffer->height = height; framebuffer->height = height;
/* We'll need to recalculate the GL viewport state derived /* We'll need to recalculate the GL viewport state derived
* from the Cogl viewport */ * from the Cogl viewport */
@ -413,153 +413,168 @@ _cogl_onscreen_clutter_backend_set_size (int width, int height)
} }
GSList * GSList *
_cogl_create_draw_buffer_stack (void) _cogl_create_framebuffer_stack (void)
{ {
GSList *stack = NULL; GSList *stack = NULL;
CoglDrawBufferStackEntry *entry;
entry = g_slice_new0 (CoglDrawBufferStackEntry); return g_slist_prepend (stack, COGL_INVALID_HANDLE);
entry->target = COGL_WINDOW_BUFFER;
entry->draw_buffer = COGL_INVALID_HANDLE;
return g_slist_prepend (stack, entry);
} }
void void
_cogl_free_draw_buffer_stack (GSList *stack) _cogl_free_framebuffer_stack (GSList *stack)
{ {
GSList *l; GSList *l;
for (l = stack; l != NULL; l = l->next) for (l = stack; l != NULL; l = l->next)
{ {
CoglDrawBufferStackEntry *entry = l->data; CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (l->data);
CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (entry->draw_buffer); if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
if (draw_buffer->type == COGL_DRAW_BUFFER_TYPE_OFFSCREEN) _cogl_offscreen_free (COGL_OFFSCREEN (framebuffer));
_cogl_offscreen_free (COGL_OFFSCREEN (draw_buffer));
else else
_cogl_onscreen_free (COGL_ONSCREEN (draw_buffer)); _cogl_onscreen_free (COGL_ONSCREEN (framebuffer));
} }
g_slist_free (stack); g_slist_free (stack);
} }
/* XXX: The target argument is redundant; when we break API, we should /* Set the current framebuffer without checking if it's already the
* remove it! */ * current framebuffer. This is used by cogl_pop_framebuffer while
* the top of the stack is currently not up to date. */
static void
_cogl_set_framebuffer_real (CoglFramebuffer *framebuffer)
{
CoglHandle *entry;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_flush ();
entry = &ctx->framebuffer_stack->data;
ctx->dirty_bound_framebuffer = 1;
ctx->dirty_gl_viewport = 1;
if (framebuffer != COGL_INVALID_HANDLE)
cogl_handle_ref (framebuffer);
if (*entry != COGL_INVALID_HANDLE)
cogl_handle_unref (*entry);
*entry = framebuffer;
/* We've effectively just switched the current modelview and
* projection matrix stacks and clip state so we need to dirty
* them to ensure they get flushed for the next batch of geometry
* we flush */
_cogl_matrix_stack_dirty (framebuffer->modelview_stack);
_cogl_matrix_stack_dirty (framebuffer->projection_stack);
_cogl_clip_stack_state_dirty (&framebuffer->clip_state);
}
void
cogl_set_framebuffer (CoglHandle handle)
{
g_return_if_fail (cogl_is_framebuffer (handle));
if (_cogl_get_framebuffer () != handle)
_cogl_set_framebuffer_real (COGL_FRAMEBUFFER (handle));
}
/* XXX: deprecated API */
void void
cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle handle) cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle handle)
{ {
CoglDrawBuffer *draw_buffer = NULL;
CoglDrawBufferStackEntry *entry;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_journal_flush ();
g_assert (ctx->draw_buffer_stack != NULL);
entry = ctx->draw_buffer_stack->data;
if (target == COGL_WINDOW_BUFFER) if (target == COGL_WINDOW_BUFFER)
handle = ctx->window_buffer; handle = ctx->window_buffer;
else if (!cogl_is_draw_buffer (handle))
return;
draw_buffer = COGL_DRAW_BUFFER (handle); cogl_set_framebuffer (handle);
if (entry->draw_buffer != draw_buffer)
{
entry->target = target;
ctx->dirty_bound_framebuffer = 1;
ctx->dirty_gl_viewport = 1;
if (draw_buffer != COGL_INVALID_HANDLE)
cogl_handle_ref (draw_buffer);
if (entry->draw_buffer != COGL_INVALID_HANDLE)
cogl_handle_unref (entry->draw_buffer);
entry->draw_buffer = draw_buffer;
/* We've effectively just switched the current modelview and
* projection matrix stacks and clip state so we need to dirty
* them to ensure they get flushed for the next batch of geometry
* we flush */
_cogl_matrix_stack_dirty (draw_buffer->modelview_stack);
_cogl_matrix_stack_dirty (draw_buffer->projection_stack);
_cogl_clip_stack_state_dirty (&draw_buffer->clip_state);
}
} }
CoglHandle CoglHandle
_cogl_get_draw_buffer (void) _cogl_get_framebuffer (void)
{ {
CoglDrawBufferStackEntry *entry;
_COGL_GET_CONTEXT (ctx, NULL); _COGL_GET_CONTEXT (ctx, NULL);
g_assert (ctx->draw_buffer_stack); g_assert (ctx->framebuffer_stack);
entry = ctx->draw_buffer_stack->data;
return entry->draw_buffer; return (CoglHandle)ctx->framebuffer_stack->data;
} }
void
cogl_push_framebuffer (CoglHandle buffer)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_framebuffer (buffer));
g_assert (ctx->framebuffer_stack);
cogl_flush ();
ctx->framebuffer_stack =
g_slist_prepend (ctx->framebuffer_stack, COGL_INVALID_HANDLE);
cogl_set_framebuffer (buffer);
}
/* XXX: deprecated API */
void void
cogl_push_draw_buffer (void) cogl_push_draw_buffer (void)
{ {
CoglDrawBufferStackEntry *old; cogl_push_framebuffer (_cogl_get_framebuffer ());
CoglDrawBufferStackEntry *entry; }
void
cogl_pop_framebuffer (void)
{
CoglHandle to_pop;
CoglHandle to_restore;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
entry = g_slice_new0 (CoglDrawBufferStackEntry); g_assert (ctx->framebuffer_stack != NULL);
g_assert (ctx->framebuffer_stack->next != NULL);
g_assert (ctx->draw_buffer_stack); to_pop = ctx->framebuffer_stack->data;
to_restore = ctx->framebuffer_stack->next->data;
old = ctx->draw_buffer_stack->data; cogl_flush ();
*entry = *old;
cogl_handle_ref (entry->draw_buffer); cogl_handle_unref (to_pop);
ctx->framebuffer_stack =
g_slist_remove_link (ctx->framebuffer_stack,
ctx->framebuffer_stack);
ctx->draw_buffer_stack = /* If the framebuffer has changed as a result of popping the top
g_slist_prepend (ctx->draw_buffer_stack, entry); * then re-assert the current buffer so as to dirty state as
* necessary. */
if (to_pop != to_restore)
_cogl_set_framebuffer_real (to_restore);
} }
/* XXX: deprecated API */
void void
cogl_pop_draw_buffer (void) cogl_pop_draw_buffer (void)
{ {
CoglDrawBufferStackEntry *to_pop; cogl_pop_framebuffer ();
CoglDrawBufferStackEntry *to_restore;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_assert (ctx->draw_buffer_stack != NULL);
to_pop = ctx->draw_buffer_stack->data;
to_restore = ctx->draw_buffer_stack->next->data;
cogl_set_draw_buffer (to_restore->target, to_restore->draw_buffer);
cogl_handle_unref (to_pop->draw_buffer);
ctx->draw_buffer_stack =
g_slist_remove_link (ctx->draw_buffer_stack,
ctx->draw_buffer_stack);
g_slice_free (CoglDrawBufferStackEntry, to_pop);
} }
void void
_cogl_draw_buffer_flush_state (CoglHandle handle, _cogl_framebuffer_flush_state (CoglHandle handle,
CoglDrawBufferFlushFlags flags) CoglFramebufferFlushFlags flags)
{ {
CoglDrawBuffer *draw_buffer; CoglFramebuffer *framebuffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
draw_buffer = COGL_DRAW_BUFFER (handle); framebuffer = COGL_FRAMEBUFFER (handle);
if (cogl_features_available (COGL_FEATURE_OFFSCREEN) && if (cogl_features_available (COGL_FEATURE_OFFSCREEN) &&
ctx->dirty_bound_framebuffer) ctx->dirty_bound_framebuffer)
{ {
if (draw_buffer->type == COGL_DRAW_BUFFER_TYPE_OFFSCREEN) if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
{ {
GE (glBindFramebuffer (GL_FRAMEBUFFER, GE (glBindFramebuffer (GL_FRAMEBUFFER,
COGL_OFFSCREEN (draw_buffer)->fbo_handle)); COGL_OFFSCREEN (framebuffer)->fbo_handle));
} }
else else
GE (glBindFramebuffer (GL_FRAMEBUFFER, 0)); GE (glBindFramebuffer (GL_FRAMEBUFFER, 0));
@ -573,31 +588,31 @@ _cogl_draw_buffer_flush_state (CoglHandle handle,
/* Convert the Cogl viewport y offset to an OpenGL viewport y offset /* Convert the Cogl viewport y offset to an OpenGL viewport y offset
* NB: OpenGL defines its window and viewport origins to be bottom * NB: OpenGL defines its window and viewport origins to be bottom
* left, while Cogl defines them to be top left. * left, while Cogl defines them to be top left.
* NB: We render upside down to offscreen draw buffers so we don't * NB: We render upside down to offscreen framebuffers so we don't
* need to convert the y offset in this case. */ * need to convert the y offset in this case. */
if (cogl_is_offscreen (draw_buffer)) if (cogl_is_offscreen (framebuffer))
gl_viewport_y = draw_buffer->viewport_y; gl_viewport_y = framebuffer->viewport_y;
else else
gl_viewport_y = draw_buffer->height - gl_viewport_y = framebuffer->height -
(draw_buffer->viewport_y + draw_buffer->viewport_height); (framebuffer->viewport_y + framebuffer->viewport_height);
GE (glViewport (draw_buffer->viewport_x, GE (glViewport (framebuffer->viewport_x,
gl_viewport_y, gl_viewport_y,
draw_buffer->viewport_width, framebuffer->viewport_width,
draw_buffer->viewport_height)); framebuffer->viewport_height));
ctx->dirty_gl_viewport = FALSE; ctx->dirty_gl_viewport = FALSE;
} }
/* XXX: Flushing clip state may trash the modelview and projection /* XXX: Flushing clip state may trash the modelview and projection
* matrices so we must do it before flushing the matrices... * matrices so we must do it before flushing the matrices...
*/ */
_cogl_flush_clip_state (&draw_buffer->clip_state); _cogl_flush_clip_state (&framebuffer->clip_state);
if (!(flags & COGL_DRAW_BUFFER_FLUSH_SKIP_MODELVIEW)) if (!(flags & COGL_FRAMEBUFFER_FLUSH_SKIP_MODELVIEW))
_cogl_matrix_stack_flush_to_gl (draw_buffer->modelview_stack, _cogl_matrix_stack_flush_to_gl (framebuffer->modelview_stack,
COGL_MATRIX_MODELVIEW); COGL_MATRIX_MODELVIEW);
_cogl_matrix_stack_flush_to_gl (draw_buffer->projection_stack, _cogl_matrix_stack_flush_to_gl (framebuffer->projection_stack,
COGL_MATRIX_PROJECTION); COGL_MATRIX_PROJECTION);
} }

View File

@ -32,7 +32,7 @@
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-material-private.h" #include "cogl-material-private.h"
#include "cogl-vertex-buffer-private.h" #include "cogl-vertex-buffer-private.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
#include <string.h> #include <string.h>
#include <gmodule.h> #include <gmodule.h>
@ -533,7 +533,7 @@ _cogl_journal_flush (void)
GLuint journal_vbo; GLuint journal_vbo;
gboolean vbo_fallback = gboolean vbo_fallback =
(cogl_get_features () & COGL_FEATURE_VBOS) ? FALSE : TRUE; (cogl_get_features () & COGL_FEATURE_VBOS) ? FALSE : TRUE;
CoglHandle draw_buffer; CoglHandle framebuffer;
CoglMatrixStack *modelview_stack; CoglMatrixStack *modelview_stack;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -551,8 +551,8 @@ _cogl_journal_flush (void)
else else
state.vbo_offset = (char *)ctx->logged_vertices->data; state.vbo_offset = (char *)ctx->logged_vertices->data;
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
modelview_stack = _cogl_draw_buffer_get_modelview_stack (draw_buffer); modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer);
state.modelview_stack = modelview_stack; state.modelview_stack = modelview_stack;
_cogl_matrix_stack_push (modelview_stack); _cogl_matrix_stack_push (modelview_stack);
@ -618,8 +618,8 @@ _cogl_journal_init (void)
* that themselves depend on the journal, such as clip state. */ * that themselves depend on the journal, such as clip state. */
/* NB: the journal deals with flushing the modelview stack manually */ /* NB: the journal deals with flushing the modelview stack manually */
_cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), _cogl_framebuffer_flush_state (_cogl_get_framebuffer (),
COGL_DRAW_BUFFER_FLUSH_SKIP_MODELVIEW); COGL_FRAMEBUFFER_FLUSH_SKIP_MODELVIEW);
} }
void void

View File

@ -33,7 +33,7 @@
#include "cogl-context.h" #include "cogl-context.h"
#include "cogl-internal.h" #include "cogl-internal.h"
#include "cogl-matrix-stack.h" #include "cogl-matrix-stack.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
typedef struct { typedef struct {
CoglMatrix matrix; CoglMatrix matrix;
@ -426,11 +426,11 @@ _cogl_matrix_stack_flush_to_gl (CoglMatrixStack *stack,
} }
/* Because Cogl defines texture coordinates to have a top left origin and /* Because Cogl defines texture coordinates to have a top left origin and
* because offscreen draw buffers may be used for rendering to textures we * because offscreen framebuffers may be used for rendering to textures we
* always render upside down to offscreen buffers. * always render upside down to offscreen buffers.
*/ */
if (mode == COGL_MATRIX_PROJECTION && if (mode == COGL_MATRIX_PROJECTION &&
cogl_is_offscreen (_cogl_get_draw_buffer ())) cogl_is_offscreen (_cogl_get_framebuffer ()))
{ {
CoglMatrix flipped_projection; CoglMatrix flipped_projection;
CoglMatrix *projection = CoglMatrix *projection =

View File

@ -32,7 +32,7 @@
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-material-private.h" #include "cogl-material-private.h"
#include "cogl-vertex-buffer-private.h" #include "cogl-vertex-buffer-private.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -862,10 +862,10 @@ cogl_polygon (CoglTextureVertex *vertices,
_cogl_journal_flush (); _cogl_journal_flush ();
/* NB: _cogl_draw_buffer_flush_state may disrupt various state (such /* NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the material state) when flushing the clip stack, so should * as the material state) when flushing the clip stack, so should
* always be done first when preparing to draw. */ * always be done first when preparing to draw. */
_cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0);
material = ctx->source_material; material = ctx->source_material;
layers = cogl_material_get_layers (ctx->source_material); layers = cogl_material_get_layers (ctx->source_material);
@ -1062,10 +1062,10 @@ _cogl_path_stroke_nodes (void)
_cogl_journal_flush (); _cogl_journal_flush ();
/* NB: _cogl_draw_buffer_flush_state may disrupt various state (such /* NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the material state) when flushing the clip stack, so should * as the material state) when flushing the clip stack, so should
* always be done first when preparing to draw. */ * always be done first when preparing to draw. */
_cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0);
enable_flags |= _cogl_material_get_cogl_enable_flags (ctx->source_material); enable_flags |= _cogl_material_get_cogl_enable_flags (ctx->source_material);
cogl_enable (enable_flags); cogl_enable (enable_flags);
@ -1121,11 +1121,11 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
unsigned long enable_flags = COGL_ENABLE_VERTEX_ARRAY; unsigned long enable_flags = COGL_ENABLE_VERTEX_ARRAY;
CoglHandle prev_source; CoglHandle prev_source;
int i; int i;
CoglHandle draw_buffer = _cogl_get_draw_buffer (); CoglHandle framebuffer = _cogl_get_framebuffer ();
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (draw_buffer); _cogl_framebuffer_get_modelview_stack (framebuffer);
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_draw_buffer_get_projection_stack (draw_buffer); _cogl_framebuffer_get_projection_stack (framebuffer);
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -1134,10 +1134,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min,
* so we need to flush any batched geometry first */ * so we need to flush any batched geometry first */
_cogl_journal_flush (); _cogl_journal_flush ();
/* NB: _cogl_draw_buffer_flush_state may disrupt various state (such /* NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the material state) when flushing the clip stack, so should * as the material state) when flushing the clip stack, so should
* always be done first when preparing to draw. */ * always be done first when preparing to draw. */
_cogl_draw_buffer_flush_state (draw_buffer, 0); _cogl_framebuffer_flush_state (framebuffer, 0);
/* Just setup a simple material that doesn't use texturing... */ /* Just setup a simple material that doesn't use texturing... */
prev_source = cogl_handle_ref (ctx->source_material); prev_source = cogl_handle_ref (ctx->source_material);
@ -1311,10 +1311,10 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path,
*/ */
_cogl_journal_flush (); _cogl_journal_flush ();
/* NB: _cogl_draw_buffer_flush_state may disrupt various state (such /* NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the material state) when flushing the clip stack, so should * as the material state) when flushing the clip stack, so should
* always be done first when preparing to draw. */ * always be done first when preparing to draw. */
_cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0);
_cogl_material_flush_gl_state (ctx->source_material, NULL); _cogl_material_flush_gl_state (ctx->source_material, NULL);
@ -1477,13 +1477,13 @@ _cogl_path_fill_nodes (void)
if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_FORCE_SCANLINE_PATHS)) && if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_FORCE_SCANLINE_PATHS)) &&
cogl_features_available (COGL_FEATURE_STENCIL_BUFFER)) cogl_features_available (COGL_FEATURE_STENCIL_BUFFER))
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
CoglClipStackState *clip_state; CoglClipStackState *clip_state;
_cogl_journal_flush (); _cogl_journal_flush ();
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
_cogl_add_path_to_stencil_buffer (ctx->path_nodes_min, _cogl_add_path_to_stencil_buffer (ctx->path_nodes_min,
ctx->path_nodes_max, ctx->path_nodes_max,

View File

@ -42,7 +42,7 @@
#include "cogl-context.h" #include "cogl-context.h"
#include "cogl-handle.h" #include "cogl-handle.h"
#include "cogl-primitives.h" #include "cogl-primitives.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -601,7 +601,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
GLuint target_gl_type) GLuint target_gl_type)
{ {
gint bpp; gint bpp;
CoglHandle draw_buffer; CoglHandle framebuffer;
int viewport[4]; int viewport[4];
CoglBitmap alpha_bmp; CoglBitmap alpha_bmp;
CoglHandle prev_source; CoglHandle prev_source;
@ -612,9 +612,9 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
bpp = _cogl_get_format_bpp (COGL_PIXEL_FORMAT_RGBA_8888); bpp = _cogl_get_format_bpp (COGL_PIXEL_FORMAT_RGBA_8888);
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
/* Viewport needs to have some size and be inside the window for this */ /* Viewport needs to have some size and be inside the window for this */
_cogl_draw_buffer_get_viewport4fv (draw_buffer, viewport); _cogl_framebuffer_get_viewport4fv (framebuffer, viewport);
if (viewport[0] < 0 || viewport[1] < 0 || if (viewport[0] < 0 || viewport[1] < 0 ||
viewport[2] <= 0 || viewport[3] <= 0) viewport[2] <= 0 || viewport[3] <= 0)
return FALSE; return FALSE;
@ -624,7 +624,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
* works) * works)
*/ */
projection_stack = _cogl_draw_buffer_get_projection_stack (draw_buffer); projection_stack = _cogl_framebuffer_get_projection_stack (framebuffer);
_cogl_matrix_stack_push (projection_stack); _cogl_matrix_stack_push (projection_stack);
_cogl_matrix_stack_load_identity (projection_stack); _cogl_matrix_stack_load_identity (projection_stack);
_cogl_matrix_stack_ortho (projection_stack, _cogl_matrix_stack_ortho (projection_stack,
@ -633,7 +633,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex,
(float)(0), (float)(0),
(float)(100)); (float)(100));
modelview_stack = _cogl_draw_buffer_get_modelview_stack (draw_buffer); modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer);
_cogl_matrix_stack_push (modelview_stack); _cogl_matrix_stack_push (modelview_stack);
_cogl_matrix_stack_load_identity (modelview_stack); _cogl_matrix_stack_load_identity (modelview_stack);

View File

@ -138,7 +138,7 @@
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-material-private.h" #include "cogl-material-private.h"
#include "cogl-primitives.h" #include "cogl-primitives.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
#define PAD_FOR_ALIGNMENT(VAR, TYPE_SIZE) \ #define PAD_FOR_ALIGNMENT(VAR, TYPE_SIZE) \
(VAR = TYPE_SIZE + ((VAR - 1) & ~(TYPE_SIZE - 1))) (VAR = TYPE_SIZE + ((VAR - 1) & ~(TYPE_SIZE - 1)))
@ -1666,10 +1666,10 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
} }
ctx->n_texcoord_arrays_enabled = max_texcoord_attrib_unit + 1; ctx->n_texcoord_arrays_enabled = max_texcoord_attrib_unit + 1;
/* NB: _cogl_draw_buffer_flush_state may disrupt various state (such /* NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the material state) when flushing the clip stack, so should * as the material state) when flushing the clip stack, so should
* always be done first when preparing to draw. */ * always be done first when preparing to draw. */
_cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0);
options.flags = options.flags =
COGL_MATERIAL_FLUSH_FALLBACK_MASK | COGL_MATERIAL_FLUSH_FALLBACK_MASK |

View File

@ -38,7 +38,7 @@
#include "cogl-context.h" #include "cogl-context.h"
#include "cogl-material-private.h" #include "cogl-material-private.h"
#include "cogl-winsys.h" #include "cogl-winsys.h"
#include "cogl-draw-buffer-private.h" #include "cogl-framebuffer-private.h"
#include "cogl-matrix-private.h" #include "cogl-matrix-private.h"
#if defined (HAVE_COGL_GLES2) || defined (HAVE_COGL_GLES) #if defined (HAVE_COGL_GLES2) || defined (HAVE_COGL_GLES)
@ -120,10 +120,10 @@ cogl_clear (const CoglColor *color, gulong buffers)
_cogl_journal_flush (); _cogl_journal_flush ();
/* NB: _cogl_draw_buffer_flush_state may disrupt various state (such /* NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the material state) when flushing the clip stack, so should * as the material state) when flushing the clip stack, so should
* always be done first when preparing to draw. */ * always be done first when preparing to draw. */
_cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0);
if (buffers & COGL_BUFFER_BIT_COLOR) if (buffers & COGL_BUFFER_BIT_COLOR)
{ {
@ -304,7 +304,7 @@ _cogl_flush_face_winding (void)
* all offscreen rendering is done upside down resulting in reversed winding * all offscreen rendering is done upside down resulting in reversed winding
* for all triangles. * for all triangles.
*/ */
if (cogl_is_offscreen (_cogl_get_draw_buffer ())) if (cogl_is_offscreen (_cogl_get_framebuffer ()))
winding = COGL_FRONT_WINDING_CLOCKWISE; winding = COGL_FRONT_WINDING_CLOCKWISE;
else else
winding = COGL_FRONT_WINDING_COUNTER_CLOCKWISE; winding = COGL_FRONT_WINDING_COUNTER_CLOCKWISE;
@ -343,13 +343,13 @@ cogl_set_viewport (int x,
int width, int width,
int height) int height)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
_cogl_draw_buffer_set_viewport (draw_buffer, _cogl_framebuffer_set_viewport (framebuffer,
x, x,
y, y,
width, width,
@ -430,7 +430,7 @@ _cogl_setup_viewport (guint width,
z_camera = 0.5 * projection_matrix.xx; z_camera = 0.5 * projection_matrix.xx;
modelview_stack = modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_load_identity (modelview_stack); _cogl_matrix_stack_load_identity (modelview_stack);
_cogl_matrix_stack_translate (modelview_stack, -0.5f, -0.5f, -z_camera); _cogl_matrix_stack_translate (modelview_stack, -0.5f, -0.5f, -z_camera);
_cogl_matrix_stack_scale (modelview_stack, _cogl_matrix_stack_scale (modelview_stack,
@ -463,19 +463,19 @@ cogl_features_available (CoglFeatureFlags features)
/* XXX: This function should either be replaced with one returning /* XXX: This function should either be replaced with one returning
* integers, or removed/deprecated and make the * integers, or removed/deprecated and make the
* _cogl_draw_buffer_get_viewport* functions public. * _cogl_framebuffer_get_viewport* functions public.
*/ */
void void
cogl_get_viewport (float v[4]) cogl_get_viewport (float v[4])
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
int viewport[4]; int viewport[4];
int i; int i;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
_cogl_draw_buffer_get_viewport4fv (draw_buffer, viewport); _cogl_framebuffer_get_viewport4fv (framebuffer, viewport);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
v[i] = viewport[i]; v[i] = viewport[i];
@ -585,8 +585,8 @@ cogl_read_pixels (int x,
CoglPixelFormat format, CoglPixelFormat format,
guint8 *pixels) guint8 *pixels)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
int draw_buffer_height; int framebuffer_height;
int rowstride = width * 4; int rowstride = width * 4;
guint8 *temprow; guint8 *temprow;
@ -595,13 +595,17 @@ cogl_read_pixels (int x,
g_return_if_fail (format == COGL_PIXEL_FORMAT_RGBA_8888); g_return_if_fail (format == COGL_PIXEL_FORMAT_RGBA_8888);
g_return_if_fail (source == COGL_READ_PIXELS_COLOR_BUFFER); g_return_if_fail (source == COGL_READ_PIXELS_COLOR_BUFFER);
/* make sure any batched primitives get emitted to the GL driver before
* issuing our read pixels... */
cogl_flush ();
temprow = g_alloca (rowstride * sizeof (guint8)); temprow = g_alloca (rowstride * sizeof (guint8));
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
_cogl_draw_buffer_flush_state (draw_buffer, 0); _cogl_framebuffer_flush_state (framebuffer, 0);
draw_buffer_height = _cogl_draw_buffer_get_height (draw_buffer); framebuffer_height = _cogl_framebuffer_get_height (framebuffer);
/* The y co-ordinate should be given in OpenGL's coordinate system /* The y co-ordinate should be given in OpenGL's coordinate system
* so 0 is the bottom row * so 0 is the bottom row
@ -609,12 +613,8 @@ cogl_read_pixels (int x,
* NB: all offscreen rendering is done upside down so no conversion * NB: all offscreen rendering is done upside down so no conversion
* is necissary in this case. * is necissary in this case.
*/ */
if (!cogl_is_offscreen (draw_buffer)) if (!cogl_is_offscreen (framebuffer))
y = draw_buffer_height - y - height; y = framebuffer_height - y - height;
/* make sure any batched primitives get emitted to the GL driver before
* issuing our read pixels... */
cogl_flush ();
/* Setup the pixel store parameters that may have been changed by /* Setup the pixel store parameters that may have been changed by
Cogl */ Cogl */
@ -629,7 +629,7 @@ cogl_read_pixels (int x,
/* NB: All offscreen rendering is done upside down so there is no need /* NB: All offscreen rendering is done upside down so there is no need
* to flip in this case... */ * to flip in this case... */
if (cogl_is_offscreen (draw_buffer)) if (cogl_is_offscreen (framebuffer))
return; return;
/* TODO: consider using the GL_MESA_pack_invert extension in the future /* TODO: consider using the GL_MESA_pack_invert extension in the future
@ -676,10 +676,10 @@ cogl_begin_gl (void)
/* Flush framebuffer state, including clip state, modelview and /* Flush framebuffer state, including clip state, modelview and
* projection matrix state * projection matrix state
* *
* NB: _cogl_draw_buffer_flush_state may disrupt various state (such * NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the material state) when flushing the clip stack, so should * as the material state) when flushing the clip stack, so should
* always be done first when preparing to draw. */ * always be done first when preparing to draw. */
_cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0);
/* Setup the state for the current material */ /* Setup the state for the current material */
@ -791,7 +791,7 @@ void
cogl_push_matrix (void) cogl_push_matrix (void)
{ {
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_push (modelview_stack); _cogl_matrix_stack_push (modelview_stack);
} }
@ -799,7 +799,7 @@ void
cogl_pop_matrix (void) cogl_pop_matrix (void)
{ {
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_pop (modelview_stack); _cogl_matrix_stack_pop (modelview_stack);
} }
@ -807,7 +807,7 @@ void
cogl_scale (float x, float y, float z) cogl_scale (float x, float y, float z)
{ {
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_scale (modelview_stack, x, y, z); _cogl_matrix_stack_scale (modelview_stack, x, y, z);
} }
@ -815,7 +815,7 @@ void
cogl_translate (float x, float y, float z) cogl_translate (float x, float y, float z)
{ {
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_translate (modelview_stack, x, y, z); _cogl_matrix_stack_translate (modelview_stack, x, y, z);
} }
@ -823,7 +823,7 @@ void
cogl_rotate (float angle, float x, float y, float z) cogl_rotate (float angle, float x, float y, float z)
{ {
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_rotate (modelview_stack, angle, x, y, z); _cogl_matrix_stack_rotate (modelview_stack, angle, x, y, z);
} }
@ -852,7 +852,7 @@ cogl_frustum (float left,
float z_far) float z_far)
{ {
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_projection_stack (_cogl_get_framebuffer ());
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -877,7 +877,7 @@ cogl_ortho (float left,
{ {
CoglMatrix ortho; CoglMatrix ortho;
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_projection_stack (_cogl_get_framebuffer ());
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -890,7 +890,7 @@ void
cogl_get_modelview_matrix (CoglMatrix *matrix) cogl_get_modelview_matrix (CoglMatrix *matrix)
{ {
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_get (modelview_stack, matrix); _cogl_matrix_stack_get (modelview_stack, matrix);
_COGL_MATRIX_DEBUG_PRINT (matrix); _COGL_MATRIX_DEBUG_PRINT (matrix);
} }
@ -899,7 +899,7 @@ void
cogl_set_modelview_matrix (CoglMatrix *matrix) cogl_set_modelview_matrix (CoglMatrix *matrix)
{ {
CoglMatrixStack *modelview_stack = CoglMatrixStack *modelview_stack =
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_set (modelview_stack, matrix); _cogl_matrix_stack_set (modelview_stack, matrix);
_COGL_MATRIX_DEBUG_PRINT (matrix); _COGL_MATRIX_DEBUG_PRINT (matrix);
} }
@ -908,7 +908,7 @@ void
cogl_get_projection_matrix (CoglMatrix *matrix) cogl_get_projection_matrix (CoglMatrix *matrix)
{ {
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_projection_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_get (projection_stack, matrix); _cogl_matrix_stack_get (projection_stack, matrix);
_COGL_MATRIX_DEBUG_PRINT (matrix); _COGL_MATRIX_DEBUG_PRINT (matrix);
} }
@ -917,7 +917,7 @@ void
cogl_set_projection_matrix (CoglMatrix *matrix) cogl_set_projection_matrix (CoglMatrix *matrix)
{ {
CoglMatrixStack *projection_stack = CoglMatrixStack *projection_stack =
_cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ()); _cogl_framebuffer_get_projection_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_set (projection_stack, matrix); _cogl_matrix_stack_set (projection_stack, matrix);
/* FIXME: Update the inverse projection matrix!! Presumably use /* FIXME: Update the inverse projection matrix!! Presumably use
@ -928,10 +928,10 @@ cogl_set_projection_matrix (CoglMatrix *matrix)
CoglClipStackState * CoglClipStackState *
_cogl_get_clip_state (void) _cogl_get_clip_state (void)
{ {
CoglHandle draw_buffer; CoglHandle framebuffer;
draw_buffer = _cogl_get_draw_buffer (); framebuffer = _cogl_get_framebuffer ();
return _cogl_draw_buffer_get_clip_state (draw_buffer); return _cogl_framebuffer_get_clip_state (framebuffer);
} }
GQuark GQuark

View File

@ -736,8 +736,8 @@ void cogl_clip_ensure (void) G_GNUC_DEPRECATED;
* cogl_clip_stack_restore(). * cogl_clip_stack_restore().
* *
* Deprecated: 1.2: This was originally added to allow us to save the * Deprecated: 1.2: This was originally added to allow us to save the
* clip stack when switching to an offscreen draw buffer, but it's * clip stack when switching to an offscreen framebuffer, but it's
* not necessary anymore given that draw buffers now own separate * not necessary anymore given that framebuffers now own separate
* clip stacks which will be automatically switched between when a * clip stacks which will be automatically switched between when a
* new buffer is set. Calling this function has no effect * new buffer is set. Calling this function has no effect
* *
@ -752,8 +752,8 @@ void cogl_clip_stack_save (void) G_GNUC_DEPRECATED;
* by cogl_clip_stack_save(). * by cogl_clip_stack_save().
* *
* Deprecated: 1.2: This was originally added to allow us to restore * Deprecated: 1.2: This was originally added to allow us to restore
* the clip stack when switching back from an offscreen draw buffer, * the clip stack when switching back from an offscreen framebuffer,
* but it's not necessary anymore given that draw buffers now own * but it's not necessary anymore given that framebuffers now own
* separate clip stacks which will be automatically switched between * separate clip stacks which will be automatically switched between
* when a new buffer is set. Calling this function has no effect * when a new buffer is set. Calling this function has no effect
* *
@ -763,34 +763,85 @@ void cogl_clip_stack_restore (void) G_GNUC_DEPRECATED;
#endif /* COGL_DISABLE_DEPRECATED */ #endif /* COGL_DISABLE_DEPRECATED */
/**
* cogl_set_framebuffer:
* @buffer: The #CoglHandle of a Cogl framebuffer; either onscreen or
* offscreen.
*
* This redirects all subsequent drawing to the specified framebuffer. This
* can either be an offscreen buffer created with
* cogl_offscreen_new_to_texture () or you can revert to your original
* onscreen window buffer.
*
* Since: 1.2
*/
void cogl_set_framebuffer (CoglHandle buffer);
/**
* cogl_push_framebuffer:
* @buffer: The #CoglHandle of a Cogl framebuffer; either onscreen or
* offscreen.
*
* Redirects all subsequent drawing to the specified framebuffer. This
* can either be an offscreen buffer created with
* cogl_offscreen_new_to_texture () or you can revert to your original
* onscreen window buffer.
*
* The previous framebuffer can be restored by calling cogl_pop_framebuffer()
*
* Since: 1.2
*/
void cogl_push_framebuffer (CoglHandle buffer);
/**
* cogl_pop_framebuffer:
*
* Restores the framebuffer that was previously at the top of the stack.
* All subsequent drawing will be redirected to this framebuffer.
*
* Since: 1.2
*/
void cogl_pop_framebuffer (void);
#ifndef COGL_DISABLE_DEPRECATED
/** /**
* cogl_set_draw_buffer: * cogl_set_draw_buffer:
* @target: A #CoglBufferTarget that specifies what kind of draw buffer you * @target: A #CoglBufferTarget that specifies what kind of framebuffer you
* are setting as the render target. * are setting as the render target.
* @offscreen: If you are setting a draw buffer of type COGL_OFFSCREEN_BUFFER * @offscreen: If you are setting a framebuffer of type COGL_OFFSCREEN_BUFFER
* then this is a CoglHandle for the offscreen buffer. * then this is a CoglHandle for the offscreen buffer.
* *
* This redirects all subsequent drawing to the specified draw buffer. This * Redirects all subsequent drawing to the specified framebuffer. This
* can either be an offscreen buffer created with * can either be an offscreen buffer created with
* cogl_offscreen_new_to_texture () or you can revert to your original * cogl_offscreen_new_to_texture () or you can revert to your original
* on screen window buffer. * on screen window buffer.
*
* Deprecated: 1.2: The target argument was redundant since we could look at
* the type of CoglHandle given instead.
*/ */
void cogl_set_draw_buffer (CoglBufferTarget target, void cogl_set_draw_buffer (CoglBufferTarget target,
CoglHandle offscreen); CoglHandle offscreen) G_GNUC_DEPRECATED;
/** /**
* cogl_push_draw_buffer: * cogl_push_draw_buffer:
* *
* Save cogl_set_draw_buffer() state. * Save cogl_set_draw_buffer() state.
*
* Deprecated: 1.2: The draw buffer API was replaced with a framebuffer API
*/ */
void cogl_push_draw_buffer (void); void cogl_push_draw_buffer (void) G_GNUC_DEPRECATED;
/** /**
* cogl_pop_draw_buffer: * cogl_pop_draw_buffer:
* *
* Restore cogl_set_draw_buffer() state. * Restore cogl_set_draw_buffer() state.
*
* Deprecated: 1.2: The draw buffer API was replaced with a framebuffer API
*/ */
void cogl_pop_draw_buffer (void); void cogl_pop_draw_buffer (void) G_GNUC_DEPRECATED;
#endif /* COGL_DISABLE_DEPRECATED */
/** /**
* CoglReadPixelsFlags: * CoglReadPixelsFlags:
@ -816,7 +867,7 @@ typedef enum { /*< prefix=COGL_READ_PIXELS >*/
* (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently) * (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently)
* @pixels: The location to write the pixel data. * @pixels: The location to write the pixel data.
* *
* This reads a rectangle of pixels from the current draw buffer where * This reads a rectangle of pixels from the current framebuffer where
* position (0, 0) is the top left. The pixel at (x, y) is the first * position (0, 0) is the top left. The pixel at (x, y) is the first
* read, and the data is returned with a rowstride of (width * 4) * read, and the data is returned with a rowstride of (width * 4)
*/ */

View File

@ -245,6 +245,9 @@ cogl_offscreen_new_to_texture
cogl_offscreen_ref cogl_offscreen_ref
cogl_offscreen_unref cogl_offscreen_unref
cogl_is_offscreen cogl_is_offscreen
cogl_set_framebuffer
cogl_push_frameffer
cogl_pop_framebuffer
cogl_set_draw_buffer cogl_set_draw_buffer
cogl_pop_draw_buffer cogl_pop_draw_buffer
cogl_push_draw_buffer cogl_push_draw_buffer