2007-05-02 Matthew Allum <mallum@openedhand.com>

* clutter/clutter-actor.c:
        * clutter/cogl/gles/cogl.c:
        Fix rotation + other fixed point cleanups.

        * clutter/clutter-texture.h:
        Sketch out an updated API.
This commit is contained in:
Matthew Allum 2007-05-02 09:01:11 +00:00
parent 78bf6ccb88
commit 2845bb5b74
4 changed files with 58 additions and 126 deletions

View File

@ -1,3 +1,12 @@
2007-05-02 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-actor.c:
* clutter/cogl/gles/cogl.c:
Fix rotation + other fixed point cleanups.
* clutter/clutter-texture.h:
Sketch out an updated API.
2007-05-01 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-rectangle.c:

View File

@ -299,6 +299,8 @@ clutter_actor_paint (ClutterActor *self)
cogl_push_matrix();
#define NEG(x) (1 + ~(x))
#if CLUTTER_COGL_GL
glLoadName (clutter_actor_get_id (self));
#endif
@ -312,45 +314,27 @@ clutter_actor_paint (ClutterActor *self)
if (self->priv->rzang)
{
cogl_translatex (priv->rzx,
priv->rzy,
0);
cogl_translate (priv->rzx, priv->rzy, 0);
cogl_rotatex (priv->rzang, 0, 0, CFX_ONE);
cogl_translatex (-1. * priv->rzx,
-1. * priv->rzy,
0);
cogl_translate (-priv->rzx, -priv->rzy, 0);
}
if (self->priv->ryang)
{
cogl_translatex (priv->ryx,
0,
CLUTTER_INT_TO_FIXED (priv->z) + priv->ryz);
cogl_translate (priv->ryx, 0, priv->z + priv->ryz);
cogl_rotatex (priv->ryang, 0, CFX_ONE, 0);
cogl_translatex (- priv->ryx,
0.0,
CLUTTER_INT_TO_FIXED(-priv->z) - priv->ryz);
cogl_translate (-priv->ryx, 0, -(priv->z + priv->ryz));
}
if (self->priv->rxang)
{
cogl_translatex (0,
priv->rxy,
CLUTTER_INT_TO_FIXED(priv->z) + priv->rxz);
cogl_translate (0, priv->rxy, priv->z + priv->rxz);
cogl_rotatex (priv->rxang, CFX_ONE, 0, CFX_ONE);
cogl_translatex (0,
- priv->rxy,
CLUTTER_INT_TO_FIXED(-priv->z) - priv->rxz);
cogl_translate (0, -priv->rxy, -(priv->z - priv->rxz));
}
if (self->priv->z)
glTranslatef (0.0, 0.0, (float) priv->z);
cogl_translate (0, 0, priv->z);
if (self->priv->scale_x != CFX_ONE ||
self->priv->scale_y != CFX_ONE)

View File

@ -31,12 +31,39 @@
G_BEGIN_DECLS
#define CLUTTER_TEXTURE_FORMAT_RGB 1
#define CLUTTER_TEXTURE_FORMAT_RGBA 2
#define CLUTTER_TEXTURE_FORMAT_BGR 3
#define CLUTTER_TEXTURE_FORMAT_BGRA 4
#define CLUTTER_TEXTURE_FORMAT_YUV 5
#define CLUTTER_TEXTURE_FORMAT_YUV2 6
#if 0
/* New API Ideas */
#define CLUTTER_TEXTURE_RGB_FLAG_BRGA (1<<1)
#define CLUTTER_TEXTURE_RGB_FLAG_PREMULT (1<<2)
gboolean
clutter_texture_set_from_rgb_data (ClutterTexture *texture,
const guchar *data,
gboolean has_alpha,
gint width,
gint height,
gint rowstride,
gint bpp,
gint flags,
GError *error);
gboolean
clutter_texture_set_from_yuv_data (ClutterTexture *texture,
const guchar *data,
gint width,
gint height,
gint flags,
GError *error);
Notes
=====
- drop format and type props - would be set in GL texture automagically
via about calls.
#endif
#define CLUTTER_TYPE_TEXTURE (clutter_texture_get_type ())
#define CLUTTER_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_TEXTURE, ClutterTexture))

View File

