Commit 020fcc58 authored by Keith Packard's avatar Keith Packard Committed by Eric Anholt

glamor: Eliminate separate 'large' pixmap private structure

Just embed the large elements in the regular pixmap private and
collapse the union to a single struct.
Signed-off-by: default avatarKeith Packard <keithp@keithp.com>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
parent 9ef5cbf8
......@@ -72,10 +72,10 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
glamor_set_pixmap_private(pixmap, pixmap_priv);
}
pixmap_priv->type = type;
pixmap_priv->base.box.x1 = 0;
pixmap_priv->base.box.x2 = pixmap->drawable.width;
pixmap_priv->base.box.y1 = 0;
pixmap_priv->base.box.y2 = pixmap->drawable.height;
pixmap_priv->box.x1 = 0;
pixmap_priv->box.x2 = pixmap->drawable.width;
pixmap_priv->box.y1 = 0;
pixmap_priv->box.y2 = pixmap->drawable.height;
}
_X_EXPORT void
......@@ -90,7 +90,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
glamor_priv = glamor_get_screen_private(screen);
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (pixmap_priv->base.fbo) {
if (pixmap_priv->fbo) {
fbo = glamor_pixmap_detach_fbo(pixmap_priv);
glamor_destroy_fbo(glamor_priv, fbo);
}
......@@ -116,10 +116,10 @@ glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap)
glamor_priv = glamor_get_screen_private(screen_pixmap->drawable.pScreen);
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
glamor_priv->screen_fbo = pixmap_priv->base.fbo->fb;
glamor_priv->screen_fbo = pixmap_priv->fbo->fb;
pixmap_priv->base.fbo->width = screen_pixmap->drawable.width;
pixmap_priv->base.fbo->height = screen_pixmap->drawable.height;
pixmap_priv->fbo->width = screen_pixmap->drawable.width;
pixmap_priv->fbo->height = screen_pixmap->drawable.height;
}
uint32_t
......@@ -130,7 +130,7 @@ glamor_get_pixmap_texture(PixmapPtr pixmap)
if (pixmap_priv->type != GLAMOR_TEXTURE_ONLY)
return 0;
return pixmap_priv->base.fbo->tex;
return pixmap_priv->fbo->tex;
}
PixmapPtr
......@@ -173,20 +173,20 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
if (usage == GLAMOR_CREATE_PIXMAP_NO_TEXTURE) {
pixmap_priv->type = GLAMOR_TEXTURE_ONLY;
pixmap_priv->base.box.x1 = 0;
pixmap_priv->base.box.y1 = 0;
pixmap_priv->base.box.x2 = w;
pixmap_priv->base.box.y2 = h;
pixmap_priv->box.x1 = 0;
pixmap_priv->box.y1 = 0;
pixmap_priv->box.x2 = w;
pixmap_priv->box.y2 = h;
return pixmap;
}
else if (usage == GLAMOR_CREATE_NO_LARGE ||
glamor_check_fbo_size(glamor_priv, w, h))
{
pixmap_priv->type = type;
pixmap_priv->base.box.x1 = 0;
pixmap_priv->base.box.y1 = 0;
pixmap_priv->base.box.x2 = w;
pixmap_priv->base.box.y2 = h;
pixmap_priv->box.x1 = 0;
pixmap_priv->box.y1 = 0;
pixmap_priv->box.x2 = w;
pixmap_priv->box.y2 = h;
fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
} else {
int tile_size = glamor_priv->max_fbo_size;
......@@ -639,7 +639,7 @@ glamor_fd_from_pixmap(ScreenPtr screen,
return -1;
return glamor_egl_dri3_fd_name_from_tex(screen,
pixmap,
pixmap_priv->base.fbo->tex,
pixmap_priv->fbo->tex,
FALSE, stride, size);
default:
break;
......@@ -664,7 +664,7 @@ glamor_name_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
return -1;
return glamor_egl_dri3_fd_name_from_tex(pixmap->drawable.pScreen,
pixmap,
pixmap_priv->base.fbo->tex,
pixmap_priv->fbo->tex,
TRUE, stride, size);
default:
break;
......
......@@ -43,9 +43,9 @@ glamor_get_drawable_location(const DrawablePtr drawable)
glamor_screen_private *glamor_priv =
glamor_get_screen_private(drawable->pScreen);
if (pixmap_priv == NULL ||
pixmap_priv->base.gl_fbo == GLAMOR_FBO_UNATTACHED)
pixmap_priv->gl_fbo == GLAMOR_FBO_UNATTACHED)
return 'm';
if (pixmap_priv->base.fbo->fb == glamor_priv->screen_fbo)
if (pixmap_priv->fbo->fb == glamor_priv->screen_fbo)
return 's';
else
return 'f';
......
......@@ -189,7 +189,7 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
/* Set the dash pattern as texture 1 */
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, dash_priv->base.fbo->tex);
glBindTexture(GL_TEXTURE_2D, dash_priv->fbo->tex);
glUniform1i(prog->dash_uniform, 1);
glUniform1f(prog->dash_length_uniform, dash_pixmap->drawable.width);
......
......@@ -239,7 +239,6 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
"Failed to create textured screen.");
return FALSE;
}
glamor_set_screen_pixmap(screen_pixmap, NULL);
return TRUE;
}
......@@ -272,7 +271,7 @@ glamor_egl_set_pixmap_image(PixmapPtr pixmap, EGLImageKHR image)
glamor_get_pixmap_private(pixmap);
EGLImageKHR old;
old = pixmap_priv->base.image;
old = pixmap_priv->image;
if (old) {
ScreenPtr screen = pixmap->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
......@@ -280,7 +279,7 @@ glamor_egl_set_pixmap_image(PixmapPtr pixmap, EGLImageKHR image)
eglDestroyImageKHR(glamor_egl->display, old);
}
pixmap_priv->base.image = image;
pixmap_priv->image = image;
}
Bool
......@@ -420,7 +419,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
glamor_make_current(glamor_priv);
image = pixmap_priv->base.image;
image = pixmap_priv->image;
if (!image) {
image = eglCreateImageKHR(glamor_egl->display,
glamor_egl->context,
......@@ -536,7 +535,7 @@ glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
struct glamor_pixmap_private *pixmap_priv =
glamor_get_pixmap_private(pixmap);
if (pixmap_priv && pixmap_priv->base.image) {
if (pixmap_priv && pixmap_priv->image) {
ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
struct glamor_egl_screen_private *glamor_egl =
glamor_egl_get_screen_private(scrn);
......@@ -545,8 +544,8 @@ glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
* a texture. we must call glFlush to make sure the
* operation on that texture has been done.*/
glamor_block_handler(pixmap->drawable.pScreen);
eglDestroyImageKHR(glamor_egl->display, pixmap_priv->base.image);
pixmap_priv->base.image = NULL;
eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
pixmap_priv->image = NULL;
}
}
......@@ -561,13 +560,12 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
glamor_pixmap_exchange_fbos(front, back);
temp = back_priv->base.image;
back_priv->base.image = front_priv->base.image;
front_priv->base.image = temp;
temp = back_priv->image;
back_priv->image = front_priv->image;
front_priv->image = temp;
glamor_set_pixmap_type(front, GLAMOR_TEXTURE_DRM);
glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
}
void
......@@ -589,8 +587,8 @@ glamor_egl_close_screen(ScreenPtr screen)
screen_pixmap = screen->GetScreenPixmap(screen);
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
eglDestroyImageKHR(glamor_egl->display, pixmap_priv->base.image);
pixmap_priv->base.image = NULL;
eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
pixmap_priv->image = NULL;
screen->CloseScreen = glamor_egl->saved_close_screen;
......
......@@ -368,9 +368,9 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
glamor_pixmap_fbo **fbo_array;
BoxPtr box_array;
int i, j;
glamor_pixmap_private_large_t *priv;
glamor_pixmap_private *priv;
priv = &pixmap_priv->large;
priv = pixmap_priv;
block_wcnt = (w + block_w - 1) / block_w;
block_hcnt = (h + block_h - 1) / block_h;
......@@ -407,7 +407,7 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
format,
GLAMOR_CREATE_PIXMAP_FIXUP);
else
fbo_array[i * block_wcnt + j] = priv->base.fbo;
fbo_array[i * block_wcnt + j] = priv->fbo;
if (fbo_array[i * block_wcnt + j] == NULL)
goto cleanup;
}
......@@ -437,8 +437,8 @@ glamor_create_fbo_array(glamor_screen_private *glamor_priv,
int block_w, int block_h,
glamor_pixmap_private *pixmap_priv)
{
pixmap_priv->large.block_w = block_w;
pixmap_priv->large.block_h = block_h;
pixmap_priv->block_w = block_w;
pixmap_priv->block_h = block_h;
return _glamor_create_fbo_array(glamor_priv, w, h, format, flag,
block_w, block_h, pixmap_priv, 0);
}
......@@ -451,11 +451,11 @@ glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv)
if (pixmap_priv == NULL)
return NULL;
fbo = pixmap_priv->base.fbo;
fbo = pixmap_priv->fbo;
if (fbo == NULL)
return NULL;
pixmap_priv->base.fbo = NULL;
pixmap_priv->fbo = NULL;
return fbo;
}
......@@ -467,21 +467,21 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (pixmap_priv->base.fbo)
if (pixmap_priv->fbo)
return;
pixmap_priv->base.fbo = fbo;
pixmap_priv->fbo = fbo;
switch (pixmap_priv->type) {
case GLAMOR_TEXTURE_LARGE:
case GLAMOR_TEXTURE_ONLY:
case GLAMOR_TEXTURE_DRM:
pixmap_priv->base.gl_fbo = GLAMOR_FBO_NORMAL;
pixmap_priv->gl_fbo = GLAMOR_FBO_NORMAL;
if (fbo->tex != 0)
pixmap_priv->base.gl_tex = 1;
pixmap_priv->gl_tex = 1;
else {
/* XXX For the Xephyr only, may be broken now. */
pixmap_priv->base.gl_tex = 0;
pixmap_priv->gl_tex = 0;
}
pixmap->devPrivate.ptr = NULL;
break;
......@@ -498,7 +498,7 @@ glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv,
if (priv->type == GLAMOR_TEXTURE_LARGE) {
int i;
glamor_pixmap_private_large_t *large = &priv->large;
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]);
......@@ -520,7 +520,7 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (pixmap_priv->base.fbo == NULL) {
if (pixmap_priv->fbo == NULL) {
fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
pixmap->drawable.height, format, flag);
......@@ -531,13 +531,13 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
}
else {
/* We do have a fbo, but it may lack of fb or tex. */
if (!pixmap_priv->base.fbo->tex)
pixmap_priv->base.fbo->tex =
if (!pixmap_priv->fbo->tex)
pixmap_priv->fbo->tex =
_glamor_create_tex(glamor_priv, pixmap->drawable.width,
pixmap->drawable.height, format);
if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->base.fbo->fb == 0)
if (glamor_pixmap_ensure_fb(glamor_priv, pixmap_priv->base.fbo) != 0)
if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->fbo->fb == 0)
if (glamor_pixmap_ensure_fb(glamor_priv, pixmap_priv->fbo) != 0)
return FALSE;
}
......@@ -552,7 +552,7 @@ glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back)
front_priv = glamor_get_pixmap_private(front);
back_priv = glamor_get_pixmap_private(back);
temp_fbo = front_priv->base.fbo;
front_priv->base.fbo = back_priv->base.fbo;
back_priv->base.fbo = temp_fbo;
temp_fbo = front_priv->fbo;
front_priv->fbo = back_priv->fbo;
back_priv->fbo = temp_fbo;
}
......@@ -2,10 +2,10 @@
#include "glamor_priv.h"
static inline glamor_pixmap_private_large_t *
static inline glamor_pixmap_private *
__glamor_large(glamor_pixmap_private *pixmap_priv) {
assert(pixmap_priv->type == GLAMOR_TEXTURE_LARGE);
return &pixmap_priv->large;
return pixmap_priv;
}
/**
......@@ -185,7 +185,7 @@ glamor_compute_clipped_regions_ext(PixmapPtr pixmap,
small_box.y2 = block_h;
}
else {
glamor_pixmap_private_large_t *priv = __glamor_large(pixmap_priv);
glamor_pixmap_private *priv = __glamor_large(pixmap_priv);
clipped_regions = __glamor_compute_clipped_regions(priv->block_w,
priv->block_h,
......@@ -352,7 +352,7 @@ _glamor_compute_clipped_regions(PixmapPtr pixmap,
int right_shift = 0;
int down_shift = 0;
int x_center_shift = 0, y_center_shift = 0;
glamor_pixmap_private_large_t *priv;
glamor_pixmap_private *priv;
DEBUGRegionPrint(region);
if (pixmap_priv->type != GLAMOR_TEXTURE_LARGE) {
......@@ -763,7 +763,7 @@ glamor_merge_clipped_regions(PixmapPtr pixmap,
int overlap;
int i;
int pixmap_width, pixmap_height;
glamor_pixmap_private_large_t *priv;
glamor_pixmap_private *priv;
priv = __glamor_large(pixmap_priv);
pixmap_width = pixmap->drawable.width;
......@@ -858,7 +858,7 @@ glamor_merge_clipped_regions(PixmapPtr pixmap,
RegionDestroy(clipped_regions[i].region);
RegionDestroy(temp_region);
priv->box = temp_box;
priv->base.fbo = glamor_pixmap_detach_fbo(temp_priv);
priv->fbo = glamor_pixmap_detach_fbo(temp_priv);
DEBUGF("priv box x1 %d y1 %d x2 %d y2 %d \n",
priv->box.x1, priv->box.y1, priv->box.x2, priv->box.y2);
glamor_destroy_pixmap(temp_pixmap);
......@@ -1335,8 +1335,8 @@ glamor_composite_largepixmap_region(CARD8 op,
null_mask = 0;
if (need_clean_mask_fbo) {
assert(is_normal_mask_fbo == 0);
glamor_destroy_fbo(glamor_priv, mask_pixmap_priv->base.fbo);
mask_pixmap_priv->base.fbo = NULL;
glamor_destroy_fbo(glamor_priv, mask_pixmap_priv->fbo);
mask_pixmap_priv->fbo = NULL;
need_clean_mask_fbo = 0;
}
}
......@@ -1364,8 +1364,8 @@ glamor_composite_largepixmap_region(CARD8 op,
null_source = 0;
if (need_clean_source_fbo) {
assert(is_normal_source_fbo == 0);
glamor_destroy_fbo(glamor_priv, source_pixmap_priv->base.fbo);
source_pixmap_priv->base.fbo = NULL;
glamor_destroy_fbo(glamor_priv, source_pixmap_priv->fbo);
source_pixmap_priv->fbo = NULL;
need_clean_source_fbo = 0;
}
}
......@@ -1426,8 +1426,8 @@ glamor_composite_largepixmap_region(CARD8 op,
if (null_mask)
null_mask = 0;
if (need_clean_mask_fbo) {
glamor_destroy_fbo(glamor_priv, mask_pixmap_priv->base.fbo);
mask_pixmap_priv->base.fbo = NULL;
glamor_destroy_fbo(glamor_priv, mask_pixmap_priv->fbo);
mask_pixmap_priv->fbo = NULL;
need_clean_mask_fbo = 0;
}
}
......
......@@ -70,8 +70,8 @@ glamor_create_picture(PicturePtr picture)
pixmap_priv = glamor_get_pixmap_private(pixmap);
}
pixmap_priv->base.is_picture = 1;
pixmap_priv->base.picture = picture;
pixmap_priv->is_picture = 1;
pixmap_priv->picture = picture;
return miCreatePicture(picture);
}
......@@ -89,8 +89,8 @@ glamor_destroy_picture(PicturePtr picture)
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (pixmap_priv) {
pixmap_priv->base.is_picture = 0;
pixmap_priv->base.picture = NULL;
pixmap_priv->is_picture = 0;
pixmap_priv->picture = NULL;
}
miDestroyPicture(picture);
}
......@@ -99,5 +99,5 @@ void
glamor_picture_format_fixup(PicturePtr picture,
glamor_pixmap_private *pixmap_priv)
{
pixmap_priv->base.picture = picture;
pixmap_priv->picture = picture;
}
......@@ -81,7 +81,7 @@ glamor_set_destination_pixmap_priv_nc(glamor_screen_private *glamor_priv,
int 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);
glamor_set_destination_pixmap_fbo(glamor_priv, pixmap_priv->fbo, 0, 0, w, h);
}
int
......@@ -478,7 +478,7 @@ glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
pict_format = pixmap_priv->base.picture->format;
pict_format = pixmap_priv->picture->format;
else
pict_format = format_for_depth(pixmap->drawable.depth);
......@@ -804,13 +804,13 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
) {
int fbo_x_off, fbo_y_off;
assert(pixmap_priv->base.fbo->tex);
assert(pixmap_priv->fbo->tex);
pixmap_priv_get_fbo_off(pixmap_priv, &fbo_x_off, &fbo_y_off);
assert(x + fbo_x_off >= 0 && y + fbo_y_off >= 0);
assert(x + fbo_x_off + w <= pixmap_priv->base.fbo->width);
assert(y + fbo_y_off + h <= pixmap_priv->base.fbo->height);
__glamor_upload_pixmap_to_texture(pixmap, &pixmap_priv->base.fbo->tex,
assert(x + fbo_x_off + w <= pixmap_priv->fbo->width);
assert(y + fbo_y_off + h <= pixmap_priv->fbo->height);
__glamor_upload_pixmap_to_texture(pixmap, &pixmap_priv->fbo->tex,
format, type,
x + fbo_x_off, y + fbo_y_off, w, h,
bits, pbo);
......@@ -874,17 +874,17 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha,
pixmap_priv = glamor_get_pixmap_private(pixmap);
glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
if (pixmap_priv->base.gl_fbo != GLAMOR_FBO_UNATTACHED)
if (pixmap_priv->gl_fbo != GLAMOR_FBO_UNATTACHED)
return 0;
if (pixmap_priv->base.fbo
&& (pixmap_priv->base.fbo->width < pixmap->drawable.width
|| pixmap_priv->base.fbo->height < pixmap->drawable.height)) {
if (pixmap_priv->fbo
&& (pixmap_priv->fbo->width < pixmap->drawable.width
|| pixmap_priv->fbo->height < pixmap->drawable.height)) {
fbo = glamor_pixmap_detach_fbo(pixmap_priv);
glamor_destroy_fbo(glamor_priv, fbo);
}
if (pixmap_priv->base.fbo && pixmap_priv->base.fbo->fb)
if (pixmap_priv->fbo && pixmap_priv->fbo->fb)
return 0;
if (!(no_alpha || (revert == REVERT_NORMAL)
......@@ -895,8 +895,8 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha,
}
if ((flag == GLAMOR_CREATE_FBO_NO_FBO
&& pixmap_priv->base.fbo && pixmap_priv->base.fbo->tex)
|| (flag == 0 && pixmap_priv->base.fbo && pixmap_priv->base.fbo->fb))
&& pixmap_priv->fbo && pixmap_priv->fbo->tex)
|| (flag == 0 && pixmap_priv->fbo && pixmap_priv->fbo->fb))
return 0;
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
......@@ -980,8 +980,8 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
clipped_regions =
glamor_compute_clipped_regions_ext(pixmap, &region,
&n_region,
pixmap_priv->large.block_w,
pixmap_priv->large.block_h,
pixmap_priv->block_w,
pixmap_priv->block_h,
0,
0);
DEBUGF("prepare upload %dx%d to a large pixmap %p\n", w, h, pixmap);
......@@ -1052,10 +1052,10 @@ glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
pixmap_priv = glamor_get_pixmap_private(pixmap);
if ((pixmap_priv->base.fbo)
&& (pixmap_priv->base.fbo->pbo_valid)) {
if ((pixmap_priv->fbo)
&& (pixmap_priv->fbo->pbo_valid)) {
data = NULL;
pbo = pixmap_priv->base.fbo->pbo;
pbo = pixmap_priv->fbo->pbo;
}
else {
data = pixmap->devPrivate.ptr;
......@@ -1126,7 +1126,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, source_priv->base.fbo->tex);
glBindTexture(GL_TEXTURE_2D, source_priv->fbo->tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
......
......@@ -54,7 +54,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
* we'll assume that it's directly mapped
* by a lower level driver
*/
if (!priv->base.prepared)
if (!priv->prepared)
return TRUE;
/* In X, multiple Drawables can be stored in the same Pixmap (such as
......@@ -65,28 +65,28 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
* As a result, when doing a series of mappings for a fallback, we may
* need to add more boxes to the set of data we've downloaded, as we go.
*/
RegionSubtract(&region, &region, &priv->base.prepare_region);
RegionSubtract(&region, &region, &priv->prepare_region);
if (!RegionNotEmpty(&region))
return TRUE;
if (access == GLAMOR_ACCESS_RW)
FatalError("attempt to remap buffer as writable");
if (priv->base.pbo) {
glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->base.pbo);
if (priv->pbo) {
glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->pbo);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
pixmap->devPrivate.ptr = NULL;
}
} else {
RegionInit(&priv->base.prepare_region, box, 1);
RegionInit(&priv->prepare_region, box, 1);
if (glamor_priv->has_rw_pbo) {
if (priv->base.pbo == 0)
glGenBuffers(1, &priv->base.pbo);
if (priv->pbo == 0)
glGenBuffers(1, &priv->pbo);
gl_usage = GL_STREAM_READ;
glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->base.pbo);
glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->pbo);
glBufferData(GL_PIXEL_PACK_BUFFER,
pixmap->devKind * pixmap->drawable.height, NULL,
gl_usage);
......@@ -96,7 +96,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
if (!pixmap->devPrivate.ptr)
return FALSE;
}
priv->base.map_access = access;
priv->map_access = access;
}
glamor_download_boxes(pixmap, RegionRects(&region), RegionNumRects(&region),
......@@ -105,7 +105,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
RegionUninit(&region);
if (glamor_priv->has_rw_pbo) {
if (priv->base.map_access == GLAMOR_ACCESS_RW)
if (priv->map_access == GLAMOR_ACCESS_RW)
gl_access = GL_READ_WRITE;
else
gl_access = GL_READ_ONLY;
......@@ -114,7 +114,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
}
priv->base.prepared = TRUE;
priv->prepared = TRUE;
return TRUE;
}
......@@ -133,34 +133,34 @@ glamor_fini_pixmap(PixmapPtr pixmap)
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
return;
if (!priv->base.prepared)
if (!priv->prepared)
return;
if (glamor_priv->has_rw_pbo) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, priv->base.pbo);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, priv->pbo);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
pixmap->devPrivate.ptr = NULL;
}
if (priv->base.map_access == GLAMOR_ACCESS_RW) {
if (priv->map_access == GLAMOR_ACCESS_RW) {
glamor_upload_boxes(pixmap,
RegionRects(&priv->base.prepare_region),
RegionNumRects(&priv->base.prepare_region),
RegionRects(&priv->prepare_region),
RegionNumRects(&priv->prepare_region),
0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
}
RegionUninit(&priv->base.prepare_region);
RegionUninit(&priv->prepare_region);
if (glamor_priv->has_rw_pbo) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glDeleteBuffers(1, &priv->base.pbo);
priv->base.pbo = 0;
glDeleteBuffers(1, &priv->pbo);
priv->pbo = 0;
} else {
free(pixmap->devPrivate.ptr);
pixmap->devPrivate.ptr = NULL;
}
priv->base.prepared = FALSE;
priv->prepared = FALSE;
}
Bool
......
......@@ -377,6 +377,14 @@ typedef struct glamor_pixmap_fbo {
* @is_picture: The drawable is attached to a picture.
* @pict_format: the corresponding picture's format.
* @pixmap: The corresponding pixmap's pointer.
* @box: current fbo's coords in the whole pixmap.
* @block_w: block width of this large pixmap.
* @block_h: block height of this large pixmap.
* @block_wcnt: block count in one block row.
* @block_hcnt: block count in one block column.
* @nbox: total block count.
* @box_array: contains each block's corresponding box.
* @fbo_array: contains each block's fbo pointer.
*
* For GLAMOR_TEXTURE_LARGE, nbox should larger than 1.
* And the box and fbo will both have nbox elements.
......@@ -426,9 +434,6 @@ typedef struct glamor_pixmap_fbo {
* to the box and fbo elements. Thus the inner routines
* can handle it as normal, only the coords calculation need
* to aware of it's large pixmap.
*
* Currently, we haven't implemented the atlas pixmap.
*
**/
typedef struct glamor_pixmap_clipped_regions {
......@@ -436,7 +441,7 @@ typedef struct glamor_pixmap_clipped_regions {
RegionPtr region;
} glamor_pixmap_clipped_regions;
typedef struct glamor_pixmap_private_base {
typedef struct glamor_pixmap_private {
glamor_pixmap_type_t type;
enum glamor_fbo_state gl_fbo;
/**
......@@ -457,26 +462,6 @@ typedef struct glamor_pixmap_private_base {
#if GLAMOR_HAS_GBM
EGLImageKHR image;
#endif
} glamor_pixmap_private_base_t;
/*
* @base.fbo: current fbo.
* @box: current fbo's coords in the whole pixmap.
* @block_w: block width of this large pixmap.
* @block_h: block height of this large pixmap.
* @block_wcnt: block count in one block row.
* @block_hcnt: block count in one block column.
* @nbox: total block count.
* @box_array: contains each block's corresponding box.
* @fbo_array: contains each block's fbo pointer.
*
**/
typedef struct glamor_pixmap_private_large {
union {
glamor_pixmap_type_t type;
glamor_pixmap_private_base_t base;
};
BoxRec box;
int block_w;
int block_h;
int block_wcnt;
......@@ -484,22 +469,19 @@ typedef struct glamor_pixmap_private_large {
int nbox;
BoxPtr box_array;
glamor_pixmap_fbo **fbo_array;
} glamor_pixmap_private_large_t;
typedef struct glamor_pixmap_private {
union {
glamor_pixmap_type_t type;
glamor_pixmap_private_base_t base;
glamor_pixmap_private_large_t large;
};
} glamor_pixmap_private;
/*
* @base.fbo: current fbo.
*
**/
static inline void
glamor_set_pixmap_fbo_current(glamor_pixmap_private *priv, int idx)
{
if (priv->type == GLAMOR_TEXTURE_LARGE) {
priv->large.base.fbo = priv->large.fbo_array[idx];
priv->large.box = priv->large.box_array[idx];
priv->fbo = priv->fbo_array[idx];
priv->box = priv->box_array[idx];
}
}
......@@ -507,33 +489,33 @@ static inline glamor_pixmap_fbo *
glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y)
{
if (priv->type == GLAMOR_TEXTURE_LARGE) {
assert(x < priv->large.block_wcnt);
assert(y < priv->large.block_hcnt);
return priv->large.fbo_array[y * priv->large.block_wcnt + x];
assert(x < priv->block_wcnt);