diff options
author | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2013-08-22 18:58:32 +0400 |
---|---|---|
committer | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2013-08-22 18:58:32 +0400 |
commit | a05a048e8f9a8eb59463374232e6a4ef59a0036f (patch) | |
tree | d100281a4e22e86418937173e6935faba305aff2 /gbm | |
parent | ccdf3d69b63094036a3165b4e0e1e127cf46a826 (diff) | |
download | emulator-yagl-a05a048e8f9a8eb59463374232e6a4ef59a0036f.tar.gz emulator-yagl-a05a048e8f9a8eb59463374232e6a4ef59a0036f.tar.bz2 emulator-yagl-a05a048e8f9a8eb59463374232e6a4ef59a0036f.zip |
YaGL: EGL_EXT_buffer_age implemented
Change-Id: I284667036114e88ea954a6c965e4eba8bd240f81
Diffstat (limited to 'gbm')
-rw-r--r-- | gbm/yagl_gbm.c | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/gbm/yagl_gbm.c b/gbm/yagl_gbm.c index 39ca11c..3a55ae5 100644 --- a/gbm/yagl_gbm.c +++ b/gbm/yagl_gbm.c @@ -31,6 +31,7 @@ struct yagl_gbm_surface { struct gbm_bo *bo; int locked; + int age; } color_buffers[3], *back, *front; }; @@ -53,10 +54,8 @@ static void gbm_free(void *ptr) free(ptr); } -static struct vigs_drm_surface - *yagl_gbm_surface_acquire_back(struct gbm_surface *sfc) +static int yagl_gbm_surface_ensure_back(struct yagl_gbm_surface *yagl_sfc) { - struct yagl_gbm_surface *yagl_sfc = (struct yagl_gbm_surface*)sfc; int i; if (!yagl_sfc->back) { @@ -71,16 +70,29 @@ static struct vigs_drm_surface } if (!yagl_sfc->back) { - return NULL; + return 0; } if (!yagl_sfc->back->bo) { - yagl_sfc->back->bo = gbm_bo_create(sfc->gbm, sfc->width, - sfc->height, sfc->format, - sfc->flags); + yagl_sfc->back->bo = gbm_bo_create(yagl_sfc->base.gbm, yagl_sfc->base.width, + yagl_sfc->base.height, yagl_sfc->base.format, + yagl_sfc->base.flags); } if (!yagl_sfc->back->bo) { + yagl_sfc->back = NULL; + return 0; + } + + return 1; +} + +static struct vigs_drm_surface + *yagl_gbm_surface_acquire_back(struct gbm_surface *sfc) +{ + struct yagl_gbm_surface *yagl_sfc = (struct yagl_gbm_surface*)sfc; + + if (!yagl_gbm_surface_ensure_back(yagl_sfc)) { return NULL; } @@ -92,10 +104,32 @@ static struct vigs_drm_surface static void yagl_gbm_surface_swap_buffers(struct gbm_surface *sfc) { struct yagl_gbm_surface *yagl_sfc = (struct yagl_gbm_surface*)sfc; + int i; + + for (i = 0; + i < sizeof(yagl_sfc->color_buffers)/sizeof(yagl_sfc->color_buffers[0]); + ++i) { + if (yagl_sfc->color_buffers[i].age > 0) { + ++yagl_sfc->color_buffers[i].age; + } + } + yagl_sfc->front = yagl_sfc->back; + yagl_sfc->front->age = 1; yagl_sfc->back = NULL; } +static int yagl_gbm_surface_get_buffer_age(struct gbm_surface *sfc) +{ + struct yagl_gbm_surface *yagl_sfc = (struct yagl_gbm_surface*)sfc; + + if (!yagl_gbm_surface_ensure_back(yagl_sfc)) { + return 0; + } + + return yagl_sfc->back->age; +} + YAGL_API int gbm_device_get_fd(struct gbm_device *gbm) { return gbm->drm_dev->fd; @@ -390,6 +424,7 @@ YAGL_API struct gbm_surface *gbm_surface_create(struct gbm_device *gbm, sfc->base.acquire_back = &yagl_gbm_surface_acquire_back; sfc->base.swap_buffers = &yagl_gbm_surface_swap_buffers; + sfc->base.get_buffer_age = &yagl_gbm_surface_get_buffer_age; return &sfc->base; } |