buffer: Add damage field
parent
21405082a0
commit
0615cd44c6
|
@ -5,6 +5,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <pixman.h>
|
||||
|
||||
struct wl_buffer;
|
||||
struct gbm_bo;
|
||||
|
@ -27,6 +28,8 @@ struct wv_buffer {
|
|||
uint32_t format;
|
||||
bool y_inverted;
|
||||
|
||||
struct pixman_region16 damage;
|
||||
|
||||
/* The following is only applicable to DMABUF */
|
||||
struct gbm_bo* bo;
|
||||
void* bo_map_handle;
|
||||
|
@ -48,6 +51,11 @@ void wv_buffer_destroy(struct wv_buffer* self);
|
|||
int wv_buffer_map(struct wv_buffer* self);
|
||||
void wv_buffer_unmap(struct wv_buffer* self);
|
||||
|
||||
void wv_buffer_damage_rect(struct wv_buffer* self, int x, int y, int width,
|
||||
int height);
|
||||
void wv_buffer_damage_whole(struct wv_buffer* self);
|
||||
void wv_buffer_damage_clear(struct wv_buffer* self);
|
||||
|
||||
struct wv_buffer_pool* wv_buffer_pool_create(enum wv_buffer_type, int width,
|
||||
int height, int stride, uint32_t format);
|
||||
void wv_buffer_pool_destroy(struct wv_buffer_pool* pool);
|
||||
|
|
22
src/buffer.c
22
src/buffer.c
|
@ -7,6 +7,7 @@
|
|||
#include <libdrm/drm_fourcc.h>
|
||||
#include <wayland-client.h>
|
||||
#include <gbm.h>
|
||||
#include <pixman.h>
|
||||
|
||||
#include "linux-dmabuf-unstable-v1.h"
|
||||
#include "shm.h"
|
||||
|
@ -54,6 +55,8 @@ struct wv_buffer* wv_buffer_create_shm(int width,
|
|||
if (!self->wl_buffer)
|
||||
goto shm_failure;
|
||||
|
||||
pixman_region_init(&self->damage);
|
||||
|
||||
close(fd);
|
||||
return self;
|
||||
|
||||
|
@ -149,6 +152,7 @@ static void wv_buffer_destroy_dmabuf(struct wv_buffer* self)
|
|||
|
||||
void wv_buffer_destroy(struct wv_buffer* self)
|
||||
{
|
||||
pixman_region_fini(&self->damage);
|
||||
wv_buffer_unmap(self);
|
||||
|
||||
switch (self->type) {
|
||||
|
@ -214,6 +218,23 @@ void wv_buffer_unmap(struct wv_buffer* self)
|
|||
abort();
|
||||
}
|
||||
|
||||
void wv_buffer_damage_rect(struct wv_buffer* self, int x, int y, int width,
|
||||
int height)
|
||||
{
|
||||
pixman_region_union_rect(&self->damage, &self->damage, x, y, width,
|
||||
height);
|
||||
}
|
||||
|
||||
void wv_buffer_damage_whole(struct wv_buffer* self)
|
||||
{
|
||||
wv_buffer_damage_rect(self, 0, 0, self->width, self->height);
|
||||
}
|
||||
|
||||
void wv_buffer_damage_clear(struct wv_buffer* self)
|
||||
{
|
||||
pixman_region_clear(&self->damage);
|
||||
}
|
||||
|
||||
struct wv_buffer_pool* wv_buffer_pool_create(enum wv_buffer_type type,
|
||||
int width, int height, int stride, uint32_t format)
|
||||
{
|
||||
|
@ -304,6 +325,7 @@ struct wv_buffer* wv_buffer_pool_acquire(struct wv_buffer_pool* pool)
|
|||
void wv_buffer_pool_release(struct wv_buffer_pool* pool,
|
||||
struct wv_buffer* buffer)
|
||||
{
|
||||
wv_buffer_damage_clear(buffer);
|
||||
wv_buffer_unmap(buffer);
|
||||
|
||||
if (wv_buffer_pool_match_buffer(pool, buffer)) {
|
||||
|
|
Loading…
Reference in New Issue