exports more rendering functions to DDX driver.

Exports all necessary rendering functions to DDx drivers, including
CopyArea, Glyphs, Composite, Triangles, ....

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2011-12-09 15:58:19 +08:00 committed by Eric Anholt
parent b5480e64ac
commit b5630663cf
11 changed files with 327 additions and 133 deletions

View File

@ -90,3 +90,55 @@ extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
int nrect, int nrect,
xRectangle * prect); xRectangle * prect);
extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
GCPtr gc, int depth, int x, int y,
int w, int h, int left_pad,
int image_format, char *bits);
extern _X_EXPORT Bool glamor_copy_n_to_n_nf(DrawablePtr src,
DrawablePtr dst,
GCPtr gc,
BoxPtr box,
int nbox,
int dx,
int dy,
Bool reverse,
Bool upsidedown, Pixel bitplane,
void *closure);
extern _X_EXPORT Bool glamor_composite_nf(CARD8 op,
PicturePtr source,
PicturePtr mask,
PicturePtr dest,
INT16 x_source,
INT16 y_source,
INT16 x_mask,
INT16 y_mask,
INT16 x_dest, INT16 y_dest,
CARD16 width, CARD16 height);
extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
PicturePtr src, PicturePtr dst,
PictFormatPtr mask_format,
INT16 x_src, INT16 y_src,
int ntrap, xTrapezoid * traps);
extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
PicturePtr src,
PicturePtr dst,
PictFormatPtr mask_format,
INT16 x_src,
INT16 y_src, int nlist,
GlyphListPtr list, GlyphPtr * glyphs);
extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc,
int ntris, xTriangle * tris);
extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);

View File

@ -286,8 +286,8 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
return FALSE; return FALSE;
} }
void static Bool
glamor_copy_n_to_n(DrawablePtr src, _glamor_copy_n_to_n(DrawablePtr src,
DrawablePtr dst, DrawablePtr dst,
GCPtr gc, GCPtr gc,
BoxPtr box, BoxPtr box,
@ -295,7 +295,8 @@ glamor_copy_n_to_n(DrawablePtr src,
int dx, int dx,
int dy, int dy,
Bool reverse, Bool reverse,
Bool upsidedown, Pixel bitplane, void *closure) Bool upsidedown, Pixel bitplane,
void *closure, Bool fallback)
{ {
glamor_access_t dst_access; glamor_access_t dst_access;
PixmapPtr dst_pixmap, src_pixmap, temp_pixmap = NULL; PixmapPtr dst_pixmap, src_pixmap, temp_pixmap = NULL;
@ -308,6 +309,7 @@ glamor_copy_n_to_n(DrawablePtr src,
int src_x_off, src_y_off, dst_x_off, dst_y_off; int src_x_off, src_y_off, dst_x_off, dst_y_off;
int i; int i;
int overlaped = 0; int overlaped = 0;
Bool ret = TRUE;
dst_pixmap = glamor_get_drawable_pixmap(dst); dst_pixmap = glamor_get_drawable_pixmap(dst);
dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap); dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
@ -315,6 +317,9 @@ glamor_copy_n_to_n(DrawablePtr src,
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap); src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
screen = dst_pixmap->drawable.pScreen; screen = dst_pixmap->drawable.pScreen;
if (!dst_pixmap_priv || !src_pixmap_priv)
goto fail;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) { if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
glamor_fallback("dest pixmap %p has no fbo. \n", glamor_fallback("dest pixmap %p has no fbo. \n",
dst_pixmap); dst_pixmap);
@ -338,14 +343,12 @@ glamor_copy_n_to_n(DrawablePtr src,
} }
} }
/* XXX need revisit to handle overlapped area copying. */ /* XXX need revisit to handle overlapped area copying. */
#ifndef GLAMOR_GLES2 #ifndef GLAMOR_GLES2
if ((overlaped if ((overlaped
|| !src_pixmap_priv->gl_tex || !dst_pixmap_priv->gl_tex) || !src_pixmap_priv->gl_tex || !dst_pixmap_priv->gl_tex)
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, && glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx,
dy)) { dy)) {
goto done; goto done;
return;
} }
#endif #endif
glamor_calculate_boxes_bound(&bound, box, nbox); glamor_calculate_boxes_bound(&bound, box, nbox);
@ -394,6 +397,12 @@ glamor_copy_n_to_n(DrawablePtr src,
fail: fail:
if (!fallback) {
ret = FALSE;
goto done;
}
glamor_report_delayed_fallbacks(src->pScreen); glamor_report_delayed_fallbacks(src->pScreen);
glamor_report_delayed_fallbacks(dst->pScreen); glamor_report_delayed_fallbacks(dst->pScreen);
@ -424,6 +433,7 @@ glamor_copy_n_to_n(DrawablePtr src,
if (temp_src != src) { if (temp_src != src) {
(*screen->DestroyPixmap) (temp_pixmap); (*screen->DestroyPixmap) (temp_pixmap);
} }
return ret;
} }
RegionPtr RegionPtr
@ -438,3 +448,36 @@ glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
return region; return region;
} }
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)
{
_glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
dy, reverse, upsidedown, bitplane, closure, TRUE);
}
Bool
glamor_copy_n_to_n_nf(DrawablePtr src,
DrawablePtr dst,
GCPtr gc,
BoxPtr box,
int nbox,
int dx,
int dy,
Bool reverse,
Bool upsidedown, Pixel bitplane,
void *closure)
{
return _glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
dy, reverse, upsidedown, bitplane, closure, FALSE);
}

