SDL_blit_auto.c 429 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543
  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. #include "SDL_blit.h"
  21. #if SDL_HAVE_BLIT_AUTO
  22. /* *INDENT-OFF* */ // clang-format off
  23. #include "SDL_blit.h"
  24. #include "SDL_blit_auto.h"
  25. static void SDL_Blit_XRGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
  26. {
  27. Uint64 srcy, srcx;
  28. Uint64 posy, posx;
  29. Uint64 incy, incx;
  30. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  31. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  32. posy = incy / 2;
  33. while (info->dst_h--) {
  34. Uint32 *src = 0;
  35. Uint32 *dst = (Uint32 *)info->dst;
  36. int n = info->dst_w;
  37. posx = incx / 2;
  38. srcy = posy >> 16;
  39. while (n--) {
  40. srcx = posx >> 16;
  41. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  42. *dst = *src;
  43. posx += incx;
  44. ++dst;
  45. }
  46. posy += incy;
  47. info->dst += info->dst_pitch;
  48. }
  49. }
  50. static void SDL_Blit_XRGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
  51. {
  52. const int flags = info->flags;
  53. Uint32 srcpixel;
  54. Uint32 srcR, srcG, srcB;
  55. Uint32 dstpixel;
  56. Uint32 dstR, dstG, dstB;
  57. while (info->dst_h--) {
  58. Uint32 *src = (Uint32 *)info->src;
  59. Uint32 *dst = (Uint32 *)info->dst;
  60. int n = info->dst_w;
  61. while (n--) {
  62. srcpixel = *src;
  63. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  64. dstpixel = *dst;
  65. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  66. switch (flags & SDL_COPY_BLEND_MASK) {
  67. case SDL_COPY_BLEND:
  68. dstR = srcR;
  69. dstG = srcG;
  70. dstB = srcB;
  71. break;
  72. case SDL_COPY_BLEND_PREMULTIPLIED:
  73. dstR = srcR;
  74. dstG = srcG;
  75. dstB = srcB;
  76. break;
  77. case SDL_COPY_ADD:
  78. case SDL_COPY_ADD_PREMULTIPLIED:
  79. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  80. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  81. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  82. break;
  83. case SDL_COPY_MOD:
  84. MULT_DIV_255(srcR, dstR, dstR);
  85. MULT_DIV_255(srcG, dstG, dstG);
  86. MULT_DIV_255(srcB, dstB, dstB);
  87. break;
  88. case SDL_COPY_MUL:
  89. MULT_DIV_255(srcR, dstR, dstR);
  90. MULT_DIV_255(srcG, dstG, dstG);
  91. MULT_DIV_255(srcB, dstB, dstB);
  92. break;
  93. }
  94. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  95. *dst = dstpixel;
  96. ++src;
  97. ++dst;
  98. }
  99. info->src += info->src_pitch;
  100. info->dst += info->dst_pitch;
  101. }
  102. }
  103. static void SDL_Blit_XRGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  104. {
  105. const int flags = info->flags;
  106. Uint32 srcpixel;
  107. Uint32 srcR, srcG, srcB;
  108. Uint32 dstpixel;
  109. Uint32 dstR, dstG, dstB;
  110. Uint64 srcy, srcx;
  111. Uint64 posy, posx;
  112. Uint64 incy, incx;
  113. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  114. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  115. posy = incy / 2;
  116. while (info->dst_h--) {
  117. Uint32 *src = 0;
  118. Uint32 *dst = (Uint32 *)info->dst;
  119. int n = info->dst_w;
  120. posx = incx / 2;
  121. srcy = posy >> 16;
  122. while (n--) {
  123. srcx = posx >> 16;
  124. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  125. srcpixel = *src;
  126. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  127. dstpixel = *dst;
  128. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  129. switch (flags & SDL_COPY_BLEND_MASK) {
  130. case SDL_COPY_BLEND:
  131. dstR = srcR;
  132. dstG = srcG;
  133. dstB = srcB;
  134. break;
  135. case SDL_COPY_BLEND_PREMULTIPLIED:
  136. dstR = srcR;
  137. dstG = srcG;
  138. dstB = srcB;
  139. break;
  140. case SDL_COPY_ADD:
  141. case SDL_COPY_ADD_PREMULTIPLIED:
  142. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  143. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  144. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  145. break;
  146. case SDL_COPY_MOD:
  147. MULT_DIV_255(srcR, dstR, dstR);
  148. MULT_DIV_255(srcG, dstG, dstG);
  149. MULT_DIV_255(srcB, dstB, dstB);
  150. break;
  151. case SDL_COPY_MUL:
  152. MULT_DIV_255(srcR, dstR, dstR);
  153. MULT_DIV_255(srcG, dstG, dstG);
  154. MULT_DIV_255(srcB, dstB, dstB);
  155. break;
  156. }
  157. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  158. *dst = dstpixel;
  159. posx += incx;
  160. ++dst;
  161. }
  162. posy += incy;
  163. info->dst += info->dst_pitch;
  164. }
  165. }
  166. static void SDL_Blit_XRGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  167. {
  168. const int flags = info->flags;
  169. const Uint32 modulateR = info->r;
  170. const Uint32 modulateG = info->g;
  171. const Uint32 modulateB = info->b;
  172. Uint32 pixel;
  173. Uint32 R, G, B;
  174. while (info->dst_h--) {
  175. Uint32 *src = (Uint32 *)info->src;
  176. Uint32 *dst = (Uint32 *)info->dst;
  177. int n = info->dst_w;
  178. while (n--) {
  179. pixel = *src;
  180. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  181. if (flags & SDL_COPY_MODULATE_COLOR) {
  182. MULT_DIV_255(R, modulateR, R);
  183. MULT_DIV_255(G, modulateG, G);
  184. MULT_DIV_255(B, modulateB, B);
  185. }
  186. pixel = (R << 16) | (G << 8) | B;
  187. *dst = pixel;
  188. ++src;
  189. ++dst;
  190. }
  191. info->src += info->src_pitch;
  192. info->dst += info->dst_pitch;
  193. }
  194. }
  195. static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  196. {
  197. const int flags = info->flags;
  198. const Uint32 modulateR = info->r;
  199. const Uint32 modulateG = info->g;
  200. const Uint32 modulateB = info->b;
  201. Uint32 pixel;
  202. Uint32 R, G, B;
  203. Uint64 srcy, srcx;
  204. Uint64 posy, posx;
  205. Uint64 incy, incx;
  206. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  207. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  208. posy = incy / 2;
  209. while (info->dst_h--) {
  210. Uint32 *src = 0;
  211. Uint32 *dst = (Uint32 *)info->dst;
  212. int n = info->dst_w;
  213. posx = incx / 2;
  214. srcy = posy >> 16;
  215. while (n--) {
  216. srcx = posx >> 16;
  217. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  218. pixel = *src;
  219. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  220. if (flags & SDL_COPY_MODULATE_COLOR) {
  221. MULT_DIV_255(R, modulateR, R);
  222. MULT_DIV_255(G, modulateG, G);
  223. MULT_DIV_255(B, modulateB, B);
  224. }
  225. pixel = (R << 16) | (G << 8) | B;
  226. *dst = pixel;
  227. posx += incx;
  228. ++dst;
  229. }
  230. posy += incy;
  231. info->dst += info->dst_pitch;
  232. }
  233. }
  234. static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  235. {
  236. const int flags = info->flags;
  237. const Uint32 modulateR = info->r;
  238. const Uint32 modulateG = info->g;
  239. const Uint32 modulateB = info->b;
  240. const Uint32 modulateA = info->a;
  241. Uint32 srcpixel;
  242. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  243. Uint32 srcR, srcG, srcB;
  244. Uint32 dstpixel;
  245. Uint32 dstR, dstG, dstB;
  246. while (info->dst_h--) {
  247. Uint32 *src = (Uint32 *)info->src;
  248. Uint32 *dst = (Uint32 *)info->dst;
  249. int n = info->dst_w;
  250. while (n--) {
  251. srcpixel = *src;
  252. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  253. dstpixel = *dst;
  254. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  255. if (flags & SDL_COPY_MODULATE_COLOR) {
  256. MULT_DIV_255(srcR, modulateR, srcR);
  257. MULT_DIV_255(srcG, modulateG, srcG);
  258. MULT_DIV_255(srcB, modulateB, srcB);
  259. }
  260. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  261. if (srcA < 255) {
  262. MULT_DIV_255(srcR, srcA, srcR);
  263. MULT_DIV_255(srcG, srcA, srcG);
  264. MULT_DIV_255(srcB, srcA, srcB);
  265. }
  266. }
  267. switch (flags & SDL_COPY_BLEND_MASK) {
  268. case SDL_COPY_BLEND:
  269. MULT_DIV_255((255 - srcA), dstR, dstR);
  270. dstR += srcR;
  271. MULT_DIV_255((255 - srcA), dstG, dstG);
  272. dstG += srcG;
  273. MULT_DIV_255((255 - srcA), dstB, dstB);
  274. dstB += srcB;
  275. break;
  276. case SDL_COPY_BLEND_PREMULTIPLIED:
  277. MULT_DIV_255((255 - srcA), dstR, dstR);
  278. dstR += srcR;
  279. if (dstR > 255) dstR = 255;
  280. MULT_DIV_255((255 - srcA), dstG, dstG);
  281. dstG += srcG;
  282. if (dstG > 255) dstG = 255;
  283. MULT_DIV_255((255 - srcA), dstB, dstB);
  284. dstB += srcB;
  285. if (dstB > 255) dstB = 255;
  286. break;
  287. case SDL_COPY_ADD:
  288. case SDL_COPY_ADD_PREMULTIPLIED:
  289. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  290. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  291. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  292. break;
  293. case SDL_COPY_MOD:
  294. MULT_DIV_255(srcR, dstR, dstR);
  295. MULT_DIV_255(srcG, dstG, dstG);
  296. MULT_DIV_255(srcB, dstB, dstB);
  297. break;
  298. case SDL_COPY_MUL:
  299. {
  300. Uint32 tmp1, tmp2;
  301. MULT_DIV_255(srcR, dstR, tmp1);
  302. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  303. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  304. MULT_DIV_255(srcG, dstG, tmp1);
  305. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  306. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  307. MULT_DIV_255(srcB, dstB, tmp1);
  308. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  309. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  310. }
  311. break;
  312. }
  313. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  314. *dst = dstpixel;
  315. ++src;
  316. ++dst;
  317. }
  318. info->src += info->src_pitch;
  319. info->dst += info->dst_pitch;
  320. }
  321. }
  322. static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  323. {
  324. const int flags = info->flags;
  325. const Uint32 modulateR = info->r;
  326. const Uint32 modulateG = info->g;
  327. const Uint32 modulateB = info->b;
  328. const Uint32 modulateA = info->a;
  329. Uint32 srcpixel;
  330. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  331. Uint32 srcR, srcG, srcB;
  332. Uint32 dstpixel;
  333. Uint32 dstR, dstG, dstB;
  334. Uint64 srcy, srcx;
  335. Uint64 posy, posx;
  336. Uint64 incy, incx;
  337. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  338. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  339. posy = incy / 2;
  340. while (info->dst_h--) {
  341. Uint32 *src = 0;
  342. Uint32 *dst = (Uint32 *)info->dst;
  343. int n = info->dst_w;
  344. posx = incx / 2;
  345. srcy = posy >> 16;
  346. while (n--) {
  347. srcx = posx >> 16;
  348. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  349. srcpixel = *src;
  350. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  351. dstpixel = *dst;
  352. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  353. if (flags & SDL_COPY_MODULATE_COLOR) {
  354. MULT_DIV_255(srcR, modulateR, srcR);
  355. MULT_DIV_255(srcG, modulateG, srcG);
  356. MULT_DIV_255(srcB, modulateB, srcB);
  357. }
  358. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  359. if (srcA < 255) {
  360. MULT_DIV_255(srcR, srcA, srcR);
  361. MULT_DIV_255(srcG, srcA, srcG);
  362. MULT_DIV_255(srcB, srcA, srcB);
  363. }
  364. }
  365. switch (flags & SDL_COPY_BLEND_MASK) {
  366. case SDL_COPY_BLEND:
  367. MULT_DIV_255((255 - srcA), dstR, dstR);
  368. dstR += srcR;
  369. MULT_DIV_255((255 - srcA), dstG, dstG);
  370. dstG += srcG;
  371. MULT_DIV_255((255 - srcA), dstB, dstB);
  372. dstB += srcB;
  373. break;
  374. case SDL_COPY_BLEND_PREMULTIPLIED:
  375. MULT_DIV_255((255 - srcA), dstR, dstR);
  376. dstR += srcR;
  377. if (dstR > 255) dstR = 255;
  378. MULT_DIV_255((255 - srcA), dstG, dstG);
  379. dstG += srcG;
  380. if (dstG > 255) dstG = 255;
  381. MULT_DIV_255((255 - srcA), dstB, dstB);
  382. dstB += srcB;
  383. if (dstB > 255) dstB = 255;
  384. break;
  385. case SDL_COPY_ADD:
  386. case SDL_COPY_ADD_PREMULTIPLIED:
  387. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  388. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  389. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  390. break;
  391. case SDL_COPY_MOD:
  392. MULT_DIV_255(srcR, dstR, dstR);
  393. MULT_DIV_255(srcG, dstG, dstG);
  394. MULT_DIV_255(srcB, dstB, dstB);
  395. break;
  396. case SDL_COPY_MUL:
  397. {
  398. Uint32 tmp1, tmp2;
  399. MULT_DIV_255(srcR, dstR, tmp1);
  400. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  401. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  402. MULT_DIV_255(srcG, dstG, tmp1);
  403. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  404. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  405. MULT_DIV_255(srcB, dstB, tmp1);
  406. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  407. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  408. }
  409. break;
  410. }
  411. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  412. *dst = dstpixel;
  413. posx += incx;
  414. ++dst;
  415. }
  416. posy += incy;
  417. info->dst += info->dst_pitch;
  418. }
  419. }
  420. static void SDL_Blit_XRGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
  421. {
  422. Uint32 pixel;
  423. Uint32 R, G, B;
  424. Uint64 srcy, srcx;
  425. Uint64 posy, posx;
  426. Uint64 incy, incx;
  427. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  428. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  429. posy = incy / 2;
  430. while (info->dst_h--) {
  431. Uint32 *src = 0;
  432. Uint32 *dst = (Uint32 *)info->dst;
  433. int n = info->dst_w;
  434. posx = incx / 2;
  435. srcy = posy >> 16;
  436. while (n--) {
  437. srcx = posx >> 16;
  438. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  439. pixel = *src;
  440. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  441. pixel = (B << 16) | (G << 8) | R;
  442. *dst = pixel;
  443. posx += incx;
  444. ++dst;
  445. }
  446. posy += incy;
  447. info->dst += info->dst_pitch;
  448. }
  449. }
  450. static void SDL_Blit_XRGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
  451. {
  452. const int flags = info->flags;
  453. Uint32 srcpixel;
  454. Uint32 srcR, srcG, srcB;
  455. Uint32 dstpixel;
  456. Uint32 dstR, dstG, dstB;
  457. while (info->dst_h--) {
  458. Uint32 *src = (Uint32 *)info->src;
  459. Uint32 *dst = (Uint32 *)info->dst;
  460. int n = info->dst_w;
  461. while (n--) {
  462. srcpixel = *src;
  463. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  464. dstpixel = *dst;
  465. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  466. switch (flags & SDL_COPY_BLEND_MASK) {
  467. case SDL_COPY_BLEND:
  468. dstR = srcR;
  469. dstG = srcG;
  470. dstB = srcB;
  471. break;
  472. case SDL_COPY_BLEND_PREMULTIPLIED:
  473. dstR = srcR;
  474. dstG = srcG;
  475. dstB = srcB;
  476. break;
  477. case SDL_COPY_ADD:
  478. case SDL_COPY_ADD_PREMULTIPLIED:
  479. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  480. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  481. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  482. break;
  483. case SDL_COPY_MOD:
  484. MULT_DIV_255(srcR, dstR, dstR);
  485. MULT_DIV_255(srcG, dstG, dstG);
  486. MULT_DIV_255(srcB, dstB, dstB);
  487. break;
  488. case SDL_COPY_MUL:
  489. MULT_DIV_255(srcR, dstR, dstR);
  490. MULT_DIV_255(srcG, dstG, dstG);
  491. MULT_DIV_255(srcB, dstB, dstB);
  492. break;
  493. }
  494. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  495. *dst = dstpixel;
  496. ++src;
  497. ++dst;
  498. }
  499. info->src += info->src_pitch;
  500. info->dst += info->dst_pitch;
  501. }
  502. }
  503. static void SDL_Blit_XRGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  504. {
  505. const int flags = info->flags;
  506. Uint32 srcpixel;
  507. Uint32 srcR, srcG, srcB;
  508. Uint32 dstpixel;
  509. Uint32 dstR, dstG, dstB;
  510. Uint64 srcy, srcx;
  511. Uint64 posy, posx;
  512. Uint64 incy, incx;
  513. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  514. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  515. posy = incy / 2;
  516. while (info->dst_h--) {
  517. Uint32 *src = 0;
  518. Uint32 *dst = (Uint32 *)info->dst;
  519. int n = info->dst_w;
  520. posx = incx / 2;
  521. srcy = posy >> 16;
  522. while (n--) {
  523. srcx = posx >> 16;
  524. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  525. srcpixel = *src;
  526. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  527. dstpixel = *dst;
  528. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  529. switch (flags & SDL_COPY_BLEND_MASK) {
  530. case SDL_COPY_BLEND:
  531. dstR = srcR;
  532. dstG = srcG;
  533. dstB = srcB;
  534. break;
  535. case SDL_COPY_BLEND_PREMULTIPLIED:
  536. dstR = srcR;
  537. dstG = srcG;
  538. dstB = srcB;
  539. break;
  540. case SDL_COPY_ADD:
  541. case SDL_COPY_ADD_PREMULTIPLIED:
  542. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  543. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  544. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  545. break;
  546. case SDL_COPY_MOD:
  547. MULT_DIV_255(srcR, dstR, dstR);
  548. MULT_DIV_255(srcG, dstG, dstG);
  549. MULT_DIV_255(srcB, dstB, dstB);
  550. break;
  551. case SDL_COPY_MUL:
  552. MULT_DIV_255(srcR, dstR, dstR);
  553. MULT_DIV_255(srcG, dstG, dstG);
  554. MULT_DIV_255(srcB, dstB, dstB);
  555. break;
  556. }
  557. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  558. *dst = dstpixel;
  559. posx += incx;
  560. ++dst;
  561. }
  562. posy += incy;
  563. info->dst += info->dst_pitch;
  564. }
  565. }
  566. static void SDL_Blit_XRGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  567. {
  568. const int flags = info->flags;
  569. const Uint32 modulateR = info->r;
  570. const Uint32 modulateG = info->g;
  571. const Uint32 modulateB = info->b;
  572. Uint32 pixel;
  573. Uint32 R, G, B;
  574. while (info->dst_h--) {
  575. Uint32 *src = (Uint32 *)info->src;
  576. Uint32 *dst = (Uint32 *)info->dst;
  577. int n = info->dst_w;
  578. while (n--) {
  579. pixel = *src;
  580. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  581. if (flags & SDL_COPY_MODULATE_COLOR) {
  582. MULT_DIV_255(R, modulateR, R);
  583. MULT_DIV_255(G, modulateG, G);
  584. MULT_DIV_255(B, modulateB, B);
  585. }
  586. pixel = (B << 16) | (G << 8) | R;
  587. *dst = pixel;
  588. ++src;
  589. ++dst;
  590. }
  591. info->src += info->src_pitch;
  592. info->dst += info->dst_pitch;
  593. }
  594. }
  595. static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  596. {
  597. const int flags = info->flags;
  598. const Uint32 modulateR = info->r;
  599. const Uint32 modulateG = info->g;
  600. const Uint32 modulateB = info->b;
  601. Uint32 pixel;
  602. Uint32 R, G, B;
  603. Uint64 srcy, srcx;
  604. Uint64 posy, posx;
  605. Uint64 incy, incx;
  606. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  607. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  608. posy = incy / 2;
  609. while (info->dst_h--) {
  610. Uint32 *src = 0;
  611. Uint32 *dst = (Uint32 *)info->dst;
  612. int n = info->dst_w;
  613. posx = incx / 2;
  614. srcy = posy >> 16;
  615. while (n--) {
  616. srcx = posx >> 16;
  617. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  618. pixel = *src;
  619. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  620. if (flags & SDL_COPY_MODULATE_COLOR) {
  621. MULT_DIV_255(R, modulateR, R);
  622. MULT_DIV_255(G, modulateG, G);
  623. MULT_DIV_255(B, modulateB, B);
  624. }
  625. pixel = (B << 16) | (G << 8) | R;
  626. *dst = pixel;
  627. posx += incx;
  628. ++dst;
  629. }
  630. posy += incy;
  631. info->dst += info->dst_pitch;
  632. }
  633. }
  634. static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  635. {
  636. const int flags = info->flags;
  637. const Uint32 modulateR = info->r;
  638. const Uint32 modulateG = info->g;
  639. const Uint32 modulateB = info->b;
  640. const Uint32 modulateA = info->a;
  641. Uint32 srcpixel;
  642. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  643. Uint32 srcR, srcG, srcB;
  644. Uint32 dstpixel;
  645. Uint32 dstR, dstG, dstB;
  646. while (info->dst_h--) {
  647. Uint32 *src = (Uint32 *)info->src;
  648. Uint32 *dst = (Uint32 *)info->dst;
  649. int n = info->dst_w;
  650. while (n--) {
  651. srcpixel = *src;
  652. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  653. dstpixel = *dst;
  654. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  655. if (flags & SDL_COPY_MODULATE_COLOR) {
  656. MULT_DIV_255(srcR, modulateR, srcR);
  657. MULT_DIV_255(srcG, modulateG, srcG);
  658. MULT_DIV_255(srcB, modulateB, srcB);
  659. }
  660. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  661. if (srcA < 255) {
  662. MULT_DIV_255(srcR, srcA, srcR);
  663. MULT_DIV_255(srcG, srcA, srcG);
  664. MULT_DIV_255(srcB, srcA, srcB);
  665. }
  666. }
  667. switch (flags & SDL_COPY_BLEND_MASK) {
  668. case SDL_COPY_BLEND:
  669. MULT_DIV_255((255 - srcA), dstR, dstR);
  670. dstR += srcR;
  671. MULT_DIV_255((255 - srcA), dstG, dstG);
  672. dstG += srcG;
  673. MULT_DIV_255((255 - srcA), dstB, dstB);
  674. dstB += srcB;
  675. break;
  676. case SDL_COPY_BLEND_PREMULTIPLIED:
  677. MULT_DIV_255((255 - srcA), dstR, dstR);
  678. dstR += srcR;
  679. if (dstR > 255) dstR = 255;
  680. MULT_DIV_255((255 - srcA), dstG, dstG);
  681. dstG += srcG;
  682. if (dstG > 255) dstG = 255;
  683. MULT_DIV_255((255 - srcA), dstB, dstB);
  684. dstB += srcB;
  685. if (dstB > 255) dstB = 255;
  686. break;
  687. case SDL_COPY_ADD:
  688. case SDL_COPY_ADD_PREMULTIPLIED:
  689. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  690. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  691. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  692. break;
  693. case SDL_COPY_MOD:
  694. MULT_DIV_255(srcR, dstR, dstR);
  695. MULT_DIV_255(srcG, dstG, dstG);
  696. MULT_DIV_255(srcB, dstB, dstB);
  697. break;
  698. case SDL_COPY_MUL:
  699. {
  700. Uint32 tmp1, tmp2;
  701. MULT_DIV_255(srcR, dstR, tmp1);
  702. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  703. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  704. MULT_DIV_255(srcG, dstG, tmp1);
  705. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  706. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  707. MULT_DIV_255(srcB, dstB, tmp1);
  708. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  709. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  710. }
  711. break;
  712. }
  713. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  714. *dst = dstpixel;
  715. ++src;
  716. ++dst;
  717. }
  718. info->src += info->src_pitch;
  719. info->dst += info->dst_pitch;
  720. }
  721. }
  722. static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  723. {
  724. const int flags = info->flags;
  725. const Uint32 modulateR = info->r;
  726. const Uint32 modulateG = info->g;
  727. const Uint32 modulateB = info->b;
  728. const Uint32 modulateA = info->a;
  729. Uint32 srcpixel;
  730. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  731. Uint32 srcR, srcG, srcB;
  732. Uint32 dstpixel;
  733. Uint32 dstR, dstG, dstB;
  734. Uint64 srcy, srcx;
  735. Uint64 posy, posx;
  736. Uint64 incy, incx;
  737. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  738. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  739. posy = incy / 2;
  740. while (info->dst_h--) {
  741. Uint32 *src = 0;
  742. Uint32 *dst = (Uint32 *)info->dst;
  743. int n = info->dst_w;
  744. posx = incx / 2;
  745. srcy = posy >> 16;
  746. while (n--) {
  747. srcx = posx >> 16;
  748. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  749. srcpixel = *src;
  750. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  751. dstpixel = *dst;
  752. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  753. if (flags & SDL_COPY_MODULATE_COLOR) {
  754. MULT_DIV_255(srcR, modulateR, srcR);
  755. MULT_DIV_255(srcG, modulateG, srcG);
  756. MULT_DIV_255(srcB, modulateB, srcB);
  757. }
  758. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  759. if (srcA < 255) {
  760. MULT_DIV_255(srcR, srcA, srcR);
  761. MULT_DIV_255(srcG, srcA, srcG);
  762. MULT_DIV_255(srcB, srcA, srcB);
  763. }
  764. }
  765. switch (flags & SDL_COPY_BLEND_MASK) {
  766. case SDL_COPY_BLEND:
  767. MULT_DIV_255((255 - srcA), dstR, dstR);
  768. dstR += srcR;
  769. MULT_DIV_255((255 - srcA), dstG, dstG);
  770. dstG += srcG;
  771. MULT_DIV_255((255 - srcA), dstB, dstB);
  772. dstB += srcB;
  773. break;
  774. case SDL_COPY_BLEND_PREMULTIPLIED:
  775. MULT_DIV_255((255 - srcA), dstR, dstR);
  776. dstR += srcR;
  777. if (dstR > 255) dstR = 255;
  778. MULT_DIV_255((255 - srcA), dstG, dstG);
  779. dstG += srcG;
  780. if (dstG > 255) dstG = 255;
  781. MULT_DIV_255((255 - srcA), dstB, dstB);
  782. dstB += srcB;
  783. if (dstB > 255) dstB = 255;
  784. break;
  785. case SDL_COPY_ADD:
  786. case SDL_COPY_ADD_PREMULTIPLIED:
  787. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  788. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  789. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  790. break;
  791. case SDL_COPY_MOD:
  792. MULT_DIV_255(srcR, dstR, dstR);
  793. MULT_DIV_255(srcG, dstG, dstG);
  794. MULT_DIV_255(srcB, dstB, dstB);
  795. break;
  796. case SDL_COPY_MUL:
  797. {
  798. Uint32 tmp1, tmp2;
  799. MULT_DIV_255(srcR, dstR, tmp1);
  800. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  801. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  802. MULT_DIV_255(srcG, dstG, tmp1);
  803. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  804. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  805. MULT_DIV_255(srcB, dstB, tmp1);
  806. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  807. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  808. }
  809. break;
  810. }
  811. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  812. *dst = dstpixel;
  813. posx += incx;
  814. ++dst;
  815. }
  816. posy += incy;
  817. info->dst += info->dst_pitch;
  818. }
  819. }
  820. static void SDL_Blit_XRGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
  821. {
  822. Uint32 pixel;
  823. const Uint32 A = 0xFF;
  824. Uint64 srcy, srcx;
  825. Uint64 posy, posx;
  826. Uint64 incy, incx;
  827. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  828. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  829. posy = incy / 2;
  830. while (info->dst_h--) {
  831. Uint32 *src = 0;
  832. Uint32 *dst = (Uint32 *)info->dst;
  833. int n = info->dst_w;
  834. posx = incx / 2;
  835. srcy = posy >> 16;
  836. while (n--) {
  837. srcx = posx >> 16;
  838. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  839. pixel = *src;
  840. pixel |= (A << 24);
  841. *dst = pixel;
  842. posx += incx;
  843. ++dst;
  844. }
  845. posy += incy;
  846. info->dst += info->dst_pitch;
  847. }
  848. }
  849. static void SDL_Blit_XRGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
  850. {
  851. const int flags = info->flags;
  852. Uint32 srcpixel;
  853. Uint32 srcR, srcG, srcB;
  854. Uint32 dstpixel;
  855. Uint32 dstR, dstG, dstB, dstA;
  856. while (info->dst_h--) {
  857. Uint32 *src = (Uint32 *)info->src;
  858. Uint32 *dst = (Uint32 *)info->dst;
  859. int n = info->dst_w;
  860. while (n--) {
  861. srcpixel = *src;
  862. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  863. dstpixel = *dst;
  864. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  865. switch (flags & SDL_COPY_BLEND_MASK) {
  866. case SDL_COPY_BLEND:
  867. dstR = srcR;
  868. dstG = srcG;
  869. dstB = srcB;
  870. dstA = 0xFF;
  871. break;
  872. case SDL_COPY_BLEND_PREMULTIPLIED:
  873. dstR = srcR;
  874. dstG = srcG;
  875. dstB = srcB;
  876. dstA = 0xFF;
  877. break;
  878. case SDL_COPY_ADD:
  879. case SDL_COPY_ADD_PREMULTIPLIED:
  880. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  881. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  882. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  883. break;
  884. case SDL_COPY_MOD:
  885. MULT_DIV_255(srcR, dstR, dstR);
  886. MULT_DIV_255(srcG, dstG, dstG);
  887. MULT_DIV_255(srcB, dstB, dstB);
  888. break;
  889. case SDL_COPY_MUL:
  890. MULT_DIV_255(srcR, dstR, dstR);
  891. MULT_DIV_255(srcG, dstG, dstG);
  892. MULT_DIV_255(srcB, dstB, dstB);
  893. break;
  894. }
  895. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  896. *dst = dstpixel;
  897. ++src;
  898. ++dst;
  899. }
  900. info->src += info->src_pitch;
  901. info->dst += info->dst_pitch;
  902. }
  903. }
  904. static void SDL_Blit_XRGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  905. {
  906. const int flags = info->flags;
  907. Uint32 srcpixel;
  908. Uint32 srcR, srcG, srcB;
  909. Uint32 dstpixel;
  910. Uint32 dstR, dstG, dstB, dstA;
  911. Uint64 srcy, srcx;
  912. Uint64 posy, posx;
  913. Uint64 incy, incx;
  914. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  915. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  916. posy = incy / 2;
  917. while (info->dst_h--) {
  918. Uint32 *src = 0;
  919. Uint32 *dst = (Uint32 *)info->dst;
  920. int n = info->dst_w;
  921. posx = incx / 2;
  922. srcy = posy >> 16;
  923. while (n--) {
  924. srcx = posx >> 16;
  925. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  926. srcpixel = *src;
  927. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  928. dstpixel = *dst;
  929. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  930. switch (flags & SDL_COPY_BLEND_MASK) {
  931. case SDL_COPY_BLEND:
  932. dstR = srcR;
  933. dstG = srcG;
  934. dstB = srcB;
  935. dstA = 0xFF;
  936. break;
  937. case SDL_COPY_BLEND_PREMULTIPLIED:
  938. dstR = srcR;
  939. dstG = srcG;
  940. dstB = srcB;
  941. dstA = 0xFF;
  942. break;
  943. case SDL_COPY_ADD:
  944. case SDL_COPY_ADD_PREMULTIPLIED:
  945. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  946. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  947. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  948. break;
  949. case SDL_COPY_MOD:
  950. MULT_DIV_255(srcR, dstR, dstR);
  951. MULT_DIV_255(srcG, dstG, dstG);
  952. MULT_DIV_255(srcB, dstB, dstB);
  953. break;
  954. case SDL_COPY_MUL:
  955. MULT_DIV_255(srcR, dstR, dstR);
  956. MULT_DIV_255(srcG, dstG, dstG);
  957. MULT_DIV_255(srcB, dstB, dstB);
  958. break;
  959. }
  960. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  961. *dst = dstpixel;
  962. posx += incx;
  963. ++dst;
  964. }
  965. posy += incy;
  966. info->dst += info->dst_pitch;
  967. }
  968. }
  969. static void SDL_Blit_XRGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  970. {
  971. const int flags = info->flags;
  972. const Uint32 modulateR = info->r;
  973. const Uint32 modulateG = info->g;
  974. const Uint32 modulateB = info->b;
  975. const Uint32 modulateA = info->a;
  976. Uint32 pixel;
  977. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  978. Uint32 R, G, B;
  979. while (info->dst_h--) {
  980. Uint32 *src = (Uint32 *)info->src;
  981. Uint32 *dst = (Uint32 *)info->dst;
  982. int n = info->dst_w;
  983. while (n--) {
  984. pixel = *src;
  985. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  986. if (flags & SDL_COPY_MODULATE_COLOR) {
  987. MULT_DIV_255(R, modulateR, R);
  988. MULT_DIV_255(G, modulateG, G);
  989. MULT_DIV_255(B, modulateB, B);
  990. }
  991. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  992. *dst = pixel;
  993. ++src;
  994. ++dst;
  995. }
  996. info->src += info->src_pitch;
  997. info->dst += info->dst_pitch;
  998. }
  999. }
  1000. static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  1001. {
  1002. const int flags = info->flags;
  1003. const Uint32 modulateR = info->r;
  1004. const Uint32 modulateG = info->g;
  1005. const Uint32 modulateB = info->b;
  1006. const Uint32 modulateA = info->a;
  1007. Uint32 pixel;
  1008. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1009. Uint32 R, G, B;
  1010. Uint64 srcy, srcx;
  1011. Uint64 posy, posx;
  1012. Uint64 incy, incx;
  1013. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1014. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1015. posy = incy / 2;
  1016. while (info->dst_h--) {
  1017. Uint32 *src = 0;
  1018. Uint32 *dst = (Uint32 *)info->dst;
  1019. int n = info->dst_w;
  1020. posx = incx / 2;
  1021. srcy = posy >> 16;
  1022. while (n--) {
  1023. srcx = posx >> 16;
  1024. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1025. pixel = *src;
  1026. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1027. if (flags & SDL_COPY_MODULATE_COLOR) {
  1028. MULT_DIV_255(R, modulateR, R);
  1029. MULT_DIV_255(G, modulateG, G);
  1030. MULT_DIV_255(B, modulateB, B);
  1031. }
  1032. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  1033. *dst = pixel;
  1034. posx += incx;
  1035. ++dst;
  1036. }
  1037. posy += incy;
  1038. info->dst += info->dst_pitch;
  1039. }
  1040. }
  1041. static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1042. {
  1043. const int flags = info->flags;
  1044. const Uint32 modulateR = info->r;
  1045. const Uint32 modulateG = info->g;
  1046. const Uint32 modulateB = info->b;
  1047. const Uint32 modulateA = info->a;
  1048. Uint32 srcpixel;
  1049. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1050. Uint32 srcR, srcG, srcB;
  1051. Uint32 dstpixel;
  1052. Uint32 dstR, dstG, dstB, dstA;
  1053. while (info->dst_h--) {
  1054. Uint32 *src = (Uint32 *)info->src;
  1055. Uint32 *dst = (Uint32 *)info->dst;
  1056. int n = info->dst_w;
  1057. while (n--) {
  1058. srcpixel = *src;
  1059. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1060. dstpixel = *dst;
  1061. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1062. if (flags & SDL_COPY_MODULATE_COLOR) {
  1063. MULT_DIV_255(srcR, modulateR, srcR);
  1064. MULT_DIV_255(srcG, modulateG, srcG);
  1065. MULT_DIV_255(srcB, modulateB, srcB);
  1066. }
  1067. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1068. if (srcA < 255) {
  1069. MULT_DIV_255(srcR, srcA, srcR);
  1070. MULT_DIV_255(srcG, srcA, srcG);
  1071. MULT_DIV_255(srcB, srcA, srcB);
  1072. }
  1073. }
  1074. switch (flags & SDL_COPY_BLEND_MASK) {
  1075. case SDL_COPY_BLEND:
  1076. MULT_DIV_255((255 - srcA), dstR, dstR);
  1077. dstR += srcR;
  1078. MULT_DIV_255((255 - srcA), dstG, dstG);
  1079. dstG += srcG;
  1080. MULT_DIV_255((255 - srcA), dstB, dstB);
  1081. dstB += srcB;
  1082. MULT_DIV_255((255 - srcA), dstA, dstA);
  1083. dstA += srcA;
  1084. break;
  1085. case SDL_COPY_BLEND_PREMULTIPLIED:
  1086. MULT_DIV_255((255 - srcA), dstR, dstR);
  1087. dstR += srcR;
  1088. if (dstR > 255) dstR = 255;
  1089. MULT_DIV_255((255 - srcA), dstG, dstG);
  1090. dstG += srcG;
  1091. if (dstG > 255) dstG = 255;
  1092. MULT_DIV_255((255 - srcA), dstB, dstB);
  1093. dstB += srcB;
  1094. if (dstB > 255) dstB = 255;
  1095. MULT_DIV_255((255 - srcA), dstA, dstA);
  1096. dstA += srcA;
  1097. if (dstA > 255) dstA = 255;
  1098. break;
  1099. case SDL_COPY_ADD:
  1100. case SDL_COPY_ADD_PREMULTIPLIED:
  1101. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1102. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1103. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1104. break;
  1105. case SDL_COPY_MOD:
  1106. MULT_DIV_255(srcR, dstR, dstR);
  1107. MULT_DIV_255(srcG, dstG, dstG);
  1108. MULT_DIV_255(srcB, dstB, dstB);
  1109. break;
  1110. case SDL_COPY_MUL:
  1111. {
  1112. Uint32 tmp1, tmp2;
  1113. MULT_DIV_255(srcR, dstR, tmp1);
  1114. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1115. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1116. MULT_DIV_255(srcG, dstG, tmp1);
  1117. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1118. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1119. MULT_DIV_255(srcB, dstB, tmp1);
  1120. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1121. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1122. }
  1123. break;
  1124. }
  1125. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  1126. *dst = dstpixel;
  1127. ++src;
  1128. ++dst;
  1129. }
  1130. info->src += info->src_pitch;
  1131. info->dst += info->dst_pitch;
  1132. }
  1133. }
  1134. static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1135. {
  1136. const int flags = info->flags;
  1137. const Uint32 modulateR = info->r;
  1138. const Uint32 modulateG = info->g;
  1139. const Uint32 modulateB = info->b;
  1140. const Uint32 modulateA = info->a;
  1141. Uint32 srcpixel;
  1142. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1143. Uint32 srcR, srcG, srcB;
  1144. Uint32 dstpixel;
  1145. Uint32 dstR, dstG, dstB, dstA;
  1146. Uint64 srcy, srcx;
  1147. Uint64 posy, posx;
  1148. Uint64 incy, incx;
  1149. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1150. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1151. posy = incy / 2;
  1152. while (info->dst_h--) {
  1153. Uint32 *src = 0;
  1154. Uint32 *dst = (Uint32 *)info->dst;
  1155. int n = info->dst_w;
  1156. posx = incx / 2;
  1157. srcy = posy >> 16;
  1158. while (n--) {
  1159. srcx = posx >> 16;
  1160. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1161. srcpixel = *src;
  1162. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1163. dstpixel = *dst;
  1164. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1165. if (flags & SDL_COPY_MODULATE_COLOR) {
  1166. MULT_DIV_255(srcR, modulateR, srcR);
  1167. MULT_DIV_255(srcG, modulateG, srcG);
  1168. MULT_DIV_255(srcB, modulateB, srcB);
  1169. }
  1170. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1171. if (srcA < 255) {
  1172. MULT_DIV_255(srcR, srcA, srcR);
  1173. MULT_DIV_255(srcG, srcA, srcG);
  1174. MULT_DIV_255(srcB, srcA, srcB);
  1175. }
  1176. }
  1177. switch (flags & SDL_COPY_BLEND_MASK) {
  1178. case SDL_COPY_BLEND:
  1179. MULT_DIV_255((255 - srcA), dstR, dstR);
  1180. dstR += srcR;
  1181. MULT_DIV_255((255 - srcA), dstG, dstG);
  1182. dstG += srcG;
  1183. MULT_DIV_255((255 - srcA), dstB, dstB);
  1184. dstB += srcB;
  1185. MULT_DIV_255((255 - srcA), dstA, dstA);
  1186. dstA += srcA;
  1187. break;
  1188. case SDL_COPY_BLEND_PREMULTIPLIED:
  1189. MULT_DIV_255((255 - srcA), dstR, dstR);
  1190. dstR += srcR;
  1191. if (dstR > 255) dstR = 255;
  1192. MULT_DIV_255((255 - srcA), dstG, dstG);
  1193. dstG += srcG;
  1194. if (dstG > 255) dstG = 255;
  1195. MULT_DIV_255((255 - srcA), dstB, dstB);
  1196. dstB += srcB;
  1197. if (dstB > 255) dstB = 255;
  1198. MULT_DIV_255((255 - srcA), dstA, dstA);
  1199. dstA += srcA;
  1200. if (dstA > 255) dstA = 255;
  1201. break;
  1202. case SDL_COPY_ADD:
  1203. case SDL_COPY_ADD_PREMULTIPLIED:
  1204. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1205. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1206. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1207. break;
  1208. case SDL_COPY_MOD:
  1209. MULT_DIV_255(srcR, dstR, dstR);
  1210. MULT_DIV_255(srcG, dstG, dstG);
  1211. MULT_DIV_255(srcB, dstB, dstB);
  1212. break;
  1213. case SDL_COPY_MUL:
  1214. {
  1215. Uint32 tmp1, tmp2;
  1216. MULT_DIV_255(srcR, dstR, tmp1);
  1217. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1218. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1219. MULT_DIV_255(srcG, dstG, tmp1);
  1220. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1221. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1222. MULT_DIV_255(srcB, dstB, tmp1);
  1223. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1224. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1225. }
  1226. break;
  1227. }
  1228. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  1229. *dst = dstpixel;
  1230. posx += incx;
  1231. ++dst;
  1232. }
  1233. posy += incy;
  1234. info->dst += info->dst_pitch;
  1235. }
  1236. }
  1237. static void SDL_Blit_XRGB8888_ABGR8888_Scale(SDL_BlitInfo *info)
  1238. {
  1239. Uint32 pixel;
  1240. const Uint32 A = 0xFF;
  1241. Uint32 R, G, B;
  1242. Uint64 srcy, srcx;
  1243. Uint64 posy, posx;
  1244. Uint64 incy, incx;
  1245. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1246. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1247. posy = incy / 2;
  1248. while (info->dst_h--) {
  1249. Uint32 *src = 0;
  1250. Uint32 *dst = (Uint32 *)info->dst;
  1251. int n = info->dst_w;
  1252. posx = incx / 2;
  1253. srcy = posy >> 16;
  1254. while (n--) {
  1255. srcx = posx >> 16;
  1256. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1257. pixel = *src;
  1258. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1259. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  1260. *dst = pixel;
  1261. posx += incx;
  1262. ++dst;
  1263. }
  1264. posy += incy;
  1265. info->dst += info->dst_pitch;
  1266. }
  1267. }
  1268. static void SDL_Blit_XRGB8888_ABGR8888_Blend(SDL_BlitInfo *info)
  1269. {
  1270. const int flags = info->flags;
  1271. Uint32 srcpixel;
  1272. Uint32 srcR, srcG, srcB;
  1273. Uint32 dstpixel;
  1274. Uint32 dstR, dstG, dstB, dstA;
  1275. while (info->dst_h--) {
  1276. Uint32 *src = (Uint32 *)info->src;
  1277. Uint32 *dst = (Uint32 *)info->dst;
  1278. int n = info->dst_w;
  1279. while (n--) {
  1280. srcpixel = *src;
  1281. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1282. dstpixel = *dst;
  1283. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1284. switch (flags & SDL_COPY_BLEND_MASK) {
  1285. case SDL_COPY_BLEND:
  1286. dstR = srcR;
  1287. dstG = srcG;
  1288. dstB = srcB;
  1289. dstA = 0xFF;
  1290. break;
  1291. case SDL_COPY_BLEND_PREMULTIPLIED:
  1292. dstR = srcR;
  1293. dstG = srcG;
  1294. dstB = srcB;
  1295. dstA = 0xFF;
  1296. break;
  1297. case SDL_COPY_ADD:
  1298. case SDL_COPY_ADD_PREMULTIPLIED:
  1299. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1300. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1301. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1302. break;
  1303. case SDL_COPY_MOD:
  1304. MULT_DIV_255(srcR, dstR, dstR);
  1305. MULT_DIV_255(srcG, dstG, dstG);
  1306. MULT_DIV_255(srcB, dstB, dstB);
  1307. break;
  1308. case SDL_COPY_MUL:
  1309. MULT_DIV_255(srcR, dstR, dstR);
  1310. MULT_DIV_255(srcG, dstG, dstG);
  1311. MULT_DIV_255(srcB, dstB, dstB);
  1312. break;
  1313. }
  1314. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  1315. *dst = dstpixel;
  1316. ++src;
  1317. ++dst;
  1318. }
  1319. info->src += info->src_pitch;
  1320. info->dst += info->dst_pitch;
  1321. }
  1322. }
  1323. static void SDL_Blit_XRGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  1324. {
  1325. const int flags = info->flags;
  1326. Uint32 srcpixel;
  1327. Uint32 srcR, srcG, srcB;
  1328. Uint32 dstpixel;
  1329. Uint32 dstR, dstG, dstB, dstA;
  1330. Uint64 srcy, srcx;
  1331. Uint64 posy, posx;
  1332. Uint64 incy, incx;
  1333. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1334. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1335. posy = incy / 2;
  1336. while (info->dst_h--) {
  1337. Uint32 *src = 0;
  1338. Uint32 *dst = (Uint32 *)info->dst;
  1339. int n = info->dst_w;
  1340. posx = incx / 2;
  1341. srcy = posy >> 16;
  1342. while (n--) {
  1343. srcx = posx >> 16;
  1344. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1345. srcpixel = *src;
  1346. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1347. dstpixel = *dst;
  1348. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1349. switch (flags & SDL_COPY_BLEND_MASK) {
  1350. case SDL_COPY_BLEND:
  1351. dstR = srcR;
  1352. dstG = srcG;
  1353. dstB = srcB;
  1354. dstA = 0xFF;
  1355. break;
  1356. case SDL_COPY_BLEND_PREMULTIPLIED:
  1357. dstR = srcR;
  1358. dstG = srcG;
  1359. dstB = srcB;
  1360. dstA = 0xFF;
  1361. break;
  1362. case SDL_COPY_ADD:
  1363. case SDL_COPY_ADD_PREMULTIPLIED:
  1364. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1365. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1366. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1367. break;
  1368. case SDL_COPY_MOD:
  1369. MULT_DIV_255(srcR, dstR, dstR);
  1370. MULT_DIV_255(srcG, dstG, dstG);
  1371. MULT_DIV_255(srcB, dstB, dstB);
  1372. break;
  1373. case SDL_COPY_MUL:
  1374. MULT_DIV_255(srcR, dstR, dstR);
  1375. MULT_DIV_255(srcG, dstG, dstG);
  1376. MULT_DIV_255(srcB, dstB, dstB);
  1377. break;
  1378. }
  1379. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  1380. *dst = dstpixel;
  1381. posx += incx;
  1382. ++dst;
  1383. }
  1384. posy += incy;
  1385. info->dst += info->dst_pitch;
  1386. }
  1387. }
  1388. static void SDL_Blit_XRGB8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  1389. {
  1390. const int flags = info->flags;
  1391. const Uint32 modulateR = info->r;
  1392. const Uint32 modulateG = info->g;
  1393. const Uint32 modulateB = info->b;
  1394. const Uint32 modulateA = info->a;
  1395. Uint32 pixel;
  1396. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1397. Uint32 R, G, B;
  1398. while (info->dst_h--) {
  1399. Uint32 *src = (Uint32 *)info->src;
  1400. Uint32 *dst = (Uint32 *)info->dst;
  1401. int n = info->dst_w;
  1402. while (n--) {
  1403. pixel = *src;
  1404. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1405. if (flags & SDL_COPY_MODULATE_COLOR) {
  1406. MULT_DIV_255(R, modulateR, R);
  1407. MULT_DIV_255(G, modulateG, G);
  1408. MULT_DIV_255(B, modulateB, B);
  1409. }
  1410. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  1411. *dst = pixel;
  1412. ++src;
  1413. ++dst;
  1414. }
  1415. info->src += info->src_pitch;
  1416. info->dst += info->dst_pitch;
  1417. }
  1418. }
  1419. static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  1420. {
  1421. const int flags = info->flags;
  1422. const Uint32 modulateR = info->r;
  1423. const Uint32 modulateG = info->g;
  1424. const Uint32 modulateB = info->b;
  1425. const Uint32 modulateA = info->a;
  1426. Uint32 pixel;
  1427. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1428. Uint32 R, G, B;
  1429. Uint64 srcy, srcx;
  1430. Uint64 posy, posx;
  1431. Uint64 incy, incx;
  1432. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1433. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1434. posy = incy / 2;
  1435. while (info->dst_h--) {
  1436. Uint32 *src = 0;
  1437. Uint32 *dst = (Uint32 *)info->dst;
  1438. int n = info->dst_w;
  1439. posx = incx / 2;
  1440. srcy = posy >> 16;
  1441. while (n--) {
  1442. srcx = posx >> 16;
  1443. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1444. pixel = *src;
  1445. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1446. if (flags & SDL_COPY_MODULATE_COLOR) {
  1447. MULT_DIV_255(R, modulateR, R);
  1448. MULT_DIV_255(G, modulateG, G);
  1449. MULT_DIV_255(B, modulateB, B);
  1450. }
  1451. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  1452. *dst = pixel;
  1453. posx += incx;
  1454. ++dst;
  1455. }
  1456. posy += incy;
  1457. info->dst += info->dst_pitch;
  1458. }
  1459. }
  1460. static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  1461. {
  1462. const int flags = info->flags;
  1463. const Uint32 modulateR = info->r;
  1464. const Uint32 modulateG = info->g;
  1465. const Uint32 modulateB = info->b;
  1466. const Uint32 modulateA = info->a;
  1467. Uint32 srcpixel;
  1468. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1469. Uint32 srcR, srcG, srcB;
  1470. Uint32 dstpixel;
  1471. Uint32 dstR, dstG, dstB, dstA;
  1472. while (info->dst_h--) {
  1473. Uint32 *src = (Uint32 *)info->src;
  1474. Uint32 *dst = (Uint32 *)info->dst;
  1475. int n = info->dst_w;
  1476. while (n--) {
  1477. srcpixel = *src;
  1478. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1479. dstpixel = *dst;
  1480. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1481. if (flags & SDL_COPY_MODULATE_COLOR) {
  1482. MULT_DIV_255(srcR, modulateR, srcR);
  1483. MULT_DIV_255(srcG, modulateG, srcG);
  1484. MULT_DIV_255(srcB, modulateB, srcB);
  1485. }
  1486. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1487. if (srcA < 255) {
  1488. MULT_DIV_255(srcR, srcA, srcR);
  1489. MULT_DIV_255(srcG, srcA, srcG);
  1490. MULT_DIV_255(srcB, srcA, srcB);
  1491. }
  1492. }
  1493. switch (flags & SDL_COPY_BLEND_MASK) {
  1494. case SDL_COPY_BLEND:
  1495. MULT_DIV_255((255 - srcA), dstR, dstR);
  1496. dstR += srcR;
  1497. MULT_DIV_255((255 - srcA), dstG, dstG);
  1498. dstG += srcG;
  1499. MULT_DIV_255((255 - srcA), dstB, dstB);
  1500. dstB += srcB;
  1501. MULT_DIV_255((255 - srcA), dstA, dstA);
  1502. dstA += srcA;
  1503. break;
  1504. case SDL_COPY_BLEND_PREMULTIPLIED:
  1505. MULT_DIV_255((255 - srcA), dstR, dstR);
  1506. dstR += srcR;
  1507. if (dstR > 255) dstR = 255;
  1508. MULT_DIV_255((255 - srcA), dstG, dstG);
  1509. dstG += srcG;
  1510. if (dstG > 255) dstG = 255;
  1511. MULT_DIV_255((255 - srcA), dstB, dstB);
  1512. dstB += srcB;
  1513. if (dstB > 255) dstB = 255;
  1514. MULT_DIV_255((255 - srcA), dstA, dstA);
  1515. dstA += srcA;
  1516. if (dstA > 255) dstA = 255;
  1517. break;
  1518. case SDL_COPY_ADD:
  1519. case SDL_COPY_ADD_PREMULTIPLIED:
  1520. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1521. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1522. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1523. break;
  1524. case SDL_COPY_MOD:
  1525. MULT_DIV_255(srcR, dstR, dstR);
  1526. MULT_DIV_255(srcG, dstG, dstG);
  1527. MULT_DIV_255(srcB, dstB, dstB);
  1528. break;
  1529. case SDL_COPY_MUL:
  1530. {
  1531. Uint32 tmp1, tmp2;
  1532. MULT_DIV_255(srcR, dstR, tmp1);
  1533. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1534. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1535. MULT_DIV_255(srcG, dstG, tmp1);
  1536. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1537. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1538. MULT_DIV_255(srcB, dstB, tmp1);
  1539. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1540. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1541. }
  1542. break;
  1543. }
  1544. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  1545. *dst = dstpixel;
  1546. ++src;
  1547. ++dst;
  1548. }
  1549. info->src += info->src_pitch;
  1550. info->dst += info->dst_pitch;
  1551. }
  1552. }
  1553. static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1554. {
  1555. const int flags = info->flags;
  1556. const Uint32 modulateR = info->r;
  1557. const Uint32 modulateG = info->g;
  1558. const Uint32 modulateB = info->b;
  1559. const Uint32 modulateA = info->a;
  1560. Uint32 srcpixel;
  1561. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1562. Uint32 srcR, srcG, srcB;
  1563. Uint32 dstpixel;
  1564. Uint32 dstR, dstG, dstB, dstA;
  1565. Uint64 srcy, srcx;
  1566. Uint64 posy, posx;
  1567. Uint64 incy, incx;
  1568. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1569. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1570. posy = incy / 2;
  1571. while (info->dst_h--) {
  1572. Uint32 *src = 0;
  1573. Uint32 *dst = (Uint32 *)info->dst;
  1574. int n = info->dst_w;
  1575. posx = incx / 2;
  1576. srcy = posy >> 16;
  1577. while (n--) {
  1578. srcx = posx >> 16;
  1579. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1580. srcpixel = *src;
  1581. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1582. dstpixel = *dst;
  1583. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1584. if (flags & SDL_COPY_MODULATE_COLOR) {
  1585. MULT_DIV_255(srcR, modulateR, srcR);
  1586. MULT_DIV_255(srcG, modulateG, srcG);
  1587. MULT_DIV_255(srcB, modulateB, srcB);
  1588. }
  1589. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1590. if (srcA < 255) {
  1591. MULT_DIV_255(srcR, srcA, srcR);
  1592. MULT_DIV_255(srcG, srcA, srcG);
  1593. MULT_DIV_255(srcB, srcA, srcB);
  1594. }
  1595. }
  1596. switch (flags & SDL_COPY_BLEND_MASK) {
  1597. case SDL_COPY_BLEND:
  1598. MULT_DIV_255((255 - srcA), dstR, dstR);
  1599. dstR += srcR;
  1600. MULT_DIV_255((255 - srcA), dstG, dstG);
  1601. dstG += srcG;
  1602. MULT_DIV_255((255 - srcA), dstB, dstB);
  1603. dstB += srcB;
  1604. MULT_DIV_255((255 - srcA), dstA, dstA);
  1605. dstA += srcA;
  1606. break;
  1607. case SDL_COPY_BLEND_PREMULTIPLIED:
  1608. MULT_DIV_255((255 - srcA), dstR, dstR);
  1609. dstR += srcR;
  1610. if (dstR > 255) dstR = 255;
  1611. MULT_DIV_255((255 - srcA), dstG, dstG);
  1612. dstG += srcG;
  1613. if (dstG > 255) dstG = 255;
  1614. MULT_DIV_255((255 - srcA), dstB, dstB);
  1615. dstB += srcB;
  1616. if (dstB > 255) dstB = 255;
  1617. MULT_DIV_255((255 - srcA), dstA, dstA);
  1618. dstA += srcA;
  1619. if (dstA > 255) dstA = 255;
  1620. break;
  1621. case SDL_COPY_ADD:
  1622. case SDL_COPY_ADD_PREMULTIPLIED:
  1623. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1624. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1625. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1626. break;
  1627. case SDL_COPY_MOD:
  1628. MULT_DIV_255(srcR, dstR, dstR);
  1629. MULT_DIV_255(srcG, dstG, dstG);
  1630. MULT_DIV_255(srcB, dstB, dstB);
  1631. break;
  1632. case SDL_COPY_MUL:
  1633. {
  1634. Uint32 tmp1, tmp2;
  1635. MULT_DIV_255(srcR, dstR, tmp1);
  1636. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1637. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1638. MULT_DIV_255(srcG, dstG, tmp1);
  1639. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1640. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1641. MULT_DIV_255(srcB, dstB, tmp1);
  1642. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1643. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1644. }
  1645. break;
  1646. }
  1647. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  1648. *dst = dstpixel;
  1649. posx += incx;
  1650. ++dst;
  1651. }
  1652. posy += incy;
  1653. info->dst += info->dst_pitch;
  1654. }
  1655. }
  1656. static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
  1657. {
  1658. Uint32 pixel;
  1659. Uint32 R, G, B;
  1660. Uint64 srcy, srcx;
  1661. Uint64 posy, posx;
  1662. Uint64 incy, incx;
  1663. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1664. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1665. posy = incy / 2;
  1666. while (info->dst_h--) {
  1667. Uint32 *src = 0;
  1668. Uint32 *dst = (Uint32 *)info->dst;
  1669. int n = info->dst_w;
  1670. posx = incx / 2;
  1671. srcy = posy >> 16;
  1672. while (n--) {
  1673. srcx = posx >> 16;
  1674. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1675. pixel = *src;
  1676. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1677. pixel = (R << 16) | (G << 8) | B;
  1678. *dst = pixel;
  1679. posx += incx;
  1680. ++dst;
  1681. }
  1682. posy += incy;
  1683. info->dst += info->dst_pitch;
  1684. }
  1685. }
  1686. static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
  1687. {
  1688. const int flags = info->flags;
  1689. Uint32 srcpixel;
  1690. Uint32 srcR, srcG, srcB;
  1691. Uint32 dstpixel;
  1692. Uint32 dstR, dstG, dstB;
  1693. while (info->dst_h--) {
  1694. Uint32 *src = (Uint32 *)info->src;
  1695. Uint32 *dst = (Uint32 *)info->dst;
  1696. int n = info->dst_w;
  1697. while (n--) {
  1698. srcpixel = *src;
  1699. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1700. dstpixel = *dst;
  1701. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1702. switch (flags & SDL_COPY_BLEND_MASK) {
  1703. case SDL_COPY_BLEND:
  1704. dstR = srcR;
  1705. dstG = srcG;
  1706. dstB = srcB;
  1707. break;
  1708. case SDL_COPY_BLEND_PREMULTIPLIED:
  1709. dstR = srcR;
  1710. dstG = srcG;
  1711. dstB = srcB;
  1712. break;
  1713. case SDL_COPY_ADD:
  1714. case SDL_COPY_ADD_PREMULTIPLIED:
  1715. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1716. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1717. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1718. break;
  1719. case SDL_COPY_MOD:
  1720. MULT_DIV_255(srcR, dstR, dstR);
  1721. MULT_DIV_255(srcG, dstG, dstG);
  1722. MULT_DIV_255(srcB, dstB, dstB);
  1723. break;
  1724. case SDL_COPY_MUL:
  1725. MULT_DIV_255(srcR, dstR, dstR);
  1726. MULT_DIV_255(srcG, dstG, dstG);
  1727. MULT_DIV_255(srcB, dstB, dstB);
  1728. break;
  1729. }
  1730. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1731. *dst = dstpixel;
  1732. ++src;
  1733. ++dst;
  1734. }
  1735. info->src += info->src_pitch;
  1736. info->dst += info->dst_pitch;
  1737. }
  1738. }
  1739. static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  1740. {
  1741. const int flags = info->flags;
  1742. Uint32 srcpixel;
  1743. Uint32 srcR, srcG, srcB;
  1744. Uint32 dstpixel;
  1745. Uint32 dstR, dstG, dstB;
  1746. Uint64 srcy, srcx;
  1747. Uint64 posy, posx;
  1748. Uint64 incy, incx;
  1749. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1750. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1751. posy = incy / 2;
  1752. while (info->dst_h--) {
  1753. Uint32 *src = 0;
  1754. Uint32 *dst = (Uint32 *)info->dst;
  1755. int n = info->dst_w;
  1756. posx = incx / 2;
  1757. srcy = posy >> 16;
  1758. while (n--) {
  1759. srcx = posx >> 16;
  1760. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1761. srcpixel = *src;
  1762. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1763. dstpixel = *dst;
  1764. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1765. switch (flags & SDL_COPY_BLEND_MASK) {
  1766. case SDL_COPY_BLEND:
  1767. dstR = srcR;
  1768. dstG = srcG;
  1769. dstB = srcB;
  1770. break;
  1771. case SDL_COPY_BLEND_PREMULTIPLIED:
  1772. dstR = srcR;
  1773. dstG = srcG;
  1774. dstB = srcB;
  1775. break;
  1776. case SDL_COPY_ADD:
  1777. case SDL_COPY_ADD_PREMULTIPLIED:
  1778. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1779. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1780. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1781. break;
  1782. case SDL_COPY_MOD:
  1783. MULT_DIV_255(srcR, dstR, dstR);
  1784. MULT_DIV_255(srcG, dstG, dstG);
  1785. MULT_DIV_255(srcB, dstB, dstB);
  1786. break;
  1787. case SDL_COPY_MUL:
  1788. MULT_DIV_255(srcR, dstR, dstR);
  1789. MULT_DIV_255(srcG, dstG, dstG);
  1790. MULT_DIV_255(srcB, dstB, dstB);
  1791. break;
  1792. }
  1793. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1794. *dst = dstpixel;
  1795. posx += incx;
  1796. ++dst;
  1797. }
  1798. posy += incy;
  1799. info->dst += info->dst_pitch;
  1800. }
  1801. }
  1802. static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  1803. {
  1804. const int flags = info->flags;
  1805. const Uint32 modulateR = info->r;
  1806. const Uint32 modulateG = info->g;
  1807. const Uint32 modulateB = info->b;
  1808. Uint32 pixel;
  1809. Uint32 R, G, B;
  1810. while (info->dst_h--) {
  1811. Uint32 *src = (Uint32 *)info->src;
  1812. Uint32 *dst = (Uint32 *)info->dst;
  1813. int n = info->dst_w;
  1814. while (n--) {
  1815. pixel = *src;
  1816. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1817. if (flags & SDL_COPY_MODULATE_COLOR) {
  1818. MULT_DIV_255(R, modulateR, R);
  1819. MULT_DIV_255(G, modulateG, G);
  1820. MULT_DIV_255(B, modulateB, B);
  1821. }
  1822. pixel = (R << 16) | (G << 8) | B;
  1823. *dst = pixel;
  1824. ++src;
  1825. ++dst;
  1826. }
  1827. info->src += info->src_pitch;
  1828. info->dst += info->dst_pitch;
  1829. }
  1830. }
  1831. static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  1832. {
  1833. const int flags = info->flags;
  1834. const Uint32 modulateR = info->r;
  1835. const Uint32 modulateG = info->g;
  1836. const Uint32 modulateB = info->b;
  1837. Uint32 pixel;
  1838. Uint32 R, G, B;
  1839. Uint64 srcy, srcx;
  1840. Uint64 posy, posx;
  1841. Uint64 incy, incx;
  1842. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1843. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1844. posy = incy / 2;
  1845. while (info->dst_h--) {
  1846. Uint32 *src = 0;
  1847. Uint32 *dst = (Uint32 *)info->dst;
  1848. int n = info->dst_w;
  1849. posx = incx / 2;
  1850. srcy = posy >> 16;
  1851. while (n--) {
  1852. srcx = posx >> 16;
  1853. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1854. pixel = *src;
  1855. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1856. if (flags & SDL_COPY_MODULATE_COLOR) {
  1857. MULT_DIV_255(R, modulateR, R);
  1858. MULT_DIV_255(G, modulateG, G);
  1859. MULT_DIV_255(B, modulateB, B);
  1860. }
  1861. pixel = (R << 16) | (G << 8) | B;
  1862. *dst = pixel;
  1863. posx += incx;
  1864. ++dst;
  1865. }
  1866. posy += incy;
  1867. info->dst += info->dst_pitch;
  1868. }
  1869. }
  1870. static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1871. {
  1872. const int flags = info->flags;
  1873. const Uint32 modulateR = info->r;
  1874. const Uint32 modulateG = info->g;
  1875. const Uint32 modulateB = info->b;
  1876. const Uint32 modulateA = info->a;
  1877. Uint32 srcpixel;
  1878. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1879. Uint32 srcR, srcG, srcB;
  1880. Uint32 dstpixel;
  1881. Uint32 dstR, dstG, dstB;
  1882. while (info->dst_h--) {
  1883. Uint32 *src = (Uint32 *)info->src;
  1884. Uint32 *dst = (Uint32 *)info->dst;
  1885. int n = info->dst_w;
  1886. while (n--) {
  1887. srcpixel = *src;
  1888. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1889. dstpixel = *dst;
  1890. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1891. if (flags & SDL_COPY_MODULATE_COLOR) {
  1892. MULT_DIV_255(srcR, modulateR, srcR);
  1893. MULT_DIV_255(srcG, modulateG, srcG);
  1894. MULT_DIV_255(srcB, modulateB, srcB);
  1895. }
  1896. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1897. if (srcA < 255) {
  1898. MULT_DIV_255(srcR, srcA, srcR);
  1899. MULT_DIV_255(srcG, srcA, srcG);
  1900. MULT_DIV_255(srcB, srcA, srcB);
  1901. }
  1902. }
  1903. switch (flags & SDL_COPY_BLEND_MASK) {
  1904. case SDL_COPY_BLEND:
  1905. MULT_DIV_255((255 - srcA), dstR, dstR);
  1906. dstR += srcR;
  1907. MULT_DIV_255((255 - srcA), dstG, dstG);
  1908. dstG += srcG;
  1909. MULT_DIV_255((255 - srcA), dstB, dstB);
  1910. dstB += srcB;
  1911. break;
  1912. case SDL_COPY_BLEND_PREMULTIPLIED:
  1913. MULT_DIV_255((255 - srcA), dstR, dstR);
  1914. dstR += srcR;
  1915. if (dstR > 255) dstR = 255;
  1916. MULT_DIV_255((255 - srcA), dstG, dstG);
  1917. dstG += srcG;
  1918. if (dstG > 255) dstG = 255;
  1919. MULT_DIV_255((255 - srcA), dstB, dstB);
  1920. dstB += srcB;
  1921. if (dstB > 255) dstB = 255;
  1922. break;
  1923. case SDL_COPY_ADD:
  1924. case SDL_COPY_ADD_PREMULTIPLIED:
  1925. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1926. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1927. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1928. break;
  1929. case SDL_COPY_MOD:
  1930. MULT_DIV_255(srcR, dstR, dstR);
  1931. MULT_DIV_255(srcG, dstG, dstG);
  1932. MULT_DIV_255(srcB, dstB, dstB);
  1933. break;
  1934. case SDL_COPY_MUL:
  1935. {
  1936. Uint32 tmp1, tmp2;
  1937. MULT_DIV_255(srcR, dstR, tmp1);
  1938. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  1939. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  1940. MULT_DIV_255(srcG, dstG, tmp1);
  1941. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  1942. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  1943. MULT_DIV_255(srcB, dstB, tmp1);
  1944. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  1945. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  1946. }
  1947. break;
  1948. }
  1949. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1950. *dst = dstpixel;
  1951. ++src;
  1952. ++dst;
  1953. }
  1954. info->src += info->src_pitch;
  1955. info->dst += info->dst_pitch;
  1956. }
  1957. }
  1958. static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1959. {
  1960. const int flags = info->flags;
  1961. const Uint32 modulateR = info->r;
  1962. const Uint32 modulateG = info->g;
  1963. const Uint32 modulateB = info->b;
  1964. const Uint32 modulateA = info->a;
  1965. Uint32 srcpixel;
  1966. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1967. Uint32 srcR, srcG, srcB;
  1968. Uint32 dstpixel;
  1969. Uint32 dstR, dstG, dstB;
  1970. Uint64 srcy, srcx;
  1971. Uint64 posy, posx;
  1972. Uint64 incy, incx;
  1973. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  1974. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  1975. posy = incy / 2;
  1976. while (info->dst_h--) {
  1977. Uint32 *src = 0;
  1978. Uint32 *dst = (Uint32 *)info->dst;
  1979. int n = info->dst_w;
  1980. posx = incx / 2;
  1981. srcy = posy >> 16;
  1982. while (n--) {
  1983. srcx = posx >> 16;
  1984. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1985. srcpixel = *src;
  1986. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1987. dstpixel = *dst;
  1988. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1989. if (flags & SDL_COPY_MODULATE_COLOR) {
  1990. MULT_DIV_255(srcR, modulateR, srcR);
  1991. MULT_DIV_255(srcG, modulateG, srcG);
  1992. MULT_DIV_255(srcB, modulateB, srcB);
  1993. }
  1994. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1995. if (srcA < 255) {
  1996. MULT_DIV_255(srcR, srcA, srcR);
  1997. MULT_DIV_255(srcG, srcA, srcG);
  1998. MULT_DIV_255(srcB, srcA, srcB);
  1999. }
  2000. }
  2001. switch (flags & SDL_COPY_BLEND_MASK) {
  2002. case SDL_COPY_BLEND:
  2003. MULT_DIV_255((255 - srcA), dstR, dstR);
  2004. dstR += srcR;
  2005. MULT_DIV_255((255 - srcA), dstG, dstG);
  2006. dstG += srcG;
  2007. MULT_DIV_255((255 - srcA), dstB, dstB);
  2008. dstB += srcB;
  2009. break;
  2010. case SDL_COPY_BLEND_PREMULTIPLIED:
  2011. MULT_DIV_255((255 - srcA), dstR, dstR);
  2012. dstR += srcR;
  2013. if (dstR > 255) dstR = 255;
  2014. MULT_DIV_255((255 - srcA), dstG, dstG);
  2015. dstG += srcG;
  2016. if (dstG > 255) dstG = 255;
  2017. MULT_DIV_255((255 - srcA), dstB, dstB);
  2018. dstB += srcB;
  2019. if (dstB > 255) dstB = 255;
  2020. break;
  2021. case SDL_COPY_ADD:
  2022. case SDL_COPY_ADD_PREMULTIPLIED:
  2023. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2024. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2025. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2026. break;
  2027. case SDL_COPY_MOD:
  2028. MULT_DIV_255(srcR, dstR, dstR);
  2029. MULT_DIV_255(srcG, dstG, dstG);
  2030. MULT_DIV_255(srcB, dstB, dstB);
  2031. break;
  2032. case SDL_COPY_MUL:
  2033. {
  2034. Uint32 tmp1, tmp2;
  2035. MULT_DIV_255(srcR, dstR, tmp1);
  2036. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2037. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2038. MULT_DIV_255(srcG, dstG, tmp1);
  2039. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2040. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2041. MULT_DIV_255(srcB, dstB, tmp1);
  2042. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2043. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2044. }
  2045. break;
  2046. }
  2047. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  2048. *dst = dstpixel;
  2049. posx += incx;
  2050. ++dst;
  2051. }
  2052. posy += incy;
  2053. info->dst += info->dst_pitch;
  2054. }
  2055. }
  2056. static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
  2057. {
  2058. Uint64 srcy, srcx;
  2059. Uint64 posy, posx;
  2060. Uint64 incy, incx;
  2061. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2062. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2063. posy = incy / 2;
  2064. while (info->dst_h--) {
  2065. Uint32 *src = 0;
  2066. Uint32 *dst = (Uint32 *)info->dst;
  2067. int n = info->dst_w;
  2068. posx = incx / 2;
  2069. srcy = posy >> 16;
  2070. while (n--) {
  2071. srcx = posx >> 16;
  2072. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2073. *dst = *src;
  2074. posx += incx;
  2075. ++dst;
  2076. }
  2077. posy += incy;
  2078. info->dst += info->dst_pitch;
  2079. }
  2080. }
  2081. static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
  2082. {
  2083. const int flags = info->flags;
  2084. Uint32 srcpixel;
  2085. Uint32 srcR, srcG, srcB;
  2086. Uint32 dstpixel;
  2087. Uint32 dstR, dstG, dstB;
  2088. while (info->dst_h--) {
  2089. Uint32 *src = (Uint32 *)info->src;
  2090. Uint32 *dst = (Uint32 *)info->dst;
  2091. int n = info->dst_w;
  2092. while (n--) {
  2093. srcpixel = *src;
  2094. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2095. dstpixel = *dst;
  2096. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2097. switch (flags & SDL_COPY_BLEND_MASK) {
  2098. case SDL_COPY_BLEND:
  2099. dstR = srcR;
  2100. dstG = srcG;
  2101. dstB = srcB;
  2102. break;
  2103. case SDL_COPY_BLEND_PREMULTIPLIED:
  2104. dstR = srcR;
  2105. dstG = srcG;
  2106. dstB = srcB;
  2107. break;
  2108. case SDL_COPY_ADD:
  2109. case SDL_COPY_ADD_PREMULTIPLIED:
  2110. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2111. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2112. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2113. break;
  2114. case SDL_COPY_MOD:
  2115. MULT_DIV_255(srcR, dstR, dstR);
  2116. MULT_DIV_255(srcG, dstG, dstG);
  2117. MULT_DIV_255(srcB, dstB, dstB);
  2118. break;
  2119. case SDL_COPY_MUL:
  2120. MULT_DIV_255(srcR, dstR, dstR);
  2121. MULT_DIV_255(srcG, dstG, dstG);
  2122. MULT_DIV_255(srcB, dstB, dstB);
  2123. break;
  2124. }
  2125. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2126. *dst = dstpixel;
  2127. ++src;
  2128. ++dst;
  2129. }
  2130. info->src += info->src_pitch;
  2131. info->dst += info->dst_pitch;
  2132. }
  2133. }
  2134. static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  2135. {
  2136. const int flags = info->flags;
  2137. Uint32 srcpixel;
  2138. Uint32 srcR, srcG, srcB;
  2139. Uint32 dstpixel;
  2140. Uint32 dstR, dstG, dstB;
  2141. Uint64 srcy, srcx;
  2142. Uint64 posy, posx;
  2143. Uint64 incy, incx;
  2144. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2145. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2146. posy = incy / 2;
  2147. while (info->dst_h--) {
  2148. Uint32 *src = 0;
  2149. Uint32 *dst = (Uint32 *)info->dst;
  2150. int n = info->dst_w;
  2151. posx = incx / 2;
  2152. srcy = posy >> 16;
  2153. while (n--) {
  2154. srcx = posx >> 16;
  2155. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2156. srcpixel = *src;
  2157. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2158. dstpixel = *dst;
  2159. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2160. switch (flags & SDL_COPY_BLEND_MASK) {
  2161. case SDL_COPY_BLEND:
  2162. dstR = srcR;
  2163. dstG = srcG;
  2164. dstB = srcB;
  2165. break;
  2166. case SDL_COPY_BLEND_PREMULTIPLIED:
  2167. dstR = srcR;
  2168. dstG = srcG;
  2169. dstB = srcB;
  2170. break;
  2171. case SDL_COPY_ADD:
  2172. case SDL_COPY_ADD_PREMULTIPLIED:
  2173. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2174. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2175. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2176. break;
  2177. case SDL_COPY_MOD:
  2178. MULT_DIV_255(srcR, dstR, dstR);
  2179. MULT_DIV_255(srcG, dstG, dstG);
  2180. MULT_DIV_255(srcB, dstB, dstB);
  2181. break;
  2182. case SDL_COPY_MUL:
  2183. MULT_DIV_255(srcR, dstR, dstR);
  2184. MULT_DIV_255(srcG, dstG, dstG);
  2185. MULT_DIV_255(srcB, dstB, dstB);
  2186. break;
  2187. }
  2188. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2189. *dst = dstpixel;
  2190. posx += incx;
  2191. ++dst;
  2192. }
  2193. posy += incy;
  2194. info->dst += info->dst_pitch;
  2195. }
  2196. }
  2197. static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  2198. {
  2199. const int flags = info->flags;
  2200. const Uint32 modulateR = info->r;
  2201. const Uint32 modulateG = info->g;
  2202. const Uint32 modulateB = info->b;
  2203. Uint32 pixel;
  2204. Uint32 R, G, B;
  2205. while (info->dst_h--) {
  2206. Uint32 *src = (Uint32 *)info->src;
  2207. Uint32 *dst = (Uint32 *)info->dst;
  2208. int n = info->dst_w;
  2209. while (n--) {
  2210. pixel = *src;
  2211. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2212. if (flags & SDL_COPY_MODULATE_COLOR) {
  2213. MULT_DIV_255(R, modulateR, R);
  2214. MULT_DIV_255(G, modulateG, G);
  2215. MULT_DIV_255(B, modulateB, B);
  2216. }
  2217. pixel = (B << 16) | (G << 8) | R;
  2218. *dst = pixel;
  2219. ++src;
  2220. ++dst;
  2221. }
  2222. info->src += info->src_pitch;
  2223. info->dst += info->dst_pitch;
  2224. }
  2225. }
  2226. static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  2227. {
  2228. const int flags = info->flags;
  2229. const Uint32 modulateR = info->r;
  2230. const Uint32 modulateG = info->g;
  2231. const Uint32 modulateB = info->b;
  2232. Uint32 pixel;
  2233. Uint32 R, G, B;
  2234. Uint64 srcy, srcx;
  2235. Uint64 posy, posx;
  2236. Uint64 incy, incx;
  2237. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2238. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2239. posy = incy / 2;
  2240. while (info->dst_h--) {
  2241. Uint32 *src = 0;
  2242. Uint32 *dst = (Uint32 *)info->dst;
  2243. int n = info->dst_w;
  2244. posx = incx / 2;
  2245. srcy = posy >> 16;
  2246. while (n--) {
  2247. srcx = posx >> 16;
  2248. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2249. pixel = *src;
  2250. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2251. if (flags & SDL_COPY_MODULATE_COLOR) {
  2252. MULT_DIV_255(R, modulateR, R);
  2253. MULT_DIV_255(G, modulateG, G);
  2254. MULT_DIV_255(B, modulateB, B);
  2255. }
  2256. pixel = (B << 16) | (G << 8) | R;
  2257. *dst = pixel;
  2258. posx += incx;
  2259. ++dst;
  2260. }
  2261. posy += incy;
  2262. info->dst += info->dst_pitch;
  2263. }
  2264. }
  2265. static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  2266. {
  2267. const int flags = info->flags;
  2268. const Uint32 modulateR = info->r;
  2269. const Uint32 modulateG = info->g;
  2270. const Uint32 modulateB = info->b;
  2271. const Uint32 modulateA = info->a;
  2272. Uint32 srcpixel;
  2273. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2274. Uint32 srcR, srcG, srcB;
  2275. Uint32 dstpixel;
  2276. Uint32 dstR, dstG, dstB;
  2277. while (info->dst_h--) {
  2278. Uint32 *src = (Uint32 *)info->src;
  2279. Uint32 *dst = (Uint32 *)info->dst;
  2280. int n = info->dst_w;
  2281. while (n--) {
  2282. srcpixel = *src;
  2283. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2284. dstpixel = *dst;
  2285. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2286. if (flags & SDL_COPY_MODULATE_COLOR) {
  2287. MULT_DIV_255(srcR, modulateR, srcR);
  2288. MULT_DIV_255(srcG, modulateG, srcG);
  2289. MULT_DIV_255(srcB, modulateB, srcB);
  2290. }
  2291. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2292. if (srcA < 255) {
  2293. MULT_DIV_255(srcR, srcA, srcR);
  2294. MULT_DIV_255(srcG, srcA, srcG);
  2295. MULT_DIV_255(srcB, srcA, srcB);
  2296. }
  2297. }
  2298. switch (flags & SDL_COPY_BLEND_MASK) {
  2299. case SDL_COPY_BLEND:
  2300. MULT_DIV_255((255 - srcA), dstR, dstR);
  2301. dstR += srcR;
  2302. MULT_DIV_255((255 - srcA), dstG, dstG);
  2303. dstG += srcG;
  2304. MULT_DIV_255((255 - srcA), dstB, dstB);
  2305. dstB += srcB;
  2306. break;
  2307. case SDL_COPY_BLEND_PREMULTIPLIED:
  2308. MULT_DIV_255((255 - srcA), dstR, dstR);
  2309. dstR += srcR;
  2310. if (dstR > 255) dstR = 255;
  2311. MULT_DIV_255((255 - srcA), dstG, dstG);
  2312. dstG += srcG;
  2313. if (dstG > 255) dstG = 255;
  2314. MULT_DIV_255((255 - srcA), dstB, dstB);
  2315. dstB += srcB;
  2316. if (dstB > 255) dstB = 255;
  2317. break;
  2318. case SDL_COPY_ADD:
  2319. case SDL_COPY_ADD_PREMULTIPLIED:
  2320. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2321. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2322. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2323. break;
  2324. case SDL_COPY_MOD:
  2325. MULT_DIV_255(srcR, dstR, dstR);
  2326. MULT_DIV_255(srcG, dstG, dstG);
  2327. MULT_DIV_255(srcB, dstB, dstB);
  2328. break;
  2329. case SDL_COPY_MUL:
  2330. {
  2331. Uint32 tmp1, tmp2;
  2332. MULT_DIV_255(srcR, dstR, tmp1);
  2333. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2334. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2335. MULT_DIV_255(srcG, dstG, tmp1);
  2336. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2337. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2338. MULT_DIV_255(srcB, dstB, tmp1);
  2339. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2340. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2341. }
  2342. break;
  2343. }
  2344. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2345. *dst = dstpixel;
  2346. ++src;
  2347. ++dst;
  2348. }
  2349. info->src += info->src_pitch;
  2350. info->dst += info->dst_pitch;
  2351. }
  2352. }
  2353. static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  2354. {
  2355. const int flags = info->flags;
  2356. const Uint32 modulateR = info->r;
  2357. const Uint32 modulateG = info->g;
  2358. const Uint32 modulateB = info->b;
  2359. const Uint32 modulateA = info->a;
  2360. Uint32 srcpixel;
  2361. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2362. Uint32 srcR, srcG, srcB;
  2363. Uint32 dstpixel;
  2364. Uint32 dstR, dstG, dstB;
  2365. Uint64 srcy, srcx;
  2366. Uint64 posy, posx;
  2367. Uint64 incy, incx;
  2368. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2369. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2370. posy = incy / 2;
  2371. while (info->dst_h--) {
  2372. Uint32 *src = 0;
  2373. Uint32 *dst = (Uint32 *)info->dst;
  2374. int n = info->dst_w;
  2375. posx = incx / 2;
  2376. srcy = posy >> 16;
  2377. while (n--) {
  2378. srcx = posx >> 16;
  2379. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2380. srcpixel = *src;
  2381. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2382. dstpixel = *dst;
  2383. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2384. if (flags & SDL_COPY_MODULATE_COLOR) {
  2385. MULT_DIV_255(srcR, modulateR, srcR);
  2386. MULT_DIV_255(srcG, modulateG, srcG);
  2387. MULT_DIV_255(srcB, modulateB, srcB);
  2388. }
  2389. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2390. if (srcA < 255) {
  2391. MULT_DIV_255(srcR, srcA, srcR);
  2392. MULT_DIV_255(srcG, srcA, srcG);
  2393. MULT_DIV_255(srcB, srcA, srcB);
  2394. }
  2395. }
  2396. switch (flags & SDL_COPY_BLEND_MASK) {
  2397. case SDL_COPY_BLEND:
  2398. MULT_DIV_255((255 - srcA), dstR, dstR);
  2399. dstR += srcR;
  2400. MULT_DIV_255((255 - srcA), dstG, dstG);
  2401. dstG += srcG;
  2402. MULT_DIV_255((255 - srcA), dstB, dstB);
  2403. dstB += srcB;
  2404. break;
  2405. case SDL_COPY_BLEND_PREMULTIPLIED:
  2406. MULT_DIV_255((255 - srcA), dstR, dstR);
  2407. dstR += srcR;
  2408. if (dstR > 255) dstR = 255;
  2409. MULT_DIV_255((255 - srcA), dstG, dstG);
  2410. dstG += srcG;
  2411. if (dstG > 255) dstG = 255;
  2412. MULT_DIV_255((255 - srcA), dstB, dstB);
  2413. dstB += srcB;
  2414. if (dstB > 255) dstB = 255;
  2415. break;
  2416. case SDL_COPY_ADD:
  2417. case SDL_COPY_ADD_PREMULTIPLIED:
  2418. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2419. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2420. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2421. break;
  2422. case SDL_COPY_MOD:
  2423. MULT_DIV_255(srcR, dstR, dstR);
  2424. MULT_DIV_255(srcG, dstG, dstG);
  2425. MULT_DIV_255(srcB, dstB, dstB);
  2426. break;
  2427. case SDL_COPY_MUL:
  2428. {
  2429. Uint32 tmp1, tmp2;
  2430. MULT_DIV_255(srcR, dstR, tmp1);
  2431. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2432. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2433. MULT_DIV_255(srcG, dstG, tmp1);
  2434. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2435. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2436. MULT_DIV_255(srcB, dstB, tmp1);
  2437. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2438. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2439. }
  2440. break;
  2441. }
  2442. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2443. *dst = dstpixel;
  2444. posx += incx;
  2445. ++dst;
  2446. }
  2447. posy += incy;
  2448. info->dst += info->dst_pitch;
  2449. }
  2450. }
  2451. static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
  2452. {
  2453. Uint32 pixel;
  2454. const Uint32 A = 0xFF;
  2455. Uint32 R, G, B;
  2456. Uint64 srcy, srcx;
  2457. Uint64 posy, posx;
  2458. Uint64 incy, incx;
  2459. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2460. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2461. posy = incy / 2;
  2462. while (info->dst_h--) {
  2463. Uint32 *src = 0;
  2464. Uint32 *dst = (Uint32 *)info->dst;
  2465. int n = info->dst_w;
  2466. posx = incx / 2;
  2467. srcy = posy >> 16;
  2468. while (n--) {
  2469. srcx = posx >> 16;
  2470. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2471. pixel = *src;
  2472. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2473. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  2474. *dst = pixel;
  2475. posx += incx;
  2476. ++dst;
  2477. }
  2478. posy += incy;
  2479. info->dst += info->dst_pitch;
  2480. }
  2481. }
  2482. static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
  2483. {
  2484. const int flags = info->flags;
  2485. Uint32 srcpixel;
  2486. Uint32 srcR, srcG, srcB;
  2487. Uint32 dstpixel;
  2488. Uint32 dstR, dstG, dstB, dstA;
  2489. while (info->dst_h--) {
  2490. Uint32 *src = (Uint32 *)info->src;
  2491. Uint32 *dst = (Uint32 *)info->dst;
  2492. int n = info->dst_w;
  2493. while (n--) {
  2494. srcpixel = *src;
  2495. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2496. dstpixel = *dst;
  2497. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2498. switch (flags & SDL_COPY_BLEND_MASK) {
  2499. case SDL_COPY_BLEND:
  2500. dstR = srcR;
  2501. dstG = srcG;
  2502. dstB = srcB;
  2503. dstA = 0xFF;
  2504. break;
  2505. case SDL_COPY_BLEND_PREMULTIPLIED:
  2506. dstR = srcR;
  2507. dstG = srcG;
  2508. dstB = srcB;
  2509. dstA = 0xFF;
  2510. break;
  2511. case SDL_COPY_ADD:
  2512. case SDL_COPY_ADD_PREMULTIPLIED:
  2513. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2514. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2515. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2516. break;
  2517. case SDL_COPY_MOD:
  2518. MULT_DIV_255(srcR, dstR, dstR);
  2519. MULT_DIV_255(srcG, dstG, dstG);
  2520. MULT_DIV_255(srcB, dstB, dstB);
  2521. break;
  2522. case SDL_COPY_MUL:
  2523. MULT_DIV_255(srcR, dstR, dstR);
  2524. MULT_DIV_255(srcG, dstG, dstG);
  2525. MULT_DIV_255(srcB, dstB, dstB);
  2526. break;
  2527. }
  2528. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2529. *dst = dstpixel;
  2530. ++src;
  2531. ++dst;
  2532. }
  2533. info->src += info->src_pitch;
  2534. info->dst += info->dst_pitch;
  2535. }
  2536. }
  2537. static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  2538. {
  2539. const int flags = info->flags;
  2540. Uint32 srcpixel;
  2541. Uint32 srcR, srcG, srcB;
  2542. Uint32 dstpixel;
  2543. Uint32 dstR, dstG, dstB, dstA;
  2544. Uint64 srcy, srcx;
  2545. Uint64 posy, posx;
  2546. Uint64 incy, incx;
  2547. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2548. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2549. posy = incy / 2;
  2550. while (info->dst_h--) {
  2551. Uint32 *src = 0;
  2552. Uint32 *dst = (Uint32 *)info->dst;
  2553. int n = info->dst_w;
  2554. posx = incx / 2;
  2555. srcy = posy >> 16;
  2556. while (n--) {
  2557. srcx = posx >> 16;
  2558. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2559. srcpixel = *src;
  2560. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2561. dstpixel = *dst;
  2562. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2563. switch (flags & SDL_COPY_BLEND_MASK) {
  2564. case SDL_COPY_BLEND:
  2565. dstR = srcR;
  2566. dstG = srcG;
  2567. dstB = srcB;
  2568. dstA = 0xFF;
  2569. break;
  2570. case SDL_COPY_BLEND_PREMULTIPLIED:
  2571. dstR = srcR;
  2572. dstG = srcG;
  2573. dstB = srcB;
  2574. dstA = 0xFF;
  2575. break;
  2576. case SDL_COPY_ADD:
  2577. case SDL_COPY_ADD_PREMULTIPLIED:
  2578. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2579. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2580. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2581. break;
  2582. case SDL_COPY_MOD:
  2583. MULT_DIV_255(srcR, dstR, dstR);
  2584. MULT_DIV_255(srcG, dstG, dstG);
  2585. MULT_DIV_255(srcB, dstB, dstB);
  2586. break;
  2587. case SDL_COPY_MUL:
  2588. MULT_DIV_255(srcR, dstR, dstR);
  2589. MULT_DIV_255(srcG, dstG, dstG);
  2590. MULT_DIV_255(srcB, dstB, dstB);
  2591. break;
  2592. }
  2593. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2594. *dst = dstpixel;
  2595. posx += incx;
  2596. ++dst;
  2597. }
  2598. posy += incy;
  2599. info->dst += info->dst_pitch;
  2600. }
  2601. }
  2602. static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  2603. {
  2604. const int flags = info->flags;
  2605. const Uint32 modulateR = info->r;
  2606. const Uint32 modulateG = info->g;
  2607. const Uint32 modulateB = info->b;
  2608. const Uint32 modulateA = info->a;
  2609. Uint32 pixel;
  2610. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2611. Uint32 R, G, B;
  2612. while (info->dst_h--) {
  2613. Uint32 *src = (Uint32 *)info->src;
  2614. Uint32 *dst = (Uint32 *)info->dst;
  2615. int n = info->dst_w;
  2616. while (n--) {
  2617. pixel = *src;
  2618. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2619. if (flags & SDL_COPY_MODULATE_COLOR) {
  2620. MULT_DIV_255(R, modulateR, R);
  2621. MULT_DIV_255(G, modulateG, G);
  2622. MULT_DIV_255(B, modulateB, B);
  2623. }
  2624. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  2625. *dst = pixel;
  2626. ++src;
  2627. ++dst;
  2628. }
  2629. info->src += info->src_pitch;
  2630. info->dst += info->dst_pitch;
  2631. }
  2632. }
  2633. static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  2634. {
  2635. const int flags = info->flags;
  2636. const Uint32 modulateR = info->r;
  2637. const Uint32 modulateG = info->g;
  2638. const Uint32 modulateB = info->b;
  2639. const Uint32 modulateA = info->a;
  2640. Uint32 pixel;
  2641. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2642. Uint32 R, G, B;
  2643. Uint64 srcy, srcx;
  2644. Uint64 posy, posx;
  2645. Uint64 incy, incx;
  2646. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2647. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2648. posy = incy / 2;
  2649. while (info->dst_h--) {
  2650. Uint32 *src = 0;
  2651. Uint32 *dst = (Uint32 *)info->dst;
  2652. int n = info->dst_w;
  2653. posx = incx / 2;
  2654. srcy = posy >> 16;
  2655. while (n--) {
  2656. srcx = posx >> 16;
  2657. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2658. pixel = *src;
  2659. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2660. if (flags & SDL_COPY_MODULATE_COLOR) {
  2661. MULT_DIV_255(R, modulateR, R);
  2662. MULT_DIV_255(G, modulateG, G);
  2663. MULT_DIV_255(B, modulateB, B);
  2664. }
  2665. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  2666. *dst = pixel;
  2667. posx += incx;
  2668. ++dst;
  2669. }
  2670. posy += incy;
  2671. info->dst += info->dst_pitch;
  2672. }
  2673. }
  2674. static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  2675. {
  2676. const int flags = info->flags;
  2677. const Uint32 modulateR = info->r;
  2678. const Uint32 modulateG = info->g;
  2679. const Uint32 modulateB = info->b;
  2680. const Uint32 modulateA = info->a;
  2681. Uint32 srcpixel;
  2682. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2683. Uint32 srcR, srcG, srcB;
  2684. Uint32 dstpixel;
  2685. Uint32 dstR, dstG, dstB, dstA;
  2686. while (info->dst_h--) {
  2687. Uint32 *src = (Uint32 *)info->src;
  2688. Uint32 *dst = (Uint32 *)info->dst;
  2689. int n = info->dst_w;
  2690. while (n--) {
  2691. srcpixel = *src;
  2692. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2693. dstpixel = *dst;
  2694. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2695. if (flags & SDL_COPY_MODULATE_COLOR) {
  2696. MULT_DIV_255(srcR, modulateR, srcR);
  2697. MULT_DIV_255(srcG, modulateG, srcG);
  2698. MULT_DIV_255(srcB, modulateB, srcB);
  2699. }
  2700. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2701. if (srcA < 255) {
  2702. MULT_DIV_255(srcR, srcA, srcR);
  2703. MULT_DIV_255(srcG, srcA, srcG);
  2704. MULT_DIV_255(srcB, srcA, srcB);
  2705. }
  2706. }
  2707. switch (flags & SDL_COPY_BLEND_MASK) {
  2708. case SDL_COPY_BLEND:
  2709. MULT_DIV_255((255 - srcA), dstR, dstR);
  2710. dstR += srcR;
  2711. MULT_DIV_255((255 - srcA), dstG, dstG);
  2712. dstG += srcG;
  2713. MULT_DIV_255((255 - srcA), dstB, dstB);
  2714. dstB += srcB;
  2715. MULT_DIV_255((255 - srcA), dstA, dstA);
  2716. dstA += srcA;
  2717. break;
  2718. case SDL_COPY_BLEND_PREMULTIPLIED:
  2719. MULT_DIV_255((255 - srcA), dstR, dstR);
  2720. dstR += srcR;
  2721. if (dstR > 255) dstR = 255;
  2722. MULT_DIV_255((255 - srcA), dstG, dstG);
  2723. dstG += srcG;
  2724. if (dstG > 255) dstG = 255;
  2725. MULT_DIV_255((255 - srcA), dstB, dstB);
  2726. dstB += srcB;
  2727. if (dstB > 255) dstB = 255;
  2728. MULT_DIV_255((255 - srcA), dstA, dstA);
  2729. dstA += srcA;
  2730. if (dstA > 255) dstA = 255;
  2731. break;
  2732. case SDL_COPY_ADD:
  2733. case SDL_COPY_ADD_PREMULTIPLIED:
  2734. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2735. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2736. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2737. break;
  2738. case SDL_COPY_MOD:
  2739. MULT_DIV_255(srcR, dstR, dstR);
  2740. MULT_DIV_255(srcG, dstG, dstG);
  2741. MULT_DIV_255(srcB, dstB, dstB);
  2742. break;
  2743. case SDL_COPY_MUL:
  2744. {
  2745. Uint32 tmp1, tmp2;
  2746. MULT_DIV_255(srcR, dstR, tmp1);
  2747. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2748. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2749. MULT_DIV_255(srcG, dstG, tmp1);
  2750. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2751. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2752. MULT_DIV_255(srcB, dstB, tmp1);
  2753. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2754. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2755. }
  2756. break;
  2757. }
  2758. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2759. *dst = dstpixel;
  2760. ++src;
  2761. ++dst;
  2762. }
  2763. info->src += info->src_pitch;
  2764. info->dst += info->dst_pitch;
  2765. }
  2766. }
  2767. static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  2768. {
  2769. const int flags = info->flags;
  2770. const Uint32 modulateR = info->r;
  2771. const Uint32 modulateG = info->g;
  2772. const Uint32 modulateB = info->b;
  2773. const Uint32 modulateA = info->a;
  2774. Uint32 srcpixel;
  2775. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2776. Uint32 srcR, srcG, srcB;
  2777. Uint32 dstpixel;
  2778. Uint32 dstR, dstG, dstB, dstA;
  2779. Uint64 srcy, srcx;
  2780. Uint64 posy, posx;
  2781. Uint64 incy, incx;
  2782. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2783. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2784. posy = incy / 2;
  2785. while (info->dst_h--) {
  2786. Uint32 *src = 0;
  2787. Uint32 *dst = (Uint32 *)info->dst;
  2788. int n = info->dst_w;
  2789. posx = incx / 2;
  2790. srcy = posy >> 16;
  2791. while (n--) {
  2792. srcx = posx >> 16;
  2793. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2794. srcpixel = *src;
  2795. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2796. dstpixel = *dst;
  2797. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2798. if (flags & SDL_COPY_MODULATE_COLOR) {
  2799. MULT_DIV_255(srcR, modulateR, srcR);
  2800. MULT_DIV_255(srcG, modulateG, srcG);
  2801. MULT_DIV_255(srcB, modulateB, srcB);
  2802. }
  2803. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2804. if (srcA < 255) {
  2805. MULT_DIV_255(srcR, srcA, srcR);
  2806. MULT_DIV_255(srcG, srcA, srcG);
  2807. MULT_DIV_255(srcB, srcA, srcB);
  2808. }
  2809. }
  2810. switch (flags & SDL_COPY_BLEND_MASK) {
  2811. case SDL_COPY_BLEND:
  2812. MULT_DIV_255((255 - srcA), dstR, dstR);
  2813. dstR += srcR;
  2814. MULT_DIV_255((255 - srcA), dstG, dstG);
  2815. dstG += srcG;
  2816. MULT_DIV_255((255 - srcA), dstB, dstB);
  2817. dstB += srcB;
  2818. MULT_DIV_255((255 - srcA), dstA, dstA);
  2819. dstA += srcA;
  2820. break;
  2821. case SDL_COPY_BLEND_PREMULTIPLIED:
  2822. MULT_DIV_255((255 - srcA), dstR, dstR);
  2823. dstR += srcR;
  2824. if (dstR > 255) dstR = 255;
  2825. MULT_DIV_255((255 - srcA), dstG, dstG);
  2826. dstG += srcG;
  2827. if (dstG > 255) dstG = 255;
  2828. MULT_DIV_255((255 - srcA), dstB, dstB);
  2829. dstB += srcB;
  2830. if (dstB > 255) dstB = 255;
  2831. MULT_DIV_255((255 - srcA), dstA, dstA);
  2832. dstA += srcA;
  2833. if (dstA > 255) dstA = 255;
  2834. break;
  2835. case SDL_COPY_ADD:
  2836. case SDL_COPY_ADD_PREMULTIPLIED:
  2837. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2838. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2839. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2840. break;
  2841. case SDL_COPY_MOD:
  2842. MULT_DIV_255(srcR, dstR, dstR);
  2843. MULT_DIV_255(srcG, dstG, dstG);
  2844. MULT_DIV_255(srcB, dstB, dstB);
  2845. break;
  2846. case SDL_COPY_MUL:
  2847. {
  2848. Uint32 tmp1, tmp2;
  2849. MULT_DIV_255(srcR, dstR, tmp1);
  2850. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  2851. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  2852. MULT_DIV_255(srcG, dstG, tmp1);
  2853. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  2854. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  2855. MULT_DIV_255(srcB, dstB, tmp1);
  2856. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  2857. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  2858. }
  2859. break;
  2860. }
  2861. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2862. *dst = dstpixel;
  2863. posx += incx;
  2864. ++dst;
  2865. }
  2866. posy += incy;
  2867. info->dst += info->dst_pitch;
  2868. }
  2869. }
  2870. static void SDL_Blit_XBGR8888_ABGR8888_Scale(SDL_BlitInfo *info)
  2871. {
  2872. Uint32 pixel;
  2873. const Uint32 A = 0xFF;
  2874. Uint64 srcy, srcx;
  2875. Uint64 posy, posx;
  2876. Uint64 incy, incx;
  2877. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2878. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2879. posy = incy / 2;
  2880. while (info->dst_h--) {
  2881. Uint32 *src = 0;
  2882. Uint32 *dst = (Uint32 *)info->dst;
  2883. int n = info->dst_w;
  2884. posx = incx / 2;
  2885. srcy = posy >> 16;
  2886. while (n--) {
  2887. srcx = posx >> 16;
  2888. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2889. pixel = *src;
  2890. pixel |= (A << 24);
  2891. *dst = pixel;
  2892. posx += incx;
  2893. ++dst;
  2894. }
  2895. posy += incy;
  2896. info->dst += info->dst_pitch;
  2897. }
  2898. }
  2899. static void SDL_Blit_XBGR8888_ABGR8888_Blend(SDL_BlitInfo *info)
  2900. {
  2901. const int flags = info->flags;
  2902. Uint32 srcpixel;
  2903. Uint32 srcR, srcG, srcB;
  2904. Uint32 dstpixel;
  2905. Uint32 dstR, dstG, dstB, dstA;
  2906. while (info->dst_h--) {
  2907. Uint32 *src = (Uint32 *)info->src;
  2908. Uint32 *dst = (Uint32 *)info->dst;
  2909. int n = info->dst_w;
  2910. while (n--) {
  2911. srcpixel = *src;
  2912. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2913. dstpixel = *dst;
  2914. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2915. switch (flags & SDL_COPY_BLEND_MASK) {
  2916. case SDL_COPY_BLEND:
  2917. dstR = srcR;
  2918. dstG = srcG;
  2919. dstB = srcB;
  2920. dstA = 0xFF;
  2921. break;
  2922. case SDL_COPY_BLEND_PREMULTIPLIED:
  2923. dstR = srcR;
  2924. dstG = srcG;
  2925. dstB = srcB;
  2926. dstA = 0xFF;
  2927. break;
  2928. case SDL_COPY_ADD:
  2929. case SDL_COPY_ADD_PREMULTIPLIED:
  2930. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2931. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2932. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2933. break;
  2934. case SDL_COPY_MOD:
  2935. MULT_DIV_255(srcR, dstR, dstR);
  2936. MULT_DIV_255(srcG, dstG, dstG);
  2937. MULT_DIV_255(srcB, dstB, dstB);
  2938. break;
  2939. case SDL_COPY_MUL:
  2940. MULT_DIV_255(srcR, dstR, dstR);
  2941. MULT_DIV_255(srcG, dstG, dstG);
  2942. MULT_DIV_255(srcB, dstB, dstB);
  2943. break;
  2944. }
  2945. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  2946. *dst = dstpixel;
  2947. ++src;
  2948. ++dst;
  2949. }
  2950. info->src += info->src_pitch;
  2951. info->dst += info->dst_pitch;
  2952. }
  2953. }
  2954. static void SDL_Blit_XBGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  2955. {
  2956. const int flags = info->flags;
  2957. Uint32 srcpixel;
  2958. Uint32 srcR, srcG, srcB;
  2959. Uint32 dstpixel;
  2960. Uint32 dstR, dstG, dstB, dstA;
  2961. Uint64 srcy, srcx;
  2962. Uint64 posy, posx;
  2963. Uint64 incy, incx;
  2964. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  2965. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  2966. posy = incy / 2;
  2967. while (info->dst_h--) {
  2968. Uint32 *src = 0;
  2969. Uint32 *dst = (Uint32 *)info->dst;
  2970. int n = info->dst_w;
  2971. posx = incx / 2;
  2972. srcy = posy >> 16;
  2973. while (n--) {
  2974. srcx = posx >> 16;
  2975. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2976. srcpixel = *src;
  2977. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2978. dstpixel = *dst;
  2979. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2980. switch (flags & SDL_COPY_BLEND_MASK) {
  2981. case SDL_COPY_BLEND:
  2982. dstR = srcR;
  2983. dstG = srcG;
  2984. dstB = srcB;
  2985. dstA = 0xFF;
  2986. break;
  2987. case SDL_COPY_BLEND_PREMULTIPLIED:
  2988. dstR = srcR;
  2989. dstG = srcG;
  2990. dstB = srcB;
  2991. dstA = 0xFF;
  2992. break;
  2993. case SDL_COPY_ADD:
  2994. case SDL_COPY_ADD_PREMULTIPLIED:
  2995. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2996. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2997. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2998. break;
  2999. case SDL_COPY_MOD:
  3000. MULT_DIV_255(srcR, dstR, dstR);
  3001. MULT_DIV_255(srcG, dstG, dstG);
  3002. MULT_DIV_255(srcB, dstB, dstB);
  3003. break;
  3004. case SDL_COPY_MUL:
  3005. MULT_DIV_255(srcR, dstR, dstR);
  3006. MULT_DIV_255(srcG, dstG, dstG);
  3007. MULT_DIV_255(srcB, dstB, dstB);
  3008. break;
  3009. }
  3010. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  3011. *dst = dstpixel;
  3012. posx += incx;
  3013. ++dst;
  3014. }
  3015. posy += incy;
  3016. info->dst += info->dst_pitch;
  3017. }
  3018. }
  3019. static void SDL_Blit_XBGR8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  3020. {
  3021. const int flags = info->flags;
  3022. const Uint32 modulateR = info->r;
  3023. const Uint32 modulateG = info->g;
  3024. const Uint32 modulateB = info->b;
  3025. const Uint32 modulateA = info->a;
  3026. Uint32 pixel;
  3027. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  3028. Uint32 R, G, B;
  3029. while (info->dst_h--) {
  3030. Uint32 *src = (Uint32 *)info->src;
  3031. Uint32 *dst = (Uint32 *)info->dst;
  3032. int n = info->dst_w;
  3033. while (n--) {
  3034. pixel = *src;
  3035. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3036. if (flags & SDL_COPY_MODULATE_COLOR) {
  3037. MULT_DIV_255(R, modulateR, R);
  3038. MULT_DIV_255(G, modulateG, G);
  3039. MULT_DIV_255(B, modulateB, B);
  3040. }
  3041. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  3042. *dst = pixel;
  3043. ++src;
  3044. ++dst;
  3045. }
  3046. info->src += info->src_pitch;
  3047. info->dst += info->dst_pitch;
  3048. }
  3049. }
  3050. static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  3051. {
  3052. const int flags = info->flags;
  3053. const Uint32 modulateR = info->r;
  3054. const Uint32 modulateG = info->g;
  3055. const Uint32 modulateB = info->b;
  3056. const Uint32 modulateA = info->a;
  3057. Uint32 pixel;
  3058. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  3059. Uint32 R, G, B;
  3060. Uint64 srcy, srcx;
  3061. Uint64 posy, posx;
  3062. Uint64 incy, incx;
  3063. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3064. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3065. posy = incy / 2;
  3066. while (info->dst_h--) {
  3067. Uint32 *src = 0;
  3068. Uint32 *dst = (Uint32 *)info->dst;
  3069. int n = info->dst_w;
  3070. posx = incx / 2;
  3071. srcy = posy >> 16;
  3072. while (n--) {
  3073. srcx = posx >> 16;
  3074. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3075. pixel = *src;
  3076. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  3077. if (flags & SDL_COPY_MODULATE_COLOR) {
  3078. MULT_DIV_255(R, modulateR, R);
  3079. MULT_DIV_255(G, modulateG, G);
  3080. MULT_DIV_255(B, modulateB, B);
  3081. }
  3082. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  3083. *dst = pixel;
  3084. posx += incx;
  3085. ++dst;
  3086. }
  3087. posy += incy;
  3088. info->dst += info->dst_pitch;
  3089. }
  3090. }
  3091. static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  3092. {
  3093. const int flags = info->flags;
  3094. const Uint32 modulateR = info->r;
  3095. const Uint32 modulateG = info->g;
  3096. const Uint32 modulateB = info->b;
  3097. const Uint32 modulateA = info->a;
  3098. Uint32 srcpixel;
  3099. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  3100. Uint32 srcR, srcG, srcB;
  3101. Uint32 dstpixel;
  3102. Uint32 dstR, dstG, dstB, dstA;
  3103. while (info->dst_h--) {
  3104. Uint32 *src = (Uint32 *)info->src;
  3105. Uint32 *dst = (Uint32 *)info->dst;
  3106. int n = info->dst_w;
  3107. while (n--) {
  3108. srcpixel = *src;
  3109. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3110. dstpixel = *dst;
  3111. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  3112. if (flags & SDL_COPY_MODULATE_COLOR) {
  3113. MULT_DIV_255(srcR, modulateR, srcR);
  3114. MULT_DIV_255(srcG, modulateG, srcG);
  3115. MULT_DIV_255(srcB, modulateB, srcB);
  3116. }
  3117. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3118. if (srcA < 255) {
  3119. MULT_DIV_255(srcR, srcA, srcR);
  3120. MULT_DIV_255(srcG, srcA, srcG);
  3121. MULT_DIV_255(srcB, srcA, srcB);
  3122. }
  3123. }
  3124. switch (flags & SDL_COPY_BLEND_MASK) {
  3125. case SDL_COPY_BLEND:
  3126. MULT_DIV_255((255 - srcA), dstR, dstR);
  3127. dstR += srcR;
  3128. MULT_DIV_255((255 - srcA), dstG, dstG);
  3129. dstG += srcG;
  3130. MULT_DIV_255((255 - srcA), dstB, dstB);
  3131. dstB += srcB;
  3132. MULT_DIV_255((255 - srcA), dstA, dstA);
  3133. dstA += srcA;
  3134. break;
  3135. case SDL_COPY_BLEND_PREMULTIPLIED:
  3136. MULT_DIV_255((255 - srcA), dstR, dstR);
  3137. dstR += srcR;
  3138. if (dstR > 255) dstR = 255;
  3139. MULT_DIV_255((255 - srcA), dstG, dstG);
  3140. dstG += srcG;
  3141. if (dstG > 255) dstG = 255;
  3142. MULT_DIV_255((255 - srcA), dstB, dstB);
  3143. dstB += srcB;
  3144. if (dstB > 255) dstB = 255;
  3145. MULT_DIV_255((255 - srcA), dstA, dstA);
  3146. dstA += srcA;
  3147. if (dstA > 255) dstA = 255;
  3148. break;
  3149. case SDL_COPY_ADD:
  3150. case SDL_COPY_ADD_PREMULTIPLIED:
  3151. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3152. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3153. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3154. break;
  3155. case SDL_COPY_MOD:
  3156. MULT_DIV_255(srcR, dstR, dstR);
  3157. MULT_DIV_255(srcG, dstG, dstG);
  3158. MULT_DIV_255(srcB, dstB, dstB);
  3159. break;
  3160. case SDL_COPY_MUL:
  3161. {
  3162. Uint32 tmp1, tmp2;
  3163. MULT_DIV_255(srcR, dstR, tmp1);
  3164. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3165. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3166. MULT_DIV_255(srcG, dstG, tmp1);
  3167. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3168. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3169. MULT_DIV_255(srcB, dstB, tmp1);
  3170. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3171. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3172. }
  3173. break;
  3174. }
  3175. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  3176. *dst = dstpixel;
  3177. ++src;
  3178. ++dst;
  3179. }
  3180. info->src += info->src_pitch;
  3181. info->dst += info->dst_pitch;
  3182. }
  3183. }
  3184. static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3185. {
  3186. const int flags = info->flags;
  3187. const Uint32 modulateR = info->r;
  3188. const Uint32 modulateG = info->g;
  3189. const Uint32 modulateB = info->b;
  3190. const Uint32 modulateA = info->a;
  3191. Uint32 srcpixel;
  3192. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  3193. Uint32 srcR, srcG, srcB;
  3194. Uint32 dstpixel;
  3195. Uint32 dstR, dstG, dstB, dstA;
  3196. Uint64 srcy, srcx;
  3197. Uint64 posy, posx;
  3198. Uint64 incy, incx;
  3199. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3200. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3201. posy = incy / 2;
  3202. while (info->dst_h--) {
  3203. Uint32 *src = 0;
  3204. Uint32 *dst = (Uint32 *)info->dst;
  3205. int n = info->dst_w;
  3206. posx = incx / 2;
  3207. srcy = posy >> 16;
  3208. while (n--) {
  3209. srcx = posx >> 16;
  3210. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3211. srcpixel = *src;
  3212. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  3213. dstpixel = *dst;
  3214. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  3215. if (flags & SDL_COPY_MODULATE_COLOR) {
  3216. MULT_DIV_255(srcR, modulateR, srcR);
  3217. MULT_DIV_255(srcG, modulateG, srcG);
  3218. MULT_DIV_255(srcB, modulateB, srcB);
  3219. }
  3220. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3221. if (srcA < 255) {
  3222. MULT_DIV_255(srcR, srcA, srcR);
  3223. MULT_DIV_255(srcG, srcA, srcG);
  3224. MULT_DIV_255(srcB, srcA, srcB);
  3225. }
  3226. }
  3227. switch (flags & SDL_COPY_BLEND_MASK) {
  3228. case SDL_COPY_BLEND:
  3229. MULT_DIV_255((255 - srcA), dstR, dstR);
  3230. dstR += srcR;
  3231. MULT_DIV_255((255 - srcA), dstG, dstG);
  3232. dstG += srcG;
  3233. MULT_DIV_255((255 - srcA), dstB, dstB);
  3234. dstB += srcB;
  3235. MULT_DIV_255((255 - srcA), dstA, dstA);
  3236. dstA += srcA;
  3237. break;
  3238. case SDL_COPY_BLEND_PREMULTIPLIED:
  3239. MULT_DIV_255((255 - srcA), dstR, dstR);
  3240. dstR += srcR;
  3241. if (dstR > 255) dstR = 255;
  3242. MULT_DIV_255((255 - srcA), dstG, dstG);
  3243. dstG += srcG;
  3244. if (dstG > 255) dstG = 255;
  3245. MULT_DIV_255((255 - srcA), dstB, dstB);
  3246. dstB += srcB;
  3247. if (dstB > 255) dstB = 255;
  3248. MULT_DIV_255((255 - srcA), dstA, dstA);
  3249. dstA += srcA;
  3250. if (dstA > 255) dstA = 255;
  3251. break;
  3252. case SDL_COPY_ADD:
  3253. case SDL_COPY_ADD_PREMULTIPLIED:
  3254. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3255. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3256. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3257. break;
  3258. case SDL_COPY_MOD:
  3259. MULT_DIV_255(srcR, dstR, dstR);
  3260. MULT_DIV_255(srcG, dstG, dstG);
  3261. MULT_DIV_255(srcB, dstB, dstB);
  3262. break;
  3263. case SDL_COPY_MUL:
  3264. {
  3265. Uint32 tmp1, tmp2;
  3266. MULT_DIV_255(srcR, dstR, tmp1);
  3267. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3268. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3269. MULT_DIV_255(srcG, dstG, tmp1);
  3270. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3271. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3272. MULT_DIV_255(srcB, dstB, tmp1);
  3273. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3274. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3275. }
  3276. break;
  3277. }
  3278. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  3279. *dst = dstpixel;
  3280. posx += incx;
  3281. ++dst;
  3282. }
  3283. posy += incy;
  3284. info->dst += info->dst_pitch;
  3285. }
  3286. }
  3287. static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
  3288. {
  3289. Uint32 pixel;
  3290. Uint64 srcy, srcx;
  3291. Uint64 posy, posx;
  3292. Uint64 incy, incx;
  3293. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3294. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3295. posy = incy / 2;
  3296. while (info->dst_h--) {
  3297. Uint32 *src = 0;
  3298. Uint32 *dst = (Uint32 *)info->dst;
  3299. int n = info->dst_w;
  3300. posx = incx / 2;
  3301. srcy = posy >> 16;
  3302. while (n--) {
  3303. srcx = posx >> 16;
  3304. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3305. pixel = *src;
  3306. pixel &= 0xFFFFFF;
  3307. *dst = pixel;
  3308. posx += incx;
  3309. ++dst;
  3310. }
  3311. posy += incy;
  3312. info->dst += info->dst_pitch;
  3313. }
  3314. }
  3315. static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
  3316. {
  3317. const int flags = info->flags;
  3318. Uint32 srcpixel;
  3319. Uint32 srcR, srcG, srcB, srcA;
  3320. Uint32 dstpixel;
  3321. Uint32 dstR, dstG, dstB;
  3322. while (info->dst_h--) {
  3323. Uint32 *src = (Uint32 *)info->src;
  3324. Uint32 *dst = (Uint32 *)info->dst;
  3325. int n = info->dst_w;
  3326. while (n--) {
  3327. srcpixel = *src;
  3328. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3329. dstpixel = *dst;
  3330. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3331. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3332. if (srcA < 255) {
  3333. MULT_DIV_255(srcR, srcA, srcR);
  3334. MULT_DIV_255(srcG, srcA, srcG);
  3335. MULT_DIV_255(srcB, srcA, srcB);
  3336. }
  3337. }
  3338. switch (flags & SDL_COPY_BLEND_MASK) {
  3339. case SDL_COPY_BLEND:
  3340. MULT_DIV_255((255 - srcA), dstR, dstR);
  3341. dstR += srcR;
  3342. MULT_DIV_255((255 - srcA), dstG, dstG);
  3343. dstG += srcG;
  3344. MULT_DIV_255((255 - srcA), dstB, dstB);
  3345. dstB += srcB;
  3346. break;
  3347. case SDL_COPY_BLEND_PREMULTIPLIED:
  3348. MULT_DIV_255((255 - srcA), dstR, dstR);
  3349. dstR += srcR;
  3350. if (dstR > 255) dstR = 255;
  3351. MULT_DIV_255((255 - srcA), dstG, dstG);
  3352. dstG += srcG;
  3353. if (dstG > 255) dstG = 255;
  3354. MULT_DIV_255((255 - srcA), dstB, dstB);
  3355. dstB += srcB;
  3356. if (dstB > 255) dstB = 255;
  3357. break;
  3358. case SDL_COPY_ADD:
  3359. case SDL_COPY_ADD_PREMULTIPLIED:
  3360. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3361. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3362. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3363. break;
  3364. case SDL_COPY_MOD:
  3365. MULT_DIV_255(srcR, dstR, dstR);
  3366. MULT_DIV_255(srcG, dstG, dstG);
  3367. MULT_DIV_255(srcB, dstB, dstB);
  3368. break;
  3369. case SDL_COPY_MUL:
  3370. {
  3371. Uint32 tmp1, tmp2;
  3372. MULT_DIV_255(srcR, dstR, tmp1);
  3373. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3374. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3375. MULT_DIV_255(srcG, dstG, tmp1);
  3376. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3377. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3378. MULT_DIV_255(srcB, dstB, tmp1);
  3379. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3380. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3381. }
  3382. break;
  3383. }
  3384. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3385. *dst = dstpixel;
  3386. ++src;
  3387. ++dst;
  3388. }
  3389. info->src += info->src_pitch;
  3390. info->dst += info->dst_pitch;
  3391. }
  3392. }
  3393. static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  3394. {
  3395. const int flags = info->flags;
  3396. Uint32 srcpixel;
  3397. Uint32 srcR, srcG, srcB, srcA;
  3398. Uint32 dstpixel;
  3399. Uint32 dstR, dstG, dstB;
  3400. Uint64 srcy, srcx;
  3401. Uint64 posy, posx;
  3402. Uint64 incy, incx;
  3403. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3404. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3405. posy = incy / 2;
  3406. while (info->dst_h--) {
  3407. Uint32 *src = 0;
  3408. Uint32 *dst = (Uint32 *)info->dst;
  3409. int n = info->dst_w;
  3410. posx = incx / 2;
  3411. srcy = posy >> 16;
  3412. while (n--) {
  3413. srcx = posx >> 16;
  3414. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3415. srcpixel = *src;
  3416. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3417. dstpixel = *dst;
  3418. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3419. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3420. if (srcA < 255) {
  3421. MULT_DIV_255(srcR, srcA, srcR);
  3422. MULT_DIV_255(srcG, srcA, srcG);
  3423. MULT_DIV_255(srcB, srcA, srcB);
  3424. }
  3425. }
  3426. switch (flags & SDL_COPY_BLEND_MASK) {
  3427. case SDL_COPY_BLEND:
  3428. MULT_DIV_255((255 - srcA), dstR, dstR);
  3429. dstR += srcR;
  3430. MULT_DIV_255((255 - srcA), dstG, dstG);
  3431. dstG += srcG;
  3432. MULT_DIV_255((255 - srcA), dstB, dstB);
  3433. dstB += srcB;
  3434. break;
  3435. case SDL_COPY_BLEND_PREMULTIPLIED:
  3436. MULT_DIV_255((255 - srcA), dstR, dstR);
  3437. dstR += srcR;
  3438. if (dstR > 255) dstR = 255;
  3439. MULT_DIV_255((255 - srcA), dstG, dstG);
  3440. dstG += srcG;
  3441. if (dstG > 255) dstG = 255;
  3442. MULT_DIV_255((255 - srcA), dstB, dstB);
  3443. dstB += srcB;
  3444. if (dstB > 255) dstB = 255;
  3445. break;
  3446. case SDL_COPY_ADD:
  3447. case SDL_COPY_ADD_PREMULTIPLIED:
  3448. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3449. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3450. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3451. break;
  3452. case SDL_COPY_MOD:
  3453. MULT_DIV_255(srcR, dstR, dstR);
  3454. MULT_DIV_255(srcG, dstG, dstG);
  3455. MULT_DIV_255(srcB, dstB, dstB);
  3456. break;
  3457. case SDL_COPY_MUL:
  3458. {
  3459. Uint32 tmp1, tmp2;
  3460. MULT_DIV_255(srcR, dstR, tmp1);
  3461. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3462. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3463. MULT_DIV_255(srcG, dstG, tmp1);
  3464. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3465. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3466. MULT_DIV_255(srcB, dstB, tmp1);
  3467. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3468. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3469. }
  3470. break;
  3471. }
  3472. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3473. *dst = dstpixel;
  3474. posx += incx;
  3475. ++dst;
  3476. }
  3477. posy += incy;
  3478. info->dst += info->dst_pitch;
  3479. }
  3480. }
  3481. static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  3482. {
  3483. const int flags = info->flags;
  3484. const Uint32 modulateR = info->r;
  3485. const Uint32 modulateG = info->g;
  3486. const Uint32 modulateB = info->b;
  3487. Uint32 pixel;
  3488. Uint32 R, G, B;
  3489. while (info->dst_h--) {
  3490. Uint32 *src = (Uint32 *)info->src;
  3491. Uint32 *dst = (Uint32 *)info->dst;
  3492. int n = info->dst_w;
  3493. while (n--) {
  3494. pixel = *src;
  3495. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3496. if (flags & SDL_COPY_MODULATE_COLOR) {
  3497. MULT_DIV_255(R, modulateR, R);
  3498. MULT_DIV_255(G, modulateG, G);
  3499. MULT_DIV_255(B, modulateB, B);
  3500. }
  3501. pixel = (R << 16) | (G << 8) | B;
  3502. *dst = pixel;
  3503. ++src;
  3504. ++dst;
  3505. }
  3506. info->src += info->src_pitch;
  3507. info->dst += info->dst_pitch;
  3508. }
  3509. }
  3510. static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  3511. {
  3512. const int flags = info->flags;
  3513. const Uint32 modulateR = info->r;
  3514. const Uint32 modulateG = info->g;
  3515. const Uint32 modulateB = info->b;
  3516. Uint32 pixel;
  3517. Uint32 R, G, B;
  3518. Uint64 srcy, srcx;
  3519. Uint64 posy, posx;
  3520. Uint64 incy, incx;
  3521. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3522. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3523. posy = incy / 2;
  3524. while (info->dst_h--) {
  3525. Uint32 *src = 0;
  3526. Uint32 *dst = (Uint32 *)info->dst;
  3527. int n = info->dst_w;
  3528. posx = incx / 2;
  3529. srcy = posy >> 16;
  3530. while (n--) {
  3531. srcx = posx >> 16;
  3532. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3533. pixel = *src;
  3534. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3535. if (flags & SDL_COPY_MODULATE_COLOR) {
  3536. MULT_DIV_255(R, modulateR, R);
  3537. MULT_DIV_255(G, modulateG, G);
  3538. MULT_DIV_255(B, modulateB, B);
  3539. }
  3540. pixel = (R << 16) | (G << 8) | B;
  3541. *dst = pixel;
  3542. posx += incx;
  3543. ++dst;
  3544. }
  3545. posy += incy;
  3546. info->dst += info->dst_pitch;
  3547. }
  3548. }
  3549. static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  3550. {
  3551. const int flags = info->flags;
  3552. const Uint32 modulateR = info->r;
  3553. const Uint32 modulateG = info->g;
  3554. const Uint32 modulateB = info->b;
  3555. const Uint32 modulateA = info->a;
  3556. Uint32 srcpixel;
  3557. Uint32 srcR, srcG, srcB, srcA;
  3558. Uint32 dstpixel;
  3559. Uint32 dstR, dstG, dstB;
  3560. while (info->dst_h--) {
  3561. Uint32 *src = (Uint32 *)info->src;
  3562. Uint32 *dst = (Uint32 *)info->dst;
  3563. int n = info->dst_w;
  3564. while (n--) {
  3565. srcpixel = *src;
  3566. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3567. dstpixel = *dst;
  3568. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3569. if (flags & SDL_COPY_MODULATE_COLOR) {
  3570. MULT_DIV_255(srcR, modulateR, srcR);
  3571. MULT_DIV_255(srcG, modulateG, srcG);
  3572. MULT_DIV_255(srcB, modulateB, srcB);
  3573. }
  3574. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3575. MULT_DIV_255(srcA, modulateA, srcA);
  3576. }
  3577. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3578. if (srcA < 255) {
  3579. MULT_DIV_255(srcR, srcA, srcR);
  3580. MULT_DIV_255(srcG, srcA, srcG);
  3581. MULT_DIV_255(srcB, srcA, srcB);
  3582. }
  3583. }
  3584. switch (flags & SDL_COPY_BLEND_MASK) {
  3585. case SDL_COPY_BLEND:
  3586. MULT_DIV_255((255 - srcA), dstR, dstR);
  3587. dstR += srcR;
  3588. MULT_DIV_255((255 - srcA), dstG, dstG);
  3589. dstG += srcG;
  3590. MULT_DIV_255((255 - srcA), dstB, dstB);
  3591. dstB += srcB;
  3592. break;
  3593. case SDL_COPY_BLEND_PREMULTIPLIED:
  3594. MULT_DIV_255((255 - srcA), dstR, dstR);
  3595. dstR += srcR;
  3596. if (dstR > 255) dstR = 255;
  3597. MULT_DIV_255((255 - srcA), dstG, dstG);
  3598. dstG += srcG;
  3599. if (dstG > 255) dstG = 255;
  3600. MULT_DIV_255((255 - srcA), dstB, dstB);
  3601. dstB += srcB;
  3602. if (dstB > 255) dstB = 255;
  3603. break;
  3604. case SDL_COPY_ADD:
  3605. case SDL_COPY_ADD_PREMULTIPLIED:
  3606. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3607. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3608. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3609. break;
  3610. case SDL_COPY_MOD:
  3611. MULT_DIV_255(srcR, dstR, dstR);
  3612. MULT_DIV_255(srcG, dstG, dstG);
  3613. MULT_DIV_255(srcB, dstB, dstB);
  3614. break;
  3615. case SDL_COPY_MUL:
  3616. {
  3617. Uint32 tmp1, tmp2;
  3618. MULT_DIV_255(srcR, dstR, tmp1);
  3619. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3620. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3621. MULT_DIV_255(srcG, dstG, tmp1);
  3622. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3623. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3624. MULT_DIV_255(srcB, dstB, tmp1);
  3625. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3626. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3627. }
  3628. break;
  3629. }
  3630. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3631. *dst = dstpixel;
  3632. ++src;
  3633. ++dst;
  3634. }
  3635. info->src += info->src_pitch;
  3636. info->dst += info->dst_pitch;
  3637. }
  3638. }
  3639. static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3640. {
  3641. const int flags = info->flags;
  3642. const Uint32 modulateR = info->r;
  3643. const Uint32 modulateG = info->g;
  3644. const Uint32 modulateB = info->b;
  3645. const Uint32 modulateA = info->a;
  3646. Uint32 srcpixel;
  3647. Uint32 srcR, srcG, srcB, srcA;
  3648. Uint32 dstpixel;
  3649. Uint32 dstR, dstG, dstB;
  3650. Uint64 srcy, srcx;
  3651. Uint64 posy, posx;
  3652. Uint64 incy, incx;
  3653. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3654. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3655. posy = incy / 2;
  3656. while (info->dst_h--) {
  3657. Uint32 *src = 0;
  3658. Uint32 *dst = (Uint32 *)info->dst;
  3659. int n = info->dst_w;
  3660. posx = incx / 2;
  3661. srcy = posy >> 16;
  3662. while (n--) {
  3663. srcx = posx >> 16;
  3664. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3665. srcpixel = *src;
  3666. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3667. dstpixel = *dst;
  3668. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3669. if (flags & SDL_COPY_MODULATE_COLOR) {
  3670. MULT_DIV_255(srcR, modulateR, srcR);
  3671. MULT_DIV_255(srcG, modulateG, srcG);
  3672. MULT_DIV_255(srcB, modulateB, srcB);
  3673. }
  3674. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3675. MULT_DIV_255(srcA, modulateA, srcA);
  3676. }
  3677. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3678. if (srcA < 255) {
  3679. MULT_DIV_255(srcR, srcA, srcR);
  3680. MULT_DIV_255(srcG, srcA, srcG);
  3681. MULT_DIV_255(srcB, srcA, srcB);
  3682. }
  3683. }
  3684. switch (flags & SDL_COPY_BLEND_MASK) {
  3685. case SDL_COPY_BLEND:
  3686. MULT_DIV_255((255 - srcA), dstR, dstR);
  3687. dstR += srcR;
  3688. MULT_DIV_255((255 - srcA), dstG, dstG);
  3689. dstG += srcG;
  3690. MULT_DIV_255((255 - srcA), dstB, dstB);
  3691. dstB += srcB;
  3692. break;
  3693. case SDL_COPY_BLEND_PREMULTIPLIED:
  3694. MULT_DIV_255((255 - srcA), dstR, dstR);
  3695. dstR += srcR;
  3696. if (dstR > 255) dstR = 255;
  3697. MULT_DIV_255((255 - srcA), dstG, dstG);
  3698. dstG += srcG;
  3699. if (dstG > 255) dstG = 255;
  3700. MULT_DIV_255((255 - srcA), dstB, dstB);
  3701. dstB += srcB;
  3702. if (dstB > 255) dstB = 255;
  3703. break;
  3704. case SDL_COPY_ADD:
  3705. case SDL_COPY_ADD_PREMULTIPLIED:
  3706. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3707. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3708. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3709. break;
  3710. case SDL_COPY_MOD:
  3711. MULT_DIV_255(srcR, dstR, dstR);
  3712. MULT_DIV_255(srcG, dstG, dstG);
  3713. MULT_DIV_255(srcB, dstB, dstB);
  3714. break;
  3715. case SDL_COPY_MUL:
  3716. {
  3717. Uint32 tmp1, tmp2;
  3718. MULT_DIV_255(srcR, dstR, tmp1);
  3719. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3720. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3721. MULT_DIV_255(srcG, dstG, tmp1);
  3722. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3723. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3724. MULT_DIV_255(srcB, dstB, tmp1);
  3725. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3726. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3727. }
  3728. break;
  3729. }
  3730. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3731. *dst = dstpixel;
  3732. posx += incx;
  3733. ++dst;
  3734. }
  3735. posy += incy;
  3736. info->dst += info->dst_pitch;
  3737. }
  3738. }
  3739. static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
  3740. {
  3741. Uint32 pixel;
  3742. Uint32 R, G, B;
  3743. Uint64 srcy, srcx;
  3744. Uint64 posy, posx;
  3745. Uint64 incy, incx;
  3746. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3747. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3748. posy = incy / 2;
  3749. while (info->dst_h--) {
  3750. Uint32 *src = 0;
  3751. Uint32 *dst = (Uint32 *)info->dst;
  3752. int n = info->dst_w;
  3753. posx = incx / 2;
  3754. srcy = posy >> 16;
  3755. while (n--) {
  3756. srcx = posx >> 16;
  3757. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3758. pixel = *src;
  3759. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3760. pixel = (B << 16) | (G << 8) | R;
  3761. *dst = pixel;
  3762. posx += incx;
  3763. ++dst;
  3764. }
  3765. posy += incy;
  3766. info->dst += info->dst_pitch;
  3767. }
  3768. }
  3769. static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
  3770. {
  3771. const int flags = info->flags;
  3772. Uint32 srcpixel;
  3773. Uint32 srcR, srcG, srcB, srcA;
  3774. Uint32 dstpixel;
  3775. Uint32 dstR, dstG, dstB;
  3776. while (info->dst_h--) {
  3777. Uint32 *src = (Uint32 *)info->src;
  3778. Uint32 *dst = (Uint32 *)info->dst;
  3779. int n = info->dst_w;
  3780. while (n--) {
  3781. srcpixel = *src;
  3782. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3783. dstpixel = *dst;
  3784. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  3785. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3786. if (srcA < 255) {
  3787. MULT_DIV_255(srcR, srcA, srcR);
  3788. MULT_DIV_255(srcG, srcA, srcG);
  3789. MULT_DIV_255(srcB, srcA, srcB);
  3790. }
  3791. }
  3792. switch (flags & SDL_COPY_BLEND_MASK) {
  3793. case SDL_COPY_BLEND:
  3794. MULT_DIV_255((255 - srcA), dstR, dstR);
  3795. dstR += srcR;
  3796. MULT_DIV_255((255 - srcA), dstG, dstG);
  3797. dstG += srcG;
  3798. MULT_DIV_255((255 - srcA), dstB, dstB);
  3799. dstB += srcB;
  3800. break;
  3801. case SDL_COPY_BLEND_PREMULTIPLIED:
  3802. MULT_DIV_255((255 - srcA), dstR, dstR);
  3803. dstR += srcR;
  3804. if (dstR > 255) dstR = 255;
  3805. MULT_DIV_255((255 - srcA), dstG, dstG);
  3806. dstG += srcG;
  3807. if (dstG > 255) dstG = 255;
  3808. MULT_DIV_255((255 - srcA), dstB, dstB);
  3809. dstB += srcB;
  3810. if (dstB > 255) dstB = 255;
  3811. break;
  3812. case SDL_COPY_ADD:
  3813. case SDL_COPY_ADD_PREMULTIPLIED:
  3814. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3815. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3816. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3817. break;
  3818. case SDL_COPY_MOD:
  3819. MULT_DIV_255(srcR, dstR, dstR);
  3820. MULT_DIV_255(srcG, dstG, dstG);
  3821. MULT_DIV_255(srcB, dstB, dstB);
  3822. break;
  3823. case SDL_COPY_MUL:
  3824. {
  3825. Uint32 tmp1, tmp2;
  3826. MULT_DIV_255(srcR, dstR, tmp1);
  3827. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3828. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3829. MULT_DIV_255(srcG, dstG, tmp1);
  3830. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3831. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3832. MULT_DIV_255(srcB, dstB, tmp1);
  3833. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3834. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3835. }
  3836. break;
  3837. }
  3838. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  3839. *dst = dstpixel;
  3840. ++src;
  3841. ++dst;
  3842. }
  3843. info->src += info->src_pitch;
  3844. info->dst += info->dst_pitch;
  3845. }
  3846. }
  3847. static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  3848. {
  3849. const int flags = info->flags;
  3850. Uint32 srcpixel;
  3851. Uint32 srcR, srcG, srcB, srcA;
  3852. Uint32 dstpixel;
  3853. Uint32 dstR, dstG, dstB;
  3854. Uint64 srcy, srcx;
  3855. Uint64 posy, posx;
  3856. Uint64 incy, incx;
  3857. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3858. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3859. posy = incy / 2;
  3860. while (info->dst_h--) {
  3861. Uint32 *src = 0;
  3862. Uint32 *dst = (Uint32 *)info->dst;
  3863. int n = info->dst_w;
  3864. posx = incx / 2;
  3865. srcy = posy >> 16;
  3866. while (n--) {
  3867. srcx = posx >> 16;
  3868. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3869. srcpixel = *src;
  3870. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3871. dstpixel = *dst;
  3872. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  3873. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3874. if (srcA < 255) {
  3875. MULT_DIV_255(srcR, srcA, srcR);
  3876. MULT_DIV_255(srcG, srcA, srcG);
  3877. MULT_DIV_255(srcB, srcA, srcB);
  3878. }
  3879. }
  3880. switch (flags & SDL_COPY_BLEND_MASK) {
  3881. case SDL_COPY_BLEND:
  3882. MULT_DIV_255((255 - srcA), dstR, dstR);
  3883. dstR += srcR;
  3884. MULT_DIV_255((255 - srcA), dstG, dstG);
  3885. dstG += srcG;
  3886. MULT_DIV_255((255 - srcA), dstB, dstB);
  3887. dstB += srcB;
  3888. break;
  3889. case SDL_COPY_BLEND_PREMULTIPLIED:
  3890. MULT_DIV_255((255 - srcA), dstR, dstR);
  3891. dstR += srcR;
  3892. if (dstR > 255) dstR = 255;
  3893. MULT_DIV_255((255 - srcA), dstG, dstG);
  3894. dstG += srcG;
  3895. if (dstG > 255) dstG = 255;
  3896. MULT_DIV_255((255 - srcA), dstB, dstB);
  3897. dstB += srcB;
  3898. if (dstB > 255) dstB = 255;
  3899. break;
  3900. case SDL_COPY_ADD:
  3901. case SDL_COPY_ADD_PREMULTIPLIED:
  3902. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3903. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3904. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3905. break;
  3906. case SDL_COPY_MOD:
  3907. MULT_DIV_255(srcR, dstR, dstR);
  3908. MULT_DIV_255(srcG, dstG, dstG);
  3909. MULT_DIV_255(srcB, dstB, dstB);
  3910. break;
  3911. case SDL_COPY_MUL:
  3912. {
  3913. Uint32 tmp1, tmp2;
  3914. MULT_DIV_255(srcR, dstR, tmp1);
  3915. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  3916. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  3917. MULT_DIV_255(srcG, dstG, tmp1);
  3918. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  3919. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  3920. MULT_DIV_255(srcB, dstB, tmp1);
  3921. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  3922. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  3923. }
  3924. break;
  3925. }
  3926. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  3927. *dst = dstpixel;
  3928. posx += incx;
  3929. ++dst;
  3930. }
  3931. posy += incy;
  3932. info->dst += info->dst_pitch;
  3933. }
  3934. }
  3935. static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  3936. {
  3937. const int flags = info->flags;
  3938. const Uint32 modulateR = info->r;
  3939. const Uint32 modulateG = info->g;
  3940. const Uint32 modulateB = info->b;
  3941. Uint32 pixel;
  3942. Uint32 R, G, B;
  3943. while (info->dst_h--) {
  3944. Uint32 *src = (Uint32 *)info->src;
  3945. Uint32 *dst = (Uint32 *)info->dst;
  3946. int n = info->dst_w;
  3947. while (n--) {
  3948. pixel = *src;
  3949. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3950. if (flags & SDL_COPY_MODULATE_COLOR) {
  3951. MULT_DIV_255(R, modulateR, R);
  3952. MULT_DIV_255(G, modulateG, G);
  3953. MULT_DIV_255(B, modulateB, B);
  3954. }
  3955. pixel = (B << 16) | (G << 8) | R;
  3956. *dst = pixel;
  3957. ++src;
  3958. ++dst;
  3959. }
  3960. info->src += info->src_pitch;
  3961. info->dst += info->dst_pitch;
  3962. }
  3963. }
  3964. static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  3965. {
  3966. const int flags = info->flags;
  3967. const Uint32 modulateR = info->r;
  3968. const Uint32 modulateG = info->g;
  3969. const Uint32 modulateB = info->b;
  3970. Uint32 pixel;
  3971. Uint32 R, G, B;
  3972. Uint64 srcy, srcx;
  3973. Uint64 posy, posx;
  3974. Uint64 incy, incx;
  3975. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  3976. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  3977. posy = incy / 2;
  3978. while (info->dst_h--) {
  3979. Uint32 *src = 0;
  3980. Uint32 *dst = (Uint32 *)info->dst;
  3981. int n = info->dst_w;
  3982. posx = incx / 2;
  3983. srcy = posy >> 16;
  3984. while (n--) {
  3985. srcx = posx >> 16;
  3986. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3987. pixel = *src;
  3988. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  3989. if (flags & SDL_COPY_MODULATE_COLOR) {
  3990. MULT_DIV_255(R, modulateR, R);
  3991. MULT_DIV_255(G, modulateG, G);
  3992. MULT_DIV_255(B, modulateB, B);
  3993. }
  3994. pixel = (B << 16) | (G << 8) | R;
  3995. *dst = pixel;
  3996. posx += incx;
  3997. ++dst;
  3998. }
  3999. posy += incy;
  4000. info->dst += info->dst_pitch;
  4001. }
  4002. }
  4003. static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  4004. {
  4005. const int flags = info->flags;
  4006. const Uint32 modulateR = info->r;
  4007. const Uint32 modulateG = info->g;
  4008. const Uint32 modulateB = info->b;
  4009. const Uint32 modulateA = info->a;
  4010. Uint32 srcpixel;
  4011. Uint32 srcR, srcG, srcB, srcA;
  4012. Uint32 dstpixel;
  4013. Uint32 dstR, dstG, dstB;
  4014. while (info->dst_h--) {
  4015. Uint32 *src = (Uint32 *)info->src;
  4016. Uint32 *dst = (Uint32 *)info->dst;
  4017. int n = info->dst_w;
  4018. while (n--) {
  4019. srcpixel = *src;
  4020. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4021. dstpixel = *dst;
  4022. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  4023. if (flags & SDL_COPY_MODULATE_COLOR) {
  4024. MULT_DIV_255(srcR, modulateR, srcR);
  4025. MULT_DIV_255(srcG, modulateG, srcG);
  4026. MULT_DIV_255(srcB, modulateB, srcB);
  4027. }
  4028. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4029. MULT_DIV_255(srcA, modulateA, srcA);
  4030. }
  4031. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4032. if (srcA < 255) {
  4033. MULT_DIV_255(srcR, srcA, srcR);
  4034. MULT_DIV_255(srcG, srcA, srcG);
  4035. MULT_DIV_255(srcB, srcA, srcB);
  4036. }
  4037. }
  4038. switch (flags & SDL_COPY_BLEND_MASK) {
  4039. case SDL_COPY_BLEND:
  4040. MULT_DIV_255((255 - srcA), dstR, dstR);
  4041. dstR += srcR;
  4042. MULT_DIV_255((255 - srcA), dstG, dstG);
  4043. dstG += srcG;
  4044. MULT_DIV_255((255 - srcA), dstB, dstB);
  4045. dstB += srcB;
  4046. break;
  4047. case SDL_COPY_BLEND_PREMULTIPLIED:
  4048. MULT_DIV_255((255 - srcA), dstR, dstR);
  4049. dstR += srcR;
  4050. if (dstR > 255) dstR = 255;
  4051. MULT_DIV_255((255 - srcA), dstG, dstG);
  4052. dstG += srcG;
  4053. if (dstG > 255) dstG = 255;
  4054. MULT_DIV_255((255 - srcA), dstB, dstB);
  4055. dstB += srcB;
  4056. if (dstB > 255) dstB = 255;
  4057. break;
  4058. case SDL_COPY_ADD:
  4059. case SDL_COPY_ADD_PREMULTIPLIED:
  4060. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4061. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4062. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4063. break;
  4064. case SDL_COPY_MOD:
  4065. MULT_DIV_255(srcR, dstR, dstR);
  4066. MULT_DIV_255(srcG, dstG, dstG);
  4067. MULT_DIV_255(srcB, dstB, dstB);
  4068. break;
  4069. case SDL_COPY_MUL:
  4070. {
  4071. Uint32 tmp1, tmp2;
  4072. MULT_DIV_255(srcR, dstR, tmp1);
  4073. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4074. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4075. MULT_DIV_255(srcG, dstG, tmp1);
  4076. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4077. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4078. MULT_DIV_255(srcB, dstB, tmp1);
  4079. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4080. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4081. }
  4082. break;
  4083. }
  4084. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  4085. *dst = dstpixel;
  4086. ++src;
  4087. ++dst;
  4088. }
  4089. info->src += info->src_pitch;
  4090. info->dst += info->dst_pitch;
  4091. }
  4092. }
  4093. static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4094. {
  4095. const int flags = info->flags;
  4096. const Uint32 modulateR = info->r;
  4097. const Uint32 modulateG = info->g;
  4098. const Uint32 modulateB = info->b;
  4099. const Uint32 modulateA = info->a;
  4100. Uint32 srcpixel;
  4101. Uint32 srcR, srcG, srcB, srcA;
  4102. Uint32 dstpixel;
  4103. Uint32 dstR, dstG, dstB;
  4104. Uint64 srcy, srcx;
  4105. Uint64 posy, posx;
  4106. Uint64 incy, incx;
  4107. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4108. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4109. posy = incy / 2;
  4110. while (info->dst_h--) {
  4111. Uint32 *src = 0;
  4112. Uint32 *dst = (Uint32 *)info->dst;
  4113. int n = info->dst_w;
  4114. posx = incx / 2;
  4115. srcy = posy >> 16;
  4116. while (n--) {
  4117. srcx = posx >> 16;
  4118. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4119. srcpixel = *src;
  4120. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4121. dstpixel = *dst;
  4122. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  4123. if (flags & SDL_COPY_MODULATE_COLOR) {
  4124. MULT_DIV_255(srcR, modulateR, srcR);
  4125. MULT_DIV_255(srcG, modulateG, srcG);
  4126. MULT_DIV_255(srcB, modulateB, srcB);
  4127. }
  4128. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4129. MULT_DIV_255(srcA, modulateA, srcA);
  4130. }
  4131. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4132. if (srcA < 255) {
  4133. MULT_DIV_255(srcR, srcA, srcR);
  4134. MULT_DIV_255(srcG, srcA, srcG);
  4135. MULT_DIV_255(srcB, srcA, srcB);
  4136. }
  4137. }
  4138. switch (flags & SDL_COPY_BLEND_MASK) {
  4139. case SDL_COPY_BLEND:
  4140. MULT_DIV_255((255 - srcA), dstR, dstR);
  4141. dstR += srcR;
  4142. MULT_DIV_255((255 - srcA), dstG, dstG);
  4143. dstG += srcG;
  4144. MULT_DIV_255((255 - srcA), dstB, dstB);
  4145. dstB += srcB;
  4146. break;
  4147. case SDL_COPY_BLEND_PREMULTIPLIED:
  4148. MULT_DIV_255((255 - srcA), dstR, dstR);
  4149. dstR += srcR;
  4150. if (dstR > 255) dstR = 255;
  4151. MULT_DIV_255((255 - srcA), dstG, dstG);
  4152. dstG += srcG;
  4153. if (dstG > 255) dstG = 255;
  4154. MULT_DIV_255((255 - srcA), dstB, dstB);
  4155. dstB += srcB;
  4156. if (dstB > 255) dstB = 255;
  4157. break;
  4158. case SDL_COPY_ADD:
  4159. case SDL_COPY_ADD_PREMULTIPLIED:
  4160. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4161. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4162. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4163. break;
  4164. case SDL_COPY_MOD:
  4165. MULT_DIV_255(srcR, dstR, dstR);
  4166. MULT_DIV_255(srcG, dstG, dstG);
  4167. MULT_DIV_255(srcB, dstB, dstB);
  4168. break;
  4169. case SDL_COPY_MUL:
  4170. {
  4171. Uint32 tmp1, tmp2;
  4172. MULT_DIV_255(srcR, dstR, tmp1);
  4173. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4174. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4175. MULT_DIV_255(srcG, dstG, tmp1);
  4176. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4177. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4178. MULT_DIV_255(srcB, dstB, tmp1);
  4179. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4180. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4181. }
  4182. break;
  4183. }
  4184. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  4185. *dst = dstpixel;
  4186. posx += incx;
  4187. ++dst;
  4188. }
  4189. posy += incy;
  4190. info->dst += info->dst_pitch;
  4191. }
  4192. }
  4193. static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
  4194. {
  4195. Uint64 srcy, srcx;
  4196. Uint64 posy, posx;
  4197. Uint64 incy, incx;
  4198. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4199. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4200. posy = incy / 2;
  4201. while (info->dst_h--) {
  4202. Uint32 *src = 0;
  4203. Uint32 *dst = (Uint32 *)info->dst;
  4204. int n = info->dst_w;
  4205. posx = incx / 2;
  4206. srcy = posy >> 16;
  4207. while (n--) {
  4208. srcx = posx >> 16;
  4209. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4210. *dst = *src;
  4211. posx += incx;
  4212. ++dst;
  4213. }
  4214. posy += incy;
  4215. info->dst += info->dst_pitch;
  4216. }
  4217. }
  4218. static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
  4219. {
  4220. const int flags = info->flags;
  4221. Uint32 srcpixel;
  4222. Uint32 srcR, srcG, srcB, srcA;
  4223. Uint32 dstpixel;
  4224. Uint32 dstR, dstG, dstB, dstA;
  4225. while (info->dst_h--) {
  4226. Uint32 *src = (Uint32 *)info->src;
  4227. Uint32 *dst = (Uint32 *)info->dst;
  4228. int n = info->dst_w;
  4229. while (n--) {
  4230. srcpixel = *src;
  4231. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4232. dstpixel = *dst;
  4233. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4234. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4235. if (srcA < 255) {
  4236. MULT_DIV_255(srcR, srcA, srcR);
  4237. MULT_DIV_255(srcG, srcA, srcG);
  4238. MULT_DIV_255(srcB, srcA, srcB);
  4239. }
  4240. }
  4241. switch (flags & SDL_COPY_BLEND_MASK) {
  4242. case SDL_COPY_BLEND:
  4243. MULT_DIV_255((255 - srcA), dstR, dstR);
  4244. dstR += srcR;
  4245. MULT_DIV_255((255 - srcA), dstG, dstG);
  4246. dstG += srcG;
  4247. MULT_DIV_255((255 - srcA), dstB, dstB);
  4248. dstB += srcB;
  4249. MULT_DIV_255((255 - srcA), dstA, dstA);
  4250. dstA += srcA;
  4251. break;
  4252. case SDL_COPY_BLEND_PREMULTIPLIED:
  4253. MULT_DIV_255((255 - srcA), dstR, dstR);
  4254. dstR += srcR;
  4255. if (dstR > 255) dstR = 255;
  4256. MULT_DIV_255((255 - srcA), dstG, dstG);
  4257. dstG += srcG;
  4258. if (dstG > 255) dstG = 255;
  4259. MULT_DIV_255((255 - srcA), dstB, dstB);
  4260. dstB += srcB;
  4261. if (dstB > 255) dstB = 255;
  4262. MULT_DIV_255((255 - srcA), dstA, dstA);
  4263. dstA += srcA;
  4264. if (dstA > 255) dstA = 255;
  4265. break;
  4266. case SDL_COPY_ADD:
  4267. case SDL_COPY_ADD_PREMULTIPLIED:
  4268. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4269. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4270. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4271. break;
  4272. case SDL_COPY_MOD:
  4273. MULT_DIV_255(srcR, dstR, dstR);
  4274. MULT_DIV_255(srcG, dstG, dstG);
  4275. MULT_DIV_255(srcB, dstB, dstB);
  4276. break;
  4277. case SDL_COPY_MUL:
  4278. {
  4279. Uint32 tmp1, tmp2;
  4280. MULT_DIV_255(srcR, dstR, tmp1);
  4281. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4282. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4283. MULT_DIV_255(srcG, dstG, tmp1);
  4284. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4285. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4286. MULT_DIV_255(srcB, dstB, tmp1);
  4287. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4288. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4289. }
  4290. break;
  4291. }
  4292. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4293. *dst = dstpixel;
  4294. ++src;
  4295. ++dst;
  4296. }
  4297. info->src += info->src_pitch;
  4298. info->dst += info->dst_pitch;
  4299. }
  4300. }
  4301. static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  4302. {
  4303. const int flags = info->flags;
  4304. Uint32 srcpixel;
  4305. Uint32 srcR, srcG, srcB, srcA;
  4306. Uint32 dstpixel;
  4307. Uint32 dstR, dstG, dstB, dstA;
  4308. Uint64 srcy, srcx;
  4309. Uint64 posy, posx;
  4310. Uint64 incy, incx;
  4311. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4312. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4313. posy = incy / 2;
  4314. while (info->dst_h--) {
  4315. Uint32 *src = 0;
  4316. Uint32 *dst = (Uint32 *)info->dst;
  4317. int n = info->dst_w;
  4318. posx = incx / 2;
  4319. srcy = posy >> 16;
  4320. while (n--) {
  4321. srcx = posx >> 16;
  4322. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4323. srcpixel = *src;
  4324. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4325. dstpixel = *dst;
  4326. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4327. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4328. if (srcA < 255) {
  4329. MULT_DIV_255(srcR, srcA, srcR);
  4330. MULT_DIV_255(srcG, srcA, srcG);
  4331. MULT_DIV_255(srcB, srcA, srcB);
  4332. }
  4333. }
  4334. switch (flags & SDL_COPY_BLEND_MASK) {
  4335. case SDL_COPY_BLEND:
  4336. MULT_DIV_255((255 - srcA), dstR, dstR);
  4337. dstR += srcR;
  4338. MULT_DIV_255((255 - srcA), dstG, dstG);
  4339. dstG += srcG;
  4340. MULT_DIV_255((255 - srcA), dstB, dstB);
  4341. dstB += srcB;
  4342. MULT_DIV_255((255 - srcA), dstA, dstA);
  4343. dstA += srcA;
  4344. break;
  4345. case SDL_COPY_BLEND_PREMULTIPLIED:
  4346. MULT_DIV_255((255 - srcA), dstR, dstR);
  4347. dstR += srcR;
  4348. if (dstR > 255) dstR = 255;
  4349. MULT_DIV_255((255 - srcA), dstG, dstG);
  4350. dstG += srcG;
  4351. if (dstG > 255) dstG = 255;
  4352. MULT_DIV_255((255 - srcA), dstB, dstB);
  4353. dstB += srcB;
  4354. if (dstB > 255) dstB = 255;
  4355. MULT_DIV_255((255 - srcA), dstA, dstA);
  4356. dstA += srcA;
  4357. if (dstA > 255) dstA = 255;
  4358. break;
  4359. case SDL_COPY_ADD:
  4360. case SDL_COPY_ADD_PREMULTIPLIED:
  4361. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4362. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4363. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4364. break;
  4365. case SDL_COPY_MOD:
  4366. MULT_DIV_255(srcR, dstR, dstR);
  4367. MULT_DIV_255(srcG, dstG, dstG);
  4368. MULT_DIV_255(srcB, dstB, dstB);
  4369. break;
  4370. case SDL_COPY_MUL:
  4371. {
  4372. Uint32 tmp1, tmp2;
  4373. MULT_DIV_255(srcR, dstR, tmp1);
  4374. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4375. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4376. MULT_DIV_255(srcG, dstG, tmp1);
  4377. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4378. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4379. MULT_DIV_255(srcB, dstB, tmp1);
  4380. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4381. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4382. }
  4383. break;
  4384. }
  4385. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4386. *dst = dstpixel;
  4387. posx += incx;
  4388. ++dst;
  4389. }
  4390. posy += incy;
  4391. info->dst += info->dst_pitch;
  4392. }
  4393. }
  4394. static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  4395. {
  4396. const int flags = info->flags;
  4397. const Uint32 modulateR = info->r;
  4398. const Uint32 modulateG = info->g;
  4399. const Uint32 modulateB = info->b;
  4400. const Uint32 modulateA = info->a;
  4401. Uint32 pixel;
  4402. Uint32 R, G, B, A;
  4403. while (info->dst_h--) {
  4404. Uint32 *src = (Uint32 *)info->src;
  4405. Uint32 *dst = (Uint32 *)info->dst;
  4406. int n = info->dst_w;
  4407. while (n--) {
  4408. pixel = *src;
  4409. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4410. if (flags & SDL_COPY_MODULATE_COLOR) {
  4411. MULT_DIV_255(R, modulateR, R);
  4412. MULT_DIV_255(G, modulateG, G);
  4413. MULT_DIV_255(B, modulateB, B);
  4414. }
  4415. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4416. MULT_DIV_255(A, modulateA, A);
  4417. }
  4418. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  4419. *dst = pixel;
  4420. ++src;
  4421. ++dst;
  4422. }
  4423. info->src += info->src_pitch;
  4424. info->dst += info->dst_pitch;
  4425. }
  4426. }
  4427. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  4428. {
  4429. const int flags = info->flags;
  4430. const Uint32 modulateR = info->r;
  4431. const Uint32 modulateG = info->g;
  4432. const Uint32 modulateB = info->b;
  4433. const Uint32 modulateA = info->a;
  4434. Uint32 pixel;
  4435. Uint32 R, G, B, A;
  4436. Uint64 srcy, srcx;
  4437. Uint64 posy, posx;
  4438. Uint64 incy, incx;
  4439. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4440. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4441. posy = incy / 2;
  4442. while (info->dst_h--) {
  4443. Uint32 *src = 0;
  4444. Uint32 *dst = (Uint32 *)info->dst;
  4445. int n = info->dst_w;
  4446. posx = incx / 2;
  4447. srcy = posy >> 16;
  4448. while (n--) {
  4449. srcx = posx >> 16;
  4450. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4451. pixel = *src;
  4452. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4453. if (flags & SDL_COPY_MODULATE_COLOR) {
  4454. MULT_DIV_255(R, modulateR, R);
  4455. MULT_DIV_255(G, modulateG, G);
  4456. MULT_DIV_255(B, modulateB, B);
  4457. }
  4458. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4459. MULT_DIV_255(A, modulateA, A);
  4460. }
  4461. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  4462. *dst = pixel;
  4463. posx += incx;
  4464. ++dst;
  4465. }
  4466. posy += incy;
  4467. info->dst += info->dst_pitch;
  4468. }
  4469. }
  4470. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  4471. {
  4472. const int flags = info->flags;
  4473. const Uint32 modulateR = info->r;
  4474. const Uint32 modulateG = info->g;
  4475. const Uint32 modulateB = info->b;
  4476. const Uint32 modulateA = info->a;
  4477. Uint32 srcpixel;
  4478. Uint32 srcR, srcG, srcB, srcA;
  4479. Uint32 dstpixel;
  4480. Uint32 dstR, dstG, dstB, dstA;
  4481. while (info->dst_h--) {
  4482. Uint32 *src = (Uint32 *)info->src;
  4483. Uint32 *dst = (Uint32 *)info->dst;
  4484. int n = info->dst_w;
  4485. while (n--) {
  4486. srcpixel = *src;
  4487. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4488. dstpixel = *dst;
  4489. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4490. if (flags & SDL_COPY_MODULATE_COLOR) {
  4491. MULT_DIV_255(srcR, modulateR, srcR);
  4492. MULT_DIV_255(srcG, modulateG, srcG);
  4493. MULT_DIV_255(srcB, modulateB, srcB);
  4494. }
  4495. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4496. MULT_DIV_255(srcA, modulateA, srcA);
  4497. }
  4498. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4499. if (srcA < 255) {
  4500. MULT_DIV_255(srcR, srcA, srcR);
  4501. MULT_DIV_255(srcG, srcA, srcG);
  4502. MULT_DIV_255(srcB, srcA, srcB);
  4503. }
  4504. }
  4505. switch (flags & SDL_COPY_BLEND_MASK) {
  4506. case SDL_COPY_BLEND:
  4507. MULT_DIV_255((255 - srcA), dstR, dstR);
  4508. dstR += srcR;
  4509. MULT_DIV_255((255 - srcA), dstG, dstG);
  4510. dstG += srcG;
  4511. MULT_DIV_255((255 - srcA), dstB, dstB);
  4512. dstB += srcB;
  4513. MULT_DIV_255((255 - srcA), dstA, dstA);
  4514. dstA += srcA;
  4515. break;
  4516. case SDL_COPY_BLEND_PREMULTIPLIED:
  4517. MULT_DIV_255((255 - srcA), dstR, dstR);
  4518. dstR += srcR;
  4519. if (dstR > 255) dstR = 255;
  4520. MULT_DIV_255((255 - srcA), dstG, dstG);
  4521. dstG += srcG;
  4522. if (dstG > 255) dstG = 255;
  4523. MULT_DIV_255((255 - srcA), dstB, dstB);
  4524. dstB += srcB;
  4525. if (dstB > 255) dstB = 255;
  4526. MULT_DIV_255((255 - srcA), dstA, dstA);
  4527. dstA += srcA;
  4528. if (dstA > 255) dstA = 255;
  4529. break;
  4530. case SDL_COPY_ADD:
  4531. case SDL_COPY_ADD_PREMULTIPLIED:
  4532. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4533. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4534. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4535. break;
  4536. case SDL_COPY_MOD:
  4537. MULT_DIV_255(srcR, dstR, dstR);
  4538. MULT_DIV_255(srcG, dstG, dstG);
  4539. MULT_DIV_255(srcB, dstB, dstB);
  4540. break;
  4541. case SDL_COPY_MUL:
  4542. {
  4543. Uint32 tmp1, tmp2;
  4544. MULT_DIV_255(srcR, dstR, tmp1);
  4545. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4546. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4547. MULT_DIV_255(srcG, dstG, tmp1);
  4548. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4549. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4550. MULT_DIV_255(srcB, dstB, tmp1);
  4551. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4552. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4553. }
  4554. break;
  4555. }
  4556. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4557. *dst = dstpixel;
  4558. ++src;
  4559. ++dst;
  4560. }
  4561. info->src += info->src_pitch;
  4562. info->dst += info->dst_pitch;
  4563. }
  4564. }
  4565. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4566. {
  4567. const int flags = info->flags;
  4568. const Uint32 modulateR = info->r;
  4569. const Uint32 modulateG = info->g;
  4570. const Uint32 modulateB = info->b;
  4571. const Uint32 modulateA = info->a;
  4572. Uint32 srcpixel;
  4573. Uint32 srcR, srcG, srcB, srcA;
  4574. Uint32 dstpixel;
  4575. Uint32 dstR, dstG, dstB, dstA;
  4576. Uint64 srcy, srcx;
  4577. Uint64 posy, posx;
  4578. Uint64 incy, incx;
  4579. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4580. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4581. posy = incy / 2;
  4582. while (info->dst_h--) {
  4583. Uint32 *src = 0;
  4584. Uint32 *dst = (Uint32 *)info->dst;
  4585. int n = info->dst_w;
  4586. posx = incx / 2;
  4587. srcy = posy >> 16;
  4588. while (n--) {
  4589. srcx = posx >> 16;
  4590. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4591. srcpixel = *src;
  4592. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4593. dstpixel = *dst;
  4594. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4595. if (flags & SDL_COPY_MODULATE_COLOR) {
  4596. MULT_DIV_255(srcR, modulateR, srcR);
  4597. MULT_DIV_255(srcG, modulateG, srcG);
  4598. MULT_DIV_255(srcB, modulateB, srcB);
  4599. }
  4600. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4601. MULT_DIV_255(srcA, modulateA, srcA);
  4602. }
  4603. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4604. if (srcA < 255) {
  4605. MULT_DIV_255(srcR, srcA, srcR);
  4606. MULT_DIV_255(srcG, srcA, srcG);
  4607. MULT_DIV_255(srcB, srcA, srcB);
  4608. }
  4609. }
  4610. switch (flags & SDL_COPY_BLEND_MASK) {
  4611. case SDL_COPY_BLEND:
  4612. MULT_DIV_255((255 - srcA), dstR, dstR);
  4613. dstR += srcR;
  4614. MULT_DIV_255((255 - srcA), dstG, dstG);
  4615. dstG += srcG;
  4616. MULT_DIV_255((255 - srcA), dstB, dstB);
  4617. dstB += srcB;
  4618. MULT_DIV_255((255 - srcA), dstA, dstA);
  4619. dstA += srcA;
  4620. break;
  4621. case SDL_COPY_BLEND_PREMULTIPLIED:
  4622. MULT_DIV_255((255 - srcA), dstR, dstR);
  4623. dstR += srcR;
  4624. if (dstR > 255) dstR = 255;
  4625. MULT_DIV_255((255 - srcA), dstG, dstG);
  4626. dstG += srcG;
  4627. if (dstG > 255) dstG = 255;
  4628. MULT_DIV_255((255 - srcA), dstB, dstB);
  4629. dstB += srcB;
  4630. if (dstB > 255) dstB = 255;
  4631. MULT_DIV_255((255 - srcA), dstA, dstA);
  4632. dstA += srcA;
  4633. if (dstA > 255) dstA = 255;
  4634. break;
  4635. case SDL_COPY_ADD:
  4636. case SDL_COPY_ADD_PREMULTIPLIED:
  4637. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4638. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4639. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4640. break;
  4641. case SDL_COPY_MOD:
  4642. MULT_DIV_255(srcR, dstR, dstR);
  4643. MULT_DIV_255(srcG, dstG, dstG);
  4644. MULT_DIV_255(srcB, dstB, dstB);
  4645. break;
  4646. case SDL_COPY_MUL:
  4647. {
  4648. Uint32 tmp1, tmp2;
  4649. MULT_DIV_255(srcR, dstR, tmp1);
  4650. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4651. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4652. MULT_DIV_255(srcG, dstG, tmp1);
  4653. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4654. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4655. MULT_DIV_255(srcB, dstB, tmp1);
  4656. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4657. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4658. }
  4659. break;
  4660. }
  4661. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4662. *dst = dstpixel;
  4663. posx += incx;
  4664. ++dst;
  4665. }
  4666. posy += incy;
  4667. info->dst += info->dst_pitch;
  4668. }
  4669. }
  4670. static void SDL_Blit_ARGB8888_ABGR8888_Scale(SDL_BlitInfo *info)
  4671. {
  4672. Uint32 pixel;
  4673. Uint32 R, G, B, A;
  4674. Uint64 srcy, srcx;
  4675. Uint64 posy, posx;
  4676. Uint64 incy, incx;
  4677. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4678. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4679. posy = incy / 2;
  4680. while (info->dst_h--) {
  4681. Uint32 *src = 0;
  4682. Uint32 *dst = (Uint32 *)info->dst;
  4683. int n = info->dst_w;
  4684. posx = incx / 2;
  4685. srcy = posy >> 16;
  4686. while (n--) {
  4687. srcx = posx >> 16;
  4688. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4689. pixel = *src;
  4690. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4691. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  4692. *dst = pixel;
  4693. posx += incx;
  4694. ++dst;
  4695. }
  4696. posy += incy;
  4697. info->dst += info->dst_pitch;
  4698. }
  4699. }
  4700. static void SDL_Blit_ARGB8888_ABGR8888_Blend(SDL_BlitInfo *info)
  4701. {
  4702. const int flags = info->flags;
  4703. Uint32 srcpixel;
  4704. Uint32 srcR, srcG, srcB, srcA;
  4705. Uint32 dstpixel;
  4706. Uint32 dstR, dstG, dstB, dstA;
  4707. while (info->dst_h--) {
  4708. Uint32 *src = (Uint32 *)info->src;
  4709. Uint32 *dst = (Uint32 *)info->dst;
  4710. int n = info->dst_w;
  4711. while (n--) {
  4712. srcpixel = *src;
  4713. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4714. dstpixel = *dst;
  4715. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4716. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4717. if (srcA < 255) {
  4718. MULT_DIV_255(srcR, srcA, srcR);
  4719. MULT_DIV_255(srcG, srcA, srcG);
  4720. MULT_DIV_255(srcB, srcA, srcB);
  4721. }
  4722. }
  4723. switch (flags & SDL_COPY_BLEND_MASK) {
  4724. case SDL_COPY_BLEND:
  4725. MULT_DIV_255((255 - srcA), dstR, dstR);
  4726. dstR += srcR;
  4727. MULT_DIV_255((255 - srcA), dstG, dstG);
  4728. dstG += srcG;
  4729. MULT_DIV_255((255 - srcA), dstB, dstB);
  4730. dstB += srcB;
  4731. MULT_DIV_255((255 - srcA), dstA, dstA);
  4732. dstA += srcA;
  4733. break;
  4734. case SDL_COPY_BLEND_PREMULTIPLIED:
  4735. MULT_DIV_255((255 - srcA), dstR, dstR);
  4736. dstR += srcR;
  4737. if (dstR > 255) dstR = 255;
  4738. MULT_DIV_255((255 - srcA), dstG, dstG);
  4739. dstG += srcG;
  4740. if (dstG > 255) dstG = 255;
  4741. MULT_DIV_255((255 - srcA), dstB, dstB);
  4742. dstB += srcB;
  4743. if (dstB > 255) dstB = 255;
  4744. MULT_DIV_255((255 - srcA), dstA, dstA);
  4745. dstA += srcA;
  4746. if (dstA > 255) dstA = 255;
  4747. break;
  4748. case SDL_COPY_ADD:
  4749. case SDL_COPY_ADD_PREMULTIPLIED:
  4750. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4751. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4752. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4753. break;
  4754. case SDL_COPY_MOD:
  4755. MULT_DIV_255(srcR, dstR, dstR);
  4756. MULT_DIV_255(srcG, dstG, dstG);
  4757. MULT_DIV_255(srcB, dstB, dstB);
  4758. break;
  4759. case SDL_COPY_MUL:
  4760. {
  4761. Uint32 tmp1, tmp2;
  4762. MULT_DIV_255(srcR, dstR, tmp1);
  4763. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4764. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4765. MULT_DIV_255(srcG, dstG, tmp1);
  4766. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4767. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4768. MULT_DIV_255(srcB, dstB, tmp1);
  4769. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4770. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4771. }
  4772. break;
  4773. }
  4774. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  4775. *dst = dstpixel;
  4776. ++src;
  4777. ++dst;
  4778. }
  4779. info->src += info->src_pitch;
  4780. info->dst += info->dst_pitch;
  4781. }
  4782. }
  4783. static void SDL_Blit_ARGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  4784. {
  4785. const int flags = info->flags;
  4786. Uint32 srcpixel;
  4787. Uint32 srcR, srcG, srcB, srcA;
  4788. Uint32 dstpixel;
  4789. Uint32 dstR, dstG, dstB, dstA;
  4790. Uint64 srcy, srcx;
  4791. Uint64 posy, posx;
  4792. Uint64 incy, incx;
  4793. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4794. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4795. posy = incy / 2;
  4796. while (info->dst_h--) {
  4797. Uint32 *src = 0;
  4798. Uint32 *dst = (Uint32 *)info->dst;
  4799. int n = info->dst_w;
  4800. posx = incx / 2;
  4801. srcy = posy >> 16;
  4802. while (n--) {
  4803. srcx = posx >> 16;
  4804. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4805. srcpixel = *src;
  4806. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4807. dstpixel = *dst;
  4808. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4809. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4810. if (srcA < 255) {
  4811. MULT_DIV_255(srcR, srcA, srcR);
  4812. MULT_DIV_255(srcG, srcA, srcG);
  4813. MULT_DIV_255(srcB, srcA, srcB);
  4814. }
  4815. }
  4816. switch (flags & SDL_COPY_BLEND_MASK) {
  4817. case SDL_COPY_BLEND:
  4818. MULT_DIV_255((255 - srcA), dstR, dstR);
  4819. dstR += srcR;
  4820. MULT_DIV_255((255 - srcA), dstG, dstG);
  4821. dstG += srcG;
  4822. MULT_DIV_255((255 - srcA), dstB, dstB);
  4823. dstB += srcB;
  4824. MULT_DIV_255((255 - srcA), dstA, dstA);
  4825. dstA += srcA;
  4826. break;
  4827. case SDL_COPY_BLEND_PREMULTIPLIED:
  4828. MULT_DIV_255((255 - srcA), dstR, dstR);
  4829. dstR += srcR;
  4830. if (dstR > 255) dstR = 255;
  4831. MULT_DIV_255((255 - srcA), dstG, dstG);
  4832. dstG += srcG;
  4833. if (dstG > 255) dstG = 255;
  4834. MULT_DIV_255((255 - srcA), dstB, dstB);
  4835. dstB += srcB;
  4836. if (dstB > 255) dstB = 255;
  4837. MULT_DIV_255((255 - srcA), dstA, dstA);
  4838. dstA += srcA;
  4839. if (dstA > 255) dstA = 255;
  4840. break;
  4841. case SDL_COPY_ADD:
  4842. case SDL_COPY_ADD_PREMULTIPLIED:
  4843. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4844. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4845. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4846. break;
  4847. case SDL_COPY_MOD:
  4848. MULT_DIV_255(srcR, dstR, dstR);
  4849. MULT_DIV_255(srcG, dstG, dstG);
  4850. MULT_DIV_255(srcB, dstB, dstB);
  4851. break;
  4852. case SDL_COPY_MUL:
  4853. {
  4854. Uint32 tmp1, tmp2;
  4855. MULT_DIV_255(srcR, dstR, tmp1);
  4856. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  4857. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  4858. MULT_DIV_255(srcG, dstG, tmp1);
  4859. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  4860. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  4861. MULT_DIV_255(srcB, dstB, tmp1);
  4862. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  4863. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  4864. }
  4865. break;
  4866. }
  4867. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  4868. *dst = dstpixel;
  4869. posx += incx;
  4870. ++dst;
  4871. }
  4872. posy += incy;
  4873. info->dst += info->dst_pitch;
  4874. }
  4875. }
  4876. static void SDL_Blit_ARGB8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  4877. {
  4878. const int flags = info->flags;
  4879. const Uint32 modulateR = info->r;
  4880. const Uint32 modulateG = info->g;
  4881. const Uint32 modulateB = info->b;
  4882. const Uint32 modulateA = info->a;
  4883. Uint32 pixel;
  4884. Uint32 R, G, B, A;
  4885. while (info->dst_h--) {
  4886. Uint32 *src = (Uint32 *)info->src;
  4887. Uint32 *dst = (Uint32 *)info->dst;
  4888. int n = info->dst_w;
  4889. while (n--) {
  4890. pixel = *src;
  4891. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4892. if (flags & SDL_COPY_MODULATE_COLOR) {
  4893. MULT_DIV_255(R, modulateR, R);
  4894. MULT_DIV_255(G, modulateG, G);
  4895. MULT_DIV_255(B, modulateB, B);
  4896. }
  4897. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4898. MULT_DIV_255(A, modulateA, A);
  4899. }
  4900. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  4901. *dst = pixel;
  4902. ++src;
  4903. ++dst;
  4904. }
  4905. info->src += info->src_pitch;
  4906. info->dst += info->dst_pitch;
  4907. }
  4908. }
  4909. static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  4910. {
  4911. const int flags = info->flags;
  4912. const Uint32 modulateR = info->r;
  4913. const Uint32 modulateG = info->g;
  4914. const Uint32 modulateB = info->b;
  4915. const Uint32 modulateA = info->a;
  4916. Uint32 pixel;
  4917. Uint32 R, G, B, A;
  4918. Uint64 srcy, srcx;
  4919. Uint64 posy, posx;
  4920. Uint64 incy, incx;
  4921. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  4922. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  4923. posy = incy / 2;
  4924. while (info->dst_h--) {
  4925. Uint32 *src = 0;
  4926. Uint32 *dst = (Uint32 *)info->dst;
  4927. int n = info->dst_w;
  4928. posx = incx / 2;
  4929. srcy = posy >> 16;
  4930. while (n--) {
  4931. srcx = posx >> 16;
  4932. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4933. pixel = *src;
  4934. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  4935. if (flags & SDL_COPY_MODULATE_COLOR) {
  4936. MULT_DIV_255(R, modulateR, R);
  4937. MULT_DIV_255(G, modulateG, G);
  4938. MULT_DIV_255(B, modulateB, B);
  4939. }
  4940. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4941. MULT_DIV_255(A, modulateA, A);
  4942. }
  4943. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  4944. *dst = pixel;
  4945. posx += incx;
  4946. ++dst;
  4947. }
  4948. posy += incy;
  4949. info->dst += info->dst_pitch;
  4950. }
  4951. }
  4952. static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  4953. {
  4954. const int flags = info->flags;
  4955. const Uint32 modulateR = info->r;
  4956. const Uint32 modulateG = info->g;
  4957. const Uint32 modulateB = info->b;
  4958. const Uint32 modulateA = info->a;
  4959. Uint32 srcpixel;
  4960. Uint32 srcR, srcG, srcB, srcA;
  4961. Uint32 dstpixel;
  4962. Uint32 dstR, dstG, dstB, dstA;
  4963. while (info->dst_h--) {
  4964. Uint32 *src = (Uint32 *)info->src;
  4965. Uint32 *dst = (Uint32 *)info->dst;
  4966. int n = info->dst_w;
  4967. while (n--) {
  4968. srcpixel = *src;
  4969. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4970. dstpixel = *dst;
  4971. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4972. if (flags & SDL_COPY_MODULATE_COLOR) {
  4973. MULT_DIV_255(srcR, modulateR, srcR);
  4974. MULT_DIV_255(srcG, modulateG, srcG);
  4975. MULT_DIV_255(srcB, modulateB, srcB);
  4976. }
  4977. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4978. MULT_DIV_255(srcA, modulateA, srcA);
  4979. }
  4980. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4981. if (srcA < 255) {
  4982. MULT_DIV_255(srcR, srcA, srcR);
  4983. MULT_DIV_255(srcG, srcA, srcG);
  4984. MULT_DIV_255(srcB, srcA, srcB);
  4985. }
  4986. }
  4987. switch (flags & SDL_COPY_BLEND_MASK) {
  4988. case SDL_COPY_BLEND:
  4989. MULT_DIV_255((255 - srcA), dstR, dstR);
  4990. dstR += srcR;
  4991. MULT_DIV_255((255 - srcA), dstG, dstG);
  4992. dstG += srcG;
  4993. MULT_DIV_255((255 - srcA), dstB, dstB);
  4994. dstB += srcB;
  4995. MULT_DIV_255((255 - srcA), dstA, dstA);
  4996. dstA += srcA;
  4997. break;
  4998. case SDL_COPY_BLEND_PREMULTIPLIED:
  4999. MULT_DIV_255((255 - srcA), dstR, dstR);
  5000. dstR += srcR;
  5001. if (dstR > 255) dstR = 255;
  5002. MULT_DIV_255((255 - srcA), dstG, dstG);
  5003. dstG += srcG;
  5004. if (dstG > 255) dstG = 255;
  5005. MULT_DIV_255((255 - srcA), dstB, dstB);
  5006. dstB += srcB;
  5007. if (dstB > 255) dstB = 255;
  5008. MULT_DIV_255((255 - srcA), dstA, dstA);
  5009. dstA += srcA;
  5010. if (dstA > 255) dstA = 255;
  5011. break;
  5012. case SDL_COPY_ADD:
  5013. case SDL_COPY_ADD_PREMULTIPLIED:
  5014. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5015. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5016. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5017. break;
  5018. case SDL_COPY_MOD:
  5019. MULT_DIV_255(srcR, dstR, dstR);
  5020. MULT_DIV_255(srcG, dstG, dstG);
  5021. MULT_DIV_255(srcB, dstB, dstB);
  5022. break;
  5023. case SDL_COPY_MUL:
  5024. {
  5025. Uint32 tmp1, tmp2;
  5026. MULT_DIV_255(srcR, dstR, tmp1);
  5027. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5028. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5029. MULT_DIV_255(srcG, dstG, tmp1);
  5030. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5031. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5032. MULT_DIV_255(srcB, dstB, tmp1);
  5033. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5034. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5035. }
  5036. break;
  5037. }
  5038. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  5039. *dst = dstpixel;
  5040. ++src;
  5041. ++dst;
  5042. }
  5043. info->src += info->src_pitch;
  5044. info->dst += info->dst_pitch;
  5045. }
  5046. }
  5047. static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5048. {
  5049. const int flags = info->flags;
  5050. const Uint32 modulateR = info->r;
  5051. const Uint32 modulateG = info->g;
  5052. const Uint32 modulateB = info->b;
  5053. const Uint32 modulateA = info->a;
  5054. Uint32 srcpixel;
  5055. Uint32 srcR, srcG, srcB, srcA;
  5056. Uint32 dstpixel;
  5057. Uint32 dstR, dstG, dstB, dstA;
  5058. Uint64 srcy, srcx;
  5059. Uint64 posy, posx;
  5060. Uint64 incy, incx;
  5061. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5062. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5063. posy = incy / 2;
  5064. while (info->dst_h--) {
  5065. Uint32 *src = 0;
  5066. Uint32 *dst = (Uint32 *)info->dst;
  5067. int n = info->dst_w;
  5068. posx = incx / 2;
  5069. srcy = posy >> 16;
  5070. while (n--) {
  5071. srcx = posx >> 16;
  5072. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5073. srcpixel = *src;
  5074. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5075. dstpixel = *dst;
  5076. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  5077. if (flags & SDL_COPY_MODULATE_COLOR) {
  5078. MULT_DIV_255(srcR, modulateR, srcR);
  5079. MULT_DIV_255(srcG, modulateG, srcG);
  5080. MULT_DIV_255(srcB, modulateB, srcB);
  5081. }
  5082. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5083. MULT_DIV_255(srcA, modulateA, srcA);
  5084. }
  5085. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5086. if (srcA < 255) {
  5087. MULT_DIV_255(srcR, srcA, srcR);
  5088. MULT_DIV_255(srcG, srcA, srcG);
  5089. MULT_DIV_255(srcB, srcA, srcB);
  5090. }
  5091. }
  5092. switch (flags & SDL_COPY_BLEND_MASK) {
  5093. case SDL_COPY_BLEND:
  5094. MULT_DIV_255((255 - srcA), dstR, dstR);
  5095. dstR += srcR;
  5096. MULT_DIV_255((255 - srcA), dstG, dstG);
  5097. dstG += srcG;
  5098. MULT_DIV_255((255 - srcA), dstB, dstB);
  5099. dstB += srcB;
  5100. MULT_DIV_255((255 - srcA), dstA, dstA);
  5101. dstA += srcA;
  5102. break;
  5103. case SDL_COPY_BLEND_PREMULTIPLIED:
  5104. MULT_DIV_255((255 - srcA), dstR, dstR);
  5105. dstR += srcR;
  5106. if (dstR > 255) dstR = 255;
  5107. MULT_DIV_255((255 - srcA), dstG, dstG);
  5108. dstG += srcG;
  5109. if (dstG > 255) dstG = 255;
  5110. MULT_DIV_255((255 - srcA), dstB, dstB);
  5111. dstB += srcB;
  5112. if (dstB > 255) dstB = 255;
  5113. MULT_DIV_255((255 - srcA), dstA, dstA);
  5114. dstA += srcA;
  5115. if (dstA > 255) dstA = 255;
  5116. break;
  5117. case SDL_COPY_ADD:
  5118. case SDL_COPY_ADD_PREMULTIPLIED:
  5119. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5120. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5121. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5122. break;
  5123. case SDL_COPY_MOD:
  5124. MULT_DIV_255(srcR, dstR, dstR);
  5125. MULT_DIV_255(srcG, dstG, dstG);
  5126. MULT_DIV_255(srcB, dstB, dstB);
  5127. break;
  5128. case SDL_COPY_MUL:
  5129. {
  5130. Uint32 tmp1, tmp2;
  5131. MULT_DIV_255(srcR, dstR, tmp1);
  5132. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5133. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5134. MULT_DIV_255(srcG, dstG, tmp1);
  5135. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5136. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5137. MULT_DIV_255(srcB, dstB, tmp1);
  5138. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5139. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5140. }
  5141. break;
  5142. }
  5143. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  5144. *dst = dstpixel;
  5145. posx += incx;
  5146. ++dst;
  5147. }
  5148. posy += incy;
  5149. info->dst += info->dst_pitch;
  5150. }
  5151. }
  5152. static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
  5153. {
  5154. Uint32 pixel;
  5155. Uint64 srcy, srcx;
  5156. Uint64 posy, posx;
  5157. Uint64 incy, incx;
  5158. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5159. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5160. posy = incy / 2;
  5161. while (info->dst_h--) {
  5162. Uint32 *src = 0;
  5163. Uint32 *dst = (Uint32 *)info->dst;
  5164. int n = info->dst_w;
  5165. posx = incx / 2;
  5166. srcy = posy >> 16;
  5167. while (n--) {
  5168. srcx = posx >> 16;
  5169. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5170. pixel = *src;
  5171. pixel >>= 8;
  5172. *dst = pixel;
  5173. posx += incx;
  5174. ++dst;
  5175. }
  5176. posy += incy;
  5177. info->dst += info->dst_pitch;
  5178. }
  5179. }
  5180. static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
  5181. {
  5182. const int flags = info->flags;
  5183. Uint32 srcpixel;
  5184. Uint32 srcR, srcG, srcB, srcA;
  5185. Uint32 dstpixel;
  5186. Uint32 dstR, dstG, dstB;
  5187. while (info->dst_h--) {
  5188. Uint32 *src = (Uint32 *)info->src;
  5189. Uint32 *dst = (Uint32 *)info->dst;
  5190. int n = info->dst_w;
  5191. while (n--) {
  5192. srcpixel = *src;
  5193. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5194. dstpixel = *dst;
  5195. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5196. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5197. if (srcA < 255) {
  5198. MULT_DIV_255(srcR, srcA, srcR);
  5199. MULT_DIV_255(srcG, srcA, srcG);
  5200. MULT_DIV_255(srcB, srcA, srcB);
  5201. }
  5202. }
  5203. switch (flags & SDL_COPY_BLEND_MASK) {
  5204. case SDL_COPY_BLEND:
  5205. MULT_DIV_255((255 - srcA), dstR, dstR);
  5206. dstR += srcR;
  5207. MULT_DIV_255((255 - srcA), dstG, dstG);
  5208. dstG += srcG;
  5209. MULT_DIV_255((255 - srcA), dstB, dstB);
  5210. dstB += srcB;
  5211. break;
  5212. case SDL_COPY_BLEND_PREMULTIPLIED:
  5213. MULT_DIV_255((255 - srcA), dstR, dstR);
  5214. dstR += srcR;
  5215. if (dstR > 255) dstR = 255;
  5216. MULT_DIV_255((255 - srcA), dstG, dstG);
  5217. dstG += srcG;
  5218. if (dstG > 255) dstG = 255;
  5219. MULT_DIV_255((255 - srcA), dstB, dstB);
  5220. dstB += srcB;
  5221. if (dstB > 255) dstB = 255;
  5222. break;
  5223. case SDL_COPY_ADD:
  5224. case SDL_COPY_ADD_PREMULTIPLIED:
  5225. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5226. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5227. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5228. break;
  5229. case SDL_COPY_MOD:
  5230. MULT_DIV_255(srcR, dstR, dstR);
  5231. MULT_DIV_255(srcG, dstG, dstG);
  5232. MULT_DIV_255(srcB, dstB, dstB);
  5233. break;
  5234. case SDL_COPY_MUL:
  5235. {
  5236. Uint32 tmp1, tmp2;
  5237. MULT_DIV_255(srcR, dstR, tmp1);
  5238. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5239. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5240. MULT_DIV_255(srcG, dstG, tmp1);
  5241. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5242. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5243. MULT_DIV_255(srcB, dstB, tmp1);
  5244. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5245. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5246. }
  5247. break;
  5248. }
  5249. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5250. *dst = dstpixel;
  5251. ++src;
  5252. ++dst;
  5253. }
  5254. info->src += info->src_pitch;
  5255. info->dst += info->dst_pitch;
  5256. }
  5257. }
  5258. static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  5259. {
  5260. const int flags = info->flags;
  5261. Uint32 srcpixel;
  5262. Uint32 srcR, srcG, srcB, srcA;
  5263. Uint32 dstpixel;
  5264. Uint32 dstR, dstG, dstB;
  5265. Uint64 srcy, srcx;
  5266. Uint64 posy, posx;
  5267. Uint64 incy, incx;
  5268. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5269. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5270. posy = incy / 2;
  5271. while (info->dst_h--) {
  5272. Uint32 *src = 0;
  5273. Uint32 *dst = (Uint32 *)info->dst;
  5274. int n = info->dst_w;
  5275. posx = incx / 2;
  5276. srcy = posy >> 16;
  5277. while (n--) {
  5278. srcx = posx >> 16;
  5279. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5280. srcpixel = *src;
  5281. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5282. dstpixel = *dst;
  5283. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5284. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5285. if (srcA < 255) {
  5286. MULT_DIV_255(srcR, srcA, srcR);
  5287. MULT_DIV_255(srcG, srcA, srcG);
  5288. MULT_DIV_255(srcB, srcA, srcB);
  5289. }
  5290. }
  5291. switch (flags & SDL_COPY_BLEND_MASK) {
  5292. case SDL_COPY_BLEND:
  5293. MULT_DIV_255((255 - srcA), dstR, dstR);
  5294. dstR += srcR;
  5295. MULT_DIV_255((255 - srcA), dstG, dstG);
  5296. dstG += srcG;
  5297. MULT_DIV_255((255 - srcA), dstB, dstB);
  5298. dstB += srcB;
  5299. break;
  5300. case SDL_COPY_BLEND_PREMULTIPLIED:
  5301. MULT_DIV_255((255 - srcA), dstR, dstR);
  5302. dstR += srcR;
  5303. if (dstR > 255) dstR = 255;
  5304. MULT_DIV_255((255 - srcA), dstG, dstG);
  5305. dstG += srcG;
  5306. if (dstG > 255) dstG = 255;
  5307. MULT_DIV_255((255 - srcA), dstB, dstB);
  5308. dstB += srcB;
  5309. if (dstB > 255) dstB = 255;
  5310. break;
  5311. case SDL_COPY_ADD:
  5312. case SDL_COPY_ADD_PREMULTIPLIED:
  5313. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5314. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5315. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5316. break;
  5317. case SDL_COPY_MOD:
  5318. MULT_DIV_255(srcR, dstR, dstR);
  5319. MULT_DIV_255(srcG, dstG, dstG);
  5320. MULT_DIV_255(srcB, dstB, dstB);
  5321. break;
  5322. case SDL_COPY_MUL:
  5323. {
  5324. Uint32 tmp1, tmp2;
  5325. MULT_DIV_255(srcR, dstR, tmp1);
  5326. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5327. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5328. MULT_DIV_255(srcG, dstG, tmp1);
  5329. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5330. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5331. MULT_DIV_255(srcB, dstB, tmp1);
  5332. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5333. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5334. }
  5335. break;
  5336. }
  5337. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5338. *dst = dstpixel;
  5339. posx += incx;
  5340. ++dst;
  5341. }
  5342. posy += incy;
  5343. info->dst += info->dst_pitch;
  5344. }
  5345. }
  5346. static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  5347. {
  5348. const int flags = info->flags;
  5349. const Uint32 modulateR = info->r;
  5350. const Uint32 modulateG = info->g;
  5351. const Uint32 modulateB = info->b;
  5352. Uint32 pixel;
  5353. Uint32 R, G, B;
  5354. while (info->dst_h--) {
  5355. Uint32 *src = (Uint32 *)info->src;
  5356. Uint32 *dst = (Uint32 *)info->dst;
  5357. int n = info->dst_w;
  5358. while (n--) {
  5359. pixel = *src;
  5360. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5361. if (flags & SDL_COPY_MODULATE_COLOR) {
  5362. MULT_DIV_255(R, modulateR, R);
  5363. MULT_DIV_255(G, modulateG, G);
  5364. MULT_DIV_255(B, modulateB, B);
  5365. }
  5366. pixel = (R << 16) | (G << 8) | B;
  5367. *dst = pixel;
  5368. ++src;
  5369. ++dst;
  5370. }
  5371. info->src += info->src_pitch;
  5372. info->dst += info->dst_pitch;
  5373. }
  5374. }
  5375. static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  5376. {
  5377. const int flags = info->flags;
  5378. const Uint32 modulateR = info->r;
  5379. const Uint32 modulateG = info->g;
  5380. const Uint32 modulateB = info->b;
  5381. Uint32 pixel;
  5382. Uint32 R, G, B;
  5383. Uint64 srcy, srcx;
  5384. Uint64 posy, posx;
  5385. Uint64 incy, incx;
  5386. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5387. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5388. posy = incy / 2;
  5389. while (info->dst_h--) {
  5390. Uint32 *src = 0;
  5391. Uint32 *dst = (Uint32 *)info->dst;
  5392. int n = info->dst_w;
  5393. posx = incx / 2;
  5394. srcy = posy >> 16;
  5395. while (n--) {
  5396. srcx = posx >> 16;
  5397. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5398. pixel = *src;
  5399. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5400. if (flags & SDL_COPY_MODULATE_COLOR) {
  5401. MULT_DIV_255(R, modulateR, R);
  5402. MULT_DIV_255(G, modulateG, G);
  5403. MULT_DIV_255(B, modulateB, B);
  5404. }
  5405. pixel = (R << 16) | (G << 8) | B;
  5406. *dst = pixel;
  5407. posx += incx;
  5408. ++dst;
  5409. }
  5410. posy += incy;
  5411. info->dst += info->dst_pitch;
  5412. }
  5413. }
  5414. static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  5415. {
  5416. const int flags = info->flags;
  5417. const Uint32 modulateR = info->r;
  5418. const Uint32 modulateG = info->g;
  5419. const Uint32 modulateB = info->b;
  5420. const Uint32 modulateA = info->a;
  5421. Uint32 srcpixel;
  5422. Uint32 srcR, srcG, srcB, srcA;
  5423. Uint32 dstpixel;
  5424. Uint32 dstR, dstG, dstB;
  5425. while (info->dst_h--) {
  5426. Uint32 *src = (Uint32 *)info->src;
  5427. Uint32 *dst = (Uint32 *)info->dst;
  5428. int n = info->dst_w;
  5429. while (n--) {
  5430. srcpixel = *src;
  5431. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5432. dstpixel = *dst;
  5433. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5434. if (flags & SDL_COPY_MODULATE_COLOR) {
  5435. MULT_DIV_255(srcR, modulateR, srcR);
  5436. MULT_DIV_255(srcG, modulateG, srcG);
  5437. MULT_DIV_255(srcB, modulateB, srcB);
  5438. }
  5439. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5440. MULT_DIV_255(srcA, modulateA, srcA);
  5441. }
  5442. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5443. if (srcA < 255) {
  5444. MULT_DIV_255(srcR, srcA, srcR);
  5445. MULT_DIV_255(srcG, srcA, srcG);
  5446. MULT_DIV_255(srcB, srcA, srcB);
  5447. }
  5448. }
  5449. switch (flags & SDL_COPY_BLEND_MASK) {
  5450. case SDL_COPY_BLEND:
  5451. MULT_DIV_255((255 - srcA), dstR, dstR);
  5452. dstR += srcR;
  5453. MULT_DIV_255((255 - srcA), dstG, dstG);
  5454. dstG += srcG;
  5455. MULT_DIV_255((255 - srcA), dstB, dstB);
  5456. dstB += srcB;
  5457. break;
  5458. case SDL_COPY_BLEND_PREMULTIPLIED:
  5459. MULT_DIV_255((255 - srcA), dstR, dstR);
  5460. dstR += srcR;
  5461. if (dstR > 255) dstR = 255;
  5462. MULT_DIV_255((255 - srcA), dstG, dstG);
  5463. dstG += srcG;
  5464. if (dstG > 255) dstG = 255;
  5465. MULT_DIV_255((255 - srcA), dstB, dstB);
  5466. dstB += srcB;
  5467. if (dstB > 255) dstB = 255;
  5468. break;
  5469. case SDL_COPY_ADD:
  5470. case SDL_COPY_ADD_PREMULTIPLIED:
  5471. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5472. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5473. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5474. break;
  5475. case SDL_COPY_MOD:
  5476. MULT_DIV_255(srcR, dstR, dstR);
  5477. MULT_DIV_255(srcG, dstG, dstG);
  5478. MULT_DIV_255(srcB, dstB, dstB);
  5479. break;
  5480. case SDL_COPY_MUL:
  5481. {
  5482. Uint32 tmp1, tmp2;
  5483. MULT_DIV_255(srcR, dstR, tmp1);
  5484. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5485. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5486. MULT_DIV_255(srcG, dstG, tmp1);
  5487. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5488. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5489. MULT_DIV_255(srcB, dstB, tmp1);
  5490. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5491. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5492. }
  5493. break;
  5494. }
  5495. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5496. *dst = dstpixel;
  5497. ++src;
  5498. ++dst;
  5499. }
  5500. info->src += info->src_pitch;
  5501. info->dst += info->dst_pitch;
  5502. }
  5503. }
  5504. static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5505. {
  5506. const int flags = info->flags;
  5507. const Uint32 modulateR = info->r;
  5508. const Uint32 modulateG = info->g;
  5509. const Uint32 modulateB = info->b;
  5510. const Uint32 modulateA = info->a;
  5511. Uint32 srcpixel;
  5512. Uint32 srcR, srcG, srcB, srcA;
  5513. Uint32 dstpixel;
  5514. Uint32 dstR, dstG, dstB;
  5515. Uint64 srcy, srcx;
  5516. Uint64 posy, posx;
  5517. Uint64 incy, incx;
  5518. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5519. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5520. posy = incy / 2;
  5521. while (info->dst_h--) {
  5522. Uint32 *src = 0;
  5523. Uint32 *dst = (Uint32 *)info->dst;
  5524. int n = info->dst_w;
  5525. posx = incx / 2;
  5526. srcy = posy >> 16;
  5527. while (n--) {
  5528. srcx = posx >> 16;
  5529. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5530. srcpixel = *src;
  5531. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5532. dstpixel = *dst;
  5533. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5534. if (flags & SDL_COPY_MODULATE_COLOR) {
  5535. MULT_DIV_255(srcR, modulateR, srcR);
  5536. MULT_DIV_255(srcG, modulateG, srcG);
  5537. MULT_DIV_255(srcB, modulateB, srcB);
  5538. }
  5539. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5540. MULT_DIV_255(srcA, modulateA, srcA);
  5541. }
  5542. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5543. if (srcA < 255) {
  5544. MULT_DIV_255(srcR, srcA, srcR);
  5545. MULT_DIV_255(srcG, srcA, srcG);
  5546. MULT_DIV_255(srcB, srcA, srcB);
  5547. }
  5548. }
  5549. switch (flags & SDL_COPY_BLEND_MASK) {
  5550. case SDL_COPY_BLEND:
  5551. MULT_DIV_255((255 - srcA), dstR, dstR);
  5552. dstR += srcR;
  5553. MULT_DIV_255((255 - srcA), dstG, dstG);
  5554. dstG += srcG;
  5555. MULT_DIV_255((255 - srcA), dstB, dstB);
  5556. dstB += srcB;
  5557. break;
  5558. case SDL_COPY_BLEND_PREMULTIPLIED:
  5559. MULT_DIV_255((255 - srcA), dstR, dstR);
  5560. dstR += srcR;
  5561. if (dstR > 255) dstR = 255;
  5562. MULT_DIV_255((255 - srcA), dstG, dstG);
  5563. dstG += srcG;
  5564. if (dstG > 255) dstG = 255;
  5565. MULT_DIV_255((255 - srcA), dstB, dstB);
  5566. dstB += srcB;
  5567. if (dstB > 255) dstB = 255;
  5568. break;
  5569. case SDL_COPY_ADD:
  5570. case SDL_COPY_ADD_PREMULTIPLIED:
  5571. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5572. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5573. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5574. break;
  5575. case SDL_COPY_MOD:
  5576. MULT_DIV_255(srcR, dstR, dstR);
  5577. MULT_DIV_255(srcG, dstG, dstG);
  5578. MULT_DIV_255(srcB, dstB, dstB);
  5579. break;
  5580. case SDL_COPY_MUL:
  5581. {
  5582. Uint32 tmp1, tmp2;
  5583. MULT_DIV_255(srcR, dstR, tmp1);
  5584. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5585. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5586. MULT_DIV_255(srcG, dstG, tmp1);
  5587. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5588. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5589. MULT_DIV_255(srcB, dstB, tmp1);
  5590. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5591. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5592. }
  5593. break;
  5594. }
  5595. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5596. *dst = dstpixel;
  5597. posx += incx;
  5598. ++dst;
  5599. }
  5600. posy += incy;
  5601. info->dst += info->dst_pitch;
  5602. }
  5603. }
  5604. static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
  5605. {
  5606. Uint32 pixel;
  5607. Uint32 R, G, B;
  5608. Uint64 srcy, srcx;
  5609. Uint64 posy, posx;
  5610. Uint64 incy, incx;
  5611. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5612. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5613. posy = incy / 2;
  5614. while (info->dst_h--) {
  5615. Uint32 *src = 0;
  5616. Uint32 *dst = (Uint32 *)info->dst;
  5617. int n = info->dst_w;
  5618. posx = incx / 2;
  5619. srcy = posy >> 16;
  5620. while (n--) {
  5621. srcx = posx >> 16;
  5622. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5623. pixel = *src;
  5624. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5625. pixel = (B << 16) | (G << 8) | R;
  5626. *dst = pixel;
  5627. posx += incx;
  5628. ++dst;
  5629. }
  5630. posy += incy;
  5631. info->dst += info->dst_pitch;
  5632. }
  5633. }
  5634. static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
  5635. {
  5636. const int flags = info->flags;
  5637. Uint32 srcpixel;
  5638. Uint32 srcR, srcG, srcB, srcA;
  5639. Uint32 dstpixel;
  5640. Uint32 dstR, dstG, dstB;
  5641. while (info->dst_h--) {
  5642. Uint32 *src = (Uint32 *)info->src;
  5643. Uint32 *dst = (Uint32 *)info->dst;
  5644. int n = info->dst_w;
  5645. while (n--) {
  5646. srcpixel = *src;
  5647. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5648. dstpixel = *dst;
  5649. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5650. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5651. if (srcA < 255) {
  5652. MULT_DIV_255(srcR, srcA, srcR);
  5653. MULT_DIV_255(srcG, srcA, srcG);
  5654. MULT_DIV_255(srcB, srcA, srcB);
  5655. }
  5656. }
  5657. switch (flags & SDL_COPY_BLEND_MASK) {
  5658. case SDL_COPY_BLEND:
  5659. MULT_DIV_255((255 - srcA), dstR, dstR);
  5660. dstR += srcR;
  5661. MULT_DIV_255((255 - srcA), dstG, dstG);
  5662. dstG += srcG;
  5663. MULT_DIV_255((255 - srcA), dstB, dstB);
  5664. dstB += srcB;
  5665. break;
  5666. case SDL_COPY_BLEND_PREMULTIPLIED:
  5667. MULT_DIV_255((255 - srcA), dstR, dstR);
  5668. dstR += srcR;
  5669. if (dstR > 255) dstR = 255;
  5670. MULT_DIV_255((255 - srcA), dstG, dstG);
  5671. dstG += srcG;
  5672. if (dstG > 255) dstG = 255;
  5673. MULT_DIV_255((255 - srcA), dstB, dstB);
  5674. dstB += srcB;
  5675. if (dstB > 255) dstB = 255;
  5676. break;
  5677. case SDL_COPY_ADD:
  5678. case SDL_COPY_ADD_PREMULTIPLIED:
  5679. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5680. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5681. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5682. break;
  5683. case SDL_COPY_MOD:
  5684. MULT_DIV_255(srcR, dstR, dstR);
  5685. MULT_DIV_255(srcG, dstG, dstG);
  5686. MULT_DIV_255(srcB, dstB, dstB);
  5687. break;
  5688. case SDL_COPY_MUL:
  5689. {
  5690. Uint32 tmp1, tmp2;
  5691. MULT_DIV_255(srcR, dstR, tmp1);
  5692. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5693. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5694. MULT_DIV_255(srcG, dstG, tmp1);
  5695. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5696. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5697. MULT_DIV_255(srcB, dstB, tmp1);
  5698. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5699. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5700. }
  5701. break;
  5702. }
  5703. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5704. *dst = dstpixel;
  5705. ++src;
  5706. ++dst;
  5707. }
  5708. info->src += info->src_pitch;
  5709. info->dst += info->dst_pitch;
  5710. }
  5711. }
  5712. static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  5713. {
  5714. const int flags = info->flags;
  5715. Uint32 srcpixel;
  5716. Uint32 srcR, srcG, srcB, srcA;
  5717. Uint32 dstpixel;
  5718. Uint32 dstR, dstG, dstB;
  5719. Uint64 srcy, srcx;
  5720. Uint64 posy, posx;
  5721. Uint64 incy, incx;
  5722. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5723. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5724. posy = incy / 2;
  5725. while (info->dst_h--) {
  5726. Uint32 *src = 0;
  5727. Uint32 *dst = (Uint32 *)info->dst;
  5728. int n = info->dst_w;
  5729. posx = incx / 2;
  5730. srcy = posy >> 16;
  5731. while (n--) {
  5732. srcx = posx >> 16;
  5733. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5734. srcpixel = *src;
  5735. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5736. dstpixel = *dst;
  5737. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5738. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5739. if (srcA < 255) {
  5740. MULT_DIV_255(srcR, srcA, srcR);
  5741. MULT_DIV_255(srcG, srcA, srcG);
  5742. MULT_DIV_255(srcB, srcA, srcB);
  5743. }
  5744. }
  5745. switch (flags & SDL_COPY_BLEND_MASK) {
  5746. case SDL_COPY_BLEND:
  5747. MULT_DIV_255((255 - srcA), dstR, dstR);
  5748. dstR += srcR;
  5749. MULT_DIV_255((255 - srcA), dstG, dstG);
  5750. dstG += srcG;
  5751. MULT_DIV_255((255 - srcA), dstB, dstB);
  5752. dstB += srcB;
  5753. break;
  5754. case SDL_COPY_BLEND_PREMULTIPLIED:
  5755. MULT_DIV_255((255 - srcA), dstR, dstR);
  5756. dstR += srcR;
  5757. if (dstR > 255) dstR = 255;
  5758. MULT_DIV_255((255 - srcA), dstG, dstG);
  5759. dstG += srcG;
  5760. if (dstG > 255) dstG = 255;
  5761. MULT_DIV_255((255 - srcA), dstB, dstB);
  5762. dstB += srcB;
  5763. if (dstB > 255) dstB = 255;
  5764. break;
  5765. case SDL_COPY_ADD:
  5766. case SDL_COPY_ADD_PREMULTIPLIED:
  5767. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5768. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5769. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5770. break;
  5771. case SDL_COPY_MOD:
  5772. MULT_DIV_255(srcR, dstR, dstR);
  5773. MULT_DIV_255(srcG, dstG, dstG);
  5774. MULT_DIV_255(srcB, dstB, dstB);
  5775. break;
  5776. case SDL_COPY_MUL:
  5777. {
  5778. Uint32 tmp1, tmp2;
  5779. MULT_DIV_255(srcR, dstR, tmp1);
  5780. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5781. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5782. MULT_DIV_255(srcG, dstG, tmp1);
  5783. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5784. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5785. MULT_DIV_255(srcB, dstB, tmp1);
  5786. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5787. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5788. }
  5789. break;
  5790. }
  5791. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5792. *dst = dstpixel;
  5793. posx += incx;
  5794. ++dst;
  5795. }
  5796. posy += incy;
  5797. info->dst += info->dst_pitch;
  5798. }
  5799. }
  5800. static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  5801. {
  5802. const int flags = info->flags;
  5803. const Uint32 modulateR = info->r;
  5804. const Uint32 modulateG = info->g;
  5805. const Uint32 modulateB = info->b;
  5806. Uint32 pixel;
  5807. Uint32 R, G, B;
  5808. while (info->dst_h--) {
  5809. Uint32 *src = (Uint32 *)info->src;
  5810. Uint32 *dst = (Uint32 *)info->dst;
  5811. int n = info->dst_w;
  5812. while (n--) {
  5813. pixel = *src;
  5814. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5815. if (flags & SDL_COPY_MODULATE_COLOR) {
  5816. MULT_DIV_255(R, modulateR, R);
  5817. MULT_DIV_255(G, modulateG, G);
  5818. MULT_DIV_255(B, modulateB, B);
  5819. }
  5820. pixel = (B << 16) | (G << 8) | R;
  5821. *dst = pixel;
  5822. ++src;
  5823. ++dst;
  5824. }
  5825. info->src += info->src_pitch;
  5826. info->dst += info->dst_pitch;
  5827. }
  5828. }
  5829. static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  5830. {
  5831. const int flags = info->flags;
  5832. const Uint32 modulateR = info->r;
  5833. const Uint32 modulateG = info->g;
  5834. const Uint32 modulateB = info->b;
  5835. Uint32 pixel;
  5836. Uint32 R, G, B;
  5837. Uint64 srcy, srcx;
  5838. Uint64 posy, posx;
  5839. Uint64 incy, incx;
  5840. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5841. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5842. posy = incy / 2;
  5843. while (info->dst_h--) {
  5844. Uint32 *src = 0;
  5845. Uint32 *dst = (Uint32 *)info->dst;
  5846. int n = info->dst_w;
  5847. posx = incx / 2;
  5848. srcy = posy >> 16;
  5849. while (n--) {
  5850. srcx = posx >> 16;
  5851. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5852. pixel = *src;
  5853. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  5854. if (flags & SDL_COPY_MODULATE_COLOR) {
  5855. MULT_DIV_255(R, modulateR, R);
  5856. MULT_DIV_255(G, modulateG, G);
  5857. MULT_DIV_255(B, modulateB, B);
  5858. }
  5859. pixel = (B << 16) | (G << 8) | R;
  5860. *dst = pixel;
  5861. posx += incx;
  5862. ++dst;
  5863. }
  5864. posy += incy;
  5865. info->dst += info->dst_pitch;
  5866. }
  5867. }
  5868. static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  5869. {
  5870. const int flags = info->flags;
  5871. const Uint32 modulateR = info->r;
  5872. const Uint32 modulateG = info->g;
  5873. const Uint32 modulateB = info->b;
  5874. const Uint32 modulateA = info->a;
  5875. Uint32 srcpixel;
  5876. Uint32 srcR, srcG, srcB, srcA;
  5877. Uint32 dstpixel;
  5878. Uint32 dstR, dstG, dstB;
  5879. while (info->dst_h--) {
  5880. Uint32 *src = (Uint32 *)info->src;
  5881. Uint32 *dst = (Uint32 *)info->dst;
  5882. int n = info->dst_w;
  5883. while (n--) {
  5884. srcpixel = *src;
  5885. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5886. dstpixel = *dst;
  5887. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5888. if (flags & SDL_COPY_MODULATE_COLOR) {
  5889. MULT_DIV_255(srcR, modulateR, srcR);
  5890. MULT_DIV_255(srcG, modulateG, srcG);
  5891. MULT_DIV_255(srcB, modulateB, srcB);
  5892. }
  5893. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5894. MULT_DIV_255(srcA, modulateA, srcA);
  5895. }
  5896. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5897. if (srcA < 255) {
  5898. MULT_DIV_255(srcR, srcA, srcR);
  5899. MULT_DIV_255(srcG, srcA, srcG);
  5900. MULT_DIV_255(srcB, srcA, srcB);
  5901. }
  5902. }
  5903. switch (flags & SDL_COPY_BLEND_MASK) {
  5904. case SDL_COPY_BLEND:
  5905. MULT_DIV_255((255 - srcA), dstR, dstR);
  5906. dstR += srcR;
  5907. MULT_DIV_255((255 - srcA), dstG, dstG);
  5908. dstG += srcG;
  5909. MULT_DIV_255((255 - srcA), dstB, dstB);
  5910. dstB += srcB;
  5911. break;
  5912. case SDL_COPY_BLEND_PREMULTIPLIED:
  5913. MULT_DIV_255((255 - srcA), dstR, dstR);
  5914. dstR += srcR;
  5915. if (dstR > 255) dstR = 255;
  5916. MULT_DIV_255((255 - srcA), dstG, dstG);
  5917. dstG += srcG;
  5918. if (dstG > 255) dstG = 255;
  5919. MULT_DIV_255((255 - srcA), dstB, dstB);
  5920. dstB += srcB;
  5921. if (dstB > 255) dstB = 255;
  5922. break;
  5923. case SDL_COPY_ADD:
  5924. case SDL_COPY_ADD_PREMULTIPLIED:
  5925. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5926. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5927. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5928. break;
  5929. case SDL_COPY_MOD:
  5930. MULT_DIV_255(srcR, dstR, dstR);
  5931. MULT_DIV_255(srcG, dstG, dstG);
  5932. MULT_DIV_255(srcB, dstB, dstB);
  5933. break;
  5934. case SDL_COPY_MUL:
  5935. {
  5936. Uint32 tmp1, tmp2;
  5937. MULT_DIV_255(srcR, dstR, tmp1);
  5938. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  5939. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  5940. MULT_DIV_255(srcG, dstG, tmp1);
  5941. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  5942. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  5943. MULT_DIV_255(srcB, dstB, tmp1);
  5944. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  5945. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  5946. }
  5947. break;
  5948. }
  5949. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5950. *dst = dstpixel;
  5951. ++src;
  5952. ++dst;
  5953. }
  5954. info->src += info->src_pitch;
  5955. info->dst += info->dst_pitch;
  5956. }
  5957. }
  5958. static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5959. {
  5960. const int flags = info->flags;
  5961. const Uint32 modulateR = info->r;
  5962. const Uint32 modulateG = info->g;
  5963. const Uint32 modulateB = info->b;
  5964. const Uint32 modulateA = info->a;
  5965. Uint32 srcpixel;
  5966. Uint32 srcR, srcG, srcB, srcA;
  5967. Uint32 dstpixel;
  5968. Uint32 dstR, dstG, dstB;
  5969. Uint64 srcy, srcx;
  5970. Uint64 posy, posx;
  5971. Uint64 incy, incx;
  5972. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  5973. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  5974. posy = incy / 2;
  5975. while (info->dst_h--) {
  5976. Uint32 *src = 0;
  5977. Uint32 *dst = (Uint32 *)info->dst;
  5978. int n = info->dst_w;
  5979. posx = incx / 2;
  5980. srcy = posy >> 16;
  5981. while (n--) {
  5982. srcx = posx >> 16;
  5983. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5984. srcpixel = *src;
  5985. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  5986. dstpixel = *dst;
  5987. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5988. if (flags & SDL_COPY_MODULATE_COLOR) {
  5989. MULT_DIV_255(srcR, modulateR, srcR);
  5990. MULT_DIV_255(srcG, modulateG, srcG);
  5991. MULT_DIV_255(srcB, modulateB, srcB);
  5992. }
  5993. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5994. MULT_DIV_255(srcA, modulateA, srcA);
  5995. }
  5996. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5997. if (srcA < 255) {
  5998. MULT_DIV_255(srcR, srcA, srcR);
  5999. MULT_DIV_255(srcG, srcA, srcG);
  6000. MULT_DIV_255(srcB, srcA, srcB);
  6001. }
  6002. }
  6003. switch (flags & SDL_COPY_BLEND_MASK) {
  6004. case SDL_COPY_BLEND:
  6005. MULT_DIV_255((255 - srcA), dstR, dstR);
  6006. dstR += srcR;
  6007. MULT_DIV_255((255 - srcA), dstG, dstG);
  6008. dstG += srcG;
  6009. MULT_DIV_255((255 - srcA), dstB, dstB);
  6010. dstB += srcB;
  6011. break;
  6012. case SDL_COPY_BLEND_PREMULTIPLIED:
  6013. MULT_DIV_255((255 - srcA), dstR, dstR);
  6014. dstR += srcR;
  6015. if (dstR > 255) dstR = 255;
  6016. MULT_DIV_255((255 - srcA), dstG, dstG);
  6017. dstG += srcG;
  6018. if (dstG > 255) dstG = 255;
  6019. MULT_DIV_255((255 - srcA), dstB, dstB);
  6020. dstB += srcB;
  6021. if (dstB > 255) dstB = 255;
  6022. break;
  6023. case SDL_COPY_ADD:
  6024. case SDL_COPY_ADD_PREMULTIPLIED:
  6025. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6026. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6027. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6028. break;
  6029. case SDL_COPY_MOD:
  6030. MULT_DIV_255(srcR, dstR, dstR);
  6031. MULT_DIV_255(srcG, dstG, dstG);
  6032. MULT_DIV_255(srcB, dstB, dstB);
  6033. break;
  6034. case SDL_COPY_MUL:
  6035. {
  6036. Uint32 tmp1, tmp2;
  6037. MULT_DIV_255(srcR, dstR, tmp1);
  6038. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6039. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6040. MULT_DIV_255(srcG, dstG, tmp1);
  6041. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6042. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6043. MULT_DIV_255(srcB, dstB, tmp1);
  6044. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6045. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6046. }
  6047. break;
  6048. }
  6049. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  6050. *dst = dstpixel;
  6051. posx += incx;
  6052. ++dst;
  6053. }
  6054. posy += incy;
  6055. info->dst += info->dst_pitch;
  6056. }
  6057. }
  6058. static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  6059. {
  6060. Uint32 pixel;
  6061. Uint64 srcy, srcx;
  6062. Uint64 posy, posx;
  6063. Uint64 incy, incx;
  6064. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6065. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6066. posy = incy / 2;
  6067. while (info->dst_h--) {
  6068. Uint32 *src = 0;
  6069. Uint32 *dst = (Uint32 *)info->dst;
  6070. int n = info->dst_w;
  6071. posx = incx / 2;
  6072. srcy = posy >> 16;
  6073. while (n--) {
  6074. srcx = posx >> 16;
  6075. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6076. pixel = *src;
  6077. pixel = (pixel >> 8) | (pixel << 24);
  6078. *dst = pixel;
  6079. posx += incx;
  6080. ++dst;
  6081. }
  6082. posy += incy;
  6083. info->dst += info->dst_pitch;
  6084. }
  6085. }
  6086. static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  6087. {
  6088. const int flags = info->flags;
  6089. Uint32 srcpixel;
  6090. Uint32 srcR, srcG, srcB, srcA;
  6091. Uint32 dstpixel;
  6092. Uint32 dstR, dstG, dstB, dstA;
  6093. while (info->dst_h--) {
  6094. Uint32 *src = (Uint32 *)info->src;
  6095. Uint32 *dst = (Uint32 *)info->dst;
  6096. int n = info->dst_w;
  6097. while (n--) {
  6098. srcpixel = *src;
  6099. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6100. dstpixel = *dst;
  6101. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6102. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6103. if (srcA < 255) {
  6104. MULT_DIV_255(srcR, srcA, srcR);
  6105. MULT_DIV_255(srcG, srcA, srcG);
  6106. MULT_DIV_255(srcB, srcA, srcB);
  6107. }
  6108. }
  6109. switch (flags & SDL_COPY_BLEND_MASK) {
  6110. case SDL_COPY_BLEND:
  6111. MULT_DIV_255((255 - srcA), dstR, dstR);
  6112. dstR += srcR;
  6113. MULT_DIV_255((255 - srcA), dstG, dstG);
  6114. dstG += srcG;
  6115. MULT_DIV_255((255 - srcA), dstB, dstB);
  6116. dstB += srcB;
  6117. MULT_DIV_255((255 - srcA), dstA, dstA);
  6118. dstA += srcA;
  6119. break;
  6120. case SDL_COPY_BLEND_PREMULTIPLIED:
  6121. MULT_DIV_255((255 - srcA), dstR, dstR);
  6122. dstR += srcR;
  6123. if (dstR > 255) dstR = 255;
  6124. MULT_DIV_255((255 - srcA), dstG, dstG);
  6125. dstG += srcG;
  6126. if (dstG > 255) dstG = 255;
  6127. MULT_DIV_255((255 - srcA), dstB, dstB);
  6128. dstB += srcB;
  6129. if (dstB > 255) dstB = 255;
  6130. MULT_DIV_255((255 - srcA), dstA, dstA);
  6131. dstA += srcA;
  6132. if (dstA > 255) dstA = 255;
  6133. break;
  6134. case SDL_COPY_ADD:
  6135. case SDL_COPY_ADD_PREMULTIPLIED:
  6136. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6137. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6138. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6139. break;
  6140. case SDL_COPY_MOD:
  6141. MULT_DIV_255(srcR, dstR, dstR);
  6142. MULT_DIV_255(srcG, dstG, dstG);
  6143. MULT_DIV_255(srcB, dstB, dstB);
  6144. break;
  6145. case SDL_COPY_MUL:
  6146. {
  6147. Uint32 tmp1, tmp2;
  6148. MULT_DIV_255(srcR, dstR, tmp1);
  6149. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6150. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6151. MULT_DIV_255(srcG, dstG, tmp1);
  6152. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6153. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6154. MULT_DIV_255(srcB, dstB, tmp1);
  6155. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6156. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6157. }
  6158. break;
  6159. }
  6160. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6161. *dst = dstpixel;
  6162. ++src;
  6163. ++dst;
  6164. }
  6165. info->src += info->src_pitch;
  6166. info->dst += info->dst_pitch;
  6167. }
  6168. }
  6169. static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  6170. {
  6171. const int flags = info->flags;
  6172. Uint32 srcpixel;
  6173. Uint32 srcR, srcG, srcB, srcA;
  6174. Uint32 dstpixel;
  6175. Uint32 dstR, dstG, dstB, dstA;
  6176. Uint64 srcy, srcx;
  6177. Uint64 posy, posx;
  6178. Uint64 incy, incx;
  6179. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6180. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6181. posy = incy / 2;
  6182. while (info->dst_h--) {
  6183. Uint32 *src = 0;
  6184. Uint32 *dst = (Uint32 *)info->dst;
  6185. int n = info->dst_w;
  6186. posx = incx / 2;
  6187. srcy = posy >> 16;
  6188. while (n--) {
  6189. srcx = posx >> 16;
  6190. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6191. srcpixel = *src;
  6192. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6193. dstpixel = *dst;
  6194. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6195. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6196. if (srcA < 255) {
  6197. MULT_DIV_255(srcR, srcA, srcR);
  6198. MULT_DIV_255(srcG, srcA, srcG);
  6199. MULT_DIV_255(srcB, srcA, srcB);
  6200. }
  6201. }
  6202. switch (flags & SDL_COPY_BLEND_MASK) {
  6203. case SDL_COPY_BLEND:
  6204. MULT_DIV_255((255 - srcA), dstR, dstR);
  6205. dstR += srcR;
  6206. MULT_DIV_255((255 - srcA), dstG, dstG);
  6207. dstG += srcG;
  6208. MULT_DIV_255((255 - srcA), dstB, dstB);
  6209. dstB += srcB;
  6210. MULT_DIV_255((255 - srcA), dstA, dstA);
  6211. dstA += srcA;
  6212. break;
  6213. case SDL_COPY_BLEND_PREMULTIPLIED:
  6214. MULT_DIV_255((255 - srcA), dstR, dstR);
  6215. dstR += srcR;
  6216. if (dstR > 255) dstR = 255;
  6217. MULT_DIV_255((255 - srcA), dstG, dstG);
  6218. dstG += srcG;
  6219. if (dstG > 255) dstG = 255;
  6220. MULT_DIV_255((255 - srcA), dstB, dstB);
  6221. dstB += srcB;
  6222. if (dstB > 255) dstB = 255;
  6223. MULT_DIV_255((255 - srcA), dstA, dstA);
  6224. dstA += srcA;
  6225. if (dstA > 255) dstA = 255;
  6226. break;
  6227. case SDL_COPY_ADD:
  6228. case SDL_COPY_ADD_PREMULTIPLIED:
  6229. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6230. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6231. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6232. break;
  6233. case SDL_COPY_MOD:
  6234. MULT_DIV_255(srcR, dstR, dstR);
  6235. MULT_DIV_255(srcG, dstG, dstG);
  6236. MULT_DIV_255(srcB, dstB, dstB);
  6237. break;
  6238. case SDL_COPY_MUL:
  6239. {
  6240. Uint32 tmp1, tmp2;
  6241. MULT_DIV_255(srcR, dstR, tmp1);
  6242. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6243. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6244. MULT_DIV_255(srcG, dstG, tmp1);
  6245. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6246. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6247. MULT_DIV_255(srcB, dstB, tmp1);
  6248. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6249. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6250. }
  6251. break;
  6252. }
  6253. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6254. *dst = dstpixel;
  6255. posx += incx;
  6256. ++dst;
  6257. }
  6258. posy += incy;
  6259. info->dst += info->dst_pitch;
  6260. }
  6261. }
  6262. static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  6263. {
  6264. const int flags = info->flags;
  6265. const Uint32 modulateR = info->r;
  6266. const Uint32 modulateG = info->g;
  6267. const Uint32 modulateB = info->b;
  6268. const Uint32 modulateA = info->a;
  6269. Uint32 pixel;
  6270. Uint32 R, G, B, A;
  6271. while (info->dst_h--) {
  6272. Uint32 *src = (Uint32 *)info->src;
  6273. Uint32 *dst = (Uint32 *)info->dst;
  6274. int n = info->dst_w;
  6275. while (n--) {
  6276. pixel = *src;
  6277. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6278. if (flags & SDL_COPY_MODULATE_COLOR) {
  6279. MULT_DIV_255(R, modulateR, R);
  6280. MULT_DIV_255(G, modulateG, G);
  6281. MULT_DIV_255(B, modulateB, B);
  6282. }
  6283. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6284. MULT_DIV_255(A, modulateA, A);
  6285. }
  6286. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  6287. *dst = pixel;
  6288. ++src;
  6289. ++dst;
  6290. }
  6291. info->src += info->src_pitch;
  6292. info->dst += info->dst_pitch;
  6293. }
  6294. }
  6295. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  6296. {
  6297. const int flags = info->flags;
  6298. const Uint32 modulateR = info->r;
  6299. const Uint32 modulateG = info->g;
  6300. const Uint32 modulateB = info->b;
  6301. const Uint32 modulateA = info->a;
  6302. Uint32 pixel;
  6303. Uint32 R, G, B, A;
  6304. Uint64 srcy, srcx;
  6305. Uint64 posy, posx;
  6306. Uint64 incy, incx;
  6307. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6308. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6309. posy = incy / 2;
  6310. while (info->dst_h--) {
  6311. Uint32 *src = 0;
  6312. Uint32 *dst = (Uint32 *)info->dst;
  6313. int n = info->dst_w;
  6314. posx = incx / 2;
  6315. srcy = posy >> 16;
  6316. while (n--) {
  6317. srcx = posx >> 16;
  6318. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6319. pixel = *src;
  6320. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6321. if (flags & SDL_COPY_MODULATE_COLOR) {
  6322. MULT_DIV_255(R, modulateR, R);
  6323. MULT_DIV_255(G, modulateG, G);
  6324. MULT_DIV_255(B, modulateB, B);
  6325. }
  6326. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6327. MULT_DIV_255(A, modulateA, A);
  6328. }
  6329. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  6330. *dst = pixel;
  6331. posx += incx;
  6332. ++dst;
  6333. }
  6334. posy += incy;
  6335. info->dst += info->dst_pitch;
  6336. }
  6337. }
  6338. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  6339. {
  6340. const int flags = info->flags;
  6341. const Uint32 modulateR = info->r;
  6342. const Uint32 modulateG = info->g;
  6343. const Uint32 modulateB = info->b;
  6344. const Uint32 modulateA = info->a;
  6345. Uint32 srcpixel;
  6346. Uint32 srcR, srcG, srcB, srcA;
  6347. Uint32 dstpixel;
  6348. Uint32 dstR, dstG, dstB, dstA;
  6349. while (info->dst_h--) {
  6350. Uint32 *src = (Uint32 *)info->src;
  6351. Uint32 *dst = (Uint32 *)info->dst;
  6352. int n = info->dst_w;
  6353. while (n--) {
  6354. srcpixel = *src;
  6355. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6356. dstpixel = *dst;
  6357. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6358. if (flags & SDL_COPY_MODULATE_COLOR) {
  6359. MULT_DIV_255(srcR, modulateR, srcR);
  6360. MULT_DIV_255(srcG, modulateG, srcG);
  6361. MULT_DIV_255(srcB, modulateB, srcB);
  6362. }
  6363. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6364. MULT_DIV_255(srcA, modulateA, srcA);
  6365. }
  6366. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6367. if (srcA < 255) {
  6368. MULT_DIV_255(srcR, srcA, srcR);
  6369. MULT_DIV_255(srcG, srcA, srcG);
  6370. MULT_DIV_255(srcB, srcA, srcB);
  6371. }
  6372. }
  6373. switch (flags & SDL_COPY_BLEND_MASK) {
  6374. case SDL_COPY_BLEND:
  6375. MULT_DIV_255((255 - srcA), dstR, dstR);
  6376. dstR += srcR;
  6377. MULT_DIV_255((255 - srcA), dstG, dstG);
  6378. dstG += srcG;
  6379. MULT_DIV_255((255 - srcA), dstB, dstB);
  6380. dstB += srcB;
  6381. MULT_DIV_255((255 - srcA), dstA, dstA);
  6382. dstA += srcA;
  6383. break;
  6384. case SDL_COPY_BLEND_PREMULTIPLIED:
  6385. MULT_DIV_255((255 - srcA), dstR, dstR);
  6386. dstR += srcR;
  6387. if (dstR > 255) dstR = 255;
  6388. MULT_DIV_255((255 - srcA), dstG, dstG);
  6389. dstG += srcG;
  6390. if (dstG > 255) dstG = 255;
  6391. MULT_DIV_255((255 - srcA), dstB, dstB);
  6392. dstB += srcB;
  6393. if (dstB > 255) dstB = 255;
  6394. MULT_DIV_255((255 - srcA), dstA, dstA);
  6395. dstA += srcA;
  6396. if (dstA > 255) dstA = 255;
  6397. break;
  6398. case SDL_COPY_ADD:
  6399. case SDL_COPY_ADD_PREMULTIPLIED:
  6400. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6401. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6402. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6403. break;
  6404. case SDL_COPY_MOD:
  6405. MULT_DIV_255(srcR, dstR, dstR);
  6406. MULT_DIV_255(srcG, dstG, dstG);
  6407. MULT_DIV_255(srcB, dstB, dstB);
  6408. break;
  6409. case SDL_COPY_MUL:
  6410. {
  6411. Uint32 tmp1, tmp2;
  6412. MULT_DIV_255(srcR, dstR, tmp1);
  6413. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6414. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6415. MULT_DIV_255(srcG, dstG, tmp1);
  6416. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6417. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6418. MULT_DIV_255(srcB, dstB, tmp1);
  6419. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6420. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6421. }
  6422. break;
  6423. }
  6424. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6425. *dst = dstpixel;
  6426. ++src;
  6427. ++dst;
  6428. }
  6429. info->src += info->src_pitch;
  6430. info->dst += info->dst_pitch;
  6431. }
  6432. }
  6433. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6434. {
  6435. const int flags = info->flags;
  6436. const Uint32 modulateR = info->r;
  6437. const Uint32 modulateG = info->g;
  6438. const Uint32 modulateB = info->b;
  6439. const Uint32 modulateA = info->a;
  6440. Uint32 srcpixel;
  6441. Uint32 srcR, srcG, srcB, srcA;
  6442. Uint32 dstpixel;
  6443. Uint32 dstR, dstG, dstB, dstA;
  6444. Uint64 srcy, srcx;
  6445. Uint64 posy, posx;
  6446. Uint64 incy, incx;
  6447. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6448. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6449. posy = incy / 2;
  6450. while (info->dst_h--) {
  6451. Uint32 *src = 0;
  6452. Uint32 *dst = (Uint32 *)info->dst;
  6453. int n = info->dst_w;
  6454. posx = incx / 2;
  6455. srcy = posy >> 16;
  6456. while (n--) {
  6457. srcx = posx >> 16;
  6458. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6459. srcpixel = *src;
  6460. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6461. dstpixel = *dst;
  6462. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6463. if (flags & SDL_COPY_MODULATE_COLOR) {
  6464. MULT_DIV_255(srcR, modulateR, srcR);
  6465. MULT_DIV_255(srcG, modulateG, srcG);
  6466. MULT_DIV_255(srcB, modulateB, srcB);
  6467. }
  6468. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6469. MULT_DIV_255(srcA, modulateA, srcA);
  6470. }
  6471. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6472. if (srcA < 255) {
  6473. MULT_DIV_255(srcR, srcA, srcR);
  6474. MULT_DIV_255(srcG, srcA, srcG);
  6475. MULT_DIV_255(srcB, srcA, srcB);
  6476. }
  6477. }
  6478. switch (flags & SDL_COPY_BLEND_MASK) {
  6479. case SDL_COPY_BLEND:
  6480. MULT_DIV_255((255 - srcA), dstR, dstR);
  6481. dstR += srcR;
  6482. MULT_DIV_255((255 - srcA), dstG, dstG);
  6483. dstG += srcG;
  6484. MULT_DIV_255((255 - srcA), dstB, dstB);
  6485. dstB += srcB;
  6486. MULT_DIV_255((255 - srcA), dstA, dstA);
  6487. dstA += srcA;
  6488. break;
  6489. case SDL_COPY_BLEND_PREMULTIPLIED:
  6490. MULT_DIV_255((255 - srcA), dstR, dstR);
  6491. dstR += srcR;
  6492. if (dstR > 255) dstR = 255;
  6493. MULT_DIV_255((255 - srcA), dstG, dstG);
  6494. dstG += srcG;
  6495. if (dstG > 255) dstG = 255;
  6496. MULT_DIV_255((255 - srcA), dstB, dstB);
  6497. dstB += srcB;
  6498. if (dstB > 255) dstB = 255;
  6499. MULT_DIV_255((255 - srcA), dstA, dstA);
  6500. dstA += srcA;
  6501. if (dstA > 255) dstA = 255;
  6502. break;
  6503. case SDL_COPY_ADD:
  6504. case SDL_COPY_ADD_PREMULTIPLIED:
  6505. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6506. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6507. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6508. break;
  6509. case SDL_COPY_MOD:
  6510. MULT_DIV_255(srcR, dstR, dstR);
  6511. MULT_DIV_255(srcG, dstG, dstG);
  6512. MULT_DIV_255(srcB, dstB, dstB);
  6513. break;
  6514. case SDL_COPY_MUL:
  6515. {
  6516. Uint32 tmp1, tmp2;
  6517. MULT_DIV_255(srcR, dstR, tmp1);
  6518. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6519. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6520. MULT_DIV_255(srcG, dstG, tmp1);
  6521. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6522. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6523. MULT_DIV_255(srcB, dstB, tmp1);
  6524. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6525. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6526. }
  6527. break;
  6528. }
  6529. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6530. *dst = dstpixel;
  6531. posx += incx;
  6532. ++dst;
  6533. }
  6534. posy += incy;
  6535. info->dst += info->dst_pitch;
  6536. }
  6537. }
  6538. static void SDL_Blit_RGBA8888_ABGR8888_Scale(SDL_BlitInfo *info)
  6539. {
  6540. Uint32 pixel;
  6541. Uint32 R, G, B, A;
  6542. Uint64 srcy, srcx;
  6543. Uint64 posy, posx;
  6544. Uint64 incy, incx;
  6545. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6546. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6547. posy = incy / 2;
  6548. while (info->dst_h--) {
  6549. Uint32 *src = 0;
  6550. Uint32 *dst = (Uint32 *)info->dst;
  6551. int n = info->dst_w;
  6552. posx = incx / 2;
  6553. srcy = posy >> 16;
  6554. while (n--) {
  6555. srcx = posx >> 16;
  6556. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6557. pixel = *src;
  6558. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6559. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  6560. *dst = pixel;
  6561. posx += incx;
  6562. ++dst;
  6563. }
  6564. posy += incy;
  6565. info->dst += info->dst_pitch;
  6566. }
  6567. }
  6568. static void SDL_Blit_RGBA8888_ABGR8888_Blend(SDL_BlitInfo *info)
  6569. {
  6570. const int flags = info->flags;
  6571. Uint32 srcpixel;
  6572. Uint32 srcR, srcG, srcB, srcA;
  6573. Uint32 dstpixel;
  6574. Uint32 dstR, dstG, dstB, dstA;
  6575. while (info->dst_h--) {
  6576. Uint32 *src = (Uint32 *)info->src;
  6577. Uint32 *dst = (Uint32 *)info->dst;
  6578. int n = info->dst_w;
  6579. while (n--) {
  6580. srcpixel = *src;
  6581. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6582. dstpixel = *dst;
  6583. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6584. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6585. if (srcA < 255) {
  6586. MULT_DIV_255(srcR, srcA, srcR);
  6587. MULT_DIV_255(srcG, srcA, srcG);
  6588. MULT_DIV_255(srcB, srcA, srcB);
  6589. }
  6590. }
  6591. switch (flags & SDL_COPY_BLEND_MASK) {
  6592. case SDL_COPY_BLEND:
  6593. MULT_DIV_255((255 - srcA), dstR, dstR);
  6594. dstR += srcR;
  6595. MULT_DIV_255((255 - srcA), dstG, dstG);
  6596. dstG += srcG;
  6597. MULT_DIV_255((255 - srcA), dstB, dstB);
  6598. dstB += srcB;
  6599. MULT_DIV_255((255 - srcA), dstA, dstA);
  6600. dstA += srcA;
  6601. break;
  6602. case SDL_COPY_BLEND_PREMULTIPLIED:
  6603. MULT_DIV_255((255 - srcA), dstR, dstR);
  6604. dstR += srcR;
  6605. if (dstR > 255) dstR = 255;
  6606. MULT_DIV_255((255 - srcA), dstG, dstG);
  6607. dstG += srcG;
  6608. if (dstG > 255) dstG = 255;
  6609. MULT_DIV_255((255 - srcA), dstB, dstB);
  6610. dstB += srcB;
  6611. if (dstB > 255) dstB = 255;
  6612. MULT_DIV_255((255 - srcA), dstA, dstA);
  6613. dstA += srcA;
  6614. if (dstA > 255) dstA = 255;
  6615. break;
  6616. case SDL_COPY_ADD:
  6617. case SDL_COPY_ADD_PREMULTIPLIED:
  6618. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6619. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6620. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6621. break;
  6622. case SDL_COPY_MOD:
  6623. MULT_DIV_255(srcR, dstR, dstR);
  6624. MULT_DIV_255(srcG, dstG, dstG);
  6625. MULT_DIV_255(srcB, dstB, dstB);
  6626. break;
  6627. case SDL_COPY_MUL:
  6628. {
  6629. Uint32 tmp1, tmp2;
  6630. MULT_DIV_255(srcR, dstR, tmp1);
  6631. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6632. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6633. MULT_DIV_255(srcG, dstG, tmp1);
  6634. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6635. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6636. MULT_DIV_255(srcB, dstB, tmp1);
  6637. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6638. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6639. }
  6640. break;
  6641. }
  6642. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  6643. *dst = dstpixel;
  6644. ++src;
  6645. ++dst;
  6646. }
  6647. info->src += info->src_pitch;
  6648. info->dst += info->dst_pitch;
  6649. }
  6650. }
  6651. static void SDL_Blit_RGBA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  6652. {
  6653. const int flags = info->flags;
  6654. Uint32 srcpixel;
  6655. Uint32 srcR, srcG, srcB, srcA;
  6656. Uint32 dstpixel;
  6657. Uint32 dstR, dstG, dstB, dstA;
  6658. Uint64 srcy, srcx;
  6659. Uint64 posy, posx;
  6660. Uint64 incy, incx;
  6661. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6662. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6663. posy = incy / 2;
  6664. while (info->dst_h--) {
  6665. Uint32 *src = 0;
  6666. Uint32 *dst = (Uint32 *)info->dst;
  6667. int n = info->dst_w;
  6668. posx = incx / 2;
  6669. srcy = posy >> 16;
  6670. while (n--) {
  6671. srcx = posx >> 16;
  6672. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6673. srcpixel = *src;
  6674. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6675. dstpixel = *dst;
  6676. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6677. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6678. if (srcA < 255) {
  6679. MULT_DIV_255(srcR, srcA, srcR);
  6680. MULT_DIV_255(srcG, srcA, srcG);
  6681. MULT_DIV_255(srcB, srcA, srcB);
  6682. }
  6683. }
  6684. switch (flags & SDL_COPY_BLEND_MASK) {
  6685. case SDL_COPY_BLEND:
  6686. MULT_DIV_255((255 - srcA), dstR, dstR);
  6687. dstR += srcR;
  6688. MULT_DIV_255((255 - srcA), dstG, dstG);
  6689. dstG += srcG;
  6690. MULT_DIV_255((255 - srcA), dstB, dstB);
  6691. dstB += srcB;
  6692. MULT_DIV_255((255 - srcA), dstA, dstA);
  6693. dstA += srcA;
  6694. break;
  6695. case SDL_COPY_BLEND_PREMULTIPLIED:
  6696. MULT_DIV_255((255 - srcA), dstR, dstR);
  6697. dstR += srcR;
  6698. if (dstR > 255) dstR = 255;
  6699. MULT_DIV_255((255 - srcA), dstG, dstG);
  6700. dstG += srcG;
  6701. if (dstG > 255) dstG = 255;
  6702. MULT_DIV_255((255 - srcA), dstB, dstB);
  6703. dstB += srcB;
  6704. if (dstB > 255) dstB = 255;
  6705. MULT_DIV_255((255 - srcA), dstA, dstA);
  6706. dstA += srcA;
  6707. if (dstA > 255) dstA = 255;
  6708. break;
  6709. case SDL_COPY_ADD:
  6710. case SDL_COPY_ADD_PREMULTIPLIED:
  6711. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6712. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6713. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6714. break;
  6715. case SDL_COPY_MOD:
  6716. MULT_DIV_255(srcR, dstR, dstR);
  6717. MULT_DIV_255(srcG, dstG, dstG);
  6718. MULT_DIV_255(srcB, dstB, dstB);
  6719. break;
  6720. case SDL_COPY_MUL:
  6721. {
  6722. Uint32 tmp1, tmp2;
  6723. MULT_DIV_255(srcR, dstR, tmp1);
  6724. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6725. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6726. MULT_DIV_255(srcG, dstG, tmp1);
  6727. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6728. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6729. MULT_DIV_255(srcB, dstB, tmp1);
  6730. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6731. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6732. }
  6733. break;
  6734. }
  6735. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  6736. *dst = dstpixel;
  6737. posx += incx;
  6738. ++dst;
  6739. }
  6740. posy += incy;
  6741. info->dst += info->dst_pitch;
  6742. }
  6743. }
  6744. static void SDL_Blit_RGBA8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  6745. {
  6746. const int flags = info->flags;
  6747. const Uint32 modulateR = info->r;
  6748. const Uint32 modulateG = info->g;
  6749. const Uint32 modulateB = info->b;
  6750. const Uint32 modulateA = info->a;
  6751. Uint32 pixel;
  6752. Uint32 R, G, B, A;
  6753. while (info->dst_h--) {
  6754. Uint32 *src = (Uint32 *)info->src;
  6755. Uint32 *dst = (Uint32 *)info->dst;
  6756. int n = info->dst_w;
  6757. while (n--) {
  6758. pixel = *src;
  6759. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6760. if (flags & SDL_COPY_MODULATE_COLOR) {
  6761. MULT_DIV_255(R, modulateR, R);
  6762. MULT_DIV_255(G, modulateG, G);
  6763. MULT_DIV_255(B, modulateB, B);
  6764. }
  6765. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6766. MULT_DIV_255(A, modulateA, A);
  6767. }
  6768. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  6769. *dst = pixel;
  6770. ++src;
  6771. ++dst;
  6772. }
  6773. info->src += info->src_pitch;
  6774. info->dst += info->dst_pitch;
  6775. }
  6776. }
  6777. static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  6778. {
  6779. const int flags = info->flags;
  6780. const Uint32 modulateR = info->r;
  6781. const Uint32 modulateG = info->g;
  6782. const Uint32 modulateB = info->b;
  6783. const Uint32 modulateA = info->a;
  6784. Uint32 pixel;
  6785. Uint32 R, G, B, A;
  6786. Uint64 srcy, srcx;
  6787. Uint64 posy, posx;
  6788. Uint64 incy, incx;
  6789. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6790. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6791. posy = incy / 2;
  6792. while (info->dst_h--) {
  6793. Uint32 *src = 0;
  6794. Uint32 *dst = (Uint32 *)info->dst;
  6795. int n = info->dst_w;
  6796. posx = incx / 2;
  6797. srcy = posy >> 16;
  6798. while (n--) {
  6799. srcx = posx >> 16;
  6800. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6801. pixel = *src;
  6802. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6803. if (flags & SDL_COPY_MODULATE_COLOR) {
  6804. MULT_DIV_255(R, modulateR, R);
  6805. MULT_DIV_255(G, modulateG, G);
  6806. MULT_DIV_255(B, modulateB, B);
  6807. }
  6808. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6809. MULT_DIV_255(A, modulateA, A);
  6810. }
  6811. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  6812. *dst = pixel;
  6813. posx += incx;
  6814. ++dst;
  6815. }
  6816. posy += incy;
  6817. info->dst += info->dst_pitch;
  6818. }
  6819. }
  6820. static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  6821. {
  6822. const int flags = info->flags;
  6823. const Uint32 modulateR = info->r;
  6824. const Uint32 modulateG = info->g;
  6825. const Uint32 modulateB = info->b;
  6826. const Uint32 modulateA = info->a;
  6827. Uint32 srcpixel;
  6828. Uint32 srcR, srcG, srcB, srcA;
  6829. Uint32 dstpixel;
  6830. Uint32 dstR, dstG, dstB, dstA;
  6831. while (info->dst_h--) {
  6832. Uint32 *src = (Uint32 *)info->src;
  6833. Uint32 *dst = (Uint32 *)info->dst;
  6834. int n = info->dst_w;
  6835. while (n--) {
  6836. srcpixel = *src;
  6837. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6838. dstpixel = *dst;
  6839. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6840. if (flags & SDL_COPY_MODULATE_COLOR) {
  6841. MULT_DIV_255(srcR, modulateR, srcR);
  6842. MULT_DIV_255(srcG, modulateG, srcG);
  6843. MULT_DIV_255(srcB, modulateB, srcB);
  6844. }
  6845. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6846. MULT_DIV_255(srcA, modulateA, srcA);
  6847. }
  6848. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6849. if (srcA < 255) {
  6850. MULT_DIV_255(srcR, srcA, srcR);
  6851. MULT_DIV_255(srcG, srcA, srcG);
  6852. MULT_DIV_255(srcB, srcA, srcB);
  6853. }
  6854. }
  6855. switch (flags & SDL_COPY_BLEND_MASK) {
  6856. case SDL_COPY_BLEND:
  6857. MULT_DIV_255((255 - srcA), dstR, dstR);
  6858. dstR += srcR;
  6859. MULT_DIV_255((255 - srcA), dstG, dstG);
  6860. dstG += srcG;
  6861. MULT_DIV_255((255 - srcA), dstB, dstB);
  6862. dstB += srcB;
  6863. MULT_DIV_255((255 - srcA), dstA, dstA);
  6864. dstA += srcA;
  6865. break;
  6866. case SDL_COPY_BLEND_PREMULTIPLIED:
  6867. MULT_DIV_255((255 - srcA), dstR, dstR);
  6868. dstR += srcR;
  6869. if (dstR > 255) dstR = 255;
  6870. MULT_DIV_255((255 - srcA), dstG, dstG);
  6871. dstG += srcG;
  6872. if (dstG > 255) dstG = 255;
  6873. MULT_DIV_255((255 - srcA), dstB, dstB);
  6874. dstB += srcB;
  6875. if (dstB > 255) dstB = 255;
  6876. MULT_DIV_255((255 - srcA), dstA, dstA);
  6877. dstA += srcA;
  6878. if (dstA > 255) dstA = 255;
  6879. break;
  6880. case SDL_COPY_ADD:
  6881. case SDL_COPY_ADD_PREMULTIPLIED:
  6882. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6883. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6884. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6885. break;
  6886. case SDL_COPY_MOD:
  6887. MULT_DIV_255(srcR, dstR, dstR);
  6888. MULT_DIV_255(srcG, dstG, dstG);
  6889. MULT_DIV_255(srcB, dstB, dstB);
  6890. break;
  6891. case SDL_COPY_MUL:
  6892. {
  6893. Uint32 tmp1, tmp2;
  6894. MULT_DIV_255(srcR, dstR, tmp1);
  6895. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  6896. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  6897. MULT_DIV_255(srcG, dstG, tmp1);
  6898. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  6899. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  6900. MULT_DIV_255(srcB, dstB, tmp1);
  6901. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  6902. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  6903. }
  6904. break;
  6905. }
  6906. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  6907. *dst = dstpixel;
  6908. ++src;
  6909. ++dst;
  6910. }
  6911. info->src += info->src_pitch;
  6912. info->dst += info->dst_pitch;
  6913. }
  6914. }
  6915. static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6916. {
  6917. const int flags = info->flags;
  6918. const Uint32 modulateR = info->r;
  6919. const Uint32 modulateG = info->g;
  6920. const Uint32 modulateB = info->b;
  6921. const Uint32 modulateA = info->a;
  6922. Uint32 srcpixel;
  6923. Uint32 srcR, srcG, srcB, srcA;
  6924. Uint32 dstpixel;
  6925. Uint32 dstR, dstG, dstB, dstA;
  6926. Uint64 srcy, srcx;
  6927. Uint64 posy, posx;
  6928. Uint64 incy, incx;
  6929. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  6930. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  6931. posy = incy / 2;
  6932. while (info->dst_h--) {
  6933. Uint32 *src = 0;
  6934. Uint32 *dst = (Uint32 *)info->dst;
  6935. int n = info->dst_w;
  6936. posx = incx / 2;
  6937. srcy = posy >> 16;
  6938. while (n--) {
  6939. srcx = posx >> 16;
  6940. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6941. srcpixel = *src;
  6942. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6943. dstpixel = *dst;
  6944. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6945. if (flags & SDL_COPY_MODULATE_COLOR) {
  6946. MULT_DIV_255(srcR, modulateR, srcR);
  6947. MULT_DIV_255(srcG, modulateG, srcG);
  6948. MULT_DIV_255(srcB, modulateB, srcB);
  6949. }
  6950. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6951. MULT_DIV_255(srcA, modulateA, srcA);
  6952. }
  6953. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6954. if (srcA < 255) {
  6955. MULT_DIV_255(srcR, srcA, srcR);
  6956. MULT_DIV_255(srcG, srcA, srcG);
  6957. MULT_DIV_255(srcB, srcA, srcB);
  6958. }
  6959. }
  6960. switch (flags & SDL_COPY_BLEND_MASK) {
  6961. case SDL_COPY_BLEND:
  6962. MULT_DIV_255((255 - srcA), dstR, dstR);
  6963. dstR += srcR;
  6964. MULT_DIV_255((255 - srcA), dstG, dstG);
  6965. dstG += srcG;
  6966. MULT_DIV_255((255 - srcA), dstB, dstB);
  6967. dstB += srcB;
  6968. MULT_DIV_255((255 - srcA), dstA, dstA);
  6969. dstA += srcA;
  6970. break;
  6971. case SDL_COPY_BLEND_PREMULTIPLIED:
  6972. MULT_DIV_255((255 - srcA), dstR, dstR);
  6973. dstR += srcR;
  6974. if (dstR > 255) dstR = 255;
  6975. MULT_DIV_255((255 - srcA), dstG, dstG);
  6976. dstG += srcG;
  6977. if (dstG > 255) dstG = 255;
  6978. MULT_DIV_255((255 - srcA), dstB, dstB);
  6979. dstB += srcB;
  6980. if (dstB > 255) dstB = 255;
  6981. MULT_DIV_255((255 - srcA), dstA, dstA);
  6982. dstA += srcA;
  6983. if (dstA > 255) dstA = 255;
  6984. break;
  6985. case SDL_COPY_ADD:
  6986. case SDL_COPY_ADD_PREMULTIPLIED:
  6987. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6988. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6989. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6990. break;
  6991. case SDL_COPY_MOD:
  6992. MULT_DIV_255(srcR, dstR, dstR);
  6993. MULT_DIV_255(srcG, dstG, dstG);
  6994. MULT_DIV_255(srcB, dstB, dstB);
  6995. break;
  6996. case SDL_COPY_MUL:
  6997. {
  6998. Uint32 tmp1, tmp2;
  6999. MULT_DIV_255(srcR, dstR, tmp1);
  7000. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7001. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7002. MULT_DIV_255(srcG, dstG, tmp1);
  7003. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7004. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7005. MULT_DIV_255(srcB, dstB, tmp1);
  7006. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7007. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7008. }
  7009. break;
  7010. }
  7011. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  7012. *dst = dstpixel;
  7013. posx += incx;
  7014. ++dst;
  7015. }
  7016. posy += incy;
  7017. info->dst += info->dst_pitch;
  7018. }
  7019. }
  7020. static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
  7021. {
  7022. Uint32 pixel;
  7023. Uint32 R, G, B;
  7024. Uint64 srcy, srcx;
  7025. Uint64 posy, posx;
  7026. Uint64 incy, incx;
  7027. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7028. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7029. posy = incy / 2;
  7030. while (info->dst_h--) {
  7031. Uint32 *src = 0;
  7032. Uint32 *dst = (Uint32 *)info->dst;
  7033. int n = info->dst_w;
  7034. posx = incx / 2;
  7035. srcy = posy >> 16;
  7036. while (n--) {
  7037. srcx = posx >> 16;
  7038. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7039. pixel = *src;
  7040. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7041. pixel = (R << 16) | (G << 8) | B;
  7042. *dst = pixel;
  7043. posx += incx;
  7044. ++dst;
  7045. }
  7046. posy += incy;
  7047. info->dst += info->dst_pitch;
  7048. }
  7049. }
  7050. static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
  7051. {
  7052. const int flags = info->flags;
  7053. Uint32 srcpixel;
  7054. Uint32 srcR, srcG, srcB, srcA;
  7055. Uint32 dstpixel;
  7056. Uint32 dstR, dstG, dstB;
  7057. while (info->dst_h--) {
  7058. Uint32 *src = (Uint32 *)info->src;
  7059. Uint32 *dst = (Uint32 *)info->dst;
  7060. int n = info->dst_w;
  7061. while (n--) {
  7062. srcpixel = *src;
  7063. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7064. dstpixel = *dst;
  7065. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  7066. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7067. if (srcA < 255) {
  7068. MULT_DIV_255(srcR, srcA, srcR);
  7069. MULT_DIV_255(srcG, srcA, srcG);
  7070. MULT_DIV_255(srcB, srcA, srcB);
  7071. }
  7072. }
  7073. switch (flags & SDL_COPY_BLEND_MASK) {
  7074. case SDL_COPY_BLEND:
  7075. MULT_DIV_255((255 - srcA), dstR, dstR);
  7076. dstR += srcR;
  7077. MULT_DIV_255((255 - srcA), dstG, dstG);
  7078. dstG += srcG;
  7079. MULT_DIV_255((255 - srcA), dstB, dstB);
  7080. dstB += srcB;
  7081. break;
  7082. case SDL_COPY_BLEND_PREMULTIPLIED:
  7083. MULT_DIV_255((255 - srcA), dstR, dstR);
  7084. dstR += srcR;
  7085. if (dstR > 255) dstR = 255;
  7086. MULT_DIV_255((255 - srcA), dstG, dstG);
  7087. dstG += srcG;
  7088. if (dstG > 255) dstG = 255;
  7089. MULT_DIV_255((255 - srcA), dstB, dstB);
  7090. dstB += srcB;
  7091. if (dstB > 255) dstB = 255;
  7092. break;
  7093. case SDL_COPY_ADD:
  7094. case SDL_COPY_ADD_PREMULTIPLIED:
  7095. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7096. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7097. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7098. break;
  7099. case SDL_COPY_MOD:
  7100. MULT_DIV_255(srcR, dstR, dstR);
  7101. MULT_DIV_255(srcG, dstG, dstG);
  7102. MULT_DIV_255(srcB, dstB, dstB);
  7103. break;
  7104. case SDL_COPY_MUL:
  7105. {
  7106. Uint32 tmp1, tmp2;
  7107. MULT_DIV_255(srcR, dstR, tmp1);
  7108. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7109. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7110. MULT_DIV_255(srcG, dstG, tmp1);
  7111. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7112. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7113. MULT_DIV_255(srcB, dstB, tmp1);
  7114. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7115. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7116. }
  7117. break;
  7118. }
  7119. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  7120. *dst = dstpixel;
  7121. ++src;
  7122. ++dst;
  7123. }
  7124. info->src += info->src_pitch;
  7125. info->dst += info->dst_pitch;
  7126. }
  7127. }
  7128. static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  7129. {
  7130. const int flags = info->flags;
  7131. Uint32 srcpixel;
  7132. Uint32 srcR, srcG, srcB, srcA;
  7133. Uint32 dstpixel;
  7134. Uint32 dstR, dstG, dstB;
  7135. Uint64 srcy, srcx;
  7136. Uint64 posy, posx;
  7137. Uint64 incy, incx;
  7138. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7139. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7140. posy = incy / 2;
  7141. while (info->dst_h--) {
  7142. Uint32 *src = 0;
  7143. Uint32 *dst = (Uint32 *)info->dst;
  7144. int n = info->dst_w;
  7145. posx = incx / 2;
  7146. srcy = posy >> 16;
  7147. while (n--) {
  7148. srcx = posx >> 16;
  7149. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7150. srcpixel = *src;
  7151. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7152. dstpixel = *dst;
  7153. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  7154. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7155. if (srcA < 255) {
  7156. MULT_DIV_255(srcR, srcA, srcR);
  7157. MULT_DIV_255(srcG, srcA, srcG);
  7158. MULT_DIV_255(srcB, srcA, srcB);
  7159. }
  7160. }
  7161. switch (flags & SDL_COPY_BLEND_MASK) {
  7162. case SDL_COPY_BLEND:
  7163. MULT_DIV_255((255 - srcA), dstR, dstR);
  7164. dstR += srcR;
  7165. MULT_DIV_255((255 - srcA), dstG, dstG);
  7166. dstG += srcG;
  7167. MULT_DIV_255((255 - srcA), dstB, dstB);
  7168. dstB += srcB;
  7169. break;
  7170. case SDL_COPY_BLEND_PREMULTIPLIED:
  7171. MULT_DIV_255((255 - srcA), dstR, dstR);
  7172. dstR += srcR;
  7173. if (dstR > 255) dstR = 255;
  7174. MULT_DIV_255((255 - srcA), dstG, dstG);
  7175. dstG += srcG;
  7176. if (dstG > 255) dstG = 255;
  7177. MULT_DIV_255((255 - srcA), dstB, dstB);
  7178. dstB += srcB;
  7179. if (dstB > 255) dstB = 255;
  7180. break;
  7181. case SDL_COPY_ADD:
  7182. case SDL_COPY_ADD_PREMULTIPLIED:
  7183. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7184. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7185. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7186. break;
  7187. case SDL_COPY_MOD:
  7188. MULT_DIV_255(srcR, dstR, dstR);
  7189. MULT_DIV_255(srcG, dstG, dstG);
  7190. MULT_DIV_255(srcB, dstB, dstB);
  7191. break;
  7192. case SDL_COPY_MUL:
  7193. {
  7194. Uint32 tmp1, tmp2;
  7195. MULT_DIV_255(srcR, dstR, tmp1);
  7196. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7197. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7198. MULT_DIV_255(srcG, dstG, tmp1);
  7199. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7200. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7201. MULT_DIV_255(srcB, dstB, tmp1);
  7202. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7203. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7204. }
  7205. break;
  7206. }
  7207. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  7208. *dst = dstpixel;
  7209. posx += incx;
  7210. ++dst;
  7211. }
  7212. posy += incy;
  7213. info->dst += info->dst_pitch;
  7214. }
  7215. }
  7216. static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  7217. {
  7218. const int flags = info->flags;
  7219. const Uint32 modulateR = info->r;
  7220. const Uint32 modulateG = info->g;
  7221. const Uint32 modulateB = info->b;
  7222. Uint32 pixel;
  7223. Uint32 R, G, B;
  7224. while (info->dst_h--) {
  7225. Uint32 *src = (Uint32 *)info->src;
  7226. Uint32 *dst = (Uint32 *)info->dst;
  7227. int n = info->dst_w;
  7228. while (n--) {
  7229. pixel = *src;
  7230. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7231. if (flags & SDL_COPY_MODULATE_COLOR) {
  7232. MULT_DIV_255(R, modulateR, R);
  7233. MULT_DIV_255(G, modulateG, G);
  7234. MULT_DIV_255(B, modulateB, B);
  7235. }
  7236. pixel = (R << 16) | (G << 8) | B;
  7237. *dst = pixel;
  7238. ++src;
  7239. ++dst;
  7240. }
  7241. info->src += info->src_pitch;
  7242. info->dst += info->dst_pitch;
  7243. }
  7244. }
  7245. static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  7246. {
  7247. const int flags = info->flags;
  7248. const Uint32 modulateR = info->r;
  7249. const Uint32 modulateG = info->g;
  7250. const Uint32 modulateB = info->b;
  7251. Uint32 pixel;
  7252. Uint32 R, G, B;
  7253. Uint64 srcy, srcx;
  7254. Uint64 posy, posx;
  7255. Uint64 incy, incx;
  7256. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7257. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7258. posy = incy / 2;
  7259. while (info->dst_h--) {
  7260. Uint32 *src = 0;
  7261. Uint32 *dst = (Uint32 *)info->dst;
  7262. int n = info->dst_w;
  7263. posx = incx / 2;
  7264. srcy = posy >> 16;
  7265. while (n--) {
  7266. srcx = posx >> 16;
  7267. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7268. pixel = *src;
  7269. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7270. if (flags & SDL_COPY_MODULATE_COLOR) {
  7271. MULT_DIV_255(R, modulateR, R);
  7272. MULT_DIV_255(G, modulateG, G);
  7273. MULT_DIV_255(B, modulateB, B);
  7274. }
  7275. pixel = (R << 16) | (G << 8) | B;
  7276. *dst = pixel;
  7277. posx += incx;
  7278. ++dst;
  7279. }
  7280. posy += incy;
  7281. info->dst += info->dst_pitch;
  7282. }
  7283. }
  7284. static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  7285. {
  7286. const int flags = info->flags;
  7287. const Uint32 modulateR = info->r;
  7288. const Uint32 modulateG = info->g;
  7289. const Uint32 modulateB = info->b;
  7290. const Uint32 modulateA = info->a;
  7291. Uint32 srcpixel;
  7292. Uint32 srcR, srcG, srcB, srcA;
  7293. Uint32 dstpixel;
  7294. Uint32 dstR, dstG, dstB;
  7295. while (info->dst_h--) {
  7296. Uint32 *src = (Uint32 *)info->src;
  7297. Uint32 *dst = (Uint32 *)info->dst;
  7298. int n = info->dst_w;
  7299. while (n--) {
  7300. srcpixel = *src;
  7301. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7302. dstpixel = *dst;
  7303. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  7304. if (flags & SDL_COPY_MODULATE_COLOR) {
  7305. MULT_DIV_255(srcR, modulateR, srcR);
  7306. MULT_DIV_255(srcG, modulateG, srcG);
  7307. MULT_DIV_255(srcB, modulateB, srcB);
  7308. }
  7309. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7310. MULT_DIV_255(srcA, modulateA, srcA);
  7311. }
  7312. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7313. if (srcA < 255) {
  7314. MULT_DIV_255(srcR, srcA, srcR);
  7315. MULT_DIV_255(srcG, srcA, srcG);
  7316. MULT_DIV_255(srcB, srcA, srcB);
  7317. }
  7318. }
  7319. switch (flags & SDL_COPY_BLEND_MASK) {
  7320. case SDL_COPY_BLEND:
  7321. MULT_DIV_255((255 - srcA), dstR, dstR);
  7322. dstR += srcR;
  7323. MULT_DIV_255((255 - srcA), dstG, dstG);
  7324. dstG += srcG;
  7325. MULT_DIV_255((255 - srcA), dstB, dstB);
  7326. dstB += srcB;
  7327. break;
  7328. case SDL_COPY_BLEND_PREMULTIPLIED:
  7329. MULT_DIV_255((255 - srcA), dstR, dstR);
  7330. dstR += srcR;
  7331. if (dstR > 255) dstR = 255;
  7332. MULT_DIV_255((255 - srcA), dstG, dstG);
  7333. dstG += srcG;
  7334. if (dstG > 255) dstG = 255;
  7335. MULT_DIV_255((255 - srcA), dstB, dstB);
  7336. dstB += srcB;
  7337. if (dstB > 255) dstB = 255;
  7338. break;
  7339. case SDL_COPY_ADD:
  7340. case SDL_COPY_ADD_PREMULTIPLIED:
  7341. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7342. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7343. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7344. break;
  7345. case SDL_COPY_MOD:
  7346. MULT_DIV_255(srcR, dstR, dstR);
  7347. MULT_DIV_255(srcG, dstG, dstG);
  7348. MULT_DIV_255(srcB, dstB, dstB);
  7349. break;
  7350. case SDL_COPY_MUL:
  7351. {
  7352. Uint32 tmp1, tmp2;
  7353. MULT_DIV_255(srcR, dstR, tmp1);
  7354. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7355. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7356. MULT_DIV_255(srcG, dstG, tmp1);
  7357. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7358. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7359. MULT_DIV_255(srcB, dstB, tmp1);
  7360. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7361. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7362. }
  7363. break;
  7364. }
  7365. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  7366. *dst = dstpixel;
  7367. ++src;
  7368. ++dst;
  7369. }
  7370. info->src += info->src_pitch;
  7371. info->dst += info->dst_pitch;
  7372. }
  7373. }
  7374. static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  7375. {
  7376. const int flags = info->flags;
  7377. const Uint32 modulateR = info->r;
  7378. const Uint32 modulateG = info->g;
  7379. const Uint32 modulateB = info->b;
  7380. const Uint32 modulateA = info->a;
  7381. Uint32 srcpixel;
  7382. Uint32 srcR, srcG, srcB, srcA;
  7383. Uint32 dstpixel;
  7384. Uint32 dstR, dstG, dstB;
  7385. Uint64 srcy, srcx;
  7386. Uint64 posy, posx;
  7387. Uint64 incy, incx;
  7388. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7389. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7390. posy = incy / 2;
  7391. while (info->dst_h--) {
  7392. Uint32 *src = 0;
  7393. Uint32 *dst = (Uint32 *)info->dst;
  7394. int n = info->dst_w;
  7395. posx = incx / 2;
  7396. srcy = posy >> 16;
  7397. while (n--) {
  7398. srcx = posx >> 16;
  7399. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7400. srcpixel = *src;
  7401. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7402. dstpixel = *dst;
  7403. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  7404. if (flags & SDL_COPY_MODULATE_COLOR) {
  7405. MULT_DIV_255(srcR, modulateR, srcR);
  7406. MULT_DIV_255(srcG, modulateG, srcG);
  7407. MULT_DIV_255(srcB, modulateB, srcB);
  7408. }
  7409. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7410. MULT_DIV_255(srcA, modulateA, srcA);
  7411. }
  7412. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7413. if (srcA < 255) {
  7414. MULT_DIV_255(srcR, srcA, srcR);
  7415. MULT_DIV_255(srcG, srcA, srcG);
  7416. MULT_DIV_255(srcB, srcA, srcB);
  7417. }
  7418. }
  7419. switch (flags & SDL_COPY_BLEND_MASK) {
  7420. case SDL_COPY_BLEND:
  7421. MULT_DIV_255((255 - srcA), dstR, dstR);
  7422. dstR += srcR;
  7423. MULT_DIV_255((255 - srcA), dstG, dstG);
  7424. dstG += srcG;
  7425. MULT_DIV_255((255 - srcA), dstB, dstB);
  7426. dstB += srcB;
  7427. break;
  7428. case SDL_COPY_BLEND_PREMULTIPLIED:
  7429. MULT_DIV_255((255 - srcA), dstR, dstR);
  7430. dstR += srcR;
  7431. if (dstR > 255) dstR = 255;
  7432. MULT_DIV_255((255 - srcA), dstG, dstG);
  7433. dstG += srcG;
  7434. if (dstG > 255) dstG = 255;
  7435. MULT_DIV_255((255 - srcA), dstB, dstB);
  7436. dstB += srcB;
  7437. if (dstB > 255) dstB = 255;
  7438. break;
  7439. case SDL_COPY_ADD:
  7440. case SDL_COPY_ADD_PREMULTIPLIED:
  7441. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7442. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7443. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7444. break;
  7445. case SDL_COPY_MOD:
  7446. MULT_DIV_255(srcR, dstR, dstR);
  7447. MULT_DIV_255(srcG, dstG, dstG);
  7448. MULT_DIV_255(srcB, dstB, dstB);
  7449. break;
  7450. case SDL_COPY_MUL:
  7451. {
  7452. Uint32 tmp1, tmp2;
  7453. MULT_DIV_255(srcR, dstR, tmp1);
  7454. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7455. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7456. MULT_DIV_255(srcG, dstG, tmp1);
  7457. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7458. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7459. MULT_DIV_255(srcB, dstB, tmp1);
  7460. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7461. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7462. }
  7463. break;
  7464. }
  7465. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  7466. *dst = dstpixel;
  7467. posx += incx;
  7468. ++dst;
  7469. }
  7470. posy += incy;
  7471. info->dst += info->dst_pitch;
  7472. }
  7473. }
  7474. static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
  7475. {
  7476. Uint32 pixel;
  7477. Uint64 srcy, srcx;
  7478. Uint64 posy, posx;
  7479. Uint64 incy, incx;
  7480. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7481. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7482. posy = incy / 2;
  7483. while (info->dst_h--) {
  7484. Uint32 *src = 0;
  7485. Uint32 *dst = (Uint32 *)info->dst;
  7486. int n = info->dst_w;
  7487. posx = incx / 2;
  7488. srcy = posy >> 16;
  7489. while (n--) {
  7490. srcx = posx >> 16;
  7491. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7492. pixel = *src;
  7493. pixel &= 0xFFFFFF;
  7494. *dst = pixel;
  7495. posx += incx;
  7496. ++dst;
  7497. }
  7498. posy += incy;
  7499. info->dst += info->dst_pitch;
  7500. }
  7501. }
  7502. static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
  7503. {
  7504. const int flags = info->flags;
  7505. Uint32 srcpixel;
  7506. Uint32 srcR, srcG, srcB, srcA;
  7507. Uint32 dstpixel;
  7508. Uint32 dstR, dstG, dstB;
  7509. while (info->dst_h--) {
  7510. Uint32 *src = (Uint32 *)info->src;
  7511. Uint32 *dst = (Uint32 *)info->dst;
  7512. int n = info->dst_w;
  7513. while (n--) {
  7514. srcpixel = *src;
  7515. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7516. dstpixel = *dst;
  7517. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  7518. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7519. if (srcA < 255) {
  7520. MULT_DIV_255(srcR, srcA, srcR);
  7521. MULT_DIV_255(srcG, srcA, srcG);
  7522. MULT_DIV_255(srcB, srcA, srcB);
  7523. }
  7524. }
  7525. switch (flags & SDL_COPY_BLEND_MASK) {
  7526. case SDL_COPY_BLEND:
  7527. MULT_DIV_255((255 - srcA), dstR, dstR);
  7528. dstR += srcR;
  7529. MULT_DIV_255((255 - srcA), dstG, dstG);
  7530. dstG += srcG;
  7531. MULT_DIV_255((255 - srcA), dstB, dstB);
  7532. dstB += srcB;
  7533. break;
  7534. case SDL_COPY_BLEND_PREMULTIPLIED:
  7535. MULT_DIV_255((255 - srcA), dstR, dstR);
  7536. dstR += srcR;
  7537. if (dstR > 255) dstR = 255;
  7538. MULT_DIV_255((255 - srcA), dstG, dstG);
  7539. dstG += srcG;
  7540. if (dstG > 255) dstG = 255;
  7541. MULT_DIV_255((255 - srcA), dstB, dstB);
  7542. dstB += srcB;
  7543. if (dstB > 255) dstB = 255;
  7544. break;
  7545. case SDL_COPY_ADD:
  7546. case SDL_COPY_ADD_PREMULTIPLIED:
  7547. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7548. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7549. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7550. break;
  7551. case SDL_COPY_MOD:
  7552. MULT_DIV_255(srcR, dstR, dstR);
  7553. MULT_DIV_255(srcG, dstG, dstG);
  7554. MULT_DIV_255(srcB, dstB, dstB);
  7555. break;
  7556. case SDL_COPY_MUL:
  7557. {
  7558. Uint32 tmp1, tmp2;
  7559. MULT_DIV_255(srcR, dstR, tmp1);
  7560. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7561. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7562. MULT_DIV_255(srcG, dstG, tmp1);
  7563. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7564. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7565. MULT_DIV_255(srcB, dstB, tmp1);
  7566. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7567. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7568. }
  7569. break;
  7570. }
  7571. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  7572. *dst = dstpixel;
  7573. ++src;
  7574. ++dst;
  7575. }
  7576. info->src += info->src_pitch;
  7577. info->dst += info->dst_pitch;
  7578. }
  7579. }
  7580. static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  7581. {
  7582. const int flags = info->flags;
  7583. Uint32 srcpixel;
  7584. Uint32 srcR, srcG, srcB, srcA;
  7585. Uint32 dstpixel;
  7586. Uint32 dstR, dstG, dstB;
  7587. Uint64 srcy, srcx;
  7588. Uint64 posy, posx;
  7589. Uint64 incy, incx;
  7590. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7591. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7592. posy = incy / 2;
  7593. while (info->dst_h--) {
  7594. Uint32 *src = 0;
  7595. Uint32 *dst = (Uint32 *)info->dst;
  7596. int n = info->dst_w;
  7597. posx = incx / 2;
  7598. srcy = posy >> 16;
  7599. while (n--) {
  7600. srcx = posx >> 16;
  7601. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7602. srcpixel = *src;
  7603. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7604. dstpixel = *dst;
  7605. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  7606. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7607. if (srcA < 255) {
  7608. MULT_DIV_255(srcR, srcA, srcR);
  7609. MULT_DIV_255(srcG, srcA, srcG);
  7610. MULT_DIV_255(srcB, srcA, srcB);
  7611. }
  7612. }
  7613. switch (flags & SDL_COPY_BLEND_MASK) {
  7614. case SDL_COPY_BLEND:
  7615. MULT_DIV_255((255 - srcA), dstR, dstR);
  7616. dstR += srcR;
  7617. MULT_DIV_255((255 - srcA), dstG, dstG);
  7618. dstG += srcG;
  7619. MULT_DIV_255((255 - srcA), dstB, dstB);
  7620. dstB += srcB;
  7621. break;
  7622. case SDL_COPY_BLEND_PREMULTIPLIED:
  7623. MULT_DIV_255((255 - srcA), dstR, dstR);
  7624. dstR += srcR;
  7625. if (dstR > 255) dstR = 255;
  7626. MULT_DIV_255((255 - srcA), dstG, dstG);
  7627. dstG += srcG;
  7628. if (dstG > 255) dstG = 255;
  7629. MULT_DIV_255((255 - srcA), dstB, dstB);
  7630. dstB += srcB;
  7631. if (dstB > 255) dstB = 255;
  7632. break;
  7633. case SDL_COPY_ADD:
  7634. case SDL_COPY_ADD_PREMULTIPLIED:
  7635. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7636. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7637. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7638. break;
  7639. case SDL_COPY_MOD:
  7640. MULT_DIV_255(srcR, dstR, dstR);
  7641. MULT_DIV_255(srcG, dstG, dstG);
  7642. MULT_DIV_255(srcB, dstB, dstB);
  7643. break;
  7644. case SDL_COPY_MUL:
  7645. {
  7646. Uint32 tmp1, tmp2;
  7647. MULT_DIV_255(srcR, dstR, tmp1);
  7648. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7649. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7650. MULT_DIV_255(srcG, dstG, tmp1);
  7651. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7652. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7653. MULT_DIV_255(srcB, dstB, tmp1);
  7654. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7655. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7656. }
  7657. break;
  7658. }
  7659. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  7660. *dst = dstpixel;
  7661. posx += incx;
  7662. ++dst;
  7663. }
  7664. posy += incy;
  7665. info->dst += info->dst_pitch;
  7666. }
  7667. }
  7668. static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  7669. {
  7670. const int flags = info->flags;
  7671. const Uint32 modulateR = info->r;
  7672. const Uint32 modulateG = info->g;
  7673. const Uint32 modulateB = info->b;
  7674. Uint32 pixel;
  7675. Uint32 R, G, B;
  7676. while (info->dst_h--) {
  7677. Uint32 *src = (Uint32 *)info->src;
  7678. Uint32 *dst = (Uint32 *)info->dst;
  7679. int n = info->dst_w;
  7680. while (n--) {
  7681. pixel = *src;
  7682. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7683. if (flags & SDL_COPY_MODULATE_COLOR) {
  7684. MULT_DIV_255(R, modulateR, R);
  7685. MULT_DIV_255(G, modulateG, G);
  7686. MULT_DIV_255(B, modulateB, B);
  7687. }
  7688. pixel = (B << 16) | (G << 8) | R;
  7689. *dst = pixel;
  7690. ++src;
  7691. ++dst;
  7692. }
  7693. info->src += info->src_pitch;
  7694. info->dst += info->dst_pitch;
  7695. }
  7696. }
  7697. static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  7698. {
  7699. const int flags = info->flags;
  7700. const Uint32 modulateR = info->r;
  7701. const Uint32 modulateG = info->g;
  7702. const Uint32 modulateB = info->b;
  7703. Uint32 pixel;
  7704. Uint32 R, G, B;
  7705. Uint64 srcy, srcx;
  7706. Uint64 posy, posx;
  7707. Uint64 incy, incx;
  7708. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7709. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7710. posy = incy / 2;
  7711. while (info->dst_h--) {
  7712. Uint32 *src = 0;
  7713. Uint32 *dst = (Uint32 *)info->dst;
  7714. int n = info->dst_w;
  7715. posx = incx / 2;
  7716. srcy = posy >> 16;
  7717. while (n--) {
  7718. srcx = posx >> 16;
  7719. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7720. pixel = *src;
  7721. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  7722. if (flags & SDL_COPY_MODULATE_COLOR) {
  7723. MULT_DIV_255(R, modulateR, R);
  7724. MULT_DIV_255(G, modulateG, G);
  7725. MULT_DIV_255(B, modulateB, B);
  7726. }
  7727. pixel = (B << 16) | (G << 8) | R;
  7728. *dst = pixel;
  7729. posx += incx;
  7730. ++dst;
  7731. }
  7732. posy += incy;
  7733. info->dst += info->dst_pitch;
  7734. }
  7735. }
  7736. static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  7737. {
  7738. const int flags = info->flags;
  7739. const Uint32 modulateR = info->r;
  7740. const Uint32 modulateG = info->g;
  7741. const Uint32 modulateB = info->b;
  7742. const Uint32 modulateA = info->a;
  7743. Uint32 srcpixel;
  7744. Uint32 srcR, srcG, srcB, srcA;
  7745. Uint32 dstpixel;
  7746. Uint32 dstR, dstG, dstB;
  7747. while (info->dst_h--) {
  7748. Uint32 *src = (Uint32 *)info->src;
  7749. Uint32 *dst = (Uint32 *)info->dst;
  7750. int n = info->dst_w;
  7751. while (n--) {
  7752. srcpixel = *src;
  7753. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7754. dstpixel = *dst;
  7755. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  7756. if (flags & SDL_COPY_MODULATE_COLOR) {
  7757. MULT_DIV_255(srcR, modulateR, srcR);
  7758. MULT_DIV_255(srcG, modulateG, srcG);
  7759. MULT_DIV_255(srcB, modulateB, srcB);
  7760. }
  7761. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7762. MULT_DIV_255(srcA, modulateA, srcA);
  7763. }
  7764. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7765. if (srcA < 255) {
  7766. MULT_DIV_255(srcR, srcA, srcR);
  7767. MULT_DIV_255(srcG, srcA, srcG);
  7768. MULT_DIV_255(srcB, srcA, srcB);
  7769. }
  7770. }
  7771. switch (flags & SDL_COPY_BLEND_MASK) {
  7772. case SDL_COPY_BLEND:
  7773. MULT_DIV_255((255 - srcA), dstR, dstR);
  7774. dstR += srcR;
  7775. MULT_DIV_255((255 - srcA), dstG, dstG);
  7776. dstG += srcG;
  7777. MULT_DIV_255((255 - srcA), dstB, dstB);
  7778. dstB += srcB;
  7779. break;
  7780. case SDL_COPY_BLEND_PREMULTIPLIED:
  7781. MULT_DIV_255((255 - srcA), dstR, dstR);
  7782. dstR += srcR;
  7783. if (dstR > 255) dstR = 255;
  7784. MULT_DIV_255((255 - srcA), dstG, dstG);
  7785. dstG += srcG;
  7786. if (dstG > 255) dstG = 255;
  7787. MULT_DIV_255((255 - srcA), dstB, dstB);
  7788. dstB += srcB;
  7789. if (dstB > 255) dstB = 255;
  7790. break;
  7791. case SDL_COPY_ADD:
  7792. case SDL_COPY_ADD_PREMULTIPLIED:
  7793. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7794. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7795. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7796. break;
  7797. case SDL_COPY_MOD:
  7798. MULT_DIV_255(srcR, dstR, dstR);
  7799. MULT_DIV_255(srcG, dstG, dstG);
  7800. MULT_DIV_255(srcB, dstB, dstB);
  7801. break;
  7802. case SDL_COPY_MUL:
  7803. {
  7804. Uint32 tmp1, tmp2;
  7805. MULT_DIV_255(srcR, dstR, tmp1);
  7806. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7807. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7808. MULT_DIV_255(srcG, dstG, tmp1);
  7809. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7810. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7811. MULT_DIV_255(srcB, dstB, tmp1);
  7812. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7813. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7814. }
  7815. break;
  7816. }
  7817. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  7818. *dst = dstpixel;
  7819. ++src;
  7820. ++dst;
  7821. }
  7822. info->src += info->src_pitch;
  7823. info->dst += info->dst_pitch;
  7824. }
  7825. }
  7826. static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  7827. {
  7828. const int flags = info->flags;
  7829. const Uint32 modulateR = info->r;
  7830. const Uint32 modulateG = info->g;
  7831. const Uint32 modulateB = info->b;
  7832. const Uint32 modulateA = info->a;
  7833. Uint32 srcpixel;
  7834. Uint32 srcR, srcG, srcB, srcA;
  7835. Uint32 dstpixel;
  7836. Uint32 dstR, dstG, dstB;
  7837. Uint64 srcy, srcx;
  7838. Uint64 posy, posx;
  7839. Uint64 incy, incx;
  7840. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7841. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7842. posy = incy / 2;
  7843. while (info->dst_h--) {
  7844. Uint32 *src = 0;
  7845. Uint32 *dst = (Uint32 *)info->dst;
  7846. int n = info->dst_w;
  7847. posx = incx / 2;
  7848. srcy = posy >> 16;
  7849. while (n--) {
  7850. srcx = posx >> 16;
  7851. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7852. srcpixel = *src;
  7853. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7854. dstpixel = *dst;
  7855. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  7856. if (flags & SDL_COPY_MODULATE_COLOR) {
  7857. MULT_DIV_255(srcR, modulateR, srcR);
  7858. MULT_DIV_255(srcG, modulateG, srcG);
  7859. MULT_DIV_255(srcB, modulateB, srcB);
  7860. }
  7861. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7862. MULT_DIV_255(srcA, modulateA, srcA);
  7863. }
  7864. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7865. if (srcA < 255) {
  7866. MULT_DIV_255(srcR, srcA, srcR);
  7867. MULT_DIV_255(srcG, srcA, srcG);
  7868. MULT_DIV_255(srcB, srcA, srcB);
  7869. }
  7870. }
  7871. switch (flags & SDL_COPY_BLEND_MASK) {
  7872. case SDL_COPY_BLEND:
  7873. MULT_DIV_255((255 - srcA), dstR, dstR);
  7874. dstR += srcR;
  7875. MULT_DIV_255((255 - srcA), dstG, dstG);
  7876. dstG += srcG;
  7877. MULT_DIV_255((255 - srcA), dstB, dstB);
  7878. dstB += srcB;
  7879. break;
  7880. case SDL_COPY_BLEND_PREMULTIPLIED:
  7881. MULT_DIV_255((255 - srcA), dstR, dstR);
  7882. dstR += srcR;
  7883. if (dstR > 255) dstR = 255;
  7884. MULT_DIV_255((255 - srcA), dstG, dstG);
  7885. dstG += srcG;
  7886. if (dstG > 255) dstG = 255;
  7887. MULT_DIV_255((255 - srcA), dstB, dstB);
  7888. dstB += srcB;
  7889. if (dstB > 255) dstB = 255;
  7890. break;
  7891. case SDL_COPY_ADD:
  7892. case SDL_COPY_ADD_PREMULTIPLIED:
  7893. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7894. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7895. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7896. break;
  7897. case SDL_COPY_MOD:
  7898. MULT_DIV_255(srcR, dstR, dstR);
  7899. MULT_DIV_255(srcG, dstG, dstG);
  7900. MULT_DIV_255(srcB, dstB, dstB);
  7901. break;
  7902. case SDL_COPY_MUL:
  7903. {
  7904. Uint32 tmp1, tmp2;
  7905. MULT_DIV_255(srcR, dstR, tmp1);
  7906. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  7907. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  7908. MULT_DIV_255(srcG, dstG, tmp1);
  7909. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  7910. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  7911. MULT_DIV_255(srcB, dstB, tmp1);
  7912. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  7913. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  7914. }
  7915. break;
  7916. }
  7917. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  7918. *dst = dstpixel;
  7919. posx += incx;
  7920. ++dst;
  7921. }
  7922. posy += incy;
  7923. info->dst += info->dst_pitch;
  7924. }
  7925. }
  7926. static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
  7927. {
  7928. Uint32 pixel;
  7929. Uint32 R, G, B, A;
  7930. Uint64 srcy, srcx;
  7931. Uint64 posy, posx;
  7932. Uint64 incy, incx;
  7933. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  7934. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  7935. posy = incy / 2;
  7936. while (info->dst_h--) {
  7937. Uint32 *src = 0;
  7938. Uint32 *dst = (Uint32 *)info->dst;
  7939. int n = info->dst_w;
  7940. posx = incx / 2;
  7941. srcy = posy >> 16;
  7942. while (n--) {
  7943. srcx = posx >> 16;
  7944. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7945. pixel = *src;
  7946. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  7947. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  7948. *dst = pixel;
  7949. posx += incx;
  7950. ++dst;
  7951. }
  7952. posy += incy;
  7953. info->dst += info->dst_pitch;
  7954. }
  7955. }
  7956. static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
  7957. {
  7958. const int flags = info->flags;
  7959. Uint32 srcpixel;
  7960. Uint32 srcR, srcG, srcB, srcA;
  7961. Uint32 dstpixel;
  7962. Uint32 dstR, dstG, dstB, dstA;
  7963. while (info->dst_h--) {
  7964. Uint32 *src = (Uint32 *)info->src;
  7965. Uint32 *dst = (Uint32 *)info->dst;
  7966. int n = info->dst_w;
  7967. while (n--) {
  7968. srcpixel = *src;
  7969. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  7970. dstpixel = *dst;
  7971. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  7972. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7973. if (srcA < 255) {
  7974. MULT_DIV_255(srcR, srcA, srcR);
  7975. MULT_DIV_255(srcG, srcA, srcG);
  7976. MULT_DIV_255(srcB, srcA, srcB);
  7977. }
  7978. }
  7979. switch (flags & SDL_COPY_BLEND_MASK) {
  7980. case SDL_COPY_BLEND:
  7981. MULT_DIV_255((255 - srcA), dstR, dstR);
  7982. dstR += srcR;
  7983. MULT_DIV_255((255 - srcA), dstG, dstG);
  7984. dstG += srcG;
  7985. MULT_DIV_255((255 - srcA), dstB, dstB);
  7986. dstB += srcB;
  7987. MULT_DIV_255((255 - srcA), dstA, dstA);
  7988. dstA += srcA;
  7989. break;
  7990. case SDL_COPY_BLEND_PREMULTIPLIED:
  7991. MULT_DIV_255((255 - srcA), dstR, dstR);
  7992. dstR += srcR;
  7993. if (dstR > 255) dstR = 255;
  7994. MULT_DIV_255((255 - srcA), dstG, dstG);
  7995. dstG += srcG;
  7996. if (dstG > 255) dstG = 255;
  7997. MULT_DIV_255((255 - srcA), dstB, dstB);
  7998. dstB += srcB;
  7999. if (dstB > 255) dstB = 255;
  8000. MULT_DIV_255((255 - srcA), dstA, dstA);
  8001. dstA += srcA;
  8002. if (dstA > 255) dstA = 255;
  8003. break;
  8004. case SDL_COPY_ADD:
  8005. case SDL_COPY_ADD_PREMULTIPLIED:
  8006. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8007. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8008. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8009. break;
  8010. case SDL_COPY_MOD:
  8011. MULT_DIV_255(srcR, dstR, dstR);
  8012. MULT_DIV_255(srcG, dstG, dstG);
  8013. MULT_DIV_255(srcB, dstB, dstB);
  8014. break;
  8015. case SDL_COPY_MUL:
  8016. {
  8017. Uint32 tmp1, tmp2;
  8018. MULT_DIV_255(srcR, dstR, tmp1);
  8019. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8020. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8021. MULT_DIV_255(srcG, dstG, tmp1);
  8022. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8023. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8024. MULT_DIV_255(srcB, dstB, tmp1);
  8025. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8026. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8027. }
  8028. break;
  8029. }
  8030. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  8031. *dst = dstpixel;
  8032. ++src;
  8033. ++dst;
  8034. }
  8035. info->src += info->src_pitch;
  8036. info->dst += info->dst_pitch;
  8037. }
  8038. }
  8039. static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  8040. {
  8041. const int flags = info->flags;
  8042. Uint32 srcpixel;
  8043. Uint32 srcR, srcG, srcB, srcA;
  8044. Uint32 dstpixel;
  8045. Uint32 dstR, dstG, dstB, dstA;
  8046. Uint64 srcy, srcx;
  8047. Uint64 posy, posx;
  8048. Uint64 incy, incx;
  8049. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8050. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8051. posy = incy / 2;
  8052. while (info->dst_h--) {
  8053. Uint32 *src = 0;
  8054. Uint32 *dst = (Uint32 *)info->dst;
  8055. int n = info->dst_w;
  8056. posx = incx / 2;
  8057. srcy = posy >> 16;
  8058. while (n--) {
  8059. srcx = posx >> 16;
  8060. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8061. srcpixel = *src;
  8062. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8063. dstpixel = *dst;
  8064. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8065. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8066. if (srcA < 255) {
  8067. MULT_DIV_255(srcR, srcA, srcR);
  8068. MULT_DIV_255(srcG, srcA, srcG);
  8069. MULT_DIV_255(srcB, srcA, srcB);
  8070. }
  8071. }
  8072. switch (flags & SDL_COPY_BLEND_MASK) {
  8073. case SDL_COPY_BLEND:
  8074. MULT_DIV_255((255 - srcA), dstR, dstR);
  8075. dstR += srcR;
  8076. MULT_DIV_255((255 - srcA), dstG, dstG);
  8077. dstG += srcG;
  8078. MULT_DIV_255((255 - srcA), dstB, dstB);
  8079. dstB += srcB;
  8080. MULT_DIV_255((255 - srcA), dstA, dstA);
  8081. dstA += srcA;
  8082. break;
  8083. case SDL_COPY_BLEND_PREMULTIPLIED:
  8084. MULT_DIV_255((255 - srcA), dstR, dstR);
  8085. dstR += srcR;
  8086. if (dstR > 255) dstR = 255;
  8087. MULT_DIV_255((255 - srcA), dstG, dstG);
  8088. dstG += srcG;
  8089. if (dstG > 255) dstG = 255;
  8090. MULT_DIV_255((255 - srcA), dstB, dstB);
  8091. dstB += srcB;
  8092. if (dstB > 255) dstB = 255;
  8093. MULT_DIV_255((255 - srcA), dstA, dstA);
  8094. dstA += srcA;
  8095. if (dstA > 255) dstA = 255;
  8096. break;
  8097. case SDL_COPY_ADD:
  8098. case SDL_COPY_ADD_PREMULTIPLIED:
  8099. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8100. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8101. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8102. break;
  8103. case SDL_COPY_MOD:
  8104. MULT_DIV_255(srcR, dstR, dstR);
  8105. MULT_DIV_255(srcG, dstG, dstG);
  8106. MULT_DIV_255(srcB, dstB, dstB);
  8107. break;
  8108. case SDL_COPY_MUL:
  8109. {
  8110. Uint32 tmp1, tmp2;
  8111. MULT_DIV_255(srcR, dstR, tmp1);
  8112. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8113. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8114. MULT_DIV_255(srcG, dstG, tmp1);
  8115. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8116. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8117. MULT_DIV_255(srcB, dstB, tmp1);
  8118. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8119. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8120. }
  8121. break;
  8122. }
  8123. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  8124. *dst = dstpixel;
  8125. posx += incx;
  8126. ++dst;
  8127. }
  8128. posy += incy;
  8129. info->dst += info->dst_pitch;
  8130. }
  8131. }
  8132. static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  8133. {
  8134. const int flags = info->flags;
  8135. const Uint32 modulateR = info->r;
  8136. const Uint32 modulateG = info->g;
  8137. const Uint32 modulateB = info->b;
  8138. const Uint32 modulateA = info->a;
  8139. Uint32 pixel;
  8140. Uint32 R, G, B, A;
  8141. while (info->dst_h--) {
  8142. Uint32 *src = (Uint32 *)info->src;
  8143. Uint32 *dst = (Uint32 *)info->dst;
  8144. int n = info->dst_w;
  8145. while (n--) {
  8146. pixel = *src;
  8147. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  8148. if (flags & SDL_COPY_MODULATE_COLOR) {
  8149. MULT_DIV_255(R, modulateR, R);
  8150. MULT_DIV_255(G, modulateG, G);
  8151. MULT_DIV_255(B, modulateB, B);
  8152. }
  8153. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8154. MULT_DIV_255(A, modulateA, A);
  8155. }
  8156. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  8157. *dst = pixel;
  8158. ++src;
  8159. ++dst;
  8160. }
  8161. info->src += info->src_pitch;
  8162. info->dst += info->dst_pitch;
  8163. }
  8164. }
  8165. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  8166. {
  8167. const int flags = info->flags;
  8168. const Uint32 modulateR = info->r;
  8169. const Uint32 modulateG = info->g;
  8170. const Uint32 modulateB = info->b;
  8171. const Uint32 modulateA = info->a;
  8172. Uint32 pixel;
  8173. Uint32 R, G, B, A;
  8174. Uint64 srcy, srcx;
  8175. Uint64 posy, posx;
  8176. Uint64 incy, incx;
  8177. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8178. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8179. posy = incy / 2;
  8180. while (info->dst_h--) {
  8181. Uint32 *src = 0;
  8182. Uint32 *dst = (Uint32 *)info->dst;
  8183. int n = info->dst_w;
  8184. posx = incx / 2;
  8185. srcy = posy >> 16;
  8186. while (n--) {
  8187. srcx = posx >> 16;
  8188. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8189. pixel = *src;
  8190. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  8191. if (flags & SDL_COPY_MODULATE_COLOR) {
  8192. MULT_DIV_255(R, modulateR, R);
  8193. MULT_DIV_255(G, modulateG, G);
  8194. MULT_DIV_255(B, modulateB, B);
  8195. }
  8196. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8197. MULT_DIV_255(A, modulateA, A);
  8198. }
  8199. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  8200. *dst = pixel;
  8201. posx += incx;
  8202. ++dst;
  8203. }
  8204. posy += incy;
  8205. info->dst += info->dst_pitch;
  8206. }
  8207. }
  8208. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  8209. {
  8210. const int flags = info->flags;
  8211. const Uint32 modulateR = info->r;
  8212. const Uint32 modulateG = info->g;
  8213. const Uint32 modulateB = info->b;
  8214. const Uint32 modulateA = info->a;
  8215. Uint32 srcpixel;
  8216. Uint32 srcR, srcG, srcB, srcA;
  8217. Uint32 dstpixel;
  8218. Uint32 dstR, dstG, dstB, dstA;
  8219. while (info->dst_h--) {
  8220. Uint32 *src = (Uint32 *)info->src;
  8221. Uint32 *dst = (Uint32 *)info->dst;
  8222. int n = info->dst_w;
  8223. while (n--) {
  8224. srcpixel = *src;
  8225. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8226. dstpixel = *dst;
  8227. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8228. if (flags & SDL_COPY_MODULATE_COLOR) {
  8229. MULT_DIV_255(srcR, modulateR, srcR);
  8230. MULT_DIV_255(srcG, modulateG, srcG);
  8231. MULT_DIV_255(srcB, modulateB, srcB);
  8232. }
  8233. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8234. MULT_DIV_255(srcA, modulateA, srcA);
  8235. }
  8236. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8237. if (srcA < 255) {
  8238. MULT_DIV_255(srcR, srcA, srcR);
  8239. MULT_DIV_255(srcG, srcA, srcG);
  8240. MULT_DIV_255(srcB, srcA, srcB);
  8241. }
  8242. }
  8243. switch (flags & SDL_COPY_BLEND_MASK) {
  8244. case SDL_COPY_BLEND:
  8245. MULT_DIV_255((255 - srcA), dstR, dstR);
  8246. dstR += srcR;
  8247. MULT_DIV_255((255 - srcA), dstG, dstG);
  8248. dstG += srcG;
  8249. MULT_DIV_255((255 - srcA), dstB, dstB);
  8250. dstB += srcB;
  8251. MULT_DIV_255((255 - srcA), dstA, dstA);
  8252. dstA += srcA;
  8253. break;
  8254. case SDL_COPY_BLEND_PREMULTIPLIED:
  8255. MULT_DIV_255((255 - srcA), dstR, dstR);
  8256. dstR += srcR;
  8257. if (dstR > 255) dstR = 255;
  8258. MULT_DIV_255((255 - srcA), dstG, dstG);
  8259. dstG += srcG;
  8260. if (dstG > 255) dstG = 255;
  8261. MULT_DIV_255((255 - srcA), dstB, dstB);
  8262. dstB += srcB;
  8263. if (dstB > 255) dstB = 255;
  8264. MULT_DIV_255((255 - srcA), dstA, dstA);
  8265. dstA += srcA;
  8266. if (dstA > 255) dstA = 255;
  8267. break;
  8268. case SDL_COPY_ADD:
  8269. case SDL_COPY_ADD_PREMULTIPLIED:
  8270. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8271. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8272. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8273. break;
  8274. case SDL_COPY_MOD:
  8275. MULT_DIV_255(srcR, dstR, dstR);
  8276. MULT_DIV_255(srcG, dstG, dstG);
  8277. MULT_DIV_255(srcB, dstB, dstB);
  8278. break;
  8279. case SDL_COPY_MUL:
  8280. {
  8281. Uint32 tmp1, tmp2;
  8282. MULT_DIV_255(srcR, dstR, tmp1);
  8283. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8284. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8285. MULT_DIV_255(srcG, dstG, tmp1);
  8286. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8287. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8288. MULT_DIV_255(srcB, dstB, tmp1);
  8289. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8290. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8291. }
  8292. break;
  8293. }
  8294. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  8295. *dst = dstpixel;
  8296. ++src;
  8297. ++dst;
  8298. }
  8299. info->src += info->src_pitch;
  8300. info->dst += info->dst_pitch;
  8301. }
  8302. }
  8303. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  8304. {
  8305. const int flags = info->flags;
  8306. const Uint32 modulateR = info->r;
  8307. const Uint32 modulateG = info->g;
  8308. const Uint32 modulateB = info->b;
  8309. const Uint32 modulateA = info->a;
  8310. Uint32 srcpixel;
  8311. Uint32 srcR, srcG, srcB, srcA;
  8312. Uint32 dstpixel;
  8313. Uint32 dstR, dstG, dstB, dstA;
  8314. Uint64 srcy, srcx;
  8315. Uint64 posy, posx;
  8316. Uint64 incy, incx;
  8317. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8318. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8319. posy = incy / 2;
  8320. while (info->dst_h--) {
  8321. Uint32 *src = 0;
  8322. Uint32 *dst = (Uint32 *)info->dst;
  8323. int n = info->dst_w;
  8324. posx = incx / 2;
  8325. srcy = posy >> 16;
  8326. while (n--) {
  8327. srcx = posx >> 16;
  8328. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8329. srcpixel = *src;
  8330. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8331. dstpixel = *dst;
  8332. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8333. if (flags & SDL_COPY_MODULATE_COLOR) {
  8334. MULT_DIV_255(srcR, modulateR, srcR);
  8335. MULT_DIV_255(srcG, modulateG, srcG);
  8336. MULT_DIV_255(srcB, modulateB, srcB);
  8337. }
  8338. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8339. MULT_DIV_255(srcA, modulateA, srcA);
  8340. }
  8341. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8342. if (srcA < 255) {
  8343. MULT_DIV_255(srcR, srcA, srcR);
  8344. MULT_DIV_255(srcG, srcA, srcG);
  8345. MULT_DIV_255(srcB, srcA, srcB);
  8346. }
  8347. }
  8348. switch (flags & SDL_COPY_BLEND_MASK) {
  8349. case SDL_COPY_BLEND:
  8350. MULT_DIV_255((255 - srcA), dstR, dstR);
  8351. dstR += srcR;
  8352. MULT_DIV_255((255 - srcA), dstG, dstG);
  8353. dstG += srcG;
  8354. MULT_DIV_255((255 - srcA), dstB, dstB);
  8355. dstB += srcB;
  8356. MULT_DIV_255((255 - srcA), dstA, dstA);
  8357. dstA += srcA;
  8358. break;
  8359. case SDL_COPY_BLEND_PREMULTIPLIED:
  8360. MULT_DIV_255((255 - srcA), dstR, dstR);
  8361. dstR += srcR;
  8362. if (dstR > 255) dstR = 255;
  8363. MULT_DIV_255((255 - srcA), dstG, dstG);
  8364. dstG += srcG;
  8365. if (dstG > 255) dstG = 255;
  8366. MULT_DIV_255((255 - srcA), dstB, dstB);
  8367. dstB += srcB;
  8368. if (dstB > 255) dstB = 255;
  8369. MULT_DIV_255((255 - srcA), dstA, dstA);
  8370. dstA += srcA;
  8371. if (dstA > 255) dstA = 255;
  8372. break;
  8373. case SDL_COPY_ADD:
  8374. case SDL_COPY_ADD_PREMULTIPLIED:
  8375. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8376. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8377. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8378. break;
  8379. case SDL_COPY_MOD:
  8380. MULT_DIV_255(srcR, dstR, dstR);
  8381. MULT_DIV_255(srcG, dstG, dstG);
  8382. MULT_DIV_255(srcB, dstB, dstB);
  8383. break;
  8384. case SDL_COPY_MUL:
  8385. {
  8386. Uint32 tmp1, tmp2;
  8387. MULT_DIV_255(srcR, dstR, tmp1);
  8388. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8389. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8390. MULT_DIV_255(srcG, dstG, tmp1);
  8391. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8392. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8393. MULT_DIV_255(srcB, dstB, tmp1);
  8394. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8395. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8396. }
  8397. break;
  8398. }
  8399. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  8400. *dst = dstpixel;
  8401. posx += incx;
  8402. ++dst;
  8403. }
  8404. posy += incy;
  8405. info->dst += info->dst_pitch;
  8406. }
  8407. }
  8408. static void SDL_Blit_ABGR8888_ABGR8888_Scale(SDL_BlitInfo *info)
  8409. {
  8410. Uint64 srcy, srcx;
  8411. Uint64 posy, posx;
  8412. Uint64 incy, incx;
  8413. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8414. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8415. posy = incy / 2;
  8416. while (info->dst_h--) {
  8417. Uint32 *src = 0;
  8418. Uint32 *dst = (Uint32 *)info->dst;
  8419. int n = info->dst_w;
  8420. posx = incx / 2;
  8421. srcy = posy >> 16;
  8422. while (n--) {
  8423. srcx = posx >> 16;
  8424. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8425. *dst = *src;
  8426. posx += incx;
  8427. ++dst;
  8428. }
  8429. posy += incy;
  8430. info->dst += info->dst_pitch;
  8431. }
  8432. }
  8433. static void SDL_Blit_ABGR8888_ABGR8888_Blend(SDL_BlitInfo *info)
  8434. {
  8435. const int flags = info->flags;
  8436. Uint32 srcpixel;
  8437. Uint32 srcR, srcG, srcB, srcA;
  8438. Uint32 dstpixel;
  8439. Uint32 dstR, dstG, dstB, dstA;
  8440. while (info->dst_h--) {
  8441. Uint32 *src = (Uint32 *)info->src;
  8442. Uint32 *dst = (Uint32 *)info->dst;
  8443. int n = info->dst_w;
  8444. while (n--) {
  8445. srcpixel = *src;
  8446. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8447. dstpixel = *dst;
  8448. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8449. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8450. if (srcA < 255) {
  8451. MULT_DIV_255(srcR, srcA, srcR);
  8452. MULT_DIV_255(srcG, srcA, srcG);
  8453. MULT_DIV_255(srcB, srcA, srcB);
  8454. }
  8455. }
  8456. switch (flags & SDL_COPY_BLEND_MASK) {
  8457. case SDL_COPY_BLEND:
  8458. MULT_DIV_255((255 - srcA), dstR, dstR);
  8459. dstR += srcR;
  8460. MULT_DIV_255((255 - srcA), dstG, dstG);
  8461. dstG += srcG;
  8462. MULT_DIV_255((255 - srcA), dstB, dstB);
  8463. dstB += srcB;
  8464. MULT_DIV_255((255 - srcA), dstA, dstA);
  8465. dstA += srcA;
  8466. break;
  8467. case SDL_COPY_BLEND_PREMULTIPLIED:
  8468. MULT_DIV_255((255 - srcA), dstR, dstR);
  8469. dstR += srcR;
  8470. if (dstR > 255) dstR = 255;
  8471. MULT_DIV_255((255 - srcA), dstG, dstG);
  8472. dstG += srcG;
  8473. if (dstG > 255) dstG = 255;
  8474. MULT_DIV_255((255 - srcA), dstB, dstB);
  8475. dstB += srcB;
  8476. if (dstB > 255) dstB = 255;
  8477. MULT_DIV_255((255 - srcA), dstA, dstA);
  8478. dstA += srcA;
  8479. if (dstA > 255) dstA = 255;
  8480. break;
  8481. case SDL_COPY_ADD:
  8482. case SDL_COPY_ADD_PREMULTIPLIED:
  8483. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8484. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8485. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8486. break;
  8487. case SDL_COPY_MOD:
  8488. MULT_DIV_255(srcR, dstR, dstR);
  8489. MULT_DIV_255(srcG, dstG, dstG);
  8490. MULT_DIV_255(srcB, dstB, dstB);
  8491. break;
  8492. case SDL_COPY_MUL:
  8493. {
  8494. Uint32 tmp1, tmp2;
  8495. MULT_DIV_255(srcR, dstR, tmp1);
  8496. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8497. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8498. MULT_DIV_255(srcG, dstG, tmp1);
  8499. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8500. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8501. MULT_DIV_255(srcB, dstB, tmp1);
  8502. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8503. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8504. }
  8505. break;
  8506. }
  8507. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  8508. *dst = dstpixel;
  8509. ++src;
  8510. ++dst;
  8511. }
  8512. info->src += info->src_pitch;
  8513. info->dst += info->dst_pitch;
  8514. }
  8515. }
  8516. static void SDL_Blit_ABGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  8517. {
  8518. const int flags = info->flags;
  8519. Uint32 srcpixel;
  8520. Uint32 srcR, srcG, srcB, srcA;
  8521. Uint32 dstpixel;
  8522. Uint32 dstR, dstG, dstB, dstA;
  8523. Uint64 srcy, srcx;
  8524. Uint64 posy, posx;
  8525. Uint64 incy, incx;
  8526. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8527. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8528. posy = incy / 2;
  8529. while (info->dst_h--) {
  8530. Uint32 *src = 0;
  8531. Uint32 *dst = (Uint32 *)info->dst;
  8532. int n = info->dst_w;
  8533. posx = incx / 2;
  8534. srcy = posy >> 16;
  8535. while (n--) {
  8536. srcx = posx >> 16;
  8537. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8538. srcpixel = *src;
  8539. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8540. dstpixel = *dst;
  8541. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8542. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8543. if (srcA < 255) {
  8544. MULT_DIV_255(srcR, srcA, srcR);
  8545. MULT_DIV_255(srcG, srcA, srcG);
  8546. MULT_DIV_255(srcB, srcA, srcB);
  8547. }
  8548. }
  8549. switch (flags & SDL_COPY_BLEND_MASK) {
  8550. case SDL_COPY_BLEND:
  8551. MULT_DIV_255((255 - srcA), dstR, dstR);
  8552. dstR += srcR;
  8553. MULT_DIV_255((255 - srcA), dstG, dstG);
  8554. dstG += srcG;
  8555. MULT_DIV_255((255 - srcA), dstB, dstB);
  8556. dstB += srcB;
  8557. MULT_DIV_255((255 - srcA), dstA, dstA);
  8558. dstA += srcA;
  8559. break;
  8560. case SDL_COPY_BLEND_PREMULTIPLIED:
  8561. MULT_DIV_255((255 - srcA), dstR, dstR);
  8562. dstR += srcR;
  8563. if (dstR > 255) dstR = 255;
  8564. MULT_DIV_255((255 - srcA), dstG, dstG);
  8565. dstG += srcG;
  8566. if (dstG > 255) dstG = 255;
  8567. MULT_DIV_255((255 - srcA), dstB, dstB);
  8568. dstB += srcB;
  8569. if (dstB > 255) dstB = 255;
  8570. MULT_DIV_255((255 - srcA), dstA, dstA);
  8571. dstA += srcA;
  8572. if (dstA > 255) dstA = 255;
  8573. break;
  8574. case SDL_COPY_ADD:
  8575. case SDL_COPY_ADD_PREMULTIPLIED:
  8576. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8577. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8578. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8579. break;
  8580. case SDL_COPY_MOD:
  8581. MULT_DIV_255(srcR, dstR, dstR);
  8582. MULT_DIV_255(srcG, dstG, dstG);
  8583. MULT_DIV_255(srcB, dstB, dstB);
  8584. break;
  8585. case SDL_COPY_MUL:
  8586. {
  8587. Uint32 tmp1, tmp2;
  8588. MULT_DIV_255(srcR, dstR, tmp1);
  8589. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8590. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8591. MULT_DIV_255(srcG, dstG, tmp1);
  8592. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8593. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8594. MULT_DIV_255(srcB, dstB, tmp1);
  8595. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8596. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8597. }
  8598. break;
  8599. }
  8600. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  8601. *dst = dstpixel;
  8602. posx += incx;
  8603. ++dst;
  8604. }
  8605. posy += incy;
  8606. info->dst += info->dst_pitch;
  8607. }
  8608. }
  8609. static void SDL_Blit_ABGR8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  8610. {
  8611. const int flags = info->flags;
  8612. const Uint32 modulateR = info->r;
  8613. const Uint32 modulateG = info->g;
  8614. const Uint32 modulateB = info->b;
  8615. const Uint32 modulateA = info->a;
  8616. Uint32 pixel;
  8617. Uint32 R, G, B, A;
  8618. while (info->dst_h--) {
  8619. Uint32 *src = (Uint32 *)info->src;
  8620. Uint32 *dst = (Uint32 *)info->dst;
  8621. int n = info->dst_w;
  8622. while (n--) {
  8623. pixel = *src;
  8624. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  8625. if (flags & SDL_COPY_MODULATE_COLOR) {
  8626. MULT_DIV_255(R, modulateR, R);
  8627. MULT_DIV_255(G, modulateG, G);
  8628. MULT_DIV_255(B, modulateB, B);
  8629. }
  8630. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8631. MULT_DIV_255(A, modulateA, A);
  8632. }
  8633. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  8634. *dst = pixel;
  8635. ++src;
  8636. ++dst;
  8637. }
  8638. info->src += info->src_pitch;
  8639. info->dst += info->dst_pitch;
  8640. }
  8641. }
  8642. static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  8643. {
  8644. const int flags = info->flags;
  8645. const Uint32 modulateR = info->r;
  8646. const Uint32 modulateG = info->g;
  8647. const Uint32 modulateB = info->b;
  8648. const Uint32 modulateA = info->a;
  8649. Uint32 pixel;
  8650. Uint32 R, G, B, A;
  8651. Uint64 srcy, srcx;
  8652. Uint64 posy, posx;
  8653. Uint64 incy, incx;
  8654. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8655. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8656. posy = incy / 2;
  8657. while (info->dst_h--) {
  8658. Uint32 *src = 0;
  8659. Uint32 *dst = (Uint32 *)info->dst;
  8660. int n = info->dst_w;
  8661. posx = incx / 2;
  8662. srcy = posy >> 16;
  8663. while (n--) {
  8664. srcx = posx >> 16;
  8665. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8666. pixel = *src;
  8667. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  8668. if (flags & SDL_COPY_MODULATE_COLOR) {
  8669. MULT_DIV_255(R, modulateR, R);
  8670. MULT_DIV_255(G, modulateG, G);
  8671. MULT_DIV_255(B, modulateB, B);
  8672. }
  8673. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8674. MULT_DIV_255(A, modulateA, A);
  8675. }
  8676. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  8677. *dst = pixel;
  8678. posx += incx;
  8679. ++dst;
  8680. }
  8681. posy += incy;
  8682. info->dst += info->dst_pitch;
  8683. }
  8684. }
  8685. static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  8686. {
  8687. const int flags = info->flags;
  8688. const Uint32 modulateR = info->r;
  8689. const Uint32 modulateG = info->g;
  8690. const Uint32 modulateB = info->b;
  8691. const Uint32 modulateA = info->a;
  8692. Uint32 srcpixel;
  8693. Uint32 srcR, srcG, srcB, srcA;
  8694. Uint32 dstpixel;
  8695. Uint32 dstR, dstG, dstB, dstA;
  8696. while (info->dst_h--) {
  8697. Uint32 *src = (Uint32 *)info->src;
  8698. Uint32 *dst = (Uint32 *)info->dst;
  8699. int n = info->dst_w;
  8700. while (n--) {
  8701. srcpixel = *src;
  8702. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8703. dstpixel = *dst;
  8704. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8705. if (flags & SDL_COPY_MODULATE_COLOR) {
  8706. MULT_DIV_255(srcR, modulateR, srcR);
  8707. MULT_DIV_255(srcG, modulateG, srcG);
  8708. MULT_DIV_255(srcB, modulateB, srcB);
  8709. }
  8710. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8711. MULT_DIV_255(srcA, modulateA, srcA);
  8712. }
  8713. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8714. if (srcA < 255) {
  8715. MULT_DIV_255(srcR, srcA, srcR);
  8716. MULT_DIV_255(srcG, srcA, srcG);
  8717. MULT_DIV_255(srcB, srcA, srcB);
  8718. }
  8719. }
  8720. switch (flags & SDL_COPY_BLEND_MASK) {
  8721. case SDL_COPY_BLEND:
  8722. MULT_DIV_255((255 - srcA), dstR, dstR);
  8723. dstR += srcR;
  8724. MULT_DIV_255((255 - srcA), dstG, dstG);
  8725. dstG += srcG;
  8726. MULT_DIV_255((255 - srcA), dstB, dstB);
  8727. dstB += srcB;
  8728. MULT_DIV_255((255 - srcA), dstA, dstA);
  8729. dstA += srcA;
  8730. break;
  8731. case SDL_COPY_BLEND_PREMULTIPLIED:
  8732. MULT_DIV_255((255 - srcA), dstR, dstR);
  8733. dstR += srcR;
  8734. if (dstR > 255) dstR = 255;
  8735. MULT_DIV_255((255 - srcA), dstG, dstG);
  8736. dstG += srcG;
  8737. if (dstG > 255) dstG = 255;
  8738. MULT_DIV_255((255 - srcA), dstB, dstB);
  8739. dstB += srcB;
  8740. if (dstB > 255) dstB = 255;
  8741. MULT_DIV_255((255 - srcA), dstA, dstA);
  8742. dstA += srcA;
  8743. if (dstA > 255) dstA = 255;
  8744. break;
  8745. case SDL_COPY_ADD:
  8746. case SDL_COPY_ADD_PREMULTIPLIED:
  8747. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8748. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8749. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8750. break;
  8751. case SDL_COPY_MOD:
  8752. MULT_DIV_255(srcR, dstR, dstR);
  8753. MULT_DIV_255(srcG, dstG, dstG);
  8754. MULT_DIV_255(srcB, dstB, dstB);
  8755. break;
  8756. case SDL_COPY_MUL:
  8757. {
  8758. Uint32 tmp1, tmp2;
  8759. MULT_DIV_255(srcR, dstR, tmp1);
  8760. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8761. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8762. MULT_DIV_255(srcG, dstG, tmp1);
  8763. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8764. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8765. MULT_DIV_255(srcB, dstB, tmp1);
  8766. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8767. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8768. }
  8769. break;
  8770. }
  8771. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  8772. *dst = dstpixel;
  8773. ++src;
  8774. ++dst;
  8775. }
  8776. info->src += info->src_pitch;
  8777. info->dst += info->dst_pitch;
  8778. }
  8779. }
  8780. static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  8781. {
  8782. const int flags = info->flags;
  8783. const Uint32 modulateR = info->r;
  8784. const Uint32 modulateG = info->g;
  8785. const Uint32 modulateB = info->b;
  8786. const Uint32 modulateA = info->a;
  8787. Uint32 srcpixel;
  8788. Uint32 srcR, srcG, srcB, srcA;
  8789. Uint32 dstpixel;
  8790. Uint32 dstR, dstG, dstB, dstA;
  8791. Uint64 srcy, srcx;
  8792. Uint64 posy, posx;
  8793. Uint64 incy, incx;
  8794. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8795. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8796. posy = incy / 2;
  8797. while (info->dst_h--) {
  8798. Uint32 *src = 0;
  8799. Uint32 *dst = (Uint32 *)info->dst;
  8800. int n = info->dst_w;
  8801. posx = incx / 2;
  8802. srcy = posy >> 16;
  8803. while (n--) {
  8804. srcx = posx >> 16;
  8805. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8806. srcpixel = *src;
  8807. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  8808. dstpixel = *dst;
  8809. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  8810. if (flags & SDL_COPY_MODULATE_COLOR) {
  8811. MULT_DIV_255(srcR, modulateR, srcR);
  8812. MULT_DIV_255(srcG, modulateG, srcG);
  8813. MULT_DIV_255(srcB, modulateB, srcB);
  8814. }
  8815. if (flags & SDL_COPY_MODULATE_ALPHA) {
  8816. MULT_DIV_255(srcA, modulateA, srcA);
  8817. }
  8818. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8819. if (srcA < 255) {
  8820. MULT_DIV_255(srcR, srcA, srcR);
  8821. MULT_DIV_255(srcG, srcA, srcG);
  8822. MULT_DIV_255(srcB, srcA, srcB);
  8823. }
  8824. }
  8825. switch (flags & SDL_COPY_BLEND_MASK) {
  8826. case SDL_COPY_BLEND:
  8827. MULT_DIV_255((255 - srcA), dstR, dstR);
  8828. dstR += srcR;
  8829. MULT_DIV_255((255 - srcA), dstG, dstG);
  8830. dstG += srcG;
  8831. MULT_DIV_255((255 - srcA), dstB, dstB);
  8832. dstB += srcB;
  8833. MULT_DIV_255((255 - srcA), dstA, dstA);
  8834. dstA += srcA;
  8835. break;
  8836. case SDL_COPY_BLEND_PREMULTIPLIED:
  8837. MULT_DIV_255((255 - srcA), dstR, dstR);
  8838. dstR += srcR;
  8839. if (dstR > 255) dstR = 255;
  8840. MULT_DIV_255((255 - srcA), dstG, dstG);
  8841. dstG += srcG;
  8842. if (dstG > 255) dstG = 255;
  8843. MULT_DIV_255((255 - srcA), dstB, dstB);
  8844. dstB += srcB;
  8845. if (dstB > 255) dstB = 255;
  8846. MULT_DIV_255((255 - srcA), dstA, dstA);
  8847. dstA += srcA;
  8848. if (dstA > 255) dstA = 255;
  8849. break;
  8850. case SDL_COPY_ADD:
  8851. case SDL_COPY_ADD_PREMULTIPLIED:
  8852. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8853. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8854. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8855. break;
  8856. case SDL_COPY_MOD:
  8857. MULT_DIV_255(srcR, dstR, dstR);
  8858. MULT_DIV_255(srcG, dstG, dstG);
  8859. MULT_DIV_255(srcB, dstB, dstB);
  8860. break;
  8861. case SDL_COPY_MUL:
  8862. {
  8863. Uint32 tmp1, tmp2;
  8864. MULT_DIV_255(srcR, dstR, tmp1);
  8865. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8866. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8867. MULT_DIV_255(srcG, dstG, tmp1);
  8868. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8869. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8870. MULT_DIV_255(srcB, dstB, tmp1);
  8871. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8872. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8873. }
  8874. break;
  8875. }
  8876. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  8877. *dst = dstpixel;
  8878. posx += incx;
  8879. ++dst;
  8880. }
  8881. posy += incy;
  8882. info->dst += info->dst_pitch;
  8883. }
  8884. }
  8885. static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
  8886. {
  8887. Uint32 pixel;
  8888. Uint32 R, G, B;
  8889. Uint64 srcy, srcx;
  8890. Uint64 posy, posx;
  8891. Uint64 incy, incx;
  8892. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  8893. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  8894. posy = incy / 2;
  8895. while (info->dst_h--) {
  8896. Uint32 *src = 0;
  8897. Uint32 *dst = (Uint32 *)info->dst;
  8898. int n = info->dst_w;
  8899. posx = incx / 2;
  8900. srcy = posy >> 16;
  8901. while (n--) {
  8902. srcx = posx >> 16;
  8903. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  8904. pixel = *src;
  8905. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  8906. pixel = (R << 16) | (G << 8) | B;
  8907. *dst = pixel;
  8908. posx += incx;
  8909. ++dst;
  8910. }
  8911. posy += incy;
  8912. info->dst += info->dst_pitch;
  8913. }
  8914. }
  8915. static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
  8916. {
  8917. const int flags = info->flags;
  8918. Uint32 srcpixel;
  8919. Uint32 srcR, srcG, srcB, srcA;
  8920. Uint32 dstpixel;
  8921. Uint32 dstR, dstG, dstB;
  8922. while (info->dst_h--) {
  8923. Uint32 *src = (Uint32 *)info->src;
  8924. Uint32 *dst = (Uint32 *)info->dst;
  8925. int n = info->dst_w;
  8926. while (n--) {
  8927. srcpixel = *src;
  8928. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  8929. dstpixel = *dst;
  8930. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  8931. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  8932. if (srcA < 255) {
  8933. MULT_DIV_255(srcR, srcA, srcR);
  8934. MULT_DIV_255(srcG, srcA, srcG);
  8935. MULT_DIV_255(srcB, srcA, srcB);
  8936. }
  8937. }
  8938. switch (flags & SDL_COPY_BLEND_MASK) {
  8939. case SDL_COPY_BLEND:
  8940. MULT_DIV_255((255 - srcA), dstR, dstR);
  8941. dstR += srcR;
  8942. MULT_DIV_255((255 - srcA), dstG, dstG);
  8943. dstG += srcG;
  8944. MULT_DIV_255((255 - srcA), dstB, dstB);
  8945. dstB += srcB;
  8946. break;
  8947. case SDL_COPY_BLEND_PREMULTIPLIED:
  8948. MULT_DIV_255((255 - srcA), dstR, dstR);
  8949. dstR += srcR;
  8950. if (dstR > 255) dstR = 255;
  8951. MULT_DIV_255((255 - srcA), dstG, dstG);
  8952. dstG += srcG;
  8953. if (dstG > 255) dstG = 255;
  8954. MULT_DIV_255((255 - srcA), dstB, dstB);
  8955. dstB += srcB;
  8956. if (dstB > 255) dstB = 255;
  8957. break;
  8958. case SDL_COPY_ADD:
  8959. case SDL_COPY_ADD_PREMULTIPLIED:
  8960. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  8961. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  8962. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  8963. break;
  8964. case SDL_COPY_MOD:
  8965. MULT_DIV_255(srcR, dstR, dstR);
  8966. MULT_DIV_255(srcG, dstG, dstG);
  8967. MULT_DIV_255(srcB, dstB, dstB);
  8968. break;
  8969. case SDL_COPY_MUL:
  8970. {
  8971. Uint32 tmp1, tmp2;
  8972. MULT_DIV_255(srcR, dstR, tmp1);
  8973. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  8974. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  8975. MULT_DIV_255(srcG, dstG, tmp1);
  8976. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  8977. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  8978. MULT_DIV_255(srcB, dstB, tmp1);
  8979. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  8980. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  8981. }
  8982. break;
  8983. }
  8984. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  8985. *dst = dstpixel;
  8986. ++src;
  8987. ++dst;
  8988. }
  8989. info->src += info->src_pitch;
  8990. info->dst += info->dst_pitch;
  8991. }
  8992. }
  8993. static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
  8994. {
  8995. const int flags = info->flags;
  8996. Uint32 srcpixel;
  8997. Uint32 srcR, srcG, srcB, srcA;
  8998. Uint32 dstpixel;
  8999. Uint32 dstR, dstG, dstB;
  9000. Uint64 srcy, srcx;
  9001. Uint64 posy, posx;
  9002. Uint64 incy, incx;
  9003. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9004. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9005. posy = incy / 2;
  9006. while (info->dst_h--) {
  9007. Uint32 *src = 0;
  9008. Uint32 *dst = (Uint32 *)info->dst;
  9009. int n = info->dst_w;
  9010. posx = incx / 2;
  9011. srcy = posy >> 16;
  9012. while (n--) {
  9013. srcx = posx >> 16;
  9014. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9015. srcpixel = *src;
  9016. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9017. dstpixel = *dst;
  9018. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  9019. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9020. if (srcA < 255) {
  9021. MULT_DIV_255(srcR, srcA, srcR);
  9022. MULT_DIV_255(srcG, srcA, srcG);
  9023. MULT_DIV_255(srcB, srcA, srcB);
  9024. }
  9025. }
  9026. switch (flags & SDL_COPY_BLEND_MASK) {
  9027. case SDL_COPY_BLEND:
  9028. MULT_DIV_255((255 - srcA), dstR, dstR);
  9029. dstR += srcR;
  9030. MULT_DIV_255((255 - srcA), dstG, dstG);
  9031. dstG += srcG;
  9032. MULT_DIV_255((255 - srcA), dstB, dstB);
  9033. dstB += srcB;
  9034. break;
  9035. case SDL_COPY_BLEND_PREMULTIPLIED:
  9036. MULT_DIV_255((255 - srcA), dstR, dstR);
  9037. dstR += srcR;
  9038. if (dstR > 255) dstR = 255;
  9039. MULT_DIV_255((255 - srcA), dstG, dstG);
  9040. dstG += srcG;
  9041. if (dstG > 255) dstG = 255;
  9042. MULT_DIV_255((255 - srcA), dstB, dstB);
  9043. dstB += srcB;
  9044. if (dstB > 255) dstB = 255;
  9045. break;
  9046. case SDL_COPY_ADD:
  9047. case SDL_COPY_ADD_PREMULTIPLIED:
  9048. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9049. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9050. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9051. break;
  9052. case SDL_COPY_MOD:
  9053. MULT_DIV_255(srcR, dstR, dstR);
  9054. MULT_DIV_255(srcG, dstG, dstG);
  9055. MULT_DIV_255(srcB, dstB, dstB);
  9056. break;
  9057. case SDL_COPY_MUL:
  9058. {
  9059. Uint32 tmp1, tmp2;
  9060. MULT_DIV_255(srcR, dstR, tmp1);
  9061. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9062. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9063. MULT_DIV_255(srcG, dstG, tmp1);
  9064. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9065. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9066. MULT_DIV_255(srcB, dstB, tmp1);
  9067. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9068. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9069. }
  9070. break;
  9071. }
  9072. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  9073. *dst = dstpixel;
  9074. posx += incx;
  9075. ++dst;
  9076. }
  9077. posy += incy;
  9078. info->dst += info->dst_pitch;
  9079. }
  9080. }
  9081. static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
  9082. {
  9083. const int flags = info->flags;
  9084. const Uint32 modulateR = info->r;
  9085. const Uint32 modulateG = info->g;
  9086. const Uint32 modulateB = info->b;
  9087. Uint32 pixel;
  9088. Uint32 R, G, B;
  9089. while (info->dst_h--) {
  9090. Uint32 *src = (Uint32 *)info->src;
  9091. Uint32 *dst = (Uint32 *)info->dst;
  9092. int n = info->dst_w;
  9093. while (n--) {
  9094. pixel = *src;
  9095. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  9096. if (flags & SDL_COPY_MODULATE_COLOR) {
  9097. MULT_DIV_255(R, modulateR, R);
  9098. MULT_DIV_255(G, modulateG, G);
  9099. MULT_DIV_255(B, modulateB, B);
  9100. }
  9101. pixel = (R << 16) | (G << 8) | B;
  9102. *dst = pixel;
  9103. ++src;
  9104. ++dst;
  9105. }
  9106. info->src += info->src_pitch;
  9107. info->dst += info->dst_pitch;
  9108. }
  9109. }
  9110. static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
  9111. {
  9112. const int flags = info->flags;
  9113. const Uint32 modulateR = info->r;
  9114. const Uint32 modulateG = info->g;
  9115. const Uint32 modulateB = info->b;
  9116. Uint32 pixel;
  9117. Uint32 R, G, B;
  9118. Uint64 srcy, srcx;
  9119. Uint64 posy, posx;
  9120. Uint64 incy, incx;
  9121. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9122. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9123. posy = incy / 2;
  9124. while (info->dst_h--) {
  9125. Uint32 *src = 0;
  9126. Uint32 *dst = (Uint32 *)info->dst;
  9127. int n = info->dst_w;
  9128. posx = incx / 2;
  9129. srcy = posy >> 16;
  9130. while (n--) {
  9131. srcx = posx >> 16;
  9132. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9133. pixel = *src;
  9134. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  9135. if (flags & SDL_COPY_MODULATE_COLOR) {
  9136. MULT_DIV_255(R, modulateR, R);
  9137. MULT_DIV_255(G, modulateG, G);
  9138. MULT_DIV_255(B, modulateB, B);
  9139. }
  9140. pixel = (R << 16) | (G << 8) | B;
  9141. *dst = pixel;
  9142. posx += incx;
  9143. ++dst;
  9144. }
  9145. posy += incy;
  9146. info->dst += info->dst_pitch;
  9147. }
  9148. }
  9149. static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
  9150. {
  9151. const int flags = info->flags;
  9152. const Uint32 modulateR = info->r;
  9153. const Uint32 modulateG = info->g;
  9154. const Uint32 modulateB = info->b;
  9155. const Uint32 modulateA = info->a;
  9156. Uint32 srcpixel;
  9157. Uint32 srcR, srcG, srcB, srcA;
  9158. Uint32 dstpixel;
  9159. Uint32 dstR, dstG, dstB;
  9160. while (info->dst_h--) {
  9161. Uint32 *src = (Uint32 *)info->src;
  9162. Uint32 *dst = (Uint32 *)info->dst;
  9163. int n = info->dst_w;
  9164. while (n--) {
  9165. srcpixel = *src;
  9166. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9167. dstpixel = *dst;
  9168. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  9169. if (flags & SDL_COPY_MODULATE_COLOR) {
  9170. MULT_DIV_255(srcR, modulateR, srcR);
  9171. MULT_DIV_255(srcG, modulateG, srcG);
  9172. MULT_DIV_255(srcB, modulateB, srcB);
  9173. }
  9174. if (flags & SDL_COPY_MODULATE_ALPHA) {
  9175. MULT_DIV_255(srcA, modulateA, srcA);
  9176. }
  9177. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9178. if (srcA < 255) {
  9179. MULT_DIV_255(srcR, srcA, srcR);
  9180. MULT_DIV_255(srcG, srcA, srcG);
  9181. MULT_DIV_255(srcB, srcA, srcB);
  9182. }
  9183. }
  9184. switch (flags & SDL_COPY_BLEND_MASK) {
  9185. case SDL_COPY_BLEND:
  9186. MULT_DIV_255((255 - srcA), dstR, dstR);
  9187. dstR += srcR;
  9188. MULT_DIV_255((255 - srcA), dstG, dstG);
  9189. dstG += srcG;
  9190. MULT_DIV_255((255 - srcA), dstB, dstB);
  9191. dstB += srcB;
  9192. break;
  9193. case SDL_COPY_BLEND_PREMULTIPLIED:
  9194. MULT_DIV_255((255 - srcA), dstR, dstR);
  9195. dstR += srcR;
  9196. if (dstR > 255) dstR = 255;
  9197. MULT_DIV_255((255 - srcA), dstG, dstG);
  9198. dstG += srcG;
  9199. if (dstG > 255) dstG = 255;
  9200. MULT_DIV_255((255 - srcA), dstB, dstB);
  9201. dstB += srcB;
  9202. if (dstB > 255) dstB = 255;
  9203. break;
  9204. case SDL_COPY_ADD:
  9205. case SDL_COPY_ADD_PREMULTIPLIED:
  9206. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9207. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9208. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9209. break;
  9210. case SDL_COPY_MOD:
  9211. MULT_DIV_255(srcR, dstR, dstR);
  9212. MULT_DIV_255(srcG, dstG, dstG);
  9213. MULT_DIV_255(srcB, dstB, dstB);
  9214. break;
  9215. case SDL_COPY_MUL:
  9216. {
  9217. Uint32 tmp1, tmp2;
  9218. MULT_DIV_255(srcR, dstR, tmp1);
  9219. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9220. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9221. MULT_DIV_255(srcG, dstG, tmp1);
  9222. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9223. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9224. MULT_DIV_255(srcB, dstB, tmp1);
  9225. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9226. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9227. }
  9228. break;
  9229. }
  9230. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  9231. *dst = dstpixel;
  9232. ++src;
  9233. ++dst;
  9234. }
  9235. info->src += info->src_pitch;
  9236. info->dst += info->dst_pitch;
  9237. }
  9238. }
  9239. static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  9240. {
  9241. const int flags = info->flags;
  9242. const Uint32 modulateR = info->r;
  9243. const Uint32 modulateG = info->g;
  9244. const Uint32 modulateB = info->b;
  9245. const Uint32 modulateA = info->a;
  9246. Uint32 srcpixel;
  9247. Uint32 srcR, srcG, srcB, srcA;
  9248. Uint32 dstpixel;
  9249. Uint32 dstR, dstG, dstB;
  9250. Uint64 srcy, srcx;
  9251. Uint64 posy, posx;
  9252. Uint64 incy, incx;
  9253. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9254. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9255. posy = incy / 2;
  9256. while (info->dst_h--) {
  9257. Uint32 *src = 0;
  9258. Uint32 *dst = (Uint32 *)info->dst;
  9259. int n = info->dst_w;
  9260. posx = incx / 2;
  9261. srcy = posy >> 16;
  9262. while (n--) {
  9263. srcx = posx >> 16;
  9264. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9265. srcpixel = *src;
  9266. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9267. dstpixel = *dst;
  9268. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  9269. if (flags & SDL_COPY_MODULATE_COLOR) {
  9270. MULT_DIV_255(srcR, modulateR, srcR);
  9271. MULT_DIV_255(srcG, modulateG, srcG);
  9272. MULT_DIV_255(srcB, modulateB, srcB);
  9273. }
  9274. if (flags & SDL_COPY_MODULATE_ALPHA) {
  9275. MULT_DIV_255(srcA, modulateA, srcA);
  9276. }
  9277. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9278. if (srcA < 255) {
  9279. MULT_DIV_255(srcR, srcA, srcR);
  9280. MULT_DIV_255(srcG, srcA, srcG);
  9281. MULT_DIV_255(srcB, srcA, srcB);
  9282. }
  9283. }
  9284. switch (flags & SDL_COPY_BLEND_MASK) {
  9285. case SDL_COPY_BLEND:
  9286. MULT_DIV_255((255 - srcA), dstR, dstR);
  9287. dstR += srcR;
  9288. MULT_DIV_255((255 - srcA), dstG, dstG);
  9289. dstG += srcG;
  9290. MULT_DIV_255((255 - srcA), dstB, dstB);
  9291. dstB += srcB;
  9292. break;
  9293. case SDL_COPY_BLEND_PREMULTIPLIED:
  9294. MULT_DIV_255((255 - srcA), dstR, dstR);
  9295. dstR += srcR;
  9296. if (dstR > 255) dstR = 255;
  9297. MULT_DIV_255((255 - srcA), dstG, dstG);
  9298. dstG += srcG;
  9299. if (dstG > 255) dstG = 255;
  9300. MULT_DIV_255((255 - srcA), dstB, dstB);
  9301. dstB += srcB;
  9302. if (dstB > 255) dstB = 255;
  9303. break;
  9304. case SDL_COPY_ADD:
  9305. case SDL_COPY_ADD_PREMULTIPLIED:
  9306. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9307. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9308. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9309. break;
  9310. case SDL_COPY_MOD:
  9311. MULT_DIV_255(srcR, dstR, dstR);
  9312. MULT_DIV_255(srcG, dstG, dstG);
  9313. MULT_DIV_255(srcB, dstB, dstB);
  9314. break;
  9315. case SDL_COPY_MUL:
  9316. {
  9317. Uint32 tmp1, tmp2;
  9318. MULT_DIV_255(srcR, dstR, tmp1);
  9319. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9320. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9321. MULT_DIV_255(srcG, dstG, tmp1);
  9322. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9323. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9324. MULT_DIV_255(srcB, dstB, tmp1);
  9325. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9326. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9327. }
  9328. break;
  9329. }
  9330. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  9331. *dst = dstpixel;
  9332. posx += incx;
  9333. ++dst;
  9334. }
  9335. posy += incy;
  9336. info->dst += info->dst_pitch;
  9337. }
  9338. }
  9339. static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
  9340. {
  9341. Uint32 pixel;
  9342. Uint64 srcy, srcx;
  9343. Uint64 posy, posx;
  9344. Uint64 incy, incx;
  9345. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9346. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9347. posy = incy / 2;
  9348. while (info->dst_h--) {
  9349. Uint32 *src = 0;
  9350. Uint32 *dst = (Uint32 *)info->dst;
  9351. int n = info->dst_w;
  9352. posx = incx / 2;
  9353. srcy = posy >> 16;
  9354. while (n--) {
  9355. srcx = posx >> 16;
  9356. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9357. pixel = *src;
  9358. pixel >>= 8;
  9359. *dst = pixel;
  9360. posx += incx;
  9361. ++dst;
  9362. }
  9363. posy += incy;
  9364. info->dst += info->dst_pitch;
  9365. }
  9366. }
  9367. static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
  9368. {
  9369. const int flags = info->flags;
  9370. Uint32 srcpixel;
  9371. Uint32 srcR, srcG, srcB, srcA;
  9372. Uint32 dstpixel;
  9373. Uint32 dstR, dstG, dstB;
  9374. while (info->dst_h--) {
  9375. Uint32 *src = (Uint32 *)info->src;
  9376. Uint32 *dst = (Uint32 *)info->dst;
  9377. int n = info->dst_w;
  9378. while (n--) {
  9379. srcpixel = *src;
  9380. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9381. dstpixel = *dst;
  9382. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  9383. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9384. if (srcA < 255) {
  9385. MULT_DIV_255(srcR, srcA, srcR);
  9386. MULT_DIV_255(srcG, srcA, srcG);
  9387. MULT_DIV_255(srcB, srcA, srcB);
  9388. }
  9389. }
  9390. switch (flags & SDL_COPY_BLEND_MASK) {
  9391. case SDL_COPY_BLEND:
  9392. MULT_DIV_255((255 - srcA), dstR, dstR);
  9393. dstR += srcR;
  9394. MULT_DIV_255((255 - srcA), dstG, dstG);
  9395. dstG += srcG;
  9396. MULT_DIV_255((255 - srcA), dstB, dstB);
  9397. dstB += srcB;
  9398. break;
  9399. case SDL_COPY_BLEND_PREMULTIPLIED:
  9400. MULT_DIV_255((255 - srcA), dstR, dstR);
  9401. dstR += srcR;
  9402. if (dstR > 255) dstR = 255;
  9403. MULT_DIV_255((255 - srcA), dstG, dstG);
  9404. dstG += srcG;
  9405. if (dstG > 255) dstG = 255;
  9406. MULT_DIV_255((255 - srcA), dstB, dstB);
  9407. dstB += srcB;
  9408. if (dstB > 255) dstB = 255;
  9409. break;
  9410. case SDL_COPY_ADD:
  9411. case SDL_COPY_ADD_PREMULTIPLIED:
  9412. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9413. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9414. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9415. break;
  9416. case SDL_COPY_MOD:
  9417. MULT_DIV_255(srcR, dstR, dstR);
  9418. MULT_DIV_255(srcG, dstG, dstG);
  9419. MULT_DIV_255(srcB, dstB, dstB);
  9420. break;
  9421. case SDL_COPY_MUL:
  9422. {
  9423. Uint32 tmp1, tmp2;
  9424. MULT_DIV_255(srcR, dstR, tmp1);
  9425. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9426. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9427. MULT_DIV_255(srcG, dstG, tmp1);
  9428. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9429. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9430. MULT_DIV_255(srcB, dstB, tmp1);
  9431. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9432. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9433. }
  9434. break;
  9435. }
  9436. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  9437. *dst = dstpixel;
  9438. ++src;
  9439. ++dst;
  9440. }
  9441. info->src += info->src_pitch;
  9442. info->dst += info->dst_pitch;
  9443. }
  9444. }
  9445. static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
  9446. {
  9447. const int flags = info->flags;
  9448. Uint32 srcpixel;
  9449. Uint32 srcR, srcG, srcB, srcA;
  9450. Uint32 dstpixel;
  9451. Uint32 dstR, dstG, dstB;
  9452. Uint64 srcy, srcx;
  9453. Uint64 posy, posx;
  9454. Uint64 incy, incx;
  9455. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9456. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9457. posy = incy / 2;
  9458. while (info->dst_h--) {
  9459. Uint32 *src = 0;
  9460. Uint32 *dst = (Uint32 *)info->dst;
  9461. int n = info->dst_w;
  9462. posx = incx / 2;
  9463. srcy = posy >> 16;
  9464. while (n--) {
  9465. srcx = posx >> 16;
  9466. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9467. srcpixel = *src;
  9468. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9469. dstpixel = *dst;
  9470. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  9471. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9472. if (srcA < 255) {
  9473. MULT_DIV_255(srcR, srcA, srcR);
  9474. MULT_DIV_255(srcG, srcA, srcG);
  9475. MULT_DIV_255(srcB, srcA, srcB);
  9476. }
  9477. }
  9478. switch (flags & SDL_COPY_BLEND_MASK) {
  9479. case SDL_COPY_BLEND:
  9480. MULT_DIV_255((255 - srcA), dstR, dstR);
  9481. dstR += srcR;
  9482. MULT_DIV_255((255 - srcA), dstG, dstG);
  9483. dstG += srcG;
  9484. MULT_DIV_255((255 - srcA), dstB, dstB);
  9485. dstB += srcB;
  9486. break;
  9487. case SDL_COPY_BLEND_PREMULTIPLIED:
  9488. MULT_DIV_255((255 - srcA), dstR, dstR);
  9489. dstR += srcR;
  9490. if (dstR > 255) dstR = 255;
  9491. MULT_DIV_255((255 - srcA), dstG, dstG);
  9492. dstG += srcG;
  9493. if (dstG > 255) dstG = 255;
  9494. MULT_DIV_255((255 - srcA), dstB, dstB);
  9495. dstB += srcB;
  9496. if (dstB > 255) dstB = 255;
  9497. break;
  9498. case SDL_COPY_ADD:
  9499. case SDL_COPY_ADD_PREMULTIPLIED:
  9500. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9501. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9502. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9503. break;
  9504. case SDL_COPY_MOD:
  9505. MULT_DIV_255(srcR, dstR, dstR);
  9506. MULT_DIV_255(srcG, dstG, dstG);
  9507. MULT_DIV_255(srcB, dstB, dstB);
  9508. break;
  9509. case SDL_COPY_MUL:
  9510. {
  9511. Uint32 tmp1, tmp2;
  9512. MULT_DIV_255(srcR, dstR, tmp1);
  9513. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9514. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9515. MULT_DIV_255(srcG, dstG, tmp1);
  9516. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9517. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9518. MULT_DIV_255(srcB, dstB, tmp1);
  9519. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9520. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9521. }
  9522. break;
  9523. }
  9524. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  9525. *dst = dstpixel;
  9526. posx += incx;
  9527. ++dst;
  9528. }
  9529. posy += incy;
  9530. info->dst += info->dst_pitch;
  9531. }
  9532. }
  9533. static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
  9534. {
  9535. const int flags = info->flags;
  9536. const Uint32 modulateR = info->r;
  9537. const Uint32 modulateG = info->g;
  9538. const Uint32 modulateB = info->b;
  9539. Uint32 pixel;
  9540. Uint32 R, G, B;
  9541. while (info->dst_h--) {
  9542. Uint32 *src = (Uint32 *)info->src;
  9543. Uint32 *dst = (Uint32 *)info->dst;
  9544. int n = info->dst_w;
  9545. while (n--) {
  9546. pixel = *src;
  9547. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  9548. if (flags & SDL_COPY_MODULATE_COLOR) {
  9549. MULT_DIV_255(R, modulateR, R);
  9550. MULT_DIV_255(G, modulateG, G);
  9551. MULT_DIV_255(B, modulateB, B);
  9552. }
  9553. pixel = (B << 16) | (G << 8) | R;
  9554. *dst = pixel;
  9555. ++src;
  9556. ++dst;
  9557. }
  9558. info->src += info->src_pitch;
  9559. info->dst += info->dst_pitch;
  9560. }
  9561. }
  9562. static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
  9563. {
  9564. const int flags = info->flags;
  9565. const Uint32 modulateR = info->r;
  9566. const Uint32 modulateG = info->g;
  9567. const Uint32 modulateB = info->b;
  9568. Uint32 pixel;
  9569. Uint32 R, G, B;
  9570. Uint64 srcy, srcx;
  9571. Uint64 posy, posx;
  9572. Uint64 incy, incx;
  9573. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9574. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9575. posy = incy / 2;
  9576. while (info->dst_h--) {
  9577. Uint32 *src = 0;
  9578. Uint32 *dst = (Uint32 *)info->dst;
  9579. int n = info->dst_w;
  9580. posx = incx / 2;
  9581. srcy = posy >> 16;
  9582. while (n--) {
  9583. srcx = posx >> 16;
  9584. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9585. pixel = *src;
  9586. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  9587. if (flags & SDL_COPY_MODULATE_COLOR) {
  9588. MULT_DIV_255(R, modulateR, R);
  9589. MULT_DIV_255(G, modulateG, G);
  9590. MULT_DIV_255(B, modulateB, B);
  9591. }
  9592. pixel = (B << 16) | (G << 8) | R;
  9593. *dst = pixel;
  9594. posx += incx;
  9595. ++dst;
  9596. }
  9597. posy += incy;
  9598. info->dst += info->dst_pitch;
  9599. }
  9600. }
  9601. static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
  9602. {
  9603. const int flags = info->flags;
  9604. const Uint32 modulateR = info->r;
  9605. const Uint32 modulateG = info->g;
  9606. const Uint32 modulateB = info->b;
  9607. const Uint32 modulateA = info->a;
  9608. Uint32 srcpixel;
  9609. Uint32 srcR, srcG, srcB, srcA;
  9610. Uint32 dstpixel;
  9611. Uint32 dstR, dstG, dstB;
  9612. while (info->dst_h--) {
  9613. Uint32 *src = (Uint32 *)info->src;
  9614. Uint32 *dst = (Uint32 *)info->dst;
  9615. int n = info->dst_w;
  9616. while (n--) {
  9617. srcpixel = *src;
  9618. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9619. dstpixel = *dst;
  9620. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  9621. if (flags & SDL_COPY_MODULATE_COLOR) {
  9622. MULT_DIV_255(srcR, modulateR, srcR);
  9623. MULT_DIV_255(srcG, modulateG, srcG);
  9624. MULT_DIV_255(srcB, modulateB, srcB);
  9625. }
  9626. if (flags & SDL_COPY_MODULATE_ALPHA) {
  9627. MULT_DIV_255(srcA, modulateA, srcA);
  9628. }
  9629. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9630. if (srcA < 255) {
  9631. MULT_DIV_255(srcR, srcA, srcR);
  9632. MULT_DIV_255(srcG, srcA, srcG);
  9633. MULT_DIV_255(srcB, srcA, srcB);
  9634. }
  9635. }
  9636. switch (flags & SDL_COPY_BLEND_MASK) {
  9637. case SDL_COPY_BLEND:
  9638. MULT_DIV_255((255 - srcA), dstR, dstR);
  9639. dstR += srcR;
  9640. MULT_DIV_255((255 - srcA), dstG, dstG);
  9641. dstG += srcG;
  9642. MULT_DIV_255((255 - srcA), dstB, dstB);
  9643. dstB += srcB;
  9644. break;
  9645. case SDL_COPY_BLEND_PREMULTIPLIED:
  9646. MULT_DIV_255((255 - srcA), dstR, dstR);
  9647. dstR += srcR;
  9648. if (dstR > 255) dstR = 255;
  9649. MULT_DIV_255((255 - srcA), dstG, dstG);
  9650. dstG += srcG;
  9651. if (dstG > 255) dstG = 255;
  9652. MULT_DIV_255((255 - srcA), dstB, dstB);
  9653. dstB += srcB;
  9654. if (dstB > 255) dstB = 255;
  9655. break;
  9656. case SDL_COPY_ADD:
  9657. case SDL_COPY_ADD_PREMULTIPLIED:
  9658. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9659. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9660. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9661. break;
  9662. case SDL_COPY_MOD:
  9663. MULT_DIV_255(srcR, dstR, dstR);
  9664. MULT_DIV_255(srcG, dstG, dstG);
  9665. MULT_DIV_255(srcB, dstB, dstB);
  9666. break;
  9667. case SDL_COPY_MUL:
  9668. {
  9669. Uint32 tmp1, tmp2;
  9670. MULT_DIV_255(srcR, dstR, tmp1);
  9671. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9672. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9673. MULT_DIV_255(srcG, dstG, tmp1);
  9674. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9675. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9676. MULT_DIV_255(srcB, dstB, tmp1);
  9677. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9678. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9679. }
  9680. break;
  9681. }
  9682. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  9683. *dst = dstpixel;
  9684. ++src;
  9685. ++dst;
  9686. }
  9687. info->src += info->src_pitch;
  9688. info->dst += info->dst_pitch;
  9689. }
  9690. }
  9691. static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  9692. {
  9693. const int flags = info->flags;
  9694. const Uint32 modulateR = info->r;
  9695. const Uint32 modulateG = info->g;
  9696. const Uint32 modulateB = info->b;
  9697. const Uint32 modulateA = info->a;
  9698. Uint32 srcpixel;
  9699. Uint32 srcR, srcG, srcB, srcA;
  9700. Uint32 dstpixel;
  9701. Uint32 dstR, dstG, dstB;
  9702. Uint64 srcy, srcx;
  9703. Uint64 posy, posx;
  9704. Uint64 incy, incx;
  9705. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9706. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9707. posy = incy / 2;
  9708. while (info->dst_h--) {
  9709. Uint32 *src = 0;
  9710. Uint32 *dst = (Uint32 *)info->dst;
  9711. int n = info->dst_w;
  9712. posx = incx / 2;
  9713. srcy = posy >> 16;
  9714. while (n--) {
  9715. srcx = posx >> 16;
  9716. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9717. srcpixel = *src;
  9718. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9719. dstpixel = *dst;
  9720. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  9721. if (flags & SDL_COPY_MODULATE_COLOR) {
  9722. MULT_DIV_255(srcR, modulateR, srcR);
  9723. MULT_DIV_255(srcG, modulateG, srcG);
  9724. MULT_DIV_255(srcB, modulateB, srcB);
  9725. }
  9726. if (flags & SDL_COPY_MODULATE_ALPHA) {
  9727. MULT_DIV_255(srcA, modulateA, srcA);
  9728. }
  9729. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9730. if (srcA < 255) {
  9731. MULT_DIV_255(srcR, srcA, srcR);
  9732. MULT_DIV_255(srcG, srcA, srcG);
  9733. MULT_DIV_255(srcB, srcA, srcB);
  9734. }
  9735. }
  9736. switch (flags & SDL_COPY_BLEND_MASK) {
  9737. case SDL_COPY_BLEND:
  9738. MULT_DIV_255((255 - srcA), dstR, dstR);
  9739. dstR += srcR;
  9740. MULT_DIV_255((255 - srcA), dstG, dstG);
  9741. dstG += srcG;
  9742. MULT_DIV_255((255 - srcA), dstB, dstB);
  9743. dstB += srcB;
  9744. break;
  9745. case SDL_COPY_BLEND_PREMULTIPLIED:
  9746. MULT_DIV_255((255 - srcA), dstR, dstR);
  9747. dstR += srcR;
  9748. if (dstR > 255) dstR = 255;
  9749. MULT_DIV_255((255 - srcA), dstG, dstG);
  9750. dstG += srcG;
  9751. if (dstG > 255) dstG = 255;
  9752. MULT_DIV_255((255 - srcA), dstB, dstB);
  9753. dstB += srcB;
  9754. if (dstB > 255) dstB = 255;
  9755. break;
  9756. case SDL_COPY_ADD:
  9757. case SDL_COPY_ADD_PREMULTIPLIED:
  9758. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9759. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9760. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9761. break;
  9762. case SDL_COPY_MOD:
  9763. MULT_DIV_255(srcR, dstR, dstR);
  9764. MULT_DIV_255(srcG, dstG, dstG);
  9765. MULT_DIV_255(srcB, dstB, dstB);
  9766. break;
  9767. case SDL_COPY_MUL:
  9768. {
  9769. Uint32 tmp1, tmp2;
  9770. MULT_DIV_255(srcR, dstR, tmp1);
  9771. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9772. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9773. MULT_DIV_255(srcG, dstG, tmp1);
  9774. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9775. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9776. MULT_DIV_255(srcB, dstB, tmp1);
  9777. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9778. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9779. }
  9780. break;
  9781. }
  9782. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  9783. *dst = dstpixel;
  9784. posx += incx;
  9785. ++dst;
  9786. }
  9787. posy += incy;
  9788. info->dst += info->dst_pitch;
  9789. }
  9790. }
  9791. static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  9792. {
  9793. Uint32 pixel;
  9794. Uint32 R, G, B, A;
  9795. Uint64 srcy, srcx;
  9796. Uint64 posy, posx;
  9797. Uint64 incy, incx;
  9798. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9799. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9800. posy = incy / 2;
  9801. while (info->dst_h--) {
  9802. Uint32 *src = 0;
  9803. Uint32 *dst = (Uint32 *)info->dst;
  9804. int n = info->dst_w;
  9805. posx = incx / 2;
  9806. srcy = posy >> 16;
  9807. while (n--) {
  9808. srcx = posx >> 16;
  9809. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9810. pixel = *src;
  9811. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  9812. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  9813. *dst = pixel;
  9814. posx += incx;
  9815. ++dst;
  9816. }
  9817. posy += incy;
  9818. info->dst += info->dst_pitch;
  9819. }
  9820. }
  9821. static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  9822. {
  9823. const int flags = info->flags;
  9824. Uint32 srcpixel;
  9825. Uint32 srcR, srcG, srcB, srcA;
  9826. Uint32 dstpixel;
  9827. Uint32 dstR, dstG, dstB, dstA;
  9828. while (info->dst_h--) {
  9829. Uint32 *src = (Uint32 *)info->src;
  9830. Uint32 *dst = (Uint32 *)info->dst;
  9831. int n = info->dst_w;
  9832. while (n--) {
  9833. srcpixel = *src;
  9834. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9835. dstpixel = *dst;
  9836. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  9837. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9838. if (srcA < 255) {
  9839. MULT_DIV_255(srcR, srcA, srcR);
  9840. MULT_DIV_255(srcG, srcA, srcG);
  9841. MULT_DIV_255(srcB, srcA, srcB);
  9842. }
  9843. }
  9844. switch (flags & SDL_COPY_BLEND_MASK) {
  9845. case SDL_COPY_BLEND:
  9846. MULT_DIV_255((255 - srcA), dstR, dstR);
  9847. dstR += srcR;
  9848. MULT_DIV_255((255 - srcA), dstG, dstG);
  9849. dstG += srcG;
  9850. MULT_DIV_255((255 - srcA), dstB, dstB);
  9851. dstB += srcB;
  9852. MULT_DIV_255((255 - srcA), dstA, dstA);
  9853. dstA += srcA;
  9854. break;
  9855. case SDL_COPY_BLEND_PREMULTIPLIED:
  9856. MULT_DIV_255((255 - srcA), dstR, dstR);
  9857. dstR += srcR;
  9858. if (dstR > 255) dstR = 255;
  9859. MULT_DIV_255((255 - srcA), dstG, dstG);
  9860. dstG += srcG;
  9861. if (dstG > 255) dstG = 255;
  9862. MULT_DIV_255((255 - srcA), dstB, dstB);
  9863. dstB += srcB;
  9864. if (dstB > 255) dstB = 255;
  9865. MULT_DIV_255((255 - srcA), dstA, dstA);
  9866. dstA += srcA;
  9867. if (dstA > 255) dstA = 255;
  9868. break;
  9869. case SDL_COPY_ADD:
  9870. case SDL_COPY_ADD_PREMULTIPLIED:
  9871. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9872. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9873. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9874. break;
  9875. case SDL_COPY_MOD:
  9876. MULT_DIV_255(srcR, dstR, dstR);
  9877. MULT_DIV_255(srcG, dstG, dstG);
  9878. MULT_DIV_255(srcB, dstB, dstB);
  9879. break;
  9880. case SDL_COPY_MUL:
  9881. {
  9882. Uint32 tmp1, tmp2;
  9883. MULT_DIV_255(srcR, dstR, tmp1);
  9884. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9885. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9886. MULT_DIV_255(srcG, dstG, tmp1);
  9887. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9888. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9889. MULT_DIV_255(srcB, dstB, tmp1);
  9890. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9891. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9892. }
  9893. break;
  9894. }
  9895. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  9896. *dst = dstpixel;
  9897. ++src;
  9898. ++dst;
  9899. }
  9900. info->src += info->src_pitch;
  9901. info->dst += info->dst_pitch;
  9902. }
  9903. }
  9904. static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  9905. {
  9906. const int flags = info->flags;
  9907. Uint32 srcpixel;
  9908. Uint32 srcR, srcG, srcB, srcA;
  9909. Uint32 dstpixel;
  9910. Uint32 dstR, dstG, dstB, dstA;
  9911. Uint64 srcy, srcx;
  9912. Uint64 posy, posx;
  9913. Uint64 incy, incx;
  9914. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  9915. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  9916. posy = incy / 2;
  9917. while (info->dst_h--) {
  9918. Uint32 *src = 0;
  9919. Uint32 *dst = (Uint32 *)info->dst;
  9920. int n = info->dst_w;
  9921. posx = incx / 2;
  9922. srcy = posy >> 16;
  9923. while (n--) {
  9924. srcx = posx >> 16;
  9925. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  9926. srcpixel = *src;
  9927. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  9928. dstpixel = *dst;
  9929. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  9930. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  9931. if (srcA < 255) {
  9932. MULT_DIV_255(srcR, srcA, srcR);
  9933. MULT_DIV_255(srcG, srcA, srcG);
  9934. MULT_DIV_255(srcB, srcA, srcB);
  9935. }
  9936. }
  9937. switch (flags & SDL_COPY_BLEND_MASK) {
  9938. case SDL_COPY_BLEND:
  9939. MULT_DIV_255((255 - srcA), dstR, dstR);
  9940. dstR += srcR;
  9941. MULT_DIV_255((255 - srcA), dstG, dstG);
  9942. dstG += srcG;
  9943. MULT_DIV_255((255 - srcA), dstB, dstB);
  9944. dstB += srcB;
  9945. MULT_DIV_255((255 - srcA), dstA, dstA);
  9946. dstA += srcA;
  9947. break;
  9948. case SDL_COPY_BLEND_PREMULTIPLIED:
  9949. MULT_DIV_255((255 - srcA), dstR, dstR);
  9950. dstR += srcR;
  9951. if (dstR > 255) dstR = 255;
  9952. MULT_DIV_255((255 - srcA), dstG, dstG);
  9953. dstG += srcG;
  9954. if (dstG > 255) dstG = 255;
  9955. MULT_DIV_255((255 - srcA), dstB, dstB);
  9956. dstB += srcB;
  9957. if (dstB > 255) dstB = 255;
  9958. MULT_DIV_255((255 - srcA), dstA, dstA);
  9959. dstA += srcA;
  9960. if (dstA > 255) dstA = 255;
  9961. break;
  9962. case SDL_COPY_ADD:
  9963. case SDL_COPY_ADD_PREMULTIPLIED:
  9964. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  9965. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  9966. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  9967. break;
  9968. case SDL_COPY_MOD:
  9969. MULT_DIV_255(srcR, dstR, dstR);
  9970. MULT_DIV_255(srcG, dstG, dstG);
  9971. MULT_DIV_255(srcB, dstB, dstB);
  9972. break;
  9973. case SDL_COPY_MUL:
  9974. {
  9975. Uint32 tmp1, tmp2;
  9976. MULT_DIV_255(srcR, dstR, tmp1);
  9977. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  9978. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  9979. MULT_DIV_255(srcG, dstG, tmp1);
  9980. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  9981. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  9982. MULT_DIV_255(srcB, dstB, tmp1);
  9983. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  9984. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  9985. }
  9986. break;
  9987. }
  9988. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  9989. *dst = dstpixel;
  9990. posx += incx;
  9991. ++dst;
  9992. }
  9993. posy += incy;
  9994. info->dst += info->dst_pitch;
  9995. }
  9996. }
  9997. static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  9998. {
  9999. const int flags = info->flags;
  10000. const Uint32 modulateR = info->r;
  10001. const Uint32 modulateG = info->g;
  10002. const Uint32 modulateB = info->b;
  10003. const Uint32 modulateA = info->a;
  10004. Uint32 pixel;
  10005. Uint32 R, G, B, A;
  10006. while (info->dst_h--) {
  10007. Uint32 *src = (Uint32 *)info->src;
  10008. Uint32 *dst = (Uint32 *)info->dst;
  10009. int n = info->dst_w;
  10010. while (n--) {
  10011. pixel = *src;
  10012. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  10013. if (flags & SDL_COPY_MODULATE_COLOR) {
  10014. MULT_DIV_255(R, modulateR, R);
  10015. MULT_DIV_255(G, modulateG, G);
  10016. MULT_DIV_255(B, modulateB, B);
  10017. }
  10018. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10019. MULT_DIV_255(A, modulateA, A);
  10020. }
  10021. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  10022. *dst = pixel;
  10023. ++src;
  10024. ++dst;
  10025. }
  10026. info->src += info->src_pitch;
  10027. info->dst += info->dst_pitch;
  10028. }
  10029. }
  10030. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  10031. {
  10032. const int flags = info->flags;
  10033. const Uint32 modulateR = info->r;
  10034. const Uint32 modulateG = info->g;
  10035. const Uint32 modulateB = info->b;
  10036. const Uint32 modulateA = info->a;
  10037. Uint32 pixel;
  10038. Uint32 R, G, B, A;
  10039. Uint64 srcy, srcx;
  10040. Uint64 posy, posx;
  10041. Uint64 incy, incx;
  10042. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10043. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10044. posy = incy / 2;
  10045. while (info->dst_h--) {
  10046. Uint32 *src = 0;
  10047. Uint32 *dst = (Uint32 *)info->dst;
  10048. int n = info->dst_w;
  10049. posx = incx / 2;
  10050. srcy = posy >> 16;
  10051. while (n--) {
  10052. srcx = posx >> 16;
  10053. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10054. pixel = *src;
  10055. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  10056. if (flags & SDL_COPY_MODULATE_COLOR) {
  10057. MULT_DIV_255(R, modulateR, R);
  10058. MULT_DIV_255(G, modulateG, G);
  10059. MULT_DIV_255(B, modulateB, B);
  10060. }
  10061. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10062. MULT_DIV_255(A, modulateA, A);
  10063. }
  10064. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  10065. *dst = pixel;
  10066. posx += incx;
  10067. ++dst;
  10068. }
  10069. posy += incy;
  10070. info->dst += info->dst_pitch;
  10071. }
  10072. }
  10073. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  10074. {
  10075. const int flags = info->flags;
  10076. const Uint32 modulateR = info->r;
  10077. const Uint32 modulateG = info->g;
  10078. const Uint32 modulateB = info->b;
  10079. const Uint32 modulateA = info->a;
  10080. Uint32 srcpixel;
  10081. Uint32 srcR, srcG, srcB, srcA;
  10082. Uint32 dstpixel;
  10083. Uint32 dstR, dstG, dstB, dstA;
  10084. while (info->dst_h--) {
  10085. Uint32 *src = (Uint32 *)info->src;
  10086. Uint32 *dst = (Uint32 *)info->dst;
  10087. int n = info->dst_w;
  10088. while (n--) {
  10089. srcpixel = *src;
  10090. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10091. dstpixel = *dst;
  10092. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10093. if (flags & SDL_COPY_MODULATE_COLOR) {
  10094. MULT_DIV_255(srcR, modulateR, srcR);
  10095. MULT_DIV_255(srcG, modulateG, srcG);
  10096. MULT_DIV_255(srcB, modulateB, srcB);
  10097. }
  10098. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10099. MULT_DIV_255(srcA, modulateA, srcA);
  10100. }
  10101. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10102. if (srcA < 255) {
  10103. MULT_DIV_255(srcR, srcA, srcR);
  10104. MULT_DIV_255(srcG, srcA, srcG);
  10105. MULT_DIV_255(srcB, srcA, srcB);
  10106. }
  10107. }
  10108. switch (flags & SDL_COPY_BLEND_MASK) {
  10109. case SDL_COPY_BLEND:
  10110. MULT_DIV_255((255 - srcA), dstR, dstR);
  10111. dstR += srcR;
  10112. MULT_DIV_255((255 - srcA), dstG, dstG);
  10113. dstG += srcG;
  10114. MULT_DIV_255((255 - srcA), dstB, dstB);
  10115. dstB += srcB;
  10116. MULT_DIV_255((255 - srcA), dstA, dstA);
  10117. dstA += srcA;
  10118. break;
  10119. case SDL_COPY_BLEND_PREMULTIPLIED:
  10120. MULT_DIV_255((255 - srcA), dstR, dstR);
  10121. dstR += srcR;
  10122. if (dstR > 255) dstR = 255;
  10123. MULT_DIV_255((255 - srcA), dstG, dstG);
  10124. dstG += srcG;
  10125. if (dstG > 255) dstG = 255;
  10126. MULT_DIV_255((255 - srcA), dstB, dstB);
  10127. dstB += srcB;
  10128. if (dstB > 255) dstB = 255;
  10129. MULT_DIV_255((255 - srcA), dstA, dstA);
  10130. dstA += srcA;
  10131. if (dstA > 255) dstA = 255;
  10132. break;
  10133. case SDL_COPY_ADD:
  10134. case SDL_COPY_ADD_PREMULTIPLIED:
  10135. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10136. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10137. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10138. break;
  10139. case SDL_COPY_MOD:
  10140. MULT_DIV_255(srcR, dstR, dstR);
  10141. MULT_DIV_255(srcG, dstG, dstG);
  10142. MULT_DIV_255(srcB, dstB, dstB);
  10143. break;
  10144. case SDL_COPY_MUL:
  10145. {
  10146. Uint32 tmp1, tmp2;
  10147. MULT_DIV_255(srcR, dstR, tmp1);
  10148. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10149. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10150. MULT_DIV_255(srcG, dstG, tmp1);
  10151. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10152. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10153. MULT_DIV_255(srcB, dstB, tmp1);
  10154. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10155. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10156. }
  10157. break;
  10158. }
  10159. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  10160. *dst = dstpixel;
  10161. ++src;
  10162. ++dst;
  10163. }
  10164. info->src += info->src_pitch;
  10165. info->dst += info->dst_pitch;
  10166. }
  10167. }
  10168. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  10169. {
  10170. const int flags = info->flags;
  10171. const Uint32 modulateR = info->r;
  10172. const Uint32 modulateG = info->g;
  10173. const Uint32 modulateB = info->b;
  10174. const Uint32 modulateA = info->a;
  10175. Uint32 srcpixel;
  10176. Uint32 srcR, srcG, srcB, srcA;
  10177. Uint32 dstpixel;
  10178. Uint32 dstR, dstG, dstB, dstA;
  10179. Uint64 srcy, srcx;
  10180. Uint64 posy, posx;
  10181. Uint64 incy, incx;
  10182. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10183. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10184. posy = incy / 2;
  10185. while (info->dst_h--) {
  10186. Uint32 *src = 0;
  10187. Uint32 *dst = (Uint32 *)info->dst;
  10188. int n = info->dst_w;
  10189. posx = incx / 2;
  10190. srcy = posy >> 16;
  10191. while (n--) {
  10192. srcx = posx >> 16;
  10193. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10194. srcpixel = *src;
  10195. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10196. dstpixel = *dst;
  10197. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10198. if (flags & SDL_COPY_MODULATE_COLOR) {
  10199. MULT_DIV_255(srcR, modulateR, srcR);
  10200. MULT_DIV_255(srcG, modulateG, srcG);
  10201. MULT_DIV_255(srcB, modulateB, srcB);
  10202. }
  10203. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10204. MULT_DIV_255(srcA, modulateA, srcA);
  10205. }
  10206. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10207. if (srcA < 255) {
  10208. MULT_DIV_255(srcR, srcA, srcR);
  10209. MULT_DIV_255(srcG, srcA, srcG);
  10210. MULT_DIV_255(srcB, srcA, srcB);
  10211. }
  10212. }
  10213. switch (flags & SDL_COPY_BLEND_MASK) {
  10214. case SDL_COPY_BLEND:
  10215. MULT_DIV_255((255 - srcA), dstR, dstR);
  10216. dstR += srcR;
  10217. MULT_DIV_255((255 - srcA), dstG, dstG);
  10218. dstG += srcG;
  10219. MULT_DIV_255((255 - srcA), dstB, dstB);
  10220. dstB += srcB;
  10221. MULT_DIV_255((255 - srcA), dstA, dstA);
  10222. dstA += srcA;
  10223. break;
  10224. case SDL_COPY_BLEND_PREMULTIPLIED:
  10225. MULT_DIV_255((255 - srcA), dstR, dstR);
  10226. dstR += srcR;
  10227. if (dstR > 255) dstR = 255;
  10228. MULT_DIV_255((255 - srcA), dstG, dstG);
  10229. dstG += srcG;
  10230. if (dstG > 255) dstG = 255;
  10231. MULT_DIV_255((255 - srcA), dstB, dstB);
  10232. dstB += srcB;
  10233. if (dstB > 255) dstB = 255;
  10234. MULT_DIV_255((255 - srcA), dstA, dstA);
  10235. dstA += srcA;
  10236. if (dstA > 255) dstA = 255;
  10237. break;
  10238. case SDL_COPY_ADD:
  10239. case SDL_COPY_ADD_PREMULTIPLIED:
  10240. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10241. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10242. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10243. break;
  10244. case SDL_COPY_MOD:
  10245. MULT_DIV_255(srcR, dstR, dstR);
  10246. MULT_DIV_255(srcG, dstG, dstG);
  10247. MULT_DIV_255(srcB, dstB, dstB);
  10248. break;
  10249. case SDL_COPY_MUL:
  10250. {
  10251. Uint32 tmp1, tmp2;
  10252. MULT_DIV_255(srcR, dstR, tmp1);
  10253. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10254. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10255. MULT_DIV_255(srcG, dstG, tmp1);
  10256. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10257. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10258. MULT_DIV_255(srcB, dstB, tmp1);
  10259. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10260. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10261. }
  10262. break;
  10263. }
  10264. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  10265. *dst = dstpixel;
  10266. posx += incx;
  10267. ++dst;
  10268. }
  10269. posy += incy;
  10270. info->dst += info->dst_pitch;
  10271. }
  10272. }
  10273. static void SDL_Blit_BGRA8888_ABGR8888_Scale(SDL_BlitInfo *info)
  10274. {
  10275. Uint32 pixel;
  10276. Uint64 srcy, srcx;
  10277. Uint64 posy, posx;
  10278. Uint64 incy, incx;
  10279. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10280. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10281. posy = incy / 2;
  10282. while (info->dst_h--) {
  10283. Uint32 *src = 0;
  10284. Uint32 *dst = (Uint32 *)info->dst;
  10285. int n = info->dst_w;
  10286. posx = incx / 2;
  10287. srcy = posy >> 16;
  10288. while (n--) {
  10289. srcx = posx >> 16;
  10290. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10291. pixel = *src;
  10292. pixel = (pixel >> 8) | (pixel << 24);
  10293. *dst = pixel;
  10294. posx += incx;
  10295. ++dst;
  10296. }
  10297. posy += incy;
  10298. info->dst += info->dst_pitch;
  10299. }
  10300. }
  10301. static void SDL_Blit_BGRA8888_ABGR8888_Blend(SDL_BlitInfo *info)
  10302. {
  10303. const int flags = info->flags;
  10304. Uint32 srcpixel;
  10305. Uint32 srcR, srcG, srcB, srcA;
  10306. Uint32 dstpixel;
  10307. Uint32 dstR, dstG, dstB, dstA;
  10308. while (info->dst_h--) {
  10309. Uint32 *src = (Uint32 *)info->src;
  10310. Uint32 *dst = (Uint32 *)info->dst;
  10311. int n = info->dst_w;
  10312. while (n--) {
  10313. srcpixel = *src;
  10314. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10315. dstpixel = *dst;
  10316. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10317. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10318. if (srcA < 255) {
  10319. MULT_DIV_255(srcR, srcA, srcR);
  10320. MULT_DIV_255(srcG, srcA, srcG);
  10321. MULT_DIV_255(srcB, srcA, srcB);
  10322. }
  10323. }
  10324. switch (flags & SDL_COPY_BLEND_MASK) {
  10325. case SDL_COPY_BLEND:
  10326. MULT_DIV_255((255 - srcA), dstR, dstR);
  10327. dstR += srcR;
  10328. MULT_DIV_255((255 - srcA), dstG, dstG);
  10329. dstG += srcG;
  10330. MULT_DIV_255((255 - srcA), dstB, dstB);
  10331. dstB += srcB;
  10332. MULT_DIV_255((255 - srcA), dstA, dstA);
  10333. dstA += srcA;
  10334. break;
  10335. case SDL_COPY_BLEND_PREMULTIPLIED:
  10336. MULT_DIV_255((255 - srcA), dstR, dstR);
  10337. dstR += srcR;
  10338. if (dstR > 255) dstR = 255;
  10339. MULT_DIV_255((255 - srcA), dstG, dstG);
  10340. dstG += srcG;
  10341. if (dstG > 255) dstG = 255;
  10342. MULT_DIV_255((255 - srcA), dstB, dstB);
  10343. dstB += srcB;
  10344. if (dstB > 255) dstB = 255;
  10345. MULT_DIV_255((255 - srcA), dstA, dstA);
  10346. dstA += srcA;
  10347. if (dstA > 255) dstA = 255;
  10348. break;
  10349. case SDL_COPY_ADD:
  10350. case SDL_COPY_ADD_PREMULTIPLIED:
  10351. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10352. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10353. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10354. break;
  10355. case SDL_COPY_MOD:
  10356. MULT_DIV_255(srcR, dstR, dstR);
  10357. MULT_DIV_255(srcG, dstG, dstG);
  10358. MULT_DIV_255(srcB, dstB, dstB);
  10359. break;
  10360. case SDL_COPY_MUL:
  10361. {
  10362. Uint32 tmp1, tmp2;
  10363. MULT_DIV_255(srcR, dstR, tmp1);
  10364. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10365. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10366. MULT_DIV_255(srcG, dstG, tmp1);
  10367. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10368. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10369. MULT_DIV_255(srcB, dstB, tmp1);
  10370. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10371. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10372. }
  10373. break;
  10374. }
  10375. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  10376. *dst = dstpixel;
  10377. ++src;
  10378. ++dst;
  10379. }
  10380. info->src += info->src_pitch;
  10381. info->dst += info->dst_pitch;
  10382. }
  10383. }
  10384. static void SDL_Blit_BGRA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
  10385. {
  10386. const int flags = info->flags;
  10387. Uint32 srcpixel;
  10388. Uint32 srcR, srcG, srcB, srcA;
  10389. Uint32 dstpixel;
  10390. Uint32 dstR, dstG, dstB, dstA;
  10391. Uint64 srcy, srcx;
  10392. Uint64 posy, posx;
  10393. Uint64 incy, incx;
  10394. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10395. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10396. posy = incy / 2;
  10397. while (info->dst_h--) {
  10398. Uint32 *src = 0;
  10399. Uint32 *dst = (Uint32 *)info->dst;
  10400. int n = info->dst_w;
  10401. posx = incx / 2;
  10402. srcy = posy >> 16;
  10403. while (n--) {
  10404. srcx = posx >> 16;
  10405. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10406. srcpixel = *src;
  10407. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10408. dstpixel = *dst;
  10409. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10410. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10411. if (srcA < 255) {
  10412. MULT_DIV_255(srcR, srcA, srcR);
  10413. MULT_DIV_255(srcG, srcA, srcG);
  10414. MULT_DIV_255(srcB, srcA, srcB);
  10415. }
  10416. }
  10417. switch (flags & SDL_COPY_BLEND_MASK) {
  10418. case SDL_COPY_BLEND:
  10419. MULT_DIV_255((255 - srcA), dstR, dstR);
  10420. dstR += srcR;
  10421. MULT_DIV_255((255 - srcA), dstG, dstG);
  10422. dstG += srcG;
  10423. MULT_DIV_255((255 - srcA), dstB, dstB);
  10424. dstB += srcB;
  10425. MULT_DIV_255((255 - srcA), dstA, dstA);
  10426. dstA += srcA;
  10427. break;
  10428. case SDL_COPY_BLEND_PREMULTIPLIED:
  10429. MULT_DIV_255((255 - srcA), dstR, dstR);
  10430. dstR += srcR;
  10431. if (dstR > 255) dstR = 255;
  10432. MULT_DIV_255((255 - srcA), dstG, dstG);
  10433. dstG += srcG;
  10434. if (dstG > 255) dstG = 255;
  10435. MULT_DIV_255((255 - srcA), dstB, dstB);
  10436. dstB += srcB;
  10437. if (dstB > 255) dstB = 255;
  10438. MULT_DIV_255((255 - srcA), dstA, dstA);
  10439. dstA += srcA;
  10440. if (dstA > 255) dstA = 255;
  10441. break;
  10442. case SDL_COPY_ADD:
  10443. case SDL_COPY_ADD_PREMULTIPLIED:
  10444. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10445. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10446. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10447. break;
  10448. case SDL_COPY_MOD:
  10449. MULT_DIV_255(srcR, dstR, dstR);
  10450. MULT_DIV_255(srcG, dstG, dstG);
  10451. MULT_DIV_255(srcB, dstB, dstB);
  10452. break;
  10453. case SDL_COPY_MUL:
  10454. {
  10455. Uint32 tmp1, tmp2;
  10456. MULT_DIV_255(srcR, dstR, tmp1);
  10457. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10458. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10459. MULT_DIV_255(srcG, dstG, tmp1);
  10460. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10461. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10462. MULT_DIV_255(srcB, dstB, tmp1);
  10463. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10464. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10465. }
  10466. break;
  10467. }
  10468. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  10469. *dst = dstpixel;
  10470. posx += incx;
  10471. ++dst;
  10472. }
  10473. posy += incy;
  10474. info->dst += info->dst_pitch;
  10475. }
  10476. }
  10477. static void SDL_Blit_BGRA8888_ABGR8888_Modulate(SDL_BlitInfo *info)
  10478. {
  10479. const int flags = info->flags;
  10480. const Uint32 modulateR = info->r;
  10481. const Uint32 modulateG = info->g;
  10482. const Uint32 modulateB = info->b;
  10483. const Uint32 modulateA = info->a;
  10484. Uint32 pixel;
  10485. Uint32 R, G, B, A;
  10486. while (info->dst_h--) {
  10487. Uint32 *src = (Uint32 *)info->src;
  10488. Uint32 *dst = (Uint32 *)info->dst;
  10489. int n = info->dst_w;
  10490. while (n--) {
  10491. pixel = *src;
  10492. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  10493. if (flags & SDL_COPY_MODULATE_COLOR) {
  10494. MULT_DIV_255(R, modulateR, R);
  10495. MULT_DIV_255(G, modulateG, G);
  10496. MULT_DIV_255(B, modulateB, B);
  10497. }
  10498. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10499. MULT_DIV_255(A, modulateA, A);
  10500. }
  10501. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  10502. *dst = pixel;
  10503. ++src;
  10504. ++dst;
  10505. }
  10506. info->src += info->src_pitch;
  10507. info->dst += info->dst_pitch;
  10508. }
  10509. }
  10510. static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
  10511. {
  10512. const int flags = info->flags;
  10513. const Uint32 modulateR = info->r;
  10514. const Uint32 modulateG = info->g;
  10515. const Uint32 modulateB = info->b;
  10516. const Uint32 modulateA = info->a;
  10517. Uint32 pixel;
  10518. Uint32 R, G, B, A;
  10519. Uint64 srcy, srcx;
  10520. Uint64 posy, posx;
  10521. Uint64 incy, incx;
  10522. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10523. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10524. posy = incy / 2;
  10525. while (info->dst_h--) {
  10526. Uint32 *src = 0;
  10527. Uint32 *dst = (Uint32 *)info->dst;
  10528. int n = info->dst_w;
  10529. posx = incx / 2;
  10530. srcy = posy >> 16;
  10531. while (n--) {
  10532. srcx = posx >> 16;
  10533. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10534. pixel = *src;
  10535. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  10536. if (flags & SDL_COPY_MODULATE_COLOR) {
  10537. MULT_DIV_255(R, modulateR, R);
  10538. MULT_DIV_255(G, modulateG, G);
  10539. MULT_DIV_255(B, modulateB, B);
  10540. }
  10541. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10542. MULT_DIV_255(A, modulateA, A);
  10543. }
  10544. pixel = (A << 24) | (B << 16) | (G << 8) | R;
  10545. *dst = pixel;
  10546. posx += incx;
  10547. ++dst;
  10548. }
  10549. posy += incy;
  10550. info->dst += info->dst_pitch;
  10551. }
  10552. }
  10553. static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
  10554. {
  10555. const int flags = info->flags;
  10556. const Uint32 modulateR = info->r;
  10557. const Uint32 modulateG = info->g;
  10558. const Uint32 modulateB = info->b;
  10559. const Uint32 modulateA = info->a;
  10560. Uint32 srcpixel;
  10561. Uint32 srcR, srcG, srcB, srcA;
  10562. Uint32 dstpixel;
  10563. Uint32 dstR, dstG, dstB, dstA;
  10564. while (info->dst_h--) {
  10565. Uint32 *src = (Uint32 *)info->src;
  10566. Uint32 *dst = (Uint32 *)info->dst;
  10567. int n = info->dst_w;
  10568. while (n--) {
  10569. srcpixel = *src;
  10570. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10571. dstpixel = *dst;
  10572. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10573. if (flags & SDL_COPY_MODULATE_COLOR) {
  10574. MULT_DIV_255(srcR, modulateR, srcR);
  10575. MULT_DIV_255(srcG, modulateG, srcG);
  10576. MULT_DIV_255(srcB, modulateB, srcB);
  10577. }
  10578. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10579. MULT_DIV_255(srcA, modulateA, srcA);
  10580. }
  10581. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10582. if (srcA < 255) {
  10583. MULT_DIV_255(srcR, srcA, srcR);
  10584. MULT_DIV_255(srcG, srcA, srcG);
  10585. MULT_DIV_255(srcB, srcA, srcB);
  10586. }
  10587. }
  10588. switch (flags & SDL_COPY_BLEND_MASK) {
  10589. case SDL_COPY_BLEND:
  10590. MULT_DIV_255((255 - srcA), dstR, dstR);
  10591. dstR += srcR;
  10592. MULT_DIV_255((255 - srcA), dstG, dstG);
  10593. dstG += srcG;
  10594. MULT_DIV_255((255 - srcA), dstB, dstB);
  10595. dstB += srcB;
  10596. MULT_DIV_255((255 - srcA), dstA, dstA);
  10597. dstA += srcA;
  10598. break;
  10599. case SDL_COPY_BLEND_PREMULTIPLIED:
  10600. MULT_DIV_255((255 - srcA), dstR, dstR);
  10601. dstR += srcR;
  10602. if (dstR > 255) dstR = 255;
  10603. MULT_DIV_255((255 - srcA), dstG, dstG);
  10604. dstG += srcG;
  10605. if (dstG > 255) dstG = 255;
  10606. MULT_DIV_255((255 - srcA), dstB, dstB);
  10607. dstB += srcB;
  10608. if (dstB > 255) dstB = 255;
  10609. MULT_DIV_255((255 - srcA), dstA, dstA);
  10610. dstA += srcA;
  10611. if (dstA > 255) dstA = 255;
  10612. break;
  10613. case SDL_COPY_ADD:
  10614. case SDL_COPY_ADD_PREMULTIPLIED:
  10615. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10616. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10617. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10618. break;
  10619. case SDL_COPY_MOD:
  10620. MULT_DIV_255(srcR, dstR, dstR);
  10621. MULT_DIV_255(srcG, dstG, dstG);
  10622. MULT_DIV_255(srcB, dstB, dstB);
  10623. break;
  10624. case SDL_COPY_MUL:
  10625. {
  10626. Uint32 tmp1, tmp2;
  10627. MULT_DIV_255(srcR, dstR, tmp1);
  10628. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10629. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10630. MULT_DIV_255(srcG, dstG, tmp1);
  10631. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10632. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10633. MULT_DIV_255(srcB, dstB, tmp1);
  10634. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10635. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10636. }
  10637. break;
  10638. }
  10639. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  10640. *dst = dstpixel;
  10641. ++src;
  10642. ++dst;
  10643. }
  10644. info->src += info->src_pitch;
  10645. info->dst += info->dst_pitch;
  10646. }
  10647. }
  10648. static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  10649. {
  10650. const int flags = info->flags;
  10651. const Uint32 modulateR = info->r;
  10652. const Uint32 modulateG = info->g;
  10653. const Uint32 modulateB = info->b;
  10654. const Uint32 modulateA = info->a;
  10655. Uint32 srcpixel;
  10656. Uint32 srcR, srcG, srcB, srcA;
  10657. Uint32 dstpixel;
  10658. Uint32 dstR, dstG, dstB, dstA;
  10659. Uint64 srcy, srcx;
  10660. Uint64 posy, posx;
  10661. Uint64 incy, incx;
  10662. incy = ((Uint64)info->src_h << 16) / info->dst_h;
  10663. incx = ((Uint64)info->src_w << 16) / info->dst_w;
  10664. posy = incy / 2;
  10665. while (info->dst_h--) {
  10666. Uint32 *src = 0;
  10667. Uint32 *dst = (Uint32 *)info->dst;
  10668. int n = info->dst_w;
  10669. posx = incx / 2;
  10670. srcy = posy >> 16;
  10671. while (n--) {
  10672. srcx = posx >> 16;
  10673. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  10674. srcpixel = *src;
  10675. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  10676. dstpixel = *dst;
  10677. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  10678. if (flags & SDL_COPY_MODULATE_COLOR) {
  10679. MULT_DIV_255(srcR, modulateR, srcR);
  10680. MULT_DIV_255(srcG, modulateG, srcG);
  10681. MULT_DIV_255(srcB, modulateB, srcB);
  10682. }
  10683. if (flags & SDL_COPY_MODULATE_ALPHA) {
  10684. MULT_DIV_255(srcA, modulateA, srcA);
  10685. }
  10686. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  10687. if (srcA < 255) {
  10688. MULT_DIV_255(srcR, srcA, srcR);
  10689. MULT_DIV_255(srcG, srcA, srcG);
  10690. MULT_DIV_255(srcB, srcA, srcB);
  10691. }
  10692. }
  10693. switch (flags & SDL_COPY_BLEND_MASK) {
  10694. case SDL_COPY_BLEND:
  10695. MULT_DIV_255((255 - srcA), dstR, dstR);
  10696. dstR += srcR;
  10697. MULT_DIV_255((255 - srcA), dstG, dstG);
  10698. dstG += srcG;
  10699. MULT_DIV_255((255 - srcA), dstB, dstB);
  10700. dstB += srcB;
  10701. MULT_DIV_255((255 - srcA), dstA, dstA);
  10702. dstA += srcA;
  10703. break;
  10704. case SDL_COPY_BLEND_PREMULTIPLIED:
  10705. MULT_DIV_255((255 - srcA), dstR, dstR);
  10706. dstR += srcR;
  10707. if (dstR > 255) dstR = 255;
  10708. MULT_DIV_255((255 - srcA), dstG, dstG);
  10709. dstG += srcG;
  10710. if (dstG > 255) dstG = 255;
  10711. MULT_DIV_255((255 - srcA), dstB, dstB);
  10712. dstB += srcB;
  10713. if (dstB > 255) dstB = 255;
  10714. MULT_DIV_255((255 - srcA), dstA, dstA);
  10715. dstA += srcA;
  10716. if (dstA > 255) dstA = 255;
  10717. break;
  10718. case SDL_COPY_ADD:
  10719. case SDL_COPY_ADD_PREMULTIPLIED:
  10720. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  10721. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  10722. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  10723. break;
  10724. case SDL_COPY_MOD:
  10725. MULT_DIV_255(srcR, dstR, dstR);
  10726. MULT_DIV_255(srcG, dstG, dstG);
  10727. MULT_DIV_255(srcB, dstB, dstB);
  10728. break;
  10729. case SDL_COPY_MUL:
  10730. {
  10731. Uint32 tmp1, tmp2;
  10732. MULT_DIV_255(srcR, dstR, tmp1);
  10733. MULT_DIV_255(dstR, (255 - srcA), tmp2);
  10734. dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
  10735. MULT_DIV_255(srcG, dstG, tmp1);
  10736. MULT_DIV_255(dstG, (255 - srcA), tmp2);
  10737. dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
  10738. MULT_DIV_255(srcB, dstB, tmp1);
  10739. MULT_DIV_255(dstB, (255 - srcA), tmp2);
  10740. dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
  10741. }
  10742. break;
  10743. }
  10744. dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
  10745. *dst = dstpixel;
  10746. posx += incx;
  10747. ++dst;
  10748. }
  10749. posy += incy;
  10750. info->dst += info->dst_pitch;
  10751. }
  10752. }
  10753. SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
  10754. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Scale },
  10755. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend },
  10756. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend_Scale },
  10757. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate },
  10758. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale },
  10759. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend },
  10760. { 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 },
  10761. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Scale },
  10762. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend },
  10763. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend_Scale },
  10764. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate },
  10765. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale },
  10766. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend },
  10767. { 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 },
  10768. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Scale },
  10769. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend },
  10770. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend_Scale },
  10771. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate },
  10772. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale },
  10773. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend },
  10774. { 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 },
  10775. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Scale },
  10776. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend },
  10777. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend_Scale },
  10778. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate },
  10779. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale },
  10780. { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend },
  10781. { 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 },
  10782. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Scale },
  10783. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend },
  10784. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend_Scale },
  10785. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate },
  10786. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale },
  10787. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend },
  10788. { 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 },
  10789. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Scale },
  10790. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend },
  10791. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend_Scale },
  10792. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate },
  10793. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale },
  10794. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend },
  10795. { 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 },
  10796. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Scale },
  10797. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend },
  10798. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend_Scale },
  10799. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate },
  10800. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale },
  10801. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend },
  10802. { 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 },
  10803. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Scale },
  10804. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend },
  10805. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend_Scale },
  10806. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate },
  10807. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale },
  10808. { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend },
  10809. { 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 },
  10810. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Scale },
  10811. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend },
  10812. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend_Scale },
  10813. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate },
  10814. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale },
  10815. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend },
  10816. { 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 },
  10817. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Scale },
  10818. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend },
  10819. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend_Scale },
  10820. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate },
  10821. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale },
  10822. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend },
  10823. { 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 },
  10824. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale },
  10825. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
  10826. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
  10827. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate },
  10828. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale },
  10829. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
  10830. { 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 },
  10831. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Scale },
  10832. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend },
  10833. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend_Scale },
  10834. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate },
  10835. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale },
  10836. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend },
  10837. { 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 },
  10838. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Scale },
  10839. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend },
  10840. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend_Scale },
  10841. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate },
  10842. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale },
  10843. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend },
  10844. { 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 },
  10845. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Scale },
  10846. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend },
  10847. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend_Scale },
  10848. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate },
  10849. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale },
  10850. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend },
  10851. { 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 },
  10852. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale },
  10853. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
  10854. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
  10855. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate },
  10856. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale },
  10857. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
  10858. { 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 },
  10859. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Scale },
  10860. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend },
  10861. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend_Scale },
  10862. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate },
  10863. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale },
  10864. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend },
  10865. { 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 },
  10866. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Scale },
  10867. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend },
  10868. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend_Scale },
  10869. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate },
  10870. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale },
  10871. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend },
  10872. { 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 },
  10873. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Scale },
  10874. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend },
  10875. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend_Scale },
  10876. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate },
  10877. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale },
  10878. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend },
  10879. { 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 },
  10880. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale },
  10881. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
  10882. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
  10883. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate },
  10884. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale },
  10885. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
  10886. { 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 },
  10887. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Scale },
  10888. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend },
  10889. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend_Scale },
  10890. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate },
  10891. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale },
  10892. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend },
  10893. { 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 },
  10894. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Scale },
  10895. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend },
  10896. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend_Scale },
  10897. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate },
  10898. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale },
  10899. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend },
  10900. { 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 },
  10901. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Scale },
  10902. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend },
  10903. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend_Scale },
  10904. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate },
  10905. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale },
  10906. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend },
  10907. { 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 },
  10908. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale },
  10909. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
  10910. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
  10911. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate },
  10912. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale },
  10913. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
  10914. { 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 },
  10915. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Scale },
  10916. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend },
  10917. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend_Scale },
  10918. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate },
  10919. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale },
  10920. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend },
  10921. { 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 },
  10922. { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_UNKNOWN, 0, 0, NULL }
  10923. };
  10924. /* *INDENT-ON* */ // clang-format on
  10925. #endif // SDL_HAVE_BLIT_AUTO