@ -37,7 +37,7 @@
static gulong __enable_flags = 0;
#define COGL_DEBUG 1
#define COGL_DEBUG 0
#if COGL_DEBUG
struct token_string
@ -250,6 +250,7 @@ cogl_texture_can_size (COGLenum pixel_format,
{
GLint new_width = 0;
/* FIXME */
return TRUE;
@ -478,52 +479,6 @@ cogl_perspective (ClutterAngle fovy,
#undef M
}
#if 0
void
cogl_perspective (ClutterAngle fovy,
ClutterFixed aspect,
ClutterFixed zNear,
ClutterFixed zFar)
{
ClutterFixed xmax, ymax;
ClutterFixed x, y, c, d;
GLfloat m[16];
memset (&m[0], 0, sizeof (m));
/*
* Based on the original algorithm in perspective():
*
* 1) xmin = -xmax => xmax + xmin == 0 && xmax - xmin == 2 * xmax
* same true for y, hence: a == 0 && b == 0;
*
* 2) When working with small numbers, we can are loosing significant
* precision, hence we use clutter_qmulx() here, not the fast macro.
*/
ymax = clutter_qmulx (zNear, clutter_tani (fovy >> 1));
xmax = clutter_qmulx (ymax, aspect);
x = CFX_DIV (zNear, xmax);
y = CFX_DIV (zNear, ymax);
c = CFX_DIV (-(zFar + zNear), ( zFar - zNear));
d = CFX_DIV (-(clutter_qmulx (2*zFar, zNear)), (zFar - zNear));
#define M(row,col) m[col*4+row]
M(0,0) = CLUTTER_FIXED_TO_FLOAT (x);
M(1,1) = CLUTTER_FIXED_TO_FLOAT (y);
M(2,2) = CLUTTER_FIXED_TO_FLOAT (c);
M(2,3) = CLUTTER_FIXED_TO_FLOAT (d);
M(3,2) = -1.0F;
GE( glMultMatrixf (m) );
#undef M
}
#endif
void
cogl_setup_viewport (guint w,
guint h,
@ -536,18 +491,11 @@ cogl_setup_viewport (guint w,
gint height = (gint) h;
GE( glViewport (0, 0, width, height) );
#define NEG(x) (1 + ~(x))
GE( glMatrixMode (GL_PROJECTION) );
GE( glLoadIdentity () );
/*
glOrthox (0,
width << 16,
0,
height << 16,
-1 << 16, 1 << 16);
/* For Ortho projection.
* glOrthox (0, width << 16, 0, height << 16, -1 << 16, 1 << 16);
*/
cogl_perspective (fovy, aspect, z_near, z_far);
@ -558,50 +506,14 @@ cogl_setup_viewport (guint w,
/* camera distance from screen, 0.5 * tan (FOV) */
#define DEFAULT_Z_CAMERA 0.866025404f
GE( glTranslatex (-1 << 15,
-1 << 15,
NEG(CLUTTER_FLOAT_TO_FIXED(DEFAULT_Z_CAMERA))) );
-CLUTTER_FLOAT_TO_FIXED(DEFAULT_Z_CAMERA)) );
g_debug ("TX1: %f/%f %f/%f %f/%f",
CLUTTER_FIXED_TO_DOUBLE (-1 << 15), -0.5,
CLUTTER_FIXED_TO_DOUBLE (-1 << 15), -0.5,
CLUTTER_FIXED_TO_DOUBLE (NEG(CLUTTER_FLOAT_TO_FIXED(DEFAULT_Z_CAMERA))),
-DEFAULT_Z_CAMERA);
GE( glScalex ( CFX_ONE / width,
NEG(CFX_ONE) / height,
-CFX_ONE / height,
CFX_ONE / width));
g_debug ("SX: %f/%f %f/%f, w %d, h %d",
CLUTTER_FIXED_TO_DOUBLE (CFX_ONE / width), 1.0f / width,
CLUTTER_FIXED_TO_DOUBLE (NEG(CFX_ONE) / height), -1.0f / height,
width, height);
GE( glTranslatex (0, NEG(CFX_ONE) * height, 0) );
g_debug ("TX2: %f/%f",
CLUTTER_FIXED_TO_DOUBLE (NEG(CFX_ONE) * height),
-1.0 * height);
#if 0
GE( glTranslatex (NEG(CFX_HALF),
NEG(CFX_HALF),
NEG(CLUTTER_FLOAT_TO_FIXED(DEFAULT_Z_CAMERA))) );
GE( glScalex ( CFX_DIV(CFX_ONE, CLUTTER_INT_TO_FIXED(width)),
NEG(CFX_DIV(CFX_ONE, CLUTTER_INT_TO_FIXED(height))),
CFX_DIV(CFX_ONE, CLUTTER_INT_TO_FIXED(width))) );
GE( glTranslatex (0, NEG(CFX_MUL(CFX_ONE, CLUTTER_INT_TO_FIXED(height))), 0) );
#endif
#if 0
GE( glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA) );
GE( glScalef ( 1.0f / width,
-1.0f / height,
1.0f / width) );
GE( glTranslatef (0.0f, -1.0 * height, 0.0f) );
#endif
GE( glTranslatex (0, -CFX_ONE * height, 0) );
}