From 2c3922f64f740693fccd7b27b42cd14d42016def Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 19 Apr 2021 11:41:22 +0800 Subject: [PATCH] Move RGBA conversion to GEGLTexture --- lib/graphics_engine/src/ge_gl_texture.cpp | 9 ++++++++- src/font/font_with_face.cpp | 7 ------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/graphics_engine/src/ge_gl_texture.cpp b/lib/graphics_engine/src/ge_gl_texture.cpp index f6225ec05..9ef0b93e3 100644 --- a/lib/graphics_engine/src/ge_gl_texture.cpp +++ b/lib/graphics_engine/src/ge_gl_texture.cpp @@ -194,8 +194,15 @@ void GEGLTexture::updateTexture(void* data, video::ECOLOR_FORMAT format, u32 w, } else if (format == video::ECF_A8R8G8B8) { + uint8_t* u8_data = (uint8_t*)data; + for (unsigned int i = 0; i < w * h; i++) + { + uint8_t tmp_val = u8_data[i * 4]; + u8_data[i * 4] = u8_data[i * 4 + 2]; + u8_data[i * 4 + 2] = tmp_val; + } glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, - GL_UNSIGNED_BYTE, data); + GL_UNSIGNED_BYTE, u8_data); } } if (hasMipMaps()) diff --git a/src/font/font_with_face.cpp b/src/font/font_with_face.cpp index bd502c75d..476968fae 100644 --- a/src/font/font_with_face.cpp +++ b/src/font/font_with_face.cpp @@ -291,13 +291,6 @@ void FontWithFace::insertGlyph(unsigned font_number, unsigned glyph_index) } } uint8_t* scaled_data = (uint8_t*)scaled->lock(); - for (unsigned int i = 0; i < cur_glyph_width * cur_glyph_height; - i++) - { - uint8_t tmp_val = scaled_data[i * 4]; - scaled_data[i * 4] = scaled_data[i * 4 + 2]; - scaled_data[i * 4 + 2] = tmp_val; - } tex->updateTexture(scaled_data, video::ECF_A8R8G8B8, cur_glyph_width, cur_glyph_height, m_used_width, m_used_height);