[maemo-commits] [maemo-commits] r17832 - in projects/haf/trunk/clutter0.8: clutter/cogl/common clutter/eglx debian

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Mar 27 13:22:00 EET 2009
Author: gw
Date: 2009-03-27 13:21:58 +0200 (Fri, 27 Mar 2009)
New Revision: 17832

Modified:
   projects/haf/trunk/clutter0.8/clutter/cogl/common/pvr-texture.c
   projects/haf/trunk/clutter0.8/clutter/eglx/clutter-eglx-texture-pixmap.c
   projects/haf/trunk/clutter0.8/debian/changelog
Log:
  * clutter/cogl/common/pvr-texture.c: fix some texture encoding artefacts
  * clutter/eglx/clutter-eglx-texture-pixmap.c: Now only use alphs channel
    if depth is reported as 32 bit, because depth != pixel bpp.


Modified: projects/haf/trunk/clutter0.8/clutter/cogl/common/pvr-texture.c
===================================================================
--- projects/haf/trunk/clutter0.8/clutter/cogl/common/pvr-texture.c	2009-03-27 10:21:33 UTC (rev 17831)
+++ projects/haf/trunk/clutter0.8/clutter/cogl/common/pvr-texture.c	2009-03-27 11:21:58 UTC (rev 17832)
@@ -1,4 +1,6 @@
 /*
+ * This file is part of libhildondesktop
+ *
  * Copyright (C) 2008 Nokia Corporation.
  *
  * Authored By Gordon Williams <gordon.williams at collabora.co.uk>
@@ -347,6 +349,34 @@
     }
 }
 
+inline static void nearest_pvr_color( Color *col, gboolean use_max ) {
+  if (col->alpha >= 224)
+    {
+      if (use_max) {
+        col->red = MIN(col->red + 7, 255);
+        col->green = MIN(col->green + 7, 255);
+        col->blue = MIN(col->blue + 7, 255);
+      }
+      col->alpha = 0xFF;
+      col->red   = (col->red & 0xF8) | (col->red >> 5);
+      col->green = (col->green & 0xF8) | (col->green >> 5);
+      col->blue  = (col->blue & 0xF8) | (col->blue >> 5);
+    }
+  else
+    {
+      if (use_max) {
+        col->alpha = MIN(col->alpha + 31, 255);
+        col->red = MIN(col->red + 15, 255);
+        col->green = MIN(col->green + 15, 255);
+        col->blue = MIN(col->blue + 15, 255);
+      }
+      col->alpha = (col->alpha & 0xE0) | (col->alpha >> 3);
+      col->red   = (col->red & 0xF0) | (col->red >> 4);
+      col->green = (col->green & 0xF0) | (col->green >> 4);
+      col->blue  = (col->blue & 0xF0) | (col->blue >> 4);
+    }
+}
+
 inline static Color pvr_color_to_color( guint32 col )
 {
   Color result;
@@ -490,6 +520,8 @@
               SETMIN(clow, blockline[3]);
               SETMAX(chigh, blockline[3]);
             }
+          nearest_pvr_color(&clow, FALSE);
+          nearest_pvr_color(&chigh, TRUE);
           col_low[1+x+block_offs] = clow;
           col_high[1+x+block_offs] = chigh;
         }

Modified: projects/haf/trunk/clutter0.8/clutter/eglx/clutter-eglx-texture-pixmap.c
===================================================================
--- projects/haf/trunk/clutter0.8/clutter/eglx/clutter-eglx-texture-pixmap.c	2009-03-27 10:21:33 UTC (rev 17831)
+++ projects/haf/trunk/clutter0.8/clutter/eglx/clutter-eglx-texture-pixmap.c	2009-03-27 11:21:58 UTC (rev 17832)
@@ -93,11 +93,6 @@
 void
 clutter_eglx_texture_pixmap_paint (ClutterActor *actor);
 
-static EGLConfig
-clutter_eglx_get_eglconfig (EGLDisplay *display, int for_pixmap,
-                            EGLSurface *surface,
-			    EGLNativePixmapType p_or_w);
-
 static void
 clutter_eglx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture,
                                         gint x,
@@ -105,6 +100,10 @@
                                         gint width,
                                         gint height);
 
+static EGLConfig
+clutter_eglx_get_eglconfig (EGLDisplay *display,
+                            EGLSurface *surface, Pixmap pixmap,
+                            int depth);
 
 static void
 clutter_eglx_texture_pixmap_surface_create (ClutterActor *actor);
@@ -288,9 +287,8 @@
   if (pixmap)
     {
       EGLConfig conf = clutter_eglx_get_eglconfig (
-                                backend->edpy, 1,
-		                &priv->egl_surface,
-                                (EGLNativePixmapType)pixmap);
+                                backend->edpy, &priv->egl_surface,
+                                pixmap, pixmap_depth);
       print_config_info (conf);
     }
   else
@@ -307,9 +305,8 @@
 	  return;
 	}
       conf = clutter_eglx_get_eglconfig (
-                        backend->edpy, 0,
-                        &priv->egl_surface,
-                        (EGLNativePixmapType)pixmap);
+                        backend->edpy, &priv->egl_surface,
+                        pixmap, pixmap_depth);
       print_config_info (conf);
     }
 
@@ -423,15 +420,15 @@
    * will free it anyway if we unrealise or set a new texture  */
 }
 
