summaryrefslogtreecommitdiffstats
path: root/minuitwrp/graphics_utils.cpp
diff options
context:
space:
mode:
authorVladimir Oltean <olteanv@gmail.com>2018-07-02 23:04:03 +0200
committerEthan Yonker <dees_troy@teamw.in>2019-03-18 17:39:38 +0100
commitd32b7ebf20217f5053aaf0597cc1a7dcf86fc2a5 (patch)
treeb61769e4756a3500a7ccc1fe9399b7de0af4d47c /minuitwrp/graphics_utils.cpp
parentAB/Non AB Devices: updates for moving cache (diff)
downloadandroid_bootable_recovery-d32b7ebf20217f5053aaf0597cc1a7dcf86fc2a5.tar
android_bootable_recovery-d32b7ebf20217f5053aaf0597cc1a7dcf86fc2a5.tar.gz
android_bootable_recovery-d32b7ebf20217f5053aaf0597cc1a7dcf86fc2a5.tar.bz2
android_bootable_recovery-d32b7ebf20217f5053aaf0597cc1a7dcf86fc2a5.tar.lz
android_bootable_recovery-d32b7ebf20217f5053aaf0597cc1a7dcf86fc2a5.tar.xz
android_bootable_recovery-d32b7ebf20217f5053aaf0597cc1a7dcf86fc2a5.tar.zst
android_bootable_recovery-d32b7ebf20217f5053aaf0597cc1a7dcf86fc2a5.zip
Diffstat (limited to 'minuitwrp/graphics_utils.cpp')
-rw-r--r--minuitwrp/graphics_utils.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/minuitwrp/graphics_utils.cpp b/minuitwrp/graphics_utils.cpp
index 67c836ed5..c591e5398 100644
--- a/minuitwrp/graphics_utils.cpp
+++ b/minuitwrp/graphics_utils.cpp
@@ -19,6 +19,7 @@
#include <png.h>
#include <pixelflinger/pixelflinger.h>
#include <linux/fb.h>
+#include <string.h>
#include "minui.h"
@@ -121,3 +122,47 @@ exit:
fclose(fp);
return res;
}
+
+#define MATRIX_ELEMENT(matrix, row, col, row_size, elem_size) \
+ (((uint8_t*) (matrix)) + (((row) * (elem_size)) * (row_size)) + ((col) * (elem_size)))
+
+#define DO_MATRIX_ROTATION(bits_per_pixel, bytes_per_pixel) \
+{ \
+ for (size_t y = 0; y < src->height; y++) { \
+ for (size_t x = 0; x < src->width; x++) { \
+ /* output pointer in dst->data */ \
+ uint##bits_per_pixel##_t *op; \
+ /* input pointer from src->data */ \
+ const uint##bits_per_pixel##_t *ip; \
+ /* Display coordinates (in dst) corresponding to (x, y) in src */ \
+ size_t x_disp = ROTATION_X_DISP(x, y, dst); \
+ size_t y_disp = ROTATION_Y_DISP(x, y, dst); \
+ \
+ ip = (const uint##bits_per_pixel##_t*) \
+ MATRIX_ELEMENT(src->data, y, x, \
+ src->stride, bytes_per_pixel); \
+ op = (uint##bits_per_pixel##_t*) \
+ MATRIX_ELEMENT(dst->data, y_disp, x_disp, \
+ dst->stride, bytes_per_pixel); \
+ *op = *ip; \
+ } \
+ } \
+}
+
+void surface_ROTATION_transform(gr_surface dst_ptr, const gr_surface src_ptr,
+ size_t num_bytes_per_pixel)
+{
+ GGLSurface *dst = (GGLSurface*) dst_ptr;
+ const GGLSurface *src = (GGLSurface*) src_ptr;
+
+ /* Handle duplicated code via a macro.
+ * This is currently used for rotating surfaces of graphical resources
+ * (32-bit pixel format) and of font glyphs (8-bit pixel format).
+ * If you need to add handling of other pixel formats feel free to do so.
+ */
+ if (num_bytes_per_pixel == 4) {
+ DO_MATRIX_ROTATION(32, 4);
+ } else if (num_bytes_per_pixel == 1) {
+ DO_MATRIX_ROTATION(8, 1);
+ }
+}