Silence compilation warnings.
authorZhigang Gong <zhigang.gong@linux.intel.com>
Wed, 8 Aug 2012 12:11:43 +0000 (20:11 +0800)
committerEric Anholt <eric@anholt.net>
Wed, 18 Dec 2013 19:23:53 +0000 (11:23 -0800)
After increase to gcc4.7, it reports more warnings, now
fix them.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Tested-by: Junyan He<junyan.he@linux.intel.com>
17 files changed:
glamor/glamor_copyarea.c
glamor/glamor_copyplane.c
glamor/glamor_core.c
glamor/glamor_egl.c
glamor/glamor_eglmodule.c
glamor/glamor_fbo.c
glamor/glamor_fillspans.c
glamor/glamor_glyphs.c
glamor/glamor_gradient.c
glamor/glamor_picture.c
glamor/glamor_pixmap.c
glamor/glamor_polyfillrect.c
glamor/glamor_polylines.c
glamor/glamor_priv.h
glamor/glamor_render.c
glamor/glamor_trapezoid.c
glamor/glamor_utils.h

index 2994179..7d06833 100644 (file)
@@ -392,14 +392,12 @@ _glamor_copy_n_to_n(DrawablePtr src,
                    Bool upsidedown, Pixel bitplane,
                    void *closure, Bool fallback)
 {
-       glamor_access_t dst_access;
        PixmapPtr dst_pixmap, src_pixmap;
        glamor_pixmap_private *dst_pixmap_priv, *src_pixmap_priv;
        glamor_screen_private *glamor_priv;
        glamor_gl_dispatch *dispatch;
        BoxPtr extent;
        RegionRec region;
-       ScreenPtr screen;
        int src_x_off, src_y_off, dst_x_off, dst_y_off;
        Bool ok = FALSE;
        int force_clip = 0;
@@ -410,7 +408,6 @@ _glamor_copy_n_to_n(DrawablePtr src,
        dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
        src_pixmap = glamor_get_drawable_pixmap(src);
        src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
-       screen = dst_pixmap->drawable.pScreen;
 
        glamor_priv = glamor_get_screen_private(dst->pScreen);
 
@@ -612,11 +609,6 @@ fall_back:
                        glamor_get_drawable_location(src),
                        glamor_get_drawable_location(dst));
 
-       if (gc && gc->alu != GXcopy)
-               dst_access = GLAMOR_ACCESS_RW;
-       else
-               dst_access = GLAMOR_ACCESS_WO;
-
        if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW)) {
                if (dst == src
                    || glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
index 6487ff7..3f2652a 100644 (file)
@@ -33,15 +33,12 @@ _glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
                   int srcx, int srcy, int w, int h, int dstx, int dsty,
                   unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
 {
-       glamor_screen_private *glamor_priv;
-
        if (!fallback 
            && glamor_ddx_fallback_check_gc(pGC)
            && glamor_ddx_fallback_check_pixmap(pSrc)
            && glamor_ddx_fallback_check_pixmap(pDst))
                goto fail;
 
-       glamor_priv = glamor_get_screen_private(pDst->pScreen);
        glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
        glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
        *pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
index 8ba3347..22065bc 100644 (file)
@@ -566,15 +566,13 @@ glamor_bitmap_to_region(PixmapPtr pixmap)
 
 /* Borrow from cairo. */
 Bool
-glamor_gl_has_extension(char *extension)
+glamor_gl_has_extension(const char *extension)
 {
-       const char *gl_extensions;
-       char *pext;
+       const char *pext;
        int ext_len;
        ext_len = strlen(extension);
 
-       gl_extensions = (const char *) glGetString(GL_EXTENSIONS);
-       pext = (char *) gl_extensions;
+       pext = (const char*)glGetString(GL_EXTENSIONS);
 
        if (pext == NULL || extension == NULL)
                return FALSE;
index a9a92a7..a248aa2 100644 (file)
@@ -335,8 +335,6 @@ _glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
        }
 }
 
-extern void glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back);
-
 _X_EXPORT void
 glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
 {
@@ -399,16 +397,13 @@ static Bool
 glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl,
                         const char *extension)
 {
-       const char *egl_extensions;
-       char *pext;
+       const char *pext;
        int ext_len;
-       ext_len = strlen(extension);
 
-       egl_extensions =
+       ext_len = strlen(extension);
+       pext =
            (const char *) eglQueryString(glamor_egl->display,
                                          EGL_EXTENSIONS);
-       pext = (char *) egl_extensions;
-
        if (pext == NULL || extension == NULL)
                return FALSE;
        while ((pext = strstr(pext, extension)) != NULL) {
index 046f4de..9a0dec9 100644 (file)
 #include "config.h"
 #endif
 
+#include <xorg-server.h>
 #define GLAMOR_FOR_XORG
-#include "glamor.h"
 #include <xf86Module.h>
-#include <xorg-server.h>
+#include "glamor.h"
 
 static XF86ModuleVersionInfo VersRec = {
        GLAMOR_EGL_MODULE_NAME,
index 4af831d..a46a740 100644 (file)
@@ -258,7 +258,6 @@ glamor_fbo_expire(glamor_screen_private *glamor_priv)
        struct xorg_list *cache;
        glamor_pixmap_fbo *fbo_entry, *tmp;
        int i,j,k;
-       int empty_cache = TRUE;
 
        for(i = 0; i < CACHE_FORMAT_COUNT; i++)
                for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
@@ -266,7 +265,6 @@ glamor_fbo_expire(glamor_screen_private *glamor_priv)
                                cache = &glamor_priv->fbo_cache[i][j][k];
                                xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
                                        if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
-                                               empty_cache = FALSE;
                                                break;
                                        }
 
index 6598249..35e881f 100644 (file)
@@ -36,11 +36,8 @@ _glamor_fill_spans(DrawablePtr drawable,
        BoxPtr pbox;
        int x1, x2, y;
        RegionPtr pClip = fbGetCompositeClip(gc);
-       glamor_screen_private *glamor_priv;
        Bool ret = FALSE;
 
-       glamor_priv = glamor_get_screen_private(drawable->pScreen);
-
        if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
                goto fail;
 
index f549904..fc361df 100644 (file)
@@ -222,7 +222,7 @@ get_mask_cache(struct glamor_glyph_mask_cache *maskcache, int blocks)
 {
        int free_cleared_bit, idx = -1;
        int retry_cnt = 0;
-       unsigned int bits_mask;
+       unsigned int bits_mask = 0;
 
        if (maskcache->free_bitmap == 0)
                return NULL;
@@ -514,20 +514,20 @@ glamor_glyph_priv_get_edge_map(GlyphPtr glyph, struct glamor_glyph *priv,
                             PicturePtr glyph_picture)
 {
        PixmapPtr glyph_pixmap = (PixmapPtr) glyph_picture->pDrawable;
-       struct glamor_pixmap_private *pixmap_priv;
        int j;
-       unsigned long long left_x1_map, left_x2_map, right_x1_map, right_x2_map;
+       unsigned long long left_x1_map = 0, left_x2_map = 0;
+       unsigned long long right_x1_map = 0, right_x2_map = 0;
        int bitsPerPixel;
        int stride;
        void *bits;
        int width;
-       unsigned int left_x1_data, left_x2_data, right_x1_data, right_x2_data;
+       unsigned int left_x1_data = 0, left_x2_data = 0;
+       unsigned int right_x1_data = 0, right_x2_data = 0;
 
        bitsPerPixel = glyph_pixmap->drawable.bitsPerPixel;
        stride = glyph_pixmap->devKind;
        bits = glyph_pixmap->devPrivate.ptr;
        width = glyph->info.width;
-       pixmap_priv = glamor_get_pixmap_private(glyph_pixmap);
 
        if (glyph_pixmap->drawable.width < 2
            || !(glyph_pixmap->drawable.depth == 8
@@ -662,12 +662,6 @@ glyph_new_fixed_list(struct glamor_glyph_list *fixed_list,
                        fixed_list->list[list_cnt - 1].len = cur_pos - n_off;
                } else
                        fixed_list->list[0].len = cur_pos - *head_pos - n_off;
-               while(list_cnt--) {
-                       DEBUGF("new fixed list type %d entry len %d x %d y %d"
-                               "head_pos %d pos %d list %d has %d glyphs.\n",
-                               fixed_list->type, fixed_list->nlist,
-                               cur_x, cur_y, *head_pos, cur_pos, i, fixed_list->list[i++].len);
-               }
                (*fixed_cnt)++;
        }
 
@@ -712,9 +706,9 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
        Bool first = TRUE, first_list = TRUE;
        Bool need_free_list_region = FALSE;
        Bool need_free_fixed_list = FALSE;
-       struct glamor_glyph *priv;
+       struct glamor_glyph *priv = NULL;
        Bool in_non_intersected_list = -1;
-       GlyphListPtr head_list, saved_list;
+       GlyphListPtr head_list;
        int head_x, head_y, head_pos;
        int fixed_cnt = 0;
        GlyphPtr *head_glyphs;
@@ -732,9 +726,10 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
 
        extents = pixman_region_extents(&current_region);
 
-       saved_list = list;
        x = 0;
        y = 0;
+       x1 = x2 = y1 = y2 = 0;
+       n = 0;
        extents->x1 = 0;
        extents->y1 = 0;
        extents->x2 = 0;
@@ -743,10 +738,10 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
        head_list = list;
        DEBUGF("has %d lists.\n", nlist);
        while (nlist--) {
-               BoxRec left_box, right_box;
+               BoxRec left_box, right_box = {0};
                Bool has_left_edge_box = FALSE, has_right_edge_box = FALSE;
                Bool left_to_right;
-               struct glamor_glyph *left_priv, *right_priv;
+               struct glamor_glyph *left_priv = NULL, *right_priv = NULL;
 
                x += list->xOff;
                y += list->yOff;
@@ -1146,7 +1141,7 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
        *out_y = priv->y;
        return cache->picture;
 }
-typedef void (*glyphs_flush)(void * arg);
+typedef void (*glyphs_flush_func)(void * arg);
 struct glyphs_flush_dst_arg {
        CARD8 op;
        PicturePtr src;
@@ -1223,7 +1218,7 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
                    int x_glyph, int y_glyph,
                    int dx, int dy, int w, int h,
                    int glyphs_dst_mode,
-                   glyphs_flush glyphs_flush, void *flush_arg)
+                   glyphs_flush_func glyphs_flush, void *flush_arg)
 {
        ScreenPtr screen = glamor_priv->screen;
        glamor_composite_rect_t *rect;
@@ -1327,7 +1322,7 @@ glamor_buffer_glyph_clip(glamor_screen_private *glamor_priv,
                         int glyph_dx, int glyph_dy,
                         int width, int height,
                         int glyphs_mode,
-                        glyphs_flush flush_func,
+                        glyphs_flush_func flush_func,
                         void *arg
                         )
 {
@@ -1490,24 +1485,24 @@ retry:
                        glyph = *glyphs++;
                        if (glyph->info.width > 0
                            && glyph->info.height > 0) {
-                               glyphs_flush flush_func;
-                               void *arg;
+                               glyphs_flush_func flush_func;
+                               void *temp_arg;
                                if (need_free_mask) {
                                        if (pmask_buffer->count)
-                                               flush_func = (glyphs_flush)glamor_glyphs_flush_mask;
+                                               flush_func = (glyphs_flush_func)glamor_glyphs_flush_mask;
                                        else
                                                flush_func = NULL;
-                                       arg = pmask_arg;
+                                       temp_arg = pmask_arg;
                                } else {
                                        /* If we are using global mask cache, then we need to
                                         * flush dst instead of mask. As some dst depends on the
                                         * previous mask result. Just flush mask can't get all previous's
                                         * overlapped glyphs.*/
                                        if (dst_buffer.count || mask_buffer.count)
-                                               flush_func = (glyphs_flush)glamor_glyphs_flush_dst;
+                                               flush_func = (glyphs_flush_func)glamor_glyphs_flush_dst;
                                        else
                                                flush_func = NULL;
-                                       arg = &dst_arg;
+                                       temp_arg = &dst_arg;
                                }
                                glamor_buffer_glyph(glamor_priv, pmask_buffer,
                                                    mask_format->format,
@@ -1516,7 +1511,7 @@ retry:
                                                    glyph->info.width, glyph->info.height,
                                                    glyphs_dst_mode,
                                                    flush_func,
-                                                   (void*)arg);
+                                                   (void*)temp_arg);
                        }
                        x += glyph->info.xOff;
                        y += glyph->info.yOff;
@@ -1538,7 +1533,7 @@ retry:
                glamor_destroy_pixmap(mask_pixmap);
        } else {
                struct glamor_glyph priv;
-               glyphs_flush flush_func;
+               glyphs_flush_func flush_func;
                BoxPtr rects;
                int nrect;
 
@@ -1570,7 +1565,7 @@ retry:
                y += dst->pDrawable->y;
 
                if (dst_buffer.count || mask_buffer.count)
-                       flush_func = (glyphs_flush)glamor_glyphs_flush_dst;
+                       flush_func = (glyphs_flush_func)glamor_glyphs_flush_dst;
                else
                        flush_func = NULL;
 
@@ -1633,10 +1628,10 @@ glamor_glyphs_to_dst(CARD8 op,
 
                        if (glyph->info.width > 0
                            && glyph->info.height > 0) {
-                               glyphs_flush flush_func;
+                               glyphs_flush_func flush_func;
 
                                if (dst_buffer.count || mask_buffer.count)
-                                       flush_func = (glyphs_flush)glamor_glyphs_flush_dst;
+                                       flush_func = (glyphs_flush_func)glamor_glyphs_flush_dst;
                                else
                                        flush_func = NULL;
                                glamor_buffer_glyph_clip(glamor_priv,
index 444ba6c..4abc82d 100644 (file)
@@ -51,36 +51,36 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, int use_ar
        char *gradient_fs = NULL;
        GLint fs_getcolor_prog;
 
-       const char *gradient_fs_getcolor =
-           GLAMOR_DEFAULT_PRECISION
-           "uniform int n_stop;\n"
-           "uniform float stops[%d];\n"
-           "uniform vec4 stop_colors[%d];\n"
-           "vec4 get_color(float stop_len)\n"
-           "{\n"
-           "    int i = 0;\n"
-           "    float new_alpha; \n"
-           "    vec4 gradient_color;\n"
-           "    float percentage; \n"
-           "    for(i = 0; i < n_stop - 1; i++) {\n"
-           "        if(stop_len < stops[i])\n"
-           "            break; \n"
-           "    }\n"
-           "    \n"
-           "    if(stops[i] - stops[i-1] > 2.0)\n"
-           "        percentage = 0.0;\n" //For comply with pixman, walker->stepper overflow.
-           "    else if(stops[i] - stops[i-1] < 0.000001)\n"
-           "        percentage = 0.0;\n"
-           "    else \n"
-           "        percentage = (stop_len - stops[i-1])/(stops[i] - stops[i-1]);\n"
-           "    new_alpha = percentage * stop_colors[i].a + \n"
-           "                       (1.0-percentage) * stop_colors[i-1].a; \n"
-           "    gradient_color = vec4((percentage * stop_colors[i].rgb \n"
-           "                          + (1.0-percentage) * stop_colors[i-1].rgb)*new_alpha, \n"
-           "                          new_alpha);\n"
-           "    \n"
-           "    return gradient_color;\n"
-           "}\n";
+       #define gradient_fs_getcolor\
+           GLAMOR_DEFAULT_PRECISION\
+           "uniform int n_stop;\n"\
+           "uniform float stops[%d];\n"\
+           "uniform vec4 stop_colors[%d];\n"\
+           "vec4 get_color(float stop_len)\n"\
+           "{\n"\
+           "    int i = 0;\n"\
+           "    float new_alpha; \n"\
+           "    vec4 gradient_color;\n"\
+           "    float percentage; \n"\
+           "    for(i = 0; i < n_stop - 1; i++) {\n"\
+           "        if(stop_len < stops[i])\n"\
+           "            break; \n"\
+           "    }\n"\
+           "    \n"\
+           "    if(stops[i] - stops[i-1] > 2.0)\n"\
+           "        percentage = 0.0;\n" /*For comply with pixman, walker->stepper overflow.*/\
+           "    else if(stops[i] - stops[i-1] < 0.000001)\n"\
+           "        percentage = 0.0;\n"\
+           "    else \n"\
+           "        percentage = (stop_len - stops[i-1])/(stops[i] - stops[i-1]);\n"\
+           "    new_alpha = percentage * stop_colors[i].a + \n"\
+           "                       (1.0-percentage) * stop_colors[i-1].a; \n"\
+           "    gradient_color = vec4((percentage * stop_colors[i].rgb \n"\
+           "                          + (1.0-percentage) * stop_colors[i-1].rgb)*new_alpha, \n"\
+           "                          new_alpha);\n"\
+           "    \n"\
+           "    return gradient_color;\n"\
+           "}\n"
 
        /* Because the array access for shader is very slow, the performance is very low
           if use array. So use global uniform to replace for it if the number of n_stops is small.*/
@@ -238,111 +238,111 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dy
         *     radius associated to it is negative (or it falls outside the valid t range)
         */
 
-       const char *gradient_fs_template =
-           GLAMOR_DEFAULT_PRECISION
-           "uniform mat3 transform_mat;\n"
-           "uniform int repeat_type;\n"
-           "uniform float A_value;\n"
-           "uniform vec2 c1;\n"
-           "uniform float r1;\n"
-           "uniform vec2 c2;\n"
-           "uniform float r2;\n"
-           "varying vec2 source_texture;\n"
-           "\n"
-           "vec4 get_color(float stop_len);\n"
-           "\n"
-           "int t_invalid;\n"
-           "\n"
-           "float get_stop_len()\n"
-           "{\n"
-           "    float t = 0.0;\n"
-           "    float sqrt_value;\n"
-           "    int revserse = 0;\n"
-           "    t_invalid = 0;\n"
-           "    \n"
-           "    vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"
-           "    vec3 source_texture_trans = transform_mat * tmp;\n"
-           "    source_texture_trans.xy = source_texture_trans.xy/source_texture_trans.z;\n"
-           "    float B_value = (source_texture_trans.x - c1.x) * (c2.x - c1.x)\n"
-           "                     + (source_texture_trans.y - c1.y) * (c2.y - c1.y)\n"
-           "                     + r1 * (r2 - r1);\n"
-           "    float C_value = (source_texture_trans.x - c1.x) * (source_texture_trans.x - c1.x)\n"
-           "                     + (source_texture_trans.y - c1.y) * (source_texture_trans.y - c1.y)\n"
-           "                     - r1*r1;\n"
-           "    if(abs(A_value) < 0.00001) {\n"
-           "        if(B_value == 0.0) {\n"
-           "            t_invalid = 1;\n"
-           "            return t;\n"
-           "        }\n"
-           "        t = 0.5 * C_value / B_value;"
-           "    } else {\n"
-           "        sqrt_value = B_value * B_value - A_value * C_value;\n"
-           "        if(sqrt_value < 0.0) {\n"
-           "            t_invalid = 1;\n"
-           "            return t;\n"
-           "        }\n"
-           "        sqrt_value = sqrt(sqrt_value);\n"
-           "        t = (B_value + sqrt_value) / A_value;\n"
-           "    }\n"
-           "    if(repeat_type == %d) {\n" // RepeatNone case.
-           "        if((t <= 0.0) || (t > 1.0))\n"
-           //           try another if first one invalid
-           "            t = (B_value - sqrt_value) / A_value;\n"
-           "        \n"
-           "        if((t <= 0.0) || (t > 1.0)) {\n" //still invalid, return.
-           "            t_invalid = 1;\n"
-           "            return t;\n"
-           "        }\n"
-           "    } else {\n"
-           "        if(t * (r2 - r1) <= -1.0 * r1)\n"
-           //           try another if first one invalid
-           "            t = (B_value - sqrt_value) / A_value;\n"
-           "        \n"
-           "        if(t * (r2 -r1) <= -1.0 * r1) {\n" //still invalid, return.
-           "            t_invalid = 1;\n"
-           "            return t;\n"
-           "        }\n"
-           "    }\n"
-           "    \n"
-           "    if(repeat_type == %d){\n" // repeat normal
-           "        while(t > 1.0) \n"
-           "            t = t - 1.0; \n"
-           "        while(t < 0.0) \n"
-           "            t = t + 1.0; \n"
-           "    }\n"
-           "    \n"
-           "    if(repeat_type == %d) {\n" // repeat reflect
-           "        while(t > 1.0) {\n"
-           "            t = t - 1.0; \n"
-           "            if(revserse == 0)\n"
-           "                revserse = 1;\n"
-           "            else\n"
-           "                revserse = 0;\n"
-           "        }\n"
-           "        while(t < 0.0) {\n"
-           "            t = t + 1.0; \n"
-           "            if(revserse == 0)\n"
-           "                revserse = 1;\n"
-           "            else\n"
-           "                revserse = 0;\n"
-           "        }\n"
-           "        if(revserse == 1) {\n"
-           "            t = 1.0 - t; \n"
-           "        }\n"
-           "    }\n"
-           "    \n"
-           "    return t;\n"
+       #define gradient_radial_fs_template\
+           GLAMOR_DEFAULT_PRECISION\
+           "uniform mat3 transform_mat;\n"\
+           "uniform int repeat_type;\n"\
+           "uniform float A_value;\n"\
+           "uniform vec2 c1;\n"\
+           "uniform float r1;\n"\
+           "uniform vec2 c2;\n"\
+           "uniform float r2;\n"\
+           "varying vec2 source_texture;\n"\
+           "\n"\
+           "vec4 get_color(float stop_len);\n"\
+           "\n"\
+           "int t_invalid;\n"\
+           "\n"\
+           "float get_stop_len()\n"\
+           "{\n"\
+           "    float t = 0.0;\n"\
+           "    float sqrt_value;\n"\
+           "    int revserse = 0;\n"\
+           "    t_invalid = 0;\n"\
+           "    \n"\
+           "    vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"\
+           "    vec3 source_texture_trans = transform_mat * tmp;\n"\
+           "    source_texture_trans.xy = source_texture_trans.xy/source_texture_trans.z;\n"\
+           "    float B_value = (source_texture_trans.x - c1.x) * (c2.x - c1.x)\n"\
+           "                     + (source_texture_trans.y - c1.y) * (c2.y - c1.y)\n"\
+           "                     + r1 * (r2 - r1);\n"\
+           "    float C_value = (source_texture_trans.x - c1.x) * (source_texture_trans.x - c1.x)\n"\
+           "                     + (source_texture_trans.y - c1.y) * (source_texture_trans.y - c1.y)\n"\
+           "                     - r1*r1;\n"\
+           "    if(abs(A_value) < 0.00001) {\n"\
+           "        if(B_value == 0.0) {\n"\
+           "            t_invalid = 1;\n"\
+           "            return t;\n"\
+           "        }\n"\
+           "        t = 0.5 * C_value / B_value;"\
+           "    } else {\n"\
+           "        sqrt_value = B_value * B_value - A_value * C_value;\n"\
+           "        if(sqrt_value < 0.0) {\n"\
+           "            t_invalid = 1;\n"\
+           "            return t;\n"\
+           "        }\n"\
+           "        sqrt_value = sqrt(sqrt_value);\n"\
+           "        t = (B_value + sqrt_value) / A_value;\n"\
+           "    }\n"\
+           "    if(repeat_type == %d) {\n" /* RepeatNone case. */\
+           "        if((t <= 0.0) || (t > 1.0))\n"\
+           /*           try another if first one invalid*/\
+           "            t = (B_value - sqrt_value) / A_value;\n"\
+           "        \n"\
+           "        if((t <= 0.0) || (t > 1.0)) {\n" /*still invalid, return.*/\
+           "            t_invalid = 1;\n"\
+           "            return t;\n"\
+           "        }\n"\
+           "    } else {\n"\
+           "        if(t * (r2 - r1) <= -1.0 * r1)\n"\
+           /*           try another if first one invalid*/\
+           "            t = (B_value - sqrt_value) / A_value;\n"\
+           "        \n"\
+           "        if(t * (r2 -r1) <= -1.0 * r1) {\n" /*still invalid, return.*/\
+           "            t_invalid = 1;\n"\
+           "            return t;\n"\
+           "        }\n"\
+           "    }\n"\
+           "    \n"\
+           "    if(repeat_type == %d){\n" /* repeat normal*/\
+           "        while(t > 1.0) \n"\
+           "            t = t - 1.0; \n"\
+           "        while(t < 0.0) \n"\
+           "            t = t + 1.0; \n"\
+           "    }\n"\
+           "    \n"\
+           "    if(repeat_type == %d) {\n" /* repeat reflect*/\
+           "        while(t > 1.0) {\n"\
+           "            t = t - 1.0; \n"\
+           "            if(revserse == 0)\n"\
+           "                revserse = 1;\n"\
+           "            else\n"\
+           "                revserse = 0;\n"\
+           "        }\n"\
+           "        while(t < 0.0) {\n"\
+           "            t = t + 1.0; \n"\
+           "            if(revserse == 0)\n"\
+           "                revserse = 1;\n"\
+           "            else\n"\
+           "                revserse = 0;\n"\
+           "        }\n"\
+           "        if(revserse == 1) {\n"\
+           "            t = 1.0 - t; \n"\
+           "        }\n"\
+           "    }\n"\
+           "    \n"\
+           "    return t;\n"\
+           "}\n"\
+           "\n"\
+           "void main()\n"\
+           "{\n"\
+           "    float stop_len = get_stop_len();\n"\
+           "    if(t_invalid == 1) {\n"\
+           "        gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"\
+           "    } else {\n"\
+           "        gl_FragColor = get_color(stop_len);\n"\
+           "    }\n"\
            "}\n"
-           "\n"
-           "void main()\n"
-           "{\n"
-           "    float stop_len = get_stop_len();\n"
-           "    if(t_invalid == 1) {\n"
-           "        gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
-           "    } else {\n"
-           "        gl_FragColor = get_color(stop_len);\n"
-           "    }\n"
-           "}\n";
 
        glamor_priv = glamor_get_screen_private(screen);
 
@@ -376,7 +376,7 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dy
                                           GL_VERTEX_SHADER, gradient_vs);
 
        XNFasprintf(&gradient_fs,
-                   gradient_fs_template,
+                   gradient_radial_fs_template,
                    PIXMAN_REPEAT_NONE, PIXMAN_REPEAT_NORMAL, PIXMAN_REPEAT_REFLECT);
 
        fs_main_prog = glamor_compile_glsl_prog(dispatch,
@@ -486,89 +486,88 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, int dy
         *              before and after it. Use the interpolation fomula to compute RGBA.
         */
 
-       const char *gradient_fs_template =
-           GLAMOR_DEFAULT_PRECISION
-           "uniform mat3 transform_mat;\n"
-           "uniform int repeat_type;\n"
-           "uniform int hor_ver;\n"
-           "uniform float pt_slope;\n"
-           "uniform float cos_val;\n"
-           "uniform float p1_distance;\n"
-           "uniform float pt_distance;\n"
-           "varying vec2 source_texture;\n"
-           "\n"
-           "vec4 get_color(float stop_len);\n"
-           "\n"
-           "float get_stop_len()\n"
-           "{\n"
-           "    vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"
-           "    float len_percentage;\n"
-           "    float distance;\n"
-           "    float _p1_distance;\n"
-           "    float _pt_distance;\n"
-           "    float y_dist;\n"
-           "    float stop_after;\n"
-           "    float stop_before;\n"
-           "    vec4 stop_color_before;\n"
-           "    vec4 stop_color_after;\n"
-           "    float new_alpha; \n"
-           "    int revserse = 0;\n"
-           "    vec4 gradient_color;\n"
-           "    float percentage; \n"
-           "    vec3 source_texture_trans = transform_mat * tmp;\n"
-           "    \n"
-           "    if(hor_ver == 0) { \n" //Normal case.
-           "        y_dist = source_texture_trans.y - source_texture_trans.x*pt_slope;\n"
-           "        distance = y_dist * cos_val;\n"
-           "        _p1_distance = p1_distance * source_texture_trans.z;\n"
-           "        _pt_distance = pt_distance * source_texture_trans.z;\n"
-           "        \n"
-           "    } else if (hor_ver == 1) {\n"//horizontal case.
-           "        distance = source_texture_trans.x;\n"
-           "        _p1_distance = p1_distance * source_texture_trans.z;\n"
-           "        _pt_distance = pt_distance * source_texture_trans.z;\n"
-           "    } \n"
-           "    \n"
-           "    distance = distance - _p1_distance; \n"
-           "    \n"
-           "    if(repeat_type == %d){\n" // repeat normal
-           "        while(distance > _pt_distance) \n"
-           "            distance = distance - (_pt_distance); \n"
-           "        while(distance < 0.0) \n"
-           "            distance = distance + (_pt_distance); \n"
-           "    }\n"
-           "    \n"
-           "    if(repeat_type == %d) {\n" // repeat reflect
-           "        while(distance > _pt_distance) {\n"
-           "            distance = distance - (_pt_distance); \n"
-           "            if(revserse == 0)\n"
-           "                revserse = 1;\n"
-           "            else\n"
-           "                revserse = 0;\n"
-           "        }\n"
-           "        while(distance < 0.0) {\n"
-           "            distance = distance + (_pt_distance); \n"
-           "            if(revserse == 0)\n"
-           "                revserse = 1;\n"
-           "            else\n"
-           "                revserse = 0;\n"
-           "        }\n"
-           "        if(revserse == 1) {\n"
-           "            distance = (_pt_distance) - distance; \n"
-           "        }\n"
-           "    }\n"
-           "    \n"
-           "    len_percentage = distance/(_pt_distance);\n"
-           "    \n"
-           "    return len_percentage;\n"
+       #define gradient_fs_template    \
+           GLAMOR_DEFAULT_PRECISION\
+           "uniform mat3 transform_mat;\n"\
+           "uniform int repeat_type;\n"\
+           "uniform int hor_ver;\n"\
+           "uniform float pt_slope;\n"\
+           "uniform float cos_val;\n"\
+           "uniform float p1_distance;\n"\
+           "uniform float pt_distance;\n"\
+           "varying vec2 source_texture;\n"\
+           "\n"\
+           "vec4 get_color(float stop_len);\n"\
+           "\n"\
+           "float get_stop_len()\n"\
+           "{\n"\
+           "    vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"\
+           "    float len_percentage;\n"\
+           "    float distance;\n"\
+           "    float _p1_distance;\n"\
+           "    float _pt_distance;\n"\
+           "    float y_dist;\n"\
+           "    float stop_after;\n"\
+           "    float stop_before;\n"\
+           "    vec4 stop_color_before;\n"\
+           "    vec4 stop_color_after;\n"\
+           "    float new_alpha; \n"\
+           "    int revserse = 0;\n"\
+           "    vec4 gradient_color;\n"\
+           "    float percentage; \n"\
+           "    vec3 source_texture_trans = transform_mat * tmp;\n"\
+           "    \n"\
+           "    if(hor_ver == 0) { \n" /*Normal case.*/\
+           "        y_dist = source_texture_trans.y - source_texture_trans.x*pt_slope;\n"\
+           "        distance = y_dist * cos_val;\n"\
+           "        _p1_distance = p1_distance * source_texture_trans.z;\n"\
+           "        _pt_distance = pt_distance * source_texture_trans.z;\n"\
+           "        \n"\
+           "    } else if (hor_ver == 1) {\n"/*horizontal case.*/\
+           "        distance = source_texture_trans.x;\n"\
+           "        _p1_distance = p1_distance * source_texture_trans.z;\n"\
+           "        _pt_distance = pt_distance * source_texture_trans.z;\n"\
+           "    } \n"\
+           "    \n"\
+           "    distance = distance - _p1_distance; \n"\
+           "    \n"\
+           "    if(repeat_type == %d){\n" /* repeat normal*/\
+           "        while(distance > _pt_distance) \n"\
+           "            distance = distance - (_pt_distance); \n"\
+           "        while(distance < 0.0) \n"\
+           "            distance = distance + (_pt_distance); \n"\
+           "    }\n"\
+           "    \n"\
+           "    if(repeat_type == %d) {\n" /* repeat reflect*/\
+           "        while(distance > _pt_distance) {\n"\
+           "            distance = distance - (_pt_distance); \n"\
+           "            if(revserse == 0)\n"\
+           "                revserse = 1;\n"\
+           "            else\n"\
+           "                revserse = 0;\n"\
+           "        }\n"\
+           "        while(distance < 0.0) {\n"\
+           "            distance = distance + (_pt_distance); \n"\
+           "            if(revserse == 0)\n"\
+           "                revserse = 1;\n"\
+           "            else\n"\
+           "                revserse = 0;\n"\
+           "        }\n"\
+           "        if(revserse == 1) {\n"\
+           "            distance = (_pt_distance) - distance; \n"\
+           "        }\n"\
+           "    }\n"\
+           "    \n"\
+           "    len_percentage = distance/(_pt_distance);\n"\
+           "    \n"\
+           "    return len_percentage;\n"\
+           "}\n"\
+           "\n"\
+           "void main()\n"\
+           "{\n"\
+           "    float stop_len = get_stop_len();\n"\
+           "    gl_FragColor = get_color(stop_len);\n"\
            "}\n"
-           "\n"
-           "void main()\n"
-           "{\n"
-           "    float stop_len = get_stop_len();\n"
-           "    gl_FragColor = get_color(stop_len);\n"
-           "}\n";
-
 
        glamor_priv = glamor_get_screen_private(screen);
 
index 44e1e40..7d5ffbb 100644 (file)
@@ -73,13 +73,10 @@ glamor_create_picture(PicturePtr picture)
 {
        PixmapPtr pixmap;
        glamor_pixmap_private *pixmap_priv;
-       glamor_screen_private *glamor_priv;
 
        if (!picture || !picture->pDrawable)
                return 0;
 
-       glamor_priv =
-           glamor_get_screen_private(picture->pDrawable->pScreen);
        pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
        pixmap_priv = glamor_get_pixmap_private(pixmap);
        if (!pixmap_priv) {
@@ -112,13 +109,10 @@ glamor_destroy_picture(PicturePtr picture)
 {
        PixmapPtr pixmap;
        glamor_pixmap_private *pixmap_priv;
-       glamor_screen_private *glamor_priv;
 
        if (!picture || !picture->pDrawable)
                return;
 
-       glamor_priv =
-           glamor_get_screen_private(picture->pDrawable->pScreen);
        pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
        pixmap_priv = glamor_get_pixmap_private(pixmap);
 
index f3a2a87..9bbc989 100644 (file)
@@ -926,7 +926,6 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
        glamor_pixmap_private *pixmap_priv;
        GLenum gl_access = 0, gl_usage = 0;
        void *data, *read;
-       ScreenPtr screen;
        glamor_screen_private *glamor_priv =
            glamor_get_screen_private(pixmap->drawable.pScreen);
        glamor_gl_dispatch *dispatch;
@@ -936,7 +935,6 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
        int fbo_x_off, fbo_y_off;
 
        data = bits;
-       screen = pixmap->drawable.pScreen;
        pixmap_priv = glamor_get_pixmap_private(pixmap);
        if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
                return NULL;
@@ -1193,13 +1191,11 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
            glamor_get_pixmap_private(pixmap);
        unsigned int stride;
        void *data = NULL, *dst;
-       ScreenPtr screen;
        glamor_screen_private *glamor_priv =
            glamor_get_screen_private(pixmap->drawable.pScreen);
        glamor_gl_dispatch *dispatch;
        int pbo = 0;
 
-       screen = pixmap->drawable.pScreen;
        if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
                return TRUE;
 
@@ -1259,7 +1255,6 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
 Bool
 glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv)
 {
-       glamor_screen_private *glamor_priv;
        glamor_pixmap_fbo *old_fbo;
        glamor_pixmap_fbo *new_fbo = NULL;
        PixmapPtr scratch = NULL;
@@ -1274,7 +1269,6 @@ glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv)
                return  TRUE;
 
        old_fbo = pixmap_priv->base.fbo;
-       glamor_priv = pixmap_priv->base.glamor_priv;
 
        if (!old_fbo)
                return FALSE;
index 738e8eb..4e1f7b3 100644 (file)
@@ -43,9 +43,6 @@ _glamor_poly_fill_rect(DrawablePtr drawable,
        register BoxPtr pbox;
        RegionPtr pClip = fbGetCompositeClip(gc);
        Bool ret = FALSE;
-       glamor_screen_private *glamor_priv;
-
-       glamor_priv = glamor_get_screen_private(drawable->pScreen);
 
        xorg = drawable->x;
        yorg = drawable->y;
index 70dd6c1..e723e95 100644 (file)
@@ -45,7 +45,6 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
        xRectangle *rects;
        int x1, x2, y1, y2;
        int i;
-       glamor_screen_private *glamor_priv;
 
        /* Don't try to do wide lines or non-solid fill style. */
        if (gc->lineWidth != 0) {
@@ -105,7 +104,6 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
            && glamor_ddx_fallback_check_gc(gc))
                return FALSE;
 
-       glamor_priv = glamor_get_screen_private(drawable->pScreen);
        if (gc->lineWidth == 0) {
                if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
                        if (glamor_prepare_access_gc(gc)) {
index 1830b56..03ef6cc 100644 (file)
@@ -549,9 +549,6 @@ extern int glamor_debug_level;
 /* glamor.c */
 PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
 
-PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
-                              unsigned int usage);
-
 Bool glamor_destroy_pixmap(PixmapPtr pixmap);
 
 glamor_pixmap_fbo* glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv);
@@ -568,16 +565,12 @@ void glamor_init_pixmap_fbo(ScreenPtr screen);
 void glamor_fini_pixmap_fbo(ScreenPtr screen);
 Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
 void glamor_fbo_expire(glamor_screen_private *glamor_priv);
-void glamor_init_pixmap_fbo(ScreenPtr screen);
-void glamor_fini_pixmap_fbo(ScreenPtr screen);
 
 glamor_pixmap_fbo *
 glamor_create_fbo_array(glamor_screen_private *glamor_priv,
                        int w, int h, GLenum format, int flag,
                        int block_w, int block_h, glamor_pixmap_private *);
 
-Bool glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv);
-
 /* glamor_copyarea.c */
 RegionPtr
 glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
@@ -603,7 +596,6 @@ void glamor_fini_finish_access_shaders(ScreenPtr screen);
 const Bool glamor_get_drawable_location(const DrawablePtr drawable);
 void glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
                                int *x, int *y);
-Bool glamor_create_gc(GCPtr gc);
 Bool glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
                    int x, int y, int width, int height,
                    unsigned char alu, unsigned long planemask,
@@ -636,7 +628,7 @@ Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch,
 Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
 Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
 RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
-Bool glamor_gl_has_extension(char *extension);
+Bool glamor_gl_has_extension(const char *extension);
 int glamor_gl_get_version(void);
 
 #define GLAMOR_GL_VERSION_ENCODE(major, minor) ( \
@@ -683,7 +675,6 @@ void glamor_glyphs(CARD8 op,
                   INT16 ySrc, int nlist, GlyphListPtr list,
                   GlyphPtr * glyphs);
 
-void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
 /* glamor_setspans.c */
 void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
                      DDXPointPtr points, int *widths, int n, int sorted);
@@ -947,9 +938,6 @@ void glamor_finish_access_picture(PicturePtr picture, glamor_access_t access);
 
 void glamor_destroy_picture(PicturePtr picture);
 
-enum glamor_pixmap_status
- glamor_upload_picture_to_texture(PicturePtr picture);
-
 /* fixup a fbo to the exact size as the pixmap. */
 Bool
 glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv);
index 9b80295..27d5dc5 100644 (file)
@@ -43,6 +43,7 @@
 //#define DEBUGRegionPrint(x) do {} while (0)
 #define DEBUGRegionPrint RegionPrint
 #endif
+
 static struct blendinfo composite_op_info[] = {
        [PictOpClear] = {0, 0, GL_ZERO, GL_ZERO},
        [PictOpSrc] = {0, 0, GL_ONE, GL_ZERO},
@@ -1715,7 +1716,7 @@ _glamor_composite(CARD8 op,
            glamor_get_screen_private(screen);
        Bool ret = TRUE;
        RegionRec region;
-       BoxPtr box, extent;
+       BoxPtr extent;
        int nbox, ok = FALSE;
        PixmapPtr sub_dest_pixmap = NULL;
        PixmapPtr sub_source_pixmap = NULL;
@@ -1778,7 +1779,6 @@ _glamor_composite(CARD8 op,
                goto done;
        }
 
-       box = REGION_RECTS(&region);
        nbox = REGION_NUM_RECTS(&region);
        DEBUGF("first clipped when compositing.\n");
        DEBUGRegionPrint(&region);
@@ -1833,6 +1833,7 @@ _glamor_composite(CARD8 op,
                                                     x_dest, y_dest);
 
        REGION_UNINIT(dest->pDrawable->pScreen, &region);
+
        if (ok)
                goto done;
 fail:
@@ -1886,7 +1887,7 @@ fail:
                GET_SUB_PICTURE(source, GLAMOR_ACCESS_RO);
        if (mask && mask->pDrawable && !mask->transform)
                GET_SUB_PICTURE(mask, GLAMOR_ACCESS_RO);
-full_fallback:
+
        if (glamor_prepare_access_picture(dest, GLAMOR_ACCESS_RW)) {
                if (source_pixmap == dest_pixmap || glamor_prepare_access_picture
                    (source, GLAMOR_ACCESS_RO)) {
index 7bb75f5..57a178c 100644 (file)
@@ -81,12 +81,16 @@ _glamor_lines_crossfixedY (xLineFixed *l, xLineFixed *r)
        xFixed dy2 = r->p2.y - r->p1.y;
        xFixed_32_32 tmp = (xFixed_32_32) dy2 * dy1;
        xFixed_32_32 dividend1 = (tmp >> 32) * (l->p1.x - r->p1.x);
+       xFixed_32_32 dividend2;
+       xFixed_32_32 dividend3;
+       xFixed_32_32 divisor;
+
        tmp = (xFixed_32_32) dx1 * dy2;
-       xFixed_32_32 dividend2 = (tmp >> 32) * l->p1.y;
+       dividend2 = (tmp >> 32) * l->p1.y;
        tmp = (xFixed_32_32) dy1 * dx2;
-       xFixed_32_32 dividend3 = (tmp >> 32) * r->p1.y;
-       xFixed_32_32 divisor = ((xFixed_32_32) dx1 * (xFixed_32_32) dy2
-                                  - (xFixed_32_32) dy1 * (xFixed_32_32) dx2) >> 32;
+       dividend3 = (tmp >> 32) * r->p1.y;
+       divisor = ((xFixed_32_32) dx1 * (xFixed_32_32) dy2
+                   - (xFixed_32_32) dy1 * (xFixed_32_32) dx2) >> 32;
 
        if (divisor)
                return (xFixed)((dividend2 - dividend1 - dividend3) / divisor);
@@ -1363,7 +1367,6 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
        glamor_pixmap_private *pixmap_priv;
        PixmapPtr pixmap = NULL;
        GLint trapezoid_prog;
-       float width, height;
        GLfloat xscale, yscale;
        float left_slope, right_slope;
        xTrapezoid *ptrap;
@@ -1399,9 +1402,6 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
 
        pixmap_priv_get_dest_scale(pixmap_priv, (&xscale), (&yscale));
 
-       width = (float)(bounds->x2 - bounds->x1);
-       height = (float)(bounds->y2 - bounds->y1);
-
        dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
        dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 
@@ -1604,11 +1604,11 @@ glamor_create_mask_picture(ScreenPtr screen,
 static int
 _glamor_trapezoid_bounds (int ntrap, xTrapezoid *traps, BoxPtr box)
 {
+       int has_large_trapezoid = 0;
        box->y1 = MAXSHORT;
        box->y2 = MINSHORT;
        box->x1 = MAXSHORT;
        box->x2 = MINSHORT;
-       int has_large_trapezoid = 0;
 
        for (; ntrap; ntrap--, traps++) {
                INT16 x1, y1, x2, y2;
index 6eef722..36beb49 100644 (file)
 #define t_from_x_coord_y(_yscale_, _y_)          (1.0 - (_y_) * (_yscale_))
 #define t_from_x_coord_y_inverted(_yscale_, _y_) ((_y_) * (_yscale_))
 
-#define pixmap_priv_get_dest_scale(_pixmap_priv_, _pxscale_, _pyscale_)\
-  do {                                                                 \
-    int w,h;                                                           \
-    PIXMAP_PRIV_GET_ACTUAL_SIZE(_pixmap_priv_, w, h);                  \
-    *(_pxscale_) = 1.0 / w;                                            \
-    *(_pyscale_) = 1.0 / h;                                            \
+#define pixmap_priv_get_dest_scale(_pixmap_priv_, _pxscale_, _pyscale_)  \
+  do {                                                                   \
+    int _w_,_h_;                                                         \
+    PIXMAP_PRIV_GET_ACTUAL_SIZE(_pixmap_priv_, _w_, _h_);                \
+    *(_pxscale_) = 1.0 / _w_;                                            \
+    *(_pyscale_) = 1.0 / _h_;                                            \
    } while(0)
 
 #define pixmap_priv_get_scale(_pixmap_priv_, _pxscale_, _pyscale_)     \
 
 #define glamor_transform_point(matrix, tx, ty, x, y)                   \
   do {                                                                 \
-    int i;                                                             \
-    float result[4];                                                   \
-    for (i = 0; i < 3; i++) {                                          \
-      result[i] = (matrix)[i * 3] * (x) + (matrix)[i * 3 + 1] * (y)    \
-       + (matrix)[i * 3 + 2];                                          \
+    int _i_;                                                           \
+    float _result_[4];                                                 \
+    for (_i_ = 0; _i_ < 3; _i_++) {                                    \
+      _result_[_i_] = (matrix)[_i_ * 3] * (x) + (matrix)[_i_ * 3 + 1] * (y)    \
+       + (matrix)[_i_ * 3 + 2];                                        \
     }                                                                  \
-    tx = result[0] / result[2];                                                \
-    ty = result[1] / result[2];                                                \
+    tx = _result_[0] / _result_[2];                                    \
+    ty = _result_[1] / _result_[2];                                    \
   } while(0)
 
 #define _glamor_set_normalize_tpoint(xscale, yscale, _tx_, _ty_,       \
 
 #define glamor_set_const_ext(params, nparam, vertices, nverts, stride) \
     do {                                                               \
-       int i = 0, j = 0;                                               \
-       for(; i < nverts; i++) {                                        \
-           for(j = 0; j < nparam; j++) {                               \
-               vertices[stride*i + j] = params[j];                     \
+       int _i_ = 0, _j_ = 0;                                           \
+       for(; _i_ < nverts; _i_++) {                                    \
+           for(_j_ = 0; _j_ < nparam; _j_++) {                         \
+               vertices[stride*_i_ + _j_] = params[_j_];               \
            }                                                           \
        }                                                               \
     } while(0)