render: Add damage checking shader program

shader-damage
Andri Yngvason 2019-10-28 19:04:00 +00:00
parent a62a9c43fc
commit 36eb48d0ca
1 changed files with 7 additions and 1 deletions

View File

@ -312,6 +312,7 @@ void renderer_destroy(struct renderer* self)
glDeleteProgram(self->dmabuf_shader_program);
glDeleteProgram(self->texture_shader_program);
glDeleteProgram(self->damage_shader_program);
eglMakeCurrent(self->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
eglDestroySurface(self->display, self->surface);
@ -396,6 +397,11 @@ int renderer_init(struct renderer* self, uint32_t width, uint32_t height)
"shaders/texture-fragment.glsl") < 0)
goto shader_failure;
if (gl_compile_shader_program(&self->damage_shader_program,
"shaders/texture-damage-vertex.glsl",
"shaders/texture-damage-fragment.glsl") < 0)
goto shader_failure;
self->width = width;
self->height = height;
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &self->read_format);
@ -554,7 +560,7 @@ void render_check_damage(struct renderer* self, GLenum target, GLuint tex)
for (int y = 0; y < height; ++y)
for (int x = 0; x < width; ++x)
if (buffer[y * width + x])
if (buffer[y * width + x] & 0xff00)
pixman_region_union_rect(damage, damage,
x * 32, y * 32,
32, 32);