diff options
Diffstat (limited to 'glamor/glamor_utils.h')
-rw-r--r-- | glamor/glamor_utils.h | 112 |
1 files changed, 57 insertions, 55 deletions
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h index 31e92d805..688350dfc 100644 --- a/glamor/glamor_utils.h +++ b/glamor/glamor_utils.h @@ -41,10 +41,10 @@ #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_) \ +#define pixmap_priv_get_dest_scale(pixmap, _pixmap_priv_, _pxscale_, _pyscale_) \ do { \ int _w_,_h_; \ - PIXMAP_PRIV_GET_ACTUAL_SIZE(_pixmap_priv_, _w_, _h_); \ + PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, _pixmap_priv_, _w_, _h_); \ *(_pxscale_) = 1.0 / _w_; \ *(_pyscale_) = 1.0 / _h_; \ } while(0) @@ -55,21 +55,21 @@ *(_pyscale_) = 1.0 / (_pixmap_priv_)->base.fbo->height; \ } while(0) -#define PIXMAP_PRIV_GET_ACTUAL_SIZE(priv, w, h) \ +#define PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, priv, w, h) \ do { \ if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) { \ w = priv->large.box.x2 - priv->large.box.x1; \ h = priv->large.box.y2 - priv->large.box.y1; \ } else { \ - w = priv->base.pixmap->drawable.width; \ - h = priv->base.pixmap->drawable.height; \ + w = (pixmap)->drawable.width; \ + h = (pixmap)->drawable.height; \ } \ } while(0) -#define glamor_pixmap_fbo_fix_wh_ratio(wh, priv) \ +#define glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap, priv) \ do { \ int actual_w, actual_h; \ - PIXMAP_PRIV_GET_ACTUAL_SIZE(priv, actual_w, actual_h); \ + PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, priv, actual_w, actual_h); \ wh[0] = (float)priv->base.fbo->width / actual_w; \ wh[1] = (float)priv->base.fbo->height / actual_h; \ wh[2] = 1.0 / priv->base.fbo->width; \ @@ -189,17 +189,17 @@ txy = xy - bxy1; \ } while(0) -#define _glamor_get_reflect_transform_coords(priv, repeat_type, \ +#define _glamor_get_reflect_transform_coords(pixmap, priv, repeat_type, \ tx1, ty1, \ _x1_, _y1_) \ do { \ int odd_x, odd_y; \ float c, d; \ fodd_repeat_mod(_x1_,priv->box.x2, \ - priv->base.pixmap->drawable.width, \ + (pixmap)->drawable.width, \ odd_x, c); \ fodd_repeat_mod(_y1_, priv->box.y2, \ - priv->base.pixmap->drawable.height, \ + (pixmap)->drawable.height, \ odd_y, d); \ DEBUGF("c %f d %f oddx %d oddy %d \n", \ c, d, odd_x, odd_y); \ @@ -208,14 +208,14 @@ DEBUGF("y2 %d y1 %d fbo->height %d \n", priv->box.y2, \ priv->box.y1, priv->base.fbo->height); \ _glamor_repeat_reflect_fixup(tx1, _x1_, c, odd_x, \ - priv->base.pixmap->drawable.width, \ + (pixmap)->drawable.width, \ priv->box.x1, priv->box.x2); \ _glamor_repeat_reflect_fixup(ty1, _y1_, d, odd_y, \ - priv->base.pixmap->drawable.height, \ + (pixmap)->drawable.height, \ priv->box.y1, priv->box.y2); \ } while(0) -#define _glamor_get_repeat_coords(priv, repeat_type, tx1, \ +#define _glamor_get_repeat_coords(pixmap, priv, repeat_type, tx1, \ ty1, tx2, ty2, \ _x1_, _y1_, _x2_, \ _y2_, c, d, odd_x, odd_y) \ @@ -224,10 +224,10 @@ DEBUGF("x1 y1 %d %d\n", \ _x1_, _y1_ ); \ DEBUGF("width %d box.x1 %d \n", \ - (priv)->base.pixmap->drawable.width, \ + (pixmap)->drawable.width, \ priv->box.x1); \ if (odd_x) { \ - c = (priv)->base.pixmap->drawable.width \ + c = (pixmap)->drawable.width \ - c; \ tx1 = c - priv->box.x1; \ tx2 = tx1 - ((_x2_) - (_x1_)); \ @@ -236,7 +236,7 @@ tx2 = tx1 + ((_x2_) - (_x1_)); \ } \ if (odd_y){ \ - d = (priv)->base.pixmap->drawable.height\ + d = (pixmap)->drawable.height\ - d; \ ty1 = d - priv->box.y1; \ ty2 = ty1 - ((_y2_) - (_y1_)); \ @@ -253,11 +253,11 @@ } while(0) /* _x1_ ... _y2_ may has fractional. */ -#define glamor_get_repeat_transform_coords(priv, repeat_type, tx1, \ +#define glamor_get_repeat_transform_coords(pixmap, priv, repeat_type, tx1, \ ty1, _x1_, _y1_) \ do { \ DEBUGF("width %d box.x1 %d x2 %d y1 %d y2 %d\n", \ - (priv)->base.pixmap->drawable.width, \ + (pixmap)->drawable.width, \ priv->box.x1, priv->box.x2, priv->box.y1, \ priv->box.y2); \ DEBUGF("x1 %f y1 %f \n", _x1_, _y1_); \ @@ -265,33 +265,33 @@ tx1 = _x1_ - priv->box.x1; \ ty1 = _y1_ - priv->box.y1; \ } else \ - _glamor_get_reflect_transform_coords(priv, repeat_type, \ + _glamor_get_reflect_transform_coords(pixmap, priv, repeat_type, \ tx1, ty1, \ _x1_, _y1_); \ DEBUGF("tx1 %f ty1 %f \n", tx1, ty1); \ } while(0) /* _x1_ ... _y2_ must be integer. */ -#define glamor_get_repeat_coords(priv, repeat_type, tx1, \ +#define glamor_get_repeat_coords(pixmap, priv, repeat_type, tx1, \ ty1, tx2, ty2, _x1_, _y1_, _x2_, \ _y2_) \ do { \ int c, d; \ int odd_x = 0, odd_y = 0; \ DEBUGF("width %d box.x1 %d x2 %d y1 %d y2 %d\n", \ - (priv)->base.pixmap->drawable.width, \ + (pixmap)->drawable.width, \ priv->box.x1, priv->box.x2, \ priv->box.y1, priv->box.y2); \ - modulus((_x1_), (priv)->base.pixmap->drawable.width, c); \ - modulus((_y1_), (priv)->base.pixmap->drawable.height, d); \ + modulus((_x1_), (pixmap)->drawable.width, c); \ + modulus((_y1_), (pixmap)->drawable.height, d); \ DEBUGF("c %d d %d \n", c, d); \ if (repeat_type == RepeatReflect) { \ odd_x = abs((_x1_ - c) \ - / (priv->base.pixmap->drawable.width)) & 1; \ + / ((pixmap)->drawable.width)) & 1; \ odd_y = abs((_y1_ - d) \ - / (priv->base.pixmap->drawable.height)) & 1; \ + / ((pixmap)->drawable.height)) & 1; \ } \ - _glamor_get_repeat_coords(priv, repeat_type, tx1, ty1, tx2, ty2,\ + _glamor_get_repeat_coords(pixmap, priv, repeat_type, tx1, ty1, tx2, ty2, \ _x1_, _y1_, _x2_, _y2_, c, d, \ odd_x, odd_y); \ } while(0) @@ -317,7 +317,7 @@ (texcoord)[1]); \ } while(0) -#define glamor_set_transformed_point(priv, matrix, xscale, \ +#define glamor_set_transformed_point(priv, matrix, xscale, \ yscale, texcoord, \ x, y) \ do { \ @@ -400,7 +400,7 @@ texcoords+4); \ } while (0) -#define glamor_set_repeat_transformed_normalize_tcoords_ext( priv, \ +#define glamor_set_repeat_transformed_normalize_tcoords_ext(pixmap, priv, \ repeat_type, \ matrix, \ xscale, \ @@ -425,16 +425,16 @@ glamor_transform_point(matrix, tx4, ty4, _x1_, _y2_); \ DEBUGF("transformed %f %f %f %f %f %f %f %f\n", \ tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4); \ - glamor_get_repeat_transform_coords((&priv->large), repeat_type, \ + glamor_get_repeat_transform_coords(pixmap, (&priv->large), repeat_type, \ ttx1, tty1, \ tx1, ty1); \ - glamor_get_repeat_transform_coords((&priv->large), repeat_type, \ + glamor_get_repeat_transform_coords(pixmap, (&priv->large), repeat_type, \ ttx2, tty2, \ tx2, ty2); \ - glamor_get_repeat_transform_coords((&priv->large), repeat_type, \ + glamor_get_repeat_transform_coords(pixmap, (&priv->large), repeat_type, \ ttx3, tty3, \ tx3, ty3); \ - glamor_get_repeat_transform_coords((&priv->large), repeat_type, \ + glamor_get_repeat_transform_coords(pixmap, (&priv->large), repeat_type, \ ttx4, tty4, \ tx4, ty4); \ DEBUGF("repeat transformed %f %f %f %f %f %f %f %f\n", ttx1, tty1, \ @@ -450,7 +450,8 @@ } \ } while (0) -#define glamor_set_repeat_transformed_normalize_tcoords( priv, \ +#define glamor_set_repeat_transformed_normalize_tcoords( pixmap, \ + priv, \ repeat_type, \ matrix, \ xscale, \ @@ -459,7 +460,8 @@ _x2_, _y2_, \ texcoords) \ do { \ - glamor_set_repeat_transformed_normalize_tcoords_ext( priv, \ + glamor_set_repeat_transformed_normalize_tcoords_ext( pixmap, \ + priv, \ repeat_type, \ matrix, \ xscale, \ @@ -516,7 +518,7 @@ vertices, 2); \ } while(0) -#define glamor_set_repeat_normalize_tcoords_ext(priv, repeat_type, \ +#define glamor_set_repeat_normalize_tcoords_ext(pixmap, priv, repeat_type, \ xscale, yscale, \ _x1_, _y1_, _x2_, _y2_, \ vertices, stride) \ @@ -529,7 +531,7 @@ tx2 = tx1 + ((_x2_) - (_x1_)); \ ty2 = ty1 + ((_y2_) - (_y1_)); \ } else { \ - glamor_get_repeat_coords((&priv->large), repeat_type, \ + glamor_get_repeat_coords(pixmap, (&priv->large), repeat_type, \ tx1, ty1, tx2, ty2, \ _x1_, _y1_, _x2_, _y2_); \ } \ @@ -791,10 +793,10 @@ static inline GLenum gl_iformat_for_pixmap(PixmapPtr pixmap) { glamor_screen_private *glamor_priv = - glamor_get_screen_private(pixmap->drawable.pScreen); + glamor_get_screen_private((pixmap)->drawable.pScreen); if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && - (pixmap->drawable.depth == 1 || pixmap->drawable.depth == 8)) { + ((pixmap)->drawable.depth == 1 || (pixmap)->drawable.depth == 8)) { return GL_ALPHA; } else { return GL_RGBA; @@ -811,7 +813,7 @@ format_for_pixmap(PixmapPtr pixmap) if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv)) pict_format = pixmap_priv->base.picture->format; else - pict_format = format_for_depth(pixmap->drawable.depth); + pict_format = format_for_depth((pixmap)->drawable.depth); return pict_format; } @@ -967,8 +969,8 @@ static inline void _glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int w, int h) { int i, j; - unsigned char *p = pixmap->devPrivate.ptr; - int stride = pixmap->devKind; + unsigned char *p = (pixmap)->devPrivate.ptr; + int stride = (pixmap)->devKind; p = p + y * stride + x; @@ -985,8 +987,8 @@ static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int w, int h) { int i, j; - unsigned char *p = pixmap->devPrivate.ptr; - int stride = pixmap->devKind; + unsigned char *p = (pixmap)->devPrivate.ptr; + int stride = (pixmap)->devKind; p = p + y * stride + x; @@ -1003,8 +1005,8 @@ static inline void _glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int w, int h) { int i, j; - unsigned short *p = pixmap->devPrivate.ptr; - int stride = pixmap->devKind / 2; + unsigned short *p = (pixmap)->devPrivate.ptr; + int stride = (pixmap)->devKind / 2; p = p + y * stride + x; @@ -1021,8 +1023,8 @@ static inline void _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int w, int h) { int i, j; - unsigned int *p = pixmap->devPrivate.ptr; - int stride = pixmap->devKind / 4; + unsigned int *p = (pixmap)->devPrivate.ptr; + int stride = (pixmap)->devKind / 4; p = p + y * stride + x; @@ -1038,11 +1040,11 @@ _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int w, int h) static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h) { - w = ((x + w) > pixmap->drawable.width) ? (pixmap->drawable.width - x) : w; - h = ((y + h) > pixmap->drawable.height) ? (pixmap->drawable.height - y) : h; + w = ((x + w) > (pixmap)->drawable.width) ? ((pixmap)->drawable.width - x) : w; + h = ((y + h) > (pixmap)->drawable.height) ? ((pixmap)->drawable.height - y) : h; - glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO); - switch (pixmap->drawable.depth) { + glamor_prepare_access(&(pixmap)->drawable, GLAMOR_ACCESS_RO); + switch ((pixmap)->drawable.depth) { case 8: _glamor_dump_pixmap_byte(pixmap, x, y, w, h); break; @@ -1059,9 +1061,9 @@ glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h) _glamor_dump_pixmap_bits(pixmap, x, y, w, h); break; default: - ErrorF("dump depth %d, not implemented.\n", pixmap->drawable.depth); + ErrorF("dump depth %d, not implemented.\n", (pixmap)->drawable.depth); } - glamor_finish_access(&pixmap->drawable); + glamor_finish_access(&(pixmap)->drawable); } static inline void @@ -1259,7 +1261,7 @@ glamor_compare_pictures(ScreenPtr screen, GLAMOR_CREATE_PIXMAP_CPU); pixman_pic = CreatePicture(0, - &pixmap->drawable, + &(pixmap)->drawable, PictureMatchFormat(screen, PIXMAN_FORMAT_DEPTH (format), format), 0, 0, @@ -1287,7 +1289,7 @@ glamor_compare_pictures(ScreenPtr screen, GLAMOR_CREATE_PIXMAP_CPU); pixman_pic = CreatePicture(0, - &pixmap->drawable, + &(pixmap)->drawable, PictureMatchFormat(screen, PIXMAN_FORMAT_DEPTH (format), format), 0, 0, |