summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2011-12-09 15:58:19 +0800
committerEric Anholt <eric@anholt.net>2013-12-18 11:23:46 -0800
commitb5630663cf9438383166f59cdfc7889571f2cd62 (patch)
treee02930bc8b7af157dd526aaca53b9df1fd968cae /glamor
parentb5480e64ac4a72bdc31e587ff9e51d67a1a0f11d (diff)
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>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor.h52
-rw-r--r--glamor/glamor_copyarea.c67
-rw-r--r--glamor/glamor_core.c2
-rw-r--r--glamor/glamor_getspans.c1
-rw-r--r--glamor/glamor_glyphs.c106
-rw-r--r--glamor/glamor_picture.c16
-rw-r--r--glamor/glamor_pixmap.c6
-rw-r--r--glamor/glamor_priv.h2
-rw-r--r--glamor/glamor_putimage.c35
-rw-r--r--glamor/glamor_render.c140
-rw-r--r--glamor/glamor_triangles.c33
11 files changed, 327 insertions, 133 deletions
diff --git a/glamor/glamor.h b/glamor/glamor.h
index ce1a41f9f..fd056e96a 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -90,3 +90,55 @@ extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
int nrect,
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);
+
+
diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c
index b49d8163f..38254d6fc 100644
--- a/glamor/glamor_copyarea.c
+++ b/glamor/glamor_copyarea.c
@@ -286,16 +286,17 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
return FALSE;
}
-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)
+static Bool
+_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, Bool fallback)
{
glamor_access_t dst_access;
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 i;
int overlaped = 0;
+ Bool ret = TRUE;
dst_pixmap = glamor_get_drawable_pixmap(dst);
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);
screen = dst_pixmap->drawable.pScreen;
+ if (!dst_pixmap_priv || !src_pixmap_priv)
+ goto fail;
+
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
glamor_fallback("dest pixmap %p has no fbo. \n",
dst_pixmap);
@@ -338,14 +343,12 @@ glamor_copy_n_to_n(DrawablePtr src,
}
}
/* XXX need revisit to handle overlapped area copying. */
-
#ifndef GLAMOR_GLES2
if ((overlaped
|| !src_pixmap_priv->gl_tex || !dst_pixmap_priv->gl_tex)
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx,
dy)) {
goto done;
- return;
}
#endif
glamor_calculate_boxes_bound(&bound, box, nbox);
@@ -394,6 +397,12 @@ glamor_copy_n_to_n(DrawablePtr src,
fail:
+
+ if (!fallback) {
+ ret = FALSE;
+ goto done;
+ }
+
glamor_report_delayed_fallbacks(src->pScreen);
glamor_report_delayed_fallbacks(dst->pScreen);
@@ -424,6 +433,7 @@ glamor_copy_n_to_n(DrawablePtr src,
if (temp_src != src) {
(*screen->DestroyPixmap) (temp_pixmap);
}
+ return ret;
}
RegionPtr
@@ -438,3 +448,36 @@ glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
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);
+}
+
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 8ba938fe3..4c58022a8 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -264,7 +264,7 @@ glamor_finish_access(DrawablePtr drawable)
glamor_get_screen_private(drawable->pScreen);
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;
if (pixmap_priv->access_mode != GLAMOR_ACCESS_RO) {
diff --git a/glamor/glamor_getspans.c b/glamor/glamor_getspans.c
index 96f51201b..dff55ba73 100644
--- a/glamor/glamor_getspans.c
+++ b/glamor/glamor_getspans.c
@@ -104,3 +104,4 @@ glamor_get_spans(DrawablePtr drawable,
glamor_finish_access(drawable);
}
}
+
diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c
index 335540d92..96e4c57ec 100644
--- a/glamor/glamor_glyphs.c
+++ b/glamor/glamor_glyphs.c
@@ -239,57 +239,9 @@ glamor_glyph_cache_upload_glyph(ScreenPtr screen,
ValidateGC(&pCachePixmap->drawable, gc);
scratch = pGlyphPixmap;
-#if 0
- /* 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,
- y);
+ (*gc->ops->CopyArea)(&scratch->drawable, &pCachePixmap->drawable, gc,
+ 0, 0, glyph->info.width, glyph->info.height, x,
+ y);
if (scratch != pGlyphPixmap)
screen->DestroyPixmap(scratch);
@@ -657,6 +609,7 @@ glamor_glyphs_via_mask(CARD8 op,
BoxRec extents = { 0, 0, 0, 0 };
CARD32 component_alpha;
glamor_glyph_buffer_t buffer;
+ xRectangle fill_rect;
GCPtr gc;
@@ -690,7 +643,14 @@ glamor_glyphs_via_mask(CARD8 op,
}
gc = GetScratchGC(mask_pixmap->drawable.depth, screen);
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);
x = -extents.x1;
y = -extents.y1;
@@ -810,13 +770,14 @@ glamor_glyphs_to_dst(CARD8 op,
x_src, y_src, x_dst, y_dst);
}
-void
-glamor_glyphs(CARD8 op,
- PicturePtr src,
- PicturePtr dst,
- PictFormatPtr mask_format,
- INT16 x_src,
- INT16 y_src, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
+static Bool
+_glamor_glyphs(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ PictFormatPtr mask_format,
+ INT16 x_src,
+ 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
* and don't intersect, use the glyph format as mask format for the full
@@ -848,4 +809,31 @@ glamor_glyphs(CARD8 op,
else
glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist,
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);
+}
+
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 9e8d6ec80..68c90eb7a 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -60,10 +60,11 @@ glamor_create_picture(PicturePtr picture)
glamor_get_screen_private(picture->pDrawable->pScreen);
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
pixmap_priv = glamor_get_pixmap_private(pixmap);
- assert(pixmap_priv);
-
- pixmap_priv->is_picture = 1;
- pixmap_priv->pict_format = picture->format;
+
+ if (pixmap_priv) {
+ pixmap_priv->is_picture = 1;
+ pixmap_priv->pict_format = picture->format;
+ }
return glamor_priv->saved_create_picture(picture);
}
@@ -81,10 +82,11 @@ glamor_destroy_picture(PicturePtr picture)
glamor_get_screen_private(picture->pDrawable->pScreen);
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
pixmap_priv = glamor_get_pixmap_private(pixmap);
- assert(pixmap_priv);
- pixmap_priv->is_picture = 0;
- pixmap_priv->pict_format = 0;
+ if (pixmap_priv) {
+ pixmap_priv->is_picture = 0;
+ pixmap_priv->pict_format = 0;
+ }
glamor_priv->saved_destroy_picture(picture);
}
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index f02acc746..6f44aabd3 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -302,6 +302,9 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
GLuint tex;
int need_flip;
+
+ if (!pixmap_priv)
+ return;
need_flip = (flip && !glamor_priv->yInverted);
/* 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_get_pixmap_private(pixmap);
glamor_gl_dispatch *dispatch = &pixmap_priv->glamor_priv->dispatch;
-
if (pixmap_priv->fb == 0)
dispatch->glGenFramebuffers(1, &pixmap_priv->fb);
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;
screen = pixmap->drawable.pScreen;
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ if (!pixmap_priv || !GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
return TRUE;
if (glamor_get_tex_format_type_from_pixmap(pixmap,
&format,
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index a40a508d2..4dfdbc456 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -545,7 +545,7 @@ glamor_picture_format_fixup(PicturePtr picture,
* fallback the whole process to cpu. Most of the time,
* this will increase performance obviously. */
-#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
+//#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
//#define GLAMOR_DELAYED_FILLING
diff --git a/glamor/glamor_putimage.c b/glamor/glamor_putimage.c
index a8cafed52..989f635da 100644
--- a/glamor/glamor_putimage.c
+++ b/glamor/glamor_putimage.c
@@ -240,9 +240,9 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
#endif
-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)
+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)
{
glamor_screen_private *glamor_priv =
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) {
assert(depth == 1);
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");
goto fail;
}
@@ -309,12 +308,12 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
pixmap->drawable.bitsPerPixel);
} else {
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
-// dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
dispatch->glGenTextures(1, &tex);
dispatch->glActiveTexture(GL_TEXTURE0);
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
+
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
iformat = format;
} else {
@@ -328,10 +327,10 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
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_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->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
dispatch->glDeleteTextures(1, &tex);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glamor_set_alu(dispatch, GXcopy);
glamor_set_planemask(pixmap, ~0);
- return;
+ return TRUE;
fail:
glamor_set_planemask(pixmap, ~0);
+ if (!fallback) return FALSE;
glamor_fallback("to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
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);
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);
+}
+
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 7f52c7b34..e7e53053c 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -36,8 +36,6 @@
#include "mipict.h"
#include "fbpict.h"
-//#include "glu3/glu3.h"
-
struct shader_key {
enum shader_source source;
enum shader_mask mask;
@@ -371,6 +369,7 @@ glamor_set_composite_texture(ScreenPtr screen, int unit,
PicturePtr picture,
glamor_pixmap_private * pixmap_priv)
{
+ unsigned int no_alpha, no_revert, format, type;
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
@@ -497,6 +496,7 @@ glamor_composite_with_copy(CARD8 op,
INT16 y_dest, CARD16 width, CARD16 height)
{
RegionRec region;
+ int ret;
if (!source->pDrawable)
return FALSE;
@@ -511,21 +511,22 @@ glamor_composite_with_copy(CARD8 op,
y_dest += dest->pDrawable->y;
x_source += source->pDrawable->x;
y_source += source->pDrawable->y;
-
if (!miComputeCompositeRegion(&region,
source, NULL, dest,
x_source, y_source,
0, 0, x_dest, y_dest, width, height))
return TRUE;
-
- glamor_copy_n_to_n(source->pDrawable,
- dest->pDrawable, NULL,
- REGION_RECTS(&region),
- REGION_NUM_RECTS(&region),
- x_source - x_dest, y_source - y_dest,
- FALSE, FALSE, 0, NULL);
+ ret = TRUE;
+ ErrorF("width %d height %d \n", width, height);
+ if (!glamor_copy_n_to_n_nf(source->pDrawable,
+ dest->pDrawable, NULL,
+ REGION_RECTS(&region),
+ REGION_NUM_RECTS(&region),
+ x_source - x_dest, y_source - y_dest,
+ FALSE, FALSE, 0, NULL))
+ ret = FALSE;
REGION_UNINIT(dest->pDrawable->pScreen, &region);
- return TRUE;
+ return ret;
}
static void
@@ -696,7 +697,6 @@ combine_pict_format(PictFormatShort * des, const PictFormatShort src,
return FALSE;
}
-
if (src_type == mask_type) {
*des = PICT_VISFORMAT(src_bpp, src_type, new_vis);
return TRUE;
@@ -753,10 +753,9 @@ glamor_composite_with_shader(CARD8 op,
PictFormatShort saved_source_format = 0;
float src_matrix[9], mask_matrix[9];
GLfloat source_solid_color[4], mask_solid_color[4];
-
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");
goto fail;
}
@@ -997,8 +996,6 @@ glamor_composite_with_shader(CARD8 op,
&dest_x_off, &dest_y_off);
pixmap_priv_get_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale);
-
-
if (glamor_priv->has_source_coords) {
glamor_get_drawable_deltas(source->pDrawable,
source_pixmap, &source_x_off,
@@ -1190,16 +1187,17 @@ glamor_convert_gradient_picture(ScreenPtr screen,
return dst;
}
-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)
+static Bool
+_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, Bool fallback)
{
ScreenPtr screen = dest->pDrawable->pScreen;
glamor_pixmap_private *dest_pixmap_priv;
@@ -1214,6 +1212,7 @@ glamor_composite(CARD8 op,
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
+ Bool ret = TRUE;
x_temp_src = x_source;
y_temp_src = y_source;
@@ -1222,7 +1221,7 @@ glamor_composite(CARD8 op,
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
/* 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;
}
@@ -1231,13 +1230,14 @@ glamor_composite(CARD8 op,
glamor_get_drawable_pixmap(source->pDrawable);
source_pixmap_priv =
glamor_get_pixmap_private(source_pixmap);
+ if (!source_pixmap_priv) goto fail;
}
if (mask && mask->pDrawable) {
mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable);
mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap);
+ if (!mask_pixmap_priv) goto fail;
}
-
if ((!source->pDrawable
&& (source->pSourcePict->type != SourcePictTypeSolidFill))
|| (source->pDrawable
@@ -1311,7 +1311,6 @@ glamor_composite(CARD8 op,
goto fail;
}
}
-
if (!mask) {
if (glamor_composite_with_copy(op, temp_src, dest,
x_temp_src, y_temp_src,
@@ -1319,7 +1318,6 @@ glamor_composite(CARD8 op,
height))
goto done;
}
-
rect.x_src = x_temp_src;
rect.y_src = y_temp_src;
rect.x_mask = x_temp_mask;
@@ -1334,6 +1332,12 @@ glamor_composite(CARD8 op,
fail:
+ dispatch->glUseProgram(0);
+ dispatch->glDisable(GL_BLEND);
+ if (!fallback) {
+ ret = FALSE;
+ goto done;
+ }
glamor_fallback
("from picts %p:%p %dx%d / %p:%p %d x %d (%c,%c) to pict %p:%p %dx%d (%c)\n",
source, source->pDrawable,
@@ -1349,8 +1353,6 @@ glamor_composite(CARD8 op,
dest->pDrawable->width, dest->pDrawable->height,
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
(source, GLAMOR_ACCESS_RO)) {
@@ -1375,8 +1377,45 @@ glamor_composite(CARD8 op,
FreePicture(temp_src, 0);
if (temp_mask != mask)
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
@@ -1418,11 +1457,11 @@ glamor_create_mask_picture(ScreenPtr screen,
* glamor_trapezoids is a copy of miTrapezoids that does all the trapezoid
* accumulation in system memory.
*/
-void
-glamor_trapezoids(CARD8 op,
+static Bool
+_glamor_trapezoids(CARD8 op,
PicturePtr src, PicturePtr dst,
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
- int ntrap, xTrapezoid * traps)
+ int ntrap, xTrapezoid * traps, Bool fallback)
{
ScreenPtr screen = dst->pDrawable->pScreen;
BoxRec bounds;
@@ -1446,13 +1485,13 @@ glamor_trapezoids(CARD8 op,
for (; ntrap; ntrap--, traps++)
glamor_trapezoids(op, src, dst, mask_format, x_src,
y_src, 1, traps);
- return;
+ return TRUE;
}
miTrapezoidBounds(ntrap, traps, &bounds);
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
- return;
+ return TRUE;
x_dst = traps[0].left.p1.x >> 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,
width, height);
if (!picture)
- return;
+ return TRUE;
image = pixman_image_create_bits(picture->format,
width, height, NULL, stride);
if (!image) {
FreePicture(picture, 0);
- return;
+ return TRUE;
}
for (; ntrap; ntrap--, traps++)
@@ -1497,9 +1536,32 @@ glamor_trapezoids(CARD8 op,
pixman_image_unref(image);
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
glamor_composite_rects(CARD8 op,
PicturePtr src, PicturePtr mask, PicturePtr dst,
int nrect, glamor_composite_rect_t * rects)
diff --git a/glamor/glamor_triangles.c b/glamor/glamor_triangles.c
index 3cbdd55a8..b7ddd823e 100644
--- a/glamor/glamor_triangles.c
+++ b/glamor/glamor_triangles.c
@@ -32,14 +32,15 @@
#include "glamor_priv.h"
-void
-glamor_triangles(CARD8 op,
+static Bool
+_glamor_triangles(CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
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 (pSrc->pDrawable == NULL ||
glamor_prepare_access(pSrc->pDrawable,
@@ -53,4 +54,28 @@ glamor_triangles(CARD8 op,
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);
+}
+