summaryrefslogtreecommitdiff
path: root/tests/conform/test-sub-texture.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/conform/test-sub-texture.c')
-rw-r--r--tests/conform/test-sub-texture.c77
1 files changed, 43 insertions, 34 deletions
diff --git a/tests/conform/test-sub-texture.c b/tests/conform/test-sub-texture.c
index 5bb23e2f..261f4d72 100644
--- a/tests/conform/test-sub-texture.c
+++ b/tests/conform/test-sub-texture.c
@@ -22,7 +22,6 @@ corner_colors[SOURCE_DIVISIONS_X * SOURCE_DIVISIONS_Y] =
typedef struct _TestState
{
- CoglContext *ctx;
CoglTexture2D *tex;
} TestState;
@@ -56,7 +55,7 @@ create_source (TestState *state)
}
}
- tex = cogl_texture_2d_new_from_data (state->ctx,
+ tex = cogl_texture_2d_new_from_data (ctx,
SOURCE_SIZE, SOURCE_SIZE,
COGL_PIXEL_FORMAT_RGBA_8888,
COGL_PIXEL_FORMAT_ANY,
@@ -88,7 +87,7 @@ create_test_texture (TestState *state)
*(p++) = 255;
}
- tex = cogl_texture_2d_new_from_data (state->ctx,
+ tex = cogl_texture_2d_new_from_data (ctx,
256, 256,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
COGL_PIXEL_FORMAT_ANY,
@@ -107,9 +106,10 @@ paint (TestState *state)
{
CoglTexture2D *full_texture;
CoglSubTexture *sub_texture, *sub_sub_texture;
+ CoglPipeline *pipeline = cogl_pipeline_new (ctx);
/* Create a sub texture of the bottom right quarter of the texture */
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (state->tex),
DIVISION_WIDTH,
DIVISION_HEIGHT,
@@ -117,40 +117,47 @@ paint (TestState *state)
DIVISION_HEIGHT);
/* Paint it */
- cogl_set_source_texture (COGL_TEXTURE (sub_texture));
- cogl_rectangle (0.0f, 0.0f, DIVISION_WIDTH, DIVISION_HEIGHT);
-
+ cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
cogl_object_unref (sub_texture);
+ cogl_framebuffer_draw_rectangle (fb, pipeline,
+ 0.0f, 0.0f, DIVISION_WIDTH, DIVISION_HEIGHT);
+
/* Repeat a sub texture of the top half of the full texture. This is
documented to be undefined so it doesn't technically have to work
but it will with the current implementation */
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (state->tex),
0, 0,
SOURCE_SIZE,
DIVISION_HEIGHT);
- cogl_set_source_texture (COGL_TEXTURE (sub_texture));
- cogl_rectangle_with_texture_coords (0.0f, SOURCE_SIZE,
- SOURCE_SIZE * 2.0f, SOURCE_SIZE * 1.5f,
- 0.0f, 0.0f,
- 2.0f, 1.0f);
+ cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
cogl_object_unref (sub_texture);
+ cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
+ 0.0f,
+ SOURCE_SIZE,
+ SOURCE_SIZE * 2.0f,
+ SOURCE_SIZE * 1.5f,
+ 0.0f, 0.0f,
+ 2.0f, 1.0f);
/* Create a sub texture of a sub texture */
full_texture = create_test_texture (state);
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (full_texture),
20, 10, 30, 20);
- sub_sub_texture = cogl_sub_texture_new (state->ctx,
+ cogl_object_unref (full_texture);
+ sub_sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (sub_texture),
20, 10, 10, 10);
- cogl_set_source_texture (COGL_TEXTURE (sub_sub_texture));
- cogl_rectangle (0.0f, SOURCE_SIZE * 2.0f,
- 10.0f, SOURCE_SIZE * 2.0f + 10.0f);
- cogl_object_unref (sub_sub_texture);
cogl_object_unref (sub_texture);
- cogl_object_unref (full_texture);
+ cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_sub_texture));
+ cogl_object_unref (sub_sub_texture);
+ cogl_framebuffer_draw_rectangle (fb, pipeline,
+ 0.0f, SOURCE_SIZE * 2.0f,
+ 10.0f, SOURCE_SIZE * 2.0f + 10.0f);
+
+ cogl_object_unref (pipeline);
}
static void
@@ -158,7 +165,8 @@ validate_part (int xpos, int ypos,
int width, int height,
guint32 color)
{
- test_utils_check_region (xpos + TEST_INSET,
+ test_utils_check_region (fb,
+ xpos + TEST_INSET,
ypos + TEST_INSET,
width - TEST_INSET - 2,
height - TEST_INSET - 2,
@@ -212,10 +220,11 @@ validate_result (TestState *state)
/* Sub sub texture */
p = texture_data = g_malloc (10 * 10 * 4);
- cogl_read_pixels (0, SOURCE_SIZE * 2, 10, 10,
- COGL_READ_PIXELS_COLOR_BUFFER,
- COGL_PIXEL_FORMAT_RGBA_8888,
- p);
+ cogl_flush ();
+ cogl_framebuffer_read_pixels (fb,
+ 0, SOURCE_SIZE * 2, 10, 10,
+ COGL_PIXEL_FORMAT_RGBA_8888,
+ p);
for (y = 0; y < 10; y++)
for (x = 0; x < 10; x++)
{
@@ -226,7 +235,7 @@ validate_result (TestState *state)
g_free (texture_data);
/* Try reading back the texture data */
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (state->tex),
SOURCE_SIZE / 4,
SOURCE_SIZE / 4,
@@ -257,7 +266,7 @@ validate_result (TestState *state)
/* Create a 256x256 test texture */
test_tex = create_test_texture (state);
/* Create a sub texture the views the center half of the texture */
- sub_texture = cogl_sub_texture_new (state->ctx,
+ sub_texture = cogl_sub_texture_new (ctx,
COGL_TEXTURE (test_tex),
64, 64, 128, 128);
/* Update the center half of the sub texture */
@@ -299,18 +308,18 @@ validate_result (TestState *state)
}
void
-test_cogl_sub_texture (TestUtilsGTestFixture *fixture,
- void *data)
+test_sub_texture (void)
{
- TestUtilsSharedState *shared_state = data;
TestState state;
- state.ctx = shared_state->ctx;
state.tex = create_source (&state);
- cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */
- cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */
- -1, 100 /* z near, far */);
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1,
+ 100);
paint (&state);
validate_result (&state);