xglScreenInfoRec xglScreenInfo = {
NULL, 0, 0, 0, 0, FALSE,
DEFAULT_GEOMETRY_DATA_TYPE,
- DEFAULT_GEOMETRY_USAGE
+ DEFAULT_GEOMETRY_USAGE,
+ FALSE,
+ XGL_DEFAULT_PBO_MASK
};
static Bool
extern WindowPtr *WindowTable;
+#define XGL_DEFAULT_PBO_MASK 0 /* don't use PBO as default */
+
typedef struct _xglScreenInfo {
glitz_drawable_t *drawable;
unsigned int width;
Bool fullscreen;
int geometryDataType;
int geometryUsage;
+ Bool yInverted;
+ int pboMask;
} xglScreenInfoRec, *xglScreenInfoPtr;
typedef struct _xglPixelFormat {
int nOffscreen;
int geometryUsage;
int geometryDataType;
+ Bool yInverted;
+ int pboMask;
xglGeometryRec scratchGeometry;
#ifdef RENDER
/* xglpixmap.c */
+#define XGL_PIXMAP_USAGE_HINT_STREAM_DRAW 1
+#define XGL_PIXMAP_USAGE_HINT_STREAM_READ 2
+#define XGL_PIXMAP_USAGE_HINT_STREAM_COPY 3
+#define XGL_PIXMAP_USAGE_HINT_STATIC_DRAW 4
+#define XGL_PIXMAP_USAGE_HINT_STATIC_READ 5
+#define XGL_PIXMAP_USAGE_HINT_STATIC_COPY 6
+#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_DRAW 7
+#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_READ 8
+#define XGL_PIXMAP_USAGE_HINT_DYNAMIC_COPY 9
+
+#define XGL_PIXMAP_USAGE_HINT_DEFAULT XGL_PIXMAP_USAGE_HINT_STREAM_DRAW
+
PixmapPtr
xglCreatePixmap (ScreenPtr pScreen,
int width,
int height,
int depth);
+void
+xglFiniPixmap (PixmapPtr pPixmap);
+
Bool
xglDestroyPixmap (PixmapPtr pPixmap);
xglCreatePixmapSurface (PixmapPtr pPixmap);
Bool
-xglAllocatePixmapBits (PixmapPtr pPixmap);
+xglAllocatePixmapBits (PixmapPtr pPixmap, int hint);
Bool
xglMapPixmapBits (PixmapPtr pPixmap);
if (xglPbufferVisuals)
{
xglPbufferVisuals[nxglPbufferVisuals].format = format;
- xglPbufferVisuals[nxglPbufferVisuals].pPixel = pPixelFormat;
- xglPbufferVisuals[nxglPbufferVisuals].visuals = visuals;
+ xglPbufferVisuals[nxglPbufferVisuals].pPixel = NULL;
+ xglPbufferVisuals[nxglPbufferVisuals].visuals = 0;
nxglPbufferVisuals++;
}
}
rm, gm, bm);
}
}
-
-#if 1
- {
- for (j = 0; j < nxglVisuals; j++)
- {
- ErrorF ("Visual: 0x%x (%c) - r/g/b/a: %d/%d/%d/%d db: %d\n",
- (int) xglVisuals[j].format->id,
- xglVisuals[j].format->types.pbuffer? 'y' : 'n',
- xglVisuals[j].format->color.red_size,
- xglVisuals[j].format->color.green_size,
- xglVisuals[j].format->color.blue_size,
- xglVisuals[j].format->color.alpha_size,
- xglVisuals[j].format->doublebuffer);
- }
- }
-#endif
-
}
void
pBox++;
}
-
- if (pPixmapPriv->target == xglPixmapTargetIn)
- {
- if (!xglSyncSurface (pDst))
- FatalError (XGL_SW_FAILURE_STRING);
- }
} else
xglAddCurrentBitDamage (pDst);
}
ErrorF ("-vertextype [short|float] set vertex data type\n");
ErrorF ("-vbostream "
"use vertex buffer objects for streaming of vertex data\n");
+ ErrorF ("-yinverted Y is upside-down\n");
+ ErrorF ("-pbomask [1|4|8|16|32] "
+ "set bpp's to use with pixel buffer objects\n");
}
int
pScreenInfo->geometryUsage = GEOMETRY_USAGE_STREAM;
return 1;
}
+ else if (!strcmp (argv[i], "-yinverted"))
+ {
+ pScreenInfo->yInverted = TRUE;
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-pbomask"))
+ {
+ if ((i + 1) < argc)
+ {
+ pScreenInfo->pboMask = atoi (argv[i + 1]);
+ }
+ else
+ return 1;
+
+ return 2;
+ }
return 0;
}
#include "xgl.h"
#include "fb.h"
+static glitz_buffer_hint_t xglPixmapUsageHints[] = {
+ (glitz_buffer_hint_t) 0, /* reserved for system memory */
+ GLITZ_BUFFER_HINT_STREAM_DRAW,
+ GLITZ_BUFFER_HINT_STREAM_READ,
+ GLITZ_BUFFER_HINT_STREAM_COPY,
+ GLITZ_BUFFER_HINT_STATIC_DRAW,
+ GLITZ_BUFFER_HINT_STATIC_READ,
+ GLITZ_BUFFER_HINT_STATIC_COPY,
+ GLITZ_BUFFER_HINT_DYNAMIC_DRAW,
+ GLITZ_BUFFER_HINT_DYNAMIC_READ,
+ GLITZ_BUFFER_HINT_DYNAMIC_COPY
+};
+
+#define NUM_XGL_PIXMAP_USAGE_HINTS \
+ (sizeof (xglPixmapUsageHints) / sizeof (xglPixmapUsageHints[0]))
+
+#define XGL_PIXMAP_USAGE_HINT(hint) (xglPixmapUsageHints[hint])
+
static void
xglPixmapDamageReport (DamagePtr pDamage,
RegionPtr pRegion,
return pPixmap;
}
-Bool
-xglDestroyPixmap (PixmapPtr pPixmap)
+void
+xglFiniPixmap (PixmapPtr pPixmap)
{
XGL_PIXMAP_PRIV (pPixmap);
-
- if (--pPixmap->refcnt)
- return TRUE;
-
+
if (pPixmapPriv->pArea)
xglWithdrawArea (pPixmapPriv->pArea);
if (pPixmapPriv->surface)
glitz_surface_destroy (pPixmapPriv->surface);
+}
+
+Bool
+xglDestroyPixmap (PixmapPtr pPixmap)
+{
+ if (--pPixmap->refcnt)
+ return TRUE;
+
+ xglFiniPixmap (pPixmap);
xfree (pPixmap);
glitz_surface_reference (pScreenPriv->surface);
pPixmapPriv->surface = pScreenPriv->surface;
- pPixmapPriv->pPixel = pScreenPriv->pVisual[0].pPixel;
pPixmapPriv->target = xglPixmapTargetIn;
pScreenPriv->pScreenPixmap = pPixmap;
if (!pPixmapPriv->buffer)
{
- if (!xglAllocatePixmapBits (pPixmap))
+ if (!xglAllocatePixmapBits (pPixmap,
+ XGL_PIXMAP_USAGE_HINT_DEFAULT))
return NULL;
}
}
Bool
-xglAllocatePixmapBits (PixmapPtr pPixmap)
+xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
{
int width, height, bpp, stride;
XGL_PIXMAP_PRIV (pPixmap);
+ XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
width = pPixmap->drawable.width;
height = pPixmap->drawable.height;
if (stride)
{
- pPixmapPriv->bits = xalloc (height * stride);
- if (!pPixmapPriv->bits)
- return FALSE;
+ glitz_buffer_t *buffer;
+
+ if ((pScreenPriv->pboMask & bpp) && hint)
+ {
+ buffer = glitz_pixel_buffer_create (pScreenPriv->drawable,
+ NULL, height * stride,
+ XGL_PIXMAP_USAGE_HINT (hint));
+ }
+ else
+ {
+ pPixmapPriv->bits = xalloc (height * stride);
+ if (!pPixmapPriv->bits)
+ return FALSE;
- pPixmapPriv->buffer =
- glitz_buffer_create_for_data (pPixmapPriv->bits);
- if (!pPixmapPriv->buffer)
+ buffer = glitz_buffer_create_for_data (pPixmapPriv->bits);
+ }
+
+ if (!buffer)
{
- xfree (pPixmapPriv->bits);
+ if (pPixmapPriv->bits)
+ xfree (pPixmapPriv->bits);
pPixmapPriv->bits = NULL;
return FALSE;
- }
+ }
+ pPixmapPriv->buffer = buffer;
}
- /* XXX: pPixmapPriv->stride = -stride */
- pPixmapPriv->stride = stride;
+ if (pScreenPriv->yInverted)
+ pPixmapPriv->stride = stride;
+ else
+ pPixmapPriv->stride = -stride;
return TRUE;
}
XGL_PIXMAP_PRIV (pPixmap);
if (!pPixmapPriv->buffer)
- if (!xglAllocatePixmapBits (pPixmap))
+ if (!xglAllocatePixmapBits (pPixmap,
+ XGL_PIXMAP_USAGE_HINT_DEFAULT))
return FALSE;
bits = glitz_buffer_map (pPixmapPriv->buffer,
xglScreenInfoPtr pScreenInfo)
{
xglScreenPtr pScreenPriv;
+ int depth;
#ifdef RENDER
PictureScreenPtr pPictureScreen;
pScreenPriv->features =
glitz_drawable_get_features (pScreenInfo->drawable);
+ depth = pScreenPriv->pVisual->pPixel->depth;
+
if (!xglInitOffscreen (pScreen, pScreenInfo))
return FALSE;
xglInitPixmapFormats (pScreen);
- if (!pScreenPriv->pixmapFormats[32].format)
+ if (!pScreenPriv->pixmapFormats[depth].format)
return FALSE;
pScreenPriv->geometryDataType = pScreenInfo->geometryDataType;
pScreenPriv->geometryUsage = pScreenInfo->geometryUsage;
+ pScreenPriv->yInverted = pScreenInfo->yInverted;
+ pScreenPriv->pboMask = pScreenInfo->pboMask;
GEOMETRY_INIT (pScreen, &pScreenPriv->scratchGeometry,
GLITZ_GEOMETRY_TYPE_VERTEX,
pScreenPriv->surface =
glitz_surface_create (pScreenPriv->drawable,
- pScreenPriv->pixmapFormats[32].format,
+ pScreenPriv->pixmapFormats[depth].format,
pScreenInfo->width, pScreenInfo->height,
0, NULL);
if (!pScreenPriv->surface)
XGL_SCREEN_PRIV (pScreen);
- miInitializeBackingStore (pScreen);
+ /* Do we want to use BackingStore?
+ miInitializeBackingStore (pScreen);
+ */
if (!fbCreateDefColormap (pScreen))
return FALSE;
ScreenPtr pScreen)
{
XGL_SCREEN_PRIV (pScreen);
-
+ XGL_PIXMAP_PRIV (pScreenPriv->pScreenPixmap);
+
#ifdef RENDER
int i;
glitz_surface_destroy (pScreenPriv->trapInfo.mask);
#endif
+ xglFiniPixmap (pScreenPriv->pScreenPixmap);
+ if (pPixmapPriv->pDamage)
+ DamageDestroy (pPixmapPriv->pDamage);
+
if (pScreenPriv->solid)
glitz_surface_destroy (pScreenPriv->solid);
XGL_PIXMAP_PRIV (pPixmap);
- if (!xglAllocatePixmapBits (pPixmap))
+ if (!xglAllocatePixmapBits (pPixmap,
+ XGL_PIXMAP_USAGE_HINT_DEFAULT))
{
(*pScreen->DestroyPixmap) (pPixmap);
return;
pBitBox = &pPixmapPriv->bitBox;
- if (pExtents)
+ if (pPixmapPriv->target == xglPixmapTargetIn && pExtents)
{
box.x1 = MAX (0, pExtents->x1);
box.y1 = MAX (0, pExtents->y1);
}
if (!pPixmapPriv->buffer)
- if (!xglAllocatePixmapBits (pPixmap))
+ if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
return FALSE;
if (pPixmapPriv->pDamage)
nBox = REGION_NUM_RECTS (®ion);
format.masks = pPixmapPriv->pPixel->masks;
-
- if (pPixmapPriv->stride < 0)
- {
- format.bytes_per_line = -pPixmapPriv->stride;
- format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
- }
- else
- {
- format.bytes_per_line = pPixmapPriv->stride;
- format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
- }
while (nBox--)
{
- format.xoffset = pBox->x1;
- format.skip_lines = pBox->y1;
-
+ format.xoffset = pBox->x1;
+
+ if (pPixmapPriv->stride < 0)
+ {
+ format.skip_lines = pPixmap->drawable.height - pBox->y2;
+ format.bytes_per_line = -pPixmapPriv->stride;
+ format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
+ }
+ else
+ {
+ format.skip_lines = pBox->y1;
+ format.bytes_per_line = pPixmapPriv->stride;
+ format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
+ }
+
glitz_get_pixels (pPixmapPriv->surface,
pBox->x1,
pBox->y1,
pBox = REGION_RECTS (pRegion);
pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
- format.masks = pPixmapPriv->pPixel->masks;
- format.xoffset = pExt->x1;
- format.skip_lines = pExt->y1;
-
+ format.masks = pPixmapPriv->pPixel->masks;
+ format.xoffset = pExt->x1;
+
if (pPixmapPriv->stride < 0)
{
+ format.skip_lines = pPixmap->drawable.height - pExt->y2;
format.bytes_per_line = -pPixmapPriv->stride;
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
}
else
{
+ format.skip_lines = pExt->y1;
format.bytes_per_line = pPixmapPriv->stride;
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
}
{
XGL_PIXMAP_PRIV (pPixmap);
- if (!xglAllocatePixmapBits (pPixmap))
+ if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
{
(*pScreen->DestroyPixmap) (pPixmap);
return 0;
}
pPixmapPriv->target = xglPixmapTargetNo;
-
- /* force negative stride */
- if (pPixmapPriv->stride > 0)
- pPixmapPriv->stride = -pPixmapPriv->stride;
}
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);