2012-02-06 08:30:08 -05:00
|
|
|
#include <cogl/cogl.h>
|
2011-05-05 18:34:38 -04:00
|
|
|
#include <string.h>
|
2012-02-06 09:02:01 -05:00
|
|
|
#include <stdlib.h>
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
#include "test-utils.h"
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
typedef struct _TestState
|
|
|
|
{
|
|
|
|
int fb_width;
|
|
|
|
int fb_height;
|
|
|
|
} TestState;
|
|
|
|
|
|
|
|
#define PRIM_COLOR 0xff00ffff
|
|
|
|
#define TEX_COLOR 0x0000ffff
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2012-02-06 09:02:01 -05:00
|
|
|
#define N_ATTRIBS 8
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
typedef CoglPrimitive * (* TestPrimFunc) (CoglContext *ctx, uint32_t *expected_color);
|
2011-05-05 18:34:38 -04:00
|
|
|
|
|
|
|
static CoglPrimitive *
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
test_prim_p2 (CoglContext *ctx, uint32_t *expected_color)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
static const CoglVertexP2 verts[] =
|
|
|
|
{ { 0, 0 }, { 0, 10 }, { 10, 0 } };
|
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
return cogl_primitive_new_p2 (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_VERTICES_MODE_TRIANGLES,
|
2011-05-05 18:34:38 -04:00
|
|
|
3, /* n_vertices */
|
|
|
|
verts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPrimitive *
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
test_prim_p3 (CoglContext *ctx, uint32_t *expected_color)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
static const CoglVertexP3 verts[] =
|
|
|
|
{ { 0, 0, 0 }, { 0, 10, 0 }, { 10, 0, 0 } };
|
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
return cogl_primitive_new_p3 (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_VERTICES_MODE_TRIANGLES,
|
2011-05-05 18:34:38 -04:00
|
|
|
3, /* n_vertices */
|
|
|
|
verts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPrimitive *
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
test_prim_p2c4 (CoglContext *ctx, uint32_t *expected_color)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
static const CoglVertexP2C4 verts[] =
|
|
|
|
{ { 0, 0, 255, 255, 0, 255 },
|
|
|
|
{ 0, 10, 255, 255, 0, 255 },
|
|
|
|
{ 10, 0, 255, 255, 0, 255 } };
|
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
*expected_color = 0xffff00ff;
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
return cogl_primitive_new_p2c4 (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_VERTICES_MODE_TRIANGLES,
|
2011-05-05 18:34:38 -04:00
|
|
|
3, /* n_vertices */
|
|
|
|
verts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPrimitive *
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
test_prim_p3c4 (CoglContext *ctx, uint32_t *expected_color)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
static const CoglVertexP3C4 verts[] =
|
|
|
|
{ { 0, 0, 0, 255, 255, 0, 255 },
|
|
|
|
{ 0, 10, 0, 255, 255, 0, 255 },
|
|
|
|
{ 10, 0, 0, 255, 255, 0, 255 } };
|
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
*expected_color = 0xffff00ff;
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
return cogl_primitive_new_p3c4 (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_VERTICES_MODE_TRIANGLES,
|
2011-05-05 18:34:38 -04:00
|
|
|
3, /* n_vertices */
|
|
|
|
verts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPrimitive *
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
test_prim_p2t2 (CoglContext *ctx, uint32_t *expected_color)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
static const CoglVertexP2T2 verts[] =
|
|
|
|
{ { 0, 0, 1, 0 },
|
|
|
|
{ 0, 10, 1, 0 },
|
|
|
|
{ 10, 0, 1, 0 } };
|
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
*expected_color = TEX_COLOR;
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
return cogl_primitive_new_p2t2 (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_VERTICES_MODE_TRIANGLES,
|
2011-05-05 18:34:38 -04:00
|
|
|
3, /* n_vertices */
|
|
|
|
verts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPrimitive *
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
test_prim_p3t2 (CoglContext *ctx, uint32_t *expected_color)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
static const CoglVertexP3T2 verts[] =
|
|
|
|
{ { 0, 0, 0, 1, 0 },
|
|
|
|
{ 0, 10, 0, 1, 0 },
|
|
|
|
{ 10, 0, 0, 1, 0 } };
|
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
*expected_color = TEX_COLOR;
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
return cogl_primitive_new_p3t2 (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_VERTICES_MODE_TRIANGLES,
|
2011-05-05 18:34:38 -04:00
|
|
|
3, /* n_vertices */
|
|
|
|
verts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPrimitive *
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
test_prim_p2t2c4 (CoglContext *ctx, uint32_t *expected_color)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
static const CoglVertexP2T2C4 verts[] =
|
|
|
|
{ { 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff },
|
|
|
|
{ 0, 10, 1, 0, 0xff, 0xff, 0xf0, 0xff },
|
|
|
|
{ 10, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff } };
|
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
/* The blue component of the texture color should be replaced with 0xf0 */
|
|
|
|
*expected_color = (TEX_COLOR & 0xffff00ff) | 0x0000f000;
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
return cogl_primitive_new_p2t2c4 (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_VERTICES_MODE_TRIANGLES,
|
2011-05-05 18:34:38 -04:00
|
|
|
3, /* n_vertices */
|
|
|
|
verts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPrimitive *
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
test_prim_p3t2c4 (CoglContext *ctx, uint32_t *expected_color)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
static const CoglVertexP3T2C4 verts[] =
|
|
|
|
{ { 0, 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff },
|
|
|
|
{ 0, 10, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff },
|
|
|
|
{ 10, 0, 0, 1, 0, 0xff, 0xff, 0xf0, 0xff } };
|
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
/* The blue component of the texture color should be replaced with 0xf0 */
|
|
|
|
*expected_color = (TEX_COLOR & 0xffff00ff) | 0x0000f000;
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
return cogl_primitive_new_p3t2c4 (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_VERTICES_MODE_TRIANGLES,
|
2011-05-05 18:34:38 -04:00
|
|
|
3, /* n_vertices */
|
|
|
|
verts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TestPrimFunc
|
|
|
|
test_prim_funcs[] =
|
|
|
|
{
|
|
|
|
test_prim_p2,
|
|
|
|
test_prim_p3,
|
|
|
|
test_prim_p2c4,
|
|
|
|
test_prim_p3c4,
|
|
|
|
test_prim_p2t2,
|
|
|
|
test_prim_p3t2,
|
|
|
|
test_prim_p2t2c4,
|
|
|
|
test_prim_p3t2c4
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-02-06 08:30:08 -05:00
|
|
|
test_paint (TestState *state)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
|
|
|
CoglPipeline *pipeline;
|
2012-02-06 08:30:08 -05:00
|
|
|
CoglTexture *tex;
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
uint8_t tex_data[6];
|
2011-05-05 18:34:38 -04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Create a two pixel texture. The first pixel is white and the
|
|
|
|
second pixel is tex_color. The assumption is that if no texture
|
|
|
|
coordinates are specified then it will default to 0,0 and get
|
|
|
|
white */
|
|
|
|
tex_data[0] = 255;
|
|
|
|
tex_data[1] = 255;
|
|
|
|
tex_data[2] = 255;
|
2012-02-06 08:30:08 -05:00
|
|
|
tex_data[3] = (TEX_COLOR >> 24) & 0xff;
|
|
|
|
tex_data[4] = (TEX_COLOR >> 16) & 0xff;
|
|
|
|
tex_data[5] = (TEX_COLOR >> 8) & 0xff;
|
2013-06-08 20:09:04 -04:00
|
|
|
tex = test_utils_texture_new_from_data (test_ctx,
|
|
|
|
2, 1, /* size */
|
|
|
|
TEST_UTILS_TEXTURE_NO_ATLAS,
|
|
|
|
COGL_PIXEL_FORMAT_RGB_888,
|
|
|
|
COGL_PIXEL_FORMAT_ANY,
|
|
|
|
6, /* rowstride */
|
|
|
|
tex_data);
|
2013-01-18 12:57:06 -05:00
|
|
|
pipeline = cogl_pipeline_new (test_ctx);
|
2011-05-05 18:34:38 -04:00
|
|
|
cogl_pipeline_set_color4ub (pipeline,
|
2012-02-06 08:30:08 -05:00
|
|
|
(PRIM_COLOR >> 24) & 0xff,
|
|
|
|
(PRIM_COLOR >> 16) & 0xff,
|
|
|
|
(PRIM_COLOR >> 8) & 0xff,
|
|
|
|
(PRIM_COLOR >> 0) & 0xff);
|
2011-05-05 18:34:38 -04:00
|
|
|
cogl_pipeline_set_layer_texture (pipeline, 0, tex);
|
2012-01-07 21:59:04 -05:00
|
|
|
cogl_object_unref (tex);
|
2011-05-05 18:34:38 -04:00
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (test_prim_funcs); i++)
|
|
|
|
{
|
|
|
|
CoglPrimitive *prim;
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
uint32_t expected_color = PRIM_COLOR;
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
prim = test_prim_funcs[i] (test_ctx, &expected_color);
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
cogl_framebuffer_push_matrix (test_fb);
|
|
|
|
cogl_framebuffer_translate (test_fb, i * 10, 0, 0);
|
2013-07-09 18:47:29 -04:00
|
|
|
cogl_primitive_draw (prim, test_fb, pipeline);
|
2013-01-18 12:57:06 -05:00
|
|
|
cogl_framebuffer_pop_matrix (test_fb);
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
test_utils_check_pixel (test_fb, i * 10 + 2, 2, expected_color);
|
2011-05-05 18:34:38 -04:00
|
|
|
|
|
|
|
cogl_object_unref (prim);
|
|
|
|
}
|
2012-01-07 21:59:04 -05:00
|
|
|
|
|
|
|
cogl_object_unref (pipeline);
|
2011-05-05 18:34:38 -04:00
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2012-02-06 09:02:01 -05:00
|
|
|
get_attributes_cb (CoglPrimitive *prim,
|
|
|
|
CoglAttribute *attrib,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
CoglAttribute ***p = user_data;
|
|
|
|
*((* p)++) = attrib;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
compare_pointers (const void *a, const void *b)
|
|
|
|
{
|
|
|
|
CoglAttribute *pa = *(CoglAttribute **) a;
|
|
|
|
CoglAttribute *pb = *(CoglAttribute **) b;
|
|
|
|
|
|
|
|
if (pa < pb)
|
|
|
|
return -1;
|
|
|
|
else if (pa > pb)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_copy (TestState *state)
|
|
|
|
{
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static const uint16_t indices_data[2] = { 1, 2 };
|
2012-02-06 12:08:58 -05:00
|
|
|
CoglAttributeBuffer *buffer =
|
2013-01-18 12:57:06 -05:00
|
|
|
cogl_attribute_buffer_new (test_ctx, 100, NULL);
|
2012-02-06 09:02:01 -05:00
|
|
|
CoglAttribute *attributes[N_ATTRIBS];
|
|
|
|
CoglAttribute *attributes_a[N_ATTRIBS], *attributes_b[N_ATTRIBS];
|
|
|
|
CoglAttribute **p;
|
|
|
|
CoglPrimitive *prim_a, *prim_b;
|
|
|
|
CoglIndices *indices;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < N_ATTRIBS; i++)
|
|
|
|
{
|
|
|
|
char *name = g_strdup_printf ("foo_%i", i);
|
|
|
|
attributes[i] = cogl_attribute_new (buffer,
|
|
|
|
name,
|
|
|
|
16, /* stride */
|
|
|
|
16, /* offset */
|
|
|
|
2, /* components */
|
|
|
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
|
|
|
g_free (name);
|
|
|
|
}
|
|
|
|
|
|
|
|
prim_a = cogl_primitive_new_with_attributes (COGL_VERTICES_MODE_TRIANGLES,
|
|
|
|
8, /* n_vertices */
|
|
|
|
attributes,
|
|
|
|
N_ATTRIBS);
|
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
indices = cogl_indices_new (test_ctx,
|
2012-02-06 12:08:58 -05:00
|
|
|
COGL_INDICES_TYPE_UNSIGNED_SHORT,
|
2012-02-06 09:02:01 -05:00
|
|
|
indices_data,
|
|
|
|
2 /* n_indices */);
|
|
|
|
|
|
|
|
cogl_primitive_set_first_vertex (prim_a, 12);
|
|
|
|
cogl_primitive_set_indices (prim_a, indices, 2);
|
|
|
|
|
|
|
|
prim_b = cogl_primitive_copy (prim_a);
|
|
|
|
|
|
|
|
p = attributes_a;
|
|
|
|
cogl_primitive_foreach_attribute (prim_a,
|
|
|
|
get_attributes_cb,
|
|
|
|
&p);
|
|
|
|
g_assert_cmpint (p - attributes_a, ==, N_ATTRIBS);
|
|
|
|
|
|
|
|
p = attributes_b;
|
|
|
|
cogl_primitive_foreach_attribute (prim_b,
|
|
|
|
get_attributes_cb,
|
|
|
|
&p);
|
|
|
|
g_assert_cmpint (p - attributes_b, ==, N_ATTRIBS);
|
|
|
|
|
|
|
|
qsort (attributes_a, N_ATTRIBS, sizeof (CoglAttribute *), compare_pointers);
|
|
|
|
qsort (attributes_b, N_ATTRIBS, sizeof (CoglAttribute *), compare_pointers);
|
|
|
|
|
|
|
|
g_assert (memcmp (attributes_a, attributes_b, sizeof (attributes_a)) == 0);
|
|
|
|
|
|
|
|
g_assert_cmpint (cogl_primitive_get_first_vertex (prim_a),
|
|
|
|
==,
|
|
|
|
cogl_primitive_get_first_vertex (prim_b));
|
|
|
|
|
|
|
|
g_assert_cmpint (cogl_primitive_get_n_vertices (prim_a),
|
|
|
|
==,
|
|
|
|
cogl_primitive_get_n_vertices (prim_b));
|
|
|
|
|
|
|
|
g_assert_cmpint (cogl_primitive_get_mode (prim_a),
|
|
|
|
==,
|
|
|
|
cogl_primitive_get_mode (prim_b));
|
|
|
|
|
|
|
|
g_assert (cogl_primitive_get_indices (prim_a) ==
|
|
|
|
cogl_primitive_get_indices (prim_b));
|
|
|
|
|
|
|
|
cogl_object_unref (prim_a);
|
|
|
|
cogl_object_unref (prim_b);
|
|
|
|
cogl_object_unref (indices);
|
|
|
|
|
|
|
|
for (i = 0; i < N_ATTRIBS; i++)
|
|
|
|
cogl_object_unref (attributes[i]);
|
|
|
|
|
|
|
|
cogl_object_unref (buffer);
|
|
|
|
}
|
|
|
|
|
2011-05-05 18:34:38 -04:00
|
|
|
void
|
2012-03-16 15:54:13 -04:00
|
|
|
test_primitive (void)
|
2011-05-05 18:34:38 -04:00
|
|
|
{
|
2012-02-06 08:30:08 -05:00
|
|
|
TestState state;
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
state.fb_width = cogl_framebuffer_get_width (test_fb);
|
|
|
|
state.fb_height = cogl_framebuffer_get_height (test_fb);
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2013-01-18 12:57:06 -05:00
|
|
|
cogl_framebuffer_orthographic (test_fb,
|
2012-03-16 15:54:13 -04:00
|
|
|
0, 0,
|
|
|
|
state.fb_width,
|
|
|
|
state.fb_height,
|
|
|
|
-1,
|
|
|
|
100);
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2012-02-06 08:30:08 -05:00
|
|
|
test_paint (&state);
|
2012-02-06 09:02:01 -05:00
|
|
|
test_copy (&state);
|
2011-05-05 18:34:38 -04:00
|
|
|
|
2012-02-23 07:30:51 -05:00
|
|
|
if (cogl_test_verbose ())
|
2011-05-05 18:34:38 -04:00
|
|
|
g_print ("OK\n");
|
|
|
|
}
|