meta: use spa_point and spa_rectangle

Change Cursor and Bitmap to what the work branch uses
This commit is contained in:
Wim Taymans 2018-11-30 15:49:58 +01:00
parent 8205486554
commit 39078f2abc
4 changed files with 42 additions and 32 deletions

View file

@ -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;

View file

@ -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++) {