From ba1b3b53240b5d499791570ba9f598a4e421c719 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Wed, 9 Nov 2011 16:09:03 +0800 Subject: [PATCH] Add new version glamor_fillspans without internal fallback. For the purpose of incrementally intergration of existing intel driver, for the GC operations we may don't want to use glamor's internal fallback which is in general much slower than the implementation in intel driver. If the parameter "fallback" is false when call the glamor_fillspans, then if glamor found it can't accelerate it then it will just return a FALSE rather than fallback to a slow path. Signed-off-by: Zhigang Gong --- glamor/glamor.h | 7 +++++++ glamor/glamor_fill.c | 5 +++-- glamor/glamor_fillspans.c | 33 ++++++++++++++++++++++++++++----- glamor/glamor_glyphs.c | 2 +- glamor/glamor_polyfillrect.c | 2 +- glamor/glamor_priv.h | 2 +- 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/glamor/glamor.h b/glamor/glamor.h index f9da4ade8..e98d7d5a5 100644 --- a/glamor/glamor.h +++ b/glamor/glamor.h @@ -79,3 +79,10 @@ extern _X_EXPORT void glamor_egl_free_screen(int scrnIndex, int flags); extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen); extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap); #endif + +extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable, + GCPtr gc, + int n, DDXPointPtr points, + int *widths, int sorted); + + diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c index 7a4325146..5fc350ba8 100644 --- a/glamor/glamor_fill.c +++ b/glamor/glamor_fill.c @@ -34,7 +34,7 @@ Bool glamor_fill(DrawablePtr drawable, - GCPtr gc, int x, int y, int width, int height) + GCPtr gc, int x, int y, int width, int height, Bool fallback) { PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable); int off_x, off_y; @@ -80,7 +80,9 @@ glamor_fill(DrawablePtr drawable, break; } return TRUE; + fail: + if (!fallback) return FALSE; if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) { if (glamor_prepare_access_gc(gc)) { fbFill(drawable, gc, x, y, width, height); @@ -89,7 +91,6 @@ glamor_fill(DrawablePtr drawable, glamor_finish_access(drawable); } return TRUE; - } void diff --git a/glamor/glamor_fillspans.c b/glamor/glamor_fillspans.c index a91e6a96a..996f0c5e8 100644 --- a/glamor/glamor_fillspans.c +++ b/glamor/glamor_fillspans.c @@ -30,10 +30,10 @@ */ #include "glamor_priv.h" -void -glamor_fill_spans(DrawablePtr drawable, +static Bool +_glamor_fill_spans(DrawablePtr drawable, GCPtr gc, - int n, DDXPointPtr points, int *widths, int sorted) + int n, DDXPointPtr points, int *widths, int sorted, Bool fallback) { DDXPointPtr ppt; int nbox; @@ -66,12 +66,15 @@ glamor_fill_spans(DrawablePtr drawable, if (x2 <= x1) continue; - glamor_fill(drawable, gc, x1, y, x2 - x1, 1); + if (!glamor_fill(drawable, gc, x1, y, x2 - x1, 1, fallback)) + goto fail; pbox++; } } - return; + return TRUE; + fail: + if (!fallback) return FALSE; glamor_fallback("to %p (%c)\n", drawable, glamor_get_drawable_location(drawable)); if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) { @@ -82,4 +85,24 @@ glamor_fill_spans(DrawablePtr drawable, } glamor_finish_access(drawable); } + return TRUE; } + + +void +glamor_fill_spans(DrawablePtr drawable, + GCPtr gc, + int n, DDXPointPtr points, int *widths, int sorted) +{ + _glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE); +} + +Bool +glamor_fill_spans_nf(DrawablePtr drawable, + GCPtr gc, + int n, DDXPointPtr points, int *widths, int sorted) +{ + return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE); +} + + diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c index 899dd9d8c..335540d92 100644 --- a/glamor/glamor_glyphs.c +++ b/glamor/glamor_glyphs.c @@ -690,7 +690,7 @@ 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); + glamor_fill(&mask_pixmap->drawable, gc, 0, 0, width, height, TRUE); FreeScratchGC(gc); x = -extents.x1; y = -extents.y1; diff --git a/glamor/glamor_polyfillrect.c b/glamor/glamor_polyfillrect.c index 762dfc255..eff63b6c0 100644 --- a/glamor/glamor_polyfillrect.c +++ b/glamor/glamor_polyfillrect.c @@ -87,7 +87,7 @@ glamor_poly_fill_rect(DrawablePtr drawable, if (x1 >= x2 || y1 >= y2) continue; if (!glamor_fill(drawable, gc, x1, y1, x2 - x1, - y2 - y1)) + y2 - y1, TRUE)) goto fail; } } diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 66c43591d..a40a508d2 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -370,7 +370,7 @@ int glamor_gl_get_version(void); /* glamor_fill.c */ Bool glamor_fill(DrawablePtr drawable, - GCPtr gc, int x, int y, int width, int height); + GCPtr gc, int x, int y, int width, int height, Bool fallback); Bool glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height, unsigned char alu, unsigned long planemask, unsigned long fg_pixel);