mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
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 <neil@linux.intel.com>
This commit is contained in:
parent
716b88b0c8
commit
c4eb869bd7
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
12
cogl/cogl.c
12
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
|
||||
|
Loading…
Reference in New Issue
Block a user