[PATCH 08/20] glamor: Add new path for migrating pixmaps in/out of CPU memory
Eric Anholt
eric at anholt.net
Thu Mar 20 13:36:52 PDT 2014
Keith Packard <keithp at keithp.com> writes:
> I couldn't get the existing paths to work and they made no sense, so I
> just wrote new ones.
>
> Signed-off-by: Keith Packard <keithp at keithp.com>
> ---
> glamor/Makefile.am | 2 +
> glamor/glamor_prepare.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++
> glamor/glamor_prepare.h | 38 +++++++++++
> glamor/glamor_priv.h | 2 +
> 4 files changed, 209 insertions(+)
> create mode 100644 glamor/glamor_prepare.c
> create mode 100644 glamor/glamor_prepare.h
>
> diff --git a/glamor/Makefile.am b/glamor/Makefile.am
> index 9544923..361c0d6 100644
> --- a/glamor/Makefile.am
> +++ b/glamor/Makefile.am
> @@ -22,6 +22,8 @@ libglamor_la_SOURCES = \
> glamor_setspans.c \
> glamor_render.c \
> glamor_gradient.c \
> + glamor_prepare.c \
> + glamor_prepare.h \
> glamor_program.c \
> glamor_transfer.c \
> glamor_transfer.h \
> diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
> new file mode 100644
> index 0000000..a653572
> --- /dev/null
> +++ b/glamor/glamor_prepare.c
> @@ -0,0 +1,167 @@
> +/*
> + * Copyright © 2014 Keith Packard
> + *
> + * Permission to use, copy, modify, distribute, and sell this software and its
> + * documentation for any purpose is hereby granted without fee, provided that
> + * the above copyright notice appear in all copies and that both that copyright
> + * notice and this permission notice appear in supporting documentation, and
> + * that the name of the copyright holders not be used in advertising or
> + * publicity pertaining to distribution of the software without specific,
> + * written prior permission. The copyright holders make no representations
> + * about the suitability of this software for any purpose. It is provided "as
> + * is" without express or implied warranty.
> + *
> + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
> + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
> + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
> + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
> + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
> + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
> + * OF THIS SOFTWARE.
> + */
> +
> +#include "glamor_priv.h"
> +#include "glamor_prepare.h"
> +#include "glamor_transfer.h"
> +
> +/*
> + * Make a drawable ready to draw with fb by
> + * creating a PBO large enough for the whole object
> + * and downloading all of the FBOs into it.
> + */
> +
> +Bool
> +glamor_prep_drawable(DrawablePtr drawable, Bool write)
> +{
> + PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
> + glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
> + int gl_access, gl_usage;
> + RegionRec region;
> + BoxRec box;
> + int off_x, off_y;
> +
> + if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
> + return TRUE;
> +
> + box.x1 = drawable->x;
> + box.x2 = box.x1 + drawable->width;
> + box.y1 = drawable->y;
> + box.y2 = box.y1 + drawable->height;
> +
> + RegionInit(®ion, &box, 1);
> +
> + /* See if it's already mapped */
> + if (pixmap->devPrivate.ptr) {
> + if (write)
> + FatalError("attempt to remap buffer as writable");
> + RegionSubtract(®ion, ®ion, &priv->base.pbo_region);
> + if (!RegionNotEmpty(®ion))
> + return TRUE;
> +
> + glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->base.pbo);
> + glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
For novices to X, an explanatory comment about the region twiddling
stuff here might be nice:
/* In X, multiple Drawables can be stored in the same Pixmap (such as
* each individual window in a non-composited screen pixmap, or the
* reparented window contents inside the window-manager-decorated window
* pixmap on a composited screen).
*
* 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.
*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140320/8c40051e/attachment-0001.sig>
More information about the xorg-devel
mailing list