Feat/row align bytes (#7)

* better bytes alignment

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* debug macos

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* debug linux

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* windows switch_rgba

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* better switch_rgba

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-03-03 09:30:05 +08:00 • committed by GitHub
parent 044bb260d9
commit 873919902e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 94 additions and 60 deletions

View file

@ -39,13 +39,18 @@ G_DEFINE_TYPE(TextureRgba, texture_rgba,
(G_TYPE_CHECK_INSTANCE_CAST((obj), texture_rgba_get_type(), \
TextureRgba))
static inline void switch_rgba(uint8_t* pixels, int width, int height) {
static inline void switch_rgba(uint8_t* pixels, int len, int height) {
uint8_t temp;
for (int i = 0; i < width * height; i++) {
temp = pixels[4 * i];
pixels[4 * i] = pixels[4 * i + 2];
pixels[4 * i + 2] = temp;
int byes_per_row = len / height;
int width = byes_per_row >> 2;
for (int i = 0; i < height; ++i) {
int row_idx_base = i * byes_per_row;
for (int k = 0; k < width; ++k) {
int idx = row_idx_base + k * 4;
temp = pixels[idx];
pixels[idx] = pixels[idx + 2];
pixels[idx + 2] = temp;
}
}
}

View file

@ -22,7 +22,7 @@ FLUTTER_PLUGIN_EXPORT void texture_rgba_renderer_plugin_register_with_registrar(
FlPluginRegistrar* registrar);
// Keep the same symbol name with Windows.
FLUTTER_PLUGIN_EXPORT void FlutterRgbaRendererPluginOnRgba(void *texture_rgba, const uint8_t *buffer, int width, int height);
FLUTTER_PLUGIN_EXPORT void FlutterRgbaRendererPluginOnRgba(void *texture_rgba, const uint8_t *buffer, int len, int width, int height, int row_align_bytes);
G_END_DECLS