diff options
author | Keith Packard <keithp@keithp.com> | 2014-10-29 23:47:23 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2015-03-24 12:43:34 -0700 |
commit | e0788a03144186522fd0ef0e9c954e2744b40275 (patch) | |
tree | b856ac85c467c2cc2ae1bbf1cd96f03f33b45fed /glamor | |
parent | cc731ce0ca4d6c5c8d9c1130864e652a814644b4 (diff) |
glamor: Eliminate GLAMOR_TEXTURE_LARGE pixmap type
Initialize full pixmap private for all pixmaps, including block
dimensions and counts so that no checks are needed when walking the
fbos.
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 | 39 | ||||
-rw-r--r-- | glamor/glamor.h | 1 | ||||
-rw-r--r-- | glamor/glamor_fbo.c | 9 | ||||
-rw-r--r-- | glamor/glamor_priv.h | 35 |
4 files changed, 35 insertions, 49 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c index f9ea8e0fa..a6d97eadd 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -60,6 +60,21 @@ glamor_get_drawable_pixmap(DrawablePtr drawable) return (PixmapPtr) drawable; } +static void +glamor_init_pixmap_private_small(PixmapPtr pixmap, glamor_pixmap_private *pixmap_priv) +{ + pixmap_priv->box.x1 = 0; + pixmap_priv->box.x2 = pixmap->drawable.width; + pixmap_priv->box.y1 = 0; + pixmap_priv->box.y2 = pixmap->drawable.height; + pixmap_priv->block_w = pixmap->drawable.width; + pixmap_priv->block_h = pixmap->drawable.height; + pixmap_priv->block_hcnt = 1; + pixmap_priv->block_wcnt = 1; + pixmap_priv->box_array = &pixmap_priv->box; + pixmap_priv->fbo_array = &pixmap_priv->fbo; +} + _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type) { @@ -72,10 +87,7 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type) glamor_set_pixmap_private(pixmap, pixmap_priv); } pixmap_priv->type = type; - pixmap_priv->box.x1 = 0; - pixmap_priv->box.x2 = pixmap->drawable.width; - pixmap_priv->box.y1 = 0; - pixmap_priv->box.y2 = pixmap->drawable.height; + glamor_init_pixmap_private_small(pixmap, pixmap_priv); } _X_EXPORT void @@ -138,7 +150,6 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, unsigned int usage) { PixmapPtr pixmap; - glamor_pixmap_type_t type = GLAMOR_TEXTURE_ONLY; glamor_pixmap_private *pixmap_priv; glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); glamor_pixmap_fbo *fbo = NULL; @@ -171,27 +182,21 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3; screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL); + pixmap_priv->type = GLAMOR_TEXTURE_ONLY; + if (usage == GLAMOR_CREATE_PIXMAP_NO_TEXTURE) { - pixmap_priv->type = GLAMOR_TEXTURE_ONLY; - pixmap_priv->box.x1 = 0; - pixmap_priv->box.y1 = 0; - pixmap_priv->box.x2 = w; - pixmap_priv->box.y2 = h; + glamor_init_pixmap_private_small(pixmap, pixmap_priv); return pixmap; } else if (usage == GLAMOR_CREATE_NO_LARGE || glamor_check_fbo_size(glamor_priv, w, h)) { - pixmap_priv->type = type; - pixmap_priv->box.x1 = 0; - pixmap_priv->box.y1 = 0; - pixmap_priv->box.x2 = w; - pixmap_priv->box.y2 = h; + glamor_init_pixmap_private_small(pixmap, pixmap_priv); fbo = glamor_create_fbo(glamor_priv, w, h, format, usage); } else { int tile_size = glamor_priv->max_fbo_size; - DEBUGF("Create LARGE pixmap %p width %d height %d, tile size %d\n", pixmap, w, h, tile_size); - pixmap_priv->type = GLAMOR_TEXTURE_LARGE; + DEBUGF("Create LARGE pixmap %p width %d height %d, tile size %d\n", + pixmap, w, h, tile_size); fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage, tile_size, tile_size, pixmap_priv); } diff --git a/glamor/glamor.h b/glamor/glamor.h index 1e51d7403..d07182d9e 100644 --- a/glamor/glamor.h +++ b/glamor/glamor.h @@ -56,7 +56,6 @@ typedef enum glamor_pixmap_type { GLAMOR_TEXTURE_DRM, GLAMOR_DRM_ONLY, GLAMOR_TEXTURE_ONLY, - GLAMOR_TEXTURE_LARGE } glamor_pixmap_type_t; #define GLAMOR_EGL_EXTERNAL_BUFFER 3 diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c index 6789b4b36..ea0e80102 100644 --- a/glamor/glamor_fbo.c +++ b/glamor/glamor_fbo.c @@ -473,7 +473,6 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo) pixmap_priv->fbo = fbo; switch (pixmap_priv->type) { - case GLAMOR_TEXTURE_LARGE: case GLAMOR_TEXTURE_ONLY: case GLAMOR_TEXTURE_DRM: pixmap_priv->gl_fbo = GLAMOR_FBO_NORMAL; @@ -484,7 +483,6 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo) pixmap_priv->gl_tex = 0; } pixmap->devPrivate.ptr = NULL; - break; default: break; } @@ -498,11 +496,10 @@ glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv, if (glamor_pixmap_priv_is_large(priv)) { int i; - glamor_pixmap_private *large = priv; - for (i = 0; i < large->block_wcnt * large->block_hcnt; i++) - glamor_destroy_fbo(glamor_priv, large->fbo_array[i]); - free(large->fbo_array); + for (i = 0; i < priv->block_wcnt * priv->block_hcnt; i++) + glamor_destroy_fbo(glamor_priv, priv->fbo_array[i]); + free(priv->fbo_array); } else { fbo = glamor_pixmap_detach_fbo(priv); diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 33b2c5ff8..cd9192446 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -466,7 +466,6 @@ typedef struct glamor_pixmap_private { int block_h; int block_wcnt; int block_hcnt; - int nbox; BoxPtr box_array; glamor_pixmap_fbo **fbo_array; } glamor_pixmap_private; @@ -520,13 +519,13 @@ glamor_pixmap_is_memory(PixmapPtr pixmap) static inline Bool glamor_pixmap_priv_is_large(glamor_pixmap_private *priv) { - return priv && priv->type == GLAMOR_TEXTURE_LARGE; + return priv && (priv->block_wcnt > 1 || priv->block_hcnt > 1); } static inline Bool glamor_pixmap_priv_is_small(glamor_pixmap_private *priv) { - return priv && priv->type != GLAMOR_TEXTURE_LARGE; + return priv && priv->block_wcnt <= 1 && priv->block_hcnt <= 1; } static inline Bool @@ -559,43 +558,29 @@ glamor_set_pixmap_fbo_current(glamor_pixmap_private *priv, int idx) static inline glamor_pixmap_fbo * glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y) { - if (glamor_pixmap_priv_is_large(priv)) { - assert(x < priv->block_wcnt); - assert(y < priv->block_hcnt); - return priv->fbo_array[y * priv->block_wcnt + x]; - } - assert (x == 0); - assert (y == 0); - return priv->fbo; + assert(x < priv->block_wcnt); + assert(y < priv->block_hcnt); + return priv->fbo_array[y * priv->block_wcnt + x]; } static inline BoxPtr glamor_pixmap_box_at(glamor_pixmap_private *priv, int x, int y) { - if (glamor_pixmap_priv_is_large(priv)) { - assert(x < priv->block_wcnt); - assert(y < priv->block_hcnt); - return &priv->box_array[y * priv->block_wcnt + x]; - } - assert (x == 0); - assert (y == 0); - return &priv->box; + assert(x < priv->block_wcnt); + assert(y < priv->block_hcnt); + return &priv->box_array[y * priv->block_wcnt + x]; } static inline int glamor_pixmap_wcnt(glamor_pixmap_private *priv) { - if (glamor_pixmap_priv_is_large(priv)) - return priv->block_wcnt; - return 1; + return priv->block_wcnt; } static inline int glamor_pixmap_hcnt(glamor_pixmap_private *priv) { - if (glamor_pixmap_priv_is_large(priv)) - return priv->block_hcnt; - return 1; + return priv->block_hcnt; } #define glamor_pixmap_loop(priv, x, y) \ |