Use new format codes
This commit is contained in:
@@ -117,7 +117,7 @@ create_shm_buffer(int width, int height, void **data_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
buffer = wl_shm_create_buffer(shm, fd, width, height, stride,
|
buffer = wl_shm_create_buffer(shm, fd, width, height, stride,
|
||||||
WL_SHM_FORMAT_XRGB32);
|
WL_SHM_FORMAT_XRGB8888);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ init_egl(struct display *display)
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const EGLint config_attribs[] = {
|
static const EGLint config_attribs[] = {
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT,
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
EGL_RED_SIZE, 1,
|
EGL_RED_SIZE, 1,
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
@@ -207,10 +207,6 @@ create_surface(struct window *window)
|
|||||||
{
|
{
|
||||||
struct display *display = window->display;
|
struct display *display = window->display;
|
||||||
EGLBoolean ret;
|
EGLBoolean ret;
|
||||||
static const EGLint surface_attribs[] = {
|
|
||||||
EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
window->surface = wl_compositor_create_surface(display->compositor);
|
window->surface = wl_compositor_create_surface(display->compositor);
|
||||||
window->shell_surface = wl_shell_get_shell_surface(display->shell,
|
window->shell_surface = wl_shell_get_shell_surface(display->shell,
|
||||||
@@ -222,8 +218,7 @@ create_surface(struct window *window)
|
|||||||
window->egl_surface =
|
window->egl_surface =
|
||||||
eglCreateWindowSurface(display->egl.dpy,
|
eglCreateWindowSurface(display->egl.dpy,
|
||||||
display->egl.conf,
|
display->egl.conf,
|
||||||
window->native,
|
window->native, NULL);
|
||||||
surface_attribs);
|
|
||||||
|
|
||||||
wl_shell_surface_set_toplevel(window->shell_surface);
|
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ create_window(struct display *display, int width, int height)
|
|||||||
window->surface);
|
window->surface);
|
||||||
window->buffer = create_shm_buffer(display,
|
window->buffer = create_shm_buffer(display,
|
||||||
width, height,
|
width, height,
|
||||||
WL_SHM_FORMAT_XRGB32,
|
WL_SHM_FORMAT_XRGB8888,
|
||||||
&window->shm_data);
|
&window->shm_data);
|
||||||
|
|
||||||
wl_shell_surface_set_toplevel(window->shell_surface);
|
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||||
@@ -213,7 +213,7 @@ create_display(void)
|
|||||||
wl_display_iterate(display->display, WL_DISPLAY_READABLE);
|
wl_display_iterate(display->display, WL_DISPLAY_READABLE);
|
||||||
wl_display_roundtrip(display->display);
|
wl_display_roundtrip(display->display);
|
||||||
|
|
||||||
if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB32))) {
|
if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB8888))) {
|
||||||
fprintf(stderr, "WL_SHM_FORMAT_XRGB32 not available\n");
|
fprintf(stderr, "WL_SHM_FORMAT_XRGB32 not available\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ create_shm_buffer(struct touch *touch)
|
|||||||
touch->buffer =
|
touch->buffer =
|
||||||
wl_shm_create_buffer(touch->shm, fd,
|
wl_shm_create_buffer(touch->shm, fd,
|
||||||
touch->width, touch->height, stride,
|
touch->width, touch->height, stride,
|
||||||
WL_SHM_FORMAT_PREMULTIPLIED_ARGB32);
|
WL_SHM_FORMAT_ARGB8888);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
|
|||||||
{
|
{
|
||||||
struct touch *touch = data;
|
struct touch *touch = data;
|
||||||
|
|
||||||
if (format == WL_SHM_FORMAT_PREMULTIPLIED_ARGB32)
|
if (format == WL_SHM_FORMAT_ARGB8888)
|
||||||
touch->has_argb = 1;
|
touch->has_argb = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-22
@@ -65,7 +65,7 @@ struct display {
|
|||||||
struct wl_data_device_manager *data_device_manager;
|
struct wl_data_device_manager *data_device_manager;
|
||||||
EGLDisplay dpy;
|
EGLDisplay dpy;
|
||||||
EGLConfig rgb_config;
|
EGLConfig rgb_config;
|
||||||
EGLConfig premultiplied_argb_config;
|
EGLConfig argb_config;
|
||||||
EGLContext rgb_ctx;
|
EGLContext rgb_ctx;
|
||||||
EGLContext argb_ctx;
|
EGLContext argb_ctx;
|
||||||
cairo_device_t *rgb_device;
|
cairo_device_t *rgb_device;
|
||||||
@@ -271,14 +271,8 @@ display_create_egl_window_surface(struct display *display,
|
|||||||
cairo_surface_t *cairo_surface;
|
cairo_surface_t *cairo_surface;
|
||||||
struct egl_window_surface_data *data;
|
struct egl_window_surface_data *data;
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
const EGLint *attribs;
|
|
||||||
cairo_device_t *device;
|
cairo_device_t *device;
|
||||||
|
|
||||||
static const EGLint premul_attribs[] = {
|
|
||||||
EGL_ALPHA_FORMAT, EGL_ALPHA_FORMAT_PRE,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
data = malloc(sizeof *data);
|
data = malloc(sizeof *data);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -289,11 +283,9 @@ display_create_egl_window_surface(struct display *display,
|
|||||||
if (flags & SURFACE_OPAQUE) {
|
if (flags & SURFACE_OPAQUE) {
|
||||||
config = display->rgb_config;
|
config = display->rgb_config;
|
||||||
device = display->rgb_device;
|
device = display->rgb_device;
|
||||||
attribs = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
config = display->premultiplied_argb_config;
|
config = display->argb_config;
|
||||||
device = display->argb_device;
|
device = display->argb_device;
|
||||||
attribs = premul_attribs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data->window = wl_egl_window_create(surface,
|
data->window = wl_egl_window_create(surface,
|
||||||
@@ -301,7 +293,7 @@ display_create_egl_window_surface(struct display *display,
|
|||||||
rectangle->height);
|
rectangle->height);
|
||||||
|
|
||||||
data->surf = eglCreateWindowSurface(display->dpy, config,
|
data->surf = eglCreateWindowSurface(display->dpy, config,
|
||||||
data->window, attribs);
|
data->window, NULL);
|
||||||
|
|
||||||
cairo_surface = cairo_gl_surface_create_for_egl(device,
|
cairo_surface = cairo_gl_surface_create_for_egl(device,
|
||||||
data->surf,
|
data->surf,
|
||||||
@@ -549,9 +541,9 @@ display_create_shm_surface(struct display *display,
|
|||||||
data, shm_surface_data_destroy);
|
data, shm_surface_data_destroy);
|
||||||
|
|
||||||
if (flags & SURFACE_OPAQUE)
|
if (flags & SURFACE_OPAQUE)
|
||||||
format = WL_SHM_FORMAT_XRGB32;
|
format = WL_SHM_FORMAT_XRGB8888;
|
||||||
else
|
else
|
||||||
format = WL_SHM_FORMAT_PREMULTIPLIED_ARGB32;
|
format = WL_SHM_FORMAT_ARGB8888;
|
||||||
|
|
||||||
data->data.buffer = wl_shm_create_buffer(display->shm,
|
data->data.buffer = wl_shm_create_buffer(display->shm,
|
||||||
fd,
|
fd,
|
||||||
@@ -2729,10 +2721,8 @@ init_egl(struct display *d)
|
|||||||
EGLint major, minor;
|
EGLint major, minor;
|
||||||
EGLint n;
|
EGLint n;
|
||||||
|
|
||||||
static const EGLint premul_argb_cfg_attribs[] = {
|
static const EGLint argb_cfg_attribs[] = {
|
||||||
EGL_SURFACE_TYPE,
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT,
|
||||||
EGL_WINDOW_BIT | EGL_PIXMAP_BIT |
|
|
||||||
EGL_VG_ALPHA_FORMAT_PRE_BIT,
|
|
||||||
EGL_RED_SIZE, 1,
|
EGL_RED_SIZE, 1,
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
@@ -2764,9 +2754,9 @@ init_egl(struct display *d)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglChooseConfig(d->dpy, premul_argb_cfg_attribs,
|
if (!eglChooseConfig(d->dpy, argb_cfg_attribs,
|
||||||
&d->premultiplied_argb_config, 1, &n) || n != 1) {
|
&d->argb_config, 1, &n) || n != 1) {
|
||||||
fprintf(stderr, "failed to choose premul argb config\n");
|
fprintf(stderr, "failed to choose argb config\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2781,7 +2771,7 @@ init_egl(struct display *d)
|
|||||||
fprintf(stderr, "failed to create context\n");
|
fprintf(stderr, "failed to create context\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
d->argb_ctx = eglCreateContext(d->dpy, d->premultiplied_argb_config,
|
d->argb_ctx = eglCreateContext(d->dpy, d->argb_config,
|
||||||
EGL_NO_CONTEXT, NULL);
|
EGL_NO_CONTEXT, NULL);
|
||||||
if (d->argb_ctx == NULL) {
|
if (d->argb_ctx == NULL) {
|
||||||
fprintf(stderr, "failed to create context\n");
|
fprintf(stderr, "failed to create context\n");
|
||||||
@@ -3027,7 +3017,7 @@ display_get_rgb_egl_config(struct display *d)
|
|||||||
EGLConfig
|
EGLConfig
|
||||||
display_get_argb_egl_config(struct display *d)
|
display_get_argb_egl_config(struct display *d)
|
||||||
{
|
{
|
||||||
return d->premultiplied_argb_config;
|
return d->argb_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_shell *
|
struct wl_shell *
|
||||||
|
|||||||
+4
-12
@@ -417,13 +417,10 @@ weston_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface)
|
|||||||
wl_shm_buffer_get_data(buffer));
|
wl_shm_buffer_get_data(buffer));
|
||||||
|
|
||||||
switch (wl_shm_buffer_get_format(buffer)) {
|
switch (wl_shm_buffer_get_format(buffer)) {
|
||||||
case WL_SHM_FORMAT_ARGB32:
|
case WL_SHM_FORMAT_ARGB8888:
|
||||||
es->visual = WESTON_ARGB_VISUAL;
|
es->visual = WESTON_ARGB_VISUAL;
|
||||||
break;
|
break;
|
||||||
case WL_SHM_FORMAT_PREMULTIPLIED_ARGB32:
|
case WL_SHM_FORMAT_XRGB8888:
|
||||||
es->visual = WESTON_PREMUL_ARGB_VISUAL;
|
|
||||||
break;
|
|
||||||
case WL_SHM_FORMAT_XRGB32:
|
|
||||||
es->visual = WESTON_RGB_VISUAL;
|
es->visual = WESTON_RGB_VISUAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -441,8 +438,7 @@ weston_buffer_attach(struct wl_buffer *buffer, struct wl_surface *surface)
|
|||||||
|
|
||||||
ec->image_target_texture_2d(GL_TEXTURE_2D, es->image);
|
ec->image_target_texture_2d(GL_TEXTURE_2D, es->image);
|
||||||
|
|
||||||
/* FIXME: we need to get the visual from the wl_buffer */
|
es->visual = WESTON_ARGB_VISUAL;
|
||||||
es->visual = WESTON_PREMUL_ARGB_VISUAL;
|
|
||||||
es->pitch = es->width;
|
es->pitch = es->width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,10 +553,6 @@ weston_surface_draw(struct weston_surface *es,
|
|||||||
|
|
||||||
switch (es->visual) {
|
switch (es->visual) {
|
||||||
case WESTON_ARGB_VISUAL:
|
case WESTON_ARGB_VISUAL:
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
break;
|
|
||||||
case WESTON_PREMUL_ARGB_VISUAL:
|
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
break;
|
break;
|
||||||
@@ -690,7 +682,7 @@ fade_output(struct weston_output *output,
|
|||||||
surface.alpha = compositor->current_alpha;
|
surface.alpha = compositor->current_alpha;
|
||||||
|
|
||||||
if (tint <= 1.0)
|
if (tint <= 1.0)
|
||||||
surface.visual = WESTON_PREMUL_ARGB_VISUAL;
|
surface.visual = WESTON_ARGB_VISUAL;
|
||||||
else
|
else
|
||||||
surface.visual = WESTON_RGB_VISUAL;
|
surface.visual = WESTON_RGB_VISUAL;
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ struct weston_input_device {
|
|||||||
enum weston_visual {
|
enum weston_visual {
|
||||||
WESTON_NONE_VISUAL,
|
WESTON_NONE_VISUAL,
|
||||||
WESTON_ARGB_VISUAL,
|
WESTON_ARGB_VISUAL,
|
||||||
WESTON_PREMUL_ARGB_VISUAL,
|
|
||||||
WESTON_RGB_VISUAL
|
WESTON_RGB_VISUAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user