$OpenBSD: patch-src_FbTk_TextureRender_cc,v 1.4 2013/01/21 09:49:20 dcoppa Exp $

Fix bug: actually invert a given Texture (stupid typo)
(upstream git commit bf5da7f1b6e87f574774558700d066d9cff1f436)

Bugfix: ensure textures have the correct size before applying 'bevel'
(upstream git commit 239e895826b2f843bc50cc6fef8108db174c33e8)

--- src/FbTk/TextureRender.cc.orig	Mon Dec 10 18:26:54 2012
+++ src/FbTk/TextureRender.cc	Mon Jan 21 10:21:35 2013
@@ -264,7 +264,7 @@ void invertRGB(unsigned int w, unsigned int h, FbTk::R
     FbTk::RGBA* r = rgba + (w * h);
 
     for (--r; l < r; ++l, --r) { // swapping 32bits (RGBA) at ones.
-        std::swap(*((unsigned int*)r), *(unsigned int*)r);
+        std::swap(*((unsigned int*)l), *(unsigned int*)r);
     }
 }
 
@@ -916,25 +916,25 @@ Pixmap TextureRender::renderSolid(const FbTk::Texture 
 
     if (texture.type() & Texture::INTERLACED) {
         lgc.setForeground(texture.colorTo());
-        register unsigned int i = 0;
-        for (; i < height; i += 2)
+        unsigned int i;
+        for (i = 0; i < height; i += 2)
             pixmap.drawLine(lgc.gc(), 0, i, width - 1, i);
 
     }
 
     lgc.setForeground(texture.loColor());
 
-    if (texture.type() & Texture::BEVEL1) {
+    if (height > 1 && width > 1 && texture.type() & Texture::BEVEL1) {
         if (texture.type() & Texture::RAISED) {
             drawBevelRectangle(pixmap, lgc.gc(), hgc.gc(), 0, height - 1, width -1 , 0);
         } else if (texture.type() & Texture::SUNKEN) {
             drawBevelRectangle(pixmap, hgc.gc(), lgc.gc(), 0, height - 1, width - 1, 0);
         }
-    } else if (texture.type() & Texture::BEVEL2) {
+    } else if (width > 2 && height > 2 && texture.type() & Texture::BEVEL2) {
         if (texture.type() & Texture::RAISED) {
-            drawBevelRectangle(pixmap, lgc.gc(), hgc.gc(), 1, height - 3, width - 3, 1);
+            drawBevelRectangle(pixmap, lgc.gc(), hgc.gc(), 1, height - 2, width - 2, 1);
         } else if (texture.type() & Texture::SUNKEN) {
-            drawBevelRectangle(pixmap, hgc.gc(), lgc.gc(), 1, height - 3, width - 3, 1);
+            drawBevelRectangle(pixmap, hgc.gc(), lgc.gc(), 1, height - 2, width - 2, 1);
         }
     }
 
