obj-y += yagl_egl_offscreen_surface.o
obj-y += yagl_egl_offscreen_image.o
# EGL onscreen backend
-#obj-y += yagl_egl_onscreen.o
-#obj-y += yagl_egl_onscreen_ts.o
-#obj-y += yagl_egl_onscreen_display.o
-#obj-y += yagl_egl_onscreen_context.o
-#obj-y += yagl_egl_onscreen_surface.o
-#obj-y += yagl_egl_onscreen_image.o
+obj-y += yagl_egl_onscreen.o
+obj-y += yagl_egl_onscreen_ts.o
+obj-y += yagl_egl_onscreen_display.o
+obj-y += yagl_egl_onscreen_context.o
+obj-y += yagl_egl_onscreen_surface.o
+obj-y += yagl_egl_onscreen_image.o
# EGL GLX driver
ifdef CONFIG_LINUX
obj-y += yagl_egl_glx.o
# GLESv2 OpenGL driver
obj-y += yagl_gles2_ogl.o
# GLES onscreen common driver
-#obj-y += yagl_gles_onscreen.o
+obj-y += yagl_gles_onscreen.o
# GLESv1_CM onscreen driver
-#obj-y += yagl_gles1_onscreen.o
+obj-y += yagl_gles1_onscreen.o
# GLESv2 onscreen driver
-#obj-y += yagl_gles2_onscreen.o
+obj-y += yagl_gles2_onscreen.o
endif
*/
/*
- * Texture that represent this surface's front buffer.
+ * Texture that represent this surface.
* Used as color attachment in 'fb'.
*
* Allocated on first access.
*/
- GLuint front_tex;
-
- /*
- * Texture that represents this surface's back buffer, only used by
- * winsys_gl clients. Switched with 'front_tex' on 'swap_buffers'.
- *
- * Allocated on first access.
- */
- GLuint back_tex;
+ GLuint tex;
};
struct vigs_gl_surface
vigs_ref_release(&vigs_sfc->ref);
}
-static GLuint vigs_winsys_gl_surface_get_front_texture(struct winsys_gl_surface *sfc)
-{
- struct vigs_winsys_gl_surface *vigs_sfc = (struct vigs_winsys_gl_surface*)sfc;
- bool has_current = vigs_sfc->backend->has_current(vigs_sfc->backend);
-
- if (!vigs_sfc->front_tex &&
- (has_current ||
- vigs_sfc->backend->make_current(vigs_sfc->backend, true))) {
-
- vigs_winsys_gl_surface_create_texture(vigs_sfc,
- &vigs_sfc->front_tex);
-
- if (!has_current) {
- vigs_sfc->backend->make_current(vigs_sfc->backend, false);
- }
- }
-
- return vigs_sfc->front_tex;
-}
-
-static GLuint vigs_winsys_gl_surface_get_back_texture(struct winsys_gl_surface *sfc)
+static GLuint vigs_winsys_gl_surface_get_texture(struct winsys_gl_surface *sfc)
{
struct vigs_winsys_gl_surface *vigs_sfc = (struct vigs_winsys_gl_surface*)sfc;
bool has_current = vigs_sfc->backend->has_current(vigs_sfc->backend);
- if (!vigs_sfc->back_tex &&
+ if (!vigs_sfc->tex &&
(has_current ||
vigs_sfc->backend->make_current(vigs_sfc->backend, true))) {
vigs_winsys_gl_surface_create_texture(vigs_sfc,
- &vigs_sfc->back_tex);
+ &vigs_sfc->tex);
if (!has_current) {
vigs_sfc->backend->make_current(vigs_sfc->backend, false);
}
}
- return vigs_sfc->back_tex;
+ return vigs_sfc->tex;
}
static void vigs_winsys_gl_surface_destroy(struct vigs_ref *ref)
if (has_current ||
vigs_sfc->backend->make_current(vigs_sfc->backend, true)) {
- if (vigs_sfc->front_tex) {
- vigs_sfc->backend->DeleteTextures(1, &vigs_sfc->front_tex);
- }
- if (vigs_sfc->back_tex) {
- vigs_sfc->backend->DeleteTextures(1, &vigs_sfc->back_tex);
+ if (vigs_sfc->tex) {
+ vigs_sfc->backend->DeleteTextures(1, &vigs_sfc->tex);
}
if (!has_current) {
ws_sfc->base.base.height = height;
ws_sfc->base.base.acquire = &vigs_winsys_gl_surface_acquire;
ws_sfc->base.base.release = &vigs_winsys_gl_surface_release;
- ws_sfc->base.get_front_texture = &vigs_winsys_gl_surface_get_front_texture;
- ws_sfc->base.get_back_texture = &vigs_winsys_gl_surface_get_back_texture;
+ ws_sfc->base.get_texture = &vigs_winsys_gl_surface_get_texture;
ws_sfc->tex_internalformat = tex_internalformat;
ws_sfc->tex_format = tex_format;
ws_sfc->tex_type = tex_type;
return;
}
- if (!ws_sfc->front_tex) {
+ if (!ws_sfc->tex) {
VIGS_LOG_TRACE("skipping blank read");
goto out;
}
- if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->front_tex)) {
+ if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->tex)) {
goto out;
}
gl_backend->EnableClientState(GL_VERTEX_ARRAY);
gl_backend->EnableClientState(GL_TEXTURE_COORD_ARRAY);
- gl_backend->BindTexture(GL_TEXTURE_2D, ws_sfc->front_tex);
+ gl_backend->BindTexture(GL_TEXTURE_2D, ws_sfc->tex);
gl_backend->Color4f(1.0f, 1.0f, 1.0f, 1.0f);
return;
}
- if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->front_tex)) {
+ if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->tex)) {
goto out;
}
gl_backend->Disable(GL_TEXTURE_2D);
gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, ws_sfc->front_tex, 0);
+ GL_TEXTURE_2D, ws_sfc->tex, 0);
gl_backend->PixelZoom(1.0f, -1.0f);
gl_backend->RasterPos2f(x, ws_sfc->base.base.height - y);
return;
}
- if (!vigs_winsys_gl_surface_create_texture(ws_dst, &ws_dst->front_tex)) {
+ if (!vigs_winsys_gl_surface_create_texture(ws_dst, &ws_dst->tex)) {
goto out;
}
- if (!ws_src->front_tex) {
+ if (!ws_src->tex) {
VIGS_LOG_WARN("copying garbage ???");
}
- if (!vigs_winsys_gl_surface_create_texture(ws_src, &ws_src->front_tex)) {
+ if (!vigs_winsys_gl_surface_create_texture(ws_src, &ws_src->tex)) {
goto out;
}
*/
gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, ws_dst->front_tex, 0);
+ GL_TEXTURE_2D, ws_dst->tex, 0);
}
gl_backend->EnableClientState(GL_VERTEX_ARRAY);
gl_backend->EnableClientState(GL_TEXTURE_COORD_ARRAY);
- gl_backend->BindTexture(GL_TEXTURE_2D, ws_src->front_tex);
+ gl_backend->BindTexture(GL_TEXTURE_2D, ws_src->tex);
gl_backend->Color4f(1.0f, 1.0f, 1.0f, 1.0f);
tex_coords[7] = 0;
gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, ws_dst->front_tex, 0);
+ GL_TEXTURE_2D, ws_dst->tex, 0);
gl_backend->BindTexture(GL_TEXTURE_2D, gl_dst->tmp_tex);
return;
}
- if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->front_tex)) {
+ if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->tex)) {
goto out;
}
gl_backend->Disable(GL_TEXTURE_2D);
gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, ws_sfc->front_tex, 0);
+ GL_TEXTURE_2D, ws_sfc->tex, 0);
vigs_vector_resize(&gl_backend->v1, 0);
{
struct winsys_surface base;
- GLuint (*get_front_texture)(struct winsys_gl_surface */*sfc*/);
- GLuint (*get_back_texture)(struct winsys_gl_surface */*sfc*/);
+ GLuint (*get_texture)(struct winsys_gl_surface */*sfc*/);
};
struct winsys_gl_info
void (*thread_init)(struct yagl_api_ps */*api_ps*/);
- void (*pre_batch)(struct yagl_api_ps */*api_ps*/);
-
yagl_api_func (*get_func)(struct yagl_api_ps */*api_ps*/,
uint32_t /*func_id*/);
{
yagl_host_handle dpy = yagl_marshal_get_host_handle(out_buff);
yagl_host_handle surface = yagl_marshal_get_host_handle(out_buff);
- yagl_winsys_id target = yagl_marshal_get_yagl_winsys_id(out_buff);
- YAGL_LOG_FUNC_ENTER_SPLIT3(eglCopyBuffers, yagl_host_handle, yagl_host_handle, yagl_winsys_id, dpy, surface, target);
+ YAGL_LOG_FUNC_ENTER_SPLIT2(eglCopyBuffers, yagl_host_handle, yagl_host_handle, dpy, surface);
EGLBoolean retval;
- bool res = yagl_host_eglCopyBuffers(&retval, dpy, surface, target);
+ bool res = yagl_host_eglCopyBuffers(&retval, dpy, surface);
if (!res) {
YAGL_LOG_FUNC_EXIT(NULL);
return false;
{
yagl_host_handle dpy = yagl_marshal_get_host_handle(out_buff);
yagl_host_handle config = yagl_marshal_get_host_handle(out_buff);
+ yagl_winsys_id buffer = yagl_marshal_get_yagl_winsys_id(out_buff);
target_ulong attrib_list = yagl_marshal_get_ptr(out_buff);
- YAGL_LOG_FUNC_ENTER_SPLIT3(eglCreatePbufferSurfaceOnscreenYAGL, yagl_host_handle, yagl_host_handle, target_ulong, dpy, config, attrib_list);
+ YAGL_LOG_FUNC_ENTER_SPLIT4(eglCreatePbufferSurfaceOnscreenYAGL, yagl_host_handle, yagl_host_handle, yagl_winsys_id, target_ulong, dpy, config, buffer, attrib_list);
yagl_host_handle retval;
- bool res = yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(&retval, dpy, config, attrib_list);
+ bool res = yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(&retval, dpy, config, buffer, attrib_list);
if (!res) {
YAGL_LOG_FUNC_EXIT(NULL);
return false;
return true;
}
-const uint32_t yagl_egl_api_num_funcs = 34;
+/*
+ * eglInvalidateOnscreenSurfaceYAGL dispatcher. id = 35
+ */
+static bool yagl_func_eglInvalidateOnscreenSurfaceYAGL(uint8_t **out_buff,
+ uint8_t *in_buff)
+{
+ yagl_host_handle dpy = yagl_marshal_get_host_handle(out_buff);
+ yagl_host_handle surface = yagl_marshal_get_host_handle(out_buff);
+ yagl_winsys_id buffer = yagl_marshal_get_yagl_winsys_id(out_buff);
+ YAGL_LOG_FUNC_ENTER_SPLIT3(eglInvalidateOnscreenSurfaceYAGL, yagl_host_handle, yagl_host_handle, yagl_winsys_id, dpy, surface, buffer);
+ bool res = yagl_host_eglInvalidateOnscreenSurfaceYAGL(dpy, surface, buffer);
+ YAGL_LOG_FUNC_EXIT(NULL);
+ return res;
+}
+
+const uint32_t yagl_egl_api_num_funcs = 35;
yagl_api_func yagl_egl_api_funcs[] = {
&yagl_func_eglGetError,
&yagl_func_eglUpdateOffscreenImageYAGL,
&yagl_func_eglCreateWindowSurfaceOnscreenYAGL,
&yagl_func_eglCreatePbufferSurfaceOnscreenYAGL,
- &yagl_func_eglCreatePixmapSurfaceOnscreenYAGL
+ &yagl_func_eglCreatePixmapSurfaceOnscreenYAGL,
+ &yagl_func_eglInvalidateOnscreenSurfaceYAGL
};
return true;
}
-static void yagl_host_egl_pre_batch(struct yagl_api_ps *api_ps)
-{
- struct yagl_egl_api_ps *egl_api_ps = (struct yagl_egl_api_ps*)api_ps;
-
- egl_api_ps->backend->pre_batch(egl_api_ps->backend);
-}
-
static yagl_api_func yagl_host_egl_get_func(struct yagl_api_ps *api_ps,
uint32_t func_id)
{
yagl_api_ps_init(&egl_api_ps->base, api);
egl_api_ps->base.thread_init = &yagl_host_egl_thread_init;
- egl_api_ps->base.pre_batch = &yagl_host_egl_pre_batch;
egl_api_ps->base.get_func = &yagl_host_egl_get_func;
egl_api_ps->base.thread_fini = &yagl_host_egl_thread_fini;
egl_api_ps->base.fini = &yagl_host_egl_process_fini;
bool yagl_host_eglCopyBuffers(EGLBoolean* retval,
yagl_host_handle dpy_,
- yagl_host_handle surface_,
- yagl_winsys_id target)
+ yagl_host_handle surface_)
{
struct yagl_egl_display *dpy = NULL;
struct yagl_egl_surface *surface = NULL;
goto out;
}
- if (!surface->backend_sfc->copy_buffers(surface->backend_sfc, target)) {
+ if (!surface->backend_sfc->copy_buffers(surface->backend_sfc)) {
YAGL_SET_ERR(EGL_BAD_NATIVE_PIXMAP);
goto out;
}
bool yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(yagl_host_handle* retval,
yagl_host_handle dpy_,
yagl_host_handle config_,
+ yagl_winsys_id buffer,
target_ulong /* const EGLint* */ attrib_list_)
{
bool res = true;
EGLint *attrib_list = NULL;
struct yagl_eglb_surface *backend_sfc = NULL;
struct yagl_egl_pbuffer_attribs attribs;
- uint32_t width = 0;
- uint32_t height = 0;
struct yagl_egl_display *dpy = NULL;
struct yagl_egl_config *config = NULL;
struct yagl_egl_surface *surface = NULL;
}
break;
case EGL_HEIGHT:
- height = attrib_list[i + 1];
- break;
case EGL_WIDTH:
- width = attrib_list[i + 1];
break;
default:
YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
backend_sfc = dpy->backend_dpy->create_onscreen_pbuffer_surface(dpy->backend_dpy,
&config->native,
&attribs,
- width,
- height);
+ buffer);
if (!backend_sfc) {
YAGL_SET_ERR(EGL_BAD_ALLOC);
return res;
}
+
+bool yagl_host_eglInvalidateOnscreenSurfaceYAGL(yagl_host_handle dpy_,
+ yagl_host_handle surface_,
+ yagl_winsys_id buffer)
+{
+ struct yagl_egl_display *dpy = NULL;
+ struct yagl_egl_surface *surface = NULL;
+
+ if (!yagl_validate_display(dpy_, &dpy)) {
+ goto out;
+ }
+
+ if (!yagl_validate_surface(dpy, surface_, &surface)) {
+ goto out;
+ }
+
+ surface->backend_sfc->invalidate(surface->backend_sfc, buffer);
+
+out:
+ yagl_egl_surface_release(surface);
+
+ return true;
+}
yagl_host_handle surface_);
bool yagl_host_eglCopyBuffers(EGLBoolean* retval,
yagl_host_handle dpy_,
- yagl_host_handle surface_,
- yagl_winsys_id target);
+ yagl_host_handle surface_);
bool yagl_host_eglCreateImageKHR(yagl_host_handle* retval,
yagl_host_handle dpy_,
yagl_host_handle ctx,
bool yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(yagl_host_handle* retval,
yagl_host_handle dpy_,
yagl_host_handle config_,
+ yagl_winsys_id buffer,
target_ulong /* const EGLint* */ attrib_list_);
bool yagl_host_eglCreatePixmapSurfaceOnscreenYAGL(yagl_host_handle* retval,
yagl_host_handle dpy_,
yagl_host_handle config_,
yagl_winsys_id pixmap,
target_ulong /* const EGLint* */ attrib_list_);
+bool yagl_host_eglInvalidateOnscreenSurfaceYAGL(yagl_host_handle dpy_,
+ yagl_host_handle surface_,
+ yagl_winsys_id buffer);
#endif
YAGL_LOG_FUNC_EXIT(NULL);
}
-static void yagl_host_gles1_pre_batch(struct yagl_api_ps *api_ps)
-{
-}
-
static void yagl_host_gles1_thread_fini(struct yagl_api_ps *api_ps)
{
YAGL_LOG_FUNC_ENTER(yagl_host_gles1_thread_fini, NULL);
yagl_api_ps_init(&gles1_api_ps->base, api);
gles1_api_ps->base.thread_init = &yagl_host_gles1_thread_init;
- gles1_api_ps->base.pre_batch = &yagl_host_gles1_pre_batch;
gles1_api_ps->base.get_func = &yagl_host_gles1_get_func;
gles1_api_ps->base.thread_fini = &yagl_host_gles1_thread_fini;
gles1_api_ps->base.fini = &yagl_host_gles1_process_fini;
return image ? &image->base : NULL;
}
-static void yagl_host_gles2_pre_batch(struct yagl_api_ps *api_ps)
-{
-}
-
static yagl_api_func yagl_host_gles2_get_func(struct yagl_api_ps *api_ps,
uint32_t func_id)
{
yagl_api_ps_init(&gles2_api_ps->base, api);
gles2_api_ps->base.thread_init = &yagl_host_gles2_thread_init;
- gles2_api_ps->base.pre_batch = &yagl_host_gles2_pre_batch;
gles2_api_ps->base.get_func = &yagl_host_gles2_get_func;
gles2_api_ps->base.thread_fini = &yagl_host_gles2_thread_fini;
gles2_api_ps->base.fini = &yagl_host_gles2_process_fini;
YAGL_LOG_FUNC_EXIT(NULL);
}
-static void yagl_egl_offscreen_pre_batch(struct yagl_egl_backend *backend)
-{
-}
-
static struct yagl_eglb_display *yagl_egl_offscreen_create_display(struct yagl_egl_backend *backend)
{
struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend;
}
egl_offscreen->base.thread_init = &yagl_egl_offscreen_thread_init;
- egl_offscreen->base.pre_batch = &yagl_egl_offscreen_pre_batch;
egl_offscreen->base.create_display = &yagl_egl_offscreen_create_display;
egl_offscreen->base.make_current = &yagl_egl_offscreen_make_current;
egl_offscreen->base.release_current = &yagl_egl_offscreen_release_current;
osfc->bimage_ct = NULL;
}
+static void yagl_egl_offscreen_surface_invalidate(struct yagl_eglb_surface *sfc,
+ yagl_winsys_id id)
+{
+}
+
static void yagl_egl_offscreen_surface_replace(struct yagl_eglb_surface *sfc,
struct yagl_eglb_surface *with)
{
return true;
}
-static bool yagl_egl_offscreen_surface_copy_buffers(struct yagl_eglb_surface *sfc,
- yagl_winsys_id target)
+static bool yagl_egl_offscreen_surface_copy_buffers(struct yagl_eglb_surface *sfc)
{
struct yagl_egl_offscreen_surface *osfc =
(struct yagl_egl_offscreen_surface*)sfc;
memcpy(&sfc->native_sfc_attribs, &pbuffer_attribs, sizeof(pbuffer_attribs));
sfc->base.reset = &yagl_egl_offscreen_surface_reset;
+ sfc->base.invalidate = &yagl_egl_offscreen_surface_invalidate;
sfc->base.replace = &yagl_egl_offscreen_surface_replace;
sfc->base.query = &yagl_egl_offscreen_surface_query;
sfc->base.swap_buffers = &yagl_egl_offscreen_surface_swap_buffers;
YAGL_LOG_FUNC_EXIT(NULL);
}
-static void yagl_egl_onscreen_pre_batch(struct yagl_egl_backend *backend)
-{
- struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend;
-
- if (!egl_onscreen_ts->dpy) {
- return;
- }
-
- if (egl_onscreen_ts->sfc_draw->needs_update) {
- yagl_egl_onscreen_setup_framebuffer_zero(egl_onscreen);
- }
-}
-
static struct yagl_eglb_display *yagl_egl_onscreen_create_display(struct yagl_egl_backend *backend)
{
struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend;
}
egl_onscreen->base.thread_init = &yagl_egl_onscreen_thread_init;
- egl_onscreen->base.pre_batch = &yagl_egl_onscreen_pre_batch;
egl_onscreen->base.create_display = &yagl_egl_onscreen_create_display;
egl_onscreen->base.make_current = &yagl_egl_onscreen_make_current;
egl_onscreen->base.release_current = &yagl_egl_onscreen_release_current;
*yagl_egl_onscreen_display_create_pbuffer_surface(struct yagl_eglb_display *dpy,
const struct yagl_egl_native_config *cfg,
const struct yagl_egl_pbuffer_attribs *attribs,
- uint32_t width,
- uint32_t height)
+ yagl_winsys_id id)
{
struct yagl_egl_onscreen_display *egl_onscreen_dpy =
(struct yagl_egl_onscreen_display*)dpy;
yagl_egl_onscreen_surface_create_pbuffer(egl_onscreen_dpy,
cfg,
attribs,
- width,
- height);
+ id);
return sfc ? &sfc->base : NULL;
}
{
struct yagl_egl_onscreen *egl_onscreen =
(struct yagl_egl_onscreen*)dpy->base.backend;
- struct winsys_resource *ws_res = NULL;
struct winsys_gl_surface *ws_sfc = NULL;
struct yagl_client_interface *client_iface = NULL;
struct yagl_egl_onscreen_image_data *image_data = NULL;
goto out;
}
- ws_res = egl_onscreen->wsi->acquire_resource(egl_onscreen->wsi, buffer);
-
- if (!ws_res) {
- goto out;
- }
-
- if (ws_res->type != winsys_res_type_pixmap) {
- goto out;
- }
-
- ws_sfc = (struct winsys_gl_surface*)ws_res->acquire_surface(ws_res);
+ ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, buffer);
if (!ws_sfc) {
goto out;
yagl_ref_init(&image_data->ref, &yagl_egl_onscreen_image_data_destroy);
glegl_image = client_iface->create_image(client_iface,
- ws_sfc->get_front_texture(ws_sfc),
+ ws_sfc->get_texture(ws_sfc),
&image_data->ref);
if (!glegl_image) {
ws_sfc->base.release(&ws_sfc->base);
}
- if (ws_res) {
- ws_res->release(ws_res);
- }
-
YAGL_LOG_FUNC_EXIT(NULL);
return image;
{
}
+static void yagl_egl_onscreen_surface_invalidate(struct yagl_eglb_surface *sfc,
+ yagl_winsys_id id)
+{
+ struct yagl_egl_onscreen_surface *osfc =
+ (struct yagl_egl_onscreen_surface*)sfc;
+ struct yagl_egl_onscreen *egl_onscreen =
+ (struct yagl_egl_onscreen*)sfc->dpy->backend;
+ struct winsys_gl_surface *ws_sfc = NULL;
+
+ YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_invalidate, NULL);
+
+ ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, id);
+
+ if (!ws_sfc) {
+ YAGL_LOG_WARN("winsys surface 0x%X not found", id);
+ YAGL_LOG_FUNC_EXIT(NULL);
+ return;
+ }
+
+ if (ws_sfc == osfc->ws_sfc) {
+ ws_sfc->base.release(&ws_sfc->base);
+ YAGL_LOG_FUNC_EXIT(NULL);
+ return;
+ }
+
+ YAGL_LOG_DEBUG("winsys surface changed to 0x%X", id);
+
+ if (osfc->rb) {
+ egl_onscreen->gles_driver->DeleteRenderbuffers(1, &osfc->rb);
+ osfc->rb = 0;
+ }
+
+ osfc->ws_sfc->base.release(&osfc->ws_sfc->base);
+ osfc->ws_sfc = ws_sfc;
+
+ if (egl_onscreen_ts->sfc_draw == osfc) {
+ yagl_egl_onscreen_surface_setup(osfc);
+ yagl_egl_onscreen_surface_attach_to_framebuffer(osfc);
+ }
+
+ YAGL_LOG_FUNC_EXIT(NULL);
+}
+
static bool yagl_egl_onscreen_surface_query(struct yagl_eglb_surface *sfc,
EGLint attribute,
EGLint *value)
static bool yagl_egl_onscreen_surface_swap_buffers(struct yagl_eglb_surface *sfc)
{
- struct yagl_egl_onscreen_surface *osfc =
- (struct yagl_egl_onscreen_surface*)sfc;
struct yagl_egl_onscreen *egl_onscreen =
(struct yagl_egl_onscreen*)sfc->dpy->backend;
- GLuint cur_fb = 0;
-
- egl_onscreen->gles_driver->GetIntegerv(GL_FRAMEBUFFER_BINDING,
- (GLint*)&cur_fb);
- egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER,
- egl_onscreen_ts->ctx->fb);
-
- osfc->ws_sfc->swap_buffers(osfc->ws_sfc);
-
- egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER, cur_fb);
+ egl_onscreen->gles_driver->Finish();
return true;
}
-static bool yagl_egl_onscreen_surface_copy_buffers(struct yagl_eglb_surface *sfc,
- yagl_winsys_id target)
+static bool yagl_egl_onscreen_surface_copy_buffers(struct yagl_eglb_surface *sfc)
{
- struct yagl_egl_onscreen_surface *osfc =
- (struct yagl_egl_onscreen_surface*)sfc;
struct yagl_egl_onscreen *egl_onscreen =
(struct yagl_egl_onscreen*)sfc->dpy->backend;
- struct winsys_resource *ws_res = NULL;
- struct winsys_gl_surface *ws_sfc = NULL;
- GLuint cur_fb = 0;
- bool res = false;
-
- ws_res = egl_onscreen->wsi->acquire_resource(egl_onscreen->wsi, target);
-
- if (!ws_res) {
- goto out;
- }
-
- if (ws_res->type != winsys_res_type_pixmap) {
- goto out;
- }
-
- ws_sfc = (struct winsys_gl_surface*)ws_res->acquire_surface(ws_res);
-
- if (!ws_sfc) {
- goto out;
- }
-
- egl_onscreen->gles_driver->GetIntegerv(GL_FRAMEBUFFER_BINDING,
- (GLint*)&cur_fb);
-
- egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER,
- egl_onscreen_ts->ctx->fb);
-
- ws_sfc->copy_buffers(yagl_egl_onscreen_surface_width(osfc),
- yagl_egl_onscreen_surface_height(osfc),
- ws_sfc,
- (ws_sfc == osfc->ws_sfc));
-
- egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER, cur_fb);
-
- res = true;
-
-out:
- if (ws_sfc) {
- ws_sfc->base.release(&ws_sfc->base);
- }
-
- if (ws_res) {
- ws_res->release(ws_res);
- }
-
- return res;
-}
-
-static void yagl_egl_onscreen_surface_update(struct winsys_resource *res,
- void *user_data)
-{
- struct yagl_egl_onscreen_surface *sfc = user_data;
-
- YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_update,
- "id = 0x%X",
- res->id);
- sfc->needs_update = true;
+ egl_onscreen->gles_driver->Finish();
- YAGL_LOG_FUNC_EXIT(NULL);
+ return true;
}
static void yagl_egl_onscreen_surface_destroy(struct yagl_eglb_surface *sfc)
YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_destroy, NULL);
- if (osfc->cookie) {
- osfc->ws_res->remove_callback(osfc->ws_res, osfc->cookie);
- osfc->cookie = NULL;
- }
-
egl_onscreen->egl_driver->pbuffer_surface_destroy(
egl_onscreen->egl_driver,
((struct yagl_egl_onscreen_display*)sfc->dpy)->native_dpy,
osfc->ws_sfc = NULL;
}
- if (osfc->ws_res) {
- osfc->ws_res->release(osfc->ws_res);
- osfc->ws_res = NULL;
- }
-
- if (osfc->pbuffer_tex || osfc->rb) {
+ if (osfc->rb) {
yagl_ensure_ctx();
- egl_onscreen->gles_driver->DeleteTextures(1, &osfc->pbuffer_tex);
egl_onscreen->gles_driver->DeleteRenderbuffers(1, &osfc->rb);
yagl_unensure_ctx();
}
{
struct yagl_egl_onscreen *egl_onscreen =
(struct yagl_egl_onscreen*)dpy->base.backend;
- struct winsys_resource *ws_res = NULL;
struct winsys_gl_surface *ws_sfc = NULL;
struct yagl_egl_onscreen_surface *sfc = NULL;
EGLSurface dummy_native_sfc = EGL_NO_SURFACE;
cfg->config_id,
id);
- ws_res = egl_onscreen->wsi->acquire_resource(egl_onscreen->wsi, id);
-
- if (!ws_res) {
- goto fail;
- }
-
- if (ws_res->type != winsys_res_type_window) {
- goto fail;
- }
-
- ws_sfc = (struct winsys_gl_surface*)ws_res->acquire_surface(ws_res);
+ ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, id);
if (!ws_sfc) {
goto fail;
yagl_eglb_surface_init(&sfc->base, &dpy->base, EGL_WINDOW_BIT, attribs);
sfc->dummy_native_sfc = dummy_native_sfc;
- sfc->ws_res = ws_res;
sfc->ws_sfc = ws_sfc;
sfc->base.reset = &yagl_egl_onscreen_surface_reset;
sfc->base.copy_buffers = &yagl_egl_onscreen_surface_copy_buffers;
sfc->base.destroy = &yagl_egl_onscreen_surface_destroy;
- sfc->cookie = ws_res->add_callback(ws_res,
- &yagl_egl_onscreen_surface_update,
- sfc);
-
YAGL_LOG_FUNC_EXIT(NULL);
return sfc;
ws_sfc->base.release(&ws_sfc->base);
}
- if (ws_res) {
- ws_res->release(ws_res);
- }
-
YAGL_LOG_FUNC_EXIT(NULL);
return NULL;
{
struct yagl_egl_onscreen *egl_onscreen =
(struct yagl_egl_onscreen*)dpy->base.backend;
- struct winsys_resource *ws_res = NULL;
struct winsys_gl_surface *ws_sfc = NULL;
struct yagl_egl_onscreen_surface *sfc = NULL;
EGLSurface dummy_native_sfc = EGL_NO_SURFACE;
cfg->config_id,
id);
- ws_res = egl_onscreen->wsi->acquire_resource(egl_onscreen->wsi, id);
-
- if (!ws_res) {
- goto fail;
- }
-
- if (ws_res->type != winsys_res_type_pixmap) {
- goto fail;
- }
-
- ws_sfc = (struct winsys_gl_surface*)ws_res->acquire_surface(ws_res);
+ ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, id);
if (!ws_sfc) {
goto fail;
yagl_eglb_surface_init(&sfc->base, &dpy->base, EGL_PIXMAP_BIT, attribs);
sfc->dummy_native_sfc = dummy_native_sfc;
- sfc->ws_res = ws_res;
sfc->ws_sfc = ws_sfc;
sfc->base.reset = &yagl_egl_onscreen_surface_reset;
ws_sfc->base.release(&ws_sfc->base);
}
- if (ws_res) {
- ws_res->release(ws_res);
- }
-
YAGL_LOG_FUNC_EXIT(NULL);
return NULL;
*yagl_egl_onscreen_surface_create_pbuffer(struct yagl_egl_onscreen_display *dpy,
const struct yagl_egl_native_config *cfg,
const struct yagl_egl_pbuffer_attribs *attribs,
- uint32_t width,
- uint32_t height)
+ yagl_winsys_id id)
{
struct yagl_egl_onscreen *egl_onscreen =
(struct yagl_egl_onscreen*)dpy->base.backend;
+ struct winsys_gl_surface *ws_sfc = NULL;
struct yagl_egl_onscreen_surface *sfc = NULL;
EGLSurface dummy_native_sfc = EGL_NO_SURFACE;
struct yagl_egl_pbuffer_attribs pbuffer_attribs;
YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_create_pbuffer,
- "dpy = %p, cfg = %d, width = %u, height = %u",
+ "dpy = %p, cfg = %d, id = 0x%X",
dpy,
cfg->config_id,
- width,
- height);
+ id);
+
+ ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, id);
+
+ if (!ws_sfc) {
+ goto fail;
+ }
yagl_egl_pbuffer_attribs_init(&pbuffer_attribs);
yagl_eglb_surface_init(&sfc->base, &dpy->base, EGL_PBUFFER_BIT, attribs);
sfc->dummy_native_sfc = dummy_native_sfc;
- sfc->pbuffer_width = width;
- sfc->pbuffer_height = height;
+ sfc->ws_sfc = ws_sfc;
sfc->base.reset = &yagl_egl_onscreen_surface_reset;
+ sfc->base.invalidate = &yagl_egl_onscreen_surface_invalidate;
sfc->base.query = &yagl_egl_onscreen_surface_query;
sfc->base.swap_buffers = &yagl_egl_onscreen_surface_swap_buffers;
sfc->base.copy_buffers = &yagl_egl_onscreen_surface_copy_buffers;
return sfc;
fail:
+ if (ws_sfc) {
+ ws_sfc->base.release(&ws_sfc->base);
+ }
+
YAGL_LOG_FUNC_EXIT(NULL);
return NULL;
struct yagl_egl_onscreen *egl_onscreen =
(struct yagl_egl_onscreen*)sfc->base.dpy->backend;
GLuint cur_rb = 0;
- GLuint cur_tex = 0;
-
- YAGL_LOG_FUNC_SET(yagl_egl_onscreen_surface_setup);
-
- if (sfc->needs_update) {
- struct winsys_gl_surface *ws_sfc = NULL;
-
- ws_sfc = (struct winsys_gl_surface*)sfc->ws_res->acquire_surface(sfc->ws_res);
-
- if (ws_sfc) {
- if (ws_sfc != sfc->ws_sfc) {
- YAGL_LOG_DEBUG("winsys resource was changed for 0x%X", sfc->ws_res->id);
-
- if (sfc->rb) {
- egl_onscreen->gles_driver->DeleteRenderbuffers(1, &sfc->rb);
- sfc->rb = 0;
- }
-
- sfc->ws_sfc->base.release(&sfc->ws_sfc->base);
- ws_sfc->base.acquire(&ws_sfc->base);
- sfc->ws_sfc = ws_sfc;
- }
-
- ws_sfc->base.release(&ws_sfc->base);
- } else {
- YAGL_LOG_WARN("winsys resource was destroyed for 0x%X", sfc->ws_res->id);
- }
- sfc->needs_update = false;
+ if (sfc->rb) {
+ return;
}
- switch (sfc->base.type) {
- case EGL_PBUFFER_BIT:
- if (!sfc->rb) {
- egl_onscreen->gles_driver->GenRenderbuffers(1, &sfc->rb);
-
- egl_onscreen->gles_driver->GetIntegerv(GL_RENDERBUFFER_BINDING,
- (GLint*)&cur_rb);
-
- egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, sfc->rb);
-
- egl_onscreen->gles_driver->RenderbufferStorage(GL_RENDERBUFFER,
- GL_DEPTH24_STENCIL8,
- sfc->pbuffer_width,
- sfc->pbuffer_height);
-
- egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, cur_rb);
- }
- if (!sfc->pbuffer_tex) {
- egl_onscreen->gles_driver->GenTextures(1, &sfc->pbuffer_tex);
-
- egl_onscreen->gles_driver->GetIntegerv(GL_TEXTURE_BINDING_2D,
- (GLint*)&cur_tex);
-
- egl_onscreen->gles_driver->BindTexture(GL_TEXTURE_2D, sfc->pbuffer_tex);
-
- /*
- * TODO: Use pbuffer attribs to setup texture format
- * correctly.
- */
-
- egl_onscreen->gles_driver->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
- sfc->pbuffer_width,
- sfc->pbuffer_height, 0,
- GL_BGRA, GL_UNSIGNED_INT,
- NULL);
+ egl_onscreen->gles_driver->GenRenderbuffers(1, &sfc->rb);
- egl_onscreen->gles_driver->BindTexture(GL_TEXTURE_2D, cur_tex);
- }
- break;
- case EGL_PIXMAP_BIT:
- case EGL_WINDOW_BIT:
- if (!sfc->rb) {
- egl_onscreen->gles_driver->GenRenderbuffers(1, &sfc->rb);
-
- egl_onscreen->gles_driver->GetIntegerv(GL_RENDERBUFFER_BINDING,
- (GLint*)&cur_rb);
+ egl_onscreen->gles_driver->GetIntegerv(GL_RENDERBUFFER_BINDING,
+ (GLint*)&cur_rb);
- egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, sfc->rb);
+ egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, sfc->rb);
- egl_onscreen->gles_driver->RenderbufferStorage(GL_RENDERBUFFER,
- GL_DEPTH24_STENCIL8,
- sfc->ws_sfc->base.width,
- sfc->ws_sfc->base.height);
+ egl_onscreen->gles_driver->RenderbufferStorage(GL_RENDERBUFFER,
+ GL_DEPTH24_STENCIL8,
+ sfc->ws_sfc->base.width,
+ sfc->ws_sfc->base.height);
- egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, cur_rb);
- }
- break;
- default:
- assert(false);
- break;
- }
+ egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, cur_rb);
}
void yagl_egl_onscreen_surface_attach_to_framebuffer(struct yagl_egl_onscreen_surface *sfc)
struct yagl_egl_onscreen *egl_onscreen =
(struct yagl_egl_onscreen*)sfc->base.dpy->backend;
- switch (sfc->base.type) {
- case EGL_PBUFFER_BIT:
- egl_onscreen->gles_driver->FramebufferTexture2D(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- sfc->pbuffer_tex,
- 0);
- break;
- case EGL_PIXMAP_BIT:
- egl_onscreen->gles_driver->FramebufferTexture2D(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- sfc->ws_sfc->get_front_texture(sfc->ws_sfc),
- 0);
- break;
- case EGL_WINDOW_BIT:
- egl_onscreen->gles_driver->FramebufferTexture2D(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- sfc->ws_sfc->get_back_texture(sfc->ws_sfc),
- 0);
- break;
- default:
- assert(false);
- break;
- }
+ egl_onscreen->gles_driver->FramebufferTexture2D(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ sfc->ws_sfc->get_texture(sfc->ws_sfc),
+ 0);
egl_onscreen->gles_driver->FramebufferRenderbuffer(GL_FRAMEBUFFER,
GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER,
uint32_t yagl_egl_onscreen_surface_width(struct yagl_egl_onscreen_surface *sfc)
{
- switch (sfc->base.type) {
- case EGL_PBUFFER_BIT:
- return sfc->pbuffer_width;
- case EGL_PIXMAP_BIT:
- case EGL_WINDOW_BIT:
- return sfc->ws_res->get_width(sfc->ws_res);
- default:
- assert(false);
- return 0;
- }
+ return sfc->ws_sfc->base.width;
}
uint32_t yagl_egl_onscreen_surface_height(struct yagl_egl_onscreen_surface *sfc)
{
- switch (sfc->base.type) {
- case EGL_PBUFFER_BIT:
- return sfc->pbuffer_height;
- case EGL_PIXMAP_BIT:
- case EGL_WINDOW_BIT:
- return sfc->ws_res->get_height(sfc->ws_res);
- default:
- assert(false);
- return 0;
- }
+ return sfc->ws_sfc->base.height;
}
struct yagl_egl_onscreen_display;
struct yagl_egl_native_config;
-struct winsys_resource;
struct winsys_gl_surface;
struct yagl_egl_onscreen_surface
EGLSurface dummy_native_sfc;
/*
- * winsys resource in case if this is a window or pixmap surface.
- */
- struct winsys_resource *ws_res;
-
- /*
- * winsys surface in case if this is a window or pixmap surface.
+ * winsys surface.
*/
struct winsys_gl_surface *ws_sfc;
/*
- * Callback cookie from ws_res::add_callback.
- */
- void *cookie;
-
- /*
- * pbuffer texture in case if this is a pbuffer surface. Allocated
- * when this surface is made current for the first time.
- */
- GLuint pbuffer_tex;
- uint32_t pbuffer_width;
- uint32_t pbuffer_height;
-
- /*
- * Depth and stencil renderbuffer for 'ws_sfc'/'pbuffer_tex'. Allocated
+ * Depth and stencil renderbuffer for 'ws_sfc'. Allocated
* when this surface is made current for the first time.
*/
GLuint rb;
-
- /*
- * This surface has been changed on target and
- * needs update on host.
- */
- bool needs_update;
};
struct yagl_egl_onscreen_surface
*yagl_egl_onscreen_surface_create_pbuffer(struct yagl_egl_onscreen_display *dpy,
const struct yagl_egl_native_config *cfg,
const struct yagl_egl_pbuffer_attribs *attribs,
- uint32_t width,
- uint32_t height);
+ yagl_winsys_id id);
void yagl_egl_onscreen_surface_setup(struct yagl_egl_onscreen_surface *sfc);
}
if (s->wsi) {
- /*
- * TODO: uncomment.
- */
- /*
egl_backend = yagl_egl_onscreen_create(s->wsi,
egl_driver,
&gles2_driver->base);
gles1_driver = yagl_gles1_onscreen_create(gles1_driver);
- gles2_driver = yagl_gles2_onscreen_create(gles2_driver);*/
+ gles2_driver = yagl_gles2_onscreen_create(gles2_driver);
} else {
egl_backend = yagl_egl_offscreen_create(egl_driver);
}
void (*thread_init)(struct yagl_egl_backend */*backend*/);
- void (*pre_batch)(struct yagl_egl_backend */*backend*/);
-
struct yagl_eglb_display *(*create_display)(struct yagl_egl_backend */*backend*/);
bool (*make_current)(struct yagl_egl_backend */*backend*/,
struct yagl_eglb_surface *(*create_onscreen_pbuffer_surface)(struct yagl_eglb_display */*dpy*/,
const struct yagl_egl_native_config */*cfg*/,
const struct yagl_egl_pbuffer_attribs */*attribs*/,
- uint32_t /*width*/,
- uint32_t /*height*/);
+ yagl_winsys_id /*id*/);
struct yagl_eglb_image *(*create_image)(struct yagl_eglb_display */*dpy*/,
yagl_winsys_id /*buffer*/);
void (*reset)(struct yagl_eglb_surface */*sfc*/);
/*
+ * Surface has been invalidated on target, update it
+ * from 'id'.
+ */
+ void (*invalidate)(struct yagl_eglb_surface */*sfc*/,
+ yagl_winsys_id /*id*/);
+
+ /*
* Replaces 'sfc' with 'with', destroying 'with' afterwards.
* 'sfc' and 'with' must be of same type, but can have
* different formats.
bool (*swap_buffers)(struct yagl_eglb_surface */*sfc*/);
- bool (*copy_buffers)(struct yagl_eglb_surface */*sfc*/,
- yagl_winsys_id /*target*/);
+ bool (*copy_buffers)(struct yagl_eglb_surface */*sfc*/);
void (*destroy)(struct yagl_eglb_surface */*sfc*/);
};
YAGL_LOG_TRACE("batch started");
- for (i = 0; i < YAGL_NUM_APIS; ++i) {
- if (ts->ps->api_states[i]) {
- ts->ps->api_states[i]->pre_batch(ts->ps->api_states[i]);
- }
- }
-
/*
* current_buff is:
* (yagl_api_id) api_id
/*
* Whenever protocol changes be sure to bump this.
*/
-#define YAGL_VERSION 16
+#define YAGL_VERSION 17
#endif