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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
|
@ -585,18 +575,16 @@ 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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
111
glamor/glamor.h
111
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.
|
||||
*
|
||||
|
@ -196,8 +204,7 @@ extern _X_EXPORT Bool glamor_is_dri3_support_enabled(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.
|
||||
*
|
||||
|
@ -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,
|
||||
PicturePtr pDst,
|
||||
xRenderColor * color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
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,8 +31,7 @@
|
|||
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
|
||||
|
@ -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,9 +36,11 @@
|
|||
* 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;
|
||||
|
||||
if (v > MAXSHORT)
|
||||
return MAXSHORT;
|
||||
return v;
|
||||
|
@ -48,8 +50,7 @@ static Bool
|
|||
_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)
|
||||
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;
|
||||
|
@ -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,8 +255,7 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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,10 +565,10 @@ _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:
|
||||
|
@ -592,8 +579,7 @@ fail:
|
|||
if (ok)
|
||||
return TRUE;
|
||||
fall_back:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(src)
|
||||
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,6 +541,7 @@ glamor_gl_has_extension(const char *extension)
|
|||
{
|
||||
const char *pext;
|
||||
int ext_len;
|
||||
|
||||
ext_len = strlen(extension);
|
||||
|
||||
pext = (const char *) glGetString(GL_EXTENSIONS);
|
||||
|
@ -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);
|
||||
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,8 +350,7 @@ 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:
|
||||
|
@ -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,8 +382,7 @@ 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:
|
||||
|
@ -421,12 +419,11 @@ 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);
|
||||
|
@ -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,15 +465,12 @@ 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);
|
||||
}
|
||||
|
@ -492,13 +485,12 @@ 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);
|
||||
|
@ -507,6 +499,7 @@ PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
|||
EGLImageKHR image;
|
||||
PixmapPtr pixmap;
|
||||
Bool ret = FALSE;
|
||||
|
||||
EGLint attribs[] = {
|
||||
EGL_WIDTH, 0,
|
||||
EGL_HEIGHT, 0,
|
||||
|
@ -554,8 +547,7 @@ PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
|||
|
||||
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;
|
||||
|
@ -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,7 +765,8 @@ 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
|
||||
|
@ -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,8 +840,7 @@ 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 =
|
||||
|
|
|
@ -44,24 +44,27 @@
|
|||
&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;
|
||||
|
@ -74,6 +77,7 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
|
|||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
|
||||
int n_format;
|
||||
|
||||
#ifdef NO_FBO_CACHE
|
||||
return NULL;
|
||||
#else
|
||||
|
@ -126,6 +130,7 @@ void
|
|||
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)
|
||||
|
@ -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);
|
||||
|
@ -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";
|
||||
|
@ -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);
|
||||
|
@ -251,7 +258,6 @@ done:
|
|||
return fbo;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fbo_expire(glamor_screen_private * glamor_priv)
|
||||
{
|
||||
|
@ -263,15 +269,17 @@ glamor_fbo_expire(glamor_screen_private *glamor_priv)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
@ -287,8 +295,7 @@ glamor_init_pixmap_fbo(ScreenPtr screen)
|
|||
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 (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
xorg_list_init(&glamor_priv->fbo_cache[i][j][k]);
|
||||
}
|
||||
glamor_priv->fbo_cache_watermark = 0;
|
||||
|
@ -305,10 +312,10 @@ glamor_fini_pixmap_fbo(ScreenPtr screen)
|
|||
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 (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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -357,9 +362,7 @@ _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)
|
||||
int w, int h, GLenum format, int flag)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
GLint tex = 0;
|
||||
|
@ -379,8 +382,7 @@ 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:
|
||||
|
@ -395,8 +397,7 @@ static 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 *pixmap_priv,
|
||||
int has_fbo)
|
||||
glamor_pixmap_private * pixmap_priv, int has_fbo)
|
||||
{
|
||||
int block_wcnt;
|
||||
int block_hcnt;
|
||||
|
@ -419,8 +420,7 @@ _glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
|||
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;
|
||||
|
@ -462,7 +465,6 @@ cleanup:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Create a fbo array to cover the w*h region, by using block_w*block_h
|
||||
* block.*/
|
||||
glamor_pixmap_fbo *
|
||||
|
@ -529,13 +531,16 @@ void
|
|||
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++)
|
||||
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,8 +192,7 @@ _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);
|
||||
|
||||
|
@ -209,7 +201,8 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
|||
|
||||
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)
|
||||
|
@ -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) {
|
||||
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++) {
|
||||
|
@ -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;
|
||||
|
@ -72,8 +73,7 @@ _glamor_fill_spans(DrawablePtr drawable,
|
|||
goto done;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -81,8 +81,7 @@ 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);
|
||||
|
@ -93,11 +92,9 @@ 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);
|
||||
|
@ -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,9 +48,12 @@ _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);
|
||||
}
|
||||
|
@ -60,8 +62,7 @@ _glamor_get_spans(DrawablePtr drawable,
|
|||
goto done;
|
||||
fail:
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
|
||||
ret = TRUE;
|
||||
|
@ -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,8 +2,7 @@ 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);
|
||||
|
||||
|
@ -11,8 +10,11 @@ typedef struct glamor_gl_dispatch {
|
|||
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);
|
||||
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,7 +59,8 @@ 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);
|
||||
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,8 +69,7 @@ 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);
|
||||
void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
|
||||
|
@ -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,19 +87,15 @@ 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);
|
||||
|
@ -110,29 +104,25 @@ typedef struct glamor_gl_dispatch {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,8 @@ static struct glamor_glyph_mask_cache {
|
|||
struct glamor_glyph_mask_cache_entry mcache[MASK_CACHE_WIDTH];
|
||||
unsigned int free_bitmap;
|
||||
unsigned int cleared_bitmap;
|
||||
}*mask_cache[GLAMOR_NUM_GLYPH_CACHE_FORMATS] = {NULL};
|
||||
} *mask_cache[GLAMOR_NUM_GLYPH_CACHE_FORMATS] = {
|
||||
NULL};
|
||||
|
||||
static void
|
||||
clear_mask_cache_bitmap(struct glamor_glyph_mask_cache *maskcache,
|
||||
|
@ -145,8 +146,7 @@ clear_mask_cache_bitmap(struct glamor_glyph_mask_cache *maskcache,
|
|||
int box_cnt = 0;
|
||||
|
||||
assert((clear_mask_bits & ~MASK_CACHE_MASK) == 0);
|
||||
for(i = 0; i < MASK_CACHE_WIDTH;i++)
|
||||
{
|
||||
for (i = 0; i < MASK_CACHE_WIDTH; i++) {
|
||||
if (clear_mask_bits & (1 << i)) {
|
||||
box[box_cnt].x1 = maskcache->mcache[i].x;
|
||||
box[box_cnt].x2 = maskcache->mcache[i].x + MASK_CACHE_MAX_SIZE;
|
||||
|
@ -166,6 +166,7 @@ clear_mask_cache(struct glamor_glyph_mask_cache *maskcache)
|
|||
int cnt = MASK_CACHE_WIDTH;
|
||||
unsigned int i = 0;
|
||||
struct glamor_glyph_mask_cache_entry *mce;
|
||||
|
||||
glamor_solid(maskcache->pixmap, 0, CACHE_PICTURE_SIZE, CACHE_PICTURE_SIZE,
|
||||
MASK_CACHE_MAX_SIZE, GXcopy, 0xFFFFFFFF, 0);
|
||||
mce = &maskcache->mcache[0];
|
||||
|
@ -187,6 +188,7 @@ find_continuous_bits(unsigned int bits, int bits_cnt, unsigned int *pbits_mask)
|
|||
{
|
||||
int idx = 0;
|
||||
unsigned int bits_mask;
|
||||
|
||||
bits_mask = ((1LL << bits_cnt) - 1);
|
||||
|
||||
if (unlikely(bits_cnt > 56)) {
|
||||
|
@ -198,10 +200,12 @@ find_continuous_bits(unsigned int bits, int bits_cnt, unsigned int *pbits_mask)
|
|||
bits >>= 1;
|
||||
idx++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
idx = __fls(bits);
|
||||
while (bits) {
|
||||
unsigned int temp_bits;
|
||||
|
||||
temp_bits = bits_mask << (idx - bits_cnt + 1);
|
||||
if ((bits & temp_bits) == temp_bits) {
|
||||
*pbits_mask = temp_bits;
|
||||
|
@ -231,7 +235,8 @@ retry:
|
|||
if (free_cleared_bit && blocks == 1) {
|
||||
idx = __fls(free_cleared_bit);
|
||||
bits_mask = 1 << idx;
|
||||
} else if (free_cleared_bit && blocks > 1) {
|
||||
}
|
||||
else if (free_cleared_bit && blocks > 1) {
|
||||
idx = find_continuous_bits(free_cleared_bit, blocks, &bits_mask);
|
||||
}
|
||||
|
||||
|
@ -302,6 +307,7 @@ static Bool
|
|||
glamor_realize_glyph_caches(ScreenPtr pScreen)
|
||||
{
|
||||
glamor_screen_private *glamor = glamor_get_screen_private(pScreen);
|
||||
|
||||
unsigned int formats[] = {
|
||||
PIXMAN_a8,
|
||||
PIXMAN_a8r8g8b8,
|
||||
|
@ -329,8 +335,8 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
|
|||
/* Now allocate the pixmap and picture */
|
||||
pixmap = pScreen->CreatePixmap(pScreen,
|
||||
CACHE_PICTURE_SIZE,
|
||||
CACHE_PICTURE_SIZE + MASK_CACHE_MAX_SIZE, depth,
|
||||
0);
|
||||
CACHE_PICTURE_SIZE + MASK_CACHE_MAX_SIZE,
|
||||
depth, 0);
|
||||
if (!pixmap)
|
||||
goto bail;
|
||||
|
||||
|
@ -364,7 +370,6 @@ glamor_realize_glyph_caches(ScreenPtr pScreen)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_glyphs_init(ScreenPtr pScreen)
|
||||
{
|
||||
|
@ -404,8 +409,7 @@ glamor_glyph_cache_upload_glyph(ScreenPtr screen,
|
|||
scratch = glamor_create_pixmap(screen,
|
||||
glyph->info.width,
|
||||
glyph->info.height,
|
||||
pCachePixmap->
|
||||
drawable.depth, 0);
|
||||
pCachePixmap->drawable.depth, 0);
|
||||
if (scratch) {
|
||||
PicturePtr picture;
|
||||
int error;
|
||||
|
@ -415,23 +419,20 @@ glamor_glyph_cache_upload_glyph(ScreenPtr screen,
|
|||
&scratch->drawable,
|
||||
PictureMatchFormat
|
||||
(screen,
|
||||
pCachePixmap->
|
||||
drawable.depth,
|
||||
pCachePixmap->drawable.depth,
|
||||
cache->picture->format),
|
||||
0, NULL, serverClient,
|
||||
&error);
|
||||
0, NULL, serverClient, &error);
|
||||
if (picture) {
|
||||
ValidatePicture(picture);
|
||||
glamor_composite(PictOpSrc,
|
||||
pGlyphPicture,
|
||||
NULL, picture,
|
||||
0, 0, 0, 0, 0,
|
||||
0,
|
||||
glyph->info.width,
|
||||
glyph->info.height);
|
||||
0, glyph->info.width, glyph->info.height);
|
||||
FreePicture(picture, 0);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
scratch = pGlyphPixmap;
|
||||
}
|
||||
}
|
||||
|
@ -442,16 +443,13 @@ glamor_glyph_cache_upload_glyph(ScreenPtr screen,
|
|||
box.y2 = y + glyph->info.height;
|
||||
glamor_copy_n_to_n_nf(&scratch->drawable,
|
||||
&pCachePixmap->drawable, NULL,
|
||||
&box, 1,
|
||||
-x, -y,
|
||||
FALSE, FALSE, 0, NULL);
|
||||
&box, 1, -x, -y, FALSE, FALSE, 0, NULL);
|
||||
if (scratch != pGlyphPixmap)
|
||||
screen->DestroyPixmap(scratch);
|
||||
|
||||
FreeScratchGC(gc);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph)
|
||||
{
|
||||
|
@ -540,23 +538,30 @@ glamor_glyph_priv_get_edge_map(GlyphPtr glyph, struct glamor_glyph *priv,
|
|||
left_x1_map = left_x2_map = 0;
|
||||
right_x1_map = right_x2_map = 0;
|
||||
|
||||
for(j = 0; j < glyph_pixmap->drawable.height; j++)
|
||||
{
|
||||
for (j = 0; j < glyph_pixmap->drawable.height; j++) {
|
||||
if (bitsPerPixel == 8) {
|
||||
unsigned char *data;
|
||||
|
||||
data = (unsigned char *) ((unsigned char *) bits + stride * j);
|
||||
left_x1_data = *data++;
|
||||
left_x2_data = *data;
|
||||
data = (unsigned char*)((unsigned char*)bits + stride * j + width - 2);
|
||||
data =
|
||||
(unsigned char *) ((unsigned char *) bits + stride * j + width -
|
||||
2);
|
||||
right_x1_data = *data++;
|
||||
right_x2_data = *data;
|
||||
} else if (bitsPerPixel == 32) {
|
||||
}
|
||||
else if (bitsPerPixel == 32) {
|
||||
left_x1_data = *((unsigned int *) bits + stride / 4 * j);
|
||||
left_x2_data = *((unsigned int *) bits + stride / 4 * j + 1);
|
||||
right_x1_data = *((unsigned int*)bits + stride/4 * j + width - 2);
|
||||
right_x2_data = *((unsigned int*)bits + stride/4 * j + width - 1);
|
||||
} else if (bitsPerPixel == 1) {
|
||||
right_x1_data =
|
||||
*((unsigned int *) bits + stride / 4 * j + width - 2);
|
||||
right_x2_data =
|
||||
*((unsigned int *) bits + stride / 4 * j + width - 1);
|
||||
}
|
||||
else if (bitsPerPixel == 1) {
|
||||
unsigned char temp;
|
||||
|
||||
temp = *((unsigned char *) glyph_pixmap->devPrivate.ptr
|
||||
+ glyph_pixmap->devKind * j) & 0x3;
|
||||
left_x1_data = temp & 0x1;
|
||||
|
@ -613,16 +618,13 @@ glyph_new_fixed_list(struct glamor_glyph_list *fixed_list,
|
|||
GlyphListPtr * head_list,
|
||||
int *head_pos,
|
||||
int *head_x,
|
||||
int *head_y,
|
||||
int *fixed_cnt,
|
||||
int type,
|
||||
BoxPtr prev_extents
|
||||
)
|
||||
int *head_y, int *fixed_cnt, int type, BoxPtr prev_extents)
|
||||
{
|
||||
int x_off = 0;
|
||||
int y_off = 0;
|
||||
int n_off = 0;
|
||||
int list_cnt;
|
||||
|
||||
if (type == NON_INTERSECTED) {
|
||||
if (x1 < prev_extents->x2 && x2 > prev_extents->x1
|
||||
&& y1 < prev_extents->y2 && y2 > prev_extents->y1)
|
||||
|
@ -660,7 +662,8 @@ glyph_new_fixed_list(struct glamor_glyph_list *fixed_list,
|
|||
fixed_list->list[0].len = (*head_list)->len - *head_pos;
|
||||
if (cur_pos != n_off)
|
||||
fixed_list->list[list_cnt - 1].len = cur_pos - n_off;
|
||||
} else
|
||||
}
|
||||
else
|
||||
fixed_list->list[0].len = cur_pos - *head_pos - n_off;
|
||||
(*fixed_cnt)++;
|
||||
}
|
||||
|
@ -695,8 +698,7 @@ static int
|
|||
glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
|
||||
PictFormatShort mask_format,
|
||||
ScreenPtr screen, Bool check_fake_overlap,
|
||||
struct glamor_glyph_list * fixed_list,
|
||||
int fixed_size)
|
||||
struct glamor_glyph_list *fixed_list, int fixed_size)
|
||||
{
|
||||
int x1, x2, y1, y2;
|
||||
int n;
|
||||
|
@ -753,7 +755,8 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
|
|||
pixman_region_init_with_extents(¤t_region, extents);
|
||||
pixman_region_union(&list_region, &list_region, ¤t_region);
|
||||
first = TRUE;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
head_list = cur_list;
|
||||
head_pos = cur_list->len - n;
|
||||
head_x = x;
|
||||
|
@ -766,8 +769,7 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
|
|||
GlyphPtr glyph = *glyphs++;
|
||||
|
||||
DEBUGF("the %dth glyph\n", cur_list->len - n - 1);
|
||||
if (glyph->info.width == 0
|
||||
|| glyph->info.height == 0) {
|
||||
if (glyph->info.width == 0 || glyph->info.height == 0) {
|
||||
x += glyph->info.xOff;
|
||||
y += glyph->info.yOff;
|
||||
continue;
|
||||
|
@ -817,40 +819,49 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
|
|||
has_left_edge_box = TRUE;
|
||||
has_right_edge_box = TRUE;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (unlikely(!first_list)) {
|
||||
current_box.x1 = x1;
|
||||
current_box.y1 = y1;
|
||||
current_box.x2 = x2;
|
||||
current_box.y2 = y2;
|
||||
if (pixman_region_contains_rectangle(&list_region, ¤t_box) != PIXMAN_REGION_OUT) {
|
||||
if (pixman_region_contains_rectangle
|
||||
(&list_region, ¤t_box) != PIXMAN_REGION_OUT) {
|
||||
need_free_fixed_list = TRUE;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (x1 < extents->x2 && x2 > extents->x1
|
||||
&& y1 < extents->y2
|
||||
&& y2 > extents->y1) {
|
||||
&& y1 < extents->y2 && y2 > extents->y1) {
|
||||
|
||||
if (check_fake_overlap && (has_left_edge_box || has_right_edge_box)
|
||||
if (check_fake_overlap &&
|
||||
(has_left_edge_box || has_right_edge_box)
|
||||
&& priv->has_edge_map && glyph->info.yOff == 0) {
|
||||
int left_dx, right_dx;
|
||||
unsigned long long intersected;
|
||||
|
||||
left_dx = has_left_edge_box ? 1 : 0;
|
||||
right_dx = has_right_edge_box ? 1 : 0;
|
||||
if (x1 + 1 < extents->x2 - right_dx && x2 - 1 > extents->x1 + left_dx)
|
||||
if (x1 + 1 < extents->x2 - right_dx &&
|
||||
x2 - 1 > extents->x1 + left_dx)
|
||||
goto real_intersected;
|
||||
|
||||
if (left_to_right && has_right_edge_box) {
|
||||
if (x1 == right_box.x1) {
|
||||
intersected = ((priv->left_x1_map & right_priv->right_x1_map)
|
||||
| (priv->left_x2_map & right_priv->right_x2_map));
|
||||
intersected =
|
||||
((priv->left_x1_map & right_priv->
|
||||
right_x1_map)
|
||||
| (priv->left_x2_map & right_priv->
|
||||
right_x2_map));
|
||||
if (intersected)
|
||||
goto real_intersected;
|
||||
} else if (x1 == right_box.x2) {
|
||||
intersected = (priv->left_x1_map & right_priv->right_x2_map);
|
||||
}
|
||||
else if (x1 == right_box.x2) {
|
||||
intersected =
|
||||
(priv->left_x1_map & right_priv->
|
||||
right_x2_map);
|
||||
if (intersected) {
|
||||
#ifdef GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
|
||||
/* tolerate with two pixels overlap. */
|
||||
|
@ -860,9 +871,12 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
|
|||
goto real_intersected;
|
||||
}
|
||||
}
|
||||
} else if (!left_to_right && has_left_edge_box) {
|
||||
}
|
||||
else if (!left_to_right && has_left_edge_box) {
|
||||
if (x2 - 1 == left_box.x1) {
|
||||
intersected = (priv->right_x2_map & left_priv->left_x1_map);
|
||||
intersected =
|
||||
(priv->right_x2_map & left_priv->
|
||||
left_x1_map);
|
||||
if (intersected) {
|
||||
#ifdef GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
|
||||
/* tolerate with two pixels overlap. */
|
||||
|
@ -871,17 +885,22 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
|
|||
#endif
|
||||
goto real_intersected;
|
||||
}
|
||||
} else if (x2 - 1 == right_box.x2) {
|
||||
if ((priv->right_x1_map & left_priv->left_x1_map)
|
||||
|| (priv->right_x2_map & left_priv->left_x2_map))
|
||||
}
|
||||
else if (x2 - 1 == right_box.x2) {
|
||||
if ((priv->right_x1_map & left_priv->
|
||||
left_x1_map)
|
||||
|| (priv->right_x2_map & left_priv->
|
||||
left_x2_map))
|
||||
goto real_intersected;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (x1 < extents->x2 && x1 + 2 > extents->x1)
|
||||
goto real_intersected;
|
||||
}
|
||||
goto non_intersected;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
real_intersected:
|
||||
DEBUGF("overlap with previous glyph.\n");
|
||||
if (in_non_intersected_list == 1) {
|
||||
|
@ -893,15 +912,13 @@ real_intersected:
|
|||
glyphs - 1,
|
||||
&head_glyphs,
|
||||
cur_list,
|
||||
cur_list->len - (n + 1), x, y,
|
||||
x1, y1, x2, y2,
|
||||
&head_list,
|
||||
&head_pos,
|
||||
&head_x,
|
||||
&head_y, &fixed_cnt,
|
||||
cur_list->len - (n + 1),
|
||||
x, y, x1, y1, x2, y2,
|
||||
&head_list, &head_pos,
|
||||
&head_x, &head_y,
|
||||
&fixed_cnt,
|
||||
NON_INTERSECTED,
|
||||
&prev_extents
|
||||
)){
|
||||
&prev_extents)) {
|
||||
need_free_fixed_list = TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
@ -910,7 +927,8 @@ real_intersected:
|
|||
in_non_intersected_list = 0;
|
||||
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
non_intersected:
|
||||
DEBUGF("doesn't overlap with previous glyph.\n");
|
||||
if (in_non_intersected_list == 0) {
|
||||
|
@ -928,9 +946,7 @@ non_intersected:
|
|||
&head_pos,
|
||||
&head_x,
|
||||
&head_y, &fixed_cnt,
|
||||
INTERSECTED,
|
||||
&prev_extents
|
||||
)) {
|
||||
INTERSECTED, &prev_extents)) {
|
||||
need_free_fixed_list = TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
@ -980,8 +996,7 @@ non_intersected:
|
|||
goto done;
|
||||
}
|
||||
|
||||
if ((in_non_intersected_list != -1
|
||||
|| head_pos != n) && (fixed_cnt > 0)) {
|
||||
if ((in_non_intersected_list != -1 || head_pos != n) && (fixed_cnt > 0)) {
|
||||
if (fixed_cnt >= fixed_size) {
|
||||
need_free_fixed_list = TRUE;
|
||||
goto done;
|
||||
|
@ -997,8 +1012,7 @@ non_intersected:
|
|||
&head_x,
|
||||
&head_y, &fixed_cnt,
|
||||
(!in_non_intersected_list) | 0x80,
|
||||
&prev_extents
|
||||
)) {
|
||||
&prev_extents)) {
|
||||
need_free_fixed_list = TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
@ -1035,8 +1049,7 @@ glamor_glyph_count_to_mask(int count)
|
|||
static inline unsigned int
|
||||
glamor_glyph_size_to_mask(int size)
|
||||
{
|
||||
return
|
||||
glamor_glyph_count_to_mask(glamor_glyph_size_to_count(size));
|
||||
return glamor_glyph_count_to_mask(glamor_glyph_size_to_count(size));
|
||||
}
|
||||
|
||||
static PicturePtr
|
||||
|
@ -1046,8 +1059,7 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
|
|||
ScreenPtr screen = glamor->screen;
|
||||
PicturePtr glyph_picture = GlyphPicture(glyph)[screen->myNum];
|
||||
glamor_glyph_cache_t *cache =
|
||||
&glamor->glyphCaches[PICT_FORMAT_RGB(glyph_picture->format) !=
|
||||
0];
|
||||
&glamor->glyphCaches[PICT_FORMAT_RGB(glyph_picture->format) != 0];
|
||||
struct glamor_glyph *priv = NULL, *evicted_priv = NULL;
|
||||
int size, mask, pos, s;
|
||||
|
||||
|
@ -1056,8 +1068,7 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
|
|||
return NULL;
|
||||
|
||||
for (size = GLYPH_MIN_SIZE; size <= GLYPH_MAX_SIZE; size *= 2)
|
||||
if (glyph->info.width <= size
|
||||
&& glyph->info.height <= size)
|
||||
if (glyph->info.width <= size && glyph->info.height <= size)
|
||||
break;
|
||||
|
||||
s = glamor_glyph_size_to_count(size);
|
||||
|
@ -1067,11 +1078,12 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
|
|||
priv = glamor_glyph_get_private(glyph);
|
||||
if (pos < GLYPH_CACHE_SIZE) {
|
||||
cache->count = pos + s;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (s = size; s <= GLYPH_MAX_SIZE; s *= 2) {
|
||||
int i =
|
||||
cache->evict & glamor_glyph_size_to_mask(s);
|
||||
int i = cache->evict & glamor_glyph_size_to_mask(s);
|
||||
GlyphPtr evicted = cache->glyphs[i];
|
||||
|
||||
if (evicted == NULL)
|
||||
continue;
|
||||
|
||||
|
@ -1080,23 +1092,23 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
|
|||
if (evicted_priv->size >= s) {
|
||||
cache->glyphs[i] = NULL;
|
||||
evicted_priv->cached = FALSE;
|
||||
pos = cache->evict &
|
||||
glamor_glyph_size_to_mask(size);
|
||||
} else
|
||||
pos = cache->evict & glamor_glyph_size_to_mask(size);
|
||||
}
|
||||
else
|
||||
evicted_priv = NULL;
|
||||
break;
|
||||
}
|
||||
if (evicted_priv == NULL) {
|
||||
int count = glamor_glyph_size_to_count(size);
|
||||
|
||||
mask = glamor_glyph_count_to_mask(count);
|
||||
pos = cache->evict & mask;
|
||||
for (s = 0; s < count; s++) {
|
||||
GlyphPtr evicted = cache->glyphs[pos + s];
|
||||
|
||||
if (evicted != NULL) {
|
||||
|
||||
evicted_priv =
|
||||
glamor_glyph_get_private
|
||||
(evicted);
|
||||
evicted_priv = glamor_glyph_get_private(evicted);
|
||||
|
||||
assert(evicted_priv->pos == pos + s);
|
||||
evicted_priv->cached = FALSE;
|
||||
|
@ -1109,7 +1121,6 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
|
|||
cache->evict = rand() % GLYPH_CACHE_SIZE;
|
||||
}
|
||||
|
||||
|
||||
cache->glyphs[pos] = glyph;
|
||||
|
||||
priv->cache = cache;
|
||||
|
@ -1117,10 +1128,8 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
|
|||
priv->pos = pos;
|
||||
s = pos / ((GLYPH_MAX_SIZE / GLYPH_MIN_SIZE) *
|
||||
(GLYPH_MAX_SIZE / GLYPH_MIN_SIZE));
|
||||
priv->x =
|
||||
s % (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE) * GLYPH_MAX_SIZE;
|
||||
priv->y =
|
||||
(s / (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE)) * GLYPH_MAX_SIZE;
|
||||
priv->x = s % (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE) * GLYPH_MAX_SIZE;
|
||||
priv->y = (s / (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE)) * GLYPH_MAX_SIZE;
|
||||
for (s = GLYPH_MIN_SIZE; s < GLYPH_MAX_SIZE; s *= 2) {
|
||||
if (pos & 1)
|
||||
priv->x += s;
|
||||
|
@ -1129,8 +1138,7 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
|
|||
pos >>= 2;
|
||||
}
|
||||
|
||||
glamor_glyph_cache_upload_glyph(screen, cache, glyph, priv->x,
|
||||
priv->y);
|
||||
glamor_glyph_cache_upload_glyph(screen, cache, glyph, priv->x, priv->y);
|
||||
#ifndef GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
|
||||
if (priv->has_edge_map == FALSE && glyph->info.width >= 2)
|
||||
glamor_glyph_priv_get_edge_map(glyph, priv, glyph_picture);
|
||||
|
@ -1141,6 +1149,7 @@ glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
|
|||
*out_y = priv->y;
|
||||
return cache->picture;
|
||||
}
|
||||
|
||||
typedef void (*glyphs_flush_func) (void *arg);
|
||||
struct glyphs_flush_dst_arg {
|
||||
CARD8 op;
|
||||
|
@ -1157,6 +1166,7 @@ static glamor_glyph_buffer_t dst_buffer;
|
|||
static glamor_glyph_buffer_t mask_buffer;
|
||||
unsigned long long mask_glyphs_cnt = 0;
|
||||
unsigned long long dst_glyphs_cnt = 0;
|
||||
|
||||
#define GLYPHS_DST_MODE_VIA_MASK 0
|
||||
#define GLYPHS_DST_MODE_VIA_MASK_CACHE 1
|
||||
#define GLYPHS_DST_MODE_TO_DST 2
|
||||
|
@ -1176,8 +1186,7 @@ glamor_glyphs_flush_mask(struct glyphs_flush_mask_arg *arg)
|
|||
#ifdef RENDER
|
||||
glamor_composite_glyph_rects(PictOpAdd, arg->buffer->source,
|
||||
NULL, arg->mask,
|
||||
arg->buffer->count,
|
||||
arg->buffer->rects);
|
||||
arg->buffer->count, arg->buffer->rects);
|
||||
#endif
|
||||
}
|
||||
arg->buffer->count = 0;
|
||||
|
@ -1209,7 +1218,6 @@ glamor_glyphs_flush_dst(struct glyphs_flush_dst_arg * arg)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static glamor_glyph_cache_result_t
|
||||
glamor_buffer_glyph(glamor_screen_private * glamor_priv,
|
||||
glamor_glyph_buffer_t * buffer,
|
||||
|
@ -1232,18 +1240,14 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
|
|||
if (PICT_FORMAT_BPP(format) == 1)
|
||||
format = PICT_a8;
|
||||
|
||||
cache =
|
||||
&glamor_priv->glyphCaches[PICT_FORMAT_RGB(format) != 0];
|
||||
cache = &glamor_priv->glyphCaches[PICT_FORMAT_RGB(format) != 0];
|
||||
|
||||
if (buffer->source
|
||||
&& buffer->source != cache->picture
|
||||
&& glyphs_flush) {
|
||||
if (buffer->source && buffer->source != cache->picture && glyphs_flush) {
|
||||
(*glyphs_flush) (flush_arg);
|
||||
glyphs_flush = NULL;
|
||||
}
|
||||
|
||||
if (buffer->count == GLYPH_BUFFER_SIZE
|
||||
&& glyphs_flush) {
|
||||
if (buffer->count == GLYPH_BUFFER_SIZE && glyphs_flush) {
|
||||
(*glyphs_flush) (flush_arg);
|
||||
glyphs_flush = NULL;
|
||||
}
|
||||
|
@ -1256,7 +1260,8 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
|
|||
buffer->source = priv->cache->picture;
|
||||
if (glyphs_dst_mode <= GLYPHS_DST_MODE_VIA_MASK_CACHE)
|
||||
assert(priv->cache->glyphs[priv->pos] == glyph);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
assert(glyphs_dst_mode != GLYPHS_DST_MODE_MASK_TO_DST);
|
||||
if (glyphs_flush)
|
||||
(*glyphs_flush) (flush_arg);
|
||||
|
@ -1270,6 +1275,7 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
|
|||
buffer->source = source;
|
||||
if (glyphs_dst_mode == GLYPHS_DST_MODE_VIA_MASK_CACHE) {
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
/* mode 1 means we are using global mask cache,
|
||||
* thus we have to composite from the cache picture
|
||||
* to the cache picture, we need a flush here to make
|
||||
|
@ -1278,12 +1284,11 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
|
|||
dispatch->glFlush();
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Couldn't find the glyph in the cache, use the glyph picture directly */
|
||||
source = GlyphPicture(glyph)[screen->myNum];
|
||||
if (buffer->source
|
||||
&& buffer->source != source
|
||||
&& glyphs_flush)
|
||||
if (buffer->source && buffer->source != source && glyphs_flush)
|
||||
(*glyphs_flush) (flush_arg);
|
||||
buffer->source = source;
|
||||
|
||||
|
@ -1312,7 +1317,6 @@ glamor_buffer_glyph(glamor_screen_private *glamor_priv,
|
|||
return GLAMOR_GLYPH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glamor_buffer_glyph_clip(glamor_screen_private * glamor_priv,
|
||||
BoxPtr rects,
|
||||
|
@ -1322,11 +1326,10 @@ glamor_buffer_glyph_clip(glamor_screen_private *glamor_priv,
|
|||
int glyph_dx, int glyph_dy,
|
||||
int width, int height,
|
||||
int glyphs_mode,
|
||||
glyphs_flush_func flush_func,
|
||||
void *arg
|
||||
)
|
||||
glyphs_flush_func flush_func, void *arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nrect; i++) {
|
||||
int dst_x, dst_y;
|
||||
int dx, dy;
|
||||
|
@ -1358,14 +1361,11 @@ glamor_buffer_glyph_clip(glamor_screen_private *glamor_priv,
|
|||
dst_y + glyph_dy,
|
||||
dx, dy,
|
||||
x2 - dst_x, y2 - dst_y,
|
||||
glyphs_mode,
|
||||
flush_func,
|
||||
arg);
|
||||
glyphs_mode, flush_func, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glamor_glyphs_via_mask(CARD8 op,
|
||||
PicturePtr src,
|
||||
|
@ -1407,8 +1407,7 @@ glamor_glyphs_via_mask(CARD8 op,
|
|||
height = extents.y2 - extents.y1;
|
||||
|
||||
if (mask_format->depth == 1) {
|
||||
PictFormatPtr a8Format =
|
||||
PictureMatchFormat(screen, 8, PICT_a8);
|
||||
PictFormatPtr a8Format = PictureMatchFormat(screen, 8, PICT_a8);
|
||||
|
||||
if (a8Format)
|
||||
mask_format = a8Format;
|
||||
|
@ -1420,8 +1419,7 @@ glamor_glyphs_via_mask(CARD8 op,
|
|||
|
||||
x = -extents.x1;
|
||||
y = -extents.y1;
|
||||
if (!use_mask_cache
|
||||
|| width > (CACHE_PICTURE_SIZE/4)
|
||||
if (!use_mask_cache || width > (CACHE_PICTURE_SIZE / 4)
|
||||
|| height > MASK_CACHE_MAX_SIZE) {
|
||||
new_mask_pixmap:
|
||||
mask_pixmap = glamor_create_pixmap(screen, width, height,
|
||||
|
@ -1445,11 +1443,14 @@ new_mask_pixmap:
|
|||
pmask_buffer->source = NULL;
|
||||
pmask_arg->used_bitmap = 0;
|
||||
glyphs_dst_mode = GLYPHS_DST_MODE_VIA_MASK;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int retry_cnt = 0;
|
||||
|
||||
retry:
|
||||
mce = get_mask_cache(maskcache,
|
||||
(width + MASK_CACHE_MAX_SIZE - 1) / MASK_CACHE_MAX_SIZE);
|
||||
(width + MASK_CACHE_MAX_SIZE -
|
||||
1) / MASK_CACHE_MAX_SIZE);
|
||||
|
||||
if (mce == NULL) {
|
||||
glamor_glyphs_flush_dst(&dst_arg);
|
||||
|
@ -1466,8 +1467,7 @@ retry:
|
|||
y += mce->y;
|
||||
mce->width = (width + MASK_CACHE_MAX_SIZE - 1) / MASK_CACHE_MAX_SIZE;
|
||||
mce->height = 1;
|
||||
if (mask_arg.mask && mask_arg.mask != mask
|
||||
&& mask_buffer.count != 0)
|
||||
if (mask_arg.mask && mask_arg.mask != mask && mask_buffer.count != 0)
|
||||
glamor_glyphs_flush_dst(&dst_arg);
|
||||
pmask_arg = &mask_arg;
|
||||
pmask_buffer = &mask_buffer;
|
||||
|
@ -1483,23 +1483,26 @@ retry:
|
|||
mask_glyphs_cnt += n;
|
||||
while (n--) {
|
||||
glyph = *glyphs++;
|
||||
if (glyph->info.width > 0
|
||||
&& glyph->info.height > 0) {
|
||||
if (glyph->info.width > 0 && glyph->info.height > 0) {
|
||||
glyphs_flush_func flush_func;
|
||||
void *temp_arg;
|
||||
|
||||
if (need_free_mask) {
|
||||
if (pmask_buffer->count)
|
||||
flush_func = (glyphs_flush_func)glamor_glyphs_flush_mask;
|
||||
flush_func =
|
||||
(glyphs_flush_func) glamor_glyphs_flush_mask;
|
||||
else
|
||||
flush_func = NULL;
|
||||
temp_arg = pmask_arg;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* If we are using global mask cache, then we need to
|
||||
* flush dst instead of mask. As some dst depends on the
|
||||
* previous mask result. Just flush mask can't get all previous's
|
||||
* overlapped glyphs.*/
|
||||
if (dst_buffer.count || mask_buffer.count)
|
||||
flush_func = (glyphs_flush_func)glamor_glyphs_flush_dst;
|
||||
flush_func =
|
||||
(glyphs_flush_func) glamor_glyphs_flush_dst;
|
||||
else
|
||||
flush_func = NULL;
|
||||
temp_arg = &dst_arg;
|
||||
|
@ -1510,8 +1513,7 @@ retry:
|
|||
0, 0,
|
||||
glyph->info.width, glyph->info.height,
|
||||
glyphs_dst_mode,
|
||||
flush_func,
|
||||
(void*)temp_arg);
|
||||
flush_func, (void *) temp_arg);
|
||||
}
|
||||
x += glyph->info.xOff;
|
||||
y += glyph->info.yOff;
|
||||
|
@ -1531,7 +1533,8 @@ retry:
|
|||
y_src + y - y_dst, 0, 0, x, y, width, height);
|
||||
FreePicture(mask, 0);
|
||||
glamor_destroy_pixmap(mask_pixmap);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
struct glamor_glyph priv;
|
||||
glyphs_flush_func flush_func;
|
||||
BoxPtr rects;
|
||||
|
@ -1556,7 +1559,8 @@ retry:
|
|||
|
||||
if (dst_buffer.source == NULL) {
|
||||
dst_buffer.source = cache->picture;
|
||||
} else if (dst_buffer.source != cache->picture) {
|
||||
}
|
||||
else if (dst_buffer.source != cache->picture) {
|
||||
glamor_glyphs_flush_dst(&dst_arg);
|
||||
dst_buffer.source = cache->picture;
|
||||
}
|
||||
|
@ -1577,9 +1581,7 @@ retry:
|
|||
0, 0,
|
||||
width, height,
|
||||
GLYPHS_DST_MODE_MASK_TO_DST,
|
||||
flush_func,
|
||||
(void *)&dst_arg
|
||||
);
|
||||
flush_func, (void *) &dst_arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1589,8 +1591,7 @@ glamor_glyphs_to_dst(CARD8 op,
|
|||
PicturePtr dst,
|
||||
INT16 x_src,
|
||||
INT16 y_src,
|
||||
int nlist, GlyphListPtr list,
|
||||
GlyphPtr * glyphs)
|
||||
int nlist, GlyphListPtr list, GlyphPtr * glyphs)
|
||||
{
|
||||
ScreenPtr screen = dst->pDrawable->pScreen;
|
||||
int x = 0, y = 0;
|
||||
|
@ -1626,8 +1627,7 @@ glamor_glyphs_to_dst(CARD8 op,
|
|||
while (n--) {
|
||||
glyph = *glyphs++;
|
||||
|
||||
if (glyph->info.width > 0
|
||||
&& glyph->info.height > 0) {
|
||||
if (glyph->info.width > 0 && glyph->info.height > 0) {
|
||||
glyphs_flush_func flush_func;
|
||||
|
||||
if (dst_buffer.count || mask_buffer.count)
|
||||
|
@ -1636,15 +1636,12 @@ glamor_glyphs_to_dst(CARD8 op,
|
|||
flush_func = NULL;
|
||||
glamor_buffer_glyph_clip(glamor_priv,
|
||||
rects, nrect,
|
||||
(GlyphPicture(glyph)[screen->myNum])->format,
|
||||
glyph, NULL,
|
||||
x, y,
|
||||
(GlyphPicture(glyph)[screen->myNum])->
|
||||
format, glyph, NULL, x, y,
|
||||
glyph->info.x, glyph->info.y,
|
||||
glyph->info.width, glyph->info.height,
|
||||
GLYPHS_DST_MODE_TO_DST,
|
||||
flush_func,
|
||||
(void *)&dst_arg
|
||||
);
|
||||
GLYPHS_DST_MODE_TO_DST, flush_func,
|
||||
(void *) &dst_arg);
|
||||
}
|
||||
|
||||
x += glyph->info.xOff;
|
||||
|
@ -1653,6 +1650,7 @@ glamor_glyphs_to_dst(CARD8 op,
|
|||
list++;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_FIXED_SIZE
|
||||
static void
|
||||
glamor_glyphs_reset_buffer(glamor_glyph_buffer_t * buffer)
|
||||
|
@ -1674,11 +1672,11 @@ _glamor_glyphs(CARD8 op,
|
|||
int fixed_size, fixed_cnt = 0;
|
||||
struct glamor_glyph_list *fixed_list = NULL;
|
||||
Bool need_free_list = FALSE;
|
||||
|
||||
#ifndef GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
|
||||
Bool check_fake_overlap = TRUE;
|
||||
if (!(op == PictOpOver
|
||||
|| op == PictOpAdd
|
||||
|| op == PictOpXor)) {
|
||||
|
||||
if (!(op == PictOpOver || op == PictOpAdd || op == PictOpXor)) {
|
||||
/* C = (0,0,0,0) D = glyphs , SRC = A, DEST = B (faked overlapped glyphs, overlapped with (0,0,0,0)).
|
||||
* For those op, (A IN (C ADD D)) OP B != (A IN D) OP ((A IN C) OP B)
|
||||
* or (A IN (D ADD C)) OP B != (A IN C) OP ((A IN D) OP B)
|
||||
|
@ -1698,9 +1696,10 @@ _glamor_glyphs(CARD8 op,
|
|||
glamor_glyphs_reset_buffer(&dst_buffer);
|
||||
|
||||
if (!mask_format || (((nlist == 1 && list->len == 1) || op == PictOpAdd)
|
||||
&& (dst->format == ((mask_format->depth << 24) | mask_format->format)))) {
|
||||
glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist,
|
||||
list, glyphs);
|
||||
&& (dst->format ==
|
||||
((mask_format->depth << 24) | mask_format->
|
||||
format)))) {
|
||||
glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist, list, glyphs);
|
||||
goto last_flush;
|
||||
}
|
||||
|
||||
|
@ -1725,13 +1724,14 @@ _glamor_glyphs(CARD8 op,
|
|||
glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist,
|
||||
list, glyphs);
|
||||
goto last_flush;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
glamor_glyphs_via_mask(op, src, dst, mask_format,
|
||||
x_src, y_src, nlist, list, glyphs,
|
||||
FALSE);
|
||||
x_src, y_src, nlist, list, glyphs, FALSE);
|
||||
goto free_fixed_list;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
/* We have splitted the original list to serval list, some are overlapped
|
||||
* and some are non-overlapped. For the non-overlapped, we render it to
|
||||
|
@ -1751,8 +1751,7 @@ _glamor_glyphs(CARD8 op,
|
|||
glamor_glyphs_to_dst(op, src, dst,
|
||||
x_src, y_src,
|
||||
fixed_list->nlist,
|
||||
fixed_list->list,
|
||||
fixed_list->glyphs);
|
||||
fixed_list->list, fixed_list->glyphs);
|
||||
}
|
||||
else
|
||||
glamor_glyphs_via_mask(op, src, dst,
|
||||
|
@ -1797,10 +1796,8 @@ glamor_glyphs_nf(CARD8 op,
|
|||
PicturePtr dst,
|
||||
PictFormatPtr mask_format,
|
||||
INT16 x_src,
|
||||
INT16 y_src, int nlist,
|
||||
GlyphListPtr list, GlyphPtr * glyphs)
|
||||
INT16 y_src, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
|
||||
{
|
||||
return _glamor_glyphs(op, src, dst, mask_format, x_src,
|
||||
y_src, nlist, list, glyphs, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
#ifdef GLAMOR_GRADIENT_SHADER
|
||||
|
||||
static GLint
|
||||
_glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, int use_array)
|
||||
_glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count,
|
||||
int use_array)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
@ -84,84 +85,7 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, int use_ar
|
|||
|
||||
/* Because the array access for shader is very slow, the performance is very low
|
||||
if use array. So use global uniform to replace for it if the number of n_stops is small. */
|
||||
const char *gradient_fs_getcolor_no_array =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"uniform int n_stop;\n"
|
||||
"uniform float stop0;\n"
|
||||
"uniform float stop1;\n"
|
||||
"uniform float stop2;\n"
|
||||
"uniform float stop3;\n"
|
||||
"uniform float stop4;\n"
|
||||
"uniform float stop5;\n"
|
||||
"uniform float stop6;\n"
|
||||
"uniform float stop7;\n"
|
||||
"uniform vec4 stop_color0;\n"
|
||||
"uniform vec4 stop_color1;\n"
|
||||
"uniform vec4 stop_color2;\n"
|
||||
"uniform vec4 stop_color3;\n"
|
||||
"uniform vec4 stop_color4;\n"
|
||||
"uniform vec4 stop_color5;\n"
|
||||
"uniform vec4 stop_color6;\n"
|
||||
"uniform vec4 stop_color7;\n"
|
||||
"\n"
|
||||
"vec4 get_color(float stop_len)\n"
|
||||
"{\n"
|
||||
" float stop_after;\n"
|
||||
" float stop_before;\n"
|
||||
" vec4 stop_color_before;\n"
|
||||
" vec4 stop_color_after;\n"
|
||||
" float new_alpha; \n"
|
||||
" vec4 gradient_color;\n"
|
||||
" float percentage; \n"
|
||||
" \n"
|
||||
" if((stop_len < stop0) && (n_stop >= 1)) {\n"
|
||||
" stop_color_before = stop_color0;\n"
|
||||
" stop_color_after = stop_color0;\n"
|
||||
" stop_after = stop0;\n"
|
||||
" stop_before = stop0;\n"
|
||||
" } else if((stop_len < stop1) && (n_stop >= 2)) {\n"
|
||||
" stop_color_before = stop_color0;\n"
|
||||
" stop_color_after = stop_color1;\n"
|
||||
" stop_after = stop1;\n"
|
||||
" stop_before = stop0;\n"
|
||||
" } else if((stop_len < stop2) && (n_stop >= 3)) {\n"
|
||||
" stop_color_before = stop_color1;\n"
|
||||
" stop_color_after = stop_color2;\n"
|
||||
" stop_after = stop2;\n"
|
||||
" stop_before = stop1;\n"
|
||||
" } else if((stop_len < stop3) && (n_stop >= 4)){\n"
|
||||
" stop_color_before = stop_color2;\n"
|
||||
" stop_color_after = stop_color3;\n"
|
||||
" stop_after = stop3;\n"
|
||||
" stop_before = stop2;\n"
|
||||
" } else if((stop_len < stop4) && (n_stop >= 5)){\n"
|
||||
" stop_color_before = stop_color3;\n"
|
||||
" stop_color_after = stop_color4;\n"
|
||||
" stop_after = stop4;\n"
|
||||
" stop_before = stop3;\n"
|
||||
" } else if((stop_len < stop5) && (n_stop >= 6)){\n"
|
||||
" stop_color_before = stop_color4;\n"
|
||||
" stop_color_after = stop_color5;\n"
|
||||
" stop_after = stop5;\n"
|
||||
" stop_before = stop4;\n"
|
||||
" } else if((stop_len < stop6) && (n_stop >= 7)){\n"
|
||||
" stop_color_before = stop_color5;\n"
|
||||
" stop_color_after = stop_color6;\n"
|
||||
" stop_after = stop6;\n"
|
||||
" stop_before = stop5;\n"
|
||||
" } else if((stop_len < stop7) && (n_stop >= 8)){\n"
|
||||
" stop_color_before = stop_color6;\n"
|
||||
" stop_color_after = stop_color7;\n"
|
||||
" stop_after = stop7;\n"
|
||||
" stop_before = stop6;\n"
|
||||
" } else {\n"
|
||||
" stop_color_before = stop_color7;\n"
|
||||
" stop_color_after = stop_color7;\n"
|
||||
" stop_after = stop7;\n"
|
||||
" stop_before = stop7;\n"
|
||||
" }\n"
|
||||
" if(stop_after - stop_before > 2.0)\n"
|
||||
" percentage = 0.0;\n"//For comply with pixman, walker->stepper overflow.
|
||||
const char *gradient_fs_getcolor_no_array = GLAMOR_DEFAULT_PRECISION "uniform int n_stop;\n" "uniform float stop0;\n" "uniform float stop1;\n" "uniform float stop2;\n" "uniform float stop3;\n" "uniform float stop4;\n" "uniform float stop5;\n" "uniform float stop6;\n" "uniform float stop7;\n" "uniform vec4 stop_color0;\n" "uniform vec4 stop_color1;\n" "uniform vec4 stop_color2;\n" "uniform vec4 stop_color3;\n" "uniform vec4 stop_color4;\n" "uniform vec4 stop_color5;\n" "uniform vec4 stop_color6;\n" "uniform vec4 stop_color7;\n" "\n" "vec4 get_color(float stop_len)\n" "{\n" " float stop_after;\n" " float stop_before;\n" " vec4 stop_color_before;\n" " vec4 stop_color_after;\n" " float new_alpha; \n" " vec4 gradient_color;\n" " float percentage; \n" " \n" " if((stop_len < stop0) && (n_stop >= 1)) {\n" " stop_color_before = stop_color0;\n" " stop_color_after = stop_color0;\n" " stop_after = stop0;\n" " stop_before = stop0;\n" " } else if((stop_len < stop1) && (n_stop >= 2)) {\n" " stop_color_before = stop_color0;\n" " stop_color_after = stop_color1;\n" " stop_after = stop1;\n" " stop_before = stop0;\n" " } else if((stop_len < stop2) && (n_stop >= 3)) {\n" " stop_color_before = stop_color1;\n" " stop_color_after = stop_color2;\n" " stop_after = stop2;\n" " stop_before = stop1;\n" " } else if((stop_len < stop3) && (n_stop >= 4)){\n" " stop_color_before = stop_color2;\n" " stop_color_after = stop_color3;\n" " stop_after = stop3;\n" " stop_before = stop2;\n" " } else if((stop_len < stop4) && (n_stop >= 5)){\n" " stop_color_before = stop_color3;\n" " stop_color_after = stop_color4;\n" " stop_after = stop4;\n" " stop_before = stop3;\n" " } else if((stop_len < stop5) && (n_stop >= 6)){\n" " stop_color_before = stop_color4;\n" " stop_color_after = stop_color5;\n" " stop_after = stop5;\n" " stop_before = stop4;\n" " } else if((stop_len < stop6) && (n_stop >= 7)){\n" " stop_color_before = stop_color5;\n" " stop_color_after = stop_color6;\n" " stop_after = stop6;\n" " stop_before = stop5;\n" " } else if((stop_len < stop7) && (n_stop >= 8)){\n" " stop_color_before = stop_color6;\n" " stop_color_after = stop_color7;\n" " stop_after = stop7;\n" " stop_before = stop6;\n" " } else {\n" " stop_color_before = stop_color7;\n" " stop_color_after = stop_color7;\n" " stop_after = stop7;\n" " stop_before = stop7;\n" " }\n" " if(stop_after - stop_before > 2.0)\n" " percentage = 0.0;\n" //For comply with pixman, walker->stepper overflow.
|
||||
" else if(stop_after - stop_before < 0.000001)\n"
|
||||
" percentage = 0.0;\n"
|
||||
" else \n"
|
||||
|
@ -171,9 +95,7 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, int use_ar
|
|||
" gradient_color = vec4((percentage * stop_color_after.rgb \n"
|
||||
" + (1.0-percentage) * stop_color_before.rgb)*new_alpha, \n"
|
||||
" new_alpha);\n"
|
||||
" \n"
|
||||
" return gradient_color;\n"
|
||||
"}\n";
|
||||
" \n" " return gradient_color;\n" "}\n";
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
@ -181,11 +103,13 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, int use_ar
|
|||
if (use_array) {
|
||||
XNFasprintf(&gradient_fs,
|
||||
gradient_fs_getcolor, stops_count, stops_count);
|
||||
fs_getcolor_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
gradient_fs);
|
||||
fs_getcolor_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, gradient_fs);
|
||||
free(gradient_fs);
|
||||
} else {
|
||||
fs_getcolor_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
}
|
||||
else {
|
||||
fs_getcolor_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
gradient_fs_getcolor_no_array);
|
||||
}
|
||||
|
||||
|
@ -193,7 +117,8 @@ _glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, int use_ar
|
|||
}
|
||||
|
||||
static void
|
||||
_glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dyn_gen)
|
||||
_glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count,
|
||||
int dyn_gen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
@ -212,8 +137,7 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dy
|
|||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" source_texture = v_texcoord.xy;\n"
|
||||
"}\n";
|
||||
" source_texture = v_texcoord.xy;\n" "}\n";
|
||||
|
||||
/*
|
||||
* Refer to pixman radial gradient.
|
||||
|
@ -354,30 +278,36 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dy
|
|||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
||||
if (dyn_gen && glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2]) {
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][2]);
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
radial_gradient_shaders
|
||||
[SHADER_GRADIENT_VS_PROG][2]);
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][2] = 0;
|
||||
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2]);
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] = 0;
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
radial_gradient_shaders
|
||||
[SHADER_GRADIENT_FS_MAIN_PROG][2]);
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] =
|
||||
0;
|
||||
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
radial_gradient_shaders
|
||||
[SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
|
||||
glamor_priv->
|
||||
radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
|
||||
|
||||
dispatch->glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2]);
|
||||
dispatch->glDeleteProgram(glamor_priv->
|
||||
gradient_prog[SHADER_GRADIENT_RADIAL][2]);
|
||||
glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2] = 0;
|
||||
}
|
||||
|
||||
gradient_prog = dispatch->glCreateProgram();
|
||||
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch,
|
||||
GL_VERTEX_SHADER, gradient_vs);
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, gradient_vs);
|
||||
|
||||
XNFasprintf(&gradient_fs,
|
||||
gradient_radial_fs_template,
|
||||
PIXMAN_REPEAT_NONE, PIXMAN_REPEAT_NORMAL, PIXMAN_REPEAT_REFLECT);
|
||||
PIXMAN_REPEAT_NONE, PIXMAN_REPEAT_NORMAL,
|
||||
PIXMAN_REPEAT_REFLECT);
|
||||
|
||||
fs_main_prog = glamor_compile_glsl_prog(dispatch,
|
||||
GL_FRAGMENT_SHADER, gradient_fs);
|
||||
|
@ -385,14 +315,17 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dy
|
|||
free(gradient_fs);
|
||||
|
||||
fs_getcolor_prog =
|
||||
_glamor_create_getcolor_fs_program(screen, stops_count, (stops_count > 0));
|
||||
_glamor_create_getcolor_fs_program(screen, stops_count,
|
||||
(stops_count > 0));
|
||||
|
||||
dispatch->glAttachShader(gradient_prog, vs_prog);
|
||||
dispatch->glAttachShader(gradient_prog, fs_getcolor_prog);
|
||||
dispatch->glAttachShader(gradient_prog, fs_main_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_positionsition");
|
||||
dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
|
||||
dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS,
|
||||
"v_positionsition");
|
||||
dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord");
|
||||
|
||||
glamor_link_glsl_prog(dispatch, gradient_prog);
|
||||
|
||||
|
@ -401,22 +334,29 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dy
|
|||
if (dyn_gen) {
|
||||
index = 2;
|
||||
glamor_priv->radial_max_nstops = stops_count;
|
||||
} else if (stops_count) {
|
||||
}
|
||||
else if (stops_count) {
|
||||
index = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][index] = gradient_prog;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][index] = vs_prog;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][index] = fs_main_prog;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][index] = fs_getcolor_prog;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][index] =
|
||||
vs_prog;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][index] =
|
||||
fs_main_prog;
|
||||
glamor_priv->
|
||||
radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][index] =
|
||||
fs_getcolor_prog;
|
||||
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
static void
|
||||
_glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, int dyn_gen)
|
||||
_glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count,
|
||||
int dyn_gen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
@ -435,8 +375,7 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, int dy
|
|||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" source_texture = v_texcoord.xy;\n"
|
||||
"}\n";
|
||||
" source_texture = v_texcoord.xy;\n" "}\n";
|
||||
|
||||
/*
|
||||
* |
|
||||
|
@ -578,26 +517,31 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, int dy
|
|||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
if (dyn_gen && glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2]) {
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][2]);
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
linear_gradient_shaders
|
||||
[SHADER_GRADIENT_VS_PROG][2]);
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][2] = 0;
|
||||
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2]);
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] = 0;
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
linear_gradient_shaders
|
||||
[SHADER_GRADIENT_FS_MAIN_PROG][2]);
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] =
|
||||
0;
|
||||
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
linear_gradient_shaders
|
||||
[SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
|
||||
glamor_priv->
|
||||
linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
|
||||
|
||||
dispatch->glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2]);
|
||||
dispatch->glDeleteProgram(glamor_priv->
|
||||
gradient_prog[SHADER_GRADIENT_LINEAR][2]);
|
||||
glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2] = 0;
|
||||
}
|
||||
|
||||
gradient_prog = dispatch->glCreateProgram();
|
||||
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch,
|
||||
GL_VERTEX_SHADER, gradient_vs);
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, gradient_vs);
|
||||
|
||||
XNFasprintf(&gradient_fs,
|
||||
gradient_fs_template,
|
||||
|
@ -608,14 +552,17 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, int dy
|
|||
free(gradient_fs);
|
||||
|
||||
fs_getcolor_prog =
|
||||
_glamor_create_getcolor_fs_program(screen, stops_count, (stops_count > 0));
|
||||
_glamor_create_getcolor_fs_program(screen, stops_count,
|
||||
(stops_count > 0));
|
||||
|
||||
dispatch->glAttachShader(gradient_prog, vs_prog);
|
||||
dispatch->glAttachShader(gradient_prog, fs_getcolor_prog);
|
||||
dispatch->glAttachShader(gradient_prog, fs_main_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
|
||||
dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS,
|
||||
"v_position");
|
||||
dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord");
|
||||
|
||||
glamor_link_glsl_prog(dispatch, gradient_prog);
|
||||
|
||||
|
@ -624,16 +571,22 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, int dy
|
|||
if (dyn_gen) {
|
||||
index = 2;
|
||||
glamor_priv->linear_max_nstops = stops_count;
|
||||
} else if (stops_count) {
|
||||
}
|
||||
else if (stops_count) {
|
||||
index = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][index] = gradient_prog;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][index] = vs_prog;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][index] = fs_main_prog;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][index] = fs_getcolor_prog;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][index] =
|
||||
vs_prog;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][index] =
|
||||
fs_main_prog;
|
||||
glamor_priv->
|
||||
linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][index] =
|
||||
fs_getcolor_prog;
|
||||
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
@ -649,13 +602,17 @@ glamor_init_gradient_shader(ScreenPtr screen)
|
|||
for (i = 0; i < 3; i++) {
|
||||
glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][i] = 0;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][i] = 0;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i] = 0;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i] = 0;
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i] =
|
||||
0;
|
||||
glamor_priv->
|
||||
linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i] = 0;
|
||||
|
||||
glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][i] = 0;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][i] = 0;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i] = 0;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i] = 0;
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i] =
|
||||
0;
|
||||
glamor_priv->
|
||||
radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i] = 0;
|
||||
}
|
||||
glamor_priv->linear_max_nstops = 0;
|
||||
glamor_priv->radial_max_nstops = 0;
|
||||
|
@ -680,35 +637,47 @@ glamor_fini_gradient_shader(ScreenPtr screen)
|
|||
for (i = 0; i < 3; i++) {
|
||||
/* Linear Gradient */
|
||||
if (glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][i])
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][i]);
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
linear_gradient_shaders
|
||||
[SHADER_GRADIENT_VS_PROG][i]);
|
||||
|
||||
if (glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i])
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i]);
|
||||
if (glamor_priv->
|
||||
linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i])
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
linear_gradient_shaders
|
||||
[SHADER_GRADIENT_FS_MAIN_PROG][i]);
|
||||
|
||||
if (glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i])
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
|
||||
if (glamor_priv->
|
||||
linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i])
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
linear_gradient_shaders
|
||||
[SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
|
||||
|
||||
if (glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][i])
|
||||
dispatch->glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][i]);
|
||||
dispatch->glDeleteProgram(glamor_priv->
|
||||
gradient_prog[SHADER_GRADIENT_LINEAR][i]);
|
||||
|
||||
/* Radial Gradient */
|
||||
if (glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][i])
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][i]);
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
radial_gradient_shaders
|
||||
[SHADER_GRADIENT_VS_PROG][i]);
|
||||
|
||||
if (glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i])
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i]);
|
||||
if (glamor_priv->
|
||||
radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i])
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
radial_gradient_shaders
|
||||
[SHADER_GRADIENT_FS_MAIN_PROG][i]);
|
||||
|
||||
if (glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i])
|
||||
dispatch->glDeleteShader(
|
||||
glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
|
||||
if (glamor_priv->
|
||||
radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i])
|
||||
dispatch->glDeleteShader(glamor_priv->
|
||||
radial_gradient_shaders
|
||||
[SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
|
||||
|
||||
if (glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][i])
|
||||
dispatch->glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][i]);
|
||||
dispatch->glDeleteProgram(glamor_priv->
|
||||
gradient_prog[SHADER_GRADIENT_RADIAL][i]);
|
||||
}
|
||||
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
@ -770,8 +739,7 @@ _glamor_gradient_convert_trans_matrix(PictTransform *from, float to[3][3],
|
|||
|
||||
DEBUGF("the transform matrix is:\n%f\t%f\t%f\n%f\t%f\t%f\n%f\t%f\t%f\n",
|
||||
to[0][0], to[0][1], to[0][2],
|
||||
to[1][0], to[1][1], to[1][2],
|
||||
to[2][0], to[2][1], to[2][2]);
|
||||
to[1][0], to[1][1], to[1][2], to[2][0], to[2][1], to[2][2]);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -806,23 +774,33 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
|
|||
|
||||
glamor_set_normalize_vcoords_tri_strip(*xscale, *yscale,
|
||||
0, 0,
|
||||
(INT16)(dst_picture->pDrawable->width),
|
||||
(INT16)(dst_picture->pDrawable->height),
|
||||
(INT16) (dst_picture->pDrawable->
|
||||
width),
|
||||
(INT16) (dst_picture->pDrawable->
|
||||
height),
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
if (tex_normalize) {
|
||||
glamor_set_normalize_tcoords_tri_stripe(*xscale, *yscale,
|
||||
x_source, y_source,
|
||||
(INT16)(dst_picture->pDrawable->width + x_source),
|
||||
(INT16)(dst_picture->pDrawable->height + y_source),
|
||||
glamor_priv->yInverted, tex_vertices);
|
||||
} else {
|
||||
(INT16) (dst_picture->
|
||||
pDrawable->width +
|
||||
x_source),
|
||||
(INT16) (dst_picture->
|
||||
pDrawable->height +
|
||||
y_source),
|
||||
glamor_priv->yInverted,
|
||||
tex_vertices);
|
||||
}
|
||||
else {
|
||||
glamor_set_tcoords_tri_strip((INT16) (dst_picture->pDrawable->width),
|
||||
(INT16) (dst_picture->pDrawable->height),
|
||||
x_source, y_source,
|
||||
(INT16)(dst_picture->pDrawable->width) + x_source,
|
||||
(INT16)(dst_picture->pDrawable->height) + y_source,
|
||||
glamor_priv->yInverted, tex_vertices);
|
||||
(INT16) (dst_picture->pDrawable->width) +
|
||||
x_source,
|
||||
(INT16) (dst_picture->pDrawable->height) +
|
||||
y_source, glamor_priv->yInverted,
|
||||
tex_vertices);
|
||||
}
|
||||
|
||||
DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
|
||||
|
@ -857,17 +835,17 @@ _glamor_gradient_set_stops(PicturePtr src_picture, PictGradient * pgradient,
|
|||
int count = 1;
|
||||
|
||||
for (i = 0; i < pgradient->nstops; i++) {
|
||||
stop_colors[count*4] = pixman_fixed_to_double(
|
||||
pgradient->stops[i].color.red);
|
||||
stop_colors[count*4+1] = pixman_fixed_to_double(
|
||||
pgradient->stops[i].color.green);
|
||||
stop_colors[count*4+2] = pixman_fixed_to_double(
|
||||
pgradient->stops[i].color.blue);
|
||||
stop_colors[count*4+3] = pixman_fixed_to_double(
|
||||
pgradient->stops[i].color.alpha);
|
||||
stop_colors[count * 4] =
|
||||
pixman_fixed_to_double(pgradient->stops[i].color.red);
|
||||
stop_colors[count * 4 + 1] =
|
||||
pixman_fixed_to_double(pgradient->stops[i].color.green);
|
||||
stop_colors[count * 4 + 2] =
|
||||
pixman_fixed_to_double(pgradient->stops[i].color.blue);
|
||||
stop_colors[count * 4 + 3] =
|
||||
pixman_fixed_to_double(pgradient->stops[i].color.alpha);
|
||||
|
||||
n_stops[count] = (GLfloat)pixman_fixed_to_double(
|
||||
pgradient->stops[i].x);
|
||||
n_stops[count] =
|
||||
(GLfloat) pixman_fixed_to_double(pgradient->stops[i].x);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -952,7 +930,8 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
float transform_mat[3][3];
|
||||
static const float identity_mat[3][3] = { {1.0, 0.0, 0.0},
|
||||
{0.0, 1.0, 0.0},
|
||||
{0.0, 0.0, 1.0}};
|
||||
{0.0, 0.0, 1.0}
|
||||
};
|
||||
GLfloat stop_colors_st[RADIAL_SMALL_STOPS * 4];
|
||||
GLfloat n_stops_st[RADIAL_SMALL_STOPS];
|
||||
GLfloat A_value;
|
||||
|
@ -992,15 +971,15 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
/* Create a pixmap with VBO. */
|
||||
pixmap = glamor_create_pixmap(screen,
|
||||
width, height,
|
||||
PIXMAN_FORMAT_DEPTH(format),
|
||||
0);
|
||||
PIXMAN_FORMAT_DEPTH(format), 0);
|
||||
if (!pixmap)
|
||||
goto GRADIENT_FAIL;
|
||||
|
||||
dst_picture = CreatePicture(0, &pixmap->drawable,
|
||||
PictureMatchFormat(screen,
|
||||
PIXMAN_FORMAT_DEPTH(format), format),
|
||||
0, 0, serverClient, &error);
|
||||
PIXMAN_FORMAT_DEPTH(format),
|
||||
format), 0, 0, serverClient,
|
||||
&error);
|
||||
|
||||
/* Release the reference, picture will hold the last one. */
|
||||
glamor_destroy_pixmap(pixmap);
|
||||
|
@ -1016,12 +995,14 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
when nstops > LINEAR_LARGE_STOPS. */
|
||||
if (stops_count <= RADIAL_SMALL_STOPS) {
|
||||
gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][0];
|
||||
} else if (stops_count <= RADIAL_LARGE_STOPS) {
|
||||
}
|
||||
else if (stops_count <= RADIAL_LARGE_STOPS) {
|
||||
gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][1];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
_glamor_create_radial_gradient_program(screen,
|
||||
src_picture->pSourcePict->linear.nstops + 2,
|
||||
1);
|
||||
src_picture->pSourcePict->linear.
|
||||
nstops + 2, 1);
|
||||
gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2];
|
||||
}
|
||||
|
||||
|
@ -1036,14 +1017,10 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
dispatch->glGetUniformLocation(gradient_prog, "A_value");
|
||||
repeat_type_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "repeat_type");
|
||||
c1_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "c1");
|
||||
r1_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "r1");
|
||||
c2_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "c2");
|
||||
r2_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "r2");
|
||||
c1_uniform_location = dispatch->glGetUniformLocation(gradient_prog, "c1");
|
||||
r1_uniform_location = dispatch->glGetUniformLocation(gradient_prog, "r1");
|
||||
c2_uniform_location = dispatch->glGetUniformLocation(gradient_prog, "c2");
|
||||
r2_uniform_location = dispatch->glGetUniformLocation(gradient_prog, "r2");
|
||||
|
||||
if (src_picture->pSourcePict->radial.nstops + 2 <= RADIAL_SMALL_STOPS) {
|
||||
stop0_uniform_location =
|
||||
|
@ -1079,7 +1056,8 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
dispatch->glGetUniformLocation(gradient_prog, "stop_color6");
|
||||
stop_color7_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "stop_color7");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
stops_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "stops");
|
||||
stop_colors_uniform_location =
|
||||
|
@ -1088,22 +1066,22 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
|
||||
dispatch->glUseProgram(gradient_prog);
|
||||
|
||||
dispatch->glUniform1i(repeat_type_uniform_location, src_picture->repeatType);
|
||||
|
||||
dispatch->glUniform1i(repeat_type_uniform_location,
|
||||
src_picture->repeatType);
|
||||
|
||||
if (src_picture->transform) {
|
||||
_glamor_gradient_convert_trans_matrix(src_picture->transform,
|
||||
transform_mat,
|
||||
width, height, 0);
|
||||
transform_mat, width, height, 0);
|
||||
dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
|
||||
1, 1, &transform_mat[0][0]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
|
||||
1, 1, &identity_mat[0][0]);
|
||||
}
|
||||
|
||||
if (!_glamor_gradient_set_pixmap_destination(screen, glamor_priv, dst_picture,
|
||||
&xscale, &yscale, x_source, y_source,
|
||||
if (!_glamor_gradient_set_pixmap_destination
|
||||
(screen, glamor_priv, dst_picture, &xscale, &yscale, x_source, y_source,
|
||||
vertices, tex_vertices, 0))
|
||||
goto GRADIENT_FAIL;
|
||||
|
||||
|
@ -1120,16 +1098,20 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
ErrorF("Failed to allocate n_stops memory.\n");
|
||||
goto GRADIENT_FAIL;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
stop_colors = stop_colors_st;
|
||||
n_stops = n_stops_st;
|
||||
}
|
||||
|
||||
count = _glamor_gradient_set_stops(src_picture, &src_picture->pSourcePict->gradient,
|
||||
count =
|
||||
_glamor_gradient_set_stops(src_picture,
|
||||
&src_picture->pSourcePict->gradient,
|
||||
stop_colors, n_stops);
|
||||
|
||||
if (src_picture->pSourcePict->linear.nstops + 2 <= RADIAL_SMALL_STOPS) {
|
||||
int j = 0;
|
||||
|
||||
dispatch->glUniform4f(stop_color0_uniform_location,
|
||||
stop_colors[4 * j + 0], stop_colors[4 * j + 1],
|
||||
stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
|
||||
|
@ -1172,8 +1154,10 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
dispatch->glUniform1f(stop6_uniform_location, n_stops[j++]);
|
||||
dispatch->glUniform1f(stop7_uniform_location, n_stops[j++]);
|
||||
dispatch->glUniform1i(n_stop_uniform_location, count);
|
||||
} else {
|
||||
dispatch->glUniform4fv(stop_colors_uniform_location, count, stop_colors);
|
||||
}
|
||||
else {
|
||||
dispatch->glUniform4fv(stop_colors_uniform_location, count,
|
||||
stop_colors);
|
||||
dispatch->glUniform1fv(stops_uniform_location, count, n_stops);
|
||||
dispatch->glUniform1i(n_stop_uniform_location, count);
|
||||
}
|
||||
|
@ -1183,18 +1167,25 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
|
|||
c2x = (float) pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.x);
|
||||
c2y = (float) pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.y);
|
||||
|
||||
r1 = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c1.radius);
|
||||
r2 = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.radius);
|
||||
r1 = (float) pixman_fixed_to_double(src_picture->pSourcePict->radial.c1.
|
||||
radius);
|
||||
r2 = (float) pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.
|
||||
radius);
|
||||
|
||||
glamor_set_circle_centre(width, height, c1x, c1y, glamor_priv->yInverted, cxy);
|
||||
glamor_set_circle_centre(width, height, c1x, c1y, glamor_priv->yInverted,
|
||||
cxy);
|
||||
dispatch->glUniform2fv(c1_uniform_location, 1, cxy);
|
||||
dispatch->glUniform1f(r1_uniform_location, r1);
|
||||
|
||||
glamor_set_circle_centre(width, height, c2x, c2y, glamor_priv->yInverted, cxy);
|
||||
glamor_set_circle_centre(width, height, c2x, c2y, glamor_priv->yInverted,
|
||||
cxy);
|
||||
dispatch->glUniform2fv(c2_uniform_location, 1, cxy);
|
||||
dispatch->glUniform1f(r2_uniform_location, r2);
|
||||
|
||||
A_value = (c2x - c1x) * (c2x - c1x) + (c2y - c1y) * (c2y - c1y) - (r2 - r1) * (r2 - r1);
|
||||
A_value =
|
||||
(c2x - c1x) * (c2x - c1x) + (c2y - c1y) * (c2y - c1y) - (r2 -
|
||||
r1) * (r2 -
|
||||
r1);
|
||||
dispatch->glUniform1f(A_value_uniform_location, A_value);
|
||||
|
||||
DEBUGF("C1:(%f, %f) R1:%f\nC2:(%f, %f) R2:%f\nA = %f\n",
|
||||
|
@ -1269,7 +1260,8 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
float transform_mat[3][3];
|
||||
static const float identity_mat[3][3] = { {1.0, 0.0, 0.0},
|
||||
{0.0, 1.0, 0.0},
|
||||
{0.0, 0.0, 1.0}};
|
||||
{0.0, 0.0, 1.0}
|
||||
};
|
||||
GLfloat stop_colors_st[LINEAR_SMALL_STOPS * 4];
|
||||
GLfloat n_stops_st[LINEAR_SMALL_STOPS];
|
||||
|
||||
|
@ -1306,16 +1298,16 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
/* Create a pixmap with VBO. */
|
||||
pixmap = glamor_create_pixmap(screen,
|
||||
width, height,
|
||||
PIXMAN_FORMAT_DEPTH(format),
|
||||
0);
|
||||
PIXMAN_FORMAT_DEPTH(format), 0);
|
||||
|
||||
if (!pixmap)
|
||||
goto GRADIENT_FAIL;
|
||||
|
||||
dst_picture = CreatePicture(0, &pixmap->drawable,
|
||||
PictureMatchFormat(screen,
|
||||
PIXMAN_FORMAT_DEPTH(format), format),
|
||||
0, 0, serverClient, &error);
|
||||
PIXMAN_FORMAT_DEPTH(format),
|
||||
format), 0, 0, serverClient,
|
||||
&error);
|
||||
|
||||
/* Release the reference, picture will hold the last one. */
|
||||
glamor_destroy_pixmap(pixmap);
|
||||
|
@ -1331,11 +1323,14 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
when nstops > LINEAR_LARGE_STOPS. */
|
||||
if (stops_count <= LINEAR_SMALL_STOPS) {
|
||||
gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][0];
|
||||
} else if (stops_count <= LINEAR_LARGE_STOPS) {
|
||||
}
|
||||
else if (stops_count <= LINEAR_LARGE_STOPS) {
|
||||
gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][1];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
_glamor_create_linear_gradient_program(screen,
|
||||
src_picture->pSourcePict->linear.nstops + 2, 1);
|
||||
src_picture->pSourcePict->linear.
|
||||
nstops + 2, 1);
|
||||
gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2];
|
||||
}
|
||||
|
||||
|
@ -1391,7 +1386,8 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
dispatch->glGetUniformLocation(gradient_prog, "stop_color6");
|
||||
stop_color7_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "stop_color7");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
stops_uniform_location =
|
||||
dispatch->glGetUniformLocation(gradient_prog, "stops");
|
||||
stop_colors_uniform_location =
|
||||
|
@ -1400,41 +1396,48 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
|
||||
dispatch->glUseProgram(gradient_prog);
|
||||
|
||||
dispatch->glUniform1i(repeat_type_uniform_location, src_picture->repeatType);
|
||||
dispatch->glUniform1i(repeat_type_uniform_location,
|
||||
src_picture->repeatType);
|
||||
|
||||
/* set the transform matrix. */
|
||||
if (src_picture->transform) {
|
||||
_glamor_gradient_convert_trans_matrix(src_picture->transform,
|
||||
transform_mat,
|
||||
width, height, 1);
|
||||
transform_mat, width, height, 1);
|
||||
dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
|
||||
1, 1, &transform_mat[0][0]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
|
||||
1, 1, &identity_mat[0][0]);
|
||||
}
|
||||
|
||||
if (!_glamor_gradient_set_pixmap_destination(screen, glamor_priv, dst_picture,
|
||||
&xscale, &yscale, x_source, y_source,
|
||||
if (!_glamor_gradient_set_pixmap_destination
|
||||
(screen, glamor_priv, dst_picture, &xscale, &yscale, x_source, y_source,
|
||||
vertices, tex_vertices, 1))
|
||||
goto GRADIENT_FAIL;
|
||||
|
||||
/* Normalize the PTs. */
|
||||
glamor_set_normalize_pt(xscale, yscale,
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->
|
||||
linear.p1.x),
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->
|
||||
linear.p1.y),
|
||||
glamor_priv->yInverted, pt1);
|
||||
DEBUGF("pt1:(%f, %f) ---> (%f %f)\n",
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.x),
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.y),
|
||||
glamor_priv->yInverted,
|
||||
pt1);
|
||||
DEBUGF("pt1:(%f, %f) ---> (%f %f)\n", pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.x),
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.y), pt1[0], pt1[1]);
|
||||
pt1[0], pt1[1]);
|
||||
|
||||
glamor_set_normalize_pt(xscale, yscale,
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->
|
||||
linear.p2.x),
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->
|
||||
linear.p2.y),
|
||||
glamor_priv->yInverted, pt2);
|
||||
DEBUGF("pt2:(%f, %f) ---> (%f %f)\n",
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.x),
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.y),
|
||||
glamor_priv->yInverted,
|
||||
pt2);
|
||||
DEBUGF("pt2:(%f, %f) ---> (%f %f)\n", pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.x),
|
||||
pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.y), pt2[0], pt2[1]);
|
||||
pt2[0], pt2[1]);
|
||||
|
||||
/* Set all the stops and colors to shader. */
|
||||
if (stops_count > LINEAR_SMALL_STOPS) {
|
||||
|
@ -1449,16 +1452,20 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
ErrorF("Failed to allocate n_stops memory.\n");
|
||||
goto GRADIENT_FAIL;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
stop_colors = stop_colors_st;
|
||||
n_stops = n_stops_st;
|
||||
}
|
||||
|
||||
count = _glamor_gradient_set_stops(src_picture, &src_picture->pSourcePict->gradient,
|
||||
count =
|
||||
_glamor_gradient_set_stops(src_picture,
|
||||
&src_picture->pSourcePict->gradient,
|
||||
stop_colors, n_stops);
|
||||
|
||||
if (src_picture->pSourcePict->linear.nstops + 2 <= LINEAR_SMALL_STOPS) {
|
||||
int j = 0;
|
||||
|
||||
dispatch->glUniform4f(stop_color0_uniform_location,
|
||||
stop_colors[4 * j + 0], stop_colors[4 * j + 1],
|
||||
stop_colors[4 * j + 2], stop_colors[4 * j + 3]);
|
||||
|
@ -1502,14 +1509,15 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
dispatch->glUniform1f(stop7_uniform_location, n_stops[j++]);
|
||||
|
||||
dispatch->glUniform1i(n_stop_uniform_location, count);
|
||||
} else {
|
||||
dispatch->glUniform4fv(stop_colors_uniform_location, count, stop_colors);
|
||||
}
|
||||
else {
|
||||
dispatch->glUniform4fv(stop_colors_uniform_location, count,
|
||||
stop_colors);
|
||||
dispatch->glUniform1fv(stops_uniform_location, count, n_stops);
|
||||
dispatch->glUniform1i(n_stop_uniform_location, count);
|
||||
}
|
||||
|
||||
if (src_picture->pSourcePict->linear.p2.y ==
|
||||
src_picture->pSourcePict->linear.p1.y) { // The horizontal case.
|
||||
if (src_picture->pSourcePict->linear.p2.y == src_picture->pSourcePict->linear.p1.y) { // The horizontal case.
|
||||
dispatch->glUniform1i(hor_ver_uniform_location, 1);
|
||||
DEBUGF("p1.y: %f, p2.y: %f, enter the horizontal case\n",
|
||||
pt1[1], pt2[1]);
|
||||
|
@ -1518,7 +1526,8 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
|
|||
pt_distance = (pt2[0] - p1_distance);
|
||||
dispatch->glUniform1f(p1_distance_uniform_location, p1_distance);
|
||||
dispatch->glUniform1f(pt_distance_uniform_location, pt_distance);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* The slope need to compute here. In shader, the viewport set will change
|
||||
the orginal slope and the slope which is vertical to it will not be correct. */
|
||||
slope = -(float) (src_picture->pSourcePict->linear.p2.x
|
||||
|
|
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);
|
||||
}
|
||||
|
@ -86,8 +86,7 @@ glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private * pixmap_priv)
|
|||
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;
|
||||
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;
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
@ -495,14 +494,13 @@ 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))
|
||||
|
@ -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 {
|
||||
}
|
||||
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,38 +978,33 @@ _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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
}
|
||||
else {
|
||||
temp_bits = sub_bits;
|
||||
}
|
||||
DEBUGF("download x %d y %d w %d h %d temp stride %d \n",
|
||||
|
@ -1144,11 +1119,11 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
|
|||
|
||||
/* 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);
|
||||
|
@ -1168,12 +1143,13 @@ 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.
|
||||
|
@ -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)
|
||||
|
@ -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,7 +1270,8 @@ 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:
|
||||
if (gc)
|
||||
|
@ -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,8 +1352,10 @@ 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);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -91,8 +90,7 @@ _glamor_poly_fill_rect(DrawablePtr drawable,
|
|||
|
||||
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;
|
||||
|
||||
|
@ -111,7 +109,6 @@ done:
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle *prect)
|
||||
|
|
|
@ -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,7 +112,8 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
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;
|
||||
|
||||
|
@ -60,8 +59,7 @@ static Bool
|
|||
_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
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,8 +69,7 @@ _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);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
@ -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)
|
||||
{
|
||||
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,
|
||||
|
@ -556,12 +550,15 @@ 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);
|
||||
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);
|
||||
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);
|
||||
|
@ -571,16 +568,16 @@ 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);
|
||||
|
||||
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);
|
||||
|
||||
/* 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,6 +699,7 @@ void glamor_fini_putimage_shaders(ScreenPtr screen);
|
|||
|
||||
/* glamor_render.c */
|
||||
Bool
|
||||
|
||||
glamor_composite_clipped_region(CARD8 op,
|
||||
PicturePtr source,
|
||||
PicturePtr mask,
|
||||
|
@ -715,10 +710,7 @@ glamor_composite_clipped_region(CARD8 op,
|
|||
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,
|
||||
|
@ -738,9 +730,7 @@ void glamor_composite_glyph_rects(CARD8 op,
|
|||
glamor_composite_rect_t * rects);
|
||||
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,
|
||||
|
@ -761,6 +751,7 @@ Bool glamor_composite_choose_shader(CARD8 op,
|
|||
PictFormatShort * psaved_source_format);
|
||||
|
||||
void
|
||||
|
||||
glamor_composite_set_shader_blend(glamor_pixmap_private * dest_priv,
|
||||
struct shader_key *key,
|
||||
glamor_composite_shader * shader,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
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;
|
||||
|
@ -232,8 +225,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
drawable, glamor_get_drawable_location(drawable));
|
||||
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:
|
||||
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",
|
||||
|
@ -332,11 +325,11 @@ fail:
|
|||
|
||||
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
|
||||
}
|
||||
else
|
||||
fbPutImage(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits);
|
||||
ret = TRUE;
|
||||
|
@ -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);
|
||||
|
@ -78,8 +81,7 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
goto done;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
|
@ -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,
|
||||
|
|
|
@ -42,6 +42,7 @@ _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);
|
||||
|
@ -53,6 +54,7 @@ _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);
|
||||
|
@ -86,8 +88,10 @@ _glamor_lines_crossfixedY (xLineFixed *l, xLineFixed *r)
|
|||
xFixed_32_32 divisor;
|
||||
|
||||
tmp = (xFixed_32_32) dx1 *dy2;
|
||||
|
||||
dividend2 = (tmp >> 32) * l->p1.y;
|
||||
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;
|
||||
|
@ -103,6 +107,7 @@ 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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -246,7 +249,8 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -457,6 +469,7 @@ _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)]
|
||||
|
@ -518,7 +531,9 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
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) (vertex[2 * i + 1] -
|
||||
vertex[1]) / (float) (vertex[2 * i] -
|
||||
vertex[0])
|
||||
: (float) INT_MAX);
|
||||
}
|
||||
|
||||
|
@ -526,8 +541,7 @@ _glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
|
|||
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,6 +550,7 @@ _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];
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -633,25 +647,29 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
|
|||
|
||||
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);
|
||||
|
@ -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.
|
||||
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;
|
||||
|
@ -856,7 +874,8 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
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;
|
||||
|
@ -864,21 +883,24 @@ _glamor_trapezoids_with_shader(CARD8 op,
|
|||
|
||||
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];
|
||||
|
||||
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];
|
||||
|
||||
|
@ -888,27 +910,28 @@ NTRAPS_LOOP_AGAIN:
|
|||
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);
|
||||
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;
|
||||
}
|
||||
|
@ -971,7 +995,8 @@ TRAPEZOID_OUT:
|
|||
|
||||
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,18 +1465,16 @@ _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],
|
||||
"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]);
|
||||
|
||||
|
@ -1467,13 +1487,15 @@ _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],
|
||||
"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;
|
||||
|
@ -1491,7 +1513,8 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
if (ptrap->left.p1.x == ptrap->left.p2.x) {
|
||||
left_slope = 0.0;
|
||||
params[3] = 1.0;
|
||||
} else {
|
||||
}
|
||||
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;
|
||||
|
@ -1507,7 +1530,8 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
|
|||
if (ptrap->right.p1.x == ptrap->right.p2.x) {
|
||||
right_slope = 0.0;
|
||||
params[3] = 1.0;
|
||||
} else {
|
||||
}
|
||||
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;
|
||||
|
@ -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);
|
||||
|
@ -1614,6 +1640,7 @@ static int
|
|||
_glamor_trapezoid_bounds(int ntrap, xTrapezoid * traps, BoxPtr box)
|
||||
{
|
||||
int has_large_trapezoid = 0;
|
||||
|
||||
box->y1 = MAXSHORT;
|
||||
box->y2 = MINSHORT;
|
||||
box->x1 = MAXSHORT;
|
||||
|
@ -1632,13 +1659,18 @@ _glamor_trapezoid_bounds (int ntrap, xTrapezoid *traps, BoxPtr box)
|
|||
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);
|
||||
|
@ -1720,12 +1750,14 @@ _glamor_trapezoids(CARD8 op,
|
|||
x_src, y_src, ntrap, traps);
|
||||
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;
|
||||
|
@ -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,13 +1395,15 @@ 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;
|
||||
|
@ -1405,8 +1411,7 @@ static inline void _glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int
|
|||
|
||||
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));
|
||||
|
@ -1415,7 +1420,8 @@ static inline void _glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1423,8 +1429,7 @@ static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int
|
|||
|
||||
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("%2x ", p[j]);
|
||||
|
@ -1433,7 +1438,8 @@ static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1441,8 +1447,7 @@ static inline void _glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int
|
|||
|
||||
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("%2x ", p[j]);
|
||||
|
@ -1451,7 +1456,8 @@ static inline void _glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1459,8 +1465,7 @@ static inline void _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int
|
|||
|
||||
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("%2x ", p[j]);
|
||||
|
@ -1469,7 +1474,8 @@ static inline void _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int
|
|||
}
|
||||
}
|
||||
|
||||
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,10 +1503,10 @@ 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;
|
||||
|
@ -1534,7 +1540,8 @@ 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;
|
||||
little_endian = (*p_test == 0xDD);
|
||||
|
@ -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,35 +1783,53 @@ 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)
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
* Screen Change Window Attribute implementation.
|
||||
*/
|
||||
|
||||
|
||||
static void
|
||||
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
|
||||
{
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -60,8 +59,7 @@ 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,11 +121,11 @@ 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"},
|
||||
|
@ -140,15 +136,13 @@ static XF86AttributeRec Attributes_glamor[NUM_ATTRIBUTES+1] =
|
|||
|
||||
#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] =
|
||||
{
|
||||
static XF86ImageRec Images[NUM_IMAGES] = {
|
||||
XVIMAGE_YV12,
|
||||
XVIMAGE_I420,
|
||||
};
|
||||
|
@ -158,6 +152,7 @@ glamor_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
|
|||
{
|
||||
glamor_port_private *port_priv = (glamor_port_private *) data;
|
||||
int i;
|
||||
|
||||
if (!cleanup)
|
||||
return;
|
||||
|
||||
|
@ -171,11 +166,10 @@ 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)
|
||||
port_priv->brightness = ClipValue(value, -1000, 1000);
|
||||
else if (attribute == xvHue)
|
||||
|
@ -195,11 +189,10 @@ 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)
|
||||
*value = port_priv->brightness;
|
||||
else if (attribute == xvHue)
|
||||
|
@ -223,8 +216,7 @@ 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;
|
||||
|
@ -238,31 +230,36 @@ glamor_xv_query_image_attributes(ScrnInfoPtr pScrn,
|
|||
{
|
||||
int size = 0, tmp;
|
||||
|
||||
if (offsets) offsets[0] = 0;
|
||||
if (offsets)
|
||||
offsets[0] = 0;
|
||||
switch (id) {
|
||||
case FOURCC_YV12:
|
||||
case FOURCC_I420:
|
||||
*h = *h;
|
||||
*w = *w;
|
||||
size = *w;
|
||||
if (pitches) pitches[0] = size;
|
||||
if (pitches)
|
||||
pitches[0] = size;
|
||||
size *= *h;
|
||||
if (offsets) offsets[1] = size;
|
||||
if (offsets)
|
||||
offsets[1] = size;
|
||||
tmp = *w >> 1;
|
||||
if (pitches) pitches[1] = pitches[2] = tmp;
|
||||
if (pitches)
|
||||
pitches[1] = pitches[2] = tmp;
|
||||
tmp *= (*h >> 1);
|
||||
size += tmp;
|
||||
if (offsets) offsets[2] = size;
|
||||
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 */
|
||||
};
|
||||
|
@ -271,8 +268,7 @@ static void
|
|||
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_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];
|
||||
|
@ -319,8 +315,10 @@ 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]);
|
||||
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);
|
||||
|
@ -335,65 +333,48 @@ 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_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
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);
|
||||
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_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
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);
|
||||
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_MIN_FILTER,
|
||||
GL_LINEAR);
|
||||
GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
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);
|
||||
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
|
||||
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");
|
||||
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");
|
||||
sampler_loc =
|
||||
dispatch->glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
|
||||
dispatch->glUniform1i(sampler_loc, 2);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
texcoords);
|
||||
2 * sizeof(float), texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
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);
|
||||
for (i = 0; i < nBox; i++) {
|
||||
|
@ -404,7 +385,6 @@ 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;
|
||||
|
@ -421,8 +401,7 @@ glamor_set_normalize_vcoords(pixmap_priv,
|
|||
dsty,
|
||||
dstx + dstw,
|
||||
dsty + dsth,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
glamor_set_normalize_tcoords(src_pixmap_priv[0],
|
||||
src_xscale[0],
|
||||
|
@ -431,8 +410,7 @@ glamor_set_normalize_tcoords(src_pixmap_priv[0],
|
|||
srcy,
|
||||
srcx + srcw,
|
||||
srcy + srch,
|
||||
glamor_priv->yInverted,
|
||||
texcoords);
|
||||
glamor_priv->yInverted, texcoords);
|
||||
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
@ -445,7 +423,8 @@ 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,9 +434,7 @@ 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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
@ -605,7 +588,8 @@ glamor_xv_init(ScreenPtr screen, int num_texture_ports)
|
|||
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;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \mainpage Mesa GL API Module
|
||||
*
|
||||
|
@ -66,7 +65,6 @@
|
|||
typedef void (*_glapi_proc) (void);
|
||||
struct _glapi_table;
|
||||
|
||||
|
||||
#if defined (GLX_USE_TLS)
|
||||
|
||||
extern __thread struct _glapi_table *_glapi_tls_Dispatch
|
||||
|
@ -95,7 +93,6 @@ extern void *_glapi_Context;
|
|||
#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)) \
|
||||
_glapi_Context = (void*)C; \
|
||||
else \
|
||||
|
@ -111,11 +108,9 @@ extern void *_glapi_Context;
|
|||
|
||||
#endif /* defined (GLX_USE_TLS) */
|
||||
|
||||
|
||||
extern void
|
||||
_glapi_set_context(void *context);
|
||||
|
||||
extern void *
|
||||
_glapi_get_context(void);
|
||||
extern void *_glapi_get_context(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue