compositor: handle YUV buffers.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
76574d1fb7
commit
28f59b027a
@@ -188,7 +188,7 @@ draw_border(struct wayland_output *output)
|
|||||||
glUniformMatrix4fv(shader->proj_uniform,
|
glUniformMatrix4fv(shader->proj_uniform,
|
||||||
1, GL_FALSE, output->base.matrix.d);
|
1, GL_FALSE, output->base.matrix.d);
|
||||||
|
|
||||||
glUniform1i(shader->tex_uniform, 0);
|
glUniform1i(shader->tex_uniforms[0], 0);
|
||||||
glUniform1f(shader->alpha_uniform, 1);
|
glUniform1f(shader->alpha_uniform, 1);
|
||||||
glUniform1f(shader->texwidth_uniform, 1);
|
glUniform1f(shader->texwidth_uniform, 1);
|
||||||
|
|
||||||
|
|||||||
+61
-17
@@ -728,7 +728,8 @@ weston_surface_attach(struct wl_surface *surface, struct wl_buffer *buffer)
|
|||||||
{
|
{
|
||||||
struct weston_surface *es = (struct weston_surface *) surface;
|
struct weston_surface *es = (struct weston_surface *) surface;
|
||||||
struct weston_compositor *ec = es->compositor;
|
struct weston_compositor *ec = es->compositor;
|
||||||
int i;
|
EGLint attribs[3], components;
|
||||||
|
int i, num_planes;
|
||||||
|
|
||||||
if (es->buffer) {
|
if (es->buffer) {
|
||||||
weston_buffer_post_release(es->buffer);
|
weston_buffer_post_release(es->buffer);
|
||||||
@@ -774,20 +775,56 @@ weston_surface_attach(struct wl_surface *surface, struct wl_buffer *buffer)
|
|||||||
es->blend = 0;
|
es->blend = 0;
|
||||||
else
|
else
|
||||||
es->blend = 1;
|
es->blend = 1;
|
||||||
} else {
|
} else if (ec->query_buffer(ec->egl_display, buffer,
|
||||||
if (es->images[0] != EGL_NO_IMAGE_KHR)
|
EGL_WAYLAND_BUFFER_COMPONENTS_WL,
|
||||||
|
&components)) {
|
||||||
|
for (i = 0; i < es->num_images; i++)
|
||||||
ec->destroy_image(ec->egl_display, es->images[0]);
|
ec->destroy_image(ec->egl_display, es->images[0]);
|
||||||
es->images[0] = ec->create_image(ec->egl_display, NULL,
|
es->num_images = 0;
|
||||||
EGL_WAYLAND_BUFFER_WL,
|
|
||||||
buffer, NULL);
|
|
||||||
es->num_images = 1;
|
|
||||||
|
|
||||||
ensure_textures(es, 1);
|
switch (components) {
|
||||||
glBindTexture(GL_TEXTURE_2D, es->textures[0]);
|
case EGL_WAYLAND_BUFFER_RGB_WL:
|
||||||
ec->image_target_texture_2d(GL_TEXTURE_2D, es->images[0]);
|
case EGL_WAYLAND_BUFFER_RGBA_WL:
|
||||||
|
default:
|
||||||
|
num_planes = 1;
|
||||||
|
es->shader = &ec->texture_shader_rgba;
|
||||||
|
break;
|
||||||
|
case EGL_WAYLAND_BUFFER_Y_UV_WL:
|
||||||
|
num_planes = 2;
|
||||||
|
es->shader = &ec->texture_shader_y_uv;
|
||||||
|
break;
|
||||||
|
case EGL_WAYLAND_BUFFER_Y_U_V_WL:
|
||||||
|
num_planes = 3;
|
||||||
|
es->shader = &ec->texture_shader_y_u_v;
|
||||||
|
break;
|
||||||
|
case EGL_WAYLAND_BUFFER_Y_XUXV_WL:
|
||||||
|
num_planes = 2;
|
||||||
|
es->shader = &ec->texture_shader_y_xuxv;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_textures(es, num_planes);
|
||||||
|
for (i = 0; i < num_planes; i++) {
|
||||||
|
attribs[0] = EGL_WAYLAND_PLANE_WL;
|
||||||
|
attribs[1] = i;
|
||||||
|
attribs[2] = EGL_NONE;
|
||||||
|
es->images[i] = ec->create_image(ec->egl_display,
|
||||||
|
NULL,
|
||||||
|
EGL_WAYLAND_BUFFER_WL,
|
||||||
|
buffer, attribs);
|
||||||
|
if (!es->images[i])
|
||||||
|
continue;
|
||||||
|
es->num_images++;
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0 + i);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, es->textures[i]);
|
||||||
|
ec->image_target_texture_2d(GL_TEXTURE_2D,
|
||||||
|
es->images[i]);
|
||||||
|
}
|
||||||
|
|
||||||
es->pitch = buffer->width;
|
es->pitch = buffer->width;
|
||||||
es->shader = &ec->texture_shader_rgba;
|
} else {
|
||||||
|
/* unhandled buffer type */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,7 +893,7 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output,
|
|||||||
GLfloat *v;
|
GLfloat *v;
|
||||||
pixman_region32_t repaint;
|
pixman_region32_t repaint;
|
||||||
GLint filter;
|
GLint filter;
|
||||||
int n;
|
int i, n;
|
||||||
|
|
||||||
pixman_region32_init(&repaint);
|
pixman_region32_init(&repaint);
|
||||||
pixman_region32_intersect(&repaint,
|
pixman_region32_intersect(&repaint,
|
||||||
@@ -879,7 +916,6 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output,
|
|||||||
|
|
||||||
glUniformMatrix4fv(es->shader->proj_uniform,
|
glUniformMatrix4fv(es->shader->proj_uniform,
|
||||||
1, GL_FALSE, output->matrix.d);
|
1, GL_FALSE, output->matrix.d);
|
||||||
glUniform1i(es->shader->tex_uniform, 0);
|
|
||||||
glUniform4fv(es->shader->color_uniform, 1, es->color);
|
glUniform4fv(es->shader->color_uniform, 1, es->color);
|
||||||
glUniform1f(es->shader->alpha_uniform, es->alpha);
|
glUniform1f(es->shader->alpha_uniform, es->alpha);
|
||||||
glUniform1f(es->shader->texwidth_uniform,
|
glUniform1f(es->shader->texwidth_uniform,
|
||||||
@@ -896,9 +932,13 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output,
|
|||||||
|
|
||||||
n = texture_region(es, &repaint);
|
n = texture_region(es, &repaint);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, es->textures[0]);
|
for (i = 0; i < es->num_textures; i++) {
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
glUniform1i(es->shader->tex_uniforms[i], i);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
glActiveTexture(GL_TEXTURE0 + i);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, es->textures[i]);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||||
|
}
|
||||||
|
|
||||||
v = ec->vertices.data;
|
v = ec->vertices.data;
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]);
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]);
|
||||||
@@ -2898,7 +2938,9 @@ weston_shader_init(struct weston_shader *shader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
shader->proj_uniform = glGetUniformLocation(shader->program, "proj");
|
shader->proj_uniform = glGetUniformLocation(shader->program, "proj");
|
||||||
shader->tex_uniform = glGetUniformLocation(shader->program, "tex");
|
shader->tex_uniforms[0] = glGetUniformLocation(shader->program, "tex");
|
||||||
|
shader->tex_uniforms[1] = glGetUniformLocation(shader->program, "tex1");
|
||||||
|
shader->tex_uniforms[2] = glGetUniformLocation(shader->program, "tex2");
|
||||||
shader->alpha_uniform = glGetUniformLocation(shader->program, "alpha");
|
shader->alpha_uniform = glGetUniformLocation(shader->program, "alpha");
|
||||||
shader->color_uniform = glGetUniformLocation(shader->program, "color");
|
shader->color_uniform = glGetUniformLocation(shader->program, "color");
|
||||||
shader->texwidth_uniform = glGetUniformLocation(shader->program, "texwidth");
|
shader->texwidth_uniform = glGetUniformLocation(shader->program, "texwidth");
|
||||||
@@ -3158,6 +3200,8 @@ weston_compositor_init_gl(struct weston_compositor *ec)
|
|||||||
(void *) eglGetProcAddress("eglBindWaylandDisplayWL");
|
(void *) eglGetProcAddress("eglBindWaylandDisplayWL");
|
||||||
ec->unbind_display =
|
ec->unbind_display =
|
||||||
(void *) eglGetProcAddress("eglUnbindWaylandDisplayWL");
|
(void *) eglGetProcAddress("eglUnbindWaylandDisplayWL");
|
||||||
|
ec->query_buffer =
|
||||||
|
(void *) eglGetProcAddress("eglQueryWaylandBufferWL");
|
||||||
|
|
||||||
extensions = (const char *) glGetString(GL_EXTENSIONS);
|
extensions = (const char *) glGetString(GL_EXTENSIONS);
|
||||||
if (!extensions) {
|
if (!extensions) {
|
||||||
|
|||||||
+2
-1
@@ -244,7 +244,7 @@ struct weston_shader {
|
|||||||
GLuint program;
|
GLuint program;
|
||||||
GLuint vertex_shader, fragment_shader;
|
GLuint vertex_shader, fragment_shader;
|
||||||
GLint proj_uniform;
|
GLint proj_uniform;
|
||||||
GLint tex_uniform;
|
GLint tex_uniforms[3];
|
||||||
GLint alpha_uniform;
|
GLint alpha_uniform;
|
||||||
GLint color_uniform;
|
GLint color_uniform;
|
||||||
GLint texwidth_uniform;
|
GLint texwidth_uniform;
|
||||||
@@ -331,6 +331,7 @@ struct weston_compositor {
|
|||||||
|
|
||||||
PFNEGLBINDWAYLANDDISPLAYWL bind_display;
|
PFNEGLBINDWAYLANDDISPLAYWL bind_display;
|
||||||
PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
|
PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
|
||||||
|
PFNEGLQUERYWAYLANDBUFFERWL query_buffer;
|
||||||
int has_bind_display;
|
int has_bind_display;
|
||||||
|
|
||||||
void (*destroy)(struct weston_compositor *ec);
|
void (*destroy)(struct weston_compositor *ec);
|
||||||
|
|||||||
Reference in New Issue
Block a user