summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-06-12 23:19:27 -0700
committerEric Anholt <eric@anholt.net>2014-06-12 23:36:17 -0700
commit5d1ce603248f4d20917624858e4f58e256ec5511 (patch)
tree7c3c6ac2c5fbdff4f97886fc5dfce67c3f71dc08
parentd9dedf8a2d9786b3c4ff15de58d51e0398833e54 (diff)
glamor: Fixes for keithp's glamor_prepare.c changes.glamor-prepare-for-keithp
Mostly this is just style consistency. There are a couple of useful changes, though: - Clear the ->pbo field when deleting the PBO. Otherwise, we'd reuse the old name next time we fall back on the pixmap, which would potentially conflict with some other pixmap that genned a new name, or just do a lazy allocation of the name (compat GL context, like we currently use) or error out (core GL context, like we hope to use some day). - Clear the .ptr field when unmapping the PBO. We were only clearing it when freeing a malloced buffer, but the value would be examined when deciding if the buffer was already mapped in the next prepare call.
-rw-r--r--glamor/glamor_prepare.c22
-rw-r--r--glamor/glamor_render.c9
2 files changed, 21 insertions, 10 deletions
diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 6fb8a9156..bc6f663b9 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -90,9 +90,12 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
gl_usage = GL_STREAM_READ;
glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->base.pbo);
- glBufferData(GL_PIXEL_PACK_BUFFER, pixmap->devKind * pixmap->drawable.height, NULL, gl_usage);
+ glBufferData(GL_PIXEL_PACK_BUFFER,
+ pixmap->devKind * pixmap->drawable.height, NULL,
+ gl_usage);
} else {
- pixmap->devPrivate.ptr = malloc (pixmap->devKind * pixmap->drawable.height);
+ pixmap->devPrivate.ptr = malloc(pixmap->devKind *
+ pixmap->drawable.height);
if (!pixmap->devPrivate.ptr)
return FALSE;
}
@@ -142,19 +145,23 @@ glamor_fini_pixmap(PixmapPtr pixmap)
pixmap->devPrivate.ptr = NULL;
}
- if (priv->base.map_access == GLAMOR_ACCESS_RW)
- glamor_upload_boxes(pixmap, RegionRects(&priv->base.prepare_region), RegionNumRects(&priv->base.prepare_region),
+ if (priv->base.map_access == GLAMOR_ACCESS_RW) {
+ glamor_upload_boxes(pixmap,
+ RegionRects(&priv->base.prepare_region),
+ RegionNumRects(&priv->base.prepare_region),
0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
+ }
RegionUninit(&priv->base.prepare_region);
if (glamor_priv->has_rw_pbo) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glDeleteBuffers(1, &priv->base.pbo);
+ priv->base.pbo = 0;
} else {
- free (pixmap->devPrivate.ptr);
- pixmap->devPrivate.ptr = NULL;
+ free(pixmap->devPrivate.ptr);
}
+ pixmap->devPrivate.ptr = NULL;
priv->base.prepared = FALSE;
}
@@ -240,7 +247,8 @@ glamor_prepare_access_gc(GCPtr gc)
{
switch (gc->fillStyle) {
case FillTiled:
- return glamor_prepare_access(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RO);
+ return glamor_prepare_access(&gc->tile.pixmap->drawable,
+ GLAMOR_ACCESS_RO);
case FillStippled:
case FillOpaqueStippled:
return glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index ea08cca4b..6da38da32 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1729,9 +1729,12 @@ _glamor_composite(CARD8 op,
dest->pDrawable->width, dest->pDrawable->height,
glamor_get_picture_location(dest));
- if (glamor_prepare_access_picture_box(dest, GLAMOR_ACCESS_RW, x_dest, y_dest, width, height) &&
- glamor_prepare_access_picture_box(source, GLAMOR_ACCESS_RO, x_source, y_source, width, height) &&
- glamor_prepare_access_picture_box(mask, GLAMOR_ACCESS_RO, x_mask, y_mask, width, height))
+ if (glamor_prepare_access_picture_box(dest, GLAMOR_ACCESS_RW,
+ x_dest, y_dest, width, height) &&
+ glamor_prepare_access_picture_box(source, GLAMOR_ACCESS_RO,
+ x_source, y_source, width, height) &&
+ glamor_prepare_access_picture_box(mask, GLAMOR_ACCESS_RO,
+ x_mask, y_mask, width, height))
{
fbComposite(op,
source, mask, dest,