From 1a4744a493a41b930d5a9e6f58c8d43eb3be3c42 Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Thu, 6 Feb 2014 19:52:28 +0100 Subject: Disable alpha blending for fully opaque rectangles * This makes the rendering several times faster, because the giant rectangle used as background no longer uses expensive blending calculations, and there are also many other big rectangles which don't need it (fileselector, ...). * Results on hammerhead: - WITHOUT the patch - scrolling in fileselector on install page: I:render 67 ms, flip 6 ms, total 73 ms I:render 82 ms, flip 6 ms, total 88 ms I:render 81 ms, flip 6 ms, total 87 ms I:render 80 ms, flip 5 ms, total 85 ms - WITH the patch - scrolling in fileselector on install page: I:render 32 ms, flip 6 ms, total 38 ms I:render 16 ms, flip 6 ms, total 22 ms I:render 16 ms, flip 7 ms, total 23 ms I:render 18 ms, flip 3 ms, total 21 ms I:render 18 ms, flip 2 ms, total 20 ms * On flo, the results are even more noticable - 160ms -> 40ms Signed-off-by: Vojtech Bocek Change-Id: I5685763ba21745d7cd93133adf5f0bcb4c9a581f --- minuitwrp/graphics.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c index fc34b6b19..99f584183 100644 --- a/minuitwrp/graphics.c +++ b/minuitwrp/graphics.c @@ -69,6 +69,7 @@ static GGLSurface gr_framebuffer[NUM_BUFFERS]; static GGLSurface gr_mem_surface; static unsigned gr_active_fb = 0; static unsigned double_buffering = 0; +static int gr_is_curr_clr_opaque = 0; static int gr_fb_fd = -1; static int gr_vt_fd = -1; @@ -288,6 +289,8 @@ void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a color[2] = ((b << 8) | b) + 1; color[3] = ((a << 8) | a) + 1; gl->color4xv(gl, color); + + gr_is_curr_clr_opaque = (a == 255); } int gr_measureEx(const char *s, void* font) @@ -463,8 +466,15 @@ int twgr_text(int x, int y, const char *s) void gr_fill(int x, int y, int w, int h) { GGLContext *gl = gr_context; + + if(gr_is_curr_clr_opaque) + gl->disable(gl, GGL_BLEND); + gl->disable(gl, GGL_TEXTURE_2D); gl->recti(gl, x, y, x + w, y + h); + + if(gr_is_curr_clr_opaque) + gl->enable(gl, GGL_BLEND); } void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) { -- cgit v1.2.3