View File

@ -264,7 +264,7 @@ glamor_finish_access(DrawablePtr drawable)
glamor_get_screen_private(drawable->pScreen); glamor_get_screen_private(drawable->pScreen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch; glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) if (!pixmap_priv || !GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return; return;
if (pixmap_priv->access_mode != GLAMOR_ACCESS_RO) { if (pixmap_priv->access_mode != GLAMOR_ACCESS_RO) {

View File

@ -104,3 +104,4 @@ glamor_get_spans(DrawablePtr drawable,
glamor_finish_access(drawable); glamor_finish_access(drawable);
} }
} }

View File

@ -239,55 +239,7 @@ glamor_glyph_cache_upload_glyph(ScreenPtr screen,
ValidateGC(&pCachePixmap->drawable, gc); ValidateGC(&pCachePixmap->drawable, gc);
scratch = pGlyphPixmap; scratch = pGlyphPixmap;
#if 0 (*gc->ops->CopyArea)(&scratch->drawable, &pCachePixmap->drawable, gc,
/* Create a temporary bo to stream the updates to the cache */
if (pGlyphPixmap->drawable.depth != pCachePixmap->drawable.depth ||
!uxa_pixmap_is_offscreen(scratch)) {
scratch = screen->CreatePixmap(screen,
glyph->info.width,
glyph->info.height,
pCachePixmap->
drawable.depth, 0);
if (scratch) {
if (pGlyphPixmap->drawable.depth !=
pCachePixmap->drawable.depth) {
PicturePtr picture;
int error;
picture =
CreatePicture(0,
&scratch->drawable,
PictureMatchFormat
(screen,
pCachePixmap->
drawable.depth,
cache->picture->format),
0, NULL, serverClient,
&error);
if (picture) {
ValidatePicture(picture);
uxa_composite(PictOpSrc,
pGlyphPicture,
NULL, picture,
0, 0, 0, 0, 0,
0,
glyph->info.width,
glyph->info.height);
FreePicture(picture, 0);
}
} else {
glamor_copy_area(&pGlyphPixmap->drawable,
&scratch->drawable,
gc, 0, 0,
glyph->info.width,
glyph->info.height, 0, 0);
}
} else {
scratch = pGlyphPixmap;
}
}
#endif
glamor_copy_area(&scratch->drawable, &pCachePixmap->drawable, gc,
0, 0, glyph->info.width, glyph->info.height, x, 0, 0, glyph->info.width, glyph->info.height, x,
y); y);
@ -657,6 +609,7 @@ glamor_glyphs_via_mask(CARD8 op,
BoxRec extents = { 0, 0, 0, 0 }; BoxRec extents = { 0, 0, 0, 0 };
CARD32 component_alpha; CARD32 component_alpha;
glamor_glyph_buffer_t buffer; glamor_glyph_buffer_t buffer;
xRectangle fill_rect;
GCPtr gc; GCPtr gc;
@ -690,7 +643,14 @@ glamor_glyphs_via_mask(CARD8 op,
} }
gc = GetScratchGC(mask_pixmap->drawable.depth, screen); gc = GetScratchGC(mask_pixmap->drawable.depth, screen);
ValidateGC(&mask_pixmap->drawable, gc); ValidateGC(&mask_pixmap->drawable, gc);
glamor_fill(&mask_pixmap->drawable, gc, 0, 0, width, height, TRUE); gc->fillStyle = FillSolid;
//glamor_fill(&mask_pixmap->drawable, gc, 0, 0, width, height, TRUE);
fill_rect.x = 0;
fill_rect.y = 0;
fill_rect.width = width;
fill_rect.height = height;
gc->ops->PolyFillRect(&mask_pixmap->drawable, gc, 1, &fill_rect);
FreeScratchGC(gc); FreeScratchGC(gc);
x = -extents.x1; x = -extents.x1;
y = -extents.y1; y = -extents.y1;
@ -810,13 +770,14 @@ glamor_glyphs_to_dst(CARD8 op,
x_src, y_src, x_dst, y_dst); x_src, y_src, x_dst, y_dst);
} }
void static Bool
glamor_glyphs(CARD8 op, _glamor_glyphs(CARD8 op,
PicturePtr src, PicturePtr src,
PicturePtr dst, PicturePtr dst,
PictFormatPtr mask_format, PictFormatPtr mask_format,
INT16 x_src, INT16 x_src,
INT16 y_src, int nlist, GlyphListPtr list, GlyphPtr * glyphs) INT16 y_src, int nlist, GlyphListPtr list,
GlyphPtr * glyphs, Bool fallback)
{ {
/* If we don't have a mask format but all the glyphs have the same format /* If we don't have a mask format but all the glyphs have the same format
* and don't intersect, use the glyph format as mask format for the full * and don't intersect, use the glyph format as mask format for the full
@ -848,4 +809,31 @@ glamor_glyphs(CARD8 op,
else else
glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist, glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist,
list, glyphs); list, glyphs);
return TRUE;
} }
void
glamor_glyphs(CARD8 op,
PicturePtr src,
PicturePtr dst,
PictFormatPtr mask_format,
INT16 x_src,
INT16 y_src, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
{
_glamor_glyphs(op, src, dst, mask_format, x_src,
y_src, nlist, list, glyphs, TRUE);
}
Bool
glamor_glyphs_nf(CARD8 op,
PicturePtr src,
PicturePtr dst,
PictFormatPtr mask_format,
INT16 x_src,
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);
}

View File

@ -60,10 +60,11 @@ glamor_create_picture(PicturePtr picture)
glamor_get_screen_private(picture->pDrawable->pScreen); glamor_get_screen_private(picture->pDrawable->pScreen);
pixmap = glamor_get_drawable_pixmap(picture->pDrawable); pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
pixmap_priv = glamor_get_pixmap_private(pixmap); pixmap_priv = glamor_get_pixmap_private(pixmap);
assert(pixmap_priv);
if (pixmap_priv) {
pixmap_priv->is_picture = 1; pixmap_priv->is_picture = 1;
pixmap_priv->pict_format = picture->format; pixmap_priv->pict_format = picture->format;
}
return glamor_priv->saved_create_picture(picture); return glamor_priv->saved_create_picture(picture);
} }
@ -81,10 +82,11 @@ glamor_destroy_picture(PicturePtr picture)
glamor_get_screen_private(picture->pDrawable->pScreen); glamor_get_screen_private(picture->pDrawable->pScreen);
pixmap = glamor_get_drawable_pixmap(picture->pDrawable); pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
pixmap_priv = glamor_get_pixmap_private(pixmap); pixmap_priv = glamor_get_pixmap_private(pixmap);
assert(pixmap_priv);
if (pixmap_priv) {
pixmap_priv->is_picture = 0; pixmap_priv->is_picture = 0;
pixmap_priv->pict_format = 0; pixmap_priv->pict_format = 0;
}
glamor_priv->saved_destroy_picture(picture); glamor_priv->saved_destroy_picture(picture);
} }

View File

@ -302,6 +302,9 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
GLuint tex; GLuint tex;
int need_flip; int need_flip;
if (!pixmap_priv)
return;
need_flip = (flip && !glamor_priv->yInverted); need_flip = (flip && !glamor_priv->yInverted);
/* Try fast path firstly, upload the pixmap to the texture attached /* Try fast path firstly, upload the pixmap to the texture attached
@ -368,7 +371,6 @@ glamor_pixmap_ensure_fb(PixmapPtr pixmap)
glamor_pixmap_private *pixmap_priv = glamor_pixmap_private *pixmap_priv =
glamor_get_pixmap_private(pixmap); glamor_get_pixmap_private(pixmap);
glamor_gl_dispatch *dispatch = &pixmap_priv->glamor_priv->dispatch; glamor_gl_dispatch *dispatch = &pixmap_priv->glamor_priv->dispatch;
if (pixmap_priv->fb == 0) if (pixmap_priv->fb == 0)
dispatch->glGenFramebuffers(1, &pixmap_priv->fb); dispatch->glGenFramebuffers(1, &pixmap_priv->fb);
assert(pixmap_priv->tex != 0); assert(pixmap_priv->tex != 0);
@ -644,7 +646,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch; glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
screen = pixmap->drawable.pScreen; screen = pixmap->drawable.pScreen;
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) if (!pixmap_priv || !GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return TRUE; return TRUE;
if (glamor_get_tex_format_type_from_pixmap(pixmap, if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format, &format,

View File

@ -545,7 +545,7 @@ glamor_picture_format_fixup(PicturePtr picture,
* fallback the whole process to cpu. Most of the time, * fallback the whole process to cpu. Most of the time,
* this will increase performance obviously. */ * this will increase performance obviously. */
#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD //#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
//#define GLAMOR_DELAYED_FILLING //#define GLAMOR_DELAYED_FILLING

View File

@ -240,9 +240,9 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
#endif #endif
void static Bool
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y, _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) int w, int h, int left_pad, int image_format, char *bits, Bool fallback)
{ {
glamor_screen_private *glamor_priv = glamor_screen_private *glamor_priv =
glamor_get_screen_private(drawable->pScreen); glamor_get_screen_private(drawable->pScreen);
@ -263,10 +263,9 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
if (image_format == XYBitmap) { if (image_format == XYBitmap) {
assert(depth == 1); assert(depth == 1);
goto fail; goto fail;
return;
} }
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) { if (!pixmap_priv || !GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
glamor_fallback("has no fbo.\n"); glamor_fallback("has no fbo.\n");
goto fail; goto fail;
} }
@ -309,12 +308,12 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
pixmap->drawable.bitsPerPixel); pixmap->drawable.bitsPerPixel);
} else { } else {
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4); dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
// dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
} }
dispatch->glGenTextures(1, &tex); dispatch->glGenTextures(1, &tex);
dispatch->glActiveTexture(GL_TEXTURE0); dispatch->glActiveTexture(GL_TEXTURE0);
dispatch->glBindTexture(GL_TEXTURE_2D, tex); dispatch->glBindTexture(GL_TEXTURE_2D, tex);
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) { if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
iformat = format; iformat = format;
} else { } else {
@ -328,10 +327,10 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
GL_NEAREST); GL_NEAREST);
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST); GL_NEAREST);
#ifndef GLAMOR_GLES2 #ifndef GLAMOR_GLES2
dispatch->glEnable(GL_TEXTURE_2D); dispatch->glEnable(GL_TEXTURE_2D);
#endif #endif
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]); dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
dispatch->glUniform1i(glamor_priv-> dispatch->glUniform1i(glamor_priv->
finish_access_no_revert[no_alpha], finish_access_no_revert[no_alpha],
@ -386,15 +385,17 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
dispatch->glUseProgram(0); dispatch->glUseProgram(0);
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS); dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE); dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
dispatch->glDeleteTextures(1, &tex); dispatch->glDeleteTextures(1, &tex);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glamor_set_alu(dispatch, GXcopy); glamor_set_alu(dispatch, GXcopy);
glamor_set_planemask(pixmap, ~0); glamor_set_planemask(pixmap, ~0);
return; return TRUE;
fail: fail:
glamor_set_planemask(pixmap, ~0); glamor_set_planemask(pixmap, ~0);
if (!fallback) return FALSE;
glamor_fallback("to %p (%c)\n", glamor_fallback("to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable)); drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RW)) { if (glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RW)) {
@ -402,4 +403,22 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
left_pad, image_format, bits); left_pad, image_format, bits);
glamor_finish_access(&pixmap->drawable); glamor_finish_access(&pixmap->drawable);
} }
return TRUE;
} }
void
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)
{
_glamor_put_image(drawable, gc, depth, x, y, w, h,
left_pad, image_format, bits, TRUE);
}
Bool
glamor_put_image_nf(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
int w, int h, int left_pad, int image_format, char *bits)
{
return _glamor_put_image(drawable, gc, depth, x, y, w, h,
left_pad, image_format, bits, FALSE);
}

