aboutsummaryrefslogtreecommitdiff
path: root/test/core.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-07-18 23:02:40 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-07-18 23:02:40 +0200
commit34dbdfd2fea2c256241e4c829c83ebfe41876b45 (patch)
tree63eadce7fa7dd6312ed11e9699a891c651d1d8b0 /test/core.c
parent6a388b93c2e1da1d724177f8ce9e8cf49524267a (diff)
downloadd2tk-34dbdfd2fea2c256241e4c829c83ebfe41876b45.tar.xz
core: only store bitmap pointer in bitmap's body.
Diffstat (limited to 'test/core.c')
-rw-r--r--test/core.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/test/core.c b/test/core.c
index 7d226f3..36d1f30 100644
--- a/test/core.c
+++ b/test/core.c
@@ -1145,8 +1145,9 @@ _test_image()
#define BITMAP_Y 20
#define BITMAP_W 30
#define BITMAP_H 40
-#define BITMAP_WIDTH 16
-#define BITMAP_HEIGHT 16
+#define BITMAP_WIDTH 24
+#define BITMAP_HEIGHT 24
+#define BITMAP_STRIDE 32*sizeof(uint32_t)
#define BITMAP_ALIGN D2TK_ALIGN_LEFT
static void
@@ -1159,8 +1160,7 @@ _check_bitmap(const d2tk_com_t *com, const d2tk_clip_t *clip)
assert(clip->w == CLIP_W);
assert(clip->h == CLIP_H);
- assert(com->size == sizeof(d2tk_body_bitmap_t)
- + BITMAP_WIDTH*BITMAP_HEIGHT*sizeof(uint32_t));
+ assert(com->size == sizeof(d2tk_body_bitmap_t));
assert(com->instr == D2TK_INSTR_BITMAP);
assert(com->body->bitmap.x == BITMAP_X - CLIP_X);
assert(com->body->bitmap.y == BITMAP_Y - CLIP_Y);
@@ -1169,9 +1169,17 @@ _check_bitmap(const d2tk_com_t *com, const d2tk_clip_t *clip)
assert(com->body->bitmap.align == BITMAP_ALIGN);
assert(com->body->bitmap.surf.w == BITMAP_WIDTH);
assert(com->body->bitmap.surf.h == BITMAP_HEIGHT);
- for(unsigned i = 0; i < BITMAP_WIDTH*BITMAP_HEIGHT; i++)
+ assert(com->body->bitmap.surf.stride == BITMAP_STRIDE);
+ for(unsigned y = 0, o = 0;
+ y < com->body->bitmap.surf.h;
+ y++, o += com->body->bitmap.surf.stride/sizeof(uint32_t))
{
- assert(com->body->bitmap.surf.rgba[i] == 999 - i);
+ for(unsigned x = 0; x < com->body->bitmap.surf.w; x++)
+ {
+ const unsigned idx = o + x;
+
+ assert(com->body->bitmap.surf.rgba[idx] == 999 - idx);
+ }
}
}
@@ -1192,14 +1200,21 @@ _test_bitmap()
&D2TK_RECT(CLIP_X, CLIP_Y, CLIP_W, CLIP_H));
assert(ref >= 0);
- uint32_t surf [BITMAP_WIDTH*BITMAP_HEIGHT];
- for(unsigned i = 0; i < BITMAP_WIDTH*BITMAP_HEIGHT; i++)
+ uint32_t surf [BITMAP_STRIDE/sizeof(uint32_t)*BITMAP_HEIGHT];
+ for(unsigned y = 0, o = 0;
+ y < BITMAP_HEIGHT;
+ y++, o += BITMAP_STRIDE/sizeof(uint32_t))
{
- surf[i] = 999 - i;
+ for(unsigned x = 0; x < BITMAP_WIDTH; x++)
+ {
+ const unsigned idx = o + x;
+
+ surf[idx] = 999 - idx;
+ }
}
d2tk_core_bitmap(core, &D2TK_RECT(BITMAP_X, BITMAP_Y, BITMAP_W, BITMAP_H),
- BITMAP_WIDTH, BITMAP_HEIGHT, surf, BITMAP_ALIGN);
+ BITMAP_WIDTH, BITMAP_HEIGHT, BITMAP_STRIDE, surf, BITMAP_ALIGN);
d2tk_core_bbox_pop(core, ref);
d2tk_core_post(core);
@@ -1212,6 +1227,7 @@ _test_bitmap()
#undef BITMAP_H
#undef BITMAP_WIDTH
#undef BITMAP_HEIGHT
+#undef BITMAP_STRIDE
#undef BITMAP_ALIGN
#define STROKE_WIDTH 2