glamor: Apply x-indent.sh.
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
e8e9a54c47
commit
d84d71029a
|
@ -55,8 +55,7 @@ PixmapPtr
|
|||
glamor_get_drawable_pixmap(DrawablePtr drawable)
|
||||
{
|
||||
if (drawable->type == DRAWABLE_WINDOW)
|
||||
return drawable->
|
||||
pScreen->GetWindowPixmap((WindowPtr) drawable);
|
||||
return drawable->pScreen->GetWindowPixmap((WindowPtr) drawable);
|
||||
else
|
||||
return (PixmapPtr) drawable;
|
||||
}
|
||||
|
@ -98,8 +97,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
|
|||
|
||||
gl_iformat_for_depth(pixmap->drawable.depth, &format);
|
||||
fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
format, tex, 0);
|
||||
pixmap->drawable.height, format, tex, 0);
|
||||
|
||||
if (fbo == NULL) {
|
||||
ErrorF("XXX fail to create fbo.\n");
|
||||
|
@ -132,8 +130,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
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_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_fbo *fbo;
|
||||
int pitch;
|
||||
GLenum format;
|
||||
|
@ -179,8 +176,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
pixmap_priv->type = GLAMOR_TEXTURE_LARGE;
|
||||
fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage,
|
||||
glamor_priv->max_fbo_size,
|
||||
glamor_priv->max_fbo_size,
|
||||
pixmap_priv);
|
||||
glamor_priv->max_fbo_size, pixmap_priv);
|
||||
}
|
||||
|
||||
if (fbo == NULL) {
|
||||
|
@ -210,7 +206,7 @@ Bool
|
|||
glamor_destroy_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_screen_private
|
||||
*glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
* glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
if (glamor_priv->dri3_enabled)
|
||||
glamor_egl_destroy_textured_pixmap(pixmap);
|
||||
else
|
||||
|
@ -221,8 +217,7 @@ glamor_destroy_pixmap(PixmapPtr pixmap)
|
|||
void
|
||||
glamor_block_handler(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
@ -238,11 +233,11 @@ glamor_block_handler(ScreenPtr screen)
|
|||
}
|
||||
|
||||
static void
|
||||
_glamor_block_handler(void *data, OSTimePtr timeout,
|
||||
void *last_select_mask)
|
||||
_glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = data;
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
||||
dispatch->glFlush();
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
@ -256,6 +251,7 @@ static void
|
|||
glamor_set_debug_level(int *debug_level)
|
||||
{
|
||||
char *debug_level_string;
|
||||
|
||||
debug_level_string = getenv("GLAMOR_DEBUG");
|
||||
if (debug_level_string
|
||||
&& sscanf(debug_level_string, "%d", debug_level) == 1)
|
||||
|
@ -285,11 +281,11 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
if (flags & GLAMOR_INVERTED_Y_AXIS) {
|
||||
glamor_priv->yInverted = 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
glamor_priv->yInverted = 0;
|
||||
|
||||
if (!dixRegisterPrivateKey
|
||||
(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
|
||||
if (!dixRegisterPrivateKey(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate screen private\n",
|
||||
screen->myNum);
|
||||
|
@ -298,8 +294,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
glamor_set_screen_private(screen, glamor_priv);
|
||||
|
||||
if (!dixRegisterPrivateKey
|
||||
(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
if (!dixRegisterPrivateKey(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
|
@ -378,14 +373,12 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
glamor_priv->saved_procs.change_window_attributes =
|
||||
screen->ChangeWindowAttributes;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_change_window_attributes;
|
||||
screen->ChangeWindowAttributes = glamor_change_window_attributes;
|
||||
|
||||
glamor_priv->saved_procs.copy_window = screen->CopyWindow;
|
||||
screen->CopyWindow = glamor_copy_window;
|
||||
|
||||
glamor_priv->saved_procs.bitmap_to_region =
|
||||
screen->BitmapToRegion;
|
||||
glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion;
|
||||
screen->BitmapToRegion = glamor_bitmap_to_region;
|
||||
}
|
||||
#ifdef RENDER
|
||||
|
@ -393,11 +386,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
glamor_priv->saved_procs.composite = ps->Composite;
|
||||
ps->Composite = glamor_composite;
|
||||
|
||||
|
||||
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
|
||||
ps->Trapezoids = glamor_trapezoids;
|
||||
|
||||
|
||||
glamor_priv->saved_procs.triangles = ps->Triangles;
|
||||
ps->Triangles = glamor_triangles;
|
||||
|
||||
|
@ -482,7 +473,7 @@ glamor_release_screen_priv(ScreenPtr screen)
|
|||
}
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
||||
glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private * priv)
|
||||
{
|
||||
glamor_pixmap_private *old_priv;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
@ -491,7 +482,8 @@ glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
|||
|
||||
if (priv) {
|
||||
assert(old_priv == NULL);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (old_priv == NULL)
|
||||
return;
|
||||
fbo = glamor_pixmap_detach_fbo(old_priv);
|
||||
|
@ -499,9 +491,7 @@ glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
|||
free(old_priv);
|
||||
}
|
||||
|
||||
dixSetPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key,
|
||||
priv);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key, priv);
|
||||
}
|
||||
|
||||
Bool
|
||||
|
@ -510,6 +500,7 @@ glamor_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
|||
glamor_screen_private *glamor_priv;
|
||||
PixmapPtr screen_pixmap;
|
||||
int flags;
|
||||
|
||||
#ifdef RENDER
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
#endif
|
||||
|
@ -551,32 +542,31 @@ glamor_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
|||
return screen->CloseScreen(CLOSE_SCREEN_ARGS);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fini(ScreenPtr screen)
|
||||
{
|
||||
/* Do nothing currently. */
|
||||
}
|
||||
|
||||
void glamor_enable_dri3(ScreenPtr screen)
|
||||
void
|
||||
glamor_enable_dri3(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
glamor_priv->dri3_enabled = TRUE;
|
||||
}
|
||||
|
||||
Bool glamor_is_dri3_support_enabled(ScreenPtr screen)
|
||||
Bool
|
||||
glamor_is_dri3_support_enabled(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
return glamor_priv->dri3_enabled;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
CARD16 *stride,
|
||||
CARD32 *size)
|
||||
glamor_dri3_fd_from_pixmap(ScreenPtr screen,
|
||||
PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
|
@ -585,24 +575,22 @@ glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
|||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||
return -1;
|
||||
switch (pixmap_priv->type)
|
||||
{
|
||||
switch (pixmap_priv->type) {
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||
return glamor_egl_dri3_fd_name_from_tex(screen,
|
||||
pixmap,
|
||||
pixmap_priv->base.fbo->tex,
|
||||
FALSE,
|
||||
stride,
|
||||
size);
|
||||
default: break;
|
||||
FALSE, stride, size);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_dri3_name_from_pixmap (PixmapPtr pixmap)
|
||||
glamor_dri3_name_from_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
|
@ -611,18 +599,16 @@ glamor_dri3_name_from_pixmap (PixmapPtr pixmap)
|
|||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||
return -1;
|
||||
switch (pixmap_priv->type)
|
||||
{
|
||||
switch (pixmap_priv->type) {
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||
return glamor_egl_dri3_fd_name_from_tex(pixmap->drawable.pScreen,
|
||||
pixmap,
|
||||
pixmap_priv->base.fbo->tex,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
default: break;
|
||||
TRUE, NULL, NULL);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
121
glamor/glamor.h
121
glamor/glamor.h
|
@ -122,11 +122,11 @@ extern _X_EXPORT Bool glamor_close_screen(int scrnIndex, ScreenPtr screen);
|
|||
extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
|
||||
#endif
|
||||
|
||||
|
||||
/* Let glamor to know the screen's fbo. The low level
|
||||
* driver should already assign a tex
|
||||
* to this pixmap through the set_pixmap_texture. */
|
||||
extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap);
|
||||
extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap,
|
||||
PixmapPtr *back_pixmap);
|
||||
|
||||
/* @glamor_glyphs_init: Initialize glyphs internal data structures.
|
||||
*
|
||||
|
@ -141,11 +141,12 @@ extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
|
|||
extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
|
||||
unsigned int tex);
|
||||
|
||||
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type);
|
||||
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
|
||||
glamor_pixmap_type_t type);
|
||||
extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
|
||||
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
|
||||
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||
unsigned int usage);
|
||||
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
|
||||
int depth, unsigned int usage);
|
||||
|
||||
extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen);
|
||||
|
||||
|
@ -160,14 +161,21 @@ extern _X_EXPORT void glamor_egl_restore_context(ScreenPtr screen);
|
|||
* Used by the DRI2 page flip. This function will exchange the KHR images and
|
||||
* fbos of the two pixmaps.
|
||||
* */
|
||||
extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back);
|
||||
extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front,
|
||||
PixmapPtr back);
|
||||
|
||||
extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back);
|
||||
extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front,
|
||||
PixmapPtr back);
|
||||
|
||||
/* The DDX is not supposed to call these three functions */
|
||||
extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
|
||||
extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h);
|
||||
extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr, unsigned int, Bool, CARD16*, CARD32*);
|
||||
extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr
|
||||
screen,
|
||||
int w,
|
||||
int h);
|
||||
extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
|
||||
unsigned int, Bool,
|
||||
CARD16 *, CARD32 *);
|
||||
|
||||
/* @glamor_is_dri3_support_enabled: Returns if DRI3 support is enabled.
|
||||
*
|
||||
|
@ -194,10 +202,9 @@ extern _X_EXPORT Bool glamor_is_dri3_support_enabled(ScreenPtr screen);
|
|||
* content.
|
||||
* Returns the fd on success, -1 on error.
|
||||
* */
|
||||
extern _X_EXPORT int glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
||||
extern _X_EXPORT int glamor_dri3_fd_from_pixmap(ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
CARD16 *stride,
|
||||
CARD32 *size);
|
||||
CARD16 *stride, CARD32 *size);
|
||||
|
||||
/* @glamor_dri3_name_from_pixmap: helper to get an gem name from a pixmap.
|
||||
*
|
||||
|
@ -208,7 +215,7 @@ extern _X_EXPORT int glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
|||
* glamor DRI3 support to be activated.
|
||||
* Returns the name on success, -1 on error.
|
||||
* */
|
||||
extern _X_EXPORT int glamor_dri3_name_from_pixmap (PixmapPtr pixmap);
|
||||
extern _X_EXPORT int glamor_dri3_name_from_pixmap(PixmapPtr pixmap);
|
||||
|
||||
/* @glamor_egl_dri3_pixmap_from_fd: DRI3 helper to get a pixmap from a dma-buf fd.
|
||||
*
|
||||
|
@ -222,7 +229,7 @@ extern _X_EXPORT int glamor_dri3_name_from_pixmap (PixmapPtr pixmap);
|
|||
*
|
||||
* Returns a valid pixmap if the import succeeded, else NULL.
|
||||
* */
|
||||
extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
||||
extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
|
||||
int fd,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
|
@ -265,8 +272,7 @@ extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
|
|||
* screen pixmap is a special, we handle it separately in this function.
|
||||
*/
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride);
|
||||
int handle, int stride);
|
||||
|
||||
/* @glamor_egl_create_textured_screen_ext:
|
||||
*
|
||||
|
@ -277,7 +283,8 @@ extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
|||
extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride,
|
||||
PixmapPtr *back_pixmap);
|
||||
PixmapPtr
|
||||
*back_pixmap);
|
||||
|
||||
/*
|
||||
* @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from
|
||||
|
@ -292,8 +299,7 @@ extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
|||
* as well. Return true if successful, otherwise return FALSE.
|
||||
*/
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
||||
int handle,
|
||||
int stride);
|
||||
int handle, int stride);
|
||||
|
||||
/*
|
||||
* @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap
|
||||
|
@ -305,8 +311,7 @@ extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
|||
* This function is similar to glamor_egl_create_textured_pixmap.
|
||||
*/
|
||||
extern _X_EXPORT Bool
|
||||
glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
|
||||
void *bo);
|
||||
glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -314,7 +319,8 @@ extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
|
|||
|
||||
extern _X_EXPORT int glamor_create_gc(GCPtr gc);
|
||||
|
||||
extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable);
|
||||
extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes,
|
||||
DrawablePtr drawable);
|
||||
/* Glamor rendering/drawing functions with XXX_nf.
|
||||
* nf means no fallback within glamor internal if possible. If glamor
|
||||
* fail to accelerate the operation, glamor will return a false, and the
|
||||
|
@ -327,8 +333,7 @@ extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
|
|||
|
||||
extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int nrect,
|
||||
xRectangle * prect);
|
||||
int nrect, xRectangle *prect);
|
||||
|
||||
extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
|
||||
GCPtr gc, int depth, int x, int y,
|
||||
|
@ -378,55 +383,65 @@ extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
|
|||
INT16 xSrc, INT16 ySrc,
|
||||
int ntris, xTriangle * tris);
|
||||
|
||||
|
||||
extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
|
||||
|
||||
extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted);
|
||||
extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc,
|
||||
char *src, DDXPointPtr points,
|
||||
int *widths, int n, int sorted);
|
||||
|
||||
extern _X_EXPORT Bool glamor_get_spans_nf(DrawablePtr drawable, int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst);
|
||||
DDXPointPtr points, int *widths,
|
||||
int count, char *dst);
|
||||
|
||||
extern _X_EXPORT Bool glamor_composite_rects_nf (CARD8 op,
|
||||
extern _X_EXPORT Bool glamor_composite_rects_nf(CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
xRenderColor * color,
|
||||
int nRect, xRectangle *rects);
|
||||
|
||||
extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d);
|
||||
extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y,
|
||||
int w, int h, unsigned int format,
|
||||
unsigned long planeMask, char *d);
|
||||
|
||||
extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps);
|
||||
INT16 y_off, int ntrap,
|
||||
xTrap * traps);
|
||||
|
||||
extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion);
|
||||
extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst,
|
||||
GCPtr pGC, int srcx, int srcy, int w,
|
||||
int h, int dstx, int dsty,
|
||||
unsigned long bitPlane,
|
||||
RegionPtr *pRegion);
|
||||
|
||||
extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable,
|
||||
GCPtr pGC, int x, int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr * ppci,
|
||||
pointer pglyphBase);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
int x, int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr * ppci,
|
||||
pointer pglyphBase);
|
||||
|
||||
extern _X_EXPORT Bool glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y);
|
||||
DrawablePtr pDrawable, int w, int h,
|
||||
int x, int y);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int mode, int npt, DDXPointPtr ppt);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg);
|
||||
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int nseg, xSegment * pSeg);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int mode, int npt, DDXPointPtr ppt);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points);
|
||||
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
|
||||
int mode, int n, DDXPointPtr points);
|
||||
|
||||
extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen, int num_texture_ports);
|
||||
extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
|
||||
int num_texture_ports);
|
||||
|
||||
#endif /* GLAMOR_H */
|
||||
|
|
|
@ -31,11 +31,10 @@
|
|||
static Bool
|
||||
_glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps,
|
||||
Bool fallback)
|
||||
INT16 y_off, int ntrap, xTrap * traps, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& ( !pPicture->pDrawable
|
||||
&& (!pPicture->pDrawable
|
||||
|| glamor_ddx_fallback_check_pixmap(pPicture->pDrawable)))
|
||||
return FALSE;
|
||||
|
||||
|
@ -49,17 +48,14 @@ _glamor_add_traps(PicturePtr pPicture,
|
|||
|
||||
void
|
||||
glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps)
|
||||
INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
|
||||
{
|
||||
_glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_add_traps_nf(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps)
|
||||
INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
|
||||
{
|
||||
return _glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,20 +36,21 @@
|
|||
* compositeRects acceleration implementation
|
||||
*/
|
||||
|
||||
static int16_t bound(int16_t a, uint16_t b)
|
||||
static int16_t
|
||||
bound(int16_t a, uint16_t b)
|
||||
{
|
||||
int v = (int)a + (int)b;
|
||||
int v = (int) a + (int) b;
|
||||
|
||||
if (v > MAXSHORT)
|
||||
return MAXSHORT;
|
||||
return v;
|
||||
}
|
||||
|
||||
static Bool
|
||||
_pixman_region_init_clipped_rectangles(pixman_region16_t *region,
|
||||
_pixman_region_init_clipped_rectangles(pixman_region16_t * region,
|
||||
unsigned int num_rects,
|
||||
xRectangle *rects,
|
||||
int tx, int ty,
|
||||
BoxPtr extents)
|
||||
int tx, int ty, BoxPtr extents)
|
||||
{
|
||||
pixman_box16_t stack_boxes[64], *boxes = stack_boxes;
|
||||
pixman_bool_t ret;
|
||||
|
@ -92,18 +93,15 @@ _pixman_region_init_clipped_rectangles(pixman_region16_t *region,
|
|||
DEBUGF("%s: nrects=%d, region=(%d, %d), (%d, %d) x %d\n",
|
||||
__FUNCTION__, num_rects,
|
||||
region->extents.x1, region->extents.y1,
|
||||
region->extents.x2, region->extents.y2,
|
||||
j);
|
||||
region->extents.x2, region->extents.y2, j);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_composite_rectangles(CARD8 op,
|
||||
PicturePtr dst,
|
||||
xRenderColor *color,
|
||||
int num_rects,
|
||||
xRectangle *rects)
|
||||
xRenderColor * color,
|
||||
int num_rects, xRectangle *rects)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
struct glamor_pixmap_private *priv;
|
||||
|
@ -120,8 +118,7 @@ glamor_composite_rectangles(CARD8 op,
|
|||
(color->red >> 8 << 16) |
|
||||
(color->green >> 8 << 8) |
|
||||
(color->blue >> 8 << 0),
|
||||
num_rects,
|
||||
rects[0].x, rects[0].y, rects[0].width, rects[0].height);
|
||||
num_rects, rects[0].x, rects[0].y, rects[0].width, rects[0].height);
|
||||
|
||||
if (!num_rects)
|
||||
return;
|
||||
|
@ -131,7 +128,7 @@ glamor_composite_rectangles(CARD8 op,
|
|||
return;
|
||||
}
|
||||
|
||||
if ((color->red|color->green|color->blue|color->alpha) <= 0x00ff) {
|
||||
if ((color->red | color->green | color->blue | color->alpha) <= 0x00ff) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
case PictOpOutReverse:
|
||||
|
@ -164,7 +161,8 @@ glamor_composite_rectangles(CARD8 op,
|
|||
op = PictOpOverReverse;
|
||||
break;
|
||||
}
|
||||
} else if (color->alpha >= 0xff00) {
|
||||
}
|
||||
else if (color->alpha >= 0xff00) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
op = PictOpSrc;
|
||||
|
@ -235,10 +233,10 @@ glamor_composite_rectangles(CARD8 op,
|
|||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2);
|
||||
|
||||
|
||||
boxes = pixman_region_rectangles(®ion, &num_boxes);
|
||||
if (op == PictOpSrc || op == PictOpClear) {
|
||||
CARD32 pixel;
|
||||
|
||||
if (op == PictOpClear)
|
||||
pixel = 0;
|
||||
else
|
||||
|
@ -246,7 +244,8 @@ glamor_composite_rectangles(CARD8 op,
|
|||
glamor_solid_boxes(pixmap, boxes, num_boxes, pixel);
|
||||
|
||||
goto done;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) {
|
||||
int error;
|
||||
|
||||
|
@ -256,14 +255,13 @@ glamor_composite_rectangles(CARD8 op,
|
|||
if (glamor_composite_clipped_region(op, source,
|
||||
NULL, dst,
|
||||
NULL, NULL, priv,
|
||||
®ion,
|
||||
0,0,0,0,0,0))
|
||||
®ion, 0, 0, 0, 0, 0, 0))
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
fallback:
|
||||
fallback:
|
||||
miCompositeRects(op, dst, color, num_rects, rects);
|
||||
done:
|
||||
done:
|
||||
/* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
|
||||
* manually append the damaged regions ourselves.
|
||||
*/
|
||||
|
|
|
@ -41,16 +41,14 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
|
||||
PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
|
||||
glamor_pixmap_private *src_pixmap_priv, *dst_pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
|
||||
int fbo_x_off, fbo_y_off;
|
||||
int src_fbo_x_off, src_fbo_y_off;
|
||||
|
||||
if (!glamor_priv->has_fbo_blit) {
|
||||
glamor_delayed_fallback(screen,
|
||||
"no EXT_framebuffer_blit\n");
|
||||
glamor_delayed_fallback(screen, "no EXT_framebuffer_blit\n");
|
||||
return FALSE;
|
||||
}
|
||||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
|
@ -77,10 +75,8 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT,
|
||||
src_pixmap_priv->base.fbo->fb);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
dst_x_off += fbo_x_off;
|
||||
dst_y_off += fbo_y_off;
|
||||
src_y_off += dy + src_fbo_y_off;
|
||||
|
@ -104,21 +100,17 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
dst_x_off),
|
||||
(box[i].y2 +
|
||||
dst_y_off),
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_NEAREST);
|
||||
} else {
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
else {
|
||||
int flip_dst_y1 =
|
||||
dst_pixmap->drawable.height - (box[i].y2 +
|
||||
dst_y_off);
|
||||
dst_pixmap->drawable.height - (box[i].y2 + dst_y_off);
|
||||
int flip_dst_y2 =
|
||||
dst_pixmap->drawable.height - (box[i].y1 +
|
||||
dst_y_off);
|
||||
dst_pixmap->drawable.height - (box[i].y1 + dst_y_off);
|
||||
int flip_src_y1 =
|
||||
src_pixmap->drawable.height - (box[i].y2 +
|
||||
src_y_off);
|
||||
src_pixmap->drawable.height - (box[i].y2 + src_y_off);
|
||||
int flip_src_y2 =
|
||||
src_pixmap->drawable.height - (box[i].y1 +
|
||||
src_y_off);
|
||||
src_pixmap->drawable.height - (box[i].y1 + src_y_off);
|
||||
|
||||
dispatch->glBlitFramebuffer(box[i].x1 + dx +
|
||||
src_x_off,
|
||||
|
@ -132,8 +124,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
box[i].x2 +
|
||||
dst_x_off,
|
||||
flip_dst_y2,
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_NEAREST);
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
}
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
@ -176,54 +167,40 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
GL_FALSE, 2 * sizeof(float), vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
dx += src_x_off;
|
||||
dy += src_y_off;
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D,
|
||||
src_pixmap_priv->base.fbo->tex);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S,
|
||||
GL_CLAMP_TO_BORDER);
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_BORDER);
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
#endif
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
texcoords);
|
||||
2 * sizeof(float), texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[0],
|
||||
REVERT_NONE);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[0], REVERT_NONE);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0],
|
||||
SWAP_NONE_UPLOADING);
|
||||
|
||||
|
@ -235,8 +212,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
box[i].y1 + dst_y_off,
|
||||
box[i].x2 + dst_x_off,
|
||||
box[i].y2 + dst_y_off,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
glamor_set_normalize_tcoords(src_pixmap_priv,
|
||||
src_xscale,
|
||||
|
@ -245,8 +221,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
box[i].y1 + dy,
|
||||
box[i].x2 + dx,
|
||||
box[i].y2 + dy,
|
||||
glamor_priv->yInverted,
|
||||
texcoords);
|
||||
glamor_priv->yInverted, texcoords);
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
|
@ -272,8 +247,7 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane,
|
||||
void *closure)
|
||||
Bool upsidedown, Pixel bitplane, void *closure)
|
||||
{
|
||||
PixmapPtr dst_pixmap, src_pixmap, temp_pixmap = NULL;
|
||||
DrawablePtr temp_src = src;
|
||||
|
@ -294,16 +268,15 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
screen = dst_pixmap->drawable.pScreen;
|
||||
glamor_priv = glamor_get_screen_private(dst->pScreen);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
|
||||
if (src_pixmap_priv->base.fbo
|
||||
&& src_pixmap_priv->base.fbo->fb == dst_pixmap_priv->base.fbo->fb) {
|
||||
int x_shift = abs(src_x_off - dx - dst_x_off);
|
||||
int y_shift = abs(src_y_off - dy - dst_y_off);
|
||||
|
||||
for (i = 0; i < nbox; i++) {
|
||||
if (x_shift < abs(box[i].x2 - box[i].x1)
|
||||
&& y_shift < abs(box[i].y2 - box[i].y1)) {
|
||||
|
@ -315,14 +288,12 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
DEBUGF("Copy %d %d %dx%d dx %d dy %d from %p to %p \n",
|
||||
box[0].x1, box[0].y1,
|
||||
box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
|
||||
dx, dy,
|
||||
src_pixmap, dst_pixmap);
|
||||
dx, dy, src_pixmap, dst_pixmap);
|
||||
#ifndef GLAMOR_GLES2
|
||||
if (!overlaped &&
|
||||
(glamor_priv->state != RENDER_STATE
|
||||
|| !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex)
|
||||
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx,
|
||||
dy)) {
|
||||
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
@ -337,13 +308,13 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
src_pixmap->drawable.height)
|
||||
|| !(glamor_check_fbo_size(glamor_priv,
|
||||
src_pixmap->drawable.width,
|
||||
src_pixmap->drawable.height))))) {
|
||||
src_pixmap->drawable.
|
||||
height))))) {
|
||||
|
||||
temp_pixmap = glamor_create_pixmap(screen,
|
||||
bound.x2 - bound.x1,
|
||||
bound.y2 - bound.y1,
|
||||
src_pixmap->
|
||||
drawable.depth,
|
||||
src_pixmap->drawable.depth,
|
||||
overlaped ? 0 :
|
||||
GLAMOR_CREATE_PIXMAP_CPU);
|
||||
assert(bound.x2 - bound.x1 <= glamor_priv->max_fbo_size);
|
||||
|
@ -356,8 +327,7 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
if (overlaped)
|
||||
glamor_copy_n_to_n_textured(src, temp_src, gc, box,
|
||||
nbox,
|
||||
temp_dx + bound.x1,
|
||||
temp_dy + bound.y1);
|
||||
temp_dx + bound.x1, temp_dy + bound.y1);
|
||||
else
|
||||
fbCopyNtoN(src, temp_src, gc, box, nbox,
|
||||
temp_dx + bound.x1, temp_dy + bound.y1,
|
||||
|
@ -365,7 +335,8 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
glamor_translate_boxes(box, nbox, bound.x1, bound.y1);
|
||||
temp_dx = -bound.x1;
|
||||
temp_dy = -bound.y1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
temp_dx = dx;
|
||||
temp_dy = dy;
|
||||
temp_src = src;
|
||||
|
@ -375,7 +346,7 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
|||
(temp_src, dst, gc, box, nbox, temp_dx, temp_dy)) {
|
||||
ret = TRUE;
|
||||
}
|
||||
done:
|
||||
done:
|
||||
if (temp_src != src)
|
||||
glamor_destroy_pixmap(temp_pixmap);
|
||||
return ret;
|
||||
|
@ -415,8 +386,7 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
DEBUGF("Copy %d %d %dx%d dx %d dy %d from %p to %p \n",
|
||||
box[0].x1, box[0].y1,
|
||||
box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
|
||||
dx, dy,
|
||||
src_pixmap, dst_pixmap);
|
||||
dx, dy, src_pixmap, dst_pixmap);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
|
||||
goto fall_back;
|
||||
|
@ -437,10 +407,8 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
}
|
||||
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
|
||||
RegionInitBoxes(®ion, box, nbox);
|
||||
extent = RegionExtents(®ion);
|
||||
|
@ -461,82 +429,101 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
|
||||
RegionTranslate(®ion, dst_x_off, dst_y_off);
|
||||
if (!force_clip)
|
||||
clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
|
||||
®ion, &n_dst_region, 0,
|
||||
reverse, upsidedown);
|
||||
clipped_dst_regions =
|
||||
glamor_compute_clipped_regions(dst_pixmap_priv, ®ion,
|
||||
&n_dst_region, 0, reverse,
|
||||
upsidedown);
|
||||
else
|
||||
clipped_dst_regions = glamor_compute_clipped_regions_ext(dst_pixmap_priv,
|
||||
®ion, &n_dst_region,
|
||||
clipped_dst_regions =
|
||||
glamor_compute_clipped_regions_ext(dst_pixmap_priv, ®ion,
|
||||
&n_dst_region,
|
||||
glamor_priv->max_fbo_size,
|
||||
glamor_priv->max_fbo_size,
|
||||
reverse, upsidedown);
|
||||
for(i = 0; i < n_dst_region; i++)
|
||||
{
|
||||
for (i = 0; i < n_dst_region; i++) {
|
||||
int n_src_region;
|
||||
glamor_pixmap_clipped_regions *clipped_src_regions;
|
||||
BoxPtr current_boxes;
|
||||
int n_current_boxes;
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv, clipped_dst_regions[i].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv,
|
||||
clipped_dst_regions[i].block_idx);
|
||||
|
||||
temp_source_pixmap = NULL;
|
||||
if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionTranslate(clipped_dst_regions[i].region,
|
||||
-dst_x_off + src_x_off + dx, -dst_y_off + src_y_off + dy);
|
||||
clipped_src_regions = glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].region,
|
||||
&n_src_region, 0,
|
||||
-dst_x_off + src_x_off + dx,
|
||||
-dst_y_off + src_y_off + dy);
|
||||
clipped_src_regions =
|
||||
glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].
|
||||
region, &n_src_region, 0,
|
||||
reverse, upsidedown);
|
||||
DEBUGF("Source is large pixmap.\n");
|
||||
for (j = 0; j < n_src_region; j++)
|
||||
{
|
||||
for (j = 0; j < n_src_region; j++) {
|
||||
if (src_pixmap_priv != dst_pixmap_priv)
|
||||
SET_PIXMAP_FBO_CURRENT(src_pixmap_priv, clipped_src_regions[j].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(src_pixmap_priv,
|
||||
clipped_src_regions[j].
|
||||
block_idx);
|
||||
else if (src_pixmap_priv == dst_pixmap_priv &&
|
||||
clipped_src_regions[j].block_idx != clipped_dst_regions[i].block_idx) {
|
||||
clipped_src_regions[j].block_idx !=
|
||||
clipped_dst_regions[i].block_idx) {
|
||||
/* source and the dest are the same, but need different block_idx.
|
||||
* we create a empty pixmap and fill the required source fbo and box to
|
||||
* it. It's a little hacky, but avoid extra copy. */
|
||||
temp_source_pixmap = glamor_create_pixmap(src->pScreen, 0, 0,
|
||||
src->depth, 0);
|
||||
temp_source_pixmap =
|
||||
glamor_create_pixmap(src->pScreen, 0, 0, src->depth,
|
||||
0);
|
||||
if (!temp_source_pixmap) {
|
||||
ok = FALSE;
|
||||
goto fail;
|
||||
}
|
||||
src->pScreen->ModifyPixmapHeader(temp_source_pixmap,
|
||||
src_pixmap->drawable.width,
|
||||
src_pixmap->drawable.height,
|
||||
0, 0, src_pixmap->devKind, NULL);
|
||||
temp_source_priv = glamor_get_pixmap_private(temp_source_pixmap);
|
||||
src_pixmap->drawable.
|
||||
width,
|
||||
src_pixmap->drawable.
|
||||
height, 0, 0,
|
||||
src_pixmap->devKind,
|
||||
NULL);
|
||||
temp_source_priv =
|
||||
glamor_get_pixmap_private(temp_source_pixmap);
|
||||
*temp_source_priv = *src_pixmap_priv;
|
||||
temp_source_priv->large.box = src_pixmap_priv->large.box_array[clipped_src_regions[j].block_idx];
|
||||
temp_source_priv->base.fbo = src_pixmap_priv->large.fbo_array[clipped_src_regions[j].block_idx];
|
||||
temp_source_priv->large.box =
|
||||
src_pixmap_priv->large.
|
||||
box_array[clipped_src_regions[j].block_idx];
|
||||
temp_source_priv->base.fbo =
|
||||
src_pixmap_priv->large.
|
||||
fbo_array[clipped_src_regions[j].block_idx];
|
||||
temp_source_priv->base.pixmap = temp_source_pixmap;
|
||||
}
|
||||
assert(temp_source_pixmap || !(src_pixmap_priv == dst_pixmap_priv
|
||||
&& (clipped_src_regions[j].block_idx != clipped_dst_regions[i].block_idx)));
|
||||
assert(temp_source_pixmap ||
|
||||
!(src_pixmap_priv == dst_pixmap_priv &&
|
||||
(clipped_src_regions[j].block_idx !=
|
||||
clipped_dst_regions[i].block_idx)));
|
||||
|
||||
RegionTranslate(clipped_src_regions[j].region,
|
||||
-src_x_off - dx,
|
||||
-src_y_off - dy);
|
||||
-src_x_off - dx, -src_y_off - dy);
|
||||
current_boxes = RegionRects(clipped_src_regions[j].region);
|
||||
n_current_boxes = RegionNumRects(clipped_src_regions[j].region);
|
||||
n_current_boxes =
|
||||
RegionNumRects(clipped_src_regions[j].region);
|
||||
DEBUGF("dst pixmap fbo idx %d src pixmap fbo idx %d \n",
|
||||
clipped_dst_regions[i].block_idx,
|
||||
clipped_src_regions[j].block_idx);
|
||||
DEBUGF("Copy %d %d %d %d dx %d dy %d from %p to %p \n",
|
||||
current_boxes[0].x1, current_boxes[0].y1,
|
||||
current_boxes[0].x2, current_boxes[0].y2,
|
||||
dx, dy, src_pixmap, dst_pixmap);
|
||||
current_boxes[0].x2, current_boxes[0].y2, dx, dy,
|
||||
src_pixmap, dst_pixmap);
|
||||
if (!temp_source_pixmap)
|
||||
ok = __glamor_copy_n_to_n(src, dst, gc, current_boxes,
|
||||
n_current_boxes, dx, dy, reverse,
|
||||
upsidedown, bitplane, closure);
|
||||
n_current_boxes, dx, dy,
|
||||
reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
else {
|
||||
ok = __glamor_copy_n_to_n(&temp_source_pixmap->drawable,
|
||||
dst, gc, current_boxes,
|
||||
n_current_boxes, dx, dy, reverse,
|
||||
upsidedown, bitplane, closure);
|
||||
n_current_boxes, dx, dy,
|
||||
reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
temp_source_priv->type = GLAMOR_MEMORY;
|
||||
temp_source_priv->base.fbo = NULL;
|
||||
glamor_destroy_pixmap(temp_source_pixmap);
|
||||
|
@ -553,10 +540,10 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
if (n_src_region == 0)
|
||||
ok = TRUE;
|
||||
free(clipped_src_regions);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
RegionTranslate(clipped_dst_regions[i].region,
|
||||
- dst_x_off,
|
||||
- dst_y_off);
|
||||
-dst_x_off, -dst_y_off);
|
||||
current_boxes = RegionRects(clipped_dst_regions[i].region);
|
||||
n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
|
||||
|
||||
|
@ -578,22 +565,21 @@ _glamor_copy_n_to_n(DrawablePtr src,
|
|||
ok = TRUE;
|
||||
free(clipped_dst_regions);
|
||||
RegionUninit(®ion);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ok = __glamor_copy_n_to_n(src, dst, gc, box, nbox, dx, dy,
|
||||
reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
reverse, upsidedown, bitplane, closure);
|
||||
}
|
||||
|
||||
fail:
|
||||
fail:
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_set_alu(dispatch, GXcopy);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
||||
if (ok)
|
||||
return TRUE;
|
||||
fall_back:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(src)
|
||||
fall_back:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(src)
|
||||
&& glamor_ddx_fallback_check_pixmap(dst))
|
||||
goto done;
|
||||
|
||||
|
@ -611,11 +597,9 @@ fall_back:
|
|||
glamor_get_drawable_location(dst));
|
||||
|
||||
if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW)) {
|
||||
if (dst == src
|
||||
|| glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
|
||||
if (dst == src || glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
|
||||
fbCopyNtoN(src, dst, gc, box, nbox,
|
||||
dx, dy, reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
dx, dy, reverse, upsidedown, bitplane, closure);
|
||||
if (dst != src)
|
||||
glamor_finish_access(src, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
|
@ -631,10 +615,10 @@ fall_back:
|
|||
|
||||
RegionPtr
|
||||
glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
int srcx, int srcy, int width, int height, int dstx,
|
||||
int dsty)
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty)
|
||||
{
|
||||
RegionPtr region;
|
||||
|
||||
region = miDoCopy(src, dst, gc,
|
||||
srcx, srcy, width, height,
|
||||
dstx, dsty, glamor_copy_n_to_n, 0, NULL);
|
||||
|
@ -650,9 +634,7 @@ glamor_copy_n_to_n(DrawablePtr src,
|
|||
int nbox,
|
||||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane,
|
||||
void *closure)
|
||||
Bool reverse, Bool upsidedown, Pixel bitplane, void *closure)
|
||||
{
|
||||
_glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
|
||||
dy, reverse, upsidedown, bitplane, closure, TRUE);
|
||||
|
@ -667,10 +649,9 @@ glamor_copy_n_to_n_nf(DrawablePtr src,
|
|||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane,
|
||||
void *closure)
|
||||
Bool upsidedown, Pixel bitplane, void *closure)
|
||||
{
|
||||
return _glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
|
||||
dy, reverse, upsidedown, bitplane, closure, FALSE);
|
||||
dy, reverse, upsidedown, bitplane, closure,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ _glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
|||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pSrc)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDst))
|
||||
goto fail;
|
||||
|
@ -57,6 +56,7 @@ glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
|||
unsigned long bitPlane)
|
||||
{
|
||||
RegionPtr ret;
|
||||
|
||||
_glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||
dstx, dsty, bitPlane, &ret, TRUE);
|
||||
return ret;
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
*/
|
||||
|
||||
void
|
||||
glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
||||
RegionPtr src_region)
|
||||
glamor_copy_window(WindowPtr win, DDXPointRec old_origin, RegionPtr src_region)
|
||||
{
|
||||
RegionRec dst_region;
|
||||
int dx, dy;
|
||||
|
@ -51,8 +50,7 @@ glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
|||
#endif
|
||||
|
||||
miCopyRegion(&pixmap->drawable, &pixmap->drawable,
|
||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0,
|
||||
NULL);
|
||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0, NULL);
|
||||
|
||||
REGION_UNINIT(win->drawable.pScreen, &dst_region);
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ const Bool
|
|||
glamor_get_drawable_location(const DrawablePtr drawable)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
if (pixmap_priv == NULL || pixmap_priv->base.gl_fbo == 0)
|
||||
|
@ -74,7 +73,8 @@ glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
|||
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
|
||||
ErrorF("Program source:\n%s", source);
|
||||
free(info);
|
||||
} else
|
||||
}
|
||||
else
|
||||
ErrorF("Failed to get shader compilation info.\n");
|
||||
FatalError("GLSL compile failure\n");
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
|
||||
return glamor_download_pixmap_to_cpu(pixmap, access);
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,6 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
"uniform sampler2D sampler;\n"
|
||||
"uniform int revert;\n"
|
||||
"uniform int swap_rb;\n"
|
||||
|
||||
"#define REVERT_NONE 0\n"
|
||||
"#define REVERT_NORMAL 1\n"
|
||||
"#define SWAP_NONE_DOWNLOADING 0\n"
|
||||
|
@ -209,8 +208,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
" gl_FragColor = vec4(texture2D(sampler, source_texture).gba, 1);\n"
|
||||
" else if (swap_rb == SWAP_NONE_UPLOADING)\n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).abg, 1);\n"
|
||||
" } \n"
|
||||
"}\n";
|
||||
" } \n" "}\n";
|
||||
GLint fs_prog, vs_prog, avs_prog, set_alpha_prog;
|
||||
GLint sampler_uniform_location;
|
||||
char *source;
|
||||
|
@ -220,60 +218,47 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
glamor_priv->finish_access_prog[0] = dispatch->glCreateProgram();
|
||||
glamor_priv->finish_access_prog[1] = dispatch->glCreateProgram();
|
||||
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
||||
vs_source);
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
|
||||
|
||||
XNFasprintf(&source, "%s%s", common_source, fs_source);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
source);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, source);
|
||||
free(source);
|
||||
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
|
||||
vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
|
||||
fs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], fs_prog);
|
||||
|
||||
avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
||||
vs_source);
|
||||
avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
|
||||
|
||||
XNFasprintf(&source, "%s%s", common_source, set_alpha_source);
|
||||
set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
source);
|
||||
free(source);
|
||||
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
||||
avs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
||||
set_alpha_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch,
|
||||
glamor_priv->finish_access_prog[0]);
|
||||
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[0]);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch,
|
||||
glamor_priv->finish_access_prog[1]);
|
||||
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[1]);
|
||||
|
||||
glamor_priv->finish_access_revert[0] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"revert");
|
||||
|
||||
glamor_priv->finish_access_swap_rb[0] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"sampler");
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
|
@ -282,16 +267,13 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
dispatch->glUseProgram(0);
|
||||
|
||||
glamor_priv->finish_access_revert[1] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"revert");
|
||||
glamor_priv->finish_access_swap_rb[1] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"sampler");
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[1]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[1], 0);
|
||||
|
@ -318,8 +300,7 @@ void
|
|||
glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
|
||||
|
@ -343,7 +324,8 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
|||
|
||||
pixmap_priv->base.fbo->pbo_valid = FALSE;
|
||||
pixmap_priv->base.fbo->pbo = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
free(pixmap->devPrivate.ptr);
|
||||
}
|
||||
|
||||
|
@ -356,7 +338,6 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
|||
pixmap->devPrivate.ptr = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls uxa_prepare_access with UXA_PREPARE_SRC for the tile, if that is the
|
||||
* current fill style.
|
||||
|
@ -369,17 +350,14 @@ Bool
|
|||
glamor_prepare_access_gc(GCPtr gc)
|
||||
{
|
||||
if (gc->stipple) {
|
||||
if (!glamor_prepare_access
|
||||
(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
|
||||
if (!glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
|
||||
return FALSE;
|
||||
}
|
||||
if (gc->fillStyle == FillTiled) {
|
||||
if (!glamor_prepare_access(&gc->tile.pixmap->drawable,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
if (gc->stipple)
|
||||
glamor_finish_access(&gc->
|
||||
stipple->drawable,
|
||||
GLAMOR_ACCESS_RO);
|
||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -405,8 +383,7 @@ glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
|||
unsigned long fg_pixel, unsigned long bg_pixel,
|
||||
int stipple_x, int stipple_y)
|
||||
{
|
||||
glamor_fallback("stubbed out stipple depth %d\n",
|
||||
pixmap->drawable.depth);
|
||||
glamor_fallback("stubbed out stipple depth %d\n", pixmap->drawable.depth);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -454,31 +431,23 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
PixmapPtr old_tile, new_tile;
|
||||
|
||||
old_tile = gc->tile.pixmap;
|
||||
if (old_tile->drawable.bitsPerPixel !=
|
||||
drawable->bitsPerPixel) {
|
||||
if (old_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||
new_tile = fbGetRotatedPixmap(gc);
|
||||
if (!new_tile ||
|
||||
new_tile->drawable.bitsPerPixel !=
|
||||
drawable->bitsPerPixel) {
|
||||
new_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||
if (new_tile)
|
||||
gc->pScreen->DestroyPixmap
|
||||
(new_tile);
|
||||
gc->pScreen->DestroyPixmap(new_tile);
|
||||
/* fb24_32ReformatTile will do direct access of a newly-
|
||||
* allocated pixmap.
|
||||
*/
|
||||
glamor_fallback
|
||||
("GC %p tile FB_24_32 transformat %p.\n",
|
||||
gc, old_tile);
|
||||
("GC %p tile FB_24_32 transformat %p.\n", gc, old_tile);
|
||||
|
||||
if (glamor_prepare_access
|
||||
(&old_tile->drawable,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
(&old_tile->drawable, GLAMOR_ACCESS_RO)) {
|
||||
new_tile =
|
||||
fb24_32ReformatTile
|
||||
(old_tile,
|
||||
drawable->bitsPerPixel);
|
||||
glamor_finish_access
|
||||
(&old_tile->drawable, GLAMOR_ACCESS_RO);
|
||||
fb24_32ReformatTile(old_tile, drawable->bitsPerPixel);
|
||||
glamor_finish_access(&old_tile->drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
}
|
||||
if (new_tile) {
|
||||
|
@ -497,11 +466,9 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
&& FbEvenTile(gc->tile.pixmap->drawable.width *
|
||||
drawable->bitsPerPixel)) {
|
||||
glamor_fallback
|
||||
("GC %p tile changed %p.\n", gc,
|
||||
gc->tile.pixmap);
|
||||
("GC %p tile changed %p.\n", gc, gc->tile.pixmap);
|
||||
if (glamor_prepare_access
|
||||
(&gc->tile.pixmap->drawable,
|
||||
GLAMOR_ACCESS_RW)) {
|
||||
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbPadPixmap(gc->tile.pixmap);
|
||||
glamor_finish_access
|
||||
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW);
|
||||
|
@ -518,12 +485,12 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
/* We can't inline stipple handling like we do for GCTile because
|
||||
* it sets fbgc privates.
|
||||
*/
|
||||
if (glamor_prepare_access
|
||||
(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
}
|
||||
|
||||
|
@ -559,6 +526,7 @@ RegionPtr
|
|||
glamor_bitmap_to_region(PixmapPtr pixmap)
|
||||
{
|
||||
RegionPtr ret;
|
||||
|
||||
glamor_fallback("pixmap %p \n", pixmap);
|
||||
if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO))
|
||||
return NULL;
|
||||
|
@ -573,9 +541,10 @@ glamor_gl_has_extension(const char *extension)
|
|||
{
|
||||
const char *pext;
|
||||
int ext_len;
|
||||
|
||||
ext_len = strlen(extension);
|
||||
|
||||
pext = (const char*)glGetString(GL_EXTENSIONS);
|
||||
pext = (const char *) glGetString(GL_EXTENSIONS);
|
||||
|
||||
if (pext == NULL || extension == NULL)
|
||||
return FALSE;
|
||||
|
@ -600,7 +569,8 @@ glamor_gl_get_version(void)
|
|||
if (dot == NULL || dot == version || *(dot + 1) == '\0') {
|
||||
major = 0;
|
||||
minor = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Find the start of the major version in the string */
|
||||
while (major_start > version && *major_start != ' ')
|
||||
--major_start;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#ifndef __GLAMOR_DEBUG_H__
|
||||
#define __GLAMOR_DEBUG_H__
|
||||
|
||||
|
||||
#define GLAMOR_DELAYED_STRING_MAX 64
|
||||
|
||||
#define GLAMOR_DEBUG_NONE 0
|
||||
|
@ -51,9 +50,6 @@ AbortServer(void)
|
|||
exit(1); \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
||||
|
||||
#define __debug_output_message(_format_, _prefix_, ...) \
|
||||
LogMessageVerb(X_NONE, 0, \
|
||||
"%32s:\t" _format_ , \
|
||||
|
@ -69,7 +65,6 @@ AbortServer(void)
|
|||
##__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_fallback(_format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
|
||||
|
@ -77,8 +72,6 @@ AbortServer(void)
|
|||
"Glamor fallback", \
|
||||
##__VA_ARGS__);} while(0)
|
||||
|
||||
|
||||
|
||||
#define glamor_delayed_fallback(_screen_, _format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
|
@ -90,7 +83,6 @@ AbortServer(void)
|
|||
"glamor delayed fallback: \t%s " _format_ , \
|
||||
__FUNCTION__, ##__VA_ARGS__); } } while(0)
|
||||
|
||||
|
||||
#define glamor_clear_delayed_fallbacks(_screen_) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
|
@ -112,5 +104,4 @@ AbortServer(void)
|
|||
#define DEBUGRegionPrint(x) do {} while (0)
|
||||
//#define DEBUGRegionPrint RegionPrint
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -69,7 +69,8 @@
|
|||
static const char glamor_name[] = "glamor";
|
||||
|
||||
static DevPrivateKeyRec glamor_egl_pixmap_private_key_index;
|
||||
DevPrivateKey glamor_egl_pixmap_private_key = &glamor_egl_pixmap_private_key_index;
|
||||
DevPrivateKey glamor_egl_pixmap_private_key =
|
||||
&glamor_egl_pixmap_private_key_index;
|
||||
|
||||
static void
|
||||
glamor_identify(int flags)
|
||||
|
@ -114,6 +115,7 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn)
|
|||
return (struct glamor_egl_screen_private *)
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
|
||||
}
|
||||
|
||||
#ifdef GLX_USE_SHARED_DISPATCH
|
||||
_X_EXPORT void
|
||||
glamor_egl_make_current(ScreenPtr screen)
|
||||
|
@ -162,6 +164,7 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
|
|||
int width, int height, int stride, int name, int depth)
|
||||
{
|
||||
EGLImageKHR image;
|
||||
|
||||
EGLint attribs[] = {
|
||||
EGL_WIDTH, 0,
|
||||
EGL_HEIGHT, 0,
|
||||
|
@ -169,8 +172,7 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
|
|||
EGL_DRM_BUFFER_FORMAT_MESA,
|
||||
EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
|
||||
EGL_DRM_BUFFER_USE_MESA,
|
||||
EGL_DRM_BUFFER_USE_SHARE_MESA |
|
||||
EGL_DRM_BUFFER_USE_SCANOUT_MESA,
|
||||
EGL_DRM_BUFFER_USE_SHARE_MESA | EGL_DRM_BUFFER_USE_SCANOUT_MESA,
|
||||
EGL_NONE
|
||||
};
|
||||
attribs[1] = width;
|
||||
|
@ -181,11 +183,11 @@ _glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
|
|||
image = glamor_egl->egl_create_image_khr(glamor_egl->display,
|
||||
glamor_egl->context,
|
||||
EGL_DRM_BUFFER_MESA,
|
||||
(void *) (uintptr_t)name, attribs);
|
||||
(void *) (uintptr_t) name,
|
||||
attribs);
|
||||
if (image == EGL_NO_IMAGE_KHR)
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
@ -193,6 +195,7 @@ static int
|
|||
glamor_get_flink_name(int fd, int handle, int *name)
|
||||
{
|
||||
struct drm_gem_flink flink;
|
||||
|
||||
flink.handle = handle;
|
||||
if (ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink) < 0)
|
||||
return FALSE;
|
||||
|
@ -208,34 +211,30 @@ glamor_create_texture_from_image(struct glamor_egl_screen_private
|
|||
glamor_egl->dispatch->glGenTextures(1, texture);
|
||||
glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, *texture);
|
||||
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
(glamor_egl->egl_image_target_texture2d_oes) (GL_TEXTURE_2D,
|
||||
image);
|
||||
(glamor_egl->egl_image_target_texture2d_oes) (GL_TEXTURE_2D, image);
|
||||
glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
glamor_egl_create_argb8888_based_texture(ScreenPtr screen,
|
||||
int w,
|
||||
int h)
|
||||
glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
EGLImageKHR image;
|
||||
GLuint texture;
|
||||
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
struct gbm_bo *bo;
|
||||
EGLNativePixmapType native_pixmap;
|
||||
|
||||
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||
bo = gbm_bo_create (glamor_egl->gbm, w, h, GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_RENDERING |
|
||||
GBM_BO_USE_SCANOUT);
|
||||
bo = gbm_bo_create(glamor_egl->gbm, w, h, GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
|
||||
if (!bo)
|
||||
return 0;
|
||||
|
||||
|
@ -272,7 +271,8 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
|||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create textured screen.");
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Failed to create textured screen.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -285,8 +285,7 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
|||
Bool
|
||||
glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride,
|
||||
PixmapPtr *back_pixmap)
|
||||
int stride, PixmapPtr *back_pixmap)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
|
@ -303,6 +302,7 @@ static Bool
|
|||
glamor_egl_check_has_gem(int fd)
|
||||
{
|
||||
struct drm_gem_flink flink;
|
||||
|
||||
flink.handle = 0;
|
||||
|
||||
ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
|
||||
|
@ -333,15 +333,16 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
|||
assert(0);
|
||||
return FALSE;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
name = handle;
|
||||
|
||||
image = _glamor_egl_create_image(glamor_egl,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
((stride * 8 + 7) / pixmap->drawable.bitsPerPixel),
|
||||
name,
|
||||
pixmap->drawable.depth);
|
||||
((stride * 8 +
|
||||
7) / pixmap->drawable.bitsPerPixel),
|
||||
name, pixmap->drawable.depth);
|
||||
if (image == EGL_NO_IMAGE_KHR) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
|
||||
goto done;
|
||||
|
@ -349,11 +350,10 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
|||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
||||
glamor_set_pixmap_texture(pixmap, texture);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
image);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key, image);
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
glamor_egl_restore_context(screen);
|
||||
return ret;
|
||||
}
|
||||
|
@ -374,8 +374,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
|
|||
|
||||
image = glamor_egl->egl_create_image_khr(glamor_egl->display,
|
||||
glamor_egl->context,
|
||||
EGL_NATIVE_PIXMAP_KHR,
|
||||
bo, NULL);
|
||||
EGL_NATIVE_PIXMAP_KHR, bo, NULL);
|
||||
if (image == EGL_NO_IMAGE_KHR) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
|
||||
goto done;
|
||||
|
@ -383,20 +382,19 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
|
|||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
||||
glamor_set_pixmap_texture(pixmap, texture);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
image);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key, image);
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
glamor_egl_restore_context(screen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
int glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd);
|
||||
void glamor_get_name_from_bo (int gbm_fd, struct gbm_bo *bo, int *name);
|
||||
int glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd);
|
||||
void glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name);
|
||||
int
|
||||
glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd)
|
||||
glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd)
|
||||
{
|
||||
union gbm_bo_handle handle;
|
||||
struct drm_prime_handle args;
|
||||
|
@ -404,14 +402,14 @@ glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd)
|
|||
handle = gbm_bo_get_handle(bo);
|
||||
args.handle = handle.u32;
|
||||
args.flags = DRM_CLOEXEC;
|
||||
if (ioctl (gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args))
|
||||
if (ioctl(gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args))
|
||||
return FALSE;
|
||||
*fd = args.fd;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_get_name_from_bo (int gbm_fd, struct gbm_bo *bo, int *name)
|
||||
glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name)
|
||||
{
|
||||
union gbm_bo_handle handle;
|
||||
|
||||
|
@ -421,18 +419,17 @@ glamor_get_name_from_bo (int gbm_fd, struct gbm_bo *bo, int *name)
|
|||
}
|
||||
#endif
|
||||
|
||||
int glamor_egl_dri3_fd_name_from_tex (ScreenPtr screen,
|
||||
int
|
||||
glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
unsigned int tex,
|
||||
Bool want_name,
|
||||
CARD16 *stride,
|
||||
CARD32 *size)
|
||||
Bool want_name, CARD16 *stride, CARD32 *size)
|
||||
{
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
EGLImageKHR image;
|
||||
struct gbm_bo* bo;
|
||||
struct gbm_bo *bo;
|
||||
int fd = -1;
|
||||
|
||||
EGLint attribs[] = {
|
||||
|
@ -448,18 +445,17 @@ int glamor_egl_dri3_fd_name_from_tex (ScreenPtr screen,
|
|||
image = dixLookupPrivate(&pixmap->devPrivates,
|
||||
glamor_egl_pixmap_private_key);
|
||||
|
||||
if (image == EGL_NO_IMAGE_KHR || image == NULL)
|
||||
{
|
||||
if (image == EGL_NO_IMAGE_KHR || image == NULL) {
|
||||
image = glamor_egl->egl_create_image_khr(glamor_egl->display,
|
||||
glamor_egl->context,
|
||||
EGL_GL_TEXTURE_2D_KHR,
|
||||
(EGLClientBuffer)(uintptr_t)tex, attribs);
|
||||
(EGLClientBuffer) (uintptr_t)
|
||||
tex, attribs);
|
||||
if (image == EGL_NO_IMAGE_KHR)
|
||||
goto failure;
|
||||
|
||||
dixSetPrivate(&pixmap->devPrivates,
|
||||
glamor_egl_pixmap_private_key,
|
||||
image);
|
||||
glamor_egl_pixmap_private_key, image);
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
|
||||
}
|
||||
|
||||
|
@ -469,22 +465,19 @@ int glamor_egl_dri3_fd_name_from_tex (ScreenPtr screen,
|
|||
|
||||
pixmap->devKind = gbm_bo_get_stride(bo);
|
||||
|
||||
if (want_name)
|
||||
{
|
||||
if (want_name) {
|
||||
if (glamor_egl->has_gem)
|
||||
glamor_get_name_from_bo(glamor_egl->fd, bo, &fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (glamor_get_fd_from_bo(glamor_egl->fd, bo, &fd))
|
||||
{
|
||||
else {
|
||||
if (glamor_get_fd_from_bo(glamor_egl->fd, bo, &fd)) {
|
||||
*stride = pixmap->devKind;
|
||||
*size = pixmap->devKind * gbm_bo_get_height(bo);
|
||||
}
|
||||
}
|
||||
|
||||
gbm_bo_destroy(bo);
|
||||
failure:
|
||||
failure:
|
||||
glamor_egl_restore_context(screen);
|
||||
return fd;
|
||||
#else
|
||||
|
@ -492,21 +485,21 @@ failure:
|
|||
#endif
|
||||
}
|
||||
|
||||
PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
||||
PixmapPtr
|
||||
glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
|
||||
int fd,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
CARD16 stride,
|
||||
CARD8 depth,
|
||||
CARD8 bpp)
|
||||
CARD16 stride, CARD8 depth, CARD8 bpp)
|
||||
{
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
struct gbm_bo* bo;
|
||||
struct gbm_bo *bo;
|
||||
EGLImageKHR image;
|
||||
PixmapPtr pixmap;
|
||||
Bool ret = FALSE;
|
||||
|
||||
EGLint attribs[] = {
|
||||
EGL_WIDTH, 0,
|
||||
EGL_HEIGHT, 0,
|
||||
|
@ -547,15 +540,14 @@ PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
|||
return NULL;
|
||||
|
||||
pixmap = screen->CreatePixmap(screen, 0, 0, depth, 0);
|
||||
screen->ModifyPixmapHeader (pixmap, width, height, 0, 0, stride, NULL);
|
||||
screen->ModifyPixmapHeader(pixmap, width, height, 0, 0, stride, NULL);
|
||||
|
||||
ret = glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo);
|
||||
gbm_bo_destroy(bo);
|
||||
|
||||
if (ret)
|
||||
return pixmap;
|
||||
else
|
||||
{
|
||||
else {
|
||||
screen->DestroyPixmap(pixmap);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -580,7 +572,8 @@ _glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
|
|||
* operation on that texture has been done.*/
|
||||
glamor_block_handler(pixmap->drawable.pScreen);
|
||||
glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key, NULL);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,10 +587,14 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
|
|||
EGLImageKHR new_front_image;
|
||||
|
||||
glamor_pixmap_exchange_fbos(front, back);
|
||||
new_front_image = dixLookupPrivate(&back->devPrivates, glamor_egl_pixmap_private_key);
|
||||
old_front_image = dixLookupPrivate(&front->devPrivates, glamor_egl_pixmap_private_key);
|
||||
dixSetPrivate(&front->devPrivates, glamor_egl_pixmap_private_key, new_front_image);
|
||||
dixSetPrivate(&back->devPrivates, glamor_egl_pixmap_private_key, old_front_image);
|
||||
new_front_image =
|
||||
dixLookupPrivate(&back->devPrivates, glamor_egl_pixmap_private_key);
|
||||
old_front_image =
|
||||
dixLookupPrivate(&front->devPrivates, glamor_egl_pixmap_private_key);
|
||||
dixSetPrivate(&front->devPrivates, glamor_egl_pixmap_private_key,
|
||||
new_front_image);
|
||||
dixSetPrivate(&back->devPrivates, glamor_egl_pixmap_private_key,
|
||||
old_front_image);
|
||||
glamor_set_pixmap_type(front, GLAMOR_TEXTURE_DRM);
|
||||
glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
|
||||
glamor_egl->front_image = new_front_image;
|
||||
|
@ -624,8 +621,10 @@ glamor_egl_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
|||
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
glamor_egl->egl_destroy_image_khr(glamor_egl->display, glamor_egl->front_image);
|
||||
dixSetPrivate(&screen_pixmap->devPrivates, glamor_egl_pixmap_private_key, NULL);
|
||||
glamor_egl->egl_destroy_image_khr(glamor_egl->display,
|
||||
glamor_egl->front_image);
|
||||
dixSetPrivate(&screen_pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
NULL);
|
||||
glamor_egl->front_image = NULL;
|
||||
if (glamor_egl->back_pixmap && *glamor_egl->back_pixmap) {
|
||||
back_image = dixLookupPrivate(&(*glamor_egl->back_pixmap)->devPrivates,
|
||||
|
@ -650,9 +649,7 @@ glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl,
|
|||
int ext_len;
|
||||
|
||||
ext_len = strlen(extension);
|
||||
pext =
|
||||
(const char *) eglQueryString(glamor_egl->display,
|
||||
EGL_EXTENSIONS);
|
||||
pext = (const char *) eglQueryString(glamor_egl->display, EGL_EXTENSIONS);
|
||||
if (pext == NULL || extension == NULL)
|
||||
return FALSE;
|
||||
while ((pext = strstr(pext, extension)) != NULL) {
|
||||
|
@ -679,6 +676,7 @@ glamor_egl_free_screen(FREE_SCREEN_ARGS_DECL)
|
|||
{
|
||||
ScrnInfoPtr scrn;
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
|
||||
#ifndef XF86_SCRN_INTERFACE
|
||||
scrn = xf86Screens[arg];
|
||||
#else
|
||||
|
@ -689,8 +687,7 @@ glamor_egl_free_screen(FREE_SCREEN_ARGS_DECL)
|
|||
if (glamor_egl != NULL) {
|
||||
|
||||
eglMakeCurrent(glamor_egl->display,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
#ifdef GLAMOR_HAS_GBM
|
||||
if (glamor_egl->gbm)
|
||||
gbm_device_destroy(glamor_egl->gbm);
|
||||
|
@ -706,6 +703,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
{
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
const char *version;
|
||||
|
||||
EGLint config_attribs[] = {
|
||||
#ifdef GLAMOR_GLES2
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
|
@ -718,8 +716,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
if (glamor_egl == NULL)
|
||||
return FALSE;
|
||||
if (xf86GlamorEGLPrivateIndex == -1)
|
||||
xf86GlamorEGLPrivateIndex =
|
||||
xf86AllocateScrnInfoPrivateIndex();
|
||||
xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
|
||||
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
|
||||
glamor_egl->fd = fd;
|
||||
|
@ -731,7 +728,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
}
|
||||
glamor_egl->display = eglGetDisplay(glamor_egl->gbm);
|
||||
#else
|
||||
glamor_egl->display = eglGetDisplay((EGLNativeDisplayType)(intptr_t)fd);
|
||||
glamor_egl->display = eglGetDisplay((EGLNativeDisplayType) (intptr_t) fd);
|
||||
#endif
|
||||
|
||||
glamor_egl->has_gem = glamor_egl_check_has_gem(fd);
|
||||
|
@ -742,10 +739,8 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
if (!eglInitialize
|
||||
(glamor_egl->display, &glamor_egl->major, &glamor_egl->minor))
|
||||
{
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"eglInitialize() failed\n");
|
||||
(glamor_egl->display, &glamor_egl->major, &glamor_egl->minor)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglInitialize() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -770,12 +765,13 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
#ifdef GLAMOR_GLES2
|
||||
GLAMOR_CHECK_EGL_EXTENSIONS(KHR_surfaceless_context, KHR_surfaceless_gles2);
|
||||
#else
|
||||
GLAMOR_CHECK_EGL_EXTENSIONS(KHR_surfaceless_context, KHR_surfaceless_opengl);
|
||||
GLAMOR_CHECK_EGL_EXTENSIONS(KHR_surfaceless_context,
|
||||
KHR_surfaceless_opengl);
|
||||
#endif
|
||||
|
||||
#ifdef GLAMOR_HAS_DRI3_SUPPORT
|
||||
if (glamor_egl_has_extension(glamor_egl, "EGL_KHR_gl_texture_2D_image") &&
|
||||
glamor_egl_has_extension(glamor_egl, "EGL_EXT_image_dma_buf_import") )
|
||||
glamor_egl_has_extension(glamor_egl, "EGL_EXT_image_dma_buf_import"))
|
||||
glamor_egl->dri3_capable = TRUE;
|
||||
#endif
|
||||
glamor_egl->egl_create_image_khr = (PFNEGLCREATEIMAGEKHRPROC)
|
||||
|
@ -790,8 +786,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
|
||||
if (!glamor_egl->egl_create_image_khr
|
||||
|| !glamor_egl->egl_image_target_texture2d_oes) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"eglGetProcAddress() failed\n");
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetProcAddress() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -799,14 +794,12 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
NULL, EGL_NO_CONTEXT,
|
||||
config_attribs);
|
||||
if (glamor_egl->context == EGL_NO_CONTEXT) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Failed to create EGL context\n");
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL context\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(glamor_egl->display,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
glamor_egl->context)) {
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Failed to make EGL context current\n");
|
||||
return FALSE;
|
||||
|
@ -819,7 +812,8 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
#ifdef GLAMOR_GLES2
|
||||
xf86DrvMsg(scrn->scrnIndex, X_INFO, "Using GLES2.\n");
|
||||
#ifdef GLX_USE_SHARED_DISPATCH
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING, "Glamor is using GLES2 but GLX needs GL. "
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
|
||||
"Glamor is using GLES2 but GLX needs GL. "
|
||||
"Indirect GLX may not work correctly.\n");
|
||||
#endif
|
||||
#endif
|
||||
|
@ -846,14 +840,13 @@ glamor_egl_init_textured_pixmap(ScreenPtr screen)
|
|||
|
||||
Bool
|
||||
glamor_gl_dispatch_init(ScreenPtr screen,
|
||||
struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version)
|
||||
struct glamor_gl_dispatch *dispatch, int gl_version)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
if (!glamor_gl_dispatch_init_impl
|
||||
(dispatch, gl_version, (get_proc_address_t)eglGetProcAddress))
|
||||
(dispatch, gl_version, (get_proc_address_t) eglGetProcAddress))
|
||||
return FALSE;
|
||||
glamor_egl->dispatch = dispatch;
|
||||
return TRUE;
|
||||
|
|
|
@ -44,36 +44,40 @@
|
|||
&pos->member != (head); \
|
||||
pos = __container_of(pos->member.prev, pos, member))
|
||||
|
||||
|
||||
#define xorg_list_for_each_entry_safe_reverse(pos, tmp, head, member) \
|
||||
for (pos = __container_of((head)->prev, pos, member), \
|
||||
tmp = __container_of(pos->member.prev, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, tmp = __container_of(pos->member.prev, tmp, member))
|
||||
|
||||
inline static int cache_wbucket(int size)
|
||||
inline static int
|
||||
cache_wbucket(int size)
|
||||
{
|
||||
int order = __fls(size / 32);
|
||||
|
||||
if (order >= CACHE_BUCKET_WCOUNT)
|
||||
order = CACHE_BUCKET_WCOUNT - 1;
|
||||
return order;
|
||||
}
|
||||
|
||||
inline static int cache_hbucket(int size)
|
||||
inline static int
|
||||
cache_hbucket(int size)
|
||||
{
|
||||
int order = __fls(size / 32);
|
||||
|
||||
if (order >= CACHE_BUCKET_HCOUNT)
|
||||
order = CACHE_BUCKET_HCOUNT - 1;
|
||||
return order;
|
||||
}
|
||||
|
||||
static glamor_pixmap_fbo *
|
||||
glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
|
||||
glamor_pixmap_fbo_cache_get(glamor_screen_private * glamor_priv,
|
||||
int w, int h, GLenum format, int flag)
|
||||
{
|
||||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
|
||||
int n_format;
|
||||
|
||||
#ifdef NO_FBO_CACHE
|
||||
return NULL;
|
||||
#else
|
||||
|
@ -123,9 +127,10 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
|
|||
}
|
||||
|
||||
void
|
||||
glamor_purge_fbo(glamor_pixmap_fbo *fbo)
|
||||
glamor_purge_fbo(glamor_pixmap_fbo * fbo)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
||||
|
||||
if (fbo->fb)
|
||||
dispatch->glDeleteFramebuffers(1, &fbo->fb);
|
||||
if (fbo->tex)
|
||||
|
@ -138,7 +143,7 @@ glamor_purge_fbo(glamor_pixmap_fbo *fbo)
|
|||
}
|
||||
|
||||
static void
|
||||
glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
|
||||
glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo * fbo)
|
||||
{
|
||||
struct xorg_list *cache;
|
||||
int n_format;
|
||||
|
@ -160,8 +165,9 @@ glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
|
|||
cache = &fbo->glamor_priv->fbo_cache[n_format]
|
||||
[cache_wbucket(fbo->width)]
|
||||
[cache_hbucket(fbo->height)];
|
||||
DEBUGF("Put cache entry %p to cache %p w %d h %d format %x fbo %d tex %d \n", fbo, cache,
|
||||
fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex);
|
||||
DEBUGF
|
||||
("Put cache entry %p to cache %p w %d h %d format %x fbo %d tex %d \n",
|
||||
fbo, cache, fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex);
|
||||
|
||||
fbo->glamor_priv->fbo_cache_watermark += fbo->width * fbo->height;
|
||||
xorg_list_add(&fbo->list, cache);
|
||||
|
@ -170,7 +176,7 @@ glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
|
|||
}
|
||||
|
||||
static void
|
||||
glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
|
||||
glamor_pixmap_ensure_fb(glamor_pixmap_fbo * fbo)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int status;
|
||||
|
@ -183,11 +189,11 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
|
|||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
|
||||
dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D, fbo->tex,
|
||||
0);
|
||||
GL_TEXTURE_2D, fbo->tex, 0);
|
||||
status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
const char *str;
|
||||
|
||||
switch (status) {
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
||||
str = "incomplete attachment";
|
||||
|
@ -219,7 +225,7 @@ glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
|
|||
}
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
||||
glamor_create_fbo_from_tex(glamor_screen_private * glamor_priv,
|
||||
int w, int h, GLenum format, GLint tex, int flag)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
@ -238,6 +244,7 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
|||
|
||||
if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glGenBuffers(1, &fbo->pbo);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
@ -247,31 +254,32 @@ glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
|||
if (flag != GLAMOR_CREATE_FBO_NO_FBO)
|
||||
glamor_pixmap_ensure_fb(fbo);
|
||||
|
||||
done:
|
||||
done:
|
||||
return fbo;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fbo_expire(glamor_screen_private *glamor_priv)
|
||||
glamor_fbo_expire(glamor_screen_private * glamor_priv)
|
||||
{
|
||||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||
int i,j,k;
|
||||
int i, j, k;
|
||||
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
|
||||
list) {
|
||||
if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
|
||||
break;
|
||||
}
|
||||
|
||||
glamor_priv->fbo_cache_watermark -= fbo_entry->width * fbo_entry->height;
|
||||
glamor_priv->fbo_cache_watermark -=
|
||||
fbo_entry->width * fbo_entry->height;
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
DEBUGF("cache %p fbo %p expired %d current %d \n", cache, fbo_entry,
|
||||
fbo_entry->expire, glamor_priv->tick);
|
||||
DEBUGF("cache %p fbo %p expired %d current %d \n", cache,
|
||||
fbo_entry, fbo_entry->expire, glamor_priv->tick);
|
||||
glamor_purge_fbo(fbo_entry);
|
||||
}
|
||||
}
|
||||
|
@ -282,13 +290,12 @@ void
|
|||
glamor_init_pixmap_fbo(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
int i,j,k;
|
||||
int i, j, k;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
|
||||
{
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
xorg_list_init(&glamor_priv->fbo_cache[i][j][k]);
|
||||
}
|
||||
glamor_priv->fbo_cache_watermark = 0;
|
||||
|
@ -300,15 +307,15 @@ glamor_fini_pixmap_fbo(ScreenPtr screen)
|
|||
struct xorg_list *cache;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||
int i,j,k;
|
||||
int i, j, k;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
|
||||
{
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
|
||||
list) {
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
glamor_purge_fbo(fbo_entry);
|
||||
}
|
||||
|
@ -316,7 +323,7 @@ glamor_fini_pixmap_fbo(ScreenPtr screen)
|
|||
}
|
||||
|
||||
void
|
||||
glamor_destroy_fbo(glamor_pixmap_fbo *fbo)
|
||||
glamor_destroy_fbo(glamor_pixmap_fbo * fbo)
|
||||
{
|
||||
xorg_list_del(&fbo->list);
|
||||
glamor_pixmap_fbo_cache_put(fbo);
|
||||
|
@ -324,7 +331,7 @@ glamor_destroy_fbo(glamor_pixmap_fbo *fbo)
|
|||
}
|
||||
|
||||
static int
|
||||
_glamor_create_tex(glamor_screen_private *glamor_priv,
|
||||
_glamor_create_tex(glamor_screen_private * glamor_priv,
|
||||
int w, int h, GLenum format)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
@ -334,13 +341,11 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
|
|||
* Depending on the implementation, GL_RGBA might not
|
||||
* give us ARGB8888. We ask glamor_egl to use get
|
||||
* an ARGB8888 based texture for us. */
|
||||
if (glamor_priv->dri3_enabled && format == GL_RGBA)
|
||||
{
|
||||
if (glamor_priv->dri3_enabled && format == GL_RGBA) {
|
||||
tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
|
||||
w, h);
|
||||
}
|
||||
if (!tex)
|
||||
{
|
||||
if (!tex) {
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glGenTextures(1, &tex);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
@ -356,10 +361,8 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
|
|||
}
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo(glamor_screen_private *glamor_priv,
|
||||
int w, int h,
|
||||
GLenum format,
|
||||
int flag)
|
||||
glamor_create_fbo(glamor_screen_private * glamor_priv,
|
||||
int w, int h, GLenum format, int flag)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
GLint tex = 0;
|
||||
|
@ -379,30 +382,28 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
|
|||
else
|
||||
cache_flag = 0;
|
||||
|
||||
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h,
|
||||
format, cache_flag);
|
||||
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h, format, cache_flag);
|
||||
if (fbo)
|
||||
return fbo;
|
||||
new_fbo:
|
||||
new_fbo:
|
||||
tex = _glamor_create_tex(glamor_priv, w, h, format);
|
||||
no_tex:
|
||||
no_tex:
|
||||
fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
|
||||
|
||||
return fbo;
|
||||
}
|
||||
|
||||
static glamor_pixmap_fbo *
|
||||
_glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||
_glamor_create_fbo_array(glamor_screen_private * glamor_priv,
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h,
|
||||
glamor_pixmap_private *pixmap_priv,
|
||||
int has_fbo)
|
||||
glamor_pixmap_private * pixmap_priv, int has_fbo)
|
||||
{
|
||||
int block_wcnt;
|
||||
int block_hcnt;
|
||||
glamor_pixmap_fbo **fbo_array;
|
||||
BoxPtr box_array;
|
||||
int i,j;
|
||||
int i, j;
|
||||
glamor_pixmap_private_large_t *priv;
|
||||
|
||||
priv = &pixmap_priv->large;
|
||||
|
@ -414,13 +415,12 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
|||
if (box_array == NULL)
|
||||
return NULL;
|
||||
|
||||
fbo_array = calloc(block_wcnt * block_hcnt, sizeof(glamor_pixmap_fbo*));
|
||||
fbo_array = calloc(block_wcnt * block_hcnt, sizeof(glamor_pixmap_fbo *));
|
||||
if (fbo_array == NULL) {
|
||||
free(box_array);
|
||||
return FALSE;
|
||||
}
|
||||
for(i = 0; i < block_hcnt; i++)
|
||||
{
|
||||
for (i = 0; i < block_hcnt; i++) {
|
||||
int block_y1, block_y2;
|
||||
int fbo_w, fbo_h;
|
||||
|
||||
|
@ -428,16 +428,19 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
|||
block_y2 = (block_y1 + block_h) > h ? h : (block_y1 + block_h);
|
||||
fbo_h = block_y2 - block_y1;
|
||||
|
||||
for (j = 0; j < block_wcnt; j++)
|
||||
{
|
||||
for (j = 0; j < block_wcnt; j++) {
|
||||
box_array[i * block_wcnt + j].x1 = j * block_w;
|
||||
box_array[i * block_wcnt + j].y1 = block_y1;
|
||||
box_array[i * block_wcnt + j].x2 = (j + 1) * block_w > w ? w : (j + 1) * block_w;
|
||||
box_array[i * block_wcnt + j].x2 =
|
||||
(j + 1) * block_w > w ? w : (j + 1) * block_w;
|
||||
box_array[i * block_wcnt + j].y2 = block_y2;
|
||||
fbo_w = box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt + j].x1;
|
||||
fbo_w =
|
||||
box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt +
|
||||
j].x1;
|
||||
if (!has_fbo)
|
||||
fbo_array[i * block_wcnt + j] = glamor_create_fbo(glamor_priv,
|
||||
fbo_w, fbo_h, format,
|
||||
fbo_w, fbo_h,
|
||||
format,
|
||||
GLAMOR_CREATE_PIXMAP_FIXUP);
|
||||
else
|
||||
fbo_array[i * block_wcnt + j] = priv->base.fbo;
|
||||
|
@ -453,8 +456,8 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
|||
priv->block_hcnt = block_hcnt;
|
||||
return fbo_array[0];
|
||||
|
||||
cleanup:
|
||||
for(i = 0; i < block_wcnt * block_hcnt; i++)
|
||||
cleanup:
|
||||
for (i = 0; i < block_wcnt * block_hcnt; i++)
|
||||
if ((fbo_array)[i])
|
||||
glamor_destroy_fbo((fbo_array)[i]);
|
||||
free(box_array);
|
||||
|
@ -462,14 +465,13 @@ cleanup:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Create a fbo array to cover the w*h region, by using block_w*block_h
|
||||
* block.*/
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||
glamor_create_fbo_array(glamor_screen_private * glamor_priv,
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h,
|
||||
glamor_pixmap_private *pixmap_priv)
|
||||
glamor_pixmap_private * pixmap_priv)
|
||||
{
|
||||
pixmap_priv->large.block_w = block_w;
|
||||
pixmap_priv->large.block_h = block_h;
|
||||
|
@ -478,7 +480,7 @@ glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
|||
}
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv)
|
||||
glamor_pixmap_detach_fbo(glamor_pixmap_private * pixmap_priv)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
|
@ -495,7 +497,7 @@ glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv)
|
|||
|
||||
/* The pixmap must not be attached to another fbo. */
|
||||
void
|
||||
glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
|
||||
glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo * fbo)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
|
@ -514,7 +516,7 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
|
|||
if (fbo->tex != 0)
|
||||
pixmap_priv->base.gl_tex = 1;
|
||||
else {
|
||||
/* XXX For the Xephyr only, may be broken now.*/
|
||||
/* XXX For the Xephyr only, may be broken now. */
|
||||
pixmap_priv->base.gl_tex = 0;
|
||||
}
|
||||
case GLAMOR_MEMORY_MAP:
|
||||
|
@ -526,16 +528,19 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
|
|||
}
|
||||
|
||||
void
|
||||
glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv)
|
||||
glamor_pixmap_destroy_fbo(glamor_pixmap_private * priv)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
int i;
|
||||
glamor_pixmap_private_large_t *large = &priv->large;
|
||||
for(i = 0; i < large->block_wcnt * large->block_hcnt; i++)
|
||||
|
||||
for (i = 0; i < large->block_wcnt * large->block_hcnt; i++)
|
||||
glamor_destroy_fbo(large->fbo_array[i]);
|
||||
free(large->fbo_array);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fbo = glamor_pixmap_detach_fbo(priv);
|
||||
if (fbo)
|
||||
glamor_destroy_fbo(fbo);
|
||||
|
@ -556,17 +561,17 @@ glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
|
|||
if (pixmap_priv->base.fbo == NULL) {
|
||||
|
||||
fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
format,
|
||||
flag);
|
||||
pixmap->drawable.height, format, flag);
|
||||
if (fbo == NULL)
|
||||
return FALSE;
|
||||
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
} else {
|
||||
}
|
||||
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 = _glamor_create_tex(glamor_priv, pixmap->drawable.width,
|
||||
pixmap_priv->base.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)
|
||||
|
|
|
@ -49,8 +49,7 @@ glamor_fill(DrawablePtr drawable,
|
|||
if (!glamor_solid(dst_pixmap,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width, height, gc->alu, gc->planemask,
|
||||
gc->fgPixel))
|
||||
width, height, gc->alu, gc->planemask, gc->fgPixel))
|
||||
goto fail;
|
||||
break;
|
||||
case FillStippled:
|
||||
|
@ -64,8 +63,7 @@ glamor_fill(DrawablePtr drawable,
|
|||
gc->alu,
|
||||
gc->planemask,
|
||||
gc->fgPixel,
|
||||
gc->bgPixel, gc->patOrg.x,
|
||||
gc->patOrg.y))
|
||||
gc->bgPixel, gc->patOrg.x, gc->patOrg.y))
|
||||
goto fail;
|
||||
break;
|
||||
case FillTiled:
|
||||
|
@ -142,8 +140,7 @@ glamor_init_solid_shader(ScreenPtr screen)
|
|||
glamor_gl_dispatch *dispatch;
|
||||
const char *solid_vs =
|
||||
"attribute vec4 v_position;"
|
||||
"void main()\n" "{\n" " gl_Position = v_position;\n"
|
||||
"}\n";
|
||||
"void main()\n" "{\n" " gl_Position = v_position;\n" "}\n";
|
||||
const char *solid_fs =
|
||||
GLAMOR_DEFAULT_PRECISION "uniform vec4 color;\n"
|
||||
"void main()\n" "{\n" " gl_FragColor = color;\n" "}\n";
|
||||
|
@ -153,8 +150,7 @@ glamor_init_solid_shader(ScreenPtr screen)
|
|||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_priv->solid_prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
solid_fs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, solid_fs);
|
||||
dispatch->glAttachShader(glamor_priv->solid_prog, vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->solid_prog, fs_prog);
|
||||
|
||||
|
@ -163,8 +159,7 @@ glamor_init_solid_shader(ScreenPtr screen)
|
|||
glamor_link_glsl_prog(dispatch, glamor_priv->solid_prog);
|
||||
|
||||
glamor_priv->solid_color_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->solid_prog,
|
||||
"color");
|
||||
dispatch->glGetUniformLocation(glamor_priv->solid_prog, "color");
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
|
@ -184,10 +179,8 @@ static void
|
|||
_glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
GLfloat xscale, yscale;
|
||||
float vertices[32];
|
||||
|
@ -199,24 +192,24 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->solid_prog);
|
||||
|
||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location,
|
||||
1, color);
|
||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
|
||||
|
||||
pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
|
||||
|
||||
if (unlikely(nbox*4*2 > ARRAY_SIZE(vertices))) {
|
||||
if (unlikely(nbox * 4 * 2 > ARRAY_SIZE(vertices))) {
|
||||
int allocated_box;
|
||||
|
||||
if (nbox * 6 > GLAMOR_COMPOSITE_VBO_VERT_CNT) {
|
||||
allocated_box = GLAMOR_COMPOSITE_VBO_VERT_CNT / 6;
|
||||
} else
|
||||
}
|
||||
else
|
||||
allocated_box = nbox;
|
||||
pvertices = malloc(allocated_box * 4 * 2 * sizeof(float));
|
||||
if (pvertices)
|
||||
valid_nbox = allocated_box;
|
||||
else {
|
||||
pvertices = vertices;
|
||||
valid_nbox = ARRAY_SIZE(vertices) / (4*2);
|
||||
valid_nbox = ARRAY_SIZE(vertices) / (4 * 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,13 +217,13 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
pvertices);
|
||||
GL_FALSE, 2 * sizeof(float), pvertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
while(nbox) {
|
||||
while (nbox) {
|
||||
int box_cnt, i;
|
||||
float *valid_vertices;
|
||||
|
||||
valid_vertices = pvertices;
|
||||
box_cnt = nbox > valid_nbox ? valid_nbox : nbox;
|
||||
for (i = 0; i < box_cnt; i++) {
|
||||
|
@ -239,7 +232,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
box[i].x2, box[i].y2,
|
||||
glamor_priv->yInverted,
|
||||
valid_vertices);
|
||||
valid_vertices += 4*2;
|
||||
valid_vertices += 4 * 2;
|
||||
}
|
||||
if (box_cnt == 1)
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
|
||||
|
@ -248,14 +241,10 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
dispatch->glDrawRangeElements(GL_TRIANGLES,
|
||||
0,
|
||||
box_cnt * 4,
|
||||
box_cnt * 6,
|
||||
GL_UNSIGNED_SHORT,
|
||||
NULL);
|
||||
box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
|
||||
#else
|
||||
dispatch->glDrawElements(GL_TRIANGLES,
|
||||
box_cnt * 6,
|
||||
GL_UNSIGNED_SHORT,
|
||||
NULL);
|
||||
box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
|
||||
#endif
|
||||
nbox -= box_cnt;
|
||||
box += box_cnt;
|
||||
|
@ -273,8 +262,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
|
||||
Bool
|
||||
glamor_solid_boxes(PixmapPtr pixmap,
|
||||
BoxPtr box, int nbox,
|
||||
unsigned long fg_pixel)
|
||||
BoxPtr box, int nbox, unsigned long fg_pixel)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
GLfloat color[4];
|
||||
|
@ -287,8 +275,7 @@ glamor_solid_boxes(PixmapPtr pixmap,
|
|||
glamor_get_rgba_from_pixel(fg_pixel,
|
||||
&color[0],
|
||||
&color[1],
|
||||
&color[2],
|
||||
&color[3], format_for_pixmap(pixmap));
|
||||
&color[2], &color[3], format_for_pixmap(pixmap));
|
||||
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionRec region;
|
||||
|
@ -297,11 +284,13 @@ glamor_solid_boxes(PixmapPtr pixmap,
|
|||
int i;
|
||||
|
||||
RegionInitBoxes(®ion, box, nbox);
|
||||
clipped_regions = glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0, 0, 0);
|
||||
for(i = 0; i < n_region; i++)
|
||||
{
|
||||
clipped_regions =
|
||||
glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0,
|
||||
0, 0);
|
||||
for (i = 0; i < n_region; i++) {
|
||||
BoxPtr inner_box;
|
||||
int inner_nbox;
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
|
||||
|
||||
inner_box = RegionRects(clipped_regions[i].region);
|
||||
|
@ -311,7 +300,8 @@ glamor_solid_boxes(PixmapPtr pixmap,
|
|||
}
|
||||
free(clipped_regions);
|
||||
RegionUninit(®ion);
|
||||
} else
|
||||
}
|
||||
else
|
||||
_glamor_solid_boxes(pixmap, box, nbox, color);
|
||||
|
||||
return TRUE;
|
||||
|
@ -319,12 +309,10 @@ glamor_solid_boxes(PixmapPtr pixmap,
|
|||
|
||||
Bool
|
||||
glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel)
|
||||
unsigned char alu, unsigned long planemask, unsigned long fg_pixel)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
BoxRec box;
|
||||
|
@ -335,8 +323,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
return FALSE;
|
||||
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback
|
||||
("Failedto set planemask in glamor_solid.\n");
|
||||
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -361,4 +348,3 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
static Bool
|
||||
_glamor_fill_spans(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted, Bool fallback)
|
||||
int n, DDXPointPtr points, int *widths, int sorted,
|
||||
Bool fallback)
|
||||
{
|
||||
DDXPointPtr ppt;
|
||||
int nbox;
|
||||
|
@ -71,9 +72,8 @@ _glamor_fill_spans(DrawablePtr drawable,
|
|||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
fail:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc)) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -81,23 +81,20 @@ fail:
|
|||
glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbFillSpans(drawable, gc, n, points, widths,
|
||||
sorted);
|
||||
fbFillSpans(drawable, gc, n, points, widths, sorted);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fill_spans(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted)
|
||||
GCPtr gc, int n, DDXPointPtr points, int *widths, int sorted)
|
||||
{
|
||||
_glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE);
|
||||
}
|
||||
|
@ -109,5 +106,3 @@ glamor_fill_spans_nf(DrawablePtr drawable,
|
|||
{
|
||||
return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "glamor_priv.h"
|
||||
|
||||
|
||||
static Bool
|
||||
_glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d,
|
||||
|
@ -49,13 +48,11 @@ _glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
|||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
|
||||
if (!glamor_set_planemask(pixmap, planeMask)) {
|
||||
glamor_fallback
|
||||
("Failedto set planemask in glamor_solid.\n");
|
||||
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||
goto fall_back;
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
goto fall_back;
|
||||
stride = PixmapBytePad(w, drawable->depth);
|
||||
|
@ -69,7 +66,7 @@ _glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
|||
assert(data == d);
|
||||
return TRUE;
|
||||
}
|
||||
fall_back:
|
||||
fall_back:
|
||||
sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
|
||||
y + y_off + drawable->y, w, h,
|
||||
GLAMOR_ACCESS_RO);
|
||||
|
@ -77,9 +74,9 @@ fall_back:
|
|||
fbGetImage(&sub_pixmap->drawable, 0, 0, w, h, format, planeMask, d);
|
||||
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
||||
x + x_off + drawable->x,
|
||||
y + y_off + drawable->y,
|
||||
w, h, GLAMOR_ACCESS_RO);
|
||||
} else
|
||||
y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
else
|
||||
miGetImage(drawable, x, y, w, h, format, planeMask, d);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -35,8 +35,7 @@ _glamor_get_spans(DrawablePtr drawable,
|
|||
Bool fallback)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
int i;
|
||||
uint8_t *readpixels_dst = (uint8_t *) dst;
|
||||
void *data;
|
||||
|
@ -49,19 +48,21 @@ _glamor_get_spans(DrawablePtr drawable,
|
|||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
for (i = 0; i < count; i++) {
|
||||
data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
|
||||
points[i].y + y_off, widths[i], 1,
|
||||
PixmapBytePad(widths[i], drawable->depth),
|
||||
readpixels_dst, 0, GLAMOR_ACCESS_RO);
|
||||
points[i].y + y_off, widths[i],
|
||||
1, PixmapBytePad(widths[i],
|
||||
drawable->
|
||||
depth),
|
||||
readpixels_dst, 0,
|
||||
GLAMOR_ACCESS_RO);
|
||||
assert(data == readpixels_dst);
|
||||
readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
fail:
|
||||
fail:
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
|
||||
ret = TRUE;
|
||||
|
@ -69,7 +70,7 @@ fail:
|
|||
fbGetSpans(drawable, wmax, points, widths, count, dst);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -78,8 +79,7 @@ glamor_get_spans(DrawablePtr drawable,
|
|||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
{
|
||||
_glamor_get_spans(drawable, wmax, points,
|
||||
widths, count, dst, TRUE);
|
||||
_glamor_get_spans(drawable, wmax, points, widths, count, dst, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
|
@ -87,9 +87,5 @@ glamor_get_spans_nf(DrawablePtr drawable,
|
|||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
{
|
||||
return _glamor_get_spans(drawable, wmax, points,
|
||||
widths, count, dst, FALSE);
|
||||
return _glamor_get_spans(drawable, wmax, points, widths, count, dst, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,17 +2,19 @@ typedef struct glamor_gl_dispatch {
|
|||
/* Transformation functions */
|
||||
void (*glMatrixMode) (GLenum mode);
|
||||
void (*glLoadIdentity) (void);
|
||||
void (*glViewport) (GLint x, GLint y, GLsizei width,
|
||||
GLsizei height);
|
||||
void (*glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
/* Drawing functions */
|
||||
void (*glRasterPos2i) (GLint x, GLint y);
|
||||
|
||||
/* Vertex Array */
|
||||
void (*glDrawArrays) (GLenum mode, GLint first, GLsizei count);
|
||||
|
||||
/* Elements Array*/
|
||||
void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
|
||||
void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices);
|
||||
/* Elements Array */
|
||||
void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type,
|
||||
const GLvoid * indices);
|
||||
void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end,
|
||||
GLsizei count, GLenum type,
|
||||
const GLvoid * indices);
|
||||
|
||||
/* Raster functions */
|
||||
void (*glReadPixels) (GLint x, GLint y,
|
||||
|
@ -20,8 +22,7 @@ typedef struct glamor_gl_dispatch {
|
|||
GLenum format, GLenum type, GLvoid * pixels);
|
||||
|
||||
void (*glDrawPixels) (GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid * pixels);
|
||||
GLenum format, GLenum type, const GLvoid * pixels);
|
||||
void (*glPixelStorei) (GLenum pname, GLint param);
|
||||
/* Texture Mapping */
|
||||
|
||||
|
@ -38,15 +39,13 @@ typedef struct glamor_gl_dispatch {
|
|||
void (*glTexSubImage2D) (GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid * pixels);
|
||||
GLenum format, GLenum type, const GLvoid * pixels);
|
||||
/* MISC */
|
||||
void (*glFlush) (void);
|
||||
void (*glFinish) (void);
|
||||
void (*glGetIntegerv) (GLenum pname, GLint * params);
|
||||
const GLubyte *(*glGetString) (GLenum name);
|
||||
void (*glScissor) (GLint x, GLint y, GLsizei width,
|
||||
GLsizei height);
|
||||
void (*glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void (*glEnable) (GLenum cap);
|
||||
void (*glDisable) (GLenum cap);
|
||||
void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
|
||||
|
@ -60,8 +59,9 @@ typedef struct glamor_gl_dispatch {
|
|||
void (*glBufferData) (GLenum target, GLsizeiptr size,
|
||||
const GLvoid * data, GLenum usage);
|
||||
GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
|
||||
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
GLboolean (*glUnmapBuffer) (GLenum target);
|
||||
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset,
|
||||
GLsizeiptr length, GLbitfield access);
|
||||
GLboolean(*glUnmapBuffer) (GLenum target);
|
||||
void (*glBindBuffer) (GLenum target, GLuint buffer);
|
||||
void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
|
||||
|
||||
|
@ -69,10 +69,9 @@ typedef struct glamor_gl_dispatch {
|
|||
GLenum textarget, GLuint texture,
|
||||
GLint level);
|
||||
void (*glBindFramebuffer) (GLenum target, GLuint framebuffer);
|
||||
void (*glDeleteFramebuffers) (GLsizei n,
|
||||
const GLuint * framebuffers);
|
||||
void (*glDeleteFramebuffers) (GLsizei n, const GLuint * framebuffers);
|
||||
void (*glGenFramebuffers) (GLsizei n, GLuint * framebuffers);
|
||||
GLenum (*glCheckFramebufferStatus) (GLenum target);
|
||||
GLenum(*glCheckFramebufferStatus) (GLenum target);
|
||||
void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
|
||||
GLint srcY1, GLint dstX0, GLint dstY0,
|
||||
GLint dstX1, GLint dstY1,
|
||||
|
@ -80,8 +79,7 @@ typedef struct glamor_gl_dispatch {
|
|||
|
||||
void (*glVertexAttribPointer) (GLuint index, GLint size,
|
||||
GLenum type, GLboolean normalized,
|
||||
GLsizei stride,
|
||||
const GLvoid * pointer);
|
||||
GLsizei stride, const GLvoid * pointer);
|
||||
void (*glDisableVertexAttribArray) (GLuint index);
|
||||
void (*glEnableVertexAttribArray) (GLuint index);
|
||||
void (*glBindAttribLocation) (GLuint program, GLuint index,
|
||||
|
@ -89,50 +87,42 @@ typedef struct glamor_gl_dispatch {
|
|||
|
||||
void (*glLinkProgram) (GLuint program);
|
||||
void (*glShaderSource) (GLuint shader, GLsizei count,
|
||||
const GLchar * *string,
|
||||
const GLint * length);
|
||||
const GLchar * *string, const GLint * length);
|
||||
void (*glUseProgram) (GLuint program);
|
||||
void (*glUniform1i) (GLint location, GLint v0);
|
||||
void (*glUniform1f) (GLint location, GLfloat v0);
|
||||
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
|
||||
GLfloat v2, GLfloat v3);
|
||||
void (*glUniform1fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniform2fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniform4fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniform1fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniform2fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniform4fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniformMatrix3fv) (GLint location, GLsizei count,
|
||||
GLboolean transpose, const GLfloat* value);
|
||||
GLuint (*glCreateProgram) (void);
|
||||
GLuint (*glDeleteProgram) (GLuint);
|
||||
GLuint (*glCreateShader) (GLenum type);
|
||||
GLboolean transpose, const GLfloat * value);
|
||||
GLuint(*glCreateProgram) (void);
|
||||
GLuint(*glDeleteProgram) (GLuint);
|
||||
GLuint(*glCreateShader) (GLenum type);
|
||||
void (*glCompileShader) (GLuint shader);
|
||||
void (*glAttachShader) (GLuint program, GLuint shader);
|
||||
void (*glDeleteShader) (GLuint shader);
|
||||
void (*glGetShaderiv) (GLuint shader, GLenum pname,
|
||||
GLint * params);
|
||||
void (*glGetShaderiv) (GLuint shader, GLenum pname, GLint * params);
|
||||
void (*glGetShaderInfoLog) (GLuint shader, GLsizei bufSize,
|
||||
GLsizei * length, GLchar * infoLog);
|
||||
void (*glGetProgramiv) (GLuint program, GLenum pname,
|
||||
GLint * params);
|
||||
void (*glGetProgramiv) (GLuint program, GLenum pname, GLint * params);
|
||||
void (*glGetProgramInfoLog) (GLuint program, GLsizei bufSize,
|
||||
GLsizei * length, GLchar * infoLog);
|
||||
GLint (*glGetUniformLocation) (GLuint program,
|
||||
const GLchar * name);
|
||||
GLint(*glGetUniformLocation) (GLuint program, const GLchar * name);
|
||||
|
||||
} glamor_gl_dispatch;
|
||||
|
||||
|
||||
typedef void *(*get_proc_address_t) (const char *);
|
||||
|
||||
_X_EXPORT Bool
|
||||
|
||||
glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version,
|
||||
get_proc_address_t get_proc_address);
|
||||
|
||||
|
||||
_X_EXPORT Bool
|
||||
|
||||
glamor_gl_dispatch_init(ScreenPtr screen,
|
||||
struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version);
|
||||
struct glamor_gl_dispatch *dispatch, int gl_version);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifdef GLAMOR_GLES2
|
||||
|
||||
#define GL_BGRA GL_BGRA_EXT
|
||||
|
|
|
@ -33,8 +33,7 @@ _glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
|||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
||||
|
@ -47,7 +46,8 @@ glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
|||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase)
|
||||
{
|
||||
_glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, TRUE);
|
||||
_glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
|
@ -55,7 +55,8 @@ glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
|||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase)
|
||||
{
|
||||
return _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, FALSE);
|
||||
return _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci,
|
||||
pglyphBase, FALSE);
|
||||
}
|
||||
|
||||
static Bool
|
||||
|
@ -63,8 +64,7 @@ _glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
|||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
||||
|
@ -77,7 +77,8 @@ glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
|||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase)
|
||||
{
|
||||
_glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, TRUE);
|
||||
_glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
|
@ -85,15 +86,16 @@ glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
|||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase)
|
||||
{
|
||||
return _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, FALSE);
|
||||
return _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci,
|
||||
pglyphBase, FALSE);
|
||||
}
|
||||
|
||||
static Bool
|
||||
_glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y, Bool fallback)
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y,
|
||||
Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_pixmap(&pBitmap->drawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
@ -115,4 +117,3 @@ glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
|
|||
{
|
||||
return _glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, FALSE);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -38,13 +38,13 @@ enum glamor_pixmap_status
|
|||
glamor_upload_picture_to_texture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
|
||||
assert(picture->pDrawable);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
|
||||
return glamor_upload_pixmap_to_texture(pixmap);
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
|
||||
{
|
||||
|
@ -86,7 +86,8 @@ glamor_create_picture(PicturePtr picture)
|
|||
* the uploading, we need to know the picture format. */
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||
/* If the picture format is not compatible with glamor fbo format,
|
||||
* we have to mark this pixmap as a separated texture, and don't
|
||||
|
|
|
@ -51,7 +51,6 @@ glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
|
|||
*y = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_pixmap_init(ScreenPtr screen)
|
||||
{
|
||||
|
@ -64,9 +63,11 @@ glamor_pixmap_fini(ScreenPtr screen)
|
|||
}
|
||||
|
||||
void
|
||||
glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo, int x0, int y0, int width, int height)
|
||||
glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo, int x0, int y0,
|
||||
int width, int height)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
||||
|
||||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glMatrixMode(GL_PROJECTION);
|
||||
|
@ -74,8 +75,7 @@ glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo, int x0, int y0, int w
|
|||
dispatch->glMatrixMode(GL_MODELVIEW);
|
||||
dispatch->glLoadIdentity();
|
||||
#endif
|
||||
dispatch->glViewport(x0, y0,
|
||||
width, height);
|
||||
dispatch->glViewport(x0, y0, width, height);
|
||||
|
||||
glamor_put_dispatch(fbo->glamor_priv);
|
||||
}
|
||||
|
@ -83,11 +83,10 @@ glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo, int x0, int y0, int w
|
|||
void
|
||||
glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private * pixmap_priv)
|
||||
{
|
||||
int w,h;
|
||||
int w, h;
|
||||
|
||||
PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap_priv, w, h);
|
||||
glamor_set_destination_pixmap_fbo(pixmap_priv->base.fbo, 0, 0,
|
||||
w, h);
|
||||
glamor_set_destination_pixmap_fbo(pixmap_priv->base.fbo, 0, 0, w, h);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -104,8 +103,7 @@ int
|
|||
glamor_set_destination_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
int err;
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
err = glamor_set_destination_pixmap_priv(pixmap_priv);
|
||||
return err;
|
||||
|
@ -189,7 +187,8 @@ glamor_set_alu(struct glamor_gl_dispatch *dispatch, unsigned char alu)
|
|||
}
|
||||
|
||||
static void *
|
||||
_glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, int w, int h, int stride, int revert)
|
||||
_glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, int w, int h,
|
||||
int stride, int revert)
|
||||
{
|
||||
PictFormatShort dst_format, src_format;
|
||||
pixman_image_t *dst_image;
|
||||
|
@ -200,24 +199,20 @@ _glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, int w, int h, int st
|
|||
src_format = PICT_a1;
|
||||
dst_format = PICT_a8;
|
||||
src_stride = PixmapBytePad(w, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dst_format = PICT_a1;
|
||||
src_format = PICT_a8;
|
||||
src_stride = (((w * 8 + 7) / 8) + 3) & ~3;
|
||||
}
|
||||
|
||||
dst_image = pixman_image_create_bits(dst_format,
|
||||
w, h,
|
||||
dst_bits,
|
||||
stride);
|
||||
dst_image = pixman_image_create_bits(dst_format, w, h, dst_bits, stride);
|
||||
if (dst_image == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
src_image = pixman_image_create_bits(src_format,
|
||||
w, h,
|
||||
src_bits,
|
||||
src_stride);
|
||||
w, h, src_bits, src_stride);
|
||||
|
||||
if (src_image == NULL) {
|
||||
pixman_image_unref(dst_image);
|
||||
|
@ -225,8 +220,7 @@ _glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, int w, int h, int st
|
|||
}
|
||||
|
||||
pixman_image_composite(PictOpSrc, src_image, NULL, dst_image,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
w,h);
|
||||
0, 0, 0, 0, 0, 0, w, h);
|
||||
|
||||
pixman_image_unref(src_image);
|
||||
pixman_image_unref(dst_image);
|
||||
|
@ -273,21 +267,22 @@ _glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, int w, int h, int st
|
|||
} while (0)
|
||||
|
||||
static void *
|
||||
_glamor_color_revert_x2b10g10r10(void *src_bits, void *dst_bits, int w, int h, int stride, int no_alpha, int revert, int swap_rb)
|
||||
_glamor_color_revert_x2b10g10r10(void *src_bits, void *dst_bits, int w, int h,
|
||||
int stride, int no_alpha, int revert,
|
||||
int swap_rb)
|
||||
{
|
||||
int x,y;
|
||||
int x, y;
|
||||
unsigned int *words, *saved_words, *source_words;
|
||||
int swap = !(swap_rb == SWAP_NONE_DOWNLOADING || swap_rb == SWAP_NONE_UPLOADING);
|
||||
int swap = !(swap_rb == SWAP_NONE_DOWNLOADING ||
|
||||
swap_rb == SWAP_NONE_UPLOADING);
|
||||
|
||||
source_words = src_bits;
|
||||
words = dst_bits;
|
||||
saved_words = words;
|
||||
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
for (y = 0; y < h; y++) {
|
||||
DEBUGF("Line %d : ", y);
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (x = 0; x < w; x++) {
|
||||
unsigned int pixel = source_words[x];
|
||||
|
||||
if (revert == REVERT_DOWNLOADING_2_10_10_10)
|
||||
|
@ -310,21 +305,21 @@ _glamor_color_revert_x2b10g10r10(void *src_bits, void *dst_bits, int w, int h, i
|
|||
}
|
||||
|
||||
static void *
|
||||
_glamor_color_revert_x1b5g5r5(void *src_bits, void *dst_bits, int w, int h, int stride, int no_alpha, int revert, int swap_rb)
|
||||
_glamor_color_revert_x1b5g5r5(void *src_bits, void *dst_bits, int w, int h,
|
||||
int stride, int no_alpha, int revert, int swap_rb)
|
||||
{
|
||||
int x,y;
|
||||
int x, y;
|
||||
unsigned short *words, *saved_words, *source_words;
|
||||
int swap = !(swap_rb == SWAP_NONE_DOWNLOADING || swap_rb == SWAP_NONE_UPLOADING);
|
||||
int swap = !(swap_rb == SWAP_NONE_DOWNLOADING ||
|
||||
swap_rb == SWAP_NONE_UPLOADING);
|
||||
|
||||
words = dst_bits;
|
||||
source_words = src_bits;
|
||||
saved_words = words;
|
||||
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
for (y = 0; y < h; y++) {
|
||||
DEBUGF("Line %d : ", y);
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (x = 0; x < w; x++) {
|
||||
unsigned short pixel = source_words[x];
|
||||
|
||||
if (revert == REVERT_DOWNLOADING_1_5_5_5)
|
||||
|
@ -364,15 +359,25 @@ _glamor_color_revert_x1b5g5r5(void *src_bits, void *dst_bits, int w, int h, int
|
|||
*/
|
||||
|
||||
static void *
|
||||
glamor_color_convert_to_bits(void *src_bits, void *dst_bits, int w, int h, int stride, int no_alpha, int revert, int swap_rb)
|
||||
glamor_color_convert_to_bits(void *src_bits, void *dst_bits, int w, int h,
|
||||
int stride, int no_alpha, int revert, int swap_rb)
|
||||
{
|
||||
if (revert == REVERT_DOWNLOADING_A1 || revert == REVERT_UPLOADING_A1) {
|
||||
return _glamor_color_convert_a1_a8(src_bits, dst_bits, w, h, stride, revert);
|
||||
} else if (revert == REVERT_DOWNLOADING_2_10_10_10 || revert == REVERT_UPLOADING_2_10_10_10) {
|
||||
return _glamor_color_revert_x2b10g10r10(src_bits, dst_bits, w, h, stride, no_alpha, revert, swap_rb);
|
||||
} else if (revert == REVERT_DOWNLOADING_1_5_5_5 || revert == REVERT_UPLOADING_1_5_5_5) {
|
||||
return _glamor_color_revert_x1b5g5r5(src_bits, dst_bits, w, h, stride, no_alpha, revert, swap_rb);
|
||||
} else
|
||||
return _glamor_color_convert_a1_a8(src_bits, dst_bits, w, h, stride,
|
||||
revert);
|
||||
}
|
||||
else if (revert == REVERT_DOWNLOADING_2_10_10_10 ||
|
||||
revert == REVERT_UPLOADING_2_10_10_10) {
|
||||
return _glamor_color_revert_x2b10g10r10(src_bits, dst_bits, w, h,
|
||||
stride, no_alpha, revert,
|
||||
swap_rb);
|
||||
}
|
||||
else if (revert == REVERT_DOWNLOADING_1_5_5_5 ||
|
||||
revert == REVERT_UPLOADING_1_5_5_5) {
|
||||
return _glamor_color_revert_x1b5g5r5(src_bits, dst_bits, w, h, stride,
|
||||
no_alpha, revert, swap_rb);
|
||||
}
|
||||
else
|
||||
ErrorF("convert a non-supported mode %x.\n", revert);
|
||||
|
||||
return NULL;
|
||||
|
@ -408,25 +413,18 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
|
|||
}
|
||||
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, *tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
|
||||
if (bits == NULL)
|
||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
|
||||
pbo);
|
||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
|
||||
if (non_sub)
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D,
|
||||
0, iformat, w, h, 0,
|
||||
format, type,
|
||||
bits);
|
||||
0, iformat, w, h, 0, format, type, bits);
|
||||
else
|
||||
dispatch->glTexSubImage2D(GL_TEXTURE_2D,
|
||||
0, x, y, w, h,
|
||||
format, type,
|
||||
bits);
|
||||
0, x, y, w, h, format, type, bits);
|
||||
|
||||
if (bits == NULL)
|
||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
@ -434,15 +432,17 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
|
|||
}
|
||||
|
||||
static Bool
|
||||
_glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GLenum type,
|
||||
int no_alpha, int revert,
|
||||
_glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
|
||||
GLenum type, int no_alpha, int revert,
|
||||
int swap_rb, int x, int y, int w, int h,
|
||||
int stride, void* bits, int pbo)
|
||||
int stride, void *bits, int pbo)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
static float vertices[8];
|
||||
|
||||
static float texcoords[8] = { 0, 1,
|
||||
1, 1,
|
||||
1, 0,
|
||||
|
@ -477,8 +477,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GLenum ty
|
|||
if (converted_bits == NULL)
|
||||
return FALSE;
|
||||
bits = glamor_color_convert_to_bits(bits, converted_bits, w, h,
|
||||
stride,
|
||||
no_alpha, revert, swap_rb);
|
||||
stride, no_alpha, revert, swap_rb);
|
||||
if (bits == NULL) {
|
||||
ErrorF("Failed to convert pixmap no_alpha %d,"
|
||||
"revert mode %d, swap mode %d\n", no_alpha, revert, swap_rb);
|
||||
|
@ -490,19 +489,18 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GLenum ty
|
|||
need_free_bits = TRUE;
|
||||
}
|
||||
|
||||
ready_to_upload:
|
||||
ready_to_upload:
|
||||
|
||||
/* Try fast path firstly, upload the pixmap to the texture attached
|
||||
* to the fbo directly. */
|
||||
if (no_alpha == 0
|
||||
&& revert == REVERT_NONE
|
||||
&& swap_rb == SWAP_NONE_UPLOADING
|
||||
&& !need_flip
|
||||
&& revert == REVERT_NONE && swap_rb == SWAP_NONE_UPLOADING && !need_flip
|
||||
#ifdef WALKAROUND_LARGE_TEXTURE_MAP
|
||||
&& pixmap_priv->type != GLAMOR_TEXTURE_LARGE
|
||||
#endif
|
||||
) {
|
||||
int fbo_x_off, fbo_y_off;
|
||||
|
||||
assert(pixmap_priv->base.fbo->tex);
|
||||
pixmap_priv_get_fbo_off(pixmap_priv, &fbo_x_off, &fbo_y_off);
|
||||
|
||||
|
@ -526,38 +524,29 @@ ready_to_upload:
|
|||
dst_yscale,
|
||||
x, y,
|
||||
x + w, y + h,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_priv->yInverted, vertices);
|
||||
/* Slow path, we need to flip y or wire alpha to 1. */
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
GL_FALSE, 2 * sizeof(float), vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
ptexcoords);
|
||||
GL_FALSE, 2 * sizeof(float), ptexcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
__glamor_upload_pixmap_to_texture(pixmap, &tex,
|
||||
format, type,
|
||||
0, 0, w, h,
|
||||
bits, pbo);
|
||||
format, type, 0, 0, w, h, bits, pbo);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
|
||||
dispatch->glUniform1i(glamor_priv->
|
||||
finish_access_revert[no_alpha],
|
||||
revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
|
||||
swap_rb);
|
||||
|
||||
|
@ -587,7 +576,8 @@ ready_to_upload:
|
|||
* 2. no_alpha != 0, we need to wire the alpha.
|
||||
* */
|
||||
static int
|
||||
glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha, int revert, int swap_rb)
|
||||
glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha,
|
||||
int revert, int swap_rb)
|
||||
{
|
||||
int flag = 0;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
@ -611,8 +601,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha, int
|
|||
if (pixmap_priv->base.fbo && pixmap_priv->base.fbo->fb)
|
||||
return 0;
|
||||
|
||||
if (!(no_alpha
|
||||
|| (revert == REVERT_NORMAL)
|
||||
if (!(no_alpha || (revert == REVERT_NORMAL)
|
||||
|| (swap_rb != SWAP_NONE_UPLOADING)
|
||||
|| !glamor_priv->yInverted)) {
|
||||
/* We don't need a fbo, a simple texture uploading should work. */
|
||||
|
@ -622,8 +611,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha, int
|
|||
|
||||
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))
|
||||
|| (flag == 0 && pixmap_priv->base.fbo && pixmap_priv->base.fbo->fb))
|
||||
return 0;
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
|
||||
|
@ -642,8 +630,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha, int
|
|||
* */
|
||||
static void
|
||||
glamor_put_bits(char *dst_bits, int dst_stride, char *src_bits,
|
||||
int src_stride, int bpp,
|
||||
int x, int y, int w, int h)
|
||||
int src_stride, int bpp, int x, int y, int w, int h)
|
||||
{
|
||||
int j;
|
||||
int byte_per_pixel;
|
||||
|
@ -651,20 +638,19 @@ glamor_put_bits(char *dst_bits, int dst_stride, char *src_bits,
|
|||
byte_per_pixel = bpp / 8;
|
||||
src_bits += y * src_stride + (x * byte_per_pixel);
|
||||
|
||||
for(j = y; j < y + h; j++)
|
||||
{
|
||||
for (j = y; j < y + h; j++) {
|
||||
memcpy(dst_bits, src_bits, w * byte_per_pixel);
|
||||
src_bits += src_stride;
|
||||
dst_bits += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* download sub region from a large region.
|
||||
*/
|
||||
static void
|
||||
glamor_get_bits(char *dst_bits, int dst_stride, char *src_bits,
|
||||
int src_stride, int bpp,
|
||||
int x, int y, int w, int h)
|
||||
int src_stride, int bpp, int x, int y, int w, int h)
|
||||
{
|
||||
int j;
|
||||
int byte_per_pixel;
|
||||
|
@ -672,18 +658,16 @@ glamor_get_bits(char *dst_bits, int dst_stride, char *src_bits,
|
|||
byte_per_pixel = bpp / 8;
|
||||
dst_bits += y * dst_stride + x * byte_per_pixel;
|
||||
|
||||
for(j = y; j < y + h; j++)
|
||||
{
|
||||
for (j = y; j < y + h; j++) {
|
||||
memcpy(dst_bits, src_bits, w * byte_per_pixel);
|
||||
src_bits += src_stride;
|
||||
dst_bits += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h,
|
||||
int stride, void *bits, int pbo)
|
||||
glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
|
||||
int h, int stride, void *bits, int pbo)
|
||||
{
|
||||
GLenum format, type;
|
||||
int no_alpha, revert, swap_rb;
|
||||
|
@ -694,10 +678,8 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h
|
|||
&format,
|
||||
&type,
|
||||
&no_alpha,
|
||||
&revert,
|
||||
&swap_rb, 1)) {
|
||||
glamor_fallback("Unknown pixmap depth %d.\n",
|
||||
pixmap->drawable.depth);
|
||||
&revert, &swap_rb, 1)) {
|
||||
glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
|
||||
return TRUE;
|
||||
}
|
||||
if (glamor_pixmap_upload_prepare(pixmap, format, no_alpha, revert, swap_rb))
|
||||
|
@ -713,7 +695,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h
|
|||
int n_region;
|
||||
glamor_pixmap_clipped_regions *clipped_regions;
|
||||
void *sub_bits;
|
||||
int i,j;
|
||||
int i, j;
|
||||
|
||||
sub_bits = malloc(h * stride);
|
||||
if (sub_bits == NULL)
|
||||
|
@ -724,14 +706,20 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h
|
|||
box.y2 = y + h;
|
||||
RegionInitBoxes(®ion, &box, 1);
|
||||
if (!force_clip)
|
||||
clipped_regions = glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0, 0, 0);
|
||||
clipped_regions =
|
||||
glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region,
|
||||
0, 0, 0);
|
||||
else
|
||||
clipped_regions = glamor_compute_clipped_regions_ext(pixmap_priv, ®ion, &n_region,
|
||||
pixmap_priv->base.glamor_priv->max_fbo_size,
|
||||
pixmap_priv->base.glamor_priv->max_fbo_size, 0, 0);
|
||||
clipped_regions =
|
||||
glamor_compute_clipped_regions_ext(pixmap_priv, ®ion,
|
||||
&n_region,
|
||||
pixmap_priv->base.
|
||||
glamor_priv->max_fbo_size,
|
||||
pixmap_priv->base.
|
||||
glamor_priv->max_fbo_size, 0,
|
||||
0);
|
||||
DEBUGF("prepare upload %dx%d to a large pixmap %p\n", w, h, pixmap);
|
||||
for(i = 0; i < n_region; i++)
|
||||
{
|
||||
for (i = 0; i < n_region; i++) {
|
||||
BoxPtr boxes;
|
||||
int nbox;
|
||||
int temp_stride;
|
||||
|
@ -744,14 +732,14 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h
|
|||
boxes = RegionRects(clipped_regions[i].region);
|
||||
nbox = RegionNumRects(clipped_regions[i].region);
|
||||
DEBUGF("split to %d boxes\n", nbox);
|
||||
for(j = 0; j < nbox; j++)
|
||||
{
|
||||
for (j = 0; j < nbox; j++) {
|
||||
temp_stride = PixmapBytePad(boxes[j].x2 - boxes[j].x1,
|
||||
pixmap->drawable.depth);
|
||||
|
||||
if (boxes[j].x1 == x && temp_stride == stride) {
|
||||
temp_bits = (char*)bits + (boxes[j].y1 - y) * stride;
|
||||
} else {
|
||||
temp_bits = (char *) bits + (boxes[j].y1 - y) * stride;
|
||||
}
|
||||
else {
|
||||
temp_bits = sub_bits;
|
||||
glamor_put_bits(temp_bits, temp_stride, bits, stride,
|
||||
pixmap->drawable.bitsPerPixel,
|
||||
|
@ -763,11 +751,11 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h
|
|||
boxes[j].x1 - x, boxes[j].y1 - y,
|
||||
boxes[j].x2 - boxes[j].x1,
|
||||
boxes[j].y2 - boxes[j].y1, temp_stride);
|
||||
if (_glamor_upload_bits_to_pixmap_texture(pixmap, format, type, no_alpha,
|
||||
revert, swap_rb, boxes[j].x1, boxes[j].y1,
|
||||
boxes[j].x2 - boxes[j].x1,
|
||||
boxes[j].y2 - boxes[j].y1,
|
||||
temp_stride, temp_bits, pbo) == FALSE) {
|
||||
if (_glamor_upload_bits_to_pixmap_texture
|
||||
(pixmap, format, type, no_alpha, revert, swap_rb,
|
||||
boxes[j].x1, boxes[j].y1, boxes[j].x2 - boxes[j].x1,
|
||||
boxes[j].y2 - boxes[j].y1, temp_stride, temp_bits,
|
||||
pbo) == FALSE) {
|
||||
RegionUninit(®ion);
|
||||
free(sub_bits);
|
||||
assert(0);
|
||||
|
@ -780,9 +768,12 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h
|
|||
free(clipped_regions);
|
||||
RegionUninit(®ion);
|
||||
return TRUE;
|
||||
} else
|
||||
return _glamor_upload_bits_to_pixmap_texture(pixmap, format, type, no_alpha, revert, swap_rb,
|
||||
x, y, w, h, stride, bits, pbo);
|
||||
}
|
||||
else
|
||||
return _glamor_upload_bits_to_pixmap_texture(pixmap, format, type,
|
||||
no_alpha, revert, swap_rb,
|
||||
x, y, w, h, stride, bits,
|
||||
pbo);
|
||||
}
|
||||
|
||||
enum glamor_pixmap_status
|
||||
|
@ -799,7 +790,8 @@ glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
|
|||
&& (pixmap_priv->base.fbo->pbo_valid)) {
|
||||
data = NULL;
|
||||
pbo = pixmap_priv->base.fbo->pbo;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
data = pixmap->devPrivate.ptr;
|
||||
pbo = 0;
|
||||
}
|
||||
|
@ -807,8 +799,7 @@ glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
|
|||
if (glamor_upload_sub_pixmap_to_texture(pixmap, 0, 0,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->devKind,
|
||||
data, pbo))
|
||||
pixmap->devKind, data, pbo))
|
||||
ret = GLAMOR_UPLOAD_DONE;
|
||||
else
|
||||
ret = GLAMOR_UPLOAD_FAILED;
|
||||
|
@ -832,9 +823,9 @@ glamor_restore_pixmap_to_texture(PixmapPtr pixmap)
|
|||
* */
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLenum format,
|
||||
GLenum type, int no_alpha, int revert, int swap_rb)
|
||||
|
||||
glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h,
|
||||
GLenum format, GLenum type, int no_alpha,
|
||||
int revert, int swap_rb)
|
||||
{
|
||||
glamor_pixmap_private *source_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
|
@ -849,10 +840,7 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLe
|
|||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
source_priv = glamor_get_pixmap_private(source);
|
||||
temp_fbo = glamor_create_fbo(glamor_priv,
|
||||
w, h,
|
||||
format,
|
||||
0);
|
||||
temp_fbo = glamor_create_fbo(glamor_priv, w, h, format, 0);
|
||||
if (temp_fbo == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -860,16 +848,12 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLe
|
|||
temp_xscale = 1.0 / w;
|
||||
temp_yscale = 1.0 / h;
|
||||
|
||||
glamor_set_normalize_vcoords((struct glamor_pixmap_private*)NULL,temp_xscale,
|
||||
temp_yscale,
|
||||
0, 0,
|
||||
w, h,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_set_normalize_vcoords((struct glamor_pixmap_private *) NULL,
|
||||
temp_xscale, temp_yscale, 0, 0, w, h,
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
GL_FALSE, 2 * sizeof(float), vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
pixmap_priv_get_scale(source_priv, &source_xscale, &source_yscale);
|
||||
|
@ -877,28 +861,20 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLe
|
|||
source_yscale,
|
||||
x, y,
|
||||
x + w, y + h,
|
||||
glamor_priv->yInverted,
|
||||
texcoords);
|
||||
glamor_priv->yInverted, texcoords);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
texcoords);
|
||||
GL_FALSE, 2 * sizeof(float), texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, source_priv->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glamor_set_destination_pixmap_fbo(temp_fbo, 0, 0, w, h);
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
|
||||
dispatch->glUniform1i(glamor_priv->
|
||||
finish_access_revert[no_alpha],
|
||||
revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
|
||||
swap_rb);
|
||||
|
||||
|
@ -921,7 +897,8 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
|
|||
GLenum type, int no_alpha,
|
||||
int revert, int swap_rb,
|
||||
int x, int y, int w, int h,
|
||||
int stride, void *bits, int pbo, glamor_access_t access)
|
||||
int stride, void *bits, int pbo,
|
||||
glamor_access_t access)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
GLenum gl_access = 0, gl_usage = 0;
|
||||
|
@ -961,6 +938,7 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
|
|||
if (need_post_conversion) {
|
||||
if (pixmap->drawable.depth == 1) {
|
||||
int temp_stride;
|
||||
|
||||
temp_stride = (((w * 8 + 7) / 8) + 3) & ~3;
|
||||
data = malloc(temp_stride * h);
|
||||
if (data == NULL)
|
||||
|
@ -992,8 +970,7 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
|
|||
if (glamor_priv->has_pack_invert || glamor_priv->yInverted) {
|
||||
|
||||
if (!glamor_priv->yInverted) {
|
||||
assert(glamor_priv->gl_flavor ==
|
||||
GLAMOR_GL_DESKTOP);
|
||||
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
|
||||
dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 1);
|
||||
}
|
||||
|
||||
|
@ -1001,41 +978,36 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
|
|||
assert(pbo > 0);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo);
|
||||
dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
|
||||
stride *
|
||||
h,
|
||||
NULL, gl_usage);
|
||||
stride * h, NULL, gl_usage);
|
||||
}
|
||||
|
||||
dispatch->glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h, format, type, data);
|
||||
dispatch->glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h, format, type,
|
||||
data);
|
||||
|
||||
if (!glamor_priv->yInverted) {
|
||||
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
|
||||
dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 0);
|
||||
}
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && bits == NULL) {
|
||||
bits = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
gl_access);
|
||||
bits = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER, gl_access);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unsigned int temp_pbo;
|
||||
int yy;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glGenBuffers(1, &temp_pbo);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
temp_pbo);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, temp_pbo);
|
||||
dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
|
||||
stride *
|
||||
h,
|
||||
NULL, GL_STREAM_READ);
|
||||
stride * h, NULL, GL_STREAM_READ);
|
||||
dispatch->glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h,
|
||||
format, type, 0);
|
||||
read = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
GL_READ_ONLY);
|
||||
read = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
for (yy = 0; yy < pixmap->drawable.height; yy++)
|
||||
memcpy((char*)data + yy * stride,
|
||||
(char*)read + (h - yy - 1) * stride, stride);
|
||||
memcpy((char *) data + yy * stride,
|
||||
(char *) read + (h - yy - 1) * stride, stride);
|
||||
dispatch->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
dispatch->glDeleteBuffers(1, &temp_pbo);
|
||||
|
@ -1049,9 +1021,7 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
|
|||
* Don't need to consider if the pbo is valid.*/
|
||||
bits = glamor_color_convert_to_bits(data, bits,
|
||||
w, h,
|
||||
stride,
|
||||
no_alpha,
|
||||
revert, swap_rb);
|
||||
stride, no_alpha, revert, swap_rb);
|
||||
}
|
||||
|
||||
if (temp_fbo != NULL)
|
||||
|
@ -1064,7 +1034,8 @@ _glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
|
|||
|
||||
void *
|
||||
glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
||||
int stride, void *bits, int pbo, glamor_access_t access)
|
||||
int stride, void *bits, int pbo,
|
||||
glamor_access_t access)
|
||||
{
|
||||
GLenum format, type;
|
||||
int no_alpha, revert, swap_rb;
|
||||
|
@ -1075,10 +1046,8 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
&format,
|
||||
&type,
|
||||
&no_alpha,
|
||||
&revert,
|
||||
&swap_rb, 0)) {
|
||||
glamor_fallback("Unknown pixmap depth %d.\n",
|
||||
pixmap->drawable.depth);
|
||||
&revert, &swap_rb, 0)) {
|
||||
glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1096,7 +1065,7 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
int n_region;
|
||||
glamor_pixmap_clipped_regions *clipped_regions;
|
||||
void *sub_bits;
|
||||
int i,j;
|
||||
int i, j;
|
||||
|
||||
sub_bits = malloc(h * stride);
|
||||
if (sub_bits == NULL)
|
||||
|
@ -1108,15 +1077,21 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
RegionInitBoxes(®ion, &box, 1);
|
||||
|
||||
if (!force_clip)
|
||||
clipped_regions = glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0, 0, 0);
|
||||
clipped_regions =
|
||||
glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region,
|
||||
0, 0, 0);
|
||||
else
|
||||
clipped_regions = glamor_compute_clipped_regions_ext(pixmap_priv, ®ion, &n_region,
|
||||
pixmap_priv->base.glamor_priv->max_fbo_size,
|
||||
pixmap_priv->base.glamor_priv->max_fbo_size, 0, 0);
|
||||
clipped_regions =
|
||||
glamor_compute_clipped_regions_ext(pixmap_priv, ®ion,
|
||||
&n_region,
|
||||
pixmap_priv->base.
|
||||
glamor_priv->max_fbo_size,
|
||||
pixmap_priv->base.
|
||||
glamor_priv->max_fbo_size, 0,
|
||||
0);
|
||||
|
||||
DEBUGF("start download large pixmap %p %dx%d \n", pixmap, w, h);
|
||||
for(i = 0; i < n_region; i++)
|
||||
{
|
||||
for (i = 0; i < n_region; i++) {
|
||||
BoxPtr boxes;
|
||||
int nbox;
|
||||
int temp_stride;
|
||||
|
@ -1127,14 +1102,14 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
|
||||
boxes = RegionRects(clipped_regions[i].region);
|
||||
nbox = RegionNumRects(clipped_regions[i].region);
|
||||
for(j = 0; j < nbox; j++)
|
||||
{
|
||||
for (j = 0; j < nbox; j++) {
|
||||
temp_stride = PixmapBytePad(boxes[j].x2 - boxes[j].x1,
|
||||
pixmap->drawable.depth);
|
||||
|
||||
if (boxes[j].x1 == x && temp_stride == stride) {
|
||||
temp_bits = (char*)bits + (boxes[j].y1 - y) * stride;
|
||||
} else {
|
||||
temp_bits = (char *) bits + (boxes[j].y1 - y) * stride;
|
||||
}
|
||||
else {
|
||||
temp_bits = sub_bits;
|
||||
}
|
||||
DEBUGF("download x %d y %d w %d h %d temp stride %d \n",
|
||||
|
@ -1142,13 +1117,13 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
boxes[j].x2 - boxes[j].x1,
|
||||
boxes[j].y2 - boxes[j].y1, temp_stride);
|
||||
|
||||
/* For large pixmap, we don't support pbo currently.*/
|
||||
/* For large pixmap, we don't support pbo currently. */
|
||||
assert(pbo == 0);
|
||||
if (_glamor_download_sub_pixmap_to_cpu(pixmap, format, type, no_alpha,
|
||||
revert, swap_rb, boxes[j].x1, boxes[j].y1,
|
||||
boxes[j].x2 - boxes[j].x1,
|
||||
boxes[j].y2 - boxes[j].y1,
|
||||
temp_stride, temp_bits, pbo, access) == FALSE) {
|
||||
if (_glamor_download_sub_pixmap_to_cpu
|
||||
(pixmap, format, type, no_alpha, revert, swap_rb,
|
||||
boxes[j].x1, boxes[j].y1, boxes[j].x2 - boxes[j].x1,
|
||||
boxes[j].y2 - boxes[j].y1, temp_stride, temp_bits, pbo,
|
||||
access) == FALSE) {
|
||||
RegionUninit(®ion);
|
||||
free(sub_bits);
|
||||
assert(0);
|
||||
|
@ -1157,7 +1132,7 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
if (boxes[j].x1 != x || temp_stride != stride)
|
||||
glamor_get_bits(bits, stride, temp_bits, temp_stride,
|
||||
pixmap->drawable.bitsPerPixel,
|
||||
boxes[j].x1 - x , boxes[j].y1 - y,
|
||||
boxes[j].x1 - x, boxes[j].y1 - y,
|
||||
boxes[j].x2 - boxes[j].x1,
|
||||
boxes[j].y2 - boxes[j].y1);
|
||||
}
|
||||
|
@ -1168,13 +1143,14 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
free(clipped_regions);
|
||||
RegionUninit(®ion);
|
||||
return bits;
|
||||
} else
|
||||
return _glamor_download_sub_pixmap_to_cpu(pixmap, format, type, no_alpha, revert, swap_rb,
|
||||
x, y, w, h, stride,
|
||||
bits, pbo, access);
|
||||
}
|
||||
else
|
||||
return _glamor_download_sub_pixmap_to_cpu(pixmap, format, type,
|
||||
no_alpha, revert, swap_rb, x,
|
||||
y, w, h, stride, bits, pbo,
|
||||
access);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move a pixmap to CPU memory.
|
||||
* The input data is the pixmap's fbo.
|
||||
|
@ -1187,8 +1163,7 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
Bool
|
||||
glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
unsigned int stride;
|
||||
void *data = NULL, *dst;
|
||||
glamor_screen_private *glamor_priv =
|
||||
|
@ -1203,8 +1178,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
"Downloading pixmap %p %dx%d depth%d\n",
|
||||
pixmap,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
pixmap->drawable.height, pixmap->drawable.depth);
|
||||
|
||||
stride = pixmap->devKind;
|
||||
|
||||
|
@ -1213,11 +1187,11 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
|| (!glamor_priv->has_pack_invert && !glamor_priv->yInverted)
|
||||
|| pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
data = malloc(stride * pixmap->drawable.height);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
if (pixmap_priv->base.fbo->pbo == 0)
|
||||
dispatch->glGenBuffers(1,
|
||||
&pixmap_priv->base.fbo->pbo);
|
||||
dispatch->glGenBuffers(1, &pixmap_priv->base.fbo->pbo);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
pbo = pixmap_priv->base.fbo->pbo;
|
||||
}
|
||||
|
@ -1231,8 +1205,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
dst = glamor_download_sub_pixmap_to_cpu(pixmap, 0, 0,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->devKind,
|
||||
data, pbo, access);
|
||||
pixmap->devKind, data, pbo, access);
|
||||
|
||||
if (!dst) {
|
||||
if (data)
|
||||
|
@ -1253,7 +1226,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
/* fixup a fbo to the exact size as the pixmap. */
|
||||
/* XXX LARGE pixmap? */
|
||||
Bool
|
||||
glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv)
|
||||
glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private * pixmap_priv)
|
||||
{
|
||||
glamor_pixmap_fbo *old_fbo;
|
||||
glamor_pixmap_fbo *new_fbo = NULL;
|
||||
|
@ -1278,8 +1251,7 @@ glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv)
|
|||
goto fail;
|
||||
|
||||
scratch = glamor_create_pixmap(screen, drawable->width, drawable->height,
|
||||
drawable->depth,
|
||||
GLAMOR_CREATE_PIXMAP_FIXUP);
|
||||
drawable->depth, GLAMOR_CREATE_PIXMAP_FIXUP);
|
||||
|
||||
scratch_priv = glamor_get_pixmap_private(scratch);
|
||||
|
||||
|
@ -1289,9 +1261,7 @@ glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv)
|
|||
ValidateGC(&scratch->drawable, gc);
|
||||
glamor_copy_area(drawable,
|
||||
&scratch->drawable,
|
||||
gc, 0, 0,
|
||||
drawable->width, drawable->height,
|
||||
0, 0);
|
||||
gc, 0, 0, drawable->width, drawable->height, 0, 0);
|
||||
old_fbo = glamor_pixmap_detach_fbo(pixmap_priv);
|
||||
new_fbo = glamor_pixmap_detach_fbo(scratch_priv);
|
||||
glamor_pixmap_attach_fbo(pixmap_priv->base.pixmap, new_fbo);
|
||||
|
@ -1300,9 +1270,10 @@ glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv)
|
|||
DEBUGF("old %dx%d type %d\n",
|
||||
drawable->width, drawable->height, pixmap_priv->type);
|
||||
DEBUGF("copy tex %d %dx%d to tex %d %dx%d \n",
|
||||
old_fbo->tex, old_fbo->width, old_fbo->height, new_fbo->tex, new_fbo->width, new_fbo->height);
|
||||
old_fbo->tex, old_fbo->width, old_fbo->height, new_fbo->tex,
|
||||
new_fbo->width, new_fbo->height);
|
||||
ret = TRUE;
|
||||
fail:
|
||||
fail:
|
||||
if (gc)
|
||||
FreeScratchGC(gc);
|
||||
if (scratch)
|
||||
|
@ -1328,7 +1299,8 @@ fail:
|
|||
*
|
||||
* */
|
||||
PixmapPtr
|
||||
glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_access_t access)
|
||||
glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h,
|
||||
glamor_access_t access)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
PixmapPtr sub_pixmap;
|
||||
|
@ -1336,13 +1308,15 @@ glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_acces
|
|||
void *data;
|
||||
int pbo;
|
||||
int flag;
|
||||
|
||||
if (x < 0 || y < 0)
|
||||
return NULL;
|
||||
w = (x + w) > pixmap->drawable.width ? (pixmap->drawable.width - x) : w;
|
||||
h = (y + h) > pixmap->drawable.height ? (pixmap->drawable.height - y) : h;
|
||||
if (access == GLAMOR_ACCESS_WO) {
|
||||
sub_pixmap = glamor_create_pixmap(pixmap->drawable.pScreen, w, h,
|
||||
pixmap->drawable.depth, GLAMOR_CREATE_PIXMAP_CPU);
|
||||
pixmap->drawable.depth,
|
||||
GLAMOR_CREATE_PIXMAP_CPU);
|
||||
return sub_pixmap;
|
||||
}
|
||||
|
||||
|
@ -1351,7 +1325,8 @@ glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_acces
|
|||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return NULL;
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2 || pixmap_priv->type == GLAMOR_TEXTURE_LARGE)
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2 ||
|
||||
pixmap_priv->type == GLAMOR_TEXTURE_LARGE)
|
||||
flag = GLAMOR_CREATE_PIXMAP_CPU;
|
||||
else
|
||||
flag = GLAMOR_CREATE_PIXMAP_MAP;
|
||||
|
@ -1363,7 +1338,9 @@ glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_acces
|
|||
return NULL;
|
||||
|
||||
sub_pixmap_priv = glamor_get_pixmap_private(sub_pixmap);
|
||||
pbo = sub_pixmap_priv ? (sub_pixmap_priv->base.fbo ? sub_pixmap_priv->base.fbo->pbo : 0): 0;
|
||||
pbo =
|
||||
sub_pixmap_priv ? (sub_pixmap_priv->base.fbo ? sub_pixmap_priv->base.
|
||||
fbo->pbo : 0) : 0;
|
||||
|
||||
if (pixmap_priv->base.is_picture) {
|
||||
sub_pixmap_priv->base.picture = pixmap_priv->base.picture;
|
||||
|
@ -1375,9 +1352,11 @@ glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_acces
|
|||
else
|
||||
data = sub_pixmap->devPrivate.ptr;
|
||||
|
||||
data = glamor_download_sub_pixmap_to_cpu(pixmap, x, y, w, h, sub_pixmap->devKind,
|
||||
data, pbo, access);
|
||||
if(data == NULL) {
|
||||
data =
|
||||
glamor_download_sub_pixmap_to_cpu(pixmap, x, y, w, h,
|
||||
sub_pixmap->devKind, data, pbo,
|
||||
access);
|
||||
if (data == NULL) {
|
||||
fbDestroyPixmap(sub_pixmap);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1390,6 +1369,7 @@ glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_acces
|
|||
struct pixman_box16 box;
|
||||
PixmapPtr new_sub_pixmap;
|
||||
int dx, dy;
|
||||
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = w;
|
||||
|
@ -1399,8 +1379,10 @@ glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_acces
|
|||
dy = y;
|
||||
|
||||
new_sub_pixmap = glamor_create_pixmap(pixmap->drawable.pScreen, w, h,
|
||||
pixmap->drawable.depth, GLAMOR_CREATE_PIXMAP_CPU);
|
||||
glamor_copy_n_to_n(&pixmap->drawable, &new_sub_pixmap->drawable, NULL, &box, 1, dx, dy, 0, 0, 0, NULL);
|
||||
pixmap->drawable.depth,
|
||||
GLAMOR_CREATE_PIXMAP_CPU);
|
||||
glamor_copy_n_to_n(&pixmap->drawable, &new_sub_pixmap->drawable, NULL, &box,
|
||||
1, dx, dy, 0, 0, 0, NULL);
|
||||
glamor_compare_pixmaps(new_sub_pixmap, sub_pixmap, 0, 0, w, h, 1, 1);
|
||||
#endif
|
||||
|
||||
|
@ -1408,18 +1390,20 @@ glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_acces
|
|||
}
|
||||
|
||||
void
|
||||
glamor_put_sub_pixmap(PixmapPtr sub_pixmap, PixmapPtr pixmap, int x, int y, int w, int h, glamor_access_t access)
|
||||
glamor_put_sub_pixmap(PixmapPtr sub_pixmap, PixmapPtr pixmap, int x, int y,
|
||||
int w, int h, glamor_access_t access)
|
||||
{
|
||||
void *bits;
|
||||
int pbo;
|
||||
glamor_pixmap_private *sub_pixmap_priv;
|
||||
|
||||
if (access != GLAMOR_ACCESS_RO) {
|
||||
sub_pixmap_priv = glamor_get_pixmap_private(sub_pixmap);
|
||||
if (sub_pixmap_priv->base.fbo
|
||||
&& sub_pixmap_priv->base.fbo->pbo_valid) {
|
||||
if (sub_pixmap_priv->base.fbo && sub_pixmap_priv->base.fbo->pbo_valid) {
|
||||
bits = NULL;
|
||||
pbo = sub_pixmap_priv->base.fbo->pbo;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bits = sub_pixmap->devPrivate.ptr;
|
||||
pbo = 0;
|
||||
}
|
||||
|
@ -1427,7 +1411,8 @@ glamor_put_sub_pixmap(PixmapPtr sub_pixmap, PixmapPtr pixmap, int x, int y, int
|
|||
assert(x >= 0 && y >= 0);
|
||||
w = (w > sub_pixmap->drawable.width) ? sub_pixmap->drawable.width : w;
|
||||
h = (h > sub_pixmap->drawable.height) ? sub_pixmap->drawable.height : h;
|
||||
glamor_upload_sub_pixmap_to_texture(pixmap, x, y, w, h, sub_pixmap->devKind, bits, pbo);
|
||||
glamor_upload_sub_pixmap_to_texture(pixmap, x, y, w, h,
|
||||
sub_pixmap->devKind, bits, pbo);
|
||||
}
|
||||
glamor_destroy_pixmap(sub_pixmap);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
static Bool
|
||||
_glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect, Bool fallback)
|
||||
GCPtr gc, int nrect, xRectangle *prect, Bool fallback)
|
||||
{
|
||||
int fullX1, fullX2, fullY1, fullY2;
|
||||
int xorg, yorg;
|
||||
|
@ -78,8 +78,7 @@ _glamor_poly_fill_rect(DrawablePtr drawable,
|
|||
pbox++;
|
||||
if (x1 >= x2 || y1 >= y2)
|
||||
continue;
|
||||
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1,
|
||||
y2 - y1, fallback)) {
|
||||
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1, y2 - y1, fallback)) {
|
||||
nrect++;
|
||||
goto fail;
|
||||
}
|
||||
|
@ -89,10 +88,9 @@ _glamor_poly_fill_rect(DrawablePtr drawable,
|
|||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
goto done;
|
||||
|
||||
|
@ -107,21 +105,20 @@ fail:
|
|||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect)
|
||||
GCPtr gc, int nrect, xRectangle *prect)
|
||||
{
|
||||
_glamor_poly_fill_rect(drawable, gc, nrect, prect, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect)
|
||||
GCPtr gc, int nrect, xRectangle *prect)
|
||||
{
|
||||
return _glamor_poly_fill_rect(drawable, gc, nrect, prect, FALSE);
|
||||
}
|
||||
|
|
|
@ -54,9 +54,7 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
goto wide_line;
|
||||
}
|
||||
if (gc->lineStyle != LineSolid) {
|
||||
glamor_fallback
|
||||
("non-solid fill line style %d\n",
|
||||
gc->lineStyle);
|
||||
glamor_fallback("non-solid fill line style %d\n", gc->lineStyle);
|
||||
goto fail;
|
||||
}
|
||||
rects = malloc(sizeof(xRectangle) * (n - 1));
|
||||
|
@ -67,7 +65,8 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
if (mode == CoordModePrevious) {
|
||||
x2 = x1 + points[i + 1].x;
|
||||
y2 = y1 + points[i + 1].y;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
x2 = points[i + 1].x;
|
||||
y2 = points[i + 1].y;
|
||||
}
|
||||
|
@ -79,14 +78,16 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
if (x1 < x2) {
|
||||
rects[i].x = x1;
|
||||
rects[i].width = x2 - x1 + 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rects[i].x = x2;
|
||||
rects[i].width = x1 - x2 + 1;
|
||||
}
|
||||
if (y1 < y2) {
|
||||
rects[i].y = y1;
|
||||
rects[i].height = y2 - y1 + 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rects[i].y = y2;
|
||||
rects[i].height = y1 - y2 + 1;
|
||||
}
|
||||
|
@ -99,8 +100,7 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
return TRUE;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
return FALSE;
|
||||
|
||||
|
@ -112,8 +112,9 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
} else {
|
||||
wide_line:
|
||||
}
|
||||
else {
|
||||
wide_line:
|
||||
/* fb calls mi functions in the lineWidth != 0 case. */
|
||||
fbPolyLine(drawable, gc, mode, n, points);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ static Bool
|
|||
_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||
return FALSE;
|
||||
|
||||
|
@ -58,10 +57,9 @@ glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
|||
|
||||
static Bool
|
||||
_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg, Bool fallback)
|
||||
xSegment * pSeg, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||
return FALSE;
|
||||
|
||||
|
@ -71,15 +69,14 @@ _glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
|||
}
|
||||
|
||||
void
|
||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg)
|
||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
|
||||
{
|
||||
_glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg)
|
||||
xSegment * pSeg)
|
||||
{
|
||||
return _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, FALSE);
|
||||
}
|
||||
|
|
|
@ -152,14 +152,12 @@ typedef struct {
|
|||
INT16 height;
|
||||
} glamor_composite_rect_t;
|
||||
|
||||
|
||||
enum glamor_vertex_type {
|
||||
GLAMOR_VERTEX_POS,
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
GLAMOR_VERTEX_MASK
|
||||
};
|
||||
|
||||
|
||||
enum gradient_shader {
|
||||
SHADER_GRADIENT_LINEAR,
|
||||
SHADER_GRADIENT_RADIAL,
|
||||
|
@ -250,7 +248,8 @@ typedef struct glamor_screen_private {
|
|||
int has_fbo_blit;
|
||||
int max_fbo_size;
|
||||
|
||||
struct xorg_list fbo_cache[CACHE_FORMAT_COUNT][CACHE_BUCKET_WCOUNT][CACHE_BUCKET_HCOUNT];
|
||||
struct xorg_list
|
||||
fbo_cache[CACHE_FORMAT_COUNT][CACHE_BUCKET_WCOUNT][CACHE_BUCKET_HCOUNT];
|
||||
unsigned long fbo_cache_watermark;
|
||||
|
||||
/* glamor_solid */
|
||||
|
@ -271,7 +270,7 @@ typedef struct glamor_screen_private {
|
|||
glamor_glyph_cache_t glyphCaches[GLAMOR_NUM_GLYPH_CACHE_FORMATS];
|
||||
Bool glyph_cache_initialized;
|
||||
|
||||
/* shaders to restore a texture to another texture.*/
|
||||
/* shaders to restore a texture to another texture. */
|
||||
GLint finish_access_prog[2];
|
||||
GLint finish_access_revert[2];
|
||||
GLint finish_access_swap_rb[2];
|
||||
|
@ -414,7 +413,7 @@ typedef struct glamor_pixmap_fbo {
|
|||
*
|
||||
**/
|
||||
|
||||
typedef struct glamor_pixmap_clipped_regions{
|
||||
typedef struct glamor_pixmap_clipped_regions {
|
||||
int block_idx;
|
||||
RegionPtr region;
|
||||
} glamor_pixmap_clipped_regions;
|
||||
|
@ -437,7 +436,7 @@ typedef struct glamor_pixmap_private_base {
|
|||
int drm_stride;
|
||||
glamor_screen_private *glamor_priv;
|
||||
PicturePtr picture;
|
||||
}glamor_pixmap_private_base_t;
|
||||
} glamor_pixmap_private_base_t;
|
||||
|
||||
/*
|
||||
* @base.fbo: current fbo.
|
||||
|
@ -464,7 +463,7 @@ typedef struct glamor_pixmap_private_large {
|
|||
int nbox;
|
||||
BoxPtr box_array;
|
||||
glamor_pixmap_fbo **fbo_array;
|
||||
}glamor_pixmap_private_large_t;
|
||||
} glamor_pixmap_private_large_t;
|
||||
|
||||
/*
|
||||
* @box: the relative coords in the corresponding fbo.
|
||||
|
@ -475,7 +474,7 @@ typedef struct glamor_pixmap_private_atlas {
|
|||
glamor_pixmap_private_base_t base;
|
||||
};
|
||||
BoxRec box;
|
||||
}glamor_pixmap_private_atlas_t;
|
||||
} glamor_pixmap_private_atlas_t;
|
||||
|
||||
typedef struct glamor_pixmap_private {
|
||||
union {
|
||||
|
@ -484,7 +483,7 @@ typedef struct glamor_pixmap_private {
|
|||
glamor_pixmap_private_large_t large;
|
||||
glamor_pixmap_private_atlas_t atlas;
|
||||
};
|
||||
}glamor_pixmap_private;
|
||||
} glamor_pixmap_private;
|
||||
|
||||
/*
|
||||
* Pixmap dynamic status, used by dynamic upload feature.
|
||||
|
@ -508,26 +507,21 @@ static inline glamor_screen_private *
|
|||
glamor_get_screen_private(ScreenPtr screen)
|
||||
{
|
||||
return (glamor_screen_private *)
|
||||
dixLookupPrivate(&screen->devPrivates,
|
||||
glamor_screen_private_key);
|
||||
dixLookupPrivate(&screen->devPrivates, glamor_screen_private_key);
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_set_screen_private(ScreenPtr screen, glamor_screen_private *priv)
|
||||
glamor_set_screen_private(ScreenPtr screen, glamor_screen_private * priv)
|
||||
{
|
||||
dixSetPrivate(&screen->devPrivates,
|
||||
glamor_screen_private_key,
|
||||
priv);
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, priv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline glamor_pixmap_private *
|
||||
glamor_get_pixmap_private(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv;
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key);
|
||||
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
|
||||
if (!priv) {
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
|
@ -536,7 +530,7 @@ glamor_get_pixmap_private(PixmapPtr pixmap)
|
|||
return priv;
|
||||
}
|
||||
|
||||
void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv);
|
||||
void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private * priv);
|
||||
|
||||
/**
|
||||
* Returns TRUE if the given planemask covers all the significant bits in the
|
||||
|
@ -556,31 +550,34 @@ PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
|
|||
|
||||
Bool glamor_destroy_pixmap(PixmapPtr pixmap);
|
||||
|
||||
glamor_pixmap_fbo* glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv);
|
||||
void glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo);
|
||||
glamor_pixmap_fbo * glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, GLint tex, int flag);
|
||||
glamor_pixmap_fbo * glamor_create_fbo(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, int flag);
|
||||
void glamor_destroy_fbo(glamor_pixmap_fbo *fbo);
|
||||
void glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv);
|
||||
void glamor_purge_fbo(glamor_pixmap_fbo *fbo);
|
||||
glamor_pixmap_fbo *glamor_pixmap_detach_fbo(glamor_pixmap_private *
|
||||
pixmap_priv);
|
||||
void glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo * fbo);
|
||||
glamor_pixmap_fbo *glamor_create_fbo_from_tex(glamor_screen_private *
|
||||
glamor_priv, int w, int h,
|
||||
GLenum format, GLint tex,
|
||||
int flag);
|
||||
glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private * glamor_priv, int w,
|
||||
int h, GLenum format, int flag);
|
||||
void glamor_destroy_fbo(glamor_pixmap_fbo * fbo);
|
||||
void glamor_pixmap_destroy_fbo(glamor_pixmap_private * priv);
|
||||
void glamor_purge_fbo(glamor_pixmap_fbo * fbo);
|
||||
|
||||
void glamor_init_pixmap_fbo(ScreenPtr screen);
|
||||
void glamor_fini_pixmap_fbo(ScreenPtr screen);
|
||||
Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
|
||||
void glamor_fbo_expire(glamor_screen_private *glamor_priv);
|
||||
void glamor_fbo_expire(glamor_screen_private * glamor_priv);
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h, glamor_pixmap_private *);
|
||||
glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private * glamor_priv,
|
||||
int w, int h, GLenum format,
|
||||
int flag, int block_w, int block_h,
|
||||
glamor_pixmap_private *);
|
||||
|
||||
/* glamor_copyarea.c */
|
||||
RegionPtr
|
||||
|
||||
glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
int srcx, int srcy, int width, int height, int dstx,
|
||||
int dsty);
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty);
|
||||
void glamor_copy_n_to_n(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
BoxPtr box, int nbox, int dx, int dy, Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane, void *closure);
|
||||
|
@ -610,26 +607,24 @@ GLint glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
|||
const char *source);
|
||||
void glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog);
|
||||
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
|
||||
unsigned long fg_pixel,
|
||||
GLfloat * color);
|
||||
unsigned long fg_pixel, GLfloat * color);
|
||||
|
||||
int glamor_set_destination_pixmap(PixmapPtr pixmap);
|
||||
int glamor_set_destination_pixmap_priv(glamor_pixmap_private *
|
||||
pixmap_priv);
|
||||
int glamor_set_destination_pixmap_priv(glamor_pixmap_private * pixmap_priv);
|
||||
void glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *, int, int, int, int);
|
||||
|
||||
/* nc means no check. caller must ensure this pixmap has valid fbo.
|
||||
* usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
|
||||
* */
|
||||
void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *
|
||||
pixmap_priv);
|
||||
void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private * pixmap_priv);
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLenum format,
|
||||
GLenum type, int no_alpha, int revert, int swap_rb);
|
||||
glamor_pixmap_fbo *glamor_es2_pixmap_read_prepare(PixmapPtr source, int x,
|
||||
int y, int w, int h,
|
||||
GLenum format, GLenum type,
|
||||
int no_alpha, int revert,
|
||||
int swap_rb);
|
||||
|
||||
Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch,
|
||||
unsigned char alu);
|
||||
Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch, unsigned char alu);
|
||||
Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
|
||||
Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
|
||||
RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
|
||||
|
@ -640,9 +635,6 @@ int glamor_gl_get_version(void);
|
|||
((major) * 256) \
|
||||
+ ((minor) * 1))
|
||||
|
||||
|
||||
|
||||
|
||||
/* glamor_fill.c */
|
||||
Bool glamor_fill(DrawablePtr drawable,
|
||||
GCPtr gc, int x, int y, int width, int height, Bool fallback);
|
||||
|
@ -650,9 +642,9 @@ Bool glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel);
|
||||
Bool
|
||||
|
||||
glamor_solid_boxes(PixmapPtr pixmap,
|
||||
BoxPtr box, int nbox,
|
||||
unsigned long fg_pixel);
|
||||
BoxPtr box, int nbox, unsigned long fg_pixel);
|
||||
|
||||
/* glamor_fillspans.c */
|
||||
void glamor_fill_spans(DrawablePtr drawable,
|
||||
|
@ -665,10 +657,10 @@ void glamor_fini_solid_shader(ScreenPtr screen);
|
|||
/* glamor_getspans.c */
|
||||
void
|
||||
|
||||
|
||||
glamor_get_spans(DrawablePtr drawable,
|
||||
int wmax,
|
||||
DDXPointPtr points,
|
||||
int *widths, int nspans, char *dst_start);
|
||||
DDXPointPtr points, int *widths, int nspans, char *dst_start);
|
||||
|
||||
/* glamor_glyphs.c */
|
||||
void glamor_glyphs_fini(ScreenPtr screen);
|
||||
|
@ -677,8 +669,7 @@ void glamor_glyphs(CARD8 op,
|
|||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc, int nlist, GlyphListPtr list,
|
||||
GlyphPtr * glyphs);
|
||||
INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs);
|
||||
|
||||
/* glamor_setspans.c */
|
||||
void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
|
@ -686,18 +677,21 @@ void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
|
||||
/* glamor_polyfillrect.c */
|
||||
void
|
||||
|
||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect);
|
||||
GCPtr gc, int nrect, xRectangle *prect);
|
||||
|
||||
/* glamor_polylines.c */
|
||||
void
|
||||
|
||||
|
||||
glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points);
|
||||
|
||||
/* glamor_putimage.c */
|
||||
void
|
||||
|
||||
|
||||
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int leftPad, int format, char *bits);
|
||||
void glamor_init_putimage_shaders(ScreenPtr screen);
|
||||
|
@ -705,20 +699,18 @@ void glamor_fini_putimage_shaders(ScreenPtr screen);
|
|||
|
||||
/* glamor_render.c */
|
||||
Bool
|
||||
|
||||
glamor_composite_clipped_region(CARD8 op,
|
||||
PicturePtr source,
|
||||
PicturePtr mask,
|
||||
PicturePtr dest,
|
||||
glamor_pixmap_private *soruce_pixmap_priv,
|
||||
glamor_pixmap_private *mask_pixmap_priv,
|
||||
glamor_pixmap_private *dest_pixmap_priv,
|
||||
glamor_pixmap_private * soruce_pixmap_priv,
|
||||
glamor_pixmap_private * mask_pixmap_priv,
|
||||
glamor_pixmap_private * dest_pixmap_priv,
|
||||
RegionPtr region,
|
||||
int x_source,
|
||||
int y_source,
|
||||
int x_mask,
|
||||
int y_mask,
|
||||
int x_dest,
|
||||
int y_dest);
|
||||
int x_mask, int y_mask, int x_dest, int y_dest);
|
||||
|
||||
void glamor_composite(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
|
@ -736,11 +728,9 @@ void glamor_composite_glyph_rects(CARD8 op,
|
|||
PicturePtr src, PicturePtr mask,
|
||||
PicturePtr dst, int nrect,
|
||||
glamor_composite_rect_t * rects);
|
||||
void glamor_composite_rects (CARD8 op,
|
||||
void glamor_composite_rects(CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
xRenderColor * color, int nRect, xRectangle *rects);
|
||||
void glamor_init_trapezoid_shader(ScreenPtr screen);
|
||||
void glamor_fini_trapezoid_shader(ScreenPtr screen);
|
||||
PicturePtr glamor_convert_gradient_picture(ScreenPtr screen,
|
||||
|
@ -752,18 +742,19 @@ Bool glamor_composite_choose_shader(CARD8 op,
|
|||
PicturePtr source,
|
||||
PicturePtr mask,
|
||||
PicturePtr dest,
|
||||
glamor_pixmap_private *source_pixmap_priv,
|
||||
glamor_pixmap_private *mask_pixmap_priv,
|
||||
glamor_pixmap_private *dest_pixmap_priv,
|
||||
glamor_pixmap_private * source_pixmap_priv,
|
||||
glamor_pixmap_private * mask_pixmap_priv,
|
||||
glamor_pixmap_private * dest_pixmap_priv,
|
||||
struct shader_key *s_key,
|
||||
glamor_composite_shader **shader,
|
||||
glamor_composite_shader ** shader,
|
||||
struct blendinfo *op_info,
|
||||
PictFormatShort *psaved_source_format);
|
||||
PictFormatShort * psaved_source_format);
|
||||
|
||||
void
|
||||
glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
|
||||
|
||||
glamor_composite_set_shader_blend(glamor_pixmap_private * dest_priv,
|
||||
struct shader_key *key,
|
||||
glamor_composite_shader *shader,
|
||||
glamor_composite_shader * shader,
|
||||
struct blendinfo *op_info);
|
||||
|
||||
void glamor_setup_composite_vbo(ScreenPtr screen, int n_verts);
|
||||
|
@ -803,6 +794,7 @@ PicturePtr glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
/* glamor_triangles.c */
|
||||
void
|
||||
|
||||
|
||||
glamor_triangles(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
|
@ -813,6 +805,7 @@ glamor_triangles(CARD8 op,
|
|||
|
||||
void glamor_pixmap_init(ScreenPtr screen);
|
||||
void glamor_pixmap_fini(ScreenPtr screen);
|
||||
|
||||
/**
|
||||
* Download a pixmap's texture to cpu memory. If success,
|
||||
* One copy of current pixmap's texture will be put into
|
||||
|
@ -822,14 +815,12 @@ void glamor_pixmap_fini(ScreenPtr screen);
|
|||
* gl_tex must be 1. Used by glamor_prepare_access.
|
||||
*
|
||||
*/
|
||||
Bool glamor_download_pixmap_to_cpu(PixmapPtr pixmap,
|
||||
Bool glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access);
|
||||
|
||||
void *glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w,
|
||||
int h, int stride, void *bits, int pbo,
|
||||
glamor_access_t access);
|
||||
|
||||
void *
|
||||
glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
||||
int stride, void *bits, int pbo, glamor_access_t access);
|
||||
|
||||
|
||||
/**
|
||||
* Restore a pixmap's data which is downloaded by
|
||||
* glamor_download_pixmap_to_cpu to its original
|
||||
|
@ -849,7 +840,7 @@ void glamor_restore_pixmap_to_texture(PixmapPtr pixmap);
|
|||
* If the fbo already has a valid glfbo then do nothing.
|
||||
*/
|
||||
Bool
|
||||
glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag);
|
||||
glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag);
|
||||
|
||||
/**
|
||||
* Upload a pixmap to gl texture. Used by dynamic pixmap
|
||||
|
@ -860,34 +851,41 @@ enum glamor_pixmap_status glamor_upload_pixmap_to_texture(PixmapPtr
|
|||
pixmap);
|
||||
|
||||
Bool
|
||||
glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h,
|
||||
int stride, void *bits, int pbo);
|
||||
|
||||
glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
|
||||
int h, int stride, void *bits, int pbo);
|
||||
|
||||
PixmapPtr
|
||||
|
||||
glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y,
|
||||
int w, int h, glamor_access_t access);
|
||||
void
|
||||
|
||||
glamor_put_sub_pixmap(PixmapPtr sub_pixmap, PixmapPtr pixmap, int x, int y,
|
||||
int w, int h, glamor_access_t access);
|
||||
|
||||
glamor_pixmap_clipped_regions *
|
||||
glamor_compute_clipped_regions(glamor_pixmap_private *priv, RegionPtr region,
|
||||
int *clipped_nbox, int repeat_type,
|
||||
int reverse, int upsidedown);
|
||||
glamor_pixmap_clipped_regions
|
||||
*glamor_compute_clipped_regions(glamor_pixmap_private * priv,
|
||||
RegionPtr region, int *clipped_nbox,
|
||||
int repeat_type, int reverse,
|
||||
int upsidedown);
|
||||
|
||||
glamor_pixmap_clipped_regions *
|
||||
glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv,
|
||||
RegionPtr region,
|
||||
int *n_region,
|
||||
glamor_pixmap_clipped_regions
|
||||
*glamor_compute_clipped_regions_ext(glamor_pixmap_private * pixmap_priv,
|
||||
RegionPtr region, int *n_region,
|
||||
int inner_block_w, int inner_block_h,
|
||||
int reverse, int upsidedown);
|
||||
|
||||
glamor_pixmap_clipped_regions *
|
||||
glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, struct pixman_transform *transform,
|
||||
RegionPtr region, int *n_region, int dx, int dy, int repeat_type,
|
||||
int reverse, int upsidedown);
|
||||
glamor_pixmap_clipped_regions
|
||||
*glamor_compute_transform_clipped_regions(glamor_pixmap_private * priv,
|
||||
struct pixman_transform
|
||||
*transform, RegionPtr region,
|
||||
int *n_region, int dx, int dy,
|
||||
int repeat_type, int reverse,
|
||||
int upsidedown);
|
||||
|
||||
Bool
|
||||
|
||||
glamor_composite_largepixmap_region(CARD8 op,
|
||||
PicturePtr source,
|
||||
PicturePtr mask,
|
||||
|
@ -904,12 +902,14 @@ glamor_composite_largepixmap_region(CARD8 op,
|
|||
CARD16 width, CARD16 height);
|
||||
|
||||
Bool
|
||||
|
||||
glamor_get_transform_block_size(struct pixman_transform *transform,
|
||||
int block_w, int block_h,
|
||||
int *transformed_block_w,
|
||||
int *transformed_block_h);
|
||||
|
||||
void
|
||||
|
||||
glamor_get_transform_extent_from_box(struct pixman_box32 *temp_box,
|
||||
struct pixman_transform *transform);
|
||||
|
||||
|
@ -925,8 +925,9 @@ enum glamor_pixmap_status
|
|||
* convert the bits to the specified format/type format
|
||||
* if the conversion is unavoidable.
|
||||
**/
|
||||
Bool glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GLenum type,
|
||||
int no_alpha, int revert, int swap_rb, void *bits);
|
||||
Bool glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
|
||||
GLenum type, int no_alpha, int revert,
|
||||
int swap_rb, void *bits);
|
||||
|
||||
/**
|
||||
* Destroy all the resources allocated on the uploading
|
||||
|
@ -939,7 +940,7 @@ int glamor_create_picture(PicturePtr picture);
|
|||
void glamor_set_window_pixmap(WindowPtr pWindow, PixmapPtr pPixmap);
|
||||
|
||||
Bool
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
|
||||
|
||||
void glamor_finish_access_picture(PicturePtr picture, glamor_access_t access);
|
||||
|
||||
|
@ -947,58 +948,68 @@ void glamor_destroy_picture(PicturePtr picture);
|
|||
|
||||
/* fixup a fbo to the exact size as the pixmap. */
|
||||
Bool
|
||||
glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv);
|
||||
|
||||
glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private * pixmap_priv);
|
||||
|
||||
void
|
||||
|
||||
glamor_picture_format_fixup(PicturePtr picture,
|
||||
glamor_pixmap_private * pixmap_priv);
|
||||
|
||||
void
|
||||
|
||||
glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d);
|
||||
|
||||
void
|
||||
|
||||
glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps);
|
||||
INT16 x_off, INT16 y_off, int ntrap, xTrap * traps);
|
||||
|
||||
RegionPtr
|
||||
|
||||
glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane);
|
||||
|
||||
void
|
||||
|
||||
glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
|
||||
void
|
||||
|
||||
glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
|
||||
void
|
||||
|
||||
glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y);
|
||||
|
||||
void
|
||||
|
||||
glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
|
||||
void
|
||||
|
||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg);
|
||||
xSegment * pSeg);
|
||||
|
||||
void
|
||||
|
||||
glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
|
||||
void
|
||||
|
||||
glamor_composite_rectangles(CARD8 op,
|
||||
PicturePtr dst,
|
||||
xRenderColor *color,
|
||||
int num_rects,
|
||||
xRectangle *rects);
|
||||
xRenderColor * color,
|
||||
int num_rects, xRectangle *rects);
|
||||
|
||||
/* glamor_xv */
|
||||
typedef struct {
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/** @file glamor_putaimge.c
|
||||
*
|
||||
* XPutImage implementation
|
||||
|
@ -37,8 +36,7 @@ void
|
|||
glamor_init_putimage_shaders(ScreenPtr screen)
|
||||
{
|
||||
#if 0
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
const char *xybitmap_vs =
|
||||
"uniform float x_bias;\n" "uniform float x_scale;\n"
|
||||
"uniform float y_bias;\n" "uniform float y_scale;\n"
|
||||
|
@ -62,8 +60,7 @@ glamor_init_putimage_shaders(ScreenPtr screen)
|
|||
|
||||
prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xybitmap_vs);
|
||||
fs_prog =
|
||||
glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
|
||||
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
|
||||
dispatch->glAttachShader(prog, vs_prog);
|
||||
dispatch->glAttachShader(prog, fs_prog);
|
||||
glamor_link_glsl_prog(prog);
|
||||
|
@ -78,13 +75,13 @@ glamor_init_putimage_shaders(ScreenPtr screen)
|
|||
glamor_priv->put_image_xybitmap_bg_uniform_location =
|
||||
dispatch->glGetUniformLocation(prog, "bg");
|
||||
glamor_get_transform_uniform_locations(prog,
|
||||
&glamor_priv->put_image_xybitmap_transform);
|
||||
&glamor_priv->
|
||||
put_image_xybitmap_transform);
|
||||
glamor_priv->put_image_xybitmap_prog = prog;
|
||||
dispatch->glUseProgram(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Do an XYBitmap putimage. The bits are byte-aligned rows of bitmap
|
||||
* data (where each row starts at a bit index of left_pad), and the
|
||||
* destination gets filled with the gc's fg color where the bitmap is set
|
||||
|
@ -110,7 +107,6 @@ y_flip(PixmapPtr pixmap, int y)
|
|||
return y;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
||||
int x, int y, int w, int h, int left_pad,
|
||||
|
@ -118,8 +114,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
{
|
||||
ScreenPtr screen = drawable->pScreen;
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
float fg[4], bg[4];
|
||||
GLuint tex;
|
||||
unsigned int stride = PixmapBytePad(1, w + left_pad);
|
||||
|
@ -127,6 +122,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
BoxPtr box;
|
||||
int nbox;
|
||||
float dest_coords[8];
|
||||
|
||||
const float bitmap_coords[8] = {
|
||||
0.0, 0.0,
|
||||
1.0, 0.0,
|
||||
|
@ -170,10 +166,8 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, stride * 8);
|
||||
dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
|
||||
|
@ -194,8 +188,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
|
||||
dispatch->glEnable(GL_SCISSOR_TEST);
|
||||
clip = fbGetCompositeClip(gc);
|
||||
for (nbox = REGION_NUM_RECTS(clip),
|
||||
box = REGION_RECTS(clip); nbox--; box++) {
|
||||
for (nbox = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nbox--; box++) {
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int x2 = x + w;
|
||||
|
@ -230,10 +223,9 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
glamor_set_planemask(pixmap, ~0);
|
||||
glamor_fallback(": to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
fail:
|
||||
fail:
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap,
|
||||
bits);
|
||||
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap, bits);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
}
|
||||
|
@ -244,14 +236,13 @@ glamor_fini_putimage_shaders(ScreenPtr screen)
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
_glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int left_pad, int image_format, char *bits, Bool fallback)
|
||||
int w, int h, int left_pad, int image_format, char *bits,
|
||||
Bool fallback)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
RegionPtr clip;
|
||||
int x_off, y_off;
|
||||
Bool ret = FALSE;
|
||||
|
@ -302,19 +293,21 @@ _glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h,
|
||||
pixmap->devKind, bits, 0);
|
||||
|
||||
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x, y);
|
||||
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x,
|
||||
y);
|
||||
glamor_destroy_pixmap(temp_pixmap);
|
||||
} else
|
||||
glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off, y + drawable->y + y_off,
|
||||
w, h, PixmapBytePad(w, depth), bits, 0);
|
||||
}
|
||||
else
|
||||
glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off,
|
||||
y + drawable->y + y_off, w, h,
|
||||
PixmapBytePad(w, depth), bits, 0);
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
|
||||
goto done;
|
||||
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
|
@ -325,23 +318,23 @@ fail:
|
|||
GLAMOR_ACCESS_RW);
|
||||
if (sub_pixmap) {
|
||||
if (clip != NULL)
|
||||
pixman_region_translate (clip, -x - drawable->x, -y - drawable->y);
|
||||
pixman_region_translate(clip, -x - drawable->x, -y - drawable->y);
|
||||
|
||||
fbPutImage(&sub_pixmap->drawable, gc, depth, 0, 0, w, h,
|
||||
left_pad, image_format, bits);
|
||||
|
||||
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
||||
x + x_off + drawable->x,
|
||||
y + y_off + drawable->y,
|
||||
w, h, GLAMOR_ACCESS_RW);
|
||||
y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RW);
|
||||
if (clip != NULL)
|
||||
pixman_region_translate (clip, x + drawable->x, y + drawable->y);
|
||||
} else
|
||||
pixman_region_translate(clip, x + drawable->x, y + drawable->y);
|
||||
}
|
||||
else
|
||||
fbPutImage(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits);
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -360,4 +353,3 @@ glamor_put_image_nf(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
return _glamor_put_image(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits, FALSE);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -56,6 +56,7 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
for (i = 0; i < numPoints; i++) {
|
||||
|
||||
int n = REGION_NUM_RECTS(clip);
|
||||
|
||||
pbox = REGION_RECTS(clip);
|
||||
while (n--) {
|
||||
int x1 = points[i].x;
|
||||
|
@ -68,8 +69,10 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
x2 = x2 < pbox->x2 ? x2 : pbox->x2;
|
||||
if (x1 >= x2)
|
||||
continue;
|
||||
glamor_upload_sub_pixmap_to_texture(dest_pixmap, x1 + x_off, y1 + y_off, x2 - x1, 1,
|
||||
PixmapBytePad(widths[i], drawable->depth),
|
||||
glamor_upload_sub_pixmap_to_texture(dest_pixmap, x1 + x_off,
|
||||
y1 + y_off, x2 - x1, 1,
|
||||
PixmapBytePad(widths[i],
|
||||
drawable->depth),
|
||||
drawpixels_src, 0);
|
||||
}
|
||||
drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
|
||||
|
@ -77,9 +80,8 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
||||
fail:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
|
@ -90,7 +92,7 @@ fail:
|
|||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -98,8 +100,7 @@ void
|
|||
glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted)
|
||||
{
|
||||
_glamor_set_spans(drawable, gc, src, points,
|
||||
widths, n, sorted, TRUE);
|
||||
_glamor_set_spans(drawable, gc, src, points, widths, n, sorted, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
|
|
|
@ -56,8 +56,7 @@ glamor_init_tile_shader(ScreenPtr screen)
|
|||
" vec2 rel_tex;"
|
||||
" rel_tex = tile_texture * wh; \n"
|
||||
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n"
|
||||
" gl_FragColor = texture2D(sampler, rel_tex);\n"
|
||||
"}\n";
|
||||
" gl_FragColor = texture2D(sampler, rel_tex);\n" "}\n";
|
||||
GLint fs_prog, vs_prog;
|
||||
GLint sampler_uniform_location;
|
||||
|
||||
|
@ -65,27 +64,23 @@ glamor_init_tile_shader(ScreenPtr screen)
|
|||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_priv->tile_prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, tile_vs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
tile_fs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, tile_fs);
|
||||
dispatch->glAttachShader(glamor_priv->tile_prog, vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->tile_prog, fs_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->tile_prog);
|
||||
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog,
|
||||
"sampler");
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "sampler");
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
|
||||
glamor_priv->tile_wh =
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog,
|
||||
"wh");
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "wh");
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
@ -104,12 +99,10 @@ glamor_fini_tile_shader(ScreenPtr screen)
|
|||
|
||||
static void
|
||||
_glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||
int x, int y, int width, int height,
|
||||
int tile_x, int tile_y)
|
||||
int x, int y, int width, int height, int tile_x, int tile_y)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int x1 = x;
|
||||
int x2 = x + width;
|
||||
|
@ -125,31 +118,24 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
float wh[4];
|
||||
|
||||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
||||
pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale,
|
||||
&src_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
|
||||
glamor_pixmap_fbo_fix_wh_ratio(wh, src_pixmap_priv);
|
||||
dispatch->glUniform2fv(glamor_priv->tile_wh, 1, wh);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D,
|
||||
src_pixmap_priv->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
|
||||
GL_REPEAT);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
|
||||
GL_REPEAT);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
|
@ -157,24 +143,19 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
(src_pixmap_priv, RepeatNormal,
|
||||
src_xscale, src_yscale,
|
||||
tile_x1, tile_y1,
|
||||
tile_x2, tile_y2,
|
||||
glamor_priv->yInverted,
|
||||
source_texcoords);
|
||||
tile_x2, tile_y2, glamor_priv->yInverted, source_texcoords);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
source_texcoords);
|
||||
2 * sizeof(float), source_texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
|
||||
x1, y1,
|
||||
x2, y2,
|
||||
glamor_priv->yInverted, vertices);
|
||||
x2, y2, glamor_priv->yInverted, vertices);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
GL_FALSE, 2 * sizeof(float), vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
|
@ -193,12 +174,10 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
Bool
|
||||
glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||
int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
int tile_x, int tile_y)
|
||||
unsigned char alu, unsigned long planemask, int tile_x, int tile_y)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
@ -245,37 +224,42 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
box.y2 = y + height;
|
||||
RegionInitBoxes(®ion, &box, 1);
|
||||
clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
|
||||
®ion, &n_dst_region, 0, 0, 0);
|
||||
for(i = 0; i < n_dst_region; i++)
|
||||
{
|
||||
®ion,
|
||||
&n_dst_region, 0,
|
||||
0, 0);
|
||||
for (i = 0; i < n_dst_region; i++) {
|
||||
int n_src_region;
|
||||
glamor_pixmap_clipped_regions *clipped_src_regions;
|
||||
BoxPtr current_boxes;
|
||||
int n_current_boxes;
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv, clipped_dst_regions[i].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv,
|
||||
clipped_dst_regions[i].block_idx);
|
||||
|
||||
if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionTranslate(clipped_dst_regions[i].region,
|
||||
tile_x - x, tile_y - y);
|
||||
DEBUGF("tiled a large src pixmap. %dx%d \n", tile->drawable.width, tile->drawable.height);
|
||||
clipped_src_regions = glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].region,
|
||||
&n_src_region, 1, 0, 0);
|
||||
DEBUGF("tiled a large src pixmap. %dx%d \n",
|
||||
tile->drawable.width, tile->drawable.height);
|
||||
clipped_src_regions =
|
||||
glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].
|
||||
region, &n_src_region, 1, 0,
|
||||
0);
|
||||
DEBUGF("got %d src regions %d \n", n_src_region);
|
||||
for (j = 0; j < n_src_region; j++)
|
||||
{
|
||||
for (j = 0; j < n_src_region; j++) {
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(src_pixmap_priv, clipped_src_regions[j].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(src_pixmap_priv,
|
||||
clipped_src_regions[j].block_idx);
|
||||
|
||||
RegionTranslate(clipped_src_regions[j].region,
|
||||
x - tile_x,
|
||||
y - tile_y);
|
||||
x - tile_x, y - tile_y);
|
||||
current_boxes = RegionRects(clipped_src_regions[j].region);
|
||||
n_current_boxes = RegionNumRects(clipped_src_regions[j].region);
|
||||
for(k = 0; k < n_current_boxes; k++)
|
||||
{
|
||||
DEBUGF("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
|
||||
n_current_boxes =
|
||||
RegionNumRects(clipped_src_regions[j].region);
|
||||
for (k = 0; k < n_current_boxes; k++) {
|
||||
DEBUGF
|
||||
("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
current_boxes[k].y2 - current_boxes[k].y1,
|
||||
|
@ -295,11 +279,11 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
RegionDestroy(clipped_src_regions[j].region);
|
||||
}
|
||||
free(clipped_src_regions);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
current_boxes = RegionRects(clipped_dst_regions[i].region);
|
||||
n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
|
||||
for(k = 0; k < n_current_boxes; k++)
|
||||
{
|
||||
for (k = 0; k < n_current_boxes; k++) {
|
||||
_glamor_tile(pixmap, tile,
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
|
@ -319,7 +303,7 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
glamor_set_alu(dispatch, GXcopy);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
return TRUE;
|
||||
fail:
|
||||
fail:
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
|
|
@ -37,22 +37,24 @@
|
|||
#include "fbpict.h"
|
||||
|
||||
static xFixed
|
||||
_glamor_linefixedX (xLineFixed *l, xFixed y, Bool ceil)
|
||||
_glamor_linefixedX(xLineFixed * l, xFixed y, Bool ceil)
|
||||
{
|
||||
xFixed dx = l->p2.x - l->p1.x;
|
||||
xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
|
||||
xFixed dy = l->p2.y - l->p1.y;
|
||||
|
||||
if (ceil)
|
||||
ex += (dy - 1);
|
||||
return l->p1.x + (xFixed) (ex / dy);
|
||||
}
|
||||
|
||||
static xFixed
|
||||
_glamor_linefixedY (xLineFixed *l, xFixed x, Bool ceil)
|
||||
_glamor_linefixedY(xLineFixed * l, xFixed x, Bool ceil)
|
||||
{
|
||||
xFixed dy = l->p2.y - l->p1.y;
|
||||
xFixed_32_32 ey = (xFixed_32_32) (x - l->p1.x) * dy;
|
||||
xFixed dx = l->p2.x - l->p1.x;
|
||||
|
||||
if (ceil)
|
||||
ey += (dx - 1);
|
||||
return l->p1.y + (xFixed) (ey / dx);
|
||||
|
@ -73,7 +75,7 @@ _glamor_linefixedY (xLineFixed *l, xFixed x, Bool ceil)
|
|||
&& point[1] <= IntToxFixed(rect->y2))
|
||||
|
||||
static xFixed
|
||||
_glamor_lines_crossfixedY (xLineFixed *l, xLineFixed *r)
|
||||
_glamor_lines_crossfixedY(xLineFixed * l, xLineFixed * r)
|
||||
{
|
||||
xFixed dx1 = l->p2.x - l->p1.x;
|
||||
xFixed dx2 = r->p2.x - r->p1.x;
|
||||
|
@ -85,15 +87,17 @@ _glamor_lines_crossfixedY (xLineFixed *l, xLineFixed *r)
|
|||
xFixed_32_32 dividend3;
|
||||
xFixed_32_32 divisor;
|
||||
|
||||
tmp = (xFixed_32_32) dx1 * dy2;
|
||||
tmp = (xFixed_32_32) dx1 *dy2;
|
||||
|
||||
dividend2 = (tmp >> 32) * l->p1.y;
|
||||
tmp = (xFixed_32_32) dy1 * dx2;
|
||||
tmp = (xFixed_32_32) dy1 *dx2;
|
||||
|
||||
dividend3 = (tmp >> 32) * r->p1.y;
|
||||
divisor = ((xFixed_32_32) dx1 * (xFixed_32_32) dy2
|
||||
- (xFixed_32_32) dy1 * (xFixed_32_32) dx2) >> 32;
|
||||
|
||||
if (divisor)
|
||||
return (xFixed)((dividend2 - dividend1 - dividend3) / divisor);
|
||||
return (xFixed) ((dividend2 - dividend1 - dividend3) / divisor);
|
||||
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
@ -103,14 +107,15 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
{
|
||||
int ret = TRUE;
|
||||
int tmp;
|
||||
|
||||
if (point[1] > trap->bottom) {
|
||||
ret = FALSE;
|
||||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("Out of Trap bottom, point[1] = %d(0x%x)), "
|
||||
"bottom = %d(0x%x)\n",
|
||||
(unsigned int)xFixedToInt(point[1]), point[1],
|
||||
(unsigned int)xFixedToInt(trap->bottom),
|
||||
(unsigned int)trap->bottom);
|
||||
(unsigned int) xFixedToInt(point[1]), point[1],
|
||||
(unsigned int) xFixedToInt(trap->bottom),
|
||||
(unsigned int) trap->bottom);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -121,15 +126,15 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("Out of Trap top, point[1] = %d(0x%x)), "
|
||||
"top = %d(0x%x)\n",
|
||||
(unsigned int)xFixedToInt(point[1]), point[1],
|
||||
(unsigned int)xFixedToInt(trap->top),
|
||||
(unsigned int)trap->top);
|
||||
(unsigned int) xFixedToInt(point[1]), point[1],
|
||||
(unsigned int) xFixedToInt(trap->top),
|
||||
(unsigned int) trap->top);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
tmp = _glamor_linefixedX (&trap->left, point[1], FALSE);
|
||||
tmp = _glamor_linefixedX(&trap->left, point[1], FALSE);
|
||||
if (point[0] < tmp) {
|
||||
ret = FALSE;
|
||||
|
||||
|
@ -137,7 +142,8 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
abs(point[1] - trap->top) < pixman_fixed_1_minus_e &&
|
||||
tmp - point[0] < pixman_fixed_1_minus_e) {
|
||||
ret = TRUE;
|
||||
} else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
}
|
||||
else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
point[1] - trap->bottom < pixman_fixed_1_minus_e &&
|
||||
tmp - point[0] < pixman_fixed_1_minus_e) {
|
||||
ret = TRUE;
|
||||
|
@ -146,15 +152,15 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
if (DEBUG_CLIP_VTX && !ret) {
|
||||
ErrorF("Out of Trap left, point[0] = %d(0x%x)), "
|
||||
"left = %d(0x%x)\n",
|
||||
(unsigned int)xFixedToInt(point[0]), point[0],
|
||||
(unsigned int)xFixedToInt(tmp), (unsigned int)tmp);
|
||||
(unsigned int) xFixedToInt(point[0]), point[0],
|
||||
(unsigned int) xFixedToInt(tmp), (unsigned int) tmp);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
tmp = _glamor_linefixedX (&trap->right, point[1], TRUE);
|
||||
tmp = _glamor_linefixedX(&trap->right, point[1], TRUE);
|
||||
if (point[0] > tmp) {
|
||||
ret = FALSE;
|
||||
|
||||
|
@ -162,7 +168,8 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
abs(point[1] - trap->top) < pixman_fixed_1_minus_e &&
|
||||
point[0] - tmp < pixman_fixed_1_minus_e) {
|
||||
ret = TRUE;
|
||||
} else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
}
|
||||
else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
abs(point[1] - trap->bottom) < pixman_fixed_1_minus_e &&
|
||||
point[0] - tmp < pixman_fixed_1_minus_e) {
|
||||
ret = TRUE;
|
||||
|
@ -171,8 +178,8 @@ point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
|||
if (DEBUG_CLIP_VTX && !ret) {
|
||||
ErrorF("Out of Trap right, point[0] = %d(0x%x)), "
|
||||
"right = %d(0x%x)\n",
|
||||
(unsigned int)xFixedToInt(point[0]), point[0],
|
||||
(unsigned int)xFixedToInt(tmp), (unsigned int)tmp);
|
||||
(unsigned int) xFixedToInt(point[0]), point[0],
|
||||
(unsigned int) xFixedToInt(tmp), (unsigned int) tmp);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
|
@ -188,19 +195,15 @@ glamor_emit_composite_triangle(ScreenPtr screen,
|
|||
const float *mask_coords,
|
||||
const float *dst_coords)
|
||||
{
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords,
|
||||
dst_coords, 0);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords,
|
||||
dst_coords, 1);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords,
|
||||
dst_coords, 2);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords, dst_coords, 0);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords, dst_coords, 1);
|
||||
glamor_emit_composite_vert(screen, src_coords, mask_coords, dst_coords, 2);
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_flush_composite_triangles(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
@ -239,26 +242,27 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
int right_cut_right[2];
|
||||
int right_cut_bottom[2];
|
||||
int tmp[2];
|
||||
int tmp_vtx[20*2];
|
||||
int tmp_vtx[20 * 2];
|
||||
float tmp_vtx_slope[20];
|
||||
BoxRec trap_bound;
|
||||
int i = 0;
|
||||
int vertex_num = 0;
|
||||
|
||||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
|
||||
ErrorF
|
||||
("The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
|
||||
"left: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n"
|
||||
"right: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n",
|
||||
xFixedToInt(trap->top), (unsigned int)trap->top,
|
||||
xFixedToInt(trap->bottom), (unsigned int)trap->bottom,
|
||||
xFixedToInt(trap->left.p1.x), (unsigned int)trap->left.p1.x,
|
||||
xFixedToInt(trap->left.p1.y), (unsigned int)trap->left.p1.y,
|
||||
xFixedToInt(trap->left.p2.x), (unsigned int)trap->left.p2.x,
|
||||
xFixedToInt(trap->left.p2.y), (unsigned int)trap->left.p2.y,
|
||||
xFixedToInt(trap->right.p1.x), (unsigned int)trap->right.p1.x,
|
||||
xFixedToInt(trap->right.p1.y), (unsigned int)trap->right.p1.y,
|
||||
xFixedToInt(trap->right.p2.x), (unsigned int)trap->right.p2.x,
|
||||
xFixedToInt(trap->right.p2.y), (unsigned int)trap->right.p2.y);
|
||||
xFixedToInt(trap->top), (unsigned int) trap->top,
|
||||
xFixedToInt(trap->bottom), (unsigned int) trap->bottom,
|
||||
xFixedToInt(trap->left.p1.x), (unsigned int) trap->left.p1.x,
|
||||
xFixedToInt(trap->left.p1.y), (unsigned int) trap->left.p1.y,
|
||||
xFixedToInt(trap->left.p2.x), (unsigned int) trap->left.p2.x,
|
||||
xFixedToInt(trap->left.p2.y), (unsigned int) trap->left.p2.y,
|
||||
xFixedToInt(trap->right.p1.x), (unsigned int) trap->right.p1.x,
|
||||
xFixedToInt(trap->right.p1.y), (unsigned int) trap->right.p1.y,
|
||||
xFixedToInt(trap->right.p2.x), (unsigned int) trap->right.p2.x,
|
||||
xFixedToInt(trap->right.p2.y), (unsigned int) trap->right.p2.y);
|
||||
}
|
||||
|
||||
miTrapezoidBounds(1, trap, &trap_bound);
|
||||
|
@ -335,14 +339,14 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
}
|
||||
|
||||
/*Trap's right edge cut right edge. */
|
||||
if((!IS_TRAP_EDGE_VERTICAL((&trap->left))) ||
|
||||
if ((!IS_TRAP_EDGE_VERTICAL((&trap->left))) ||
|
||||
(!IS_TRAP_EDGE_VERTICAL((&trap->right)))) {
|
||||
edge_cross_y = _glamor_lines_crossfixedY((&trap->left), (&trap->right));
|
||||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("Trap's left edge cut right edge at %d(0x%x), "
|
||||
"trap_top = %x, trap_bottom = %x\n",
|
||||
xFixedToInt(edge_cross_y), edge_cross_y,
|
||||
(unsigned int)trap->top, (unsigned int)trap->bottom);
|
||||
(unsigned int) trap->top, (unsigned int) trap->bottom);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,32 +385,40 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
/*Trap's left edge cut Rect. */
|
||||
if (DEBUG_CLIP_VTX)
|
||||
ErrorF("Trap's left edge cut Rect\n");
|
||||
CACULATE_CUT_VERTEX(left_cut_top, 1, FALSE, IntToxFixed(pbox->y1), (&trap->left));
|
||||
CACULATE_CUT_VERTEX(left_cut_top, 1, FALSE, IntToxFixed(pbox->y1),
|
||||
(&trap->left));
|
||||
ADD_VERTEX_IF_INSIDE(left_cut_top);
|
||||
if (!IS_TRAP_EDGE_VERTICAL((&trap->left))) {
|
||||
CACULATE_CUT_VERTEX(left_cut_left, 0, FALSE, IntToxFixed(pbox->x1), (&trap->left));
|
||||
CACULATE_CUT_VERTEX(left_cut_left, 0, FALSE, IntToxFixed(pbox->x1),
|
||||
(&trap->left));
|
||||
ADD_VERTEX_IF_INSIDE(left_cut_left);
|
||||
}
|
||||
CACULATE_CUT_VERTEX(left_cut_bottom, 1, FALSE, IntToxFixed(pbox->y2), (&trap->left));
|
||||
CACULATE_CUT_VERTEX(left_cut_bottom, 1, FALSE, IntToxFixed(pbox->y2),
|
||||
(&trap->left));
|
||||
ADD_VERTEX_IF_INSIDE(left_cut_bottom);
|
||||
if (!IS_TRAP_EDGE_VERTICAL((&trap->left))) {
|
||||
CACULATE_CUT_VERTEX(left_cut_right, 0, FALSE, IntToxFixed(pbox->x2), (&trap->left));
|
||||
CACULATE_CUT_VERTEX(left_cut_right, 0, FALSE, IntToxFixed(pbox->x2),
|
||||
(&trap->left));
|
||||
ADD_VERTEX_IF_INSIDE(left_cut_right);
|
||||
}
|
||||
|
||||
/*Trap's right edge cut Rect. */
|
||||
if (DEBUG_CLIP_VTX)
|
||||
ErrorF("Trap's right edge cut Rect\n");
|
||||
CACULATE_CUT_VERTEX(right_cut_top, 1, TRUE, IntToxFixed(pbox->y1), (&trap->right));
|
||||
CACULATE_CUT_VERTEX(right_cut_top, 1, TRUE, IntToxFixed(pbox->y1),
|
||||
(&trap->right));
|
||||
ADD_VERTEX_IF_INSIDE(right_cut_top);
|
||||
if (!IS_TRAP_EDGE_VERTICAL((&trap->right))) {
|
||||
CACULATE_CUT_VERTEX(right_cut_left, 0, TRUE, IntToxFixed(pbox->x1), (&trap->right));
|
||||
CACULATE_CUT_VERTEX(right_cut_left, 0, TRUE, IntToxFixed(pbox->x1),
|
||||
(&trap->right));
|
||||
ADD_VERTEX_IF_INSIDE(right_cut_left);
|
||||
}
|
||||
CACULATE_CUT_VERTEX(right_cut_bottom, 1, TRUE, IntToxFixed(pbox->y2), (&trap->right));
|
||||
CACULATE_CUT_VERTEX(right_cut_bottom, 1, TRUE, IntToxFixed(pbox->y2),
|
||||
(&trap->right));
|
||||
ADD_VERTEX_IF_INSIDE(right_cut_bottom);
|
||||
if (!IS_TRAP_EDGE_VERTICAL((&trap->right))) {
|
||||
CACULATE_CUT_VERTEX(right_cut_right, 0, TRUE, IntToxFixed(pbox->x2), (&trap->right));
|
||||
CACULATE_CUT_VERTEX(right_cut_right, 0, TRUE, IntToxFixed(pbox->x2),
|
||||
(&trap->right));
|
||||
ADD_VERTEX_IF_INSIDE(right_cut_right);
|
||||
}
|
||||
|
||||
|
@ -449,7 +461,7 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("\nThe candidate vertex number is %d\n", vertex_num / 2);
|
||||
for (i = 0; i < vertex_num / 2; i++) {
|
||||
ErrorF("(%d, %d) ", tmp_vtx[2*i], tmp_vtx[2*i + 1]);
|
||||
ErrorF("(%d, %d) ", tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
|
||||
}
|
||||
ErrorF("\n");
|
||||
}
|
||||
|
@ -457,16 +469,17 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
/* Sort the vertex by X and then Y. */
|
||||
for (i = 0; i < vertex_num / 2; i++) {
|
||||
int j;
|
||||
|
||||
for (j = 0; j < vertex_num / 2 - i - 1; j++) {
|
||||
if (tmp_vtx[2*j] > tmp_vtx[2*(j+1)]
|
||||
|| (tmp_vtx[2*j] == tmp_vtx[2*(j+1)]
|
||||
&& tmp_vtx[2*j + 1] > tmp_vtx[2*(j+1) + 1])) {
|
||||
tmp[0] = tmp_vtx[2*j];
|
||||
tmp[1] = tmp_vtx[2*j + 1];
|
||||
tmp_vtx[2*j] = tmp_vtx[2*(j+1)];
|
||||
tmp_vtx[2*j + 1] = tmp_vtx[2*(j+1) + 1];
|
||||
tmp_vtx[2*(j+1)] = tmp[0];
|
||||
tmp_vtx[2*(j+1) + 1] = tmp[1];
|
||||
if (tmp_vtx[2 * j] > tmp_vtx[2 * (j + 1)]
|
||||
|| (tmp_vtx[2 * j] == tmp_vtx[2 * (j + 1)]
|
||||
&& tmp_vtx[2 * j + 1] > tmp_vtx[2 * (j + 1) + 1])) {
|
||||
tmp[0] = tmp_vtx[2 * j];
|
||||
tmp[1] = tmp_vtx[2 * j + 1];
|
||||
tmp_vtx[2 * j] = tmp_vtx[2 * (j + 1)];
|
||||
tmp_vtx[2 * j + 1] = tmp_vtx[2 * (j + 1) + 1];
|
||||
tmp_vtx[2 * (j + 1)] = tmp[0];
|
||||
tmp_vtx[2 * (j + 1) + 1] = tmp[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,21 +488,21 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("\nAfter sort vertex number is:\n");
|
||||
for (i = 0; i < vertex_num / 2; i++) {
|
||||
ErrorF("(%d, %d) ", tmp_vtx[2*i], tmp_vtx[2*i + 1]);
|
||||
ErrorF("(%d, %d) ", tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
|
||||
}
|
||||
ErrorF("\n");
|
||||
}
|
||||
|
||||
memset(vertex, -1, 2*6);
|
||||
memset(vertex, -1, 2 * 6);
|
||||
*num = 0;
|
||||
|
||||
for (i = 0; i < vertex_num / 2; i++) {
|
||||
if (*num > 0 && vertex[2*(*num - 1)] == tmp_vtx[2*i]
|
||||
&& vertex[2*(*num - 1) + 1] == tmp_vtx[2*i + 1]) {
|
||||
/*same vertex.*/
|
||||
if (*num > 0 && vertex[2 * (*num - 1)] == tmp_vtx[2 * i]
|
||||
&& vertex[2 * (*num - 1) + 1] == tmp_vtx[2 * i + 1]) {
|
||||
/*same vertex. */
|
||||
if (DEBUG_CLIP_VTX)
|
||||
ErrorF("X Point:(%d, %d) discard\n",
|
||||
tmp_vtx[2*i], tmp_vtx[2*i + 1]);
|
||||
tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -506,28 +519,29 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
}
|
||||
}
|
||||
|
||||
vertex[2*(*num - 1)] = tmp_vtx[2*i];
|
||||
vertex[2*(*num - 1) + 1] = tmp_vtx[2*i + 1];
|
||||
vertex[2 * (*num - 1)] = tmp_vtx[2 * i];
|
||||
vertex[2 * (*num - 1) + 1] = tmp_vtx[2 * i + 1];
|
||||
if (DEBUG_CLIP_VTX)
|
||||
ErrorF("@ Point:(%d, %d) select, num now is %d\n",
|
||||
tmp_vtx[2*i], tmp_vtx[2*i + 1], *num);
|
||||
tmp_vtx[2 * i], tmp_vtx[2 * i + 1], *num);
|
||||
}
|
||||
|
||||
/* Now we need to arrange the vtx in the polygon's counter-clockwise
|
||||
order. We first select the left and top point as the start point and
|
||||
sort every vtx by the slope from vtx to the start vtx. */
|
||||
for (i = 1; i < *num; i++) {
|
||||
tmp_vtx_slope[i] = (vertex[2*i] != vertex[0] ?
|
||||
(float)(vertex[2*i + 1] - vertex[1]) / (float)(vertex[2*i] - vertex[0])
|
||||
: (float)INT_MAX);
|
||||
tmp_vtx_slope[i] = (vertex[2 * i] != vertex[0] ?
|
||||
(float) (vertex[2 * i + 1] -
|
||||
vertex[1]) / (float) (vertex[2 * i] -
|
||||
vertex[0])
|
||||
: (float) INT_MAX);
|
||||
}
|
||||
|
||||
if (DEBUG_CLIP_VTX) {
|
||||
ErrorF("\nvtx number: %d, VTX and slope:\n", *num);
|
||||
for (i = 0; i < *num; i++) {
|
||||
ErrorF("(%d, %d):%f ",
|
||||
vertex[2*i], vertex[2*i + 1],
|
||||
tmp_vtx_slope[i]);
|
||||
vertex[2 * i], vertex[2 * i + 1], tmp_vtx_slope[i]);
|
||||
}
|
||||
ErrorF("\n");
|
||||
}
|
||||
|
@ -536,17 +550,18 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
for (i = 0; i < *num - 1; i++) {
|
||||
int j;
|
||||
float tmp_slope;
|
||||
|
||||
for (j = 1; j < *num - i - 1; j++) {
|
||||
if (tmp_vtx_slope[j] < tmp_vtx_slope[j + 1]) {
|
||||
tmp_slope = tmp_vtx_slope[j];
|
||||
tmp_vtx_slope[j] = tmp_vtx_slope[j + 1];
|
||||
tmp_vtx_slope[j + 1] = tmp_slope;
|
||||
tmp[0] = vertex[2*j];
|
||||
tmp[1] = vertex[2*j + 1];
|
||||
vertex[2*j] = vertex[2*(j+1)];
|
||||
vertex[2*j + 1] = vertex[2*(j+1) + 1];
|
||||
vertex[2*(j+1)] = tmp[0];
|
||||
vertex[2*(j+1) + 1] = tmp[1];
|
||||
tmp[0] = vertex[2 * j];
|
||||
tmp[1] = vertex[2 * j + 1];
|
||||
vertex[2 * j] = vertex[2 * (j + 1)];
|
||||
vertex[2 * j + 1] = vertex[2 * (j + 1) + 1];
|
||||
vertex[2 * (j + 1)] = tmp[0];
|
||||
vertex[2 * (j + 1) + 1] = tmp[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -555,8 +570,7 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
ErrorF("\nBefore return, vtx number: %d, VTX and slope:\n", *num);
|
||||
for (i = 0; i < *num; i++) {
|
||||
ErrorF("(%d, %d):%f ",
|
||||
vertex[2*i], vertex[2*i + 1],
|
||||
tmp_vtx_slope[i]);
|
||||
vertex[2 * i], vertex[2 * i + 1], tmp_vtx_slope[i]);
|
||||
}
|
||||
ErrorF("\n");
|
||||
}
|
||||
|
@ -567,8 +581,7 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
static void
|
||||
glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int stride;
|
||||
int vert_size;
|
||||
|
@ -607,18 +620,19 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
|||
glamor_priv->vb_stride;
|
||||
glamor_priv->vbo_offset = 0;
|
||||
dispatch->glBufferData(GL_ARRAY_BUFFER,
|
||||
glamor_priv->vbo_size,
|
||||
NULL, GL_STREAM_DRAW);
|
||||
glamor_priv->vbo_size, NULL, GL_STREAM_DRAW);
|
||||
}
|
||||
|
||||
glamor_priv->vb = dispatch->glMapBufferRange(GL_ARRAY_BUFFER,
|
||||
glamor_priv->vbo_offset,
|
||||
vert_size,
|
||||
GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
GL_MAP_WRITE_BIT |
|
||||
GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
|
||||
assert(glamor_priv->vb != NULL);
|
||||
glamor_priv->vb -= glamor_priv->vbo_offset;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
glamor_priv->vbo_offset = 0;
|
||||
}
|
||||
|
||||
|
@ -627,31 +641,35 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
|||
/* Set the vertex pointer. */
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset));
|
||||
(void *) ((long) glamor_priv->vbo_offset));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
stride = 2;
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
|
||||
(void *) ((long) glamor_priv->vbo_offset +
|
||||
stride * sizeof(float)));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
stride += 2;
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_TOP_BOTTOM, 2, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
|
||||
(void *) ((long) glamor_priv->vbo_offset +
|
||||
stride * sizeof(float)));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
|
||||
stride += 2;
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_LEFT_PARAM, 4, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
|
||||
(void *) ((long) glamor_priv->vbo_offset +
|
||||
stride * sizeof(float)));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
|
||||
stride += 4;
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_RIGHT_PARAM, 4, GL_FLOAT,
|
||||
GL_FALSE, glamor_priv->vb_stride,
|
||||
(void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
|
||||
(void *) ((long) glamor_priv->vbo_offset +
|
||||
stride * sizeof(float)));
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
|
||||
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
@ -660,8 +678,8 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
|||
static Bool
|
||||
_glamor_trapezoids_with_shader(CARD8 op,
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps)
|
||||
PictFormatPtr mask_format, INT16 x_src,
|
||||
INT16 y_src, int ntrap, xTrapezoid * traps)
|
||||
{
|
||||
ScreenPtr screen = dst->pDrawable->pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
@ -689,13 +707,13 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
int nclip_rect;
|
||||
int mclip_rect;
|
||||
int clip_processed;
|
||||
int clipped_vtx[6*2];
|
||||
int clipped_vtx[6 * 2];
|
||||
RegionRec region;
|
||||
BoxPtr box = NULL;
|
||||
BoxPtr pbox = NULL;
|
||||
int traps_count = 0;
|
||||
int traps_not_completed = 0;
|
||||
xTrapezoid * ptrap = NULL;
|
||||
xTrapezoid *ptrap = NULL;
|
||||
int nbox;
|
||||
float src_matrix[9];
|
||||
Bool ret = FALSE;
|
||||
|
@ -728,7 +746,7 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)
|
||||
|| dest_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
/* Currently. Always fallback to cpu if destination is in CPU memory.*/
|
||||
/* Currently. Always fallback to cpu if destination is in CPU memory. */
|
||||
ret = FALSE;
|
||||
DEBUGF("dst pixmap has no FBO.\n");
|
||||
goto TRAPEZOID_OUT;
|
||||
|
@ -755,13 +773,13 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
x_temp_src = x_src + bounds.x1 - (traps[0].left.p1.x >> 16);
|
||||
y_temp_src = y_src + bounds.y1 - (traps[0].left.p1.y >> 16);
|
||||
|
||||
if ((!src->pDrawable &&
|
||||
(src->pSourcePict->type != SourcePictTypeSolidFill)) //1. The Gradient case.
|
||||
/* 2. Has no fbo but can upload.*/
|
||||
if ((!src->pDrawable && (src->pSourcePict->type != SourcePictTypeSolidFill)) //1. The Gradient case.
|
||||
/* 2. Has no fbo but can upload. */
|
||||
|| (src->pDrawable && !GLAMOR_PIXMAP_PRIV_HAS_FBO(source_pixmap_priv)
|
||||
&& ((src_width * src_height * 4 <
|
||||
source_pixmap->drawable.width * source_pixmap->drawable.height)
|
||||
|| !glamor_check_fbo_size(glamor_priv, source_pixmap->drawable.width,
|
||||
|| !glamor_check_fbo_size(glamor_priv,
|
||||
source_pixmap->drawable.width,
|
||||
source_pixmap->drawable.height)))) {
|
||||
|
||||
if (!glamor_check_fbo_size(glamor_priv, src_width, src_height)) {
|
||||
|
@ -777,7 +795,8 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
DEBUGF("Convert gradient picture failed\n");
|
||||
goto TRAPEZOID_OUT;
|
||||
}
|
||||
temp_src_priv = glamor_get_pixmap_private((PixmapPtr)temp_src->pDrawable);
|
||||
temp_src_priv =
|
||||
glamor_get_pixmap_private((PixmapPtr) temp_src->pDrawable);
|
||||
x_temp_src = y_temp_src = 0;
|
||||
}
|
||||
|
||||
|
@ -791,9 +810,7 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
if (!miComputeCompositeRegion(®ion,
|
||||
temp_src, NULL, dst,
|
||||
x_temp_src, y_temp_src,
|
||||
0, 0,
|
||||
x_dst, y_dst,
|
||||
src_width, src_height)) {
|
||||
0, 0, x_dst, y_dst, src_width, src_height)) {
|
||||
DEBUGF("All the regions are clipped out, do nothing\n");
|
||||
goto TRAPEZOID_OUT;
|
||||
}
|
||||
|
@ -804,7 +821,8 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
|
||||
ret = glamor_composite_choose_shader(op, temp_src, NULL, dst,
|
||||
temp_src_priv, NULL, dest_pixmap_priv,
|
||||
&key, &shader, &op_info, &saved_source_format);
|
||||
&key, &shader, &op_info,
|
||||
&saved_source_format);
|
||||
if (ret == FALSE) {
|
||||
DEBUGF("can not set the shader program for composite\n");
|
||||
goto TRAPEZOID_RESET_GL;
|
||||
|
@ -826,10 +844,8 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
source_pixmap = glamor_get_drawable_pixmap(temp_src->pDrawable);
|
||||
source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
|
||||
glamor_get_drawable_deltas(temp_src->pDrawable,
|
||||
source_pixmap,
|
||||
&source_x_off, &source_y_off);
|
||||
pixmap_priv_get_scale(source_pixmap_priv,
|
||||
&src_xscale, &src_yscale);
|
||||
source_pixmap, &source_x_off, &source_y_off);
|
||||
pixmap_priv_get_scale(source_pixmap_priv, &src_xscale, &src_yscale);
|
||||
glamor_picture_get_matrixf(temp_src, src_matrix);
|
||||
vert_stride += 3;
|
||||
}
|
||||
|
@ -842,8 +858,10 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
|
||||
/* A trapezoid clip with a rectangle will at most generate a hexagon,
|
||||
which can be devided into 4 triangles to render. */
|
||||
ntriangle_per_loop = (vert_stride * nbox * ntrap * 4) > GLAMOR_COMPOSITE_VBO_VERT_CNT ?
|
||||
(GLAMOR_COMPOSITE_VBO_VERT_CNT / vert_stride) : nbox * ntrap * 4;
|
||||
ntriangle_per_loop =
|
||||
(vert_stride * nbox * ntrap * 4) >
|
||||
GLAMOR_COMPOSITE_VBO_VERT_CNT ? (GLAMOR_COMPOSITE_VBO_VERT_CNT /
|
||||
vert_stride) : nbox * ntrap * 4;
|
||||
ntriangle_per_loop = (ntriangle_per_loop / 4) * 4;
|
||||
|
||||
nclip_rect = nbox;
|
||||
|
@ -851,64 +869,69 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
mclip_rect = (nclip_rect * ntrap * 4) > ntriangle_per_loop ?
|
||||
(ntriangle_per_loop / (4 * ntrap)) : nclip_rect;
|
||||
|
||||
if (!mclip_rect) {/* Maybe too many traps. */
|
||||
if (!mclip_rect) { /* Maybe too many traps. */
|
||||
mclip_rect = 1;
|
||||
ptrap = traps;
|
||||
traps_count = ntriangle_per_loop / 4;
|
||||
traps_not_completed = ntrap - traps_count;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
traps_count = ntrap;
|
||||
ptrap = traps;
|
||||
traps_not_completed = 0;
|
||||
}
|
||||
|
||||
NTRAPS_LOOP_AGAIN:
|
||||
NTRAPS_LOOP_AGAIN:
|
||||
|
||||
glamor_setup_composite_vbo(screen, mclip_rect * traps_count * 4 * vert_stride);
|
||||
glamor_setup_composite_vbo(screen,
|
||||
mclip_rect * traps_count * 4 * vert_stride);
|
||||
clip_processed = mclip_rect;
|
||||
|
||||
|
||||
while (mclip_rect--) {
|
||||
while (traps_count--) {
|
||||
int vtx_num;
|
||||
int i;
|
||||
float vertices[3*2], source_texcoords[3*2];
|
||||
float vertices[3 * 2], source_texcoords[3 * 2];
|
||||
|
||||
DEBUGF("In loop of render trapezoid, nclip_rect = %d, mclip_rect = %d, "
|
||||
DEBUGF
|
||||
("In loop of render trapezoid, nclip_rect = %d, mclip_rect = %d, "
|
||||
"clip_processed = %d, traps_count = %d, traps_not_completed = %d\n",
|
||||
nclip_rect, mclip_rect, clip_processed, traps_count, traps_not_completed);
|
||||
nclip_rect, mclip_rect, clip_processed, traps_count,
|
||||
traps_not_completed);
|
||||
|
||||
if (_glamor_clip_trapezoid_vertex(ptrap, pbox, clipped_vtx, &vtx_num)) {
|
||||
if (_glamor_clip_trapezoid_vertex
|
||||
(ptrap, pbox, clipped_vtx, &vtx_num)) {
|
||||
for (i = 0; i < vtx_num - 2; i++) {
|
||||
int clipped_vtx_tmp[3*2];
|
||||
int clipped_vtx_tmp[3 * 2];
|
||||
|
||||
clipped_vtx_tmp[0] = clipped_vtx[0];
|
||||
clipped_vtx_tmp[1] = clipped_vtx[1];
|
||||
clipped_vtx_tmp[2] = clipped_vtx[(i+1)*2];
|
||||
clipped_vtx_tmp[3] = clipped_vtx[(i+1)*2 + 1];
|
||||
clipped_vtx_tmp[4] = clipped_vtx[(i+2)*2];
|
||||
clipped_vtx_tmp[5] = clipped_vtx[(i+2)*2 + 1];
|
||||
glamor_set_normalize_tri_vcoords(
|
||||
dst_xscale, dst_yscale, clipped_vtx_tmp,
|
||||
glamor_priv->yInverted, vertices);
|
||||
clipped_vtx_tmp[2] = clipped_vtx[(i + 1) * 2];
|
||||
clipped_vtx_tmp[3] = clipped_vtx[(i + 1) * 2 + 1];
|
||||
clipped_vtx_tmp[4] = clipped_vtx[(i + 2) * 2];
|
||||
clipped_vtx_tmp[5] = clipped_vtx[(i + 2) * 2 + 1];
|
||||
glamor_set_normalize_tri_vcoords(dst_xscale, dst_yscale,
|
||||
clipped_vtx_tmp,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
DEBUGF("vertices of triangle: (%f X %f), (%f X %f), "
|
||||
"(%f X %f)\n", vertices[0], vertices[1],
|
||||
vertices[2], vertices[3], vertices[4], vertices[5]);
|
||||
|
||||
vertices[2], vertices[3], vertices[4],
|
||||
vertices[5]);
|
||||
|
||||
if (key.source != SHADER_SOURCE_SOLID) {
|
||||
if (src->transform) {
|
||||
glamor_set_transformed_normalize_tri_tcoords(
|
||||
source_pixmap_priv,
|
||||
src_matrix, src_xscale, src_yscale,
|
||||
glamor_set_transformed_normalize_tri_tcoords
|
||||
(source_pixmap_priv, src_matrix, src_xscale,
|
||||
src_yscale, clipped_vtx_tmp,
|
||||
glamor_priv->yInverted, source_texcoords);
|
||||
}
|
||||
else {
|
||||
glamor_set_normalize_tri_tcoords(src_xscale,
|
||||
src_yscale,
|
||||
clipped_vtx_tmp,
|
||||
glamor_priv->yInverted,
|
||||
source_texcoords);
|
||||
} else {
|
||||
glamor_set_normalize_tri_tcoords(
|
||||
src_xscale, src_yscale,
|
||||
clipped_vtx_tmp,
|
||||
glamor_priv->yInverted,
|
||||
glamor_priv->
|
||||
yInverted,
|
||||
source_texcoords);
|
||||
}
|
||||
|
||||
|
@ -934,7 +957,8 @@ NTRAPS_LOOP_AGAIN:
|
|||
traps_not_completed -= traps_count;
|
||||
glamor_flush_composite_triangles(screen);
|
||||
goto NTRAPS_LOOP_AGAIN;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ptrap = traps;
|
||||
traps_count = ntrap;
|
||||
}
|
||||
|
@ -949,7 +973,7 @@ NTRAPS_LOOP_AGAIN:
|
|||
|
||||
ret = TRUE;
|
||||
|
||||
TRAPEZOID_RESET_GL:
|
||||
TRAPEZOID_RESET_GL:
|
||||
dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
@ -964,14 +988,15 @@ TRAPEZOID_RESET_GL:
|
|||
#endif
|
||||
dispatch->glUseProgram(0);
|
||||
|
||||
TRAPEZOID_OUT:
|
||||
TRAPEZOID_OUT:
|
||||
if (box) {
|
||||
REGION_UNINIT(dst->pDrawable->pScreen, ®ion);
|
||||
}
|
||||
|
||||
if (temp_src != src) {
|
||||
FreePicture(temp_src, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (saved_source_format) {
|
||||
src->format = saved_source_format;
|
||||
}
|
||||
|
@ -993,8 +1018,7 @@ glamor_init_trapezoid_shader(ScreenPtr screen)
|
|||
|
||||
const char *trapezoid_vs =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"attribute vec4 v_position;\n"
|
||||
"attribute vec2 v_texcoord;\n"
|
||||
"attribute vec4 v_position;\n" "attribute vec2 v_texcoord;\n"
|
||||
/* v_top_bottom, v_left_param and v_right_param contain the
|
||||
constant value for all the vertex of one rect. Using uniform
|
||||
is more suitable but we need to reset the uniform variables
|
||||
|
@ -1032,8 +1056,7 @@ glamor_init_trapezoid_shader(ScreenPtr screen)
|
|||
" trap_right_x = v_right_param.x;\n"
|
||||
" trap_right_y = v_right_param.y;\n"
|
||||
" trap_right_slope = v_right_param.z;\n"
|
||||
" trap_right_vertical_f = v_right_param.w;\n"
|
||||
"}\n";
|
||||
" trap_right_vertical_f = v_right_param.w;\n" "}\n";
|
||||
|
||||
/*
|
||||
* Because some GL fill function do not support the MultSample
|
||||
|
@ -1135,9 +1158,7 @@ glamor_init_trapezoid_shader(ScreenPtr screen)
|
|||
" || (x_up_cut_left > source_texture.x + x_per_pix/2.0 && \n"
|
||||
" x_bottom_cut_left > source_texture.x + x_per_pix/2.0)) { \n"
|
||||
// The complete outside. At Left or Right of the trapezoide.
|
||||
" return 0.0; \n"
|
||||
" } \n"
|
||||
" } \n"
|
||||
" return 0.0; \n" " } \n" " } \n"
|
||||
// Get here, the pix is partly inside the trapezoid.
|
||||
" { \n"
|
||||
" float percent = 0.0; \n"
|
||||
|
@ -1315,8 +1336,7 @@ glamor_init_trapezoid_shader(ScreenPtr screen)
|
|||
"void main() \n"
|
||||
"{ \n"
|
||||
" float alpha_val = get_alpha_val(); \n"
|
||||
" gl_FragColor = vec4(0.0, 0.0, 0.0, alpha_val); \n"
|
||||
"}\n";
|
||||
" gl_FragColor = vec4(0.0, 0.0, 0.0, alpha_val); \n" "}\n";
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
@ -1363,7 +1383,8 @@ glamor_fini_trapezoid_shader(ScreenPtr screen)
|
|||
|
||||
static Bool
|
||||
_glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
||||
xTrapezoid * traps, int ntrap, BoxRec *bounds)
|
||||
xTrapezoid * traps, int ntrap,
|
||||
BoxRec * bounds)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
@ -1427,7 +1448,8 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
for (j = 0; j < mrect; j++) {
|
||||
ptrap = traps + i + j;
|
||||
|
||||
DEBUGF("--- The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
|
||||
DEBUGF
|
||||
("--- The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
|
||||
"left: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n"
|
||||
"right: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n",
|
||||
xFixedToInt(ptrap->top), ptrap->top,
|
||||
|
@ -1443,20 +1465,18 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
|
||||
miTrapezoidBounds(1, ptrap, &one_trap_bound);
|
||||
|
||||
vertices = (float*)(glamor_priv->vb + glamor_priv->vbo_offset) + 2;
|
||||
vertices =
|
||||
(float *) (glamor_priv->vb + glamor_priv->vbo_offset) + 2;
|
||||
glamor_set_tcoords_ext((pixmap_priv->base.pixmap->drawable.width),
|
||||
(pixmap_priv->base.pixmap->drawable.height),
|
||||
(one_trap_bound.x1),
|
||||
(one_trap_bound.y1),
|
||||
(one_trap_bound.x2),
|
||||
(one_trap_bound.y2),
|
||||
(one_trap_bound.x1), (one_trap_bound.y1),
|
||||
(one_trap_bound.x2), (one_trap_bound.y2),
|
||||
glamor_priv->yInverted, vertices, stride);
|
||||
DEBUGF("tex_vertices --> leftup : %f X %f, rightup: %f X %f,"
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n",
|
||||
vertices[0], vertices[1],
|
||||
vertices[1*stride], vertices[1*stride + 1],
|
||||
vertices[2*stride], vertices[2*stride + 1],
|
||||
vertices[3*stride], vertices[3*stride + 1]);
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n", vertices[0],
|
||||
vertices[1], vertices[1 * stride], vertices[1 * stride + 1],
|
||||
vertices[2 * stride], vertices[2 * stride + 1],
|
||||
vertices[3 * stride], vertices[3 * stride + 1]);
|
||||
|
||||
/* Need to rebase. */
|
||||
one_trap_bound.x1 -= bounds->x1;
|
||||
|
@ -1467,33 +1487,36 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
vertices -= 2;
|
||||
|
||||
glamor_set_normalize_vcoords_ext(pixmap_priv, xscale, yscale,
|
||||
one_trap_bound.x1, one_trap_bound.y1,
|
||||
one_trap_bound.x2, one_trap_bound.y2,
|
||||
glamor_priv->yInverted, vertices, stride);
|
||||
one_trap_bound.x1,
|
||||
one_trap_bound.y1,
|
||||
one_trap_bound.x2,
|
||||
one_trap_bound.y2,
|
||||
glamor_priv->yInverted, vertices,
|
||||
stride);
|
||||
DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n",
|
||||
vertices[0], vertices[1],
|
||||
vertices[1*stride], vertices[1*stride + 1],
|
||||
vertices[2*stride], vertices[2*stride + 1],
|
||||
vertices[3*stride], vertices[3*stride + 1]);
|
||||
"rightbottom: %f X %f, leftbottom : %f X %f\n", vertices[0],
|
||||
vertices[1], vertices[1 * stride], vertices[1 * stride + 1],
|
||||
vertices[2 * stride], vertices[2 * stride + 1],
|
||||
vertices[3 * stride], vertices[3 * stride + 1]);
|
||||
vertices += 4;
|
||||
|
||||
/* Set the top and bottom. */
|
||||
params[0] = ((float)ptrap->top) / 65536;
|
||||
params[1] = ((float)ptrap->bottom) / 65536;
|
||||
params[0] = ((float) ptrap->top) / 65536;
|
||||
params[1] = ((float) ptrap->bottom) / 65536;
|
||||
glamor_set_const_ext(params, 2, vertices, 4, stride);
|
||||
vertices += 2;
|
||||
|
||||
/* Set the left params. */
|
||||
params[0] = ((float)ptrap->left.p1.x) / 65536;
|
||||
params[1] = ((float)ptrap->left.p1.y) / 65536;
|
||||
params[0] = ((float) ptrap->left.p1.x) / 65536;
|
||||
params[1] = ((float) ptrap->left.p1.y) / 65536;
|
||||
|
||||
if (ptrap->left.p1.x == ptrap->left.p2.x) {
|
||||
left_slope = 0.0;
|
||||
params[3] = 1.0;
|
||||
} else {
|
||||
left_slope = ((float)(ptrap->left.p1.y - ptrap->left.p2.y))
|
||||
/ ((float)(ptrap->left.p1.x - ptrap->left.p2.x));
|
||||
}
|
||||
else {
|
||||
left_slope = ((float) (ptrap->left.p1.y - ptrap->left.p2.y))
|
||||
/ ((float) (ptrap->left.p1.x - ptrap->left.p2.x));
|
||||
params[3] = 0.0;
|
||||
}
|
||||
params[2] = left_slope;
|
||||
|
@ -1501,15 +1524,16 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
vertices += 4;
|
||||
|
||||
/* Set the left params. */
|
||||
params[0] = ((float)ptrap->right.p1.x) / 65536;
|
||||
params[1] = ((float)ptrap->right.p1.y) / 65536;
|
||||
params[0] = ((float) ptrap->right.p1.x) / 65536;
|
||||
params[1] = ((float) ptrap->right.p1.y) / 65536;
|
||||
|
||||
if (ptrap->right.p1.x == ptrap->right.p2.x) {
|
||||
right_slope = 0.0;
|
||||
params[3] = 1.0;
|
||||
} else {
|
||||
right_slope = ((float)(ptrap->right.p1.y - ptrap->right.p2.y))
|
||||
/ ((float)(ptrap->right.p1.x - ptrap->right.p2.x));
|
||||
}
|
||||
else {
|
||||
right_slope = ((float) (ptrap->right.p1.y - ptrap->right.p2.y))
|
||||
/ ((float) (ptrap->right.p1.x - ptrap->right.p2.x));
|
||||
params[3] = 0.0;
|
||||
}
|
||||
params[2] = right_slope;
|
||||
|
@ -1518,11 +1542,12 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
DEBUGF("trap_top = %f, trap_bottom = %f, "
|
||||
"trap_left_x = %f, trap_left_y = %f, left_slope = %f, "
|
||||
"trap_right_x = %f, trap_right_y = %f, right_slope = %f\n",
|
||||
((float)ptrap->top) / 65536, ((float)ptrap->bottom) / 65536,
|
||||
((float)ptrap->left.p1.x) / 65536, ((float)ptrap->left.p1.y) / 65536,
|
||||
left_slope,
|
||||
((float)ptrap->right.p1.x) / 65536, ((float)ptrap->right.p1.y) / 65536,
|
||||
right_slope);
|
||||
((float) ptrap->top) / 65536,
|
||||
((float) ptrap->bottom) / 65536,
|
||||
((float) ptrap->left.p1.x) / 65536,
|
||||
((float) ptrap->left.p1.y) / 65536, left_slope,
|
||||
((float) ptrap->right.p1.x) / 65536,
|
||||
((float) ptrap->right.p1.y) / 65536, right_slope);
|
||||
|
||||
glamor_priv->render_nr_verts += 4;
|
||||
glamor_priv->vbo_offset += glamor_priv->vb_stride * 4;
|
||||
|
@ -1544,11 +1569,13 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
}
|
||||
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
|
||||
dispatch->glDrawRangeElements(GL_TRIANGLES, 0,
|
||||
glamor_priv->render_nr_verts,
|
||||
(glamor_priv->render_nr_verts * 3) / 2,
|
||||
GL_UNSIGNED_SHORT, NULL);
|
||||
#else
|
||||
dispatch->glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
|
||||
dispatch->glDrawElements(GL_TRIANGLES,
|
||||
(glamor_priv->render_nr_verts * 3) / 2,
|
||||
GL_UNSIGNED_SHORT, NULL);
|
||||
#endif
|
||||
}
|
||||
|
@ -1584,11 +1611,9 @@ glamor_create_mask_picture(ScreenPtr screen,
|
|||
|
||||
if (!pict_format) {
|
||||
if (dst->polyEdge == PolyEdgeSharp)
|
||||
pict_format =
|
||||
PictureMatchFormat(screen, 1, PICT_a1);
|
||||
pict_format = PictureMatchFormat(screen, 1, PICT_a1);
|
||||
else
|
||||
pict_format =
|
||||
PictureMatchFormat(screen, 8, PICT_a8);
|
||||
pict_format = PictureMatchFormat(screen, 8, PICT_a8);
|
||||
if (!pict_format)
|
||||
return 0;
|
||||
}
|
||||
|
@ -1596,7 +1621,8 @@ glamor_create_mask_picture(ScreenPtr screen,
|
|||
if (gpu) {
|
||||
pixmap = glamor_create_pixmap(screen, width, height,
|
||||
pict_format->depth, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pixmap = glamor_create_pixmap(screen, 0, 0,
|
||||
pict_format->depth,
|
||||
GLAMOR_CREATE_PIXMAP_CPU);
|
||||
|
@ -1611,9 +1637,10 @@ glamor_create_mask_picture(ScreenPtr screen,
|
|||
}
|
||||
|
||||
static int
|
||||
_glamor_trapezoid_bounds (int ntrap, xTrapezoid *traps, BoxPtr box)
|
||||
_glamor_trapezoid_bounds(int ntrap, xTrapezoid * traps, BoxPtr box)
|
||||
{
|
||||
int has_large_trapezoid = 0;
|
||||
|
||||
box->y1 = MAXSHORT;
|
||||
box->y2 = MINSHORT;
|
||||
box->x1 = MAXSHORT;
|
||||
|
@ -1624,21 +1651,26 @@ _glamor_trapezoid_bounds (int ntrap, xTrapezoid *traps, BoxPtr box)
|
|||
|
||||
if (!xTrapezoidValid(traps))
|
||||
continue;
|
||||
y1 = xFixedToInt (traps->top);
|
||||
y1 = xFixedToInt(traps->top);
|
||||
if (y1 < box->y1)
|
||||
box->y1 = y1;
|
||||
|
||||
y2 = xFixedToInt (xFixedCeil (traps->bottom));
|
||||
y2 = xFixedToInt(xFixedCeil(traps->bottom));
|
||||
if (y2 > box->y2)
|
||||
box->y2 = y2;
|
||||
|
||||
x1 = xFixedToInt (min (_glamor_linefixedX (&traps->left, traps->top, FALSE),
|
||||
_glamor_linefixedX (&traps->left, traps->bottom, FALSE)));
|
||||
x1 = xFixedToInt(min
|
||||
(_glamor_linefixedX(&traps->left, traps->top, FALSE),
|
||||
_glamor_linefixedX(&traps->left, traps->bottom,
|
||||
FALSE)));
|
||||
if (x1 < box->x1)
|
||||
box->x1 = x1;
|
||||
|
||||
x2 = xFixedToInt (xFixedCeil (max (_glamor_linefixedX (&traps->right, traps->top, TRUE),
|
||||
_glamor_linefixedX (&traps->right, traps->bottom, TRUE))));
|
||||
x2 = xFixedToInt(xFixedCeil
|
||||
(max
|
||||
(_glamor_linefixedX(&traps->right, traps->top, TRUE),
|
||||
_glamor_linefixedX(&traps->right, traps->bottom,
|
||||
TRUE))));
|
||||
if (x2 > box->x2)
|
||||
box->x2 = x2;
|
||||
|
||||
|
@ -1676,11 +1708,9 @@ _glamor_trapezoids(CARD8 op,
|
|||
*/
|
||||
if (!mask_format) {
|
||||
if (dst->polyEdge == PolyEdgeSharp)
|
||||
mask_format =
|
||||
PictureMatchFormat(screen, 1, PICT_a1);
|
||||
mask_format = PictureMatchFormat(screen, 1, PICT_a1);
|
||||
else
|
||||
mask_format =
|
||||
PictureMatchFormat(screen, 8, PICT_a8);
|
||||
mask_format = PictureMatchFormat(screen, 8, PICT_a8);
|
||||
for (; ntrap; ntrap--, traps++)
|
||||
glamor_trapezoids(op, src, dst, mask_format, x_src,
|
||||
y_src, 1, traps);
|
||||
|
@ -1718,14 +1748,16 @@ _glamor_trapezoids(CARD8 op,
|
|||
if (mask_format->depth == 1) {
|
||||
ret = _glamor_trapezoids_with_shader(op, src, dst, mask_format,
|
||||
x_src, y_src, ntrap, traps);
|
||||
if(ret)
|
||||
if (ret)
|
||||
return TRUE;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (has_large_trapezoid || ntrap > 256) {
|
||||
/* The shader speed is relative slower than pixman when generating big chunk
|
||||
trapezoid mask. We fallback to pixman to improve the performance. */
|
||||
;
|
||||
} else if (dst->polyMode == PolyModeImprecise) {
|
||||
}
|
||||
else if (dst->polyMode == PolyModeImprecise) {
|
||||
/* The precise mode is that we sample the trapezoid on the centre points of
|
||||
an (2*n+1)x(2*n-1) subpixel grid. It is computationally expensive in shader
|
||||
and we use inside area ratio to replace it if the polymode == Imprecise. */
|
||||
|
@ -1734,7 +1766,9 @@ _glamor_trapezoids(CARD8 op,
|
|||
if (!picture)
|
||||
return TRUE;
|
||||
|
||||
ret = _glamor_generate_trapezoid_with_shader(screen, picture, traps, ntrap, &bounds);
|
||||
ret =
|
||||
_glamor_generate_trapezoid_with_shader(screen, picture, traps,
|
||||
ntrap, &bounds);
|
||||
|
||||
if (!ret)
|
||||
FreePicture(picture, 0);
|
||||
|
@ -1816,4 +1850,3 @@ glamor_trapezoids_nf(CARD8 op,
|
|||
}
|
||||
|
||||
#endif /* RENDER */
|
||||
|
||||
|
|
|
@ -33,20 +33,18 @@ _glamor_triangles(CARD8 op,
|
|||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris, Bool fallback)
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris,
|
||||
Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
|
||||
&& (!pSrc->pDrawable
|
||||
|| glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
|
||||
return FALSE;
|
||||
|
||||
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_picture(pSrc,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
if (glamor_prepare_access_picture(pSrc, GLAMOR_ACCESS_RO)) {
|
||||
|
||||
fbTriangles(op, pSrc, pDst, maskFormat, xSrc,
|
||||
ySrc, ntris, tris);
|
||||
fbTriangles(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntris, tris);
|
||||
|
||||
glamor_finish_access_picture(pSrc, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
|
@ -77,4 +75,3 @@ glamor_triangles_nf(CARD8 op,
|
|||
return _glamor_triangles(op, pSrc, pDst, maskFormat,
|
||||
xSrc, ySrc, ntris, tris, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,6 @@
|
|||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
/* _x1_ ... _y2_ may has fractional. */
|
||||
#define glamor_get_repeat_transform_coords(priv, repeat_type, tx1, \
|
||||
ty1, _x1_, _y1_) \
|
||||
|
@ -402,8 +401,6 @@
|
|||
2); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
#define glamor_set_normalize_tri_tcoords(xscale, \
|
||||
yscale, \
|
||||
vtx, \
|
||||
|
@ -475,7 +472,6 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define glamor_set_repeat_transformed_normalize_tcoords( priv, \
|
||||
repeat_type, \
|
||||
matrix, \
|
||||
|
@ -541,7 +537,6 @@
|
|||
x2, y2, yInverted, vertices, stride);\
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_set_normalize_tcoords(priv, xscale, yscale, \
|
||||
x1, y1, x2, y2, \
|
||||
yInverted, vertices) \
|
||||
|
@ -577,7 +572,6 @@
|
|||
stride); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_set_repeat_normalize_tcoords(priv, repeat_type, \
|
||||
xscale, yscale, \
|
||||
_x1_, _y1_, _x2_, _y2_, \
|
||||
|
@ -721,7 +715,6 @@
|
|||
(vertices)[3 * stride + 1] = _t5_; \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_set_normalize_vcoords(priv, xscale, yscale, \
|
||||
x1, y1, x2, y2, \
|
||||
yInverted, vertices) \
|
||||
|
@ -789,6 +782,7 @@ glamor_calculate_boxes_bound(BoxPtr bound, BoxPtr boxes, int nbox)
|
|||
int x_min, y_min;
|
||||
int x_max, y_max;
|
||||
int i;
|
||||
|
||||
x_min = y_min = MAXSHORT;
|
||||
x_max = y_max = MINSHORT;
|
||||
for (i = 0; i < nbox; i++) {
|
||||
|
@ -812,6 +806,7 @@ inline static void
|
|||
glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, int dy)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nbox; i++) {
|
||||
boxes[i].x1 += dx;
|
||||
boxes[i].y1 += dy;
|
||||
|
@ -821,7 +816,7 @@ glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, int dy)
|
|||
}
|
||||
|
||||
static inline Bool
|
||||
region_is_empty(pixman_region16_t *region)
|
||||
region_is_empty(pixman_region16_t * region)
|
||||
{
|
||||
return region->data && region->data->numRects == 0;
|
||||
}
|
||||
|
@ -943,9 +938,7 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
GLenum * tex_type,
|
||||
int *no_alpha,
|
||||
int *revert,
|
||||
int *swap_rb,
|
||||
int is_upload)
|
||||
|
||||
int *swap_rb, int is_upload)
|
||||
{
|
||||
*no_alpha = 0;
|
||||
*revert = REVERT_NONE;
|
||||
|
@ -1029,15 +1022,15 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
|
||||
default:
|
||||
LogMessageVerb(X_INFO, 0,
|
||||
"fail to get matched format for %x \n",
|
||||
format);
|
||||
"fail to get matched format for %x \n", format);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Currently, we use RGBA to represent all formats. */
|
||||
inline static int cache_format(GLenum format)
|
||||
inline static int
|
||||
cache_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_ALPHA:
|
||||
|
@ -1058,8 +1051,7 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
GLenum * tex_type,
|
||||
int *no_alpha,
|
||||
int *revert,
|
||||
int *swap_rb,
|
||||
int is_upload)
|
||||
int *swap_rb, int is_upload)
|
||||
{
|
||||
int need_swap_rb = 0;
|
||||
|
||||
|
@ -1157,8 +1149,11 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
*tex_format = GL_RGBA;
|
||||
*tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
if (IS_LITTLE_ENDIAN) {
|
||||
*revert = is_upload ? REVERT_UPLOADING_1_5_5_5 : REVERT_DOWNLOADING_1_5_5_5;
|
||||
} else
|
||||
*revert =
|
||||
is_upload ? REVERT_UPLOADING_1_5_5_5 :
|
||||
REVERT_DOWNLOADING_1_5_5_5;
|
||||
}
|
||||
else
|
||||
*revert = REVERT_NONE;
|
||||
break;
|
||||
|
||||
|
@ -1168,8 +1163,11 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
*tex_format = GL_RGBA;
|
||||
*tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
if (IS_LITTLE_ENDIAN) {
|
||||
*revert = is_upload ? REVERT_UPLOADING_1_5_5_5 : REVERT_DOWNLOADING_1_5_5_5;
|
||||
} else
|
||||
*revert =
|
||||
is_upload ? REVERT_UPLOADING_1_5_5_5 :
|
||||
REVERT_DOWNLOADING_1_5_5_5;
|
||||
}
|
||||
else
|
||||
*revert = REVERT_NONE;
|
||||
need_swap_rb = 1;
|
||||
break;
|
||||
|
@ -1205,8 +1203,7 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
|
||||
default:
|
||||
LogMessageVerb(X_INFO, 0,
|
||||
"fail to get matched format for %x \n",
|
||||
format);
|
||||
"fail to get matched format for %x \n", format);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1214,8 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
return 0;
|
||||
}
|
||||
|
||||
inline static int cache_format(GLenum format)
|
||||
inline static int
|
||||
cache_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_ALPHA:
|
||||
|
@ -1233,15 +1231,12 @@ inline static int cache_format(GLenum format)
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
static inline int
|
||||
glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
|
||||
GLenum * format,
|
||||
GLenum * type,
|
||||
int *no_alpha,
|
||||
int *revert,
|
||||
int *swap_rb,
|
||||
int is_upload)
|
||||
int *revert, int *swap_rb, int is_upload)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PictFormatShort pict_format;
|
||||
|
@ -1256,11 +1251,9 @@ glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
|
|||
format, type,
|
||||
no_alpha,
|
||||
revert,
|
||||
swap_rb,
|
||||
is_upload);
|
||||
swap_rb, is_upload);
|
||||
}
|
||||
|
||||
|
||||
/* borrowed from uxa */
|
||||
static inline Bool
|
||||
glamor_get_rgba_from_pixel(CARD32 pixel,
|
||||
|
@ -1278,27 +1271,30 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
|
|||
|
||||
if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) {
|
||||
rshift = gshift = bshift = ashift = 0;
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
|
||||
}
|
||||
else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
|
||||
bshift = 0;
|
||||
gshift = bbits;
|
||||
rshift = gshift + gbits;
|
||||
ashift = rshift + rbits;
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
|
||||
}
|
||||
else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
|
||||
rshift = 0;
|
||||
gshift = rbits;
|
||||
bshift = gshift + gbits;
|
||||
ashift = bshift + bbits;
|
||||
#if XORG_VERSION_CURRENT >= 10699900
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
|
||||
}
|
||||
else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
|
||||
ashift = 0;
|
||||
rshift = abits;
|
||||
if (abits == 0)
|
||||
rshift = PICT_FORMAT_BPP(format) - (rbits + gbits +
|
||||
bbits);
|
||||
rshift = PICT_FORMAT_BPP(format) - (rbits + gbits + bbits);
|
||||
gshift = rshift + rbits;
|
||||
bshift = gshift + gbits;
|
||||
#endif
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
#define COLOR_INT_TO_FLOAT(_fc_, _p_, _s_, _bits_) \
|
||||
|
@ -1328,7 +1324,8 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
inline static Bool glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth)
|
||||
inline static Bool
|
||||
glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth)
|
||||
{
|
||||
GLenum iformat;
|
||||
|
||||
|
@ -1344,19 +1341,23 @@ inline static Bool glamor_pict_format_is_compatible(PictFormatShort pict_format,
|
|||
}
|
||||
|
||||
/* return TRUE if we can access this pixmap at DDX driver. */
|
||||
inline static Bool glamor_ddx_fallback_check_pixmap(DrawablePtr drawable)
|
||||
inline static Bool
|
||||
glamor_ddx_fallback_check_pixmap(DrawablePtr drawable)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return (!pixmap_priv
|
||||
|| (pixmap_priv->type == GLAMOR_TEXTURE_DRM
|
||||
|| pixmap_priv->type == GLAMOR_MEMORY
|
||||
|| pixmap_priv->type == GLAMOR_DRM_ONLY));
|
||||
}
|
||||
|
||||
inline static Bool glamor_ddx_fallback_check_gc(GCPtr gc)
|
||||
inline static Bool
|
||||
glamor_ddx_fallback_check_gc(GCPtr gc)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
|
||||
if (!gc)
|
||||
return TRUE;
|
||||
switch (gc->fillStyle) {
|
||||
|
@ -1372,7 +1373,9 @@ inline static Bool glamor_ddx_fallback_check_gc(GCPtr gc)
|
|||
}
|
||||
return (!pixmap || glamor_ddx_fallback_check_pixmap(&pixmap->drawable));
|
||||
}
|
||||
inline static Bool glamor_is_large_pixmap(PixmapPtr pixmap)
|
||||
|
||||
inline static Bool
|
||||
glamor_is_large_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *priv;
|
||||
|
||||
|
@ -1380,7 +1383,8 @@ inline static Bool glamor_is_large_pixmap(PixmapPtr pixmap)
|
|||
return (priv->type == GLAMOR_TEXTURE_LARGE);
|
||||
}
|
||||
|
||||
inline static Bool glamor_is_large_picture(PicturePtr picture)
|
||||
inline static Bool
|
||||
glamor_is_large_picture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
|
||||
|
@ -1391,85 +1395,87 @@ inline static Bool glamor_is_large_picture(PicturePtr picture)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
inline static Bool glamor_tex_format_is_readable(GLenum format)
|
||||
inline static Bool
|
||||
glamor_tex_format_is_readable(GLenum format)
|
||||
{
|
||||
return ((format == GL_RGBA || format == GL_RGB || format == GL_ALPHA));
|
||||
|
||||
}
|
||||
|
||||
static inline void _glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
_glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
int i,j;
|
||||
unsigned char * p = pixmap->devPrivate.ptr;
|
||||
int i, j;
|
||||
unsigned char *p = pixmap->devPrivate.ptr;
|
||||
int stride = pixmap->devKind;
|
||||
|
||||
p = p + y * stride + x;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
for (i = 0; i < h; i++) {
|
||||
ErrorF("line %3d: ", i);
|
||||
for(j = 0; j < w; j++)
|
||||
ErrorF("%2d ", (p[j/8] & (1 << (j%8)))>>(j%8));
|
||||
for (j = 0; j < w; j++)
|
||||
ErrorF("%2d ", (p[j / 8] & (1 << (j % 8))) >> (j % 8));
|
||||
p += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
_glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
int i,j;
|
||||
unsigned char * p = pixmap->devPrivate.ptr;
|
||||
int i, j;
|
||||
unsigned char *p = pixmap->devPrivate.ptr;
|
||||
int stride = pixmap->devKind;
|
||||
|
||||
p = p + y * stride + x;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
for (i = 0; i < h; i++) {
|
||||
ErrorF("line %3d: ", i);
|
||||
for(j = 0; j < w; j++)
|
||||
for (j = 0; j < w; j++)
|
||||
ErrorF("%2x ", p[j]);
|
||||
p += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
_glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
int i,j;
|
||||
unsigned short * p = pixmap->devPrivate.ptr;
|
||||
int i, j;
|
||||
unsigned short *p = pixmap->devPrivate.ptr;
|
||||
int stride = pixmap->devKind / 2;
|
||||
|
||||
p = p + y * stride + x;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
for (i = 0; i < h; i++) {
|
||||
ErrorF("line %3d: ", i);
|
||||
for(j = 0; j < w; j++)
|
||||
for (j = 0; j < w; j++)
|
||||
ErrorF("%2x ", p[j]);
|
||||
p += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
_glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
int i,j;
|
||||
unsigned int * p = pixmap->devPrivate.ptr;
|
||||
int i, j;
|
||||
unsigned int *p = pixmap->devPrivate.ptr;
|
||||
int stride = pixmap->devKind / 4;
|
||||
|
||||
p = p + y * stride + x;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
for (i = 0; i < h; i++) {
|
||||
ErrorF("line %3d: ", i);
|
||||
for(j = 0; j < w; j++)
|
||||
for (j = 0; j < w; j++)
|
||||
ErrorF("%2x ", p[j]);
|
||||
p += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
static inline void
|
||||
glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h)
|
||||
{
|
||||
w = ((x + w) > pixmap->drawable.width) ? (pixmap->drawable.width - x) : w;
|
||||
h = ((y + h) > pixmap->drawable.height) ? (pixmap->drawable.height - y) : h;
|
||||
|
@ -1497,14 +1503,14 @@ static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int
|
|||
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
|
||||
static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
||||
static inline void
|
||||
_glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
||||
int x, int y, int w, int h,
|
||||
PictFormatShort short_format,
|
||||
int all, int diffs)
|
||||
PictFormatShort short_format, int all, int diffs)
|
||||
{
|
||||
int i, j;
|
||||
unsigned char * p1 = pixmap1->devPrivate.ptr;
|
||||
unsigned char * p2 = pixmap2->devPrivate.ptr;
|
||||
unsigned char *p1 = pixmap1->devPrivate.ptr;
|
||||
unsigned char *p2 = pixmap2->devPrivate.ptr;
|
||||
int line_need_printed = 0;
|
||||
int test_code = 0xAABBCCDD;
|
||||
int little_endian = 0;
|
||||
|
@ -1534,9 +1540,10 @@ static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
p2 += stride;
|
||||
ErrorF("\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (short_format == PICT_a8r8g8b8) {
|
||||
p_test = (unsigned char *) & test_code;
|
||||
p_test = (unsigned char *) &test_code;
|
||||
little_endian = (*p_test == 0xDD);
|
||||
bpp = 4;
|
||||
|
||||
|
@ -1544,40 +1551,51 @@ static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
line_need_printed = 0;
|
||||
|
||||
for (j = 0; j < stride; j++) {
|
||||
if (p1[j] != p2[j] && (p1[j] - p2[j] > diffs || p2[j] - p1[j] > diffs)) {
|
||||
if (p1[j] != p2[j] &&
|
||||
(p1[j] - p2[j] > diffs || p2[j] - p1[j] > diffs)) {
|
||||
if (line_need_printed) {
|
||||
if (little_endian) {
|
||||
switch (j % 4) {
|
||||
case 2:
|
||||
ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 1:
|
||||
ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 0:
|
||||
ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 3:
|
||||
ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
switch (j % 4) {
|
||||
case 1:
|
||||
ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 2:
|
||||
ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 3:
|
||||
ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
case 0:
|
||||
ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j],
|
||||
p2[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
line_need_printed = 1;
|
||||
j = -1;
|
||||
ErrorF("line %3d: ", i);
|
||||
|
@ -1599,7 +1617,8 @@ static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
if (p1[j] != p2[j]) {
|
||||
if (line_need_printed) {
|
||||
ErrorF("[%d]%2x:%2x ", j / bpp, p1[j], p2[j]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
line_need_printed = 1;
|
||||
j = -1;
|
||||
ErrorF("line %3d: ", i);
|
||||
|
@ -1616,7 +1635,8 @@ static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
}
|
||||
}
|
||||
|
||||
static inline void glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
||||
static inline void
|
||||
glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
||||
int x, int y, int w, int h, int all, int diffs)
|
||||
{
|
||||
assert(pixmap1->drawable.depth == pixmap2->drawable.depth);
|
||||
|
@ -1632,12 +1652,12 @@ static inline void glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
|
|||
|
||||
/* This function is used to compare two pictures.
|
||||
If the picture has no drawable, we use fb functions to generate it. */
|
||||
static inline void glamor_compare_pictures( ScreenPtr screen,
|
||||
static inline void
|
||||
glamor_compare_pictures(ScreenPtr screen,
|
||||
PicturePtr fst_picture,
|
||||
PicturePtr snd_picture,
|
||||
int x_source, int y_source,
|
||||
int width, int height,
|
||||
int all, int diffs)
|
||||
int width, int height, int all, int diffs)
|
||||
{
|
||||
PixmapPtr fst_pixmap;
|
||||
PixmapPtr snd_pixmap;
|
||||
|
@ -1681,14 +1701,12 @@ static inline void glamor_compare_pictures( ScreenPtr screen,
|
|||
pixman_pic = CreatePicture(0,
|
||||
&pixmap->drawable,
|
||||
PictureMatchFormat(screen,
|
||||
PIXMAN_FORMAT_DEPTH(format), format),
|
||||
0, 0, serverClient, &error);
|
||||
PIXMAN_FORMAT_DEPTH
|
||||
(format), format), 0, 0,
|
||||
serverClient, &error);
|
||||
|
||||
fbComposite(PictOpSrc, fst_picture, NULL, pixman_pic,
|
||||
x_source, y_source,
|
||||
0, 0,
|
||||
0, 0,
|
||||
width, height);
|
||||
x_source, y_source, 0, 0, 0, 0, width, height);
|
||||
|
||||
glamor_destroy_pixmap(pixmap);
|
||||
|
||||
|
@ -1711,14 +1729,12 @@ static inline void glamor_compare_pictures( ScreenPtr screen,
|
|||
pixman_pic = CreatePicture(0,
|
||||
&pixmap->drawable,
|
||||
PictureMatchFormat(screen,
|
||||
PIXMAN_FORMAT_DEPTH(format), format),
|
||||
0, 0, serverClient, &error);
|
||||
PIXMAN_FORMAT_DEPTH
|
||||
(format), format), 0, 0,
|
||||
serverClient, &error);
|
||||
|
||||
fbComposite(PictOpSrc, snd_picture, NULL, pixman_pic,
|
||||
x_source, y_source,
|
||||
0, 0,
|
||||
0, 0,
|
||||
width, height);
|
||||
x_source, y_source, 0, 0, 0, 0, width, height);
|
||||
|
||||
glamor_destroy_pixmap(pixmap);
|
||||
|
||||
|
@ -1753,8 +1769,7 @@ static inline void glamor_compare_pictures( ScreenPtr screen,
|
|||
|
||||
_glamor_compare_pixmaps(fst_pixmap, snd_pixmap,
|
||||
x_source, y_source,
|
||||
width, height,
|
||||
fst_picture->format, all, diffs);
|
||||
width, height, fst_picture->format, all, diffs);
|
||||
|
||||
glamor_finish_access(&fst_pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
glamor_finish_access(&snd_pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
|
@ -1768,42 +1783,60 @@ static inline void glamor_compare_pictures( ScreenPtr screen,
|
|||
}
|
||||
|
||||
#ifdef __i386__
|
||||
static inline unsigned long __fls(unsigned long x)
|
||||
static inline unsigned long
|
||||
__fls(unsigned long x)
|
||||
{
|
||||
asm("bsr %1,%0"
|
||||
: "=r" (x)
|
||||
: "rm" (x));
|
||||
asm("bsr %1,%0":"=r"(x)
|
||||
: "rm"(x));
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
static inline unsigned long __fls(unsigned long x)
|
||||
static inline unsigned long
|
||||
__fls(unsigned long x)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (x == 0) return(0);
|
||||
if (x == 0)
|
||||
return (0);
|
||||
n = 0;
|
||||
if (x <= 0x0000FFFF) {n = n +16; x = x <<16;}
|
||||
if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;}
|
||||
if (x <= 0x0FFFFFFF) {n = n + 4; x = x << 4;}
|
||||
if (x <= 0x3FFFFFFF) {n = n + 2; x = x << 2;}
|
||||
if (x <= 0x7FFFFFFF) {n = n + 1;}
|
||||
if (x <= 0x0000FFFF) {
|
||||
n = n + 16;
|
||||
x = x << 16;
|
||||
}
|
||||
if (x <= 0x00FFFFFF) {
|
||||
n = n + 8;
|
||||
x = x << 8;
|
||||
}
|
||||
if (x <= 0x0FFFFFFF) {
|
||||
n = n + 4;
|
||||
x = x << 4;
|
||||
}
|
||||
if (x <= 0x3FFFFFFF) {
|
||||
n = n + 2;
|
||||
x = x << 2;
|
||||
}
|
||||
if (x <= 0x7FFFFFFF) {
|
||||
n = n + 1;
|
||||
}
|
||||
return 31 - n;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void glamor_make_current(ScreenPtr screen)
|
||||
static inline void
|
||||
glamor_make_current(ScreenPtr screen)
|
||||
{
|
||||
glamor_egl_make_current(screen);
|
||||
}
|
||||
|
||||
static inline void glamor_restore_current(ScreenPtr screen)
|
||||
static inline void
|
||||
glamor_restore_current(ScreenPtr screen)
|
||||
{
|
||||
glamor_egl_restore_context(screen);
|
||||
}
|
||||
|
||||
#ifdef GLX_USE_SHARED_DISPATCH
|
||||
static inline glamor_gl_dispatch *
|
||||
glamor_get_dispatch(glamor_screen_private *glamor_priv)
|
||||
glamor_get_dispatch(glamor_screen_private * glamor_priv)
|
||||
{
|
||||
if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN)
|
||||
glamor_make_current(glamor_priv->screen);
|
||||
|
@ -1812,7 +1845,7 @@ glamor_get_dispatch(glamor_screen_private *glamor_priv)
|
|||
}
|
||||
|
||||
static inline void
|
||||
glamor_put_dispatch(glamor_screen_private *glamor_priv)
|
||||
glamor_put_dispatch(glamor_screen_private * glamor_priv)
|
||||
{
|
||||
if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN)
|
||||
glamor_restore_current(glamor_priv->screen);
|
||||
|
@ -1820,13 +1853,13 @@ glamor_put_dispatch(glamor_screen_private *glamor_priv)
|
|||
#else
|
||||
#warning "Indirect GLX may be broken, need to implement context switch."
|
||||
static inline glamor_gl_dispatch *
|
||||
glamor_get_dispatch(glamor_screen_private *glamor_priv)
|
||||
glamor_get_dispatch(glamor_screen_private * glamor_priv)
|
||||
{
|
||||
return &glamor_priv->_dispatch;
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_put_dispatch(glamor_screen_private *glamor_priv)
|
||||
glamor_put_dispatch(glamor_screen_private * glamor_priv)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,8 @@
|
|||
* Screen Change Window Attribute implementation.
|
||||
*/
|
||||
|
||||
|
||||
static void
|
||||
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr * ppPixmap)
|
||||
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
|
||||
{
|
||||
PixmapPtr pPixmap = *ppPixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
@ -41,8 +40,7 @@ glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr * ppPixmap)
|
|||
glamor_fallback("pixmap %p has no fbo\n", pPixmap);
|
||||
goto fail;
|
||||
}
|
||||
glamor_debug_output(GLAMOR_DEBUG_UNIMPL,
|
||||
"To be implemented.\n");
|
||||
glamor_debug_output(GLAMOR_DEBUG_UNIMPL, "To be implemented.\n");
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -58,14 +56,12 @@ glamor_change_window_attributes(WindowPtr pWin, unsigned long mask)
|
|||
if (mask & CWBackPixmap) {
|
||||
if (pWin->backgroundState == BackgroundPixmap)
|
||||
glamor_fixup_window_pixmap(&pWin->drawable,
|
||||
&pWin->
|
||||
background.pixmap);
|
||||
&pWin->background.pixmap);
|
||||
}
|
||||
|
||||
if (mask & CWBorderPixmap) {
|
||||
if (pWin->borderIsPixel == FALSE)
|
||||
glamor_fixup_window_pixmap(&pWin->drawable,
|
||||
&pWin->border.pixmap);
|
||||
glamor_fixup_window_pixmap(&pWin->drawable, &pWin->border.pixmap);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -74,8 +70,7 @@ void
|
|||
glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
||||
{
|
||||
ScreenPtr screen = win->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
PixmapPtr old = screen->GetWindowPixmap(win);
|
||||
|
||||
if (pPixmap != old) {
|
||||
|
@ -83,7 +78,8 @@ glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
|||
PicturePtr pic = NULL;
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(old);
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) && pixmap_priv->base.picture->pDrawable == (DrawablePtr)win) {
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) &&
|
||||
pixmap_priv->base.picture->pDrawable == (DrawablePtr) win) {
|
||||
pic = pixmap_priv->base.picture;
|
||||
pixmap_priv->base.is_picture = 0;
|
||||
pixmap_priv->base.picture = NULL;
|
||||
|
@ -91,13 +87,13 @@ glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
|||
|
||||
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
||||
if (pixmap_priv) {
|
||||
pixmap_priv->base.is_picture = !!pic;
|
||||
pixmap_priv->base.is_picture = ! !pic;
|
||||
pixmap_priv->base.picture = pic;
|
||||
}
|
||||
}
|
||||
|
||||
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
||||
(screen->SetWindowPixmap)(win, pPixmap);
|
||||
(screen->SetWindowPixmap) (win, pPixmap);
|
||||
glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
|
||||
screen->SetWindowPixmap = glamor_set_window_pixmap;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@
|
|||
#include <X11/extensions/Xv.h>
|
||||
#include "fourcc.h"
|
||||
/* Reference color space transform data */
|
||||
typedef struct tagREF_TRANSFORM
|
||||
{
|
||||
typedef struct tagREF_TRANSFORM {
|
||||
float RefLuma;
|
||||
float RefRCb;
|
||||
float RefRCr;
|
||||
|
@ -56,12 +55,11 @@ typedef struct tagREF_TRANSFORM
|
|||
#define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0)
|
||||
#define RTFHue(a) (((a)*3.1416)/1000.0)
|
||||
|
||||
static const char *xv_vs= "attribute vec4 v_position;\n"
|
||||
static const char *xv_vs = "attribute vec4 v_position;\n"
|
||||
"attribute vec4 v_texcoord0;\n"
|
||||
"varying vec2 tcs;\n"
|
||||
"void main()\n" "{\n" " gl_Position = v_position;\n"
|
||||
"tcs = v_texcoord0.xy;\n"
|
||||
"}\n";
|
||||
"tcs = v_texcoord0.xy;\n" "}\n";
|
||||
|
||||
static const char *xv_ps = GLAMOR_DEFAULT_PRECISION
|
||||
"uniform sampler2D y_sampler;\n"
|
||||
|
@ -80,9 +78,7 @@ static const char *xv_ps = GLAMOR_DEFAULT_PRECISION
|
|||
"temp1.xyz = ucogamma.xyz * vec3(sample) + temp1.xyz;\n"
|
||||
"sample = texture2D(v_sampler, tcs).w;\n"
|
||||
"temp1.xyz = clamp(vco.xyz * vec3(sample) + temp1.xyz, 0.0, 1.0);\n"
|
||||
"temp1.w = 1.0;\n"
|
||||
"gl_FragColor = temp1;\n"
|
||||
"}\n";
|
||||
"temp1.w = 1.0;\n" "gl_FragColor = temp1;\n" "}\n";
|
||||
|
||||
void
|
||||
glamor_init_xv_shader(ScreenPtr screen)
|
||||
|
@ -125,97 +121,94 @@ glamor_fini_xv_shader(ScreenPtr screen)
|
|||
#define ClipValue(v,min,max) ((v) < (min) ? (min) : (v) > (max) ? (max) : (v))
|
||||
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
|
||||
|
||||
static Atom xvBrightness, xvContrast, xvSaturation, xvHue, xvColorspace, xvGamma;
|
||||
static Atom xvBrightness, xvContrast, xvSaturation, xvHue, xvColorspace,
|
||||
xvGamma;
|
||||
|
||||
#define NUM_ATTRIBUTES 5
|
||||
static XF86AttributeRec Attributes_glamor[NUM_ATTRIBUTES+1] =
|
||||
{
|
||||
static XF86AttributeRec Attributes_glamor[NUM_ATTRIBUTES + 1] = {
|
||||
{XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
|
||||
{XvSettable | XvGettable, -1000, 1000, "XV_CONTRAST"},
|
||||
{XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"},
|
||||
{XvSettable | XvGettable, -1000, 1000, "XV_HUE"},
|
||||
{XvSettable | XvGettable, 0, 1, "XV_COLORSPACE"},
|
||||
{0, 0, 0, NULL}
|
||||
};
|
||||
};
|
||||
|
||||
#define NUM_FORMATS 3
|
||||
|
||||
static XF86VideoFormatRec Formats[NUM_FORMATS] =
|
||||
{
|
||||
static XF86VideoFormatRec Formats[NUM_FORMATS] = {
|
||||
{15, TrueColor}, {16, TrueColor}, {24, TrueColor}
|
||||
};
|
||||
};
|
||||
|
||||
#define NUM_IMAGES 2
|
||||
|
||||
static XF86ImageRec Images[NUM_IMAGES] =
|
||||
{
|
||||
XVIMAGE_YV12,
|
||||
static XF86ImageRec Images[NUM_IMAGES] = {
|
||||
XVIMAGE_YV12,
|
||||
XVIMAGE_I420,
|
||||
};
|
||||
};
|
||||
|
||||
static void
|
||||
glamor_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
|
||||
{
|
||||
glamor_port_private *port_priv = (glamor_port_private *)data;
|
||||
int i;
|
||||
if (!cleanup)
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
int i;
|
||||
|
||||
if (!cleanup)
|
||||
return;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
glamor_destroy_pixmap(port_priv->src_pix[i]);
|
||||
port_priv->src_pix[i] = NULL;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
glamor_destroy_pixmap(port_priv->src_pix[i]);
|
||||
port_priv->src_pix[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
glamor_xv_set_port_attribute(ScrnInfoPtr pScrn,
|
||||
Atom attribute,
|
||||
INT32 value,
|
||||
pointer data)
|
||||
Atom attribute, INT32 value, pointer data)
|
||||
{
|
||||
glamor_port_private *port_priv = (glamor_port_private *)data;
|
||||
if (attribute == xvBrightness)
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
|
||||
if (attribute == xvBrightness)
|
||||
port_priv->brightness = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvHue)
|
||||
else if (attribute == xvHue)
|
||||
port_priv->hue = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvContrast)
|
||||
else if (attribute == xvContrast)
|
||||
port_priv->contrast = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvSaturation)
|
||||
else if (attribute == xvSaturation)
|
||||
port_priv->saturation = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvGamma)
|
||||
port_priv->gamma = ClipValue (value, 100, 10000);
|
||||
else if(attribute == xvColorspace)
|
||||
port_priv->transform_index = ClipValue (value, 0, 1);
|
||||
else
|
||||
else if (attribute == xvGamma)
|
||||
port_priv->gamma = ClipValue(value, 100, 10000);
|
||||
else if (attribute == xvColorspace)
|
||||
port_priv->transform_index = ClipValue(value, 0, 1);
|
||||
else
|
||||
return BadMatch;
|
||||
return Success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
glamor_xv_get_port_attribute(ScrnInfoPtr pScrn,
|
||||
Atom attribute,
|
||||
INT32 *value,
|
||||
pointer data)
|
||||
Atom attribute, INT32 *value, pointer data)
|
||||
{
|
||||
glamor_port_private *port_priv = (glamor_port_private *)data;
|
||||
if (attribute == xvBrightness)
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
|
||||
if (attribute == xvBrightness)
|
||||
*value = port_priv->brightness;
|
||||
else if (attribute == xvHue)
|
||||
else if (attribute == xvHue)
|
||||
*value = port_priv->hue;
|
||||
else if (attribute == xvContrast)
|
||||
else if (attribute == xvContrast)
|
||||
*value = port_priv->contrast;
|
||||
else if (attribute == xvSaturation)
|
||||
else if (attribute == xvSaturation)
|
||||
*value = port_priv->saturation;
|
||||
else if (attribute == xvGamma)
|
||||
else if (attribute == xvGamma)
|
||||
*value = port_priv->gamma;
|
||||
else if(attribute == xvColorspace)
|
||||
else if (attribute == xvColorspace)
|
||||
*value = port_priv->transform_index;
|
||||
else
|
||||
else
|
||||
return BadMatch;
|
||||
|
||||
return Success;
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -223,11 +216,10 @@ glamor_xv_query_best_size(ScrnInfoPtr pScrn,
|
|||
Bool motion,
|
||||
short vid_w, short vid_h,
|
||||
short drw_w, short drw_h,
|
||||
unsigned int *p_w, unsigned int *p_h,
|
||||
pointer data)
|
||||
unsigned int *p_w, unsigned int *p_h, pointer data)
|
||||
{
|
||||
*p_w = drw_w;
|
||||
*p_h = drw_h;
|
||||
*p_w = drw_w;
|
||||
*p_h = drw_h;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -236,216 +228,203 @@ glamor_xv_query_image_attributes(ScrnInfoPtr pScrn,
|
|||
unsigned short *w, unsigned short *h,
|
||||
int *pitches, int *offsets)
|
||||
{
|
||||
int size = 0, tmp;
|
||||
int size = 0, tmp;
|
||||
|
||||
if (offsets) offsets[0] = 0;
|
||||
switch (id) {
|
||||
case FOURCC_YV12:
|
||||
case FOURCC_I420:
|
||||
*h = *h;
|
||||
*w = *w;
|
||||
size = *w;
|
||||
if (pitches) pitches[0] = size;
|
||||
size *= *h;
|
||||
if (offsets) offsets[1] = size;
|
||||
tmp = *w >> 1;
|
||||
if (pitches) pitches[1] = pitches[2] = tmp;
|
||||
tmp *= (*h >> 1);
|
||||
size += tmp;
|
||||
if (offsets) offsets[2] = size;
|
||||
size += tmp;
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
if (offsets)
|
||||
offsets[0] = 0;
|
||||
switch (id) {
|
||||
case FOURCC_YV12:
|
||||
case FOURCC_I420:
|
||||
*h = *h;
|
||||
*w = *w;
|
||||
size = *w;
|
||||
if (pitches)
|
||||
pitches[0] = size;
|
||||
size *= *h;
|
||||
if (offsets)
|
||||
offsets[1] = size;
|
||||
tmp = *w >> 1;
|
||||
if (pitches)
|
||||
pitches[1] = pitches[2] = tmp;
|
||||
tmp *= (*h >> 1);
|
||||
size += tmp;
|
||||
if (offsets)
|
||||
offsets[2] = size;
|
||||
size += tmp;
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Parameters for ITU-R BT.601 and ITU-R BT.709 colour spaces
|
||||
note the difference to the parameters used in overlay are due
|
||||
to 10bit vs. float calcs */
|
||||
static REF_TRANSFORM trans[2] =
|
||||
{
|
||||
static REF_TRANSFORM trans[2] = {
|
||||
{1.1643, 0.0, 1.5960, -0.3918, -0.8129, 2.0172, 0.0}, /* BT.601 */
|
||||
{1.1643, 0.0, 1.7927, -0.2132, -0.5329, 2.1124, 0.0} /* BT.709 */
|
||||
};
|
||||
};
|
||||
|
||||
static void
|
||||
glamor_display_textured_video(glamor_port_private *port_priv)
|
||||
glamor_display_textured_video(glamor_port_private * port_priv)
|
||||
{
|
||||
ScreenPtr screen = port_priv->pPixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
ScreenPtr screen = port_priv->pPixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(port_priv->pPixmap);
|
||||
glamor_pixmap_private *src_pixmap_priv[3];
|
||||
glamor_gl_dispatch *dispatch;
|
||||
float vertices[32], texcoords[8];
|
||||
BoxPtr box = REGION_RECTS(&port_priv->clip);
|
||||
int nBox = REGION_NUM_RECTS(&port_priv->clip);
|
||||
int dst_x_off, dst_y_off;
|
||||
GLfloat dst_xscale, dst_yscale;
|
||||
GLfloat src_xscale[3], src_yscale[3];
|
||||
int i;
|
||||
const float Loff = -0.0627;
|
||||
const float Coff = -0.502;
|
||||
float uvcosf, uvsinf;
|
||||
float yco;
|
||||
float uco[3], vco[3], off[3];
|
||||
float bright, cont, gamma;
|
||||
int ref = port_priv->transform_index;
|
||||
GLint uloc, sampler_loc;
|
||||
glamor_pixmap_private *src_pixmap_priv[3];
|
||||
glamor_gl_dispatch *dispatch;
|
||||
float vertices[32], texcoords[8];
|
||||
BoxPtr box = REGION_RECTS(&port_priv->clip);
|
||||
int nBox = REGION_NUM_RECTS(&port_priv->clip);
|
||||
int dst_x_off, dst_y_off;
|
||||
GLfloat dst_xscale, dst_yscale;
|
||||
GLfloat src_xscale[3], src_yscale[3];
|
||||
int i;
|
||||
const float Loff = -0.0627;
|
||||
const float Coff = -0.502;
|
||||
float uvcosf, uvsinf;
|
||||
float yco;
|
||||
float uco[3], vco[3], off[3];
|
||||
float bright, cont, gamma;
|
||||
int ref = port_priv->transform_index;
|
||||
GLint uloc, sampler_loc;
|
||||
|
||||
cont = RTFContrast(port_priv->contrast);
|
||||
bright = RTFBrightness(port_priv->brightness);
|
||||
gamma = (float)port_priv->gamma / 1000.0;
|
||||
uvcosf = RTFSaturation(port_priv->saturation) * cos(RTFHue(port_priv->hue));
|
||||
uvsinf = RTFSaturation(port_priv->saturation) * sin(RTFHue(port_priv->hue));
|
||||
cont = RTFContrast(port_priv->contrast);
|
||||
bright = RTFBrightness(port_priv->brightness);
|
||||
gamma = (float) port_priv->gamma / 1000.0;
|
||||
uvcosf = RTFSaturation(port_priv->saturation) * cos(RTFHue(port_priv->hue));
|
||||
uvsinf = RTFSaturation(port_priv->saturation) * sin(RTFHue(port_priv->hue));
|
||||
/* overlay video also does pre-gamma contrast/sat adjust, should we? */
|
||||
|
||||
yco = trans[ref].RefLuma * cont;
|
||||
uco[0] = -trans[ref].RefRCr * uvsinf;
|
||||
uco[1] = trans[ref].RefGCb * uvcosf - trans[ref].RefGCr * uvsinf;
|
||||
uco[2] = trans[ref].RefBCb * uvcosf;
|
||||
vco[0] = trans[ref].RefRCr * uvcosf;
|
||||
vco[1] = trans[ref].RefGCb * uvsinf + trans[ref].RefGCr * uvcosf;
|
||||
vco[2] = trans[ref].RefBCb * uvsinf;
|
||||
off[0] = Loff * yco + Coff * (uco[0] + vco[0]) + bright;
|
||||
off[1] = Loff * yco + Coff * (uco[1] + vco[1]) + bright;
|
||||
off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright;
|
||||
gamma = 1.0;
|
||||
yco = trans[ref].RefLuma * cont;
|
||||
uco[0] = -trans[ref].RefRCr * uvsinf;
|
||||
uco[1] = trans[ref].RefGCb * uvcosf - trans[ref].RefGCr * uvsinf;
|
||||
uco[2] = trans[ref].RefBCb * uvcosf;
|
||||
vco[0] = trans[ref].RefRCr * uvcosf;
|
||||
vco[1] = trans[ref].RefGCb * uvsinf + trans[ref].RefGCr * uvcosf;
|
||||
vco[2] = trans[ref].RefBCb * uvsinf;
|
||||
off[0] = Loff * yco + Coff * (uco[0] + vco[0]) + bright;
|
||||
off[1] = Loff * yco + Coff * (uco[1] + vco[1]) + bright;
|
||||
off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright;
|
||||
gamma = 1.0;
|
||||
|
||||
pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
glamor_get_drawable_deltas(port_priv->pDraw, port_priv->pPixmap, &dst_x_off,
|
||||
pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
glamor_get_drawable_deltas(port_priv->pDraw, port_priv->pPixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
src_pixmap_priv[i] = glamor_get_pixmap_private(port_priv->src_pix[i]);
|
||||
pixmap_priv_get_scale(src_pixmap_priv[i], &src_xscale[i], &src_yscale[i]);
|
||||
}
|
||||
}
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->xv_prog);
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (port_priv->src_pix[i]) {
|
||||
src_pixmap_priv[i] =
|
||||
glamor_get_pixmap_private(port_priv->src_pix[i]);
|
||||
pixmap_priv_get_scale(src_pixmap_priv[i], &src_xscale[i],
|
||||
&src_yscale[i]);
|
||||
}
|
||||
}
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->xv_prog);
|
||||
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "offsetyco");
|
||||
dispatch->glUniform4f(uloc, off[0], off[1], off[2], yco);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "ucogamma");
|
||||
dispatch->glUniform4f(uloc, uco[0], uco[1], uco[2], gamma);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "vco");
|
||||
dispatch->glUniform4f(uloc, vco[0], vco[1], vco[2], 0);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "offsetyco");
|
||||
dispatch->glUniform4f(uloc, off[0], off[1], off[2], yco);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "ucogamma");
|
||||
dispatch->glUniform4f(uloc, uco[0], uco[1], uco[2], gamma);
|
||||
uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "vco");
|
||||
dispatch->glUniform4f(uloc, vco[0], vco[1], vco[2], 0);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE1);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glActiveTexture(GL_TEXTURE1);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE2);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[2]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T,
|
||||
GL_CLAMP_TO_EDGE);
|
||||
dispatch->glActiveTexture(GL_TEXTURE2);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[2]->base.fbo->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 0);
|
||||
sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 1);
|
||||
sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 2);
|
||||
sampler_loc =
|
||||
dispatch->glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 0);
|
||||
sampler_loc =
|
||||
dispatch->glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 1);
|
||||
sampler_loc =
|
||||
dispatch->glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 2);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
2 * sizeof(float), texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float), vertices);
|
||||
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
for (i = 0; i < nBox; i++) {
|
||||
float off_x = box[i].x1 - port_priv->drw_x;
|
||||
float off_y = box[i].y1 - port_priv->drw_y;
|
||||
float diff_x = (float)port_priv->src_w / (float)port_priv->dst_w;
|
||||
float diff_y = (float)port_priv->src_h / (float)port_priv->dst_h;
|
||||
float srcx, srcy, srcw, srch;
|
||||
int dstx, dsty, dstw, dsth;
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
for (i = 0; i < nBox; i++) {
|
||||
float off_x = box[i].x1 - port_priv->drw_x;
|
||||
float off_y = box[i].y1 - port_priv->drw_y;
|
||||
float diff_x = (float) port_priv->src_w / (float) port_priv->dst_w;
|
||||
float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
|
||||
float srcx, srcy, srcw, srch;
|
||||
int dstx, dsty, dstw, dsth;
|
||||
|
||||
dstx = box[i].x1 + dst_x_off;
|
||||
dsty = box[i].y1 + dst_y_off;
|
||||
dstw = box[i].x2 - box[i].x1;
|
||||
dsth = box[i].y2 - box[i].y1;
|
||||
|
||||
dstx = box[i].x1 + dst_x_off;
|
||||
dsty = box[i].y1 + dst_y_off;
|
||||
dstw = box[i].x2 - box[i].x1;
|
||||
dsth = box[i].y2 - box[i].y1;
|
||||
srcx = port_priv->src_x + off_x * diff_x;
|
||||
srcy = port_priv->src_y + off_y * diff_y;
|
||||
srcw = (port_priv->src_w * dstw) / (float) port_priv->dst_w;
|
||||
srch = (port_priv->src_h * dsth) / (float) port_priv->dst_h;
|
||||
|
||||
srcx = port_priv->src_x + off_x * diff_x;
|
||||
srcy = port_priv->src_y + off_y * diff_y;
|
||||
srcw = (port_priv->src_w * dstw) / (float)port_priv->dst_w;
|
||||
srch = (port_priv->src_h * dsth) / (float)port_priv->dst_h;
|
||||
|
||||
glamor_set_normalize_vcoords(pixmap_priv,
|
||||
glamor_set_normalize_vcoords(pixmap_priv,
|
||||
dst_xscale, dst_yscale,
|
||||
dstx,
|
||||
dsty,
|
||||
dstx + dstw,
|
||||
dsty + dsth,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
glamor_set_normalize_tcoords(src_pixmap_priv[0],
|
||||
glamor_set_normalize_tcoords(src_pixmap_priv[0],
|
||||
src_xscale[0],
|
||||
src_yscale[0],
|
||||
srcx,
|
||||
srcy,
|
||||
srcx + srcw,
|
||||
srcy + srch,
|
||||
glamor_priv->yInverted,
|
||||
texcoords);
|
||||
glamor_priv->yInverted, texcoords);
|
||||
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
DamageDamageRegion(port_priv->pDraw, &port_priv->clip);
|
||||
}
|
||||
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
DamageDamageRegion(port_priv->pDraw, &port_priv->clip);
|
||||
}
|
||||
|
||||
static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
||||
static int
|
||||
glamor_xv_put_image(ScrnInfoPtr pScrn,
|
||||
short src_x, short src_y,
|
||||
short drw_x, short drw_y,
|
||||
short src_w, short src_h,
|
||||
|
@ -455,12 +434,10 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
short width,
|
||||
short height,
|
||||
Bool sync,
|
||||
RegionPtr clipBoxes,
|
||||
pointer data,
|
||||
DrawablePtr pDrawable)
|
||||
RegionPtr clipBoxes, pointer data, DrawablePtr pDrawable)
|
||||
{
|
||||
ScreenPtr screen = xf86ScrnToScreen(pScrn);
|
||||
glamor_port_private *port_priv = (glamor_port_private *)data;
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
INT32 x1, x2, y1, y2;
|
||||
int srcPitch, srcPitch2;
|
||||
BoxRec dstBox;
|
||||
|
@ -479,7 +456,8 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
dstBox.x2 = drw_x + drw_w;
|
||||
dstBox.y1 = drw_y;
|
||||
dstBox.y2 = drw_y + drw_h;
|
||||
if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height))
|
||||
if (!xf86XVClipVideoHelper
|
||||
(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height))
|
||||
return Success;
|
||||
|
||||
if ((x1 >= x2) || (y1 >= y2))
|
||||
|
@ -488,19 +466,25 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
srcPitch = width;
|
||||
srcPitch2 = width >> 1;
|
||||
|
||||
if (!port_priv->src_pix[0] || (width != port_priv->src_pix_w || height != port_priv->src_pix_h)) {
|
||||
if (!port_priv->src_pix[0] ||
|
||||
(width != port_priv->src_pix_w || height != port_priv->src_pix_h)) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (port_priv->src_pix[i])
|
||||
glamor_destroy_pixmap(port_priv->src_pix[i]);
|
||||
|
||||
port_priv->src_pix[0] = glamor_create_pixmap(screen, width, height, 8, 0);
|
||||
port_priv->src_pix[1] = glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
|
||||
port_priv->src_pix[2] = glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
|
||||
port_priv->src_pix[0] =
|
||||
glamor_create_pixmap(screen, width, height, 8, 0);
|
||||
port_priv->src_pix[1] =
|
||||
glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
|
||||
port_priv->src_pix[2] =
|
||||
glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
|
||||
port_priv->src_pix_w = width;
|
||||
port_priv->src_pix_h = height;
|
||||
|
||||
if (!port_priv->src_pix[0] || !port_priv->src_pix[1] || !port_priv->src_pix[2])
|
||||
if (!port_priv->src_pix[0] || !port_priv->src_pix[1] ||
|
||||
!port_priv->src_pix[2])
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
|
@ -539,9 +523,9 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
}
|
||||
|
||||
if (pDrawable->type == DRAWABLE_WINDOW)
|
||||
port_priv->pPixmap = (*screen->GetWindowPixmap)((WindowPtr)pDrawable);
|
||||
port_priv->pPixmap = (*screen->GetWindowPixmap) ((WindowPtr) pDrawable);
|
||||
else
|
||||
port_priv->pPixmap = (PixmapPtr)pDrawable;
|
||||
port_priv->pPixmap = (PixmapPtr) pDrawable;
|
||||
|
||||
if (!RegionEqual(&port_priv->clip, clipBoxes)) {
|
||||
RegionCopy(&port_priv->clip, clipBoxes);
|
||||
|
@ -562,8 +546,7 @@ static int glamor_xv_put_image(ScrnInfoPtr pScrn,
|
|||
return Success;
|
||||
}
|
||||
|
||||
static XF86VideoEncodingRec DummyEncodingGLAMOR[1] =
|
||||
{
|
||||
static XF86VideoEncodingRec DummyEncodingGLAMOR[1] = {
|
||||
{
|
||||
0,
|
||||
"XV_IMAGE",
|
||||
|
@ -600,12 +583,13 @@ glamor_xv_init(ScreenPtr screen, int num_texture_ports)
|
|||
adapt->nFormats = NUM_FORMATS;
|
||||
adapt->pFormats = Formats;
|
||||
adapt->nPorts = num_texture_ports;
|
||||
adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
|
||||
adapt->pPortPrivates = (DevUnion *) (&adapt[1]);
|
||||
|
||||
adapt->pAttributes = Attributes_glamor;
|
||||
adapt->nAttributes = NUM_ATTRIBUTES;
|
||||
|
||||
port_priv = (glamor_port_private *)(&adapt->pPortPrivates[num_texture_ports]);
|
||||
port_priv =
|
||||
(glamor_port_private *) (&adapt->pPortPrivates[num_texture_ports]);
|
||||
adapt->pImages = Images;
|
||||
adapt->nImages = NUM_IMAGES;
|
||||
adapt->PutVideo = NULL;
|
||||
|
@ -632,7 +616,7 @@ glamor_xv_init(ScreenPtr screen, int num_texture_ports)
|
|||
|
||||
REGION_NULL(pScreen, &pPriv->clip);
|
||||
|
||||
adapt->pPortPrivates[i].ptr = (pointer)(pPriv);
|
||||
adapt->pPortPrivates[i].ptr = (pointer) (pPriv);
|
||||
}
|
||||
return adapt;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \mainpage Mesa GL API Module
|
||||
*
|
||||
|
@ -63,59 +62,55 @@
|
|||
#define _glapi_Context _mglapi_Context
|
||||
#endif
|
||||
|
||||
typedef void (*_glapi_proc)(void);
|
||||
typedef void (*_glapi_proc) (void);
|
||||
struct _glapi_table;
|
||||
|
||||
|
||||
#if defined (GLX_USE_TLS)
|
||||
|
||||
extern __thread struct _glapi_table * _glapi_tls_Dispatch
|
||||
__attribute__((tls_model("initial-exec")));
|
||||
extern __thread struct _glapi_table *_glapi_tls_Dispatch
|
||||
__attribute__ ((tls_model("initial-exec")));
|
||||
|
||||
extern __thread void * _glapi_tls_Context
|
||||
__attribute__((tls_model("initial-exec")));
|
||||
extern __thread void *_glapi_tls_Context
|
||||
__attribute__ ((tls_model("initial-exec")));
|
||||
|
||||
extern const struct _glapi_table *_glapi_Dispatch;
|
||||
extern const void *_glapi_Context;
|
||||
|
||||
# define GET_DISPATCH() _glapi_tls_Dispatch
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_tls_Context
|
||||
# define SET_CURRENT_CONTEXT(C) _glapi_tls_Context = (void*)C
|
||||
#define GET_DISPATCH() _glapi_tls_Dispatch
|
||||
#define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_tls_Context
|
||||
#define SET_CURRENT_CONTEXT(C) _glapi_tls_Context = (void*)C
|
||||
|
||||
#else
|
||||
|
||||
extern struct _glapi_table *_glapi_Dispatch;
|
||||
extern void *_glapi_Context;
|
||||
|
||||
# ifdef THREADS
|
||||
#ifdef THREADS
|
||||
|
||||
# define GET_DISPATCH() \
|
||||
#define GET_DISPATCH() \
|
||||
(likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
|
||||
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) \
|
||||
#define GET_CURRENT_CONTEXT(C) C = (typeof(C)) \
|
||||
(likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
|
||||
|
||||
|
||||
# define SET_CURRENT_CONTEXT(C) do { if (likely(_glapi_Context)) \
|
||||
#define SET_CURRENT_CONTEXT(C) do { if (likely(_glapi_Context)) \
|
||||
_glapi_Context = (void*)C; \
|
||||
else \
|
||||
_glapi_set_context(C); } while(0)
|
||||
|
||||
# else
|
||||
#else
|
||||
|
||||
# define GET_DISPATCH() _glapi_Dispatch
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_Context
|
||||
# define SET_CURRENT_CONTEXT(C) _glapi_Context = (void*)C
|
||||
#define GET_DISPATCH() _glapi_Dispatch
|
||||
#define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_Context
|
||||
#define SET_CURRENT_CONTEXT(C) _glapi_Context = (void*)C
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* defined (GLX_USE_TLS) */
|
||||
|
||||
|
||||
extern void
|
||||
_glapi_set_context(void *context);
|
||||
_glapi_set_context(void *context);
|
||||
|
||||
extern void *
|
||||
_glapi_get_context(void);
|
||||
extern void *_glapi_get_context(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue