SDL_blit_auto.c 429 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542
  1. // DO NOT EDIT! This file is generated by sdlgenblit.pl
  2. /*
  3. Simple DirectMedia Layer
  4. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any damages
  7. arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose,
  9. including commercial applications, and to alter it and redistribute it
  10. freely, subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software
  13. in a product, an acknowledgment in the product documentation would be
  14. appreciated but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. */
  19. #include "SDL_internal.h"
  20. #if SDL_HAVE_BLIT_AUTO
  21. /* *INDENT-OFF* */ // clang-format off
  22. #include "SDL_blit.h"
  23. #include "SDL_blit_auto.h"
  24. static void SDL_Blit_XRGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
  25. {
  26. Uint64 srcy, srcx;
  27. Uint64 posy, posx;
  28. Uint64 incy, incx;
  29. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  30. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  31. posy = incy / 2;
  32. while (info->dst_h--) {
  33. Uint32 *src = 0;
  34. Uint32 *dst = (Uint32 *)info->dst;
  35. int n = info->dst_w;
  36. posx = incx / 2;
  37. srcy = posy >> 16;
  38. while (n--) {
  39. srcx = posx >> 16;
  40. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  41. *dst = *src;
  42. posx += incx;
  43. ++dst;
  44. }
  45. posy += incy;
  46. info->dst += info->dst_pitch;
  47. }
  48. }
  49. static void SDL_Blit_XRGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
  50. {
  51. const int flags = info->flags;
  52. Uint32 srcpixel;
  53. Uint32 srcR, srcG, srcB;
  54. Uint32 dstpixel;
  55. Uint32 dstR, dstG, dstB;
  56. while (info->dst_h--) {
  57. Uint32 *src = (Uint32 *)info->src;
  58. Uint32 *dst = (Uint32 *)info->dst;
  59. int n = info->dst_w;
  60. while (n--) {
  61. srcpixel = *src;
  62. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  63. dstpixel = *dst;
  64. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  65. switch (flags & SDL_COPY_BLEND_MASK) {
  66. case SDL_COPY_BLEND:
  67. dstR = srcR;
  68. dstG = srcG;
  69. dstB = srcB;
  70. break;
  71. case SDL_COPY_BLEND_PREMULTIPLIED:
  72. dstR = srcR;
  73. dstG = srcG;
  74. dstB = srcB;
  75. break;
  76. case SDL_COPY_ADD:
  77. case SDL_COPY_ADD_PREMULTIPLIED:
  78. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  79. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  80. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  81. break;
  82. case SDL_COPY_MOD:
  83. MULT_DIV_255(srcR, dstR, dstR);
  84. MULT_DIV_255(srcG, dstG, dstG);
  85. MULT_DIV_255(srcB, dstB, dstB);
  86. break;
  87. case SDL_COPY_MUL:
  88. MULT_DIV_255(srcR, dstR, dstR);
  89. MULT_DIV_255(srcG, dstG, dstG);
  90. MULT_DIV_255(srcB, dstB, dstB);
  91. break;
  92. }
  93. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  94. *dst = dstpixel;
  95. ++src;
  96. ++dst;
  97. }
  98. info->src += info->src_pitch;
  99. info->dst += info->dst_pitch;
  100. }
  101. }
  102. static void SDL_Blit_XRGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  103. {
  104. const int flags = info->flags;
  105. Uint32 srcpixel;
  106. Uint32 srcR, srcG, srcB;
  107. Uint32 dstpixel;
  108. Uint32 dstR, dstG, dstB;
  109. Uint64 srcy, srcx;
  110. Uint64 posy, posx;
  111. Uint64 incy, incx;
  112. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  113. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  114. posy = incy / 2;
  115. while (info->dst_h--) {
  116. Uint32 *src = 0;
  117. Uint32 *dst = (Uint32 *)info->dst;
  118. int n = info->dst_w;
  119. posx = incx / 2;
  120. srcy = posy >> 16;
  121. while (n--) {
  122. srcx = posx >> 16;
  123. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  124. srcpixel = *src;
  125. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  126. dstpixel = *dst;
  127. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  128. switch (flags & SDL_COPY_BLEND_MASK) {
  129. case SDL_COPY_BLEND:
  130. dstR = srcR;
  131. dstG = srcG;
  132. dstB = srcB;
  133. break;
  134. case SDL_COPY_BLEND_PREMULTIPLIED:
  135. dstR = srcR;
  136. dstG = srcG;
  137. dstB = srcB;
  138. break;
  139. case SDL_COPY_ADD:
  140. case SDL_COPY_ADD_PREMULTIPLIED:
  141. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  142. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  143. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  144. break;
  145. case SDL_COPY_MOD:
  146. MULT_DIV_255(srcR, dstR, dstR);
  147. MULT_DIV_255(srcG, dstG, dstG);
  148. MULT_DIV_255(srcB, dstB, dstB);
  149. break;
  150. case SDL_COPY_MUL:
  151. MULT_DIV_255(srcR, dstR, dstR);
  152. MULT_DIV_255(srcG, dstG, dstG);
  153. MULT_DIV_255(srcB, dstB, dstB);
  154. break;
  155. }
  156. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  157. *dst = dstpixel;
  158. posx += incx;
  159. ++dst;
  160. }
  161. posy += incy;
  162. info->dst += info->dst_pitch;
  163. }
  164. }
  165. static void SDL_Blit_XRGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  166. {
  167. const int flags = info->flags;
  168. const Uint32 modulateR = info->r;
  169. const Uint32 modulateG = info->g;
  170. const Uint32 modulateB = info->b;
  171. Uint32 pixel;
  172. Uint32 R, G, B;
  173. while (info->dst_h--) {
  174. Uint32 *src = (Uint32 *)info->src;
  175. Uint32 *dst = (Uint32 *)info->dst;
  176. int n = info->dst_w;
  177. while (n--) {
  178. pixel = *src;
  179. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  180. if (flags & SDL_COPY_MODULATE_COLOR) {
  181. MULT_DIV_255(R, modulateR, R);
  182. MULT_DIV_255(G, modulateG, G);
  183. MULT_DIV_255(B, modulateB, B);
  184. }
  185. pixel = (R << 16) | (G << 8) | B;
  186. *dst = pixel;
  187. ++src;
  188. ++dst;
  189. }
  190. info->src += info->src_pitch;
  191. info->dst += info->dst_pitch;
  192. }
  193. }
  194. static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  195. {
  196. const int flags = info->flags;
  197. const Uint32 modulateR = info->r;
  198. const Uint32 modulateG = info->g;
  199. const Uint32 modulateB = info->b;
  200. Uint32 pixel;
  201. Uint32 R, G, B;
  202. Uint64 srcy, srcx;
  203. Uint64 posy, posx;
  204. Uint64 incy, incx;
  205. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  206. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  207. posy = incy / 2;
  208. while (info->dst_h--) {
  209. Uint32 *src = 0;
  210. Uint32 *dst = (Uint32 *)info->dst;
  211. int n = info->dst_w;
  212. posx = incx / 2;
  213. srcy = posy >> 16;
  214. while (n--) {
  215. srcx = posx >> 16;
  216. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  217. pixel = *src;
  218. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  219. if (flags & SDL_COPY_MODULATE_COLOR) {
  220. MULT_DIV_255(R, modulateR, R);
  221. MULT_DIV_255(G, modulateG, G);
  222. MULT_DIV_255(B, modulateB, B);
  223. }
  224. pixel = (R << 16) | (G << 8) | B;
  225. *dst = pixel;
  226. posx += incx;
  227. ++dst;
  228. }
  229. posy += incy;
  230. info->dst += info->dst_pitch;
  231. }
  232. }
  233. static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  234. {
  235. const int flags = info->flags;
  236. const Uint32 modulateR = info->r;
  237. const Uint32 modulateG = info->g;
  238. const Uint32 modulateB = info->b;
  239. const Uint32 modulateA = info->a;
  240. Uint32 srcpixel;
  241. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  242. Uint32 srcR, srcG, srcB;
  243. Uint32 dstpixel;
  244. Uint32 dstR, dstG, dstB;
  245. while (info->dst_h--) {
  246. Uint32 *src = (Uint32 *)info->src;
  247. Uint32 *dst = (Uint32 *)info->dst;
  248. int n = info->dst_w;
  249. while (n--) {
  250. srcpixel = *src;
  251. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  252. dstpixel = *dst;
  253. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  254. if (flags & SDL_COPY_MODULATE_COLOR) {
  255. MULT_DIV_255(srcR, modulateR, srcR);
  256. MULT_DIV_255(srcG, modulateG, srcG);
  257. MULT_DIV_255(srcB, modulateB, srcB);
  258. }
  259. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  260. if (srcA < 255) {
  261. MULT_DIV_255(srcR, srcA, srcR);
  262. MULT_DIV_255(srcG, srcA, srcG);
  263. MULT_DIV_255(srcB, srcA, srcB);
  264. }
  265. }
  266. switch (flags & SDL_COPY_BLEND_MASK) {
  267. case SDL_COPY_BLEND:
  268. MULT_DIV_255((255 - srcA), dstR, dstR);
  269. dstR += srcR;
  270. MULT_DIV_255((255 - srcA), dstG, dstG);
  271. dstG += srcG;
  272. MULT_DIV_255((255 - srcA), dstB, dstB);
  273. dstB += srcB;
  274. break;
  275. case SDL_COPY_BLEND_PREMULTIPLIED:
  276. MULT_DIV_255((255 - srcA), dstR, dstR);
  277. dstR += srcR;
  278. if (dstR > 255) dstR = 255;
  279. MULT_DIV_255((255 - srcA), dstG, dstG);
  280. dstG += srcG;
  281. if (dstG > 255) dstG = 255;
  282. MULT_DIV_255((255 - srcA), dstB, dstB);
  283. dstB += srcB;
  284. if (dstB > 255) dstB = 255;
  285. break;
  286. case SDL_COPY_ADD:
  287. case SDL_COPY_ADD_PREMULTIPLIED:
  288. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  289. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  290. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  291. break;
  292. case SDL_COPY_MOD:
  293. MULT_DIV_255(srcR, dstR, dstR);
  294. MULT_DIV_255(srcG, dstG, dstG);
  295. MULT_DIV_255(srcB, dstB, dstB);
  296. break;
  297. case SDL_COPY_MUL:
  298. {
  299. Uint32 tmp1, tmp2;
  300. MULT_DIV_255(srcR, dstR, tmp1);
  301. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  302. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  303. MULT_DIV_255(srcG, dstG, tmp1);
  304. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  305. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  306. MULT_DIV_255(srcB, dstB, tmp1);
  307. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  308. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  309. }
  310. break;
  311. }
  312. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  313. *dst = dstpixel;
  314. ++src;
  315. ++dst;
  316. }
  317. info->src += info->src_pitch;
  318. info->dst += info->dst_pitch;
  319. }
  320. }
  321. static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  322. {
  323. const int flags = info->flags;
  324. const Uint32 modulateR = info->r;
  325. const Uint32 modulateG = info->g;
  326. const Uint32 modulateB = info->b;
  327. const Uint32 modulateA = info->a;
  328. Uint32 srcpixel;
  329. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  330. Uint32 srcR, srcG, srcB;
  331. Uint32 dstpixel;
  332. Uint32 dstR, dstG, dstB;
  333. Uint64 srcy, srcx;
  334. Uint64 posy, posx;
  335. Uint64 incy, incx;
  336. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  337. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  338. posy = incy / 2;
  339. while (info->dst_h--) {
  340. Uint32 *src = 0;
  341. Uint32 *dst = (Uint32 *)info->dst;
  342. int n = info->dst_w;
  343. posx = incx / 2;
  344. srcy = posy >> 16;
  345. while (n--) {
  346. srcx = posx >> 16;
  347. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  348. srcpixel = *src;
  349. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  350. dstpixel = *dst;
  351. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  352. if (flags & SDL_COPY_MODULATE_COLOR) {
  353. MULT_DIV_255(srcR, modulateR, srcR);
  354. MULT_DIV_255(srcG, modulateG, srcG);
  355. MULT_DIV_255(srcB, modulateB, srcB);
  356. }
  357. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  358. if (srcA < 255) {
  359. MULT_DIV_255(srcR, srcA, srcR);
  360. MULT_DIV_255(srcG, srcA, srcG);
  361. MULT_DIV_255(srcB, srcA, srcB);
  362. }
  363. }
  364. switch (flags & SDL_COPY_BLEND_MASK) {
  365. case SDL_COPY_BLEND:
  366. MULT_DIV_255((255 - srcA), dstR, dstR);
  367. dstR += srcR;
  368. MULT_DIV_255((255 - srcA), dstG, dstG);
  369. dstG += srcG;
  370. MULT_DIV_255((255 - srcA), dstB, dstB);
  371. dstB += srcB;
  372. break;
  373. case SDL_COPY_BLEND_PREMULTIPLIED:
  374. MULT_DIV_255((255 - srcA), dstR, dstR);
  375. dstR += srcR;
  376. if (dstR > 255) dstR = 255;
  377. MULT_DIV_255((255 - srcA), dstG, dstG);
  378. dstG += srcG;
  379. if (dstG > 255) dstG = 255;
  380. MULT_DIV_255((255 - srcA), dstB, dstB);
  381. dstB += srcB;
  382. if (dstB > 255) dstB = 255;
  383. break;
  384. case SDL_COPY_ADD:
  385. case SDL_COPY_ADD_PREMULTIPLIED:
  386. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  387. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  388. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  389. break;
  390. case SDL_COPY_MOD:
  391. MULT_DIV_255(srcR, dstR, dstR);
  392. MULT_DIV_255(srcG, dstG, dstG);
  393. MULT_DIV_255(srcB, dstB, dstB);
  394. break;
  395. case SDL_COPY_MUL:
  396. {
  397. Uint32 tmp1, tmp2;
  398. MULT_DIV_255(srcR, dstR, tmp1);
  399. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  400. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  401. MULT_DIV_255(srcG, dstG, tmp1);
  402. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  403. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  404. MULT_DIV_255(srcB, dstB, tmp1);
  405. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  406. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  407. }
  408. break;
  409. }
  410. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  411. *dst = dstpixel;
  412. posx += incx;
  413. ++dst;
  414. }
  415. posy += incy;
  416. info->dst += info->dst_pitch;
  417. }
  418. }
  419. static void SDL_Blit_XRGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
  420. {
  421. Uint32 pixel;
  422. Uint32 R, G, B;
  423. Uint64 srcy, srcx;
  424. Uint64 posy, posx;
  425. Uint64 incy, incx;
  426. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  427. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  428. posy = incy / 2;
  429. while (info->dst_h--) {
  430. Uint32 *src = 0;
  431. Uint32 *dst = (Uint32 *)info->dst;
  432. int n = info->dst_w;
  433. posx = incx / 2;
  434. srcy = posy >> 16;
  435. while (n--) {
  436. srcx = posx >> 16;
  437. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  438. pixel = *src;
  439. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  440. pixel = (B << 16) | (G << 8) | R;
  441. *dst = pixel;
  442. posx += incx;
  443. ++dst;
  444. }
  445. posy += incy;
  446. info->dst += info->dst_pitch;
  447. }
  448. }
  449. static void SDL_Blit_XRGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
  450. {
  451. const int flags = info->flags;
  452. Uint32 srcpixel;
  453. Uint32 srcR, srcG, srcB;
  454. Uint32 dstpixel;
  455. Uint32 dstR, dstG, dstB;
  456. while (info->dst_h--) {
  457. Uint32 *src = (Uint32 *)info->src;
  458. Uint32 *dst = (Uint32 *)info->dst;
  459. int n = info->dst_w;
  460. while (n--) {
  461. srcpixel = *src;
  462. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  463. dstpixel = *dst;
  464. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  465. switch (flags & SDL_COPY_BLEND_MASK) {
  466. case SDL_COPY_BLEND:
  467. dstR = srcR;
  468. dstG = srcG;
  469. dstB = srcB;
  470. break;
  471. case SDL_COPY_BLEND_PREMULTIPLIED:
  472. dstR = srcR;
  473. dstG = srcG;
  474. dstB = srcB;
  475. break;
  476. case SDL_COPY_ADD:
  477. case SDL_COPY_ADD_PREMULTIPLIED:
  478. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  479. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  480. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  481. break;
  482. case SDL_COPY_MOD:
  483. MULT_DIV_255(srcR, dstR, dstR);
  484. MULT_DIV_255(srcG, dstG, dstG);
  485. MULT_DIV_255(srcB, dstB, dstB);
  486. break;
  487. case SDL_COPY_MUL:
  488. MULT_DIV_255(srcR, dstR, dstR);
  489. MULT_DIV_255(srcG, dstG, dstG);
  490. MULT_DIV_255(srcB, dstB, dstB);
  491. break;
  492. }
  493. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  494. *dst = dstpixel;
  495. ++src;
  496. ++dst;
  497. }
  498. info->src += info->src_pitch;
  499. info->dst += info->dst_pitch;
  500. }
  501. }
  502. static void SDL_Blit_XRGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  503. {
  504. const int flags = info->flags;
  505. Uint32 srcpixel;
  506. Uint32 srcR, srcG, srcB;
  507. Uint32 dstpixel;
  508. Uint32 dstR, dstG, dstB;
  509. Uint64 srcy, srcx;
  510. Uint64 posy, posx;
  511. Uint64 incy, incx;
  512. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  513. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  514. posy = incy / 2;
  515. while (info->dst_h--) {
  516. Uint32 *src = 0;
  517. Uint32 *dst = (Uint32 *)info->dst;
  518. int n = info->dst_w;
  519. posx = incx / 2;
  520. srcy = posy >> 16;
  521. while (n--) {
  522. srcx = posx >> 16;
  523. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  524. srcpixel = *src;
  525. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  526. dstpixel = *dst;
  527. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  528. switch (flags & SDL_COPY_BLEND_MASK) {
  529. case SDL_COPY_BLEND:
  530. dstR = srcR;
  531. dstG = srcG;
  532. dstB = srcB;
  533. break;
  534. case SDL_COPY_BLEND_PREMULTIPLIED:
  535. dstR = srcR;
  536. dstG = srcG;
  537. dstB = srcB;
  538. break;
  539. case SDL_COPY_ADD:
  540. case SDL_COPY_ADD_PREMULTIPLIED:
  541. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  542. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  543. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  544. break;
  545. case SDL_COPY_MOD:
  546. MULT_DIV_255(srcR, dstR, dstR);
  547. MULT_DIV_255(srcG, dstG, dstG);
  548. MULT_DIV_255(srcB, dstB, dstB);
  549. break;
  550. case SDL_COPY_MUL:
  551. MULT_DIV_255(srcR, dstR, dstR);
  552. MULT_DIV_255(srcG, dstG, dstG);
  553. MULT_DIV_255(srcB, dstB, dstB);
  554. break;
  555. }
  556. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  557. *dst = dstpixel;
  558. posx += incx;
  559. ++dst;
  560. }
  561. posy += incy;
  562. info->dst += info->dst_pitch;
  563. }
  564. }
  565. static void SDL_Blit_XRGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  566. {
  567. const int flags = info->flags;
  568. const Uint32 modulateR = info->r;
  569. const Uint32 modulateG = info->g;
  570. const Uint32 modulateB = info->b;
  571. Uint32 pixel;
  572. Uint32 R, G, B;
  573. while (info->dst_h--) {
  574. Uint32 *src = (Uint32 *)info->src;
  575. Uint32 *dst = (Uint32 *)info->dst;
  576. int n = info->dst_w;
  577. while (n--) {
  578. pixel = *src;
  579. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  580. if (flags & SDL_COPY_MODULATE_COLOR) {
  581. MULT_DIV_255(R, modulateR, R);
  582. MULT_DIV_255(G, modulateG, G);
  583. MULT_DIV_255(B, modulateB, B);
  584. }
  585. pixel = (B << 16) | (G << 8) | R;
  586. *dst = pixel;
  587. ++src;
  588. ++dst;
  589. }
  590. info->src += info->src_pitch;
  591. info->dst += info->dst_pitch;
  592. }
  593. }
  594. static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  595. {
  596. const int flags = info->flags;
  597. const Uint32 modulateR = info->r;
  598. const Uint32 modulateG = info->g;
  599. const Uint32 modulateB = info->b;
  600. Uint32 pixel;
  601. Uint32 R, G, B;
  602. Uint64 srcy, srcx;
  603. Uint64 posy, posx;
  604. Uint64 incy, incx;
  605. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  606. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  607. posy = incy / 2;
  608. while (info->dst_h--) {
  609. Uint32 *src = 0;
  610. Uint32 *dst = (Uint32 *)info->dst;
  611. int n = info->dst_w;
  612. posx = incx / 2;
  613. srcy = posy >> 16;
  614. while (n--) {
  615. srcx = posx >> 16;
  616. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  617. pixel = *src;
  618. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  619. if (flags & SDL_COPY_MODULATE_COLOR) {
  620. MULT_DIV_255(R, modulateR, R);
  621. MULT_DIV_255(G, modulateG, G);
  622. MULT_DIV_255(B, modulateB, B);
  623. }
  624. pixel = (B << 16) | (G << 8) | R;
  625. *dst = pixel;
  626. posx += incx;
  627. ++dst;
  628. }
  629. posy += incy;
  630. info->dst += info->dst_pitch;
  631. }
  632. }
  633. static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  634. {
  635. const int flags = info->flags;
  636. const Uint32 modulateR = info->r;
  637. const Uint32 modulateG = info->g;
  638. const Uint32 modulateB = info->b;
  639. const Uint32 modulateA = info->a;
  640. Uint32 srcpixel;
  641. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  642. Uint32 srcR, srcG, srcB;
  643. Uint32 dstpixel;
  644. Uint32 dstR, dstG, dstB;
  645. while (info->dst_h--) {
  646. Uint32 *src = (Uint32 *)info->src;
  647. Uint32 *dst = (Uint32 *)info->dst;
  648. int n = info->dst_w;
  649. while (n--) {
  650. srcpixel = *src;
  651. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  652. dstpixel = *dst;
  653. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  654. if (flags & SDL_COPY_MODULATE_COLOR) {
  655. MULT_DIV_255(srcR, modulateR, srcR);
  656. MULT_DIV_255(srcG, modulateG, srcG);
  657. MULT_DIV_255(srcB, modulateB, srcB);
  658. }
  659. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  660. if (srcA < 255) {
  661. MULT_DIV_255(srcR, srcA, srcR);
  662. MULT_DIV_255(srcG, srcA, srcG);
  663. MULT_DIV_255(srcB, srcA, srcB);
  664. }
  665. }
  666. switch (flags & SDL_COPY_BLEND_MASK) {
  667. case SDL_COPY_BLEND:
  668. MULT_DIV_255((255 - srcA), dstR, dstR);
  669. dstR += srcR;
  670. MULT_DIV_255((255 - srcA), dstG, dstG);
  671. dstG += srcG;
  672. MULT_DIV_255((255 - srcA), dstB, dstB);
  673. dstB += srcB;
  674. break;
  675. case SDL_COPY_BLEND_PREMULTIPLIED:
  676. MULT_DIV_255((255 - srcA), dstR, dstR);
  677. dstR += srcR;
  678. if (dstR > 255) dstR = 255;
  679. MULT_DIV_255((255 - srcA), dstG, dstG);
  680. dstG += srcG;
  681. if (dstG > 255) dstG = 255;
  682. MULT_DIV_255((255 - srcA), dstB, dstB);
  683. dstB += srcB;
  684. if (dstB > 255) dstB = 255;
  685. break;
  686. case SDL_COPY_ADD:
  687. case SDL_COPY_ADD_PREMULTIPLIED:
  688. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  689. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  690. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  691. break;
  692. case SDL_COPY_MOD:
  693. MULT_DIV_255(srcR, dstR, dstR);
  694. MULT_DIV_255(srcG, dstG, dstG);
  695. MULT_DIV_255(srcB, dstB, dstB);
  696. break;
  697. case SDL_COPY_MUL:
  698. {
  699. Uint32 tmp1, tmp2;
  700. MULT_DIV_255(srcR, dstR, tmp1);
  701. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  702. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  703. MULT_DIV_255(srcG, dstG, tmp1);
  704. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  705. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  706. MULT_DIV_255(srcB, dstB, tmp1);
  707. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  708. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  709. }
  710. break;
  711. }
  712. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  713. *dst = dstpixel;
  714. ++src;
  715. ++dst;
  716. }
  717. info->src += info->src_pitch;
  718. info->dst += info->dst_pitch;
  719. }
  720. }
  721. static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  722. {
  723. const int flags = info->flags;
  724. const Uint32 modulateR = info->r;
  725. const Uint32 modulateG = info->g;
  726. const Uint32 modulateB = info->b;
  727. const Uint32 modulateA = info->a;
  728. Uint32 srcpixel;
  729. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  730. Uint32 srcR, srcG, srcB;
  731. Uint32 dstpixel;
  732. Uint32 dstR, dstG, dstB;
  733. Uint64 srcy, srcx;
  734. Uint64 posy, posx;
  735. Uint64 incy, incx;
  736. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  737. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  738. posy = incy / 2;
  739. while (info->dst_h--) {
  740. Uint32 *src = 0;
  741. Uint32 *dst = (Uint32 *)info->dst;
  742. int n = info->dst_w;
  743. posx = incx / 2;
  744. srcy = posy >> 16;
  745. while (n--) {
  746. srcx = posx >> 16;
  747. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  748. srcpixel = *src;
  749. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  750. dstpixel = *dst;
  751. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  752. if (flags & SDL_COPY_MODULATE_COLOR) {
  753. MULT_DIV_255(srcR, modulateR, srcR);
  754. MULT_DIV_255(srcG, modulateG, srcG);
  755. MULT_DIV_255(srcB, modulateB, srcB);
  756. }
  757. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  758. if (srcA < 255) {
  759. MULT_DIV_255(srcR, srcA, srcR);
  760. MULT_DIV_255(srcG, srcA, srcG);
  761. MULT_DIV_255(srcB, srcA, srcB);
  762. }
  763. }
  764. switch (flags & SDL_COPY_BLEND_MASK) {
  765. case SDL_COPY_BLEND:
  766. MULT_DIV_255((255 - srcA), dstR, dstR);
  767. dstR += srcR;
  768. MULT_DIV_255((255 - srcA), dstG, dstG);
  769. dstG += srcG;
  770. MULT_DIV_255((255 - srcA), dstB, dstB);
  771. dstB += srcB;
  772. break;
  773. case SDL_COPY_BLEND_PREMULTIPLIED:
  774. MULT_DIV_255((255 - srcA), dstR, dstR);
  775. dstR += srcR;
  776. if (dstR > 255) dstR = 255;
  777. MULT_DIV_255((255 - srcA), dstG, dstG);
  778. dstG += srcG;
  779. if (dstG > 255) dstG = 255;
  780. MULT_DIV_255((255 - srcA), dstB, dstB);
  781. dstB += srcB;
  782. if (dstB > 255) dstB = 255;
  783. break;
  784. case SDL_COPY_ADD:
  785. case SDL_COPY_ADD_PREMULTIPLIED:
  786. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  787. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  788. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  789. break;
  790. case SDL_COPY_MOD:
  791. MULT_DIV_255(srcR, dstR, dstR);
  792. MULT_DIV_255(srcG, dstG, dstG);
  793. MULT_DIV_255(srcB, dstB, dstB);
  794. break;
  795. case SDL_COPY_MUL:
  796. {
  797. Uint32 tmp1, tmp2;
  798. MULT_DIV_255(srcR, dstR, tmp1);
  799. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  800. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  801. MULT_DIV_255(srcG, dstG, tmp1);
  802. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  803. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  804. MULT_DIV_255(srcB, dstB, tmp1);
  805. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  806. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  807. }
  808. break;
  809. }
  810. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  811. *dst = dstpixel;
  812. posx += incx;
  813. ++dst;
  814. }
  815. posy += incy;
  816. info->dst += info->dst_pitch;
  817. }
  818. }
  819. static void SDL_Blit_XRGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
  820. {
  821. Uint32 pixel;
  822. const Uint32 A = 0xFF;
  823. Uint64 srcy, srcx;
  824. Uint64 posy, posx;
  825. Uint64 incy, incx;
  826. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  827. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  828. posy = incy / 2;
  829. while (info->dst_h--) {
  830. Uint32 *src = 0;
  831. Uint32 *dst = (Uint32 *)info->dst;
  832. int n = info->dst_w;
  833. posx = incx / 2;
  834. srcy = posy >> 16;
  835. while (n--) {
  836. srcx = posx >> 16;
  837. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  838. pixel = *src;
  839. pixel |= (A << 24);
  840. *dst = pixel;
  841. posx += incx;
  842. ++dst;
  843. }
  844. posy += incy;
  845. info->dst += info->dst_pitch;
  846. }
  847. }
  848. static void SDL_Blit_XRGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
  849. {
  850. const int flags = info->flags;
  851. Uint32 srcpixel;
  852. Uint32 srcR, srcG, srcB;
  853. Uint32 dstpixel;
  854. Uint32 dstR, dstG, dstB, dstA;
  855. while (info->dst_h--) {
  856. Uint32 *src = (Uint32 *)info->src;
  857. Uint32 *dst = (Uint32 *)info->dst;
  858. int n = info->dst_w;
  859. while (n--) {
  860. srcpixel = *src;
  861. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  862. dstpixel = *dst;
  863. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  864. switch (flags & SDL_COPY_BLEND_MASK) {
  865. case SDL_COPY_BLEND:
  866. dstR = srcR;
  867. dstG = srcG;
  868. dstB = srcB;
  869. dstA = 0xFF;
  870. break;
  871. case SDL_COPY_BLEND_PREMULTIPLIED:
  872. dstR = srcR;
  873. dstG = srcG;
  874. dstB = srcB;
  875. dstA = 0xFF;
  876. break;
  877. case SDL_COPY_ADD:
  878. case SDL_COPY_ADD_PREMULTIPLIED:
  879. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  880. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  881. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  882. break;
  883. case SDL_COPY_MOD:
  884. MULT_DIV_255(srcR, dstR, dstR);
  885. MULT_DIV_255(srcG, dstG, dstG);
  886. MULT_DIV_255(srcB, dstB, dstB);
  887. break;
  888. case SDL_COPY_MUL:
  889. MULT_DIV_255(srcR, dstR, dstR);
  890. MULT_DIV_255(srcG, dstG, dstG);
  891. MULT_DIV_255(srcB, dstB, dstB);
  892. break;
  893. }
  894. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  895. *dst = dstpixel;
  896. ++src;
  897. ++dst;
  898. }
  899. info->src += info->src_pitch;
  900. info->dst += info->dst_pitch;
  901. }
  902. }
  903. static void SDL_Blit_XRGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  904. {
  905. const int flags = info->flags;
  906. Uint32 srcpixel;
  907. Uint32 srcR, srcG, srcB;
  908. Uint32 dstpixel;
  909. Uint32 dstR, dstG, dstB, dstA;
  910. Uint64 srcy, srcx;
  911. Uint64 posy, posx;
  912. Uint64 incy, incx;
  913. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  914. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  915. posy = incy / 2;
  916. while (info->dst_h--) {
  917. Uint32 *src = 0;
  918. Uint32 *dst = (Uint32 *)info->dst;
  919. int n = info->dst_w;
  920. posx = incx / 2;
  921. srcy = posy >> 16;
  922. while (n--) {
  923. srcx = posx >> 16;
  924. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  925. srcpixel = *src;
  926. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  927. dstpixel = *dst;
  928. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  929. switch (flags & SDL_COPY_BLEND_MASK) {
  930. case SDL_COPY_BLEND:
  931. dstR = srcR;
  932. dstG = srcG;
  933. dstB = srcB;
  934. dstA = 0xFF;
  935. break;
  936. case SDL_COPY_BLEND_PREMULTIPLIED:
  937. dstR = srcR;
  938. dstG = srcG;
  939. dstB = srcB;
  940. dstA = 0xFF;
  941. break;
  942. case SDL_COPY_ADD:
  943. case SDL_COPY_ADD_PREMULTIPLIED:
  944. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  945. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  946. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  947. break;
  948. case SDL_COPY_MOD:
  949. MULT_DIV_255(srcR, dstR, dstR);
  950. MULT_DIV_255(srcG, dstG, dstG);
  951. MULT_DIV_255(srcB, dstB, dstB);
  952. break;
  953. case SDL_COPY_MUL:
  954. MULT_DIV_255(srcR, dstR, dstR);
  955. MULT_DIV_255(srcG, dstG, dstG);
  956. MULT_DIV_255(srcB, dstB, dstB);
  957. break;
  958. }
  959. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  960. *dst = dstpixel;
  961. posx += incx;
  962. ++dst;
  963. }
  964. posy += incy;
  965. info->dst += info->dst_pitch;
  966. }
  967. }
  968. static void SDL_Blit_XRGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  969. {
  970. const int flags = info->flags;
  971. const Uint32 modulateR = info->r;
  972. const Uint32 modulateG = info->g;
  973. const Uint32 modulateB = info->b;
  974. const Uint32 modulateA = info->a;
  975. Uint32 pixel;
  976. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  977. Uint32 R, G, B;
  978. while (info->dst_h--) {
  979. Uint32 *src = (Uint32 *)info->src;
  980. Uint32 *dst = (Uint32 *)info->dst;
  981. int n = info->dst_w;
  982. while (n--) {
  983. pixel = *src;
  984. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  985. if (flags & SDL_COPY_MODULATE_COLOR) {
  986. MULT_DIV_255(R, modulateR, R);
  987. MULT_DIV_255(G, modulateG, G);
  988. MULT_DIV_255(B, modulateB, B);
  989. }
  990. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  991. *dst = pixel;
  992. ++src;
  993. ++dst;
  994. }
  995. info->src += info->src_pitch;
  996. info->dst += info->dst_pitch;
  997. }
  998. }
  999. static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  1000. {
  1001. const int flags = info->flags;
  1002. const Uint32 modulateR = info->r;
  1003. const Uint32 modulateG = info->g;
  1004. const Uint32 modulateB = info->b;
  1005. const Uint32 modulateA = info->a;
  1006. Uint32 pixel;
  1007. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1008. Uint32 R, G, B;
  1009. Uint64 srcy, srcx;
  1010. Uint64 posy, posx;
  1011. Uint64 incy, incx;
  1012. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1013. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1014. posy = incy / 2;
  1015. while (info->dst_h--) {
  1016. Uint32 *src = 0;
  1017. Uint32 *dst = (Uint32 *)info->dst;
  1018. int n = info->dst_w;
  1019. posx = incx / 2;
  1020. srcy = posy >> 16;
  1021. while (n--) {
  1022. srcx = posx >> 16;
  1023. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1024. pixel = *src;
  1025. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1026. if (flags & SDL_COPY_MODULATE_COLOR) {
  1027. MULT_DIV_255(R, modulateR, R);
  1028. MULT_DIV_255(G, modulateG, G);
  1029. MULT_DIV_255(B, modulateB, B);
  1030. }
  1031. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  1032. *dst = pixel;
  1033. posx += incx;
  1034. ++dst;
  1035. }
  1036. posy += incy;
  1037. info->dst += info->dst_pitch;
  1038. }
  1039. }
  1040. static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1041. {
  1042. const int flags = info->flags;
  1043. const Uint32 modulateR = info->r;
  1044. const Uint32 modulateG = info->g;
  1045. const Uint32 modulateB = info->b;
  1046. const Uint32 modulateA = info->a;
  1047. Uint32 srcpixel;
  1048. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1049. Uint32 srcR, srcG, srcB;
  1050. Uint32 dstpixel;
  1051. Uint32 dstR, dstG, dstB, dstA;
  1052. while (info->dst_h--) {
  1053. Uint32 *src = (Uint32 *)info->src;
  1054. Uint32 *dst = (Uint32 *)info->dst;
  1055. int n = info->dst_w;
  1056. while (n--) {
  1057. srcpixel = *src;
  1058. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1059. dstpixel = *dst;
  1060. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1061. if (flags & SDL_COPY_MODULATE_COLOR) {
  1062. MULT_DIV_255(srcR, modulateR, srcR);
  1063. MULT_DIV_255(srcG, modulateG, srcG);
  1064. MULT_DIV_255(srcB, modulateB, srcB);
  1065. }
  1066. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1067. if (srcA < 255) {
  1068. MULT_DIV_255(srcR, srcA, srcR);
  1069. MULT_DIV_255(srcG, srcA, srcG);
  1070. MULT_DIV_255(srcB, srcA, srcB);
  1071. }
  1072. }
  1073. switch (flags & SDL_COPY_BLEND_MASK) {
  1074. case SDL_COPY_BLEND:
  1075. MULT_DIV_255((255 - srcA), dstR, dstR);
  1076. dstR += srcR;
  1077. MULT_DIV_255((255 - srcA), dstG, dstG);
  1078. dstG += srcG;
  1079. MULT_DIV_255((255 - srcA), dstB, dstB);
  1080. dstB += srcB;
  1081. MULT_DIV_255((255 - srcA), dstA, dstA);
  1082. dstA += srcA;
  1083. break;
  1084. case SDL_COPY_BLEND_PREMULTIPLIED:
  1085. MULT_DIV_255((255 - srcA), dstR, dstR);
  1086. dstR += srcR;
  1087. if (dstR > 255) dstR = 255;
  1088. MULT_DIV_255((255 - srcA), dstG, dstG);
  1089. dstG += srcG;
  1090. if (dstG > 255) dstG = 255;
  1091. MULT_DIV_255((255 - srcA), dstB, dstB);
  1092. dstB += srcB;
  1093. if (dstB > 255) dstB = 255;
  1094. MULT_DIV_255((255 - srcA), dstA, dstA);
  1095. dstA += srcA;
  1096. if (dstA > 255) dstA = 255;
  1097. break;
  1098. case SDL_COPY_ADD:
  1099. case SDL_COPY_ADD_PREMULTIPLIED:
  1100. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1101. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1102. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1103. break;
  1104. case SDL_COPY_MOD:
  1105. MULT_DIV_255(srcR, dstR, dstR);
  1106. MULT_DIV_255(srcG, dstG, dstG);
  1107. MULT_DIV_255(srcB, dstB, dstB);
  1108. break;
  1109. case SDL_COPY_MUL:
  1110. {
  1111. Uint32 tmp1, tmp2;
  1112. MULT_DIV_255(srcR, dstR, tmp1);
  1113. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1114. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1115. MULT_DIV_255(srcG, dstG, tmp1);
  1116. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1117. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1118. MULT_DIV_255(srcB, dstB, tmp1);
  1119. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1120. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1121. }
  1122. break;
  1123. }
  1124. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  1125. *dst = dstpixel;
  1126. ++src;
  1127. ++dst;
  1128. }
  1129. info->src += info->src_pitch;
  1130. info->dst += info->dst_pitch;
  1131. }
  1132. }
  1133. static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1134. {
  1135. const int flags = info->flags;
  1136. const Uint32 modulateR = info->r;
  1137. const Uint32 modulateG = info->g;
  1138. const Uint32 modulateB = info->b;
  1139. const Uint32 modulateA = info->a;
  1140. Uint32 srcpixel;
  1141. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1142. Uint32 srcR, srcG, srcB;
  1143. Uint32 dstpixel;
  1144. Uint32 dstR, dstG, dstB, dstA;
  1145. Uint64 srcy, srcx;
  1146. Uint64 posy, posx;
  1147. Uint64 incy, incx;
  1148. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1149. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1150. posy = incy / 2;
  1151. while (info->dst_h--) {
  1152. Uint32 *src = 0;
  1153. Uint32 *dst = (Uint32 *)info->dst;
  1154. int n = info->dst_w;
  1155. posx = incx / 2;
  1156. srcy = posy >> 16;
  1157. while (n--) {
  1158. srcx = posx >> 16;
  1159. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1160. srcpixel = *src;
  1161. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1162. dstpixel = *dst;
  1163. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1164. if (flags & SDL_COPY_MODULATE_COLOR) {
  1165. MULT_DIV_255(srcR, modulateR, srcR);
  1166. MULT_DIV_255(srcG, modulateG, srcG);
  1167. MULT_DIV_255(srcB, modulateB, srcB);
  1168. }
  1169. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1170. if (srcA < 255) {
  1171. MULT_DIV_255(srcR, srcA, srcR);
  1172. MULT_DIV_255(srcG, srcA, srcG);
  1173. MULT_DIV_255(srcB, srcA, srcB);
  1174. }
  1175. }
  1176. switch (flags & SDL_COPY_BLEND_MASK) {
  1177. case SDL_COPY_BLEND:
  1178. MULT_DIV_255((255 - srcA), dstR, dstR);
  1179. dstR += srcR;
  1180. MULT_DIV_255((255 - srcA), dstG, dstG);
  1181. dstG += srcG;
  1182. MULT_DIV_255((255 - srcA), dstB, dstB);
  1183. dstB += srcB;
  1184. MULT_DIV_255((255 - srcA), dstA, dstA);
  1185. dstA += srcA;
  1186. break;
  1187. case SDL_COPY_BLEND_PREMULTIPLIED:
  1188. MULT_DIV_255((255 - srcA), dstR, dstR);
  1189. dstR += srcR;
  1190. if (dstR > 255) dstR = 255;
  1191. MULT_DIV_255((255 - srcA), dstG, dstG);
  1192. dstG += srcG;
  1193. if (dstG > 255) dstG = 255;
  1194. MULT_DIV_255((255 - srcA), dstB, dstB);
  1195. dstB += srcB;
  1196. if (dstB > 255) dstB = 255;
  1197. MULT_DIV_255((255 - srcA), dstA, dstA);
  1198. dstA += srcA;
  1199. if (dstA > 255) dstA = 255;
  1200. break;
  1201. case SDL_COPY_ADD:
  1202. case SDL_COPY_ADD_PREMULTIPLIED:
  1203. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1204. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1205. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1206. break;
  1207. case SDL_COPY_MOD:
  1208. MULT_DIV_255(srcR, dstR, dstR);
  1209. MULT_DIV_255(srcG, dstG, dstG);
  1210. MULT_DIV_255(srcB, dstB, dstB);
  1211. break;
  1212. case SDL_COPY_MUL:
  1213. {
  1214. Uint32 tmp1, tmp2;
  1215. MULT_DIV_255(srcR, dstR, tmp1);
  1216. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1217. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1218. MULT_DIV_255(srcG, dstG, tmp1);
  1219. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1220. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1221. MULT_DIV_255(srcB, dstB, tmp1);
  1222. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1223. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1224. }
  1225. break;
  1226. }
  1227. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  1228. *dst = dstpixel;
  1229. posx += incx;
  1230. ++dst;
  1231. }
  1232. posy += incy;
  1233. info->dst += info->dst_pitch;
  1234. }
  1235. }
  1236. static void SDL_Blit_XRGB8888_ABGR8888_Scale(SDL_BlitInfo *info)
  1237. {
  1238. Uint32 pixel;
  1239. const Uint32 A = 0xFF;
  1240. Uint32 R, G, B;
  1241. Uint64 srcy, srcx;
  1242. Uint64 posy, posx;
  1243. Uint64 incy, incx;
  1244. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1245. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1246. posy = incy / 2;
  1247. while (info->dst_h--) {
  1248. Uint32 *src = 0;
  1249. Uint32 *dst = (Uint32 *)info->dst;
  1250. int n = info->dst_w;
  1251. posx = incx / 2;
  1252. srcy = posy >> 16;
  1253. while (n--) {
  1254. srcx = posx >> 16;
  1255. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1256. pixel = *src;
  1257. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1258. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  1259. *dst = pixel;
  1260. posx += incx;
  1261. ++dst;
  1262. }
  1263. posy += incy;
  1264. info->dst += info->dst_pitch;
  1265. }
  1266. }
  1267. static void SDL_Blit_XRGB8888_ABGR8888_Blend(SDL_BlitInfo *info)
  1268. {
  1269. const int flags = info->flags;
  1270. Uint32 srcpixel;
  1271. Uint32 srcR, srcG, srcB;
  1272. Uint32 dstpixel;
  1273. Uint32 dstR, dstG, dstB, dstA;
  1274. while (info->dst_h--) {
  1275. Uint32 *src = (Uint32 *)info->src;
  1276. Uint32 *dst = (Uint32 *)info->dst;
  1277. int n = info->dst_w;
  1278. while (n--) {
  1279. srcpixel = *src;
  1280. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1281. dstpixel = *dst;
  1282. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1283. switch (flags & SDL_COPY_BLEND_MASK) {
  1284. case SDL_COPY_BLEND:
  1285. dstR = srcR;
  1286. dstG = srcG;
  1287. dstB = srcB;
  1288. dstA = 0xFF;
  1289. break;
  1290. case SDL_COPY_BLEND_PREMULTIPLIED:
  1291. dstR = srcR;
  1292. dstG = srcG;
  1293. dstB = srcB;
  1294. dstA = 0xFF;
  1295. break;
  1296. case SDL_COPY_ADD:
  1297. case SDL_COPY_ADD_PREMULTIPLIED:
  1298. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1299. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1300. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1301. break;
  1302. case SDL_COPY_MOD:
  1303. MULT_DIV_255(srcR, dstR, dstR);
  1304. MULT_DIV_255(srcG, dstG, dstG);
  1305. MULT_DIV_255(srcB, dstB, dstB);
  1306. break;
  1307. case SDL_COPY_MUL:
  1308. MULT_DIV_255(srcR, dstR, dstR);
  1309. MULT_DIV_255(srcG, dstG, dstG);
  1310. MULT_DIV_255(srcB, dstB, dstB);
  1311. break;
  1312. }
  1313. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  1314. *dst = dstpixel;
  1315. ++src;
  1316. ++dst;
  1317. }
  1318. info->src += info->src_pitch;
  1319. info->dst += info->dst_pitch;
  1320. }
  1321. }
  1322. static void SDL_Blit_XRGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  1323. {
  1324. const int flags = info->flags;
  1325. Uint32 srcpixel;
  1326. Uint32 srcR, srcG, srcB;
  1327. Uint32 dstpixel;
  1328. Uint32 dstR, dstG, dstB, dstA;
  1329. Uint64 srcy, srcx;
  1330. Uint64 posy, posx;
  1331. Uint64 incy, incx;
  1332. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1333. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1334. posy = incy / 2;
  1335. while (info->dst_h--) {
  1336. Uint32 *src = 0;
  1337. Uint32 *dst = (Uint32 *)info->dst;
  1338. int n = info->dst_w;
  1339. posx = incx / 2;
  1340. srcy = posy >> 16;
  1341. while (n--) {
  1342. srcx = posx >> 16;
  1343. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1344. srcpixel = *src;
  1345. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1346. dstpixel = *dst;
  1347. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1348. switch (flags & SDL_COPY_BLEND_MASK) {
  1349. case SDL_COPY_BLEND:
  1350. dstR = srcR;
  1351. dstG = srcG;
  1352. dstB = srcB;
  1353. dstA = 0xFF;
  1354. break;
  1355. case SDL_COPY_BLEND_PREMULTIPLIED:
  1356. dstR = srcR;
  1357. dstG = srcG;
  1358. dstB = srcB;
  1359. dstA = 0xFF;
  1360. break;
  1361. case SDL_COPY_ADD:
  1362. case SDL_COPY_ADD_PREMULTIPLIED:
  1363. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1364. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1365. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1366. break;
  1367. case SDL_COPY_MOD:
  1368. MULT_DIV_255(srcR, dstR, dstR);
  1369. MULT_DIV_255(srcG, dstG, dstG);
  1370. MULT_DIV_255(srcB, dstB, dstB);
  1371. break;
  1372. case SDL_COPY_MUL:
  1373. MULT_DIV_255(srcR, dstR, dstR);
  1374. MULT_DIV_255(srcG, dstG, dstG);
  1375. MULT_DIV_255(srcB, dstB, dstB);
  1376. break;
  1377. }
  1378. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  1379. *dst = dstpixel;
  1380. posx += incx;
  1381. ++dst;
  1382. }
  1383. posy += incy;
  1384. info->dst += info->dst_pitch;
  1385. }
  1386. }
  1387. static void SDL_Blit_XRGB8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  1388. {
  1389. const int flags = info->flags;
  1390. const Uint32 modulateR = info->r;
  1391. const Uint32 modulateG = info->g;
  1392. const Uint32 modulateB = info->b;
  1393. const Uint32 modulateA = info->a;
  1394. Uint32 pixel;
  1395. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1396. Uint32 R, G, B;
  1397. while (info->dst_h--) {
  1398. Uint32 *src = (Uint32 *)info->src;
  1399. Uint32 *dst = (Uint32 *)info->dst;
  1400. int n = info->dst_w;
  1401. while (n--) {
  1402. pixel = *src;
  1403. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1404. if (flags & SDL_COPY_MODULATE_COLOR) {
  1405. MULT_DIV_255(R, modulateR, R);
  1406. MULT_DIV_255(G, modulateG, G);
  1407. MULT_DIV_255(B, modulateB, B);
  1408. }
  1409. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  1410. *dst = pixel;
  1411. ++src;
  1412. ++dst;
  1413. }
  1414. info->src += info->src_pitch;
  1415. info->dst += info->dst_pitch;
  1416. }
  1417. }
  1418. static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  1419. {
  1420. const int flags = info->flags;
  1421. const Uint32 modulateR = info->r;
  1422. const Uint32 modulateG = info->g;
  1423. const Uint32 modulateB = info->b;
  1424. const Uint32 modulateA = info->a;
  1425. Uint32 pixel;
  1426. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1427. Uint32 R, G, B;
  1428. Uint64 srcy, srcx;
  1429. Uint64 posy, posx;
  1430. Uint64 incy, incx;
  1431. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1432. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1433. posy = incy / 2;
  1434. while (info->dst_h--) {
  1435. Uint32 *src = 0;
  1436. Uint32 *dst = (Uint32 *)info->dst;
  1437. int n = info->dst_w;
  1438. posx = incx / 2;
  1439. srcy = posy >> 16;
  1440. while (n--) {
  1441. srcx = posx >> 16;
  1442. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1443. pixel = *src;
  1444. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1445. if (flags & SDL_COPY_MODULATE_COLOR) {
  1446. MULT_DIV_255(R, modulateR, R);
  1447. MULT_DIV_255(G, modulateG, G);
  1448. MULT_DIV_255(B, modulateB, B);
  1449. }
  1450. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  1451. *dst = pixel;
  1452. posx += incx;
  1453. ++dst;
  1454. }
  1455. posy += incy;
  1456. info->dst += info->dst_pitch;
  1457. }
  1458. }
  1459. static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  1460. {
  1461. const int flags = info->flags;
  1462. const Uint32 modulateR = info->r;
  1463. const Uint32 modulateG = info->g;
  1464. const Uint32 modulateB = info->b;
  1465. const Uint32 modulateA = info->a;
  1466. Uint32 srcpixel;
  1467. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1468. Uint32 srcR, srcG, srcB;
  1469. Uint32 dstpixel;
  1470. Uint32 dstR, dstG, dstB, dstA;
  1471. while (info->dst_h--) {
  1472. Uint32 *src = (Uint32 *)info->src;
  1473. Uint32 *dst = (Uint32 *)info->dst;
  1474. int n = info->dst_w;
  1475. while (n--) {
  1476. srcpixel = *src;
  1477. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1478. dstpixel = *dst;
  1479. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1480. if (flags & SDL_COPY_MODULATE_COLOR) {
  1481. MULT_DIV_255(srcR, modulateR, srcR);
  1482. MULT_DIV_255(srcG, modulateG, srcG);
  1483. MULT_DIV_255(srcB, modulateB, srcB);
  1484. }
  1485. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1486. if (srcA < 255) {
  1487. MULT_DIV_255(srcR, srcA, srcR);
  1488. MULT_DIV_255(srcG, srcA, srcG);
  1489. MULT_DIV_255(srcB, srcA, srcB);
  1490. }
  1491. }
  1492. switch (flags & SDL_COPY_BLEND_MASK) {
  1493. case SDL_COPY_BLEND:
  1494. MULT_DIV_255((255 - srcA), dstR, dstR);
  1495. dstR += srcR;
  1496. MULT_DIV_255((255 - srcA), dstG, dstG);
  1497. dstG += srcG;
  1498. MULT_DIV_255((255 - srcA), dstB, dstB);
  1499. dstB += srcB;
  1500. MULT_DIV_255((255 - srcA), dstA, dstA);
  1501. dstA += srcA;
  1502. break;
  1503. case SDL_COPY_BLEND_PREMULTIPLIED:
  1504. MULT_DIV_255((255 - srcA), dstR, dstR);
  1505. dstR += srcR;
  1506. if (dstR > 255) dstR = 255;
  1507. MULT_DIV_255((255 - srcA), dstG, dstG);
  1508. dstG += srcG;
  1509. if (dstG > 255) dstG = 255;
  1510. MULT_DIV_255((255 - srcA), dstB, dstB);
  1511. dstB += srcB;
  1512. if (dstB > 255) dstB = 255;
  1513. MULT_DIV_255((255 - srcA), dstA, dstA);
  1514. dstA += srcA;
  1515. if (dstA > 255) dstA = 255;
  1516. break;
  1517. case SDL_COPY_ADD:
  1518. case SDL_COPY_ADD_PREMULTIPLIED:
  1519. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1520. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1521. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1522. break;
  1523. case SDL_COPY_MOD:
  1524. MULT_DIV_255(srcR, dstR, dstR);
  1525. MULT_DIV_255(srcG, dstG, dstG);
  1526. MULT_DIV_255(srcB, dstB, dstB);
  1527. break;
  1528. case SDL_COPY_MUL:
  1529. {
  1530. Uint32 tmp1, tmp2;
  1531. MULT_DIV_255(srcR, dstR, tmp1);
  1532. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1533. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1534. MULT_DIV_255(srcG, dstG, tmp1);
  1535. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1536. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1537. MULT_DIV_255(srcB, dstB, tmp1);
  1538. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1539. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1540. }
  1541. break;
  1542. }
  1543. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  1544. *dst = dstpixel;
  1545. ++src;
  1546. ++dst;
  1547. }
  1548. info->src += info->src_pitch;
  1549. info->dst += info->dst_pitch;
  1550. }
  1551. }
  1552. static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1553. {
  1554. const int flags = info->flags;
  1555. const Uint32 modulateR = info->r;
  1556. const Uint32 modulateG = info->g;
  1557. const Uint32 modulateB = info->b;
  1558. const Uint32 modulateA = info->a;
  1559. Uint32 srcpixel;
  1560. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1561. Uint32 srcR, srcG, srcB;
  1562. Uint32 dstpixel;
  1563. Uint32 dstR, dstG, dstB, dstA;
  1564. Uint64 srcy, srcx;
  1565. Uint64 posy, posx;
  1566. Uint64 incy, incx;
  1567. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1568. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1569. posy = incy / 2;
  1570. while (info->dst_h--) {
  1571. Uint32 *src = 0;
  1572. Uint32 *dst = (Uint32 *)info->dst;
  1573. int n = info->dst_w;
  1574. posx = incx / 2;
  1575. srcy = posy >> 16;
  1576. while (n--) {
  1577. srcx = posx >> 16;
  1578. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1579. srcpixel = *src;
  1580. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1581. dstpixel = *dst;
  1582. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1583. if (flags & SDL_COPY_MODULATE_COLOR) {
  1584. MULT_DIV_255(srcR, modulateR, srcR);
  1585. MULT_DIV_255(srcG, modulateG, srcG);
  1586. MULT_DIV_255(srcB, modulateB, srcB);
  1587. }
  1588. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1589. if (srcA < 255) {
  1590. MULT_DIV_255(srcR, srcA, srcR);
  1591. MULT_DIV_255(srcG, srcA, srcG);
  1592. MULT_DIV_255(srcB, srcA, srcB);
  1593. }
  1594. }
  1595. switch (flags & SDL_COPY_BLEND_MASK) {
  1596. case SDL_COPY_BLEND:
  1597. MULT_DIV_255((255 - srcA), dstR, dstR);
  1598. dstR += srcR;
  1599. MULT_DIV_255((255 - srcA), dstG, dstG);
  1600. dstG += srcG;
  1601. MULT_DIV_255((255 - srcA), dstB, dstB);
  1602. dstB += srcB;
  1603. MULT_DIV_255((255 - srcA), dstA, dstA);
  1604. dstA += srcA;
  1605. break;
  1606. case SDL_COPY_BLEND_PREMULTIPLIED:
  1607. MULT_DIV_255((255 - srcA), dstR, dstR);
  1608. dstR += srcR;
  1609. if (dstR > 255) dstR = 255;
  1610. MULT_DIV_255((255 - srcA), dstG, dstG);
  1611. dstG += srcG;
  1612. if (dstG > 255) dstG = 255;
  1613. MULT_DIV_255((255 - srcA), dstB, dstB);
  1614. dstB += srcB;
  1615. if (dstB > 255) dstB = 255;
  1616. MULT_DIV_255((255 - srcA), dstA, dstA);
  1617. dstA += srcA;
  1618. if (dstA > 255) dstA = 255;
  1619. break;
  1620. case SDL_COPY_ADD:
  1621. case SDL_COPY_ADD_PREMULTIPLIED:
  1622. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1623. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1624. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1625. break;
  1626. case SDL_COPY_MOD:
  1627. MULT_DIV_255(srcR, dstR, dstR);
  1628. MULT_DIV_255(srcG, dstG, dstG);
  1629. MULT_DIV_255(srcB, dstB, dstB);
  1630. break;
  1631. case SDL_COPY_MUL:
  1632. {
  1633. Uint32 tmp1, tmp2;
  1634. MULT_DIV_255(srcR, dstR, tmp1);
  1635. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1636. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1637. MULT_DIV_255(srcG, dstG, tmp1);
  1638. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1639. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1640. MULT_DIV_255(srcB, dstB, tmp1);
  1641. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1642. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1643. }
  1644. break;
  1645. }
  1646. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  1647. *dst = dstpixel;
  1648. posx += incx;
  1649. ++dst;
  1650. }
  1651. posy += incy;
  1652. info->dst += info->dst_pitch;
  1653. }
  1654. }
  1655. static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
  1656. {
  1657. Uint32 pixel;
  1658. Uint32 R, G, B;
  1659. Uint64 srcy, srcx;
  1660. Uint64 posy, posx;
  1661. Uint64 incy, incx;
  1662. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1663. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1664. posy = incy / 2;
  1665. while (info->dst_h--) {
  1666. Uint32 *src = 0;
  1667. Uint32 *dst = (Uint32 *)info->dst;
  1668. int n = info->dst_w;
  1669. posx = incx / 2;
  1670. srcy = posy >> 16;
  1671. while (n--) {
  1672. srcx = posx >> 16;
  1673. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1674. pixel = *src;
  1675. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1676. pixel = (R << 16) | (G << 8) | B;
  1677. *dst = pixel;
  1678. posx += incx;
  1679. ++dst;
  1680. }
  1681. posy += incy;
  1682. info->dst += info->dst_pitch;
  1683. }
  1684. }
  1685. static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
  1686. {
  1687. const int flags = info->flags;
  1688. Uint32 srcpixel;
  1689. Uint32 srcR, srcG, srcB;
  1690. Uint32 dstpixel;
  1691. Uint32 dstR, dstG, dstB;
  1692. while (info->dst_h--) {
  1693. Uint32 *src = (Uint32 *)info->src;
  1694. Uint32 *dst = (Uint32 *)info->dst;
  1695. int n = info->dst_w;
  1696. while (n--) {
  1697. srcpixel = *src;
  1698. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1699. dstpixel = *dst;
  1700. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1701. switch (flags & SDL_COPY_BLEND_MASK) {
  1702. case SDL_COPY_BLEND:
  1703. dstR = srcR;
  1704. dstG = srcG;
  1705. dstB = srcB;
  1706. break;
  1707. case SDL_COPY_BLEND_PREMULTIPLIED:
  1708. dstR = srcR;
  1709. dstG = srcG;
  1710. dstB = srcB;
  1711. break;
  1712. case SDL_COPY_ADD:
  1713. case SDL_COPY_ADD_PREMULTIPLIED:
  1714. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1715. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1716. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1717. break;
  1718. case SDL_COPY_MOD:
  1719. MULT_DIV_255(srcR, dstR, dstR);
  1720. MULT_DIV_255(srcG, dstG, dstG);
  1721. MULT_DIV_255(srcB, dstB, dstB);
  1722. break;
  1723. case SDL_COPY_MUL:
  1724. MULT_DIV_255(srcR, dstR, dstR);
  1725. MULT_DIV_255(srcG, dstG, dstG);
  1726. MULT_DIV_255(srcB, dstB, dstB);
  1727. break;
  1728. }
  1729. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1730. *dst = dstpixel;
  1731. ++src;
  1732. ++dst;
  1733. }
  1734. info->src += info->src_pitch;
  1735. info->dst += info->dst_pitch;
  1736. }
  1737. }
  1738. static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  1739. {
  1740. const int flags = info->flags;
  1741. Uint32 srcpixel;
  1742. Uint32 srcR, srcG, srcB;
  1743. Uint32 dstpixel;
  1744. Uint32 dstR, dstG, dstB;
  1745. Uint64 srcy, srcx;
  1746. Uint64 posy, posx;
  1747. Uint64 incy, incx;
  1748. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1749. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1750. posy = incy / 2;
  1751. while (info->dst_h--) {
  1752. Uint32 *src = 0;
  1753. Uint32 *dst = (Uint32 *)info->dst;
  1754. int n = info->dst_w;
  1755. posx = incx / 2;
  1756. srcy = posy >> 16;
  1757. while (n--) {
  1758. srcx = posx >> 16;
  1759. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1760. srcpixel = *src;
  1761. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1762. dstpixel = *dst;
  1763. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1764. switch (flags & SDL_COPY_BLEND_MASK) {
  1765. case SDL_COPY_BLEND:
  1766. dstR = srcR;
  1767. dstG = srcG;
  1768. dstB = srcB;
  1769. break;
  1770. case SDL_COPY_BLEND_PREMULTIPLIED:
  1771. dstR = srcR;
  1772. dstG = srcG;
  1773. dstB = srcB;
  1774. break;
  1775. case SDL_COPY_ADD:
  1776. case SDL_COPY_ADD_PREMULTIPLIED:
  1777. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1778. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1779. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1780. break;
  1781. case SDL_COPY_MOD:
  1782. MULT_DIV_255(srcR, dstR, dstR);
  1783. MULT_DIV_255(srcG, dstG, dstG);
  1784. MULT_DIV_255(srcB, dstB, dstB);
  1785. break;
  1786. case SDL_COPY_MUL:
  1787. MULT_DIV_255(srcR, dstR, dstR);
  1788. MULT_DIV_255(srcG, dstG, dstG);
  1789. MULT_DIV_255(srcB, dstB, dstB);
  1790. break;
  1791. }
  1792. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1793. *dst = dstpixel;
  1794. posx += incx;
  1795. ++dst;
  1796. }
  1797. posy += incy;
  1798. info->dst += info->dst_pitch;
  1799. }
  1800. }
  1801. static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  1802. {
  1803. const int flags = info->flags;
  1804. const Uint32 modulateR = info->r;
  1805. const Uint32 modulateG = info->g;
  1806. const Uint32 modulateB = info->b;
  1807. Uint32 pixel;
  1808. Uint32 R, G, B;
  1809. while (info->dst_h--) {
  1810. Uint32 *src = (Uint32 *)info->src;
  1811. Uint32 *dst = (Uint32 *)info->dst;
  1812. int n = info->dst_w;
  1813. while (n--) {
  1814. pixel = *src;
  1815. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1816. if (flags & SDL_COPY_MODULATE_COLOR) {
  1817. MULT_DIV_255(R, modulateR, R);
  1818. MULT_DIV_255(G, modulateG, G);
  1819. MULT_DIV_255(B, modulateB, B);
  1820. }
  1821. pixel = (R << 16) | (G << 8) | B;
  1822. *dst = pixel;
  1823. ++src;
  1824. ++dst;
  1825. }
  1826. info->src += info->src_pitch;
  1827. info->dst += info->dst_pitch;
  1828. }
  1829. }
  1830. static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  1831. {
  1832. const int flags = info->flags;
  1833. const Uint32 modulateR = info->r;
  1834. const Uint32 modulateG = info->g;
  1835. const Uint32 modulateB = info->b;
  1836. Uint32 pixel;
  1837. Uint32 R, G, B;
  1838. Uint64 srcy, srcx;
  1839. Uint64 posy, posx;
  1840. Uint64 incy, incx;
  1841. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1842. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1843. posy = incy / 2;
  1844. while (info->dst_h--) {
  1845. Uint32 *src = 0;
  1846. Uint32 *dst = (Uint32 *)info->dst;
  1847. int n = info->dst_w;
  1848. posx = incx / 2;
  1849. srcy = posy >> 16;
  1850. while (n--) {
  1851. srcx = posx >> 16;
  1852. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1853. pixel = *src;
  1854. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1855. if (flags & SDL_COPY_MODULATE_COLOR) {
  1856. MULT_DIV_255(R, modulateR, R);
  1857. MULT_DIV_255(G, modulateG, G);
  1858. MULT_DIV_255(B, modulateB, B);
  1859. }
  1860. pixel = (R << 16) | (G << 8) | B;
  1861. *dst = pixel;
  1862. posx += incx;
  1863. ++dst;
  1864. }
  1865. posy += incy;
  1866. info->dst += info->dst_pitch;
  1867. }
  1868. }
  1869. static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1870. {
  1871. const int flags = info->flags;
  1872. const Uint32 modulateR = info->r;
  1873. const Uint32 modulateG = info->g;
  1874. const Uint32 modulateB = info->b;
  1875. const Uint32 modulateA = info->a;
  1876. Uint32 srcpixel;
  1877. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1878. Uint32 srcR, srcG, srcB;
  1879. Uint32 dstpixel;
  1880. Uint32 dstR, dstG, dstB;
  1881. while (info->dst_h--) {
  1882. Uint32 *src = (Uint32 *)info->src;
  1883. Uint32 *dst = (Uint32 *)info->dst;
  1884. int n = info->dst_w;
  1885. while (n--) {
  1886. srcpixel = *src;
  1887. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1888. dstpixel = *dst;
  1889. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1890. if (flags & SDL_COPY_MODULATE_COLOR) {
  1891. MULT_DIV_255(srcR, modulateR, srcR);
  1892. MULT_DIV_255(srcG, modulateG, srcG);
  1893. MULT_DIV_255(srcB, modulateB, srcB);
  1894. }
  1895. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1896. if (srcA < 255) {
  1897. MULT_DIV_255(srcR, srcA, srcR);
  1898. MULT_DIV_255(srcG, srcA, srcG);
  1899. MULT_DIV_255(srcB, srcA, srcB);
  1900. }
  1901. }
  1902. switch (flags & SDL_COPY_BLEND_MASK) {
  1903. case SDL_COPY_BLEND:
  1904. MULT_DIV_255((255 - srcA), dstR, dstR);
  1905. dstR += srcR;
  1906. MULT_DIV_255((255 - srcA), dstG, dstG);
  1907. dstG += srcG;
  1908. MULT_DIV_255((255 - srcA), dstB, dstB);
  1909. dstB += srcB;
  1910. break;
  1911. case SDL_COPY_BLEND_PREMULTIPLIED:
  1912. MULT_DIV_255((255 - srcA), dstR, dstR);
  1913. dstR += srcR;
  1914. if (dstR > 255) dstR = 255;
  1915. MULT_DIV_255((255 - srcA), dstG, dstG);
  1916. dstG += srcG;
  1917. if (dstG > 255) dstG = 255;
  1918. MULT_DIV_255((255 - srcA), dstB, dstB);
  1919. dstB += srcB;
  1920. if (dstB > 255) dstB = 255;
  1921. break;
  1922. case SDL_COPY_ADD:
  1923. case SDL_COPY_ADD_PREMULTIPLIED:
  1924. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1925. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1926. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1927. break;
  1928. case SDL_COPY_MOD:
  1929. MULT_DIV_255(srcR, dstR, dstR);
  1930. MULT_DIV_255(srcG, dstG, dstG);
  1931. MULT_DIV_255(srcB, dstB, dstB);
  1932. break;
  1933. case SDL_COPY_MUL:
  1934. {
  1935. Uint32 tmp1, tmp2;
  1936. MULT_DIV_255(srcR, dstR, tmp1);
  1937. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1938. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1939. MULT_DIV_255(srcG, dstG, tmp1);
  1940. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1941. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1942. MULT_DIV_255(srcB, dstB, tmp1);
  1943. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1944. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1945. }
  1946. break;
  1947. }
  1948. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1949. *dst = dstpixel;
  1950. ++src;
  1951. ++dst;
  1952. }
  1953. info->src += info->src_pitch;
  1954. info->dst += info->dst_pitch;
  1955. }
  1956. }
  1957. static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1958. {
  1959. const int flags = info->flags;
  1960. const Uint32 modulateR = info->r;
  1961. const Uint32 modulateG = info->g;
  1962. const Uint32 modulateB = info->b;
  1963. const Uint32 modulateA = info->a;
  1964. Uint32 srcpixel;
  1965. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1966. Uint32 srcR, srcG, srcB;
  1967. Uint32 dstpixel;
  1968. Uint32 dstR, dstG, dstB;
  1969. Uint64 srcy, srcx;
  1970. Uint64 posy, posx;
  1971. Uint64 incy, incx;
  1972. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1973. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1974. posy = incy / 2;
  1975. while (info->dst_h--) {
  1976. Uint32 *src = 0;
  1977. Uint32 *dst = (Uint32 *)info->dst;
  1978. int n = info->dst_w;
  1979. posx = incx / 2;
  1980. srcy = posy >> 16;
  1981. while (n--) {
  1982. srcx = posx >> 16;
  1983. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1984. srcpixel = *src;
  1985. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1986. dstpixel = *dst;
  1987. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1988. if (flags & SDL_COPY_MODULATE_COLOR) {
  1989. MULT_DIV_255(srcR, modulateR, srcR);
  1990. MULT_DIV_255(srcG, modulateG, srcG);
  1991. MULT_DIV_255(srcB, modulateB, srcB);
  1992. }
  1993. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1994. if (srcA < 255) {
  1995. MULT_DIV_255(srcR, srcA, srcR);
  1996. MULT_DIV_255(srcG, srcA, srcG);
  1997. MULT_DIV_255(srcB, srcA, srcB);
  1998. }
  1999. }
  2000. switch (flags & SDL_COPY_BLEND_MASK) {
  2001. case SDL_COPY_BLEND:
  2002. MULT_DIV_255((255 - srcA), dstR, dstR);
  2003. dstR += srcR;
  2004. MULT_DIV_255((255 - srcA), dstG, dstG);
  2005. dstG += srcG;
  2006. MULT_DIV_255((255 - srcA), dstB, dstB);
  2007. dstB += srcB;
  2008. break;
  2009. case SDL_COPY_BLEND_PREMULTIPLIED:
  2010. MULT_DIV_255((255 - srcA), dstR, dstR);
  2011. dstR += srcR;
  2012. if (dstR > 255) dstR = 255;
  2013. MULT_DIV_255((255 - srcA), dstG, dstG);
  2014. dstG += srcG;
  2015. if (dstG > 255) dstG = 255;
  2016. MULT_DIV_255((255 - srcA), dstB, dstB);
  2017. dstB += srcB;
  2018. if (dstB > 255) dstB = 255;
  2019. break;
  2020. case SDL_COPY_ADD:
  2021. case SDL_COPY_ADD_PREMULTIPLIED:
  2022. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2023. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2024. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2025. break;
  2026. case SDL_COPY_MOD:
  2027. MULT_DIV_255(srcR, dstR, dstR);
  2028. MULT_DIV_255(srcG, dstG, dstG);
  2029. MULT_DIV_255(srcB, dstB, dstB);
  2030. break;
  2031. case SDL_COPY_MUL:
  2032. {
  2033. Uint32 tmp1, tmp2;
  2034. MULT_DIV_255(srcR, dstR, tmp1);
  2035. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2036. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2037. MULT_DIV_255(srcG, dstG, tmp1);
  2038. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2039. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2040. MULT_DIV_255(srcB, dstB, tmp1);
  2041. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2042. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2043. }
  2044. break;
  2045. }
  2046. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  2047. *dst = dstpixel;
  2048. posx += incx;
  2049. ++dst;
  2050. }
  2051. posy += incy;
  2052. info->dst += info->dst_pitch;
  2053. }
  2054. }
  2055. static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
  2056. {
  2057. Uint64 srcy, srcx;
  2058. Uint64 posy, posx;
  2059. Uint64 incy, incx;
  2060. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2061. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2062. posy = incy / 2;
  2063. while (info->dst_h--) {
  2064. Uint32 *src = 0;
  2065. Uint32 *dst = (Uint32 *)info->dst;
  2066. int n = info->dst_w;
  2067. posx = incx / 2;
  2068. srcy = posy >> 16;
  2069. while (n--) {
  2070. srcx = posx >> 16;
  2071. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2072. *dst = *src;
  2073. posx += incx;
  2074. ++dst;
  2075. }
  2076. posy += incy;
  2077. info->dst += info->dst_pitch;
  2078. }
  2079. }
  2080. static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
  2081. {
  2082. const int flags = info->flags;
  2083. Uint32 srcpixel;
  2084. Uint32 srcR, srcG, srcB;
  2085. Uint32 dstpixel;
  2086. Uint32 dstR, dstG, dstB;
  2087. while (info->dst_h--) {
  2088. Uint32 *src = (Uint32 *)info->src;
  2089. Uint32 *dst = (Uint32 *)info->dst;
  2090. int n = info->dst_w;
  2091. while (n--) {
  2092. srcpixel = *src;
  2093. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2094. dstpixel = *dst;
  2095. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2096. switch (flags & SDL_COPY_BLEND_MASK) {
  2097. case SDL_COPY_BLEND:
  2098. dstR = srcR;
  2099. dstG = srcG;
  2100. dstB = srcB;
  2101. break;
  2102. case SDL_COPY_BLEND_PREMULTIPLIED:
  2103. dstR = srcR;
  2104. dstG = srcG;
  2105. dstB = srcB;
  2106. break;
  2107. case SDL_COPY_ADD:
  2108. case SDL_COPY_ADD_PREMULTIPLIED:
  2109. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2110. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2111. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2112. break;
  2113. case SDL_COPY_MOD:
  2114. MULT_DIV_255(srcR, dstR, dstR);
  2115. MULT_DIV_255(srcG, dstG, dstG);
  2116. MULT_DIV_255(srcB, dstB, dstB);
  2117. break;
  2118. case SDL_COPY_MUL:
  2119. MULT_DIV_255(srcR, dstR, dstR);
  2120. MULT_DIV_255(srcG, dstG, dstG);
  2121. MULT_DIV_255(srcB, dstB, dstB);
  2122. break;
  2123. }
  2124. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2125. *dst = dstpixel;
  2126. ++src;
  2127. ++dst;
  2128. }
  2129. info->src += info->src_pitch;
  2130. info->dst += info->dst_pitch;
  2131. }
  2132. }
  2133. static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  2134. {
  2135. const int flags = info->flags;
  2136. Uint32 srcpixel;
  2137. Uint32 srcR, srcG, srcB;
  2138. Uint32 dstpixel;
  2139. Uint32 dstR, dstG, dstB;
  2140. Uint64 srcy, srcx;
  2141. Uint64 posy, posx;
  2142. Uint64 incy, incx;
  2143. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2144. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2145. posy = incy / 2;
  2146. while (info->dst_h--) {
  2147. Uint32 *src = 0;
  2148. Uint32 *dst = (Uint32 *)info->dst;
  2149. int n = info->dst_w;
  2150. posx = incx / 2;
  2151. srcy = posy >> 16;
  2152. while (n--) {
  2153. srcx = posx >> 16;
  2154. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2155. srcpixel = *src;
  2156. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2157. dstpixel = *dst;
  2158. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2159. switch (flags & SDL_COPY_BLEND_MASK) {
  2160. case SDL_COPY_BLEND:
  2161. dstR = srcR;
  2162. dstG = srcG;
  2163. dstB = srcB;
  2164. break;
  2165. case SDL_COPY_BLEND_PREMULTIPLIED:
  2166. dstR = srcR;
  2167. dstG = srcG;
  2168. dstB = srcB;
  2169. break;
  2170. case SDL_COPY_ADD:
  2171. case SDL_COPY_ADD_PREMULTIPLIED:
  2172. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2173. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2174. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2175. break;
  2176. case SDL_COPY_MOD:
  2177. MULT_DIV_255(srcR, dstR, dstR);
  2178. MULT_DIV_255(srcG, dstG, dstG);
  2179. MULT_DIV_255(srcB, dstB, dstB);
  2180. break;
  2181. case SDL_COPY_MUL:
  2182. MULT_DIV_255(srcR, dstR, dstR);
  2183. MULT_DIV_255(srcG, dstG, dstG);
  2184. MULT_DIV_255(srcB, dstB, dstB);
  2185. break;
  2186. }
  2187. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2188. *dst = dstpixel;
  2189. posx += incx;
  2190. ++dst;
  2191. }
  2192. posy += incy;
  2193. info->dst += info->dst_pitch;
  2194. }
  2195. }
  2196. static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  2197. {
  2198. const int flags = info->flags;
  2199. const Uint32 modulateR = info->r;
  2200. const Uint32 modulateG = info->g;
  2201. const Uint32 modulateB = info->b;
  2202. Uint32 pixel;
  2203. Uint32 R, G, B;
  2204. while (info->dst_h--) {
  2205. Uint32 *src = (Uint32 *)info->src;
  2206. Uint32 *dst = (Uint32 *)info->dst;
  2207. int n = info->dst_w;
  2208. while (n--) {
  2209. pixel = *src;
  2210. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2211. if (flags & SDL_COPY_MODULATE_COLOR) {
  2212. MULT_DIV_255(R, modulateR, R);
  2213. MULT_DIV_255(G, modulateG, G);
  2214. MULT_DIV_255(B, modulateB, B);
  2215. }
  2216. pixel = (B << 16) | (G << 8) | R;
  2217. *dst = pixel;
  2218. ++src;
  2219. ++dst;
  2220. }
  2221. info->src += info->src_pitch;
  2222. info->dst += info->dst_pitch;
  2223. }
  2224. }
  2225. static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  2226. {
  2227. const int flags = info->flags;
  2228. const Uint32 modulateR = info->r;
  2229. const Uint32 modulateG = info->g;
  2230. const Uint32 modulateB = info->b;
  2231. Uint32 pixel;
  2232. Uint32 R, G, B;
  2233. Uint64 srcy, srcx;
  2234. Uint64 posy, posx;
  2235. Uint64 incy, incx;
  2236. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2237. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2238. posy = incy / 2;
  2239. while (info->dst_h--) {
  2240. Uint32 *src = 0;
  2241. Uint32 *dst = (Uint32 *)info->dst;
  2242. int n = info->dst_w;
  2243. posx = incx / 2;
  2244. srcy = posy >> 16;
  2245. while (n--) {
  2246. srcx = posx >> 16;
  2247. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2248. pixel = *src;
  2249. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2250. if (flags & SDL_COPY_MODULATE_COLOR) {
  2251. MULT_DIV_255(R, modulateR, R);
  2252. MULT_DIV_255(G, modulateG, G);
  2253. MULT_DIV_255(B, modulateB, B);
  2254. }
  2255. pixel = (B << 16) | (G << 8) | R;
  2256. *dst = pixel;
  2257. posx += incx;
  2258. ++dst;
  2259. }
  2260. posy += incy;
  2261. info->dst += info->dst_pitch;
  2262. }
  2263. }
  2264. static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  2265. {
  2266. const int flags = info->flags;
  2267. const Uint32 modulateR = info->r;
  2268. const Uint32 modulateG = info->g;
  2269. const Uint32 modulateB = info->b;
  2270. const Uint32 modulateA = info->a;
  2271. Uint32 srcpixel;
  2272. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2273. Uint32 srcR, srcG, srcB;
  2274. Uint32 dstpixel;
  2275. Uint32 dstR, dstG, dstB;
  2276. while (info->dst_h--) {
  2277. Uint32 *src = (Uint32 *)info->src;
  2278. Uint32 *dst = (Uint32 *)info->dst;
  2279. int n = info->dst_w;
  2280. while (n--) {
  2281. srcpixel = *src;
  2282. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2283. dstpixel = *dst;
  2284. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2285. if (flags & SDL_COPY_MODULATE_COLOR) {
  2286. MULT_DIV_255(srcR, modulateR, srcR);
  2287. MULT_DIV_255(srcG, modulateG, srcG);
  2288. MULT_DIV_255(srcB, modulateB, srcB);
  2289. }
  2290. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2291. if (srcA < 255) {
  2292. MULT_DIV_255(srcR, srcA, srcR);
  2293. MULT_DIV_255(srcG, srcA, srcG);
  2294. MULT_DIV_255(srcB, srcA, srcB);
  2295. }
  2296. }
  2297. switch (flags & SDL_COPY_BLEND_MASK) {
  2298. case SDL_COPY_BLEND:
  2299. MULT_DIV_255((255 - srcA), dstR, dstR);
  2300. dstR += srcR;
  2301. MULT_DIV_255((255 - srcA), dstG, dstG);
  2302. dstG += srcG;
  2303. MULT_DIV_255((255 - srcA), dstB, dstB);
  2304. dstB += srcB;
  2305. break;
  2306. case SDL_COPY_BLEND_PREMULTIPLIED:
  2307. MULT_DIV_255((255 - srcA), dstR, dstR);
  2308. dstR += srcR;
  2309. if (dstR > 255) dstR = 255;
  2310. MULT_DIV_255((255 - srcA), dstG, dstG);
  2311. dstG += srcG;
  2312. if (dstG > 255) dstG = 255;
  2313. MULT_DIV_255((255 - srcA), dstB, dstB);
  2314. dstB += srcB;
  2315. if (dstB > 255) dstB = 255;
  2316. break;
  2317. case SDL_COPY_ADD:
  2318. case SDL_COPY_ADD_PREMULTIPLIED:
  2319. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2320. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2321. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2322. break;
  2323. case SDL_COPY_MOD:
  2324. MULT_DIV_255(srcR, dstR, dstR);
  2325. MULT_DIV_255(srcG, dstG, dstG);
  2326. MULT_DIV_255(srcB, dstB, dstB);
  2327. break;
  2328. case SDL_COPY_MUL:
  2329. {
  2330. Uint32 tmp1, tmp2;
  2331. MULT_DIV_255(srcR, dstR, tmp1);
  2332. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2333. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2334. MULT_DIV_255(srcG, dstG, tmp1);
  2335. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2336. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2337. MULT_DIV_255(srcB, dstB, tmp1);
  2338. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2339. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2340. }
  2341. break;
  2342. }
  2343. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2344. *dst = dstpixel;
  2345. ++src;
  2346. ++dst;
  2347. }
  2348. info->src += info->src_pitch;
  2349. info->dst += info->dst_pitch;
  2350. }
  2351. }
  2352. static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  2353. {
  2354. const int flags = info->flags;
  2355. const Uint32 modulateR = info->r;
  2356. const Uint32 modulateG = info->g;
  2357. const Uint32 modulateB = info->b;
  2358. const Uint32 modulateA = info->a;
  2359. Uint32 srcpixel;
  2360. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2361. Uint32 srcR, srcG, srcB;
  2362. Uint32 dstpixel;
  2363. Uint32 dstR, dstG, dstB;
  2364. Uint64 srcy, srcx;
  2365. Uint64 posy, posx;
  2366. Uint64 incy, incx;
  2367. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2368. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2369. posy = incy / 2;
  2370. while (info->dst_h--) {
  2371. Uint32 *src = 0;
  2372. Uint32 *dst = (Uint32 *)info->dst;
  2373. int n = info->dst_w;
  2374. posx = incx / 2;
  2375. srcy = posy >> 16;
  2376. while (n--) {
  2377. srcx = posx >> 16;
  2378. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2379. srcpixel = *src;
  2380. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2381. dstpixel = *dst;
  2382. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2383. if (flags & SDL_COPY_MODULATE_COLOR) {
  2384. MULT_DIV_255(srcR, modulateR, srcR);
  2385. MULT_DIV_255(srcG, modulateG, srcG);
  2386. MULT_DIV_255(srcB, modulateB, srcB);
  2387. }
  2388. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2389. if (srcA < 255) {
  2390. MULT_DIV_255(srcR, srcA, srcR);
  2391. MULT_DIV_255(srcG, srcA, srcG);
  2392. MULT_DIV_255(srcB, srcA, srcB);
  2393. }
  2394. }
  2395. switch (flags & SDL_COPY_BLEND_MASK) {
  2396. case SDL_COPY_BLEND:
  2397. MULT_DIV_255((255 - srcA), dstR, dstR);
  2398. dstR += srcR;
  2399. MULT_DIV_255((255 - srcA), dstG, dstG);
  2400. dstG += srcG;
  2401. MULT_DIV_255((255 - srcA), dstB, dstB);
  2402. dstB += srcB;
  2403. break;
  2404. case SDL_COPY_BLEND_PREMULTIPLIED:
  2405. MULT_DIV_255((255 - srcA), dstR, dstR);
  2406. dstR += srcR;
  2407. if (dstR > 255) dstR = 255;
  2408. MULT_DIV_255((255 - srcA), dstG, dstG);
  2409. dstG += srcG;
  2410. if (dstG > 255) dstG = 255;
  2411. MULT_DIV_255((255 - srcA), dstB, dstB);
  2412. dstB += srcB;
  2413. if (dstB > 255) dstB = 255;
  2414. break;
  2415. case SDL_COPY_ADD:
  2416. case SDL_COPY_ADD_PREMULTIPLIED:
  2417. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2418. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2419. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2420. break;
  2421. case SDL_COPY_MOD:
  2422. MULT_DIV_255(srcR, dstR, dstR);
  2423. MULT_DIV_255(srcG, dstG, dstG);
  2424. MULT_DIV_255(srcB, dstB, dstB);
  2425. break;
  2426. case SDL_COPY_MUL:
  2427. {
  2428. Uint32 tmp1, tmp2;
  2429. MULT_DIV_255(srcR, dstR, tmp1);
  2430. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2431. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2432. MULT_DIV_255(srcG, dstG, tmp1);
  2433. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2434. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2435. MULT_DIV_255(srcB, dstB, tmp1);
  2436. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2437. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2438. }
  2439. break;
  2440. }
  2441. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2442. *dst = dstpixel;
  2443. posx += incx;
  2444. ++dst;
  2445. }
  2446. posy += incy;
  2447. info->dst += info->dst_pitch;
  2448. }
  2449. }
  2450. static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
  2451. {
  2452. Uint32 pixel;
  2453. const Uint32 A = 0xFF;
  2454. Uint32 R, G, B;
  2455. Uint64 srcy, srcx;
  2456. Uint64 posy, posx;
  2457. Uint64 incy, incx;
  2458. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2459. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2460. posy = incy / 2;
  2461. while (info->dst_h--) {
  2462. Uint32 *src = 0;
  2463. Uint32 *dst = (Uint32 *)info->dst;
  2464. int n = info->dst_w;
  2465. posx = incx / 2;
  2466. srcy = posy >> 16;
  2467. while (n--) {
  2468. srcx = posx >> 16;
  2469. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2470. pixel = *src;
  2471. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2472. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  2473. *dst = pixel;
  2474. posx += incx;
  2475. ++dst;
  2476. }
  2477. posy += incy;
  2478. info->dst += info->dst_pitch;
  2479. }
  2480. }
  2481. static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
  2482. {
  2483. const int flags = info->flags;
  2484. Uint32 srcpixel;
  2485. Uint32 srcR, srcG, srcB;
  2486. Uint32 dstpixel;
  2487. Uint32 dstR, dstG, dstB, dstA;
  2488. while (info->dst_h--) {
  2489. Uint32 *src = (Uint32 *)info->src;
  2490. Uint32 *dst = (Uint32 *)info->dst;
  2491. int n = info->dst_w;
  2492. while (n--) {
  2493. srcpixel = *src;
  2494. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2495. dstpixel = *dst;
  2496. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2497. switch (flags & SDL_COPY_BLEND_MASK) {
  2498. case SDL_COPY_BLEND:
  2499. dstR = srcR;
  2500. dstG = srcG;
  2501. dstB = srcB;
  2502. dstA = 0xFF;
  2503. break;
  2504. case SDL_COPY_BLEND_PREMULTIPLIED:
  2505. dstR = srcR;
  2506. dstG = srcG;
  2507. dstB = srcB;
  2508. dstA = 0xFF;
  2509. break;
  2510. case SDL_COPY_ADD:
  2511. case SDL_COPY_ADD_PREMULTIPLIED:
  2512. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2513. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2514. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2515. break;
  2516. case SDL_COPY_MOD:
  2517. MULT_DIV_255(srcR, dstR, dstR);
  2518. MULT_DIV_255(srcG, dstG, dstG);
  2519. MULT_DIV_255(srcB, dstB, dstB);
  2520. break;
  2521. case SDL_COPY_MUL:
  2522. MULT_DIV_255(srcR, dstR, dstR);
  2523. MULT_DIV_255(srcG, dstG, dstG);
  2524. MULT_DIV_255(srcB, dstB, dstB);
  2525. break;
  2526. }
  2527. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2528. *dst = dstpixel;
  2529. ++src;
  2530. ++dst;
  2531. }
  2532. info->src += info->src_pitch;
  2533. info->dst += info->dst_pitch;
  2534. }
  2535. }
  2536. static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  2537. {
  2538. const int flags = info->flags;
  2539. Uint32 srcpixel;
  2540. Uint32 srcR, srcG, srcB;
  2541. Uint32 dstpixel;
  2542. Uint32 dstR, dstG, dstB, dstA;
  2543. Uint64 srcy, srcx;
  2544. Uint64 posy, posx;
  2545. Uint64 incy, incx;
  2546. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2547. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2548. posy = incy / 2;
  2549. while (info->dst_h--) {
  2550. Uint32 *src = 0;
  2551. Uint32 *dst = (Uint32 *)info->dst;
  2552. int n = info->dst_w;
  2553. posx = incx / 2;
  2554. srcy = posy >> 16;
  2555. while (n--) {
  2556. srcx = posx >> 16;
  2557. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2558. srcpixel = *src;
  2559. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2560. dstpixel = *dst;
  2561. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2562. switch (flags & SDL_COPY_BLEND_MASK) {
  2563. case SDL_COPY_BLEND:
  2564. dstR = srcR;
  2565. dstG = srcG;
  2566. dstB = srcB;
  2567. dstA = 0xFF;
  2568. break;
  2569. case SDL_COPY_BLEND_PREMULTIPLIED:
  2570. dstR = srcR;
  2571. dstG = srcG;
  2572. dstB = srcB;
  2573. dstA = 0xFF;
  2574. break;
  2575. case SDL_COPY_ADD:
  2576. case SDL_COPY_ADD_PREMULTIPLIED:
  2577. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2578. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2579. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2580. break;
  2581. case SDL_COPY_MOD:
  2582. MULT_DIV_255(srcR, dstR, dstR);
  2583. MULT_DIV_255(srcG, dstG, dstG);
  2584. MULT_DIV_255(srcB, dstB, dstB);
  2585. break;
  2586. case SDL_COPY_MUL:
  2587. MULT_DIV_255(srcR, dstR, dstR);
  2588. MULT_DIV_255(srcG, dstG, dstG);
  2589. MULT_DIV_255(srcB, dstB, dstB);
  2590. break;
  2591. }
  2592. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2593. *dst = dstpixel;
  2594. posx += incx;
  2595. ++dst;
  2596. }
  2597. posy += incy;
  2598. info->dst += info->dst_pitch;
  2599. }
  2600. }
  2601. static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  2602. {
  2603. const int flags = info->flags;
  2604. const Uint32 modulateR = info->r;
  2605. const Uint32 modulateG = info->g;
  2606. const Uint32 modulateB = info->b;
  2607. const Uint32 modulateA = info->a;
  2608. Uint32 pixel;
  2609. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2610. Uint32 R, G, B;
  2611. while (info->dst_h--) {
  2612. Uint32 *src = (Uint32 *)info->src;
  2613. Uint32 *dst = (Uint32 *)info->dst;
  2614. int n = info->dst_w;
  2615. while (n--) {
  2616. pixel = *src;
  2617. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2618. if (flags & SDL_COPY_MODULATE_COLOR) {
  2619. MULT_DIV_255(R, modulateR, R);
  2620. MULT_DIV_255(G, modulateG, G);
  2621. MULT_DIV_255(B, modulateB, B);
  2622. }
  2623. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  2624. *dst = pixel;
  2625. ++src;
  2626. ++dst;
  2627. }
  2628. info->src += info->src_pitch;
  2629. info->dst += info->dst_pitch;
  2630. }
  2631. }
  2632. static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  2633. {
  2634. const int flags = info->flags;
  2635. const Uint32 modulateR = info->r;
  2636. const Uint32 modulateG = info->g;
  2637. const Uint32 modulateB = info->b;
  2638. const Uint32 modulateA = info->a;
  2639. Uint32 pixel;
  2640. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2641. Uint32 R, G, B;
  2642. Uint64 srcy, srcx;
  2643. Uint64 posy, posx;
  2644. Uint64 incy, incx;
  2645. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2646. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2647. posy = incy / 2;
  2648. while (info->dst_h--) {
  2649. Uint32 *src = 0;
  2650. Uint32 *dst = (Uint32 *)info->dst;
  2651. int n = info->dst_w;
  2652. posx = incx / 2;
  2653. srcy = posy >> 16;
  2654. while (n--) {
  2655. srcx = posx >> 16;
  2656. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2657. pixel = *src;
  2658. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2659. if (flags & SDL_COPY_MODULATE_COLOR) {
  2660. MULT_DIV_255(R, modulateR, R);
  2661. MULT_DIV_255(G, modulateG, G);
  2662. MULT_DIV_255(B, modulateB, B);
  2663. }
  2664. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  2665. *dst = pixel;
  2666. posx += incx;
  2667. ++dst;
  2668. }
  2669. posy += incy;
  2670. info->dst += info->dst_pitch;
  2671. }
  2672. }
  2673. static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  2674. {
  2675. const int flags = info->flags;
  2676. const Uint32 modulateR = info->r;
  2677. const Uint32 modulateG = info->g;
  2678. const Uint32 modulateB = info->b;
  2679. const Uint32 modulateA = info->a;
  2680. Uint32 srcpixel;
  2681. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2682. Uint32 srcR, srcG, srcB;
  2683. Uint32 dstpixel;
  2684. Uint32 dstR, dstG, dstB, dstA;
  2685. while (info->dst_h--) {
  2686. Uint32 *src = (Uint32 *)info->src;
  2687. Uint32 *dst = (Uint32 *)info->dst;
  2688. int n = info->dst_w;
  2689. while (n--) {
  2690. srcpixel = *src;
  2691. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2692. dstpixel = *dst;
  2693. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2694. if (flags & SDL_COPY_MODULATE_COLOR) {
  2695. MULT_DIV_255(srcR, modulateR, srcR);
  2696. MULT_DIV_255(srcG, modulateG, srcG);
  2697. MULT_DIV_255(srcB, modulateB, srcB);
  2698. }
  2699. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2700. if (srcA < 255) {
  2701. MULT_DIV_255(srcR, srcA, srcR);
  2702. MULT_DIV_255(srcG, srcA, srcG);
  2703. MULT_DIV_255(srcB, srcA, srcB);
  2704. }
  2705. }
  2706. switch (flags & SDL_COPY_BLEND_MASK) {
  2707. case SDL_COPY_BLEND:
  2708. MULT_DIV_255((255 - srcA), dstR, dstR);
  2709. dstR += srcR;
  2710. MULT_DIV_255((255 - srcA), dstG, dstG);
  2711. dstG += srcG;
  2712. MULT_DIV_255((255 - srcA), dstB, dstB);
  2713. dstB += srcB;
  2714. MULT_DIV_255((255 - srcA), dstA, dstA);
  2715. dstA += srcA;
  2716. break;
  2717. case SDL_COPY_BLEND_PREMULTIPLIED:
  2718. MULT_DIV_255((255 - srcA), dstR, dstR);
  2719. dstR += srcR;
  2720. if (dstR > 255) dstR = 255;
  2721. MULT_DIV_255((255 - srcA), dstG, dstG);
  2722. dstG += srcG;
  2723. if (dstG > 255) dstG = 255;
  2724. MULT_DIV_255((255 - srcA), dstB, dstB);
  2725. dstB += srcB;
  2726. if (dstB > 255) dstB = 255;
  2727. MULT_DIV_255((255 - srcA), dstA, dstA);
  2728. dstA += srcA;
  2729. if (dstA > 255) dstA = 255;
  2730. break;
  2731. case SDL_COPY_ADD:
  2732. case SDL_COPY_ADD_PREMULTIPLIED:
  2733. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2734. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2735. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2736. break;
  2737. case SDL_COPY_MOD:
  2738. MULT_DIV_255(srcR, dstR, dstR);
  2739. MULT_DIV_255(srcG, dstG, dstG);
  2740. MULT_DIV_255(srcB, dstB, dstB);
  2741. break;
  2742. case SDL_COPY_MUL:
  2743. {
  2744. Uint32 tmp1, tmp2;
  2745. MULT_DIV_255(srcR, dstR, tmp1);
  2746. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2747. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2748. MULT_DIV_255(srcG, dstG, tmp1);
  2749. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2750. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2751. MULT_DIV_255(srcB, dstB, tmp1);
  2752. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2753. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2754. }
  2755. break;
  2756. }
  2757. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2758. *dst = dstpixel;
  2759. ++src;
  2760. ++dst;
  2761. }
  2762. info->src += info->src_pitch;
  2763. info->dst += info->dst_pitch;
  2764. }
  2765. }
  2766. static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  2767. {
  2768. const int flags = info->flags;
  2769. const Uint32 modulateR = info->r;
  2770. const Uint32 modulateG = info->g;
  2771. const Uint32 modulateB = info->b;
  2772. const Uint32 modulateA = info->a;
  2773. Uint32 srcpixel;
  2774. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2775. Uint32 srcR, srcG, srcB;
  2776. Uint32 dstpixel;
  2777. Uint32 dstR, dstG, dstB, dstA;
  2778. Uint64 srcy, srcx;
  2779. Uint64 posy, posx;
  2780. Uint64 incy, incx;
  2781. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2782. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2783. posy = incy / 2;
  2784. while (info->dst_h--) {
  2785. Uint32 *src = 0;
  2786. Uint32 *dst = (Uint32 *)info->dst;
  2787. int n = info->dst_w;
  2788. posx = incx / 2;
  2789. srcy = posy >> 16;
  2790. while (n--) {
  2791. srcx = posx >> 16;
  2792. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2793. srcpixel = *src;
  2794. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2795. dstpixel = *dst;
  2796. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2797. if (flags & SDL_COPY_MODULATE_COLOR) {
  2798. MULT_DIV_255(srcR, modulateR, srcR);
  2799. MULT_DIV_255(srcG, modulateG, srcG);
  2800. MULT_DIV_255(srcB, modulateB, srcB);
  2801. }
  2802. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2803. if (srcA < 255) {
  2804. MULT_DIV_255(srcR, srcA, srcR);
  2805. MULT_DIV_255(srcG, srcA, srcG);
  2806. MULT_DIV_255(srcB, srcA, srcB);
  2807. }
  2808. }
  2809. switch (flags & SDL_COPY_BLEND_MASK) {
  2810. case SDL_COPY_BLEND:
  2811. MULT_DIV_255((255 - srcA), dstR, dstR);
  2812. dstR += srcR;
  2813. MULT_DIV_255((255 - srcA), dstG, dstG);
  2814. dstG += srcG;
  2815. MULT_DIV_255((255 - srcA), dstB, dstB);
  2816. dstB += srcB;
  2817. MULT_DIV_255((255 - srcA), dstA, dstA);
  2818. dstA += srcA;
  2819. break;
  2820. case SDL_COPY_BLEND_PREMULTIPLIED:
  2821. MULT_DIV_255((255 - srcA), dstR, dstR);
  2822. dstR += srcR;
  2823. if (dstR > 255) dstR = 255;
  2824. MULT_DIV_255((255 - srcA), dstG, dstG);
  2825. dstG += srcG;
  2826. if (dstG > 255) dstG = 255;
  2827. MULT_DIV_255((255 - srcA), dstB, dstB);
  2828. dstB += srcB;
  2829. if (dstB > 255) dstB = 255;
  2830. MULT_DIV_255((255 - srcA), dstA, dstA);
  2831. dstA += srcA;
  2832. if (dstA > 255) dstA = 255;
  2833. break;
  2834. case SDL_COPY_ADD:
  2835. case SDL_COPY_ADD_PREMULTIPLIED:
  2836. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2837. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2838. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2839. break;
  2840. case SDL_COPY_MOD:
  2841. MULT_DIV_255(srcR, dstR, dstR);
  2842. MULT_DIV_255(srcG, dstG, dstG);
  2843. MULT_DIV_255(srcB, dstB, dstB);
  2844. break;
  2845. case SDL_COPY_MUL:
  2846. {
  2847. Uint32 tmp1, tmp2;
  2848. MULT_DIV_255(srcR, dstR, tmp1);
  2849. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2850. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2851. MULT_DIV_255(srcG, dstG, tmp1);
  2852. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2853. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2854. MULT_DIV_255(srcB, dstB, tmp1);
  2855. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2856. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2857. }
  2858. break;
  2859. }
  2860. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2861. *dst = dstpixel;
  2862. posx += incx;
  2863. ++dst;
  2864. }
  2865. posy += incy;
  2866. info->dst += info->dst_pitch;
  2867. }
  2868. }
  2869. static void SDL_Blit_XBGR8888_ABGR8888_Scale(SDL_BlitInfo *info)
  2870. {
  2871. Uint32 pixel;
  2872. const Uint32 A = 0xFF;
  2873. Uint64 srcy, srcx;
  2874. Uint64 posy, posx;
  2875. Uint64 incy, incx;
  2876. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2877. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2878. posy = incy / 2;
  2879. while (info->dst_h--) {
  2880. Uint32 *src = 0;
  2881. Uint32 *dst = (Uint32 *)info->dst;
  2882. int n = info->dst_w;
  2883. posx = incx / 2;
  2884. srcy = posy >> 16;
  2885. while (n--) {
  2886. srcx = posx >> 16;
  2887. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2888. pixel = *src;
  2889. pixel |= (A << 24);
  2890. *dst = pixel;
  2891. posx += incx;
  2892. ++dst;
  2893. }
  2894. posy += incy;
  2895. info->dst += info->dst_pitch;
  2896. }
  2897. }
  2898. static void SDL_Blit_XBGR8888_ABGR8888_Blend(SDL_BlitInfo *info)
  2899. {
  2900. const int flags = info->flags;
  2901. Uint32 srcpixel;
  2902. Uint32 srcR, srcG, srcB;
  2903. Uint32 dstpixel;
  2904. Uint32 dstR, dstG, dstB, dstA;
  2905. while (info->dst_h--) {
  2906. Uint32 *src = (Uint32 *)info->src;
  2907. Uint32 *dst = (Uint32 *)info->dst;
  2908. int n = info->dst_w;
  2909. while (n--) {
  2910. srcpixel = *src;
  2911. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2912. dstpixel = *dst;
  2913. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2914. switch (flags & SDL_COPY_BLEND_MASK) {
  2915. case SDL_COPY_BLEND:
  2916. dstR = srcR;
  2917. dstG = srcG;
  2918. dstB = srcB;
  2919. dstA = 0xFF;
  2920. break;
  2921. case SDL_COPY_BLEND_PREMULTIPLIED:
  2922. dstR = srcR;
  2923. dstG = srcG;
  2924. dstB = srcB;
  2925. dstA = 0xFF;
  2926. break;
  2927. case SDL_COPY_ADD:
  2928. case SDL_COPY_ADD_PREMULTIPLIED:
  2929. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2930. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2931. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2932. break;
  2933. case SDL_COPY_MOD:
  2934. MULT_DIV_255(srcR, dstR, dstR);
  2935. MULT_DIV_255(srcG, dstG, dstG);
  2936. MULT_DIV_255(srcB, dstB, dstB);
  2937. break;
  2938. case SDL_COPY_MUL:
  2939. MULT_DIV_255(srcR, dstR, dstR);
  2940. MULT_DIV_255(srcG, dstG, dstG);
  2941. MULT_DIV_255(srcB, dstB, dstB);
  2942. break;
  2943. }
  2944. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  2945. *dst = dstpixel;
  2946. ++src;
  2947. ++dst;
  2948. }
  2949. info->src += info->src_pitch;
  2950. info->dst += info->dst_pitch;
  2951. }
  2952. }
  2953. static void SDL_Blit_XBGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  2954. {
  2955. const int flags = info->flags;
  2956. Uint32 srcpixel;
  2957. Uint32 srcR, srcG, srcB;
  2958. Uint32 dstpixel;
  2959. Uint32 dstR, dstG, dstB, dstA;
  2960. Uint64 srcy, srcx;
  2961. Uint64 posy, posx;
  2962. Uint64 incy, incx;
  2963. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2964. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2965. posy = incy / 2;
  2966. while (info->dst_h--) {
  2967. Uint32 *src = 0;
  2968. Uint32 *dst = (Uint32 *)info->dst;
  2969. int n = info->dst_w;
  2970. posx = incx / 2;
  2971. srcy = posy >> 16;
  2972. while (n--) {
  2973. srcx = posx >> 16;
  2974. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2975. srcpixel = *src;
  2976. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2977. dstpixel = *dst;
  2978. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2979. switch (flags & SDL_COPY_BLEND_MASK) {
  2980. case SDL_COPY_BLEND:
  2981. dstR = srcR;
  2982. dstG = srcG;
  2983. dstB = srcB;
  2984. dstA = 0xFF;
  2985. break;
  2986. case SDL_COPY_BLEND_PREMULTIPLIED:
  2987. dstR = srcR;
  2988. dstG = srcG;
  2989. dstB = srcB;
  2990. dstA = 0xFF;
  2991. break;
  2992. case SDL_COPY_ADD:
  2993. case SDL_COPY_ADD_PREMULTIPLIED:
  2994. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2995. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2996. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2997. break;
  2998. case SDL_COPY_MOD:
  2999. MULT_DIV_255(srcR, dstR, dstR);
  3000. MULT_DIV_255(srcG, dstG, dstG);
  3001. MULT_DIV_255(srcB, dstB, dstB);
  3002. break;
  3003. case SDL_COPY_MUL:
  3004. MULT_DIV_255(srcR, dstR, dstR);
  3005. MULT_DIV_255(srcG, dstG, dstG);
  3006. MULT_DIV_255(srcB, dstB, dstB);
  3007. break;
  3008. }
  3009. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  3010. *dst = dstpixel;
  3011. posx += incx;
  3012. ++dst;
  3013. }
  3014. posy += incy;
  3015. info->dst += info->dst_pitch;
  3016. }
  3017. }
  3018. static void SDL_Blit_XBGR8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  3019. {
  3020. const int flags = info->flags;
  3021. const Uint32 modulateR = info->r;
  3022. const Uint32 modulateG = info->g;
  3023. const Uint32 modulateB = info->b;
  3024. const Uint32 modulateA = info->a;
  3025. Uint32 pixel;
  3026. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  3027. Uint32 R, G, B;
  3028. while (info->dst_h--) {
  3029. Uint32 *src = (Uint32 *)info->src;
  3030. Uint32 *dst = (Uint32 *)info->dst;
  3031. int n = info->dst_w;
  3032. while (n--) {
  3033. pixel = *src;
  3034. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3035. if (flags & SDL_COPY_MODULATE_COLOR) {
  3036. MULT_DIV_255(R, modulateR, R);
  3037. MULT_DIV_255(G, modulateG, G);
  3038. MULT_DIV_255(B, modulateB, B);
  3039. }
  3040. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  3041. *dst = pixel;
  3042. ++src;
  3043. ++dst;
  3044. }
  3045. info->src += info->src_pitch;
  3046. info->dst += info->dst_pitch;
  3047. }
  3048. }
  3049. static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  3050. {
  3051. const int flags = info->flags;
  3052. const Uint32 modulateR = info->r;
  3053. const Uint32 modulateG = info->g;
  3054. const Uint32 modulateB = info->b;
  3055. const Uint32 modulateA = info->a;
  3056. Uint32 pixel;
  3057. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  3058. Uint32 R, G, B;
  3059. Uint64 srcy, srcx;
  3060. Uint64 posy, posx;
  3061. Uint64 incy, incx;
  3062. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3063. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3064. posy = incy / 2;
  3065. while (info->dst_h--) {
  3066. Uint32 *src = 0;
  3067. Uint32 *dst = (Uint32 *)info->dst;
  3068. int n = info->dst_w;
  3069. posx = incx / 2;
  3070. srcy = posy >> 16;
  3071. while (n--) {
  3072. srcx = posx >> 16;
  3073. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3074. pixel = *src;
  3075. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3076. if (flags & SDL_COPY_MODULATE_COLOR) {
  3077. MULT_DIV_255(R, modulateR, R);
  3078. MULT_DIV_255(G, modulateG, G);
  3079. MULT_DIV_255(B, modulateB, B);
  3080. }
  3081. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  3082. *dst = pixel;
  3083. posx += incx;
  3084. ++dst;
  3085. }
  3086. posy += incy;
  3087. info->dst += info->dst_pitch;
  3088. }
  3089. }
  3090. static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  3091. {
  3092. const int flags = info->flags;
  3093. const Uint32 modulateR = info->r;
  3094. const Uint32 modulateG = info->g;
  3095. const Uint32 modulateB = info->b;
  3096. const Uint32 modulateA = info->a;
  3097. Uint32 srcpixel;
  3098. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  3099. Uint32 srcR, srcG, srcB;
  3100. Uint32 dstpixel;
  3101. Uint32 dstR, dstG, dstB, dstA;
  3102. while (info->dst_h--) {
  3103. Uint32 *src = (Uint32 *)info->src;
  3104. Uint32 *dst = (Uint32 *)info->dst;
  3105. int n = info->dst_w;
  3106. while (n--) {
  3107. srcpixel = *src;
  3108. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3109. dstpixel = *dst;
  3110. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  3111. if (flags & SDL_COPY_MODULATE_COLOR) {
  3112. MULT_DIV_255(srcR, modulateR, srcR);
  3113. MULT_DIV_255(srcG, modulateG, srcG);
  3114. MULT_DIV_255(srcB, modulateB, srcB);
  3115. }
  3116. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3117. if (srcA < 255) {
  3118. MULT_DIV_255(srcR, srcA, srcR);
  3119. MULT_DIV_255(srcG, srcA, srcG);
  3120. MULT_DIV_255(srcB, srcA, srcB);
  3121. }
  3122. }
  3123. switch (flags & SDL_COPY_BLEND_MASK) {
  3124. case SDL_COPY_BLEND:
  3125. MULT_DIV_255((255 - srcA), dstR, dstR);
  3126. dstR += srcR;
  3127. MULT_DIV_255((255 - srcA), dstG, dstG);
  3128. dstG += srcG;
  3129. MULT_DIV_255((255 - srcA), dstB, dstB);
  3130. dstB += srcB;
  3131. MULT_DIV_255((255 - srcA), dstA, dstA);
  3132. dstA += srcA;
  3133. break;
  3134. case SDL_COPY_BLEND_PREMULTIPLIED:
  3135. MULT_DIV_255((255 - srcA), dstR, dstR);
  3136. dstR += srcR;
  3137. if (dstR > 255) dstR = 255;
  3138. MULT_DIV_255((255 - srcA), dstG, dstG);
  3139. dstG += srcG;
  3140. if (dstG > 255) dstG = 255;
  3141. MULT_DIV_255((255 - srcA), dstB, dstB);
  3142. dstB += srcB;
  3143. if (dstB > 255) dstB = 255;
  3144. MULT_DIV_255((255 - srcA), dstA, dstA);
  3145. dstA += srcA;
  3146. if (dstA > 255) dstA = 255;
  3147. break;
  3148. case SDL_COPY_ADD:
  3149. case SDL_COPY_ADD_PREMULTIPLIED:
  3150. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3151. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3152. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3153. break;
  3154. case SDL_COPY_MOD:
  3155. MULT_DIV_255(srcR, dstR, dstR);
  3156. MULT_DIV_255(srcG, dstG, dstG);
  3157. MULT_DIV_255(srcB, dstB, dstB);
  3158. break;
  3159. case SDL_COPY_MUL:
  3160. {
  3161. Uint32 tmp1, tmp2;
  3162. MULT_DIV_255(srcR, dstR, tmp1);
  3163. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3164. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3165. MULT_DIV_255(srcG, dstG, tmp1);
  3166. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3167. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3168. MULT_DIV_255(srcB, dstB, tmp1);
  3169. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3170. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3171. }
  3172. break;
  3173. }
  3174. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  3175. *dst = dstpixel;
  3176. ++src;
  3177. ++dst;
  3178. }
  3179. info->src += info->src_pitch;
  3180. info->dst += info->dst_pitch;
  3181. }
  3182. }
  3183. static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3184. {
  3185. const int flags = info->flags;
  3186. const Uint32 modulateR = info->r;
  3187. const Uint32 modulateG = info->g;
  3188. const Uint32 modulateB = info->b;
  3189. const Uint32 modulateA = info->a;
  3190. Uint32 srcpixel;
  3191. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  3192. Uint32 srcR, srcG, srcB;
  3193. Uint32 dstpixel;
  3194. Uint32 dstR, dstG, dstB, dstA;
  3195. Uint64 srcy, srcx;
  3196. Uint64 posy, posx;
  3197. Uint64 incy, incx;
  3198. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3199. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3200. posy = incy / 2;
  3201. while (info->dst_h--) {
  3202. Uint32 *src = 0;
  3203. Uint32 *dst = (Uint32 *)info->dst;
  3204. int n = info->dst_w;
  3205. posx = incx / 2;
  3206. srcy = posy >> 16;
  3207. while (n--) {
  3208. srcx = posx >> 16;
  3209. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3210. srcpixel = *src;
  3211. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3212. dstpixel = *dst;
  3213. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  3214. if (flags & SDL_COPY_MODULATE_COLOR) {
  3215. MULT_DIV_255(srcR, modulateR, srcR);
  3216. MULT_DIV_255(srcG, modulateG, srcG);
  3217. MULT_DIV_255(srcB, modulateB, srcB);
  3218. }
  3219. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3220. if (srcA < 255) {
  3221. MULT_DIV_255(srcR, srcA, srcR);
  3222. MULT_DIV_255(srcG, srcA, srcG);
  3223. MULT_DIV_255(srcB, srcA, srcB);
  3224. }
  3225. }
  3226. switch (flags & SDL_COPY_BLEND_MASK) {
  3227. case SDL_COPY_BLEND:
  3228. MULT_DIV_255((255 - srcA), dstR, dstR);
  3229. dstR += srcR;
  3230. MULT_DIV_255((255 - srcA), dstG, dstG);
  3231. dstG += srcG;
  3232. MULT_DIV_255((255 - srcA), dstB, dstB);
  3233. dstB += srcB;
  3234. MULT_DIV_255((255 - srcA), dstA, dstA);
  3235. dstA += srcA;
  3236. break;
  3237. case SDL_COPY_BLEND_PREMULTIPLIED:
  3238. MULT_DIV_255((255 - srcA), dstR, dstR);
  3239. dstR += srcR;
  3240. if (dstR > 255) dstR = 255;
  3241. MULT_DIV_255((255 - srcA), dstG, dstG);
  3242. dstG += srcG;
  3243. if (dstG > 255) dstG = 255;
  3244. MULT_DIV_255((255 - srcA), dstB, dstB);
  3245. dstB += srcB;
  3246. if (dstB > 255) dstB = 255;
  3247. MULT_DIV_255((255 - srcA), dstA, dstA);
  3248. dstA += srcA;
  3249. if (dstA > 255) dstA = 255;
  3250. break;
  3251. case SDL_COPY_ADD:
  3252. case SDL_COPY_ADD_PREMULTIPLIED:
  3253. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3254. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3255. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3256. break;
  3257. case SDL_COPY_MOD:
  3258. MULT_DIV_255(srcR, dstR, dstR);
  3259. MULT_DIV_255(srcG, dstG, dstG);
  3260. MULT_DIV_255(srcB, dstB, dstB);
  3261. break;
  3262. case SDL_COPY_MUL:
  3263. {
  3264. Uint32 tmp1, tmp2;
  3265. MULT_DIV_255(srcR, dstR, tmp1);
  3266. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3267. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3268. MULT_DIV_255(srcG, dstG, tmp1);
  3269. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3270. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3271. MULT_DIV_255(srcB, dstB, tmp1);
  3272. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3273. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3274. }
  3275. break;
  3276. }
  3277. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  3278. *dst = dstpixel;
  3279. posx += incx;
  3280. ++dst;
  3281. }
  3282. posy += incy;
  3283. info->dst += info->dst_pitch;
  3284. }
  3285. }
  3286. static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
  3287. {
  3288. Uint32 pixel;
  3289. Uint64 srcy, srcx;
  3290. Uint64 posy, posx;
  3291. Uint64 incy, incx;
  3292. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3293. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3294. posy = incy / 2;
  3295. while (info->dst_h--) {
  3296. Uint32 *src = 0;
  3297. Uint32 *dst = (Uint32 *)info->dst;
  3298. int n = info->dst_w;
  3299. posx = incx / 2;
  3300. srcy = posy >> 16;
  3301. while (n--) {
  3302. srcx = posx >> 16;
  3303. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3304. pixel = *src;
  3305. pixel &= 0xFFFFFF;
  3306. *dst = pixel;
  3307. posx += incx;
  3308. ++dst;
  3309. }
  3310. posy += incy;
  3311. info->dst += info->dst_pitch;
  3312. }
  3313. }
  3314. static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
  3315. {
  3316. const int flags = info->flags;
  3317. Uint32 srcpixel;
  3318. Uint32 srcR, srcG, srcB, srcA;
  3319. Uint32 dstpixel;
  3320. Uint32 dstR, dstG, dstB;
  3321. while (info->dst_h--) {
  3322. Uint32 *src = (Uint32 *)info->src;
  3323. Uint32 *dst = (Uint32 *)info->dst;
  3324. int n = info->dst_w;
  3325. while (n--) {
  3326. srcpixel = *src;
  3327. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3328. dstpixel = *dst;
  3329. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3330. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3331. if (srcA < 255) {
  3332. MULT_DIV_255(srcR, srcA, srcR);
  3333. MULT_DIV_255(srcG, srcA, srcG);
  3334. MULT_DIV_255(srcB, srcA, srcB);
  3335. }
  3336. }
  3337. switch (flags & SDL_COPY_BLEND_MASK) {
  3338. case SDL_COPY_BLEND:
  3339. MULT_DIV_255((255 - srcA), dstR, dstR);
  3340. dstR += srcR;
  3341. MULT_DIV_255((255 - srcA), dstG, dstG);
  3342. dstG += srcG;
  3343. MULT_DIV_255((255 - srcA), dstB, dstB);
  3344. dstB += srcB;
  3345. break;
  3346. case SDL_COPY_BLEND_PREMULTIPLIED:
  3347. MULT_DIV_255((255 - srcA), dstR, dstR);
  3348. dstR += srcR;
  3349. if (dstR > 255) dstR = 255;
  3350. MULT_DIV_255((255 - srcA), dstG, dstG);
  3351. dstG += srcG;
  3352. if (dstG > 255) dstG = 255;
  3353. MULT_DIV_255((255 - srcA), dstB, dstB);
  3354. dstB += srcB;
  3355. if (dstB > 255) dstB = 255;
  3356. break;
  3357. case SDL_COPY_ADD:
  3358. case SDL_COPY_ADD_PREMULTIPLIED:
  3359. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3360. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3361. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3362. break;
  3363. case SDL_COPY_MOD:
  3364. MULT_DIV_255(srcR, dstR, dstR);
  3365. MULT_DIV_255(srcG, dstG, dstG);
  3366. MULT_DIV_255(srcB, dstB, dstB);
  3367. break;
  3368. case SDL_COPY_MUL:
  3369. {
  3370. Uint32 tmp1, tmp2;
  3371. MULT_DIV_255(srcR, dstR, tmp1);
  3372. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3373. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3374. MULT_DIV_255(srcG, dstG, tmp1);
  3375. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3376. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3377. MULT_DIV_255(srcB, dstB, tmp1);
  3378. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3379. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3380. }
  3381. break;
  3382. }
  3383. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3384. *dst = dstpixel;
  3385. ++src;
  3386. ++dst;
  3387. }
  3388. info->src += info->src_pitch;
  3389. info->dst += info->dst_pitch;
  3390. }
  3391. }
  3392. static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  3393. {
  3394. const int flags = info->flags;
  3395. Uint32 srcpixel;
  3396. Uint32 srcR, srcG, srcB, srcA;
  3397. Uint32 dstpixel;
  3398. Uint32 dstR, dstG, dstB;
  3399. Uint64 srcy, srcx;
  3400. Uint64 posy, posx;
  3401. Uint64 incy, incx;
  3402. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3403. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3404. posy = incy / 2;
  3405. while (info->dst_h--) {
  3406. Uint32 *src = 0;
  3407. Uint32 *dst = (Uint32 *)info->dst;
  3408. int n = info->dst_w;
  3409. posx = incx / 2;
  3410. srcy = posy >> 16;
  3411. while (n--) {
  3412. srcx = posx >> 16;
  3413. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3414. srcpixel = *src;
  3415. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3416. dstpixel = *dst;
  3417. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3418. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3419. if (srcA < 255) {
  3420. MULT_DIV_255(srcR, srcA, srcR);
  3421. MULT_DIV_255(srcG, srcA, srcG);
  3422. MULT_DIV_255(srcB, srcA, srcB);
  3423. }
  3424. }
  3425. switch (flags & SDL_COPY_BLEND_MASK) {
  3426. case SDL_COPY_BLEND:
  3427. MULT_DIV_255((255 - srcA), dstR, dstR);
  3428. dstR += srcR;
  3429. MULT_DIV_255((255 - srcA), dstG, dstG);
  3430. dstG += srcG;
  3431. MULT_DIV_255((255 - srcA), dstB, dstB);
  3432. dstB += srcB;
  3433. break;
  3434. case SDL_COPY_BLEND_PREMULTIPLIED:
  3435. MULT_DIV_255((255 - srcA), dstR, dstR);
  3436. dstR += srcR;
  3437. if (dstR > 255) dstR = 255;
  3438. MULT_DIV_255((255 - srcA), dstG, dstG);
  3439. dstG += srcG;
  3440. if (dstG > 255) dstG = 255;
  3441. MULT_DIV_255((255 - srcA), dstB, dstB);
  3442. dstB += srcB;
  3443. if (dstB > 255) dstB = 255;
  3444. break;
  3445. case SDL_COPY_ADD:
  3446. case SDL_COPY_ADD_PREMULTIPLIED:
  3447. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3448. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3449. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3450. break;
  3451. case SDL_COPY_MOD:
  3452. MULT_DIV_255(srcR, dstR, dstR);
  3453. MULT_DIV_255(srcG, dstG, dstG);
  3454. MULT_DIV_255(srcB, dstB, dstB);
  3455. break;
  3456. case SDL_COPY_MUL:
  3457. {
  3458. Uint32 tmp1, tmp2;
  3459. MULT_DIV_255(srcR, dstR, tmp1);
  3460. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3461. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3462. MULT_DIV_255(srcG, dstG, tmp1);
  3463. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3464. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3465. MULT_DIV_255(srcB, dstB, tmp1);
  3466. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3467. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3468. }
  3469. break;
  3470. }
  3471. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3472. *dst = dstpixel;
  3473. posx += incx;
  3474. ++dst;
  3475. }
  3476. posy += incy;
  3477. info->dst += info->dst_pitch;
  3478. }
  3479. }
  3480. static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  3481. {
  3482. const int flags = info->flags;
  3483. const Uint32 modulateR = info->r;
  3484. const Uint32 modulateG = info->g;
  3485. const Uint32 modulateB = info->b;
  3486. Uint32 pixel;
  3487. Uint32 R, G, B;
  3488. while (info->dst_h--) {
  3489. Uint32 *src = (Uint32 *)info->src;
  3490. Uint32 *dst = (Uint32 *)info->dst;
  3491. int n = info->dst_w;
  3492. while (n--) {
  3493. pixel = *src;
  3494. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3495. if (flags & SDL_COPY_MODULATE_COLOR) {
  3496. MULT_DIV_255(R, modulateR, R);
  3497. MULT_DIV_255(G, modulateG, G);
  3498. MULT_DIV_255(B, modulateB, B);
  3499. }
  3500. pixel = (R << 16) | (G << 8) | B;
  3501. *dst = pixel;
  3502. ++src;
  3503. ++dst;
  3504. }
  3505. info->src += info->src_pitch;
  3506. info->dst += info->dst_pitch;
  3507. }
  3508. }
  3509. static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  3510. {
  3511. const int flags = info->flags;
  3512. const Uint32 modulateR = info->r;
  3513. const Uint32 modulateG = info->g;
  3514. const Uint32 modulateB = info->b;
  3515. Uint32 pixel;
  3516. Uint32 R, G, B;
  3517. Uint64 srcy, srcx;
  3518. Uint64 posy, posx;
  3519. Uint64 incy, incx;
  3520. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3521. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3522. posy = incy / 2;
  3523. while (info->dst_h--) {
  3524. Uint32 *src = 0;
  3525. Uint32 *dst = (Uint32 *)info->dst;
  3526. int n = info->dst_w;
  3527. posx = incx / 2;
  3528. srcy = posy >> 16;
  3529. while (n--) {
  3530. srcx = posx >> 16;
  3531. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3532. pixel = *src;
  3533. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3534. if (flags & SDL_COPY_MODULATE_COLOR) {
  3535. MULT_DIV_255(R, modulateR, R);
  3536. MULT_DIV_255(G, modulateG, G);
  3537. MULT_DIV_255(B, modulateB, B);
  3538. }
  3539. pixel = (R << 16) | (G << 8) | B;
  3540. *dst = pixel;
  3541. posx += incx;
  3542. ++dst;
  3543. }
  3544. posy += incy;
  3545. info->dst += info->dst_pitch;
  3546. }
  3547. }
  3548. static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  3549. {
  3550. const int flags = info->flags;
  3551. const Uint32 modulateR = info->r;
  3552. const Uint32 modulateG = info->g;
  3553. const Uint32 modulateB = info->b;
  3554. const Uint32 modulateA = info->a;
  3555. Uint32 srcpixel;
  3556. Uint32 srcR, srcG, srcB, srcA;
  3557. Uint32 dstpixel;
  3558. Uint32 dstR, dstG, dstB;
  3559. while (info->dst_h--) {
  3560. Uint32 *src = (Uint32 *)info->src;
  3561. Uint32 *dst = (Uint32 *)info->dst;
  3562. int n = info->dst_w;
  3563. while (n--) {
  3564. srcpixel = *src;
  3565. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3566. dstpixel = *dst;
  3567. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3568. if (flags & SDL_COPY_MODULATE_COLOR) {
  3569. MULT_DIV_255(srcR, modulateR, srcR);
  3570. MULT_DIV_255(srcG, modulateG, srcG);
  3571. MULT_DIV_255(srcB, modulateB, srcB);
  3572. }
  3573. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3574. MULT_DIV_255(srcA, modulateA, srcA);
  3575. }
  3576. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3577. if (srcA < 255) {
  3578. MULT_DIV_255(srcR, srcA, srcR);
  3579. MULT_DIV_255(srcG, srcA, srcG);
  3580. MULT_DIV_255(srcB, srcA, srcB);
  3581. }
  3582. }
  3583. switch (flags & SDL_COPY_BLEND_MASK) {
  3584. case SDL_COPY_BLEND:
  3585. MULT_DIV_255((255 - srcA), dstR, dstR);
  3586. dstR += srcR;
  3587. MULT_DIV_255((255 - srcA), dstG, dstG);
  3588. dstG += srcG;
  3589. MULT_DIV_255((255 - srcA), dstB, dstB);
  3590. dstB += srcB;
  3591. break;
  3592. case SDL_COPY_BLEND_PREMULTIPLIED:
  3593. MULT_DIV_255((255 - srcA), dstR, dstR);
  3594. dstR += srcR;
  3595. if (dstR > 255) dstR = 255;
  3596. MULT_DIV_255((255 - srcA), dstG, dstG);
  3597. dstG += srcG;
  3598. if (dstG > 255) dstG = 255;
  3599. MULT_DIV_255((255 - srcA), dstB, dstB);
  3600. dstB += srcB;
  3601. if (dstB > 255) dstB = 255;
  3602. break;
  3603. case SDL_COPY_ADD:
  3604. case SDL_COPY_ADD_PREMULTIPLIED:
  3605. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3606. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3607. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3608. break;
  3609. case SDL_COPY_MOD:
  3610. MULT_DIV_255(srcR, dstR, dstR);
  3611. MULT_DIV_255(srcG, dstG, dstG);
  3612. MULT_DIV_255(srcB, dstB, dstB);
  3613. break;
  3614. case SDL_COPY_MUL:
  3615. {
  3616. Uint32 tmp1, tmp2;
  3617. MULT_DIV_255(srcR, dstR, tmp1);
  3618. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3619. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3620. MULT_DIV_255(srcG, dstG, tmp1);
  3621. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3622. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3623. MULT_DIV_255(srcB, dstB, tmp1);
  3624. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3625. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3626. }
  3627. break;
  3628. }
  3629. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3630. *dst = dstpixel;
  3631. ++src;
  3632. ++dst;
  3633. }
  3634. info->src += info->src_pitch;
  3635. info->dst += info->dst_pitch;
  3636. }
  3637. }
  3638. static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3639. {
  3640. const int flags = info->flags;
  3641. const Uint32 modulateR = info->r;
  3642. const Uint32 modulateG = info->g;
  3643. const Uint32 modulateB = info->b;
  3644. const Uint32 modulateA = info->a;
  3645. Uint32 srcpixel;
  3646. Uint32 srcR, srcG, srcB, srcA;
  3647. Uint32 dstpixel;
  3648. Uint32 dstR, dstG, dstB;
  3649. Uint64 srcy, srcx;
  3650. Uint64 posy, posx;
  3651. Uint64 incy, incx;
  3652. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3653. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3654. posy = incy / 2;
  3655. while (info->dst_h--) {
  3656. Uint32 *src = 0;
  3657. Uint32 *dst = (Uint32 *)info->dst;
  3658. int n = info->dst_w;
  3659. posx = incx / 2;
  3660. srcy = posy >> 16;
  3661. while (n--) {
  3662. srcx = posx >> 16;
  3663. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3664. srcpixel = *src;
  3665. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3666. dstpixel = *dst;
  3667. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3668. if (flags & SDL_COPY_MODULATE_COLOR) {
  3669. MULT_DIV_255(srcR, modulateR, srcR);
  3670. MULT_DIV_255(srcG, modulateG, srcG);
  3671. MULT_DIV_255(srcB, modulateB, srcB);
  3672. }
  3673. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3674. MULT_DIV_255(srcA, modulateA, srcA);
  3675. }
  3676. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3677. if (srcA < 255) {
  3678. MULT_DIV_255(srcR, srcA, srcR);
  3679. MULT_DIV_255(srcG, srcA, srcG);
  3680. MULT_DIV_255(srcB, srcA, srcB);
  3681. }
  3682. }
  3683. switch (flags & SDL_COPY_BLEND_MASK) {
  3684. case SDL_COPY_BLEND:
  3685. MULT_DIV_255((255 - srcA), dstR, dstR);
  3686. dstR += srcR;
  3687. MULT_DIV_255((255 - srcA), dstG, dstG);
  3688. dstG += srcG;
  3689. MULT_DIV_255((255 - srcA), dstB, dstB);
  3690. dstB += srcB;
  3691. break;
  3692. case SDL_COPY_BLEND_PREMULTIPLIED:
  3693. MULT_DIV_255((255 - srcA), dstR, dstR);
  3694. dstR += srcR;
  3695. if (dstR > 255) dstR = 255;
  3696. MULT_DIV_255((255 - srcA), dstG, dstG);
  3697. dstG += srcG;
  3698. if (dstG > 255) dstG = 255;
  3699. MULT_DIV_255((255 - srcA), dstB, dstB);
  3700. dstB += srcB;
  3701. if (dstB > 255) dstB = 255;
  3702. break;
  3703. case SDL_COPY_ADD:
  3704. case SDL_COPY_ADD_PREMULTIPLIED:
  3705. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3706. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3707. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3708. break;
  3709. case SDL_COPY_MOD:
  3710. MULT_DIV_255(srcR, dstR, dstR);
  3711. MULT_DIV_255(srcG, dstG, dstG);
  3712. MULT_DIV_255(srcB, dstB, dstB);
  3713. break;
  3714. case SDL_COPY_MUL:
  3715. {
  3716. Uint32 tmp1, tmp2;
  3717. MULT_DIV_255(srcR, dstR, tmp1);
  3718. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3719. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3720. MULT_DIV_255(srcG, dstG, tmp1);
  3721. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3722. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3723. MULT_DIV_255(srcB, dstB, tmp1);
  3724. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3725. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3726. }
  3727. break;
  3728. }
  3729. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3730. *dst = dstpixel;
  3731. posx += incx;
  3732. ++dst;
  3733. }
  3734. posy += incy;
  3735. info->dst += info->dst_pitch;
  3736. }
  3737. }
  3738. static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
  3739. {
  3740. Uint32 pixel;
  3741. Uint32 R, G, B;
  3742. Uint64 srcy, srcx;
  3743. Uint64 posy, posx;
  3744. Uint64 incy, incx;
  3745. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3746. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3747. posy = incy / 2;
  3748. while (info->dst_h--) {
  3749. Uint32 *src = 0;
  3750. Uint32 *dst = (Uint32 *)info->dst;
  3751. int n = info->dst_w;
  3752. posx = incx / 2;
  3753. srcy = posy >> 16;
  3754. while (n--) {
  3755. srcx = posx >> 16;
  3756. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3757. pixel = *src;
  3758. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3759. pixel = (B << 16) | (G << 8) | R;
  3760. *dst = pixel;
  3761. posx += incx;
  3762. ++dst;
  3763. }
  3764. posy += incy;
  3765. info->dst += info->dst_pitch;
  3766. }
  3767. }
  3768. static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
  3769. {
  3770. const int flags = info->flags;
  3771. Uint32 srcpixel;
  3772. Uint32 srcR, srcG, srcB, srcA;
  3773. Uint32 dstpixel;
  3774. Uint32 dstR, dstG, dstB;
  3775. while (info->dst_h--) {
  3776. Uint32 *src = (Uint32 *)info->src;
  3777. Uint32 *dst = (Uint32 *)info->dst;
  3778. int n = info->dst_w;
  3779. while (n--) {
  3780. srcpixel = *src;
  3781. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3782. dstpixel = *dst;
  3783. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  3784. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3785. if (srcA < 255) {
  3786. MULT_DIV_255(srcR, srcA, srcR);
  3787. MULT_DIV_255(srcG, srcA, srcG);
  3788. MULT_DIV_255(srcB, srcA, srcB);
  3789. }
  3790. }
  3791. switch (flags & SDL_COPY_BLEND_MASK) {
  3792. case SDL_COPY_BLEND:
  3793. MULT_DIV_255((255 - srcA), dstR, dstR);
  3794. dstR += srcR;
  3795. MULT_DIV_255((255 - srcA), dstG, dstG);
  3796. dstG += srcG;
  3797. MULT_DIV_255((255 - srcA), dstB, dstB);
  3798. dstB += srcB;
  3799. break;
  3800. case SDL_COPY_BLEND_PREMULTIPLIED:
  3801. MULT_DIV_255((255 - srcA), dstR, dstR);
  3802. dstR += srcR;
  3803. if (dstR > 255) dstR = 255;
  3804. MULT_DIV_255((255 - srcA), dstG, dstG);
  3805. dstG += srcG;
  3806. if (dstG > 255) dstG = 255;
  3807. MULT_DIV_255((255 - srcA), dstB, dstB);
  3808. dstB += srcB;
  3809. if (dstB > 255) dstB = 255;
  3810. break;
  3811. case SDL_COPY_ADD:
  3812. case SDL_COPY_ADD_PREMULTIPLIED:
  3813. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3814. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3815. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3816. break;
  3817. case SDL_COPY_MOD:
  3818. MULT_DIV_255(srcR, dstR, dstR);
  3819. MULT_DIV_255(srcG, dstG, dstG);
  3820. MULT_DIV_255(srcB, dstB, dstB);
  3821. break;
  3822. case SDL_COPY_MUL:
  3823. {
  3824. Uint32 tmp1, tmp2;
  3825. MULT_DIV_255(srcR, dstR, tmp1);
  3826. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3827. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3828. MULT_DIV_255(srcG, dstG, tmp1);
  3829. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3830. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3831. MULT_DIV_255(srcB, dstB, tmp1);
  3832. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3833. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3834. }
  3835. break;
  3836. }
  3837. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  3838. *dst = dstpixel;
  3839. ++src;
  3840. ++dst;
  3841. }
  3842. info->src += info->src_pitch;
  3843. info->dst += info->dst_pitch;
  3844. }
  3845. }
  3846. static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  3847. {
  3848. const int flags = info->flags;
  3849. Uint32 srcpixel;
  3850. Uint32 srcR, srcG, srcB, srcA;
  3851. Uint32 dstpixel;
  3852. Uint32 dstR, dstG, dstB;
  3853. Uint64 srcy, srcx;
  3854. Uint64 posy, posx;
  3855. Uint64 incy, incx;
  3856. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3857. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3858. posy = incy / 2;
  3859. while (info->dst_h--) {
  3860. Uint32 *src = 0;
  3861. Uint32 *dst = (Uint32 *)info->dst;
  3862. int n = info->dst_w;
  3863. posx = incx / 2;
  3864. srcy = posy >> 16;
  3865. while (n--) {
  3866. srcx = posx >> 16;
  3867. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3868. srcpixel = *src;
  3869. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3870. dstpixel = *dst;
  3871. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  3872. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3873. if (srcA < 255) {
  3874. MULT_DIV_255(srcR, srcA, srcR);
  3875. MULT_DIV_255(srcG, srcA, srcG);
  3876. MULT_DIV_255(srcB, srcA, srcB);
  3877. }
  3878. }
  3879. switch (flags & SDL_COPY_BLEND_MASK) {
  3880. case SDL_COPY_BLEND:
  3881. MULT_DIV_255((255 - srcA), dstR, dstR);
  3882. dstR += srcR;
  3883. MULT_DIV_255((255 - srcA), dstG, dstG);
  3884. dstG += srcG;
  3885. MULT_DIV_255((255 - srcA), dstB, dstB);
  3886. dstB += srcB;
  3887. break;
  3888. case SDL_COPY_BLEND_PREMULTIPLIED:
  3889. MULT_DIV_255((255 - srcA), dstR, dstR);
  3890. dstR += srcR;
  3891. if (dstR > 255) dstR = 255;
  3892. MULT_DIV_255((255 - srcA), dstG, dstG);
  3893. dstG += srcG;
  3894. if (dstG > 255) dstG = 255;
  3895. MULT_DIV_255((255 - srcA), dstB, dstB);
  3896. dstB += srcB;
  3897. if (dstB > 255) dstB = 255;
  3898. break;
  3899. case SDL_COPY_ADD:
  3900. case SDL_COPY_ADD_PREMULTIPLIED:
  3901. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3902. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3903. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3904. break;
  3905. case SDL_COPY_MOD:
  3906. MULT_DIV_255(srcR, dstR, dstR);
  3907. MULT_DIV_255(srcG, dstG, dstG);
  3908. MULT_DIV_255(srcB, dstB, dstB);
  3909. break;
  3910. case SDL_COPY_MUL:
  3911. {
  3912. Uint32 tmp1, tmp2;
  3913. MULT_DIV_255(srcR, dstR, tmp1);
  3914. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3915. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3916. MULT_DIV_255(srcG, dstG, tmp1);
  3917. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3918. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3919. MULT_DIV_255(srcB, dstB, tmp1);
  3920. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3921. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3922. }
  3923. break;
  3924. }
  3925. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  3926. *dst = dstpixel;
  3927. posx += incx;
  3928. ++dst;
  3929. }
  3930. posy += incy;
  3931. info->dst += info->dst_pitch;
  3932. }
  3933. }
  3934. static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  3935. {
  3936. const int flags = info->flags;
  3937. const Uint32 modulateR = info->r;
  3938. const Uint32 modulateG = info->g;
  3939. const Uint32 modulateB = info->b;
  3940. Uint32 pixel;
  3941. Uint32 R, G, B;
  3942. while (info->dst_h--) {
  3943. Uint32 *src = (Uint32 *)info->src;
  3944. Uint32 *dst = (Uint32 *)info->dst;
  3945. int n = info->dst_w;
  3946. while (n--) {
  3947. pixel = *src;
  3948. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3949. if (flags & SDL_COPY_MODULATE_COLOR) {
  3950. MULT_DIV_255(R, modulateR, R);
  3951. MULT_DIV_255(G, modulateG, G);
  3952. MULT_DIV_255(B, modulateB, B);
  3953. }
  3954. pixel = (B << 16) | (G << 8) | R;
  3955. *dst = pixel;
  3956. ++src;
  3957. ++dst;
  3958. }
  3959. info->src += info->src_pitch;
  3960. info->dst += info->dst_pitch;
  3961. }
  3962. }
  3963. static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  3964. {
  3965. const int flags = info->flags;
  3966. const Uint32 modulateR = info->r;
  3967. const Uint32 modulateG = info->g;
  3968. const Uint32 modulateB = info->b;
  3969. Uint32 pixel;
  3970. Uint32 R, G, B;
  3971. Uint64 srcy, srcx;
  3972. Uint64 posy, posx;
  3973. Uint64 incy, incx;
  3974. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3975. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3976. posy = incy / 2;
  3977. while (info->dst_h--) {
  3978. Uint32 *src = 0;
  3979. Uint32 *dst = (Uint32 *)info->dst;
  3980. int n = info->dst_w;
  3981. posx = incx / 2;
  3982. srcy = posy >> 16;
  3983. while (n--) {
  3984. srcx = posx >> 16;
  3985. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3986. pixel = *src;
  3987. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3988. if (flags & SDL_COPY_MODULATE_COLOR) {
  3989. MULT_DIV_255(R, modulateR, R);
  3990. MULT_DIV_255(G, modulateG, G);
  3991. MULT_DIV_255(B, modulateB, B);
  3992. }
  3993. pixel = (B << 16) | (G << 8) | R;
  3994. *dst = pixel;
  3995. posx += incx;
  3996. ++dst;
  3997. }
  3998. posy += incy;
  3999. info->dst += info->dst_pitch;
  4000. }
  4001. }
  4002. static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  4003. {
  4004. const int flags = info->flags;
  4005. const Uint32 modulateR = info->r;
  4006. const Uint32 modulateG = info->g;
  4007. const Uint32 modulateB = info->b;
  4008. const Uint32 modulateA = info->a;
  4009. Uint32 srcpixel;
  4010. Uint32 srcR, srcG, srcB, srcA;
  4011. Uint32 dstpixel;
  4012. Uint32 dstR, dstG, dstB;
  4013. while (info->dst_h--) {
  4014. Uint32 *src = (Uint32 *)info->src;
  4015. Uint32 *dst = (Uint32 *)info->dst;
  4016. int n = info->dst_w;
  4017. while (n--) {
  4018. srcpixel = *src;
  4019. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4020. dstpixel = *dst;
  4021. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  4022. if (flags & SDL_COPY_MODULATE_COLOR) {
  4023. MULT_DIV_255(srcR, modulateR, srcR);
  4024. MULT_DIV_255(srcG, modulateG, srcG);
  4025. MULT_DIV_255(srcB, modulateB, srcB);
  4026. }
  4027. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4028. MULT_DIV_255(srcA, modulateA, srcA);
  4029. }
  4030. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4031. if (srcA < 255) {
  4032. MULT_DIV_255(srcR, srcA, srcR);
  4033. MULT_DIV_255(srcG, srcA, srcG);
  4034. MULT_DIV_255(srcB, srcA, srcB);
  4035. }
  4036. }
  4037. switch (flags & SDL_COPY_BLEND_MASK) {
  4038. case SDL_COPY_BLEND:
  4039. MULT_DIV_255((255 - srcA), dstR, dstR);
  4040. dstR += srcR;
  4041. MULT_DIV_255((255 - srcA), dstG, dstG);
  4042. dstG += srcG;
  4043. MULT_DIV_255((255 - srcA), dstB, dstB);
  4044. dstB += srcB;
  4045. break;
  4046. case SDL_COPY_BLEND_PREMULTIPLIED:
  4047. MULT_DIV_255((255 - srcA), dstR, dstR);
  4048. dstR += srcR;
  4049. if (dstR > 255) dstR = 255;
  4050. MULT_DIV_255((255 - srcA), dstG, dstG);
  4051. dstG += srcG;
  4052. if (dstG > 255) dstG = 255;
  4053. MULT_DIV_255((255 - srcA), dstB, dstB);
  4054. dstB += srcB;
  4055. if (dstB > 255) dstB = 255;
  4056. break;
  4057. case SDL_COPY_ADD:
  4058. case SDL_COPY_ADD_PREMULTIPLIED:
  4059. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4060. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4061. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4062. break;
  4063. case SDL_COPY_MOD:
  4064. MULT_DIV_255(srcR, dstR, dstR);
  4065. MULT_DIV_255(srcG, dstG, dstG);
  4066. MULT_DIV_255(srcB, dstB, dstB);
  4067. break;
  4068. case SDL_COPY_MUL:
  4069. {
  4070. Uint32 tmp1, tmp2;
  4071. MULT_DIV_255(srcR, dstR, tmp1);
  4072. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4073. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4074. MULT_DIV_255(srcG, dstG, tmp1);
  4075. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4076. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4077. MULT_DIV_255(srcB, dstB, tmp1);
  4078. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4079. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4080. }
  4081. break;
  4082. }
  4083. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  4084. *dst = dstpixel;
  4085. ++src;
  4086. ++dst;
  4087. }
  4088. info->src += info->src_pitch;
  4089. info->dst += info->dst_pitch;
  4090. }
  4091. }
  4092. static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4093. {
  4094. const int flags = info->flags;
  4095. const Uint32 modulateR = info->r;
  4096. const Uint32 modulateG = info->g;
  4097. const Uint32 modulateB = info->b;
  4098. const Uint32 modulateA = info->a;
  4099. Uint32 srcpixel;
  4100. Uint32 srcR, srcG, srcB, srcA;
  4101. Uint32 dstpixel;
  4102. Uint32 dstR, dstG, dstB;
  4103. Uint64 srcy, srcx;
  4104. Uint64 posy, posx;
  4105. Uint64 incy, incx;
  4106. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4107. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4108. posy = incy / 2;
  4109. while (info->dst_h--) {
  4110. Uint32 *src = 0;
  4111. Uint32 *dst = (Uint32 *)info->dst;
  4112. int n = info->dst_w;
  4113. posx = incx / 2;
  4114. srcy = posy >> 16;
  4115. while (n--) {
  4116. srcx = posx >> 16;
  4117. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4118. srcpixel = *src;
  4119. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4120. dstpixel = *dst;
  4121. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  4122. if (flags & SDL_COPY_MODULATE_COLOR) {
  4123. MULT_DIV_255(srcR, modulateR, srcR);
  4124. MULT_DIV_255(srcG, modulateG, srcG);
  4125. MULT_DIV_255(srcB, modulateB, srcB);
  4126. }
  4127. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4128. MULT_DIV_255(srcA, modulateA, srcA);
  4129. }
  4130. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4131. if (srcA < 255) {
  4132. MULT_DIV_255(srcR, srcA, srcR);
  4133. MULT_DIV_255(srcG, srcA, srcG);
  4134. MULT_DIV_255(srcB, srcA, srcB);
  4135. }
  4136. }
  4137. switch (flags & SDL_COPY_BLEND_MASK) {
  4138. case SDL_COPY_BLEND:
  4139. MULT_DIV_255((255 - srcA), dstR, dstR);
  4140. dstR += srcR;
  4141. MULT_DIV_255((255 - srcA), dstG, dstG);
  4142. dstG += srcG;
  4143. MULT_DIV_255((255 - srcA), dstB, dstB);
  4144. dstB += srcB;
  4145. break;
  4146. case SDL_COPY_BLEND_PREMULTIPLIED:
  4147. MULT_DIV_255((255 - srcA), dstR, dstR);
  4148. dstR += srcR;
  4149. if (dstR > 255) dstR = 255;
  4150. MULT_DIV_255((255 - srcA), dstG, dstG);
  4151. dstG += srcG;
  4152. if (dstG > 255) dstG = 255;
  4153. MULT_DIV_255((255 - srcA), dstB, dstB);
  4154. dstB += srcB;
  4155. if (dstB > 255) dstB = 255;
  4156. break;
  4157. case SDL_COPY_ADD:
  4158. case SDL_COPY_ADD_PREMULTIPLIED:
  4159. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4160. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4161. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4162. break;
  4163. case SDL_COPY_MOD:
  4164. MULT_DIV_255(srcR, dstR, dstR);
  4165. MULT_DIV_255(srcG, dstG, dstG);
  4166. MULT_DIV_255(srcB, dstB, dstB);
  4167. break;
  4168. case SDL_COPY_MUL:
  4169. {
  4170. Uint32 tmp1, tmp2;
  4171. MULT_DIV_255(srcR, dstR, tmp1);
  4172. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4173. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4174. MULT_DIV_255(srcG, dstG, tmp1);
  4175. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4176. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4177. MULT_DIV_255(srcB, dstB, tmp1);
  4178. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4179. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4180. }
  4181. break;
  4182. }
  4183. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  4184. *dst = dstpixel;
  4185. posx += incx;
  4186. ++dst;
  4187. }
  4188. posy += incy;
  4189. info->dst += info->dst_pitch;
  4190. }
  4191. }
  4192. static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
  4193. {
  4194. Uint64 srcy, srcx;
  4195. Uint64 posy, posx;
  4196. Uint64 incy, incx;
  4197. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4198. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4199. posy = incy / 2;
  4200. while (info->dst_h--) {
  4201. Uint32 *src = 0;
  4202. Uint32 *dst = (Uint32 *)info->dst;
  4203. int n = info->dst_w;
  4204. posx = incx / 2;
  4205. srcy = posy >> 16;
  4206. while (n--) {
  4207. srcx = posx >> 16;
  4208. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4209. *dst = *src;
  4210. posx += incx;
  4211. ++dst;
  4212. }
  4213. posy += incy;
  4214. info->dst += info->dst_pitch;
  4215. }
  4216. }
  4217. static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
  4218. {
  4219. const int flags = info->flags;
  4220. Uint32 srcpixel;
  4221. Uint32 srcR, srcG, srcB, srcA;
  4222. Uint32 dstpixel;
  4223. Uint32 dstR, dstG, dstB, dstA;
  4224. while (info->dst_h--) {
  4225. Uint32 *src = (Uint32 *)info->src;
  4226. Uint32 *dst = (Uint32 *)info->dst;
  4227. int n = info->dst_w;
  4228. while (n--) {
  4229. srcpixel = *src;
  4230. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4231. dstpixel = *dst;
  4232. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4233. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4234. if (srcA < 255) {
  4235. MULT_DIV_255(srcR, srcA, srcR);
  4236. MULT_DIV_255(srcG, srcA, srcG);
  4237. MULT_DIV_255(srcB, srcA, srcB);
  4238. }
  4239. }
  4240. switch (flags & SDL_COPY_BLEND_MASK) {
  4241. case SDL_COPY_BLEND:
  4242. MULT_DIV_255((255 - srcA), dstR, dstR);
  4243. dstR += srcR;
  4244. MULT_DIV_255((255 - srcA), dstG, dstG);
  4245. dstG += srcG;
  4246. MULT_DIV_255((255 - srcA), dstB, dstB);
  4247. dstB += srcB;
  4248. MULT_DIV_255((255 - srcA), dstA, dstA);
  4249. dstA += srcA;
  4250. break;
  4251. case SDL_COPY_BLEND_PREMULTIPLIED:
  4252. MULT_DIV_255((255 - srcA), dstR, dstR);
  4253. dstR += srcR;
  4254. if (dstR > 255) dstR = 255;
  4255. MULT_DIV_255((255 - srcA), dstG, dstG);
  4256. dstG += srcG;
  4257. if (dstG > 255) dstG = 255;
  4258. MULT_DIV_255((255 - srcA), dstB, dstB);
  4259. dstB += srcB;
  4260. if (dstB > 255) dstB = 255;
  4261. MULT_DIV_255((255 - srcA), dstA, dstA);
  4262. dstA += srcA;
  4263. if (dstA > 255) dstA = 255;
  4264. break;
  4265. case SDL_COPY_ADD:
  4266. case SDL_COPY_ADD_PREMULTIPLIED:
  4267. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4268. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4269. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4270. break;
  4271. case SDL_COPY_MOD:
  4272. MULT_DIV_255(srcR, dstR, dstR);
  4273. MULT_DIV_255(srcG, dstG, dstG);
  4274. MULT_DIV_255(srcB, dstB, dstB);
  4275. break;
  4276. case SDL_COPY_MUL:
  4277. {
  4278. Uint32 tmp1, tmp2;
  4279. MULT_DIV_255(srcR, dstR, tmp1);
  4280. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4281. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4282. MULT_DIV_255(srcG, dstG, tmp1);
  4283. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4284. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4285. MULT_DIV_255(srcB, dstB, tmp1);
  4286. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4287. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4288. }
  4289. break;
  4290. }
  4291. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4292. *dst = dstpixel;
  4293. ++src;
  4294. ++dst;
  4295. }
  4296. info->src += info->src_pitch;
  4297. info->dst += info->dst_pitch;
  4298. }
  4299. }
  4300. static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  4301. {
  4302. const int flags = info->flags;
  4303. Uint32 srcpixel;
  4304. Uint32 srcR, srcG, srcB, srcA;
  4305. Uint32 dstpixel;
  4306. Uint32 dstR, dstG, dstB, dstA;
  4307. Uint64 srcy, srcx;
  4308. Uint64 posy, posx;
  4309. Uint64 incy, incx;
  4310. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4311. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4312. posy = incy / 2;
  4313. while (info->dst_h--) {
  4314. Uint32 *src = 0;
  4315. Uint32 *dst = (Uint32 *)info->dst;
  4316. int n = info->dst_w;
  4317. posx = incx / 2;
  4318. srcy = posy >> 16;
  4319. while (n--) {
  4320. srcx = posx >> 16;
  4321. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4322. srcpixel = *src;
  4323. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4324. dstpixel = *dst;
  4325. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4326. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4327. if (srcA < 255) {
  4328. MULT_DIV_255(srcR, srcA, srcR);
  4329. MULT_DIV_255(srcG, srcA, srcG);
  4330. MULT_DIV_255(srcB, srcA, srcB);
  4331. }
  4332. }
  4333. switch (flags & SDL_COPY_BLEND_MASK) {
  4334. case SDL_COPY_BLEND:
  4335. MULT_DIV_255((255 - srcA), dstR, dstR);
  4336. dstR += srcR;
  4337. MULT_DIV_255((255 - srcA), dstG, dstG);
  4338. dstG += srcG;
  4339. MULT_DIV_255((255 - srcA), dstB, dstB);
  4340. dstB += srcB;
  4341. MULT_DIV_255((255 - srcA), dstA, dstA);
  4342. dstA += srcA;
  4343. break;
  4344. case SDL_COPY_BLEND_PREMULTIPLIED:
  4345. MULT_DIV_255((255 - srcA), dstR, dstR);
  4346. dstR += srcR;
  4347. if (dstR > 255) dstR = 255;
  4348. MULT_DIV_255((255 - srcA), dstG, dstG);
  4349. dstG += srcG;
  4350. if (dstG > 255) dstG = 255;
  4351. MULT_DIV_255((255 - srcA), dstB, dstB);
  4352. dstB += srcB;
  4353. if (dstB > 255) dstB = 255;
  4354. MULT_DIV_255((255 - srcA), dstA, dstA);
  4355. dstA += srcA;
  4356. if (dstA > 255) dstA = 255;
  4357. break;
  4358. case SDL_COPY_ADD:
  4359. case SDL_COPY_ADD_PREMULTIPLIED:
  4360. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4361. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4362. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4363. break;
  4364. case SDL_COPY_MOD:
  4365. MULT_DIV_255(srcR, dstR, dstR);
  4366. MULT_DIV_255(srcG, dstG, dstG);
  4367. MULT_DIV_255(srcB, dstB, dstB);
  4368. break;
  4369. case SDL_COPY_MUL:
  4370. {
  4371. Uint32 tmp1, tmp2;
  4372. MULT_DIV_255(srcR, dstR, tmp1);
  4373. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4374. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4375. MULT_DIV_255(srcG, dstG, tmp1);
  4376. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4377. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4378. MULT_DIV_255(srcB, dstB, tmp1);
  4379. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4380. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4381. }
  4382. break;
  4383. }
  4384. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4385. *dst = dstpixel;
  4386. posx += incx;
  4387. ++dst;
  4388. }
  4389. posy += incy;
  4390. info->dst += info->dst_pitch;
  4391. }
  4392. }
  4393. static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  4394. {
  4395. const int flags = info->flags;
  4396. const Uint32 modulateR = info->r;
  4397. const Uint32 modulateG = info->g;
  4398. const Uint32 modulateB = info->b;
  4399. const Uint32 modulateA = info->a;
  4400. Uint32 pixel;
  4401. Uint32 R, G, B, A;
  4402. while (info->dst_h--) {
  4403. Uint32 *src = (Uint32 *)info->src;
  4404. Uint32 *dst = (Uint32 *)info->dst;
  4405. int n = info->dst_w;
  4406. while (n--) {
  4407. pixel = *src;
  4408. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4409. if (flags & SDL_COPY_MODULATE_COLOR) {
  4410. MULT_DIV_255(R, modulateR, R);
  4411. MULT_DIV_255(G, modulateG, G);
  4412. MULT_DIV_255(B, modulateB, B);
  4413. }
  4414. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4415. MULT_DIV_255(A, modulateA, A);
  4416. }
  4417. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  4418. *dst = pixel;
  4419. ++src;
  4420. ++dst;
  4421. }
  4422. info->src += info->src_pitch;
  4423. info->dst += info->dst_pitch;
  4424. }
  4425. }
  4426. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  4427. {
  4428. const int flags = info->flags;
  4429. const Uint32 modulateR = info->r;
  4430. const Uint32 modulateG = info->g;
  4431. const Uint32 modulateB = info->b;
  4432. const Uint32 modulateA = info->a;
  4433. Uint32 pixel;
  4434. Uint32 R, G, B, A;
  4435. Uint64 srcy, srcx;
  4436. Uint64 posy, posx;
  4437. Uint64 incy, incx;
  4438. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4439. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4440. posy = incy / 2;
  4441. while (info->dst_h--) {
  4442. Uint32 *src = 0;
  4443. Uint32 *dst = (Uint32 *)info->dst;
  4444. int n = info->dst_w;
  4445. posx = incx / 2;
  4446. srcy = posy >> 16;
  4447. while (n--) {
  4448. srcx = posx >> 16;
  4449. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4450. pixel = *src;
  4451. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4452. if (flags & SDL_COPY_MODULATE_COLOR) {
  4453. MULT_DIV_255(R, modulateR, R);
  4454. MULT_DIV_255(G, modulateG, G);
  4455. MULT_DIV_255(B, modulateB, B);
  4456. }
  4457. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4458. MULT_DIV_255(A, modulateA, A);
  4459. }
  4460. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  4461. *dst = pixel;
  4462. posx += incx;
  4463. ++dst;
  4464. }
  4465. posy += incy;
  4466. info->dst += info->dst_pitch;
  4467. }
  4468. }
  4469. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  4470. {
  4471. const int flags = info->flags;
  4472. const Uint32 modulateR = info->r;
  4473. const Uint32 modulateG = info->g;
  4474. const Uint32 modulateB = info->b;
  4475. const Uint32 modulateA = info->a;
  4476. Uint32 srcpixel;
  4477. Uint32 srcR, srcG, srcB, srcA;
  4478. Uint32 dstpixel;
  4479. Uint32 dstR, dstG, dstB, dstA;
  4480. while (info->dst_h--) {
  4481. Uint32 *src = (Uint32 *)info->src;
  4482. Uint32 *dst = (Uint32 *)info->dst;
  4483. int n = info->dst_w;
  4484. while (n--) {
  4485. srcpixel = *src;
  4486. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4487. dstpixel = *dst;
  4488. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4489. if (flags & SDL_COPY_MODULATE_COLOR) {
  4490. MULT_DIV_255(srcR, modulateR, srcR);
  4491. MULT_DIV_255(srcG, modulateG, srcG);
  4492. MULT_DIV_255(srcB, modulateB, srcB);
  4493. }
  4494. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4495. MULT_DIV_255(srcA, modulateA, srcA);
  4496. }
  4497. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4498. if (srcA < 255) {
  4499. MULT_DIV_255(srcR, srcA, srcR);
  4500. MULT_DIV_255(srcG, srcA, srcG);
  4501. MULT_DIV_255(srcB, srcA, srcB);
  4502. }
  4503. }
  4504. switch (flags & SDL_COPY_BLEND_MASK) {
  4505. case SDL_COPY_BLEND:
  4506. MULT_DIV_255((255 - srcA), dstR, dstR);
  4507. dstR += srcR;
  4508. MULT_DIV_255((255 - srcA), dstG, dstG);
  4509. dstG += srcG;
  4510. MULT_DIV_255((255 - srcA), dstB, dstB);
  4511. dstB += srcB;
  4512. MULT_DIV_255((255 - srcA), dstA, dstA);
  4513. dstA += srcA;
  4514. break;
  4515. case SDL_COPY_BLEND_PREMULTIPLIED:
  4516. MULT_DIV_255((255 - srcA), dstR, dstR);
  4517. dstR += srcR;
  4518. if (dstR > 255) dstR = 255;
  4519. MULT_DIV_255((255 - srcA), dstG, dstG);
  4520. dstG += srcG;
  4521. if (dstG > 255) dstG = 255;
  4522. MULT_DIV_255((255 - srcA), dstB, dstB);
  4523. dstB += srcB;
  4524. if (dstB > 255) dstB = 255;
  4525. MULT_DIV_255((255 - srcA), dstA, dstA);
  4526. dstA += srcA;
  4527. if (dstA > 255) dstA = 255;
  4528. break;
  4529. case SDL_COPY_ADD:
  4530. case SDL_COPY_ADD_PREMULTIPLIED:
  4531. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4532. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4533. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4534. break;
  4535. case SDL_COPY_MOD:
  4536. MULT_DIV_255(srcR, dstR, dstR);
  4537. MULT_DIV_255(srcG, dstG, dstG);
  4538. MULT_DIV_255(srcB, dstB, dstB);
  4539. break;
  4540. case SDL_COPY_MUL:
  4541. {
  4542. Uint32 tmp1, tmp2;
  4543. MULT_DIV_255(srcR, dstR, tmp1);
  4544. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4545. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4546. MULT_DIV_255(srcG, dstG, tmp1);
  4547. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4548. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4549. MULT_DIV_255(srcB, dstB, tmp1);
  4550. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4551. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4552. }
  4553. break;
  4554. }
  4555. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4556. *dst = dstpixel;
  4557. ++src;
  4558. ++dst;
  4559. }
  4560. info->src += info->src_pitch;
  4561. info->dst += info->dst_pitch;
  4562. }
  4563. }
  4564. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4565. {
  4566. const int flags = info->flags;
  4567. const Uint32 modulateR = info->r;
  4568. const Uint32 modulateG = info->g;
  4569. const Uint32 modulateB = info->b;
  4570. const Uint32 modulateA = info->a;
  4571. Uint32 srcpixel;
  4572. Uint32 srcR, srcG, srcB, srcA;
  4573. Uint32 dstpixel;
  4574. Uint32 dstR, dstG, dstB, dstA;
  4575. Uint64 srcy, srcx;
  4576. Uint64 posy, posx;
  4577. Uint64 incy, incx;
  4578. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4579. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4580. posy = incy / 2;
  4581. while (info->dst_h--) {
  4582. Uint32 *src = 0;
  4583. Uint32 *dst = (Uint32 *)info->dst;
  4584. int n = info->dst_w;
  4585. posx = incx / 2;
  4586. srcy = posy >> 16;
  4587. while (n--) {
  4588. srcx = posx >> 16;
  4589. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4590. srcpixel = *src;
  4591. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4592. dstpixel = *dst;
  4593. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4594. if (flags & SDL_COPY_MODULATE_COLOR) {
  4595. MULT_DIV_255(srcR, modulateR, srcR);
  4596. MULT_DIV_255(srcG, modulateG, srcG);
  4597. MULT_DIV_255(srcB, modulateB, srcB);
  4598. }
  4599. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4600. MULT_DIV_255(srcA, modulateA, srcA);
  4601. }
  4602. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4603. if (srcA < 255) {
  4604. MULT_DIV_255(srcR, srcA, srcR);
  4605. MULT_DIV_255(srcG, srcA, srcG);
  4606. MULT_DIV_255(srcB, srcA, srcB);
  4607. }
  4608. }
  4609. switch (flags & SDL_COPY_BLEND_MASK) {
  4610. case SDL_COPY_BLEND:
  4611. MULT_DIV_255((255 - srcA), dstR, dstR);
  4612. dstR += srcR;
  4613. MULT_DIV_255((255 - srcA), dstG, dstG);
  4614. dstG += srcG;
  4615. MULT_DIV_255((255 - srcA), dstB, dstB);
  4616. dstB += srcB;
  4617. MULT_DIV_255((255 - srcA), dstA, dstA);
  4618. dstA += srcA;
  4619. break;
  4620. case SDL_COPY_BLEND_PREMULTIPLIED:
  4621. MULT_DIV_255((255 - srcA), dstR, dstR);
  4622. dstR += srcR;
  4623. if (dstR > 255) dstR = 255;
  4624. MULT_DIV_255((255 - srcA), dstG, dstG);
  4625. dstG += srcG;
  4626. if (dstG > 255) dstG = 255;
  4627. MULT_DIV_255((255 - srcA), dstB, dstB);
  4628. dstB += srcB;
  4629. if (dstB > 255) dstB = 255;
  4630. MULT_DIV_255((255 - srcA), dstA, dstA);
  4631. dstA += srcA;
  4632. if (dstA > 255) dstA = 255;
  4633. break;
  4634. case SDL_COPY_ADD:
  4635. case SDL_COPY_ADD_PREMULTIPLIED:
  4636. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4637. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4638. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4639. break;
  4640. case SDL_COPY_MOD:
  4641. MULT_DIV_255(srcR, dstR, dstR);
  4642. MULT_DIV_255(srcG, dstG, dstG);
  4643. MULT_DIV_255(srcB, dstB, dstB);
  4644. break;
  4645. case SDL_COPY_MUL:
  4646. {
  4647. Uint32 tmp1, tmp2;
  4648. MULT_DIV_255(srcR, dstR, tmp1);
  4649. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4650. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4651. MULT_DIV_255(srcG, dstG, tmp1);
  4652. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4653. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4654. MULT_DIV_255(srcB, dstB, tmp1);
  4655. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4656. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4657. }
  4658. break;
  4659. }
  4660. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4661. *dst = dstpixel;
  4662. posx += incx;
  4663. ++dst;
  4664. }
  4665. posy += incy;
  4666. info->dst += info->dst_pitch;
  4667. }
  4668. }
  4669. static void SDL_Blit_ARGB8888_ABGR8888_Scale(SDL_BlitInfo *info)
  4670. {
  4671. Uint32 pixel;
  4672. Uint32 R, G, B, A;
  4673. Uint64 srcy, srcx;
  4674. Uint64 posy, posx;
  4675. Uint64 incy, incx;
  4676. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4677. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4678. posy = incy / 2;
  4679. while (info->dst_h--) {
  4680. Uint32 *src = 0;
  4681. Uint32 *dst = (Uint32 *)info->dst;
  4682. int n = info->dst_w;
  4683. posx = incx / 2;
  4684. srcy = posy >> 16;
  4685. while (n--) {
  4686. srcx = posx >> 16;
  4687. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4688. pixel = *src;
  4689. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4690. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  4691. *dst = pixel;
  4692. posx += incx;
  4693. ++dst;
  4694. }
  4695. posy += incy;
  4696. info->dst += info->dst_pitch;
  4697. }
  4698. }
  4699. static void SDL_Blit_ARGB8888_ABGR8888_Blend(SDL_BlitInfo *info)
  4700. {
  4701. const int flags = info->flags;
  4702. Uint32 srcpixel;
  4703. Uint32 srcR, srcG, srcB, srcA;
  4704. Uint32 dstpixel;
  4705. Uint32 dstR, dstG, dstB, dstA;
  4706. while (info->dst_h--) {
  4707. Uint32 *src = (Uint32 *)info->src;
  4708. Uint32 *dst = (Uint32 *)info->dst;
  4709. int n = info->dst_w;
  4710. while (n--) {
  4711. srcpixel = *src;
  4712. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4713. dstpixel = *dst;
  4714. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4715. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4716. if (srcA < 255) {
  4717. MULT_DIV_255(srcR, srcA, srcR);
  4718. MULT_DIV_255(srcG, srcA, srcG);
  4719. MULT_DIV_255(srcB, srcA, srcB);
  4720. }
  4721. }
  4722. switch (flags & SDL_COPY_BLEND_MASK) {
  4723. case SDL_COPY_BLEND:
  4724. MULT_DIV_255((255 - srcA), dstR, dstR);
  4725. dstR += srcR;
  4726. MULT_DIV_255((255 - srcA), dstG, dstG);
  4727. dstG += srcG;
  4728. MULT_DIV_255((255 - srcA), dstB, dstB);
  4729. dstB += srcB;
  4730. MULT_DIV_255((255 - srcA), dstA, dstA);
  4731. dstA += srcA;
  4732. break;
  4733. case SDL_COPY_BLEND_PREMULTIPLIED:
  4734. MULT_DIV_255((255 - srcA), dstR, dstR);
  4735. dstR += srcR;
  4736. if (dstR > 255) dstR = 255;
  4737. MULT_DIV_255((255 - srcA), dstG, dstG);
  4738. dstG += srcG;
  4739. if (dstG > 255) dstG = 255;
  4740. MULT_DIV_255((255 - srcA), dstB, dstB);
  4741. dstB += srcB;
  4742. if (dstB > 255) dstB = 255;
  4743. MULT_DIV_255((255 - srcA), dstA, dstA);
  4744. dstA += srcA;
  4745. if (dstA > 255) dstA = 255;
  4746. break;
  4747. case SDL_COPY_ADD:
  4748. case SDL_COPY_ADD_PREMULTIPLIED:
  4749. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4750. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4751. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4752. break;
  4753. case SDL_COPY_MOD:
  4754. MULT_DIV_255(srcR, dstR, dstR);
  4755. MULT_DIV_255(srcG, dstG, dstG);
  4756. MULT_DIV_255(srcB, dstB, dstB);
  4757. break;
  4758. case SDL_COPY_MUL:
  4759. {
  4760. Uint32 tmp1, tmp2;
  4761. MULT_DIV_255(srcR, dstR, tmp1);
  4762. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4763. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4764. MULT_DIV_255(srcG, dstG, tmp1);
  4765. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4766. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4767. MULT_DIV_255(srcB, dstB, tmp1);
  4768. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4769. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4770. }
  4771. break;
  4772. }
  4773. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  4774. *dst = dstpixel;
  4775. ++src;
  4776. ++dst;
  4777. }
  4778. info->src += info->src_pitch;
  4779. info->dst += info->dst_pitch;
  4780. }
  4781. }
  4782. static void SDL_Blit_ARGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  4783. {
  4784. const int flags = info->flags;
  4785. Uint32 srcpixel;
  4786. Uint32 srcR, srcG, srcB, srcA;
  4787. Uint32 dstpixel;
  4788. Uint32 dstR, dstG, dstB, dstA;
  4789. Uint64 srcy, srcx;
  4790. Uint64 posy, posx;
  4791. Uint64 incy, incx;
  4792. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4793. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4794. posy = incy / 2;
  4795. while (info->dst_h--) {
  4796. Uint32 *src = 0;
  4797. Uint32 *dst = (Uint32 *)info->dst;
  4798. int n = info->dst_w;
  4799. posx = incx / 2;
  4800. srcy = posy >> 16;
  4801. while (n--) {
  4802. srcx = posx >> 16;
  4803. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4804. srcpixel = *src;
  4805. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4806. dstpixel = *dst;
  4807. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4808. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4809. if (srcA < 255) {
  4810. MULT_DIV_255(srcR, srcA, srcR);
  4811. MULT_DIV_255(srcG, srcA, srcG);
  4812. MULT_DIV_255(srcB, srcA, srcB);
  4813. }
  4814. }
  4815. switch (flags & SDL_COPY_BLEND_MASK) {
  4816. case SDL_COPY_BLEND:
  4817. MULT_DIV_255((255 - srcA), dstR, dstR);
  4818. dstR += srcR;
  4819. MULT_DIV_255((255 - srcA), dstG, dstG);
  4820. dstG += srcG;
  4821. MULT_DIV_255((255 - srcA), dstB, dstB);
  4822. dstB += srcB;
  4823. MULT_DIV_255((255 - srcA), dstA, dstA);
  4824. dstA += srcA;
  4825. break;
  4826. case SDL_COPY_BLEND_PREMULTIPLIED:
  4827. MULT_DIV_255((255 - srcA), dstR, dstR);
  4828. dstR += srcR;
  4829. if (dstR > 255) dstR = 255;
  4830. MULT_DIV_255((255 - srcA), dstG, dstG);
  4831. dstG += srcG;
  4832. if (dstG > 255) dstG = 255;
  4833. MULT_DIV_255((255 - srcA), dstB, dstB);
  4834. dstB += srcB;
  4835. if (dstB > 255) dstB = 255;
  4836. MULT_DIV_255((255 - srcA), dstA, dstA);
  4837. dstA += srcA;
  4838. if (dstA > 255) dstA = 255;
  4839. break;
  4840. case SDL_COPY_ADD:
  4841. case SDL_COPY_ADD_PREMULTIPLIED:
  4842. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4843. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4844. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4845. break;
  4846. case SDL_COPY_MOD:
  4847. MULT_DIV_255(srcR, dstR, dstR);
  4848. MULT_DIV_255(srcG, dstG, dstG);
  4849. MULT_DIV_255(srcB, dstB, dstB);
  4850. break;
  4851. case SDL_COPY_MUL:
  4852. {
  4853. Uint32 tmp1, tmp2;
  4854. MULT_DIV_255(srcR, dstR, tmp1);
  4855. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4856. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4857. MULT_DIV_255(srcG, dstG, tmp1);
  4858. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4859. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4860. MULT_DIV_255(srcB, dstB, tmp1);
  4861. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4862. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4863. }
  4864. break;
  4865. }
  4866. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  4867. *dst = dstpixel;
  4868. posx += incx;
  4869. ++dst;
  4870. }
  4871. posy += incy;
  4872. info->dst += info->dst_pitch;
  4873. }
  4874. }
  4875. static void SDL_Blit_ARGB8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  4876. {
  4877. const int flags = info->flags;
  4878. const Uint32 modulateR = info->r;
  4879. const Uint32 modulateG = info->g;
  4880. const Uint32 modulateB = info->b;
  4881. const Uint32 modulateA = info->a;
  4882. Uint32 pixel;
  4883. Uint32 R, G, B, A;
  4884. while (info->dst_h--) {
  4885. Uint32 *src = (Uint32 *)info->src;
  4886. Uint32 *dst = (Uint32 *)info->dst;
  4887. int n = info->dst_w;
  4888. while (n--) {
  4889. pixel = *src;
  4890. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4891. if (flags & SDL_COPY_MODULATE_COLOR) {
  4892. MULT_DIV_255(R, modulateR, R);
  4893. MULT_DIV_255(G, modulateG, G);
  4894. MULT_DIV_255(B, modulateB, B);
  4895. }
  4896. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4897. MULT_DIV_255(A, modulateA, A);
  4898. }
  4899. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  4900. *dst = pixel;
  4901. ++src;
  4902. ++dst;
  4903. }
  4904. info->src += info->src_pitch;
  4905. info->dst += info->dst_pitch;
  4906. }
  4907. }
  4908. static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  4909. {
  4910. const int flags = info->flags;
  4911. const Uint32 modulateR = info->r;
  4912. const Uint32 modulateG = info->g;
  4913. const Uint32 modulateB = info->b;
  4914. const Uint32 modulateA = info->a;
  4915. Uint32 pixel;
  4916. Uint32 R, G, B, A;
  4917. Uint64 srcy, srcx;
  4918. Uint64 posy, posx;
  4919. Uint64 incy, incx;
  4920. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4921. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4922. posy = incy / 2;
  4923. while (info->dst_h--) {
  4924. Uint32 *src = 0;
  4925. Uint32 *dst = (Uint32 *)info->dst;
  4926. int n = info->dst_w;
  4927. posx = incx / 2;
  4928. srcy = posy >> 16;
  4929. while (n--) {
  4930. srcx = posx >> 16;
  4931. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4932. pixel = *src;
  4933. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4934. if (flags & SDL_COPY_MODULATE_COLOR) {
  4935. MULT_DIV_255(R, modulateR, R);
  4936. MULT_DIV_255(G, modulateG, G);
  4937. MULT_DIV_255(B, modulateB, B);
  4938. }
  4939. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4940. MULT_DIV_255(A, modulateA, A);
  4941. }
  4942. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  4943. *dst = pixel;
  4944. posx += incx;
  4945. ++dst;
  4946. }
  4947. posy += incy;
  4948. info->dst += info->dst_pitch;
  4949. }
  4950. }
  4951. static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  4952. {
  4953. const int flags = info->flags;
  4954. const Uint32 modulateR = info->r;
  4955. const Uint32 modulateG = info->g;
  4956. const Uint32 modulateB = info->b;
  4957. const Uint32 modulateA = info->a;
  4958. Uint32 srcpixel;
  4959. Uint32 srcR, srcG, srcB, srcA;
  4960. Uint32 dstpixel;
  4961. Uint32 dstR, dstG, dstB, dstA;
  4962. while (info->dst_h--) {
  4963. Uint32 *src = (Uint32 *)info->src;
  4964. Uint32 *dst = (Uint32 *)info->dst;
  4965. int n = info->dst_w;
  4966. while (n--) {
  4967. srcpixel = *src;
  4968. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4969. dstpixel = *dst;
  4970. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4971. if (flags & SDL_COPY_MODULATE_COLOR) {
  4972. MULT_DIV_255(srcR, modulateR, srcR);
  4973. MULT_DIV_255(srcG, modulateG, srcG);
  4974. MULT_DIV_255(srcB, modulateB, srcB);
  4975. }
  4976. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4977. MULT_DIV_255(srcA, modulateA, srcA);
  4978. }
  4979. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4980. if (srcA < 255) {
  4981. MULT_DIV_255(srcR, srcA, srcR);
  4982. MULT_DIV_255(srcG, srcA, srcG);
  4983. MULT_DIV_255(srcB, srcA, srcB);
  4984. }
  4985. }
  4986. switch (flags & SDL_COPY_BLEND_MASK) {
  4987. case SDL_COPY_BLEND:
  4988. MULT_DIV_255((255 - srcA), dstR, dstR);
  4989. dstR += srcR;
  4990. MULT_DIV_255((255 - srcA), dstG, dstG);
  4991. dstG += srcG;
  4992. MULT_DIV_255((255 - srcA), dstB, dstB);
  4993. dstB += srcB;
  4994. MULT_DIV_255((255 - srcA), dstA, dstA);
  4995. dstA += srcA;
  4996. break;
  4997. case SDL_COPY_BLEND_PREMULTIPLIED:
  4998. MULT_DIV_255((255 - srcA), dstR, dstR);
  4999. dstR += srcR;
  5000. if (dstR > 255) dstR = 255;
  5001. MULT_DIV_255((255 - srcA), dstG, dstG);
  5002. dstG += srcG;
  5003. if (dstG > 255) dstG = 255;
  5004. MULT_DIV_255((255 - srcA), dstB, dstB);
  5005. dstB += srcB;
  5006. if (dstB > 255) dstB = 255;
  5007. MULT_DIV_255((255 - srcA), dstA, dstA);
  5008. dstA += srcA;
  5009. if (dstA > 255) dstA = 255;
  5010. break;
  5011. case SDL_COPY_ADD:
  5012. case SDL_COPY_ADD_PREMULTIPLIED:
  5013. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5014. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5015. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5016. break;
  5017. case SDL_COPY_MOD:
  5018. MULT_DIV_255(srcR, dstR, dstR);
  5019. MULT_DIV_255(srcG, dstG, dstG);
  5020. MULT_DIV_255(srcB, dstB, dstB);
  5021. break;
  5022. case SDL_COPY_MUL:
  5023. {
  5024. Uint32 tmp1, tmp2;
  5025. MULT_DIV_255(srcR, dstR, tmp1);
  5026. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5027. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5028. MULT_DIV_255(srcG, dstG, tmp1);
  5029. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5030. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5031. MULT_DIV_255(srcB, dstB, tmp1);
  5032. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5033. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5034. }
  5035. break;
  5036. }
  5037. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  5038. *dst = dstpixel;
  5039. ++src;
  5040. ++dst;
  5041. }
  5042. info->src += info->src_pitch;
  5043. info->dst += info->dst_pitch;
  5044. }
  5045. }
  5046. static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5047. {
  5048. const int flags = info->flags;
  5049. const Uint32 modulateR = info->r;
  5050. const Uint32 modulateG = info->g;
  5051. const Uint32 modulateB = info->b;
  5052. const Uint32 modulateA = info->a;
  5053. Uint32 srcpixel;
  5054. Uint32 srcR, srcG, srcB, srcA;
  5055. Uint32 dstpixel;
  5056. Uint32 dstR, dstG, dstB, dstA;
  5057. Uint64 srcy, srcx;
  5058. Uint64 posy, posx;
  5059. Uint64 incy, incx;
  5060. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5061. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5062. posy = incy / 2;
  5063. while (info->dst_h--) {
  5064. Uint32 *src = 0;
  5065. Uint32 *dst = (Uint32 *)info->dst;
  5066. int n = info->dst_w;
  5067. posx = incx / 2;
  5068. srcy = posy >> 16;
  5069. while (n--) {
  5070. srcx = posx >> 16;
  5071. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5072. srcpixel = *src;
  5073. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5074. dstpixel = *dst;
  5075. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  5076. if (flags & SDL_COPY_MODULATE_COLOR) {
  5077. MULT_DIV_255(srcR, modulateR, srcR);
  5078. MULT_DIV_255(srcG, modulateG, srcG);
  5079. MULT_DIV_255(srcB, modulateB, srcB);
  5080. }
  5081. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5082. MULT_DIV_255(srcA, modulateA, srcA);
  5083. }
  5084. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5085. if (srcA < 255) {
  5086. MULT_DIV_255(srcR, srcA, srcR);
  5087. MULT_DIV_255(srcG, srcA, srcG);
  5088. MULT_DIV_255(srcB, srcA, srcB);
  5089. }
  5090. }
  5091. switch (flags & SDL_COPY_BLEND_MASK) {
  5092. case SDL_COPY_BLEND:
  5093. MULT_DIV_255((255 - srcA), dstR, dstR);
  5094. dstR += srcR;
  5095. MULT_DIV_255((255 - srcA), dstG, dstG);
  5096. dstG += srcG;
  5097. MULT_DIV_255((255 - srcA), dstB, dstB);
  5098. dstB += srcB;
  5099. MULT_DIV_255((255 - srcA), dstA, dstA);
  5100. dstA += srcA;
  5101. break;
  5102. case SDL_COPY_BLEND_PREMULTIPLIED:
  5103. MULT_DIV_255((255 - srcA), dstR, dstR);
  5104. dstR += srcR;
  5105. if (dstR > 255) dstR = 255;
  5106. MULT_DIV_255((255 - srcA), dstG, dstG);
  5107. dstG += srcG;
  5108. if (dstG > 255) dstG = 255;
  5109. MULT_DIV_255((255 - srcA), dstB, dstB);
  5110. dstB += srcB;
  5111. if (dstB > 255) dstB = 255;
  5112. MULT_DIV_255((255 - srcA), dstA, dstA);
  5113. dstA += srcA;
  5114. if (dstA > 255) dstA = 255;
  5115. break;
  5116. case SDL_COPY_ADD:
  5117. case SDL_COPY_ADD_PREMULTIPLIED:
  5118. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5119. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5120. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5121. break;
  5122. case SDL_COPY_MOD:
  5123. MULT_DIV_255(srcR, dstR, dstR);
  5124. MULT_DIV_255(srcG, dstG, dstG);
  5125. MULT_DIV_255(srcB, dstB, dstB);
  5126. break;
  5127. case SDL_COPY_MUL:
  5128. {
  5129. Uint32 tmp1, tmp2;
  5130. MULT_DIV_255(srcR, dstR, tmp1);
  5131. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5132. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5133. MULT_DIV_255(srcG, dstG, tmp1);
  5134. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5135. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5136. MULT_DIV_255(srcB, dstB, tmp1);
  5137. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5138. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5139. }
  5140. break;
  5141. }
  5142. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  5143. *dst = dstpixel;
  5144. posx += incx;
  5145. ++dst;
  5146. }
  5147. posy += incy;
  5148. info->dst += info->dst_pitch;
  5149. }
  5150. }
  5151. static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
  5152. {
  5153. Uint32 pixel;
  5154. Uint64 srcy, srcx;
  5155. Uint64 posy, posx;
  5156. Uint64 incy, incx;
  5157. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5158. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5159. posy = incy / 2;
  5160. while (info->dst_h--) {
  5161. Uint32 *src = 0;
  5162. Uint32 *dst = (Uint32 *)info->dst;
  5163. int n = info->dst_w;
  5164. posx = incx / 2;
  5165. srcy = posy >> 16;
  5166. while (n--) {
  5167. srcx = posx >> 16;
  5168. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5169. pixel = *src;
  5170. pixel >>= 8;
  5171. *dst = pixel;
  5172. posx += incx;
  5173. ++dst;
  5174. }
  5175. posy += incy;
  5176. info->dst += info->dst_pitch;
  5177. }
  5178. }
  5179. static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
  5180. {
  5181. const int flags = info->flags;
  5182. Uint32 srcpixel;
  5183. Uint32 srcR, srcG, srcB, srcA;
  5184. Uint32 dstpixel;
  5185. Uint32 dstR, dstG, dstB;
  5186. while (info->dst_h--) {
  5187. Uint32 *src = (Uint32 *)info->src;
  5188. Uint32 *dst = (Uint32 *)info->dst;
  5189. int n = info->dst_w;
  5190. while (n--) {
  5191. srcpixel = *src;
  5192. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5193. dstpixel = *dst;
  5194. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5195. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5196. if (srcA < 255) {
  5197. MULT_DIV_255(srcR, srcA, srcR);
  5198. MULT_DIV_255(srcG, srcA, srcG);
  5199. MULT_DIV_255(srcB, srcA, srcB);
  5200. }
  5201. }
  5202. switch (flags & SDL_COPY_BLEND_MASK) {
  5203. case SDL_COPY_BLEND:
  5204. MULT_DIV_255((255 - srcA), dstR, dstR);
  5205. dstR += srcR;
  5206. MULT_DIV_255((255 - srcA), dstG, dstG);
  5207. dstG += srcG;
  5208. MULT_DIV_255((255 - srcA), dstB, dstB);
  5209. dstB += srcB;
  5210. break;
  5211. case SDL_COPY_BLEND_PREMULTIPLIED:
  5212. MULT_DIV_255((255 - srcA), dstR, dstR);
  5213. dstR += srcR;
  5214. if (dstR > 255) dstR = 255;
  5215. MULT_DIV_255((255 - srcA), dstG, dstG);
  5216. dstG += srcG;
  5217. if (dstG > 255) dstG = 255;
  5218. MULT_DIV_255((255 - srcA), dstB, dstB);
  5219. dstB += srcB;
  5220. if (dstB > 255) dstB = 255;
  5221. break;
  5222. case SDL_COPY_ADD:
  5223. case SDL_COPY_ADD_PREMULTIPLIED:
  5224. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5225. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5226. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5227. break;
  5228. case SDL_COPY_MOD:
  5229. MULT_DIV_255(srcR, dstR, dstR);
  5230. MULT_DIV_255(srcG, dstG, dstG);
  5231. MULT_DIV_255(srcB, dstB, dstB);
  5232. break;
  5233. case SDL_COPY_MUL:
  5234. {
  5235. Uint32 tmp1, tmp2;
  5236. MULT_DIV_255(srcR, dstR, tmp1);
  5237. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5238. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5239. MULT_DIV_255(srcG, dstG, tmp1);
  5240. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5241. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5242. MULT_DIV_255(srcB, dstB, tmp1);
  5243. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5244. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5245. }
  5246. break;
  5247. }
  5248. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5249. *dst = dstpixel;
  5250. ++src;
  5251. ++dst;
  5252. }
  5253. info->src += info->src_pitch;
  5254. info->dst += info->dst_pitch;
  5255. }
  5256. }
  5257. static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  5258. {
  5259. const int flags = info->flags;
  5260. Uint32 srcpixel;
  5261. Uint32 srcR, srcG, srcB, srcA;
  5262. Uint32 dstpixel;
  5263. Uint32 dstR, dstG, dstB;
  5264. Uint64 srcy, srcx;
  5265. Uint64 posy, posx;
  5266. Uint64 incy, incx;
  5267. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5268. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5269. posy = incy / 2;
  5270. while (info->dst_h--) {
  5271. Uint32 *src = 0;
  5272. Uint32 *dst = (Uint32 *)info->dst;
  5273. int n = info->dst_w;
  5274. posx = incx / 2;
  5275. srcy = posy >> 16;
  5276. while (n--) {
  5277. srcx = posx >> 16;
  5278. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5279. srcpixel = *src;
  5280. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5281. dstpixel = *dst;
  5282. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5283. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5284. if (srcA < 255) {
  5285. MULT_DIV_255(srcR, srcA, srcR);
  5286. MULT_DIV_255(srcG, srcA, srcG);
  5287. MULT_DIV_255(srcB, srcA, srcB);
  5288. }
  5289. }
  5290. switch (flags & SDL_COPY_BLEND_MASK) {
  5291. case SDL_COPY_BLEND:
  5292. MULT_DIV_255((255 - srcA), dstR, dstR);
  5293. dstR += srcR;
  5294. MULT_DIV_255((255 - srcA), dstG, dstG);
  5295. dstG += srcG;
  5296. MULT_DIV_255((255 - srcA), dstB, dstB);
  5297. dstB += srcB;
  5298. break;
  5299. case SDL_COPY_BLEND_PREMULTIPLIED:
  5300. MULT_DIV_255((255 - srcA), dstR, dstR);
  5301. dstR += srcR;
  5302. if (dstR > 255) dstR = 255;
  5303. MULT_DIV_255((255 - srcA), dstG, dstG);
  5304. dstG += srcG;
  5305. if (dstG > 255) dstG = 255;
  5306. MULT_DIV_255((255 - srcA), dstB, dstB);
  5307. dstB += srcB;
  5308. if (dstB > 255) dstB = 255;
  5309. break;
  5310. case SDL_COPY_ADD:
  5311. case SDL_COPY_ADD_PREMULTIPLIED:
  5312. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5313. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5314. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5315. break;
  5316. case SDL_COPY_MOD:
  5317. MULT_DIV_255(srcR, dstR, dstR);
  5318. MULT_DIV_255(srcG, dstG, dstG);
  5319. MULT_DIV_255(srcB, dstB, dstB);
  5320. break;
  5321. case SDL_COPY_MUL:
  5322. {
  5323. Uint32 tmp1, tmp2;
  5324. MULT_DIV_255(srcR, dstR, tmp1);
  5325. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5326. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5327. MULT_DIV_255(srcG, dstG, tmp1);
  5328. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5329. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5330. MULT_DIV_255(srcB, dstB, tmp1);
  5331. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5332. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5333. }
  5334. break;
  5335. }
  5336. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5337. *dst = dstpixel;
  5338. posx += incx;
  5339. ++dst;
  5340. }
  5341. posy += incy;
  5342. info->dst += info->dst_pitch;
  5343. }
  5344. }
  5345. static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  5346. {
  5347. const int flags = info->flags;
  5348. const Uint32 modulateR = info->r;
  5349. const Uint32 modulateG = info->g;
  5350. const Uint32 modulateB = info->b;
  5351. Uint32 pixel;
  5352. Uint32 R, G, B;
  5353. while (info->dst_h--) {
  5354. Uint32 *src = (Uint32 *)info->src;
  5355. Uint32 *dst = (Uint32 *)info->dst;
  5356. int n = info->dst_w;
  5357. while (n--) {
  5358. pixel = *src;
  5359. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5360. if (flags & SDL_COPY_MODULATE_COLOR) {
  5361. MULT_DIV_255(R, modulateR, R);
  5362. MULT_DIV_255(G, modulateG, G);
  5363. MULT_DIV_255(B, modulateB, B);
  5364. }
  5365. pixel = (R << 16) | (G << 8) | B;
  5366. *dst = pixel;
  5367. ++src;
  5368. ++dst;
  5369. }
  5370. info->src += info->src_pitch;
  5371. info->dst += info->dst_pitch;
  5372. }
  5373. }
  5374. static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  5375. {
  5376. const int flags = info->flags;
  5377. const Uint32 modulateR = info->r;
  5378. const Uint32 modulateG = info->g;
  5379. const Uint32 modulateB = info->b;
  5380. Uint32 pixel;
  5381. Uint32 R, G, B;
  5382. Uint64 srcy, srcx;
  5383. Uint64 posy, posx;
  5384. Uint64 incy, incx;
  5385. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5386. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5387. posy = incy / 2;
  5388. while (info->dst_h--) {
  5389. Uint32 *src = 0;
  5390. Uint32 *dst = (Uint32 *)info->dst;
  5391. int n = info->dst_w;
  5392. posx = incx / 2;
  5393. srcy = posy >> 16;
  5394. while (n--) {
  5395. srcx = posx >> 16;
  5396. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5397. pixel = *src;
  5398. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5399. if (flags & SDL_COPY_MODULATE_COLOR) {
  5400. MULT_DIV_255(R, modulateR, R);
  5401. MULT_DIV_255(G, modulateG, G);
  5402. MULT_DIV_255(B, modulateB, B);
  5403. }
  5404. pixel = (R << 16) | (G << 8) | B;
  5405. *dst = pixel;
  5406. posx += incx;
  5407. ++dst;
  5408. }
  5409. posy += incy;
  5410. info->dst += info->dst_pitch;
  5411. }
  5412. }
  5413. static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  5414. {
  5415. const int flags = info->flags;
  5416. const Uint32 modulateR = info->r;
  5417. const Uint32 modulateG = info->g;
  5418. const Uint32 modulateB = info->b;
  5419. const Uint32 modulateA = info->a;
  5420. Uint32 srcpixel;
  5421. Uint32 srcR, srcG, srcB, srcA;
  5422. Uint32 dstpixel;
  5423. Uint32 dstR, dstG, dstB;
  5424. while (info->dst_h--) {
  5425. Uint32 *src = (Uint32 *)info->src;
  5426. Uint32 *dst = (Uint32 *)info->dst;
  5427. int n = info->dst_w;
  5428. while (n--) {
  5429. srcpixel = *src;
  5430. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5431. dstpixel = *dst;
  5432. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5433. if (flags & SDL_COPY_MODULATE_COLOR) {
  5434. MULT_DIV_255(srcR, modulateR, srcR);
  5435. MULT_DIV_255(srcG, modulateG, srcG);
  5436. MULT_DIV_255(srcB, modulateB, srcB);
  5437. }
  5438. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5439. MULT_DIV_255(srcA, modulateA, srcA);
  5440. }
  5441. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5442. if (srcA < 255) {
  5443. MULT_DIV_255(srcR, srcA, srcR);
  5444. MULT_DIV_255(srcG, srcA, srcG);
  5445. MULT_DIV_255(srcB, srcA, srcB);
  5446. }
  5447. }
  5448. switch (flags & SDL_COPY_BLEND_MASK) {
  5449. case SDL_COPY_BLEND:
  5450. MULT_DIV_255((255 - srcA), dstR, dstR);
  5451. dstR += srcR;
  5452. MULT_DIV_255((255 - srcA), dstG, dstG);
  5453. dstG += srcG;
  5454. MULT_DIV_255((255 - srcA), dstB, dstB);
  5455. dstB += srcB;
  5456. break;
  5457. case SDL_COPY_BLEND_PREMULTIPLIED:
  5458. MULT_DIV_255((255 - srcA), dstR, dstR);
  5459. dstR += srcR;
  5460. if (dstR > 255) dstR = 255;
  5461. MULT_DIV_255((255 - srcA), dstG, dstG);
  5462. dstG += srcG;
  5463. if (dstG > 255) dstG = 255;
  5464. MULT_DIV_255((255 - srcA), dstB, dstB);
  5465. dstB += srcB;
  5466. if (dstB > 255) dstB = 255;
  5467. break;
  5468. case SDL_COPY_ADD:
  5469. case SDL_COPY_ADD_PREMULTIPLIED:
  5470. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5471. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5472. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5473. break;
  5474. case SDL_COPY_MOD:
  5475. MULT_DIV_255(srcR, dstR, dstR);
  5476. MULT_DIV_255(srcG, dstG, dstG);
  5477. MULT_DIV_255(srcB, dstB, dstB);
  5478. break;
  5479. case SDL_COPY_MUL:
  5480. {
  5481. Uint32 tmp1, tmp2;
  5482. MULT_DIV_255(srcR, dstR, tmp1);
  5483. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5484. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5485. MULT_DIV_255(srcG, dstG, tmp1);
  5486. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5487. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5488. MULT_DIV_255(srcB, dstB, tmp1);
  5489. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5490. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5491. }
  5492. break;
  5493. }
  5494. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5495. *dst = dstpixel;
  5496. ++src;
  5497. ++dst;
  5498. }
  5499. info->src += info->src_pitch;
  5500. info->dst += info->dst_pitch;
  5501. }
  5502. }
  5503. static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5504. {
  5505. const int flags = info->flags;
  5506. const Uint32 modulateR = info->r;
  5507. const Uint32 modulateG = info->g;
  5508. const Uint32 modulateB = info->b;
  5509. const Uint32 modulateA = info->a;
  5510. Uint32 srcpixel;
  5511. Uint32 srcR, srcG, srcB, srcA;
  5512. Uint32 dstpixel;
  5513. Uint32 dstR, dstG, dstB;
  5514. Uint64 srcy, srcx;
  5515. Uint64 posy, posx;
  5516. Uint64 incy, incx;
  5517. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5518. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5519. posy = incy / 2;
  5520. while (info->dst_h--) {
  5521. Uint32 *src = 0;
  5522. Uint32 *dst = (Uint32 *)info->dst;
  5523. int n = info->dst_w;
  5524. posx = incx / 2;
  5525. srcy = posy >> 16;
  5526. while (n--) {
  5527. srcx = posx >> 16;
  5528. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5529. srcpixel = *src;
  5530. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5531. dstpixel = *dst;
  5532. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5533. if (flags & SDL_COPY_MODULATE_COLOR) {
  5534. MULT_DIV_255(srcR, modulateR, srcR);
  5535. MULT_DIV_255(srcG, modulateG, srcG);
  5536. MULT_DIV_255(srcB, modulateB, srcB);
  5537. }
  5538. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5539. MULT_DIV_255(srcA, modulateA, srcA);
  5540. }
  5541. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5542. if (srcA < 255) {
  5543. MULT_DIV_255(srcR, srcA, srcR);
  5544. MULT_DIV_255(srcG, srcA, srcG);
  5545. MULT_DIV_255(srcB, srcA, srcB);
  5546. }
  5547. }
  5548. switch (flags & SDL_COPY_BLEND_MASK) {
  5549. case SDL_COPY_BLEND:
  5550. MULT_DIV_255((255 - srcA), dstR, dstR);
  5551. dstR += srcR;
  5552. MULT_DIV_255((255 - srcA), dstG, dstG);
  5553. dstG += srcG;
  5554. MULT_DIV_255((255 - srcA), dstB, dstB);
  5555. dstB += srcB;
  5556. break;
  5557. case SDL_COPY_BLEND_PREMULTIPLIED:
  5558. MULT_DIV_255((255 - srcA), dstR, dstR);
  5559. dstR += srcR;
  5560. if (dstR > 255) dstR = 255;
  5561. MULT_DIV_255((255 - srcA), dstG, dstG);
  5562. dstG += srcG;
  5563. if (dstG > 255) dstG = 255;
  5564. MULT_DIV_255((255 - srcA), dstB, dstB);
  5565. dstB += srcB;
  5566. if (dstB > 255) dstB = 255;
  5567. break;
  5568. case SDL_COPY_ADD:
  5569. case SDL_COPY_ADD_PREMULTIPLIED:
  5570. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5571. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5572. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5573. break;
  5574. case SDL_COPY_MOD:
  5575. MULT_DIV_255(srcR, dstR, dstR);
  5576. MULT_DIV_255(srcG, dstG, dstG);
  5577. MULT_DIV_255(srcB, dstB, dstB);
  5578. break;
  5579. case SDL_COPY_MUL:
  5580. {
  5581. Uint32 tmp1, tmp2;
  5582. MULT_DIV_255(srcR, dstR, tmp1);
  5583. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5584. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5585. MULT_DIV_255(srcG, dstG, tmp1);
  5586. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5587. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5588. MULT_DIV_255(srcB, dstB, tmp1);
  5589. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5590. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5591. }
  5592. break;
  5593. }
  5594. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5595. *dst = dstpixel;
  5596. posx += incx;
  5597. ++dst;
  5598. }
  5599. posy += incy;
  5600. info->dst += info->dst_pitch;
  5601. }
  5602. }
  5603. static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
  5604. {
  5605. Uint32 pixel;
  5606. Uint32 R, G, B;
  5607. Uint64 srcy, srcx;
  5608. Uint64 posy, posx;
  5609. Uint64 incy, incx;
  5610. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5611. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5612. posy = incy / 2;
  5613. while (info->dst_h--) {
  5614. Uint32 *src = 0;
  5615. Uint32 *dst = (Uint32 *)info->dst;
  5616. int n = info->dst_w;
  5617. posx = incx / 2;
  5618. srcy = posy >> 16;
  5619. while (n--) {
  5620. srcx = posx >> 16;
  5621. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5622. pixel = *src;
  5623. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5624. pixel = (B << 16) | (G << 8) | R;
  5625. *dst = pixel;
  5626. posx += incx;
  5627. ++dst;
  5628. }
  5629. posy += incy;
  5630. info->dst += info->dst_pitch;
  5631. }
  5632. }
  5633. static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
  5634. {
  5635. const int flags = info->flags;
  5636. Uint32 srcpixel;
  5637. Uint32 srcR, srcG, srcB, srcA;
  5638. Uint32 dstpixel;
  5639. Uint32 dstR, dstG, dstB;
  5640. while (info->dst_h--) {
  5641. Uint32 *src = (Uint32 *)info->src;
  5642. Uint32 *dst = (Uint32 *)info->dst;
  5643. int n = info->dst_w;
  5644. while (n--) {
  5645. srcpixel = *src;
  5646. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5647. dstpixel = *dst;
  5648. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5649. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5650. if (srcA < 255) {
  5651. MULT_DIV_255(srcR, srcA, srcR);
  5652. MULT_DIV_255(srcG, srcA, srcG);
  5653. MULT_DIV_255(srcB, srcA, srcB);
  5654. }
  5655. }
  5656. switch (flags & SDL_COPY_BLEND_MASK) {
  5657. case SDL_COPY_BLEND:
  5658. MULT_DIV_255((255 - srcA), dstR, dstR);
  5659. dstR += srcR;
  5660. MULT_DIV_255((255 - srcA), dstG, dstG);
  5661. dstG += srcG;
  5662. MULT_DIV_255((255 - srcA), dstB, dstB);
  5663. dstB += srcB;
  5664. break;
  5665. case SDL_COPY_BLEND_PREMULTIPLIED:
  5666. MULT_DIV_255((255 - srcA), dstR, dstR);
  5667. dstR += srcR;
  5668. if (dstR > 255) dstR = 255;
  5669. MULT_DIV_255((255 - srcA), dstG, dstG);
  5670. dstG += srcG;
  5671. if (dstG > 255) dstG = 255;
  5672. MULT_DIV_255((255 - srcA), dstB, dstB);
  5673. dstB += srcB;
  5674. if (dstB > 255) dstB = 255;
  5675. break;
  5676. case SDL_COPY_ADD:
  5677. case SDL_COPY_ADD_PREMULTIPLIED:
  5678. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5679. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5680. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5681. break;
  5682. case SDL_COPY_MOD:
  5683. MULT_DIV_255(srcR, dstR, dstR);
  5684. MULT_DIV_255(srcG, dstG, dstG);
  5685. MULT_DIV_255(srcB, dstB, dstB);
  5686. break;
  5687. case SDL_COPY_MUL:
  5688. {
  5689. Uint32 tmp1, tmp2;
  5690. MULT_DIV_255(srcR, dstR, tmp1);
  5691. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5692. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5693. MULT_DIV_255(srcG, dstG, tmp1);
  5694. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5695. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5696. MULT_DIV_255(srcB, dstB, tmp1);
  5697. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5698. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5699. }
  5700. break;
  5701. }
  5702. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5703. *dst = dstpixel;
  5704. ++src;
  5705. ++dst;
  5706. }
  5707. info->src += info->src_pitch;
  5708. info->dst += info->dst_pitch;
  5709. }
  5710. }
  5711. static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  5712. {
  5713. const int flags = info->flags;
  5714. Uint32 srcpixel;
  5715. Uint32 srcR, srcG, srcB, srcA;
  5716. Uint32 dstpixel;
  5717. Uint32 dstR, dstG, dstB;
  5718. Uint64 srcy, srcx;
  5719. Uint64 posy, posx;
  5720. Uint64 incy, incx;
  5721. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5722. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5723. posy = incy / 2;
  5724. while (info->dst_h--) {
  5725. Uint32 *src = 0;
  5726. Uint32 *dst = (Uint32 *)info->dst;
  5727. int n = info->dst_w;
  5728. posx = incx / 2;
  5729. srcy = posy >> 16;
  5730. while (n--) {
  5731. srcx = posx >> 16;
  5732. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5733. srcpixel = *src;
  5734. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5735. dstpixel = *dst;
  5736. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5737. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5738. if (srcA < 255) {
  5739. MULT_DIV_255(srcR, srcA, srcR);
  5740. MULT_DIV_255(srcG, srcA, srcG);
  5741. MULT_DIV_255(srcB, srcA, srcB);
  5742. }
  5743. }
  5744. switch (flags & SDL_COPY_BLEND_MASK) {
  5745. case SDL_COPY_BLEND:
  5746. MULT_DIV_255((255 - srcA), dstR, dstR);
  5747. dstR += srcR;
  5748. MULT_DIV_255((255 - srcA), dstG, dstG);
  5749. dstG += srcG;
  5750. MULT_DIV_255((255 - srcA), dstB, dstB);
  5751. dstB += srcB;
  5752. break;
  5753. case SDL_COPY_BLEND_PREMULTIPLIED:
  5754. MULT_DIV_255((255 - srcA), dstR, dstR);
  5755. dstR += srcR;
  5756. if (dstR > 255) dstR = 255;
  5757. MULT_DIV_255((255 - srcA), dstG, dstG);
  5758. dstG += srcG;
  5759. if (dstG > 255) dstG = 255;
  5760. MULT_DIV_255((255 - srcA), dstB, dstB);
  5761. dstB += srcB;
  5762. if (dstB > 255) dstB = 255;
  5763. break;
  5764. case SDL_COPY_ADD:
  5765. case SDL_COPY_ADD_PREMULTIPLIED:
  5766. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5767. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5768. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5769. break;
  5770. case SDL_COPY_MOD:
  5771. MULT_DIV_255(srcR, dstR, dstR);
  5772. MULT_DIV_255(srcG, dstG, dstG);
  5773. MULT_DIV_255(srcB, dstB, dstB);
  5774. break;
  5775. case SDL_COPY_MUL:
  5776. {
  5777. Uint32 tmp1, tmp2;
  5778. MULT_DIV_255(srcR, dstR, tmp1);
  5779. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5780. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5781. MULT_DIV_255(srcG, dstG, tmp1);
  5782. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5783. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5784. MULT_DIV_255(srcB, dstB, tmp1);
  5785. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5786. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5787. }
  5788. break;
  5789. }
  5790. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5791. *dst = dstpixel;
  5792. posx += incx;
  5793. ++dst;
  5794. }
  5795. posy += incy;
  5796. info->dst += info->dst_pitch;
  5797. }
  5798. }
  5799. static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  5800. {
  5801. const int flags = info->flags;
  5802. const Uint32 modulateR = info->r;
  5803. const Uint32 modulateG = info->g;
  5804. const Uint32 modulateB = info->b;
  5805. Uint32 pixel;
  5806. Uint32 R, G, B;
  5807. while (info->dst_h--) {
  5808. Uint32 *src = (Uint32 *)info->src;
  5809. Uint32 *dst = (Uint32 *)info->dst;
  5810. int n = info->dst_w;
  5811. while (n--) {
  5812. pixel = *src;
  5813. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5814. if (flags & SDL_COPY_MODULATE_COLOR) {
  5815. MULT_DIV_255(R, modulateR, R);
  5816. MULT_DIV_255(G, modulateG, G);
  5817. MULT_DIV_255(B, modulateB, B);
  5818. }
  5819. pixel = (B << 16) | (G << 8) | R;
  5820. *dst = pixel;
  5821. ++src;
  5822. ++dst;
  5823. }
  5824. info->src += info->src_pitch;
  5825. info->dst += info->dst_pitch;
  5826. }
  5827. }
  5828. static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  5829. {
  5830. const int flags = info->flags;
  5831. const Uint32 modulateR = info->r;
  5832. const Uint32 modulateG = info->g;
  5833. const Uint32 modulateB = info->b;
  5834. Uint32 pixel;
  5835. Uint32 R, G, B;
  5836. Uint64 srcy, srcx;
  5837. Uint64 posy, posx;
  5838. Uint64 incy, incx;
  5839. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5840. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5841. posy = incy / 2;
  5842. while (info->dst_h--) {
  5843. Uint32 *src = 0;
  5844. Uint32 *dst = (Uint32 *)info->dst;
  5845. int n = info->dst_w;
  5846. posx = incx / 2;
  5847. srcy = posy >> 16;
  5848. while (n--) {
  5849. srcx = posx >> 16;
  5850. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5851. pixel = *src;
  5852. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5853. if (flags & SDL_COPY_MODULATE_COLOR) {
  5854. MULT_DIV_255(R, modulateR, R);
  5855. MULT_DIV_255(G, modulateG, G);
  5856. MULT_DIV_255(B, modulateB, B);
  5857. }
  5858. pixel = (B << 16) | (G << 8) | R;
  5859. *dst = pixel;
  5860. posx += incx;
  5861. ++dst;
  5862. }
  5863. posy += incy;
  5864. info->dst += info->dst_pitch;
  5865. }
  5866. }
  5867. static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  5868. {
  5869. const int flags = info->flags;
  5870. const Uint32 modulateR = info->r;
  5871. const Uint32 modulateG = info->g;
  5872. const Uint32 modulateB = info->b;
  5873. const Uint32 modulateA = info->a;
  5874. Uint32 srcpixel;
  5875. Uint32 srcR, srcG, srcB, srcA;
  5876. Uint32 dstpixel;
  5877. Uint32 dstR, dstG, dstB;
  5878. while (info->dst_h--) {
  5879. Uint32 *src = (Uint32 *)info->src;
  5880. Uint32 *dst = (Uint32 *)info->dst;
  5881. int n = info->dst_w;
  5882. while (n--) {
  5883. srcpixel = *src;
  5884. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5885. dstpixel = *dst;
  5886. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5887. if (flags & SDL_COPY_MODULATE_COLOR) {
  5888. MULT_DIV_255(srcR, modulateR, srcR);
  5889. MULT_DIV_255(srcG, modulateG, srcG);
  5890. MULT_DIV_255(srcB, modulateB, srcB);
  5891. }
  5892. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5893. MULT_DIV_255(srcA, modulateA, srcA);
  5894. }
  5895. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5896. if (srcA < 255) {
  5897. MULT_DIV_255(srcR, srcA, srcR);
  5898. MULT_DIV_255(srcG, srcA, srcG);
  5899. MULT_DIV_255(srcB, srcA, srcB);
  5900. }
  5901. }
  5902. switch (flags & SDL_COPY_BLEND_MASK) {
  5903. case SDL_COPY_BLEND:
  5904. MULT_DIV_255((255 - srcA), dstR, dstR);
  5905. dstR += srcR;
  5906. MULT_DIV_255((255 - srcA), dstG, dstG);
  5907. dstG += srcG;
  5908. MULT_DIV_255((255 - srcA), dstB, dstB);
  5909. dstB += srcB;
  5910. break;
  5911. case SDL_COPY_BLEND_PREMULTIPLIED:
  5912. MULT_DIV_255((255 - srcA), dstR, dstR);
  5913. dstR += srcR;
  5914. if (dstR > 255) dstR = 255;
  5915. MULT_DIV_255((255 - srcA), dstG, dstG);
  5916. dstG += srcG;
  5917. if (dstG > 255) dstG = 255;
  5918. MULT_DIV_255((255 - srcA), dstB, dstB);
  5919. dstB += srcB;
  5920. if (dstB > 255) dstB = 255;
  5921. break;
  5922. case SDL_COPY_ADD:
  5923. case SDL_COPY_ADD_PREMULTIPLIED:
  5924. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5925. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5926. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5927. break;
  5928. case SDL_COPY_MOD:
  5929. MULT_DIV_255(srcR, dstR, dstR);
  5930. MULT_DIV_255(srcG, dstG, dstG);
  5931. MULT_DIV_255(srcB, dstB, dstB);
  5932. break;
  5933. case SDL_COPY_MUL:
  5934. {
  5935. Uint32 tmp1, tmp2;
  5936. MULT_DIV_255(srcR, dstR, tmp1);
  5937. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5938. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5939. MULT_DIV_255(srcG, dstG, tmp1);
  5940. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5941. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5942. MULT_DIV_255(srcB, dstB, tmp1);
  5943. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5944. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5945. }
  5946. break;
  5947. }
  5948. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5949. *dst = dstpixel;
  5950. ++src;
  5951. ++dst;
  5952. }
  5953. info->src += info->src_pitch;
  5954. info->dst += info->dst_pitch;
  5955. }
  5956. }
  5957. static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5958. {
  5959. const int flags = info->flags;
  5960. const Uint32 modulateR = info->r;
  5961. const Uint32 modulateG = info->g;
  5962. const Uint32 modulateB = info->b;
  5963. const Uint32 modulateA = info->a;
  5964. Uint32 srcpixel;
  5965. Uint32 srcR, srcG, srcB, srcA;
  5966. Uint32 dstpixel;
  5967. Uint32 dstR, dstG, dstB;
  5968. Uint64 srcy, srcx;
  5969. Uint64 posy, posx;
  5970. Uint64 incy, incx;
  5971. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5972. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5973. posy = incy / 2;
  5974. while (info->dst_h--) {
  5975. Uint32 *src = 0;
  5976. Uint32 *dst = (Uint32 *)info->dst;
  5977. int n = info->dst_w;
  5978. posx = incx / 2;
  5979. srcy = posy >> 16;
  5980. while (n--) {
  5981. srcx = posx >> 16;
  5982. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5983. srcpixel = *src;
  5984. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5985. dstpixel = *dst;
  5986. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5987. if (flags & SDL_COPY_MODULATE_COLOR) {
  5988. MULT_DIV_255(srcR, modulateR, srcR);
  5989. MULT_DIV_255(srcG, modulateG, srcG);
  5990. MULT_DIV_255(srcB, modulateB, srcB);
  5991. }
  5992. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5993. MULT_DIV_255(srcA, modulateA, srcA);
  5994. }
  5995. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5996. if (srcA < 255) {
  5997. MULT_DIV_255(srcR, srcA, srcR);
  5998. MULT_DIV_255(srcG, srcA, srcG);
  5999. MULT_DIV_255(srcB, srcA, srcB);
  6000. }
  6001. }
  6002. switch (flags & SDL_COPY_BLEND_MASK) {
  6003. case SDL_COPY_BLEND:
  6004. MULT_DIV_255((255 - srcA), dstR, dstR);
  6005. dstR += srcR;
  6006. MULT_DIV_255((255 - srcA), dstG, dstG);
  6007. dstG += srcG;
  6008. MULT_DIV_255((255 - srcA), dstB, dstB);
  6009. dstB += srcB;
  6010. break;
  6011. case SDL_COPY_BLEND_PREMULTIPLIED:
  6012. MULT_DIV_255((255 - srcA), dstR, dstR);
  6013. dstR += srcR;
  6014. if (dstR > 255) dstR = 255;
  6015. MULT_DIV_255((255 - srcA), dstG, dstG);
  6016. dstG += srcG;
  6017. if (dstG > 255) dstG = 255;
  6018. MULT_DIV_255((255 - srcA), dstB, dstB);
  6019. dstB += srcB;
  6020. if (dstB > 255) dstB = 255;
  6021. break;
  6022. case SDL_COPY_ADD:
  6023. case SDL_COPY_ADD_PREMULTIPLIED:
  6024. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6025. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6026. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6027. break;
  6028. case SDL_COPY_MOD:
  6029. MULT_DIV_255(srcR, dstR, dstR);
  6030. MULT_DIV_255(srcG, dstG, dstG);
  6031. MULT_DIV_255(srcB, dstB, dstB);
  6032. break;
  6033. case SDL_COPY_MUL:
  6034. {
  6035. Uint32 tmp1, tmp2;
  6036. MULT_DIV_255(srcR, dstR, tmp1);
  6037. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6038. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6039. MULT_DIV_255(srcG, dstG, tmp1);
  6040. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6041. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6042. MULT_DIV_255(srcB, dstB, tmp1);
  6043. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6044. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6045. }
  6046. break;
  6047. }
  6048. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  6049. *dst = dstpixel;
  6050. posx += incx;
  6051. ++dst;
  6052. }
  6053. posy += incy;
  6054. info->dst += info->dst_pitch;
  6055. }
  6056. }
  6057. static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  6058. {
  6059. Uint32 pixel;
  6060. Uint64 srcy, srcx;
  6061. Uint64 posy, posx;
  6062. Uint64 incy, incx;
  6063. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6064. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6065. posy = incy / 2;
  6066. while (info->dst_h--) {
  6067. Uint32 *src = 0;
  6068. Uint32 *dst = (Uint32 *)info->dst;
  6069. int n = info->dst_w;
  6070. posx = incx / 2;
  6071. srcy = posy >> 16;
  6072. while (n--) {
  6073. srcx = posx >> 16;
  6074. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6075. pixel = *src;
  6076. pixel = (pixel >> 8) | (pixel << 24);
  6077. *dst = pixel;
  6078. posx += incx;
  6079. ++dst;
  6080. }
  6081. posy += incy;
  6082. info->dst += info->dst_pitch;
  6083. }
  6084. }
  6085. static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  6086. {
  6087. const int flags = info->flags;
  6088. Uint32 srcpixel;
  6089. Uint32 srcR, srcG, srcB, srcA;
  6090. Uint32 dstpixel;
  6091. Uint32 dstR, dstG, dstB, dstA;
  6092. while (info->dst_h--) {
  6093. Uint32 *src = (Uint32 *)info->src;
  6094. Uint32 *dst = (Uint32 *)info->dst;
  6095. int n = info->dst_w;
  6096. while (n--) {
  6097. srcpixel = *src;
  6098. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6099. dstpixel = *dst;
  6100. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6101. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6102. if (srcA < 255) {
  6103. MULT_DIV_255(srcR, srcA, srcR);
  6104. MULT_DIV_255(srcG, srcA, srcG);
  6105. MULT_DIV_255(srcB, srcA, srcB);
  6106. }
  6107. }
  6108. switch (flags & SDL_COPY_BLEND_MASK) {
  6109. case SDL_COPY_BLEND:
  6110. MULT_DIV_255((255 - srcA), dstR, dstR);
  6111. dstR += srcR;
  6112. MULT_DIV_255((255 - srcA), dstG, dstG);
  6113. dstG += srcG;
  6114. MULT_DIV_255((255 - srcA), dstB, dstB);
  6115. dstB += srcB;
  6116. MULT_DIV_255((255 - srcA), dstA, dstA);
  6117. dstA += srcA;
  6118. break;
  6119. case SDL_COPY_BLEND_PREMULTIPLIED:
  6120. MULT_DIV_255((255 - srcA), dstR, dstR);
  6121. dstR += srcR;
  6122. if (dstR > 255) dstR = 255;
  6123. MULT_DIV_255((255 - srcA), dstG, dstG);
  6124. dstG += srcG;
  6125. if (dstG > 255) dstG = 255;
  6126. MULT_DIV_255((255 - srcA), dstB, dstB);
  6127. dstB += srcB;
  6128. if (dstB > 255) dstB = 255;
  6129. MULT_DIV_255((255 - srcA), dstA, dstA);
  6130. dstA += srcA;
  6131. if (dstA > 255) dstA = 255;
  6132. break;
  6133. case SDL_COPY_ADD:
  6134. case SDL_COPY_ADD_PREMULTIPLIED:
  6135. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6136. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6137. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6138. break;
  6139. case SDL_COPY_MOD:
  6140. MULT_DIV_255(srcR, dstR, dstR);
  6141. MULT_DIV_255(srcG, dstG, dstG);
  6142. MULT_DIV_255(srcB, dstB, dstB);
  6143. break;
  6144. case SDL_COPY_MUL:
  6145. {
  6146. Uint32 tmp1, tmp2;
  6147. MULT_DIV_255(srcR, dstR, tmp1);
  6148. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6149. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6150. MULT_DIV_255(srcG, dstG, tmp1);
  6151. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6152. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6153. MULT_DIV_255(srcB, dstB, tmp1);
  6154. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6155. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6156. }
  6157. break;
  6158. }
  6159. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6160. *dst = dstpixel;
  6161. ++src;
  6162. ++dst;
  6163. }
  6164. info->src += info->src_pitch;
  6165. info->dst += info->dst_pitch;
  6166. }
  6167. }
  6168. static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  6169. {
  6170. const int flags = info->flags;
  6171. Uint32 srcpixel;
  6172. Uint32 srcR, srcG, srcB, srcA;
  6173. Uint32 dstpixel;
  6174. Uint32 dstR, dstG, dstB, dstA;
  6175. Uint64 srcy, srcx;
  6176. Uint64 posy, posx;
  6177. Uint64 incy, incx;
  6178. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6179. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6180. posy = incy / 2;
  6181. while (info->dst_h--) {
  6182. Uint32 *src = 0;
  6183. Uint32 *dst = (Uint32 *)info->dst;
  6184. int n = info->dst_w;
  6185. posx = incx / 2;
  6186. srcy = posy >> 16;
  6187. while (n--) {
  6188. srcx = posx >> 16;
  6189. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6190. srcpixel = *src;
  6191. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6192. dstpixel = *dst;
  6193. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6194. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6195. if (srcA < 255) {
  6196. MULT_DIV_255(srcR, srcA, srcR);
  6197. MULT_DIV_255(srcG, srcA, srcG);
  6198. MULT_DIV_255(srcB, srcA, srcB);
  6199. }
  6200. }
  6201. switch (flags & SDL_COPY_BLEND_MASK) {
  6202. case SDL_COPY_BLEND:
  6203. MULT_DIV_255((255 - srcA), dstR, dstR);
  6204. dstR += srcR;
  6205. MULT_DIV_255((255 - srcA), dstG, dstG);
  6206. dstG += srcG;
  6207. MULT_DIV_255((255 - srcA), dstB, dstB);
  6208. dstB += srcB;
  6209. MULT_DIV_255((255 - srcA), dstA, dstA);
  6210. dstA += srcA;
  6211. break;
  6212. case SDL_COPY_BLEND_PREMULTIPLIED:
  6213. MULT_DIV_255((255 - srcA), dstR, dstR);
  6214. dstR += srcR;
  6215. if (dstR > 255) dstR = 255;
  6216. MULT_DIV_255((255 - srcA), dstG, dstG);
  6217. dstG += srcG;
  6218. if (dstG > 255) dstG = 255;
  6219. MULT_DIV_255((255 - srcA), dstB, dstB);
  6220. dstB += srcB;
  6221. if (dstB > 255) dstB = 255;
  6222. MULT_DIV_255((255 - srcA), dstA, dstA);
  6223. dstA += srcA;
  6224. if (dstA > 255) dstA = 255;
  6225. break;
  6226. case SDL_COPY_ADD:
  6227. case SDL_COPY_ADD_PREMULTIPLIED:
  6228. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6229. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6230. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6231. break;
  6232. case SDL_COPY_MOD:
  6233. MULT_DIV_255(srcR, dstR, dstR);
  6234. MULT_DIV_255(srcG, dstG, dstG);
  6235. MULT_DIV_255(srcB, dstB, dstB);
  6236. break;
  6237. case SDL_COPY_MUL:
  6238. {
  6239. Uint32 tmp1, tmp2;
  6240. MULT_DIV_255(srcR, dstR, tmp1);
  6241. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6242. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6243. MULT_DIV_255(srcG, dstG, tmp1);
  6244. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6245. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6246. MULT_DIV_255(srcB, dstB, tmp1);
  6247. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6248. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6249. }
  6250. break;
  6251. }
  6252. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6253. *dst = dstpixel;
  6254. posx += incx;
  6255. ++dst;
  6256. }
  6257. posy += incy;
  6258. info->dst += info->dst_pitch;
  6259. }
  6260. }
  6261. static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  6262. {
  6263. const int flags = info->flags;
  6264. const Uint32 modulateR = info->r;
  6265. const Uint32 modulateG = info->g;
  6266. const Uint32 modulateB = info->b;
  6267. const Uint32 modulateA = info->a;
  6268. Uint32 pixel;
  6269. Uint32 R, G, B, A;
  6270. while (info->dst_h--) {
  6271. Uint32 *src = (Uint32 *)info->src;
  6272. Uint32 *dst = (Uint32 *)info->dst;
  6273. int n = info->dst_w;
  6274. while (n--) {
  6275. pixel = *src;
  6276. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6277. if (flags & SDL_COPY_MODULATE_COLOR) {
  6278. MULT_DIV_255(R, modulateR, R);
  6279. MULT_DIV_255(G, modulateG, G);
  6280. MULT_DIV_255(B, modulateB, B);
  6281. }
  6282. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6283. MULT_DIV_255(A, modulateA, A);
  6284. }
  6285. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  6286. *dst = pixel;
  6287. ++src;
  6288. ++dst;
  6289. }
  6290. info->src += info->src_pitch;
  6291. info->dst += info->dst_pitch;
  6292. }
  6293. }
  6294. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  6295. {
  6296. const int flags = info->flags;
  6297. const Uint32 modulateR = info->r;
  6298. const Uint32 modulateG = info->g;
  6299. const Uint32 modulateB = info->b;
  6300. const Uint32 modulateA = info->a;
  6301. Uint32 pixel;
  6302. Uint32 R, G, B, A;
  6303. Uint64 srcy, srcx;
  6304. Uint64 posy, posx;
  6305. Uint64 incy, incx;
  6306. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6307. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6308. posy = incy / 2;
  6309. while (info->dst_h--) {
  6310. Uint32 *src = 0;
  6311. Uint32 *dst = (Uint32 *)info->dst;
  6312. int n = info->dst_w;
  6313. posx = incx / 2;
  6314. srcy = posy >> 16;
  6315. while (n--) {
  6316. srcx = posx >> 16;
  6317. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6318. pixel = *src;
  6319. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6320. if (flags & SDL_COPY_MODULATE_COLOR) {
  6321. MULT_DIV_255(R, modulateR, R);
  6322. MULT_DIV_255(G, modulateG, G);
  6323. MULT_DIV_255(B, modulateB, B);
  6324. }
  6325. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6326. MULT_DIV_255(A, modulateA, A);
  6327. }
  6328. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  6329. *dst = pixel;
  6330. posx += incx;
  6331. ++dst;
  6332. }
  6333. posy += incy;
  6334. info->dst += info->dst_pitch;
  6335. }
  6336. }
  6337. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  6338. {
  6339. const int flags = info->flags;
  6340. const Uint32 modulateR = info->r;
  6341. const Uint32 modulateG = info->g;
  6342. const Uint32 modulateB = info->b;
  6343. const Uint32 modulateA = info->a;
  6344. Uint32 srcpixel;
  6345. Uint32 srcR, srcG, srcB, srcA;
  6346. Uint32 dstpixel;
  6347. Uint32 dstR, dstG, dstB, dstA;
  6348. while (info->dst_h--) {
  6349. Uint32 *src = (Uint32 *)info->src;
  6350. Uint32 *dst = (Uint32 *)info->dst;
  6351. int n = info->dst_w;
  6352. while (n--) {
  6353. srcpixel = *src;
  6354. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6355. dstpixel = *dst;
  6356. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6357. if (flags & SDL_COPY_MODULATE_COLOR) {
  6358. MULT_DIV_255(srcR, modulateR, srcR);
  6359. MULT_DIV_255(srcG, modulateG, srcG);
  6360. MULT_DIV_255(srcB, modulateB, srcB);
  6361. }
  6362. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6363. MULT_DIV_255(srcA, modulateA, srcA);
  6364. }
  6365. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6366. if (srcA < 255) {
  6367. MULT_DIV_255(srcR, srcA, srcR);
  6368. MULT_DIV_255(srcG, srcA, srcG);
  6369. MULT_DIV_255(srcB, srcA, srcB);
  6370. }
  6371. }
  6372. switch (flags & SDL_COPY_BLEND_MASK) {
  6373. case SDL_COPY_BLEND:
  6374. MULT_DIV_255((255 - srcA), dstR, dstR);
  6375. dstR += srcR;
  6376. MULT_DIV_255((255 - srcA), dstG, dstG);
  6377. dstG += srcG;
  6378. MULT_DIV_255((255 - srcA), dstB, dstB);
  6379. dstB += srcB;
  6380. MULT_DIV_255((255 - srcA), dstA, dstA);
  6381. dstA += srcA;
  6382. break;
  6383. case SDL_COPY_BLEND_PREMULTIPLIED:
  6384. MULT_DIV_255((255 - srcA), dstR, dstR);
  6385. dstR += srcR;
  6386. if (dstR > 255) dstR = 255;
  6387. MULT_DIV_255((255 - srcA), dstG, dstG);
  6388. dstG += srcG;
  6389. if (dstG > 255) dstG = 255;
  6390. MULT_DIV_255((255 - srcA), dstB, dstB);
  6391. dstB += srcB;
  6392. if (dstB > 255) dstB = 255;
  6393. MULT_DIV_255((255 - srcA), dstA, dstA);
  6394. dstA += srcA;
  6395. if (dstA > 255) dstA = 255;
  6396. break;
  6397. case SDL_COPY_ADD:
  6398. case SDL_COPY_ADD_PREMULTIPLIED:
  6399. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6400. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6401. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6402. break;
  6403. case SDL_COPY_MOD:
  6404. MULT_DIV_255(srcR, dstR, dstR);
  6405. MULT_DIV_255(srcG, dstG, dstG);
  6406. MULT_DIV_255(srcB, dstB, dstB);
  6407. break;
  6408. case SDL_COPY_MUL:
  6409. {
  6410. Uint32 tmp1, tmp2;
  6411. MULT_DIV_255(srcR, dstR, tmp1);
  6412. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6413. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6414. MULT_DIV_255(srcG, dstG, tmp1);
  6415. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6416. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6417. MULT_DIV_255(srcB, dstB, tmp1);
  6418. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6419. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6420. }
  6421. break;
  6422. }
  6423. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6424. *dst = dstpixel;
  6425. ++src;
  6426. ++dst;
  6427. }
  6428. info->src += info->src_pitch;
  6429. info->dst += info->dst_pitch;
  6430. }
  6431. }
  6432. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6433. {
  6434. const int flags = info->flags;
  6435. const Uint32 modulateR = info->r;
  6436. const Uint32 modulateG = info->g;
  6437. const Uint32 modulateB = info->b;
  6438. const Uint32 modulateA = info->a;
  6439. Uint32 srcpixel;
  6440. Uint32 srcR, srcG, srcB, srcA;
  6441. Uint32 dstpixel;
  6442. Uint32 dstR, dstG, dstB, dstA;
  6443. Uint64 srcy, srcx;
  6444. Uint64 posy, posx;
  6445. Uint64 incy, incx;
  6446. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6447. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6448. posy = incy / 2;
  6449. while (info->dst_h--) {
  6450. Uint32 *src = 0;
  6451. Uint32 *dst = (Uint32 *)info->dst;
  6452. int n = info->dst_w;
  6453. posx = incx / 2;
  6454. srcy = posy >> 16;
  6455. while (n--) {
  6456. srcx = posx >> 16;
  6457. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6458. srcpixel = *src;
  6459. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6460. dstpixel = *dst;
  6461. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6462. if (flags & SDL_COPY_MODULATE_COLOR) {
  6463. MULT_DIV_255(srcR, modulateR, srcR);
  6464. MULT_DIV_255(srcG, modulateG, srcG);
  6465. MULT_DIV_255(srcB, modulateB, srcB);
  6466. }
  6467. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6468. MULT_DIV_255(srcA, modulateA, srcA);
  6469. }
  6470. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6471. if (srcA < 255) {
  6472. MULT_DIV_255(srcR, srcA, srcR);
  6473. MULT_DIV_255(srcG, srcA, srcG);
  6474. MULT_DIV_255(srcB, srcA, srcB);
  6475. }
  6476. }
  6477. switch (flags & SDL_COPY_BLEND_MASK) {
  6478. case SDL_COPY_BLEND:
  6479. MULT_DIV_255((255 - srcA), dstR, dstR);
  6480. dstR += srcR;
  6481. MULT_DIV_255((255 - srcA), dstG, dstG);
  6482. dstG += srcG;
  6483. MULT_DIV_255((255 - srcA), dstB, dstB);
  6484. dstB += srcB;
  6485. MULT_DIV_255((255 - srcA), dstA, dstA);
  6486. dstA += srcA;
  6487. break;
  6488. case SDL_COPY_BLEND_PREMULTIPLIED:
  6489. MULT_DIV_255((255 - srcA), dstR, dstR);
  6490. dstR += srcR;
  6491. if (dstR > 255) dstR = 255;
  6492. MULT_DIV_255((255 - srcA), dstG, dstG);
  6493. dstG += srcG;
  6494. if (dstG > 255) dstG = 255;
  6495. MULT_DIV_255((255 - srcA), dstB, dstB);
  6496. dstB += srcB;
  6497. if (dstB > 255) dstB = 255;
  6498. MULT_DIV_255((255 - srcA), dstA, dstA);
  6499. dstA += srcA;
  6500. if (dstA > 255) dstA = 255;
  6501. break;
  6502. case SDL_COPY_ADD:
  6503. case SDL_COPY_ADD_PREMULTIPLIED:
  6504. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6505. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6506. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6507. break;
  6508. case SDL_COPY_MOD:
  6509. MULT_DIV_255(srcR, dstR, dstR);
  6510. MULT_DIV_255(srcG, dstG, dstG);
  6511. MULT_DIV_255(srcB, dstB, dstB);
  6512. break;
  6513. case SDL_COPY_MUL:
  6514. {
  6515. Uint32 tmp1, tmp2;
  6516. MULT_DIV_255(srcR, dstR, tmp1);
  6517. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6518. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6519. MULT_DIV_255(srcG, dstG, tmp1);
  6520. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6521. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6522. MULT_DIV_255(srcB, dstB, tmp1);
  6523. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6524. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6525. }
  6526. break;
  6527. }
  6528. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6529. *dst = dstpixel;
  6530. posx += incx;
  6531. ++dst;
  6532. }
  6533. posy += incy;
  6534. info->dst += info->dst_pitch;
  6535. }
  6536. }
  6537. static void SDL_Blit_RGBA8888_ABGR8888_Scale(SDL_BlitInfo *info)
  6538. {
  6539. Uint32 pixel;
  6540. Uint32 R, G, B, A;
  6541. Uint64 srcy, srcx;
  6542. Uint64 posy, posx;
  6543. Uint64 incy, incx;
  6544. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6545. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6546. posy = incy / 2;
  6547. while (info->dst_h--) {
  6548. Uint32 *src = 0;
  6549. Uint32 *dst = (Uint32 *)info->dst;
  6550. int n = info->dst_w;
  6551. posx = incx / 2;
  6552. srcy = posy >> 16;
  6553. while (n--) {
  6554. srcx = posx >> 16;
  6555. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6556. pixel = *src;
  6557. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6558. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  6559. *dst = pixel;
  6560. posx += incx;
  6561. ++dst;
  6562. }
  6563. posy += incy;
  6564. info->dst += info->dst_pitch;
  6565. }
  6566. }
  6567. static void SDL_Blit_RGBA8888_ABGR8888_Blend(SDL_BlitInfo *info)
  6568. {
  6569. const int flags = info->flags;
  6570. Uint32 srcpixel;
  6571. Uint32 srcR, srcG, srcB, srcA;
  6572. Uint32 dstpixel;
  6573. Uint32 dstR, dstG, dstB, dstA;
  6574. while (info->dst_h--) {
  6575. Uint32 *src = (Uint32 *)info->src;
  6576. Uint32 *dst = (Uint32 *)info->dst;
  6577. int n = info->dst_w;
  6578. while (n--) {
  6579. srcpixel = *src;
  6580. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6581. dstpixel = *dst;
  6582. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6583. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6584. if (srcA < 255) {
  6585. MULT_DIV_255(srcR, srcA, srcR);
  6586. MULT_DIV_255(srcG, srcA, srcG);
  6587. MULT_DIV_255(srcB, srcA, srcB);
  6588. }
  6589. }
  6590. switch (flags & SDL_COPY_BLEND_MASK) {
  6591. case SDL_COPY_BLEND:
  6592. MULT_DIV_255((255 - srcA), dstR, dstR);
  6593. dstR += srcR;
  6594. MULT_DIV_255((255 - srcA), dstG, dstG);
  6595. dstG += srcG;
  6596. MULT_DIV_255((255 - srcA), dstB, dstB);
  6597. dstB += srcB;
  6598. MULT_DIV_255((255 - srcA), dstA, dstA);
  6599. dstA += srcA;
  6600. break;
  6601. case SDL_COPY_BLEND_PREMULTIPLIED:
  6602. MULT_DIV_255((255 - srcA), dstR, dstR);
  6603. dstR += srcR;
  6604. if (dstR > 255) dstR = 255;
  6605. MULT_DIV_255((255 - srcA), dstG, dstG);
  6606. dstG += srcG;
  6607. if (dstG > 255) dstG = 255;
  6608. MULT_DIV_255((255 - srcA), dstB, dstB);
  6609. dstB += srcB;
  6610. if (dstB > 255) dstB = 255;
  6611. MULT_DIV_255((255 - srcA), dstA, dstA);
  6612. dstA += srcA;
  6613. if (dstA > 255) dstA = 255;
  6614. break;
  6615. case SDL_COPY_ADD:
  6616. case SDL_COPY_ADD_PREMULTIPLIED:
  6617. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6618. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6619. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6620. break;
  6621. case SDL_COPY_MOD:
  6622. MULT_DIV_255(srcR, dstR, dstR);
  6623. MULT_DIV_255(srcG, dstG, dstG);
  6624. MULT_DIV_255(srcB, dstB, dstB);
  6625. break;
  6626. case SDL_COPY_MUL:
  6627. {
  6628. Uint32 tmp1, tmp2;
  6629. MULT_DIV_255(srcR, dstR, tmp1);
  6630. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6631. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6632. MULT_DIV_255(srcG, dstG, tmp1);
  6633. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6634. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6635. MULT_DIV_255(srcB, dstB, tmp1);
  6636. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6637. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6638. }
  6639. break;
  6640. }
  6641. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  6642. *dst = dstpixel;
  6643. ++src;
  6644. ++dst;
  6645. }
  6646. info->src += info->src_pitch;
  6647. info->dst += info->dst_pitch;
  6648. }
  6649. }
  6650. static void SDL_Blit_RGBA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  6651. {
  6652. const int flags = info->flags;
  6653. Uint32 srcpixel;
  6654. Uint32 srcR, srcG, srcB, srcA;
  6655. Uint32 dstpixel;
  6656. Uint32 dstR, dstG, dstB, dstA;
  6657. Uint64 srcy, srcx;
  6658. Uint64 posy, posx;
  6659. Uint64 incy, incx;
  6660. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6661. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6662. posy = incy / 2;
  6663. while (info->dst_h--) {
  6664. Uint32 *src = 0;
  6665. Uint32 *dst = (Uint32 *)info->dst;
  6666. int n = info->dst_w;
  6667. posx = incx / 2;
  6668. srcy = posy >> 16;
  6669. while (n--) {
  6670. srcx = posx >> 16;
  6671. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6672. srcpixel = *src;
  6673. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6674. dstpixel = *dst;
  6675. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6676. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6677. if (srcA < 255) {
  6678. MULT_DIV_255(srcR, srcA, srcR);
  6679. MULT_DIV_255(srcG, srcA, srcG);
  6680. MULT_DIV_255(srcB, srcA, srcB);
  6681. }
  6682. }
  6683. switch (flags & SDL_COPY_BLEND_MASK) {
  6684. case SDL_COPY_BLEND:
  6685. MULT_DIV_255((255 - srcA), dstR, dstR);
  6686. dstR += srcR;
  6687. MULT_DIV_255((255 - srcA), dstG, dstG);
  6688. dstG += srcG;
  6689. MULT_DIV_255((255 - srcA), dstB, dstB);
  6690. dstB += srcB;
  6691. MULT_DIV_255((255 - srcA), dstA, dstA);
  6692. dstA += srcA;
  6693. break;
  6694. case SDL_COPY_BLEND_PREMULTIPLIED:
  6695. MULT_DIV_255((255 - srcA), dstR, dstR);
  6696. dstR += srcR;
  6697. if (dstR > 255) dstR = 255;
  6698. MULT_DIV_255((255 - srcA), dstG, dstG);
  6699. dstG += srcG;
  6700. if (dstG > 255) dstG = 255;
  6701. MULT_DIV_255((255 - srcA), dstB, dstB);
  6702. dstB += srcB;
  6703. if (dstB > 255) dstB = 255;
  6704. MULT_DIV_255((255 - srcA), dstA, dstA);
  6705. dstA += srcA;
  6706. if (dstA > 255) dstA = 255;
  6707. break;
  6708. case SDL_COPY_ADD:
  6709. case SDL_COPY_ADD_PREMULTIPLIED:
  6710. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6711. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6712. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6713. break;
  6714. case SDL_COPY_MOD:
  6715. MULT_DIV_255(srcR, dstR, dstR);
  6716. MULT_DIV_255(srcG, dstG, dstG);
  6717. MULT_DIV_255(srcB, dstB, dstB);
  6718. break;
  6719. case SDL_COPY_MUL:
  6720. {
  6721. Uint32 tmp1, tmp2;
  6722. MULT_DIV_255(srcR, dstR, tmp1);
  6723. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6724. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6725. MULT_DIV_255(srcG, dstG, tmp1);
  6726. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6727. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6728. MULT_DIV_255(srcB, dstB, tmp1);
  6729. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6730. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6731. }
  6732. break;
  6733. }
  6734. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  6735. *dst = dstpixel;
  6736. posx += incx;
  6737. ++dst;
  6738. }
  6739. posy += incy;
  6740. info->dst += info->dst_pitch;
  6741. }
  6742. }
  6743. static void SDL_Blit_RGBA8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  6744. {
  6745. const int flags = info->flags;
  6746. const Uint32 modulateR = info->r;
  6747. const Uint32 modulateG = info->g;
  6748. const Uint32 modulateB = info->b;
  6749. const Uint32 modulateA = info->a;
  6750. Uint32 pixel;
  6751. Uint32 R, G, B, A;
  6752. while (info->dst_h--) {
  6753. Uint32 *src = (Uint32 *)info->src;
  6754. Uint32 *dst = (Uint32 *)info->dst;
  6755. int n = info->dst_w;
  6756. while (n--) {
  6757. pixel = *src;
  6758. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6759. if (flags & SDL_COPY_MODULATE_COLOR) {
  6760. MULT_DIV_255(R, modulateR, R);
  6761. MULT_DIV_255(G, modulateG, G);
  6762. MULT_DIV_255(B, modulateB, B);
  6763. }
  6764. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6765. MULT_DIV_255(A, modulateA, A);
  6766. }
  6767. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  6768. *dst = pixel;
  6769. ++src;
  6770. ++dst;
  6771. }
  6772. info->src += info->src_pitch;
  6773. info->dst += info->dst_pitch;
  6774. }
  6775. }
  6776. static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  6777. {
  6778. const int flags = info->flags;
  6779. const Uint32 modulateR = info->r;
  6780. const Uint32 modulateG = info->g;
  6781. const Uint32 modulateB = info->b;
  6782. const Uint32 modulateA = info->a;
  6783. Uint32 pixel;
  6784. Uint32 R, G, B, A;
  6785. Uint64 srcy, srcx;
  6786. Uint64 posy, posx;
  6787. Uint64 incy, incx;
  6788. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6789. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6790. posy = incy / 2;
  6791. while (info->dst_h--) {
  6792. Uint32 *src = 0;
  6793. Uint32 *dst = (Uint32 *)info->dst;
  6794. int n = info->dst_w;
  6795. posx = incx / 2;
  6796. srcy = posy >> 16;
  6797. while (n--) {
  6798. srcx = posx >> 16;
  6799. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6800. pixel = *src;
  6801. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6802. if (flags & SDL_COPY_MODULATE_COLOR) {
  6803. MULT_DIV_255(R, modulateR, R);
  6804. MULT_DIV_255(G, modulateG, G);
  6805. MULT_DIV_255(B, modulateB, B);
  6806. }
  6807. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6808. MULT_DIV_255(A, modulateA, A);
  6809. }
  6810. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  6811. *dst = pixel;
  6812. posx += incx;
  6813. ++dst;
  6814. }
  6815. posy += incy;
  6816. info->dst += info->dst_pitch;
  6817. }
  6818. }
  6819. static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  6820. {
  6821. const int flags = info->flags;
  6822. const Uint32 modulateR = info->r;
  6823. const Uint32 modulateG = info->g;
  6824. const Uint32 modulateB = info->b;
  6825. const Uint32 modulateA = info->a;
  6826. Uint32 srcpixel;
  6827. Uint32 srcR, srcG, srcB, srcA;
  6828. Uint32 dstpixel;
  6829. Uint32 dstR, dstG, dstB, dstA;
  6830. while (info->dst_h--) {
  6831. Uint32 *src = (Uint32 *)info->src;
  6832. Uint32 *dst = (Uint32 *)info->dst;
  6833. int n = info->dst_w;
  6834. while (n--) {
  6835. srcpixel = *src;
  6836. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6837. dstpixel = *dst;
  6838. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6839. if (flags & SDL_COPY_MODULATE_COLOR) {
  6840. MULT_DIV_255(srcR, modulateR, srcR);
  6841. MULT_DIV_255(srcG, modulateG, srcG);
  6842. MULT_DIV_255(srcB, modulateB, srcB);
  6843. }
  6844. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6845. MULT_DIV_255(srcA, modulateA, srcA);
  6846. }
  6847. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6848. if (srcA < 255) {
  6849. MULT_DIV_255(srcR, srcA, srcR);
  6850. MULT_DIV_255(srcG, srcA, srcG);
  6851. MULT_DIV_255(srcB, srcA, srcB);
  6852. }
  6853. }
  6854. switch (flags & SDL_COPY_BLEND_MASK) {
  6855. case SDL_COPY_BLEND:
  6856. MULT_DIV_255((255 - srcA), dstR, dstR);
  6857. dstR += srcR;
  6858. MULT_DIV_255((255 - srcA), dstG, dstG);
  6859. dstG += srcG;
  6860. MULT_DIV_255((255 - srcA), dstB, dstB);
  6861. dstB += srcB;
  6862. MULT_DIV_255((255 - srcA), dstA, dstA);
  6863. dstA += srcA;
  6864. break;
  6865. case SDL_COPY_BLEND_PREMULTIPLIED:
  6866. MULT_DIV_255((255 - srcA), dstR, dstR);
  6867. dstR += srcR;
  6868. if (dstR > 255) dstR = 255;
  6869. MULT_DIV_255((255 - srcA), dstG, dstG);
  6870. dstG += srcG;
  6871. if (dstG > 255) dstG = 255;
  6872. MULT_DIV_255((255 - srcA), dstB, dstB);
  6873. dstB += srcB;
  6874. if (dstB > 255) dstB = 255;
  6875. MULT_DIV_255((255 - srcA), dstA, dstA);
  6876. dstA += srcA;
  6877. if (dstA > 255) dstA = 255;
  6878. break;
  6879. case SDL_COPY_ADD:
  6880. case SDL_COPY_ADD_PREMULTIPLIED:
  6881. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6882. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6883. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6884. break;
  6885. case SDL_COPY_MOD:
  6886. MULT_DIV_255(srcR, dstR, dstR);
  6887. MULT_DIV_255(srcG, dstG, dstG);
  6888. MULT_DIV_255(srcB, dstB, dstB);
  6889. break;
  6890. case SDL_COPY_MUL:
  6891. {
  6892. Uint32 tmp1, tmp2;
  6893. MULT_DIV_255(srcR, dstR, tmp1);
  6894. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6895. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6896. MULT_DIV_255(srcG, dstG, tmp1);
  6897. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6898. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6899. MULT_DIV_255(srcB, dstB, tmp1);
  6900. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6901. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6902. }
  6903. break;
  6904. }
  6905. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  6906. *dst = dstpixel;
  6907. ++src;
  6908. ++dst;
  6909. }
  6910. info->src += info->src_pitch;
  6911. info->dst += info->dst_pitch;
  6912. }
  6913. }
  6914. static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6915. {
  6916. const int flags = info->flags;
  6917. const Uint32 modulateR = info->r;
  6918. const Uint32 modulateG = info->g;
  6919. const Uint32 modulateB = info->b;
  6920. const Uint32 modulateA = info->a;
  6921. Uint32 srcpixel;
  6922. Uint32 srcR, srcG, srcB, srcA;
  6923. Uint32 dstpixel;
  6924. Uint32 dstR, dstG, dstB, dstA;
  6925. Uint64 srcy, srcx;
  6926. Uint64 posy, posx;
  6927. Uint64 incy, incx;
  6928. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6929. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6930. posy = incy / 2;
  6931. while (info->dst_h--) {
  6932. Uint32 *src = 0;
  6933. Uint32 *dst = (Uint32 *)info->dst;
  6934. int n = info->dst_w;
  6935. posx = incx / 2;
  6936. srcy = posy >> 16;
  6937. while (n--) {
  6938. srcx = posx >> 16;
  6939. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6940. srcpixel = *src;
  6941. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6942. dstpixel = *dst;
  6943. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6944. if (flags & SDL_COPY_MODULATE_COLOR) {
  6945. MULT_DIV_255(srcR, modulateR, srcR);
  6946. MULT_DIV_255(srcG, modulateG, srcG);
  6947. MULT_DIV_255(srcB, modulateB, srcB);
  6948. }
  6949. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6950. MULT_DIV_255(srcA, modulateA, srcA);
  6951. }
  6952. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6953. if (srcA < 255) {
  6954. MULT_DIV_255(srcR, srcA, srcR);
  6955. MULT_DIV_255(srcG, srcA, srcG);
  6956. MULT_DIV_255(srcB, srcA, srcB);
  6957. }
  6958. }
  6959. switch (flags & SDL_COPY_BLEND_MASK) {
  6960. case SDL_COPY_BLEND:
  6961. MULT_DIV_255((255 - srcA), dstR, dstR);
  6962. dstR += srcR;
  6963. MULT_DIV_255((255 - srcA), dstG, dstG);
  6964. dstG += srcG;
  6965. MULT_DIV_255((255 - srcA), dstB, dstB);
  6966. dstB += srcB;
  6967. MULT_DIV_255((255 - srcA), dstA, dstA);
  6968. dstA += srcA;
  6969. break;
  6970. case SDL_COPY_BLEND_PREMULTIPLIED:
  6971. MULT_DIV_255((255 - srcA), dstR, dstR);
  6972. dstR += srcR;
  6973. if (dstR > 255) dstR = 255;
  6974. MULT_DIV_255((255 - srcA), dstG, dstG);
  6975. dstG += srcG;
  6976. if (dstG > 255) dstG = 255;
  6977. MULT_DIV_255((255 - srcA), dstB, dstB);
  6978. dstB += srcB;
  6979. if (dstB > 255) dstB = 255;
  6980. MULT_DIV_255((255 - srcA), dstA, dstA);
  6981. dstA += srcA;
  6982. if (dstA > 255) dstA = 255;
  6983. break;
  6984. case SDL_COPY_ADD:
  6985. case SDL_COPY_ADD_PREMULTIPLIED:
  6986. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6987. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6988. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6989. break;
  6990. case SDL_COPY_MOD:
  6991. MULT_DIV_255(srcR, dstR, dstR);
  6992. MULT_DIV_255(srcG, dstG, dstG);
  6993. MULT_DIV_255(srcB, dstB, dstB);
  6994. break;
  6995. case SDL_COPY_MUL:
  6996. {
  6997. Uint32 tmp1, tmp2;
  6998. MULT_DIV_255(srcR, dstR, tmp1);
  6999. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7000. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7001. MULT_DIV_255(srcG, dstG, tmp1);
  7002. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7003. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7004. MULT_DIV_255(srcB, dstB, tmp1);
  7005. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7006. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7007. }
  7008. break;
  7009. }
  7010. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  7011. *dst = dstpixel;
  7012. posx += incx;
  7013. ++dst;
  7014. }
  7015. posy += incy;
  7016. info->dst += info->dst_pitch;
  7017. }
  7018. }
  7019. static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
  7020. {
  7021. Uint32 pixel;
  7022. Uint32 R, G, B;
  7023. Uint64 srcy, srcx;
  7024. Uint64 posy, posx;
  7025. Uint64 incy, incx;
  7026. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7027. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7028. posy = incy / 2;
  7029. while (info->dst_h--) {
  7030. Uint32 *src = 0;
  7031. Uint32 *dst = (Uint32 *)info->dst;
  7032. int n = info->dst_w;
  7033. posx = incx / 2;
  7034. srcy = posy >> 16;
  7035. while (n--) {
  7036. srcx = posx >> 16;
  7037. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7038. pixel = *src;
  7039. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7040. pixel = (R << 16) | (G << 8) | B;
  7041. *dst = pixel;
  7042. posx += incx;
  7043. ++dst;
  7044. }
  7045. posy += incy;
  7046. info->dst += info->dst_pitch;
  7047. }
  7048. }
  7049. static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
  7050. {
  7051. const int flags = info->flags;
  7052. Uint32 srcpixel;
  7053. Uint32 srcR, srcG, srcB, srcA;
  7054. Uint32 dstpixel;
  7055. Uint32 dstR, dstG, dstB;
  7056. while (info->dst_h--) {
  7057. Uint32 *src = (Uint32 *)info->src;
  7058. Uint32 *dst = (Uint32 *)info->dst;
  7059. int n = info->dst_w;
  7060. while (n--) {
  7061. srcpixel = *src;
  7062. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7063. dstpixel = *dst;
  7064. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  7065. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7066. if (srcA < 255) {
  7067. MULT_DIV_255(srcR, srcA, srcR);
  7068. MULT_DIV_255(srcG, srcA, srcG);
  7069. MULT_DIV_255(srcB, srcA, srcB);
  7070. }
  7071. }
  7072. switch (flags & SDL_COPY_BLEND_MASK) {
  7073. case SDL_COPY_BLEND:
  7074. MULT_DIV_255((255 - srcA), dstR, dstR);
  7075. dstR += srcR;
  7076. MULT_DIV_255((255 - srcA), dstG, dstG);
  7077. dstG += srcG;
  7078. MULT_DIV_255((255 - srcA), dstB, dstB);
  7079. dstB += srcB;
  7080. break;
  7081. case SDL_COPY_BLEND_PREMULTIPLIED:
  7082. MULT_DIV_255((255 - srcA), dstR, dstR);
  7083. dstR += srcR;
  7084. if (dstR > 255) dstR = 255;
  7085. MULT_DIV_255((255 - srcA), dstG, dstG);
  7086. dstG += srcG;
  7087. if (dstG > 255) dstG = 255;
  7088. MULT_DIV_255((255 - srcA), dstB, dstB);
  7089. dstB += srcB;
  7090. if (dstB > 255) dstB = 255;
  7091. break;
  7092. case SDL_COPY_ADD:
  7093. case SDL_COPY_ADD_PREMULTIPLIED:
  7094. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7095. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7096. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7097. break;
  7098. case SDL_COPY_MOD:
  7099. MULT_DIV_255(srcR, dstR, dstR);
  7100. MULT_DIV_255(srcG, dstG, dstG);
  7101. MULT_DIV_255(srcB, dstB, dstB);
  7102. break;
  7103. case SDL_COPY_MUL:
  7104. {
  7105. Uint32 tmp1, tmp2;
  7106. MULT_DIV_255(srcR, dstR, tmp1);
  7107. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7108. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7109. MULT_DIV_255(srcG, dstG, tmp1);
  7110. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7111. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7112. MULT_DIV_255(srcB, dstB, tmp1);
  7113. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7114. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7115. }
  7116. break;
  7117. }
  7118. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  7119. *dst = dstpixel;
  7120. ++src;
  7121. ++dst;
  7122. }
  7123. info->src += info->src_pitch;
  7124. info->dst += info->dst_pitch;
  7125. }
  7126. }
  7127. static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  7128. {
  7129. const int flags = info->flags;
  7130. Uint32 srcpixel;
  7131. Uint32 srcR, srcG, srcB, srcA;
  7132. Uint32 dstpixel;
  7133. Uint32 dstR, dstG, dstB;
  7134. Uint64 srcy, srcx;
  7135. Uint64 posy, posx;
  7136. Uint64 incy, incx;
  7137. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7138. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7139. posy = incy / 2;
  7140. while (info->dst_h--) {
  7141. Uint32 *src = 0;
  7142. Uint32 *dst = (Uint32 *)info->dst;
  7143. int n = info->dst_w;
  7144. posx = incx / 2;
  7145. srcy = posy >> 16;
  7146. while (n--) {
  7147. srcx = posx >> 16;
  7148. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7149. srcpixel = *src;
  7150. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7151. dstpixel = *dst;
  7152. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  7153. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7154. if (srcA < 255) {
  7155. MULT_DIV_255(srcR, srcA, srcR);
  7156. MULT_DIV_255(srcG, srcA, srcG);
  7157. MULT_DIV_255(srcB, srcA, srcB);
  7158. }
  7159. }
  7160. switch (flags & SDL_COPY_BLEND_MASK) {
  7161. case SDL_COPY_BLEND:
  7162. MULT_DIV_255((255 - srcA), dstR, dstR);
  7163. dstR += srcR;
  7164. MULT_DIV_255((255 - srcA), dstG, dstG);
  7165. dstG += srcG;
  7166. MULT_DIV_255((255 - srcA), dstB, dstB);
  7167. dstB += srcB;
  7168. break;
  7169. case SDL_COPY_BLEND_PREMULTIPLIED:
  7170. MULT_DIV_255((255 - srcA), dstR, dstR);
  7171. dstR += srcR;
  7172. if (dstR > 255) dstR = 255;
  7173. MULT_DIV_255((255 - srcA), dstG, dstG);
  7174. dstG += srcG;
  7175. if (dstG > 255) dstG = 255;
  7176. MULT_DIV_255((255 - srcA), dstB, dstB);
  7177. dstB += srcB;
  7178. if (dstB > 255) dstB = 255;
  7179. break;
  7180. case SDL_COPY_ADD:
  7181. case SDL_COPY_ADD_PREMULTIPLIED:
  7182. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7183. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7184. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7185. break;
  7186. case SDL_COPY_MOD:
  7187. MULT_DIV_255(srcR, dstR, dstR);
  7188. MULT_DIV_255(srcG, dstG, dstG);
  7189. MULT_DIV_255(srcB, dstB, dstB);
  7190. break;
  7191. case SDL_COPY_MUL:
  7192. {
  7193. Uint32 tmp1, tmp2;
  7194. MULT_DIV_255(srcR, dstR, tmp1);
  7195. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7196. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7197. MULT_DIV_255(srcG, dstG, tmp1);
  7198. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7199. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7200. MULT_DIV_255(srcB, dstB, tmp1);
  7201. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7202. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7203. }
  7204. break;
  7205. }
  7206. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  7207. *dst = dstpixel;
  7208. posx += incx;
  7209. ++dst;
  7210. }
  7211. posy += incy;
  7212. info->dst += info->dst_pitch;
  7213. }
  7214. }
  7215. static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  7216. {
  7217. const int flags = info->flags;
  7218. const Uint32 modulateR = info->r;
  7219. const Uint32 modulateG = info->g;
  7220. const Uint32 modulateB = info->b;
  7221. Uint32 pixel;
  7222. Uint32 R, G, B;
  7223. while (info->dst_h--) {
  7224. Uint32 *src = (Uint32 *)info->src;
  7225. Uint32 *dst = (Uint32 *)info->dst;
  7226. int n = info->dst_w;
  7227. while (n--) {
  7228. pixel = *src;
  7229. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7230. if (flags & SDL_COPY_MODULATE_COLOR) {
  7231. MULT_DIV_255(R, modulateR, R);
  7232. MULT_DIV_255(G, modulateG, G);
  7233. MULT_DIV_255(B, modulateB, B);
  7234. }
  7235. pixel = (R << 16) | (G << 8) | B;
  7236. *dst = pixel;
  7237. ++src;
  7238. ++dst;
  7239. }
  7240. info->src += info->src_pitch;
  7241. info->dst += info->dst_pitch;
  7242. }
  7243. }
  7244. static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  7245. {
  7246. const int flags = info->flags;
  7247. const Uint32 modulateR = info->r;
  7248. const Uint32 modulateG = info->g;
  7249. const Uint32 modulateB = info->b;
  7250. Uint32 pixel;
  7251. Uint32 R, G, B;
  7252. Uint64 srcy, srcx;
  7253. Uint64 posy, posx;
  7254. Uint64 incy, incx;
  7255. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7256. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7257. posy = incy / 2;
  7258. while (info->dst_h--) {
  7259. Uint32 *src = 0;
  7260. Uint32 *dst = (Uint32 *)info->dst;
  7261. int n = info->dst_w;
  7262. posx = incx / 2;
  7263. srcy = posy >> 16;
  7264. while (n--) {
  7265. srcx = posx >> 16;
  7266. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7267. pixel = *src;
  7268. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7269. if (flags & SDL_COPY_MODULATE_COLOR) {
  7270. MULT_DIV_255(R, modulateR, R);
  7271. MULT_DIV_255(G, modulateG, G);
  7272. MULT_DIV_255(B, modulateB, B);
  7273. }
  7274. pixel = (R << 16) | (G << 8) | B;
  7275. *dst = pixel;
  7276. posx += incx;
  7277. ++dst;
  7278. }
  7279. posy += incy;
  7280. info->dst += info->dst_pitch;
  7281. }
  7282. }
  7283. static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  7284. {
  7285. const int flags = info->flags;
  7286. const Uint32 modulateR = info->r;
  7287. const Uint32 modulateG = info->g;
  7288. const Uint32 modulateB = info->b;
  7289. const Uint32 modulateA = info->a;
  7290. Uint32 srcpixel;
  7291. Uint32 srcR, srcG, srcB, srcA;
  7292. Uint32 dstpixel;
  7293. Uint32 dstR, dstG, dstB;
  7294. while (info->dst_h--) {
  7295. Uint32 *src = (Uint32 *)info->src;
  7296. Uint32 *dst = (Uint32 *)info->dst;
  7297. int n = info->dst_w;
  7298. while (n--) {
  7299. srcpixel = *src;
  7300. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7301. dstpixel = *dst;
  7302. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  7303. if (flags & SDL_COPY_MODULATE_COLOR) {
  7304. MULT_DIV_255(srcR, modulateR, srcR);
  7305. MULT_DIV_255(srcG, modulateG, srcG);
  7306. MULT_DIV_255(srcB, modulateB, srcB);
  7307. }
  7308. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7309. MULT_DIV_255(srcA, modulateA, srcA);
  7310. }
  7311. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7312. if (srcA < 255) {
  7313. MULT_DIV_255(srcR, srcA, srcR);
  7314. MULT_DIV_255(srcG, srcA, srcG);
  7315. MULT_DIV_255(srcB, srcA, srcB);
  7316. }
  7317. }
  7318. switch (flags & SDL_COPY_BLEND_MASK) {
  7319. case SDL_COPY_BLEND:
  7320. MULT_DIV_255((255 - srcA), dstR, dstR);
  7321. dstR += srcR;
  7322. MULT_DIV_255((255 - srcA), dstG, dstG);
  7323. dstG += srcG;
  7324. MULT_DIV_255((255 - srcA), dstB, dstB);
  7325. dstB += srcB;
  7326. break;
  7327. case SDL_COPY_BLEND_PREMULTIPLIED:
  7328. MULT_DIV_255((255 - srcA), dstR, dstR);
  7329. dstR += srcR;
  7330. if (dstR > 255) dstR = 255;
  7331. MULT_DIV_255((255 - srcA), dstG, dstG);
  7332. dstG += srcG;
  7333. if (dstG > 255) dstG = 255;
  7334. MULT_DIV_255((255 - srcA), dstB, dstB);
  7335. dstB += srcB;
  7336. if (dstB > 255) dstB = 255;
  7337. break;
  7338. case SDL_COPY_ADD:
  7339. case SDL_COPY_ADD_PREMULTIPLIED:
  7340. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7341. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7342. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7343. break;
  7344. case SDL_COPY_MOD:
  7345. MULT_DIV_255(srcR, dstR, dstR);
  7346. MULT_DIV_255(srcG, dstG, dstG);
  7347. MULT_DIV_255(srcB, dstB, dstB);
  7348. break;
  7349. case SDL_COPY_MUL:
  7350. {
  7351. Uint32 tmp1, tmp2;
  7352. MULT_DIV_255(srcR, dstR, tmp1);
  7353. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7354. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7355. MULT_DIV_255(srcG, dstG, tmp1);
  7356. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7357. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7358. MULT_DIV_255(srcB, dstB, tmp1);
  7359. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7360. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7361. }
  7362. break;
  7363. }
  7364. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  7365. *dst = dstpixel;
  7366. ++src;
  7367. ++dst;
  7368. }
  7369. info->src += info->src_pitch;
  7370. info->dst += info->dst_pitch;
  7371. }
  7372. }
  7373. static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  7374. {
  7375. const int flags = info->flags;
  7376. const Uint32 modulateR = info->r;
  7377. const Uint32 modulateG = info->g;
  7378. const Uint32 modulateB = info->b;
  7379. const Uint32 modulateA = info->a;
  7380. Uint32 srcpixel;
  7381. Uint32 srcR, srcG, srcB, srcA;
  7382. Uint32 dstpixel;
  7383. Uint32 dstR, dstG, dstB;
  7384. Uint64 srcy, srcx;
  7385. Uint64 posy, posx;
  7386. Uint64 incy, incx;
  7387. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7388. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7389. posy = incy / 2;
  7390. while (info->dst_h--) {
  7391. Uint32 *src = 0;
  7392. Uint32 *dst = (Uint32 *)info->dst;
  7393. int n = info->dst_w;
  7394. posx = incx / 2;
  7395. srcy = posy >> 16;
  7396. while (n--) {
  7397. srcx = posx >> 16;
  7398. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7399. srcpixel = *src;
  7400. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7401. dstpixel = *dst;
  7402. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  7403. if (flags & SDL_COPY_MODULATE_COLOR) {
  7404. MULT_DIV_255(srcR, modulateR, srcR);
  7405. MULT_DIV_255(srcG, modulateG, srcG);
  7406. MULT_DIV_255(srcB, modulateB, srcB);
  7407. }
  7408. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7409. MULT_DIV_255(srcA, modulateA, srcA);
  7410. }
  7411. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7412. if (srcA < 255) {
  7413. MULT_DIV_255(srcR, srcA, srcR);
  7414. MULT_DIV_255(srcG, srcA, srcG);
  7415. MULT_DIV_255(srcB, srcA, srcB);
  7416. }
  7417. }
  7418. switch (flags & SDL_COPY_BLEND_MASK) {
  7419. case SDL_COPY_BLEND:
  7420. MULT_DIV_255((255 - srcA), dstR, dstR);
  7421. dstR += srcR;
  7422. MULT_DIV_255((255 - srcA), dstG, dstG);
  7423. dstG += srcG;
  7424. MULT_DIV_255((255 - srcA), dstB, dstB);
  7425. dstB += srcB;
  7426. break;
  7427. case SDL_COPY_BLEND_PREMULTIPLIED:
  7428. MULT_DIV_255((255 - srcA), dstR, dstR);
  7429. dstR += srcR;
  7430. if (dstR > 255) dstR = 255;
  7431. MULT_DIV_255((255 - srcA), dstG, dstG);
  7432. dstG += srcG;
  7433. if (dstG > 255) dstG = 255;
  7434. MULT_DIV_255((255 - srcA), dstB, dstB);
  7435. dstB += srcB;
  7436. if (dstB > 255) dstB = 255;
  7437. break;
  7438. case SDL_COPY_ADD:
  7439. case SDL_COPY_ADD_PREMULTIPLIED:
  7440. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7441. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7442. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7443. break;
  7444. case SDL_COPY_MOD:
  7445. MULT_DIV_255(srcR, dstR, dstR);
  7446. MULT_DIV_255(srcG, dstG, dstG);
  7447. MULT_DIV_255(srcB, dstB, dstB);
  7448. break;
  7449. case SDL_COPY_MUL:
  7450. {
  7451. Uint32 tmp1, tmp2;
  7452. MULT_DIV_255(srcR, dstR, tmp1);
  7453. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7454. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7455. MULT_DIV_255(srcG, dstG, tmp1);
  7456. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7457. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7458. MULT_DIV_255(srcB, dstB, tmp1);
  7459. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7460. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7461. }
  7462. break;
  7463. }
  7464. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  7465. *dst = dstpixel;
  7466. posx += incx;
  7467. ++dst;
  7468. }
  7469. posy += incy;
  7470. info->dst += info->dst_pitch;
  7471. }
  7472. }
  7473. static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
  7474. {
  7475. Uint32 pixel;
  7476. Uint64 srcy, srcx;
  7477. Uint64 posy, posx;
  7478. Uint64 incy, incx;
  7479. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7480. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7481. posy = incy / 2;
  7482. while (info->dst_h--) {
  7483. Uint32 *src = 0;
  7484. Uint32 *dst = (Uint32 *)info->dst;
  7485. int n = info->dst_w;
  7486. posx = incx / 2;
  7487. srcy = posy >> 16;
  7488. while (n--) {
  7489. srcx = posx >> 16;
  7490. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7491. pixel = *src;
  7492. pixel &= 0xFFFFFF;
  7493. *dst = pixel;
  7494. posx += incx;
  7495. ++dst;
  7496. }
  7497. posy += incy;
  7498. info->dst += info->dst_pitch;
  7499. }
  7500. }
  7501. static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
  7502. {
  7503. const int flags = info->flags;
  7504. Uint32 srcpixel;
  7505. Uint32 srcR, srcG, srcB, srcA;
  7506. Uint32 dstpixel;
  7507. Uint32 dstR, dstG, dstB;
  7508. while (info->dst_h--) {
  7509. Uint32 *src = (Uint32 *)info->src;
  7510. Uint32 *dst = (Uint32 *)info->dst;
  7511. int n = info->dst_w;
  7512. while (n--) {
  7513. srcpixel = *src;
  7514. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7515. dstpixel = *dst;
  7516. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  7517. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7518. if (srcA < 255) {
  7519. MULT_DIV_255(srcR, srcA, srcR);
  7520. MULT_DIV_255(srcG, srcA, srcG);
  7521. MULT_DIV_255(srcB, srcA, srcB);
  7522. }
  7523. }
  7524. switch (flags & SDL_COPY_BLEND_MASK) {
  7525. case SDL_COPY_BLEND:
  7526. MULT_DIV_255((255 - srcA), dstR, dstR);
  7527. dstR += srcR;
  7528. MULT_DIV_255((255 - srcA), dstG, dstG);
  7529. dstG += srcG;
  7530. MULT_DIV_255((255 - srcA), dstB, dstB);
  7531. dstB += srcB;
  7532. break;
  7533. case SDL_COPY_BLEND_PREMULTIPLIED:
  7534. MULT_DIV_255((255 - srcA), dstR, dstR);
  7535. dstR += srcR;
  7536. if (dstR > 255) dstR = 255;
  7537. MULT_DIV_255((255 - srcA), dstG, dstG);
  7538. dstG += srcG;
  7539. if (dstG > 255) dstG = 255;
  7540. MULT_DIV_255((255 - srcA), dstB, dstB);
  7541. dstB += srcB;
  7542. if (dstB > 255) dstB = 255;
  7543. break;
  7544. case SDL_COPY_ADD:
  7545. case SDL_COPY_ADD_PREMULTIPLIED:
  7546. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7547. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7548. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7549. break;
  7550. case SDL_COPY_MOD:
  7551. MULT_DIV_255(srcR, dstR, dstR);
  7552. MULT_DIV_255(srcG, dstG, dstG);
  7553. MULT_DIV_255(srcB, dstB, dstB);
  7554. break;
  7555. case SDL_COPY_MUL:
  7556. {
  7557. Uint32 tmp1, tmp2;
  7558. MULT_DIV_255(srcR, dstR, tmp1);
  7559. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7560. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7561. MULT_DIV_255(srcG, dstG, tmp1);
  7562. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7563. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7564. MULT_DIV_255(srcB, dstB, tmp1);
  7565. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7566. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7567. }
  7568. break;
  7569. }
  7570. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  7571. *dst = dstpixel;
  7572. ++src;
  7573. ++dst;
  7574. }
  7575. info->src += info->src_pitch;
  7576. info->dst += info->dst_pitch;
  7577. }
  7578. }
  7579. static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  7580. {
  7581. const int flags = info->flags;
  7582. Uint32 srcpixel;
  7583. Uint32 srcR, srcG, srcB, srcA;
  7584. Uint32 dstpixel;
  7585. Uint32 dstR, dstG, dstB;
  7586. Uint64 srcy, srcx;
  7587. Uint64 posy, posx;
  7588. Uint64 incy, incx;
  7589. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7590. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7591. posy = incy / 2;
  7592. while (info->dst_h--) {
  7593. Uint32 *src = 0;
  7594. Uint32 *dst = (Uint32 *)info->dst;
  7595. int n = info->dst_w;
  7596. posx = incx / 2;
  7597. srcy = posy >> 16;
  7598. while (n--) {
  7599. srcx = posx >> 16;
  7600. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7601. srcpixel = *src;
  7602. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7603. dstpixel = *dst;
  7604. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  7605. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7606. if (srcA < 255) {
  7607. MULT_DIV_255(srcR, srcA, srcR);
  7608. MULT_DIV_255(srcG, srcA, srcG);
  7609. MULT_DIV_255(srcB, srcA, srcB);
  7610. }
  7611. }
  7612. switch (flags & SDL_COPY_BLEND_MASK) {
  7613. case SDL_COPY_BLEND:
  7614. MULT_DIV_255((255 - srcA), dstR, dstR);
  7615. dstR += srcR;
  7616. MULT_DIV_255((255 - srcA), dstG, dstG);
  7617. dstG += srcG;
  7618. MULT_DIV_255((255 - srcA), dstB, dstB);
  7619. dstB += srcB;
  7620. break;
  7621. case SDL_COPY_BLEND_PREMULTIPLIED:
  7622. MULT_DIV_255((255 - srcA), dstR, dstR);
  7623. dstR += srcR;
  7624. if (dstR > 255) dstR = 255;
  7625. MULT_DIV_255((255 - srcA), dstG, dstG);
  7626. dstG += srcG;
  7627. if (dstG > 255) dstG = 255;
  7628. MULT_DIV_255((255 - srcA), dstB, dstB);
  7629. dstB += srcB;
  7630. if (dstB > 255) dstB = 255;
  7631. break;
  7632. case SDL_COPY_ADD:
  7633. case SDL_COPY_ADD_PREMULTIPLIED:
  7634. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7635. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7636. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7637. break;
  7638. case SDL_COPY_MOD:
  7639. MULT_DIV_255(srcR, dstR, dstR);
  7640. MULT_DIV_255(srcG, dstG, dstG);
  7641. MULT_DIV_255(srcB, dstB, dstB);
  7642. break;
  7643. case SDL_COPY_MUL:
  7644. {
  7645. Uint32 tmp1, tmp2;
  7646. MULT_DIV_255(srcR, dstR, tmp1);
  7647. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7648. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7649. MULT_DIV_255(srcG, dstG, tmp1);
  7650. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7651. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7652. MULT_DIV_255(srcB, dstB, tmp1);
  7653. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7654. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7655. }
  7656. break;
  7657. }
  7658. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  7659. *dst = dstpixel;
  7660. posx += incx;
  7661. ++dst;
  7662. }
  7663. posy += incy;
  7664. info->dst += info->dst_pitch;
  7665. }
  7666. }
  7667. static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  7668. {
  7669. const int flags = info->flags;
  7670. const Uint32 modulateR = info->r;
  7671. const Uint32 modulateG = info->g;
  7672. const Uint32 modulateB = info->b;
  7673. Uint32 pixel;
  7674. Uint32 R, G, B;
  7675. while (info->dst_h--) {
  7676. Uint32 *src = (Uint32 *)info->src;
  7677. Uint32 *dst = (Uint32 *)info->dst;
  7678. int n = info->dst_w;
  7679. while (n--) {
  7680. pixel = *src;
  7681. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7682. if (flags & SDL_COPY_MODULATE_COLOR) {
  7683. MULT_DIV_255(R, modulateR, R);
  7684. MULT_DIV_255(G, modulateG, G);
  7685. MULT_DIV_255(B, modulateB, B);
  7686. }
  7687. pixel = (B << 16) | (G << 8) | R;
  7688. *dst = pixel;
  7689. ++src;
  7690. ++dst;
  7691. }
  7692. info->src += info->src_pitch;
  7693. info->dst += info->dst_pitch;
  7694. }
  7695. }
  7696. static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  7697. {
  7698. const int flags = info->flags;
  7699. const Uint32 modulateR = info->r;
  7700. const Uint32 modulateG = info->g;
  7701. const Uint32 modulateB = info->b;
  7702. Uint32 pixel;
  7703. Uint32 R, G, B;
  7704. Uint64 srcy, srcx;
  7705. Uint64 posy, posx;
  7706. Uint64 incy, incx;
  7707. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7708. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7709. posy = incy / 2;
  7710. while (info->dst_h--) {
  7711. Uint32 *src = 0;
  7712. Uint32 *dst = (Uint32 *)info->dst;
  7713. int n = info->dst_w;
  7714. posx = incx / 2;
  7715. srcy = posy >> 16;
  7716. while (n--) {
  7717. srcx = posx >> 16;
  7718. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7719. pixel = *src;
  7720. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7721. if (flags & SDL_COPY_MODULATE_COLOR) {
  7722. MULT_DIV_255(R, modulateR, R);
  7723. MULT_DIV_255(G, modulateG, G);
  7724. MULT_DIV_255(B, modulateB, B);
  7725. }
  7726. pixel = (B << 16) | (G << 8) | R;
  7727. *dst = pixel;
  7728. posx += incx;
  7729. ++dst;
  7730. }
  7731. posy += incy;
  7732. info->dst += info->dst_pitch;
  7733. }
  7734. }
  7735. static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  7736. {
  7737. const int flags = info->flags;
  7738. const Uint32 modulateR = info->r;
  7739. const Uint32 modulateG = info->g;
  7740. const Uint32 modulateB = info->b;
  7741. const Uint32 modulateA = info->a;
  7742. Uint32 srcpixel;
  7743. Uint32 srcR, srcG, srcB, srcA;
  7744. Uint32 dstpixel;
  7745. Uint32 dstR, dstG, dstB;
  7746. while (info->dst_h--) {
  7747. Uint32 *src = (Uint32 *)info->src;
  7748. Uint32 *dst = (Uint32 *)info->dst;
  7749. int n = info->dst_w;
  7750. while (n--) {
  7751. srcpixel = *src;
  7752. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7753. dstpixel = *dst;
  7754. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  7755. if (flags & SDL_COPY_MODULATE_COLOR) {
  7756. MULT_DIV_255(srcR, modulateR, srcR);
  7757. MULT_DIV_255(srcG, modulateG, srcG);
  7758. MULT_DIV_255(srcB, modulateB, srcB);
  7759. }
  7760. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7761. MULT_DIV_255(srcA, modulateA, srcA);
  7762. }
  7763. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7764. if (srcA < 255) {
  7765. MULT_DIV_255(srcR, srcA, srcR);
  7766. MULT_DIV_255(srcG, srcA, srcG);
  7767. MULT_DIV_255(srcB, srcA, srcB);
  7768. }
  7769. }
  7770. switch (flags & SDL_COPY_BLEND_MASK) {
  7771. case SDL_COPY_BLEND:
  7772. MULT_DIV_255((255 - srcA), dstR, dstR);
  7773. dstR += srcR;
  7774. MULT_DIV_255((255 - srcA), dstG, dstG);
  7775. dstG += srcG;
  7776. MULT_DIV_255((255 - srcA), dstB, dstB);
  7777. dstB += srcB;
  7778. break;
  7779. case SDL_COPY_BLEND_PREMULTIPLIED:
  7780. MULT_DIV_255((255 - srcA), dstR, dstR);
  7781. dstR += srcR;
  7782. if (dstR > 255) dstR = 255;
  7783. MULT_DIV_255((255 - srcA), dstG, dstG);
  7784. dstG += srcG;
  7785. if (dstG > 255) dstG = 255;
  7786. MULT_DIV_255((255 - srcA), dstB, dstB);
  7787. dstB += srcB;
  7788. if (dstB > 255) dstB = 255;
  7789. break;
  7790. case SDL_COPY_ADD:
  7791. case SDL_COPY_ADD_PREMULTIPLIED:
  7792. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7793. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7794. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7795. break;
  7796. case SDL_COPY_MOD:
  7797. MULT_DIV_255(srcR, dstR, dstR);
  7798. MULT_DIV_255(srcG, dstG, dstG);
  7799. MULT_DIV_255(srcB, dstB, dstB);
  7800. break;
  7801. case SDL_COPY_MUL:
  7802. {
  7803. Uint32 tmp1, tmp2;
  7804. MULT_DIV_255(srcR, dstR, tmp1);
  7805. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7806. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7807. MULT_DIV_255(srcG, dstG, tmp1);
  7808. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7809. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7810. MULT_DIV_255(srcB, dstB, tmp1);
  7811. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7812. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7813. }
  7814. break;
  7815. }
  7816. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  7817. *dst = dstpixel;
  7818. ++src;
  7819. ++dst;
  7820. }
  7821. info->src += info->src_pitch;
  7822. info->dst += info->dst_pitch;
  7823. }
  7824. }
  7825. static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  7826. {
  7827. const int flags = info->flags;
  7828. const Uint32 modulateR = info->r;
  7829. const Uint32 modulateG = info->g;
  7830. const Uint32 modulateB = info->b;
  7831. const Uint32 modulateA = info->a;
  7832. Uint32 srcpixel;
  7833. Uint32 srcR, srcG, srcB, srcA;
  7834. Uint32 dstpixel;
  7835. Uint32 dstR, dstG, dstB;
  7836. Uint64 srcy, srcx;
  7837. Uint64 posy, posx;
  7838. Uint64 incy, incx;
  7839. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7840. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7841. posy = incy / 2;
  7842. while (info->dst_h--) {
  7843. Uint32 *src = 0;
  7844. Uint32 *dst = (Uint32 *)info->dst;
  7845. int n = info->dst_w;
  7846. posx = incx / 2;
  7847. srcy = posy >> 16;
  7848. while (n--) {
  7849. srcx = posx >> 16;
  7850. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7851. srcpixel = *src;
  7852. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7853. dstpixel = *dst;
  7854. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  7855. if (flags & SDL_COPY_MODULATE_COLOR) {
  7856. MULT_DIV_255(srcR, modulateR, srcR);
  7857. MULT_DIV_255(srcG, modulateG, srcG);
  7858. MULT_DIV_255(srcB, modulateB, srcB);
  7859. }
  7860. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7861. MULT_DIV_255(srcA, modulateA, srcA);
  7862. }
  7863. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7864. if (srcA < 255) {
  7865. MULT_DIV_255(srcR, srcA, srcR);
  7866. MULT_DIV_255(srcG, srcA, srcG);
  7867. MULT_DIV_255(srcB, srcA, srcB);
  7868. }
  7869. }
  7870. switch (flags & SDL_COPY_BLEND_MASK) {
  7871. case SDL_COPY_BLEND:
  7872. MULT_DIV_255((255 - srcA), dstR, dstR);
  7873. dstR += srcR;
  7874. MULT_DIV_255((255 - srcA), dstG, dstG);
  7875. dstG += srcG;
  7876. MULT_DIV_255((255 - srcA), dstB, dstB);
  7877. dstB += srcB;
  7878. break;
  7879. case SDL_COPY_BLEND_PREMULTIPLIED:
  7880. MULT_DIV_255((255 - srcA), dstR, dstR);
  7881. dstR += srcR;
  7882. if (dstR > 255) dstR = 255;
  7883. MULT_DIV_255((255 - srcA), dstG, dstG);
  7884. dstG += srcG;
  7885. if (dstG > 255) dstG = 255;
  7886. MULT_DIV_255((255 - srcA), dstB, dstB);
  7887. dstB += srcB;
  7888. if (dstB > 255) dstB = 255;
  7889. break;
  7890. case SDL_COPY_ADD:
  7891. case SDL_COPY_ADD_PREMULTIPLIED:
  7892. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7893. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7894. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7895. break;
  7896. case SDL_COPY_MOD:
  7897. MULT_DIV_255(srcR, dstR, dstR);
  7898. MULT_DIV_255(srcG, dstG, dstG);
  7899. MULT_DIV_255(srcB, dstB, dstB);
  7900. break;
  7901. case SDL_COPY_MUL:
  7902. {
  7903. Uint32 tmp1, tmp2;
  7904. MULT_DIV_255(srcR, dstR, tmp1);
  7905. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7906. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7907. MULT_DIV_255(srcG, dstG, tmp1);
  7908. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7909. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7910. MULT_DIV_255(srcB, dstB, tmp1);
  7911. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7912. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7913. }
  7914. break;
  7915. }
  7916. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  7917. *dst = dstpixel;
  7918. posx += incx;
  7919. ++dst;
  7920. }
  7921. posy += incy;
  7922. info->dst += info->dst_pitch;
  7923. }
  7924. }
  7925. static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
  7926. {
  7927. Uint32 pixel;
  7928. Uint32 R, G, B, A;
  7929. Uint64 srcy, srcx;
  7930. Uint64 posy, posx;
  7931. Uint64 incy, incx;
  7932. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7933. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7934. posy = incy / 2;
  7935. while (info->dst_h--) {
  7936. Uint32 *src = 0;
  7937. Uint32 *dst = (Uint32 *)info->dst;
  7938. int n = info->dst_w;
  7939. posx = incx / 2;
  7940. srcy = posy >> 16;
  7941. while (n--) {
  7942. srcx = posx >> 16;
  7943. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7944. pixel = *src;
  7945. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  7946. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  7947. *dst = pixel;
  7948. posx += incx;
  7949. ++dst;
  7950. }
  7951. posy += incy;
  7952. info->dst += info->dst_pitch;
  7953. }
  7954. }
  7955. static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
  7956. {
  7957. const int flags = info->flags;
  7958. Uint32 srcpixel;
  7959. Uint32 srcR, srcG, srcB, srcA;
  7960. Uint32 dstpixel;
  7961. Uint32 dstR, dstG, dstB, dstA;
  7962. while (info->dst_h--) {
  7963. Uint32 *src = (Uint32 *)info->src;
  7964. Uint32 *dst = (Uint32 *)info->dst;
  7965. int n = info->dst_w;
  7966. while (n--) {
  7967. srcpixel = *src;
  7968. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7969. dstpixel = *dst;
  7970. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  7971. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7972. if (srcA < 255) {
  7973. MULT_DIV_255(srcR, srcA, srcR);
  7974. MULT_DIV_255(srcG, srcA, srcG);
  7975. MULT_DIV_255(srcB, srcA, srcB);
  7976. }
  7977. }
  7978. switch (flags & SDL_COPY_BLEND_MASK) {
  7979. case SDL_COPY_BLEND:
  7980. MULT_DIV_255((255 - srcA), dstR, dstR);
  7981. dstR += srcR;
  7982. MULT_DIV_255((255 - srcA), dstG, dstG);
  7983. dstG += srcG;
  7984. MULT_DIV_255((255 - srcA), dstB, dstB);
  7985. dstB += srcB;
  7986. MULT_DIV_255((255 - srcA), dstA, dstA);
  7987. dstA += srcA;
  7988. break;
  7989. case SDL_COPY_BLEND_PREMULTIPLIED:
  7990. MULT_DIV_255((255 - srcA), dstR, dstR);
  7991. dstR += srcR;
  7992. if (dstR > 255) dstR = 255;
  7993. MULT_DIV_255((255 - srcA), dstG, dstG);
  7994. dstG += srcG;
  7995. if (dstG > 255) dstG = 255;
  7996. MULT_DIV_255((255 - srcA), dstB, dstB);
  7997. dstB += srcB;
  7998. if (dstB > 255) dstB = 255;
  7999. MULT_DIV_255((255 - srcA), dstA, dstA);
  8000. dstA += srcA;
  8001. if (dstA > 255) dstA = 255;
  8002. break;
  8003. case SDL_COPY_ADD:
  8004. case SDL_COPY_ADD_PREMULTIPLIED:
  8005. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8006. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8007. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8008. break;
  8009. case SDL_COPY_MOD:
  8010. MULT_DIV_255(srcR, dstR, dstR);
  8011. MULT_DIV_255(srcG, dstG, dstG);
  8012. MULT_DIV_255(srcB, dstB, dstB);
  8013. break;
  8014. case SDL_COPY_MUL:
  8015. {
  8016. Uint32 tmp1, tmp2;
  8017. MULT_DIV_255(srcR, dstR, tmp1);
  8018. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8019. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8020. MULT_DIV_255(srcG, dstG, tmp1);
  8021. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8022. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8023. MULT_DIV_255(srcB, dstB, tmp1);
  8024. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8025. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8026. }
  8027. break;
  8028. }
  8029. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  8030. *dst = dstpixel;
  8031. ++src;
  8032. ++dst;
  8033. }
  8034. info->src += info->src_pitch;
  8035. info->dst += info->dst_pitch;
  8036. }
  8037. }
  8038. static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  8039. {
  8040. const int flags = info->flags;
  8041. Uint32 srcpixel;
  8042. Uint32 srcR, srcG, srcB, srcA;
  8043. Uint32 dstpixel;
  8044. Uint32 dstR, dstG, dstB, dstA;
  8045. Uint64 srcy, srcx;
  8046. Uint64 posy, posx;
  8047. Uint64 incy, incx;
  8048. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8049. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8050. posy = incy / 2;
  8051. while (info->dst_h--) {
  8052. Uint32 *src = 0;
  8053. Uint32 *dst = (Uint32 *)info->dst;
  8054. int n = info->dst_w;
  8055. posx = incx / 2;
  8056. srcy = posy >> 16;
  8057. while (n--) {
  8058. srcx = posx >> 16;
  8059. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8060. srcpixel = *src;
  8061. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8062. dstpixel = *dst;
  8063. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8064. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8065. if (srcA < 255) {
  8066. MULT_DIV_255(srcR, srcA, srcR);
  8067. MULT_DIV_255(srcG, srcA, srcG);
  8068. MULT_DIV_255(srcB, srcA, srcB);
  8069. }
  8070. }
  8071. switch (flags & SDL_COPY_BLEND_MASK) {
  8072. case SDL_COPY_BLEND:
  8073. MULT_DIV_255((255 - srcA), dstR, dstR);
  8074. dstR += srcR;
  8075. MULT_DIV_255((255 - srcA), dstG, dstG);
  8076. dstG += srcG;
  8077. MULT_DIV_255((255 - srcA), dstB, dstB);
  8078. dstB += srcB;
  8079. MULT_DIV_255((255 - srcA), dstA, dstA);
  8080. dstA += srcA;
  8081. break;
  8082. case SDL_COPY_BLEND_PREMULTIPLIED:
  8083. MULT_DIV_255((255 - srcA), dstR, dstR);
  8084. dstR += srcR;
  8085. if (dstR > 255) dstR = 255;
  8086. MULT_DIV_255((255 - srcA), dstG, dstG);
  8087. dstG += srcG;
  8088. if (dstG > 255) dstG = 255;
  8089. MULT_DIV_255((255 - srcA), dstB, dstB);
  8090. dstB += srcB;
  8091. if (dstB > 255) dstB = 255;
  8092. MULT_DIV_255((255 - srcA), dstA, dstA);
  8093. dstA += srcA;
  8094. if (dstA > 255) dstA = 255;
  8095. break;
  8096. case SDL_COPY_ADD:
  8097. case SDL_COPY_ADD_PREMULTIPLIED:
  8098. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8099. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8100. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8101. break;
  8102. case SDL_COPY_MOD:
  8103. MULT_DIV_255(srcR, dstR, dstR);
  8104. MULT_DIV_255(srcG, dstG, dstG);
  8105. MULT_DIV_255(srcB, dstB, dstB);
  8106. break;
  8107. case SDL_COPY_MUL:
  8108. {
  8109. Uint32 tmp1, tmp2;
  8110. MULT_DIV_255(srcR, dstR, tmp1);
  8111. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8112. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8113. MULT_DIV_255(srcG, dstG, tmp1);
  8114. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8115. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8116. MULT_DIV_255(srcB, dstB, tmp1);
  8117. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8118. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8119. }
  8120. break;
  8121. }
  8122. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  8123. *dst = dstpixel;
  8124. posx += incx;
  8125. ++dst;
  8126. }
  8127. posy += incy;
  8128. info->dst += info->dst_pitch;
  8129. }
  8130. }
  8131. static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  8132. {
  8133. const int flags = info->flags;
  8134. const Uint32 modulateR = info->r;
  8135. const Uint32 modulateG = info->g;
  8136. const Uint32 modulateB = info->b;
  8137. const Uint32 modulateA = info->a;
  8138. Uint32 pixel;
  8139. Uint32 R, G, B, A;
  8140. while (info->dst_h--) {
  8141. Uint32 *src = (Uint32 *)info->src;
  8142. Uint32 *dst = (Uint32 *)info->dst;
  8143. int n = info->dst_w;
  8144. while (n--) {
  8145. pixel = *src;
  8146. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  8147. if (flags & SDL_COPY_MODULATE_COLOR) {
  8148. MULT_DIV_255(R, modulateR, R);
  8149. MULT_DIV_255(G, modulateG, G);
  8150. MULT_DIV_255(B, modulateB, B);
  8151. }
  8152. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8153. MULT_DIV_255(A, modulateA, A);
  8154. }
  8155. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  8156. *dst = pixel;
  8157. ++src;
  8158. ++dst;
  8159. }
  8160. info->src += info->src_pitch;
  8161. info->dst += info->dst_pitch;
  8162. }
  8163. }
  8164. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  8165. {
  8166. const int flags = info->flags;
  8167. const Uint32 modulateR = info->r;
  8168. const Uint32 modulateG = info->g;
  8169. const Uint32 modulateB = info->b;
  8170. const Uint32 modulateA = info->a;
  8171. Uint32 pixel;
  8172. Uint32 R, G, B, A;
  8173. Uint64 srcy, srcx;
  8174. Uint64 posy, posx;
  8175. Uint64 incy, incx;
  8176. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8177. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8178. posy = incy / 2;
  8179. while (info->dst_h--) {
  8180. Uint32 *src = 0;
  8181. Uint32 *dst = (Uint32 *)info->dst;
  8182. int n = info->dst_w;
  8183. posx = incx / 2;
  8184. srcy = posy >> 16;
  8185. while (n--) {
  8186. srcx = posx >> 16;
  8187. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8188. pixel = *src;
  8189. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  8190. if (flags & SDL_COPY_MODULATE_COLOR) {
  8191. MULT_DIV_255(R, modulateR, R);
  8192. MULT_DIV_255(G, modulateG, G);
  8193. MULT_DIV_255(B, modulateB, B);
  8194. }
  8195. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8196. MULT_DIV_255(A, modulateA, A);
  8197. }
  8198. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  8199. *dst = pixel;
  8200. posx += incx;
  8201. ++dst;
  8202. }
  8203. posy += incy;
  8204. info->dst += info->dst_pitch;
  8205. }
  8206. }
  8207. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  8208. {
  8209. const int flags = info->flags;
  8210. const Uint32 modulateR = info->r;
  8211. const Uint32 modulateG = info->g;
  8212. const Uint32 modulateB = info->b;
  8213. const Uint32 modulateA = info->a;
  8214. Uint32 srcpixel;
  8215. Uint32 srcR, srcG, srcB, srcA;
  8216. Uint32 dstpixel;
  8217. Uint32 dstR, dstG, dstB, dstA;
  8218. while (info->dst_h--) {
  8219. Uint32 *src = (Uint32 *)info->src;
  8220. Uint32 *dst = (Uint32 *)info->dst;
  8221. int n = info->dst_w;
  8222. while (n--) {
  8223. srcpixel = *src;
  8224. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8225. dstpixel = *dst;
  8226. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8227. if (flags & SDL_COPY_MODULATE_COLOR) {
  8228. MULT_DIV_255(srcR, modulateR, srcR);
  8229. MULT_DIV_255(srcG, modulateG, srcG);
  8230. MULT_DIV_255(srcB, modulateB, srcB);
  8231. }
  8232. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8233. MULT_DIV_255(srcA, modulateA, srcA);
  8234. }
  8235. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8236. if (srcA < 255) {
  8237. MULT_DIV_255(srcR, srcA, srcR);
  8238. MULT_DIV_255(srcG, srcA, srcG);
  8239. MULT_DIV_255(srcB, srcA, srcB);
  8240. }
  8241. }
  8242. switch (flags & SDL_COPY_BLEND_MASK) {
  8243. case SDL_COPY_BLEND:
  8244. MULT_DIV_255((255 - srcA), dstR, dstR);
  8245. dstR += srcR;
  8246. MULT_DIV_255((255 - srcA), dstG, dstG);
  8247. dstG += srcG;
  8248. MULT_DIV_255((255 - srcA), dstB, dstB);
  8249. dstB += srcB;
  8250. MULT_DIV_255((255 - srcA), dstA, dstA);
  8251. dstA += srcA;
  8252. break;
  8253. case SDL_COPY_BLEND_PREMULTIPLIED:
  8254. MULT_DIV_255((255 - srcA), dstR, dstR);
  8255. dstR += srcR;
  8256. if (dstR > 255) dstR = 255;
  8257. MULT_DIV_255((255 - srcA), dstG, dstG);
  8258. dstG += srcG;
  8259. if (dstG > 255) dstG = 255;
  8260. MULT_DIV_255((255 - srcA), dstB, dstB);
  8261. dstB += srcB;
  8262. if (dstB > 255) dstB = 255;
  8263. MULT_DIV_255((255 - srcA), dstA, dstA);
  8264. dstA += srcA;
  8265. if (dstA > 255) dstA = 255;
  8266. break;
  8267. case SDL_COPY_ADD:
  8268. case SDL_COPY_ADD_PREMULTIPLIED:
  8269. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8270. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8271. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8272. break;
  8273. case SDL_COPY_MOD:
  8274. MULT_DIV_255(srcR, dstR, dstR);
  8275. MULT_DIV_255(srcG, dstG, dstG);
  8276. MULT_DIV_255(srcB, dstB, dstB);
  8277. break;
  8278. case SDL_COPY_MUL:
  8279. {
  8280. Uint32 tmp1, tmp2;
  8281. MULT_DIV_255(srcR, dstR, tmp1);
  8282. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8283. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8284. MULT_DIV_255(srcG, dstG, tmp1);
  8285. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8286. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8287. MULT_DIV_255(srcB, dstB, tmp1);
  8288. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8289. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8290. }
  8291. break;
  8292. }
  8293. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  8294. *dst = dstpixel;
  8295. ++src;
  8296. ++dst;
  8297. }
  8298. info->src += info->src_pitch;
  8299. info->dst += info->dst_pitch;
  8300. }
  8301. }
  8302. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  8303. {
  8304. const int flags = info->flags;
  8305. const Uint32 modulateR = info->r;
  8306. const Uint32 modulateG = info->g;
  8307. const Uint32 modulateB = info->b;
  8308. const Uint32 modulateA = info->a;
  8309. Uint32 srcpixel;
  8310. Uint32 srcR, srcG, srcB, srcA;
  8311. Uint32 dstpixel;
  8312. Uint32 dstR, dstG, dstB, dstA;
  8313. Uint64 srcy, srcx;
  8314. Uint64 posy, posx;
  8315. Uint64 incy, incx;
  8316. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8317. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8318. posy = incy / 2;
  8319. while (info->dst_h--) {
  8320. Uint32 *src = 0;
  8321. Uint32 *dst = (Uint32 *)info->dst;
  8322. int n = info->dst_w;
  8323. posx = incx / 2;
  8324. srcy = posy >> 16;
  8325. while (n--) {
  8326. srcx = posx >> 16;
  8327. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8328. srcpixel = *src;
  8329. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8330. dstpixel = *dst;
  8331. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8332. if (flags & SDL_COPY_MODULATE_COLOR) {
  8333. MULT_DIV_255(srcR, modulateR, srcR);
  8334. MULT_DIV_255(srcG, modulateG, srcG);
  8335. MULT_DIV_255(srcB, modulateB, srcB);
  8336. }
  8337. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8338. MULT_DIV_255(srcA, modulateA, srcA);
  8339. }
  8340. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8341. if (srcA < 255) {
  8342. MULT_DIV_255(srcR, srcA, srcR);
  8343. MULT_DIV_255(srcG, srcA, srcG);
  8344. MULT_DIV_255(srcB, srcA, srcB);
  8345. }
  8346. }
  8347. switch (flags & SDL_COPY_BLEND_MASK) {
  8348. case SDL_COPY_BLEND:
  8349. MULT_DIV_255((255 - srcA), dstR, dstR);
  8350. dstR += srcR;
  8351. MULT_DIV_255((255 - srcA), dstG, dstG);
  8352. dstG += srcG;
  8353. MULT_DIV_255((255 - srcA), dstB, dstB);
  8354. dstB += srcB;
  8355. MULT_DIV_255((255 - srcA), dstA, dstA);
  8356. dstA += srcA;
  8357. break;
  8358. case SDL_COPY_BLEND_PREMULTIPLIED:
  8359. MULT_DIV_255((255 - srcA), dstR, dstR);
  8360. dstR += srcR;
  8361. if (dstR > 255) dstR = 255;
  8362. MULT_DIV_255((255 - srcA), dstG, dstG);
  8363. dstG += srcG;
  8364. if (dstG > 255) dstG = 255;
  8365. MULT_DIV_255((255 - srcA), dstB, dstB);
  8366. dstB += srcB;
  8367. if (dstB > 255) dstB = 255;
  8368. MULT_DIV_255((255 - srcA), dstA, dstA);
  8369. dstA += srcA;
  8370. if (dstA > 255) dstA = 255;
  8371. break;
  8372. case SDL_COPY_ADD:
  8373. case SDL_COPY_ADD_PREMULTIPLIED:
  8374. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8375. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8376. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8377. break;
  8378. case SDL_COPY_MOD:
  8379. MULT_DIV_255(srcR, dstR, dstR);
  8380. MULT_DIV_255(srcG, dstG, dstG);
  8381. MULT_DIV_255(srcB, dstB, dstB);
  8382. break;
  8383. case SDL_COPY_MUL:
  8384. {
  8385. Uint32 tmp1, tmp2;
  8386. MULT_DIV_255(srcR, dstR, tmp1);
  8387. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8388. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8389. MULT_DIV_255(srcG, dstG, tmp1);
  8390. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8391. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8392. MULT_DIV_255(srcB, dstB, tmp1);
  8393. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8394. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8395. }
  8396. break;
  8397. }
  8398. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  8399. *dst = dstpixel;
  8400. posx += incx;
  8401. ++dst;
  8402. }
  8403. posy += incy;
  8404. info->dst += info->dst_pitch;
  8405. }
  8406. }
  8407. static void SDL_Blit_ABGR8888_ABGR8888_Scale(SDL_BlitInfo *info)
  8408. {
  8409. Uint64 srcy, srcx;
  8410. Uint64 posy, posx;
  8411. Uint64 incy, incx;
  8412. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8413. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8414. posy = incy / 2;
  8415. while (info->dst_h--) {
  8416. Uint32 *src = 0;
  8417. Uint32 *dst = (Uint32 *)info->dst;
  8418. int n = info->dst_w;
  8419. posx = incx / 2;
  8420. srcy = posy >> 16;
  8421. while (n--) {
  8422. srcx = posx >> 16;
  8423. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8424. *dst = *src;
  8425. posx += incx;
  8426. ++dst;
  8427. }
  8428. posy += incy;
  8429. info->dst += info->dst_pitch;
  8430. }
  8431. }
  8432. static void SDL_Blit_ABGR8888_ABGR8888_Blend(SDL_BlitInfo *info)
  8433. {
  8434. const int flags = info->flags;
  8435. Uint32 srcpixel;
  8436. Uint32 srcR, srcG, srcB, srcA;
  8437. Uint32 dstpixel;
  8438. Uint32 dstR, dstG, dstB, dstA;
  8439. while (info->dst_h--) {
  8440. Uint32 *src = (Uint32 *)info->src;
  8441. Uint32 *dst = (Uint32 *)info->dst;
  8442. int n = info->dst_w;
  8443. while (n--) {
  8444. srcpixel = *src;
  8445. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8446. dstpixel = *dst;
  8447. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8448. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8449. if (srcA < 255) {
  8450. MULT_DIV_255(srcR, srcA, srcR);
  8451. MULT_DIV_255(srcG, srcA, srcG);
  8452. MULT_DIV_255(srcB, srcA, srcB);
  8453. }
  8454. }
  8455. switch (flags & SDL_COPY_BLEND_MASK) {
  8456. case SDL_COPY_BLEND:
  8457. MULT_DIV_255((255 - srcA), dstR, dstR);
  8458. dstR += srcR;
  8459. MULT_DIV_255((255 - srcA), dstG, dstG);
  8460. dstG += srcG;
  8461. MULT_DIV_255((255 - srcA), dstB, dstB);
  8462. dstB += srcB;
  8463. MULT_DIV_255((255 - srcA), dstA, dstA);
  8464. dstA += srcA;
  8465. break;
  8466. case SDL_COPY_BLEND_PREMULTIPLIED:
  8467. MULT_DIV_255((255 - srcA), dstR, dstR);
  8468. dstR += srcR;
  8469. if (dstR > 255) dstR = 255;
  8470. MULT_DIV_255((255 - srcA), dstG, dstG);
  8471. dstG += srcG;
  8472. if (dstG > 255) dstG = 255;
  8473. MULT_DIV_255((255 - srcA), dstB, dstB);
  8474. dstB += srcB;
  8475. if (dstB > 255) dstB = 255;
  8476. MULT_DIV_255((255 - srcA), dstA, dstA);
  8477. dstA += srcA;
  8478. if (dstA > 255) dstA = 255;
  8479. break;
  8480. case SDL_COPY_ADD:
  8481. case SDL_COPY_ADD_PREMULTIPLIED:
  8482. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8483. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8484. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8485. break;
  8486. case SDL_COPY_MOD:
  8487. MULT_DIV_255(srcR, dstR, dstR);
  8488. MULT_DIV_255(srcG, dstG, dstG);
  8489. MULT_DIV_255(srcB, dstB, dstB);
  8490. break;
  8491. case SDL_COPY_MUL:
  8492. {
  8493. Uint32 tmp1, tmp2;
  8494. MULT_DIV_255(srcR, dstR, tmp1);
  8495. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8496. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8497. MULT_DIV_255(srcG, dstG, tmp1);
  8498. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8499. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8500. MULT_DIV_255(srcB, dstB, tmp1);
  8501. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8502. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8503. }
  8504. break;
  8505. }
  8506. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  8507. *dst = dstpixel;
  8508. ++src;
  8509. ++dst;
  8510. }
  8511. info->src += info->src_pitch;
  8512. info->dst += info->dst_pitch;
  8513. }
  8514. }
  8515. static void SDL_Blit_ABGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  8516. {
  8517. const int flags = info->flags;
  8518. Uint32 srcpixel;
  8519. Uint32 srcR, srcG, srcB, srcA;
  8520. Uint32 dstpixel;
  8521. Uint32 dstR, dstG, dstB, dstA;
  8522. Uint64 srcy, srcx;
  8523. Uint64 posy, posx;
  8524. Uint64 incy, incx;
  8525. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8526. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8527. posy = incy / 2;
  8528. while (info->dst_h--) {
  8529. Uint32 *src = 0;
  8530. Uint32 *dst = (Uint32 *)info->dst;
  8531. int n = info->dst_w;
  8532. posx = incx / 2;
  8533. srcy = posy >> 16;
  8534. while (n--) {
  8535. srcx = posx >> 16;
  8536. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8537. srcpixel = *src;
  8538. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8539. dstpixel = *dst;
  8540. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8541. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8542. if (srcA < 255) {
  8543. MULT_DIV_255(srcR, srcA, srcR);
  8544. MULT_DIV_255(srcG, srcA, srcG);
  8545. MULT_DIV_255(srcB, srcA, srcB);
  8546. }
  8547. }
  8548. switch (flags & SDL_COPY_BLEND_MASK) {
  8549. case SDL_COPY_BLEND:
  8550. MULT_DIV_255((255 - srcA), dstR, dstR);
  8551. dstR += srcR;
  8552. MULT_DIV_255((255 - srcA), dstG, dstG);
  8553. dstG += srcG;
  8554. MULT_DIV_255((255 - srcA), dstB, dstB);
  8555. dstB += srcB;
  8556. MULT_DIV_255((255 - srcA), dstA, dstA);
  8557. dstA += srcA;
  8558. break;
  8559. case SDL_COPY_BLEND_PREMULTIPLIED:
  8560. MULT_DIV_255((255 - srcA), dstR, dstR);
  8561. dstR += srcR;
  8562. if (dstR > 255) dstR = 255;
  8563. MULT_DIV_255((255 - srcA), dstG, dstG);
  8564. dstG += srcG;
  8565. if (dstG > 255) dstG = 255;
  8566. MULT_DIV_255((255 - srcA), dstB, dstB);
  8567. dstB += srcB;
  8568. if (dstB > 255) dstB = 255;
  8569. MULT_DIV_255((255 - srcA), dstA, dstA);
  8570. dstA += srcA;
  8571. if (dstA > 255) dstA = 255;
  8572. break;
  8573. case SDL_COPY_ADD:
  8574. case SDL_COPY_ADD_PREMULTIPLIED:
  8575. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8576. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8577. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8578. break;
  8579. case SDL_COPY_MOD:
  8580. MULT_DIV_255(srcR, dstR, dstR);
  8581. MULT_DIV_255(srcG, dstG, dstG);
  8582. MULT_DIV_255(srcB, dstB, dstB);
  8583. break;
  8584. case SDL_COPY_MUL:
  8585. {
  8586. Uint32 tmp1, tmp2;
  8587. MULT_DIV_255(srcR, dstR, tmp1);
  8588. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8589. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8590. MULT_DIV_255(srcG, dstG, tmp1);
  8591. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8592. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8593. MULT_DIV_255(srcB, dstB, tmp1);
  8594. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8595. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8596. }
  8597. break;
  8598. }
  8599. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  8600. *dst = dstpixel;
  8601. posx += incx;
  8602. ++dst;
  8603. }
  8604. posy += incy;
  8605. info->dst += info->dst_pitch;
  8606. }
  8607. }
  8608. static void SDL_Blit_ABGR8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  8609. {
  8610. const int flags = info->flags;
  8611. const Uint32 modulateR = info->r;
  8612. const Uint32 modulateG = info->g;
  8613. const Uint32 modulateB = info->b;
  8614. const Uint32 modulateA = info->a;
  8615. Uint32 pixel;
  8616. Uint32 R, G, B, A;
  8617. while (info->dst_h--) {
  8618. Uint32 *src = (Uint32 *)info->src;
  8619. Uint32 *dst = (Uint32 *)info->dst;
  8620. int n = info->dst_w;
  8621. while (n--) {
  8622. pixel = *src;
  8623. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  8624. if (flags & SDL_COPY_MODULATE_COLOR) {
  8625. MULT_DIV_255(R, modulateR, R);
  8626. MULT_DIV_255(G, modulateG, G);
  8627. MULT_DIV_255(B, modulateB, B);
  8628. }
  8629. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8630. MULT_DIV_255(A, modulateA, A);
  8631. }
  8632. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  8633. *dst = pixel;
  8634. ++src;
  8635. ++dst;
  8636. }
  8637. info->src += info->src_pitch;
  8638. info->dst += info->dst_pitch;
  8639. }
  8640. }
  8641. static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  8642. {
  8643. const int flags = info->flags;
  8644. const Uint32 modulateR = info->r;
  8645. const Uint32 modulateG = info->g;
  8646. const Uint32 modulateB = info->b;
  8647. const Uint32 modulateA = info->a;
  8648. Uint32 pixel;
  8649. Uint32 R, G, B, A;
  8650. Uint64 srcy, srcx;
  8651. Uint64 posy, posx;
  8652. Uint64 incy, incx;
  8653. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8654. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8655. posy = incy / 2;
  8656. while (info->dst_h--) {
  8657. Uint32 *src = 0;
  8658. Uint32 *dst = (Uint32 *)info->dst;
  8659. int n = info->dst_w;
  8660. posx = incx / 2;
  8661. srcy = posy >> 16;
  8662. while (n--) {
  8663. srcx = posx >> 16;
  8664. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8665. pixel = *src;
  8666. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  8667. if (flags & SDL_COPY_MODULATE_COLOR) {
  8668. MULT_DIV_255(R, modulateR, R);
  8669. MULT_DIV_255(G, modulateG, G);
  8670. MULT_DIV_255(B, modulateB, B);
  8671. }
  8672. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8673. MULT_DIV_255(A, modulateA, A);
  8674. }
  8675. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  8676. *dst = pixel;
  8677. posx += incx;
  8678. ++dst;
  8679. }
  8680. posy += incy;
  8681. info->dst += info->dst_pitch;
  8682. }
  8683. }
  8684. static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  8685. {
  8686. const int flags = info->flags;
  8687. const Uint32 modulateR = info->r;
  8688. const Uint32 modulateG = info->g;
  8689. const Uint32 modulateB = info->b;
  8690. const Uint32 modulateA = info->a;
  8691. Uint32 srcpixel;
  8692. Uint32 srcR, srcG, srcB, srcA;
  8693. Uint32 dstpixel;
  8694. Uint32 dstR, dstG, dstB, dstA;
  8695. while (info->dst_h--) {
  8696. Uint32 *src = (Uint32 *)info->src;
  8697. Uint32 *dst = (Uint32 *)info->dst;
  8698. int n = info->dst_w;
  8699. while (n--) {
  8700. srcpixel = *src;
  8701. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8702. dstpixel = *dst;
  8703. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8704. if (flags & SDL_COPY_MODULATE_COLOR) {
  8705. MULT_DIV_255(srcR, modulateR, srcR);
  8706. MULT_DIV_255(srcG, modulateG, srcG);
  8707. MULT_DIV_255(srcB, modulateB, srcB);
  8708. }
  8709. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8710. MULT_DIV_255(srcA, modulateA, srcA);
  8711. }
  8712. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8713. if (srcA < 255) {
  8714. MULT_DIV_255(srcR, srcA, srcR);
  8715. MULT_DIV_255(srcG, srcA, srcG);
  8716. MULT_DIV_255(srcB, srcA, srcB);
  8717. }
  8718. }
  8719. switch (flags & SDL_COPY_BLEND_MASK) {
  8720. case SDL_COPY_BLEND:
  8721. MULT_DIV_255((255 - srcA), dstR, dstR);
  8722. dstR += srcR;
  8723. MULT_DIV_255((255 - srcA), dstG, dstG);
  8724. dstG += srcG;
  8725. MULT_DIV_255((255 - srcA), dstB, dstB);
  8726. dstB += srcB;
  8727. MULT_DIV_255((255 - srcA), dstA, dstA);
  8728. dstA += srcA;
  8729. break;
  8730. case SDL_COPY_BLEND_PREMULTIPLIED:
  8731. MULT_DIV_255((255 - srcA), dstR, dstR);
  8732. dstR += srcR;
  8733. if (dstR > 255) dstR = 255;
  8734. MULT_DIV_255((255 - srcA), dstG, dstG);
  8735. dstG += srcG;
  8736. if (dstG > 255) dstG = 255;
  8737. MULT_DIV_255((255 - srcA), dstB, dstB);
  8738. dstB += srcB;
  8739. if (dstB > 255) dstB = 255;
  8740. MULT_DIV_255((255 - srcA), dstA, dstA);
  8741. dstA += srcA;
  8742. if (dstA > 255) dstA = 255;
  8743. break;
  8744. case SDL_COPY_ADD:
  8745. case SDL_COPY_ADD_PREMULTIPLIED:
  8746. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8747. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8748. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8749. break;
  8750. case SDL_COPY_MOD:
  8751. MULT_DIV_255(srcR, dstR, dstR);
  8752. MULT_DIV_255(srcG, dstG, dstG);
  8753. MULT_DIV_255(srcB, dstB, dstB);
  8754. break;
  8755. case SDL_COPY_MUL:
  8756. {
  8757. Uint32 tmp1, tmp2;
  8758. MULT_DIV_255(srcR, dstR, tmp1);
  8759. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8760. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8761. MULT_DIV_255(srcG, dstG, tmp1);
  8762. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8763. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8764. MULT_DIV_255(srcB, dstB, tmp1);
  8765. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8766. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8767. }
  8768. break;
  8769. }
  8770. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  8771. *dst = dstpixel;
  8772. ++src;
  8773. ++dst;
  8774. }
  8775. info->src += info->src_pitch;
  8776. info->dst += info->dst_pitch;
  8777. }
  8778. }
  8779. static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  8780. {
  8781. const int flags = info->flags;
  8782. const Uint32 modulateR = info->r;
  8783. const Uint32 modulateG = info->g;
  8784. const Uint32 modulateB = info->b;
  8785. const Uint32 modulateA = info->a;
  8786. Uint32 srcpixel;
  8787. Uint32 srcR, srcG, srcB, srcA;
  8788. Uint32 dstpixel;
  8789. Uint32 dstR, dstG, dstB, dstA;
  8790. Uint64 srcy, srcx;
  8791. Uint64 posy, posx;
  8792. Uint64 incy, incx;
  8793. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8794. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8795. posy = incy / 2;
  8796. while (info->dst_h--) {
  8797. Uint32 *src = 0;
  8798. Uint32 *dst = (Uint32 *)info->dst;
  8799. int n = info->dst_w;
  8800. posx = incx / 2;
  8801. srcy = posy >> 16;
  8802. while (n--) {
  8803. srcx = posx >> 16;
  8804. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8805. srcpixel = *src;
  8806. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8807. dstpixel = *dst;
  8808. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8809. if (flags & SDL_COPY_MODULATE_COLOR) {
  8810. MULT_DIV_255(srcR, modulateR, srcR);
  8811. MULT_DIV_255(srcG, modulateG, srcG);
  8812. MULT_DIV_255(srcB, modulateB, srcB);
  8813. }
  8814. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8815. MULT_DIV_255(srcA, modulateA, srcA);
  8816. }
  8817. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8818. if (srcA < 255) {
  8819. MULT_DIV_255(srcR, srcA, srcR);
  8820. MULT_DIV_255(srcG, srcA, srcG);
  8821. MULT_DIV_255(srcB, srcA, srcB);
  8822. }
  8823. }
  8824. switch (flags & SDL_COPY_BLEND_MASK) {
  8825. case SDL_COPY_BLEND:
  8826. MULT_DIV_255((255 - srcA), dstR, dstR);
  8827. dstR += srcR;
  8828. MULT_DIV_255((255 - srcA), dstG, dstG);
  8829. dstG += srcG;
  8830. MULT_DIV_255((255 - srcA), dstB, dstB);
  8831. dstB += srcB;
  8832. MULT_DIV_255((255 - srcA), dstA, dstA);
  8833. dstA += srcA;
  8834. break;
  8835. case SDL_COPY_BLEND_PREMULTIPLIED:
  8836. MULT_DIV_255((255 - srcA), dstR, dstR);
  8837. dstR += srcR;
  8838. if (dstR > 255) dstR = 255;
  8839. MULT_DIV_255((255 - srcA), dstG, dstG);
  8840. dstG += srcG;
  8841. if (dstG > 255) dstG = 255;
  8842. MULT_DIV_255((255 - srcA), dstB, dstB);
  8843. dstB += srcB;
  8844. if (dstB > 255) dstB = 255;
  8845. MULT_DIV_255((255 - srcA), dstA, dstA);
  8846. dstA += srcA;
  8847. if (dstA > 255) dstA = 255;
  8848. break;
  8849. case SDL_COPY_ADD:
  8850. case SDL_COPY_ADD_PREMULTIPLIED:
  8851. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8852. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8853. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8854. break;
  8855. case SDL_COPY_MOD:
  8856. MULT_DIV_255(srcR, dstR, dstR);
  8857. MULT_DIV_255(srcG, dstG, dstG);
  8858. MULT_DIV_255(srcB, dstB, dstB);
  8859. break;
  8860. case SDL_COPY_MUL:
  8861. {
  8862. Uint32 tmp1, tmp2;
  8863. MULT_DIV_255(srcR, dstR, tmp1);
  8864. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8865. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8866. MULT_DIV_255(srcG, dstG, tmp1);
  8867. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8868. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8869. MULT_DIV_255(srcB, dstB, tmp1);
  8870. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8871. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8872. }
  8873. break;
  8874. }
  8875. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  8876. *dst = dstpixel;
  8877. posx += incx;
  8878. ++dst;
  8879. }
  8880. posy += incy;
  8881. info->dst += info->dst_pitch;
  8882. }
  8883. }
  8884. static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
  8885. {
  8886. Uint32 pixel;
  8887. Uint32 R, G, B;
  8888. Uint64 srcy, srcx;
  8889. Uint64 posy, posx;
  8890. Uint64 incy, incx;
  8891. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8892. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8893. posy = incy / 2;
  8894. while (info->dst_h--) {
  8895. Uint32 *src = 0;
  8896. Uint32 *dst = (Uint32 *)info->dst;
  8897. int n = info->dst_w;
  8898. posx = incx / 2;
  8899. srcy = posy >> 16;
  8900. while (n--) {
  8901. srcx = posx >> 16;
  8902. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8903. pixel = *src;
  8904. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  8905. pixel = (R << 16) | (G << 8) | B;
  8906. *dst = pixel;
  8907. posx += incx;
  8908. ++dst;
  8909. }
  8910. posy += incy;
  8911. info->dst += info->dst_pitch;
  8912. }
  8913. }
  8914. static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
  8915. {
  8916. const int flags = info->flags;
  8917. Uint32 srcpixel;
  8918. Uint32 srcR, srcG, srcB, srcA;
  8919. Uint32 dstpixel;
  8920. Uint32 dstR, dstG, dstB;
  8921. while (info->dst_h--) {
  8922. Uint32 *src = (Uint32 *)info->src;
  8923. Uint32 *dst = (Uint32 *)info->dst;
  8924. int n = info->dst_w;
  8925. while (n--) {
  8926. srcpixel = *src;
  8927. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  8928. dstpixel = *dst;
  8929. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  8930. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8931. if (srcA < 255) {
  8932. MULT_DIV_255(srcR, srcA, srcR);
  8933. MULT_DIV_255(srcG, srcA, srcG);
  8934. MULT_DIV_255(srcB, srcA, srcB);
  8935. }
  8936. }
  8937. switch (flags & SDL_COPY_BLEND_MASK) {
  8938. case SDL_COPY_BLEND:
  8939. MULT_DIV_255((255 - srcA), dstR, dstR);
  8940. dstR += srcR;
  8941. MULT_DIV_255((255 - srcA), dstG, dstG);
  8942. dstG += srcG;
  8943. MULT_DIV_255((255 - srcA), dstB, dstB);
  8944. dstB += srcB;
  8945. break;
  8946. case SDL_COPY_BLEND_PREMULTIPLIED:
  8947. MULT_DIV_255((255 - srcA), dstR, dstR);
  8948. dstR += srcR;
  8949. if (dstR > 255) dstR = 255;
  8950. MULT_DIV_255((255 - srcA), dstG, dstG);
  8951. dstG += srcG;
  8952. if (dstG > 255) dstG = 255;
  8953. MULT_DIV_255((255 - srcA), dstB, dstB);
  8954. dstB += srcB;
  8955. if (dstB > 255) dstB = 255;
  8956. break;
  8957. case SDL_COPY_ADD:
  8958. case SDL_COPY_ADD_PREMULTIPLIED:
  8959. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8960. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8961. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8962. break;
  8963. case SDL_COPY_MOD:
  8964. MULT_DIV_255(srcR, dstR, dstR);
  8965. MULT_DIV_255(srcG, dstG, dstG);
  8966. MULT_DIV_255(srcB, dstB, dstB);
  8967. break;
  8968. case SDL_COPY_MUL:
  8969. {
  8970. Uint32 tmp1, tmp2;
  8971. MULT_DIV_255(srcR, dstR, tmp1);
  8972. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8973. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8974. MULT_DIV_255(srcG, dstG, tmp1);
  8975. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8976. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8977. MULT_DIV_255(srcB, dstB, tmp1);
  8978. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8979. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8980. }
  8981. break;
  8982. }
  8983. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  8984. *dst = dstpixel;
  8985. ++src;
  8986. ++dst;
  8987. }
  8988. info->src += info->src_pitch;
  8989. info->dst += info->dst_pitch;
  8990. }
  8991. }
  8992. static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  8993. {
  8994. const int flags = info->flags;
  8995. Uint32 srcpixel;
  8996. Uint32 srcR, srcG, srcB, srcA;
  8997. Uint32 dstpixel;
  8998. Uint32 dstR, dstG, dstB;
  8999. Uint64 srcy, srcx;
  9000. Uint64 posy, posx;
  9001. Uint64 incy, incx;
  9002. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9003. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9004. posy = incy / 2;
  9005. while (info->dst_h--) {
  9006. Uint32 *src = 0;
  9007. Uint32 *dst = (Uint32 *)info->dst;
  9008. int n = info->dst_w;
  9009. posx = incx / 2;
  9010. srcy = posy >> 16;
  9011. while (n--) {
  9012. srcx = posx >> 16;
  9013. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9014. srcpixel = *src;
  9015. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9016. dstpixel = *dst;
  9017. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  9018. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9019. if (srcA < 255) {
  9020. MULT_DIV_255(srcR, srcA, srcR);
  9021. MULT_DIV_255(srcG, srcA, srcG);
  9022. MULT_DIV_255(srcB, srcA, srcB);
  9023. }
  9024. }
  9025. switch (flags & SDL_COPY_BLEND_MASK) {
  9026. case SDL_COPY_BLEND:
  9027. MULT_DIV_255((255 - srcA), dstR, dstR);
  9028. dstR += srcR;
  9029. MULT_DIV_255((255 - srcA), dstG, dstG);
  9030. dstG += srcG;
  9031. MULT_DIV_255((255 - srcA), dstB, dstB);
  9032. dstB += srcB;
  9033. break;
  9034. case SDL_COPY_BLEND_PREMULTIPLIED:
  9035. MULT_DIV_255((255 - srcA), dstR, dstR);
  9036. dstR += srcR;
  9037. if (dstR > 255) dstR = 255;
  9038. MULT_DIV_255((255 - srcA), dstG, dstG);
  9039. dstG += srcG;
  9040. if (dstG > 255) dstG = 255;
  9041. MULT_DIV_255((255 - srcA), dstB, dstB);
  9042. dstB += srcB;
  9043. if (dstB > 255) dstB = 255;
  9044. break;
  9045. case SDL_COPY_ADD:
  9046. case SDL_COPY_ADD_PREMULTIPLIED:
  9047. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9048. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9049. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9050. break;
  9051. case SDL_COPY_MOD:
  9052. MULT_DIV_255(srcR, dstR, dstR);
  9053. MULT_DIV_255(srcG, dstG, dstG);
  9054. MULT_DIV_255(srcB, dstB, dstB);
  9055. break;
  9056. case SDL_COPY_MUL:
  9057. {
  9058. Uint32 tmp1, tmp2;
  9059. MULT_DIV_255(srcR, dstR, tmp1);
  9060. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9061. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9062. MULT_DIV_255(srcG, dstG, tmp1);
  9063. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9064. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9065. MULT_DIV_255(srcB, dstB, tmp1);
  9066. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9067. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9068. }
  9069. break;
  9070. }
  9071. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  9072. *dst = dstpixel;
  9073. posx += incx;
  9074. ++dst;
  9075. }
  9076. posy += incy;
  9077. info->dst += info->dst_pitch;
  9078. }
  9079. }
  9080. static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  9081. {
  9082. const int flags = info->flags;
  9083. const Uint32 modulateR = info->r;
  9084. const Uint32 modulateG = info->g;
  9085. const Uint32 modulateB = info->b;
  9086. Uint32 pixel;
  9087. Uint32 R, G, B;
  9088. while (info->dst_h--) {
  9089. Uint32 *src = (Uint32 *)info->src;
  9090. Uint32 *dst = (Uint32 *)info->dst;
  9091. int n = info->dst_w;
  9092. while (n--) {
  9093. pixel = *src;
  9094. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  9095. if (flags & SDL_COPY_MODULATE_COLOR) {
  9096. MULT_DIV_255(R, modulateR, R);
  9097. MULT_DIV_255(G, modulateG, G);
  9098. MULT_DIV_255(B, modulateB, B);
  9099. }
  9100. pixel = (R << 16) | (G << 8) | B;
  9101. *dst = pixel;
  9102. ++src;
  9103. ++dst;
  9104. }
  9105. info->src += info->src_pitch;
  9106. info->dst += info->dst_pitch;
  9107. }
  9108. }
  9109. static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  9110. {
  9111. const int flags = info->flags;
  9112. const Uint32 modulateR = info->r;
  9113. const Uint32 modulateG = info->g;
  9114. const Uint32 modulateB = info->b;
  9115. Uint32 pixel;
  9116. Uint32 R, G, B;
  9117. Uint64 srcy, srcx;
  9118. Uint64 posy, posx;
  9119. Uint64 incy, incx;
  9120. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9121. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9122. posy = incy / 2;
  9123. while (info->dst_h--) {
  9124. Uint32 *src = 0;
  9125. Uint32 *dst = (Uint32 *)info->dst;
  9126. int n = info->dst_w;
  9127. posx = incx / 2;
  9128. srcy = posy >> 16;
  9129. while (n--) {
  9130. srcx = posx >> 16;
  9131. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9132. pixel = *src;
  9133. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  9134. if (flags & SDL_COPY_MODULATE_COLOR) {
  9135. MULT_DIV_255(R, modulateR, R);
  9136. MULT_DIV_255(G, modulateG, G);
  9137. MULT_DIV_255(B, modulateB, B);
  9138. }
  9139. pixel = (R << 16) | (G << 8) | B;
  9140. *dst = pixel;
  9141. posx += incx;
  9142. ++dst;
  9143. }
  9144. posy += incy;
  9145. info->dst += info->dst_pitch;
  9146. }
  9147. }
  9148. static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  9149. {
  9150. const int flags = info->flags;
  9151. const Uint32 modulateR = info->r;
  9152. const Uint32 modulateG = info->g;
  9153. const Uint32 modulateB = info->b;
  9154. const Uint32 modulateA = info->a;
  9155. Uint32 srcpixel;
  9156. Uint32 srcR, srcG, srcB, srcA;
  9157. Uint32 dstpixel;
  9158. Uint32 dstR, dstG, dstB;
  9159. while (info->dst_h--) {
  9160. Uint32 *src = (Uint32 *)info->src;
  9161. Uint32 *dst = (Uint32 *)info->dst;
  9162. int n = info->dst_w;
  9163. while (n--) {
  9164. srcpixel = *src;
  9165. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9166. dstpixel = *dst;
  9167. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  9168. if (flags & SDL_COPY_MODULATE_COLOR) {
  9169. MULT_DIV_255(srcR, modulateR, srcR);
  9170. MULT_DIV_255(srcG, modulateG, srcG);
  9171. MULT_DIV_255(srcB, modulateB, srcB);
  9172. }
  9173. if (flags & SDL_COPY_MODULATE_ALPHA) {
  9174. MULT_DIV_255(srcA, modulateA, srcA);
  9175. }
  9176. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9177. if (srcA < 255) {
  9178. MULT_DIV_255(srcR, srcA, srcR);
  9179. MULT_DIV_255(srcG, srcA, srcG);
  9180. MULT_DIV_255(srcB, srcA, srcB);
  9181. }
  9182. }
  9183. switch (flags & SDL_COPY_BLEND_MASK) {
  9184. case SDL_COPY_BLEND:
  9185. MULT_DIV_255((255 - srcA), dstR, dstR);
  9186. dstR += srcR;
  9187. MULT_DIV_255((255 - srcA), dstG, dstG);
  9188. dstG += srcG;
  9189. MULT_DIV_255((255 - srcA), dstB, dstB);
  9190. dstB += srcB;
  9191. break;
  9192. case SDL_COPY_BLEND_PREMULTIPLIED:
  9193. MULT_DIV_255((255 - srcA), dstR, dstR);
  9194. dstR += srcR;
  9195. if (dstR > 255) dstR = 255;
  9196. MULT_DIV_255((255 - srcA), dstG, dstG);
  9197. dstG += srcG;
  9198. if (dstG > 255) dstG = 255;
  9199. MULT_DIV_255((255 - srcA), dstB, dstB);
  9200. dstB += srcB;
  9201. if (dstB > 255) dstB = 255;
  9202. break;
  9203. case SDL_COPY_ADD:
  9204. case SDL_COPY_ADD_PREMULTIPLIED:
  9205. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9206. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9207. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9208. break;
  9209. case SDL_COPY_MOD:
  9210. MULT_DIV_255(srcR, dstR, dstR);
  9211. MULT_DIV_255(srcG, dstG, dstG);
  9212. MULT_DIV_255(srcB, dstB, dstB);
  9213. break;
  9214. case SDL_COPY_MUL:
  9215. {
  9216. Uint32 tmp1, tmp2;
  9217. MULT_DIV_255(srcR, dstR, tmp1);
  9218. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9219. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9220. MULT_DIV_255(srcG, dstG, tmp1);
  9221. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9222. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9223. MULT_DIV_255(srcB, dstB, tmp1);
  9224. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9225. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9226. }
  9227. break;
  9228. }
  9229. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  9230. *dst = dstpixel;
  9231. ++src;
  9232. ++dst;
  9233. }
  9234. info->src += info->src_pitch;
  9235. info->dst += info->dst_pitch;
  9236. }
  9237. }
  9238. static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  9239. {
  9240. const int flags = info->flags;
  9241. const Uint32 modulateR = info->r;
  9242. const Uint32 modulateG = info->g;
  9243. const Uint32 modulateB = info->b;
  9244. const Uint32 modulateA = info->a;
  9245. Uint32 srcpixel;
  9246. Uint32 srcR, srcG, srcB, srcA;
  9247. Uint32 dstpixel;
  9248. Uint32 dstR, dstG, dstB;
  9249. Uint64 srcy, srcx;
  9250. Uint64 posy, posx;
  9251. Uint64 incy, incx;
  9252. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9253. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9254. posy = incy / 2;
  9255. while (info->dst_h--) {
  9256. Uint32 *src = 0;
  9257. Uint32 *dst = (Uint32 *)info->dst;
  9258. int n = info->dst_w;
  9259. posx = incx / 2;
  9260. srcy = posy >> 16;
  9261. while (n--) {
  9262. srcx = posx >> 16;
  9263. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9264. srcpixel = *src;
  9265. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9266. dstpixel = *dst;
  9267. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  9268. if (flags & SDL_COPY_MODULATE_COLOR) {
  9269. MULT_DIV_255(srcR, modulateR, srcR);
  9270. MULT_DIV_255(srcG, modulateG, srcG);
  9271. MULT_DIV_255(srcB, modulateB, srcB);
  9272. }
  9273. if (flags & SDL_COPY_MODULATE_ALPHA) {
  9274. MULT_DIV_255(srcA, modulateA, srcA);
  9275. }
  9276. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9277. if (srcA < 255) {
  9278. MULT_DIV_255(srcR, srcA, srcR);
  9279. MULT_DIV_255(srcG, srcA, srcG);
  9280. MULT_DIV_255(srcB, srcA, srcB);
  9281. }
  9282. }
  9283. switch (flags & SDL_COPY_BLEND_MASK) {
  9284. case SDL_COPY_BLEND:
  9285. MULT_DIV_255((255 - srcA), dstR, dstR);
  9286. dstR += srcR;
  9287. MULT_DIV_255((255 - srcA), dstG, dstG);
  9288. dstG += srcG;
  9289. MULT_DIV_255((255 - srcA), dstB, dstB);
  9290. dstB += srcB;
  9291. break;
  9292. case SDL_COPY_BLEND_PREMULTIPLIED:
  9293. MULT_DIV_255((255 - srcA), dstR, dstR);
  9294. dstR += srcR;
  9295. if (dstR > 255) dstR = 255;
  9296. MULT_DIV_255((255 - srcA), dstG, dstG);
  9297. dstG += srcG;
  9298. if (dstG > 255) dstG = 255;
  9299. MULT_DIV_255((255 - srcA), dstB, dstB);
  9300. dstB += srcB;
  9301. if (dstB > 255) dstB = 255;
  9302. break;
  9303. case SDL_COPY_ADD:
  9304. case SDL_COPY_ADD_PREMULTIPLIED:
  9305. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9306. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9307. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9308. break;
  9309. case SDL_COPY_MOD:
  9310. MULT_DIV_255(srcR, dstR, dstR);
  9311. MULT_DIV_255(srcG, dstG, dstG);
  9312. MULT_DIV_255(srcB, dstB, dstB);
  9313. break;
  9314. case SDL_COPY_MUL:
  9315. {
  9316. Uint32 tmp1, tmp2;
  9317. MULT_DIV_255(srcR, dstR, tmp1);
  9318. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9319. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9320. MULT_DIV_255(srcG, dstG, tmp1);
  9321. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9322. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9323. MULT_DIV_255(srcB, dstB, tmp1);
  9324. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9325. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9326. }
  9327. break;
  9328. }
  9329. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  9330. *dst = dstpixel;
  9331. posx += incx;
  9332. ++dst;
  9333. }
  9334. posy += incy;
  9335. info->dst += info->dst_pitch;
  9336. }
  9337. }
  9338. static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
  9339. {
  9340. Uint32 pixel;
  9341. Uint64 srcy, srcx;
  9342. Uint64 posy, posx;
  9343. Uint64 incy, incx;
  9344. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9345. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9346. posy = incy / 2;
  9347. while (info->dst_h--) {
  9348. Uint32 *src = 0;
  9349. Uint32 *dst = (Uint32 *)info->dst;
  9350. int n = info->dst_w;
  9351. posx = incx / 2;
  9352. srcy = posy >> 16;
  9353. while (n--) {
  9354. srcx = posx >> 16;
  9355. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9356. pixel = *src;
  9357. pixel >>= 8;
  9358. *dst = pixel;
  9359. posx += incx;
  9360. ++dst;
  9361. }
  9362. posy += incy;
  9363. info->dst += info->dst_pitch;
  9364. }
  9365. }
  9366. static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
  9367. {
  9368. const int flags = info->flags;
  9369. Uint32 srcpixel;
  9370. Uint32 srcR, srcG, srcB, srcA;
  9371. Uint32 dstpixel;
  9372. Uint32 dstR, dstG, dstB;
  9373. while (info->dst_h--) {
  9374. Uint32 *src = (Uint32 *)info->src;
  9375. Uint32 *dst = (Uint32 *)info->dst;
  9376. int n = info->dst_w;
  9377. while (n--) {
  9378. srcpixel = *src;
  9379. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9380. dstpixel = *dst;
  9381. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  9382. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9383. if (srcA < 255) {
  9384. MULT_DIV_255(srcR, srcA, srcR);
  9385. MULT_DIV_255(srcG, srcA, srcG);
  9386. MULT_DIV_255(srcB, srcA, srcB);
  9387. }
  9388. }
  9389. switch (flags & SDL_COPY_BLEND_MASK) {
  9390. case SDL_COPY_BLEND:
  9391. MULT_DIV_255((255 - srcA), dstR, dstR);
  9392. dstR += srcR;
  9393. MULT_DIV_255((255 - srcA), dstG, dstG);
  9394. dstG += srcG;
  9395. MULT_DIV_255((255 - srcA), dstB, dstB);
  9396. dstB += srcB;
  9397. break;
  9398. case SDL_COPY_BLEND_PREMULTIPLIED:
  9399. MULT_DIV_255((255 - srcA), dstR, dstR);
  9400. dstR += srcR;
  9401. if (dstR > 255) dstR = 255;
  9402. MULT_DIV_255((255 - srcA), dstG, dstG);
  9403. dstG += srcG;
  9404. if (dstG > 255) dstG = 255;
  9405. MULT_DIV_255((255 - srcA), dstB, dstB);
  9406. dstB += srcB;
  9407. if (dstB > 255) dstB = 255;
  9408. break;
  9409. case SDL_COPY_ADD:
  9410. case SDL_COPY_ADD_PREMULTIPLIED:
  9411. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9412. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9413. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9414. break;
  9415. case SDL_COPY_MOD:
  9416. MULT_DIV_255(srcR, dstR, dstR);
  9417. MULT_DIV_255(srcG, dstG, dstG);
  9418. MULT_DIV_255(srcB, dstB, dstB);
  9419. break;
  9420. case SDL_COPY_MUL:
  9421. {
  9422. Uint32 tmp1, tmp2;
  9423. MULT_DIV_255(srcR, dstR, tmp1);
  9424. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9425. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9426. MULT_DIV_255(srcG, dstG, tmp1);
  9427. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9428. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9429. MULT_DIV_255(srcB, dstB, tmp1);
  9430. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9431. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9432. }
  9433. break;
  9434. }
  9435. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  9436. *dst = dstpixel;
  9437. ++src;
  9438. ++dst;
  9439. }
  9440. info->src += info->src_pitch;
  9441. info->dst += info->dst_pitch;
  9442. }
  9443. }
  9444. static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  9445. {
  9446. const int flags = info->flags;
  9447. Uint32 srcpixel;
  9448. Uint32 srcR, srcG, srcB, srcA;
  9449. Uint32 dstpixel;
  9450. Uint32 dstR, dstG, dstB;
  9451. Uint64 srcy, srcx;
  9452. Uint64 posy, posx;
  9453. Uint64 incy, incx;
  9454. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9455. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9456. posy = incy / 2;
  9457. while (info->dst_h--) {
  9458. Uint32 *src = 0;
  9459. Uint32 *dst = (Uint32 *)info->dst;
  9460. int n = info->dst_w;
  9461. posx = incx / 2;
  9462. srcy = posy >> 16;
  9463. while (n--) {
  9464. srcx = posx >> 16;
  9465. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9466. srcpixel = *src;
  9467. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9468. dstpixel = *dst;
  9469. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  9470. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9471. if (srcA < 255) {
  9472. MULT_DIV_255(srcR, srcA, srcR);
  9473. MULT_DIV_255(srcG, srcA, srcG);
  9474. MULT_DIV_255(srcB, srcA, srcB);
  9475. }
  9476. }
  9477. switch (flags & SDL_COPY_BLEND_MASK) {
  9478. case SDL_COPY_BLEND:
  9479. MULT_DIV_255((255 - srcA), dstR, dstR);
  9480. dstR += srcR;
  9481. MULT_DIV_255((255 - srcA), dstG, dstG);
  9482. dstG += srcG;
  9483. MULT_DIV_255((255 - srcA), dstB, dstB);
  9484. dstB += srcB;
  9485. break;
  9486. case SDL_COPY_BLEND_PREMULTIPLIED:
  9487. MULT_DIV_255((255 - srcA), dstR, dstR);
  9488. dstR += srcR;
  9489. if (dstR > 255) dstR = 255;
  9490. MULT_DIV_255((255 - srcA), dstG, dstG);
  9491. dstG += srcG;
  9492. if (dstG > 255) dstG = 255;
  9493. MULT_DIV_255((255 - srcA), dstB, dstB);
  9494. dstB += srcB;
  9495. if (dstB > 255) dstB = 255;
  9496. break;
  9497. case SDL_COPY_ADD:
  9498. case SDL_COPY_ADD_PREMULTIPLIED:
  9499. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9500. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9501. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9502. break;
  9503. case SDL_COPY_MOD:
  9504. MULT_DIV_255(srcR, dstR, dstR);
  9505. MULT_DIV_255(srcG, dstG, dstG);
  9506. MULT_DIV_255(srcB, dstB, dstB);
  9507. break;
  9508. case SDL_COPY_MUL:
  9509. {
  9510. Uint32 tmp1, tmp2;
  9511. MULT_DIV_255(srcR, dstR, tmp1);
  9512. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9513. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9514. MULT_DIV_255(srcG, dstG, tmp1);
  9515. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9516. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9517. MULT_DIV_255(srcB, dstB, tmp1);
  9518. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9519. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9520. }
  9521. break;
  9522. }
  9523. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  9524. *dst = dstpixel;
  9525. posx += incx;
  9526. ++dst;
  9527. }
  9528. posy += incy;
  9529. info->dst += info->dst_pitch;
  9530. }
  9531. }
  9532. static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  9533. {
  9534. const int flags = info->flags;
  9535. const Uint32 modulateR = info->r;
  9536. const Uint32 modulateG = info->g;
  9537. const Uint32 modulateB = info->b;
  9538. Uint32 pixel;
  9539. Uint32 R, G, B;
  9540. while (info->dst_h--) {
  9541. Uint32 *src = (Uint32 *)info->src;
  9542. Uint32 *dst = (Uint32 *)info->dst;
  9543. int n = info->dst_w;
  9544. while (n--) {
  9545. pixel = *src;
  9546. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  9547. if (flags & SDL_COPY_MODULATE_COLOR) {
  9548. MULT_DIV_255(R, modulateR, R);
  9549. MULT_DIV_255(G, modulateG, G);
  9550. MULT_DIV_255(B, modulateB, B);
  9551. }
  9552. pixel = (B << 16) | (G << 8) | R;
  9553. *dst = pixel;
  9554. ++src;
  9555. ++dst;
  9556. }
  9557. info->src += info->src_pitch;
  9558. info->dst += info->dst_pitch;
  9559. }
  9560. }
  9561. static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  9562. {
  9563. const int flags = info->flags;
  9564. const Uint32 modulateR = info->r;
  9565. const Uint32 modulateG = info->g;
  9566. const Uint32 modulateB = info->b;
  9567. Uint32 pixel;
  9568. Uint32 R, G, B;
  9569. Uint64 srcy, srcx;
  9570. Uint64 posy, posx;
  9571. Uint64 incy, incx;
  9572. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9573. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9574. posy = incy / 2;
  9575. while (info->dst_h--) {
  9576. Uint32 *src = 0;
  9577. Uint32 *dst = (Uint32 *)info->dst;
  9578. int n = info->dst_w;
  9579. posx = incx / 2;
  9580. srcy = posy >> 16;
  9581. while (n--) {
  9582. srcx = posx >> 16;
  9583. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9584. pixel = *src;
  9585. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  9586. if (flags & SDL_COPY_MODULATE_COLOR) {
  9587. MULT_DIV_255(R, modulateR, R);
  9588. MULT_DIV_255(G, modulateG, G);
  9589. MULT_DIV_255(B, modulateB, B);
  9590. }
  9591. pixel = (B << 16) | (G << 8) | R;
  9592. *dst = pixel;
  9593. posx += incx;
  9594. ++dst;
  9595. }
  9596. posy += incy;
  9597. info->dst += info->dst_pitch;
  9598. }
  9599. }
  9600. static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  9601. {
  9602. const int flags = info->flags;
  9603. const Uint32 modulateR = info->r;
  9604. const Uint32 modulateG = info->g;
  9605. const Uint32 modulateB = info->b;
  9606. const Uint32 modulateA = info->a;
  9607. Uint32 srcpixel;
  9608. Uint32 srcR, srcG, srcB, srcA;
  9609. Uint32 dstpixel;
  9610. Uint32 dstR, dstG, dstB;
  9611. while (info->dst_h--) {
  9612. Uint32 *src = (Uint32 *)info->src;
  9613. Uint32 *dst = (Uint32 *)info->dst;
  9614. int n = info->dst_w;
  9615. while (n--) {
  9616. srcpixel = *src;
  9617. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9618. dstpixel = *dst;
  9619. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  9620. if (flags & SDL_COPY_MODULATE_COLOR) {
  9621. MULT_DIV_255(srcR, modulateR, srcR);
  9622. MULT_DIV_255(srcG, modulateG, srcG);
  9623. MULT_DIV_255(srcB, modulateB, srcB);
  9624. }
  9625. if (flags & SDL_COPY_MODULATE_ALPHA) {
  9626. MULT_DIV_255(srcA, modulateA, srcA);
  9627. }
  9628. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9629. if (srcA < 255) {
  9630. MULT_DIV_255(srcR, srcA, srcR);
  9631. MULT_DIV_255(srcG, srcA, srcG);
  9632. MULT_DIV_255(srcB, srcA, srcB);
  9633. }
  9634. }
  9635. switch (flags & SDL_COPY_BLEND_MASK) {
  9636. case SDL_COPY_BLEND:
  9637. MULT_DIV_255((255 - srcA), dstR, dstR);
  9638. dstR += srcR;
  9639. MULT_DIV_255((255 - srcA), dstG, dstG);
  9640. dstG += srcG;
  9641. MULT_DIV_255((255 - srcA), dstB, dstB);
  9642. dstB += srcB;
  9643. break;
  9644. case SDL_COPY_BLEND_PREMULTIPLIED:
  9645. MULT_DIV_255((255 - srcA), dstR, dstR);
  9646. dstR += srcR;
  9647. if (dstR > 255) dstR = 255;
  9648. MULT_DIV_255((255 - srcA), dstG, dstG);
  9649. dstG += srcG;
  9650. if (dstG > 255) dstG = 255;
  9651. MULT_DIV_255((255 - srcA), dstB, dstB);
  9652. dstB += srcB;
  9653. if (dstB > 255) dstB = 255;
  9654. break;
  9655. case SDL_COPY_ADD:
  9656. case SDL_COPY_ADD_PREMULTIPLIED:
  9657. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9658. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9659. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9660. break;
  9661. case SDL_COPY_MOD:
  9662. MULT_DIV_255(srcR, dstR, dstR);
  9663. MULT_DIV_255(srcG, dstG, dstG);
  9664. MULT_DIV_255(srcB, dstB, dstB);
  9665. break;
  9666. case SDL_COPY_MUL:
  9667. {
  9668. Uint32 tmp1, tmp2;
  9669. MULT_DIV_255(srcR, dstR, tmp1);
  9670. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9671. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9672. MULT_DIV_255(srcG, dstG, tmp1);
  9673. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9674. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9675. MULT_DIV_255(srcB, dstB, tmp1);
  9676. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9677. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9678. }
  9679. break;
  9680. }
  9681. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  9682. *dst = dstpixel;
  9683. ++src;
  9684. ++dst;
  9685. }
  9686. info->src += info->src_pitch;
  9687. info->dst += info->dst_pitch;
  9688. }
  9689. }
  9690. static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  9691. {
  9692. const int flags = info->flags;
  9693. const Uint32 modulateR = info->r;
  9694. const Uint32 modulateG = info->g;
  9695. const Uint32 modulateB = info->b;
  9696. const Uint32 modulateA = info->a;
  9697. Uint32 srcpixel;
  9698. Uint32 srcR, srcG, srcB, srcA;
  9699. Uint32 dstpixel;
  9700. Uint32 dstR, dstG, dstB;
  9701. Uint64 srcy, srcx;
  9702. Uint64 posy, posx;
  9703. Uint64 incy, incx;
  9704. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9705. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9706. posy = incy / 2;
  9707. while (info->dst_h--) {
  9708. Uint32 *src = 0;
  9709. Uint32 *dst = (Uint32 *)info->dst;
  9710. int n = info->dst_w;
  9711. posx = incx / 2;
  9712. srcy = posy >> 16;
  9713. while (n--) {
  9714. srcx = posx >> 16;
  9715. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9716. srcpixel = *src;
  9717. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9718. dstpixel = *dst;
  9719. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  9720. if (flags & SDL_COPY_MODULATE_COLOR) {
  9721. MULT_DIV_255(srcR, modulateR, srcR);
  9722. MULT_DIV_255(srcG, modulateG, srcG);
  9723. MULT_DIV_255(srcB, modulateB, srcB);
  9724. }
  9725. if (flags & SDL_COPY_MODULATE_ALPHA) {
  9726. MULT_DIV_255(srcA, modulateA, srcA);
  9727. }
  9728. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9729. if (srcA < 255) {
  9730. MULT_DIV_255(srcR, srcA, srcR);
  9731. MULT_DIV_255(srcG, srcA, srcG);
  9732. MULT_DIV_255(srcB, srcA, srcB);
  9733. }
  9734. }
  9735. switch (flags & SDL_COPY_BLEND_MASK) {
  9736. case SDL_COPY_BLEND:
  9737. MULT_DIV_255((255 - srcA), dstR, dstR);
  9738. dstR += srcR;
  9739. MULT_DIV_255((255 - srcA), dstG, dstG);
  9740. dstG += srcG;
  9741. MULT_DIV_255((255 - srcA), dstB, dstB);
  9742. dstB += srcB;
  9743. break;
  9744. case SDL_COPY_BLEND_PREMULTIPLIED:
  9745. MULT_DIV_255((255 - srcA), dstR, dstR);
  9746. dstR += srcR;
  9747. if (dstR > 255) dstR = 255;
  9748. MULT_DIV_255((255 - srcA), dstG, dstG);
  9749. dstG += srcG;
  9750. if (dstG > 255) dstG = 255;
  9751. MULT_DIV_255((255 - srcA), dstB, dstB);
  9752. dstB += srcB;
  9753. if (dstB > 255) dstB = 255;
  9754. break;
  9755. case SDL_COPY_ADD:
  9756. case SDL_COPY_ADD_PREMULTIPLIED:
  9757. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9758. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9759. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9760. break;
  9761. case SDL_COPY_MOD:
  9762. MULT_DIV_255(srcR, dstR, dstR);
  9763. MULT_DIV_255(srcG, dstG, dstG);
  9764. MULT_DIV_255(srcB, dstB, dstB);
  9765. break;
  9766. case SDL_COPY_MUL:
  9767. {
  9768. Uint32 tmp1, tmp2;
  9769. MULT_DIV_255(srcR, dstR, tmp1);
  9770. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9771. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9772. MULT_DIV_255(srcG, dstG, tmp1);
  9773. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9774. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9775. MULT_DIV_255(srcB, dstB, tmp1);
  9776. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9777. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9778. }
  9779. break;
  9780. }
  9781. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  9782. *dst = dstpixel;
  9783. posx += incx;
  9784. ++dst;
  9785. }
  9786. posy += incy;
  9787. info->dst += info->dst_pitch;
  9788. }
  9789. }
  9790. static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  9791. {
  9792. Uint32 pixel;
  9793. Uint32 R, G, B, A;
  9794. Uint64 srcy, srcx;
  9795. Uint64 posy, posx;
  9796. Uint64 incy, incx;
  9797. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9798. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9799. posy = incy / 2;
  9800. while (info->dst_h--) {
  9801. Uint32 *src = 0;
  9802. Uint32 *dst = (Uint32 *)info->dst;
  9803. int n = info->dst_w;
  9804. posx = incx / 2;
  9805. srcy = posy >> 16;
  9806. while (n--) {
  9807. srcx = posx >> 16;
  9808. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9809. pixel = *src;
  9810. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  9811. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  9812. *dst = pixel;
  9813. posx += incx;
  9814. ++dst;
  9815. }
  9816. posy += incy;
  9817. info->dst += info->dst_pitch;
  9818. }
  9819. }
  9820. static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  9821. {
  9822. const int flags = info->flags;
  9823. Uint32 srcpixel;
  9824. Uint32 srcR, srcG, srcB, srcA;
  9825. Uint32 dstpixel;
  9826. Uint32 dstR, dstG, dstB, dstA;
  9827. while (info->dst_h--) {
  9828. Uint32 *src = (Uint32 *)info->src;
  9829. Uint32 *dst = (Uint32 *)info->dst;
  9830. int n = info->dst_w;
  9831. while (n--) {
  9832. srcpixel = *src;
  9833. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9834. dstpixel = *dst;
  9835. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  9836. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9837. if (srcA < 255) {
  9838. MULT_DIV_255(srcR, srcA, srcR);
  9839. MULT_DIV_255(srcG, srcA, srcG);
  9840. MULT_DIV_255(srcB, srcA, srcB);
  9841. }
  9842. }
  9843. switch (flags & SDL_COPY_BLEND_MASK) {
  9844. case SDL_COPY_BLEND:
  9845. MULT_DIV_255((255 - srcA), dstR, dstR);
  9846. dstR += srcR;
  9847. MULT_DIV_255((255 - srcA), dstG, dstG);
  9848. dstG += srcG;
  9849. MULT_DIV_255((255 - srcA), dstB, dstB);
  9850. dstB += srcB;
  9851. MULT_DIV_255((255 - srcA), dstA, dstA);
  9852. dstA += srcA;
  9853. break;
  9854. case SDL_COPY_BLEND_PREMULTIPLIED:
  9855. MULT_DIV_255((255 - srcA), dstR, dstR);
  9856. dstR += srcR;
  9857. if (dstR > 255) dstR = 255;
  9858. MULT_DIV_255((255 - srcA), dstG, dstG);
  9859. dstG += srcG;
  9860. if (dstG > 255) dstG = 255;
  9861. MULT_DIV_255((255 - srcA), dstB, dstB);
  9862. dstB += srcB;
  9863. if (dstB > 255) dstB = 255;
  9864. MULT_DIV_255((255 - srcA), dstA, dstA);
  9865. dstA += srcA;
  9866. if (dstA > 255) dstA = 255;
  9867. break;
  9868. case SDL_COPY_ADD:
  9869. case SDL_COPY_ADD_PREMULTIPLIED:
  9870. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9871. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9872. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9873. break;
  9874. case SDL_COPY_MOD:
  9875. MULT_DIV_255(srcR, dstR, dstR);
  9876. MULT_DIV_255(srcG, dstG, dstG);
  9877. MULT_DIV_255(srcB, dstB, dstB);
  9878. break;
  9879. case SDL_COPY_MUL:
  9880. {
  9881. Uint32 tmp1, tmp2;
  9882. MULT_DIV_255(srcR, dstR, tmp1);
  9883. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9884. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9885. MULT_DIV_255(srcG, dstG, tmp1);
  9886. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9887. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9888. MULT_DIV_255(srcB, dstB, tmp1);
  9889. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9890. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9891. }
  9892. break;
  9893. }
  9894. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  9895. *dst = dstpixel;
  9896. ++src;
  9897. ++dst;
  9898. }
  9899. info->src += info->src_pitch;
  9900. info->dst += info->dst_pitch;
  9901. }
  9902. }
  9903. static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  9904. {
  9905. const int flags = info->flags;
  9906. Uint32 srcpixel;
  9907. Uint32 srcR, srcG, srcB, srcA;
  9908. Uint32 dstpixel;
  9909. Uint32 dstR, dstG, dstB, dstA;
  9910. Uint64 srcy, srcx;
  9911. Uint64 posy, posx;
  9912. Uint64 incy, incx;
  9913. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9914. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9915. posy = incy / 2;
  9916. while (info->dst_h--) {
  9917. Uint32 *src = 0;
  9918. Uint32 *dst = (Uint32 *)info->dst;
  9919. int n = info->dst_w;
  9920. posx = incx / 2;
  9921. srcy = posy >> 16;
  9922. while (n--) {
  9923. srcx = posx >> 16;
  9924. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9925. srcpixel = *src;
  9926. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9927. dstpixel = *dst;
  9928. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  9929. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9930. if (srcA < 255) {
  9931. MULT_DIV_255(srcR, srcA, srcR);
  9932. MULT_DIV_255(srcG, srcA, srcG);
  9933. MULT_DIV_255(srcB, srcA, srcB);
  9934. }
  9935. }
  9936. switch (flags & SDL_COPY_BLEND_MASK) {
  9937. case SDL_COPY_BLEND:
  9938. MULT_DIV_255((255 - srcA), dstR, dstR);
  9939. dstR += srcR;
  9940. MULT_DIV_255((255 - srcA), dstG, dstG);
  9941. dstG += srcG;
  9942. MULT_DIV_255((255 - srcA), dstB, dstB);
  9943. dstB += srcB;
  9944. MULT_DIV_255((255 - srcA), dstA, dstA);
  9945. dstA += srcA;
  9946. break;
  9947. case SDL_COPY_BLEND_PREMULTIPLIED:
  9948. MULT_DIV_255((255 - srcA), dstR, dstR);
  9949. dstR += srcR;
  9950. if (dstR > 255) dstR = 255;
  9951. MULT_DIV_255((255 - srcA), dstG, dstG);
  9952. dstG += srcG;
  9953. if (dstG > 255) dstG = 255;
  9954. MULT_DIV_255((255 - srcA), dstB, dstB);
  9955. dstB += srcB;
  9956. if (dstB > 255) dstB = 255;
  9957. MULT_DIV_255((255 - srcA), dstA, dstA);
  9958. dstA += srcA;
  9959. if (dstA > 255) dstA = 255;
  9960. break;
  9961. case SDL_COPY_ADD:
  9962. case SDL_COPY_ADD_PREMULTIPLIED:
  9963. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9964. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9965. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9966. break;
  9967. case SDL_COPY_MOD:
  9968. MULT_DIV_255(srcR, dstR, dstR);
  9969. MULT_DIV_255(srcG, dstG, dstG);
  9970. MULT_DIV_255(srcB, dstB, dstB);
  9971. break;
  9972. case SDL_COPY_MUL:
  9973. {
  9974. Uint32 tmp1, tmp2;
  9975. MULT_DIV_255(srcR, dstR, tmp1);
  9976. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9977. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9978. MULT_DIV_255(srcG, dstG, tmp1);
  9979. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9980. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9981. MULT_DIV_255(srcB, dstB, tmp1);
  9982. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9983. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9984. }
  9985. break;
  9986. }
  9987. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  9988. *dst = dstpixel;
  9989. posx += incx;
  9990. ++dst;
  9991. }
  9992. posy += incy;
  9993. info->dst += info->dst_pitch;
  9994. }
  9995. }
  9996. static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  9997. {
  9998. const int flags = info->flags;
  9999. const Uint32 modulateR = info->r;
  10000. const Uint32 modulateG = info->g;
  10001. const Uint32 modulateB = info->b;
  10002. const Uint32 modulateA = info->a;
  10003. Uint32 pixel;
  10004. Uint32 R, G, B, A;
  10005. while (info->dst_h--) {
  10006. Uint32 *src = (Uint32 *)info->src;
  10007. Uint32 *dst = (Uint32 *)info->dst;
  10008. int n = info->dst_w;
  10009. while (n--) {
  10010. pixel = *src;
  10011. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  10012. if (flags & SDL_COPY_MODULATE_COLOR) {
  10013. MULT_DIV_255(R, modulateR, R);
  10014. MULT_DIV_255(G, modulateG, G);
  10015. MULT_DIV_255(B, modulateB, B);
  10016. }
  10017. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10018. MULT_DIV_255(A, modulateA, A);
  10019. }
  10020. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  10021. *dst = pixel;
  10022. ++src;
  10023. ++dst;
  10024. }
  10025. info->src += info->src_pitch;
  10026. info->dst += info->dst_pitch;
  10027. }
  10028. }
  10029. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  10030. {
  10031. const int flags = info->flags;
  10032. const Uint32 modulateR = info->r;
  10033. const Uint32 modulateG = info->g;
  10034. const Uint32 modulateB = info->b;
  10035. const Uint32 modulateA = info->a;
  10036. Uint32 pixel;
  10037. Uint32 R, G, B, A;
  10038. Uint64 srcy, srcx;
  10039. Uint64 posy, posx;
  10040. Uint64 incy, incx;
  10041. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10042. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10043. posy = incy / 2;
  10044. while (info->dst_h--) {
  10045. Uint32 *src = 0;
  10046. Uint32 *dst = (Uint32 *)info->dst;
  10047. int n = info->dst_w;
  10048. posx = incx / 2;
  10049. srcy = posy >> 16;
  10050. while (n--) {
  10051. srcx = posx >> 16;
  10052. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10053. pixel = *src;
  10054. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  10055. if (flags & SDL_COPY_MODULATE_COLOR) {
  10056. MULT_DIV_255(R, modulateR, R);
  10057. MULT_DIV_255(G, modulateG, G);
  10058. MULT_DIV_255(B, modulateB, B);
  10059. }
  10060. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10061. MULT_DIV_255(A, modulateA, A);
  10062. }
  10063. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  10064. *dst = pixel;
  10065. posx += incx;
  10066. ++dst;
  10067. }
  10068. posy += incy;
  10069. info->dst += info->dst_pitch;
  10070. }
  10071. }
  10072. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  10073. {
  10074. const int flags = info->flags;
  10075. const Uint32 modulateR = info->r;
  10076. const Uint32 modulateG = info->g;
  10077. const Uint32 modulateB = info->b;
  10078. const Uint32 modulateA = info->a;
  10079. Uint32 srcpixel;
  10080. Uint32 srcR, srcG, srcB, srcA;
  10081. Uint32 dstpixel;
  10082. Uint32 dstR, dstG, dstB, dstA;
  10083. while (info->dst_h--) {
  10084. Uint32 *src = (Uint32 *)info->src;
  10085. Uint32 *dst = (Uint32 *)info->dst;
  10086. int n = info->dst_w;
  10087. while (n--) {
  10088. srcpixel = *src;
  10089. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10090. dstpixel = *dst;
  10091. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10092. if (flags & SDL_COPY_MODULATE_COLOR) {
  10093. MULT_DIV_255(srcR, modulateR, srcR);
  10094. MULT_DIV_255(srcG, modulateG, srcG);
  10095. MULT_DIV_255(srcB, modulateB, srcB);
  10096. }
  10097. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10098. MULT_DIV_255(srcA, modulateA, srcA);
  10099. }
  10100. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10101. if (srcA < 255) {
  10102. MULT_DIV_255(srcR, srcA, srcR);
  10103. MULT_DIV_255(srcG, srcA, srcG);
  10104. MULT_DIV_255(srcB, srcA, srcB);
  10105. }
  10106. }
  10107. switch (flags & SDL_COPY_BLEND_MASK) {
  10108. case SDL_COPY_BLEND:
  10109. MULT_DIV_255((255 - srcA), dstR, dstR);
  10110. dstR += srcR;
  10111. MULT_DIV_255((255 - srcA), dstG, dstG);
  10112. dstG += srcG;
  10113. MULT_DIV_255((255 - srcA), dstB, dstB);
  10114. dstB += srcB;
  10115. MULT_DIV_255((255 - srcA), dstA, dstA);
  10116. dstA += srcA;
  10117. break;
  10118. case SDL_COPY_BLEND_PREMULTIPLIED:
  10119. MULT_DIV_255((255 - srcA), dstR, dstR);
  10120. dstR += srcR;
  10121. if (dstR > 255) dstR = 255;
  10122. MULT_DIV_255((255 - srcA), dstG, dstG);
  10123. dstG += srcG;
  10124. if (dstG > 255) dstG = 255;
  10125. MULT_DIV_255((255 - srcA), dstB, dstB);
  10126. dstB += srcB;
  10127. if (dstB > 255) dstB = 255;
  10128. MULT_DIV_255((255 - srcA), dstA, dstA);
  10129. dstA += srcA;
  10130. if (dstA > 255) dstA = 255;
  10131. break;
  10132. case SDL_COPY_ADD:
  10133. case SDL_COPY_ADD_PREMULTIPLIED:
  10134. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10135. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10136. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10137. break;
  10138. case SDL_COPY_MOD:
  10139. MULT_DIV_255(srcR, dstR, dstR);
  10140. MULT_DIV_255(srcG, dstG, dstG);
  10141. MULT_DIV_255(srcB, dstB, dstB);
  10142. break;
  10143. case SDL_COPY_MUL:
  10144. {
  10145. Uint32 tmp1, tmp2;
  10146. MULT_DIV_255(srcR, dstR, tmp1);
  10147. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10148. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10149. MULT_DIV_255(srcG, dstG, tmp1);
  10150. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10151. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10152. MULT_DIV_255(srcB, dstB, tmp1);
  10153. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10154. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10155. }
  10156. break;
  10157. }
  10158. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  10159. *dst = dstpixel;
  10160. ++src;
  10161. ++dst;
  10162. }
  10163. info->src += info->src_pitch;
  10164. info->dst += info->dst_pitch;
  10165. }
  10166. }
  10167. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  10168. {
  10169. const int flags = info->flags;
  10170. const Uint32 modulateR = info->r;
  10171. const Uint32 modulateG = info->g;
  10172. const Uint32 modulateB = info->b;
  10173. const Uint32 modulateA = info->a;
  10174. Uint32 srcpixel;
  10175. Uint32 srcR, srcG, srcB, srcA;
  10176. Uint32 dstpixel;
  10177. Uint32 dstR, dstG, dstB, dstA;
  10178. Uint64 srcy, srcx;
  10179. Uint64 posy, posx;
  10180. Uint64 incy, incx;
  10181. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10182. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10183. posy = incy / 2;
  10184. while (info->dst_h--) {
  10185. Uint32 *src = 0;
  10186. Uint32 *dst = (Uint32 *)info->dst;
  10187. int n = info->dst_w;
  10188. posx = incx / 2;
  10189. srcy = posy >> 16;
  10190. while (n--) {
  10191. srcx = posx >> 16;
  10192. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10193. srcpixel = *src;
  10194. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10195. dstpixel = *dst;
  10196. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10197. if (flags & SDL_COPY_MODULATE_COLOR) {
  10198. MULT_DIV_255(srcR, modulateR, srcR);
  10199. MULT_DIV_255(srcG, modulateG, srcG);
  10200. MULT_DIV_255(srcB, modulateB, srcB);
  10201. }
  10202. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10203. MULT_DIV_255(srcA, modulateA, srcA);
  10204. }
  10205. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10206. if (srcA < 255) {
  10207. MULT_DIV_255(srcR, srcA, srcR);
  10208. MULT_DIV_255(srcG, srcA, srcG);
  10209. MULT_DIV_255(srcB, srcA, srcB);
  10210. }
  10211. }
  10212. switch (flags & SDL_COPY_BLEND_MASK) {
  10213. case SDL_COPY_BLEND:
  10214. MULT_DIV_255((255 - srcA), dstR, dstR);
  10215. dstR += srcR;
  10216. MULT_DIV_255((255 - srcA), dstG, dstG);
  10217. dstG += srcG;
  10218. MULT_DIV_255((255 - srcA), dstB, dstB);
  10219. dstB += srcB;
  10220. MULT_DIV_255((255 - srcA), dstA, dstA);
  10221. dstA += srcA;
  10222. break;
  10223. case SDL_COPY_BLEND_PREMULTIPLIED:
  10224. MULT_DIV_255((255 - srcA), dstR, dstR);
  10225. dstR += srcR;
  10226. if (dstR > 255) dstR = 255;
  10227. MULT_DIV_255((255 - srcA), dstG, dstG);
  10228. dstG += srcG;
  10229. if (dstG > 255) dstG = 255;
  10230. MULT_DIV_255((255 - srcA), dstB, dstB);
  10231. dstB += srcB;
  10232. if (dstB > 255) dstB = 255;
  10233. MULT_DIV_255((255 - srcA), dstA, dstA);
  10234. dstA += srcA;
  10235. if (dstA > 255) dstA = 255;
  10236. break;
  10237. case SDL_COPY_ADD:
  10238. case SDL_COPY_ADD_PREMULTIPLIED:
  10239. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10240. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10241. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10242. break;
  10243. case SDL_COPY_MOD:
  10244. MULT_DIV_255(srcR, dstR, dstR);
  10245. MULT_DIV_255(srcG, dstG, dstG);
  10246. MULT_DIV_255(srcB, dstB, dstB);
  10247. break;
  10248. case SDL_COPY_MUL:
  10249. {
  10250. Uint32 tmp1, tmp2;
  10251. MULT_DIV_255(srcR, dstR, tmp1);
  10252. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10253. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10254. MULT_DIV_255(srcG, dstG, tmp1);
  10255. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10256. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10257. MULT_DIV_255(srcB, dstB, tmp1);
  10258. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10259. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10260. }
  10261. break;
  10262. }
  10263. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  10264. *dst = dstpixel;
  10265. posx += incx;
  10266. ++dst;
  10267. }
  10268. posy += incy;
  10269. info->dst += info->dst_pitch;
  10270. }
  10271. }
  10272. static void SDL_Blit_BGRA8888_ABGR8888_Scale(SDL_BlitInfo *info)
  10273. {
  10274. Uint32 pixel;
  10275. Uint64 srcy, srcx;
  10276. Uint64 posy, posx;
  10277. Uint64 incy, incx;
  10278. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10279. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10280. posy = incy / 2;
  10281. while (info->dst_h--) {
  10282. Uint32 *src = 0;
  10283. Uint32 *dst = (Uint32 *)info->dst;
  10284. int n = info->dst_w;
  10285. posx = incx / 2;
  10286. srcy = posy >> 16;
  10287. while (n--) {
  10288. srcx = posx >> 16;
  10289. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10290. pixel = *src;
  10291. pixel = (pixel >> 8) | (pixel << 24);
  10292. *dst = pixel;
  10293. posx += incx;
  10294. ++dst;
  10295. }
  10296. posy += incy;
  10297. info->dst += info->dst_pitch;
  10298. }
  10299. }
  10300. static void SDL_Blit_BGRA8888_ABGR8888_Blend(SDL_BlitInfo *info)
  10301. {
  10302. const int flags = info->flags;
  10303. Uint32 srcpixel;
  10304. Uint32 srcR, srcG, srcB, srcA;
  10305. Uint32 dstpixel;
  10306. Uint32 dstR, dstG, dstB, dstA;
  10307. while (info->dst_h--) {
  10308. Uint32 *src = (Uint32 *)info->src;
  10309. Uint32 *dst = (Uint32 *)info->dst;
  10310. int n = info->dst_w;
  10311. while (n--) {
  10312. srcpixel = *src;
  10313. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10314. dstpixel = *dst;
  10315. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10316. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10317. if (srcA < 255) {
  10318. MULT_DIV_255(srcR, srcA, srcR);
  10319. MULT_DIV_255(srcG, srcA, srcG);
  10320. MULT_DIV_255(srcB, srcA, srcB);
  10321. }
  10322. }
  10323. switch (flags & SDL_COPY_BLEND_MASK) {
  10324. case SDL_COPY_BLEND:
  10325. MULT_DIV_255((255 - srcA), dstR, dstR);
  10326. dstR += srcR;
  10327. MULT_DIV_255((255 - srcA), dstG, dstG);
  10328. dstG += srcG;
  10329. MULT_DIV_255((255 - srcA), dstB, dstB);
  10330. dstB += srcB;
  10331. MULT_DIV_255((255 - srcA), dstA, dstA);
  10332. dstA += srcA;
  10333. break;
  10334. case SDL_COPY_BLEND_PREMULTIPLIED:
  10335. MULT_DIV_255((255 - srcA), dstR, dstR);
  10336. dstR += srcR;
  10337. if (dstR > 255) dstR = 255;
  10338. MULT_DIV_255((255 - srcA), dstG, dstG);
  10339. dstG += srcG;
  10340. if (dstG > 255) dstG = 255;
  10341. MULT_DIV_255((255 - srcA), dstB, dstB);
  10342. dstB += srcB;
  10343. if (dstB > 255) dstB = 255;
  10344. MULT_DIV_255((255 - srcA), dstA, dstA);
  10345. dstA += srcA;
  10346. if (dstA > 255) dstA = 255;
  10347. break;
  10348. case SDL_COPY_ADD:
  10349. case SDL_COPY_ADD_PREMULTIPLIED:
  10350. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10351. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10352. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10353. break;
  10354. case SDL_COPY_MOD:
  10355. MULT_DIV_255(srcR, dstR, dstR);
  10356. MULT_DIV_255(srcG, dstG, dstG);
  10357. MULT_DIV_255(srcB, dstB, dstB);
  10358. break;
  10359. case SDL_COPY_MUL:
  10360. {
  10361. Uint32 tmp1, tmp2;
  10362. MULT_DIV_255(srcR, dstR, tmp1);
  10363. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10364. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10365. MULT_DIV_255(srcG, dstG, tmp1);
  10366. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10367. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10368. MULT_DIV_255(srcB, dstB, tmp1);
  10369. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10370. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10371. }
  10372. break;
  10373. }
  10374. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  10375. *dst = dstpixel;
  10376. ++src;
  10377. ++dst;
  10378. }
  10379. info->src += info->src_pitch;
  10380. info->dst += info->dst_pitch;
  10381. }
  10382. }
  10383. static void SDL_Blit_BGRA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  10384. {
  10385. const int flags = info->flags;
  10386. Uint32 srcpixel;
  10387. Uint32 srcR, srcG, srcB, srcA;
  10388. Uint32 dstpixel;
  10389. Uint32 dstR, dstG, dstB, dstA;
  10390. Uint64 srcy, srcx;
  10391. Uint64 posy, posx;
  10392. Uint64 incy, incx;
  10393. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10394. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10395. posy = incy / 2;
  10396. while (info->dst_h--) {
  10397. Uint32 *src = 0;
  10398. Uint32 *dst = (Uint32 *)info->dst;
  10399. int n = info->dst_w;
  10400. posx = incx / 2;
  10401. srcy = posy >> 16;
  10402. while (n--) {
  10403. srcx = posx >> 16;
  10404. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10405. srcpixel = *src;
  10406. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10407. dstpixel = *dst;
  10408. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10409. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10410. if (srcA < 255) {
  10411. MULT_DIV_255(srcR, srcA, srcR);
  10412. MULT_DIV_255(srcG, srcA, srcG);
  10413. MULT_DIV_255(srcB, srcA, srcB);
  10414. }
  10415. }
  10416. switch (flags & SDL_COPY_BLEND_MASK) {
  10417. case SDL_COPY_BLEND:
  10418. MULT_DIV_255((255 - srcA), dstR, dstR);
  10419. dstR += srcR;
  10420. MULT_DIV_255((255 - srcA), dstG, dstG);
  10421. dstG += srcG;
  10422. MULT_DIV_255((255 - srcA), dstB, dstB);
  10423. dstB += srcB;
  10424. MULT_DIV_255((255 - srcA), dstA, dstA);
  10425. dstA += srcA;
  10426. break;
  10427. case SDL_COPY_BLEND_PREMULTIPLIED:
  10428. MULT_DIV_255((255 - srcA), dstR, dstR);
  10429. dstR += srcR;
  10430. if (dstR > 255) dstR = 255;
  10431. MULT_DIV_255((255 - srcA), dstG, dstG);
  10432. dstG += srcG;
  10433. if (dstG > 255) dstG = 255;
  10434. MULT_DIV_255((255 - srcA), dstB, dstB);
  10435. dstB += srcB;
  10436. if (dstB > 255) dstB = 255;
  10437. MULT_DIV_255((255 - srcA), dstA, dstA);
  10438. dstA += srcA;
  10439. if (dstA > 255) dstA = 255;
  10440. break;
  10441. case SDL_COPY_ADD:
  10442. case SDL_COPY_ADD_PREMULTIPLIED:
  10443. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10444. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10445. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10446. break;
  10447. case SDL_COPY_MOD:
  10448. MULT_DIV_255(srcR, dstR, dstR);
  10449. MULT_DIV_255(srcG, dstG, dstG);
  10450. MULT_DIV_255(srcB, dstB, dstB);
  10451. break;
  10452. case SDL_COPY_MUL:
  10453. {
  10454. Uint32 tmp1, tmp2;
  10455. MULT_DIV_255(srcR, dstR, tmp1);
  10456. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10457. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10458. MULT_DIV_255(srcG, dstG, tmp1);
  10459. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10460. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10461. MULT_DIV_255(srcB, dstB, tmp1);
  10462. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10463. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10464. }
  10465. break;
  10466. }
  10467. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  10468. *dst = dstpixel;
  10469. posx += incx;
  10470. ++dst;
  10471. }
  10472. posy += incy;
  10473. info->dst += info->dst_pitch;
  10474. }
  10475. }
  10476. static void SDL_Blit_BGRA8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  10477. {
  10478. const int flags = info->flags;
  10479. const Uint32 modulateR = info->r;
  10480. const Uint32 modulateG = info->g;
  10481. const Uint32 modulateB = info->b;
  10482. const Uint32 modulateA = info->a;
  10483. Uint32 pixel;
  10484. Uint32 R, G, B, A;
  10485. while (info->dst_h--) {
  10486. Uint32 *src = (Uint32 *)info->src;
  10487. Uint32 *dst = (Uint32 *)info->dst;
  10488. int n = info->dst_w;
  10489. while (n--) {
  10490. pixel = *src;
  10491. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  10492. if (flags & SDL_COPY_MODULATE_COLOR) {
  10493. MULT_DIV_255(R, modulateR, R);
  10494. MULT_DIV_255(G, modulateG, G);
  10495. MULT_DIV_255(B, modulateB, B);
  10496. }
  10497. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10498. MULT_DIV_255(A, modulateA, A);
  10499. }
  10500. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  10501. *dst = pixel;
  10502. ++src;
  10503. ++dst;
  10504. }
  10505. info->src += info->src_pitch;
  10506. info->dst += info->dst_pitch;
  10507. }
  10508. }
  10509. static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  10510. {
  10511. const int flags = info->flags;
  10512. const Uint32 modulateR = info->r;
  10513. const Uint32 modulateG = info->g;
  10514. const Uint32 modulateB = info->b;
  10515. const Uint32 modulateA = info->a;
  10516. Uint32 pixel;
  10517. Uint32 R, G, B, A;
  10518. Uint64 srcy, srcx;
  10519. Uint64 posy, posx;
  10520. Uint64 incy, incx;
  10521. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10522. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10523. posy = incy / 2;
  10524. while (info->dst_h--) {
  10525. Uint32 *src = 0;
  10526. Uint32 *dst = (Uint32 *)info->dst;
  10527. int n = info->dst_w;
  10528. posx = incx / 2;
  10529. srcy = posy >> 16;
  10530. while (n--) {
  10531. srcx = posx >> 16;
  10532. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10533. pixel = *src;
  10534. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  10535. if (flags & SDL_COPY_MODULATE_COLOR) {
  10536. MULT_DIV_255(R, modulateR, R);
  10537. MULT_DIV_255(G, modulateG, G);
  10538. MULT_DIV_255(B, modulateB, B);
  10539. }
  10540. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10541. MULT_DIV_255(A, modulateA, A);
  10542. }
  10543. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  10544. *dst = pixel;
  10545. posx += incx;
  10546. ++dst;
  10547. }
  10548. posy += incy;
  10549. info->dst += info->dst_pitch;
  10550. }
  10551. }
  10552. static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  10553. {
  10554. const int flags = info->flags;
  10555. const Uint32 modulateR = info->r;
  10556. const Uint32 modulateG = info->g;
  10557. const Uint32 modulateB = info->b;
  10558. const Uint32 modulateA = info->a;
  10559. Uint32 srcpixel;
  10560. Uint32 srcR, srcG, srcB, srcA;
  10561. Uint32 dstpixel;
  10562. Uint32 dstR, dstG, dstB, dstA;
  10563. while (info->dst_h--) {
  10564. Uint32 *src = (Uint32 *)info->src;
  10565. Uint32 *dst = (Uint32 *)info->dst;
  10566. int n = info->dst_w;
  10567. while (n--) {
  10568. srcpixel = *src;
  10569. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10570. dstpixel = *dst;
  10571. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10572. if (flags & SDL_COPY_MODULATE_COLOR) {
  10573. MULT_DIV_255(srcR, modulateR, srcR);
  10574. MULT_DIV_255(srcG, modulateG, srcG);
  10575. MULT_DIV_255(srcB, modulateB, srcB);
  10576. }
  10577. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10578. MULT_DIV_255(srcA, modulateA, srcA);
  10579. }
  10580. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10581. if (srcA < 255) {
  10582. MULT_DIV_255(srcR, srcA, srcR);
  10583. MULT_DIV_255(srcG, srcA, srcG);
  10584. MULT_DIV_255(srcB, srcA, srcB);
  10585. }
  10586. }
  10587. switch (flags & SDL_COPY_BLEND_MASK) {
  10588. case SDL_COPY_BLEND:
  10589. MULT_DIV_255((255 - srcA), dstR, dstR);
  10590. dstR += srcR;
  10591. MULT_DIV_255((255 - srcA), dstG, dstG);
  10592. dstG += srcG;
  10593. MULT_DIV_255((255 - srcA), dstB, dstB);
  10594. dstB += srcB;
  10595. MULT_DIV_255((255 - srcA), dstA, dstA);
  10596. dstA += srcA;
  10597. break;
  10598. case SDL_COPY_BLEND_PREMULTIPLIED:
  10599. MULT_DIV_255((255 - srcA), dstR, dstR);
  10600. dstR += srcR;
  10601. if (dstR > 255) dstR = 255;
  10602. MULT_DIV_255((255 - srcA), dstG, dstG);
  10603. dstG += srcG;
  10604. if (dstG > 255) dstG = 255;
  10605. MULT_DIV_255((255 - srcA), dstB, dstB);
  10606. dstB += srcB;
  10607. if (dstB > 255) dstB = 255;
  10608. MULT_DIV_255((255 - srcA), dstA, dstA);
  10609. dstA += srcA;
  10610. if (dstA > 255) dstA = 255;
  10611. break;
  10612. case SDL_COPY_ADD:
  10613. case SDL_COPY_ADD_PREMULTIPLIED:
  10614. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10615. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10616. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10617. break;
  10618. case SDL_COPY_MOD:
  10619. MULT_DIV_255(srcR, dstR, dstR);
  10620. MULT_DIV_255(srcG, dstG, dstG);
  10621. MULT_DIV_255(srcB, dstB, dstB);
  10622. break;
  10623. case SDL_COPY_MUL:
  10624. {
  10625. Uint32 tmp1, tmp2;
  10626. MULT_DIV_255(srcR, dstR, tmp1);
  10627. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10628. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10629. MULT_DIV_255(srcG, dstG, tmp1);
  10630. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10631. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10632. MULT_DIV_255(srcB, dstB, tmp1);
  10633. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10634. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10635. }
  10636. break;
  10637. }
  10638. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  10639. *dst = dstpixel;
  10640. ++src;
  10641. ++dst;
  10642. }
  10643. info->src += info->src_pitch;
  10644. info->dst += info->dst_pitch;
  10645. }
  10646. }
  10647. static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  10648. {
  10649. const int flags = info->flags;
  10650. const Uint32 modulateR = info->r;
  10651. const Uint32 modulateG = info->g;
  10652. const Uint32 modulateB = info->b;
  10653. const Uint32 modulateA = info->a;
  10654. Uint32 srcpixel;
  10655. Uint32 srcR, srcG, srcB, srcA;
  10656. Uint32 dstpixel;
  10657. Uint32 dstR, dstG, dstB, dstA;
  10658. Uint64 srcy, srcx;
  10659. Uint64 posy, posx;
  10660. Uint64 incy, incx;
  10661. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10662. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10663. posy = incy / 2;
  10664. while (info->dst_h--) {
  10665. Uint32 *src = 0;
  10666. Uint32 *dst = (Uint32 *)info->dst;
  10667. int n = info->dst_w;
  10668. posx = incx / 2;
  10669. srcy = posy >> 16;
  10670. while (n--) {
  10671. srcx = posx >> 16;
  10672. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10673. srcpixel = *src;
  10674. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10675. dstpixel = *dst;
  10676. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10677. if (flags & SDL_COPY_MODULATE_COLOR) {
  10678. MULT_DIV_255(srcR, modulateR, srcR);
  10679. MULT_DIV_255(srcG, modulateG, srcG);
  10680. MULT_DIV_255(srcB, modulateB, srcB);
  10681. }
  10682. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10683. MULT_DIV_255(srcA, modulateA, srcA);
  10684. }
  10685. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10686. if (srcA < 255) {
  10687. MULT_DIV_255(srcR, srcA, srcR);
  10688. MULT_DIV_255(srcG, srcA, srcG);
  10689. MULT_DIV_255(srcB, srcA, srcB);
  10690. }
  10691. }
  10692. switch (flags & SDL_COPY_BLEND_MASK) {
  10693. case SDL_COPY_BLEND:
  10694. MULT_DIV_255((255 - srcA), dstR, dstR);
  10695. dstR += srcR;
  10696. MULT_DIV_255((255 - srcA), dstG, dstG);
  10697. dstG += srcG;
  10698. MULT_DIV_255((255 - srcA), dstB, dstB);
  10699. dstB += srcB;
  10700. MULT_DIV_255((255 - srcA), dstA, dstA);
  10701. dstA += srcA;
  10702. break;
  10703. case SDL_COPY_BLEND_PREMULTIPLIED:
  10704. MULT_DIV_255((255 - srcA), dstR, dstR);
  10705. dstR += srcR;
  10706. if (dstR > 255) dstR = 255;
  10707. MULT_DIV_255((255 - srcA), dstG, dstG);
  10708. dstG += srcG;
  10709. if (dstG > 255) dstG = 255;
  10710. MULT_DIV_255((255 - srcA), dstB, dstB);
  10711. dstB += srcB;
  10712. if (dstB > 255) dstB = 255;
  10713. MULT_DIV_255((255 - srcA), dstA, dstA);
  10714. dstA += srcA;
  10715. if (dstA > 255) dstA = 255;
  10716. break;
  10717. case SDL_COPY_ADD:
  10718. case SDL_COPY_ADD_PREMULTIPLIED:
  10719. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10720. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10721. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10722. break;
  10723. case SDL_COPY_MOD:
  10724. MULT_DIV_255(srcR, dstR, dstR);
  10725. MULT_DIV_255(srcG, dstG, dstG);
  10726. MULT_DIV_255(srcB, dstB, dstB);
  10727. break;
  10728. case SDL_COPY_MUL:
  10729. {
  10730. Uint32 tmp1, tmp2;
  10731. MULT_DIV_255(srcR, dstR, tmp1);
  10732. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10733. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10734. MULT_DIV_255(srcG, dstG, tmp1);
  10735. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10736. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10737. MULT_DIV_255(srcB, dstB, tmp1);
  10738. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10739. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10740. }
  10741. break;
  10742. }
  10743. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  10744. *dst = dstpixel;
  10745. posx += incx;
  10746. ++dst;
  10747. }
  10748. posy += incy;
  10749. info->dst += info->dst_pitch;
  10750. }
  10751. }
  10752. SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
  10753. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Scale },
  10754. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend },
  10755. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend_Scale },
  10756. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate },
  10757. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale },
  10758. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend },
  10759. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale },
  10760. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Scale },
  10761. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend },
  10762. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend_Scale },
  10763. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate },
  10764. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale },
  10765. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend },
  10766. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale },
  10767. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Scale },
  10768. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend },
  10769. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend_Scale },
  10770. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate },
  10771. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale },
  10772. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend },
  10773. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale },
  10774. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Scale },
  10775. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend },
  10776. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend_Scale },
  10777. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate },
  10778. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale },
  10779. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend },
  10780. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale },
  10781. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Scale },
  10782. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend },
  10783. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend_Scale },
  10784. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate },
  10785. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale },
  10786. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend },
  10787. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale },
  10788. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Scale },
  10789. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend },
  10790. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend_Scale },
  10791. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate },
  10792. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale },
  10793. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend },
  10794. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale },
  10795. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Scale },
  10796. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend },
  10797. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend_Scale },
  10798. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate },
  10799. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale },
  10800. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend },
  10801. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale },
  10802. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Scale },
  10803. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend },
  10804. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend_Scale },
  10805. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate },
  10806. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale },
  10807. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend },
  10808. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale },
  10809. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Scale },
  10810. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend },
  10811. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend_Scale },
  10812. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate },
  10813. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale },
  10814. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend },
  10815. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale },
  10816. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Scale },
  10817. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend },
  10818. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend_Scale },
  10819. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate },
  10820. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale },
  10821. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend },
  10822. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale },
  10823. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale },
  10824. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
  10825. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
  10826. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate },
  10827. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale },
  10828. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
  10829. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
  10830. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Scale },
  10831. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend },
  10832. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend_Scale },
  10833. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate },
  10834. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale },
  10835. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend },
  10836. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale },
  10837. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Scale },
  10838. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend },
  10839. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend_Scale },
  10840. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate },
  10841. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale },
  10842. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend },
  10843. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale },
  10844. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Scale },
  10845. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend },
  10846. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend_Scale },
  10847. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate },
  10848. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale },
  10849. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend },
  10850. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale },
  10851. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale },
  10852. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
  10853. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
  10854. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate },
  10855. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale },
  10856. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
  10857. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
  10858. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Scale },
  10859. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend },
  10860. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend_Scale },
  10861. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate },
  10862. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale },
  10863. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend },
  10864. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale },
  10865. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Scale },
  10866. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend },
  10867. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend_Scale },
  10868. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate },
  10869. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale },
  10870. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend },
  10871. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale },
  10872. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Scale },
  10873. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend },
  10874. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend_Scale },
  10875. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate },
  10876. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale },
  10877. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend },
  10878. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale },
  10879. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale },
  10880. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
  10881. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
  10882. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate },
  10883. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale },
  10884. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
  10885. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
  10886. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Scale },
  10887. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend },
  10888. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend_Scale },
  10889. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate },
  10890. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale },
  10891. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend },
  10892. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale },
  10893. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Scale },
  10894. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend },
  10895. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend_Scale },
  10896. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate },
  10897. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale },
  10898. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend },
  10899. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale },
  10900. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Scale },
  10901. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend },
  10902. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend_Scale },
  10903. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate },
  10904. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale },
  10905. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend },
  10906. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale },
  10907. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale },
  10908. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
  10909. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
  10910. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate },
  10911. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale },
  10912. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
  10913. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
  10914. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Scale },
  10915. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend },
  10916. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend_Scale },
  10917. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate },
  10918. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale },
  10919. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend },
  10920. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale },
  10921. { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_UNKNOWN, 0, 0, NULL }
  10922. };
  10923. /* *INDENT-ON* */ // clang-format on
  10924. #endif // SDL_HAVE_BLIT_AUTO