Commit 5f4b6916 authored by Laurent Aimar's avatar Laurent Aimar

Cached texture created for subpicture rendering (opengl).

It avoids creating/destroying texture uselessly.
parent 0a5dcfef
...@@ -563,10 +563,9 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, ...@@ -563,10 +563,9 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
} }
#endif #endif
for (int i = 0; i < vgl->region_count; i++) { int last_count = vgl->region_count;
glDeleteTextures(1, &vgl->region[i].texture); gl_region_t *last = vgl->region;
}
free(vgl->region);
vgl->region_count = 0; vgl->region_count = 0;
vgl->region = NULL; vgl->region = NULL;
...@@ -595,6 +594,27 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, ...@@ -595,6 +594,27 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
glr->right = 2.0 * (r->i_x + r->fmt.i_visible_width ) / subpicture->i_original_picture_width - 1.0; glr->right = 2.0 * (r->i_x + r->fmt.i_visible_width ) / subpicture->i_original_picture_width - 1.0;
glr->bottom = -2.0 * (r->i_y + r->fmt.i_visible_height) / subpicture->i_original_picture_height + 1.0; glr->bottom = -2.0 * (r->i_y + r->fmt.i_visible_height) / subpicture->i_original_picture_height + 1.0;
glr->texture = 0;
for (int j = 0; j < last_count; j++) {
if (last[i].texture &&
last[i].width == glr->width &&
last[i].height == glr->height &&
last[i].format == glr->format &&
last[i].type == glr->type) {
glr->texture = last[i].texture;
memset(&last[i], 0, sizeof(last[i]));
break;
}
}
if (glr->texture) {
glBindTexture(GL_TEXTURE_2D, glr->texture);
/* TODO set GL_UNPACK_ALIGNMENT */
glPixelStorei(GL_UNPACK_ROW_LENGTH, r->p_picture->p->i_pitch / r->p_picture->p->i_pixel_pitch);
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, 0, glr->width, glr->height,
glr->format, glr->type, r->p_picture->p->p_pixels);
} else {
glGenTextures(1, &glr->texture); glGenTextures(1, &glr->texture);
glBindTexture(GL_TEXTURE_2D, glr->texture); glBindTexture(GL_TEXTURE_2D, glr->texture);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0);
...@@ -610,6 +630,12 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, ...@@ -610,6 +630,12 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
r->p_picture->p->p_pixels); r->p_picture->p->p_pixels);
} }
} }
}
for (int i = 0; i < last_count; i++) {
if (last[i].texture)
glDeleteTextures(1, &last[i].texture);
}
free(last);
vlc_gl_Unlock(vgl->gl); vlc_gl_Unlock(vgl->gl);
VLC_UNUSED(subpicture); VLC_UNUSED(subpicture);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment