aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-08-03 18:34:26 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-08-03 18:34:26 +0200
commit43b1ad559e082cfd1d4cb537bf01523b904f3818 (patch)
tree4580831fe287324516f666145692766e97ac8c99
parentc4552c95fcf3a60a92504039cd8ee89ebf63c724 (diff)
downloadtracker.lv2-43b1ad559e082cfd1d4cb537bf01523b904f3818.zip
tracker.lv2-43b1ad559e082cfd1d4cb537bf01523b904f3818.tar.gz
tracker.lv2-43b1ad559e082cfd1d4cb537bf01523b904f3818.tar.bz2
tracker.lv2-43b1ad559e082cfd1d4cb537bf01523b904f3818.tar.xz
Squashed 'subprojects/d2tk/' changes from 5633cfaf..32363715
32363715 add revision property to bitmap primitive. git-subtree-dir: subprojects/d2tk git-subtree-split: 32363715f79b5e06804f6302bc53496344ea5c6d
-rw-r--r--VERSION2
-rw-r--r--d2tk/base.h3
-rw-r--r--d2tk/core.h3
-rw-r--r--example/example.c3
-rw-r--r--src/backend_cairo.c3
-rw-r--r--src/backend_nanovg.c3
-rw-r--r--src/base.c7
-rw-r--r--src/core.c16
-rw-r--r--src/core_internal.h16
-rw-r--r--test/base.c4
-rw-r--r--test/core.c4
11 files changed, 42 insertions, 22 deletions
diff --git a/VERSION b/VERSION
index 7ace64a..d6039d6 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.765
+0.1.767
diff --git a/d2tk/base.h b/d2tk/base.h
index 3ba8d40..76bbf24 100644
--- a/d2tk/base.h
+++ b/d2tk/base.h
@@ -389,7 +389,8 @@ d2tk_base_image(d2tk_base_t *base, ssize_t path_len, const char *path,
D2TK_API void
d2tk_base_bitmap(d2tk_base_t *base, uint32_t w, uint32_t h, uint32_t stride,
- const uint32_t *argb, const d2tk_rect_t *rect, d2tk_align_t align);
+ const uint32_t *argb, uint64_t rev, const d2tk_rect_t *rect,
+ d2tk_align_t align);
D2TK_API void
d2tk_base_custom(d2tk_base_t *base, uint32_t size, const void *data,
diff --git a/d2tk/core.h b/d2tk/core.h
index f3bac84..903118d 100644
--- a/d2tk/core.h
+++ b/d2tk/core.h
@@ -175,7 +175,8 @@ d2tk_core_image(d2tk_core_t *core, const d2tk_rect_t *rect, size_t sz,
D2TK_API void
d2tk_core_bitmap(d2tk_core_t *core, const d2tk_rect_t *rect, uint32_t w,
- uint32_t h, uint32_t stride, const uint32_t *argb, d2tk_align_t align);
+ uint32_t h, uint32_t stride, const uint32_t *argb, uint64_t rev,
+ d2tk_align_t align);
D2TK_API void
d2tk_core_custom(d2tk_core_t *core, const d2tk_rect_t *rect, uint32_t size,
diff --git a/example/example.c b/example/example.c
index 9cce286..be4c257 100644
--- a/example/example.c
+++ b/example/example.c
@@ -223,8 +223,9 @@ _render_c_mix(d2tk_base_t *base, const d2tk_rect_t *rect)
0xffffcf00, 0x7f7f6700,
0x7f7f6700, 0x00000000
};
+ static const uint64_t rev = 0;
- d2tk_base_bitmap(base, 2, 2, 2*sizeof(uint32_t), argb, bnd,
+ d2tk_base_bitmap(base, 2, 2, 2*sizeof(uint32_t), argb, rev, bnd,
D2TK_ALIGN_CENTERED);
} break;
default:
diff --git a/src/backend_cairo.c b/src/backend_cairo.c
index a96d831..0cfadb3 100644
--- a/src/backend_cairo.c
+++ b/src/backend_cairo.c
@@ -694,8 +694,7 @@ d2tk_cairo_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
{
const d2tk_body_bitmap_t *body = &com->body->bitmap;
- const size_t rgba_sz = body->surf.stride * body->surf.h;
- const uint64_t hash = d2tk_hash(body->surf.argb, rgba_sz);
+ const uint64_t hash = d2tk_hash(&body->surf, sizeof(body->surf));
uintptr_t *sprite = d2tk_core_get_sprite(core, hash, SPRITE_TYPE_SURF);
assert(sprite);
diff --git a/src/backend_nanovg.c b/src/backend_nanovg.c
index ad48e16..fe5d377 100644
--- a/src/backend_nanovg.c
+++ b/src/backend_nanovg.c
@@ -742,8 +742,7 @@ d2tk_nanovg_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
{
const d2tk_body_bitmap_t *body = &com->body->bitmap;
- const size_t rgba_sz = body->surf.stride * body->surf.h;
- const uint64_t hash = d2tk_hash(body->surf.argb, rgba_sz);
+ const uint64_t hash = d2tk_hash(&body->surf, sizeof(body->surf));
uintptr_t *sprite = d2tk_core_get_sprite(core, hash, SPRITE_TYPE_IMG);
assert(sprite);
diff --git a/src/base.c b/src/base.c
index 280ce17..3c37398 100644
--- a/src/base.c
+++ b/src/base.c
@@ -1877,13 +1877,14 @@ d2tk_base_image(d2tk_base_t *base, ssize_t path_len, const char *path,
D2TK_API void
d2tk_base_bitmap(d2tk_base_t *base, uint32_t w, uint32_t h, uint32_t stride,
- const uint32_t *argb, const d2tk_rect_t *rect, d2tk_align_t align)
+ const uint32_t *argb, uint64_t rev, const d2tk_rect_t *rect,
+ d2tk_align_t align)
{
const uint64_t hash = d2tk_hash_foreach(rect, sizeof(d2tk_rect_t),
&w, sizeof(uint32_t),
&h, sizeof(uint32_t),
&stride, sizeof(uint32_t),
- argb, stride*h, //FIXME
+ &rev, sizeof(uint64_t),
NULL);
d2tk_core_t *core = base->core;;
@@ -1892,7 +1893,7 @@ d2tk_base_bitmap(d2tk_base_t *base, uint32_t w, uint32_t h, uint32_t stride,
{
const size_t ref = d2tk_core_bbox_push(core, true, rect);
- d2tk_core_bitmap(core, rect, w, h, stride, argb, align);
+ d2tk_core_bitmap(core, rect, w, h, stride, argb, rev, align);
d2tk_core_bbox_pop(core, ref);
}
diff --git a/src/core.c b/src/core.c
index 33506c8..eb2ed97 100644
--- a/src/core.c
+++ b/src/core.c
@@ -381,9 +381,17 @@ _d2tk_bitmap_reset(d2tk_core_t *core)
{
d2tk_bitmap_t *bitmap = &core->bitmap;
- const size_t stride = (bitmap->x1 - bitmap->x0)*sizeof(uint32_t);
+ // x1/y1 may be wrong after window shrink
+ const d2tk_coord_t x1 = bitmap->x1 < core->w
+ ? bitmap->x1
+ : core->w;
+ const d2tk_coord_t y1 = bitmap->y1 < core->h
+ ? bitmap->y1
+ : core->h;
- for(d2tk_coord_t y = bitmap->y0, Y = y*core->w; y < bitmap->y1; y++, Y+=core->w)
+ const size_t stride = (x1 - bitmap->x0)*sizeof(uint32_t);
+
+ for(d2tk_coord_t y = bitmap->y0, Y = y*core->w; y < y1; y++, Y+=core->w)
{
memset(&bitmap->pixels[Y + bitmap->x0], 0x0, stride);
}
@@ -1090,7 +1098,8 @@ d2tk_core_image(d2tk_core_t *core, const d2tk_rect_t *rect, size_t sz,
D2TK_API void
d2tk_core_bitmap(d2tk_core_t *core, const d2tk_rect_t *rect, uint32_t w,
- uint32_t h, uint32_t stride, const uint32_t *argb, d2tk_align_t align)
+ uint32_t h, uint32_t stride, const uint32_t *argb, uint64_t rev,
+ d2tk_align_t align)
{
const size_t len = sizeof(d2tk_body_bitmap_t);
d2tk_body_t *body = _d2tk_append_request(core, len, D2TK_INSTR_BITMAP);
@@ -1106,6 +1115,7 @@ d2tk_core_bitmap(d2tk_core_t *core, const d2tk_rect_t *rect, uint32_t w,
body->bitmap.surf.h = h;
body->bitmap.surf.stride = stride;
body->bitmap.surf.argb = argb;
+ body->bitmap.surf.rev = rev;
body->bitmap.x -= core->ref.x;
body->bitmap.y -= core->ref.y;
diff --git a/src/core_internal.h b/src/core_internal.h
index d875e8b..951c605 100644
--- a/src/core_internal.h
+++ b/src/core_internal.h
@@ -54,6 +54,7 @@ typedef struct _d2tk_body_font_face_t d2tk_body_font_face_t;
typedef struct _d2tk_body_font_size_t d2tk_body_font_size_t;
typedef struct _d2tk_body_text_t d2tk_body_text_t;
typedef struct _d2tk_body_image_t d2tk_body_image_t;
+typedef struct _d2tk_body_bitmap_surf_t d2tk_body_bitmap_surf_t;
typedef struct _d2tk_body_bitmap_t d2tk_body_bitmap_t;
typedef struct _d2tk_body_custom_t d2tk_body_custom_t;
typedef struct _d2tk_body_stroke_width_t d2tk_body_stroke_width_t;
@@ -167,18 +168,21 @@ struct _d2tk_body_image_t {
char path [1]; // at least zero-terminator
};
+struct _d2tk_body_bitmap_surf_t {
+ uint32_t w;
+ uint32_t h;
+ uint32_t stride;
+ const uint32_t *argb;
+ uint64_t rev;
+};
+
struct _d2tk_body_bitmap_t {
d2tk_coord_t x;
d2tk_coord_t y;
d2tk_coord_t w;
d2tk_coord_t h;
d2tk_align_t align;
- struct {
- uint32_t w;
- uint32_t h;
- uint32_t stride;
- const uint32_t *argb;
- } surf;
+ d2tk_body_bitmap_surf_t surf;
};
struct _d2tk_body_custom_t {
diff --git a/test/base.c b/test/base.c
index f470c79..f8701bf 100644
--- a/test/base.c
+++ b/test/base.c
@@ -1419,8 +1419,10 @@ _test_bitmap()
0xff0000ff, 0x00ff001f,
0x0000ff7f, 0xffff003f
};
+ const uint64_t rev = 0;
- d2tk_base_bitmap(base, 2, 2, 2*sizeof(uint32_t), bmp, &rect, D2TK_ALIGN_CENTERED);
+ d2tk_base_bitmap(base, 2, 2, 2*sizeof(uint32_t), bmp, rev, &rect,
+ D2TK_ALIGN_CENTERED);
d2tk_base_free(base);
}
diff --git a/test/core.c b/test/core.c
index 7c5b45a..76c7a3f 100644
--- a/test/core.c
+++ b/test/core.c
@@ -1213,8 +1213,10 @@ _test_bitmap()
}
}
+ const uint64_t rev = 0;
+
d2tk_core_bitmap(core, &D2TK_RECT(BITMAP_X, BITMAP_Y, BITMAP_W, BITMAP_H),
- BITMAP_WIDTH, BITMAP_HEIGHT, BITMAP_STRIDE, surf, BITMAP_ALIGN);
+ BITMAP_WIDTH, BITMAP_HEIGHT, BITMAP_STRIDE, surf, rev, BITMAP_ALIGN);
d2tk_core_bbox_pop(core, ref);
d2tk_core_post(core);