mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-10 04:37:55 +08:00
fix(gles): transpose lv_matrix_t before uploading to shader (#9703)
This commit is contained in:
@@ -348,11 +348,14 @@ void lv_opengles_render(const lv_opengles_render_params_t * params)
|
||||
lv_matrix_scale(&matrix, hor_scale, ver_scale);
|
||||
}
|
||||
|
||||
lv_matrix_t gl_matrix;
|
||||
lv_matrix_transpose(&matrix, &gl_matrix);
|
||||
|
||||
lv_opengles_shader_bind();
|
||||
lv_opengles_enable_blending(params->blend_opt);
|
||||
lv_opengles_shader_set_uniform1f("u_ColorDepth", LV_COLOR_DEPTH);
|
||||
lv_opengles_shader_set_uniform1i("u_Texture", 0);
|
||||
lv_opengles_shader_set_uniformmatrix3fv("u_VertexTransform", 1, (const float *)&matrix);
|
||||
lv_opengles_shader_set_uniformmatrix3fv("u_VertexTransform", 1, (float *)&gl_matrix);
|
||||
lv_opengles_shader_set_uniform1f("u_Opa", (float)params->opa / (float)LV_OPA_100);
|
||||
lv_opengles_shader_set_uniform1i("u_IsFill", params->texture == 0);
|
||||
lv_opengles_shader_set_uniform3f("u_FillColor", (float)params->fill_color.red / 255.0f,
|
||||
|
||||
@@ -243,6 +243,41 @@ bool lv_matrix_is_identity_or_translation(const lv_matrix_t * matrix)
|
||||
matrix->m[2][2] == 1.0f);
|
||||
}
|
||||
|
||||
void lv_matrix_transpose(const lv_matrix_t * src, lv_matrix_t * dst)
|
||||
{
|
||||
if(src == NULL || dst == NULL) return;
|
||||
|
||||
if(src == dst) {
|
||||
/* In-place transposition: 3 swaps, minimal stack usage */
|
||||
float tmp;
|
||||
|
||||
tmp = dst->m[0][1];
|
||||
dst->m[0][1] = dst->m[1][0];
|
||||
dst->m[1][0] = tmp;
|
||||
|
||||
tmp = dst->m[0][2];
|
||||
dst->m[0][2] = dst->m[2][0];
|
||||
dst->m[2][0] = tmp;
|
||||
|
||||
tmp = dst->m[1][2];
|
||||
dst->m[1][2] = dst->m[2][1];
|
||||
dst->m[2][1] = tmp;
|
||||
}
|
||||
else {
|
||||
dst->m[0][0] = src->m[0][0];
|
||||
dst->m[0][1] = src->m[1][0];
|
||||
dst->m[0][2] = src->m[2][0];
|
||||
|
||||
dst->m[1][0] = src->m[0][1];
|
||||
dst->m[1][1] = src->m[1][1];
|
||||
dst->m[1][2] = src->m[2][1];
|
||||
|
||||
dst->m[2][0] = src->m[0][2];
|
||||
dst->m[2][1] = src->m[1][2];
|
||||
dst->m[2][2] = src->m[2][2];
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
@@ -123,6 +123,14 @@ bool lv_matrix_is_identity(const lv_matrix_t * matrix);
|
||||
*/
|
||||
bool lv_matrix_is_identity_or_translation(const lv_matrix_t * matrix);
|
||||
|
||||
/**
|
||||
* Transpose a matrix.
|
||||
* @param src pointer to the source matrix. If NULL, the function returns.
|
||||
* @param dst pointer to the destination matrix. If NULL, the function returns.
|
||||
* Note: src and dst may point to the same matrix for in-place transposition.
|
||||
*/
|
||||
void lv_matrix_transpose(const lv_matrix_t * src, lv_matrix_t * dst);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
Reference in New Issue
Block a user