summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2018-11-30 15:49:58 +0100
committerWim Taymans <wtaymans@redhat.com>2018-11-30 15:49:58 +0100
commit39078f2abcec18a8906e31b1caa969b15d2ddb74 (patch)
tree9482294df03f75cadfb6603ddd2a6b8db75b3d2d
parent8205486554f949c509519eccc90126ed921ea991 (diff)
meta: use spa_point and spa_rectangle
Change Cursor and Bitmap to what the work branch uses
-rw-r--r--spa/include/spa/buffer/meta.h19
-rw-r--r--spa/include/spa/utils/defs.h13
-rw-r--r--src/examples/video-play.c27
-rw-r--r--src/examples/video-src.c15
4 files changed, 42 insertions, 32 deletions
diff --git a/spa/include/spa/buffer/meta.h b/spa/include/spa/buffer/meta.h
index b58fc11d..553448df 100644
--- a/spa/include/spa/buffer/meta.h
+++ b/spa/include/spa/buffer/meta.h
@@ -36,6 +36,7 @@ extern "C" {
#define SPA_TYPE_META__Header SPA_TYPE_META_BASE "Header"
#define SPA_TYPE_META__VideoCrop SPA_TYPE_META_BASE "VideoCrop"
+#define SPA_TYPE_META__Bitmap SPA_TYPE_META_BASE "Bitmap"
#define SPA_TYPE_META__Cursor SPA_TYPE_META_BASE "Cursor"
/**
@@ -85,24 +86,28 @@ struct spa_meta_control {
uint32_t offset; /**< offset in buffer memory */
};
+#define spa_meta_bitmap_is_valid(m) ((m)->format != 0)
+
/**
* Bitmap information
*/
struct spa_meta_bitmap {
- uint32_t format; /**< bitmap video format */
- uint32_t width, height; /**< width and height of bitmap */
- uint32_t stride; /**< stride of bitmap data */
- uint32_t size; /**< size of bitmap data */
+ uint32_t format; /**< bitmap video format, 0 invalid */
+ struct spa_rectangle size; /**< width and height of bitmap */
+ int32_t stride; /**< stride of bitmap data */
uint32_t offset; /**< offset of bitmap data in this structure */
};
+#define spa_meta_cursor_is_valid(m) ((m)->id != 0)
+
/**
* Cursor information
*/
struct spa_meta_cursor {
- uint32_t id; /**< cursor id, SPA_ID_INVALID for no cursor */
- int32_t x, y; /**< offsets on screen */
- int32_t hotspot_x, hotspot_y; /**< offsets for hotspot in bitmap */
+ uint32_t id; /**< cursor id, 0 for no cursor */
+ uint32_t flags; /**< extra flags */
+ struct spa_point position; /**< position on screen */
+ struct spa_point hotspot; /**< offsets for hotspot in bitmap */
uint32_t bitmap_offset; /**< offset of bitmap meta in this structure */
};
diff --git a/spa/include/spa/utils/defs.h b/spa/include/spa/utils/defs.h
index f955478b..69454cf4 100644
--- a/spa/include/spa/utils/defs.h
+++ b/spa/include/spa/utils/defs.h
@@ -52,12 +52,23 @@ enum spa_direction {
};
#define SPA_RECTANGLE(width,height) (struct spa_rectangle){ width, height }
-
struct spa_rectangle {
uint32_t width;
uint32_t height;
};
+#define SPA_POINT(x,y) (struct spa_point){ x, y }
+struct spa_point {
+ int32_t x;
+ int32_t y;
+};
+
+#define SPA_REGION(x,y,width,height) (struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) }
+struct spa_region {
+ struct spa_point position;
+ struct spa_rectangle size;
+};
+
#define SPA_FRACTION(num,denom) (struct spa_fraction){ num, denom }
struct spa_fraction {
uint32_t num;
diff --git a/src/examples/video-play.c b/src/examples/video-play.c
index a18c1348..7ba9034e 100644
--- a/src/examples/video-play.c
+++ b/src/examples/video-play.c
@@ -125,34 +125,29 @@ on_stream_process(void *_data)
goto done;
}
if ((mc = spa_buffer_find_meta(b, data->t->meta.VideoCrop))) {
- if (data->rect.x != mc->x ||
- data->rect.y != mc->y ||
- data->rect.w != mc->width ||
- data->rect.h != mc->height) {
- data->rect.x = mc->x;
- data->rect.y = mc->y;
- data->rect.w = mc->width;
- data->rect.h = mc->height;
- }
+ data->rect.x = mc->x;
+ data->rect.y = mc->y;
+ data->rect.w = mc->width;
+ data->rect.h = mc->height;
}
if ((mcs = spa_buffer_find_meta(b, data->type.meta_cursor)) &&
- mcs->id != SPA_ID_INVALID) {
+ spa_meta_cursor_is_valid(mcs)) {
struct spa_meta_bitmap *mb;
void *cdata;
int cstride;
- data->cursor_rect.x = mcs->x;
- data->cursor_rect.y = mcs->y;
+ data->cursor_rect.x = mcs->position.x;
+ data->cursor_rect.y = mcs->position.y;
mb = SPA_MEMBER(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
- data->cursor_rect.w = mb->width;
- data->cursor_rect.h = mb->height;
+ data->cursor_rect.w = mb->size.width;
+ data->cursor_rect.h = mb->size.height;
if (data->cursor == NULL) {
data->cursor = SDL_CreateTexture(data->renderer,
id_to_sdl_format(data, mb->format),
SDL_TEXTUREACCESS_STREAMING,
- mb->width, mb->height);
+ mb->size.width, mb->size.height);
SDL_SetTextureBlendMode(data->cursor, SDL_BLENDMODE_BLEND);
}
@@ -166,7 +161,7 @@ on_stream_process(void *_data)
dst = cdata;
ostride = SPA_MIN(cstride, mb->stride);
- for (i = 0; i < mb->height; i++) {
+ for (i = 0; i < mb->size.height; i++) {
memcpy(dst, src, ostride);
dst += cstride;
src += mb->stride;
diff --git a/src/examples/video-src.c b/src/examples/video-src.c
index 23963198..d756ba0e 100644
--- a/src/examples/video-src.c
+++ b/src/examples/video-src.c
@@ -142,25 +142,24 @@ static void on_timeout(void *userdata, uint64_t expirations)
uint32_t *bitmap, color;
mcs->id = 0;
- mcs->x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
- mcs->y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
- mcs->hotspot_x = 0;
- mcs->hotspot_y = 0;
+ mcs->position.x = (sin(data->accumulator) + 1.0) * 160.0 + 80;
+ mcs->position.y = (cos(data->accumulator) + 1.0) * 100.0 + 50;
+ mcs->hotspot.x = 0;
+ mcs->hotspot.y = 0;
mcs->bitmap_offset = sizeof(struct spa_meta_cursor);
mb = SPA_MEMBER(mcs, mcs->bitmap_offset, struct spa_meta_bitmap);
mb->format = data->type.video_format.ARGB;
- mb->width = CURSOR_WIDTH;
- mb->height = CURSOR_HEIGHT;
+ mb->size.width = CURSOR_WIDTH;
+ mb->size.height = CURSOR_HEIGHT;
mb->stride = CURSOR_WIDTH * CURSOR_BPP;
- mb->size = mb->stride * mb->height;
mb->offset = sizeof(struct spa_meta_bitmap);
bitmap = SPA_MEMBER(mb, mb->offset, uint32_t);
color = (cos(data->accumulator) + 1.0) * (1 << 23);
color |= 0xff000000;
- draw_elipse(bitmap, mb->width, mb->height, color);
+ draw_elipse(bitmap, mb->size.width, mb->size.height, color);
}
for (i = 0; i < data->format.size.height; i++) {