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 <vbocek@gmail.com>

Change-Id: I5685763ba21745d7cd93133adf5f0bcb4c9a581f
diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c
index fc34b6b..99f5841 100644
--- a/minuitwrp/graphics.c
+++ b/minuitwrp/graphics.c
@@ -69,6 +69,7 @@
 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 @@
     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 @@
 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) {