Thanks for the response mr. Daniel.<br><br>According to my understanding KDrive has been developed with more focus on embedded systems. So why do u want me to go for XOrg ( u mean XAA??) instead of KDrive??<br><br>I think the code which handles whether to call a hardware accelerated operation or software callback lies inside Kdrive code itself know. That code is already present in the Xserver/hw/kdrive/src folder.<br>
<br>Anyway for you reference i am posting the perticular code block below. In that i have added my hw accelerated blit call in (*pKaaScr->info->Copy) callback which will get called from KaaCopyNtoN() function.<br><br>
Do u have any ided why the mapping pScreen->PaintWindowBackground = kaaPaintWindow;<br>has been removed in the next versions?? and <br>why is the function kaaFillRegionTiled() is left unimplemented and commented??<br>
<br>please let me know if u want any more specific information.<br><br>#ifdef HAVE_CONFIG_H<br>#include <config.h><br>#endif<br>#include "kdrive.h"<br>#include "kaa.h"<br>#include "dixfontstr.h"<br>
<br>#define DEBUG_MIGRATE 0<br>#define DEBUG_PIXMAP 0<br>#if DEBUG_MIGRATE<br>#define DBG_MIGRATE(a) ErrorF a<br>#else<br>#define DBG_MIGRATE(a)<br>#endif<br>#if DEBUG_PIXMAP<br>#define DBG_PIXMAP(a) ErrorF a<br>#else<br>
#define DBG_PIXMAP(a)<br>#endif<br> <br>int kaaGeneration;<br>int kaaScreenPrivateIndex;<br>int kaaPixmapPrivateIndex;<br><br>#define KAA_PIXMAP_SCORE_MOVE_IN 10<br>#define KAA_PIXMAP_SCORE_MAX 20<br>#define KAA_PIXMAP_SCORE_MOVE_OUT -10<br>
#define KAA_PIXMAP_SCORE_MIN -20<br>#define KAA_PIXMAP_SCORE_PINNED 1000<br>#define KAA_PIXMAP_SCORE_INIT 1001<br><br>void<br>kaaDrawableDirty (DrawablePtr pDrawable)<br>{<br> PixmapPtr pPixmap;<br>
KaaPixmapPrivPtr pKaaPixmap;<br><br> if (pDrawable->type == DRAWABLE_WINDOW)<br> pPixmap = (*pDrawable->pScreen->GetWindowPixmap)((WindowPtr) pDrawable);<br> else<br> pPixmap = (PixmapPtr)pDrawable;<br>
<br> pKaaPixmap = KaaGetPixmapPriv(pPixmap);<br> if (pKaaPixmap != NULL)<br> pKaaPixmap->dirty = TRUE;<br>}<br><br>static void<br>kaaPixmapSave (ScreenPtr pScreen, KdOffscreenArea *area)<br>{<br> PixmapPtr pPixmap = area->privData;<br>
KaaPixmapPriv(pPixmap);<br> int dst_pitch, src_pitch, bytes;<br> unsigned char *dst, *src;<br> int i; <br> <br> DBG_MIGRATE (("Save 0x%08x (0x%x) (%dx%d)\n",<br> pPixmap-><a href="http://drawable.id">drawable.id</a>,<br>
KaaGetPixmapPriv(pPixmap)->area ? <br> KaaGetPixmapPriv(pPixmap)->area->offset : -1,<br> pPixmap->drawable.width,<br> pPixmap->drawable.height));<br> <br> src_pitch = pPixmap->devKind;<br>
dst_pitch = pKaaPixmap->devKind;<br><br> src = pPixmap->devPrivate.ptr;<br> dst = pKaaPixmap->devPrivate.ptr;<br> <br> pPixmap->devKind = dst_pitch;<br> pPixmap->devPrivate.ptr = dst;<br>
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;<br> pKaaPixmap->area = NULL;<br><br>#if 0<br> if (!pKaaPixmap->dirty)<br> return;<br>#endif<br><br> kaaWaitSync (pPixmap->drawable.pScreen);<br>
<br> bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;<br><br> i = pPixmap->drawable.height;<br> while (i--) {<br> memcpy (dst, src, bytes);<br> dst += dst_pitch;<br> src += src_pitch;<br> }<br>
}<br><br>static int<br>kaaLog2(int val)<br>{<br> int bits;<br><br> if (!val)<br> return 0;<br> for (bits = 0; val != 0; bits++)<br> val >>= 1;<br> return bits - 1;<br>}<br><br>static Bool<br>kaaPixmapAllocArea (PixmapPtr pPixmap)<br>
{<br> ScreenPtr pScreen = pPixmap->drawable.pScreen;<br> KaaScreenPriv (pScreen);<br> KaaPixmapPriv (pPixmap);<br> KdScreenPriv (pScreen);<br> int bpp = pPixmap->drawable.bitsPerPixel;<br> CARD16 h = pPixmap->drawable.height;<br>
CARD16 w = pPixmap->drawable.width;<br> int pitch;<br><br> if (pKaaScr->info->flags & KAA_OFFSCREEN_ALIGN_POT && w != 1)<br> w = 1 << (kaaLog2(w - 1) + 1);<br> pitch = (w * bpp / 8 + pKaaScr->info->pitchAlign - 1) &<br>
~(pKaaScr->info->pitchAlign - 1);<br> <br> pKaaPixmap->devKind = pPixmap->devKind;<br> pKaaPixmap->devPrivate = pPixmap->devPrivate;<br> pKaaPixmap->area = KdOffscreenAlloc (pScreen, pitch * h,<br>
pKaaScr->info->offsetAlign,<br> FALSE, <br> kaaPixmapSave, (pointer) pPixmap);<br> if (!pKaaPixmap->area)<br> return FALSE;<br> <br> DBG_PIXMAP(("++ 0x%08x (0x%x) (%dx%d)\n",<br>
pPixmap-><a href="http://drawable.id">drawable.id</a>,<br> KaaGetPixmapPriv(pPixmap)->area ? <br> KaaGetPixmapPriv(pPixmap)->area->offset : -1,<br> pPixmap->drawable.width,<br>
pPixmap->drawable.height));<br> pPixmap->devKind = pitch;<br> pPixmap->devPrivate.ptr = (pointer) ((CARD8 *) pScreenPriv->screen->memory_base + pKaaPixmap->area->offset);<br> pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;<br>
return TRUE;<br>}<br><br>void<br>kaaMoveInPixmap (PixmapPtr pPixmap)<br>{<br> ScreenPtr pScreen = pPixmap->drawable.pScreen;<br> KaaScreenPriv (pScreen);<br> KaaPixmapPriv (pPixmap);<br> int dst_pitch, src_pitch, bytes;<br>
unsigned char *dst, *src;<br> int i;<br><br> DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n",<br> pPixmap-><a href="http://drawable.id">drawable.id</a>,<br> KaaGetPixmapPriv(pPixmap)->area ? <br>
KaaGetPixmapPriv(pPixmap)->area->offset : -1,<br> pPixmap->drawable.width,<br> pPixmap->drawable.height));<br><br> src = pPixmap->devPrivate.ptr;<br> src_pitch = pPixmap->devKind;<br>
<br> if (!kaaPixmapAllocArea (pPixmap))<br> return;<br><br> pKaaPixmap->dirty = FALSE;<br><br> if (pKaaScr->info->UploadToScreen)<br> {<br> if (pKaaScr->info->UploadToScreen(pPixmap, src, src_pitch))<br>
return;<br> }<br><br> dst = pPixmap->devPrivate.ptr;<br> dst_pitch = pPixmap->devKind;<br> <br> bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;<br><br> kaaWaitSync (pPixmap->drawable.pScreen);<br>
<br> i = pPixmap->drawable.height;<br> while (i--) {<br> memcpy (dst, src, bytes);<br> dst += dst_pitch;<br> src += src_pitch;<br> }<br>}<br><br>static void<br>kaaMoveOutPixmap (PixmapPtr pPixmap)<br>
{<br> KaaPixmapPriv (pPixmap);<br> KdOffscreenArea *area = pKaaPixmap->area;<br><br> DBG_MIGRATE (("<- 0x%08x (0x%x) (%dx%d)\n",<br> pPixmap-><a href="http://drawable.id">drawable.id</a>,<br>
KaaGetPixmapPriv(pPixmap)->area ? <br> KaaGetPixmapPriv(pPixmap)->area->offset : -1,<br> pPixmap->drawable.width,<br> pPixmap->drawable.height));<br> if (area)<br> {<br>
kaaPixmapSave (pPixmap->drawable.pScreen, area);<br> KdOffscreenFree (pPixmap->drawable.pScreen, area);<br> }<br>}<br><br>void<br>kaaPixmapUseScreen (PixmapPtr pPixmap)<br>{<br> KaaPixmapPriv (pPixmap);<br>
<br> if (pKaaPixmap == NULL)<br> return;<br><br> if (pKaaPixmap->score == KAA_PIXMAP_SCORE_PINNED)<br> return;<br><br> if (pKaaPixmap->score == KAA_PIXMAP_SCORE_INIT) {<br> kaaMoveInPixmap(pPixmap);<br>
pKaaPixmap->score = 0;<br> }<br><br> if (pKaaPixmap->score < KAA_PIXMAP_SCORE_MAX)<br> {<br> pKaaPixmap->score++;<br> if (!kaaPixmapIsOffscreen(pPixmap) &&<br> pKaaPixmap->score >= KAA_PIXMAP_SCORE_MOVE_IN)<br>
kaaMoveInPixmap (pPixmap);<br> }<br> KdOffscreenMarkUsed (pPixmap);<br>}<br><br>void<br>kaaPixmapUseMemory (PixmapPtr pPixmap)<br>{<br> KaaPixmapPriv (pPixmap);<br><br> if (pKaaPixmap == NULL)<br> return;<br>
<br> if (pKaaPixmap->score == KAA_PIXMAP_SCORE_PINNED)<br> return;<br><br> if (pKaaPixmap->score == KAA_PIXMAP_SCORE_INIT)<br> pKaaPixmap->score = 0;<br><br> if (pKaaPixmap->score > KAA_PIXMAP_SCORE_MIN)<br>
{<br> pKaaPixmap->score--;<br> if (pKaaPixmap->area &&<br> pKaaPixmap->score <= KAA_PIXMAP_SCORE_MOVE_OUT)<br> kaaMoveOutPixmap (pPixmap);<br> }<br>}<br><br>static Bool<br>kaaDestroyPixmap (PixmapPtr pPixmap)<br>
{<br> if (pPixmap->refcnt == 1)<br> {<br> KaaPixmapPriv (pPixmap);<br> if (pKaaPixmap->area)<br> {<br> DBG_PIXMAP(("-- 0x%08x (0x%x) (%dx%d)\n",<br> pPixmap-><a href="http://drawable.id">drawable.id</a>,<br>
KaaGetPixmapPriv(pPixmap)->area->offset,<br> pPixmap->drawable.width,<br> pPixmap->drawable.height));<br> /* Free the offscreen area */<br> KdOffscreenFree (pPixmap->drawable.pScreen, pKaaPixmap->area);<br>
pPixmap->devPrivate = pKaaPixmap->devPrivate;<br> pPixmap->devKind = pKaaPixmap->devKind;<br> }<br> }<br> return fbDestroyPixmap (pPixmap);<br>}<br><br>static PixmapPtr <br>kaaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)<br>
{<br> PixmapPtr pPixmap;<br> KaaPixmapPrivPtr pKaaPixmap;<br> int bpp;<br> <br> bpp = BitsPerPixel (depth);<br> if (bpp == 32 && depth == 24)<br> {<br> int fb;<br> KdScreenPriv (pScreen);<br>
<br> for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)<br> if (pScreenPriv->screen->fb[fb].depth == 24)<br> {<br> bpp = pScreenPriv->screen->fb[fb].bitsPerPixel;<br>
break;<br> }<br> }<br><br> pPixmap = fbCreatePixmapBpp (pScreen, w, h, depth, bpp);<br> if (!pPixmap)<br> return NULL;<br> pKaaPixmap = KaaGetPixmapPriv(pPixmap);<br> if (!w || !h)<br> pKaaPixmap->score = KAA_PIXMAP_SCORE_PINNED;<br>
else<br> pKaaPixmap->score = KAA_PIXMAP_SCORE_INIT;<br> <br> pKaaPixmap->area = NULL;<br> pKaaPixmap->dirty = FALSE;<br><br> return pPixmap;<br>}<br><br>Bool<br>kaaPixmapIsOffscreen(PixmapPtr p)<br>
{<br> ScreenPtr pScreen = p->drawable.pScreen;<br> KdScreenPriv(pScreen);<br><br> return ((unsigned long) ((CARD8 *) p->devPrivate.ptr - <br> (CARD8 *) pScreenPriv->screen->memory_base) <<br>
pScreenPriv->screen->memory_size);<br>}<br><br>PixmapPtr<br>kaaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)<br>{<br> PixmapPtr pPixmap;<br> int x, y;<br> <br> if (pDrawable->type == DRAWABLE_WINDOW) {<br>
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);<br>#ifdef COMPOSITE<br> x = -pPixmap->screen_x;<br> y = -pPixmap->screen_y;<br>#else<br> x = 0;<br> y = 0;<br>#endif<br>
}<br> else<br> {<br> pPixmap = (PixmapPtr) pDrawable;<br> x = 0;<br> y = 0;<br> }<br> *xp = x;<br> *yp = y;<br> if (kaaPixmapIsOffscreen (pPixmap))<br> return pPixmap;<br> else<br> return NULL;<br>
}<br><br>Bool<br>kaaDrawableIsOffscreen (DrawablePtr pDrawable)<br>{<br> PixmapPtr pPixmap;<br> if (pDrawable->type == DRAWABLE_WINDOW)<br> pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);<br>
else<br> pPixmap = (PixmapPtr) pDrawable;<br> return kaaPixmapIsOffscreen (pPixmap);<br>}<br><br>#if 0<br>static void<br>kaaFillTiled(int dst_x,<br> int dst_y,<br> int width,<br> int height,<br>
int src_x,<br> int src_y,<br> int src_width,<br> int src_height,<br> void (*Copy) (int srcX,<br> int srcY,<br> int dstX,<br>
int dstY,<br> int width,<br> int height))<br>{<br> modulus (src_x, src_width, src_x);<br> modulus (src_y, src_height, src_y);<br> <br> while (height)<br>
{<br> int dst_x_tmp = dst_x;<br> int src_x_tmp = src_x;<br> int width_tmp = width;<br> int height_left = src_height - src_y;<br> int height_this = min (height, height_left);<br> <br> while (width_tmp)<br>
{<br> int width_left = src_width - src_x_tmp;<br> int width_this = min (width_tmp, width_left);<br><br> (*Copy) (src_x_tmp, src_y,<br> dst_x_tmp, dst_y,<br> width_this, height_this);<br>
<br> width_tmp -= width_this;<br> dst_x_tmp += width_this;<br> }<br> height -= height_this;<br> dst_y += height_this;<br> src_y = 0;<br> }<br>}<br>#endif<br><br>static void<br>kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, <br>
DDXPointPtr ppt, int *pwidth, int fSorted)<br>{<br> ScreenPtr pScreen = pDrawable->pScreen;<br> KdScreenPriv (pScreen);<br> KaaScreenPriv (pScreen);<br> RegionPtr pClip = fbGetCompositeClip(pGC);<br>
PixmapPtr pPixmap; <br> BoxPtr pextent, pbox;<br> int nbox;<br> int extentX1, extentX2, extentY1, extentY2;<br> int fullX1, fullX2, fullY1;<br> int partX1, partX2;<br>
int off_x, off_y;<br><br> if (!pScreenPriv->enabled ||<br> pGC->fillStyle != FillSolid ||<br> !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &off_x, &off_y)) ||<br> !(*pKaaScr->info->PrepareSolid) (pPixmap,<br>
pGC->alu,<br> pGC->planemask,<br> pGC->fgPixel))<br> {<br> KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);<br> return;<br> }<br>
<br> pextent = REGION_EXTENTS(pGC->pScreen, pClip);<br> extentX1 = pextent->x1;<br> extentY1 = pextent->y1;<br> extentX2 = pextent->x2;<br> extentY2 = pextent->y2;<br> while (n--)<br> {<br>
fullX1 = ppt->x;<br> fullY1 = ppt->y;<br> fullX2 = fullX1 + (int) *pwidth;<br> ppt++;<br> pwidth++;<br> <br> if (fullY1 < extentY1 || extentY2 <= fullY1)<br> continue;<br> <br> if (fullX1 < extentX1)<br>
fullX1 = extentX1;<br><br> if (fullX2 > extentX2)<br> fullX2 = extentX2;<br> <br> if (fullX1 >= fullX2)<br> continue;<br> <br> nbox = REGION_NUM_RECTS (pClip);<br> if (nbox == 1)<br>
{<br> (*pKaaScr->info->Solid) (fullX1 + off_x, fullY1 + off_y,<br> fullX2 + off_x, fullY1 + 1 + off_y);<br> }<br> else<br> {<br> pbox = REGION_RECTS(pClip);<br> while(nbox--)<br>
{<br> if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)<br> {<br> partX1 = pbox->x1;<br> if (partX1 < fullX1)<br> partX1 = fullX1;<br> partX2 = pbox->x2;<br>
if (partX2 > fullX2)<br> partX2 = fullX2;<br> if (partX2 > partX1)<br> (*pKaaScr->info->Solid) (partX1 + off_x, fullY1 + off_y,<br> partX2 + off_x, fullY1 + 1 + off_y);<br>
}<br> pbox++;<br> }<br> }<br> }<br> (*pKaaScr->info->DoneSolid) ();<br> kaaDrawableDirty (pDrawable);<br> kaaMarkSync (pDrawable->pScreen);<br>}<br><br>void<br>kaaCopyNtoN (DrawablePtr pSrcDrawable,<br>
DrawablePtr pDstDrawable,<br> GCPtr pGC,<br> BoxPtr pbox,<br> int nbox,<br> int dx,<br> int dy,<br> Bool reverse,<br> Bool upsidedown,<br>
Pixel bitplane,<br> void *closure)<br>{<br> KdScreenPriv (pDstDrawable->pScreen);<br> KaaScreenPriv (pDstDrawable->pScreen);<br> PixmapPtr pSrcPixmap, pDstPixmap;<br> int src_off_x, src_off_y;<br>
int dst_off_x, dst_off_y;<br><br> /* Migrate pixmaps to same place as destination */<br> if (pScreenPriv->enabled && pSrcDrawable->type == DRAWABLE_PIXMAP) {<br> if (kaaDrawableIsOffscreen (pDstDrawable))<br>
kaaPixmapUseScreen ((PixmapPtr) pSrcDrawable);<br> else<br> kaaPixmapUseMemory ((PixmapPtr) pSrcDrawable);<br> }<br><br> if (pScreenPriv->enabled &&<br> (pSrcPixmap = kaaGetOffscreenPixmap (pSrcDrawable, &src_off_x, &src_off_y)) &&<br>
(pDstPixmap = kaaGetOffscreenPixmap (pDstDrawable, &dst_off_x, &dst_off_y)) && <br> (*pKaaScr->info->PrepareCopy) (pSrcPixmap,<br> pDstPixmap,<br> dx,<br>
dy,<br> pGC ? pGC->alu : GXcopy,<br> pGC ? pGC->planemask : FB_ALLONES))<br> {<br> while (nbox--)<br> {<br> (*pKaaScr->info->Copy) (pbox->x1 + dx + src_off_x,<br>
pbox->y1 + dy + src_off_y,<br> pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,<br> pbox->x2 - pbox->x1,<br> pbox->y2 - pbox->y1);<br>
pbox++;<br> }<br> (*pKaaScr->info->DoneCopy) ();<br> kaaMarkSync (pDstDrawable->pScreen);<br> }<br> else<br> {<br> kaaWaitSync (pDstDrawable->pScreen);<br> fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, <br>
pbox, nbox, dx, dy, reverse, upsidedown, <br> bitplane, closure);<br> }<br> kaaDrawableDirty (pDstDrawable);<br>}<br><br>static RegionPtr<br>kaaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,<br>
int srcx, int srcy, int width, int height, int dstx, int dsty)<br>{<br> return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, <br> srcx, srcy, width, height, <br> dstx, dsty, kaaCopyNtoN, 0, 0);<br>
}<br><br>static void<br>kaaPolyFillRect(DrawablePtr pDrawable, <br> GCPtr pGC, <br> int nrect,<br> xRectangle *prect)<br>{<br> KdScreenPriv (pDrawable->pScreen);<br> KaaScreenPriv (pDrawable->pScreen);<br>
RegionPtr pClip = fbGetCompositeClip(pGC);<br> PixmapPtr pPixmap;<br> register BoxPtr pbox;<br> BoxPtr pextent;<br> int extentX1, extentX2, extentY1, extentY2;<br> int fullX1, fullX2, fullY1, fullY2;<br>
int partX1, partX2, partY1, partY2;<br> int xoff, yoff;<br> int xorg, yorg;<br> int n;<br> <br> if (!pScreenPriv->enabled ||<br> pGC->fillStyle != FillSolid ||<br>
!(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) || <br> !(*pKaaScr->info->PrepareSolid) (pPixmap,<br> pGC->alu,<br> pGC->planemask,<br> pGC->fgPixel))<br>
{<br> KdCheckPolyFillRect (pDrawable, pGC, nrect, prect);<br> return;<br> }<br> <br> xorg = pDrawable->x;<br> yorg = pDrawable->y;<br> <br> pextent = REGION_EXTENTS(pGC->pScreen, pClip);<br>
extentX1 = pextent->x1;<br> extentY1 = pextent->y1;<br> extentX2 = pextent->x2;<br> extentY2 = pextent->y2;<br> while (nrect--)<br> {<br> fullX1 = prect->x + xorg;<br> fullY1 = prect->y + yorg;<br>
fullX2 = fullX1 + (int) prect->width;<br> fullY2 = fullY1 + (int) prect->height;<br> prect++;<br> <br> if (fullX1 < extentX1)<br> fullX1 = extentX1;<br><br> if (fullY1 < extentY1)<br>
fullY1 = extentY1;<br><br> if (fullX2 > extentX2)<br> fullX2 = extentX2;<br> <br> if (fullY2 > extentY2)<br> fullY2 = extentY2;<br><br> if ((fullX1 >= fullX2) || (fullY1 >= fullY2))<br>
continue;<br> n = REGION_NUM_RECTS (pClip);<br> if (n == 1)<br> {<br> (*pKaaScr->info->Solid) (fullX1 + xoff, fullY1 + yoff,<br> fullX2 + xoff, fullY2 + yoff);<br> }<br>
else<br> {<br> pbox = REGION_RECTS(pClip);<br> /* <br> * clip the rectangle to each box in the clip region<br> * this is logically equivalent to calling Intersect()<br> */<br> while(n--)<br>
{<br> partX1 = pbox->x1;<br> if (partX1 < fullX1)<br> partX1 = fullX1;<br> partY1 = pbox->y1;<br> if (partY1 < fullY1)<br> partY1 = fullY1;<br> partX2 = pbox->x2;<br>
if (partX2 > fullX2)<br> partX2 = fullX2;<br> partY2 = pbox->y2;<br> if (partY2 > fullY2)<br> partY2 = fullY2;<br> <br> pbox++;<br> <br> if (partX1 < partX2 && partY1 < partY2)<br>
(*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff,<br> partX2 + xoff, partY2 + yoff);<br> }<br> }<br> }<br> (*pKaaScr->info->DoneSolid) ();<br> kaaDrawableDirty (pDrawable);<br>
kaaMarkSync (pDrawable->pScreen);<br>}<br> <br>static void<br>kaaSolidBoxClipped (DrawablePtr pDrawable,<br> RegionPtr pClip,<br> FbBits pm,<br> FbBits fg,<br> int x1,<br>
int y1,<br> int x2,<br> int y2)<br>{<br> KdScreenPriv (pDrawable->pScreen);<br> KaaScreenPriv (pDrawable->pScreen);<br> PixmapPtr pPixmap; <br>
BoxPtr pbox;<br> int nbox;<br> int xoff, yoff;<br> int partX1, partX2, partY1, partY2;<br><br> if (!pScreenPriv->enabled ||<br> !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) ||<br>
!(*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg))<br> {<br> kaaWaitSync (pDrawable->pScreen);<br> fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);<br> fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2,<br>
fbAnd (GXcopy, fg, pm),<br> fbXor (GXcopy, fg, pm));<br> kaaDrawableDirty (pDrawable);<br> return;<br> }<br> for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip); <br> nbox--; <br>
pbox++)<br> {<br> partX1 = pbox->x1;<br> if (partX1 < x1)<br> partX1 = x1;<br> <br> partX2 = pbox->x2;<br> if (partX2 > x2)<br> partX2 = x2;<br> <br> if (partX2 <= partX1)<br>
continue;<br> <br> partY1 = pbox->y1;<br> if (partY1 < y1)<br> partY1 = y1;<br> <br> partY2 = pbox->y2;<br> if (partY2 > y2)<br> partY2 = y2;<br> <br> if (partY2 <= partY1)<br>
continue;<br> <br> (*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff,<br> partX2 + xoff, partY2 + yoff);<br> }<br> (*pKaaScr->info->DoneSolid) ();<br> kaaDrawableDirty (pDrawable);<br>
kaaMarkSync (pDrawable->pScreen);<br>}<br><br>static void<br>kaaImageGlyphBlt (DrawablePtr pDrawable,<br> GCPtr pGC,<br> int x, <br> int y,<br> unsigned int nglyph,<br>
CharInfoPtr *ppciInit,<br> pointer pglyphBase)<br>{<br> FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);<br> CharInfoPtr *ppci;<br> CharInfoPtr pci;<br> unsigned char *pglyph; /* pointer bits in glyph */<br>
int gWidth, gHeight; /* width and height of glyph */<br> FbStride gStride; /* stride of glyph */<br> Bool opaque;<br> int n;<br> int gx, gy;<br> void (*glyph) (FbBits *,<br>
FbStride,<br> int,<br> FbStip *,<br> FbBits,<br> int,<br> int);<br> FbBits *dst;<br> FbStride dstStride;<br>
int dstBpp;<br> int dstXoff, dstYoff;<br> FbBits depthMask;<br> <br> depthMask = FbFullMask(pDrawable->depth);<br> if ((pGC->planemask & depthMask) != depthMask)<br>
{<br> KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);<br> return;<br> }<br> glyph = 0;<br> fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);<br> switch (dstBpp) {<br>
case 8: glyph = fbGlyph8; break;<br> case 16: glyph = fbGlyph16; break;<br> case 24: glyph = fbGlyph24; break;<br> case 32: glyph = fbGlyph32; break;<br> }<br> <br> x += pDrawable->x;<br>
y += pDrawable->y;<br><br> if (TERMINALFONT (pGC->font) && !glyph)<br> {<br> opaque = TRUE;<br> }<br> else<br> {<br> int xBack, widthBack;<br> int yBack, heightBack;<br>
<br> ppci = ppciInit;<br> n = nglyph;<br> widthBack = 0;<br> while (n--)<br> widthBack += (*ppci++)->metrics.characterWidth;<br> <br> xBack = x;<br> if (widthBack < 0)<br> {<br>
xBack += widthBack;<br> widthBack = -widthBack;<br> }<br> yBack = y - FONTASCENT(pGC->font);<br> heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);<br> kaaSolidBoxClipped (pDrawable,<br>
fbGetCompositeClip(pGC),<br> pGC->planemask,<br> pGC->bgPixel,<br> xBack,<br> yBack,<br> xBack + widthBack,<br> yBack + heightBack);<br>
opaque = FALSE;<br> }<br><br> kaaWaitSync (pDrawable->pScreen);<br> kaaDrawableDirty (pDrawable);<br> <br> ppci = ppciInit;<br> while (nglyph--)<br> {<br> pci = *ppci++;<br> pglyph = FONTGLYPHBITS(pglyphBase, pci);<br>
gWidth = GLYPHWIDTHPIXELS(pci);<br> gHeight = GLYPHHEIGHTPIXELS(pci);<br> if (gWidth && gHeight)<br> {<br> gx = x + pci->metrics.leftSideBearing;<br> gy = y - pci->metrics.ascent; <br>
if (glyph && gWidth <= sizeof (FbStip) * 8 &&<br> fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))<br> {<br> (*glyph) (dst + (gy + dstYoff) * dstStride,<br> dstStride,<br>
dstBpp,<br> (FbStip *) pglyph,<br> pPriv->fg,<br> gx + dstXoff,<br> gHeight);<br> }<br> else<br> {<br> gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);<br>
fbPutXYImage (pDrawable,<br> fbGetCompositeClip(pGC),<br> pPriv->fg,<br> pPriv->bg,<br> pPriv->pm,<br> GXcopy,<br> opaque,<br>
<br> gx,<br> gy,<br> gWidth, gHeight,<br> <br> (FbStip *) pglyph,<br> gStride,<br> 0);<br> }<br> }<br>
x += pci->metrics.characterWidth;<br> }<br>}<br><br>static const GCOps kaaOps = {<br> kaaFillSpans,<br> KdCheckSetSpans,<br> KdCheckPutImage,<br> kaaCopyArea,<br> KdCheckCopyPlane,<br> KdCheckPolyPoint,<br>
KdCheckPolylines,<br> KdCheckPolySegment,<br> miPolyRectangle,<br> KdCheckPolyArc,<br> miFillPolygon,<br> kaaPolyFillRect,<br> miPolyFillArc,<br> miPolyText8,<br> miPolyText16,<br> miImageText8,<br>
miImageText16,<br> kaaImageGlyphBlt,<br> KdCheckPolyGlyphBlt,<br> KdCheckPushPixels,<br>#ifdef NEED_LINEHELPER<br> ,NULL<br>#endif<br>};<br><br>static void<br>kaaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)<br>
{<br> fbValidateGC (pGC, changes, pDrawable);<br><br> if (kaaDrawableIsOffscreen (pDrawable))<br> pGC->ops = (GCOps *) &kaaOps;<br> else<br> pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;<br>}<br><br>
GCFuncs kaaGCFuncs = {<br> kaaValidateGC,<br> miChangeGC,<br> miCopyGC,<br> miDestroyGC,<br> miChangeClip,<br> miDestroyClip,<br> miCopyClip<br>};<br><br>static int<br>kaaCreateGC (GCPtr pGC)<br>{<br>
if (!fbCreateGC (pGC))<br> return FALSE;<br><br> pGC->funcs = &kaaGCFuncs;<br><br> return TRUE;<br>}<br><br><br>static void<br>kaaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)<br>
{<br> RegionRec rgnDst;<br> int dx, dy;<br> PixmapPtr pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);<br><br> dx = ptOldOrg.x - pWin->drawable.x;<br> dy = ptOldOrg.y - pWin->drawable.y;<br>
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);<br><br> REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);<br> <br> REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);<br>
#ifdef COMPOSITE<br> if (pPixmap->screen_x || pPixmap->screen_y)<br> REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, <br> -pPixmap->screen_x, -pPixmap->screen_y);<br>#endif<br><br>
fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,<br> 0,<br> &rgnDst, dx, dy, kaaCopyNtoN, 0, 0);<br> <br> REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);<br>}<br><br>
static void<br>kaaFillRegionSolid (DrawablePtr pDrawable,<br> RegionPtr pRegion,<br> Pixel pixel)<br>{<br> KdScreenPriv(pDrawable->pScreen);<br> KaaScreenPriv(pDrawable->pScreen);<br>
PixmapPtr pPixmap;<br> int xoff, yoff;<br><br> if (pScreenPriv->enabled &&<br> (pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) &&<br> (*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel))<br>
{<br> int nbox = REGION_NUM_RECTS (pRegion);<br> BoxPtr pBox = REGION_RECTS (pRegion);<br> <br> while (nbox--)<br> {<br> (*pKaaScr->info->Solid) (pBox->x1 + xoff, pBox->y1 + yoff,<br>
pBox->x2 + xoff, pBox->y2 + yoff);<br> pBox++;<br> }<br> (*pKaaScr->info->DoneSolid) ();<br> kaaMarkSync (pDrawable->pScreen);<br> }<br> else<br> {<br> kaaWaitSync (pDrawable->pScreen);<br>
fbFillRegionSolid (pDrawable, pRegion, 0,<br> fbReplicatePixel (pixel, pDrawable->bitsPerPixel));<br> }<br> kaaDrawableDirty (pDrawable);<br>}<br><br>#if 0<br>static void<br>kaaFillRegionTiled (DrawablePtr pDrawable,<br>
RegionPtr pRegion,<br> PixmapPtr pTile)<br>{<br> KdScreenPriv(pDrawable->pScreen);<br> KaaScreenPriv(pDrawable->pScreen);<br> PixmapPtr pPixmap;<br> int xoff, yoff;<br> int tileWidth, tileHeight;<br>
int nbox = REGION_NUM_RECTS (pRegion);<br> BoxPtr pBox = REGION_RECTS (pRegion);<br> Bool ret = FALSE;<br><br> tileWidth = pTile->drawable.width;<br> tileHeight = pTile->drawable.height;<br><br> /* If we're filling with a solid color, grab it out and go to<br>
* FillRegionSolid, saving numerous copies.<br> */<br> if (tileWidth == 1 && tileHeight == 1)<br> return kaaFillRegionSolid(pDrawable, pRegion,<br> exaGetPixmapFirstPixel (pTile), planemask,<br>
alu);<br> <br> REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);<br> <br> <br> if (pScreenPriv->enabled &&<br> (pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) &&<br>
(*pKaaScr->info->PrepareCopy) (pTile, pPixmap, 1, 1, GXcopy, FB_ALLONES))<br> {<br><br> if ((*pKaaScr->info->PrepareCopy) (pTile, pPixmap, 1, 1, alu, planemask))<br> {<br> while (nbox--)<br>
{<br> int height = pBox->y2 - pBox->y1;<br> int dstY = pBox->y1;<br> int tileY;<br><br> modulus(dstY - yoff - pDrawable->y - (WindowPtr)pDrawable->origin.y, tileHeight, tileY);<br>
<br> while (height > 0) {<br> int width = pBox->x2 - pBox->x1;<br> int dstX = pBox->x1;<br> int tileX;<br> int h = tileHeight - tileY;<br><br> if (h > height)<br> h = height;<br>
height -= h;<br><br> modulus(dstX - xoff - pDrawable->x - pPatOrg->x, tileWidth,<br> tileX);<br><br> while (width > 0) {<br> int w = tileWidth - tileX;<br> if (w > width)<br>
w = width;<br> width -= w;<br><br> (*pKaaScr->info->Copy) (pPixmap, tileX, tileY, dstX, dstY,<br> w, h);<br> dstX += w;<br> tileX = 0;<br>
}<br> dstY += h;<br> tileY = 0;<br> }<br> pBox++;<br> }<br> (*pKaaScr->info->DoneCopy) (pPixmap);<br> kaaMarkSync(pDrawable->pScreen);<br><br> ret = TRUE;<br> }<br>
<br> return ret;<br>}<br>#endif<br><br>static void<br>kaaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)<br>{<br><br> if (!REGION_NUM_RECTS(pRegion)) <br> return;<br> switch (what) {<br> case PW_BACKGROUND:<br>
switch (pWin->backgroundState) {<br> case None:<br> return;<br> case ParentRelative:<br> do {<br> pWin = pWin->parent;<br> } while (pWin->backgroundState == ParentRelative);<br>
(*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,<br> what);<br> return;<br> case BackgroundPixel:<br> kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel);<br>
return;<br>#if 0 <br> case BackgroundPixmap:<br> kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap);<br> return;<br>#endif<br> }<br> break;<br> case PW_BORDER:<br>
if (pWin->borderIsPixel)<br> {<br> kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel);<br> return;<br> }<br>#if 0<br> else<br> {<br> kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap);<br>
return;<br> }<br>#endif<br> break;<br> }<br> KdCheckPaintWindow (pWin, pRegion, what);<br>}<br><br>Bool<br>kaaDrawInit (ScreenPtr pScreen,<br> KaaScreenInfoPtr pScreenInfo)<br>{<br> KaaScreenPrivPtr pKaaScr;<br>
KdScreenPriv(pScreen);<br> KdScreenInfo *screen = pScreenPriv->screen;<br>#ifdef RENDER<br> PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);<br>#endif<br> <br> if (kaaGeneration != serverGeneration)<br>
{<br> kaaScreenPrivateIndex = AllocateScreenPrivateIndex();<br> kaaPixmapPrivateIndex = AllocatePixmapPrivateIndex();<br> kaaGeneration = serverGeneration;<br> }<br><br> pKaaScr = xalloc (sizeof (KaaScreenPrivRec));<br>
<br> if (!pKaaScr)<br> return FALSE;<br> <br> pKaaScr->info = pScreenInfo;<br> <br> pScreen->devPrivates[kaaScreenPrivateIndex].ptr = (pointer) pKaaScr;<br> <br> /*<br> * Hook up asynchronous drawing<br>
*/<br> KdScreenInitAsync (pScreen);<br> /*<br> * Replace various fb screen functions<br> */<br> pScreen->CreateGC = kaaCreateGC;<br> pScreen->CopyWindow = kaaCopyWindow;<br> pScreen->PaintWindowBackground = kaaPaintWindow;<br>
pScreen->PaintWindowBorder = kaaPaintWindow;<br>#ifdef RENDER<br> if (ps) {<br> ps->Composite = kaaComposite;<br> ps->RasterizeTrapezoid = kaaRasterizeTrapezoid;<br> }<br>#endif<br><br> /*<br> * Hookup offscreen pixmaps<br>
*/<br> if ((pKaaScr->info->flags & KAA_OFFSCREEN_PIXMAPS) &&<br> screen->off_screen_base < screen->memory_size)<br> {<br> if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex,<br>
sizeof (KaaPixmapPrivRec)))<br> return FALSE;<br> pScreen->CreatePixmap = kaaCreatePixmap;<br> pScreen->DestroyPixmap = kaaDestroyPixmap;<br> }<br> else<br> {<br> if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex, 0))<br>
return FALSE;<br> }<br><br> return TRUE;<br>}<br><br>void<br>kaaDrawFini (ScreenPtr pScreen)<br>{<br> KaaScreenPriv(pScreen);<br><br> xfree (pKaaScr);<br>}<br><br>void<br>kaaMarkSync (ScreenPtr pScreen)<br>
{<br> KdScreenPriv(pScreen);<br> KaaScreenPriv(pScreen);<br><br> pScreenPriv->card->needSync = TRUE;<br> if (pKaaScr->info->markSync != NULL) {<br> pScreenPriv->card->lastMarker = (*pKaaScr->info->markSync) (pScreen);<br>
}<br>}<br><br>void<br>kaaWaitSync (ScreenPtr pScreen)<br>{<br> KdScreenPriv(pScreen);<br> KaaScreenPriv(pScreen);<br> KdCardInfo *card = pScreenPriv->card;<br><br> if (card->needSync) {<br> (*pKaaScr->info->waitMarker) (pScreen, card->lastMarker);<br>
card->needSync = FALSE;<br> }<br>}<br><br><br><div class="gmail_quote">On Fri, Oct 30, 2009 at 12:45 PM, Daniel Stone <span dir="ltr"><<a href="mailto:daniel@fooishbar.org">daniel@fooishbar.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">Hi,<br>
<br>
On Fri, Oct 30, 2009 at 11:04:57AM +0530, prudhvi raj wrote:<br>
</div><div><div></div><div class="h5">> I have added the acceleration support to the Xfbdev server (in X windows<br>
> version 11 release 7.4) in order to improve the performance on ARM 11 board.<br>
> Among the accelerated hooks supported by KAA we have implemented<br>
> polyFillRect and CopyArea.<br>
><br>
> But when we run some client application on this accelerated server the calls<br>
> to the accelerated copyArea (which internally calls the hardware bitBlit<br>
> function) are coming very less frequently compared to the software blit<br>
> calls.<br>
><br>
> During my observation i have found some partially implemented functions like<br>
> kaaFillRegionTiled() etc which may internally call the blit operation<br>
> through (*pKaaScr->info->Copy) hook.<br>
><br>
> If at all this function could help to improve the performance of blit, can<br>
> you provide the fully implemented kaaFillRegionTiled().<br>
><br>
> When i have run one sample client application (gtkDemo) the fbBlt() function<br>
> got called around 40000 times where as the hardware accelerated blit<br>
> function called through kaaCopyNtoN (which calls (*pKaaScr->info->Copy)<br>
> internally) very few times (around 2500 times only) compared to fbBlt.<br>
><br>
> Can you provide more clarity why are most of the Blit calls are routed<br>
> through software fallbacks.<br>
<br>
</div></div><div><div></div><div class="h5">Firstly, we very strongly recommend using Xorg instead of KDrive, and<br>
also secondly, it's really very hard to debug your code without having<br>
access to it. Are you able to post it somewhere?<br>
<br>
Cheers,<br>
Daniel<br>
</div></div></blockquote></div><br>