Commit 92643353 authored by Zhigang Gong's avatar Zhigang Gong Committed by Eric Anholt

Added more drawing functions.

As we want to take over all the possible GC ops from the DDX
layer, we need to add all the missed functions.
This commit also fixed one bug at polylines.
We simply drop the bugy optimized code now, as it did not
consider of clip info.
Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent d42eb04c
......@@ -37,6 +37,9 @@ libglamor_la_SOURCES = \
glamor_triangles.c\
glamor_addtraps.c\
glamor_getimage.c\
glamor_copyplane.c\
glamor_glyphblt.c\
glamor_polyops.c\
glamor_pixmap.c\
glamor_picture.c\
glamor_window.c\
......
......@@ -270,3 +270,30 @@ extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
INT16 x_off,
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_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);
extern _X_EXPORT Bool glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
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_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_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
DDXPointPtr points);
/*
* Copyright © 2009 Intel Corporation
* Copyright © 1998 Keith Packard
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Zhigang Gong <zhigang.gong@gmail.com>
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
static Bool
_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)
&& glamor_ddx_fallback_check_pixmap(pSrc)
&& glamor_ddx_fallback_check_pixmap(pDst))
goto fail;
glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
*pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
dstx, dsty, bitPlane);
glamor_finish_access(pSrc, GLAMOR_ACCESS_RO);
glamor_finish_access(pDst, GLAMOR_ACCESS_RW);
return TRUE;
fail:
return FALSE;
}
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)
{
RegionPtr ret;
_glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
dstx, dsty, bitPlane, &ret, TRUE);
return ret;
}
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)
{
return _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
dstx, dsty, bitPlane, pRegion, FALSE);
}
......@@ -344,10 +344,10 @@ GCOps glamor_gc_ops = {
.SetSpans = glamor_set_spans,
.PutImage = glamor_put_image,
.CopyArea = glamor_copy_area,
.CopyPlane = miCopyPlane,
.PolyPoint = miPolyPoint,
.CopyPlane = glamor_copy_plane,
.PolyPoint = glamor_poly_point,
.Polylines = glamor_poly_lines,
.PolySegment = miPolySegment,
.PolySegment = glamor_poly_segment,
.PolyRectangle = miPolyRectangle,
.PolyArc = miPolyArc,
.FillPolygon = miFillPolygon,
......@@ -357,9 +357,9 @@ GCOps glamor_gc_ops = {
.PolyText16 = miPolyText16,
.ImageText8 = miImageText8,
.ImageText16 = miImageText16,
.ImageGlyphBlt = miImageGlyphBlt,
.PolyGlyphBlt = miPolyGlyphBlt,
.PushPixels = miPushPixels,
.ImageGlyphBlt = glamor_image_glyph_blt, //miImageGlyphBlt,
.PolyGlyphBlt = glamor_poly_glyph_blt, //miPolyGlyphBlt,
.PushPixels = glamor_push_pixels, //miPushPixels,
};
/**
......
/*
* Copyright © 2009 Intel Corporation
* Copyright © 1998 Keith Packard
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Zhigang Gong <zhigang.gong@gmail.com>
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
static Bool
_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)
&& glamor_ddx_fallback_check_gc(pGC))
goto fail;
glamor_prepare_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_prepare_access_gc(pGC);
fbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
glamor_finish_access_gc(pGC);
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
return TRUE;
fail:
return FALSE;
}
void
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);
}
Bool
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);
}
static Bool
_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)
&& glamor_ddx_fallback_check_gc(pGC))
goto fail;
glamor_prepare_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_prepare_access_gc(pGC);
fbPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
glamor_finish_access_gc(pGC);
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
return TRUE;
fail:
return FALSE;
}
void
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);
}
Bool
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);
}
static Bool
_glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
DrawablePtr pDrawable, int w, int h, int x, int y, Bool fallback)
{
if (!fallback
&& glamor_ddx_fallback_check_pixmap(pDrawable)
&& glamor_ddx_fallback_check_pixmap(&pBitmap->drawable)
&& glamor_ddx_fallback_check_gc(pGC))
goto fail;
glamor_prepare_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_prepare_access(&pBitmap->drawable, GLAMOR_ACCESS_RO);
glamor_prepare_access_gc(pGC);
fbPushPixels(pGC, pBitmap, pDrawable, w, h, x, y);
glamor_finish_access_gc(pGC);
glamor_finish_access(&pBitmap->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
return TRUE;
fail:
return FALSE;
}
void
glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
DrawablePtr pDrawable, int w, int h, int x, int y)
{
_glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, TRUE);
}
Bool
glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
DrawablePtr pDrawable, int w, int h, int x, int y)
{
return _glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, FALSE);
}
......@@ -42,26 +42,19 @@
* horizontal or vertical lines (rectangles), and uses existing rectangle fill
* acceleration if so.
*/
void
glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
DDXPointPtr points)
static Bool
_glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
DDXPointPtr points, Bool fallback)
{
xRectangle *rects;
int x1, x2, y1, y2;
int i;
int x_min = MAXSHORT;
int x_max = MINSHORT;
int y_min = MAXSHORT;
int y_max = MINSHORT;
DrawablePtr temp_dest;
PixmapPtr temp_pixmap;
GCPtr temp_gc = NULL;
/* Don't try to do wide lines or non-solid fill style. */
if (gc->lineWidth != 0) {
/* This ends up in miSetSpans, which is accelerated as well as we
* can hope X wide lines will be.
*/
goto fail;
goto wide_line;
}
if (gc->lineStyle != LineSolid || gc->fillStyle != FillSolid) {
glamor_fallback
......@@ -107,69 +100,40 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
}
gc->ops->PolyFillRect(drawable, gc, n - 1, rects);
free(rects);
return;
return TRUE;
fail:
for (i = 0; i < n; i++) {
if (x_min > points[i].x)
x_min = points[i].x;
if (x_max < points[i].x)
x_max = points[i].x;
if (y_min > points[i].y)
y_min = points[i].y;
if (y_max < points[i].y)
y_max = points[i].y;
}
temp_pixmap = glamor_create_pixmap(drawable->pScreen,
x_max - x_min + 1,
y_max - y_min + 1,
drawable->depth, 0);
if (temp_pixmap) {
temp_dest = &temp_pixmap->drawable;
temp_gc =
GetScratchGC(temp_dest->depth, temp_dest->pScreen);
ValidateGC(temp_dest, temp_gc);
for (i = 0; i < n; i++) {
points[i].x -= x_min;
points[i].y -= y_min;
}
(void) glamor_copy_area(drawable,
temp_dest,
temp_gc,
x_min, y_min,
x_max - x_min + 1,
y_max - y_min + 1, 0, 0);
} else
temp_dest = drawable;
if (!fallback
&& glamor_ddx_fallback_check_pixmap(drawable)
&& glamor_ddx_fallback_check_gc(gc))
return FALSE;
if (gc->lineWidth == 0) {
if (glamor_prepare_access(temp_dest, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {
fbPolyLine(temp_dest, gc, mode, n, points);
fbPolyLine(drawable, gc, mode, n, points);
glamor_finish_access_gc(gc);
}
glamor_finish_access(temp_dest, GLAMOR_ACCESS_RW);
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
}
} else {
wide_line:
/* fb calls mi functions in the lineWidth != 0 case. */
fbPolyLine(drawable, gc, mode, n, points);
}
if (temp_dest != drawable) {
(void) glamor_copy_area(temp_dest,
drawable,
temp_gc,
0, 0,
x_max - x_min + 1,
y_max - y_min + 1, x_min, y_min);
glamor_destroy_pixmap(temp_pixmap);
for (i = 0; i < n; i++) {
points[i].x += x_min;
points[i].y += y_min;
}
return TRUE;
}
FreeScratchGC(temp_gc);
}
void
glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
DDXPointPtr points)
{
_glamor_poly_lines(drawable, gc, mode, n, points, TRUE);
}
Bool
glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
DDXPointPtr points)
{
return _glamor_poly_lines(drawable, gc, mode, n, points, FALSE);
}
/*
* Copyright © 2009 Intel Corporation
* Copyright © 1998 Keith Packard
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Zhigang Gong <zhigang.gong@linux.intel.com>
*
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "glamor_priv.h"
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)
&& glamor_ddx_fallback_check_pixmap(pDrawable))
goto fail;
glamor_prepare_access_gc(pGC);
glamor_prepare_access(pDrawable, GLAMOR_ACCESS_RW);
fbPolyPoint(pDrawable, pGC, mode, npt, ppt);
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_finish_access_gc(pGC);
return TRUE;
fail:
return FALSE;
}
void
glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
DDXPointPtr ppt)
{
_glamor_poly_point(pDrawable, pGC, mode, npt, ppt, TRUE);
}
Bool
glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
DDXPointPtr ppt)
{
return _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, FALSE);
}
static Bool
_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
xSegment *pSeg, Bool fallback)
{
if (!fallback
&& glamor_ddx_fallback_check_gc(pGC)
&& glamor_ddx_fallback_check_pixmap(pDrawable))
goto fail;
/* For lineWidth is not zero, fb calls to mi functions. */
if (pGC->lineWidth == 0) {
glamor_prepare_access_gc(pGC);
glamor_prepare_access(pDrawable, GLAMOR_ACCESS_RW);
fbPolySegment(pDrawable, pGC, nseg, pSeg);
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_finish_access_gc(pGC);
} else
fbPolySegment(pDrawable, pGC, nseg, pSeg);
return TRUE;
fail:
return FALSE;
}
void
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
xSegment *pSeg)
{
_glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
}
Bool
glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
xSegment *pSeg)
{
return _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, FALSE);
}
static Bool
_glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
DDXPointPtr ppt, Bool fallback)
{
if (!fallback
&& glamor_ddx_fallback_check_gc(pGC)
&& glamor_ddx_fallback_check_pixmap(pDrawable))
goto fail;
/* For lineWidth is not zero, fb calls to mi functions. */
if (pGC->lineWidth == 0) {
glamor_prepare_access_gc(pGC);
glamor_prepare_access(pDrawable, GLAMOR_ACCESS_RW);
fbPolyLine(pDrawable, pGC, mode, npt, ppt);
glamor_finish_access(pDrawable, GLAMOR_ACCESS_RW);
glamor_finish_access_gc(pGC);
} else
fbPolyLine(pDrawable, pGC, mode, npt, ppt);
return TRUE;
fail:
return FALSE;
}
void
glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
DDXPointPtr ppt)
{
_glamor_poly_line(pDrawable, pGC, mode, npt, ppt, TRUE);
}
Bool
glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
DDXPointPtr ppt)
{
return _glamor_poly_line(pDrawable, pGC, mode, npt, ppt, FALSE);
}
......@@ -550,12 +550,42 @@ 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);
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);
#include"glamor_utils.h"
/* Dynamic pixmap upload to texture if needed.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment