1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include "yagl_onscreen_buffer.h"
#include "yagl_onscreen_display.h"
#include "yagl_native_display.h"
#include "yagl_native_drawable.h"
#include "yagl_log.h"
#include "yagl_malloc.h"
#include "vigs.h"
#include <string.h>
struct yagl_onscreen_buffer
*yagl_onscreen_buffer_create(struct yagl_onscreen_display *dpy,
struct yagl_native_drawable *native_drawable,
yagl_native_attachment attachment,
uint32_t check_name)
{
int ret;
uint32_t name;
struct vigs_drm_surface *drm_sfc;
struct yagl_onscreen_buffer *buffer;
YAGL_LOG_FUNC_ENTER(yagl_onscreen_buffer_create,
"dpy = %p, d = %p, attachment = %u, check_name = %u",
native_drawable->dpy->os_dpy,
native_drawable->os_drawable,
attachment,
check_name);
name = native_drawable->get_buffer(native_drawable, attachment);
if (!name) {
YAGL_LOG_FUNC_EXIT(NULL);
return NULL;
}
if (name == check_name) {
YAGL_LOG_FUNC_EXIT(NULL);
return NULL;
}
ret = vigs_drm_surface_open(dpy->drm_dev, name, &drm_sfc);
if (ret != 0) {
YAGL_LOG_ERROR("vigs_drm_surface_open failed for drawable %p: %s",
native_drawable->os_drawable,
strerror(-ret));
YAGL_LOG_FUNC_EXIT(NULL);
return NULL;
}
buffer = yagl_malloc0(sizeof(*buffer));
buffer->name = name;
buffer->drm_sfc = drm_sfc;
YAGL_LOG_FUNC_EXIT(NULL);
return buffer;
}
void yagl_onscreen_buffer_destroy(struct yagl_onscreen_buffer *buffer)
{
vigs_drm_gem_unref(&buffer->drm_sfc->gem);
yagl_free(buffer);
}
|