View File

@ -36,8 +36,6 @@
#include "mipict.h" #include "mipict.h"
#include "fbpict.h" #include "fbpict.h"
//#include "glu3/glu3.h"
struct shader_key { struct shader_key {
enum shader_source source; enum shader_source source;
enum shader_mask mask; enum shader_mask mask;
@ -371,6 +369,7 @@ glamor_set_composite_texture(ScreenPtr screen, int unit,
PicturePtr picture, PicturePtr picture,
glamor_pixmap_private * pixmap_priv) glamor_pixmap_private * pixmap_priv)
{ {
unsigned int no_alpha, no_revert, format, type;
glamor_screen_private *glamor_priv = glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen); glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch; glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
@ -497,6 +496,7 @@ glamor_composite_with_copy(CARD8 op,
INT16 y_dest, CARD16 width, CARD16 height) INT16 y_dest, CARD16 width, CARD16 height)
{ {
RegionRec region; RegionRec region;
int ret;
if (!source->pDrawable) if (!source->pDrawable)
return FALSE; return FALSE;
@ -511,21 +511,22 @@ glamor_composite_with_copy(CARD8 op,
y_dest += dest->pDrawable->y; y_dest += dest->pDrawable->y;
x_source += source->pDrawable->x; x_source += source->pDrawable->x;
y_source += source->pDrawable->y; y_source += source->pDrawable->y;
if (!miComputeCompositeRegion(&region, if (!miComputeCompositeRegion(&region,
source, NULL, dest, source, NULL, dest,
x_source, y_source, x_source, y_source,
0, 0, x_dest, y_dest, width, height)) 0, 0, x_dest, y_dest, width, height))
return TRUE; return TRUE;
ret = TRUE;
glamor_copy_n_to_n(source->pDrawable, ErrorF("width %d height %d \n", width, height);
if (!glamor_copy_n_to_n_nf(source->pDrawable,
dest->pDrawable, NULL, dest->pDrawable, NULL,
REGION_RECTS(&region), REGION_RECTS(&region),
REGION_NUM_RECTS(&region), REGION_NUM_RECTS(&region),
x_source - x_dest, y_source - y_dest, x_source - x_dest, y_source - y_dest,
FALSE, FALSE, 0, NULL); FALSE, FALSE, 0, NULL))
ret = FALSE;
REGION_UNINIT(dest->pDrawable->pScreen, &region); REGION_UNINIT(dest->pDrawable->pScreen, &region);
return TRUE; return ret;
} }
static void static void
@ -696,7 +697,6 @@ combine_pict_format(PictFormatShort * des, const PictFormatShort src,
return FALSE; return FALSE;
} }
if (src_type == mask_type) { if (src_type == mask_type) {
*des = PICT_VISFORMAT(src_bpp, src_type, new_vis); *des = PICT_VISFORMAT(src_bpp, src_type, new_vis);
return TRUE; return TRUE;
@ -753,10 +753,9 @@ glamor_composite_with_shader(CARD8 op,
PictFormatShort saved_source_format = 0; PictFormatShort saved_source_format = 0;
float src_matrix[9], mask_matrix[9]; float src_matrix[9], mask_matrix[9];
GLfloat source_solid_color[4], mask_solid_color[4]; GLfloat source_solid_color[4], mask_solid_color[4];
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap); dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) { if (!dest_pixmap_priv || !GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
glamor_fallback("dest has no fbo.\n"); glamor_fallback("dest has no fbo.\n");
goto fail; goto fail;
} }
@ -997,8 +996,6 @@ glamor_composite_with_shader(CARD8 op,
&dest_x_off, &dest_y_off); &dest_x_off, &dest_y_off);
pixmap_priv_get_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale); pixmap_priv_get_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale);
if (glamor_priv->has_source_coords) { if (glamor_priv->has_source_coords) {
glamor_get_drawable_deltas(source->pDrawable, glamor_get_drawable_deltas(source->pDrawable,
source_pixmap, &source_x_off, source_pixmap, &source_x_off,
@ -1190,8 +1187,8 @@ glamor_convert_gradient_picture(ScreenPtr screen,
return dst; return dst;
} }
void static Bool
glamor_composite(CARD8 op, _glamor_composite(CARD8 op,
PicturePtr source, PicturePtr source,
PicturePtr mask, PicturePtr mask,
PicturePtr dest, PicturePtr dest,
@ -1199,7 +1196,8 @@ glamor_composite(CARD8 op,
INT16 y_source, INT16 y_source,
INT16 x_mask, INT16 x_mask,
INT16 y_mask, INT16 y_mask,
INT16 x_dest, INT16 y_dest, CARD16 width, CARD16 height) INT16 x_dest, INT16 y_dest,
CARD16 width, CARD16 height, Bool fallback)
{ {
ScreenPtr screen = dest->pDrawable->pScreen; ScreenPtr screen = dest->pDrawable->pScreen;
glamor_pixmap_private *dest_pixmap_priv; glamor_pixmap_private *dest_pixmap_priv;
@ -1214,6 +1212,7 @@ glamor_composite(CARD8 op,
glamor_screen_private *glamor_priv = glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen); glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch; glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
Bool ret = TRUE;
x_temp_src = x_source; x_temp_src = x_source;
y_temp_src = y_source; y_temp_src = y_source;
@ -1222,7 +1221,7 @@ glamor_composite(CARD8 op,
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap); dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
/* Currently. Always fallback to cpu if destination is in CPU memory. */ /* Currently. Always fallback to cpu if destination is in CPU memory. */
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) { if (!dest_pixmap_priv || !GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
goto fail; goto fail;
} }
@ -1231,13 +1230,14 @@ glamor_composite(CARD8 op,
glamor_get_drawable_pixmap(source->pDrawable); glamor_get_drawable_pixmap(source->pDrawable);
source_pixmap_priv = source_pixmap_priv =
glamor_get_pixmap_private(source_pixmap); glamor_get_pixmap_private(source_pixmap);
if (!source_pixmap_priv) goto fail;
} }
if (mask && mask->pDrawable) { if (mask && mask->pDrawable) {
mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable); mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable);
mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap); mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap);
if (!mask_pixmap_priv) goto fail;
} }
if ((!source->pDrawable if ((!source->pDrawable
&& (source->pSourcePict->type != SourcePictTypeSolidFill)) && (source->pSourcePict->type != SourcePictTypeSolidFill))
|| (source->pDrawable || (source->pDrawable
@ -1311,7 +1311,6 @@ glamor_composite(CARD8 op,
goto fail; goto fail;
} }
} }
if (!mask) { if (!mask) {
if (glamor_composite_with_copy(op, temp_src, dest, if (glamor_composite_with_copy(op, temp_src, dest,
x_temp_src, y_temp_src, x_temp_src, y_temp_src,
@ -1319,7 +1318,6 @@ glamor_composite(CARD8 op,
height)) height))
goto done; goto done;
} }
rect.x_src = x_temp_src; rect.x_src = x_temp_src;
rect.y_src = y_temp_src; rect.y_src = y_temp_src;
rect.x_mask = x_temp_mask; rect.x_mask = x_temp_mask;
@ -1334,6 +1332,12 @@ glamor_composite(CARD8 op,
fail: fail:
dispatch->glUseProgram(0);
dispatch->glDisable(GL_BLEND);
if (!fallback) {
ret = FALSE;
goto done;
}
glamor_fallback glamor_fallback
("from picts %p:%p %dx%d / %p:%p %d x %d (%c,%c) to pict %p:%p %dx%d (%c)\n", ("from picts %p:%p %dx%d / %p:%p %d x %d (%c,%c) to pict %p:%p %dx%d (%c)\n",
source, source->pDrawable, source, source->pDrawable,
@ -1349,8 +1353,6 @@ glamor_composite(CARD8 op,
dest->pDrawable->width, dest->pDrawable->height, dest->pDrawable->width, dest->pDrawable->height,
glamor_get_picture_location(dest)); glamor_get_picture_location(dest));
dispatch->glUseProgram(0);
dispatch->glDisable(GL_BLEND);
if (glamor_prepare_access_picture(dest, GLAMOR_ACCESS_RW)) { if (glamor_prepare_access_picture(dest, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_picture if (glamor_prepare_access_picture
(source, GLAMOR_ACCESS_RO)) { (source, GLAMOR_ACCESS_RO)) {
@ -1375,8 +1377,45 @@ glamor_composite(CARD8 op,
FreePicture(temp_src, 0); FreePicture(temp_src, 0);
if (temp_mask != mask) if (temp_mask != mask)
FreePicture(temp_mask, 0); FreePicture(temp_mask, 0);
return ret;
} }
void
glamor_composite(CARD8 op,
PicturePtr source,
PicturePtr mask,
PicturePtr dest,
INT16 x_source,
INT16 y_source,
INT16 x_mask,
INT16 y_mask,
INT16 x_dest, INT16 y_dest,
CARD16 width, CARD16 height)
{
_glamor_composite(op, source, mask, dest, x_source, y_source,
x_mask, y_mask, x_dest, y_dest, width, height,
TRUE);
}
Bool
glamor_composite_nf(CARD8 op,
PicturePtr source,
PicturePtr mask,
PicturePtr dest,
INT16 x_source,
INT16 y_source,
INT16 x_mask,
INT16 y_mask,
INT16 x_dest, INT16 y_dest,
CARD16 width, CARD16 height)
{
return _glamor_composite(op, source, mask, dest, x_source, y_source,
x_mask, y_mask, x_dest, y_dest, width, height,
FALSE);
}
/** /**
* Creates an appropriate picture to upload our alpha mask into (which * Creates an appropriate picture to upload our alpha mask into (which
@ -1418,11 +1457,11 @@ glamor_create_mask_picture(ScreenPtr screen,
* glamor_trapezoids is a copy of miTrapezoids that does all the trapezoid * glamor_trapezoids is a copy of miTrapezoids that does all the trapezoid
* accumulation in system memory. * accumulation in system memory.
*/ */
void static Bool
glamor_trapezoids(CARD8 op, _glamor_trapezoids(CARD8 op,
PicturePtr src, PicturePtr dst, PicturePtr src, PicturePtr dst,
PictFormatPtr mask_format, INT16 x_src, INT16 y_src, PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
int ntrap, xTrapezoid * traps) int ntrap, xTrapezoid * traps, Bool fallback)
{ {
ScreenPtr screen = dst->pDrawable->pScreen; ScreenPtr screen = dst->pDrawable->pScreen;
BoxRec bounds; BoxRec bounds;
@ -1446,13 +1485,13 @@ glamor_trapezoids(CARD8 op,
for (; ntrap; ntrap--, traps++) for (; ntrap; ntrap--, traps++)
glamor_trapezoids(op, src, dst, mask_format, x_src, glamor_trapezoids(op, src, dst, mask_format, x_src,
y_src, 1, traps); y_src, 1, traps);
return; return TRUE;
} }
miTrapezoidBounds(ntrap, traps, &bounds); miTrapezoidBounds(ntrap, traps, &bounds);
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
return; return TRUE;
x_dst = traps[0].left.p1.x >> 16; x_dst = traps[0].left.p1.x >> 16;
y_dst = traps[0].left.p1.y >> 16; y_dst = traps[0].left.p1.y >> 16;
@ -1463,13 +1502,13 @@ glamor_trapezoids(CARD8 op,
picture = glamor_create_mask_picture(screen, dst, mask_format, picture = glamor_create_mask_picture(screen, dst, mask_format,
width, height); width, height);
if (!picture) if (!picture)
return; return TRUE;
image = pixman_image_create_bits(picture->format, image = pixman_image_create_bits(picture->format,
width, height, NULL, stride); width, height, NULL, stride);
if (!image) { if (!image) {
FreePicture(picture, 0); FreePicture(picture, 0);
return; return TRUE;
} }
for (; ntrap; ntrap--, traps++) for (; ntrap; ntrap--, traps++)
@ -1497,8 +1536,31 @@ glamor_trapezoids(CARD8 op,
pixman_image_unref(image); pixman_image_unref(image);
FreePicture(picture, 0); FreePicture(picture, 0);
return TRUE;
} }
void
glamor_trapezoids(CARD8 op,
PicturePtr src, PicturePtr dst,
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
int ntrap, xTrapezoid * traps)
{
_glamor_trapezoids(op, src, dst, mask_format, x_src,
y_src, ntrap, traps, TRUE);
}
Bool
glamor_trapezoids_nf(CARD8 op,
PicturePtr src, PicturePtr dst,
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
int ntrap, xTrapezoid * traps)
{
return _glamor_trapezoids(op, src, dst, mask_format, x_src,
y_src, ntrap, traps, FALSE);
}
void void
glamor_composite_rects(CARD8 op, glamor_composite_rects(CARD8 op,
PicturePtr src, PicturePtr mask, PicturePtr dst, PicturePtr src, PicturePtr mask, PicturePtr dst,

View File

@ -32,14 +32,15 @@
#include "glamor_priv.h" #include "glamor_priv.h"
void static Bool
glamor_triangles(CARD8 op, _glamor_triangles(CARD8 op,
PicturePtr pSrc, PicturePtr pSrc,
PicturePtr pDst, PicturePtr pDst,
PictFormatPtr maskFormat, PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris) INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris, Bool fallback)
{ {
if (!fallback)
return FALSE;
if (glamor_prepare_access(pDst->pDrawable, GLAMOR_ACCESS_RW)) { if (glamor_prepare_access(pDst->pDrawable, GLAMOR_ACCESS_RW)) {
if (pSrc->pDrawable == NULL || if (pSrc->pDrawable == NULL ||
glamor_prepare_access(pSrc->pDrawable, glamor_prepare_access(pSrc->pDrawable,
@ -53,4 +54,28 @@ glamor_triangles(CARD8 op,
glamor_finish_access(pDst->pDrawable); glamor_finish_access(pDst->pDrawable);
} }
return TRUE;
} }
void
glamor_triangles(CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
{
_glamor_triangles(op, pSrc, pDst, maskFormat,
xSrc, ySrc, ntris, tris, TRUE);
}
Bool
glamor_triangles_nf(CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
{
return _glamor_triangles(op, pSrc, pDst, maskFormat,
xSrc, ySrc, ntris, tris, FALSE);
}