From f8db04e254295920f77b9d69d4a1edb6fd8130c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 10 Apr 2015 23:33:36 +0300 Subject: [PATCH] cairo-dock: Fix white flash when NPOT textures aren't available --- src/gldit/cairo-dock-draw-opengl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/gldit/cairo-dock-draw-opengl.c b/src/gldit/cairo-dock-draw-opengl.c index ea975dd..4ad2dab 100644 --- a/src/gldit/cairo-dock-draw-opengl.c +++ b/src/gldit/cairo-dock-draw-opengl.c @@ -691,6 +691,26 @@ GLuint cairo_dock_create_texture_from_raw_data (const guchar *pTextureRaw, int i cd_debug ("\\%o\\%o\\%o\\%o", red, green, blue, alpha); } pTextureRaw = pPixelBuffer2;*/ + + guint *pPixelBuffer = (guint *) pTextureRaw; + guint *pPixelBuffer2 = NULL; + if (! g_openglConfig.bNonPowerOfTwoAvailable ) { + double log2_w = log (iWidth) / log (2); + double log2_h = log (iHeight) / log (2); + int w_ = MIN (4096, pow (2, ceil (log2_w))); + int h_ = MIN (4096, pow (2, ceil (log2_h))); + + if (pTextureRaw) { + int i; + pPixelBuffer2 = g_new0(guint, w_ * h_); + for (i = 0; i < iHeight; i ++) + memcpy(&pPixelBuffer2[i*w_], &pPixelBuffer[i*iWidth], iWidth * 4); + pTextureRaw = (guchar *)pPixelBuffer2; + } + iWidth = w_; + iHeight = h_; + } + GLuint iTexture = 0; _cairo_dock_enable_texture (); @@ -718,6 +738,7 @@ GLuint cairo_dock_create_texture_from_raw_data (const guchar *pTextureRaw, int i glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, iWidth, iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTextureRaw); glBindTexture (GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); + g_free(pPixelBuffer2); return iTexture; } -- 2.0.5