12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241 |
- /*
- *
- * Copyright © 2000 SuSE, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. SuSE makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Keith Packard, SuSE, Inc.
- */
- #ifdef HAVE_DIX_CONFIG_H
- #include <dix-config.h>
- #endif
- #include <string.h>
- #include "fb.h"
- #include "picturestr.h"
- #include "mipict.h"
- #include "fbpict.h"
- typedef void (*CompositeFunc) (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst, CARD16 width, CARD16 height);
- CARD32
- fbOver(CARD32 x, CARD32 y)
- {
- CARD16 a = ~x >> 24;
- CARD16 t;
- CARD32 m, n, o, p;
- m = FbOverU(x, y, 0, a, t);
- n = FbOverU(x, y, 8, a, t);
- o = FbOverU(x, y, 16, a, t);
- p = FbOverU(x, y, 24, a, t);
- return m | n | o | p;
- }
- CARD32
- fbOver24(CARD32 x, CARD32 y)
- {
- CARD16 a = ~x >> 24;
- CARD16 t;
- CARD32 m, n, o;
- m = FbOverU(x, y, 0, a, t);
- n = FbOverU(x, y, 8, a, t);
- o = FbOverU(x, y, 16, a, t);
- return m | n | o;
- }
- CARD32
- fbIn(CARD32 x, CARD8 y)
- {
- CARD16 a = y;
- CARD16 t;
- CARD32 m, n, o, p;
- m = FbInU(x, 0, a, t);
- n = FbInU(x, 8, a, t);
- o = FbInU(x, 16, a, t);
- p = FbInU(x, 24, a, t);
- return m | n | o | p;
- }
- /*
- * Naming convention:
- *
- * opSRCxMASKxDST
- */
- void
- fbCompositeSolidMask_nx8x8888(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD32 src, srca;
- CARD32 *dstLine, *dst, d, dstMask;
- CARD8 *maskLine, *mask, m;
- FbStride dstStride, maskStride;
- CARD16 w;
- fbComposeGetSolid(pSrc, src, pDst->format);
- dstMask = FbFullMask(pDst->pDrawable->depth);
- srca = src >> 24;
- if (src == 0)
- return;
- fbComposeGetStart(pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
- fbComposeGetStart(pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- mask = maskLine;
- maskLine += maskStride;
- w = width;
- while (w--) {
- m = *mask++;
- if (m == 0xff) {
- if (srca == 0xff)
- *dst = src & dstMask;
- else
- *dst = fbOver(src, *dst) & dstMask;
- }
- else if (m) {
- d = fbIn(src, m);
- *dst = fbOver(d, *dst) & dstMask;
- }
- dst++;
- }
- }
- }
- void
- fbCompositeSolidMask_nx8888x8888C(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD32 src, srca;
- CARD32 *dstLine, *dst, d, dstMask;
- CARD32 *maskLine, *mask, ma;
- FbStride dstStride, maskStride;
- CARD16 w;
- CARD32 m, n, o, p;
- fbComposeGetSolid(pSrc, src, pDst->format);
- dstMask = FbFullMask(pDst->pDrawable->depth);
- srca = src >> 24;
- if (src == 0)
- return;
- fbComposeGetStart(pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
- fbComposeGetStart(pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- mask = maskLine;
- maskLine += maskStride;
- w = width;
- while (w--) {
- ma = *mask++;
- if (ma == 0xffffffff) {
- if (srca == 0xff)
- *dst = src & dstMask;
- else
- *dst = fbOver(src, *dst) & dstMask;
- }
- else if (ma) {
- d = *dst;
- #define FbInOverC(src,srca,msk,dst,i,result) { \
- CARD16 __a = FbGet8(msk,i); \
- CARD32 __t, __ta; \
- CARD32 __i; \
- __t = FbIntMult (FbGet8(src,i), __a,__i); \
- __ta = (CARD8) ~FbIntMult (srca, __a,__i); \
- __t = __t + FbIntMult(FbGet8(dst,i),__ta,__i); \
- __t = (CARD32) (CARD8) (__t | (-(__t >> 8))); \
- result = __t << (i); \
- }
- FbInOverC(src, srca, ma, d, 0, m);
- FbInOverC(src, srca, ma, d, 8, n);
- FbInOverC(src, srca, ma, d, 16, o);
- FbInOverC(src, srca, ma, d, 24, p);
- *dst = m | n | o | p;
- }
- dst++;
- }
- }
- }
- void
- fbCompositeSolidMask_nx8x0888(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD32 src, srca;
- CARD8 *dstLine, *dst;
- CARD32 d;
- CARD8 *maskLine, *mask, m;
- FbStride dstStride, maskStride;
- CARD16 w;
- fbComposeGetSolid(pSrc, src, pDst->format);
- srca = src >> 24;
- if (src == 0)
- return;
- fbComposeGetStart(pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
- fbComposeGetStart(pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- mask = maskLine;
- maskLine += maskStride;
- w = width;
- while (w--) {
- m = *mask++;
- if (m == 0xff) {
- if (srca == 0xff)
- d = src;
- else {
- d = Fetch24(dst);
- d = fbOver24(src, d);
- }
- Store24(dst, d);
- }
- else if (m) {
- d = fbOver24(fbIn(src, m), Fetch24(dst));
- Store24(dst, d);
- }
- dst += 3;
- }
- }
- }
- void
- fbCompositeSolidMask_nx8x0565(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD32 src, srca;
- CARD16 *dstLine, *dst;
- CARD32 d;
- CARD8 *maskLine, *mask, m;
- FbStride dstStride, maskStride;
- CARD16 w;
- fbComposeGetSolid(pSrc, src, pDst->format);
- srca = src >> 24;
- if (src == 0)
- return;
- fbComposeGetStart(pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
- fbComposeGetStart(pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- mask = maskLine;
- maskLine += maskStride;
- w = width;
- while (w--) {
- m = *mask++;
- if (m == 0xff) {
- if (srca == 0xff)
- d = src;
- else {
- d = *dst;
- d = fbOver24(src, cvt0565to8888(d));
- }
- *dst = cvt8888to0565(d);
- }
- else if (m) {
- d = *dst;
- d = fbOver24(fbIn(src, m), cvt0565to8888(d));
- *dst = cvt8888to0565(d);
- }
- dst++;
- }
- }
- }
- void
- fbCompositeSolidMask_nx8888x0565C(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD32 src, srca;
- CARD16 src16;
- CARD16 *dstLine, *dst;
- CARD32 d;
- CARD32 *maskLine, *mask, ma;
- FbStride dstStride, maskStride;
- CARD16 w;
- CARD32 m, n, o;
- fbComposeGetSolid(pSrc, src, pDst->format);
- srca = src >> 24;
- if (src == 0)
- return;
- src16 = cvt8888to0565(src);
- fbComposeGetStart(pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
- fbComposeGetStart(pMask, xMask, yMask, CARD32, maskStride, maskLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- mask = maskLine;
- maskLine += maskStride;
- w = width;
- while (w--) {
- ma = *mask++;
- if (ma == 0xffffffff) {
- if (srca == 0xff) {
- *dst = src16;
- }
- else {
- d = *dst;
- d = fbOver24(src, cvt0565to8888(d));
- *dst = cvt8888to0565(d);
- }
- }
- else if (ma) {
- d = *dst;
- d = cvt0565to8888(d);
- FbInOverC(src, srca, ma, d, 0, m);
- FbInOverC(src, srca, ma, d, 8, n);
- FbInOverC(src, srca, ma, d, 16, o);
- d = m | n | o;
- *dst = cvt8888to0565(d);
- }
- dst++;
- }
- }
- }
- void
- fbCompositeSrc_8888x8888(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD32 *dstLine, *dst, dstMask;
- CARD32 *srcLine, *src, s;
- FbStride dstStride, srcStride;
- CARD8 a;
- CARD16 w;
- fbComposeGetStart(pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
- fbComposeGetStart(pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
- dstMask = FbFullMask(pDst->pDrawable->depth);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- src = srcLine;
- srcLine += srcStride;
- w = width;
- while (w--) {
- s = *src++;
- a = s >> 24;
- if (a == 0xff)
- *dst = s & dstMask;
- else if (a)
- *dst = fbOver(s, *dst) & dstMask;
- dst++;
- }
- }
- }
- void
- fbCompositeSrc_8888x0888(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD8 *dstLine, *dst;
- CARD32 d;
- CARD32 *srcLine, *src, s;
- CARD8 a;
- FbStride dstStride, srcStride;
- CARD16 w;
- fbComposeGetStart(pDst, xDst, yDst, CARD8, dstStride, dstLine, 3);
- fbComposeGetStart(pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- src = srcLine;
- srcLine += srcStride;
- w = width;
- while (w--) {
- s = *src++;
- a = s >> 24;
- if (a) {
- if (a == 0xff)
- d = s;
- else
- d = fbOver24(s, Fetch24(dst));
- Store24(dst, d);
- }
- dst += 3;
- }
- }
- }
- void
- fbCompositeSrc_8888x0565(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD16 *dstLine, *dst;
- CARD32 d;
- CARD32 *srcLine, *src, s;
- CARD8 a;
- FbStride dstStride, srcStride;
- CARD16 w;
- fbComposeGetStart(pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
- fbComposeGetStart(pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- src = srcLine;
- srcLine += srcStride;
- w = width;
- while (w--) {
- s = *src++;
- a = s >> 24;
- if (a) {
- if (a == 0xff)
- d = s;
- else {
- d = *dst;
- d = fbOver24(s, cvt0565to8888(d));
- }
- *dst = cvt8888to0565(d);
- }
- dst++;
- }
- }
- }
- void
- fbCompositeSrc_0565x0565(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD16 *dstLine, *dst;
- CARD16 *srcLine, *src;
- FbStride dstStride, srcStride;
- CARD16 w;
- fbComposeGetStart(pSrc, xSrc, ySrc, CARD16, srcStride, srcLine, 1);
- fbComposeGetStart(pDst, xDst, yDst, CARD16, dstStride, dstLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- src = srcLine;
- srcLine += srcStride;
- w = width;
- while (w--)
- *dst++ = *src++;
- }
- }
- void
- fbCompositeSrcAdd_8000x8000(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD8 *dstLine, *dst;
- CARD8 *srcLine, *src;
- FbStride dstStride, srcStride;
- CARD16 w;
- CARD8 s, d;
- CARD16 t;
- fbComposeGetStart(pSrc, xSrc, ySrc, CARD8, srcStride, srcLine, 1);
- fbComposeGetStart(pDst, xDst, yDst, CARD8, dstStride, dstLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- src = srcLine;
- srcLine += srcStride;
- w = width;
- while (w--) {
- s = *src++;
- if (s) {
- if (s != 0xff) {
- d = *dst;
- t = d + s;
- s = t | (0 - (t >> 8));
- }
- *dst = s;
- }
- dst++;
- }
- }
- }
- void
- fbCompositeSrcAdd_8888x8888(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- CARD32 *dstLine, *dst;
- CARD32 *srcLine, *src;
- FbStride dstStride, srcStride;
- CARD16 w;
- CARD32 s, d;
- CARD16 t;
- CARD32 m, n, o, p;
- fbComposeGetStart(pSrc, xSrc, ySrc, CARD32, srcStride, srcLine, 1);
- fbComposeGetStart(pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
- while (height--) {
- dst = dstLine;
- dstLine += dstStride;
- src = srcLine;
- srcLine += srcStride;
- w = width;
- while (w--) {
- s = *src++;
- if (s) {
- if (s != 0xffffffff) {
- d = *dst;
- if (d) {
- m = FbAdd(s, d, 0, t);
- n = FbAdd(s, d, 8, t);
- o = FbAdd(s, d, 16, t);
- p = FbAdd(s, d, 24, t);
- s = m | n | o | p;
- }
- }
- *dst = s;
- }
- dst++;
- }
- }
- }
- void
- fbCompositeSrcAdd_1000x1000(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- FbBits *dstBits, *srcBits;
- FbStride dstStride, srcStride;
- int dstBpp, srcBpp;
- int dstXoff, dstYoff;
- int srcXoff, srcYoff;
- fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp, srcXoff,
- srcYoff);
- fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff,
- dstYoff);
- fbBlt(srcBits + srcStride * (ySrc + srcYoff),
- srcStride,
- xSrc + srcXoff,
- dstBits + dstStride * (yDst + dstYoff),
- dstStride,
- xDst + dstXoff,
- width, height, GXor, FB_ALLONES, srcBpp, FALSE, FALSE);
- }
- void
- fbCompositeSolidMask_nx1xn(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- FbBits *dstBits;
- FbStip *maskBits;
- FbStride dstStride, maskStride;
- int dstBpp, maskBpp;
- int dstXoff, dstYoff;
- int maskXoff, maskYoff;
- FbBits src;
- fbComposeGetSolid(pSrc, src, pDst->format);
- if ((src & 0xff000000) != 0xff000000) {
- fbCompositeGeneral(op, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
- return;
- }
- fbGetStipDrawable(pMask->pDrawable, maskBits, maskStride, maskBpp, maskXoff,
- maskYoff);
- fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp, dstXoff,
- dstYoff);
- switch (dstBpp) {
- case 32:
- break;
- case 24:
- break;
- case 16:
- src = cvt8888to0565(src);
- break;
- }
- src = fbReplicatePixel(src, dstBpp);
- fbBltOne(maskBits + maskStride * (yMask + maskYoff),
- maskStride,
- xMask + maskXoff,
- dstBits + dstStride * (yDst + dstYoff),
- dstStride,
- (xDst + dstXoff) * dstBpp,
- dstBpp, width * dstBpp, height, 0x0, src, FB_ALLONES, 0x0);
- }
- # define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
- void
- fbComposite(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
- {
- RegionRec region;
- int n;
- BoxPtr pbox;
- CompositeFunc func = NULL;
- Bool srcRepeat = pSrc->pDrawable && pSrc->repeat;
- Bool maskRepeat = FALSE;
- Bool srcAlphaMap = pSrc->alphaMap != 0;
- Bool maskAlphaMap = FALSE;
- Bool dstAlphaMap = pDst->alphaMap != 0;
- int x_msk, y_msk, x_src, y_src, x_dst, y_dst;
- int w, h, w_this, h_this;
- xDst += pDst->pDrawable->x;
- yDst += pDst->pDrawable->y;
- if (pSrc->pDrawable) {
- xSrc += pSrc->pDrawable->x;
- ySrc += pSrc->pDrawable->y;
- }
- if (pMask && pMask->pDrawable) {
- xMask += pMask->pDrawable->x;
- yMask += pMask->pDrawable->y;
- maskRepeat = pMask->repeat == RepeatNormal;
- maskAlphaMap = pMask->alphaMap != 0;
- }
- if (pSrc->pDrawable && (!pMask || pMask->pDrawable)
- && !pSrc->transform && !(pMask && pMask->transform)
- && !maskAlphaMap && !srcAlphaMap && !dstAlphaMap
- && (pSrc->filter != PictFilterConvolution)
- && (!pMask || pMask->filter != PictFilterConvolution))
- switch (op) {
- case PictOpSrc:
- break;
- case PictOpOver:
- if (pMask) {
- if (fbCanGetSolid(pSrc) && !maskRepeat) {
- srcRepeat = FALSE;
- if (PICT_FORMAT_COLOR(pSrc->format)) {
- switch (pMask->format) {
- case PICT_a8:
- switch (pDst->format) {
- case PICT_r5g6b5:
- case PICT_b5g6r5:
- func = fbCompositeSolidMask_nx8x0565;
- break;
- case PICT_r8g8b8:
- case PICT_b8g8r8:
- func = fbCompositeSolidMask_nx8x0888;
- break;
- case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- case PICT_a8b8g8r8:
- case PICT_x8b8g8r8:
- func = fbCompositeSolidMask_nx8x8888;
- break;
- default:
- break;
- }
- break;
- case PICT_a8r8g8b8:
- if (pMask->componentAlpha) {
- switch (pDst->format) {
- case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- func =
- fbCompositeSolidMask_nx8888x8888C;
- break;
- case PICT_r5g6b5:
- func =
- fbCompositeSolidMask_nx8888x0565C;
- break;
- default:
- break;
- }
- }
- break;
- case PICT_a8b8g8r8:
- if (pMask->componentAlpha) {
- switch (pDst->format) {
- case PICT_a8b8g8r8:
- case PICT_x8b8g8r8:
- func =
- fbCompositeSolidMask_nx8888x8888C;
- break;
- case PICT_b5g6r5:
- func =
- fbCompositeSolidMask_nx8888x0565C;
- break;
- default:
- break;
- }
- }
- break;
- case PICT_a1:
- switch (pDst->format) {
- case PICT_r5g6b5:
- case PICT_b5g6r5:
- case PICT_r8g8b8:
- case PICT_b8g8r8:
- case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- case PICT_a8b8g8r8:
- case PICT_x8b8g8r8:
- func = fbCompositeSolidMask_nx1xn;
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- default:
- break;
- }
- }
- else if (!srcRepeat) { /* has mask and non-repeating source */
- if (pSrc->pDrawable == pMask->pDrawable &&
- xSrc == xMask && ySrc == yMask &&
- !pMask->componentAlpha && !maskRepeat) {
- /* source == mask: non-premultiplied data */
- switch (pSrc->format) {
- case PICT_x8b8g8r8:
- switch (pMask->format) {
- case PICT_a8r8g8b8:
- case PICT_a8b8g8r8:
- switch (pDst->format) {
- case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- break;
- case PICT_r5g6b5:
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
- case PICT_x8r8g8b8:
- switch (pMask->format) {
- case PICT_a8r8g8b8:
- case PICT_a8b8g8r8:
- switch (pDst->format) {
- case PICT_a8b8g8r8:
- case PICT_x8b8g8r8:
- break;
- case PICT_r5g6b5:
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
- }
- else {
- /* non-repeating source, repeating mask => translucent window */
- if (fbCanGetSolid(pMask)) {
- if (pSrc->format == PICT_x8r8g8b8 &&
- pDst->format == PICT_x8r8g8b8 &&
- pMask->format == PICT_a8) {
- }
- }
- }
- }
- }
- else { /* no mask */
- if (fbCanGetSolid(pSrc)) {
- /* no mask and repeating source */
- switch (pSrc->format) {
- case PICT_a8r8g8b8:
- switch (pDst->format) {
- case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- break;
- case PICT_r5g6b5:
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- }
- else if (!srcRepeat) {
- switch (pSrc->format) {
- case PICT_a8r8g8b8:
- switch (pDst->format) {
- case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- func = fbCompositeSrc_8888x8888;
- break;
- case PICT_r8g8b8:
- func = fbCompositeSrc_8888x0888;
- break;
- case PICT_r5g6b5:
- func = fbCompositeSrc_8888x0565;
- break;
- default:
- break;
- }
- break;
- case PICT_x8r8g8b8:
- switch (pDst->format) {
- case PICT_a8r8g8b8:
- case PICT_x8r8g8b8:
- break;
- default:
- break;
- }
- case PICT_x8b8g8r8:
- switch (pDst->format) {
- case PICT_a8b8g8r8:
- case PICT_x8b8g8r8:
- break;
- default:
- break;
- }
- break;
- case PICT_a8b8g8r8:
- switch (pDst->format) {
- case PICT_a8b8g8r8:
- case PICT_x8b8g8r8:
- func = fbCompositeSrc_8888x8888;
- break;
- case PICT_b8g8r8:
- func = fbCompositeSrc_8888x0888;
- break;
- case PICT_b5g6r5:
- func = fbCompositeSrc_8888x0565;
- break;
- default:
- break;
- }
- break;
- case PICT_r5g6b5:
- switch (pDst->format) {
- case PICT_r5g6b5:
- func = fbCompositeSrc_0565x0565;
- break;
- default:
- break;
- }
- break;
- case PICT_b5g6r5:
- switch (pDst->format) {
- case PICT_b5g6r5:
- func = fbCompositeSrc_0565x0565;
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- }
- }
- break;
- case PictOpAdd:
- if (pMask == 0) {
- switch (pSrc->format) {
- case PICT_a8r8g8b8:
- switch (pDst->format) {
- case PICT_a8r8g8b8:
- func = fbCompositeSrcAdd_8888x8888;
- break;
- default:
- break;
- }
- break;
- case PICT_a8b8g8r8:
- switch (pDst->format) {
- case PICT_a8b8g8r8:
- func = fbCompositeSrcAdd_8888x8888;
- break;
- default:
- break;
- }
- break;
- case PICT_a8:
- switch (pDst->format) {
- case PICT_a8:
- func = fbCompositeSrcAdd_8000x8000;
- break;
- default:
- break;
- }
- break;
- case PICT_a1:
- switch (pDst->format) {
- case PICT_a1:
- func = fbCompositeSrcAdd_1000x1000;
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- }
- break;
- }
- if (!func) {
- /* no fast path, use the general code */
- fbCompositeGeneral(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
- xDst, yDst, width, height);
- return;
- }
- if (!miComputeCompositeRegion(®ion,
- pSrc,
- pMask,
- pDst,
- xSrc,
- ySrc,
- xMask, yMask, xDst, yDst, width, height))
- return;
- n = REGION_NUM_RECTS(®ion);
- pbox = REGION_RECTS(®ion);
- while (n--) {
- h = pbox->y2 - pbox->y1;
- y_src = pbox->y1 - yDst + ySrc;
- y_msk = pbox->y1 - yDst + yMask;
- y_dst = pbox->y1;
- while (h) {
- h_this = h;
- w = pbox->x2 - pbox->x1;
- x_src = pbox->x1 - xDst + xSrc;
- x_msk = pbox->x1 - xDst + xMask;
- x_dst = pbox->x1;
- if (maskRepeat) {
- y_msk =
- mod(y_msk - pMask->pDrawable->y, pMask->pDrawable->height);
- if (h_this > pMask->pDrawable->height - y_msk)
- h_this = pMask->pDrawable->height - y_msk;
- y_msk += pMask->pDrawable->y;
- }
- if (srcRepeat) {
- y_src =
- mod(y_src - pSrc->pDrawable->y, pSrc->pDrawable->height);
- if (h_this > pSrc->pDrawable->height - y_src)
- h_this = pSrc->pDrawable->height - y_src;
- y_src += pSrc->pDrawable->y;
- }
- while (w) {
- w_this = w;
- if (maskRepeat) {
- x_msk =
- mod(x_msk - pMask->pDrawable->x,
- pMask->pDrawable->width);
- if (w_this > pMask->pDrawable->width - x_msk)
- w_this = pMask->pDrawable->width - x_msk;
- x_msk += pMask->pDrawable->x;
- }
- if (srcRepeat) {
- x_src =
- mod(x_src - pSrc->pDrawable->x, pSrc->pDrawable->width);
- if (w_this > pSrc->pDrawable->width - x_src)
- w_this = pSrc->pDrawable->width - x_src;
- x_src += pSrc->pDrawable->x;
- }
- (*func) (op, pSrc, pMask, pDst,
- x_src, y_src, x_msk, y_msk, x_dst, y_dst,
- w_this, h_this);
- w -= w_this;
- x_src += w_this;
- x_msk += w_this;
- x_dst += w_this;
- }
- h -= h_this;
- y_src += h_this;
- y_msk += h_this;
- y_dst += h_this;
- }
- pbox++;
- }
- REGION_UNINIT(®ion);
- }
- Bool
- fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
- {
- PictureScreenPtr ps;
- if (!miPictureInit(pScreen, formats, nformats))
- return FALSE;
- ps = GetPictureScreen(pScreen);
- ps->Composite = fbComposite;
- ps->Glyphs = miGlyphs;
- ps->CompositeRects = miCompositeRects;
- ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
- ps->AddTraps = fbAddTraps;
- ps->AddTriangles = fbAddTriangles;
- return TRUE;
- }
|