1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285 |
- /*
- *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
- * 2005 Lars Knoll & Zack Rusin, Trolltech
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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.
- */
- #ifdef HAVE_DIX_CONFIG_H
- #include <dix-config.h>
- #endif
- #include "fb.h"
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <assert.h>
- #include "picturestr.h"
- #include "mipict.h"
- #include "fbpict.h"
- #define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
- #define SCANLINE_BUFFER_LENGTH 2048
- typedef FASTCALL void (*fetchProc) (const FbBits * bits, int x, int width,
- CARD32 *buffer, miIndexedPtr indexed);
- /*
- * All of the fetch functions
- */
- static FASTCALL void
- fbFetch_a8r8g8b8(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- memcpy(buffer, (const CARD32 *) bits + x, width * sizeof(CARD32));
- }
- static FASTCALL void
- fbFetch_x8r8g8b8(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD32 *pixel = (const CARD32 *) bits + x;
- const CARD32 *end = pixel + width;
- while (pixel < end) {
- *buffer++ = *pixel++ | 0xff000000;
- }
- }
- static FASTCALL void
- fbFetch_a8b8g8r8(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD32 *pixel = (CARD32 *) bits + x;
- const CARD32 *end = pixel + width;
- while (pixel < end) {
- *buffer++ = ((*pixel & 0xff00ff00) |
- ((*pixel >> 16) & 0xff) | ((*pixel & 0xff) << 16));
- ++pixel;
- }
- }
- static FASTCALL void
- fbFetch_x8b8g8r8(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD32 *pixel = (CARD32 *) bits + x;
- const CARD32 *end = pixel + width;
- while (pixel < end) {
- *buffer++ = 0xff000000 |
- ((*pixel & 0x0000ff00) |
- ((*pixel >> 16) & 0xff) | ((*pixel & 0xff) << 16));
- ++pixel;
- }
- }
- static FASTCALL void
- fbFetch_r8g8b8(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + 3 * x;
- const CARD8 *end = pixel + 3 * width;
- while (pixel < end) {
- CARD32 b = Fetch24(pixel) | 0xff000000;
- pixel += 3;
- *buffer++ = b;
- }
- }
- static FASTCALL void
- fbFetch_b8g8r8(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + 3 * x;
- const CARD8 *end = pixel + 3 * width;
- while (pixel < end) {
- CARD32 b = 0xff000000;
- #if IMAGE_BYTE_ORDER == MSBFirst
- b |= (*pixel++);
- b |= (*pixel++ << 8);
- b |= (*pixel++ << 16);
- #else
- b |= (*pixel++ << 16);
- b |= (*pixel++ << 8);
- b |= (*pixel++);
- #endif
- *buffer++ = b;
- }
- }
- static FASTCALL void
- fbFetch_r5g6b5(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r = (((p) << 3) & 0xf8) |
- (((p) << 5) & 0xfc00) | (((p) << 8) & 0xf80000);
- r |= (r >> 5) & 0x70007;
- r |= (r >> 6) & 0x300;
- *buffer++ = 0xff000000 | r;
- }
- }
- static FASTCALL void
- fbFetch_b5g6r5(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b;
- b = ((p & 0xf800) | ((p & 0xe000) >> 5)) >> 8;
- g = ((p & 0x07e0) | ((p & 0x0600) >> 6)) << 5;
- r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
- *buffer++ = (0xff000000 | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_a1r5g5b5(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b, a;
- a = (CARD32) ((CARD8) (0 - ((p & 0x8000) >> 15))) << 24;
- r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
- g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
- b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
- *buffer++ = (a | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_x1r5g5b5(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b;
- r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9;
- g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
- b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2;
- *buffer++ = (0xff000000 | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_a1b5g5r5(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b, a;
- a = (CARD32) ((CARD8) (0 - ((p & 0x8000) >> 15))) << 24;
- b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
- g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
- r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
- *buffer++ = (a | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_x1b5g5r5(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b;
- b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7;
- g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6;
- r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14;
- *buffer++ = (0xff000000 | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_a4r4g4b4(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b, a;
- a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
- r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
- g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
- b = ((p & 0x000f) | ((p & 0x000f) << 4));
- *buffer++ = (a | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_x4r4g4b4(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b;
- r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12;
- g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
- b = ((p & 0x000f) | ((p & 0x000f) << 4));
- *buffer++ = (0xff000000 | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_a4b4g4r4(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b, a;
- a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16;
- b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4;
- g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
- r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16;
- *buffer++ = (a | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_x4b4g4r4(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD16 *pixel = (const CARD16 *) bits + x;
- const CARD16 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b;
- b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4;
- g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8;
- r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16;
- *buffer++ = (0xff000000 | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_a8(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + x;
- const CARD8 *end = pixel + width;
- while (pixel < end) {
- *buffer++ = (*pixel++) << 24;
- }
- }
- static FASTCALL void
- fbFetch_r3g3b2(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + x;
- const CARD8 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b;
- r = ((p & 0xe0) | ((p & 0xe0) >> 3) | ((p & 0xc0) >> 6)) << 16;
- g = ((p & 0x1c) | ((p & 0x18) >> 3) | ((p & 0x1c) << 3)) << 8;
- b = (((p & 0x03)) |
- ((p & 0x03) << 2) | ((p & 0x03) << 4) | ((p & 0x03) << 6));
- *buffer++ = (0xff000000 | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_b2g3r3(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + x;
- const CARD8 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 r, g, b;
- b = (((p & 0xc0)) |
- ((p & 0xc0) >> 2) | ((p & 0xc0) >> 4) | ((p & 0xc0) >> 6));
- g = ((p & 0x38) | ((p & 0x38) >> 3) | ((p & 0x30) << 2)) << 8;
- r = (((p & 0x07)) | ((p & 0x07) << 3) | ((p & 0x06) << 6)) << 16;
- *buffer++ = (0xff000000 | r | g | b);
- }
- }
- static FASTCALL void
- fbFetch_a2r2g2b2(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + x;
- const CARD8 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 a, r, g, b;
- a = ((p & 0xc0) * 0x55) << 18;
- r = ((p & 0x30) * 0x55) << 12;
- g = ((p & 0x0c) * 0x55) << 6;
- b = ((p & 0x03) * 0x55);
- *buffer++ = a | r | g | b;
- }
- }
- static FASTCALL void
- fbFetch_a2b2g2r2(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + x;
- const CARD8 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- CARD32 a, r, g, b;
- a = ((p & 0xc0) * 0x55) << 18;
- b = ((p & 0x30) * 0x55) >> 6;
- g = ((p & 0x0c) * 0x55) << 6;
- r = ((p & 0x03) * 0x55) << 16;
- *buffer++ = a | r | g | b;
- }
- }
- static FASTCALL void
- fbFetch_c8(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + x;
- const CARD8 *end = pixel + width;
- while (pixel < end) {
- CARD32 p = *pixel++;
- *buffer++ = indexed->rgba[p];
- }
- }
- static FASTCALL void
- fbFetch_x4a4(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- const CARD8 *pixel = (const CARD8 *) bits + x;
- const CARD8 *end = pixel + width;
- while (pixel < end) {
- CARD8 p = (*pixel++) & 0xf;
- *buffer++ = (p | (p << 4)) << 24;
- }
- }
- #define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 2])
- #if IMAGE_BYTE_ORDER == MSBFirst
- #define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4)
- #else
- #define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf)
- #endif
- static FASTCALL void
- fbFetch_a4(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 p = Fetch4(bits, i + x);
- p |= p << 4;
- *buffer++ = p << 24;
- }
- }
- static FASTCALL void
- fbFetch_r1g2b1(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 p = Fetch4(bits, i + x);
- CARD32 r, g, b;
- r = ((p & 0x8) * 0xff) << 13;
- g = ((p & 0x6) * 0x55) << 7;
- b = ((p & 0x1) * 0xff);
- *buffer++ = 0xff000000 | r | g | b;
- }
- }
- static FASTCALL void
- fbFetch_b1g2r1(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 p = Fetch4(bits, i + x);
- CARD32 r, g, b;
- b = ((p & 0x8) * 0xff) >> 3;
- g = ((p & 0x6) * 0x55) << 7;
- r = ((p & 0x1) * 0xff) << 16;
- *buffer++ = 0xff000000 | r | g | b;
- }
- }
- static FASTCALL void
- fbFetch_a1r1g1b1(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 p = Fetch4(bits, i + x);
- CARD32 a, r, g, b;
- a = ((p & 0x8) * 0xff) << 21;
- r = ((p & 0x4) * 0xff) << 14;
- g = ((p & 0x2) * 0xff) << 7;
- b = ((p & 0x1) * 0xff);
- *buffer++ = a | r | g | b;
- }
- }
- static FASTCALL void
- fbFetch_a1b1g1r1(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 p = Fetch4(bits, i + x);
- CARD32 a, r, g, b;
- a = ((p & 0x8) * 0xff) << 21;
- r = ((p & 0x4) * 0xff) >> 3;
- g = ((p & 0x2) * 0xff) << 7;
- b = ((p & 0x1) * 0xff) << 16;
- *buffer++ = a | r | g | b;
- }
- }
- static FASTCALL void
- fbFetch_c4(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 p = Fetch4(bits, i + x);
- *buffer++ = indexed->rgba[p];
- }
- }
- static FASTCALL void
- fbFetch_a1(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 p = ((CARD32 *) bits)[(i + x) >> 5];
- CARD32 a;
- #if BITMAP_BIT_ORDER == MSBFirst
- a = p >> (0x1f - ((i + x) & 0x1f));
- #else
- a = p >> ((i + x) & 0x1f);
- #endif
- a = a & 1;
- a |= a << 1;
- a |= a << 2;
- a |= a << 4;
- *buffer++ = a << 24;
- }
- }
- static FASTCALL void
- fbFetch_g1(const FbBits * bits, int x, int width, CARD32 *buffer,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 p = ((CARD32 *) bits)[(i + x) >> 5];
- CARD32 a;
- #if BITMAP_BIT_ORDER == MSBFirst
- a = p >> (0x1f - ((i + x) & 0x1f));
- #else
- a = p >> ((i + x) & 0x1f);
- #endif
- a = a & 1;
- *buffer++ = indexed->rgba[a];
- }
- }
- static fetchProc
- fetchProcForPicture(PicturePtr pict)
- {
- switch (pict->format) {
- case PICT_a8r8g8b8:
- return fbFetch_a8r8g8b8;
- case PICT_x8r8g8b8:
- return fbFetch_x8r8g8b8;
- case PICT_a8b8g8r8:
- return fbFetch_a8b8g8r8;
- case PICT_x8b8g8r8:
- return fbFetch_x8b8g8r8;
- /* 24bpp formats */
- case PICT_r8g8b8:
- return fbFetch_r8g8b8;
- case PICT_b8g8r8:
- return fbFetch_b8g8r8;
- /* 16bpp formats */
- case PICT_r5g6b5:
- return fbFetch_r5g6b5;
- case PICT_b5g6r5:
- return fbFetch_b5g6r5;
- case PICT_a1r5g5b5:
- return fbFetch_a1r5g5b5;
- case PICT_x1r5g5b5:
- return fbFetch_x1r5g5b5;
- case PICT_a1b5g5r5:
- return fbFetch_a1b5g5r5;
- case PICT_x1b5g5r5:
- return fbFetch_x1b5g5r5;
- case PICT_a4r4g4b4:
- return fbFetch_a4r4g4b4;
- case PICT_x4r4g4b4:
- return fbFetch_x4r4g4b4;
- case PICT_a4b4g4r4:
- return fbFetch_a4b4g4r4;
- case PICT_x4b4g4r4:
- return fbFetch_x4b4g4r4;
- /* 8bpp formats */
- case PICT_a8:
- return fbFetch_a8;
- case PICT_r3g3b2:
- return fbFetch_r3g3b2;
- case PICT_b2g3r3:
- return fbFetch_b2g3r3;
- case PICT_a2r2g2b2:
- return fbFetch_a2r2g2b2;
- case PICT_a2b2g2r2:
- return fbFetch_a2b2g2r2;
- case PICT_c8:
- return fbFetch_c8;
- case PICT_g8:
- return fbFetch_c8;
- case PICT_x4a4:
- return fbFetch_x4a4;
- /* 4bpp formats */
- case PICT_a4:
- return fbFetch_a4;
- case PICT_r1g2b1:
- return fbFetch_r1g2b1;
- case PICT_b1g2r1:
- return fbFetch_b1g2r1;
- case PICT_a1r1g1b1:
- return fbFetch_a1r1g1b1;
- case PICT_a1b1g1r1:
- return fbFetch_a1b1g1r1;
- case PICT_c4:
- return fbFetch_c4;
- case PICT_g4:
- return fbFetch_c4;
- /* 1bpp formats */
- case PICT_a1:
- return fbFetch_a1;
- case PICT_g1:
- return fbFetch_g1;
- }
- return NULL;
- }
- /*
- * Pixel wise fetching
- */
- typedef FASTCALL CARD32 (*fetchPixelProc) (const FbBits * bits, int offset,
- miIndexedPtr indexed);
- static FASTCALL CARD32
- fbFetchPixel_a8r8g8b8(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- return ((CARD32 *) bits)[offset];
- }
- static FASTCALL CARD32
- fbFetchPixel_x8r8g8b8(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- return ((CARD32 *) bits)[offset] | 0xff000000;
- }
- static FASTCALL CARD32
- fbFetchPixel_a8b8g8r8(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD32 *) bits)[offset];
- return ((pixel & 0xff000000) |
- ((pixel >> 16) & 0xff) |
- (pixel & 0x0000ff00) | ((pixel & 0xff) << 16));
- }
- static FASTCALL CARD32
- fbFetchPixel_x8b8g8r8(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD32 *) bits)[offset];
- return ((0xff000000) |
- ((pixel >> 16) & 0xff) |
- (pixel & 0x0000ff00) | ((pixel & 0xff) << 16));
- }
- static FASTCALL CARD32
- fbFetchPixel_r8g8b8(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD8 *pixel = ((CARD8 *) bits) + (offset * 3);
- #if IMAGE_BYTE_ORDER == MSBFirst
- return (0xff000000 | (pixel[0] << 16) | (pixel[1] << 8) | (pixel[2]));
- #else
- return (0xff000000 | (pixel[2] << 16) | (pixel[1] << 8) | (pixel[0]));
- #endif
- }
- static FASTCALL CARD32
- fbFetchPixel_b8g8r8(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD8 *pixel = ((CARD8 *) bits) + (offset * 3);
- #if IMAGE_BYTE_ORDER == MSBFirst
- return (0xff000000 | (pixel[2] << 16) | (pixel[1] << 8) | (pixel[0]));
- #else
- return (0xff000000 | (pixel[0] << 16) | (pixel[1] << 8) | (pixel[2]));
- #endif
- }
- static FASTCALL CARD32
- fbFetchPixel_r5g6b5(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 r, g, b;
- r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8;
- g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
- b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
- return (0xff000000 | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_b5g6r5(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 r, g, b;
- b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8;
- g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
- r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
- return (0xff000000 | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_a1r5g5b5(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 a, r, g, b;
- a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
- r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
- g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
- b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
- return (a | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_x1r5g5b5(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 r, g, b;
- r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
- g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
- b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
- return (0xff000000 | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_a1b5g5r5(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 a, r, g, b;
- a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
- b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
- g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
- r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
- return (a | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_x1b5g5r5(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 r, g, b;
- b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
- g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
- r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
- return (0xff000000 | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_a4r4g4b4(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 a, r, g, b;
- a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
- r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
- g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
- b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
- return (a | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_x4r4g4b4(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 r, g, b;
- r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12;
- g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
- b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4));
- return (0xff000000 | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_a4b4g4r4(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 a, r, g, b;
- a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16;
- b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4;
- g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
- r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16;
- return (a | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_x4b4g4r4(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD16 *) bits)[offset];
- CARD32 r, g, b;
- b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4;
- g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8;
- r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16;
- return (0xff000000 | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_a8(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD8 *) bits)[offset];
- return pixel << 24;
- }
- static FASTCALL CARD32
- fbFetchPixel_r3g3b2(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD8 *) bits)[offset];
- CARD32 r, g, b;
- r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16;
- g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8;
- b = (((pixel & 0x03)) |
- ((pixel & 0x03) << 2) | ((pixel & 0x03) << 4) | ((pixel & 0x03) << 6));
- return (0xff000000 | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_b2g3r3(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD8 *) bits)[offset];
- CARD32 r, g, b;
- b = (((pixel & 0xc0)) |
- ((pixel & 0xc0) >> 2) | ((pixel & 0xc0) >> 4) | ((pixel & 0xc0) >> 6));
- g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8;
- r = (((pixel & 0x07)) |
- ((pixel & 0x07) << 3) | ((pixel & 0x06) << 6)) << 16;
- return (0xff000000 | r | g | b);
- }
- static FASTCALL CARD32
- fbFetchPixel_a2r2g2b2(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD8 *) bits)[offset];
- CARD32 a, r, g, b;
- a = ((pixel & 0xc0) * 0x55) << 18;
- r = ((pixel & 0x30) * 0x55) << 12;
- g = ((pixel & 0x0c) * 0x55) << 6;
- b = ((pixel & 0x03) * 0x55);
- return a | r | g | b;
- }
- static FASTCALL CARD32
- fbFetchPixel_a2b2g2r2(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD8 *) bits)[offset];
- CARD32 a, r, g, b;
- a = ((pixel & 0xc0) * 0x55) << 18;
- b = ((pixel & 0x30) * 0x55) >> 6;
- g = ((pixel & 0x0c) * 0x55) << 6;
- r = ((pixel & 0x03) * 0x55) << 16;
- return a | r | g | b;
- }
- static FASTCALL CARD32
- fbFetchPixel_c8(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD8 *) bits)[offset];
- return indexed->rgba[pixel];
- }
- static FASTCALL CARD32
- fbFetchPixel_x4a4(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD8 *) bits)[offset];
- return ((pixel & 0xf) | ((pixel & 0xf) << 4)) << 24;
- }
- #define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 2])
- #if IMAGE_BYTE_ORDER == MSBFirst
- #define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4)
- #else
- #define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf)
- #endif
- static FASTCALL CARD32
- fbFetchPixel_a4(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = Fetch4(bits, offset);
- pixel |= pixel << 4;
- return pixel << 24;
- }
- static FASTCALL CARD32
- fbFetchPixel_r1g2b1(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = Fetch4(bits, offset);
- CARD32 r, g, b;
- r = ((pixel & 0x8) * 0xff) << 13;
- g = ((pixel & 0x6) * 0x55) << 7;
- b = ((pixel & 0x1) * 0xff);
- return 0xff000000 | r | g | b;
- }
- static FASTCALL CARD32
- fbFetchPixel_b1g2r1(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = Fetch4(bits, offset);
- CARD32 r, g, b;
- b = ((pixel & 0x8) * 0xff) >> 3;
- g = ((pixel & 0x6) * 0x55) << 7;
- r = ((pixel & 0x1) * 0xff) << 16;
- return 0xff000000 | r | g | b;
- }
- static FASTCALL CARD32
- fbFetchPixel_a1r1g1b1(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = Fetch4(bits, offset);
- CARD32 a, r, g, b;
- a = ((pixel & 0x8) * 0xff) << 21;
- r = ((pixel & 0x4) * 0xff) << 14;
- g = ((pixel & 0x2) * 0xff) << 7;
- b = ((pixel & 0x1) * 0xff);
- return a | r | g | b;
- }
- static FASTCALL CARD32
- fbFetchPixel_a1b1g1r1(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = Fetch4(bits, offset);
- CARD32 a, r, g, b;
- a = ((pixel & 0x8) * 0xff) << 21;
- r = ((pixel & 0x4) * 0xff) >> 3;
- g = ((pixel & 0x2) * 0xff) << 7;
- b = ((pixel & 0x1) * 0xff) << 16;
- return a | r | g | b;
- }
- static FASTCALL CARD32
- fbFetchPixel_c4(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = Fetch4(bits, offset);
- return indexed->rgba[pixel];
- }
- static FASTCALL CARD32
- fbFetchPixel_a1(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD32 *) bits)[offset >> 5];
- CARD32 a;
- #if BITMAP_BIT_ORDER == MSBFirst
- a = pixel >> (0x1f - (offset & 0x1f));
- #else
- a = pixel >> (offset & 0x1f);
- #endif
- a = a & 1;
- a |= a << 1;
- a |= a << 2;
- a |= a << 4;
- return a << 24;
- }
- static FASTCALL CARD32
- fbFetchPixel_g1(const FbBits * bits, int offset, miIndexedPtr indexed)
- {
- CARD32 pixel = ((CARD32 *) bits)[offset >> 5];
- CARD32 a;
- #if BITMAP_BIT_ORDER == MSBFirst
- a = pixel >> (0x1f - (offset & 0x1f));
- #else
- a = pixel >> (offset & 0x1f);
- #endif
- a = a & 1;
- return indexed->rgba[a];
- }
- static fetchPixelProc
- fetchPixelProcForPicture(PicturePtr pict)
- {
- switch (pict->format) {
- case PICT_a8r8g8b8:
- return fbFetchPixel_a8r8g8b8;
- case PICT_x8r8g8b8:
- return fbFetchPixel_x8r8g8b8;
- case PICT_a8b8g8r8:
- return fbFetchPixel_a8b8g8r8;
- case PICT_x8b8g8r8:
- return fbFetchPixel_x8b8g8r8;
- /* 24bpp formats */
- case PICT_r8g8b8:
- return fbFetchPixel_r8g8b8;
- case PICT_b8g8r8:
- return fbFetchPixel_b8g8r8;
- /* 16bpp formats */
- case PICT_r5g6b5:
- return fbFetchPixel_r5g6b5;
- case PICT_b5g6r5:
- return fbFetchPixel_b5g6r5;
- case PICT_a1r5g5b5:
- return fbFetchPixel_a1r5g5b5;
- case PICT_x1r5g5b5:
- return fbFetchPixel_x1r5g5b5;
- case PICT_a1b5g5r5:
- return fbFetchPixel_a1b5g5r5;
- case PICT_x1b5g5r5:
- return fbFetchPixel_x1b5g5r5;
- case PICT_a4r4g4b4:
- return fbFetchPixel_a4r4g4b4;
- case PICT_x4r4g4b4:
- return fbFetchPixel_x4r4g4b4;
- case PICT_a4b4g4r4:
- return fbFetchPixel_a4b4g4r4;
- case PICT_x4b4g4r4:
- return fbFetchPixel_x4b4g4r4;
- /* 8bpp formats */
- case PICT_a8:
- return fbFetchPixel_a8;
- case PICT_r3g3b2:
- return fbFetchPixel_r3g3b2;
- case PICT_b2g3r3:
- return fbFetchPixel_b2g3r3;
- case PICT_a2r2g2b2:
- return fbFetchPixel_a2r2g2b2;
- case PICT_a2b2g2r2:
- return fbFetchPixel_a2b2g2r2;
- case PICT_c8:
- return fbFetchPixel_c8;
- case PICT_g8:
- return fbFetchPixel_c8;
- case PICT_x4a4:
- return fbFetchPixel_x4a4;
- /* 4bpp formats */
- case PICT_a4:
- return fbFetchPixel_a4;
- case PICT_r1g2b1:
- return fbFetchPixel_r1g2b1;
- case PICT_b1g2r1:
- return fbFetchPixel_b1g2r1;
- case PICT_a1r1g1b1:
- return fbFetchPixel_a1r1g1b1;
- case PICT_a1b1g1r1:
- return fbFetchPixel_a1b1g1r1;
- case PICT_c4:
- return fbFetchPixel_c4;
- case PICT_g4:
- return fbFetchPixel_c4;
- /* 1bpp formats */
- case PICT_a1:
- return fbFetchPixel_a1;
- case PICT_g1:
- return fbFetchPixel_g1;
- }
- return NULL;
- }
- /*
- * All the store functions
- */
- typedef FASTCALL void (*storeProc) (FbBits * bits, const CARD32 *values, int x,
- int width, miIndexedPtr indexed);
- #define Splita(v) CARD32 a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
- #define Split(v) CARD32 r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
- static FASTCALL void
- fbStore_a8r8g8b8(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- memcpy(((CARD32 *) bits) + x, values, width * sizeof(CARD32));
- }
- static FASTCALL void
- fbStore_x8r8g8b8(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD32 *pixel = (CARD32 *) bits + x;
- for (i = 0; i < width; ++i)
- *pixel++ = values[i] & 0xffffff;
- }
- static FASTCALL void
- fbStore_a8b8g8r8(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD32 *pixel = (CARD32 *) bits + x;
- for (i = 0; i < width; ++i)
- *pixel++ =
- (values[i] & 0xff00ff00) | ((values[i] >> 16) & 0xff) |
- ((values[i] & 0xff) << 16);
- }
- static FASTCALL void
- fbStore_x8b8g8r8(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD32 *pixel = (CARD32 *) bits + x;
- for (i = 0; i < width; ++i)
- *pixel++ =
- (values[i] & 0x0000ff00) | ((values[i] >> 16) & 0xff) |
- ((values[i] & 0xff) << 16);
- }
- static FASTCALL void
- fbStore_r8g8b8(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD8 *pixel = ((CARD8 *) bits) + 3 * x;
- for (i = 0; i < width; ++i) {
- Store24(pixel, values[i]);
- pixel += 3;
- }
- }
- static FASTCALL void
- fbStore_b8g8r8(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD8 *pixel = ((CARD8 *) bits) + 3 * x;
- for (i = 0; i < width; ++i) {
- #if IMAGE_BYTE_ORDER == MSBFirst
- *pixel++ = Blue(values[i]);
- *pixel++ = Green(values[i]);
- *pixel++ = Red(values[i]);
- #else
- *pixel++ = Red(values[i]);
- *pixel++ = Green(values[i]);
- *pixel++ = Blue(values[i]);
- #endif
- }
- }
- static FASTCALL void
- fbStore_r5g6b5(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- CARD32 s = values[i];
- *pixel++ = ((s >> 3) & 0x001f) |
- ((s >> 5) & 0x07e0) | ((s >> 8) & 0xf800);
- }
- }
- static FASTCALL void
- fbStore_b5g6r5(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Split(values[i]);
- *pixel++ = (((b << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((r >> 3)));
- }
- }
- static FASTCALL void
- fbStore_a1r5g5b5(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Splita(values[i]);
- *pixel++ = (((a << 8) & 0x8000) |
- ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3)));
- }
- }
- static FASTCALL void
- fbStore_x1r5g5b5(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Split(values[i]);
- *pixel++ = (((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3)));
- }
- }
- static FASTCALL void
- fbStore_a1b5g5r5(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Splita(values[i]);
- *pixel++ = (((a << 8) & 0x8000) |
- ((b << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((r >> 3)));
- }
- }
- static FASTCALL void
- fbStore_x1b5g5r5(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Split(values[i]);
- *pixel++ = (((b << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((r >> 3)));
- }
- }
- static FASTCALL void
- fbStore_a4r4g4b4(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Splita(values[i]);
- *pixel++ = (((a << 8) & 0xf000) |
- ((r << 4) & 0x0f00) | ((g) & 0x00f0) | ((b >> 4)));
- }
- }
- static FASTCALL void
- fbStore_x4r4g4b4(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Split(values[i]);
- *pixel++ = (((r << 4) & 0x0f00) | ((g) & 0x00f0) | ((b >> 4)));
- }
- }
- static FASTCALL void
- fbStore_a4b4g4r4(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Splita(values[i]);
- *pixel++ = (((a << 8) & 0xf000) |
- ((b << 4) & 0x0f00) | ((g) & 0x00f0) | ((r >> 4)));
- }
- }
- static FASTCALL void
- fbStore_x4b4g4r4(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD16 *pixel = ((CARD16 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Split(values[i]);
- *pixel++ = (((b << 4) & 0x0f00) | ((g) & 0x00f0) | ((r >> 4)));
- }
- }
- static FASTCALL void
- fbStore_a8(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD8 *pixel = ((CARD8 *) bits) + x;
- for (i = 0; i < width; ++i) {
- *pixel++ = values[i] >> 24;
- }
- }
- static FASTCALL void
- fbStore_r3g3b2(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD8 *pixel = ((CARD8 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Split(values[i]);
- *pixel++ = (((r) & 0xe0) | ((g >> 3) & 0x1c) | ((b >> 6)));
- }
- }
- static FASTCALL void
- fbStore_b2g3r3(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD8 *pixel = ((CARD8 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Split(values[i]);
- *pixel++ = (((b) & 0xe0) | ((g >> 3) & 0x1c) | ((r >> 6)));
- }
- }
- static FASTCALL void
- fbStore_a2r2g2b2(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD8 *pixel = ((CARD8 *) bits) + x;
- for (i = 0; i < width; ++i) {
- Splita(values[i]);
- *pixel++ = (((a) & 0xc0) |
- ((r >> 2) & 0x30) | ((g >> 4) & 0x0c) | ((b >> 6)));
- }
- }
- static FASTCALL void
- fbStore_c8(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD8 *pixel = ((CARD8 *) bits) + x;
- for (i = 0; i < width; ++i) {
- *pixel++ = miIndexToEnt24(indexed, values[i]);
- }
- }
- static FASTCALL void
- fbStore_x4a4(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- CARD8 *pixel = ((CARD8 *) bits) + x;
- for (i = 0; i < width; ++i) {
- *pixel++ = values[i] >> 28;
- }
- }
- #define Store8(l,o,v) (((CARD8 *) l)[(o) >> 3] = (v))
- #if IMAGE_BYTE_ORDER == MSBFirst
- #define Store4(l,o,v) Store8(l,o,((o) & 4 ? \
- (Fetch8(l,o) & 0xf0) | (v) : \
- (Fetch8(l,o) & 0x0f) | ((v) << 4)))
- #else
- #define Store4(l,o,v) Store8(l,o,((o) & 4 ? \
- (Fetch8(l,o) & 0x0f) | ((v) << 4) : \
- (Fetch8(l,o) & 0xf0) | (v)))
- #endif
- static FASTCALL void
- fbStore_a4(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- Store4(bits, i + x, values[i] >> 28);
- }
- }
- static FASTCALL void
- fbStore_r1g2b1(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 pixel;
- Split(values[i]);
- pixel = (((r >> 4) & 0x8) | ((g >> 5) & 0x6) | ((b >> 7)));
- Store4(bits, i + x, pixel);
- }
- }
- static FASTCALL void
- fbStore_b1g2r1(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 pixel;
- Split(values[i]);
- pixel = (((b >> 4) & 0x8) | ((g >> 5) & 0x6) | ((r >> 7)));
- Store4(bits, i + x, pixel);
- }
- }
- static FASTCALL void
- fbStore_a1r1g1b1(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 pixel;
- Splita(values[i]);
- pixel = (((a >> 4) & 0x8) |
- ((r >> 5) & 0x4) | ((g >> 6) & 0x2) | ((b >> 7)));
- Store4(bits, i + x, pixel);
- }
- }
- static FASTCALL void
- fbStore_a1b1g1r1(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 pixel;
- Splita(values[i]);
- pixel = (((a >> 4) & 0x8) |
- ((b >> 5) & 0x4) | ((g >> 6) & 0x2) | ((r >> 7)));
- Store4(bits, i + x, pixel);
- }
- }
- static FASTCALL void
- fbStore_c4(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 pixel;
- pixel = miIndexToEnt24(indexed, values[i]);
- Store4(bits, i + x, pixel);
- }
- }
- static FASTCALL void
- fbStore_a1(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 *pixel = ((CARD32 *) bits) + ((i + x) >> 5);
- CARD32 mask = FbStipMask((i + x) & 0x1f, 1);
- CARD32 v = values[i] & 0x80000000 ? mask : 0;
- *pixel = (*pixel & ~mask) | v;
- }
- }
- static FASTCALL void
- fbStore_g1(FbBits * bits, const CARD32 *values, int x, int width,
- miIndexedPtr indexed)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 *pixel = ((CARD32 *) bits) + ((i + x) >> 5);
- CARD32 mask = FbStipMask((i + x) & 0x1f, 1);
- CARD32 v = miIndexToEntY24(indexed, values[i]) ? mask : 0;
- *pixel = (*pixel & ~mask) | v;
- }
- }
- static storeProc
- storeProcForPicture(PicturePtr pict)
- {
- switch (pict->format) {
- case PICT_a8r8g8b8:
- return fbStore_a8r8g8b8;
- case PICT_x8r8g8b8:
- return fbStore_x8r8g8b8;
- case PICT_a8b8g8r8:
- return fbStore_a8b8g8r8;
- case PICT_x8b8g8r8:
- return fbStore_x8b8g8r8;
- /* 24bpp formats */
- case PICT_r8g8b8:
- return fbStore_r8g8b8;
- case PICT_b8g8r8:
- return fbStore_b8g8r8;
- /* 16bpp formats */
- case PICT_r5g6b5:
- return fbStore_r5g6b5;
- case PICT_b5g6r5:
- return fbStore_b5g6r5;
- case PICT_a1r5g5b5:
- return fbStore_a1r5g5b5;
- case PICT_x1r5g5b5:
- return fbStore_x1r5g5b5;
- case PICT_a1b5g5r5:
- return fbStore_a1b5g5r5;
- case PICT_x1b5g5r5:
- return fbStore_x1b5g5r5;
- case PICT_a4r4g4b4:
- return fbStore_a4r4g4b4;
- case PICT_x4r4g4b4:
- return fbStore_x4r4g4b4;
- case PICT_a4b4g4r4:
- return fbStore_a4b4g4r4;
- case PICT_x4b4g4r4:
- return fbStore_x4b4g4r4;
- /* 8bpp formats */
- case PICT_a8:
- return fbStore_a8;
- case PICT_r3g3b2:
- return fbStore_r3g3b2;
- case PICT_b2g3r3:
- return fbStore_b2g3r3;
- case PICT_a2r2g2b2:
- return fbStore_a2r2g2b2;
- case PICT_c8:
- return fbStore_c8;
- case PICT_g8:
- return fbStore_c8;
- case PICT_x4a4:
- return fbStore_x4a4;
- /* 4bpp formats */
- case PICT_a4:
- return fbStore_a4;
- case PICT_r1g2b1:
- return fbStore_r1g2b1;
- case PICT_b1g2r1:
- return fbStore_b1g2r1;
- case PICT_a1r1g1b1:
- return fbStore_a1r1g1b1;
- case PICT_a1b1g1r1:
- return fbStore_a1b1g1r1;
- case PICT_c4:
- return fbStore_c4;
- case PICT_g4:
- return fbStore_c4;
- /* 1bpp formats */
- case PICT_a1:
- return fbStore_a1;
- case PICT_g1:
- return fbStore_g1;
- default:
- return NULL;
- }
- }
- /*
- * Combine src and mask
- */
- static FASTCALL void
- fbCombineMaskU(CARD32 *src, const CARD32 *mask, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 a = mask[i] >> 24;
- CARD32 s = src[i];
- FbByteMul(s, a);
- src[i] = s;
- }
- }
- /*
- * All of the composing functions
- */
- static FASTCALL void
- fbCombineClear(CARD32 *dest, const CARD32 *src, int width)
- {
- memset(dest, 0, width * sizeof(CARD32));
- }
- static FASTCALL void
- fbCombineSrcU(CARD32 *dest, const CARD32 *src, int width)
- {
- memcpy(dest, src, width * sizeof(CARD32));
- }
- static FASTCALL void
- fbCombineOverU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- CARD32 ia = Alpha(~s);
- FbByteMulAdd(d, ia, s);
- dest[i] = d;
- }
- }
- static FASTCALL void
- fbCombineOverReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- CARD32 ia = Alpha(~dest[i]);
- FbByteMulAdd(s, ia, d);
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineInU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 a = Alpha(dest[i]);
- FbByteMul(s, a);
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineInReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 d = dest[i];
- CARD32 a = Alpha(src[i]);
- FbByteMul(d, a);
- dest[i] = d;
- }
- }
- static FASTCALL void
- fbCombineOutU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 a = Alpha(~dest[i]);
- FbByteMul(s, a);
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineOutReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 d = dest[i];
- CARD32 a = Alpha(~src[i]);
- FbByteMul(d, a);
- dest[i] = d;
- }
- }
- static FASTCALL void
- fbCombineAtopU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- CARD32 dest_a = Alpha(d);
- CARD32 src_ia = Alpha(~s);
- FbByteAddMul(s, dest_a, d, src_ia);
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineAtopReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- CARD32 src_a = Alpha(s);
- CARD32 dest_ia = Alpha(~d);
- FbByteAddMul(s, dest_ia, d, src_a);
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineXorU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- CARD32 src_ia = Alpha(~s);
- CARD32 dest_ia = Alpha(~d);
- FbByteAddMul(s, dest_ia, d, src_ia);
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineAddU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- FbByteAdd(d, s);
- dest[i] = d;
- }
- }
- static FASTCALL void
- fbCombineSaturateU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- CARD16 sa, da;
- sa = s >> 24;
- da = ~d >> 24;
- if (sa > da) {
- sa = FbIntDiv(da, sa);
- FbByteMul(s, sa);
- }
- FbByteAdd(d, s);
- dest[i] = d;
- }
- }
- /*
- * All of the disjoint composing functions
- The four entries in the first column indicate what source contributions
- come from each of the four areas of the picture -- areas covered by neither
- A nor B, areas covered only by A, areas covered only by B and finally
- areas covered by both A and B.
- Disjoint Conjoint
- Fa Fb Fa Fb
- (0,0,0,0) 0 0 0 0
- (0,A,0,A) 1 0 1 0
- (0,0,B,B) 0 1 0 1
- (0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0)
- (0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1
- (0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0
- (0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1)
- (0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0
- (0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0)
- (0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0)
- (0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b)
- (0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0)
- */
- #define CombineAOut 1
- #define CombineAIn 2
- #define CombineBOut 4
- #define CombineBIn 8
- #define CombineClear 0
- #define CombineA (CombineAOut|CombineAIn)
- #define CombineB (CombineBOut|CombineBIn)
- #define CombineAOver (CombineAOut|CombineBOut|CombineAIn)
- #define CombineBOver (CombineAOut|CombineBOut|CombineBIn)
- #define CombineAAtop (CombineBOut|CombineAIn)
- #define CombineBAtop (CombineAOut|CombineBIn)
- #define CombineXor (CombineAOut|CombineBOut)
- /* portion covered by a but not b */
- static INLINE CARD8
- fbCombineDisjointOutPart(CARD8 a, CARD8 b)
- {
- /* min (1, (1-b) / a) */
- b = ~b; /* 1 - b */
- if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
- return 0xff; /* 1 */
- return FbIntDiv(b, a); /* (1-b) / a */
- }
- /* portion covered by both a and b */
- static INLINE CARD8
- fbCombineDisjointInPart(CARD8 a, CARD8 b)
- {
- /* max (1-(1-b)/a,0) */
- /* = - min ((1-b)/a - 1, 0) */
- /* = 1 - min (1, (1-b)/a) */
- b = ~b; /* 1 - b */
- if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
- return 0; /* 1 - 1 */
- return ~FbIntDiv(b, a); /* 1 - (1-b) / a */
- }
- static FASTCALL void
- fbCombineDisjointGeneralU(CARD32 *dest, const CARD32 *src, int width,
- CARD8 combine)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- CARD32 m, n, o, p;
- CARD16 Fa, Fb, t, u, v;
- CARD8 sa = s >> 24;
- CARD8 da = d >> 24;
- switch (combine & CombineA) {
- default:
- Fa = 0;
- break;
- case CombineAOut:
- Fa = fbCombineDisjointOutPart(sa, da);
- break;
- case CombineAIn:
- Fa = fbCombineDisjointInPart(sa, da);
- break;
- case CombineA:
- Fa = 0xff;
- break;
- }
- switch (combine & CombineB) {
- default:
- Fb = 0;
- break;
- case CombineBOut:
- Fb = fbCombineDisjointOutPart(da, sa);
- break;
- case CombineBIn:
- Fb = fbCombineDisjointInPart(da, sa);
- break;
- case CombineB:
- Fb = 0xff;
- break;
- }
- m = FbGen(s, d, 0, Fa, Fb, t, u, v);
- n = FbGen(s, d, 8, Fa, Fb, t, u, v);
- o = FbGen(s, d, 16, Fa, Fb, t, u, v);
- p = FbGen(s, d, 24, Fa, Fb, t, u, v);
- s = m | n | o | p;
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineDisjointOverU(CARD32 *dest, const CARD32 *src, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD16 a = s >> 24;
- if (a != 0x00) {
- if (a != 0xff) {
- CARD32 d = dest[i];
- a = fbCombineDisjointOutPart(d >> 24, a);
- FbByteMulAdd(d, a, s);
- s = d;
- }
- dest[i] = s;
- }
- }
- }
- static FASTCALL void
- fbCombineDisjointInU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineDisjointGeneralU(dest, src, width, CombineAIn);
- }
- static FASTCALL void
- fbCombineDisjointInReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineDisjointGeneralU(dest, src, width, CombineBIn);
- }
- static FASTCALL void
- fbCombineDisjointOutU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineDisjointGeneralU(dest, src, width, CombineAOut);
- }
- static FASTCALL void
- fbCombineDisjointOutReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineDisjointGeneralU(dest, src, width, CombineBOut);
- }
- static FASTCALL void
- fbCombineDisjointAtopU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineDisjointGeneralU(dest, src, width, CombineAAtop);
- }
- static FASTCALL void
- fbCombineDisjointAtopReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineDisjointGeneralU(dest, src, width, CombineBAtop);
- }
- static FASTCALL void
- fbCombineDisjointXorU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineDisjointGeneralU(dest, src, width, CombineXor);
- }
- /* portion covered by a but not b */
- static INLINE CARD8
- fbCombineConjointOutPart(CARD8 a, CARD8 b)
- {
- /* max (1-b/a,0) */
- /* = 1-min(b/a,1) */
- /* min (1, (1-b) / a) */
- if (b >= a) /* b >= a -> b/a >= 1 */
- return 0x00; /* 0 */
- return ~FbIntDiv(b, a); /* 1 - b/a */
- }
- /* portion covered by both a and b */
- static INLINE CARD8
- fbCombineConjointInPart(CARD8 a, CARD8 b)
- {
- /* min (1,b/a) */
- if (b >= a) /* b >= a -> b/a >= 1 */
- return 0xff; /* 1 */
- return FbIntDiv(b, a); /* b/a */
- }
- static FASTCALL void
- fbCombineConjointGeneralU(CARD32 *dest, const CARD32 *src, int width,
- CARD8 combine)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- CARD32 m, n, o, p;
- CARD16 Fa, Fb, t, u, v;
- CARD8 sa = s >> 24;
- CARD8 da = d >> 24;
- switch (combine & CombineA) {
- default:
- Fa = 0;
- break;
- case CombineAOut:
- Fa = fbCombineConjointOutPart(sa, da);
- break;
- case CombineAIn:
- Fa = fbCombineConjointInPart(sa, da);
- break;
- case CombineA:
- Fa = 0xff;
- break;
- }
- switch (combine & CombineB) {
- default:
- Fb = 0;
- break;
- case CombineBOut:
- Fb = fbCombineConjointOutPart(da, sa);
- break;
- case CombineBIn:
- Fb = fbCombineConjointInPart(da, sa);
- break;
- case CombineB:
- Fb = 0xff;
- break;
- }
- m = FbGen(s, d, 0, Fa, Fb, t, u, v);
- n = FbGen(s, d, 8, Fa, Fb, t, u, v);
- o = FbGen(s, d, 16, Fa, Fb, t, u, v);
- p = FbGen(s, d, 24, Fa, Fb, t, u, v);
- s = m | n | o | p;
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineConjointOverU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineAOver);
- }
- static FASTCALL void
- fbCombineConjointOverReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineBOver);
- }
- static FASTCALL void
- fbCombineConjointInU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineAIn);
- }
- static FASTCALL void
- fbCombineConjointInReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineBIn);
- }
- static FASTCALL void
- fbCombineConjointOutU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineAOut);
- }
- static FASTCALL void
- fbCombineConjointOutReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineBOut);
- }
- static FASTCALL void
- fbCombineConjointAtopU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineAAtop);
- }
- static FASTCALL void
- fbCombineConjointAtopReverseU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineBAtop);
- }
- static FASTCALL void
- fbCombineConjointXorU(CARD32 *dest, const CARD32 *src, int width)
- {
- fbCombineConjointGeneralU(dest, src, width, CombineXor);
- }
- static const CombineFuncU fbCombineFuncU[] = {
- fbCombineClear,
- fbCombineSrcU,
- NULL, /* CombineDst */
- fbCombineOverU,
- fbCombineOverReverseU,
- fbCombineInU,
- fbCombineInReverseU,
- fbCombineOutU,
- fbCombineOutReverseU,
- fbCombineAtopU,
- fbCombineAtopReverseU,
- fbCombineXorU,
- fbCombineAddU,
- fbCombineSaturateU,
- NULL,
- NULL,
- fbCombineClear,
- fbCombineSrcU,
- NULL, /* CombineDst */
- fbCombineDisjointOverU,
- fbCombineSaturateU, /* DisjointOverReverse */
- fbCombineDisjointInU,
- fbCombineDisjointInReverseU,
- fbCombineDisjointOutU,
- fbCombineDisjointOutReverseU,
- fbCombineDisjointAtopU,
- fbCombineDisjointAtopReverseU,
- fbCombineDisjointXorU,
- NULL,
- NULL,
- NULL,
- NULL,
- fbCombineClear,
- fbCombineSrcU,
- NULL, /* CombineDst */
- fbCombineConjointOverU,
- fbCombineConjointOverReverseU,
- fbCombineConjointInU,
- fbCombineConjointInReverseU,
- fbCombineConjointOutU,
- fbCombineConjointOutReverseU,
- fbCombineConjointAtopU,
- fbCombineConjointAtopReverseU,
- fbCombineConjointXorU,
- };
- static FASTCALL void
- fbCombineMaskC(CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 a = mask[i];
- CARD32 x;
- CARD16 xa;
- if (!a) {
- src[i] = 0;
- continue;
- }
- x = src[i];
- if (a == 0xffffffff) {
- x = x >> 24;
- x |= x << 8;
- x |= x << 16;
- mask[i] = x;
- continue;
- }
- xa = x >> 24;
- FbByteMulC(x, a);
- src[i] = x;
- FbByteMul(a, xa);
- mask[i] = a;
- }
- }
- static FASTCALL void
- fbCombineMaskValueC(CARD32 *src, const CARD32 *mask, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 a = mask[i];
- CARD32 x;
- if (!a) {
- src[i] = 0;
- continue;
- }
- if (a == 0xffffffff)
- continue;
- x = src[i];
- FbByteMulC(x, a);
- src[i] = x;
- }
- }
- static FASTCALL void
- fbCombineMaskAlphaC(const CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- for (i = 0; i < width; ++i) {
- CARD32 a = mask[i];
- CARD32 x;
- if (!a)
- continue;
- x = src[i] >> 24;
- if (x == 0xff)
- continue;
- if (a == 0xffffffff) {
- x = x >> 24;
- x |= x << 8;
- x |= x << 16;
- mask[i] = x;
- continue;
- }
- FbByteMul(a, x);
- mask[i] = a;
- }
- }
- static FASTCALL void
- fbCombineClearC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- memset(dest, 0, width * sizeof(CARD32));
- }
- static FASTCALL void
- fbCombineSrcC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineMaskValueC(src, mask, width);
- memcpy(dest, src, width * sizeof(CARD32));
- }
- static FASTCALL void
- fbCombineOverC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 a = ~mask[i];
- if (a != 0xffffffff) {
- if (a) {
- CARD32 d = dest[i];
- FbByteMulAddC(d, a, s);
- s = d;
- }
- dest[i] = s;
- }
- }
- }
- static FASTCALL void
- fbCombineOverReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskValueC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 d = dest[i];
- CARD32 a = ~d >> 24;
- if (a) {
- CARD32 s = src[i];
- if (a != 0xff) {
- FbByteMulAdd(s, a, d);
- }
- dest[i] = s;
- }
- }
- }
- static FASTCALL void
- fbCombineInC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskValueC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 d = dest[i];
- CARD16 a = d >> 24;
- CARD32 s = 0;
- if (a) {
- s = src[i];
- if (a != 0xff) {
- FbByteMul(s, a);
- }
- }
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineInReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskAlphaC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 a = mask[i];
- if (a != 0xffffffff) {
- CARD32 d = 0;
- if (a) {
- d = dest[i];
- FbByteMulC(d, a);
- }
- dest[i] = d;
- }
- }
- }
- static FASTCALL void
- fbCombineOutC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskValueC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 d = dest[i];
- CARD16 a = ~d >> 24;
- CARD32 s = 0;
- if (a) {
- s = src[i];
- if (a != 0xff) {
- FbByteMul(s, a);
- }
- }
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineOutReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskAlphaC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 a = ~mask[i];
- if (a != 0xffffffff) {
- CARD32 d = 0;
- if (a) {
- d = dest[i];
- FbByteMulC(d, a);
- }
- dest[i] = d;
- }
- }
- }
- static FASTCALL void
- fbCombineAtopC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 d = dest[i];
- CARD32 s = src[i];
- CARD32 ad = ~mask[i];
- CARD16 as = d >> 24;
- FbByteAddMulC(d, ad, s, as);
- dest[i] = d;
- }
- }
- static FASTCALL void
- fbCombineAtopReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 d = dest[i];
- CARD32 s = src[i];
- CARD32 ad = mask[i];
- CARD16 as = ~d >> 24;
- FbByteAddMulC(d, ad, s, as);
- dest[i] = d;
- }
- }
- static FASTCALL void
- fbCombineXorC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 d = dest[i];
- CARD32 s = src[i];
- CARD32 ad = ~mask[i];
- CARD16 as = ~d >> 24;
- FbByteAddMulC(d, ad, s, as);
- dest[i] = d;
- }
- }
- static FASTCALL void
- fbCombineAddC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskValueC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 s = src[i];
- CARD32 d = dest[i];
- FbByteAdd(d, s);
- dest[i] = d;
- }
- }
- static FASTCALL void
- fbCombineSaturateC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- int i;
- fbCombineMaskC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 s, d;
- CARD16 sa, sr, sg, sb, da;
- CARD16 t, u, v;
- CARD32 m, n, o, p;
- d = dest[i];
- s = src[i];
- sa = (mask[i] >> 24);
- sr = (mask[i] >> 16) & 0xff;
- sg = (mask[i] >> 8) & 0xff;
- sb = (mask[i]) & 0xff;
- da = ~d >> 24;
- if (sb <= da)
- m = FbAdd(s, d, 0, t);
- else
- m = FbGen(s, d, 0, (da << 8) / sb, 0xff, t, u, v);
- if (sg <= da)
- n = FbAdd(s, d, 8, t);
- else
- n = FbGen(s, d, 8, (da << 8) / sg, 0xff, t, u, v);
- if (sr <= da)
- o = FbAdd(s, d, 16, t);
- else
- o = FbGen(s, d, 16, (da << 8) / sr, 0xff, t, u, v);
- if (sa <= da)
- p = FbAdd(s, d, 24, t);
- else
- p = FbGen(s, d, 24, (da << 8) / sa, 0xff, t, u, v);
- dest[i] = m | n | o | p;
- }
- }
- static FASTCALL void
- fbCombineDisjointGeneralC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width,
- CARD8 combine)
- {
- int i;
- fbCombineMaskC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 s, d;
- CARD32 m, n, o, p;
- CARD32 Fa, Fb;
- CARD16 t, u, v;
- CARD32 sa;
- CARD8 da;
- s = src[i];
- sa = mask[i];
- d = dest[i];
- da = d >> 24;
- switch (combine & CombineA) {
- default:
- Fa = 0;
- break;
- case CombineAOut:
- m = fbCombineDisjointOutPart((CARD8) (sa >> 0), da);
- n = fbCombineDisjointOutPart((CARD8) (sa >> 8), da) << 8;
- o = fbCombineDisjointOutPart((CARD8) (sa >> 16), da) << 16;
- p = fbCombineDisjointOutPart((CARD8) (sa >> 24), da) << 24;
- Fa = m | n | o | p;
- break;
- case CombineAIn:
- m = fbCombineDisjointInPart((CARD8) (sa >> 0), da);
- n = fbCombineDisjointInPart((CARD8) (sa >> 8), da) << 8;
- o = fbCombineDisjointInPart((CARD8) (sa >> 16), da) << 16;
- p = fbCombineDisjointInPart((CARD8) (sa >> 24), da) << 24;
- Fa = m | n | o | p;
- break;
- case CombineA:
- Fa = 0xffffffff;
- break;
- }
- switch (combine & CombineB) {
- default:
- Fb = 0;
- break;
- case CombineBOut:
- m = fbCombineDisjointOutPart(da, (CARD8) (sa >> 0));
- n = fbCombineDisjointOutPart(da, (CARD8) (sa >> 8)) << 8;
- o = fbCombineDisjointOutPart(da, (CARD8) (sa >> 16)) << 16;
- p = fbCombineDisjointOutPart(da, (CARD8) (sa >> 24)) << 24;
- Fb = m | n | o | p;
- break;
- case CombineBIn:
- m = fbCombineDisjointInPart(da, (CARD8) (sa >> 0));
- n = fbCombineDisjointInPart(da, (CARD8) (sa >> 8)) << 8;
- o = fbCombineDisjointInPart(da, (CARD8) (sa >> 16)) << 16;
- p = fbCombineDisjointInPart(da, (CARD8) (sa >> 24)) << 24;
- Fb = m | n | o | p;
- break;
- case CombineB:
- Fb = 0xffffffff;
- break;
- }
- m = FbGen(s, d, 0, FbGet8(Fa, 0), FbGet8(Fb, 0), t, u, v);
- n = FbGen(s, d, 8, FbGet8(Fa, 8), FbGet8(Fb, 8), t, u, v);
- o = FbGen(s, d, 16, FbGet8(Fa, 16), FbGet8(Fb, 16), t, u, v);
- p = FbGen(s, d, 24, FbGet8(Fa, 24), FbGet8(Fb, 24), t, u, v);
- s = m | n | o | p;
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineDisjointOverC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineDisjointGeneralC(dest, src, mask, width, CombineAOver);
- }
- static FASTCALL void
- fbCombineDisjointInC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineDisjointGeneralC(dest, src, mask, width, CombineAIn);
- }
- static FASTCALL void
- fbCombineDisjointInReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineDisjointGeneralC(dest, src, mask, width, CombineBIn);
- }
- static FASTCALL void
- fbCombineDisjointOutC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineDisjointGeneralC(dest, src, mask, width, CombineAOut);
- }
- static FASTCALL void
- fbCombineDisjointOutReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineDisjointGeneralC(dest, src, mask, width, CombineBOut);
- }
- static FASTCALL void
- fbCombineDisjointAtopC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineDisjointGeneralC(dest, src, mask, width, CombineAAtop);
- }
- static FASTCALL void
- fbCombineDisjointAtopReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask,
- int width)
- {
- fbCombineDisjointGeneralC(dest, src, mask, width, CombineBAtop);
- }
- static FASTCALL void
- fbCombineDisjointXorC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineDisjointGeneralC(dest, src, mask, width, CombineXor);
- }
- static FASTCALL void
- fbCombineConjointGeneralC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width,
- CARD8 combine)
- {
- int i;
- fbCombineMaskC(src, mask, width);
- for (i = 0; i < width; ++i) {
- CARD32 s, d;
- CARD32 m, n, o, p;
- CARD32 Fa, Fb;
- CARD16 t, u, v;
- CARD32 sa;
- CARD8 da;
- s = src[i];
- sa = mask[i];
- d = dest[i];
- da = d >> 24;
- switch (combine & CombineA) {
- default:
- Fa = 0;
- break;
- case CombineAOut:
- m = fbCombineConjointOutPart((CARD8) (sa >> 0), da);
- n = fbCombineConjointOutPart((CARD8) (sa >> 8), da) << 8;
- o = fbCombineConjointOutPart((CARD8) (sa >> 16), da) << 16;
- p = fbCombineConjointOutPart((CARD8) (sa >> 24), da) << 24;
- Fa = m | n | o | p;
- break;
- case CombineAIn:
- m = fbCombineConjointInPart((CARD8) (sa >> 0), da);
- n = fbCombineConjointInPart((CARD8) (sa >> 8), da) << 8;
- o = fbCombineConjointInPart((CARD8) (sa >> 16), da) << 16;
- p = fbCombineConjointInPart((CARD8) (sa >> 24), da) << 24;
- Fa = m | n | o | p;
- break;
- case CombineA:
- Fa = 0xffffffff;
- break;
- }
- switch (combine & CombineB) {
- default:
- Fb = 0;
- break;
- case CombineBOut:
- m = fbCombineConjointOutPart(da, (CARD8) (sa >> 0));
- n = fbCombineConjointOutPart(da, (CARD8) (sa >> 8)) << 8;
- o = fbCombineConjointOutPart(da, (CARD8) (sa >> 16)) << 16;
- p = fbCombineConjointOutPart(da, (CARD8) (sa >> 24)) << 24;
- Fb = m | n | o | p;
- break;
- case CombineBIn:
- m = fbCombineConjointInPart(da, (CARD8) (sa >> 0));
- n = fbCombineConjointInPart(da, (CARD8) (sa >> 8)) << 8;
- o = fbCombineConjointInPart(da, (CARD8) (sa >> 16)) << 16;
- p = fbCombineConjointInPart(da, (CARD8) (sa >> 24)) << 24;
- Fb = m | n | o | p;
- break;
- case CombineB:
- Fb = 0xffffffff;
- break;
- }
- m = FbGen(s, d, 0, FbGet8(Fa, 0), FbGet8(Fb, 0), t, u, v);
- n = FbGen(s, d, 8, FbGet8(Fa, 8), FbGet8(Fb, 8), t, u, v);
- o = FbGen(s, d, 16, FbGet8(Fa, 16), FbGet8(Fb, 16), t, u, v);
- p = FbGen(s, d, 24, FbGet8(Fa, 24), FbGet8(Fb, 24), t, u, v);
- s = m | n | o | p;
- dest[i] = s;
- }
- }
- static FASTCALL void
- fbCombineConjointOverC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineAOver);
- }
- static FASTCALL void
- fbCombineConjointOverReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask,
- int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineBOver);
- }
- static FASTCALL void
- fbCombineConjointInC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineAIn);
- }
- static FASTCALL void
- fbCombineConjointInReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineBIn);
- }
- static FASTCALL void
- fbCombineConjointOutC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineAOut);
- }
- static FASTCALL void
- fbCombineConjointOutReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineBOut);
- }
- static FASTCALL void
- fbCombineConjointAtopC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineAAtop);
- }
- static FASTCALL void
- fbCombineConjointAtopReverseC(CARD32 *dest, CARD32 *src, CARD32 *mask,
- int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineBAtop);
- }
- static FASTCALL void
- fbCombineConjointXorC(CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
- {
- fbCombineConjointGeneralC(dest, src, mask, width, CombineXor);
- }
- static const CombineFuncC fbCombineFuncC[] = {
- fbCombineClearC,
- fbCombineSrcC,
- NULL, /* Dest */
- fbCombineOverC,
- fbCombineOverReverseC,
- fbCombineInC,
- fbCombineInReverseC,
- fbCombineOutC,
- fbCombineOutReverseC,
- fbCombineAtopC,
- fbCombineAtopReverseC,
- fbCombineXorC,
- fbCombineAddC,
- fbCombineSaturateC,
- NULL,
- NULL,
- fbCombineClearC, /* 0x10 */
- fbCombineSrcC,
- NULL, /* Dest */
- fbCombineDisjointOverC,
- fbCombineSaturateC, /* DisjointOverReverse */
- fbCombineDisjointInC,
- fbCombineDisjointInReverseC,
- fbCombineDisjointOutC,
- fbCombineDisjointOutReverseC,
- fbCombineDisjointAtopC,
- fbCombineDisjointAtopReverseC,
- fbCombineDisjointXorC, /* 0x1b */
- NULL,
- NULL,
- NULL,
- NULL,
- fbCombineClearC,
- fbCombineSrcC,
- NULL, /* Dest */
- fbCombineConjointOverC,
- fbCombineConjointOverReverseC,
- fbCombineConjointInC,
- fbCombineConjointInReverseC,
- fbCombineConjointOutC,
- fbCombineConjointOutReverseC,
- fbCombineConjointAtopC,
- fbCombineConjointAtopReverseC,
- fbCombineConjointXorC,
- };
- static const FbComposeFunctions composeFunctions = {
- fbCombineFuncU,
- fbCombineFuncC,
- fbCombineMaskU
- };
- static void
- fbFetchSolid(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
- {
- FbBits *bits;
- FbStride stride;
- int bpp;
- int xoff, yoff;
- CARD32 color;
- CARD32 *end;
- fetchPixelProc fetch = fetchPixelProcForPicture(pict);
- miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
- fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff);
- bits += yoff * stride + (xoff * bpp >> FB_SHIFT);
- color = fetch(bits, 0, indexed);
- end = buffer + width;
- while (buffer < end)
- *buffer++ = color;
- }
- static void
- fbFetch(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
- {
- FbBits *bits;
- FbStride stride;
- int bpp;
- int xoff, yoff;
- fetchProc fetch = fetchProcForPicture(pict);
- miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
- fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff);
- x += xoff;
- y += yoff;
- bits += y * stride;
- fetch(bits, x, width, buffer, indexed);
- }
- #define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
- #define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :\
- ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
- static CARD32
- gradientPixel(const SourcePictPtr pGradient, xFixed_48_16 pos,
- unsigned int spread)
- {
- int ipos = (pos * PICT_GRADIENT_STOPTABLE_SIZE - 1) >> 16;
- /* calculate the actual offset. */
- if (ipos < 0 || ipos >= PICT_GRADIENT_STOPTABLE_SIZE) {
- if (pGradient->type == SourcePictTypeConical || spread == RepeatNormal) {
- ipos = ipos % PICT_GRADIENT_STOPTABLE_SIZE;
- ipos = ipos < 0 ? PICT_GRADIENT_STOPTABLE_SIZE + ipos : ipos;
- }
- else if (spread == RepeatReflect) {
- const int limit = PICT_GRADIENT_STOPTABLE_SIZE * 2 - 1;
- ipos = ipos % limit;
- ipos = ipos < 0 ? limit + ipos : ipos;
- ipos = ipos >= PICT_GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos;
- }
- else if (spread == RepeatPad) {
- if (ipos < 0)
- ipos = 0;
- else if (ipos >= PICT_GRADIENT_STOPTABLE_SIZE)
- ipos = PICT_GRADIENT_STOPTABLE_SIZE - 1;
- }
- else { /* RepeatNone */
- return 0;
- }
- }
- assert(ipos >= 0);
- assert(ipos < PICT_GRADIENT_STOPTABLE_SIZE);
- return pGradient->linear.colorTable[ipos];
- }
- static void
- fbFetchSourcePict(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
- {
- SourcePictPtr pGradient = pict->pSourcePict;
- CARD32 *end = buffer + width;
- if (pGradient->type == SourcePictTypeSolidFill) {
- CARD32 color = pGradient->solidFill.color;
- while (buffer < end) {
- *buffer++ = color;
- }
- }
- else if (pGradient->type == SourcePictTypeLinear) {
- PictVector v, unit;
- xFixed_32_32 l;
- xFixed_48_16 dx, dy, a, b, off;
- /* reference point is the center of the pixel */
- v.vector[0] = IntToxFixed(x) + xFixed1 / 2;
- v.vector[1] = IntToxFixed(y) + xFixed1 / 2;
- v.vector[2] = xFixed1;
- if (pict->transform) {
- if (!PictureTransformPoint3d(pict->transform, &v))
- return;
- unit.vector[0] = pict->transform->matrix[0][0];
- unit.vector[1] = pict->transform->matrix[1][0];
- unit.vector[2] = pict->transform->matrix[2][0];
- }
- else {
- unit.vector[0] = xFixed1;
- unit.vector[1] = 0;
- unit.vector[2] = 0;
- }
- dx = pGradient->linear.p2.x - pGradient->linear.p1.x;
- dy = pGradient->linear.p2.y - pGradient->linear.p1.y;
- l = dx * dx + dy * dy;
- if (l != 0) {
- a = (dx << 32) / l;
- b = (dy << 32) / l;
- off =
- (-a * pGradient->linear.p1.x -
- b * pGradient->linear.p1.y) >> 16;
- }
- if (l == 0 || (unit.vector[2] == 0 && v.vector[2] == xFixed1)) {
- xFixed_48_16 inc, t;
- /* affine transformation only */
- if (l == 0) {
- t = 0;
- inc = 0;
- }
- else {
- t = ((a * v.vector[0] + b * v.vector[1]) >> 16) + off;
- inc = (a * unit.vector[0] + b * unit.vector[1]) >> 16;
- }
- while (buffer < end) {
- *buffer++ = gradientPixel(pGradient, t, pict->repeatType);
- t += inc;
- }
- }
- else {
- /* projective transformation */
- while (buffer < end) {
- xFixed_48_16 t;
- if (v.vector[2] == 0) {
- t = 0;
- }
- else {
- xFixed_48_16 x, y;
- x = ((xFixed_48_16) v.vector[0] << 16) / v.vector[2];
- y = ((xFixed_48_16) v.vector[1] << 16) / v.vector[2];
- t = ((a * x + b * y) >> 16) + off;
- }
- *buffer++ = gradientPixel(pGradient, t, pict->repeatType);
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- }
- else {
- /* radial or conical */
- Bool affine = TRUE;
- double cx = 1.;
- double cy = 0.;
- double cz = 0.;
- double rx = x;
- double ry = y;
- double rz = 1.;
- if (pict->transform) {
- PictVector v;
- /* reference point is the center of the pixel */
- v.vector[0] = IntToxFixed(x) + xFixed1 / 2;
- v.vector[1] = IntToxFixed(y) + xFixed1 / 2;
- v.vector[2] = xFixed1;
- if (!PictureTransformPoint3d(pict->transform, &v))
- return;
- cx = pict->transform->matrix[0][0] / 65536.;
- cy = pict->transform->matrix[1][0] / 65536.;
- cz = pict->transform->matrix[2][0] / 65536.;
- rx = v.vector[0] / 65536.;
- ry = v.vector[1] / 65536.;
- rz = v.vector[2] / 65536.;
- affine = pict->transform->matrix[2][0] == 0 &&
- v.vector[2] == xFixed1;
- }
- if (pGradient->type == SourcePictTypeRadial) {
- if (affine) {
- rx -= pGradient->radial.fx;
- ry -= pGradient->radial.fy;
- while (buffer < end) {
- double b =
- 2 * (rx * pGradient->radial.dx +
- ry * pGradient->radial.dy);
- double c = -(rx * rx + ry * ry);
- double det = (b * b) - (4 * pGradient->radial.a * c);
- double s = (-b + sqrt(det)) / (2. * pGradient->radial.a);
- *buffer = gradientPixel(pGradient,
- (xFixed_48_16) ((s *
- pGradient->radial.
- m +
- pGradient->radial.
- b) * 65536),
- pict->repeatType);
- ++buffer;
- rx += cx;
- ry += cy;
- }
- }
- else {
- while (buffer < end) {
- double x, y;
- double b, c, det, s;
- if (rz != 0) {
- x = rx / rz;
- y = ry / rz;
- }
- else {
- x = y = 0.;
- }
- x -= pGradient->radial.fx;
- y -= pGradient->radial.fy;
- b = 2 * (x * pGradient->radial.dx +
- y * pGradient->radial.dy);
- c = -(x * x + y * y);
- det = (b * b) - (4 * pGradient->radial.a * c);
- s = (-b + sqrt(det)) / (2. * pGradient->radial.a);
- *buffer = gradientPixel(pGradient,
- (xFixed_48_16) ((s *
- pGradient->radial.
- m +
- pGradient->radial.
- b) * 65536),
- pict->repeatType);
- ++buffer;
- rx += cx;
- ry += cy;
- rz += cz;
- }
- }
- }
- else { /* SourcePictTypeConical */
- double a = pGradient->conical.angle / (180. * 65536);
- if (affine) {
- rx -= pGradient->conical.center.x / 65536.;
- ry -= pGradient->conical.center.y / 65536.;
- while (buffer < end) {
- double angle = atan2(ry, rx) + a;
- *buffer =
- gradientPixel(pGradient,
- (xFixed_48_16) (angle *
- (65536. / (2 * M_PI))),
- pict->repeatType);
- ++buffer;
- rx += cx;
- ry += cy;
- }
- }
- else {
- while (buffer < end) {
- double x, y, angle;
- if (rz != 0) {
- x = rx / rz;
- y = ry / rz;
- }
- else {
- x = y = 0.;
- }
- x -= pGradient->conical.center.x / 65536.;
- y -= pGradient->conical.center.y / 65536.;
- angle = atan2(y, x) + a;
- *buffer =
- gradientPixel(pGradient,
- (xFixed_48_16) (angle *
- (65536. / (2 * M_PI))),
- pict->repeatType);
- ++buffer;
- rx += cx;
- ry += cy;
- rz += cz;
- }
- }
- }
- }
- }
- static void
- fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
- {
- FbBits *bits;
- FbStride stride;
- int bpp;
- int xoff, yoff, dx, dy;
- fetchPixelProc fetch;
- PictVector v;
- PictVector unit;
- int i;
- BoxRec box;
- miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
- Bool affine = TRUE;
- fetch = fetchPixelProcForPicture(pict);
- fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff);
- x += xoff;
- y += yoff;
- dx = pict->pDrawable->x;
- dy = pict->pDrawable->y;
- /* reference point is the center of the pixel */
- v.vector[0] = IntToxFixed(x - dx) + xFixed1 / 2;
- v.vector[1] = IntToxFixed(y - dy) + xFixed1 / 2;
- v.vector[2] = xFixed1;
- /* when using convolution filters one might get here without a transform */
- if (pict->transform) {
- if (!PictureTransformPoint3d(pict->transform, &v))
- return;
- unit.vector[0] = pict->transform->matrix[0][0];
- unit.vector[1] = pict->transform->matrix[1][0];
- unit.vector[2] = pict->transform->matrix[2][0];
- affine = v.vector[2] == xFixed1 && unit.vector[2] == 0;
- }
- else {
- unit.vector[0] = xFixed1;
- unit.vector[1] = 0;
- unit.vector[2] = 0;
- }
- if (pict->filter == PictFilterNearest) {
- if (pict->repeatType == RepeatNormal) {
- if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- if (!affine) {
- y = MOD(DIV(v.vector[1], v.vector[2]),
- pict->pDrawable->height);
- x = MOD(DIV(v.vector[0], v.vector[2]),
- pict->pDrawable->width);
- }
- else {
- y = MOD(v.vector[1] >> 16, pict->pDrawable->height);
- x = MOD(v.vector[0] >> 16, pict->pDrawable->width);
- }
- buffer[i] =
- fetch(bits + (y + dy) * stride, x + dx, indexed);
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- else {
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- if (!affine) {
- y = MOD(DIV(v.vector[1], v.vector[2]),
- pict->pDrawable->height);
- x = MOD(DIV(v.vector[0], v.vector[2]),
- pict->pDrawable->width);
- }
- else {
- y = MOD(v.vector[1] >> 16, pict->pDrawable->height);
- x = MOD(v.vector[0] >> 16, pict->pDrawable->width);
- }
- if (POINT_IN_REGION(pict->pCompositeClip, x + dx, y + dy, &box))
- buffer[i] =
- fetch(bits + (y + dy) * stride, x + dx,
- indexed);
- else
- buffer[i] = 0;
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- }
- else {
- if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
- box = pict->pCompositeClip->extents;
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- if (!affine) {
- y = DIV(v.vector[1], v.vector[2]);
- x = DIV(v.vector[0], v.vector[2]);
- }
- else {
- y = v.vector[1] >> 16;
- x = v.vector[0] >> 16;
- }
- buffer[i] =
- ((x < box.x1 - dx) | (x >= box.x2 - dx) | (y <
- box.y1 -
- dy) | (y
- >=
- box.
- y2
- -
- dy))
- ? 0 : fetch(bits + (y + dy) * stride, x + dx,
- indexed);
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- else {
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- if (!affine) {
- y = DIV(v.vector[1], v.vector[2]);
- x = DIV(v.vector[0], v.vector[2]);
- }
- else {
- y = v.vector[1] >> 16;
- x = v.vector[0] >> 16;
- }
- if (POINT_IN_REGION(pict->pCompositeClip, x + dx, y + dy, &box))
- buffer[i] =
- fetch(bits + (y + dy) * stride, x + dx,
- indexed);
- else
- buffer[i] = 0;
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- }
- }
- else if (pict->filter == PictFilterBilinear) {
- /* adjust vector for maximum contribution at 0.5, 0.5 of each texel. */
- v.vector[0] -= v.vector[2] / 2;
- v.vector[1] -= v.vector[2] / 2;
- unit.vector[0] -= unit.vector[2] / 2;
- unit.vector[1] -= unit.vector[2] / 2;
- if (pict->repeatType == RepeatNormal) {
- if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- int x1, x2, y1, y2, distx, idistx, disty, idisty;
- FbBits *b;
- CARD32 tl, tr, bl, br, r;
- CARD32 ft, fb;
- if (!affine) {
- xFixed_48_16 div;
- div =
- ((xFixed_48_16) v.vector[0] << 16) /
- v.vector[2];
- x1 = div >> 16;
- distx = ((xFixed) div >> 8) & 0xff;
- div =
- ((xFixed_48_16) v.vector[1] << 16) /
- v.vector[2];
- y1 = div >> 16;
- disty = ((xFixed) div >> 8) & 0xff;
- }
- else {
- x1 = v.vector[0] >> 16;
- distx = (v.vector[0] >> 8) & 0xff;
- y1 = v.vector[1] >> 16;
- disty = (v.vector[1] >> 8) & 0xff;
- }
- x2 = x1 + 1;
- y2 = y1 + 1;
- idistx = 256 - distx;
- idisty = 256 - disty;
- x1 = MOD(x1, pict->pDrawable->width);
- x2 = MOD(x2, pict->pDrawable->width);
- y1 = MOD(y1, pict->pDrawable->height);
- y2 = MOD(y2, pict->pDrawable->height);
- b = bits + (y1 + dy) * stride;
- tl = fetch(b, x1 + dx, indexed);
- tr = fetch(b, x2 + dx, indexed);
- b = bits + (y2 + dy) * stride;
- bl = fetch(b, x1 + dx, indexed);
- br = fetch(b, x2 + dx, indexed);
- ft = FbGet8(tl, 0) * idistx + FbGet8(tr, 0) * distx;
- fb = FbGet8(bl, 0) * idistx + FbGet8(br, 0) * distx;
- r = (((ft * idisty + fb * disty) >> 16) & 0xff);
- ft = FbGet8(tl, 8) * idistx + FbGet8(tr, 8) * distx;
- fb = FbGet8(bl, 8) * idistx + FbGet8(br, 8) * distx;
- r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
- ft = FbGet8(tl, 16) * idistx + FbGet8(tr, 16) * distx;
- fb = FbGet8(bl, 16) * idistx + FbGet8(br, 16) * distx;
- r |= (((ft * idisty + fb * disty)) & 0xff0000);
- ft = FbGet8(tl, 24) * idistx + FbGet8(tr, 24) * distx;
- fb = FbGet8(bl, 24) * idistx + FbGet8(br, 24) * distx;
- r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
- buffer[i] = r;
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- else {
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- int x1, x2, y1, y2, distx, idistx, disty, idisty;
- FbBits *b;
- CARD32 tl, tr, bl, br, r;
- CARD32 ft, fb;
- if (!affine) {
- xFixed_48_16 div;
- div =
- ((xFixed_48_16) v.vector[0] << 16) /
- v.vector[2];
- x1 = div >> 16;
- distx = ((xFixed) div >> 8) & 0xff;
- div =
- ((xFixed_48_16) v.vector[1] << 16) /
- v.vector[2];
- y1 = div >> 16;
- disty = ((xFixed) div >> 8) & 0xff;
- }
- else {
- x1 = v.vector[0] >> 16;
- distx = (v.vector[0] >> 8) & 0xff;
- y1 = v.vector[1] >> 16;
- disty = (v.vector[1] >> 8) & 0xff;
- }
- x2 = x1 + 1;
- y2 = y1 + 1;
- idistx = 256 - distx;
- idisty = 256 - disty;
- x1 = MOD(x1, pict->pDrawable->width);
- x2 = MOD(x2, pict->pDrawable->width);
- y1 = MOD(y1, pict->pDrawable->height);
- y2 = MOD(y2, pict->pDrawable->height);
- b = bits + (y1 + dy) * stride;
- tl = POINT_IN_REGION(pict->pCompositeClip, x1 + dx,
- y1 + dy, &box)
- ? fetch(b, x1 + dx, indexed) : 0;
- tr = POINT_IN_REGION(pict->pCompositeClip, x2 + dx,
- y1 + dy, &box)
- ? fetch(b, x2 + dx, indexed) : 0;
- b = bits + (y2 + dy) * stride;
- bl = POINT_IN_REGION(pict->pCompositeClip, x1 + dx,
- y2 + dy, &box)
- ? fetch(b, x1 + dx, indexed) : 0;
- br = POINT_IN_REGION(pict->pCompositeClip, x2 + dx,
- y2 + dy, &box)
- ? fetch(b, x2 + dx, indexed) : 0;
- ft = FbGet8(tl, 0) * idistx + FbGet8(tr, 0) * distx;
- fb = FbGet8(bl, 0) * idistx + FbGet8(br, 0) * distx;
- r = (((ft * idisty + fb * disty) >> 16) & 0xff);
- ft = FbGet8(tl, 8) * idistx + FbGet8(tr, 8) * distx;
- fb = FbGet8(bl, 8) * idistx + FbGet8(br, 8) * distx;
- r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
- ft = FbGet8(tl, 16) * idistx + FbGet8(tr, 16) * distx;
- fb = FbGet8(bl, 16) * idistx + FbGet8(br, 16) * distx;
- r |= (((ft * idisty + fb * disty)) & 0xff0000);
- ft = FbGet8(tl, 24) * idistx + FbGet8(tr, 24) * distx;
- fb = FbGet8(bl, 24) * idistx + FbGet8(br, 24) * distx;
- r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
- buffer[i] = r;
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- }
- else {
- if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
- box = pict->pCompositeClip->extents;
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
- FbBits *b;
- CARD32 tl, tr, bl, br, r;
- Bool x1_out, x2_out, y1_out, y2_out;
- CARD32 ft, fb;
- if (!affine) {
- xFixed_48_16 div;
- div =
- ((xFixed_48_16) v.vector[0] << 16) /
- v.vector[2];
- x1 = div >> 16;
- distx = ((xFixed) div >> 8) & 0xff;
- div =
- ((xFixed_48_16) v.vector[1] << 16) /
- v.vector[2];
- y1 = div >> 16;
- disty = ((xFixed) div >> 8) & 0xff;
- }
- else {
- x1 = v.vector[0] >> 16;
- distx = (v.vector[0] >> 8) & 0xff;
- y1 = v.vector[1] >> 16;
- disty = (v.vector[1] >> 8) & 0xff;
- }
- x2 = x1 + 1;
- y2 = y1 + 1;
- idistx = 256 - distx;
- idisty = 256 - disty;
- b = bits + (y1 + dy) * stride;
- x_off = x1 + dx;
- x1_out = (x1 < box.x1 - dx) | (x1 >= box.x2 - dx);
- x2_out = (x2 < box.x1 - dx) | (x2 >= box.x2 - dx);
- y1_out = (y1 < box.y1 - dy) | (y1 >= box.y2 - dy);
- y2_out = (y2 < box.y1 - dy) | (y2 >= box.y2 - dy);
- tl = x1_out | y1_out ? 0 : fetch(b, x_off, indexed);
- tr = x2_out | y1_out ? 0 : fetch(b, x_off + 1, indexed);
- b += stride;
- bl = x1_out | y2_out ? 0 : fetch(b, x_off, indexed);
- br = x2_out | y2_out ? 0 : fetch(b, x_off + 1, indexed);
- ft = FbGet8(tl, 0) * idistx + FbGet8(tr, 0) * distx;
- fb = FbGet8(bl, 0) * idistx + FbGet8(br, 0) * distx;
- r = (((ft * idisty + fb * disty) >> 16) & 0xff);
- ft = FbGet8(tl, 8) * idistx + FbGet8(tr, 8) * distx;
- fb = FbGet8(bl, 8) * idistx + FbGet8(br, 8) * distx;
- r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
- ft = FbGet8(tl, 16) * idistx + FbGet8(tr, 16) * distx;
- fb = FbGet8(bl, 16) * idistx + FbGet8(br, 16) * distx;
- r |= (((ft * idisty + fb * disty)) & 0xff0000);
- ft = FbGet8(tl, 24) * idistx + FbGet8(tr, 24) * distx;
- fb = FbGet8(bl, 24) * idistx + FbGet8(br, 24) * distx;
- r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
- buffer[i] = r;
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- else {
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
- FbBits *b;
- CARD32 tl, tr, bl, br, r;
- CARD32 ft, fb;
- if (!affine) {
- xFixed_48_16 div;
- div =
- ((xFixed_48_16) v.vector[0] << 16) /
- v.vector[2];
- x1 = div >> 16;
- distx = ((xFixed) div >> 8) & 0xff;
- div =
- ((xFixed_48_16) v.vector[1] << 16) /
- v.vector[2];
- y1 = div >> 16;
- disty = ((xFixed) div >> 8) & 0xff;
- }
- else {
- x1 = v.vector[0] >> 16;
- distx = (v.vector[0] >> 8) & 0xff;
- y1 = v.vector[1] >> 16;
- disty = (v.vector[1] >> 8) & 0xff;
- }
- x2 = x1 + 1;
- y2 = y1 + 1;
- idistx = 256 - distx;
- idisty = 256 - disty;
- b = bits + (y1 + dy) * stride;
- x_off = x1 + dx;
- tl = POINT_IN_REGION(pict->pCompositeClip, x1 + dx,
- y1 + dy, &box)
- ? fetch(b, x_off, indexed) : 0;
- tr = POINT_IN_REGION(pict->pCompositeClip, x2 + dx,
- y1 + dy, &box)
- ? fetch(b, x_off + 1, indexed) : 0;
- b += stride;
- bl = POINT_IN_REGION(pict->pCompositeClip, x1 + dx,
- y2 + dy, &box)
- ? fetch(b, x_off, indexed) : 0;
- br = POINT_IN_REGION(pict->pCompositeClip, x2 + dx,
- y2 + dy, &box)
- ? fetch(b, x_off + 1, indexed) : 0;
- ft = FbGet8(tl, 0) * idistx + FbGet8(tr, 0) * distx;
- fb = FbGet8(bl, 0) * idistx + FbGet8(br, 0) * distx;
- r = (((ft * idisty + fb * disty) >> 16) & 0xff);
- ft = FbGet8(tl, 8) * idistx + FbGet8(tr, 8) * distx;
- fb = FbGet8(bl, 8) * idistx + FbGet8(br, 8) * distx;
- r |= (((ft * idisty + fb * disty) >> 8) & 0xff00);
- ft = FbGet8(tl, 16) * idistx + FbGet8(tr, 16) * distx;
- fb = FbGet8(bl, 16) * idistx + FbGet8(br, 16) * distx;
- r |= (((ft * idisty + fb * disty)) & 0xff0000);
- ft = FbGet8(tl, 24) * idistx + FbGet8(tr, 24) * distx;
- fb = FbGet8(bl, 24) * idistx + FbGet8(br, 24) * distx;
- r |= (((ft * idisty + fb * disty) << 8) & 0xff000000);
- buffer[i] = r;
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- }
- }
- else if (pict->filter == PictFilterConvolution) {
- xFixed *params = pict->filter_params;
- INT32 cwidth = xFixedToInt(params[0]);
- INT32 cheight = xFixedToInt(params[1]);
- int xoff = (params[0] - xFixed1) >> 1;
- int yoff = (params[1] - xFixed1) >> 1;
- params += 2;
- for (i = 0; i < width; ++i) {
- if (!v.vector[2]) {
- buffer[i] = 0;
- }
- else {
- int x1, x2, y1, y2, x, y;
- INT32 srtot, sgtot, sbtot, satot;
- xFixed *p = params;
- if (!affine) {
- xFixed_48_16 tmp;
- tmp =
- ((xFixed_48_16) v.vector[0] << 16) / v.vector[2] - xoff;
- x1 = xFixedToInt(tmp);
- tmp =
- ((xFixed_48_16) v.vector[1] << 16) / v.vector[2] - yoff;
- y1 = xFixedToInt(tmp);
- }
- else {
- x1 = xFixedToInt(v.vector[0] - xoff);
- y1 = xFixedToInt(v.vector[1] - yoff);
- }
- x2 = x1 + cwidth;
- y2 = y1 + cheight;
- srtot = sgtot = sbtot = satot = 0;
- for (y = y1; y < y2; y++) {
- int ty =
- (pict->repeatType == RepeatNormal) ? MOD(y,
- pict->
- pDrawable->
- height) : y;
- for (x = x1; x < x2; x++) {
- if (*p) {
- int tx =
- (pict->repeatType == RepeatNormal) ? MOD(x,
- pict->
- pDrawable->
- width)
- : x;
- if (POINT_IN_REGION(pict->pCompositeClip, tx + dx, ty + dy,
- &box)) {
- FbBits *b = bits + (ty + dy) * stride;
- CARD32 c = fetch(b, tx + dx, indexed);
- srtot += Red(c) * *p;
- sgtot += Green(c) * *p;
- sbtot += Blue(c) * *p;
- satot += Alpha(c) * *p;
- }
- }
- p++;
- }
- }
- satot >>= 16;
- srtot >>= 16;
- sgtot >>= 16;
- sbtot >>= 16;
- if (satot < 0)
- satot = 0;
- else if (satot > 0xff)
- satot = 0xff;
- if (srtot < 0)
- srtot = 0;
- else if (srtot > 0xff)
- srtot = 0xff;
- if (sgtot < 0)
- sgtot = 0;
- else if (sgtot > 0xff)
- sgtot = 0xff;
- if (sbtot < 0)
- sbtot = 0;
- else if (sbtot > 0xff)
- sbtot = 0xff;
- buffer[i] = ((satot << 24) |
- (srtot << 16) | (sgtot << 8) | (sbtot));
- }
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
- }
- static void
- fbFetchExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
- {
- int i;
- CARD32 _alpha_buffer[SCANLINE_BUFFER_LENGTH];
- CARD32 *alpha_buffer = _alpha_buffer;
- if (!pict->alphaMap) {
- fbFetchTransformed(pict, x, y, width, buffer);
- return;
- }
- if (width > SCANLINE_BUFFER_LENGTH)
- alpha_buffer = malloc(width * sizeof(CARD32));
- fbFetchTransformed(pict, x, y, width, buffer);
- fbFetchTransformed(pict->alphaMap, x - pict->alphaOrigin.x,
- y - pict->alphaOrigin.y, width, alpha_buffer);
- for (i = 0; i < width; ++i) {
- int a = alpha_buffer[i] >> 24;
- buffer[i] = (a << 24)
- | (div_255(Red(buffer[i]) * a) << 16)
- | (div_255(Green(buffer[i]) * a) << 8)
- | (div_255(Blue(buffer[i]) * a));
- }
- if (alpha_buffer != _alpha_buffer)
- free(alpha_buffer);
- }
- static void
- fbStore(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
- {
- FbBits *bits;
- FbStride stride;
- int bpp;
- int xoff, yoff;
- storeProc store = storeProcForPicture(pict);
- miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
- fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff);
- x += xoff;
- y += yoff;
- bits += y * stride;
- store(bits, buffer, x, width, indexed);
- }
- static void
- fbStoreExternalAlpha(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
- {
- FbBits *bits, *alpha_bits;
- FbStride stride, astride;
- int bpp, abpp;
- int xoff, yoff;
- int ax, ay;
- storeProc store;
- storeProc astore;
- miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
- miIndexedPtr aindexed;
- if (!pict->alphaMap) {
- fbStore(pict, x, y, width, buffer);
- return;
- }
- store = storeProcForPicture(pict);
- astore = storeProcForPicture(pict->alphaMap);
- aindexed = (miIndexedPtr) pict->alphaMap->pFormat->index.devPrivate;
- ax = x;
- ay = y;
- fbGetDrawable(pict->pDrawable, bits, stride, bpp, xoff, yoff);
- x += xoff;
- y += yoff;
- fbGetDrawable(pict->alphaMap->pDrawable, alpha_bits, astride, abpp, xoff,
- yoff);
- ax += xoff;
- ay += yoff;
- bits += y * stride;
- alpha_bits += (ay - pict->alphaOrigin.y) * astride;
- store(bits, buffer, x, width, indexed);
- astore(alpha_bits, buffer, ax - pict->alphaOrigin.x, width, aindexed);
- }
- typedef void (*scanStoreProc) (PicturePtr, int, int, int, CARD32 *);
- typedef void (*scanFetchProc) (PicturePtr, int, int, int, CARD32 *);
- static void
- fbCompositeRect(const FbComposeData * data, CARD32 *scanline_buffer)
- {
- CARD32 *src_buffer = scanline_buffer;
- CARD32 *dest_buffer = src_buffer + data->width;
- int i;
- scanStoreProc store;
- scanFetchProc fetchSrc = NULL, fetchMask = NULL, fetchDest = NULL;
- if (data->op == PictOpClear)
- fetchSrc = NULL;
- else if (!data->src->pDrawable) {
- if (data->src->pSourcePict)
- fetchSrc = fbFetchSourcePict;
- }
- else if (data->src->alphaMap)
- fetchSrc = fbFetchExternalAlpha;
- else if (data->src->repeatType == RepeatNormal &&
- data->src->pDrawable->width == 1 &&
- data->src->pDrawable->height == 1)
- fetchSrc = fbFetchSolid;
- else if (!data->src->transform &&
- data->src->filter != PictFilterConvolution)
- fetchSrc = fbFetch;
- else
- fetchSrc = fbFetchTransformed;
- if (data->mask && data->op != PictOpClear) {
- if (!data->mask->pDrawable) {
- if (data->mask->pSourcePict)
- fetchMask = fbFetchSourcePict;
- }
- else if (data->mask->alphaMap)
- fetchMask = fbFetchExternalAlpha;
- else if (data->mask->repeatType == RepeatNormal
- && data->mask->pDrawable->width == 1 &&
- data->mask->pDrawable->height == 1)
- fetchMask = fbFetchSolid;
- else if (!data->mask->transform &&
- data->mask->filter != PictFilterConvolution)
- fetchMask = fbFetch;
- else
- fetchMask = fbFetchTransformed;
- }
- else {
- fetchMask = NULL;
- }
- if (data->dest->alphaMap) {
- fetchDest = fbFetchExternalAlpha;
- store = fbStoreExternalAlpha;
- }
- else {
- fetchDest = fbFetch;
- store = fbStore;
- }
- if (data->op == PictOpClear || data->op == PictOpSrc)
- fetchDest = NULL;
- if (fetchSrc && fetchMask && data->mask && data->mask->componentAlpha &&
- PICT_FORMAT_RGB(data->mask->format)) {
- CARD32 *mask_buffer = dest_buffer + data->width;
- CombineFuncC compose = composeFunctions.combineC[data->op];
- if (!compose)
- return;
- for (i = 0; i < data->height; ++i) {
- /* fill first half of scanline with source */
- fetchSrc(data->src, data->xSrc, data->ySrc + i, data->width,
- src_buffer);
- fetchMask(data->mask, data->xMask, data->yMask + i, data->width,
- mask_buffer);
- /* fill dest into second half of scanline */
- if (fetchDest)
- fetchDest(data->dest, data->xDest, data->yDest + i, data->width,
- dest_buffer);
- /* blend */
- compose(dest_buffer, src_buffer, mask_buffer, data->width);
- /* write back */
- store(data->dest, data->xDest, data->yDest + i, data->width,
- dest_buffer);
- }
- }
- else {
- CombineFuncU compose = composeFunctions.combineU[data->op];
- if (!compose)
- return;
- if (fetchSrc == fbFetchSolid &&
- (!fetchMask || fetchMask == fbFetchSolid)) {
- fetchSrc(data->src, data->xSrc, data->ySrc, data->width,
- src_buffer);
- if (fetchMask) {
- fetchMask(data->mask, data->xMask, data->yMask, data->width,
- dest_buffer);
- composeFunctions.combineMaskU(src_buffer, dest_buffer,
- data->width);
- }
- fetchSrc = NULL;
- fetchMask = NULL;
- }
- for (i = 0; i < data->height; ++i) {
- /* fill first half of scanline with source */
- if (fetchSrc) {
- fetchSrc(data->src, data->xSrc, data->ySrc + i, data->width,
- src_buffer);
- /* add in mask */
- if (fetchMask) {
- fetchMask(data->mask, data->xMask, data->yMask + i,
- data->width, dest_buffer);
- composeFunctions.combineMaskU(src_buffer, dest_buffer,
- data->width);
- }
- }
- /* fill dest into second half of scanline */
- if (fetchDest)
- fetchDest(data->dest, data->xDest, data->yDest + i, data->width,
- dest_buffer);
- /* blend */
- compose(dest_buffer, src_buffer, data->width);
- /* write back */
- store(data->dest, data->xDest, data->yDest + i, data->width,
- dest_buffer);
- }
- }
- }
- void
- fbCompositeGeneral(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;
- Bool srcRepeat = FALSE;
- Bool maskRepeat = FALSE;
- int w, h;
- CARD32 _scanline_buffer[SCANLINE_BUFFER_LENGTH * 3];
- CARD32 *scanline_buffer = _scanline_buffer;
- FbComposeData compose_data;
- if (pSrc->pDrawable)
- srcRepeat = pSrc->repeatType == RepeatNormal && !pSrc->transform
- && (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1);
- if (pMask && pMask->pDrawable)
- maskRepeat = pMask->repeatType == RepeatNormal && !pMask->transform
- && (pMask->pDrawable->width != 1 || pMask->pDrawable->height != 1);
- if (op == PictOpOver && !pMask && !pSrc->transform &&
- !PICT_FORMAT_A(pSrc->format) && !pSrc->alphaMap)
- op = PictOpSrc;
- if (!miComputeCompositeRegion(®ion,
- pSrc,
- pMask,
- pDst,
- xSrc,
- ySrc,
- xMask, yMask, xDst, yDst, width, height))
- return;
- compose_data.op = op;
- compose_data.src = pSrc;
- compose_data.mask = pMask;
- compose_data.dest = pDst;
- if (width > SCANLINE_BUFFER_LENGTH)
- scanline_buffer = malloc(width * 3 * sizeof(CARD32));
- n = REGION_NUM_RECTS(®ion);
- pbox = REGION_RECTS(®ion);
- while (n--) {
- h = pbox->y2 - pbox->y1;
- compose_data.ySrc = pbox->y1 - yDst + ySrc;
- compose_data.yMask = pbox->y1 - yDst + yMask;
- compose_data.yDest = pbox->y1;
- while (h) {
- compose_data.height = h;
- w = pbox->x2 - pbox->x1;
- compose_data.xSrc = pbox->x1 - xDst + xSrc;
- compose_data.xMask = pbox->x1 - xDst + xMask;
- compose_data.xDest = pbox->x1;
- if (maskRepeat) {
- compose_data.yMask =
- mod(compose_data.yMask, pMask->pDrawable->height);
- if (compose_data.height >
- pMask->pDrawable->height - compose_data.yMask)
- compose_data.height =
- pMask->pDrawable->height - compose_data.yMask;
- }
- if (srcRepeat) {
- compose_data.ySrc =
- mod(compose_data.ySrc, pSrc->pDrawable->height);
- if (compose_data.height >
- pSrc->pDrawable->height - compose_data.ySrc)
- compose_data.height =
- pSrc->pDrawable->height - compose_data.ySrc;
- }
- while (w) {
- compose_data.width = w;
- if (maskRepeat) {
- compose_data.xMask =
- mod(compose_data.xMask, pMask->pDrawable->width);
- if (compose_data.width >
- pMask->pDrawable->width - compose_data.xMask)
- compose_data.width =
- pMask->pDrawable->width - compose_data.xMask;
- }
- if (srcRepeat) {
- compose_data.xSrc =
- mod(compose_data.xSrc, pSrc->pDrawable->width);
- if (compose_data.width >
- pSrc->pDrawable->width - compose_data.xSrc)
- compose_data.width =
- pSrc->pDrawable->width - compose_data.xSrc;
- }
- fbCompositeRect(&compose_data, scanline_buffer);
- w -= compose_data.width;
- compose_data.xSrc += compose_data.width;
- compose_data.xMask += compose_data.width;
- compose_data.xDest += compose_data.width;
- }
- h -= compose_data.height;
- compose_data.ySrc += compose_data.height;
- compose_data.yMask += compose_data.height;
- compose_data.yDest += compose_data.height;
- }
- pbox++;
- }
- REGION_UNINIT(®ion);
- if (scanline_buffer != _scanline_buffer)
- free(scanline_buffer);
- }
|