-static const EGLint pixmap_creation_config[] = {
+static const EGLint pixmap_creation_config_rgb[] = {
         EGL_TEXTURE_TARGET,             EGL_TEXTURE_2D,
         EGL_TEXTURE_FORMAT,             EGL_TEXTURE_RGB,
         EGL_NONE
 };
 
-static const EGLint window_creation_config[] = {
+static const EGLint pixmap_creation_config_rgba[] = {
         EGL_TEXTURE_TARGET,             EGL_TEXTURE_2D,
-        EGL_TEXTURE_FORMAT,             EGL_TEXTURE_RGB,
+        EGL_TEXTURE_FORMAT,             EGL_TEXTURE_RGBA,
         EGL_NONE
 };
 
@@ -444,39 +441,19 @@
 	EGL_NONE
 };
 
-static const EGLint window_config[] = {
-	EGL_SURFACE_TYPE,		EGL_PIXMAP_BIT,
-	EGL_RENDERABLE_TYPE,		EGL_OPENGL_ES2_BIT,
-	EGL_DEPTH_SIZE,			0,
-	EGL_BIND_TO_TEXTURE_RGB,	EGL_TRUE,
-	EGL_NONE
-};
 
-
-
 static EGLConfig
-clutter_eglx_get_eglconfig (EGLDisplay *display, int for_pixmap,
-                            EGLSurface *surface, EGLNativePixmapType p_or_w)
+clutter_eglx_get_eglconfig (EGLDisplay *display,
+                            EGLSurface *surface, Pixmap pixmap,
+                            int depth)
 {
    EGLConfig configs[20];
-   EGLint creation_config[
-                    MAX(sizeof(pixmap_creation_config),
-                        sizeof(window_creation_config))];
    int i, nconfigs = 0;
    EGLBoolean ret;
+   gboolean has_alpha = depth==32;
 
-   if (for_pixmap)
-     {
-       ret = eglChooseConfig (display, pixmap_config, configs,
-		              G_N_ELEMENTS (configs), &nconfigs);
-       memcpy(creation_config, pixmap_creation_config, sizeof(pixmap_creation_config));
-     }
-   else
-     {
-       ret = eglChooseConfig (display, window_config, configs,
-		              G_N_ELEMENTS (configs), &nconfigs);
-       memcpy(creation_config, window_creation_config, sizeof(window_creation_config));
-     }
+   ret = eglChooseConfig (display, pixmap_config, configs,
+                          G_N_ELEMENTS (configs), &nconfigs);
 
    if (ret != EGL_TRUE)
      {
@@ -490,33 +467,19 @@
 
    for (i = 0; i < nconfigs; ++i)
     {
-      int j;
-      /* we don't seem to be able to find out if we have an alpha channel or
-       * not from the pixmap (depth may be 32, but no alpha) - so we'll
-       * just try once with alpha, and if it fails we try without */
+      if (has_alpha)
+        *surface = eglCreatePixmapSurface (display, configs[i],
+                                           (EGLNativePixmapType)pixmap,
+                                           pixmap_creation_config_rgba);
+      else
+        *surface = eglCreatePixmapSurface (display, configs[i],
+                                           (EGLNativePixmapType)pixmap,
+                                           pixmap_creation_config_rgb);
 
-      /* set up texture for alpha and try to create a surface... */
-      for (j=0; creation_config[j]!=EGL_NONE; j+=2)
-        if (creation_config[j] == EGL_TEXTURE_FORMAT)
-          creation_config[j+1] = EGL_TEXTURE_RGBA;
-
-      *surface = eglCreatePixmapSurface (display, configs[i],
-                                         p_or_w, creation_config);
-
-      if (*surface == EGL_NO_SURFACE)
-        {
-          /* set up texture for no alpha and try... */
-          for (j=0; creation_config[j]!=EGL_NONE; j+=2)
-            if (creation_config[j] == EGL_TEXTURE_FORMAT)
-              creation_config[j+1] = EGL_TEXTURE_RGB;
-          *surface = eglCreatePixmapSurface (display, configs[i],
-                                             p_or_w, creation_config);
-        }
-
       if (*surface != EGL_NO_SURFACE)
         break;
 
-      g_debug ("%s: eglCreate(Pixmap|Window)Surface failed for config:",
+      g_debug ("%s: eglCreatePixmapSurface failed for config:",
                __FUNCTION__);
       print_config_info (configs[i]);
    }

Modified: projects/haf/trunk/clutter0.8/debian/changelog
===================================================================
--- projects/haf/trunk/clutter0.8/debian/changelog	2009-03-27 10:21:33 UTC (rev 17831)
+++ projects/haf/trunk/clutter0.8/debian/changelog	2009-03-27 11:21:58 UTC (rev 17832)
@@ -1,6 +1,8 @@
 clutter (0.8.2-0maemo25~unreleased) unstable; urgency=low
 
-  * writeme
+  * clutter/cogl/common/pvr-texture.c: fix some texture encoding artefacts
+  * clutter/eglx/clutter-eglx-texture-pixmap.c: Now only use alphs channel
+    if depth is reported as 32 bit, because depth != pixel bpp.
 
  -- Gordon Williams <gordon.williams at collabora.co.uk>  Fri, 27 Mar 2009 09:44:29 +0200
 


More information about the maemo-commits mailing list