Use texture->pixel_format instead of re-scanning

master
Drew DeVault 7 years ago
parent 4de930542f
commit e2b7712302

@ -43,11 +43,7 @@ static bool gles2_texture_update_pixels(struct wlr_texture_state *texture,
return gles2_texture_upload_pixels(texture, format, stride, return gles2_texture_upload_pixels(texture, format, stride,
width, height, pixels); width, height, pixels);
} }
const struct pixel_format *fmt = gl_format_for_wl_format(format); const struct pixel_format *fmt = texture->pixel_format;
if (!fmt || !fmt->gl_format) {
wlr_log(L_ERROR, "No supported pixel format for this texture");
return false;
}
GL_CALL(glBindTexture(GL_TEXTURE_2D, texture->tex_id)); GL_CALL(glBindTexture(GL_TEXTURE_2D, texture->tex_id));
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride)); GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride));
GL_CALL(glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, x)); GL_CALL(glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, x));
@ -98,11 +94,7 @@ static bool gles2_texture_update_shm(struct wlr_texture_state *texture,
if (texture->wlr_texture->format != format) { if (texture->wlr_texture->format != format) {
return gles2_texture_upload_shm(texture, format, buffer); return gles2_texture_upload_shm(texture, format, buffer);
} }
const struct pixel_format *fmt = gl_format_for_wl_format(format); const struct pixel_format *fmt = texture->pixel_format;
if (!fmt || !fmt->gl_format) {
wlr_log(L_ERROR, "No supported pixel format for this texture");
return false;
}
wl_shm_buffer_begin_access(buffer); wl_shm_buffer_begin_access(buffer);
uint8_t *pixels = wl_shm_buffer_get_data(buffer); uint8_t *pixels = wl_shm_buffer_get_data(buffer);
int pitch = wl_shm_buffer_get_stride(buffer) / (fmt->bpp / 8); int pitch = wl_shm_buffer_get_stride(buffer) / (fmt->bpp / 8);

Loading…
Cancel
Save