From c4eb869bd737b2b27c95f1bf9123e34343e80741 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 15 Jun 2011 00:06:29 +0100 Subject: [PATCH] framebuffer: expose viewport getters/setters This exposes experimental cogl_framebuffer APIs for getting and setting a viewport without having to refer to the implicit CoglContext. It adds the following experimental API: cogl_framebuffer_set_viewport cogl_framebuffer_get_viewport4fv cogl_framebuffer_get_viewport_x cogl_framebuffer_get_viewport_y cogl_framebuffer_get_viewport_width cogl_framebuffer_get_viewport_height Signed-off-by: Neil Roberts --- cogl/cogl-framebuffer-private.h | 22 ---------------------- cogl/cogl-framebuffer.c | 22 +++++++++++----------- cogl/cogl-framebuffer.h | 29 +++++++++++++++++++++++++++++ cogl/cogl-journal.c | 3 +-- cogl/cogl-texture.c | 2 +- cogl/cogl.c | 12 ++++++------ 6 files changed, 48 insertions(+), 42 deletions(-) diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h index 42d7babb7..509dc19b0 100644 --- a/cogl/cogl-framebuffer-private.h +++ b/cogl/cogl-framebuffer-private.h @@ -194,28 +194,6 @@ void _cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer, CoglClipStack *stack); -void -_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, - float x, - float y, - float width, - float height); -float -_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer); - -float -_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer); - -float -_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer); - -float -_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer); - -void -_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer, - float *viewport); - CoglMatrixStack * _cogl_framebuffer_get_modelview_stack (CoglFramebuffer *framebuffer); diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index 564a0c9a3..8257201d8 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -507,11 +507,11 @@ _cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer, } void -_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, - float x, - float y, - float width, - float height) +cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, + float x, + float y, + float width, + float height) { g_return_if_fail (width > 0 && height > 0); @@ -533,32 +533,32 @@ _cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, } float -_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer) +cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer) { return framebuffer->viewport_x; } float -_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer) +cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer) { return framebuffer->viewport_y; } float -_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer) +cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer) { return framebuffer->viewport_width; } float -_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer) +cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer) { return framebuffer->viewport_height; } void -_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer, - float *viewport) +cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer, + float *viewport) { viewport[0] = framebuffer->viewport_x; viewport[1] = framebuffer->viewport_y; diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h index ae2419aaa..8b56d9846 100644 --- a/cogl/cogl-framebuffer.h +++ b/cogl/cogl-framebuffer.h @@ -58,6 +58,35 @@ cogl_framebuffer_get_width (CoglFramebuffer *framebuffer); int cogl_framebuffer_get_height (CoglFramebuffer *framebuffer); +#define cogl_framebuffer_set_viewport cogl_framebuffer_set_viewport_EXP +void +cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, + float x, + float y, + float width, + float height); + +#define cogl_framebuffer_get_viewport_x cogl_framebuffer_get_viewport_x_EXP +float +cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer); + +#define cogl_framebuffer_get_viewport_y cogl_framebuffer_get_viewport_y_EXP +float +cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer); + +#define cogl_framebuffer_get_viewport_width cogl_framebuffer_get_viewport_width_EXP +float +cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer); + +#define cogl_framebuffer_get_viewport_height cogl_framebuffer_get_viewport_height_EXP +float +cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer); + +#define cogl_framebuffer_get_viewport4fv cogl_framebuffer_get_viewport4fv_EXP +void +cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer, + float *viewport); + #define cogl_framebuffer_swap_buffers cogl_framebuffer_swap_buffers_EXP void cogl_framebuffer_swap_buffers (CoglFramebuffer *framebuffer); diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c index cb378bb22..755584bc4 100644 --- a/cogl/cogl-journal.c +++ b/cogl/cogl-journal.c @@ -1647,8 +1647,7 @@ entry_to_screen_polygon (const CoglJournalEntry *entry, poly, /* points_out */ 4 /* n_points */); - _cogl_framebuffer_get_viewport4fv (cogl_get_draw_framebuffer (), - viewport); + cogl_framebuffer_get_viewport4fv (cogl_get_draw_framebuffer (), viewport); /* Scale from OpenGL normalized device coordinates (ranging from -1 to 1) * to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index d7b207051..f1ff63dd3 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -1066,7 +1066,7 @@ _cogl_texture_draw_and_read (CoglHandle handle, framebuffer = cogl_get_draw_framebuffer (); /* Viewport needs to have some size and be inside the window for this */ - _cogl_framebuffer_get_viewport4fv (framebuffer, viewport); + cogl_framebuffer_get_viewport4fv (framebuffer, viewport); if (viewport[0] < 0 || viewport[1] < 0 || viewport[2] <= 0 || viewport[3] <= 0) return FALSE; diff --git a/cogl/cogl.c b/cogl/cogl.c index 448622077..b83e3e1b0 100644 --- a/cogl/cogl.c +++ b/cogl/cogl.c @@ -349,11 +349,11 @@ cogl_set_viewport (int x, framebuffer = cogl_get_draw_framebuffer (); - _cogl_framebuffer_set_viewport (framebuffer, - x, - y, - width, - height); + cogl_framebuffer_set_viewport (framebuffer, + x, + y, + width, + height); } /* XXX: This should be deprecated, and we should expose a way to also @@ -393,7 +393,7 @@ cogl_get_viewport (float viewport[4]) _COGL_GET_CONTEXT (ctx, NO_RETVAL); framebuffer = cogl_get_draw_framebuffer (); - _cogl_framebuffer_get_viewport4fv (framebuffer, viewport); + cogl_framebuffer_get_viewport4fv (framebuffer, viewport); } void