diff options
author | Keith Packard <keithp@keithp.com> | 2014-10-29 22:50:53 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2015-03-24 12:32:46 -0700 |
commit | af687396f1875de0a45683aad4fd5a9a2e00f10d (patch) | |
tree | edfc30a8c59c4ff0a9a68a828f835557c60234a6 /glamor | |
parent | 1eb954c3830d46c27bf2a61f825b59f12092728c (diff) |
glamor: Remove screen private and pixmap ptrs from pixmap private and fbo
There's no reason to waste memory storing redundant copies of the same
pointer all over the system; just pass in pointers as necessary to
each function.
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'glamor')
-rw-r--r-- | glamor/glamor.c | 13 | ||||
-rw-r--r-- | glamor/glamor_compositerects.c | 2 | ||||
-rw-r--r-- | glamor/glamor_fbo.c | 52 | ||||
-rw-r--r-- | glamor/glamor_gradient.c | 4 | ||||
-rw-r--r-- | glamor/glamor_largepixmap.c | 131 | ||||
-rw-r--r-- | glamor/glamor_pixmap.c | 41 | ||||
-rw-r--r-- | glamor/glamor_priv.h | 102 | ||||
-rw-r--r-- | glamor/glamor_render.c | 173 | ||||
-rw-r--r-- | glamor/glamor_transform.c | 4 | ||||
-rw-r--r-- | glamor/glamor_utils.h | 112 | ||||
-rw-r--r-- | glamor/glamor_xv.c | 8 |
11 files changed, 345 insertions, 297 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c index 6ee006fa0..555f65058 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -64,16 +64,12 @@ _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type) { glamor_pixmap_private *pixmap_priv; - glamor_screen_private *glamor_priv = - glamor_get_screen_private(pixmap->drawable.pScreen); pixmap_priv = dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key); if (pixmap_priv == NULL) { pixmap_priv = calloc(sizeof(*pixmap_priv), 1); glamor_set_pixmap_private(pixmap, pixmap_priv); - pixmap_priv->base.pixmap = pixmap; - pixmap_priv->base.glamor_priv = glamor_priv; } pixmap_priv->type = type; pixmap_priv->base.box.x1 = 0; @@ -96,7 +92,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex) if (pixmap_priv->base.fbo) { fbo = glamor_pixmap_detach_fbo(pixmap_priv); - glamor_destroy_fbo(fbo); + glamor_destroy_fbo(glamor_priv, fbo); } format = gl_iformat_for_pixmap(pixmap); @@ -170,9 +166,6 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, } glamor_set_pixmap_private(pixmap, pixmap_priv); - pixmap_priv->base.pixmap = pixmap; - pixmap_priv->base.glamor_priv = glamor_priv; - format = gl_iformat_for_pixmap(pixmap); pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3; @@ -557,8 +550,8 @@ glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv) else { if (old_priv == NULL) return; - - glamor_pixmap_destroy_fbo(old_priv); + glamor_pixmap_destroy_fbo(glamor_get_screen_private(pixmap->drawable.pScreen), + old_priv); free(old_priv); } diff --git a/glamor/glamor_compositerects.c b/glamor/glamor_compositerects.c index 3b6b2ed07..4459fce07 100644 --- a/glamor/glamor_compositerects.c +++ b/glamor/glamor_compositerects.c @@ -254,7 +254,7 @@ glamor_composite_rectangles(CARD8 op, goto done; if (glamor_composite_clipped_region(op, source, NULL, dst, - NULL, NULL, priv, + NULL, NULL, pixmap, ®ion, 0, 0, 0, 0, 0, 0)) goto done; } diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c index 941eaee04..cf5216dda 100644 --- a/glamor/glamor_fbo.c +++ b/glamor/glamor_fbo.c @@ -112,9 +112,10 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv, } static void -glamor_purge_fbo(glamor_pixmap_fbo *fbo) +glamor_purge_fbo(glamor_screen_private *glamor_priv, + glamor_pixmap_fbo *fbo) { - glamor_make_current(fbo->glamor_priv); + glamor_make_current(glamor_priv); if (fbo->fb) glDeleteFramebuffers(1, &fbo->fb); @@ -127,7 +128,8 @@ glamor_purge_fbo(glamor_pixmap_fbo *fbo) } static void -glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo) +glamor_pixmap_fbo_cache_put(glamor_screen_private *glamor_priv, + glamor_pixmap_fbo *fbo) { struct xorg_list *cache; int n_format; @@ -139,32 +141,33 @@ glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo) n_format = cache_format(fbo->format); if (fbo->fb == 0 || fbo->external || n_format == -1 - || fbo->glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) { - fbo->glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX; - glamor_fbo_expire(fbo->glamor_priv); - glamor_purge_fbo(fbo); + || glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) { + glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX; + glamor_fbo_expire(glamor_priv); + glamor_purge_fbo(glamor_priv, fbo); return; } - cache = &fbo->glamor_priv->fbo_cache[n_format] + cache = &glamor_priv->fbo_cache[n_format] [cache_wbucket(fbo->width)] [cache_hbucket(fbo->height)]; DEBUGF ("Put cache entry %p to cache %p w %d h %d format %x fbo %d tex %d \n", fbo, cache, fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex); - fbo->glamor_priv->fbo_cache_watermark += fbo->width * fbo->height; + glamor_priv->fbo_cache_watermark += fbo->width * fbo->height; xorg_list_add(&fbo->list, cache); - fbo->expire = fbo->glamor_priv->tick + GLAMOR_CACHE_EXPIRE_MAX; + fbo->expire = glamor_priv->tick + GLAMOR_CACHE_EXPIRE_MAX; #endif } static int -glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo) +glamor_pixmap_ensure_fb(glamor_screen_private *glamor_priv, + glamor_pixmap_fbo *fbo) { int status, err = 0; - glamor_make_current(fbo->glamor_priv); + glamor_make_current(glamor_priv); if (fbo->fb == 0) glGenFramebuffers(1, &fbo->fb); @@ -224,11 +227,10 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv, fbo->height = h; fbo->external = FALSE; fbo->format = format; - fbo->glamor_priv = glamor_priv; if (flag != GLAMOR_CREATE_FBO_NO_FBO) { - if (glamor_pixmap_ensure_fb(fbo) != 0) { - glamor_purge_fbo(fbo); + if (glamor_pixmap_ensure_fb(glamor_priv, fbo) != 0) { + glamor_purge_fbo(glamor_priv, fbo); fbo = NULL; } } @@ -258,7 +260,7 @@ glamor_fbo_expire(glamor_screen_private *glamor_priv) xorg_list_del(&fbo_entry->list); DEBUGF("cache %p fbo %p expired %d current %d \n", cache, fbo_entry, fbo_entry->expire, glamor_priv->tick); - glamor_purge_fbo(fbo_entry); + glamor_purge_fbo(glamor_priv, fbo_entry); } } @@ -295,16 +297,17 @@ glamor_fini_pixmap_fbo(ScreenPtr screen) xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) { xorg_list_del(&fbo_entry->list); - glamor_purge_fbo(fbo_entry); + glamor_purge_fbo(glamor_priv, fbo_entry); } } } void -glamor_destroy_fbo(glamor_pixmap_fbo *fbo) +glamor_destroy_fbo(glamor_screen_private *glamor_priv, + glamor_pixmap_fbo *fbo) { xorg_list_del(&fbo->list); - glamor_pixmap_fbo_cache_put(fbo); + glamor_pixmap_fbo_cache_put(glamor_priv, fbo); } @@ -420,7 +423,7 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv, cleanup: for (i = 0; i < block_wcnt * block_hcnt; i++) if ((fbo_array)[i]) - glamor_destroy_fbo((fbo_array)[i]); + glamor_destroy_fbo(glamor_priv, (fbo_array)[i]); free(box_array); free(fbo_array); return NULL; @@ -488,7 +491,8 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo) } void -glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv) +glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv, + glamor_pixmap_private *priv) { glamor_pixmap_fbo *fbo; @@ -497,13 +501,13 @@ glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv) glamor_pixmap_private_large_t *large = &priv->large; for (i = 0; i < large->block_wcnt * large->block_hcnt; i++) - glamor_destroy_fbo(large->fbo_array[i]); + glamor_destroy_fbo(glamor_priv, large->fbo_array[i]); free(large->fbo_array); } else { fbo = glamor_pixmap_detach_fbo(priv); if (fbo) - glamor_destroy_fbo(fbo); + glamor_destroy_fbo(glamor_priv, fbo); } } @@ -533,7 +537,7 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag) pixmap->drawable.height, format); if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->base.fbo->fb == 0) - if (glamor_pixmap_ensure_fb(pixmap_priv->base.fbo) != 0) + if (glamor_pixmap_ensure_fb(glamor_priv, pixmap_priv->base.fbo) != 0) return FALSE; } diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c index 2b9f7f320..232b4023d 100644 --- a/glamor/glamor_gradient.c +++ b/glamor/glamor_gradient.c @@ -682,9 +682,9 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen, return 0; } - glamor_set_destination_pixmap_priv_nc(pixmap_priv); + glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, pixmap_priv); - pixmap_priv_get_dest_scale(pixmap_priv, xscale, yscale); + pixmap_priv_get_dest_scale(pixmap, pixmap_priv, xscale, yscale); DEBUGF("xscale = %f, yscale = %f," " x_source = %d, y_source = %d, width = %d, height = %d\n", diff --git a/glamor/glamor_largepixmap.c b/glamor/glamor_largepixmap.c index 9b2458453..2c91c27de 100644 --- a/glamor/glamor_largepixmap.c +++ b/glamor/glamor_largepixmap.c @@ -150,12 +150,13 @@ __glamor_compute_clipped_regions(int block_w, */ glamor_pixmap_clipped_regions * -glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv, +glamor_compute_clipped_regions_ext(PixmapPtr pixmap, RegionPtr region, int *n_region, int inner_block_w, int inner_block_h, int reverse, int upsidedown) { + glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_clipped_regions *clipped_regions, *inner_regions, *result_regions; int i, j, x, y, k, inner_n_regions; @@ -176,8 +177,8 @@ glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv, clipped_regions[0].block_idx = 0; RegionCopy(clipped_regions[0].region, region); *n_region = 1; - block_w = pixmap_priv->base.pixmap->drawable.width; - block_h = pixmap_priv->base.pixmap->drawable.height; + block_w = pixmap->drawable.width; + block_h = pixmap->drawable.height; box_array = &small_box; small_box.x1 = small_box.y1 = 0; small_box.x2 = block_w; @@ -190,10 +191,8 @@ glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv, priv->block_h, priv->block_wcnt, 0, 0, - priv->base.pixmap-> - drawable.width, - priv->base.pixmap-> - drawable.height, + pixmap->drawable.width, + pixmap->drawable.height, region, n_region, reverse, upsidedown); @@ -336,7 +335,8 @@ _glamor_largepixmap_reflect_fixup(short *xy1, short *xy2, int wh) * */ static glamor_pixmap_clipped_regions * -_glamor_compute_clipped_regions(glamor_pixmap_private *pixmap_priv, +_glamor_compute_clipped_regions(PixmapPtr pixmap, + glamor_pixmap_private *pixmap_priv, RegionPtr region, int *n_region, int repeat_type, int is_transform, int reverse, int upsidedown) @@ -366,8 +366,8 @@ _glamor_compute_clipped_regions(glamor_pixmap_private *pixmap_priv, priv = __glamor_large(pixmap_priv); - pixmap_width = priv->base.pixmap->drawable.width; - pixmap_height = priv->base.pixmap->drawable.height; + pixmap_width = pixmap->drawable.width; + pixmap_height = pixmap->drawable.height; if (repeat_type == 0 || repeat_type == RepeatPad) { RegionPtr saved_region = NULL; @@ -385,10 +385,8 @@ _glamor_compute_clipped_regions(glamor_pixmap_private *pixmap_priv, priv->block_h, priv->block_wcnt, 0, 0, - priv->base.pixmap-> - drawable.width, - priv->base.pixmap-> - drawable.height, + pixmap->drawable.width, + pixmap->drawable.height, region, n_region, reverse, upsidedown); if (saved_region) @@ -670,11 +668,13 @@ _glamor_compute_clipped_regions(glamor_pixmap_private *pixmap_priv, } glamor_pixmap_clipped_regions * -glamor_compute_clipped_regions(glamor_pixmap_private *priv, RegionPtr region, +glamor_compute_clipped_regions(PixmapPtr pixmap, + RegionPtr region, int *n_region, int repeat_type, int reverse, int upsidedown) { - return _glamor_compute_clipped_regions(priv, region, n_region, repeat_type, + glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); + return _glamor_compute_clipped_regions(pixmap, priv, region, n_region, repeat_type, 0, reverse, upsidedown); } @@ -682,12 +682,13 @@ glamor_compute_clipped_regions(glamor_pixmap_private *priv, RegionPtr region, * by default. Or just use region32 for repeat cases? **/ glamor_pixmap_clipped_regions * -glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, +glamor_compute_transform_clipped_regions(PixmapPtr pixmap, struct pixman_transform *transform, RegionPtr region, int *n_region, int dx, int dy, int repeat_type, int reverse, int upsidedown) { + glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); BoxPtr temp_extent; struct pixman_box32 temp_box; struct pixman_box16 short_box; @@ -714,8 +715,8 @@ glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, temp_box.x1 = 0; if (temp_box.y1 < 0) temp_box.y1 = 0; - temp_box.x2 = MIN(temp_box.x2, priv->base.pixmap->drawable.width); - temp_box.y2 = MIN(temp_box.y2, priv->base.pixmap->drawable.height); + temp_box.x2 = MIN(temp_box.x2, pixmap->drawable.width); + temp_box.y2 = MIN(temp_box.y2, pixmap->drawable.height); } /* Now copy back the box32 to a box16 box. */ short_box.x1 = temp_box.x1; @@ -725,7 +726,8 @@ glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, RegionInitBoxes(temp_region, &short_box, 1); DEBUGF("copy to temp source region \n"); DEBUGRegionPrint(temp_region); - ret = _glamor_compute_clipped_regions(priv, + ret = _glamor_compute_clipped_regions(pixmap, + priv, temp_region, n_region, repeat_type, 1, reverse, upsidedown); @@ -747,7 +749,8 @@ glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, * if the clipped result cross the region boundary. */ static void -glamor_merge_clipped_regions(glamor_pixmap_private *pixmap_priv, +glamor_merge_clipped_regions(PixmapPtr pixmap, + glamor_pixmap_private *pixmap_priv, int repeat_type, glamor_pixmap_clipped_regions *clipped_regions, int *n_regions, int *need_clean_fbo) @@ -763,8 +766,8 @@ glamor_merge_clipped_regions(glamor_pixmap_private *pixmap_priv, glamor_pixmap_private_large_t *priv; priv = __glamor_large(pixmap_priv); - pixmap_width = priv->base.pixmap->drawable.width; - pixmap_height = priv->base.pixmap->drawable.height; + pixmap_width = pixmap->drawable.width; + pixmap_height =pixmap->drawable.height; temp_region = RegionCreate(NULL, 4); for (i = 0; i < *n_regions; i++) { @@ -784,10 +787,10 @@ glamor_merge_clipped_regions(glamor_pixmap_private *pixmap_priv, DEBUGF("%d %d %d %d \n", temp_box.x1, temp_box.y1, temp_box.x2, temp_box.y2); temp_pixmap = - glamor_create_pixmap(priv->base.pixmap->drawable.pScreen, + glamor_create_pixmap(pixmap->drawable.pScreen, temp_box.x2 - temp_box.x1, temp_box.y2 - temp_box.y1, - priv->base.pixmap->drawable.depth, + pixmap->drawable.depth, GLAMOR_CREATE_PIXMAP_FIXUP); if (temp_pixmap == NULL) { assert(0); @@ -808,7 +811,7 @@ glamor_merge_clipped_regions(glamor_pixmap_private *pixmap_priv, copy_box.y2 = temp_extent->y2 - temp_extent->y1; dx = temp_extent->x1; dy = temp_extent->y1; - glamor_copy(&priv->base.pixmap->drawable, + glamor_copy(&pixmap->drawable, &temp_pixmap->drawable, NULL, ©_box, 1, dx, dy, 0, 0, 0, NULL); // glamor_solid(temp_pixmap, 0, 0, temp_pixmap->drawable.width, @@ -840,7 +843,7 @@ glamor_merge_clipped_regions(glamor_pixmap_private *pixmap_priv, copy_box.x1, copy_box.y1, copy_box.x2, copy_box.y2, dx, dy); - glamor_copy(&priv->base.pixmap->drawable, + glamor_copy(&pixmap->drawable, &temp_pixmap->drawable, NULL, ©_box, 1, dx, dy, 0, 0, 0, NULL); @@ -966,7 +969,8 @@ glamor_get_transform_extent_from_box(struct pixman_box32 *box, } static void -_glamor_process_transformed_clipped_region(glamor_pixmap_private *priv, +_glamor_process_transformed_clipped_region(PixmapPtr pixmap, + glamor_pixmap_private *priv, int repeat_type, glamor_pixmap_clipped_regions * clipped_regions, int *n_regions, @@ -976,7 +980,7 @@ _glamor_process_transformed_clipped_region(glamor_pixmap_private *priv, if (*n_regions != 1) { /* Merge all source regions into one region. */ - glamor_merge_clipped_regions(priv, repeat_type, + glamor_merge_clipped_regions(pixmap, priv, repeat_type, clipped_regions, n_regions, need_clean_fbo); } @@ -990,22 +994,22 @@ _glamor_process_transformed_clipped_region(glamor_pixmap_private *priv, int rem; temp_box = RegionExtents(clipped_regions[0].region); - modulus(temp_box->x1, priv->base.pixmap->drawable.width, rem); - shift_x = (temp_box->x1 - rem) / priv->base.pixmap->drawable.width; - modulus(temp_box->y1, priv->base.pixmap->drawable.height, rem); - shift_y = (temp_box->y1 - rem) / priv->base.pixmap->drawable.height; + modulus(temp_box->x1, pixmap->drawable.width, rem); + shift_x = (temp_box->x1 - rem) / pixmap->drawable.width; + modulus(temp_box->y1, pixmap->drawable.height, rem); + shift_y = (temp_box->y1 - rem) / pixmap->drawable.height; if (shift_x != 0) { __glamor_large(priv)->box.x1 += - shift_x * priv->base.pixmap->drawable.width; + shift_x * pixmap->drawable.width; __glamor_large(priv)->box.x2 += - shift_x * priv->base.pixmap->drawable.width; + shift_x * pixmap->drawable.width; } if (shift_y != 0) { __glamor_large(priv)->box.y1 += - shift_y * priv->base.pixmap->drawable.height; + shift_y * pixmap->drawable.height; __glamor_large(priv)->box.y2 += - shift_y * priv->base.pixmap->drawable.height; + shift_y * pixmap->drawable.height; } } } @@ -1016,9 +1020,9 @@ glamor_composite_largepixmap_region(CARD8 op, PicturePtr source, PicturePtr mask, PicturePtr dest, - glamor_pixmap_private *source_pixmap_priv, - glamor_pixmap_private *mask_pixmap_priv, - glamor_pixmap_private *dest_pixmap_priv, + PixmapPtr source_pixmap, + PixmapPtr mask_pixmap, + PixmapPtr dest_pixmap, RegionPtr region, Bool force_clip, INT16 x_source, INT16 y_source, @@ -1027,6 +1031,11 @@ glamor_composite_largepixmap_region(CARD8 op, INT16 x_dest, INT16 y_dest, CARD16 width, CARD16 height) { + ScreenPtr screen = dest_pixmap->drawable.pScreen; + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); + glamor_pixmap_private *source_pixmap_priv = glamor_get_pixmap_private(source_pixmap); + glamor_pixmap_private *mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap); + glamor_pixmap_private *dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap); glamor_pixmap_clipped_regions *clipped_dest_regions; glamor_pixmap_clipped_regions *clipped_source_regions; glamor_pixmap_clipped_regions *clipped_mask_regions; @@ -1060,8 +1069,8 @@ glamor_composite_largepixmap_region(CARD8 op, dest_block_width = __glamor_large(dest_pixmap_priv)->block_w; dest_block_height = __glamor_large(dest_pixmap_priv)->block_h; } else { - dest_block_width = dest_pixmap_priv->base.pixmap->drawable.width; - dest_block_height = dest_pixmap_priv->base.pixmap->drawable.height; + dest_block_width = dest_pixmap->drawable.width; + dest_block_height = dest_pixmap->drawable.height; } fixed_block_width = dest_block_width; fixed_block_height = dest_block_height; @@ -1134,12 +1143,12 @@ glamor_composite_largepixmap_region(CARD8 op, if (force_clip || fixed_block_width < dest_block_width || fixed_block_height < dest_block_height) clipped_dest_regions = - glamor_compute_clipped_regions_ext(dest_pixmap_priv, region, + glamor_compute_clipped_regions_ext(dest_pixmap, region, &n_dest_regions, fixed_block_width, fixed_block_height, 0, 0); else - clipped_dest_regions = glamor_compute_clipped_regions(dest_pixmap_priv, + clipped_dest_regions = glamor_compute_clipped_regions(dest_pixmap, region, &n_dest_regions, 0, 0, 0); @@ -1168,7 +1177,7 @@ glamor_composite_largepixmap_region(CARD8 op, RegionTranslate(clipped_dest_regions[i].region, x_source - x_dest, y_source - y_dest); clipped_source_regions = - glamor_compute_clipped_regions(source_pixmap_priv, + glamor_compute_clipped_regions(source_pixmap, clipped_dest_regions[i]. region, &n_source_regions, source_repeat_type, 0, 0); @@ -1176,7 +1185,7 @@ glamor_composite_largepixmap_region(CARD8 op, } else { clipped_source_regions = - glamor_compute_transform_clipped_regions(source_pixmap_priv, + glamor_compute_transform_clipped_regions(source_pixmap, source->transform, clipped_dest_regions [i].region, @@ -1193,7 +1202,7 @@ glamor_composite_largepixmap_region(CARD8 op, } else _glamor_process_transformed_clipped_region - (source_pixmap_priv, source_repeat_type, + (source_pixmap, source_pixmap_priv, source_repeat_type, clipped_source_regions, &n_source_regions, &need_clean_source_fbo); } @@ -1214,7 +1223,7 @@ glamor_composite_largepixmap_region(CARD8 op, RegionTranslate(clipped_source_regions[j].region, -x_source + x_mask, -y_source + y_mask); clipped_mask_regions = - glamor_compute_clipped_regions(mask_pixmap_priv, + glamor_compute_clipped_regions(mask_pixmap, clipped_source_regions [j].region, &n_mask_regions, @@ -1230,7 +1239,7 @@ glamor_composite_largepixmap_region(CARD8 op, RegionTranslate(clipped_dest_regions[i].region, -x_dest + x_mask, -y_dest + y_mask); clipped_mask_regions = - glamor_compute_clipped_regions(mask_pixmap_priv, + glamor_compute_clipped_regions(mask_pixmap, clipped_dest_regions [i].region, &n_mask_regions, @@ -1244,14 +1253,14 @@ glamor_composite_largepixmap_region(CARD8 op, if (!is_normal_source_fbo) clipped_mask_regions = glamor_compute_transform_clipped_regions - (mask_pixmap_priv, mask->transform, + (mask_pixmap, mask->transform, clipped_dest_regions[i].region, &n_mask_regions, x_mask - x_dest, y_mask - y_dest, mask_repeat_type, 0, 0); else clipped_mask_regions = glamor_compute_transform_clipped_regions - (mask_pixmap_priv, mask->transform, + (mask_pixmap, mask->transform, clipped_source_regions[j].region, &n_mask_regions, x_mask - x_source, y_mask - y_source, mask_repeat_type, 0, 0); @@ -1263,7 +1272,7 @@ glamor_composite_largepixmap_region(CARD8 op, } else _glamor_process_transformed_clipped_region - (mask_pixmap_priv, mask_repeat_type, + (mask_pixmap, mask_pixmap_priv, mask_repeat_type, clipped_mask_regions, &n_mask_regions, &need_clean_mask_fbo); } @@ -1273,9 +1282,9 @@ glamor_composite_largepixmap_region(CARD8 op, if (!glamor_composite_clipped_region(op, \ null_source ? NULL : source, \ null_mask ? NULL : mask, dest, \ - null_source ? NULL : source_pixmap_priv, \ - null_mask ? NULL : mask_pixmap_priv, \ - dest_pixmap_priv, region, \ + null_source ? NULL : source_pixmap, \ + null_mask ? NULL : mask_pixmap, \ + dest_pixmap, region, \ x_source, y_source, x_mask, y_mask, \ x_dest, y_dest)) { \ assert(0); \ @@ -1326,7 +1335,7 @@ glamor_composite_largepixmap_region(CARD8 op, null_mask = 0; if (need_clean_mask_fbo) { assert(is_normal_mask_fbo == 0); - glamor_destroy_fbo(mask_pixmap_priv->base.fbo); + glamor_destroy_fbo(glamor_priv, mask_pixmap_priv->base.fbo); mask_pixmap_priv->base.fbo = NULL; need_clean_mask_fbo = 0; } @@ -1355,7 +1364,7 @@ glamor_composite_largepixmap_region(CARD8 op, null_source = 0; if (need_clean_source_fbo) { assert(is_normal_source_fbo == 0); - glamor_destroy_fbo(source_pixmap_priv->base.fbo); + glamor_destroy_fbo(glamor_priv, source_pixmap_priv->base.fbo); source_pixmap_priv->base.fbo = NULL; need_clean_source_fbo = 0; } @@ -1367,7 +1376,7 @@ glamor_composite_largepixmap_region(CARD8 op, RegionTranslate(clipped_dest_regions[i].region, x_mask - x_dest, y_mask - y_dest); clipped_mask_regions = - glamor_compute_clipped_regions(mask_pixmap_priv, + glamor_compute_clipped_regions(mask_pixmap, clipped_dest_regions[i]. region, &n_mask_regions, mask_repeat_type, 0, 0); @@ -1376,7 +1385,7 @@ glamor_composite_largepixmap_region(CARD8 op, else { clipped_mask_regions = glamor_compute_transform_clipped_regions - (mask_pixmap_priv, mask->transform, + (mask_pixmap, mask->transform, clipped_dest_regions[i].region, &n_mask_regions, x_mask - x_dest, y_mask - y_dest, mask_repeat_type, 0, 0); @@ -1388,7 +1397,7 @@ glamor_composite_largepixmap_region(CARD8 op, } else _glamor_process_transformed_clipped_region - (mask_pixmap_priv, mask_repeat_type, + (mask_pixmap, mask_pixmap_priv, mask_repeat_type, clipped_mask_regions, &n_mask_regions, &need_clean_mask_fbo); } @@ -1417,7 +1426,7 @@ glamor_composite_largepixmap_region(CARD8 op, if (null_mask) null_mask = 0; if (need_clean_mask_fbo) { - glamor_destroy_fbo(mask_pixmap_priv->base.fbo); + glamor_destroy_fbo(glamor_priv, mask_pixmap_priv->base.fbo); mask_pixmap_priv->base.fbo = NULL; need_clean_mask_fbo = 0; } diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c index f5021b24d..7935bf25f 100644 --- a/glamor/glamor_pixmap.c +++ b/glamor/glamor_pixmap.c @@ -63,31 +63,36 @@ glamor_pixmap_fini(ScreenPtr screen) } void -glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *fbo, int x0, int y0, +glamor_set_destination_pixmap_fbo(glamor_screen_private *glamor_priv, + glamor_pixmap_fbo *fbo, int x0, int y0, int width, int height) { - glamor_make_current(fbo->glamor_priv); + glamor_make_current(glamor_priv); glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb); glViewport(x0, y0, width, height); } void -glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv) +glamor_set_destination_pixmap_priv_nc(glamor_screen_private *glamor_priv, + PixmapPtr pixmap, + glamor_pixmap_private *pixmap_priv) { int w, h; - PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap_priv, w, h); - glamor_set_destination_pixmap_fbo(pixmap_priv->base.fbo, 0, 0, w, h); + PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, pixmap_priv, w, h); + glamor_set_destination_pixmap_fbo(glamor_priv, pixmap_priv->base.fbo, 0, 0, w, h); } int -glamor_set_destination_pixmap_priv(glamor_pixmap_private *pixmap_priv) +glamor_set_destination_pixmap_priv(glamor_screen_private *glamor_priv, + PixmapPtr pixmap, + glamor_pixmap_private *pixmap_priv) { if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) return -1; - glamor_set_destination_pixmap_priv_nc(pixmap_priv); + glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, pixmap_priv); return 0; } @@ -96,8 +101,10 @@ glamor_set_destination_pixmap(PixmapPtr pixmap) { int err; glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); + ScreenPtr screen = pixmap->drawable.pScreen; + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); - err = glamor_set_destination_pixmap_priv(pixmap_priv); + err = glamor_set_destination_pixmap_priv(glamor_priv, pixmap, pixmap_priv); return err; } @@ -810,7 +817,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, } else { ptexcoords = texcoords_inv; - pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale); + pixmap_priv_get_dest_scale(pixmap, pixmap_priv, &dst_xscale, &dst_yscale); glamor_set_normalize_vcoords(pixmap_priv, dst_xscale, dst_yscale, x, y, @@ -825,7 +832,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GL_FALSE, 2 * sizeof(float), ptexcoords); glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE); - glamor_set_destination_pixmap_priv_nc(pixmap_priv); + glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, pixmap_priv); __glamor_upload_pixmap_to_texture(pixmap, &tex, format, type, 0, 0, w, h, bits, pbo); glActiveTexture(GL_TEXTURE0); @@ -874,7 +881,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha, && (pixmap_priv->base.fbo->width < pixmap->drawable.width || pixmap_priv->base.fbo->height < pixmap->drawable.height)) { fbo = glamor_pixmap_detach_fbo(pixmap_priv); - glamor_destroy_fbo(fbo); + glamor_destroy_fbo(glamor_priv, fbo); } if (pixmap_priv->base.fbo && pixmap_priv->base.fbo->fb) @@ -927,6 +934,8 @@ Bool glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h, int stride, void *bits, int pbo) { + ScreenPtr screen = pixmap->drawable.pScreen; + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); GLenum format, type; int no_alpha, revert, swap_rb; glamor_pixmap_private *pixmap_priv; @@ -944,8 +953,8 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, return FALSE; pixmap_priv = glamor_get_pixmap_private(pixmap); - force_clip = pixmap_priv->base.glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP - && !glamor_check_fbo_size(pixmap_priv->base.glamor_priv, w, h); + force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP + && !glamor_check_fbo_size(glamor_priv, w, h); if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE || force_clip) { RegionRec region; @@ -965,11 +974,11 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, RegionInitBoxes(®ion, &box, 1); if (!force_clip) clipped_regions = - glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, + glamor_compute_clipped_regions(pixmap, ®ion, &n_region, 0, 0, 0); else clipped_regions = - glamor_compute_clipped_regions_ext(pixmap_priv, ®ion, + glamor_compute_clipped_regions_ext(pixmap, ®ion, &n_region, pixmap_priv->large.block_w, pixmap_priv->large.block_h, @@ -1121,7 +1130,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glamor_set_destination_pixmap_fbo(temp_fbo, 0, 0, w, h); + glamor_set_destination_pixmap_fbo(glamor_priv, temp_fbo, 0, 0, w, h); glUseProgram(glamor_priv->finish_access_prog[no_alpha]); glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert); glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb); diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 1df96d640..c5c6bb3a2 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -72,7 +72,7 @@ typedef struct glamor_composite_shader { union { float source_solid_color[4]; struct { - struct glamor_pixmap_private *source_priv; + PixmapPtr source_pixmap; PicturePtr source; }; }; @@ -80,7 +80,7 @@ typedef struct glamor_composite_shader { union { float mask_solid_color[4]; struct { - struct glamor_pixmap_private *mask_priv; + PixmapPtr mask_pixmap; PicturePtr mask; }; }; @@ -369,7 +369,6 @@ typedef struct glamor_pixmap_fbo { Bool external; GLenum format; GLenum type; - glamor_screen_private *glamor_priv; } glamor_pixmap_fbo; /* @@ -449,10 +448,8 @@ typedef struct glamor_pixmap_private_base { unsigned char is_picture:1; unsigned char gl_tex:1; glamor_pixmap_fbo *fbo; - PixmapPtr pixmap; BoxRec box; int drm_stride; - glamor_screen_private *glamor_priv; PicturePtr picture; GLuint pbo; RegionRec prepare_region; @@ -610,6 +607,9 @@ glamor_get_pixmap_private(PixmapPtr pixmap) { glamor_pixmap_private *priv; + if (pixmap == NULL) + return NULL; + priv = dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key); if (!priv) { glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY); @@ -619,6 +619,50 @@ glamor_get_pixmap_private(PixmapPtr pixmap) return priv; } +/* + * Returns TRUE if pixmap has no image object + */ +static inline Bool +glamor_pixmap_drm_only(PixmapPtr pixmap) +{ + glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); + + return priv && priv->base.type == GLAMOR_DRM_ONLY; +} + +/* + * Returns TRUE if pixmap is plain memory (not a GL object at all) + */ +static inline Bool +glamor_pixmap_is_memory(PixmapPtr pixmap) +{ + glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); + + return !priv || priv->base.type == GLAMOR_TEXTURE_LARGE; +} + +/* + * Returns TRUE if pixmap requires multiple textures to hold it + */ +static inline Bool +glamor_pixmap_is_large(PixmapPtr pixmap) +{ + glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); + + return priv && priv->base.type == GLAMOR_TEXTURE_LARGE; +} + +/* + * Returns TRUE if pixmap has an FBO + */ +static inline Bool +glamor_pixmap_has_fbo(PixmapPtr pixmap) +{ + glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap); + + return priv && priv->base.gl_fbo == GLAMOR_FBO_NORMAL; +} + void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv); static inline glamor_gc_private * @@ -652,9 +696,10 @@ glamor_pixmap_fbo *glamor_create_fbo_from_tex(glamor_screen_private * int flag); glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv, int w, int h, GLenum format, int flag); -void glamor_destroy_fbo(glamor_pixmap_fbo *fbo); -void glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv); - +void glamor_destroy_fbo(glamor_screen_private *glamor_priv, + glamor_pixmap_fbo *fbo); +void glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv, + glamor_pixmap_private *priv); void glamor_init_pixmap_fbo(ScreenPtr screen); void glamor_fini_pixmap_fbo(ScreenPtr screen); Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap); @@ -679,13 +724,13 @@ void glamor_get_color_4f_from_pixel(PixmapPtr pixmap, unsigned long fg_pixel, GLfloat *color); int glamor_set_destination_pixmap(PixmapPtr pixmap); -int glamor_set_destination_pixmap_priv(glamor_pixmap_private *pixmap_priv); -void glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *, int, int, int, int); +int glamor_set_destination_pixmap_priv(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv); +void glamor_set_destination_pixmap_fbo(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *, int, int, int, int); /* nc means no check. caller must ensure this pixmap has valid fbo. * usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly. * */ -void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv); +void glamor_set_destination_pixmap_priv_nc(glamor_screen_private *glamor_priv, PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv); glamor_pixmap_fbo *glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, @@ -716,9 +761,9 @@ Bool glamor_composite_clipped_region(CARD8 op, PicturePtr source, PicturePtr mask, PicturePtr dest, - glamor_pixmap_private *soruce_pixmap_priv, - glamor_pixmap_private *mask_pixmap_priv, - glamor_pixmap_private *dest_pixmap_priv, + PixmapPtr source_pixmap, + PixmapPtr mask_pixmap, + PixmapPtr dest_pixmap, RegionPtr region, int x_source, int y_source, @@ -749,23 +794,6 @@ PicturePtr glamor_convert_gradient_picture(ScreenPtr screen, int x_source, int y_source, int width, int height); -Bool glamor_composite_choose_shader(CARD8 op, - PicturePtr source, - PicturePtr mask, - PicturePtr dest, - glamor_pixmap_private *source_pixmap_priv, - glamor_pixmap_private *mask_pixmap_priv, - glamor_pixmap_private *dest_pixmap_priv, - struct shader_key *s_key, - glamor_composite_shader ** shader, - struct blendinfo *op_info, - PictFormatShort *psaved_source_format); - -void glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv, - struct shader_key *key, - glamor_composite_shader *shader, - struct blendinfo *op_info); - void *glamor_setup_composite_vbo(ScreenPtr screen, int n_verts); /* glamor_trapezoid.c */ @@ -832,19 +860,19 @@ Bool glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int pbo); glamor_pixmap_clipped_regions * -glamor_compute_clipped_regions(glamor_pixmap_private *priv, +glamor_compute_clipped_regions(PixmapPtr pixmap, RegionPtr region, int *clipped_nbox, int repeat_type, int reverse, int upsidedown); glamor_pixmap_clipped_regions * -glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv, +glamor_compute_clipped_regions_ext(PixmapPtr pixmap, RegionPtr region, int *n_region, int inner_block_w, int inner_block_h, int reverse, int upsidedown); glamor_pixmap_clipped_regions * -glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, +glamor_compute_transform_clipped_regions(PixmapPtr pixmap, struct pixman_transform *transform, RegionPtr region, int *n_region, int dx, int dy, @@ -855,9 +883,9 @@ Bool glamor_composite_largepixmap_region(CARD8 op, PicturePtr source, PicturePtr mask, PicturePtr dest, - glamor_pixmap_private *source_pixmap_priv, - glamor_pixmap_private *mask_pixmap_priv, - glamor_pixmap_private *dest_pixmap_priv, + PixmapPtr source_pixmap, + PixmapPtr mask_pixmap, + PixmapPtr dest_pixmap, RegionPtr region, Bool force_clip, INT16 x_source, INT16 y_source, diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index 1d60622ed..3ef9a151b 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -482,9 +482,10 @@ glamor_set_composite_op(ScreenPtr screen, static void glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit, PicturePtr picture, - glamor_pixmap_private *pixmap_priv, + PixmapPtr pixmap, GLuint wh_location, GLuint repeat_location) { + glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); float wh[4]; int repeat_type; @@ -546,7 +547,7 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit, repeat_type += RepeatFix; } if (repeat_type >= RepeatFix) { - glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap_priv); + glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap, pixmap_priv); if ((wh[0] != 1.0 || wh[1] != 1.0) || (glamor_priv->gl_flavor == GLAMOR_GL_ES2 && repeat_type == RepeatFix)) @@ -786,7 +787,8 @@ combine_pict_format(PictFormatShort * des, const PictFormatShort src, } static void -glamor_set_normalize_tcoords_generic(glamor_pixmap_private *priv, +glamor_set_normalize_tcoords_generic(PixmapPtr pixmap, + glamor_pixmap_private *priv, int repeat_type, float *matrix, float xscale, float yscale, @@ -804,24 +806,27 @@ glamor_set_normalize_tcoords_generic(glamor_pixmap_private *priv, x2, y2, texcoords, stride); else if (!matrix && repeat_type != RepeatNone) - glamor_set_repeat_normalize_tcoords_ext(priv, repeat_type, + glamor_set_repeat_normalize_tcoords_ext(pixmap, priv, repeat_type, xscale, yscale, x1, y1, x2, y2, texcoords, stride); else if (matrix && repeat_type != RepeatNone) - glamor_set_repeat_transformed_normalize_tcoords_ext(priv, repeat_type, + glamor_set_repeat_transformed_normalize_tcoords_ext(pixmap, priv, repeat_type, matrix, xscale, yscale, x1, y1, x2, y2, texcoords, stride); } -Bool +static Bool glamor_composite_choose_shader(CARD8 op, PicturePtr source, PicturePtr mask, PicturePtr dest, + PixmapPtr source_pixmap, + PixmapPtr mask_pixmap, + PixmapPtr dest_pixmap, glamor_pixmap_private *source_pixmap_priv, glamor_pixmap_private *mask_pixmap_priv, glamor_pixmap_private *dest_pixmap_priv, @@ -831,9 +836,6 @@ glamor_composite_choose_shader(CARD8 op, PictFormatShort *psaved_source_format) { ScreenPtr screen = dest->pDrawable->pScreen; - PixmapPtr dest_pixmap = dest_pixmap_priv->base.pixmap; - PixmapPtr source_pixmap = NULL; - PixmapPtr mask_pixmap = NULL; enum glamor_pixmap_status source_status = GLAMOR_NONE; enum glamor_pixmap_status mask_status = GLAMOR_NONE; PictFormatShort saved_source_format = 0; @@ -926,7 +928,6 @@ glamor_composite_choose_shader(CARD8 op, if (key.source == SHADER_SOURCE_TEXTURE || key.source == SHADER_SOURCE_TEXTURE_ALPHA) { - source_pixmap = source_pixmap_priv->base.pixmap; if (source_pixmap == dest_pixmap) { /* XXX source and the dest share the same texture. * Does it need special handle? */ @@ -944,7 +945,6 @@ glamor_composite_choose_shader(CARD8 op, if (key.mask == SHADER_MASK_TEXTURE || key.mask == SHADER_MASK_TEXTURE_ALPHA) { - mask_pixmap = mask_pixmap_priv->base.pixmap; if (mask_pixmap == dest_pixmap) { glamor_fallback("mask == dest\n"); goto fail; @@ -1052,7 +1052,7 @@ glamor_composite_choose_shader(CARD8 op, memcpy(&(*shader)->source_solid_color[0], source_solid_color, 4 * sizeof(float)); else { - (*shader)->source_priv = source_pixmap_priv; + (*shader)->source_pixmap = source_pixmap; (*shader)->source = source; } @@ -1060,7 +1060,7 @@ glamor_composite_choose_shader(CARD8 op, memcpy(&(*shader)->mask_solid_color[0], mask_solid_color, 4 * sizeof(float)); else { - (*shader)->mask_priv = mask_pixmap_priv; + (*shader)->mask_pixmap = mask_pixmap; (*shader)->mask = mask; } @@ -1076,16 +1076,13 @@ glamor_composite_choose_shader(CARD8 op, return ret; } -void -glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv, +static void +glamor_composite_set_shader_blend(glamor_screen_private *glamor_priv, + glamor_pixmap_private *dest_priv, struct shader_key *key, glamor_composite_shader *shader, struct blendinfo *op_info) { - glamor_screen_private *glamor_priv; - - glamor_priv = dest_priv->base.glamor_priv; - glamor_make_current(glamor_priv); glUseProgram(shader->prog); @@ -1096,7 +1093,7 @@ glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv, else { glamor_set_composite_texture(glamor_priv, 0, shader->source, - shader->source_priv, shader->source_wh, + shader->source_pixmap, shader->source_wh, shader->source_repeat_mode); } @@ -1108,7 +1105,7 @@ glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv, else { glamor_set_composite_texture(glamor_priv, 1, shader->mask, - shader->mask_priv, shader->mask_wh, + shader->mask_pixmap, shader->mask_wh, shader->mask_repeat_mode); } } @@ -1127,6 +1124,9 @@ glamor_composite_with_shader(CARD8 op, PicturePtr source, PicturePtr mask, PicturePtr dest, + PixmapPtr source_pixmap, + PixmapPtr mask_pixmap, + PixmapPtr dest_pixmap, glamor_pixmap_private *source_pixmap_priv, glamor_pixmap_private *mask_pixmap_priv, glamor_pixmap_private *dest_pixmap_priv, @@ -1134,10 +1134,7 @@ glamor_composite_with_shader(CARD8 op, Bool two_pass_ca) { ScreenPtr screen = dest->pDrawable->pScreen; - glamor_screen_private *glamor_priv = dest_pixmap_priv->base.glamor_priv; - PixmapPtr dest_pixmap = dest_pixmap_priv->base.pixmap; - PixmapPtr source_pixmap = NULL; - PixmapPtr mask_pixmap = NULL; + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); GLfloat dst_xscale, dst_yscale; GLfloat mask_xscale = 1, mask_yscale = 1, src_xscale = 1, src_yscale = 1; struct shader_key key, key_ca; @@ -1153,6 +1150,7 @@ glamor_composite_with_shader(CARD8 op, struct blendinfo op_info, op_info_ca; if (!glamor_composite_choose_shader(op, source, mask, dest, + source_pixmap, mask_pixmap, dest_pixmap, source_pixmap_priv, mask_pixmap_priv, dest_pixmap_priv, &key, &shader, &op_info, @@ -1162,6 +1160,7 @@ glamor_composite_with_shader(CARD8 op, } if (two_pass_ca) { if (!glamor_composite_choose_shader(PictOpAdd, source, mask, dest, + source_pixmap, mask_pixmap, dest_pixmap, source_pixmap_priv, mask_pixmap_priv, dest_pixmap_priv, &key_ca, &shader_ca, &op_info_ca, @@ -1171,8 +1170,8 @@ glamor_composite_with_shader(CARD8 op, } } - glamor_set_destination_pixmap_priv_nc(dest_pixmap_priv); - glamor_composite_set_shader_blend(dest_pixmap_priv, &key, shader, &op_info); + glamor_set_destination_pixmap_priv_nc(glamor_priv, dest_pixmap, dest_pixmap_priv); + glamor_composite_set_shader_blend(glamor_priv, dest_pixmap_priv, &key, shader, &op_info); glamor_make_current(glamor_priv); @@ -1184,10 +1183,9 @@ glamor_composite_with_shader(CARD8 op, dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap); glamor_get_drawable_deltas(dest->pDrawable, dest_pixmap, &dest_x_off, &dest_y_off); - pixmap_priv_get_dest_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale); + pixmap_priv_get_dest_scale(dest_pixmap, dest_pixmap_priv, &dst_xscale, &dst_yscale); if (glamor_priv->has_source_coords) { - source_pixmap = source_pixmap_priv->base.pixmap; glamor_get_drawable_deltas(source->pDrawable, source_pixmap, &source_x_off, &source_y_off); pixmap_priv_get_scale(source_pixmap_priv, &src_xscale, &src_yscale); @@ -1198,7 +1196,6 @@ glamor_composite_with_shader(CARD8 op, } if (glamor_priv->has_mask_coords) { - mask_pixmap = mask_pixmap_priv->base.pixmap; glamor_get_drawable_deltas(mask->pDrawable, mask_pixmap, &mask_x_off, &mask_y_off); pixmap_priv_get_scale(mask_pixmap_priv, &mask_xscale, &mask_yscale); @@ -1250,7 +1247,8 @@ glamor_composite_with_shader(CARD8 op, vb_stride); vertices += 2; if (key.source != SHADER_SOURCE_SOLID) { - glamor_set_normalize_tcoords_generic(source_pixmap_priv, + glamor_set_normalize_tcoords_generic(source_pixmap, + source_pixmap_priv, source->repeatType, psrc_matrix, src_xscale, src_yscale, x_source, @@ -1261,7 +1259,8 @@ glamor_composite_with_shader(CARD8 op, } if (key.mask != SHADER_MASK_NONE && key.mask != SHADER_MASK_SOLID) { - glamor_set_normalize_tcoords_generic(mask_pixmap_priv, + glamor_set_normalize_tcoords_generic(mask_pixmap, + mask_pixmap_priv, mask->repeatType, pmask_matrix, mask_xscale, mask_yscale, x_mask, @@ -1280,11 +1279,11 @@ glamor_composite_with_shader(CARD8 op, glamor_flush_composite_rects(screen); nrect -= rect_processed; if (two_pass_ca) { - glamor_composite_set_shader_blend(dest_pixmap_priv, + glamor_composite_set_shader_blend(glamor_priv, dest_pixmap_priv, &key_ca, shader_ca, &op_info_ca); glamor_flush_composite_rects(screen); if (nrect) - glamor_composite_set_shader_blend(dest_pixmap_priv, + glamor_composite_set_shader_blend(glamor_priv, dest_pixmap_priv, &key, shader, &op_info); } } @@ -1371,17 +1370,21 @@ glamor_composite_clipped_region(CARD8 op, PicturePtr source, PicturePtr mask, PicturePtr dest, - glamor_pixmap_private *source_pixmap_priv, - glamor_pixmap_private *mask_pixmap_priv, - glamor_pixmap_private *dest_pixmap_priv, + PixmapPtr source_pixmap, + PixmapPtr mask_pixmap, + PixmapPtr dest_pixmap, RegionPtr region, int x_source, int y_source, int x_mask, int y_mask, int x_dest, int y_dest) { + glamor_pixmap_private *source_pixmap_priv = glamor_get_pixmap_private(source_pixmap); + glamor_pixmap_private *mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap); + glamor_pixmap_private *dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap); ScreenPtr screen = dest->pDrawable->pScreen; - PixmapPtr source_pixmap = NULL, mask_pixmap = NULL; PicturePtr temp_src = source, temp_mask = mask; + PixmapPtr temp_src_pixmap = source_pixmap; + PixmapPtr temp_mask_pixmap = mask_pixmap; glamor_pixmap_private *temp_src_priv = source_pixmap_priv; glamor_pixmap_private *temp_mask_priv = mask_pixmap_priv; int x_temp_src, y_temp_src, x_temp_mask, y_temp_mask; @@ -1411,12 +1414,6 @@ glamor_composite_clipped_region(CARD8 op, DEBUGF("clipped (%d %d) (%d %d) (%d %d) width %d height %d \n", x_source, y_source, x_mask, y_mask, x_dest, y_dest, width, height); - if (source_pixmap_priv) - source_pixmap = source_pixmap_priv->base.pixmap; - - if (mask_pixmap_priv) - mask_pixmap = mask_pixmap_priv->base.pixmap; - /* XXX is it possible source mask have non-zero drawable.x/y? */ if (source && ((!source->pDrawable @@ -1434,8 +1431,8 @@ glamor_composite_clipped_region(CARD8 op, temp_src = source; goto out; } - temp_src_priv = - glamor_get_pixmap_private((PixmapPtr) (temp_src->pDrawable)); + temp_src_pixmap = (PixmapPtr) (temp_src->pDrawable); + temp_src_priv = glamor_get_pixmap_private(temp_src_pixmap); x_temp_src = -extent->x1 + x_dest + dest->pDrawable->x; y_temp_src = -extent->y1 + y_dest + dest->pDrawable->y; } @@ -1458,8 +1455,8 @@ glamor_composite_clipped_region(CARD8 op, temp_mask = mask; goto out; } - temp_mask_priv = - glamor_get_pixmap_private((PixmapPtr) (temp_mask->pDrawable)); + temp_mask_pixmap = (PixmapPtr) (temp_mask->pDrawable); + temp_mask_priv = glamor_get_pixmap_private(temp_mask_pixmap); x_temp_mask = -extent->x1 + x_dest + dest->pDrawable->x; y_temp_mask = -extent->y1 + y_dest + dest->pDrawable->y; } @@ -1521,6 +1518,7 @@ glamor_composite_clipped_region(CARD8 op, DEBUGF("dest %d %d \n", prect[i].x_dst, prect[i].y_dst); } ok = glamor_composite_with_shader(op, temp_src, temp_mask, dest, + temp_src_pixmap, temp_mask_pixmap, dest_pixmap, temp_src_priv, temp_mask_priv, dest_pixmap_priv, box_cnt, prect, two_pass_ca); @@ -1553,8 +1551,6 @@ glamor_composite(CARD8 op, INT16 x_dest, INT16 y_dest, CARD16 width, CARD16 height) { ScreenPtr screen = dest->pDrawable->pScreen; - glamor_pixmap_private *dest_pixmap_priv; - glamor_pixmap_private *source_pixmap_priv = NULL, *mask_pixmap_priv = NULL; PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(dest->pDrawable); PixmapPtr source_pixmap = NULL, mask_pixmap = NULL; glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); @@ -1563,19 +1559,15 @@ glamor_composite(CARD8 op, int nbox, ok = FALSE; int force_clip = 0; - dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap); - if (source->pDrawable) { source_pixmap = glamor_get_drawable_pixmap(source->pDrawable); - source_pixmap_priv = glamor_get_pixmap_private(source_pixmap); - if (source_pixmap_priv && source_pixmap_priv->type == GLAMOR_DRM_ONLY) + if (glamor_pixmap_drm_only(source_pixmap)) goto fail; } if (mask && mask->pDrawable) { mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable); - mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap); - if (mask_pixmap_priv && mask_pixmap_priv->type == GLAMOR_DRM_ONLY) + if (glamor_pixmap_drm_only(mask_pixmap)) goto fail; } @@ -1584,9 +1576,8 @@ glamor_composite(CARD8 op, source_pixmap, x_source, y_source, x_mask, y_mask, x_dest, y_dest, width, height); - if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) { + if (!glamor_pixmap_has_fbo(dest_pixmap)) goto fail; - } if (op >= ARRAY_SIZE(composite_op_info)) goto fail; @@ -1636,28 +1627,28 @@ glamor_composite(CARD8 op, * pixmap. */ if (!glamor_check_fbo_size(glamor_priv, extent->x2 - extent->x1, extent->y2 - extent->y1) - && (dest_pixmap_priv->type != GLAMOR_TEXTURE_LARGE) - && ((source_pixmap_priv - && (source_pixmap_priv->type == GLAMOR_MEMORY || + && glamor_pixmap_is_large(dest_pixmap) + && ((source_pixmap + && (glamor_pixmap_is_memory(source_pixmap) || source->repeatType == RepeatPad)) - || (mask_pixmap_priv && - (mask_pixmap_priv->type == GLAMOR_MEMORY || + || (mask_pixmap && + (glamor_pixmap_is_memory(mask_pixmap) || mask->repeatType == RepeatPad)) - || (!source_pixmap_priv && + || (!source_pixmap && (source->pSourcePict->type != SourcePictTypeSolidFill)) - || (!mask_pixmap_priv && mask && + || (!mask_pixmap && mask && mask->pSourcePict->type != SourcePictTypeSolidFill))) force_clip = 1; - if (force_clip || dest_pixmap_priv->type == GLAMOR_TEXTURE_LARGE - || (source_pixmap_priv - && source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) - || (mask_pixmap_priv && mask_pixmap_priv->type == GLAMOR_TEXTURE_LARGE)) + if (force_clip || glamor_pixmap_is_large(dest_pixmap) + || (source_pixmap + && glamor_pixmap_is_large(source_pixmap)) + || (mask_pixmap && glamor_pixmap_is_large(mask_pixmap))) ok = glamor_composite_largepixmap_region(op, source, mask, dest, - source_pixmap_priv, - mask_pixmap_priv, - dest_pixmap_priv, + source_pixmap, + mask_pixmap, + dest_pixmap, ®ion, force_clip, x_source, y_source, x_mask, y_mask, @@ -1665,9 +1656,9 @@ glamor_composite(CARD8 op, else ok = glamor_composite_clipped_region(op, source, mask, dest, - source_pixmap_priv, - mask_pixmap_priv, - dest_pixmap_priv, + source_pixmap, + mask_pixmap, + dest_pixmap, ®ion, x_source, y_source, x_mask, y_mask, x_dest, y_dest); @@ -1758,21 +1749,27 @@ glamor_composite_glyph_rects(CARD8 op, if (!(glamor_is_large_picture(src) || (mask && glamor_is_large_picture(mask)) || glamor_is_large_picture(dst))) { + PixmapPtr src_pixmap = NULL; + PixmapPtr mask_pixmap = NULL; + PixmapPtr dst_pixmap = NULL; + PixmapPtr temp_src_pixmap = NULL; glamor_pixmap_private *src_pixmap_priv = NULL; glamor_pixmap_private *mask_pixmap_priv = NULL; glamor_pixmap_private *dst_pixmap_priv; glamor_pixmap_private *temp_src_priv = NULL; BoxRec src_extent; - dst_pixmap_priv = glamor_get_pixmap_private - (glamor_get_drawable_pixmap(dst->pDrawable)); + dst_pixmap = glamor_get_drawable_pixmap(dst->pDrawable); + dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap); - if (mask && mask->pDrawable) - mask_pixmap_priv = glamor_get_pixmap_private - (glamor_get_drawable_pixmap(mask->pDrawable)); - if (src->pDrawable) - src_pixmap_priv = glamor_get_pixmap_private - (glamor_get_drawable_pixmap(src->pDrawable)); + if (mask && mask->pDrawable) { + mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable); + mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap); + } + if (src->pDrawable) { + src_pixmap = glamor_get_drawable_pixmap(src->pDrawable); + src_pixmap_priv = glamor_get_pixmap_private(src_pixmap); + } if (!src->pDrawable && (src->pSourcePict->type != SourcePictTypeSolidFill)) { @@ -1788,13 +1785,14 @@ glamor_composite_glyph_rects(CARD8 op, if (!temp_src) goto fallback; - temp_src_priv = glamor_get_pixmap_private - ((PixmapPtr) (temp_src->pDrawable)); + temp_src_pixmap = (PixmapPtr) (temp_src->pDrawable); + temp_src_priv = glamor_get_pixmap_private(temp_src_pixmap); glamor_composite_src_rect_translate(nrect, rects, -src_extent.x1, -src_extent.y1); } else { temp_src = src; + temp_src_pixmap = src_pixmap; temp_src_priv = src_pixmap_priv; } @@ -1802,6 +1800,7 @@ glamor_composite_glyph_rects(CARD8 op, if (op == PictOpOver) { if (glamor_composite_with_shader(PictOpOutReverse, temp_src, mask, dst, + temp_src_pixmap, mask_pixmap, dst_pixmap, temp_src_priv, mask_pixmap_priv, dst_pixmap_priv, nrect, rects, @@ -1811,7 +1810,9 @@ glamor_composite_glyph_rects(CARD8 op, } else { if (glamor_composite_with_shader - (op, temp_src, mask, dst, temp_src_priv, mask_pixmap_priv, + (op, temp_src, mask, dst, + temp_src_pixmap, mask_pixmap, dst_pixmap, + temp_src_priv, mask_pixmap_priv, dst_pixmap_priv, nrect, rects, FALSE)) goto done; } diff --git a/glamor/glamor_transform.c b/glamor/glamor_transform.c index c1df56018..eddc46875 100644 --- a/glamor/glamor_transform.c +++ b/glamor/glamor_transform.c @@ -43,6 +43,8 @@ glamor_set_destination_drawable(DrawablePtr drawable, int *p_off_x, int *p_off_y) { + ScreenPtr screen = drawable->pScreen; + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); int off_x, off_y; @@ -95,7 +97,7 @@ glamor_set_destination_drawable(DrawablePtr drawable, scale_x, (off_x + center_adjust) * scale_x - 1.0f, scale_y, (off_y + center_adjust) * scale_y - 1.0f); - glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y), + glamor_set_destination_pixmap_fbo(glamor_priv, glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y), 0, 0, w, h); } 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, diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c index 83e24adb2..74654f5e9 100644 --- a/glamor/glamor_xv.c +++ b/glamor/glamor_xv.c @@ -241,8 +241,8 @@ glamor_xv_render(glamor_port_private *port_priv) { ScreenPtr screen = port_priv->pPixmap->drawable.pScreen; glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); - glamor_pixmap_private *pixmap_priv = - glamor_get_pixmap_private(port_priv->pPixmap); + PixmapPtr pixmap = port_priv->pPixmap; + glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); glamor_pixmap_private *src_pixmap_priv[3]; float vertices[32], texcoords[8]; BoxPtr box = REGION_RECTS(&port_priv->clip); @@ -282,10 +282,10 @@ glamor_xv_render(glamor_port_private *port_priv) off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright; gamma = 1.0; - pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale); + pixmap_priv_get_dest_scale(pixmap, pixmap_priv, &dst_xscale, &dst_yscale); glamor_get_drawable_deltas(port_priv->pDraw, port_priv->pPixmap, &dst_x_off, &dst_y_off); - glamor_set_destination_pixmap_priv_nc(pixmap_priv); + glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, pixmap_priv); for (i = 0; i < 3; i++) { if (port_priv->src_pix[i]) { |