mirror of
https://github.com/brl/mutter.git
synced 2025-02-17 05:44:08 +00:00
viewport: consistently use floats for viewports
OpenGL < 4.0 only supports integer based viewports and internally we have a mixture of code using floats and integers for viewports. This patch switches all viewports throughout clutter and cogl to be represented using floats considering that in the future we may want to take advantage of floating point viewports with modern hardware/drivers.
This commit is contained in:
parent
54f85832b7
commit
013b2433f0
@ -1968,7 +1968,7 @@ _clutter_actor_fully_transform_vertices (ClutterActor *self,
|
|||||||
ClutterActor *stage;
|
ClutterActor *stage;
|
||||||
CoglMatrix modelview;
|
CoglMatrix modelview;
|
||||||
CoglMatrix projection;
|
CoglMatrix projection;
|
||||||
int viewport[4];
|
float viewport[4];
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
|
||||||
|
|
||||||
@ -11786,7 +11786,7 @@ clutter_actor_get_paint_box (ClutterActor *self,
|
|||||||
const ClutterPaintVolume *pv;
|
const ClutterPaintVolume *pv;
|
||||||
CoglMatrix modelview;
|
CoglMatrix modelview;
|
||||||
CoglMatrix projection;
|
CoglMatrix projection;
|
||||||
int viewport[4];
|
float viewport[4];
|
||||||
ClutterPaintVolume projected_pv;
|
ClutterPaintVolume projected_pv;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
|
||||||
|
@ -113,7 +113,7 @@ void _clutter_paint_volume_transform (ClutterPaintVolu
|
|||||||
void _clutter_paint_volume_project (ClutterPaintVolume *pv,
|
void _clutter_paint_volume_project (ClutterPaintVolume *pv,
|
||||||
const CoglMatrix *modelview,
|
const CoglMatrix *modelview,
|
||||||
const CoglMatrix *projection,
|
const CoglMatrix *projection,
|
||||||
const int *viewport);
|
const float *viewport);
|
||||||
void _clutter_paint_volume_get_bounding_box (ClutterPaintVolume *pv,
|
void _clutter_paint_volume_get_bounding_box (ClutterPaintVolume *pv,
|
||||||
ClutterActorBox *box);
|
ClutterActorBox *box);
|
||||||
void _clutter_paint_volume_axis_align (ClutterPaintVolume *pv);
|
void _clutter_paint_volume_axis_align (ClutterPaintVolume *pv);
|
||||||
|
@ -651,7 +651,7 @@ void
|
|||||||
_clutter_paint_volume_project (ClutterPaintVolume *pv,
|
_clutter_paint_volume_project (ClutterPaintVolume *pv,
|
||||||
const CoglMatrix *modelview,
|
const CoglMatrix *modelview,
|
||||||
const CoglMatrix *projection,
|
const CoglMatrix *projection,
|
||||||
const int *viewport)
|
const float *viewport)
|
||||||
{
|
{
|
||||||
int transform_count;
|
int transform_count;
|
||||||
|
|
||||||
|
@ -221,11 +221,17 @@ GType _clutter_layout_manager_get_child_meta_type (ClutterLayoutManager *manager
|
|||||||
|
|
||||||
void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
|
void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
|
||||||
const CoglMatrix *projection,
|
const CoglMatrix *projection,
|
||||||
const int *viewport,
|
const float *viewport,
|
||||||
const ClutterVertex *vertices_in,
|
const ClutterVertex *vertices_in,
|
||||||
ClutterVertex *vertices_out,
|
ClutterVertex *vertices_out,
|
||||||
int n_vertices);
|
int n_vertices);
|
||||||
|
|
||||||
|
typedef struct _ClutterPlane
|
||||||
|
{
|
||||||
|
CoglVector3 v0;
|
||||||
|
CoglVector3 n;
|
||||||
|
} ClutterPlane;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __CLUTTER_PRIVATE_H__ */
|
#endif /* __CLUTTER_PRIVATE_H__ */
|
||||||
|
@ -41,15 +41,15 @@ void _clutter_stage_get_projection_matrix (ClutterStage
|
|||||||
CoglMatrix *projection);
|
CoglMatrix *projection);
|
||||||
void _clutter_stage_dirty_projection (ClutterStage *stage);
|
void _clutter_stage_dirty_projection (ClutterStage *stage);
|
||||||
void _clutter_stage_set_viewport (ClutterStage *stage,
|
void _clutter_stage_set_viewport (ClutterStage *stage,
|
||||||
int x,
|
float x,
|
||||||
int y,
|
float y,
|
||||||
int width,
|
float width,
|
||||||
int height);
|
float height);
|
||||||
void _clutter_stage_get_viewport (ClutterStage *stage,
|
void _clutter_stage_get_viewport (ClutterStage *stage,
|
||||||
int *x,
|
float *x,
|
||||||
int *y,
|
float *y,
|
||||||
int *width,
|
float *width,
|
||||||
int *height);
|
float *height);
|
||||||
void _clutter_stage_dirty_viewport (ClutterStage *stage);
|
void _clutter_stage_dirty_viewport (ClutterStage *stage);
|
||||||
void _clutter_stage_maybe_setup_viewport (ClutterStage *stage);
|
void _clutter_stage_maybe_setup_viewport (ClutterStage *stage);
|
||||||
void _clutter_stage_maybe_relayout (ClutterActor *stage);
|
void _clutter_stage_maybe_relayout (ClutterActor *stage);
|
||||||
|
@ -115,7 +115,7 @@ struct _ClutterStagePrivate
|
|||||||
ClutterColor color;
|
ClutterColor color;
|
||||||
ClutterPerspective perspective;
|
ClutterPerspective perspective;
|
||||||
CoglMatrix projection;
|
CoglMatrix projection;
|
||||||
int viewport[4];
|
float viewport[4];
|
||||||
ClutterFog fog;
|
ClutterFog fog;
|
||||||
|
|
||||||
gchar *title;
|
gchar *title;
|
||||||
@ -1880,14 +1880,19 @@ _clutter_stage_dirty_projection (ClutterStage *stage)
|
|||||||
* (XXX: If we were to make this API public then we might want to do
|
* (XXX: If we were to make this API public then we might want to do
|
||||||
* add that property.)
|
* add that property.)
|
||||||
*
|
*
|
||||||
|
* Note: currently this interface only support integer precision
|
||||||
|
* offsets and sizes for viewports but the interface takes floats because
|
||||||
|
* OpenGL 4.0 has introduced floating point viewports which we might
|
||||||
|
* want to expose via this API eventually.
|
||||||
|
*
|
||||||
* Since: 1.6
|
* Since: 1.6
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_clutter_stage_set_viewport (ClutterStage *stage,
|
_clutter_stage_set_viewport (ClutterStage *stage,
|
||||||
int x,
|
float x,
|
||||||
int y,
|
float y,
|
||||||
int width,
|
float width,
|
||||||
int height)
|
float height)
|
||||||
{
|
{
|
||||||
ClutterStagePrivate *priv;
|
ClutterStagePrivate *priv;
|
||||||
|
|
||||||
@ -1943,10 +1948,10 @@ _clutter_stage_dirty_viewport (ClutterStage *stage)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_clutter_stage_get_viewport (ClutterStage *stage,
|
_clutter_stage_get_viewport (ClutterStage *stage,
|
||||||
int *x,
|
float *x,
|
||||||
int *y,
|
float *y,
|
||||||
int *width,
|
float *width,
|
||||||
int *height)
|
float *height)
|
||||||
{
|
{
|
||||||
ClutterStagePrivate *priv;
|
ClutterStagePrivate *priv;
|
||||||
|
|
||||||
@ -2753,7 +2758,7 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage)
|
|||||||
if (priv->dirty_viewport)
|
if (priv->dirty_viewport)
|
||||||
{
|
{
|
||||||
CLUTTER_NOTE (PAINT,
|
CLUTTER_NOTE (PAINT,
|
||||||
"Setting up the viewport { w:%d, h:%d }",
|
"Setting up the viewport { w:%f, h:%f }",
|
||||||
priv->viewport[2], priv->viewport[3]);
|
priv->viewport[2], priv->viewport[3]);
|
||||||
|
|
||||||
cogl_set_viewport (priv->viewport[0],
|
cogl_set_viewport (priv->viewport[0],
|
||||||
|
@ -84,7 +84,7 @@ _clutter_gettext (const gchar *str)
|
|||||||
void
|
void
|
||||||
_clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
|
_clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
|
||||||
const CoglMatrix *projection,
|
const CoglMatrix *projection,
|
||||||
const int *viewport,
|
const float *viewport,
|
||||||
const ClutterVertex *vertices_in,
|
const ClutterVertex *vertices_in,
|
||||||
ClutterVertex *vertices_out,
|
ClutterVertex *vertices_out,
|
||||||
int n_vertices)
|
int n_vertices)
|
||||||
|
@ -46,10 +46,10 @@ struct _CoglFramebuffer
|
|||||||
|
|
||||||
CoglMatrixStack *modelview_stack;
|
CoglMatrixStack *modelview_stack;
|
||||||
CoglMatrixStack *projection_stack;
|
CoglMatrixStack *projection_stack;
|
||||||
int viewport_x;
|
float viewport_x;
|
||||||
int viewport_y;
|
float viewport_y;
|
||||||
int viewport_width;
|
float viewport_width;
|
||||||
int viewport_height;
|
float viewport_height;
|
||||||
|
|
||||||
CoglClipState clip_state;
|
CoglClipState clip_state;
|
||||||
|
|
||||||
@ -173,25 +173,25 @@ _cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer,
|
|||||||
|
|
||||||
void
|
void
|
||||||
_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
|
_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
|
||||||
int x,
|
float x,
|
||||||
int y,
|
float y,
|
||||||
int width,
|
float width,
|
||||||
int height);
|
float height);
|
||||||
int
|
float
|
||||||
_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer);
|
_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer);
|
||||||
|
|
||||||
int
|
float
|
||||||
_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer);
|
_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer);
|
||||||
|
|
||||||
int
|
float
|
||||||
_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer);
|
_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer);
|
||||||
|
|
||||||
int
|
float
|
||||||
_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer);
|
_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer,
|
_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer,
|
||||||
int *viewport);
|
float *viewport);
|
||||||
|
|
||||||
CoglMatrixStack *
|
CoglMatrixStack *
|
||||||
_cogl_framebuffer_get_modelview_stack (CoglFramebuffer *framebuffer);
|
_cogl_framebuffer_get_modelview_stack (CoglFramebuffer *framebuffer);
|
||||||
|
@ -499,10 +499,10 @@ _cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer,
|
|||||||
|
|
||||||
void
|
void
|
||||||
_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
|
_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
|
||||||
int x,
|
float x,
|
||||||
int y,
|
float y,
|
||||||
int width,
|
float width,
|
||||||
int height)
|
float height)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
@ -523,32 +523,33 @@ _cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
|
|||||||
ctx->dirty_gl_viewport = TRUE;
|
ctx->dirty_gl_viewport = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
float
|
||||||
_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer)
|
_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
return framebuffer->viewport_x;
|
return framebuffer->viewport_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
float
|
||||||
_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer)
|
_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
return framebuffer->viewport_y;
|
return framebuffer->viewport_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
float
|
||||||
_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer)
|
_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
return framebuffer->viewport_width;
|
return framebuffer->viewport_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
float
|
||||||
_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer)
|
_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
return framebuffer->viewport_height;
|
return framebuffer->viewport_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer, int *viewport)
|
_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer,
|
||||||
|
float *viewport)
|
||||||
{
|
{
|
||||||
viewport[0] = framebuffer->viewport_x;
|
viewport[0] = framebuffer->viewport_x;
|
||||||
viewport[1] = framebuffer->viewport_y;
|
viewport[1] = framebuffer->viewport_y;
|
||||||
@ -1290,7 +1291,7 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
|
|||||||
|
|
||||||
if (ctx->dirty_gl_viewport)
|
if (ctx->dirty_gl_viewport)
|
||||||
{
|
{
|
||||||
int gl_viewport_y;
|
float gl_viewport_y;
|
||||||
|
|
||||||
/* 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
|
||||||
@ -1303,7 +1304,7 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
|
|||||||
gl_viewport_y = draw_buffer->height -
|
gl_viewport_y = draw_buffer->height -
|
||||||
(draw_buffer->viewport_y + draw_buffer->viewport_height);
|
(draw_buffer->viewport_y + draw_buffer->viewport_height);
|
||||||
|
|
||||||
COGL_NOTE (OPENGL, "Calling glViewport(%d, %d, %d, %d)",
|
COGL_NOTE (OPENGL, "Calling glViewport(%f, %f, %f, %f)",
|
||||||
draw_buffer->viewport_x,
|
draw_buffer->viewport_x,
|
||||||
gl_viewport_y,
|
gl_viewport_y,
|
||||||
draw_buffer->viewport_width,
|
draw_buffer->viewport_width,
|
||||||
|
@ -1552,7 +1552,7 @@ entry_to_screen_polygon (const CoglJournalEntry *entry,
|
|||||||
CoglMatrixStack *projection_stack;
|
CoglMatrixStack *projection_stack;
|
||||||
CoglMatrix projection;
|
CoglMatrix projection;
|
||||||
int i;
|
int i;
|
||||||
int viewport[4];
|
float viewport[4];
|
||||||
|
|
||||||
poly[0] = vertices[0];
|
poly[0] = vertices[0];
|
||||||
poly[1] = vertices[1];
|
poly[1] = vertices[1];
|
||||||
|
@ -1251,13 +1251,15 @@ _math_matrix_translate (CoglMatrix *matrix, float x, float y, float z)
|
|||||||
* Transforms Normalized Device Coords to window/Z values.
|
* Transforms Normalized Device Coords to window/Z values.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_math_matrix_viewport (CoglMatrix *matrix, int x, int y, int width, int height,
|
_math_matrix_viewport (CoglMatrix *matrix,
|
||||||
|
float x, float y,
|
||||||
|
float width, float height,
|
||||||
float zNear, float zFar, float depthMax)
|
float zNear, float zFar, float depthMax)
|
||||||
{
|
{
|
||||||
float *m = (float *)matrix;
|
float *m = (float *)matrix;
|
||||||
m[MAT_SX] = (float)width / 2.0f;
|
m[MAT_SX] = width / 2.0f;
|
||||||
m[MAT_TX] = m[MAT_SX] + x;
|
m[MAT_TX] = m[MAT_SX] + x;
|
||||||
m[MAT_SY] = (float) height / 2.0f;
|
m[MAT_SY] = height / 2.0f;
|
||||||
m[MAT_TY] = m[MAT_SY] + y;
|
m[MAT_TY] = m[MAT_SY] + y;
|
||||||
m[MAT_SZ] = depthMax * ((zFar - zNear) / 2.0f);
|
m[MAT_SZ] = depthMax * ((zFar - zNear) / 2.0f);
|
||||||
m[MAT_TZ] = depthMax * ((zFar - zNear) / 2.0f + zNear);
|
m[MAT_TZ] = depthMax * ((zFar - zNear) / 2.0f + zNear);
|
||||||
|
@ -134,7 +134,7 @@ _math_matrix_frustum (CoglMatrix *matrix,
|
|||||||
|
|
||||||
void
|
void
|
||||||
_math_matrix_viewport (CoglMatrix *matrix,
|
_math_matrix_viewport (CoglMatrix *matrix,
|
||||||
int x, int y, int width, int height,
|
float x, float y, float width, float height,
|
||||||
float z_near, float z_far, float depth_max);
|
float z_near, float z_far, float depth_max);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -929,7 +929,7 @@ cogl_texture_set_region (CoglHandle handle,
|
|||||||
static void
|
static void
|
||||||
do_texture_draw_and_read (CoglHandle handle,
|
do_texture_draw_and_read (CoglHandle handle,
|
||||||
CoglBitmap *target_bmp,
|
CoglBitmap *target_bmp,
|
||||||
GLint *viewport)
|
float *viewport)
|
||||||
{
|
{
|
||||||
int bpp;
|
int bpp;
|
||||||
float rx1, ry1;
|
float rx1, ry1;
|
||||||
@ -1036,7 +1036,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
{
|
{
|
||||||
int bpp;
|
int bpp;
|
||||||
CoglFramebuffer *framebuffer;
|
CoglFramebuffer *framebuffer;
|
||||||
int viewport[4];
|
float viewport[4];
|
||||||
CoglBitmap *alpha_bmp;
|
CoglBitmap *alpha_bmp;
|
||||||
CoglMatrixStack *projection_stack;
|
CoglMatrixStack *projection_stack;
|
||||||
CoglMatrixStack *modelview_stack;
|
CoglMatrixStack *modelview_stack;
|
||||||
@ -1064,10 +1064,10 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
_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,
|
||||||
0, (float)(viewport[2]),
|
0, viewport[2],
|
||||||
(float)(viewport[3]), 0,
|
viewport[3], 0,
|
||||||
(float)(0),
|
0,
|
||||||
(float)(100));
|
100);
|
||||||
|
|
||||||
modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer);
|
modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer);
|
||||||
_cogl_matrix_stack_push (modelview_stack);
|
_cogl_matrix_stack_push (modelview_stack);
|
||||||
|
@ -407,19 +407,14 @@ _cogl_features_available_private (CoglFeatureFlagsPrivate features)
|
|||||||
* _cogl_framebuffer_get_viewport* functions public.
|
* _cogl_framebuffer_get_viewport* functions public.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
cogl_get_viewport (float v[4])
|
cogl_get_viewport (float viewport[4])
|
||||||
{
|
{
|
||||||
CoglFramebuffer *framebuffer;
|
CoglFramebuffer *framebuffer;
|
||||||
int viewport[4];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
framebuffer = _cogl_get_draw_buffer ();
|
framebuffer = _cogl_get_draw_buffer ();
|
||||||
_cogl_framebuffer_get_viewport4fv (framebuffer, viewport);
|
_cogl_framebuffer_get_viewport4fv (framebuffer, viewport);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
v[i] = viewport[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1281,9 +1281,6 @@ _cogl_check_extension (const char *name, const char *ext);
|
|||||||
void
|
void
|
||||||
_cogl_set_indirect_context (gboolean indirect);
|
_cogl_set_indirect_context (gboolean indirect);
|
||||||
|
|
||||||
void
|
|
||||||
_cogl_set_viewport (int x, int y, int width, int height);
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_cogl_check_driver_valid (GError **error);
|
_cogl_check_driver_valid (GError **error);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user