SDL_blit_auto.c 285 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681
  1. /* DO NOT EDIT! This file is generated by sdlgenblit.pl */
  2. /*
  3. Simple DirectMedia Layer
  4. Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any damages
  7. arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose,
  9. including commercial applications, and to alter it and redistribute it
  10. freely, subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software
  13. in a product, an acknowledgment in the product documentation would be
  14. appreciated but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. */
  19. #include "../SDL_internal.h"
  20. #if SDL_HAVE_BLIT_AUTO
  21. /* *INDENT-OFF* */
  22. #include "SDL_video.h"
  23. #include "SDL_blit.h"
  24. #include "SDL_blit_auto.h"
  25. static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
  26. {
  27. int srcy, srcx;
  28. int posy, posx;
  29. int incy, incx;
  30. srcy = 0;
  31. posy = 0;
  32. incy = (info->src_h << 16) / info->dst_h;
  33. incx = (info->src_w << 16) / info->dst_w;
  34. while (info->dst_h--) {
  35. Uint32 *src = 0;
  36. Uint32 *dst = (Uint32 *)info->dst;
  37. int n = info->dst_w;
  38. srcx = -1;
  39. posx = 0x10000L;
  40. while (posy >= 0x10000L) {
  41. ++srcy;
  42. posy -= 0x10000L;
  43. }
  44. while (n--) {
  45. if (posx >= 0x10000L) {
  46. while (posx >= 0x10000L) {
  47. ++srcx;
  48. posx -= 0x10000L;
  49. }
  50. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  51. }
  52. *dst = *src;
  53. posx += incx;
  54. ++dst;
  55. }
  56. posy += incy;
  57. info->dst += info->dst_pitch;
  58. }
  59. }
  60. static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
  61. {
  62. const int flags = info->flags;
  63. Uint32 srcpixel;
  64. Uint32 srcR, srcG, srcB;
  65. Uint32 dstpixel;
  66. Uint32 dstR, dstG, dstB;
  67. while (info->dst_h--) {
  68. Uint32 *src = (Uint32 *)info->src;
  69. Uint32 *dst = (Uint32 *)info->dst;
  70. int n = info->dst_w;
  71. while (n--) {
  72. srcpixel = *src;
  73. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  74. dstpixel = *dst;
  75. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  76. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  77. case SDL_COPY_BLEND:
  78. dstR = srcR;
  79. dstG = srcG;
  80. dstB = srcB;
  81. break;
  82. case SDL_COPY_ADD:
  83. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  84. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  85. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  86. break;
  87. case SDL_COPY_MOD:
  88. dstR = (srcR * dstR) / 255;
  89. dstG = (srcG * dstG) / 255;
  90. dstB = (srcB * dstB) / 255;
  91. break;
  92. case SDL_COPY_MUL:
  93. dstR = (srcR * dstR) / 255;
  94. dstG = (srcG * dstG) / 255;
  95. dstB = (srcB * dstB) / 255;
  96. break;
  97. }
  98. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  99. *dst = dstpixel;
  100. ++src;
  101. ++dst;
  102. }
  103. info->src += info->src_pitch;
  104. info->dst += info->dst_pitch;
  105. }
  106. }
  107. static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  108. {
  109. const int flags = info->flags;
  110. Uint32 srcpixel;
  111. Uint32 srcR, srcG, srcB;
  112. Uint32 dstpixel;
  113. Uint32 dstR, dstG, dstB;
  114. int srcy, srcx;
  115. int posy, posx;
  116. int incy, incx;
  117. srcy = 0;
  118. posy = 0;
  119. incy = (info->src_h << 16) / info->dst_h;
  120. incx = (info->src_w << 16) / info->dst_w;
  121. while (info->dst_h--) {
  122. Uint32 *src = 0;
  123. Uint32 *dst = (Uint32 *)info->dst;
  124. int n = info->dst_w;
  125. srcx = -1;
  126. posx = 0x10000L;
  127. while (posy >= 0x10000L) {
  128. ++srcy;
  129. posy -= 0x10000L;
  130. }
  131. while (n--) {
  132. if (posx >= 0x10000L) {
  133. while (posx >= 0x10000L) {
  134. ++srcx;
  135. posx -= 0x10000L;
  136. }
  137. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  138. }
  139. srcpixel = *src;
  140. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  141. dstpixel = *dst;
  142. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  143. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  144. case SDL_COPY_BLEND:
  145. dstR = srcR;
  146. dstG = srcG;
  147. dstB = srcB;
  148. break;
  149. case SDL_COPY_ADD:
  150. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  151. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  152. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  153. break;
  154. case SDL_COPY_MOD:
  155. dstR = (srcR * dstR) / 255;
  156. dstG = (srcG * dstG) / 255;
  157. dstB = (srcB * dstB) / 255;
  158. break;
  159. case SDL_COPY_MUL:
  160. dstR = (srcR * dstR) / 255;
  161. dstG = (srcG * dstG) / 255;
  162. dstB = (srcB * dstB) / 255;
  163. break;
  164. }
  165. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  166. *dst = dstpixel;
  167. posx += incx;
  168. ++dst;
  169. }
  170. posy += incy;
  171. info->dst += info->dst_pitch;
  172. }
  173. }
  174. static void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
  175. {
  176. const int flags = info->flags;
  177. const Uint32 modulateR = info->r;
  178. const Uint32 modulateG = info->g;
  179. const Uint32 modulateB = info->b;
  180. Uint32 pixel;
  181. Uint32 R, G, B;
  182. while (info->dst_h--) {
  183. Uint32 *src = (Uint32 *)info->src;
  184. Uint32 *dst = (Uint32 *)info->dst;
  185. int n = info->dst_w;
  186. while (n--) {
  187. pixel = *src;
  188. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  189. if (flags & SDL_COPY_MODULATE_COLOR) {
  190. R = (R * modulateR) / 255;
  191. G = (G * modulateG) / 255;
  192. B = (B * modulateB) / 255;
  193. }
  194. pixel = (R << 16) | (G << 8) | B;
  195. *dst = pixel;
  196. ++src;
  197. ++dst;
  198. }
  199. info->src += info->src_pitch;
  200. info->dst += info->dst_pitch;
  201. }
  202. }
  203. static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  204. {
  205. const int flags = info->flags;
  206. const Uint32 modulateR = info->r;
  207. const Uint32 modulateG = info->g;
  208. const Uint32 modulateB = info->b;
  209. Uint32 pixel;
  210. Uint32 R, G, B;
  211. int srcy, srcx;
  212. int posy, posx;
  213. int incy, incx;
  214. srcy = 0;
  215. posy = 0;
  216. incy = (info->src_h << 16) / info->dst_h;
  217. incx = (info->src_w << 16) / info->dst_w;
  218. while (info->dst_h--) {
  219. Uint32 *src = 0;
  220. Uint32 *dst = (Uint32 *)info->dst;
  221. int n = info->dst_w;
  222. srcx = -1;
  223. posx = 0x10000L;
  224. while (posy >= 0x10000L) {
  225. ++srcy;
  226. posy -= 0x10000L;
  227. }
  228. while (n--) {
  229. if (posx >= 0x10000L) {
  230. while (posx >= 0x10000L) {
  231. ++srcx;
  232. posx -= 0x10000L;
  233. }
  234. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  235. }
  236. pixel = *src;
  237. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  238. if (flags & SDL_COPY_MODULATE_COLOR) {
  239. R = (R * modulateR) / 255;
  240. G = (G * modulateG) / 255;
  241. B = (B * modulateB) / 255;
  242. }
  243. pixel = (R << 16) | (G << 8) | B;
  244. *dst = pixel;
  245. posx += incx;
  246. ++dst;
  247. }
  248. posy += incy;
  249. info->dst += info->dst_pitch;
  250. }
  251. }
  252. static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  253. {
  254. const int flags = info->flags;
  255. const Uint32 modulateR = info->r;
  256. const Uint32 modulateG = info->g;
  257. const Uint32 modulateB = info->b;
  258. const Uint32 modulateA = info->a;
  259. Uint32 srcpixel;
  260. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  261. Uint32 srcR, srcG, srcB;
  262. Uint32 dstpixel;
  263. Uint32 dstR, dstG, dstB;
  264. while (info->dst_h--) {
  265. Uint32 *src = (Uint32 *)info->src;
  266. Uint32 *dst = (Uint32 *)info->dst;
  267. int n = info->dst_w;
  268. while (n--) {
  269. srcpixel = *src;
  270. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  271. dstpixel = *dst;
  272. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  273. if (flags & SDL_COPY_MODULATE_COLOR) {
  274. srcR = (srcR * modulateR) / 255;
  275. srcG = (srcG * modulateG) / 255;
  276. srcB = (srcB * modulateB) / 255;
  277. }
  278. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  279. /* This goes away if we ever use premultiplied alpha */
  280. if (srcA < 255) {
  281. srcR = (srcR * srcA) / 255;
  282. srcG = (srcG * srcA) / 255;
  283. srcB = (srcB * srcA) / 255;
  284. }
  285. }
  286. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  287. case SDL_COPY_BLEND:
  288. dstR = srcR + ((255 - srcA) * dstR) / 255;
  289. dstG = srcG + ((255 - srcA) * dstG) / 255;
  290. dstB = srcB + ((255 - srcA) * dstB) / 255;
  291. break;
  292. case SDL_COPY_ADD:
  293. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  294. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  295. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  296. break;
  297. case SDL_COPY_MOD:
  298. dstR = (srcR * dstR) / 255;
  299. dstG = (srcG * dstG) / 255;
  300. dstB = (srcB * dstB) / 255;
  301. break;
  302. case SDL_COPY_MUL:
  303. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  304. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  305. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  306. break;
  307. }
  308. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  309. *dst = dstpixel;
  310. ++src;
  311. ++dst;
  312. }
  313. info->src += info->src_pitch;
  314. info->dst += info->dst_pitch;
  315. }
  316. }
  317. static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  318. {
  319. const int flags = info->flags;
  320. const Uint32 modulateR = info->r;
  321. const Uint32 modulateG = info->g;
  322. const Uint32 modulateB = info->b;
  323. const Uint32 modulateA = info->a;
  324. Uint32 srcpixel;
  325. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  326. Uint32 srcR, srcG, srcB;
  327. Uint32 dstpixel;
  328. Uint32 dstR, dstG, dstB;
  329. int srcy, srcx;
  330. int posy, posx;
  331. int incy, incx;
  332. srcy = 0;
  333. posy = 0;
  334. incy = (info->src_h << 16) / info->dst_h;
  335. incx = (info->src_w << 16) / info->dst_w;
  336. while (info->dst_h--) {
  337. Uint32 *src = 0;
  338. Uint32 *dst = (Uint32 *)info->dst;
  339. int n = info->dst_w;
  340. srcx = -1;
  341. posx = 0x10000L;
  342. while (posy >= 0x10000L) {
  343. ++srcy;
  344. posy -= 0x10000L;
  345. }
  346. while (n--) {
  347. if (posx >= 0x10000L) {
  348. while (posx >= 0x10000L) {
  349. ++srcx;
  350. posx -= 0x10000L;
  351. }
  352. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  353. }
  354. srcpixel = *src;
  355. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  356. dstpixel = *dst;
  357. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  358. if (flags & SDL_COPY_MODULATE_COLOR) {
  359. srcR = (srcR * modulateR) / 255;
  360. srcG = (srcG * modulateG) / 255;
  361. srcB = (srcB * modulateB) / 255;
  362. }
  363. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  364. /* This goes away if we ever use premultiplied alpha */
  365. if (srcA < 255) {
  366. srcR = (srcR * srcA) / 255;
  367. srcG = (srcG * srcA) / 255;
  368. srcB = (srcB * srcA) / 255;
  369. }
  370. }
  371. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  372. case SDL_COPY_BLEND:
  373. dstR = srcR + ((255 - srcA) * dstR) / 255;
  374. dstG = srcG + ((255 - srcA) * dstG) / 255;
  375. dstB = srcB + ((255 - srcA) * dstB) / 255;
  376. break;
  377. case SDL_COPY_ADD:
  378. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  379. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  380. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  381. break;
  382. case SDL_COPY_MOD:
  383. dstR = (srcR * dstR) / 255;
  384. dstG = (srcG * dstG) / 255;
  385. dstB = (srcB * dstB) / 255;
  386. break;
  387. case SDL_COPY_MUL:
  388. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  389. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  390. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  391. break;
  392. }
  393. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  394. *dst = dstpixel;
  395. posx += incx;
  396. ++dst;
  397. }
  398. posy += incy;
  399. info->dst += info->dst_pitch;
  400. }
  401. }
  402. static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
  403. {
  404. Uint32 pixel;
  405. Uint32 R, G, B;
  406. int srcy, srcx;
  407. int posy, posx;
  408. int incy, incx;
  409. srcy = 0;
  410. posy = 0;
  411. incy = (info->src_h << 16) / info->dst_h;
  412. incx = (info->src_w << 16) / info->dst_w;
  413. while (info->dst_h--) {
  414. Uint32 *src = 0;
  415. Uint32 *dst = (Uint32 *)info->dst;
  416. int n = info->dst_w;
  417. srcx = -1;
  418. posx = 0x10000L;
  419. while (posy >= 0x10000L) {
  420. ++srcy;
  421. posy -= 0x10000L;
  422. }
  423. while (n--) {
  424. if (posx >= 0x10000L) {
  425. while (posx >= 0x10000L) {
  426. ++srcx;
  427. posx -= 0x10000L;
  428. }
  429. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  430. }
  431. pixel = *src;
  432. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  433. pixel = (B << 16) | (G << 8) | R;
  434. *dst = pixel;
  435. posx += incx;
  436. ++dst;
  437. }
  438. posy += incy;
  439. info->dst += info->dst_pitch;
  440. }
  441. }
  442. static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
  443. {
  444. const int flags = info->flags;
  445. Uint32 srcpixel;
  446. Uint32 srcR, srcG, srcB;
  447. Uint32 dstpixel;
  448. Uint32 dstR, dstG, dstB;
  449. while (info->dst_h--) {
  450. Uint32 *src = (Uint32 *)info->src;
  451. Uint32 *dst = (Uint32 *)info->dst;
  452. int n = info->dst_w;
  453. while (n--) {
  454. srcpixel = *src;
  455. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  456. dstpixel = *dst;
  457. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  458. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  459. case SDL_COPY_BLEND:
  460. dstR = srcR;
  461. dstG = srcG;
  462. dstB = srcB;
  463. break;
  464. case SDL_COPY_ADD:
  465. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  466. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  467. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  468. break;
  469. case SDL_COPY_MOD:
  470. dstR = (srcR * dstR) / 255;
  471. dstG = (srcG * dstG) / 255;
  472. dstB = (srcB * dstB) / 255;
  473. break;
  474. case SDL_COPY_MUL:
  475. dstR = (srcR * dstR) / 255;
  476. dstG = (srcG * dstG) / 255;
  477. dstB = (srcB * dstB) / 255;
  478. break;
  479. }
  480. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  481. *dst = dstpixel;
  482. ++src;
  483. ++dst;
  484. }
  485. info->src += info->src_pitch;
  486. info->dst += info->dst_pitch;
  487. }
  488. }
  489. static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  490. {
  491. const int flags = info->flags;
  492. Uint32 srcpixel;
  493. Uint32 srcR, srcG, srcB;
  494. Uint32 dstpixel;
  495. Uint32 dstR, dstG, dstB;
  496. int srcy, srcx;
  497. int posy, posx;
  498. int incy, incx;
  499. srcy = 0;
  500. posy = 0;
  501. incy = (info->src_h << 16) / info->dst_h;
  502. incx = (info->src_w << 16) / info->dst_w;
  503. while (info->dst_h--) {
  504. Uint32 *src = 0;
  505. Uint32 *dst = (Uint32 *)info->dst;
  506. int n = info->dst_w;
  507. srcx = -1;
  508. posx = 0x10000L;
  509. while (posy >= 0x10000L) {
  510. ++srcy;
  511. posy -= 0x10000L;
  512. }
  513. while (n--) {
  514. if (posx >= 0x10000L) {
  515. while (posx >= 0x10000L) {
  516. ++srcx;
  517. posx -= 0x10000L;
  518. }
  519. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  520. }
  521. srcpixel = *src;
  522. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  523. dstpixel = *dst;
  524. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  525. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  526. case SDL_COPY_BLEND:
  527. dstR = srcR;
  528. dstG = srcG;
  529. dstB = srcB;
  530. break;
  531. case SDL_COPY_ADD:
  532. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  533. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  534. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  535. break;
  536. case SDL_COPY_MOD:
  537. dstR = (srcR * dstR) / 255;
  538. dstG = (srcG * dstG) / 255;
  539. dstB = (srcB * dstB) / 255;
  540. break;
  541. case SDL_COPY_MUL:
  542. dstR = (srcR * dstR) / 255;
  543. dstG = (srcG * dstG) / 255;
  544. dstB = (srcB * dstB) / 255;
  545. break;
  546. }
  547. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  548. *dst = dstpixel;
  549. posx += incx;
  550. ++dst;
  551. }
  552. posy += incy;
  553. info->dst += info->dst_pitch;
  554. }
  555. }
  556. static void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
  557. {
  558. const int flags = info->flags;
  559. const Uint32 modulateR = info->r;
  560. const Uint32 modulateG = info->g;
  561. const Uint32 modulateB = info->b;
  562. Uint32 pixel;
  563. Uint32 R, G, B;
  564. while (info->dst_h--) {
  565. Uint32 *src = (Uint32 *)info->src;
  566. Uint32 *dst = (Uint32 *)info->dst;
  567. int n = info->dst_w;
  568. while (n--) {
  569. pixel = *src;
  570. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  571. if (flags & SDL_COPY_MODULATE_COLOR) {
  572. R = (R * modulateR) / 255;
  573. G = (G * modulateG) / 255;
  574. B = (B * modulateB) / 255;
  575. }
  576. pixel = (B << 16) | (G << 8) | R;
  577. *dst = pixel;
  578. ++src;
  579. ++dst;
  580. }
  581. info->src += info->src_pitch;
  582. info->dst += info->dst_pitch;
  583. }
  584. }
  585. static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  586. {
  587. const int flags = info->flags;
  588. const Uint32 modulateR = info->r;
  589. const Uint32 modulateG = info->g;
  590. const Uint32 modulateB = info->b;
  591. Uint32 pixel;
  592. Uint32 R, G, B;
  593. int srcy, srcx;
  594. int posy, posx;
  595. int incy, incx;
  596. srcy = 0;
  597. posy = 0;
  598. incy = (info->src_h << 16) / info->dst_h;
  599. incx = (info->src_w << 16) / info->dst_w;
  600. while (info->dst_h--) {
  601. Uint32 *src = 0;
  602. Uint32 *dst = (Uint32 *)info->dst;
  603. int n = info->dst_w;
  604. srcx = -1;
  605. posx = 0x10000L;
  606. while (posy >= 0x10000L) {
  607. ++srcy;
  608. posy -= 0x10000L;
  609. }
  610. while (n--) {
  611. if (posx >= 0x10000L) {
  612. while (posx >= 0x10000L) {
  613. ++srcx;
  614. posx -= 0x10000L;
  615. }
  616. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  617. }
  618. pixel = *src;
  619. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  620. if (flags & SDL_COPY_MODULATE_COLOR) {
  621. R = (R * modulateR) / 255;
  622. G = (G * modulateG) / 255;
  623. B = (B * modulateB) / 255;
  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_RGB888_BGR888_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. srcR = (srcR * modulateR) / 255;
  657. srcG = (srcG * modulateG) / 255;
  658. srcB = (srcB * modulateB) / 255;
  659. }
  660. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  661. /* This goes away if we ever use premultiplied alpha */
  662. if (srcA < 255) {
  663. srcR = (srcR * srcA) / 255;
  664. srcG = (srcG * srcA) / 255;
  665. srcB = (srcB * srcA) / 255;
  666. }
  667. }
  668. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  669. case SDL_COPY_BLEND:
  670. dstR = srcR + ((255 - srcA) * dstR) / 255;
  671. dstG = srcG + ((255 - srcA) * dstG) / 255;
  672. dstB = srcB + ((255 - srcA) * dstB) / 255;
  673. break;
  674. case SDL_COPY_ADD:
  675. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  676. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  677. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  678. break;
  679. case SDL_COPY_MOD:
  680. dstR = (srcR * dstR) / 255;
  681. dstG = (srcG * dstG) / 255;
  682. dstB = (srcB * dstB) / 255;
  683. break;
  684. case SDL_COPY_MUL:
  685. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  686. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  687. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  688. break;
  689. }
  690. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  691. *dst = dstpixel;
  692. ++src;
  693. ++dst;
  694. }
  695. info->src += info->src_pitch;
  696. info->dst += info->dst_pitch;
  697. }
  698. }
  699. static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  700. {
  701. const int flags = info->flags;
  702. const Uint32 modulateR = info->r;
  703. const Uint32 modulateG = info->g;
  704. const Uint32 modulateB = info->b;
  705. const Uint32 modulateA = info->a;
  706. Uint32 srcpixel;
  707. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  708. Uint32 srcR, srcG, srcB;
  709. Uint32 dstpixel;
  710. Uint32 dstR, dstG, dstB;
  711. int srcy, srcx;
  712. int posy, posx;
  713. int incy, incx;
  714. srcy = 0;
  715. posy = 0;
  716. incy = (info->src_h << 16) / info->dst_h;
  717. incx = (info->src_w << 16) / info->dst_w;
  718. while (info->dst_h--) {
  719. Uint32 *src = 0;
  720. Uint32 *dst = (Uint32 *)info->dst;
  721. int n = info->dst_w;
  722. srcx = -1;
  723. posx = 0x10000L;
  724. while (posy >= 0x10000L) {
  725. ++srcy;
  726. posy -= 0x10000L;
  727. }
  728. while (n--) {
  729. if (posx >= 0x10000L) {
  730. while (posx >= 0x10000L) {
  731. ++srcx;
  732. posx -= 0x10000L;
  733. }
  734. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  735. }
  736. srcpixel = *src;
  737. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  738. dstpixel = *dst;
  739. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  740. if (flags & SDL_COPY_MODULATE_COLOR) {
  741. srcR = (srcR * modulateR) / 255;
  742. srcG = (srcG * modulateG) / 255;
  743. srcB = (srcB * modulateB) / 255;
  744. }
  745. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  746. /* This goes away if we ever use premultiplied alpha */
  747. if (srcA < 255) {
  748. srcR = (srcR * srcA) / 255;
  749. srcG = (srcG * srcA) / 255;
  750. srcB = (srcB * srcA) / 255;
  751. }
  752. }
  753. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  754. case SDL_COPY_BLEND:
  755. dstR = srcR + ((255 - srcA) * dstR) / 255;
  756. dstG = srcG + ((255 - srcA) * dstG) / 255;
  757. dstB = srcB + ((255 - srcA) * dstB) / 255;
  758. break;
  759. case SDL_COPY_ADD:
  760. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  761. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  762. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  763. break;
  764. case SDL_COPY_MOD:
  765. dstR = (srcR * dstR) / 255;
  766. dstG = (srcG * dstG) / 255;
  767. dstB = (srcB * dstB) / 255;
  768. break;
  769. case SDL_COPY_MUL:
  770. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  771. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  772. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  773. break;
  774. }
  775. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  776. *dst = dstpixel;
  777. posx += incx;
  778. ++dst;
  779. }
  780. posy += incy;
  781. info->dst += info->dst_pitch;
  782. }
  783. }
  784. static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info)
  785. {
  786. Uint32 pixel;
  787. const Uint32 A = 0xFF;
  788. Uint32 R, G, B;
  789. int srcy, srcx;
  790. int posy, posx;
  791. int incy, incx;
  792. srcy = 0;
  793. posy = 0;
  794. incy = (info->src_h << 16) / info->dst_h;
  795. incx = (info->src_w << 16) / info->dst_w;
  796. while (info->dst_h--) {
  797. Uint32 *src = 0;
  798. Uint32 *dst = (Uint32 *)info->dst;
  799. int n = info->dst_w;
  800. srcx = -1;
  801. posx = 0x10000L;
  802. while (posy >= 0x10000L) {
  803. ++srcy;
  804. posy -= 0x10000L;
  805. }
  806. while (n--) {
  807. if (posx >= 0x10000L) {
  808. while (posx >= 0x10000L) {
  809. ++srcx;
  810. posx -= 0x10000L;
  811. }
  812. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  813. }
  814. pixel = *src;
  815. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  816. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  817. *dst = pixel;
  818. posx += incx;
  819. ++dst;
  820. }
  821. posy += incy;
  822. info->dst += info->dst_pitch;
  823. }
  824. }
  825. static void SDL_Blit_RGB888_ARGB8888_Blend(SDL_BlitInfo *info)
  826. {
  827. const int flags = info->flags;
  828. Uint32 srcpixel;
  829. Uint32 srcR, srcG, srcB;
  830. Uint32 dstpixel;
  831. Uint32 dstR, dstG, dstB, dstA;
  832. while (info->dst_h--) {
  833. Uint32 *src = (Uint32 *)info->src;
  834. Uint32 *dst = (Uint32 *)info->dst;
  835. int n = info->dst_w;
  836. while (n--) {
  837. srcpixel = *src;
  838. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  839. dstpixel = *dst;
  840. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  841. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  842. case SDL_COPY_BLEND:
  843. dstR = srcR;
  844. dstG = srcG;
  845. dstB = srcB;
  846. dstA = 0xFF;
  847. break;
  848. case SDL_COPY_ADD:
  849. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  850. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  851. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  852. break;
  853. case SDL_COPY_MOD:
  854. dstR = (srcR * dstR) / 255;
  855. dstG = (srcG * dstG) / 255;
  856. dstB = (srcB * dstB) / 255;
  857. break;
  858. case SDL_COPY_MUL:
  859. dstR = (srcR * dstR) / 255;
  860. dstG = (srcG * dstG) / 255;
  861. dstB = (srcB * dstB) / 255;
  862. dstA = 0xFF;
  863. break;
  864. }
  865. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  866. *dst = dstpixel;
  867. ++src;
  868. ++dst;
  869. }
  870. info->src += info->src_pitch;
  871. info->dst += info->dst_pitch;
  872. }
  873. }
  874. static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  875. {
  876. const int flags = info->flags;
  877. Uint32 srcpixel;
  878. Uint32 srcR, srcG, srcB;
  879. Uint32 dstpixel;
  880. Uint32 dstR, dstG, dstB, dstA;
  881. int srcy, srcx;
  882. int posy, posx;
  883. int incy, incx;
  884. srcy = 0;
  885. posy = 0;
  886. incy = (info->src_h << 16) / info->dst_h;
  887. incx = (info->src_w << 16) / info->dst_w;
  888. while (info->dst_h--) {
  889. Uint32 *src = 0;
  890. Uint32 *dst = (Uint32 *)info->dst;
  891. int n = info->dst_w;
  892. srcx = -1;
  893. posx = 0x10000L;
  894. while (posy >= 0x10000L) {
  895. ++srcy;
  896. posy -= 0x10000L;
  897. }
  898. while (n--) {
  899. if (posx >= 0x10000L) {
  900. while (posx >= 0x10000L) {
  901. ++srcx;
  902. posx -= 0x10000L;
  903. }
  904. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  905. }
  906. srcpixel = *src;
  907. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  908. dstpixel = *dst;
  909. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  910. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  911. case SDL_COPY_BLEND:
  912. dstR = srcR;
  913. dstG = srcG;
  914. dstB = srcB;
  915. dstA = 0xFF;
  916. break;
  917. case SDL_COPY_ADD:
  918. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  919. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  920. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  921. break;
  922. case SDL_COPY_MOD:
  923. dstR = (srcR * dstR) / 255;
  924. dstG = (srcG * dstG) / 255;
  925. dstB = (srcB * dstB) / 255;
  926. break;
  927. case SDL_COPY_MUL:
  928. dstR = (srcR * dstR) / 255;
  929. dstG = (srcG * dstG) / 255;
  930. dstB = (srcB * dstB) / 255;
  931. dstA = 0xFF;
  932. break;
  933. }
  934. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  935. *dst = dstpixel;
  936. posx += incx;
  937. ++dst;
  938. }
  939. posy += incy;
  940. info->dst += info->dst_pitch;
  941. }
  942. }
  943. static void SDL_Blit_RGB888_ARGB8888_Modulate(SDL_BlitInfo *info)
  944. {
  945. const int flags = info->flags;
  946. const Uint32 modulateR = info->r;
  947. const Uint32 modulateG = info->g;
  948. const Uint32 modulateB = info->b;
  949. const Uint32 modulateA = info->a;
  950. Uint32 pixel;
  951. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  952. Uint32 R, G, B;
  953. while (info->dst_h--) {
  954. Uint32 *src = (Uint32 *)info->src;
  955. Uint32 *dst = (Uint32 *)info->dst;
  956. int n = info->dst_w;
  957. while (n--) {
  958. pixel = *src;
  959. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  960. if (flags & SDL_COPY_MODULATE_COLOR) {
  961. R = (R * modulateR) / 255;
  962. G = (G * modulateG) / 255;
  963. B = (B * modulateB) / 255;
  964. }
  965. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  966. *dst = pixel;
  967. ++src;
  968. ++dst;
  969. }
  970. info->src += info->src_pitch;
  971. info->dst += info->dst_pitch;
  972. }
  973. }
  974. static void SDL_Blit_RGB888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  975. {
  976. const int flags = info->flags;
  977. const Uint32 modulateR = info->r;
  978. const Uint32 modulateG = info->g;
  979. const Uint32 modulateB = info->b;
  980. const Uint32 modulateA = info->a;
  981. Uint32 pixel;
  982. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  983. Uint32 R, G, B;
  984. int srcy, srcx;
  985. int posy, posx;
  986. int incy, incx;
  987. srcy = 0;
  988. posy = 0;
  989. incy = (info->src_h << 16) / info->dst_h;
  990. incx = (info->src_w << 16) / info->dst_w;
  991. while (info->dst_h--) {
  992. Uint32 *src = 0;
  993. Uint32 *dst = (Uint32 *)info->dst;
  994. int n = info->dst_w;
  995. srcx = -1;
  996. posx = 0x10000L;
  997. while (posy >= 0x10000L) {
  998. ++srcy;
  999. posy -= 0x10000L;
  1000. }
  1001. while (n--) {
  1002. if (posx >= 0x10000L) {
  1003. while (posx >= 0x10000L) {
  1004. ++srcx;
  1005. posx -= 0x10000L;
  1006. }
  1007. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1008. }
  1009. pixel = *src;
  1010. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1011. if (flags & SDL_COPY_MODULATE_COLOR) {
  1012. R = (R * modulateR) / 255;
  1013. G = (G * modulateG) / 255;
  1014. B = (B * modulateB) / 255;
  1015. }
  1016. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  1017. *dst = pixel;
  1018. posx += incx;
  1019. ++dst;
  1020. }
  1021. posy += incy;
  1022. info->dst += info->dst_pitch;
  1023. }
  1024. }
  1025. static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1026. {
  1027. const int flags = info->flags;
  1028. const Uint32 modulateR = info->r;
  1029. const Uint32 modulateG = info->g;
  1030. const Uint32 modulateB = info->b;
  1031. const Uint32 modulateA = info->a;
  1032. Uint32 srcpixel;
  1033. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1034. Uint32 srcR, srcG, srcB;
  1035. Uint32 dstpixel;
  1036. Uint32 dstR, dstG, dstB, dstA;
  1037. while (info->dst_h--) {
  1038. Uint32 *src = (Uint32 *)info->src;
  1039. Uint32 *dst = (Uint32 *)info->dst;
  1040. int n = info->dst_w;
  1041. while (n--) {
  1042. srcpixel = *src;
  1043. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1044. dstpixel = *dst;
  1045. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1046. if (flags & SDL_COPY_MODULATE_COLOR) {
  1047. srcR = (srcR * modulateR) / 255;
  1048. srcG = (srcG * modulateG) / 255;
  1049. srcB = (srcB * modulateB) / 255;
  1050. }
  1051. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1052. /* This goes away if we ever use premultiplied alpha */
  1053. if (srcA < 255) {
  1054. srcR = (srcR * srcA) / 255;
  1055. srcG = (srcG * srcA) / 255;
  1056. srcB = (srcB * srcA) / 255;
  1057. }
  1058. }
  1059. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1060. case SDL_COPY_BLEND:
  1061. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1062. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1063. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1064. dstA = srcA + ((255 - srcA) * dstA) / 255;
  1065. break;
  1066. case SDL_COPY_ADD:
  1067. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1068. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1069. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1070. break;
  1071. case SDL_COPY_MOD:
  1072. dstR = (srcR * dstR) / 255;
  1073. dstG = (srcG * dstG) / 255;
  1074. dstB = (srcB * dstB) / 255;
  1075. break;
  1076. case SDL_COPY_MUL:
  1077. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  1078. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  1079. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  1080. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  1081. break;
  1082. }
  1083. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  1084. *dst = dstpixel;
  1085. ++src;
  1086. ++dst;
  1087. }
  1088. info->src += info->src_pitch;
  1089. info->dst += info->dst_pitch;
  1090. }
  1091. }
  1092. static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1093. {
  1094. const int flags = info->flags;
  1095. const Uint32 modulateR = info->r;
  1096. const Uint32 modulateG = info->g;
  1097. const Uint32 modulateB = info->b;
  1098. const Uint32 modulateA = info->a;
  1099. Uint32 srcpixel;
  1100. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1101. Uint32 srcR, srcG, srcB;
  1102. Uint32 dstpixel;
  1103. Uint32 dstR, dstG, dstB, dstA;
  1104. int srcy, srcx;
  1105. int posy, posx;
  1106. int incy, incx;
  1107. srcy = 0;
  1108. posy = 0;
  1109. incy = (info->src_h << 16) / info->dst_h;
  1110. incx = (info->src_w << 16) / info->dst_w;
  1111. while (info->dst_h--) {
  1112. Uint32 *src = 0;
  1113. Uint32 *dst = (Uint32 *)info->dst;
  1114. int n = info->dst_w;
  1115. srcx = -1;
  1116. posx = 0x10000L;
  1117. while (posy >= 0x10000L) {
  1118. ++srcy;
  1119. posy -= 0x10000L;
  1120. }
  1121. while (n--) {
  1122. if (posx >= 0x10000L) {
  1123. while (posx >= 0x10000L) {
  1124. ++srcx;
  1125. posx -= 0x10000L;
  1126. }
  1127. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1128. }
  1129. srcpixel = *src;
  1130. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1131. dstpixel = *dst;
  1132. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1133. if (flags & SDL_COPY_MODULATE_COLOR) {
  1134. srcR = (srcR * modulateR) / 255;
  1135. srcG = (srcG * modulateG) / 255;
  1136. srcB = (srcB * modulateB) / 255;
  1137. }
  1138. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1139. /* This goes away if we ever use premultiplied alpha */
  1140. if (srcA < 255) {
  1141. srcR = (srcR * srcA) / 255;
  1142. srcG = (srcG * srcA) / 255;
  1143. srcB = (srcB * srcA) / 255;
  1144. }
  1145. }
  1146. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1147. case SDL_COPY_BLEND:
  1148. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1149. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1150. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1151. dstA = srcA + ((255 - srcA) * dstA) / 255;
  1152. break;
  1153. case SDL_COPY_ADD:
  1154. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1155. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1156. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1157. break;
  1158. case SDL_COPY_MOD:
  1159. dstR = (srcR * dstR) / 255;
  1160. dstG = (srcG * dstG) / 255;
  1161. dstB = (srcB * dstB) / 255;
  1162. break;
  1163. case SDL_COPY_MUL:
  1164. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  1165. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  1166. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  1167. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  1168. break;
  1169. }
  1170. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  1171. *dst = dstpixel;
  1172. posx += incx;
  1173. ++dst;
  1174. }
  1175. posy += incy;
  1176. info->dst += info->dst_pitch;
  1177. }
  1178. }
  1179. static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
  1180. {
  1181. Uint32 pixel;
  1182. Uint32 R, G, B;
  1183. int srcy, srcx;
  1184. int posy, posx;
  1185. int incy, incx;
  1186. srcy = 0;
  1187. posy = 0;
  1188. incy = (info->src_h << 16) / info->dst_h;
  1189. incx = (info->src_w << 16) / info->dst_w;
  1190. while (info->dst_h--) {
  1191. Uint32 *src = 0;
  1192. Uint32 *dst = (Uint32 *)info->dst;
  1193. int n = info->dst_w;
  1194. srcx = -1;
  1195. posx = 0x10000L;
  1196. while (posy >= 0x10000L) {
  1197. ++srcy;
  1198. posy -= 0x10000L;
  1199. }
  1200. while (n--) {
  1201. if (posx >= 0x10000L) {
  1202. while (posx >= 0x10000L) {
  1203. ++srcx;
  1204. posx -= 0x10000L;
  1205. }
  1206. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1207. }
  1208. pixel = *src;
  1209. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1210. pixel = (R << 16) | (G << 8) | B;
  1211. *dst = pixel;
  1212. posx += incx;
  1213. ++dst;
  1214. }
  1215. posy += incy;
  1216. info->dst += info->dst_pitch;
  1217. }
  1218. }
  1219. static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
  1220. {
  1221. const int flags = info->flags;
  1222. Uint32 srcpixel;
  1223. Uint32 srcR, srcG, srcB;
  1224. Uint32 dstpixel;
  1225. Uint32 dstR, dstG, dstB;
  1226. while (info->dst_h--) {
  1227. Uint32 *src = (Uint32 *)info->src;
  1228. Uint32 *dst = (Uint32 *)info->dst;
  1229. int n = info->dst_w;
  1230. while (n--) {
  1231. srcpixel = *src;
  1232. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1233. dstpixel = *dst;
  1234. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1235. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1236. case SDL_COPY_BLEND:
  1237. dstR = srcR;
  1238. dstG = srcG;
  1239. dstB = srcB;
  1240. break;
  1241. case SDL_COPY_ADD:
  1242. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1243. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1244. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1245. break;
  1246. case SDL_COPY_MOD:
  1247. dstR = (srcR * dstR) / 255;
  1248. dstG = (srcG * dstG) / 255;
  1249. dstB = (srcB * dstB) / 255;
  1250. break;
  1251. case SDL_COPY_MUL:
  1252. dstR = (srcR * dstR) / 255;
  1253. dstG = (srcG * dstG) / 255;
  1254. dstB = (srcB * dstB) / 255;
  1255. break;
  1256. }
  1257. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1258. *dst = dstpixel;
  1259. ++src;
  1260. ++dst;
  1261. }
  1262. info->src += info->src_pitch;
  1263. info->dst += info->dst_pitch;
  1264. }
  1265. }
  1266. static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  1267. {
  1268. const int flags = info->flags;
  1269. Uint32 srcpixel;
  1270. Uint32 srcR, srcG, srcB;
  1271. Uint32 dstpixel;
  1272. Uint32 dstR, dstG, dstB;
  1273. int srcy, srcx;
  1274. int posy, posx;
  1275. int incy, incx;
  1276. srcy = 0;
  1277. posy = 0;
  1278. incy = (info->src_h << 16) / info->dst_h;
  1279. incx = (info->src_w << 16) / info->dst_w;
  1280. while (info->dst_h--) {
  1281. Uint32 *src = 0;
  1282. Uint32 *dst = (Uint32 *)info->dst;
  1283. int n = info->dst_w;
  1284. srcx = -1;
  1285. posx = 0x10000L;
  1286. while (posy >= 0x10000L) {
  1287. ++srcy;
  1288. posy -= 0x10000L;
  1289. }
  1290. while (n--) {
  1291. if (posx >= 0x10000L) {
  1292. while (posx >= 0x10000L) {
  1293. ++srcx;
  1294. posx -= 0x10000L;
  1295. }
  1296. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1297. }
  1298. srcpixel = *src;
  1299. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1300. dstpixel = *dst;
  1301. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1302. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1303. case SDL_COPY_BLEND:
  1304. dstR = srcR;
  1305. dstG = srcG;
  1306. dstB = srcB;
  1307. break;
  1308. case SDL_COPY_ADD:
  1309. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1310. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1311. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1312. break;
  1313. case SDL_COPY_MOD:
  1314. dstR = (srcR * dstR) / 255;
  1315. dstG = (srcG * dstG) / 255;
  1316. dstB = (srcB * dstB) / 255;
  1317. break;
  1318. case SDL_COPY_MUL:
  1319. dstR = (srcR * dstR) / 255;
  1320. dstG = (srcG * dstG) / 255;
  1321. dstB = (srcB * dstB) / 255;
  1322. break;
  1323. }
  1324. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1325. *dst = dstpixel;
  1326. posx += incx;
  1327. ++dst;
  1328. }
  1329. posy += incy;
  1330. info->dst += info->dst_pitch;
  1331. }
  1332. }
  1333. static void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
  1334. {
  1335. const int flags = info->flags;
  1336. const Uint32 modulateR = info->r;
  1337. const Uint32 modulateG = info->g;
  1338. const Uint32 modulateB = info->b;
  1339. Uint32 pixel;
  1340. Uint32 R, G, B;
  1341. while (info->dst_h--) {
  1342. Uint32 *src = (Uint32 *)info->src;
  1343. Uint32 *dst = (Uint32 *)info->dst;
  1344. int n = info->dst_w;
  1345. while (n--) {
  1346. pixel = *src;
  1347. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1348. if (flags & SDL_COPY_MODULATE_COLOR) {
  1349. R = (R * modulateR) / 255;
  1350. G = (G * modulateG) / 255;
  1351. B = (B * modulateB) / 255;
  1352. }
  1353. pixel = (R << 16) | (G << 8) | B;
  1354. *dst = pixel;
  1355. ++src;
  1356. ++dst;
  1357. }
  1358. info->src += info->src_pitch;
  1359. info->dst += info->dst_pitch;
  1360. }
  1361. }
  1362. static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  1363. {
  1364. const int flags = info->flags;
  1365. const Uint32 modulateR = info->r;
  1366. const Uint32 modulateG = info->g;
  1367. const Uint32 modulateB = info->b;
  1368. Uint32 pixel;
  1369. Uint32 R, G, B;
  1370. int srcy, srcx;
  1371. int posy, posx;
  1372. int incy, incx;
  1373. srcy = 0;
  1374. posy = 0;
  1375. incy = (info->src_h << 16) / info->dst_h;
  1376. incx = (info->src_w << 16) / info->dst_w;
  1377. while (info->dst_h--) {
  1378. Uint32 *src = 0;
  1379. Uint32 *dst = (Uint32 *)info->dst;
  1380. int n = info->dst_w;
  1381. srcx = -1;
  1382. posx = 0x10000L;
  1383. while (posy >= 0x10000L) {
  1384. ++srcy;
  1385. posy -= 0x10000L;
  1386. }
  1387. while (n--) {
  1388. if (posx >= 0x10000L) {
  1389. while (posx >= 0x10000L) {
  1390. ++srcx;
  1391. posx -= 0x10000L;
  1392. }
  1393. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1394. }
  1395. pixel = *src;
  1396. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1397. if (flags & SDL_COPY_MODULATE_COLOR) {
  1398. R = (R * modulateR) / 255;
  1399. G = (G * modulateG) / 255;
  1400. B = (B * modulateB) / 255;
  1401. }
  1402. pixel = (R << 16) | (G << 8) | B;
  1403. *dst = pixel;
  1404. posx += incx;
  1405. ++dst;
  1406. }
  1407. posy += incy;
  1408. info->dst += info->dst_pitch;
  1409. }
  1410. }
  1411. static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  1412. {
  1413. const int flags = info->flags;
  1414. const Uint32 modulateR = info->r;
  1415. const Uint32 modulateG = info->g;
  1416. const Uint32 modulateB = info->b;
  1417. const Uint32 modulateA = info->a;
  1418. Uint32 srcpixel;
  1419. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1420. Uint32 srcR, srcG, srcB;
  1421. Uint32 dstpixel;
  1422. Uint32 dstR, dstG, dstB;
  1423. while (info->dst_h--) {
  1424. Uint32 *src = (Uint32 *)info->src;
  1425. Uint32 *dst = (Uint32 *)info->dst;
  1426. int n = info->dst_w;
  1427. while (n--) {
  1428. srcpixel = *src;
  1429. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1430. dstpixel = *dst;
  1431. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1432. if (flags & SDL_COPY_MODULATE_COLOR) {
  1433. srcR = (srcR * modulateR) / 255;
  1434. srcG = (srcG * modulateG) / 255;
  1435. srcB = (srcB * modulateB) / 255;
  1436. }
  1437. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1438. /* This goes away if we ever use premultiplied alpha */
  1439. if (srcA < 255) {
  1440. srcR = (srcR * srcA) / 255;
  1441. srcG = (srcG * srcA) / 255;
  1442. srcB = (srcB * srcA) / 255;
  1443. }
  1444. }
  1445. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1446. case SDL_COPY_BLEND:
  1447. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1448. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1449. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1450. break;
  1451. case SDL_COPY_ADD:
  1452. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1453. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1454. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1455. break;
  1456. case SDL_COPY_MOD:
  1457. dstR = (srcR * dstR) / 255;
  1458. dstG = (srcG * dstG) / 255;
  1459. dstB = (srcB * dstB) / 255;
  1460. break;
  1461. case SDL_COPY_MUL:
  1462. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  1463. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  1464. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  1465. break;
  1466. }
  1467. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1468. *dst = dstpixel;
  1469. ++src;
  1470. ++dst;
  1471. }
  1472. info->src += info->src_pitch;
  1473. info->dst += info->dst_pitch;
  1474. }
  1475. }
  1476. static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1477. {
  1478. const int flags = info->flags;
  1479. const Uint32 modulateR = info->r;
  1480. const Uint32 modulateG = info->g;
  1481. const Uint32 modulateB = info->b;
  1482. const Uint32 modulateA = info->a;
  1483. Uint32 srcpixel;
  1484. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1485. Uint32 srcR, srcG, srcB;
  1486. Uint32 dstpixel;
  1487. Uint32 dstR, dstG, dstB;
  1488. int srcy, srcx;
  1489. int posy, posx;
  1490. int incy, incx;
  1491. srcy = 0;
  1492. posy = 0;
  1493. incy = (info->src_h << 16) / info->dst_h;
  1494. incx = (info->src_w << 16) / info->dst_w;
  1495. while (info->dst_h--) {
  1496. Uint32 *src = 0;
  1497. Uint32 *dst = (Uint32 *)info->dst;
  1498. int n = info->dst_w;
  1499. srcx = -1;
  1500. posx = 0x10000L;
  1501. while (posy >= 0x10000L) {
  1502. ++srcy;
  1503. posy -= 0x10000L;
  1504. }
  1505. while (n--) {
  1506. if (posx >= 0x10000L) {
  1507. while (posx >= 0x10000L) {
  1508. ++srcx;
  1509. posx -= 0x10000L;
  1510. }
  1511. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1512. }
  1513. srcpixel = *src;
  1514. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1515. dstpixel = *dst;
  1516. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1517. if (flags & SDL_COPY_MODULATE_COLOR) {
  1518. srcR = (srcR * modulateR) / 255;
  1519. srcG = (srcG * modulateG) / 255;
  1520. srcB = (srcB * modulateB) / 255;
  1521. }
  1522. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1523. /* This goes away if we ever use premultiplied alpha */
  1524. if (srcA < 255) {
  1525. srcR = (srcR * srcA) / 255;
  1526. srcG = (srcG * srcA) / 255;
  1527. srcB = (srcB * srcA) / 255;
  1528. }
  1529. }
  1530. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1531. case SDL_COPY_BLEND:
  1532. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1533. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1534. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1535. break;
  1536. case SDL_COPY_ADD:
  1537. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1538. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1539. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1540. break;
  1541. case SDL_COPY_MOD:
  1542. dstR = (srcR * dstR) / 255;
  1543. dstG = (srcG * dstG) / 255;
  1544. dstB = (srcB * dstB) / 255;
  1545. break;
  1546. case SDL_COPY_MUL:
  1547. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  1548. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  1549. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  1550. break;
  1551. }
  1552. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  1553. *dst = dstpixel;
  1554. posx += incx;
  1555. ++dst;
  1556. }
  1557. posy += incy;
  1558. info->dst += info->dst_pitch;
  1559. }
  1560. }
  1561. static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
  1562. {
  1563. int srcy, srcx;
  1564. int posy, posx;
  1565. int incy, incx;
  1566. srcy = 0;
  1567. posy = 0;
  1568. incy = (info->src_h << 16) / info->dst_h;
  1569. incx = (info->src_w << 16) / info->dst_w;
  1570. while (info->dst_h--) {
  1571. Uint32 *src = 0;
  1572. Uint32 *dst = (Uint32 *)info->dst;
  1573. int n = info->dst_w;
  1574. srcx = -1;
  1575. posx = 0x10000L;
  1576. while (posy >= 0x10000L) {
  1577. ++srcy;
  1578. posy -= 0x10000L;
  1579. }
  1580. while (n--) {
  1581. if (posx >= 0x10000L) {
  1582. while (posx >= 0x10000L) {
  1583. ++srcx;
  1584. posx -= 0x10000L;
  1585. }
  1586. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1587. }
  1588. *dst = *src;
  1589. posx += incx;
  1590. ++dst;
  1591. }
  1592. posy += incy;
  1593. info->dst += info->dst_pitch;
  1594. }
  1595. }
  1596. static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
  1597. {
  1598. const int flags = info->flags;
  1599. Uint32 srcpixel;
  1600. Uint32 srcR, srcG, srcB;
  1601. Uint32 dstpixel;
  1602. Uint32 dstR, dstG, dstB;
  1603. while (info->dst_h--) {
  1604. Uint32 *src = (Uint32 *)info->src;
  1605. Uint32 *dst = (Uint32 *)info->dst;
  1606. int n = info->dst_w;
  1607. while (n--) {
  1608. srcpixel = *src;
  1609. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1610. dstpixel = *dst;
  1611. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  1612. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1613. case SDL_COPY_BLEND:
  1614. dstR = srcR;
  1615. dstG = srcG;
  1616. dstB = srcB;
  1617. break;
  1618. case SDL_COPY_ADD:
  1619. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1620. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1621. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1622. break;
  1623. case SDL_COPY_MOD:
  1624. dstR = (srcR * dstR) / 255;
  1625. dstG = (srcG * dstG) / 255;
  1626. dstB = (srcB * dstB) / 255;
  1627. break;
  1628. case SDL_COPY_MUL:
  1629. dstR = (srcR * dstR) / 255;
  1630. dstG = (srcG * dstG) / 255;
  1631. dstB = (srcB * dstB) / 255;
  1632. break;
  1633. }
  1634. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  1635. *dst = dstpixel;
  1636. ++src;
  1637. ++dst;
  1638. }
  1639. info->src += info->src_pitch;
  1640. info->dst += info->dst_pitch;
  1641. }
  1642. }
  1643. static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  1644. {
  1645. const int flags = info->flags;
  1646. Uint32 srcpixel;
  1647. Uint32 srcR, srcG, srcB;
  1648. Uint32 dstpixel;
  1649. Uint32 dstR, dstG, dstB;
  1650. int srcy, srcx;
  1651. int posy, posx;
  1652. int incy, incx;
  1653. srcy = 0;
  1654. posy = 0;
  1655. incy = (info->src_h << 16) / info->dst_h;
  1656. incx = (info->src_w << 16) / info->dst_w;
  1657. while (info->dst_h--) {
  1658. Uint32 *src = 0;
  1659. Uint32 *dst = (Uint32 *)info->dst;
  1660. int n = info->dst_w;
  1661. srcx = -1;
  1662. posx = 0x10000L;
  1663. while (posy >= 0x10000L) {
  1664. ++srcy;
  1665. posy -= 0x10000L;
  1666. }
  1667. while (n--) {
  1668. if (posx >= 0x10000L) {
  1669. while (posx >= 0x10000L) {
  1670. ++srcx;
  1671. posx -= 0x10000L;
  1672. }
  1673. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1674. }
  1675. srcpixel = *src;
  1676. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1677. dstpixel = *dst;
  1678. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  1679. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1680. case SDL_COPY_BLEND:
  1681. dstR = srcR;
  1682. dstG = srcG;
  1683. dstB = srcB;
  1684. break;
  1685. case SDL_COPY_ADD:
  1686. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1687. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1688. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1689. break;
  1690. case SDL_COPY_MOD:
  1691. dstR = (srcR * dstR) / 255;
  1692. dstG = (srcG * dstG) / 255;
  1693. dstB = (srcB * dstB) / 255;
  1694. break;
  1695. case SDL_COPY_MUL:
  1696. dstR = (srcR * dstR) / 255;
  1697. dstG = (srcG * dstG) / 255;
  1698. dstB = (srcB * dstB) / 255;
  1699. break;
  1700. }
  1701. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  1702. *dst = dstpixel;
  1703. posx += incx;
  1704. ++dst;
  1705. }
  1706. posy += incy;
  1707. info->dst += info->dst_pitch;
  1708. }
  1709. }
  1710. static void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
  1711. {
  1712. const int flags = info->flags;
  1713. const Uint32 modulateR = info->r;
  1714. const Uint32 modulateG = info->g;
  1715. const Uint32 modulateB = info->b;
  1716. Uint32 pixel;
  1717. Uint32 R, G, B;
  1718. while (info->dst_h--) {
  1719. Uint32 *src = (Uint32 *)info->src;
  1720. Uint32 *dst = (Uint32 *)info->dst;
  1721. int n = info->dst_w;
  1722. while (n--) {
  1723. pixel = *src;
  1724. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1725. if (flags & SDL_COPY_MODULATE_COLOR) {
  1726. R = (R * modulateR) / 255;
  1727. G = (G * modulateG) / 255;
  1728. B = (B * modulateB) / 255;
  1729. }
  1730. pixel = (B << 16) | (G << 8) | R;
  1731. *dst = pixel;
  1732. ++src;
  1733. ++dst;
  1734. }
  1735. info->src += info->src_pitch;
  1736. info->dst += info->dst_pitch;
  1737. }
  1738. }
  1739. static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  1740. {
  1741. const int flags = info->flags;
  1742. const Uint32 modulateR = info->r;
  1743. const Uint32 modulateG = info->g;
  1744. const Uint32 modulateB = info->b;
  1745. Uint32 pixel;
  1746. Uint32 R, G, B;
  1747. int srcy, srcx;
  1748. int posy, posx;
  1749. int incy, incx;
  1750. srcy = 0;
  1751. posy = 0;
  1752. incy = (info->src_h << 16) / info->dst_h;
  1753. incx = (info->src_w << 16) / info->dst_w;
  1754. while (info->dst_h--) {
  1755. Uint32 *src = 0;
  1756. Uint32 *dst = (Uint32 *)info->dst;
  1757. int n = info->dst_w;
  1758. srcx = -1;
  1759. posx = 0x10000L;
  1760. while (posy >= 0x10000L) {
  1761. ++srcy;
  1762. posy -= 0x10000L;
  1763. }
  1764. while (n--) {
  1765. if (posx >= 0x10000L) {
  1766. while (posx >= 0x10000L) {
  1767. ++srcx;
  1768. posx -= 0x10000L;
  1769. }
  1770. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1771. }
  1772. pixel = *src;
  1773. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1774. if (flags & SDL_COPY_MODULATE_COLOR) {
  1775. R = (R * modulateR) / 255;
  1776. G = (G * modulateG) / 255;
  1777. B = (B * modulateB) / 255;
  1778. }
  1779. pixel = (B << 16) | (G << 8) | R;
  1780. *dst = pixel;
  1781. posx += incx;
  1782. ++dst;
  1783. }
  1784. posy += incy;
  1785. info->dst += info->dst_pitch;
  1786. }
  1787. }
  1788. static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  1789. {
  1790. const int flags = info->flags;
  1791. const Uint32 modulateR = info->r;
  1792. const Uint32 modulateG = info->g;
  1793. const Uint32 modulateB = info->b;
  1794. const Uint32 modulateA = info->a;
  1795. Uint32 srcpixel;
  1796. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1797. Uint32 srcR, srcG, srcB;
  1798. Uint32 dstpixel;
  1799. Uint32 dstR, dstG, dstB;
  1800. while (info->dst_h--) {
  1801. Uint32 *src = (Uint32 *)info->src;
  1802. Uint32 *dst = (Uint32 *)info->dst;
  1803. int n = info->dst_w;
  1804. while (n--) {
  1805. srcpixel = *src;
  1806. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1807. dstpixel = *dst;
  1808. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  1809. if (flags & SDL_COPY_MODULATE_COLOR) {
  1810. srcR = (srcR * modulateR) / 255;
  1811. srcG = (srcG * modulateG) / 255;
  1812. srcB = (srcB * modulateB) / 255;
  1813. }
  1814. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1815. /* This goes away if we ever use premultiplied alpha */
  1816. if (srcA < 255) {
  1817. srcR = (srcR * srcA) / 255;
  1818. srcG = (srcG * srcA) / 255;
  1819. srcB = (srcB * srcA) / 255;
  1820. }
  1821. }
  1822. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1823. case SDL_COPY_BLEND:
  1824. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1825. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1826. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1827. break;
  1828. case SDL_COPY_ADD:
  1829. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1830. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1831. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1832. break;
  1833. case SDL_COPY_MOD:
  1834. dstR = (srcR * dstR) / 255;
  1835. dstG = (srcG * dstG) / 255;
  1836. dstB = (srcB * dstB) / 255;
  1837. break;
  1838. case SDL_COPY_MUL:
  1839. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  1840. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  1841. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  1842. break;
  1843. }
  1844. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  1845. *dst = dstpixel;
  1846. ++src;
  1847. ++dst;
  1848. }
  1849. info->src += info->src_pitch;
  1850. info->dst += info->dst_pitch;
  1851. }
  1852. }
  1853. static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1854. {
  1855. const int flags = info->flags;
  1856. const Uint32 modulateR = info->r;
  1857. const Uint32 modulateG = info->g;
  1858. const Uint32 modulateB = info->b;
  1859. const Uint32 modulateA = info->a;
  1860. Uint32 srcpixel;
  1861. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  1862. Uint32 srcR, srcG, srcB;
  1863. Uint32 dstpixel;
  1864. Uint32 dstR, dstG, dstB;
  1865. int srcy, srcx;
  1866. int posy, posx;
  1867. int incy, incx;
  1868. srcy = 0;
  1869. posy = 0;
  1870. incy = (info->src_h << 16) / info->dst_h;
  1871. incx = (info->src_w << 16) / info->dst_w;
  1872. while (info->dst_h--) {
  1873. Uint32 *src = 0;
  1874. Uint32 *dst = (Uint32 *)info->dst;
  1875. int n = info->dst_w;
  1876. srcx = -1;
  1877. posx = 0x10000L;
  1878. while (posy >= 0x10000L) {
  1879. ++srcy;
  1880. posy -= 0x10000L;
  1881. }
  1882. while (n--) {
  1883. if (posx >= 0x10000L) {
  1884. while (posx >= 0x10000L) {
  1885. ++srcx;
  1886. posx -= 0x10000L;
  1887. }
  1888. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1889. }
  1890. srcpixel = *src;
  1891. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1892. dstpixel = *dst;
  1893. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  1894. if (flags & SDL_COPY_MODULATE_COLOR) {
  1895. srcR = (srcR * modulateR) / 255;
  1896. srcG = (srcG * modulateG) / 255;
  1897. srcB = (srcB * modulateB) / 255;
  1898. }
  1899. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1900. /* This goes away if we ever use premultiplied alpha */
  1901. if (srcA < 255) {
  1902. srcR = (srcR * srcA) / 255;
  1903. srcG = (srcG * srcA) / 255;
  1904. srcB = (srcB * srcA) / 255;
  1905. }
  1906. }
  1907. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1908. case SDL_COPY_BLEND:
  1909. dstR = srcR + ((255 - srcA) * dstR) / 255;
  1910. dstG = srcG + ((255 - srcA) * dstG) / 255;
  1911. dstB = srcB + ((255 - srcA) * dstB) / 255;
  1912. break;
  1913. case SDL_COPY_ADD:
  1914. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1915. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1916. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1917. break;
  1918. case SDL_COPY_MOD:
  1919. dstR = (srcR * dstR) / 255;
  1920. dstG = (srcG * dstG) / 255;
  1921. dstB = (srcB * dstB) / 255;
  1922. break;
  1923. case SDL_COPY_MUL:
  1924. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  1925. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  1926. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  1927. break;
  1928. }
  1929. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  1930. *dst = dstpixel;
  1931. posx += incx;
  1932. ++dst;
  1933. }
  1934. posy += incy;
  1935. info->dst += info->dst_pitch;
  1936. }
  1937. }
  1938. static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info)
  1939. {
  1940. Uint32 pixel;
  1941. const Uint32 A = 0xFF;
  1942. Uint32 R, G, B;
  1943. int srcy, srcx;
  1944. int posy, posx;
  1945. int incy, incx;
  1946. srcy = 0;
  1947. posy = 0;
  1948. incy = (info->src_h << 16) / info->dst_h;
  1949. incx = (info->src_w << 16) / info->dst_w;
  1950. while (info->dst_h--) {
  1951. Uint32 *src = 0;
  1952. Uint32 *dst = (Uint32 *)info->dst;
  1953. int n = info->dst_w;
  1954. srcx = -1;
  1955. posx = 0x10000L;
  1956. while (posy >= 0x10000L) {
  1957. ++srcy;
  1958. posy -= 0x10000L;
  1959. }
  1960. while (n--) {
  1961. if (posx >= 0x10000L) {
  1962. while (posx >= 0x10000L) {
  1963. ++srcx;
  1964. posx -= 0x10000L;
  1965. }
  1966. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1967. }
  1968. pixel = *src;
  1969. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1970. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  1971. *dst = pixel;
  1972. posx += incx;
  1973. ++dst;
  1974. }
  1975. posy += incy;
  1976. info->dst += info->dst_pitch;
  1977. }
  1978. }
  1979. static void SDL_Blit_BGR888_ARGB8888_Blend(SDL_BlitInfo *info)
  1980. {
  1981. const int flags = info->flags;
  1982. Uint32 srcpixel;
  1983. Uint32 srcR, srcG, srcB;
  1984. Uint32 dstpixel;
  1985. Uint32 dstR, dstG, dstB, dstA;
  1986. while (info->dst_h--) {
  1987. Uint32 *src = (Uint32 *)info->src;
  1988. Uint32 *dst = (Uint32 *)info->dst;
  1989. int n = info->dst_w;
  1990. while (n--) {
  1991. srcpixel = *src;
  1992. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1993. dstpixel = *dst;
  1994. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  1995. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  1996. case SDL_COPY_BLEND:
  1997. dstR = srcR;
  1998. dstG = srcG;
  1999. dstB = srcB;
  2000. dstA = 0xFF;
  2001. break;
  2002. case SDL_COPY_ADD:
  2003. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2004. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2005. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2006. break;
  2007. case SDL_COPY_MOD:
  2008. dstR = (srcR * dstR) / 255;
  2009. dstG = (srcG * dstG) / 255;
  2010. dstB = (srcB * dstB) / 255;
  2011. break;
  2012. case SDL_COPY_MUL:
  2013. dstR = (srcR * dstR) / 255;
  2014. dstG = (srcG * dstG) / 255;
  2015. dstB = (srcB * dstB) / 255;
  2016. dstA = 0xFF;
  2017. break;
  2018. }
  2019. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2020. *dst = dstpixel;
  2021. ++src;
  2022. ++dst;
  2023. }
  2024. info->src += info->src_pitch;
  2025. info->dst += info->dst_pitch;
  2026. }
  2027. }
  2028. static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  2029. {
  2030. const int flags = info->flags;
  2031. Uint32 srcpixel;
  2032. Uint32 srcR, srcG, srcB;
  2033. Uint32 dstpixel;
  2034. Uint32 dstR, dstG, dstB, dstA;
  2035. int srcy, srcx;
  2036. int posy, posx;
  2037. int incy, incx;
  2038. srcy = 0;
  2039. posy = 0;
  2040. incy = (info->src_h << 16) / info->dst_h;
  2041. incx = (info->src_w << 16) / info->dst_w;
  2042. while (info->dst_h--) {
  2043. Uint32 *src = 0;
  2044. Uint32 *dst = (Uint32 *)info->dst;
  2045. int n = info->dst_w;
  2046. srcx = -1;
  2047. posx = 0x10000L;
  2048. while (posy >= 0x10000L) {
  2049. ++srcy;
  2050. posy -= 0x10000L;
  2051. }
  2052. while (n--) {
  2053. if (posx >= 0x10000L) {
  2054. while (posx >= 0x10000L) {
  2055. ++srcx;
  2056. posx -= 0x10000L;
  2057. }
  2058. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2059. }
  2060. srcpixel = *src;
  2061. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2062. dstpixel = *dst;
  2063. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2064. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2065. case SDL_COPY_BLEND:
  2066. dstR = srcR;
  2067. dstG = srcG;
  2068. dstB = srcB;
  2069. dstA = 0xFF;
  2070. break;
  2071. case SDL_COPY_ADD:
  2072. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2073. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2074. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2075. break;
  2076. case SDL_COPY_MOD:
  2077. dstR = (srcR * dstR) / 255;
  2078. dstG = (srcG * dstG) / 255;
  2079. dstB = (srcB * dstB) / 255;
  2080. break;
  2081. case SDL_COPY_MUL:
  2082. dstR = (srcR * dstR) / 255;
  2083. dstG = (srcG * dstG) / 255;
  2084. dstB = (srcB * dstB) / 255;
  2085. dstA = 0xFF;
  2086. break;
  2087. }
  2088. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2089. *dst = dstpixel;
  2090. posx += incx;
  2091. ++dst;
  2092. }
  2093. posy += incy;
  2094. info->dst += info->dst_pitch;
  2095. }
  2096. }
  2097. static void SDL_Blit_BGR888_ARGB8888_Modulate(SDL_BlitInfo *info)
  2098. {
  2099. const int flags = info->flags;
  2100. const Uint32 modulateR = info->r;
  2101. const Uint32 modulateG = info->g;
  2102. const Uint32 modulateB = info->b;
  2103. const Uint32 modulateA = info->a;
  2104. Uint32 pixel;
  2105. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2106. Uint32 R, G, B;
  2107. while (info->dst_h--) {
  2108. Uint32 *src = (Uint32 *)info->src;
  2109. Uint32 *dst = (Uint32 *)info->dst;
  2110. int n = info->dst_w;
  2111. while (n--) {
  2112. pixel = *src;
  2113. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2114. if (flags & SDL_COPY_MODULATE_COLOR) {
  2115. R = (R * modulateR) / 255;
  2116. G = (G * modulateG) / 255;
  2117. B = (B * modulateB) / 255;
  2118. }
  2119. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  2120. *dst = pixel;
  2121. ++src;
  2122. ++dst;
  2123. }
  2124. info->src += info->src_pitch;
  2125. info->dst += info->dst_pitch;
  2126. }
  2127. }
  2128. static void SDL_Blit_BGR888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  2129. {
  2130. const int flags = info->flags;
  2131. const Uint32 modulateR = info->r;
  2132. const Uint32 modulateG = info->g;
  2133. const Uint32 modulateB = info->b;
  2134. const Uint32 modulateA = info->a;
  2135. Uint32 pixel;
  2136. const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2137. Uint32 R, G, B;
  2138. int srcy, srcx;
  2139. int posy, posx;
  2140. int incy, incx;
  2141. srcy = 0;
  2142. posy = 0;
  2143. incy = (info->src_h << 16) / info->dst_h;
  2144. incx = (info->src_w << 16) / info->dst_w;
  2145. while (info->dst_h--) {
  2146. Uint32 *src = 0;
  2147. Uint32 *dst = (Uint32 *)info->dst;
  2148. int n = info->dst_w;
  2149. srcx = -1;
  2150. posx = 0x10000L;
  2151. while (posy >= 0x10000L) {
  2152. ++srcy;
  2153. posy -= 0x10000L;
  2154. }
  2155. while (n--) {
  2156. if (posx >= 0x10000L) {
  2157. while (posx >= 0x10000L) {
  2158. ++srcx;
  2159. posx -= 0x10000L;
  2160. }
  2161. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2162. }
  2163. pixel = *src;
  2164. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  2165. if (flags & SDL_COPY_MODULATE_COLOR) {
  2166. R = (R * modulateR) / 255;
  2167. G = (G * modulateG) / 255;
  2168. B = (B * modulateB) / 255;
  2169. }
  2170. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  2171. *dst = pixel;
  2172. posx += incx;
  2173. ++dst;
  2174. }
  2175. posy += incy;
  2176. info->dst += info->dst_pitch;
  2177. }
  2178. }
  2179. static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  2180. {
  2181. const int flags = info->flags;
  2182. const Uint32 modulateR = info->r;
  2183. const Uint32 modulateG = info->g;
  2184. const Uint32 modulateB = info->b;
  2185. const Uint32 modulateA = info->a;
  2186. Uint32 srcpixel;
  2187. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2188. Uint32 srcR, srcG, srcB;
  2189. Uint32 dstpixel;
  2190. Uint32 dstR, dstG, dstB, dstA;
  2191. while (info->dst_h--) {
  2192. Uint32 *src = (Uint32 *)info->src;
  2193. Uint32 *dst = (Uint32 *)info->dst;
  2194. int n = info->dst_w;
  2195. while (n--) {
  2196. srcpixel = *src;
  2197. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2198. dstpixel = *dst;
  2199. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2200. if (flags & SDL_COPY_MODULATE_COLOR) {
  2201. srcR = (srcR * modulateR) / 255;
  2202. srcG = (srcG * modulateG) / 255;
  2203. srcB = (srcB * modulateB) / 255;
  2204. }
  2205. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2206. /* This goes away if we ever use premultiplied alpha */
  2207. if (srcA < 255) {
  2208. srcR = (srcR * srcA) / 255;
  2209. srcG = (srcG * srcA) / 255;
  2210. srcB = (srcB * srcA) / 255;
  2211. }
  2212. }
  2213. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2214. case SDL_COPY_BLEND:
  2215. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2216. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2217. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2218. dstA = srcA + ((255 - srcA) * dstA) / 255;
  2219. break;
  2220. case SDL_COPY_ADD:
  2221. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2222. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2223. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2224. break;
  2225. case SDL_COPY_MOD:
  2226. dstR = (srcR * dstR) / 255;
  2227. dstG = (srcG * dstG) / 255;
  2228. dstB = (srcB * dstB) / 255;
  2229. break;
  2230. case SDL_COPY_MUL:
  2231. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  2232. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  2233. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  2234. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  2235. break;
  2236. }
  2237. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2238. *dst = dstpixel;
  2239. ++src;
  2240. ++dst;
  2241. }
  2242. info->src += info->src_pitch;
  2243. info->dst += info->dst_pitch;
  2244. }
  2245. }
  2246. static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  2247. {
  2248. const int flags = info->flags;
  2249. const Uint32 modulateR = info->r;
  2250. const Uint32 modulateG = info->g;
  2251. const Uint32 modulateB = info->b;
  2252. const Uint32 modulateA = info->a;
  2253. Uint32 srcpixel;
  2254. const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
  2255. Uint32 srcR, srcG, srcB;
  2256. Uint32 dstpixel;
  2257. Uint32 dstR, dstG, dstB, dstA;
  2258. int srcy, srcx;
  2259. int posy, posx;
  2260. int incy, incx;
  2261. srcy = 0;
  2262. posy = 0;
  2263. incy = (info->src_h << 16) / info->dst_h;
  2264. incx = (info->src_w << 16) / info->dst_w;
  2265. while (info->dst_h--) {
  2266. Uint32 *src = 0;
  2267. Uint32 *dst = (Uint32 *)info->dst;
  2268. int n = info->dst_w;
  2269. srcx = -1;
  2270. posx = 0x10000L;
  2271. while (posy >= 0x10000L) {
  2272. ++srcy;
  2273. posy -= 0x10000L;
  2274. }
  2275. while (n--) {
  2276. if (posx >= 0x10000L) {
  2277. while (posx >= 0x10000L) {
  2278. ++srcx;
  2279. posx -= 0x10000L;
  2280. }
  2281. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2282. }
  2283. srcpixel = *src;
  2284. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  2285. dstpixel = *dst;
  2286. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  2287. if (flags & SDL_COPY_MODULATE_COLOR) {
  2288. srcR = (srcR * modulateR) / 255;
  2289. srcG = (srcG * modulateG) / 255;
  2290. srcB = (srcB * modulateB) / 255;
  2291. }
  2292. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2293. /* This goes away if we ever use premultiplied alpha */
  2294. if (srcA < 255) {
  2295. srcR = (srcR * srcA) / 255;
  2296. srcG = (srcG * srcA) / 255;
  2297. srcB = (srcB * srcA) / 255;
  2298. }
  2299. }
  2300. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2301. case SDL_COPY_BLEND:
  2302. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2303. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2304. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2305. dstA = srcA + ((255 - srcA) * dstA) / 255;
  2306. break;
  2307. case SDL_COPY_ADD:
  2308. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2309. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2310. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2311. break;
  2312. case SDL_COPY_MOD:
  2313. dstR = (srcR * dstR) / 255;
  2314. dstG = (srcG * dstG) / 255;
  2315. dstB = (srcB * dstB) / 255;
  2316. break;
  2317. case SDL_COPY_MUL:
  2318. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  2319. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  2320. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  2321. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  2322. break;
  2323. }
  2324. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  2325. *dst = dstpixel;
  2326. posx += incx;
  2327. ++dst;
  2328. }
  2329. posy += incy;
  2330. info->dst += info->dst_pitch;
  2331. }
  2332. }
  2333. static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
  2334. {
  2335. Uint32 pixel;
  2336. Uint32 R, G, B;
  2337. int srcy, srcx;
  2338. int posy, posx;
  2339. int incy, incx;
  2340. srcy = 0;
  2341. posy = 0;
  2342. incy = (info->src_h << 16) / info->dst_h;
  2343. incx = (info->src_w << 16) / info->dst_w;
  2344. while (info->dst_h--) {
  2345. Uint32 *src = 0;
  2346. Uint32 *dst = (Uint32 *)info->dst;
  2347. int n = info->dst_w;
  2348. srcx = -1;
  2349. posx = 0x10000L;
  2350. while (posy >= 0x10000L) {
  2351. ++srcy;
  2352. posy -= 0x10000L;
  2353. }
  2354. while (n--) {
  2355. if (posx >= 0x10000L) {
  2356. while (posx >= 0x10000L) {
  2357. ++srcx;
  2358. posx -= 0x10000L;
  2359. }
  2360. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2361. }
  2362. pixel = *src;
  2363. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2364. pixel = (R << 16) | (G << 8) | B;
  2365. *dst = pixel;
  2366. posx += incx;
  2367. ++dst;
  2368. }
  2369. posy += incy;
  2370. info->dst += info->dst_pitch;
  2371. }
  2372. }
  2373. static void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
  2374. {
  2375. const int flags = info->flags;
  2376. Uint32 srcpixel;
  2377. Uint32 srcR, srcG, srcB, srcA;
  2378. Uint32 dstpixel;
  2379. Uint32 dstR, dstG, dstB;
  2380. while (info->dst_h--) {
  2381. Uint32 *src = (Uint32 *)info->src;
  2382. Uint32 *dst = (Uint32 *)info->dst;
  2383. int n = info->dst_w;
  2384. while (n--) {
  2385. srcpixel = *src;
  2386. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  2387. dstpixel = *dst;
  2388. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  2389. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2390. /* This goes away if we ever use premultiplied alpha */
  2391. if (srcA < 255) {
  2392. srcR = (srcR * srcA) / 255;
  2393. srcG = (srcG * srcA) / 255;
  2394. srcB = (srcB * srcA) / 255;
  2395. }
  2396. }
  2397. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2398. case SDL_COPY_BLEND:
  2399. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2400. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2401. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2402. break;
  2403. case SDL_COPY_ADD:
  2404. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2405. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2406. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2407. break;
  2408. case SDL_COPY_MOD:
  2409. dstR = (srcR * dstR) / 255;
  2410. dstG = (srcG * dstG) / 255;
  2411. dstB = (srcB * dstB) / 255;
  2412. break;
  2413. case SDL_COPY_MUL:
  2414. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  2415. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  2416. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  2417. break;
  2418. }
  2419. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  2420. *dst = dstpixel;
  2421. ++src;
  2422. ++dst;
  2423. }
  2424. info->src += info->src_pitch;
  2425. info->dst += info->dst_pitch;
  2426. }
  2427. }
  2428. static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  2429. {
  2430. const int flags = info->flags;
  2431. Uint32 srcpixel;
  2432. Uint32 srcR, srcG, srcB, srcA;
  2433. Uint32 dstpixel;
  2434. Uint32 dstR, dstG, dstB;
  2435. int srcy, srcx;
  2436. int posy, posx;
  2437. int incy, incx;
  2438. srcy = 0;
  2439. posy = 0;
  2440. incy = (info->src_h << 16) / info->dst_h;
  2441. incx = (info->src_w << 16) / info->dst_w;
  2442. while (info->dst_h--) {
  2443. Uint32 *src = 0;
  2444. Uint32 *dst = (Uint32 *)info->dst;
  2445. int n = info->dst_w;
  2446. srcx = -1;
  2447. posx = 0x10000L;
  2448. while (posy >= 0x10000L) {
  2449. ++srcy;
  2450. posy -= 0x10000L;
  2451. }
  2452. while (n--) {
  2453. if (posx >= 0x10000L) {
  2454. while (posx >= 0x10000L) {
  2455. ++srcx;
  2456. posx -= 0x10000L;
  2457. }
  2458. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2459. }
  2460. srcpixel = *src;
  2461. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  2462. dstpixel = *dst;
  2463. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  2464. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2465. /* This goes away if we ever use premultiplied alpha */
  2466. if (srcA < 255) {
  2467. srcR = (srcR * srcA) / 255;
  2468. srcG = (srcG * srcA) / 255;
  2469. srcB = (srcB * srcA) / 255;
  2470. }
  2471. }
  2472. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2473. case SDL_COPY_BLEND:
  2474. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2475. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2476. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2477. break;
  2478. case SDL_COPY_ADD:
  2479. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2480. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2481. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2482. break;
  2483. case SDL_COPY_MOD:
  2484. dstR = (srcR * dstR) / 255;
  2485. dstG = (srcG * dstG) / 255;
  2486. dstB = (srcB * dstB) / 255;
  2487. break;
  2488. case SDL_COPY_MUL:
  2489. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  2490. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  2491. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  2492. break;
  2493. }
  2494. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  2495. *dst = dstpixel;
  2496. posx += incx;
  2497. ++dst;
  2498. }
  2499. posy += incy;
  2500. info->dst += info->dst_pitch;
  2501. }
  2502. }
  2503. static void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
  2504. {
  2505. const int flags = info->flags;
  2506. const Uint32 modulateR = info->r;
  2507. const Uint32 modulateG = info->g;
  2508. const Uint32 modulateB = info->b;
  2509. Uint32 pixel;
  2510. Uint32 R, G, B;
  2511. while (info->dst_h--) {
  2512. Uint32 *src = (Uint32 *)info->src;
  2513. Uint32 *dst = (Uint32 *)info->dst;
  2514. int n = info->dst_w;
  2515. while (n--) {
  2516. pixel = *src;
  2517. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2518. if (flags & SDL_COPY_MODULATE_COLOR) {
  2519. R = (R * modulateR) / 255;
  2520. G = (G * modulateG) / 255;
  2521. B = (B * modulateB) / 255;
  2522. }
  2523. pixel = (R << 16) | (G << 8) | B;
  2524. *dst = pixel;
  2525. ++src;
  2526. ++dst;
  2527. }
  2528. info->src += info->src_pitch;
  2529. info->dst += info->dst_pitch;
  2530. }
  2531. }
  2532. static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  2533. {
  2534. const int flags = info->flags;
  2535. const Uint32 modulateR = info->r;
  2536. const Uint32 modulateG = info->g;
  2537. const Uint32 modulateB = info->b;
  2538. Uint32 pixel;
  2539. Uint32 R, G, B;
  2540. int srcy, srcx;
  2541. int posy, posx;
  2542. int incy, incx;
  2543. srcy = 0;
  2544. posy = 0;
  2545. incy = (info->src_h << 16) / info->dst_h;
  2546. incx = (info->src_w << 16) / info->dst_w;
  2547. while (info->dst_h--) {
  2548. Uint32 *src = 0;
  2549. Uint32 *dst = (Uint32 *)info->dst;
  2550. int n = info->dst_w;
  2551. srcx = -1;
  2552. posx = 0x10000L;
  2553. while (posy >= 0x10000L) {
  2554. ++srcy;
  2555. posy -= 0x10000L;
  2556. }
  2557. while (n--) {
  2558. if (posx >= 0x10000L) {
  2559. while (posx >= 0x10000L) {
  2560. ++srcx;
  2561. posx -= 0x10000L;
  2562. }
  2563. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2564. }
  2565. pixel = *src;
  2566. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2567. if (flags & SDL_COPY_MODULATE_COLOR) {
  2568. R = (R * modulateR) / 255;
  2569. G = (G * modulateG) / 255;
  2570. B = (B * modulateB) / 255;
  2571. }
  2572. pixel = (R << 16) | (G << 8) | B;
  2573. *dst = pixel;
  2574. posx += incx;
  2575. ++dst;
  2576. }
  2577. posy += incy;
  2578. info->dst += info->dst_pitch;
  2579. }
  2580. }
  2581. static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  2582. {
  2583. const int flags = info->flags;
  2584. const Uint32 modulateR = info->r;
  2585. const Uint32 modulateG = info->g;
  2586. const Uint32 modulateB = info->b;
  2587. const Uint32 modulateA = info->a;
  2588. Uint32 srcpixel;
  2589. Uint32 srcR, srcG, srcB, srcA;
  2590. Uint32 dstpixel;
  2591. Uint32 dstR, dstG, dstB;
  2592. while (info->dst_h--) {
  2593. Uint32 *src = (Uint32 *)info->src;
  2594. Uint32 *dst = (Uint32 *)info->dst;
  2595. int n = info->dst_w;
  2596. while (n--) {
  2597. srcpixel = *src;
  2598. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  2599. dstpixel = *dst;
  2600. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  2601. if (flags & SDL_COPY_MODULATE_COLOR) {
  2602. srcR = (srcR * modulateR) / 255;
  2603. srcG = (srcG * modulateG) / 255;
  2604. srcB = (srcB * modulateB) / 255;
  2605. }
  2606. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2607. srcA = (srcA * modulateA) / 255;
  2608. }
  2609. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2610. /* This goes away if we ever use premultiplied alpha */
  2611. if (srcA < 255) {
  2612. srcR = (srcR * srcA) / 255;
  2613. srcG = (srcG * srcA) / 255;
  2614. srcB = (srcB * srcA) / 255;
  2615. }
  2616. }
  2617. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2618. case SDL_COPY_BLEND:
  2619. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2620. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2621. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2622. break;
  2623. case SDL_COPY_ADD:
  2624. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2625. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2626. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2627. break;
  2628. case SDL_COPY_MOD:
  2629. dstR = (srcR * dstR) / 255;
  2630. dstG = (srcG * dstG) / 255;
  2631. dstB = (srcB * dstB) / 255;
  2632. break;
  2633. case SDL_COPY_MUL:
  2634. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  2635. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  2636. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  2637. break;
  2638. }
  2639. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  2640. *dst = dstpixel;
  2641. ++src;
  2642. ++dst;
  2643. }
  2644. info->src += info->src_pitch;
  2645. info->dst += info->dst_pitch;
  2646. }
  2647. }
  2648. static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  2649. {
  2650. const int flags = info->flags;
  2651. const Uint32 modulateR = info->r;
  2652. const Uint32 modulateG = info->g;
  2653. const Uint32 modulateB = info->b;
  2654. const Uint32 modulateA = info->a;
  2655. Uint32 srcpixel;
  2656. Uint32 srcR, srcG, srcB, srcA;
  2657. Uint32 dstpixel;
  2658. Uint32 dstR, dstG, dstB;
  2659. int srcy, srcx;
  2660. int posy, posx;
  2661. int incy, incx;
  2662. srcy = 0;
  2663. posy = 0;
  2664. incy = (info->src_h << 16) / info->dst_h;
  2665. incx = (info->src_w << 16) / info->dst_w;
  2666. while (info->dst_h--) {
  2667. Uint32 *src = 0;
  2668. Uint32 *dst = (Uint32 *)info->dst;
  2669. int n = info->dst_w;
  2670. srcx = -1;
  2671. posx = 0x10000L;
  2672. while (posy >= 0x10000L) {
  2673. ++srcy;
  2674. posy -= 0x10000L;
  2675. }
  2676. while (n--) {
  2677. if (posx >= 0x10000L) {
  2678. while (posx >= 0x10000L) {
  2679. ++srcx;
  2680. posx -= 0x10000L;
  2681. }
  2682. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2683. }
  2684. srcpixel = *src;
  2685. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  2686. dstpixel = *dst;
  2687. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  2688. if (flags & SDL_COPY_MODULATE_COLOR) {
  2689. srcR = (srcR * modulateR) / 255;
  2690. srcG = (srcG * modulateG) / 255;
  2691. srcB = (srcB * modulateB) / 255;
  2692. }
  2693. if (flags & SDL_COPY_MODULATE_ALPHA) {
  2694. srcA = (srcA * modulateA) / 255;
  2695. }
  2696. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2697. /* This goes away if we ever use premultiplied alpha */
  2698. if (srcA < 255) {
  2699. srcR = (srcR * srcA) / 255;
  2700. srcG = (srcG * srcA) / 255;
  2701. srcB = (srcB * srcA) / 255;
  2702. }
  2703. }
  2704. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2705. case SDL_COPY_BLEND:
  2706. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2707. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2708. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2709. break;
  2710. case SDL_COPY_ADD:
  2711. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2712. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2713. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2714. break;
  2715. case SDL_COPY_MOD:
  2716. dstR = (srcR * dstR) / 255;
  2717. dstG = (srcG * dstG) / 255;
  2718. dstB = (srcB * dstB) / 255;
  2719. break;
  2720. case SDL_COPY_MUL:
  2721. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  2722. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  2723. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  2724. break;
  2725. }
  2726. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  2727. *dst = dstpixel;
  2728. posx += incx;
  2729. ++dst;
  2730. }
  2731. posy += incy;
  2732. info->dst += info->dst_pitch;
  2733. }
  2734. }
  2735. static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
  2736. {
  2737. Uint32 pixel;
  2738. Uint32 R, G, B;
  2739. int srcy, srcx;
  2740. int posy, posx;
  2741. int incy, incx;
  2742. srcy = 0;
  2743. posy = 0;
  2744. incy = (info->src_h << 16) / info->dst_h;
  2745. incx = (info->src_w << 16) / info->dst_w;
  2746. while (info->dst_h--) {
  2747. Uint32 *src = 0;
  2748. Uint32 *dst = (Uint32 *)info->dst;
  2749. int n = info->dst_w;
  2750. srcx = -1;
  2751. posx = 0x10000L;
  2752. while (posy >= 0x10000L) {
  2753. ++srcy;
  2754. posy -= 0x10000L;
  2755. }
  2756. while (n--) {
  2757. if (posx >= 0x10000L) {
  2758. while (posx >= 0x10000L) {
  2759. ++srcx;
  2760. posx -= 0x10000L;
  2761. }
  2762. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2763. }
  2764. pixel = *src;
  2765. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2766. pixel = (B << 16) | (G << 8) | R;
  2767. *dst = pixel;
  2768. posx += incx;
  2769. ++dst;
  2770. }
  2771. posy += incy;
  2772. info->dst += info->dst_pitch;
  2773. }
  2774. }
  2775. static void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
  2776. {
  2777. const int flags = info->flags;
  2778. Uint32 srcpixel;
  2779. Uint32 srcR, srcG, srcB, srcA;
  2780. Uint32 dstpixel;
  2781. Uint32 dstR, dstG, dstB;
  2782. while (info->dst_h--) {
  2783. Uint32 *src = (Uint32 *)info->src;
  2784. Uint32 *dst = (Uint32 *)info->dst;
  2785. int n = info->dst_w;
  2786. while (n--) {
  2787. srcpixel = *src;
  2788. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  2789. dstpixel = *dst;
  2790. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2791. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2792. /* This goes away if we ever use premultiplied alpha */
  2793. if (srcA < 255) {
  2794. srcR = (srcR * srcA) / 255;
  2795. srcG = (srcG * srcA) / 255;
  2796. srcB = (srcB * srcA) / 255;
  2797. }
  2798. }
  2799. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2800. case SDL_COPY_BLEND:
  2801. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2802. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2803. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2804. break;
  2805. case SDL_COPY_ADD:
  2806. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2807. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2808. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2809. break;
  2810. case SDL_COPY_MOD:
  2811. dstR = (srcR * dstR) / 255;
  2812. dstG = (srcG * dstG) / 255;
  2813. dstB = (srcB * dstB) / 255;
  2814. break;
  2815. case SDL_COPY_MUL:
  2816. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  2817. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  2818. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  2819. break;
  2820. }
  2821. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2822. *dst = dstpixel;
  2823. ++src;
  2824. ++dst;
  2825. }
  2826. info->src += info->src_pitch;
  2827. info->dst += info->dst_pitch;
  2828. }
  2829. }
  2830. static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  2831. {
  2832. const int flags = info->flags;
  2833. Uint32 srcpixel;
  2834. Uint32 srcR, srcG, srcB, srcA;
  2835. Uint32 dstpixel;
  2836. Uint32 dstR, dstG, dstB;
  2837. int srcy, srcx;
  2838. int posy, posx;
  2839. int incy, incx;
  2840. srcy = 0;
  2841. posy = 0;
  2842. incy = (info->src_h << 16) / info->dst_h;
  2843. incx = (info->src_w << 16) / info->dst_w;
  2844. while (info->dst_h--) {
  2845. Uint32 *src = 0;
  2846. Uint32 *dst = (Uint32 *)info->dst;
  2847. int n = info->dst_w;
  2848. srcx = -1;
  2849. posx = 0x10000L;
  2850. while (posy >= 0x10000L) {
  2851. ++srcy;
  2852. posy -= 0x10000L;
  2853. }
  2854. while (n--) {
  2855. if (posx >= 0x10000L) {
  2856. while (posx >= 0x10000L) {
  2857. ++srcx;
  2858. posx -= 0x10000L;
  2859. }
  2860. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2861. }
  2862. srcpixel = *src;
  2863. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  2864. dstpixel = *dst;
  2865. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  2866. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  2867. /* This goes away if we ever use premultiplied alpha */
  2868. if (srcA < 255) {
  2869. srcR = (srcR * srcA) / 255;
  2870. srcG = (srcG * srcA) / 255;
  2871. srcB = (srcB * srcA) / 255;
  2872. }
  2873. }
  2874. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  2875. case SDL_COPY_BLEND:
  2876. dstR = srcR + ((255 - srcA) * dstR) / 255;
  2877. dstG = srcG + ((255 - srcA) * dstG) / 255;
  2878. dstB = srcB + ((255 - srcA) * dstB) / 255;
  2879. break;
  2880. case SDL_COPY_ADD:
  2881. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  2882. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  2883. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  2884. break;
  2885. case SDL_COPY_MOD:
  2886. dstR = (srcR * dstR) / 255;
  2887. dstG = (srcG * dstG) / 255;
  2888. dstB = (srcB * dstB) / 255;
  2889. break;
  2890. case SDL_COPY_MUL:
  2891. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  2892. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  2893. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  2894. break;
  2895. }
  2896. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  2897. *dst = dstpixel;
  2898. posx += incx;
  2899. ++dst;
  2900. }
  2901. posy += incy;
  2902. info->dst += info->dst_pitch;
  2903. }
  2904. }
  2905. static void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
  2906. {
  2907. const int flags = info->flags;
  2908. const Uint32 modulateR = info->r;
  2909. const Uint32 modulateG = info->g;
  2910. const Uint32 modulateB = info->b;
  2911. Uint32 pixel;
  2912. Uint32 R, G, B;
  2913. while (info->dst_h--) {
  2914. Uint32 *src = (Uint32 *)info->src;
  2915. Uint32 *dst = (Uint32 *)info->dst;
  2916. int n = info->dst_w;
  2917. while (n--) {
  2918. pixel = *src;
  2919. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2920. if (flags & SDL_COPY_MODULATE_COLOR) {
  2921. R = (R * modulateR) / 255;
  2922. G = (G * modulateG) / 255;
  2923. B = (B * modulateB) / 255;
  2924. }
  2925. pixel = (B << 16) | (G << 8) | R;
  2926. *dst = pixel;
  2927. ++src;
  2928. ++dst;
  2929. }
  2930. info->src += info->src_pitch;
  2931. info->dst += info->dst_pitch;
  2932. }
  2933. }
  2934. static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  2935. {
  2936. const int flags = info->flags;
  2937. const Uint32 modulateR = info->r;
  2938. const Uint32 modulateG = info->g;
  2939. const Uint32 modulateB = info->b;
  2940. Uint32 pixel;
  2941. Uint32 R, G, B;
  2942. int srcy, srcx;
  2943. int posy, posx;
  2944. int incy, incx;
  2945. srcy = 0;
  2946. posy = 0;
  2947. incy = (info->src_h << 16) / info->dst_h;
  2948. incx = (info->src_w << 16) / info->dst_w;
  2949. while (info->dst_h--) {
  2950. Uint32 *src = 0;
  2951. Uint32 *dst = (Uint32 *)info->dst;
  2952. int n = info->dst_w;
  2953. srcx = -1;
  2954. posx = 0x10000L;
  2955. while (posy >= 0x10000L) {
  2956. ++srcy;
  2957. posy -= 0x10000L;
  2958. }
  2959. while (n--) {
  2960. if (posx >= 0x10000L) {
  2961. while (posx >= 0x10000L) {
  2962. ++srcx;
  2963. posx -= 0x10000L;
  2964. }
  2965. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  2966. }
  2967. pixel = *src;
  2968. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  2969. if (flags & SDL_COPY_MODULATE_COLOR) {
  2970. R = (R * modulateR) / 255;
  2971. G = (G * modulateG) / 255;
  2972. B = (B * modulateB) / 255;
  2973. }
  2974. pixel = (B << 16) | (G << 8) | R;
  2975. *dst = pixel;
  2976. posx += incx;
  2977. ++dst;
  2978. }
  2979. posy += incy;
  2980. info->dst += info->dst_pitch;
  2981. }
  2982. }
  2983. static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  2984. {
  2985. const int flags = info->flags;
  2986. const Uint32 modulateR = info->r;
  2987. const Uint32 modulateG = info->g;
  2988. const Uint32 modulateB = info->b;
  2989. const Uint32 modulateA = info->a;
  2990. Uint32 srcpixel;
  2991. Uint32 srcR, srcG, srcB, srcA;
  2992. Uint32 dstpixel;
  2993. Uint32 dstR, dstG, dstB;
  2994. while (info->dst_h--) {
  2995. Uint32 *src = (Uint32 *)info->src;
  2996. Uint32 *dst = (Uint32 *)info->dst;
  2997. int n = info->dst_w;
  2998. while (n--) {
  2999. srcpixel = *src;
  3000. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3001. dstpixel = *dst;
  3002. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  3003. if (flags & SDL_COPY_MODULATE_COLOR) {
  3004. srcR = (srcR * modulateR) / 255;
  3005. srcG = (srcG * modulateG) / 255;
  3006. srcB = (srcB * modulateB) / 255;
  3007. }
  3008. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3009. srcA = (srcA * modulateA) / 255;
  3010. }
  3011. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3012. /* This goes away if we ever use premultiplied alpha */
  3013. if (srcA < 255) {
  3014. srcR = (srcR * srcA) / 255;
  3015. srcG = (srcG * srcA) / 255;
  3016. srcB = (srcB * srcA) / 255;
  3017. }
  3018. }
  3019. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3020. case SDL_COPY_BLEND:
  3021. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3022. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3023. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3024. break;
  3025. case SDL_COPY_ADD:
  3026. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3027. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3028. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3029. break;
  3030. case SDL_COPY_MOD:
  3031. dstR = (srcR * dstR) / 255;
  3032. dstG = (srcG * dstG) / 255;
  3033. dstB = (srcB * dstB) / 255;
  3034. break;
  3035. case SDL_COPY_MUL:
  3036. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3037. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3038. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3039. break;
  3040. }
  3041. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  3042. *dst = dstpixel;
  3043. ++src;
  3044. ++dst;
  3045. }
  3046. info->src += info->src_pitch;
  3047. info->dst += info->dst_pitch;
  3048. }
  3049. }
  3050. static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_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 srcpixel;
  3058. Uint32 srcR, srcG, srcB, srcA;
  3059. Uint32 dstpixel;
  3060. Uint32 dstR, dstG, dstB;
  3061. int srcy, srcx;
  3062. int posy, posx;
  3063. int incy, incx;
  3064. srcy = 0;
  3065. posy = 0;
  3066. incy = (info->src_h << 16) / info->dst_h;
  3067. incx = (info->src_w << 16) / info->dst_w;
  3068. while (info->dst_h--) {
  3069. Uint32 *src = 0;
  3070. Uint32 *dst = (Uint32 *)info->dst;
  3071. int n = info->dst_w;
  3072. srcx = -1;
  3073. posx = 0x10000L;
  3074. while (posy >= 0x10000L) {
  3075. ++srcy;
  3076. posy -= 0x10000L;
  3077. }
  3078. while (n--) {
  3079. if (posx >= 0x10000L) {
  3080. while (posx >= 0x10000L) {
  3081. ++srcx;
  3082. posx -= 0x10000L;
  3083. }
  3084. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3085. }
  3086. srcpixel = *src;
  3087. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3088. dstpixel = *dst;
  3089. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  3090. if (flags & SDL_COPY_MODULATE_COLOR) {
  3091. srcR = (srcR * modulateR) / 255;
  3092. srcG = (srcG * modulateG) / 255;
  3093. srcB = (srcB * modulateB) / 255;
  3094. }
  3095. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3096. srcA = (srcA * modulateA) / 255;
  3097. }
  3098. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3099. /* This goes away if we ever use premultiplied alpha */
  3100. if (srcA < 255) {
  3101. srcR = (srcR * srcA) / 255;
  3102. srcG = (srcG * srcA) / 255;
  3103. srcB = (srcB * srcA) / 255;
  3104. }
  3105. }
  3106. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3107. case SDL_COPY_BLEND:
  3108. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3109. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3110. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3111. break;
  3112. case SDL_COPY_ADD:
  3113. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3114. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3115. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3116. break;
  3117. case SDL_COPY_MOD:
  3118. dstR = (srcR * dstR) / 255;
  3119. dstG = (srcG * dstG) / 255;
  3120. dstB = (srcB * dstB) / 255;
  3121. break;
  3122. case SDL_COPY_MUL:
  3123. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3124. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3125. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3126. break;
  3127. }
  3128. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  3129. *dst = dstpixel;
  3130. posx += incx;
  3131. ++dst;
  3132. }
  3133. posy += incy;
  3134. info->dst += info->dst_pitch;
  3135. }
  3136. }
  3137. static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
  3138. {
  3139. int srcy, srcx;
  3140. int posy, posx;
  3141. int incy, incx;
  3142. srcy = 0;
  3143. posy = 0;
  3144. incy = (info->src_h << 16) / info->dst_h;
  3145. incx = (info->src_w << 16) / info->dst_w;
  3146. while (info->dst_h--) {
  3147. Uint32 *src = 0;
  3148. Uint32 *dst = (Uint32 *)info->dst;
  3149. int n = info->dst_w;
  3150. srcx = -1;
  3151. posx = 0x10000L;
  3152. while (posy >= 0x10000L) {
  3153. ++srcy;
  3154. posy -= 0x10000L;
  3155. }
  3156. while (n--) {
  3157. if (posx >= 0x10000L) {
  3158. while (posx >= 0x10000L) {
  3159. ++srcx;
  3160. posx -= 0x10000L;
  3161. }
  3162. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3163. }
  3164. *dst = *src;
  3165. posx += incx;
  3166. ++dst;
  3167. }
  3168. posy += incy;
  3169. info->dst += info->dst_pitch;
  3170. }
  3171. }
  3172. static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
  3173. {
  3174. const int flags = info->flags;
  3175. Uint32 srcpixel;
  3176. Uint32 srcR, srcG, srcB, srcA;
  3177. Uint32 dstpixel;
  3178. Uint32 dstR, dstG, dstB, dstA;
  3179. while (info->dst_h--) {
  3180. Uint32 *src = (Uint32 *)info->src;
  3181. Uint32 *dst = (Uint32 *)info->dst;
  3182. int n = info->dst_w;
  3183. while (n--) {
  3184. srcpixel = *src;
  3185. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3186. dstpixel = *dst;
  3187. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  3188. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3189. /* This goes away if we ever use premultiplied alpha */
  3190. if (srcA < 255) {
  3191. srcR = (srcR * srcA) / 255;
  3192. srcG = (srcG * srcA) / 255;
  3193. srcB = (srcB * srcA) / 255;
  3194. }
  3195. }
  3196. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3197. case SDL_COPY_BLEND:
  3198. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3199. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3200. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3201. dstA = srcA + ((255 - srcA) * dstA) / 255;
  3202. break;
  3203. case SDL_COPY_ADD:
  3204. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3205. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3206. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3207. break;
  3208. case SDL_COPY_MOD:
  3209. dstR = (srcR * dstR) / 255;
  3210. dstG = (srcG * dstG) / 255;
  3211. dstB = (srcB * dstB) / 255;
  3212. break;
  3213. case SDL_COPY_MUL:
  3214. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3215. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3216. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3217. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  3218. break;
  3219. }
  3220. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  3221. *dst = dstpixel;
  3222. ++src;
  3223. ++dst;
  3224. }
  3225. info->src += info->src_pitch;
  3226. info->dst += info->dst_pitch;
  3227. }
  3228. }
  3229. static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  3230. {
  3231. const int flags = info->flags;
  3232. Uint32 srcpixel;
  3233. Uint32 srcR, srcG, srcB, srcA;
  3234. Uint32 dstpixel;
  3235. Uint32 dstR, dstG, dstB, dstA;
  3236. int srcy, srcx;
  3237. int posy, posx;
  3238. int incy, incx;
  3239. srcy = 0;
  3240. posy = 0;
  3241. incy = (info->src_h << 16) / info->dst_h;
  3242. incx = (info->src_w << 16) / info->dst_w;
  3243. while (info->dst_h--) {
  3244. Uint32 *src = 0;
  3245. Uint32 *dst = (Uint32 *)info->dst;
  3246. int n = info->dst_w;
  3247. srcx = -1;
  3248. posx = 0x10000L;
  3249. while (posy >= 0x10000L) {
  3250. ++srcy;
  3251. posy -= 0x10000L;
  3252. }
  3253. while (n--) {
  3254. if (posx >= 0x10000L) {
  3255. while (posx >= 0x10000L) {
  3256. ++srcx;
  3257. posx -= 0x10000L;
  3258. }
  3259. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3260. }
  3261. srcpixel = *src;
  3262. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3263. dstpixel = *dst;
  3264. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  3265. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3266. /* This goes away if we ever use premultiplied alpha */
  3267. if (srcA < 255) {
  3268. srcR = (srcR * srcA) / 255;
  3269. srcG = (srcG * srcA) / 255;
  3270. srcB = (srcB * srcA) / 255;
  3271. }
  3272. }
  3273. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3274. case SDL_COPY_BLEND:
  3275. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3276. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3277. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3278. dstA = srcA + ((255 - srcA) * dstA) / 255;
  3279. break;
  3280. case SDL_COPY_ADD:
  3281. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3282. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3283. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3284. break;
  3285. case SDL_COPY_MOD:
  3286. dstR = (srcR * dstR) / 255;
  3287. dstG = (srcG * dstG) / 255;
  3288. dstB = (srcB * dstB) / 255;
  3289. break;
  3290. case SDL_COPY_MUL:
  3291. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3292. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3293. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3294. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  3295. break;
  3296. }
  3297. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  3298. *dst = dstpixel;
  3299. posx += incx;
  3300. ++dst;
  3301. }
  3302. posy += incy;
  3303. info->dst += info->dst_pitch;
  3304. }
  3305. }
  3306. static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  3307. {
  3308. const int flags = info->flags;
  3309. const Uint32 modulateR = info->r;
  3310. const Uint32 modulateG = info->g;
  3311. const Uint32 modulateB = info->b;
  3312. const Uint32 modulateA = info->a;
  3313. Uint32 pixel;
  3314. Uint32 R, G, B, A;
  3315. while (info->dst_h--) {
  3316. Uint32 *src = (Uint32 *)info->src;
  3317. Uint32 *dst = (Uint32 *)info->dst;
  3318. int n = info->dst_w;
  3319. while (n--) {
  3320. pixel = *src;
  3321. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  3322. if (flags & SDL_COPY_MODULATE_COLOR) {
  3323. R = (R * modulateR) / 255;
  3324. G = (G * modulateG) / 255;
  3325. B = (B * modulateB) / 255;
  3326. }
  3327. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3328. A = (A * modulateA) / 255;
  3329. }
  3330. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  3331. *dst = pixel;
  3332. ++src;
  3333. ++dst;
  3334. }
  3335. info->src += info->src_pitch;
  3336. info->dst += info->dst_pitch;
  3337. }
  3338. }
  3339. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  3340. {
  3341. const int flags = info->flags;
  3342. const Uint32 modulateR = info->r;
  3343. const Uint32 modulateG = info->g;
  3344. const Uint32 modulateB = info->b;
  3345. const Uint32 modulateA = info->a;
  3346. Uint32 pixel;
  3347. Uint32 R, G, B, A;
  3348. int srcy, srcx;
  3349. int posy, posx;
  3350. int incy, incx;
  3351. srcy = 0;
  3352. posy = 0;
  3353. incy = (info->src_h << 16) / info->dst_h;
  3354. incx = (info->src_w << 16) / info->dst_w;
  3355. while (info->dst_h--) {
  3356. Uint32 *src = 0;
  3357. Uint32 *dst = (Uint32 *)info->dst;
  3358. int n = info->dst_w;
  3359. srcx = -1;
  3360. posx = 0x10000L;
  3361. while (posy >= 0x10000L) {
  3362. ++srcy;
  3363. posy -= 0x10000L;
  3364. }
  3365. while (n--) {
  3366. if (posx >= 0x10000L) {
  3367. while (posx >= 0x10000L) {
  3368. ++srcx;
  3369. posx -= 0x10000L;
  3370. }
  3371. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3372. }
  3373. pixel = *src;
  3374. R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  3375. if (flags & SDL_COPY_MODULATE_COLOR) {
  3376. R = (R * modulateR) / 255;
  3377. G = (G * modulateG) / 255;
  3378. B = (B * modulateB) / 255;
  3379. }
  3380. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3381. A = (A * modulateA) / 255;
  3382. }
  3383. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  3384. *dst = pixel;
  3385. posx += incx;
  3386. ++dst;
  3387. }
  3388. posy += incy;
  3389. info->dst += info->dst_pitch;
  3390. }
  3391. }
  3392. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  3393. {
  3394. const int flags = info->flags;
  3395. const Uint32 modulateR = info->r;
  3396. const Uint32 modulateG = info->g;
  3397. const Uint32 modulateB = info->b;
  3398. const Uint32 modulateA = info->a;
  3399. Uint32 srcpixel;
  3400. Uint32 srcR, srcG, srcB, srcA;
  3401. Uint32 dstpixel;
  3402. Uint32 dstR, dstG, dstB, dstA;
  3403. while (info->dst_h--) {
  3404. Uint32 *src = (Uint32 *)info->src;
  3405. Uint32 *dst = (Uint32 *)info->dst;
  3406. int n = info->dst_w;
  3407. while (n--) {
  3408. srcpixel = *src;
  3409. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3410. dstpixel = *dst;
  3411. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  3412. if (flags & SDL_COPY_MODULATE_COLOR) {
  3413. srcR = (srcR * modulateR) / 255;
  3414. srcG = (srcG * modulateG) / 255;
  3415. srcB = (srcB * modulateB) / 255;
  3416. }
  3417. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3418. srcA = (srcA * modulateA) / 255;
  3419. }
  3420. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3421. /* This goes away if we ever use premultiplied alpha */
  3422. if (srcA < 255) {
  3423. srcR = (srcR * srcA) / 255;
  3424. srcG = (srcG * srcA) / 255;
  3425. srcB = (srcB * srcA) / 255;
  3426. }
  3427. }
  3428. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3429. case SDL_COPY_BLEND:
  3430. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3431. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3432. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3433. dstA = srcA + ((255 - srcA) * dstA) / 255;
  3434. break;
  3435. case SDL_COPY_ADD:
  3436. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3437. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3438. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3439. break;
  3440. case SDL_COPY_MOD:
  3441. dstR = (srcR * dstR) / 255;
  3442. dstG = (srcG * dstG) / 255;
  3443. dstB = (srcB * dstB) / 255;
  3444. break;
  3445. case SDL_COPY_MUL:
  3446. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3447. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3448. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3449. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  3450. break;
  3451. }
  3452. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  3453. *dst = dstpixel;
  3454. ++src;
  3455. ++dst;
  3456. }
  3457. info->src += info->src_pitch;
  3458. info->dst += info->dst_pitch;
  3459. }
  3460. }
  3461. static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3462. {
  3463. const int flags = info->flags;
  3464. const Uint32 modulateR = info->r;
  3465. const Uint32 modulateG = info->g;
  3466. const Uint32 modulateB = info->b;
  3467. const Uint32 modulateA = info->a;
  3468. Uint32 srcpixel;
  3469. Uint32 srcR, srcG, srcB, srcA;
  3470. Uint32 dstpixel;
  3471. Uint32 dstR, dstG, dstB, dstA;
  3472. int srcy, srcx;
  3473. int posy, posx;
  3474. int incy, incx;
  3475. srcy = 0;
  3476. posy = 0;
  3477. incy = (info->src_h << 16) / info->dst_h;
  3478. incx = (info->src_w << 16) / info->dst_w;
  3479. while (info->dst_h--) {
  3480. Uint32 *src = 0;
  3481. Uint32 *dst = (Uint32 *)info->dst;
  3482. int n = info->dst_w;
  3483. srcx = -1;
  3484. posx = 0x10000L;
  3485. while (posy >= 0x10000L) {
  3486. ++srcy;
  3487. posy -= 0x10000L;
  3488. }
  3489. while (n--) {
  3490. if (posx >= 0x10000L) {
  3491. while (posx >= 0x10000L) {
  3492. ++srcx;
  3493. posx -= 0x10000L;
  3494. }
  3495. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3496. }
  3497. srcpixel = *src;
  3498. srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  3499. dstpixel = *dst;
  3500. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  3501. if (flags & SDL_COPY_MODULATE_COLOR) {
  3502. srcR = (srcR * modulateR) / 255;
  3503. srcG = (srcG * modulateG) / 255;
  3504. srcB = (srcB * modulateB) / 255;
  3505. }
  3506. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3507. srcA = (srcA * modulateA) / 255;
  3508. }
  3509. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3510. /* This goes away if we ever use premultiplied alpha */
  3511. if (srcA < 255) {
  3512. srcR = (srcR * srcA) / 255;
  3513. srcG = (srcG * srcA) / 255;
  3514. srcB = (srcB * srcA) / 255;
  3515. }
  3516. }
  3517. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3518. case SDL_COPY_BLEND:
  3519. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3520. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3521. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3522. dstA = srcA + ((255 - srcA) * dstA) / 255;
  3523. break;
  3524. case SDL_COPY_ADD:
  3525. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3526. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3527. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3528. break;
  3529. case SDL_COPY_MOD:
  3530. dstR = (srcR * dstR) / 255;
  3531. dstG = (srcG * dstG) / 255;
  3532. dstB = (srcB * dstB) / 255;
  3533. break;
  3534. case SDL_COPY_MUL:
  3535. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3536. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3537. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3538. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  3539. break;
  3540. }
  3541. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  3542. *dst = dstpixel;
  3543. posx += incx;
  3544. ++dst;
  3545. }
  3546. posy += incy;
  3547. info->dst += info->dst_pitch;
  3548. }
  3549. }
  3550. static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
  3551. {
  3552. Uint32 pixel;
  3553. Uint32 R, G, B;
  3554. int srcy, srcx;
  3555. int posy, posx;
  3556. int incy, incx;
  3557. srcy = 0;
  3558. posy = 0;
  3559. incy = (info->src_h << 16) / info->dst_h;
  3560. incx = (info->src_w << 16) / info->dst_w;
  3561. while (info->dst_h--) {
  3562. Uint32 *src = 0;
  3563. Uint32 *dst = (Uint32 *)info->dst;
  3564. int n = info->dst_w;
  3565. srcx = -1;
  3566. posx = 0x10000L;
  3567. while (posy >= 0x10000L) {
  3568. ++srcy;
  3569. posy -= 0x10000L;
  3570. }
  3571. while (n--) {
  3572. if (posx >= 0x10000L) {
  3573. while (posx >= 0x10000L) {
  3574. ++srcx;
  3575. posx -= 0x10000L;
  3576. }
  3577. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3578. }
  3579. pixel = *src;
  3580. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  3581. pixel = (R << 16) | (G << 8) | B;
  3582. *dst = pixel;
  3583. posx += incx;
  3584. ++dst;
  3585. }
  3586. posy += incy;
  3587. info->dst += info->dst_pitch;
  3588. }
  3589. }
  3590. static void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info)
  3591. {
  3592. const int flags = info->flags;
  3593. Uint32 srcpixel;
  3594. Uint32 srcR, srcG, srcB, srcA;
  3595. Uint32 dstpixel;
  3596. Uint32 dstR, dstG, dstB;
  3597. while (info->dst_h--) {
  3598. Uint32 *src = (Uint32 *)info->src;
  3599. Uint32 *dst = (Uint32 *)info->dst;
  3600. int n = info->dst_w;
  3601. while (n--) {
  3602. srcpixel = *src;
  3603. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3604. dstpixel = *dst;
  3605. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3606. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3607. /* This goes away if we ever use premultiplied alpha */
  3608. if (srcA < 255) {
  3609. srcR = (srcR * srcA) / 255;
  3610. srcG = (srcG * srcA) / 255;
  3611. srcB = (srcB * srcA) / 255;
  3612. }
  3613. }
  3614. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3615. case SDL_COPY_BLEND:
  3616. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3617. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3618. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3619. break;
  3620. case SDL_COPY_ADD:
  3621. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3622. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3623. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3624. break;
  3625. case SDL_COPY_MOD:
  3626. dstR = (srcR * dstR) / 255;
  3627. dstG = (srcG * dstG) / 255;
  3628. dstB = (srcB * dstB) / 255;
  3629. break;
  3630. case SDL_COPY_MUL:
  3631. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3632. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3633. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3634. break;
  3635. }
  3636. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3637. *dst = dstpixel;
  3638. ++src;
  3639. ++dst;
  3640. }
  3641. info->src += info->src_pitch;
  3642. info->dst += info->dst_pitch;
  3643. }
  3644. }
  3645. static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  3646. {
  3647. const int flags = info->flags;
  3648. Uint32 srcpixel;
  3649. Uint32 srcR, srcG, srcB, srcA;
  3650. Uint32 dstpixel;
  3651. Uint32 dstR, dstG, dstB;
  3652. int srcy, srcx;
  3653. int posy, posx;
  3654. int incy, incx;
  3655. srcy = 0;
  3656. posy = 0;
  3657. incy = (info->src_h << 16) / info->dst_h;
  3658. incx = (info->src_w << 16) / info->dst_w;
  3659. while (info->dst_h--) {
  3660. Uint32 *src = 0;
  3661. Uint32 *dst = (Uint32 *)info->dst;
  3662. int n = info->dst_w;
  3663. srcx = -1;
  3664. posx = 0x10000L;
  3665. while (posy >= 0x10000L) {
  3666. ++srcy;
  3667. posy -= 0x10000L;
  3668. }
  3669. while (n--) {
  3670. if (posx >= 0x10000L) {
  3671. while (posx >= 0x10000L) {
  3672. ++srcx;
  3673. posx -= 0x10000L;
  3674. }
  3675. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3676. }
  3677. srcpixel = *src;
  3678. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3679. dstpixel = *dst;
  3680. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3681. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3682. /* This goes away if we ever use premultiplied alpha */
  3683. if (srcA < 255) {
  3684. srcR = (srcR * srcA) / 255;
  3685. srcG = (srcG * srcA) / 255;
  3686. srcB = (srcB * srcA) / 255;
  3687. }
  3688. }
  3689. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3690. case SDL_COPY_BLEND:
  3691. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3692. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3693. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3694. break;
  3695. case SDL_COPY_ADD:
  3696. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3697. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3698. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3699. break;
  3700. case SDL_COPY_MOD:
  3701. dstR = (srcR * dstR) / 255;
  3702. dstG = (srcG * dstG) / 255;
  3703. dstB = (srcB * dstB) / 255;
  3704. break;
  3705. case SDL_COPY_MUL:
  3706. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3707. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3708. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3709. break;
  3710. }
  3711. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3712. *dst = dstpixel;
  3713. posx += incx;
  3714. ++dst;
  3715. }
  3716. posy += incy;
  3717. info->dst += info->dst_pitch;
  3718. }
  3719. }
  3720. static void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info)
  3721. {
  3722. const int flags = info->flags;
  3723. const Uint32 modulateR = info->r;
  3724. const Uint32 modulateG = info->g;
  3725. const Uint32 modulateB = info->b;
  3726. Uint32 pixel;
  3727. Uint32 R, G, B;
  3728. while (info->dst_h--) {
  3729. Uint32 *src = (Uint32 *)info->src;
  3730. Uint32 *dst = (Uint32 *)info->dst;
  3731. int n = info->dst_w;
  3732. while (n--) {
  3733. pixel = *src;
  3734. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  3735. if (flags & SDL_COPY_MODULATE_COLOR) {
  3736. R = (R * modulateR) / 255;
  3737. G = (G * modulateG) / 255;
  3738. B = (B * modulateB) / 255;
  3739. }
  3740. pixel = (R << 16) | (G << 8) | B;
  3741. *dst = pixel;
  3742. ++src;
  3743. ++dst;
  3744. }
  3745. info->src += info->src_pitch;
  3746. info->dst += info->dst_pitch;
  3747. }
  3748. }
  3749. static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  3750. {
  3751. const int flags = info->flags;
  3752. const Uint32 modulateR = info->r;
  3753. const Uint32 modulateG = info->g;
  3754. const Uint32 modulateB = info->b;
  3755. Uint32 pixel;
  3756. Uint32 R, G, B;
  3757. int srcy, srcx;
  3758. int posy, posx;
  3759. int incy, incx;
  3760. srcy = 0;
  3761. posy = 0;
  3762. incy = (info->src_h << 16) / info->dst_h;
  3763. incx = (info->src_w << 16) / info->dst_w;
  3764. while (info->dst_h--) {
  3765. Uint32 *src = 0;
  3766. Uint32 *dst = (Uint32 *)info->dst;
  3767. int n = info->dst_w;
  3768. srcx = -1;
  3769. posx = 0x10000L;
  3770. while (posy >= 0x10000L) {
  3771. ++srcy;
  3772. posy -= 0x10000L;
  3773. }
  3774. while (n--) {
  3775. if (posx >= 0x10000L) {
  3776. while (posx >= 0x10000L) {
  3777. ++srcx;
  3778. posx -= 0x10000L;
  3779. }
  3780. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3781. }
  3782. pixel = *src;
  3783. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  3784. if (flags & SDL_COPY_MODULATE_COLOR) {
  3785. R = (R * modulateR) / 255;
  3786. G = (G * modulateG) / 255;
  3787. B = (B * modulateB) / 255;
  3788. }
  3789. pixel = (R << 16) | (G << 8) | B;
  3790. *dst = pixel;
  3791. posx += incx;
  3792. ++dst;
  3793. }
  3794. posy += incy;
  3795. info->dst += info->dst_pitch;
  3796. }
  3797. }
  3798. static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  3799. {
  3800. const int flags = info->flags;
  3801. const Uint32 modulateR = info->r;
  3802. const Uint32 modulateG = info->g;
  3803. const Uint32 modulateB = info->b;
  3804. const Uint32 modulateA = info->a;
  3805. Uint32 srcpixel;
  3806. Uint32 srcR, srcG, srcB, srcA;
  3807. Uint32 dstpixel;
  3808. Uint32 dstR, dstG, dstB;
  3809. while (info->dst_h--) {
  3810. Uint32 *src = (Uint32 *)info->src;
  3811. Uint32 *dst = (Uint32 *)info->dst;
  3812. int n = info->dst_w;
  3813. while (n--) {
  3814. srcpixel = *src;
  3815. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3816. dstpixel = *dst;
  3817. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3818. if (flags & SDL_COPY_MODULATE_COLOR) {
  3819. srcR = (srcR * modulateR) / 255;
  3820. srcG = (srcG * modulateG) / 255;
  3821. srcB = (srcB * modulateB) / 255;
  3822. }
  3823. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3824. srcA = (srcA * modulateA) / 255;
  3825. }
  3826. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3827. /* This goes away if we ever use premultiplied alpha */
  3828. if (srcA < 255) {
  3829. srcR = (srcR * srcA) / 255;
  3830. srcG = (srcG * srcA) / 255;
  3831. srcB = (srcB * srcA) / 255;
  3832. }
  3833. }
  3834. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3835. case SDL_COPY_BLEND:
  3836. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3837. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3838. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3839. break;
  3840. case SDL_COPY_ADD:
  3841. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3842. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3843. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3844. break;
  3845. case SDL_COPY_MOD:
  3846. dstR = (srcR * dstR) / 255;
  3847. dstG = (srcG * dstG) / 255;
  3848. dstB = (srcB * dstB) / 255;
  3849. break;
  3850. case SDL_COPY_MUL:
  3851. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3852. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3853. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3854. break;
  3855. }
  3856. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3857. *dst = dstpixel;
  3858. ++src;
  3859. ++dst;
  3860. }
  3861. info->src += info->src_pitch;
  3862. info->dst += info->dst_pitch;
  3863. }
  3864. }
  3865. static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  3866. {
  3867. const int flags = info->flags;
  3868. const Uint32 modulateR = info->r;
  3869. const Uint32 modulateG = info->g;
  3870. const Uint32 modulateB = info->b;
  3871. const Uint32 modulateA = info->a;
  3872. Uint32 srcpixel;
  3873. Uint32 srcR, srcG, srcB, srcA;
  3874. Uint32 dstpixel;
  3875. Uint32 dstR, dstG, dstB;
  3876. int srcy, srcx;
  3877. int posy, posx;
  3878. int incy, incx;
  3879. srcy = 0;
  3880. posy = 0;
  3881. incy = (info->src_h << 16) / info->dst_h;
  3882. incx = (info->src_w << 16) / info->dst_w;
  3883. while (info->dst_h--) {
  3884. Uint32 *src = 0;
  3885. Uint32 *dst = (Uint32 *)info->dst;
  3886. int n = info->dst_w;
  3887. srcx = -1;
  3888. posx = 0x10000L;
  3889. while (posy >= 0x10000L) {
  3890. ++srcy;
  3891. posy -= 0x10000L;
  3892. }
  3893. while (n--) {
  3894. if (posx >= 0x10000L) {
  3895. while (posx >= 0x10000L) {
  3896. ++srcx;
  3897. posx -= 0x10000L;
  3898. }
  3899. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3900. }
  3901. srcpixel = *src;
  3902. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  3903. dstpixel = *dst;
  3904. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  3905. if (flags & SDL_COPY_MODULATE_COLOR) {
  3906. srcR = (srcR * modulateR) / 255;
  3907. srcG = (srcG * modulateG) / 255;
  3908. srcB = (srcB * modulateB) / 255;
  3909. }
  3910. if (flags & SDL_COPY_MODULATE_ALPHA) {
  3911. srcA = (srcA * modulateA) / 255;
  3912. }
  3913. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  3914. /* This goes away if we ever use premultiplied alpha */
  3915. if (srcA < 255) {
  3916. srcR = (srcR * srcA) / 255;
  3917. srcG = (srcG * srcA) / 255;
  3918. srcB = (srcB * srcA) / 255;
  3919. }
  3920. }
  3921. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  3922. case SDL_COPY_BLEND:
  3923. dstR = srcR + ((255 - srcA) * dstR) / 255;
  3924. dstG = srcG + ((255 - srcA) * dstG) / 255;
  3925. dstB = srcB + ((255 - srcA) * dstB) / 255;
  3926. break;
  3927. case SDL_COPY_ADD:
  3928. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  3929. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  3930. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  3931. break;
  3932. case SDL_COPY_MOD:
  3933. dstR = (srcR * dstR) / 255;
  3934. dstG = (srcG * dstG) / 255;
  3935. dstB = (srcB * dstB) / 255;
  3936. break;
  3937. case SDL_COPY_MUL:
  3938. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  3939. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  3940. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  3941. break;
  3942. }
  3943. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  3944. *dst = dstpixel;
  3945. posx += incx;
  3946. ++dst;
  3947. }
  3948. posy += incy;
  3949. info->dst += info->dst_pitch;
  3950. }
  3951. }
  3952. static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info)
  3953. {
  3954. Uint32 pixel;
  3955. Uint32 R, G, B;
  3956. int srcy, srcx;
  3957. int posy, posx;
  3958. int incy, incx;
  3959. srcy = 0;
  3960. posy = 0;
  3961. incy = (info->src_h << 16) / info->dst_h;
  3962. incx = (info->src_w << 16) / info->dst_w;
  3963. while (info->dst_h--) {
  3964. Uint32 *src = 0;
  3965. Uint32 *dst = (Uint32 *)info->dst;
  3966. int n = info->dst_w;
  3967. srcx = -1;
  3968. posx = 0x10000L;
  3969. while (posy >= 0x10000L) {
  3970. ++srcy;
  3971. posy -= 0x10000L;
  3972. }
  3973. while (n--) {
  3974. if (posx >= 0x10000L) {
  3975. while (posx >= 0x10000L) {
  3976. ++srcx;
  3977. posx -= 0x10000L;
  3978. }
  3979. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  3980. }
  3981. pixel = *src;
  3982. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  3983. pixel = (B << 16) | (G << 8) | R;
  3984. *dst = pixel;
  3985. posx += incx;
  3986. ++dst;
  3987. }
  3988. posy += incy;
  3989. info->dst += info->dst_pitch;
  3990. }
  3991. }
  3992. static void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info)
  3993. {
  3994. const int flags = info->flags;
  3995. Uint32 srcpixel;
  3996. Uint32 srcR, srcG, srcB, srcA;
  3997. Uint32 dstpixel;
  3998. Uint32 dstR, dstG, dstB;
  3999. while (info->dst_h--) {
  4000. Uint32 *src = (Uint32 *)info->src;
  4001. Uint32 *dst = (Uint32 *)info->dst;
  4002. int n = info->dst_w;
  4003. while (n--) {
  4004. srcpixel = *src;
  4005. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4006. dstpixel = *dst;
  4007. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  4008. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4009. /* This goes away if we ever use premultiplied alpha */
  4010. if (srcA < 255) {
  4011. srcR = (srcR * srcA) / 255;
  4012. srcG = (srcG * srcA) / 255;
  4013. srcB = (srcB * srcA) / 255;
  4014. }
  4015. }
  4016. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4017. case SDL_COPY_BLEND:
  4018. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4019. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4020. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4021. break;
  4022. case SDL_COPY_ADD:
  4023. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4024. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4025. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4026. break;
  4027. case SDL_COPY_MOD:
  4028. dstR = (srcR * dstR) / 255;
  4029. dstG = (srcG * dstG) / 255;
  4030. dstB = (srcB * dstB) / 255;
  4031. break;
  4032. case SDL_COPY_MUL:
  4033. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4034. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4035. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4036. break;
  4037. }
  4038. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  4039. *dst = dstpixel;
  4040. ++src;
  4041. ++dst;
  4042. }
  4043. info->src += info->src_pitch;
  4044. info->dst += info->dst_pitch;
  4045. }
  4046. }
  4047. static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  4048. {
  4049. const int flags = info->flags;
  4050. Uint32 srcpixel;
  4051. Uint32 srcR, srcG, srcB, srcA;
  4052. Uint32 dstpixel;
  4053. Uint32 dstR, dstG, dstB;
  4054. int srcy, srcx;
  4055. int posy, posx;
  4056. int incy, incx;
  4057. srcy = 0;
  4058. posy = 0;
  4059. incy = (info->src_h << 16) / info->dst_h;
  4060. incx = (info->src_w << 16) / info->dst_w;
  4061. while (info->dst_h--) {
  4062. Uint32 *src = 0;
  4063. Uint32 *dst = (Uint32 *)info->dst;
  4064. int n = info->dst_w;
  4065. srcx = -1;
  4066. posx = 0x10000L;
  4067. while (posy >= 0x10000L) {
  4068. ++srcy;
  4069. posy -= 0x10000L;
  4070. }
  4071. while (n--) {
  4072. if (posx >= 0x10000L) {
  4073. while (posx >= 0x10000L) {
  4074. ++srcx;
  4075. posx -= 0x10000L;
  4076. }
  4077. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4078. }
  4079. srcpixel = *src;
  4080. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4081. dstpixel = *dst;
  4082. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  4083. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4084. /* This goes away if we ever use premultiplied alpha */
  4085. if (srcA < 255) {
  4086. srcR = (srcR * srcA) / 255;
  4087. srcG = (srcG * srcA) / 255;
  4088. srcB = (srcB * srcA) / 255;
  4089. }
  4090. }
  4091. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4092. case SDL_COPY_BLEND:
  4093. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4094. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4095. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4096. break;
  4097. case SDL_COPY_ADD:
  4098. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4099. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4100. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4101. break;
  4102. case SDL_COPY_MOD:
  4103. dstR = (srcR * dstR) / 255;
  4104. dstG = (srcG * dstG) / 255;
  4105. dstB = (srcB * dstB) / 255;
  4106. break;
  4107. case SDL_COPY_MUL:
  4108. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4109. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4110. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4111. break;
  4112. }
  4113. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  4114. *dst = dstpixel;
  4115. posx += incx;
  4116. ++dst;
  4117. }
  4118. posy += incy;
  4119. info->dst += info->dst_pitch;
  4120. }
  4121. }
  4122. static void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info)
  4123. {
  4124. const int flags = info->flags;
  4125. const Uint32 modulateR = info->r;
  4126. const Uint32 modulateG = info->g;
  4127. const Uint32 modulateB = info->b;
  4128. Uint32 pixel;
  4129. Uint32 R, G, B;
  4130. while (info->dst_h--) {
  4131. Uint32 *src = (Uint32 *)info->src;
  4132. Uint32 *dst = (Uint32 *)info->dst;
  4133. int n = info->dst_w;
  4134. while (n--) {
  4135. pixel = *src;
  4136. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  4137. if (flags & SDL_COPY_MODULATE_COLOR) {
  4138. R = (R * modulateR) / 255;
  4139. G = (G * modulateG) / 255;
  4140. B = (B * modulateB) / 255;
  4141. }
  4142. pixel = (B << 16) | (G << 8) | R;
  4143. *dst = pixel;
  4144. ++src;
  4145. ++dst;
  4146. }
  4147. info->src += info->src_pitch;
  4148. info->dst += info->dst_pitch;
  4149. }
  4150. }
  4151. static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  4152. {
  4153. const int flags = info->flags;
  4154. const Uint32 modulateR = info->r;
  4155. const Uint32 modulateG = info->g;
  4156. const Uint32 modulateB = info->b;
  4157. Uint32 pixel;
  4158. Uint32 R, G, B;
  4159. int srcy, srcx;
  4160. int posy, posx;
  4161. int incy, incx;
  4162. srcy = 0;
  4163. posy = 0;
  4164. incy = (info->src_h << 16) / info->dst_h;
  4165. incx = (info->src_w << 16) / info->dst_w;
  4166. while (info->dst_h--) {
  4167. Uint32 *src = 0;
  4168. Uint32 *dst = (Uint32 *)info->dst;
  4169. int n = info->dst_w;
  4170. srcx = -1;
  4171. posx = 0x10000L;
  4172. while (posy >= 0x10000L) {
  4173. ++srcy;
  4174. posy -= 0x10000L;
  4175. }
  4176. while (n--) {
  4177. if (posx >= 0x10000L) {
  4178. while (posx >= 0x10000L) {
  4179. ++srcx;
  4180. posx -= 0x10000L;
  4181. }
  4182. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4183. }
  4184. pixel = *src;
  4185. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
  4186. if (flags & SDL_COPY_MODULATE_COLOR) {
  4187. R = (R * modulateR) / 255;
  4188. G = (G * modulateG) / 255;
  4189. B = (B * modulateB) / 255;
  4190. }
  4191. pixel = (B << 16) | (G << 8) | R;
  4192. *dst = pixel;
  4193. posx += incx;
  4194. ++dst;
  4195. }
  4196. posy += incy;
  4197. info->dst += info->dst_pitch;
  4198. }
  4199. }
  4200. static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  4201. {
  4202. const int flags = info->flags;
  4203. const Uint32 modulateR = info->r;
  4204. const Uint32 modulateG = info->g;
  4205. const Uint32 modulateB = info->b;
  4206. const Uint32 modulateA = info->a;
  4207. Uint32 srcpixel;
  4208. Uint32 srcR, srcG, srcB, srcA;
  4209. Uint32 dstpixel;
  4210. Uint32 dstR, dstG, dstB;
  4211. while (info->dst_h--) {
  4212. Uint32 *src = (Uint32 *)info->src;
  4213. Uint32 *dst = (Uint32 *)info->dst;
  4214. int n = info->dst_w;
  4215. while (n--) {
  4216. srcpixel = *src;
  4217. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4218. dstpixel = *dst;
  4219. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  4220. if (flags & SDL_COPY_MODULATE_COLOR) {
  4221. srcR = (srcR * modulateR) / 255;
  4222. srcG = (srcG * modulateG) / 255;
  4223. srcB = (srcB * modulateB) / 255;
  4224. }
  4225. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4226. srcA = (srcA * modulateA) / 255;
  4227. }
  4228. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4229. /* This goes away if we ever use premultiplied alpha */
  4230. if (srcA < 255) {
  4231. srcR = (srcR * srcA) / 255;
  4232. srcG = (srcG * srcA) / 255;
  4233. srcB = (srcB * srcA) / 255;
  4234. }
  4235. }
  4236. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4237. case SDL_COPY_BLEND:
  4238. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4239. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4240. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4241. break;
  4242. case SDL_COPY_ADD:
  4243. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4244. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4245. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4246. break;
  4247. case SDL_COPY_MOD:
  4248. dstR = (srcR * dstR) / 255;
  4249. dstG = (srcG * dstG) / 255;
  4250. dstB = (srcB * dstB) / 255;
  4251. break;
  4252. case SDL_COPY_MUL:
  4253. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4254. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4255. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4256. break;
  4257. }
  4258. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  4259. *dst = dstpixel;
  4260. ++src;
  4261. ++dst;
  4262. }
  4263. info->src += info->src_pitch;
  4264. info->dst += info->dst_pitch;
  4265. }
  4266. }
  4267. static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4268. {
  4269. const int flags = info->flags;
  4270. const Uint32 modulateR = info->r;
  4271. const Uint32 modulateG = info->g;
  4272. const Uint32 modulateB = info->b;
  4273. const Uint32 modulateA = info->a;
  4274. Uint32 srcpixel;
  4275. Uint32 srcR, srcG, srcB, srcA;
  4276. Uint32 dstpixel;
  4277. Uint32 dstR, dstG, dstB;
  4278. int srcy, srcx;
  4279. int posy, posx;
  4280. int incy, incx;
  4281. srcy = 0;
  4282. posy = 0;
  4283. incy = (info->src_h << 16) / info->dst_h;
  4284. incx = (info->src_w << 16) / info->dst_w;
  4285. while (info->dst_h--) {
  4286. Uint32 *src = 0;
  4287. Uint32 *dst = (Uint32 *)info->dst;
  4288. int n = info->dst_w;
  4289. srcx = -1;
  4290. posx = 0x10000L;
  4291. while (posy >= 0x10000L) {
  4292. ++srcy;
  4293. posy -= 0x10000L;
  4294. }
  4295. while (n--) {
  4296. if (posx >= 0x10000L) {
  4297. while (posx >= 0x10000L) {
  4298. ++srcx;
  4299. posx -= 0x10000L;
  4300. }
  4301. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4302. }
  4303. srcpixel = *src;
  4304. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4305. dstpixel = *dst;
  4306. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  4307. if (flags & SDL_COPY_MODULATE_COLOR) {
  4308. srcR = (srcR * modulateR) / 255;
  4309. srcG = (srcG * modulateG) / 255;
  4310. srcB = (srcB * modulateB) / 255;
  4311. }
  4312. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4313. srcA = (srcA * modulateA) / 255;
  4314. }
  4315. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4316. /* This goes away if we ever use premultiplied alpha */
  4317. if (srcA < 255) {
  4318. srcR = (srcR * srcA) / 255;
  4319. srcG = (srcG * srcA) / 255;
  4320. srcB = (srcB * srcA) / 255;
  4321. }
  4322. }
  4323. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4324. case SDL_COPY_BLEND:
  4325. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4326. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4327. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4328. break;
  4329. case SDL_COPY_ADD:
  4330. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4331. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4332. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4333. break;
  4334. case SDL_COPY_MOD:
  4335. dstR = (srcR * dstR) / 255;
  4336. dstG = (srcG * dstG) / 255;
  4337. dstB = (srcB * dstB) / 255;
  4338. break;
  4339. case SDL_COPY_MUL:
  4340. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4341. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4342. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4343. break;
  4344. }
  4345. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  4346. *dst = dstpixel;
  4347. posx += incx;
  4348. ++dst;
  4349. }
  4350. posy += incy;
  4351. info->dst += info->dst_pitch;
  4352. }
  4353. }
  4354. static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  4355. {
  4356. Uint32 pixel;
  4357. Uint32 R, G, B, A;
  4358. int srcy, srcx;
  4359. int posy, posx;
  4360. int incy, incx;
  4361. srcy = 0;
  4362. posy = 0;
  4363. incy = (info->src_h << 16) / info->dst_h;
  4364. incx = (info->src_w << 16) / info->dst_w;
  4365. while (info->dst_h--) {
  4366. Uint32 *src = 0;
  4367. Uint32 *dst = (Uint32 *)info->dst;
  4368. int n = info->dst_w;
  4369. srcx = -1;
  4370. posx = 0x10000L;
  4371. while (posy >= 0x10000L) {
  4372. ++srcy;
  4373. posy -= 0x10000L;
  4374. }
  4375. while (n--) {
  4376. if (posx >= 0x10000L) {
  4377. while (posx >= 0x10000L) {
  4378. ++srcx;
  4379. posx -= 0x10000L;
  4380. }
  4381. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4382. }
  4383. pixel = *src;
  4384. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  4385. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  4386. *dst = pixel;
  4387. posx += incx;
  4388. ++dst;
  4389. }
  4390. posy += incy;
  4391. info->dst += info->dst_pitch;
  4392. }
  4393. }
  4394. static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  4395. {
  4396. const int flags = info->flags;
  4397. Uint32 srcpixel;
  4398. Uint32 srcR, srcG, srcB, srcA;
  4399. Uint32 dstpixel;
  4400. Uint32 dstR, dstG, dstB, dstA;
  4401. while (info->dst_h--) {
  4402. Uint32 *src = (Uint32 *)info->src;
  4403. Uint32 *dst = (Uint32 *)info->dst;
  4404. int n = info->dst_w;
  4405. while (n--) {
  4406. srcpixel = *src;
  4407. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4408. dstpixel = *dst;
  4409. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4410. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4411. /* This goes away if we ever use premultiplied alpha */
  4412. if (srcA < 255) {
  4413. srcR = (srcR * srcA) / 255;
  4414. srcG = (srcG * srcA) / 255;
  4415. srcB = (srcB * srcA) / 255;
  4416. }
  4417. }
  4418. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4419. case SDL_COPY_BLEND:
  4420. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4421. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4422. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4423. dstA = srcA + ((255 - srcA) * dstA) / 255;
  4424. break;
  4425. case SDL_COPY_ADD:
  4426. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4427. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4428. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4429. break;
  4430. case SDL_COPY_MOD:
  4431. dstR = (srcR * dstR) / 255;
  4432. dstG = (srcG * dstG) / 255;
  4433. dstB = (srcB * dstB) / 255;
  4434. break;
  4435. case SDL_COPY_MUL:
  4436. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4437. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4438. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4439. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  4440. break;
  4441. }
  4442. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4443. *dst = dstpixel;
  4444. ++src;
  4445. ++dst;
  4446. }
  4447. info->src += info->src_pitch;
  4448. info->dst += info->dst_pitch;
  4449. }
  4450. }
  4451. static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  4452. {
  4453. const int flags = info->flags;
  4454. Uint32 srcpixel;
  4455. Uint32 srcR, srcG, srcB, srcA;
  4456. Uint32 dstpixel;
  4457. Uint32 dstR, dstG, dstB, dstA;
  4458. int srcy, srcx;
  4459. int posy, posx;
  4460. int incy, incx;
  4461. srcy = 0;
  4462. posy = 0;
  4463. incy = (info->src_h << 16) / info->dst_h;
  4464. incx = (info->src_w << 16) / info->dst_w;
  4465. while (info->dst_h--) {
  4466. Uint32 *src = 0;
  4467. Uint32 *dst = (Uint32 *)info->dst;
  4468. int n = info->dst_w;
  4469. srcx = -1;
  4470. posx = 0x10000L;
  4471. while (posy >= 0x10000L) {
  4472. ++srcy;
  4473. posy -= 0x10000L;
  4474. }
  4475. while (n--) {
  4476. if (posx >= 0x10000L) {
  4477. while (posx >= 0x10000L) {
  4478. ++srcx;
  4479. posx -= 0x10000L;
  4480. }
  4481. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4482. }
  4483. srcpixel = *src;
  4484. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4485. dstpixel = *dst;
  4486. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4487. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4488. /* This goes away if we ever use premultiplied alpha */
  4489. if (srcA < 255) {
  4490. srcR = (srcR * srcA) / 255;
  4491. srcG = (srcG * srcA) / 255;
  4492. srcB = (srcB * srcA) / 255;
  4493. }
  4494. }
  4495. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4496. case SDL_COPY_BLEND:
  4497. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4498. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4499. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4500. dstA = srcA + ((255 - srcA) * dstA) / 255;
  4501. break;
  4502. case SDL_COPY_ADD:
  4503. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4504. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4505. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4506. break;
  4507. case SDL_COPY_MOD:
  4508. dstR = (srcR * dstR) / 255;
  4509. dstG = (srcG * dstG) / 255;
  4510. dstB = (srcB * dstB) / 255;
  4511. break;
  4512. case SDL_COPY_MUL:
  4513. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4514. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4515. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4516. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  4517. break;
  4518. }
  4519. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4520. *dst = dstpixel;
  4521. posx += incx;
  4522. ++dst;
  4523. }
  4524. posy += incy;
  4525. info->dst += info->dst_pitch;
  4526. }
  4527. }
  4528. static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  4529. {
  4530. const int flags = info->flags;
  4531. const Uint32 modulateR = info->r;
  4532. const Uint32 modulateG = info->g;
  4533. const Uint32 modulateB = info->b;
  4534. const Uint32 modulateA = info->a;
  4535. Uint32 pixel;
  4536. Uint32 R, G, B, A;
  4537. while (info->dst_h--) {
  4538. Uint32 *src = (Uint32 *)info->src;
  4539. Uint32 *dst = (Uint32 *)info->dst;
  4540. int n = info->dst_w;
  4541. while (n--) {
  4542. pixel = *src;
  4543. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  4544. if (flags & SDL_COPY_MODULATE_COLOR) {
  4545. R = (R * modulateR) / 255;
  4546. G = (G * modulateG) / 255;
  4547. B = (B * modulateB) / 255;
  4548. }
  4549. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4550. A = (A * modulateA) / 255;
  4551. }
  4552. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  4553. *dst = pixel;
  4554. ++src;
  4555. ++dst;
  4556. }
  4557. info->src += info->src_pitch;
  4558. info->dst += info->dst_pitch;
  4559. }
  4560. }
  4561. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  4562. {
  4563. const int flags = info->flags;
  4564. const Uint32 modulateR = info->r;
  4565. const Uint32 modulateG = info->g;
  4566. const Uint32 modulateB = info->b;
  4567. const Uint32 modulateA = info->a;
  4568. Uint32 pixel;
  4569. Uint32 R, G, B, A;
  4570. int srcy, srcx;
  4571. int posy, posx;
  4572. int incy, incx;
  4573. srcy = 0;
  4574. posy = 0;
  4575. incy = (info->src_h << 16) / info->dst_h;
  4576. incx = (info->src_w << 16) / info->dst_w;
  4577. while (info->dst_h--) {
  4578. Uint32 *src = 0;
  4579. Uint32 *dst = (Uint32 *)info->dst;
  4580. int n = info->dst_w;
  4581. srcx = -1;
  4582. posx = 0x10000L;
  4583. while (posy >= 0x10000L) {
  4584. ++srcy;
  4585. posy -= 0x10000L;
  4586. }
  4587. while (n--) {
  4588. if (posx >= 0x10000L) {
  4589. while (posx >= 0x10000L) {
  4590. ++srcx;
  4591. posx -= 0x10000L;
  4592. }
  4593. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4594. }
  4595. pixel = *src;
  4596. R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  4597. if (flags & SDL_COPY_MODULATE_COLOR) {
  4598. R = (R * modulateR) / 255;
  4599. G = (G * modulateG) / 255;
  4600. B = (B * modulateB) / 255;
  4601. }
  4602. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4603. A = (A * modulateA) / 255;
  4604. }
  4605. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  4606. *dst = pixel;
  4607. posx += incx;
  4608. ++dst;
  4609. }
  4610. posy += incy;
  4611. info->dst += info->dst_pitch;
  4612. }
  4613. }
  4614. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  4615. {
  4616. const int flags = info->flags;
  4617. const Uint32 modulateR = info->r;
  4618. const Uint32 modulateG = info->g;
  4619. const Uint32 modulateB = info->b;
  4620. const Uint32 modulateA = info->a;
  4621. Uint32 srcpixel;
  4622. Uint32 srcR, srcG, srcB, srcA;
  4623. Uint32 dstpixel;
  4624. Uint32 dstR, dstG, dstB, dstA;
  4625. while (info->dst_h--) {
  4626. Uint32 *src = (Uint32 *)info->src;
  4627. Uint32 *dst = (Uint32 *)info->dst;
  4628. int n = info->dst_w;
  4629. while (n--) {
  4630. srcpixel = *src;
  4631. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4632. dstpixel = *dst;
  4633. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4634. if (flags & SDL_COPY_MODULATE_COLOR) {
  4635. srcR = (srcR * modulateR) / 255;
  4636. srcG = (srcG * modulateG) / 255;
  4637. srcB = (srcB * modulateB) / 255;
  4638. }
  4639. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4640. srcA = (srcA * modulateA) / 255;
  4641. }
  4642. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4643. /* This goes away if we ever use premultiplied alpha */
  4644. if (srcA < 255) {
  4645. srcR = (srcR * srcA) / 255;
  4646. srcG = (srcG * srcA) / 255;
  4647. srcB = (srcB * srcA) / 255;
  4648. }
  4649. }
  4650. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4651. case SDL_COPY_BLEND:
  4652. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4653. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4654. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4655. dstA = srcA + ((255 - srcA) * dstA) / 255;
  4656. break;
  4657. case SDL_COPY_ADD:
  4658. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4659. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4660. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4661. break;
  4662. case SDL_COPY_MOD:
  4663. dstR = (srcR * dstR) / 255;
  4664. dstG = (srcG * dstG) / 255;
  4665. dstB = (srcB * dstB) / 255;
  4666. break;
  4667. case SDL_COPY_MUL:
  4668. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4669. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4670. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4671. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  4672. break;
  4673. }
  4674. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4675. *dst = dstpixel;
  4676. ++src;
  4677. ++dst;
  4678. }
  4679. info->src += info->src_pitch;
  4680. info->dst += info->dst_pitch;
  4681. }
  4682. }
  4683. static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  4684. {
  4685. const int flags = info->flags;
  4686. const Uint32 modulateR = info->r;
  4687. const Uint32 modulateG = info->g;
  4688. const Uint32 modulateB = info->b;
  4689. const Uint32 modulateA = info->a;
  4690. Uint32 srcpixel;
  4691. Uint32 srcR, srcG, srcB, srcA;
  4692. Uint32 dstpixel;
  4693. Uint32 dstR, dstG, dstB, dstA;
  4694. int srcy, srcx;
  4695. int posy, posx;
  4696. int incy, incx;
  4697. srcy = 0;
  4698. posy = 0;
  4699. incy = (info->src_h << 16) / info->dst_h;
  4700. incx = (info->src_w << 16) / info->dst_w;
  4701. while (info->dst_h--) {
  4702. Uint32 *src = 0;
  4703. Uint32 *dst = (Uint32 *)info->dst;
  4704. int n = info->dst_w;
  4705. srcx = -1;
  4706. posx = 0x10000L;
  4707. while (posy >= 0x10000L) {
  4708. ++srcy;
  4709. posy -= 0x10000L;
  4710. }
  4711. while (n--) {
  4712. if (posx >= 0x10000L) {
  4713. while (posx >= 0x10000L) {
  4714. ++srcx;
  4715. posx -= 0x10000L;
  4716. }
  4717. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4718. }
  4719. srcpixel = *src;
  4720. srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  4721. dstpixel = *dst;
  4722. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  4723. if (flags & SDL_COPY_MODULATE_COLOR) {
  4724. srcR = (srcR * modulateR) / 255;
  4725. srcG = (srcG * modulateG) / 255;
  4726. srcB = (srcB * modulateB) / 255;
  4727. }
  4728. if (flags & SDL_COPY_MODULATE_ALPHA) {
  4729. srcA = (srcA * modulateA) / 255;
  4730. }
  4731. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4732. /* This goes away if we ever use premultiplied alpha */
  4733. if (srcA < 255) {
  4734. srcR = (srcR * srcA) / 255;
  4735. srcG = (srcG * srcA) / 255;
  4736. srcB = (srcB * srcA) / 255;
  4737. }
  4738. }
  4739. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4740. case SDL_COPY_BLEND:
  4741. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4742. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4743. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4744. dstA = srcA + ((255 - srcA) * dstA) / 255;
  4745. break;
  4746. case SDL_COPY_ADD:
  4747. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4748. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4749. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4750. break;
  4751. case SDL_COPY_MOD:
  4752. dstR = (srcR * dstR) / 255;
  4753. dstG = (srcG * dstG) / 255;
  4754. dstB = (srcB * dstB) / 255;
  4755. break;
  4756. case SDL_COPY_MUL:
  4757. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4758. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4759. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4760. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  4761. break;
  4762. }
  4763. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  4764. *dst = dstpixel;
  4765. posx += incx;
  4766. ++dst;
  4767. }
  4768. posy += incy;
  4769. info->dst += info->dst_pitch;
  4770. }
  4771. }
  4772. static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info)
  4773. {
  4774. Uint32 pixel;
  4775. Uint32 R, G, B;
  4776. int srcy, srcx;
  4777. int posy, posx;
  4778. int incy, incx;
  4779. srcy = 0;
  4780. posy = 0;
  4781. incy = (info->src_h << 16) / info->dst_h;
  4782. incx = (info->src_w << 16) / info->dst_w;
  4783. while (info->dst_h--) {
  4784. Uint32 *src = 0;
  4785. Uint32 *dst = (Uint32 *)info->dst;
  4786. int n = info->dst_w;
  4787. srcx = -1;
  4788. posx = 0x10000L;
  4789. while (posy >= 0x10000L) {
  4790. ++srcy;
  4791. posy -= 0x10000L;
  4792. }
  4793. while (n--) {
  4794. if (posx >= 0x10000L) {
  4795. while (posx >= 0x10000L) {
  4796. ++srcx;
  4797. posx -= 0x10000L;
  4798. }
  4799. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4800. }
  4801. pixel = *src;
  4802. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  4803. pixel = (R << 16) | (G << 8) | B;
  4804. *dst = pixel;
  4805. posx += incx;
  4806. ++dst;
  4807. }
  4808. posy += incy;
  4809. info->dst += info->dst_pitch;
  4810. }
  4811. }
  4812. static void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info)
  4813. {
  4814. const int flags = info->flags;
  4815. Uint32 srcpixel;
  4816. Uint32 srcR, srcG, srcB, srcA;
  4817. Uint32 dstpixel;
  4818. Uint32 dstR, dstG, dstB;
  4819. while (info->dst_h--) {
  4820. Uint32 *src = (Uint32 *)info->src;
  4821. Uint32 *dst = (Uint32 *)info->dst;
  4822. int n = info->dst_w;
  4823. while (n--) {
  4824. srcpixel = *src;
  4825. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4826. dstpixel = *dst;
  4827. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  4828. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4829. /* This goes away if we ever use premultiplied alpha */
  4830. if (srcA < 255) {
  4831. srcR = (srcR * srcA) / 255;
  4832. srcG = (srcG * srcA) / 255;
  4833. srcB = (srcB * srcA) / 255;
  4834. }
  4835. }
  4836. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4837. case SDL_COPY_BLEND:
  4838. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4839. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4840. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4841. break;
  4842. case SDL_COPY_ADD:
  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. dstR = (srcR * dstR) / 255;
  4849. dstG = (srcG * dstG) / 255;
  4850. dstB = (srcB * dstB) / 255;
  4851. break;
  4852. case SDL_COPY_MUL:
  4853. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4854. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4855. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4856. break;
  4857. }
  4858. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  4859. *dst = dstpixel;
  4860. ++src;
  4861. ++dst;
  4862. }
  4863. info->src += info->src_pitch;
  4864. info->dst += info->dst_pitch;
  4865. }
  4866. }
  4867. static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  4868. {
  4869. const int flags = info->flags;
  4870. Uint32 srcpixel;
  4871. Uint32 srcR, srcG, srcB, srcA;
  4872. Uint32 dstpixel;
  4873. Uint32 dstR, dstG, dstB;
  4874. int srcy, srcx;
  4875. int posy, posx;
  4876. int incy, incx;
  4877. srcy = 0;
  4878. posy = 0;
  4879. incy = (info->src_h << 16) / info->dst_h;
  4880. incx = (info->src_w << 16) / info->dst_w;
  4881. while (info->dst_h--) {
  4882. Uint32 *src = 0;
  4883. Uint32 *dst = (Uint32 *)info->dst;
  4884. int n = info->dst_w;
  4885. srcx = -1;
  4886. posx = 0x10000L;
  4887. while (posy >= 0x10000L) {
  4888. ++srcy;
  4889. posy -= 0x10000L;
  4890. }
  4891. while (n--) {
  4892. if (posx >= 0x10000L) {
  4893. while (posx >= 0x10000L) {
  4894. ++srcx;
  4895. posx -= 0x10000L;
  4896. }
  4897. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  4898. }
  4899. srcpixel = *src;
  4900. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  4901. dstpixel = *dst;
  4902. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  4903. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  4904. /* This goes away if we ever use premultiplied alpha */
  4905. if (srcA < 255) {
  4906. srcR = (srcR * srcA) / 255;
  4907. srcG = (srcG * srcA) / 255;
  4908. srcB = (srcB * srcA) / 255;
  4909. }
  4910. }
  4911. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  4912. case SDL_COPY_BLEND:
  4913. dstR = srcR + ((255 - srcA) * dstR) / 255;
  4914. dstG = srcG + ((255 - srcA) * dstG) / 255;
  4915. dstB = srcB + ((255 - srcA) * dstB) / 255;
  4916. break;
  4917. case SDL_COPY_ADD:
  4918. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  4919. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  4920. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  4921. break;
  4922. case SDL_COPY_MOD:
  4923. dstR = (srcR * dstR) / 255;
  4924. dstG = (srcG * dstG) / 255;
  4925. dstB = (srcB * dstB) / 255;
  4926. break;
  4927. case SDL_COPY_MUL:
  4928. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  4929. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  4930. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  4931. break;
  4932. }
  4933. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  4934. *dst = dstpixel;
  4935. posx += incx;
  4936. ++dst;
  4937. }
  4938. posy += incy;
  4939. info->dst += info->dst_pitch;
  4940. }
  4941. }
  4942. static void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info)
  4943. {
  4944. const int flags = info->flags;
  4945. const Uint32 modulateR = info->r;
  4946. const Uint32 modulateG = info->g;
  4947. const Uint32 modulateB = info->b;
  4948. Uint32 pixel;
  4949. Uint32 R, G, B;
  4950. while (info->dst_h--) {
  4951. Uint32 *src = (Uint32 *)info->src;
  4952. Uint32 *dst = (Uint32 *)info->dst;
  4953. int n = info->dst_w;
  4954. while (n--) {
  4955. pixel = *src;
  4956. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  4957. if (flags & SDL_COPY_MODULATE_COLOR) {
  4958. R = (R * modulateR) / 255;
  4959. G = (G * modulateG) / 255;
  4960. B = (B * modulateB) / 255;
  4961. }
  4962. pixel = (R << 16) | (G << 8) | B;
  4963. *dst = pixel;
  4964. ++src;
  4965. ++dst;
  4966. }
  4967. info->src += info->src_pitch;
  4968. info->dst += info->dst_pitch;
  4969. }
  4970. }
  4971. static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  4972. {
  4973. const int flags = info->flags;
  4974. const Uint32 modulateR = info->r;
  4975. const Uint32 modulateG = info->g;
  4976. const Uint32 modulateB = info->b;
  4977. Uint32 pixel;
  4978. Uint32 R, G, B;
  4979. int srcy, srcx;
  4980. int posy, posx;
  4981. int incy, incx;
  4982. srcy = 0;
  4983. posy = 0;
  4984. incy = (info->src_h << 16) / info->dst_h;
  4985. incx = (info->src_w << 16) / info->dst_w;
  4986. while (info->dst_h--) {
  4987. Uint32 *src = 0;
  4988. Uint32 *dst = (Uint32 *)info->dst;
  4989. int n = info->dst_w;
  4990. srcx = -1;
  4991. posx = 0x10000L;
  4992. while (posy >= 0x10000L) {
  4993. ++srcy;
  4994. posy -= 0x10000L;
  4995. }
  4996. while (n--) {
  4997. if (posx >= 0x10000L) {
  4998. while (posx >= 0x10000L) {
  4999. ++srcx;
  5000. posx -= 0x10000L;
  5001. }
  5002. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5003. }
  5004. pixel = *src;
  5005. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5006. if (flags & SDL_COPY_MODULATE_COLOR) {
  5007. R = (R * modulateR) / 255;
  5008. G = (G * modulateG) / 255;
  5009. B = (B * modulateB) / 255;
  5010. }
  5011. pixel = (R << 16) | (G << 8) | B;
  5012. *dst = pixel;
  5013. posx += incx;
  5014. ++dst;
  5015. }
  5016. posy += incy;
  5017. info->dst += info->dst_pitch;
  5018. }
  5019. }
  5020. static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  5021. {
  5022. const int flags = info->flags;
  5023. const Uint32 modulateR = info->r;
  5024. const Uint32 modulateG = info->g;
  5025. const Uint32 modulateB = info->b;
  5026. const Uint32 modulateA = info->a;
  5027. Uint32 srcpixel;
  5028. Uint32 srcR, srcG, srcB, srcA;
  5029. Uint32 dstpixel;
  5030. Uint32 dstR, dstG, dstB;
  5031. while (info->dst_h--) {
  5032. Uint32 *src = (Uint32 *)info->src;
  5033. Uint32 *dst = (Uint32 *)info->dst;
  5034. int n = info->dst_w;
  5035. while (n--) {
  5036. srcpixel = *src;
  5037. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5038. dstpixel = *dst;
  5039. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5040. if (flags & SDL_COPY_MODULATE_COLOR) {
  5041. srcR = (srcR * modulateR) / 255;
  5042. srcG = (srcG * modulateG) / 255;
  5043. srcB = (srcB * modulateB) / 255;
  5044. }
  5045. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5046. srcA = (srcA * modulateA) / 255;
  5047. }
  5048. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5049. /* This goes away if we ever use premultiplied alpha */
  5050. if (srcA < 255) {
  5051. srcR = (srcR * srcA) / 255;
  5052. srcG = (srcG * srcA) / 255;
  5053. srcB = (srcB * srcA) / 255;
  5054. }
  5055. }
  5056. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5057. case SDL_COPY_BLEND:
  5058. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5059. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5060. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5061. break;
  5062. case SDL_COPY_ADD:
  5063. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5064. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5065. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5066. break;
  5067. case SDL_COPY_MOD:
  5068. dstR = (srcR * dstR) / 255;
  5069. dstG = (srcG * dstG) / 255;
  5070. dstB = (srcB * dstB) / 255;
  5071. break;
  5072. case SDL_COPY_MUL:
  5073. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5074. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5075. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5076. break;
  5077. }
  5078. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5079. *dst = dstpixel;
  5080. ++src;
  5081. ++dst;
  5082. }
  5083. info->src += info->src_pitch;
  5084. info->dst += info->dst_pitch;
  5085. }
  5086. }
  5087. static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5088. {
  5089. const int flags = info->flags;
  5090. const Uint32 modulateR = info->r;
  5091. const Uint32 modulateG = info->g;
  5092. const Uint32 modulateB = info->b;
  5093. const Uint32 modulateA = info->a;
  5094. Uint32 srcpixel;
  5095. Uint32 srcR, srcG, srcB, srcA;
  5096. Uint32 dstpixel;
  5097. Uint32 dstR, dstG, dstB;
  5098. int srcy, srcx;
  5099. int posy, posx;
  5100. int incy, incx;
  5101. srcy = 0;
  5102. posy = 0;
  5103. incy = (info->src_h << 16) / info->dst_h;
  5104. incx = (info->src_w << 16) / info->dst_w;
  5105. while (info->dst_h--) {
  5106. Uint32 *src = 0;
  5107. Uint32 *dst = (Uint32 *)info->dst;
  5108. int n = info->dst_w;
  5109. srcx = -1;
  5110. posx = 0x10000L;
  5111. while (posy >= 0x10000L) {
  5112. ++srcy;
  5113. posy -= 0x10000L;
  5114. }
  5115. while (n--) {
  5116. if (posx >= 0x10000L) {
  5117. while (posx >= 0x10000L) {
  5118. ++srcx;
  5119. posx -= 0x10000L;
  5120. }
  5121. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5122. }
  5123. srcpixel = *src;
  5124. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5125. dstpixel = *dst;
  5126. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  5127. if (flags & SDL_COPY_MODULATE_COLOR) {
  5128. srcR = (srcR * modulateR) / 255;
  5129. srcG = (srcG * modulateG) / 255;
  5130. srcB = (srcB * modulateB) / 255;
  5131. }
  5132. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5133. srcA = (srcA * modulateA) / 255;
  5134. }
  5135. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5136. /* This goes away if we ever use premultiplied alpha */
  5137. if (srcA < 255) {
  5138. srcR = (srcR * srcA) / 255;
  5139. srcG = (srcG * srcA) / 255;
  5140. srcB = (srcB * srcA) / 255;
  5141. }
  5142. }
  5143. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5144. case SDL_COPY_BLEND:
  5145. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5146. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5147. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5148. break;
  5149. case SDL_COPY_ADD:
  5150. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5151. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5152. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5153. break;
  5154. case SDL_COPY_MOD:
  5155. dstR = (srcR * dstR) / 255;
  5156. dstG = (srcG * dstG) / 255;
  5157. dstB = (srcB * dstB) / 255;
  5158. break;
  5159. case SDL_COPY_MUL:
  5160. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5161. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5162. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5163. break;
  5164. }
  5165. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  5166. *dst = dstpixel;
  5167. posx += incx;
  5168. ++dst;
  5169. }
  5170. posy += incy;
  5171. info->dst += info->dst_pitch;
  5172. }
  5173. }
  5174. static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
  5175. {
  5176. Uint32 pixel;
  5177. Uint32 R, G, B;
  5178. int srcy, srcx;
  5179. int posy, posx;
  5180. int incy, incx;
  5181. srcy = 0;
  5182. posy = 0;
  5183. incy = (info->src_h << 16) / info->dst_h;
  5184. incx = (info->src_w << 16) / info->dst_w;
  5185. while (info->dst_h--) {
  5186. Uint32 *src = 0;
  5187. Uint32 *dst = (Uint32 *)info->dst;
  5188. int n = info->dst_w;
  5189. srcx = -1;
  5190. posx = 0x10000L;
  5191. while (posy >= 0x10000L) {
  5192. ++srcy;
  5193. posy -= 0x10000L;
  5194. }
  5195. while (n--) {
  5196. if (posx >= 0x10000L) {
  5197. while (posx >= 0x10000L) {
  5198. ++srcx;
  5199. posx -= 0x10000L;
  5200. }
  5201. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5202. }
  5203. pixel = *src;
  5204. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5205. pixel = (B << 16) | (G << 8) | R;
  5206. *dst = pixel;
  5207. posx += incx;
  5208. ++dst;
  5209. }
  5210. posy += incy;
  5211. info->dst += info->dst_pitch;
  5212. }
  5213. }
  5214. static void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info)
  5215. {
  5216. const int flags = info->flags;
  5217. Uint32 srcpixel;
  5218. Uint32 srcR, srcG, srcB, srcA;
  5219. Uint32 dstpixel;
  5220. Uint32 dstR, dstG, dstB;
  5221. while (info->dst_h--) {
  5222. Uint32 *src = (Uint32 *)info->src;
  5223. Uint32 *dst = (Uint32 *)info->dst;
  5224. int n = info->dst_w;
  5225. while (n--) {
  5226. srcpixel = *src;
  5227. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5228. dstpixel = *dst;
  5229. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5230. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5231. /* This goes away if we ever use premultiplied alpha */
  5232. if (srcA < 255) {
  5233. srcR = (srcR * srcA) / 255;
  5234. srcG = (srcG * srcA) / 255;
  5235. srcB = (srcB * srcA) / 255;
  5236. }
  5237. }
  5238. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5239. case SDL_COPY_BLEND:
  5240. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5241. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5242. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5243. break;
  5244. case SDL_COPY_ADD:
  5245. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5246. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5247. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5248. break;
  5249. case SDL_COPY_MOD:
  5250. dstR = (srcR * dstR) / 255;
  5251. dstG = (srcG * dstG) / 255;
  5252. dstB = (srcB * dstB) / 255;
  5253. break;
  5254. case SDL_COPY_MUL:
  5255. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5256. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5257. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5258. break;
  5259. }
  5260. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5261. *dst = dstpixel;
  5262. ++src;
  5263. ++dst;
  5264. }
  5265. info->src += info->src_pitch;
  5266. info->dst += info->dst_pitch;
  5267. }
  5268. }
  5269. static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  5270. {
  5271. const int flags = info->flags;
  5272. Uint32 srcpixel;
  5273. Uint32 srcR, srcG, srcB, srcA;
  5274. Uint32 dstpixel;
  5275. Uint32 dstR, dstG, dstB;
  5276. int srcy, srcx;
  5277. int posy, posx;
  5278. int incy, incx;
  5279. srcy = 0;
  5280. posy = 0;
  5281. incy = (info->src_h << 16) / info->dst_h;
  5282. incx = (info->src_w << 16) / info->dst_w;
  5283. while (info->dst_h--) {
  5284. Uint32 *src = 0;
  5285. Uint32 *dst = (Uint32 *)info->dst;
  5286. int n = info->dst_w;
  5287. srcx = -1;
  5288. posx = 0x10000L;
  5289. while (posy >= 0x10000L) {
  5290. ++srcy;
  5291. posy -= 0x10000L;
  5292. }
  5293. while (n--) {
  5294. if (posx >= 0x10000L) {
  5295. while (posx >= 0x10000L) {
  5296. ++srcx;
  5297. posx -= 0x10000L;
  5298. }
  5299. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5300. }
  5301. srcpixel = *src;
  5302. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5303. dstpixel = *dst;
  5304. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5305. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5306. /* This goes away if we ever use premultiplied alpha */
  5307. if (srcA < 255) {
  5308. srcR = (srcR * srcA) / 255;
  5309. srcG = (srcG * srcA) / 255;
  5310. srcB = (srcB * srcA) / 255;
  5311. }
  5312. }
  5313. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5314. case SDL_COPY_BLEND:
  5315. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5316. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5317. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5318. break;
  5319. case SDL_COPY_ADD:
  5320. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5321. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5322. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5323. break;
  5324. case SDL_COPY_MOD:
  5325. dstR = (srcR * dstR) / 255;
  5326. dstG = (srcG * dstG) / 255;
  5327. dstB = (srcB * dstB) / 255;
  5328. break;
  5329. case SDL_COPY_MUL:
  5330. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5331. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5332. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5333. break;
  5334. }
  5335. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5336. *dst = dstpixel;
  5337. posx += incx;
  5338. ++dst;
  5339. }
  5340. posy += incy;
  5341. info->dst += info->dst_pitch;
  5342. }
  5343. }
  5344. static void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info)
  5345. {
  5346. const int flags = info->flags;
  5347. const Uint32 modulateR = info->r;
  5348. const Uint32 modulateG = info->g;
  5349. const Uint32 modulateB = info->b;
  5350. Uint32 pixel;
  5351. Uint32 R, G, B;
  5352. while (info->dst_h--) {
  5353. Uint32 *src = (Uint32 *)info->src;
  5354. Uint32 *dst = (Uint32 *)info->dst;
  5355. int n = info->dst_w;
  5356. while (n--) {
  5357. pixel = *src;
  5358. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5359. if (flags & SDL_COPY_MODULATE_COLOR) {
  5360. R = (R * modulateR) / 255;
  5361. G = (G * modulateG) / 255;
  5362. B = (B * modulateB) / 255;
  5363. }
  5364. pixel = (B << 16) | (G << 8) | R;
  5365. *dst = pixel;
  5366. ++src;
  5367. ++dst;
  5368. }
  5369. info->src += info->src_pitch;
  5370. info->dst += info->dst_pitch;
  5371. }
  5372. }
  5373. static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  5374. {
  5375. const int flags = info->flags;
  5376. const Uint32 modulateR = info->r;
  5377. const Uint32 modulateG = info->g;
  5378. const Uint32 modulateB = info->b;
  5379. Uint32 pixel;
  5380. Uint32 R, G, B;
  5381. int srcy, srcx;
  5382. int posy, posx;
  5383. int incy, incx;
  5384. srcy = 0;
  5385. posy = 0;
  5386. incy = (info->src_h << 16) / info->dst_h;
  5387. incx = (info->src_w << 16) / info->dst_w;
  5388. while (info->dst_h--) {
  5389. Uint32 *src = 0;
  5390. Uint32 *dst = (Uint32 *)info->dst;
  5391. int n = info->dst_w;
  5392. srcx = -1;
  5393. posx = 0x10000L;
  5394. while (posy >= 0x10000L) {
  5395. ++srcy;
  5396. posy -= 0x10000L;
  5397. }
  5398. while (n--) {
  5399. if (posx >= 0x10000L) {
  5400. while (posx >= 0x10000L) {
  5401. ++srcx;
  5402. posx -= 0x10000L;
  5403. }
  5404. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5405. }
  5406. pixel = *src;
  5407. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  5408. if (flags & SDL_COPY_MODULATE_COLOR) {
  5409. R = (R * modulateR) / 255;
  5410. G = (G * modulateG) / 255;
  5411. B = (B * modulateB) / 255;
  5412. }
  5413. pixel = (B << 16) | (G << 8) | R;
  5414. *dst = pixel;
  5415. posx += incx;
  5416. ++dst;
  5417. }
  5418. posy += incy;
  5419. info->dst += info->dst_pitch;
  5420. }
  5421. }
  5422. static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  5423. {
  5424. const int flags = info->flags;
  5425. const Uint32 modulateR = info->r;
  5426. const Uint32 modulateG = info->g;
  5427. const Uint32 modulateB = info->b;
  5428. const Uint32 modulateA = info->a;
  5429. Uint32 srcpixel;
  5430. Uint32 srcR, srcG, srcB, srcA;
  5431. Uint32 dstpixel;
  5432. Uint32 dstR, dstG, dstB;
  5433. while (info->dst_h--) {
  5434. Uint32 *src = (Uint32 *)info->src;
  5435. Uint32 *dst = (Uint32 *)info->dst;
  5436. int n = info->dst_w;
  5437. while (n--) {
  5438. srcpixel = *src;
  5439. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5440. dstpixel = *dst;
  5441. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5442. if (flags & SDL_COPY_MODULATE_COLOR) {
  5443. srcR = (srcR * modulateR) / 255;
  5444. srcG = (srcG * modulateG) / 255;
  5445. srcB = (srcB * modulateB) / 255;
  5446. }
  5447. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5448. srcA = (srcA * modulateA) / 255;
  5449. }
  5450. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5451. /* This goes away if we ever use premultiplied alpha */
  5452. if (srcA < 255) {
  5453. srcR = (srcR * srcA) / 255;
  5454. srcG = (srcG * srcA) / 255;
  5455. srcB = (srcB * srcA) / 255;
  5456. }
  5457. }
  5458. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5459. case SDL_COPY_BLEND:
  5460. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5461. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5462. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5463. break;
  5464. case SDL_COPY_ADD:
  5465. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5466. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5467. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5468. break;
  5469. case SDL_COPY_MOD:
  5470. dstR = (srcR * dstR) / 255;
  5471. dstG = (srcG * dstG) / 255;
  5472. dstB = (srcB * dstB) / 255;
  5473. break;
  5474. case SDL_COPY_MUL:
  5475. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5476. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5477. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5478. break;
  5479. }
  5480. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5481. *dst = dstpixel;
  5482. ++src;
  5483. ++dst;
  5484. }
  5485. info->src += info->src_pitch;
  5486. info->dst += info->dst_pitch;
  5487. }
  5488. }
  5489. static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5490. {
  5491. const int flags = info->flags;
  5492. const Uint32 modulateR = info->r;
  5493. const Uint32 modulateG = info->g;
  5494. const Uint32 modulateB = info->b;
  5495. const Uint32 modulateA = info->a;
  5496. Uint32 srcpixel;
  5497. Uint32 srcR, srcG, srcB, srcA;
  5498. Uint32 dstpixel;
  5499. Uint32 dstR, dstG, dstB;
  5500. int srcy, srcx;
  5501. int posy, posx;
  5502. int incy, incx;
  5503. srcy = 0;
  5504. posy = 0;
  5505. incy = (info->src_h << 16) / info->dst_h;
  5506. incx = (info->src_w << 16) / info->dst_w;
  5507. while (info->dst_h--) {
  5508. Uint32 *src = 0;
  5509. Uint32 *dst = (Uint32 *)info->dst;
  5510. int n = info->dst_w;
  5511. srcx = -1;
  5512. posx = 0x10000L;
  5513. while (posy >= 0x10000L) {
  5514. ++srcy;
  5515. posy -= 0x10000L;
  5516. }
  5517. while (n--) {
  5518. if (posx >= 0x10000L) {
  5519. while (posx >= 0x10000L) {
  5520. ++srcx;
  5521. posx -= 0x10000L;
  5522. }
  5523. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5524. }
  5525. srcpixel = *src;
  5526. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5527. dstpixel = *dst;
  5528. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  5529. if (flags & SDL_COPY_MODULATE_COLOR) {
  5530. srcR = (srcR * modulateR) / 255;
  5531. srcG = (srcG * modulateG) / 255;
  5532. srcB = (srcB * modulateB) / 255;
  5533. }
  5534. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5535. srcA = (srcA * modulateA) / 255;
  5536. }
  5537. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5538. /* This goes away if we ever use premultiplied alpha */
  5539. if (srcA < 255) {
  5540. srcR = (srcR * srcA) / 255;
  5541. srcG = (srcG * srcA) / 255;
  5542. srcB = (srcB * srcA) / 255;
  5543. }
  5544. }
  5545. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5546. case SDL_COPY_BLEND:
  5547. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5548. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5549. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5550. break;
  5551. case SDL_COPY_ADD:
  5552. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5553. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5554. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5555. break;
  5556. case SDL_COPY_MOD:
  5557. dstR = (srcR * dstR) / 255;
  5558. dstG = (srcG * dstG) / 255;
  5559. dstB = (srcB * dstB) / 255;
  5560. break;
  5561. case SDL_COPY_MUL:
  5562. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5563. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5564. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5565. break;
  5566. }
  5567. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  5568. *dst = dstpixel;
  5569. posx += incx;
  5570. ++dst;
  5571. }
  5572. posy += incy;
  5573. info->dst += info->dst_pitch;
  5574. }
  5575. }
  5576. static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
  5577. {
  5578. Uint32 pixel;
  5579. Uint32 R, G, B, A;
  5580. int srcy, srcx;
  5581. int posy, posx;
  5582. int incy, incx;
  5583. srcy = 0;
  5584. posy = 0;
  5585. incy = (info->src_h << 16) / info->dst_h;
  5586. incx = (info->src_w << 16) / info->dst_w;
  5587. while (info->dst_h--) {
  5588. Uint32 *src = 0;
  5589. Uint32 *dst = (Uint32 *)info->dst;
  5590. int n = info->dst_w;
  5591. srcx = -1;
  5592. posx = 0x10000L;
  5593. while (posy >= 0x10000L) {
  5594. ++srcy;
  5595. posy -= 0x10000L;
  5596. }
  5597. while (n--) {
  5598. if (posx >= 0x10000L) {
  5599. while (posx >= 0x10000L) {
  5600. ++srcx;
  5601. posx -= 0x10000L;
  5602. }
  5603. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5604. }
  5605. pixel = *src;
  5606. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  5607. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  5608. *dst = pixel;
  5609. posx += incx;
  5610. ++dst;
  5611. }
  5612. posy += incy;
  5613. info->dst += info->dst_pitch;
  5614. }
  5615. }
  5616. static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
  5617. {
  5618. const int flags = info->flags;
  5619. Uint32 srcpixel;
  5620. Uint32 srcR, srcG, srcB, srcA;
  5621. Uint32 dstpixel;
  5622. Uint32 dstR, dstG, dstB, dstA;
  5623. while (info->dst_h--) {
  5624. Uint32 *src = (Uint32 *)info->src;
  5625. Uint32 *dst = (Uint32 *)info->dst;
  5626. int n = info->dst_w;
  5627. while (n--) {
  5628. srcpixel = *src;
  5629. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5630. dstpixel = *dst;
  5631. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  5632. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5633. /* This goes away if we ever use premultiplied alpha */
  5634. if (srcA < 255) {
  5635. srcR = (srcR * srcA) / 255;
  5636. srcG = (srcG * srcA) / 255;
  5637. srcB = (srcB * srcA) / 255;
  5638. }
  5639. }
  5640. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5641. case SDL_COPY_BLEND:
  5642. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5643. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5644. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5645. dstA = srcA + ((255 - srcA) * dstA) / 255;
  5646. break;
  5647. case SDL_COPY_ADD:
  5648. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5649. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5650. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5651. break;
  5652. case SDL_COPY_MOD:
  5653. dstR = (srcR * dstR) / 255;
  5654. dstG = (srcG * dstG) / 255;
  5655. dstB = (srcB * dstB) / 255;
  5656. break;
  5657. case SDL_COPY_MUL:
  5658. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5659. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5660. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5661. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  5662. break;
  5663. }
  5664. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  5665. *dst = dstpixel;
  5666. ++src;
  5667. ++dst;
  5668. }
  5669. info->src += info->src_pitch;
  5670. info->dst += info->dst_pitch;
  5671. }
  5672. }
  5673. static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  5674. {
  5675. const int flags = info->flags;
  5676. Uint32 srcpixel;
  5677. Uint32 srcR, srcG, srcB, srcA;
  5678. Uint32 dstpixel;
  5679. Uint32 dstR, dstG, dstB, dstA;
  5680. int srcy, srcx;
  5681. int posy, posx;
  5682. int incy, incx;
  5683. srcy = 0;
  5684. posy = 0;
  5685. incy = (info->src_h << 16) / info->dst_h;
  5686. incx = (info->src_w << 16) / info->dst_w;
  5687. while (info->dst_h--) {
  5688. Uint32 *src = 0;
  5689. Uint32 *dst = (Uint32 *)info->dst;
  5690. int n = info->dst_w;
  5691. srcx = -1;
  5692. posx = 0x10000L;
  5693. while (posy >= 0x10000L) {
  5694. ++srcy;
  5695. posy -= 0x10000L;
  5696. }
  5697. while (n--) {
  5698. if (posx >= 0x10000L) {
  5699. while (posx >= 0x10000L) {
  5700. ++srcx;
  5701. posx -= 0x10000L;
  5702. }
  5703. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5704. }
  5705. srcpixel = *src;
  5706. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5707. dstpixel = *dst;
  5708. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  5709. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5710. /* This goes away if we ever use premultiplied alpha */
  5711. if (srcA < 255) {
  5712. srcR = (srcR * srcA) / 255;
  5713. srcG = (srcG * srcA) / 255;
  5714. srcB = (srcB * srcA) / 255;
  5715. }
  5716. }
  5717. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5718. case SDL_COPY_BLEND:
  5719. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5720. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5721. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5722. dstA = srcA + ((255 - srcA) * dstA) / 255;
  5723. break;
  5724. case SDL_COPY_ADD:
  5725. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5726. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5727. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5728. break;
  5729. case SDL_COPY_MOD:
  5730. dstR = (srcR * dstR) / 255;
  5731. dstG = (srcG * dstG) / 255;
  5732. dstB = (srcB * dstB) / 255;
  5733. break;
  5734. case SDL_COPY_MUL:
  5735. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5736. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5737. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5738. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  5739. break;
  5740. }
  5741. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  5742. *dst = dstpixel;
  5743. posx += incx;
  5744. ++dst;
  5745. }
  5746. posy += incy;
  5747. info->dst += info->dst_pitch;
  5748. }
  5749. }
  5750. static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  5751. {
  5752. const int flags = info->flags;
  5753. const Uint32 modulateR = info->r;
  5754. const Uint32 modulateG = info->g;
  5755. const Uint32 modulateB = info->b;
  5756. const Uint32 modulateA = info->a;
  5757. Uint32 pixel;
  5758. Uint32 R, G, B, A;
  5759. while (info->dst_h--) {
  5760. Uint32 *src = (Uint32 *)info->src;
  5761. Uint32 *dst = (Uint32 *)info->dst;
  5762. int n = info->dst_w;
  5763. while (n--) {
  5764. pixel = *src;
  5765. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  5766. if (flags & SDL_COPY_MODULATE_COLOR) {
  5767. R = (R * modulateR) / 255;
  5768. G = (G * modulateG) / 255;
  5769. B = (B * modulateB) / 255;
  5770. }
  5771. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5772. A = (A * modulateA) / 255;
  5773. }
  5774. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  5775. *dst = pixel;
  5776. ++src;
  5777. ++dst;
  5778. }
  5779. info->src += info->src_pitch;
  5780. info->dst += info->dst_pitch;
  5781. }
  5782. }
  5783. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  5784. {
  5785. const int flags = info->flags;
  5786. const Uint32 modulateR = info->r;
  5787. const Uint32 modulateG = info->g;
  5788. const Uint32 modulateB = info->b;
  5789. const Uint32 modulateA = info->a;
  5790. Uint32 pixel;
  5791. Uint32 R, G, B, A;
  5792. int srcy, srcx;
  5793. int posy, posx;
  5794. int incy, incx;
  5795. srcy = 0;
  5796. posy = 0;
  5797. incy = (info->src_h << 16) / info->dst_h;
  5798. incx = (info->src_w << 16) / info->dst_w;
  5799. while (info->dst_h--) {
  5800. Uint32 *src = 0;
  5801. Uint32 *dst = (Uint32 *)info->dst;
  5802. int n = info->dst_w;
  5803. srcx = -1;
  5804. posx = 0x10000L;
  5805. while (posy >= 0x10000L) {
  5806. ++srcy;
  5807. posy -= 0x10000L;
  5808. }
  5809. while (n--) {
  5810. if (posx >= 0x10000L) {
  5811. while (posx >= 0x10000L) {
  5812. ++srcx;
  5813. posx -= 0x10000L;
  5814. }
  5815. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5816. }
  5817. pixel = *src;
  5818. B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
  5819. if (flags & SDL_COPY_MODULATE_COLOR) {
  5820. R = (R * modulateR) / 255;
  5821. G = (G * modulateG) / 255;
  5822. B = (B * modulateB) / 255;
  5823. }
  5824. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5825. A = (A * modulateA) / 255;
  5826. }
  5827. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  5828. *dst = pixel;
  5829. posx += incx;
  5830. ++dst;
  5831. }
  5832. posy += incy;
  5833. info->dst += info->dst_pitch;
  5834. }
  5835. }
  5836. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  5837. {
  5838. const int flags = info->flags;
  5839. const Uint32 modulateR = info->r;
  5840. const Uint32 modulateG = info->g;
  5841. const Uint32 modulateB = info->b;
  5842. const Uint32 modulateA = info->a;
  5843. Uint32 srcpixel;
  5844. Uint32 srcR, srcG, srcB, srcA;
  5845. Uint32 dstpixel;
  5846. Uint32 dstR, dstG, dstB, dstA;
  5847. while (info->dst_h--) {
  5848. Uint32 *src = (Uint32 *)info->src;
  5849. Uint32 *dst = (Uint32 *)info->dst;
  5850. int n = info->dst_w;
  5851. while (n--) {
  5852. srcpixel = *src;
  5853. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5854. dstpixel = *dst;
  5855. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  5856. if (flags & SDL_COPY_MODULATE_COLOR) {
  5857. srcR = (srcR * modulateR) / 255;
  5858. srcG = (srcG * modulateG) / 255;
  5859. srcB = (srcB * modulateB) / 255;
  5860. }
  5861. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5862. srcA = (srcA * modulateA) / 255;
  5863. }
  5864. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5865. /* This goes away if we ever use premultiplied alpha */
  5866. if (srcA < 255) {
  5867. srcR = (srcR * srcA) / 255;
  5868. srcG = (srcG * srcA) / 255;
  5869. srcB = (srcB * srcA) / 255;
  5870. }
  5871. }
  5872. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5873. case SDL_COPY_BLEND:
  5874. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5875. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5876. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5877. dstA = srcA + ((255 - srcA) * dstA) / 255;
  5878. break;
  5879. case SDL_COPY_ADD:
  5880. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5881. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5882. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5883. break;
  5884. case SDL_COPY_MOD:
  5885. dstR = (srcR * dstR) / 255;
  5886. dstG = (srcG * dstG) / 255;
  5887. dstB = (srcB * dstB) / 255;
  5888. break;
  5889. case SDL_COPY_MUL:
  5890. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5891. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5892. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5893. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  5894. break;
  5895. }
  5896. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  5897. *dst = dstpixel;
  5898. ++src;
  5899. ++dst;
  5900. }
  5901. info->src += info->src_pitch;
  5902. info->dst += info->dst_pitch;
  5903. }
  5904. }
  5905. static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  5906. {
  5907. const int flags = info->flags;
  5908. const Uint32 modulateR = info->r;
  5909. const Uint32 modulateG = info->g;
  5910. const Uint32 modulateB = info->b;
  5911. const Uint32 modulateA = info->a;
  5912. Uint32 srcpixel;
  5913. Uint32 srcR, srcG, srcB, srcA;
  5914. Uint32 dstpixel;
  5915. Uint32 dstR, dstG, dstB, dstA;
  5916. int srcy, srcx;
  5917. int posy, posx;
  5918. int incy, incx;
  5919. srcy = 0;
  5920. posy = 0;
  5921. incy = (info->src_h << 16) / info->dst_h;
  5922. incx = (info->src_w << 16) / info->dst_w;
  5923. while (info->dst_h--) {
  5924. Uint32 *src = 0;
  5925. Uint32 *dst = (Uint32 *)info->dst;
  5926. int n = info->dst_w;
  5927. srcx = -1;
  5928. posx = 0x10000L;
  5929. while (posy >= 0x10000L) {
  5930. ++srcy;
  5931. posy -= 0x10000L;
  5932. }
  5933. while (n--) {
  5934. if (posx >= 0x10000L) {
  5935. while (posx >= 0x10000L) {
  5936. ++srcx;
  5937. posx -= 0x10000L;
  5938. }
  5939. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  5940. }
  5941. srcpixel = *src;
  5942. srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
  5943. dstpixel = *dst;
  5944. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  5945. if (flags & SDL_COPY_MODULATE_COLOR) {
  5946. srcR = (srcR * modulateR) / 255;
  5947. srcG = (srcG * modulateG) / 255;
  5948. srcB = (srcB * modulateB) / 255;
  5949. }
  5950. if (flags & SDL_COPY_MODULATE_ALPHA) {
  5951. srcA = (srcA * modulateA) / 255;
  5952. }
  5953. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  5954. /* This goes away if we ever use premultiplied alpha */
  5955. if (srcA < 255) {
  5956. srcR = (srcR * srcA) / 255;
  5957. srcG = (srcG * srcA) / 255;
  5958. srcB = (srcB * srcA) / 255;
  5959. }
  5960. }
  5961. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  5962. case SDL_COPY_BLEND:
  5963. dstR = srcR + ((255 - srcA) * dstR) / 255;
  5964. dstG = srcG + ((255 - srcA) * dstG) / 255;
  5965. dstB = srcB + ((255 - srcA) * dstB) / 255;
  5966. dstA = srcA + ((255 - srcA) * dstA) / 255;
  5967. break;
  5968. case SDL_COPY_ADD:
  5969. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  5970. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  5971. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  5972. break;
  5973. case SDL_COPY_MOD:
  5974. dstR = (srcR * dstR) / 255;
  5975. dstG = (srcG * dstG) / 255;
  5976. dstB = (srcB * dstB) / 255;
  5977. break;
  5978. case SDL_COPY_MUL:
  5979. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  5980. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  5981. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  5982. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  5983. break;
  5984. }
  5985. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  5986. *dst = dstpixel;
  5987. posx += incx;
  5988. ++dst;
  5989. }
  5990. posy += incy;
  5991. info->dst += info->dst_pitch;
  5992. }
  5993. }
  5994. static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info)
  5995. {
  5996. Uint32 pixel;
  5997. Uint32 R, G, B;
  5998. int srcy, srcx;
  5999. int posy, posx;
  6000. int incy, incx;
  6001. srcy = 0;
  6002. posy = 0;
  6003. incy = (info->src_h << 16) / info->dst_h;
  6004. incx = (info->src_w << 16) / info->dst_w;
  6005. while (info->dst_h--) {
  6006. Uint32 *src = 0;
  6007. Uint32 *dst = (Uint32 *)info->dst;
  6008. int n = info->dst_w;
  6009. srcx = -1;
  6010. posx = 0x10000L;
  6011. while (posy >= 0x10000L) {
  6012. ++srcy;
  6013. posy -= 0x10000L;
  6014. }
  6015. while (n--) {
  6016. if (posx >= 0x10000L) {
  6017. while (posx >= 0x10000L) {
  6018. ++srcx;
  6019. posx -= 0x10000L;
  6020. }
  6021. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6022. }
  6023. pixel = *src;
  6024. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  6025. pixel = (R << 16) | (G << 8) | B;
  6026. *dst = pixel;
  6027. posx += incx;
  6028. ++dst;
  6029. }
  6030. posy += incy;
  6031. info->dst += info->dst_pitch;
  6032. }
  6033. }
  6034. static void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info)
  6035. {
  6036. const int flags = info->flags;
  6037. Uint32 srcpixel;
  6038. Uint32 srcR, srcG, srcB, srcA;
  6039. Uint32 dstpixel;
  6040. Uint32 dstR, dstG, dstB;
  6041. while (info->dst_h--) {
  6042. Uint32 *src = (Uint32 *)info->src;
  6043. Uint32 *dst = (Uint32 *)info->dst;
  6044. int n = info->dst_w;
  6045. while (n--) {
  6046. srcpixel = *src;
  6047. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6048. dstpixel = *dst;
  6049. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  6050. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6051. /* This goes away if we ever use premultiplied alpha */
  6052. if (srcA < 255) {
  6053. srcR = (srcR * srcA) / 255;
  6054. srcG = (srcG * srcA) / 255;
  6055. srcB = (srcB * srcA) / 255;
  6056. }
  6057. }
  6058. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6059. case SDL_COPY_BLEND:
  6060. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6061. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6062. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6063. break;
  6064. case SDL_COPY_ADD:
  6065. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6066. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6067. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6068. break;
  6069. case SDL_COPY_MOD:
  6070. dstR = (srcR * dstR) / 255;
  6071. dstG = (srcG * dstG) / 255;
  6072. dstB = (srcB * dstB) / 255;
  6073. break;
  6074. case SDL_COPY_MUL:
  6075. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6076. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6077. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6078. break;
  6079. }
  6080. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  6081. *dst = dstpixel;
  6082. ++src;
  6083. ++dst;
  6084. }
  6085. info->src += info->src_pitch;
  6086. info->dst += info->dst_pitch;
  6087. }
  6088. }
  6089. static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  6090. {
  6091. const int flags = info->flags;
  6092. Uint32 srcpixel;
  6093. Uint32 srcR, srcG, srcB, srcA;
  6094. Uint32 dstpixel;
  6095. Uint32 dstR, dstG, dstB;
  6096. int srcy, srcx;
  6097. int posy, posx;
  6098. int incy, incx;
  6099. srcy = 0;
  6100. posy = 0;
  6101. incy = (info->src_h << 16) / info->dst_h;
  6102. incx = (info->src_w << 16) / info->dst_w;
  6103. while (info->dst_h--) {
  6104. Uint32 *src = 0;
  6105. Uint32 *dst = (Uint32 *)info->dst;
  6106. int n = info->dst_w;
  6107. srcx = -1;
  6108. posx = 0x10000L;
  6109. while (posy >= 0x10000L) {
  6110. ++srcy;
  6111. posy -= 0x10000L;
  6112. }
  6113. while (n--) {
  6114. if (posx >= 0x10000L) {
  6115. while (posx >= 0x10000L) {
  6116. ++srcx;
  6117. posx -= 0x10000L;
  6118. }
  6119. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6120. }
  6121. srcpixel = *src;
  6122. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6123. dstpixel = *dst;
  6124. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  6125. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6126. /* This goes away if we ever use premultiplied alpha */
  6127. if (srcA < 255) {
  6128. srcR = (srcR * srcA) / 255;
  6129. srcG = (srcG * srcA) / 255;
  6130. srcB = (srcB * srcA) / 255;
  6131. }
  6132. }
  6133. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6134. case SDL_COPY_BLEND:
  6135. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6136. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6137. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6138. break;
  6139. case SDL_COPY_ADD:
  6140. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6141. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6142. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6143. break;
  6144. case SDL_COPY_MOD:
  6145. dstR = (srcR * dstR) / 255;
  6146. dstG = (srcG * dstG) / 255;
  6147. dstB = (srcB * dstB) / 255;
  6148. break;
  6149. case SDL_COPY_MUL:
  6150. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6151. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6152. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6153. break;
  6154. }
  6155. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  6156. *dst = dstpixel;
  6157. posx += incx;
  6158. ++dst;
  6159. }
  6160. posy += incy;
  6161. info->dst += info->dst_pitch;
  6162. }
  6163. }
  6164. static void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info)
  6165. {
  6166. const int flags = info->flags;
  6167. const Uint32 modulateR = info->r;
  6168. const Uint32 modulateG = info->g;
  6169. const Uint32 modulateB = info->b;
  6170. Uint32 pixel;
  6171. Uint32 R, G, B;
  6172. while (info->dst_h--) {
  6173. Uint32 *src = (Uint32 *)info->src;
  6174. Uint32 *dst = (Uint32 *)info->dst;
  6175. int n = info->dst_w;
  6176. while (n--) {
  6177. pixel = *src;
  6178. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  6179. if (flags & SDL_COPY_MODULATE_COLOR) {
  6180. R = (R * modulateR) / 255;
  6181. G = (G * modulateG) / 255;
  6182. B = (B * modulateB) / 255;
  6183. }
  6184. pixel = (R << 16) | (G << 8) | B;
  6185. *dst = pixel;
  6186. ++src;
  6187. ++dst;
  6188. }
  6189. info->src += info->src_pitch;
  6190. info->dst += info->dst_pitch;
  6191. }
  6192. }
  6193. static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  6194. {
  6195. const int flags = info->flags;
  6196. const Uint32 modulateR = info->r;
  6197. const Uint32 modulateG = info->g;
  6198. const Uint32 modulateB = info->b;
  6199. Uint32 pixel;
  6200. Uint32 R, G, B;
  6201. int srcy, srcx;
  6202. int posy, posx;
  6203. int incy, incx;
  6204. srcy = 0;
  6205. posy = 0;
  6206. incy = (info->src_h << 16) / info->dst_h;
  6207. incx = (info->src_w << 16) / info->dst_w;
  6208. while (info->dst_h--) {
  6209. Uint32 *src = 0;
  6210. Uint32 *dst = (Uint32 *)info->dst;
  6211. int n = info->dst_w;
  6212. srcx = -1;
  6213. posx = 0x10000L;
  6214. while (posy >= 0x10000L) {
  6215. ++srcy;
  6216. posy -= 0x10000L;
  6217. }
  6218. while (n--) {
  6219. if (posx >= 0x10000L) {
  6220. while (posx >= 0x10000L) {
  6221. ++srcx;
  6222. posx -= 0x10000L;
  6223. }
  6224. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6225. }
  6226. pixel = *src;
  6227. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  6228. if (flags & SDL_COPY_MODULATE_COLOR) {
  6229. R = (R * modulateR) / 255;
  6230. G = (G * modulateG) / 255;
  6231. B = (B * modulateB) / 255;
  6232. }
  6233. pixel = (R << 16) | (G << 8) | B;
  6234. *dst = pixel;
  6235. posx += incx;
  6236. ++dst;
  6237. }
  6238. posy += incy;
  6239. info->dst += info->dst_pitch;
  6240. }
  6241. }
  6242. static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  6243. {
  6244. const int flags = info->flags;
  6245. const Uint32 modulateR = info->r;
  6246. const Uint32 modulateG = info->g;
  6247. const Uint32 modulateB = info->b;
  6248. const Uint32 modulateA = info->a;
  6249. Uint32 srcpixel;
  6250. Uint32 srcR, srcG, srcB, srcA;
  6251. Uint32 dstpixel;
  6252. Uint32 dstR, dstG, dstB;
  6253. while (info->dst_h--) {
  6254. Uint32 *src = (Uint32 *)info->src;
  6255. Uint32 *dst = (Uint32 *)info->dst;
  6256. int n = info->dst_w;
  6257. while (n--) {
  6258. srcpixel = *src;
  6259. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6260. dstpixel = *dst;
  6261. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  6262. if (flags & SDL_COPY_MODULATE_COLOR) {
  6263. srcR = (srcR * modulateR) / 255;
  6264. srcG = (srcG * modulateG) / 255;
  6265. srcB = (srcB * modulateB) / 255;
  6266. }
  6267. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6268. srcA = (srcA * modulateA) / 255;
  6269. }
  6270. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6271. /* This goes away if we ever use premultiplied alpha */
  6272. if (srcA < 255) {
  6273. srcR = (srcR * srcA) / 255;
  6274. srcG = (srcG * srcA) / 255;
  6275. srcB = (srcB * srcA) / 255;
  6276. }
  6277. }
  6278. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6279. case SDL_COPY_BLEND:
  6280. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6281. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6282. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6283. break;
  6284. case SDL_COPY_ADD:
  6285. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6286. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6287. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6288. break;
  6289. case SDL_COPY_MOD:
  6290. dstR = (srcR * dstR) / 255;
  6291. dstG = (srcG * dstG) / 255;
  6292. dstB = (srcB * dstB) / 255;
  6293. break;
  6294. case SDL_COPY_MUL:
  6295. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6296. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6297. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6298. break;
  6299. }
  6300. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  6301. *dst = dstpixel;
  6302. ++src;
  6303. ++dst;
  6304. }
  6305. info->src += info->src_pitch;
  6306. info->dst += info->dst_pitch;
  6307. }
  6308. }
  6309. static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6310. {
  6311. const int flags = info->flags;
  6312. const Uint32 modulateR = info->r;
  6313. const Uint32 modulateG = info->g;
  6314. const Uint32 modulateB = info->b;
  6315. const Uint32 modulateA = info->a;
  6316. Uint32 srcpixel;
  6317. Uint32 srcR, srcG, srcB, srcA;
  6318. Uint32 dstpixel;
  6319. Uint32 dstR, dstG, dstB;
  6320. int srcy, srcx;
  6321. int posy, posx;
  6322. int incy, incx;
  6323. srcy = 0;
  6324. posy = 0;
  6325. incy = (info->src_h << 16) / info->dst_h;
  6326. incx = (info->src_w << 16) / info->dst_w;
  6327. while (info->dst_h--) {
  6328. Uint32 *src = 0;
  6329. Uint32 *dst = (Uint32 *)info->dst;
  6330. int n = info->dst_w;
  6331. srcx = -1;
  6332. posx = 0x10000L;
  6333. while (posy >= 0x10000L) {
  6334. ++srcy;
  6335. posy -= 0x10000L;
  6336. }
  6337. while (n--) {
  6338. if (posx >= 0x10000L) {
  6339. while (posx >= 0x10000L) {
  6340. ++srcx;
  6341. posx -= 0x10000L;
  6342. }
  6343. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6344. }
  6345. srcpixel = *src;
  6346. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6347. dstpixel = *dst;
  6348. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  6349. if (flags & SDL_COPY_MODULATE_COLOR) {
  6350. srcR = (srcR * modulateR) / 255;
  6351. srcG = (srcG * modulateG) / 255;
  6352. srcB = (srcB * modulateB) / 255;
  6353. }
  6354. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6355. srcA = (srcA * modulateA) / 255;
  6356. }
  6357. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6358. /* This goes away if we ever use premultiplied alpha */
  6359. if (srcA < 255) {
  6360. srcR = (srcR * srcA) / 255;
  6361. srcG = (srcG * srcA) / 255;
  6362. srcB = (srcB * srcA) / 255;
  6363. }
  6364. }
  6365. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6366. case SDL_COPY_BLEND:
  6367. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6368. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6369. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6370. break;
  6371. case SDL_COPY_ADD:
  6372. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6373. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6374. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6375. break;
  6376. case SDL_COPY_MOD:
  6377. dstR = (srcR * dstR) / 255;
  6378. dstG = (srcG * dstG) / 255;
  6379. dstB = (srcB * dstB) / 255;
  6380. break;
  6381. case SDL_COPY_MUL:
  6382. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6383. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6384. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6385. break;
  6386. }
  6387. dstpixel = (dstR << 16) | (dstG << 8) | dstB;
  6388. *dst = dstpixel;
  6389. posx += incx;
  6390. ++dst;
  6391. }
  6392. posy += incy;
  6393. info->dst += info->dst_pitch;
  6394. }
  6395. }
  6396. static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
  6397. {
  6398. Uint32 pixel;
  6399. Uint32 R, G, B;
  6400. int srcy, srcx;
  6401. int posy, posx;
  6402. int incy, incx;
  6403. srcy = 0;
  6404. posy = 0;
  6405. incy = (info->src_h << 16) / info->dst_h;
  6406. incx = (info->src_w << 16) / info->dst_w;
  6407. while (info->dst_h--) {
  6408. Uint32 *src = 0;
  6409. Uint32 *dst = (Uint32 *)info->dst;
  6410. int n = info->dst_w;
  6411. srcx = -1;
  6412. posx = 0x10000L;
  6413. while (posy >= 0x10000L) {
  6414. ++srcy;
  6415. posy -= 0x10000L;
  6416. }
  6417. while (n--) {
  6418. if (posx >= 0x10000L) {
  6419. while (posx >= 0x10000L) {
  6420. ++srcx;
  6421. posx -= 0x10000L;
  6422. }
  6423. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6424. }
  6425. pixel = *src;
  6426. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  6427. pixel = (B << 16) | (G << 8) | R;
  6428. *dst = pixel;
  6429. posx += incx;
  6430. ++dst;
  6431. }
  6432. posy += incy;
  6433. info->dst += info->dst_pitch;
  6434. }
  6435. }
  6436. static void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info)
  6437. {
  6438. const int flags = info->flags;
  6439. Uint32 srcpixel;
  6440. Uint32 srcR, srcG, srcB, srcA;
  6441. Uint32 dstpixel;
  6442. Uint32 dstR, dstG, dstB;
  6443. while (info->dst_h--) {
  6444. Uint32 *src = (Uint32 *)info->src;
  6445. Uint32 *dst = (Uint32 *)info->dst;
  6446. int n = info->dst_w;
  6447. while (n--) {
  6448. srcpixel = *src;
  6449. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6450. dstpixel = *dst;
  6451. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  6452. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6453. /* This goes away if we ever use premultiplied alpha */
  6454. if (srcA < 255) {
  6455. srcR = (srcR * srcA) / 255;
  6456. srcG = (srcG * srcA) / 255;
  6457. srcB = (srcB * srcA) / 255;
  6458. }
  6459. }
  6460. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6461. case SDL_COPY_BLEND:
  6462. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6463. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6464. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6465. break;
  6466. case SDL_COPY_ADD:
  6467. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6468. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6469. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6470. break;
  6471. case SDL_COPY_MOD:
  6472. dstR = (srcR * dstR) / 255;
  6473. dstG = (srcG * dstG) / 255;
  6474. dstB = (srcB * dstB) / 255;
  6475. break;
  6476. case SDL_COPY_MUL:
  6477. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6478. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6479. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6480. break;
  6481. }
  6482. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  6483. *dst = dstpixel;
  6484. ++src;
  6485. ++dst;
  6486. }
  6487. info->src += info->src_pitch;
  6488. info->dst += info->dst_pitch;
  6489. }
  6490. }
  6491. static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  6492. {
  6493. const int flags = info->flags;
  6494. Uint32 srcpixel;
  6495. Uint32 srcR, srcG, srcB, srcA;
  6496. Uint32 dstpixel;
  6497. Uint32 dstR, dstG, dstB;
  6498. int srcy, srcx;
  6499. int posy, posx;
  6500. int incy, incx;
  6501. srcy = 0;
  6502. posy = 0;
  6503. incy = (info->src_h << 16) / info->dst_h;
  6504. incx = (info->src_w << 16) / info->dst_w;
  6505. while (info->dst_h--) {
  6506. Uint32 *src = 0;
  6507. Uint32 *dst = (Uint32 *)info->dst;
  6508. int n = info->dst_w;
  6509. srcx = -1;
  6510. posx = 0x10000L;
  6511. while (posy >= 0x10000L) {
  6512. ++srcy;
  6513. posy -= 0x10000L;
  6514. }
  6515. while (n--) {
  6516. if (posx >= 0x10000L) {
  6517. while (posx >= 0x10000L) {
  6518. ++srcx;
  6519. posx -= 0x10000L;
  6520. }
  6521. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6522. }
  6523. srcpixel = *src;
  6524. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6525. dstpixel = *dst;
  6526. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  6527. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6528. /* This goes away if we ever use premultiplied alpha */
  6529. if (srcA < 255) {
  6530. srcR = (srcR * srcA) / 255;
  6531. srcG = (srcG * srcA) / 255;
  6532. srcB = (srcB * srcA) / 255;
  6533. }
  6534. }
  6535. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6536. case SDL_COPY_BLEND:
  6537. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6538. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6539. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6540. break;
  6541. case SDL_COPY_ADD:
  6542. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6543. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6544. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6545. break;
  6546. case SDL_COPY_MOD:
  6547. dstR = (srcR * dstR) / 255;
  6548. dstG = (srcG * dstG) / 255;
  6549. dstB = (srcB * dstB) / 255;
  6550. break;
  6551. case SDL_COPY_MUL:
  6552. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6553. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6554. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6555. break;
  6556. }
  6557. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  6558. *dst = dstpixel;
  6559. posx += incx;
  6560. ++dst;
  6561. }
  6562. posy += incy;
  6563. info->dst += info->dst_pitch;
  6564. }
  6565. }
  6566. static void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info)
  6567. {
  6568. const int flags = info->flags;
  6569. const Uint32 modulateR = info->r;
  6570. const Uint32 modulateG = info->g;
  6571. const Uint32 modulateB = info->b;
  6572. Uint32 pixel;
  6573. Uint32 R, G, B;
  6574. while (info->dst_h--) {
  6575. Uint32 *src = (Uint32 *)info->src;
  6576. Uint32 *dst = (Uint32 *)info->dst;
  6577. int n = info->dst_w;
  6578. while (n--) {
  6579. pixel = *src;
  6580. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  6581. if (flags & SDL_COPY_MODULATE_COLOR) {
  6582. R = (R * modulateR) / 255;
  6583. G = (G * modulateG) / 255;
  6584. B = (B * modulateB) / 255;
  6585. }
  6586. pixel = (B << 16) | (G << 8) | R;
  6587. *dst = pixel;
  6588. ++src;
  6589. ++dst;
  6590. }
  6591. info->src += info->src_pitch;
  6592. info->dst += info->dst_pitch;
  6593. }
  6594. }
  6595. static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  6596. {
  6597. const int flags = info->flags;
  6598. const Uint32 modulateR = info->r;
  6599. const Uint32 modulateG = info->g;
  6600. const Uint32 modulateB = info->b;
  6601. Uint32 pixel;
  6602. Uint32 R, G, B;
  6603. int srcy, srcx;
  6604. int posy, posx;
  6605. int incy, incx;
  6606. srcy = 0;
  6607. posy = 0;
  6608. incy = (info->src_h << 16) / info->dst_h;
  6609. incx = (info->src_w << 16) / info->dst_w;
  6610. while (info->dst_h--) {
  6611. Uint32 *src = 0;
  6612. Uint32 *dst = (Uint32 *)info->dst;
  6613. int n = info->dst_w;
  6614. srcx = -1;
  6615. posx = 0x10000L;
  6616. while (posy >= 0x10000L) {
  6617. ++srcy;
  6618. posy -= 0x10000L;
  6619. }
  6620. while (n--) {
  6621. if (posx >= 0x10000L) {
  6622. while (posx >= 0x10000L) {
  6623. ++srcx;
  6624. posx -= 0x10000L;
  6625. }
  6626. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6627. }
  6628. pixel = *src;
  6629. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
  6630. if (flags & SDL_COPY_MODULATE_COLOR) {
  6631. R = (R * modulateR) / 255;
  6632. G = (G * modulateG) / 255;
  6633. B = (B * modulateB) / 255;
  6634. }
  6635. pixel = (B << 16) | (G << 8) | R;
  6636. *dst = pixel;
  6637. posx += incx;
  6638. ++dst;
  6639. }
  6640. posy += incy;
  6641. info->dst += info->dst_pitch;
  6642. }
  6643. }
  6644. static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  6645. {
  6646. const int flags = info->flags;
  6647. const Uint32 modulateR = info->r;
  6648. const Uint32 modulateG = info->g;
  6649. const Uint32 modulateB = info->b;
  6650. const Uint32 modulateA = info->a;
  6651. Uint32 srcpixel;
  6652. Uint32 srcR, srcG, srcB, srcA;
  6653. Uint32 dstpixel;
  6654. Uint32 dstR, dstG, dstB;
  6655. while (info->dst_h--) {
  6656. Uint32 *src = (Uint32 *)info->src;
  6657. Uint32 *dst = (Uint32 *)info->dst;
  6658. int n = info->dst_w;
  6659. while (n--) {
  6660. srcpixel = *src;
  6661. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6662. dstpixel = *dst;
  6663. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  6664. if (flags & SDL_COPY_MODULATE_COLOR) {
  6665. srcR = (srcR * modulateR) / 255;
  6666. srcG = (srcG * modulateG) / 255;
  6667. srcB = (srcB * modulateB) / 255;
  6668. }
  6669. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6670. srcA = (srcA * modulateA) / 255;
  6671. }
  6672. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6673. /* This goes away if we ever use premultiplied alpha */
  6674. if (srcA < 255) {
  6675. srcR = (srcR * srcA) / 255;
  6676. srcG = (srcG * srcA) / 255;
  6677. srcB = (srcB * srcA) / 255;
  6678. }
  6679. }
  6680. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6681. case SDL_COPY_BLEND:
  6682. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6683. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6684. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6685. break;
  6686. case SDL_COPY_ADD:
  6687. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6688. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6689. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6690. break;
  6691. case SDL_COPY_MOD:
  6692. dstR = (srcR * dstR) / 255;
  6693. dstG = (srcG * dstG) / 255;
  6694. dstB = (srcB * dstB) / 255;
  6695. break;
  6696. case SDL_COPY_MUL:
  6697. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6698. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6699. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6700. break;
  6701. }
  6702. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  6703. *dst = dstpixel;
  6704. ++src;
  6705. ++dst;
  6706. }
  6707. info->src += info->src_pitch;
  6708. info->dst += info->dst_pitch;
  6709. }
  6710. }
  6711. static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  6712. {
  6713. const int flags = info->flags;
  6714. const Uint32 modulateR = info->r;
  6715. const Uint32 modulateG = info->g;
  6716. const Uint32 modulateB = info->b;
  6717. const Uint32 modulateA = info->a;
  6718. Uint32 srcpixel;
  6719. Uint32 srcR, srcG, srcB, srcA;
  6720. Uint32 dstpixel;
  6721. Uint32 dstR, dstG, dstB;
  6722. int srcy, srcx;
  6723. int posy, posx;
  6724. int incy, incx;
  6725. srcy = 0;
  6726. posy = 0;
  6727. incy = (info->src_h << 16) / info->dst_h;
  6728. incx = (info->src_w << 16) / info->dst_w;
  6729. while (info->dst_h--) {
  6730. Uint32 *src = 0;
  6731. Uint32 *dst = (Uint32 *)info->dst;
  6732. int n = info->dst_w;
  6733. srcx = -1;
  6734. posx = 0x10000L;
  6735. while (posy >= 0x10000L) {
  6736. ++srcy;
  6737. posy -= 0x10000L;
  6738. }
  6739. while (n--) {
  6740. if (posx >= 0x10000L) {
  6741. while (posx >= 0x10000L) {
  6742. ++srcx;
  6743. posx -= 0x10000L;
  6744. }
  6745. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6746. }
  6747. srcpixel = *src;
  6748. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6749. dstpixel = *dst;
  6750. dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
  6751. if (flags & SDL_COPY_MODULATE_COLOR) {
  6752. srcR = (srcR * modulateR) / 255;
  6753. srcG = (srcG * modulateG) / 255;
  6754. srcB = (srcB * modulateB) / 255;
  6755. }
  6756. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6757. srcA = (srcA * modulateA) / 255;
  6758. }
  6759. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6760. /* This goes away if we ever use premultiplied alpha */
  6761. if (srcA < 255) {
  6762. srcR = (srcR * srcA) / 255;
  6763. srcG = (srcG * srcA) / 255;
  6764. srcB = (srcB * srcA) / 255;
  6765. }
  6766. }
  6767. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6768. case SDL_COPY_BLEND:
  6769. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6770. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6771. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6772. break;
  6773. case SDL_COPY_ADD:
  6774. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6775. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6776. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6777. break;
  6778. case SDL_COPY_MOD:
  6779. dstR = (srcR * dstR) / 255;
  6780. dstG = (srcG * dstG) / 255;
  6781. dstB = (srcB * dstB) / 255;
  6782. break;
  6783. case SDL_COPY_MUL:
  6784. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6785. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6786. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6787. break;
  6788. }
  6789. dstpixel = (dstB << 16) | (dstG << 8) | dstR;
  6790. *dst = dstpixel;
  6791. posx += incx;
  6792. ++dst;
  6793. }
  6794. posy += incy;
  6795. info->dst += info->dst_pitch;
  6796. }
  6797. }
  6798. static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  6799. {
  6800. Uint32 pixel;
  6801. Uint32 R, G, B, A;
  6802. int srcy, srcx;
  6803. int posy, posx;
  6804. int incy, incx;
  6805. srcy = 0;
  6806. posy = 0;
  6807. incy = (info->src_h << 16) / info->dst_h;
  6808. incx = (info->src_w << 16) / info->dst_w;
  6809. while (info->dst_h--) {
  6810. Uint32 *src = 0;
  6811. Uint32 *dst = (Uint32 *)info->dst;
  6812. int n = info->dst_w;
  6813. srcx = -1;
  6814. posx = 0x10000L;
  6815. while (posy >= 0x10000L) {
  6816. ++srcy;
  6817. posy -= 0x10000L;
  6818. }
  6819. while (n--) {
  6820. if (posx >= 0x10000L) {
  6821. while (posx >= 0x10000L) {
  6822. ++srcx;
  6823. posx -= 0x10000L;
  6824. }
  6825. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6826. }
  6827. pixel = *src;
  6828. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6829. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  6830. *dst = pixel;
  6831. posx += incx;
  6832. ++dst;
  6833. }
  6834. posy += incy;
  6835. info->dst += info->dst_pitch;
  6836. }
  6837. }
  6838. static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  6839. {
  6840. const int flags = info->flags;
  6841. Uint32 srcpixel;
  6842. Uint32 srcR, srcG, srcB, srcA;
  6843. Uint32 dstpixel;
  6844. Uint32 dstR, dstG, dstB, dstA;
  6845. while (info->dst_h--) {
  6846. Uint32 *src = (Uint32 *)info->src;
  6847. Uint32 *dst = (Uint32 *)info->dst;
  6848. int n = info->dst_w;
  6849. while (n--) {
  6850. srcpixel = *src;
  6851. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6852. dstpixel = *dst;
  6853. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6854. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6855. /* This goes away if we ever use premultiplied alpha */
  6856. if (srcA < 255) {
  6857. srcR = (srcR * srcA) / 255;
  6858. srcG = (srcG * srcA) / 255;
  6859. srcB = (srcB * srcA) / 255;
  6860. }
  6861. }
  6862. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6863. case SDL_COPY_BLEND:
  6864. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6865. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6866. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6867. dstA = srcA + ((255 - srcA) * dstA) / 255;
  6868. break;
  6869. case SDL_COPY_ADD:
  6870. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6871. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6872. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6873. break;
  6874. case SDL_COPY_MOD:
  6875. dstR = (srcR * dstR) / 255;
  6876. dstG = (srcG * dstG) / 255;
  6877. dstB = (srcB * dstB) / 255;
  6878. break;
  6879. case SDL_COPY_MUL:
  6880. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6881. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6882. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6883. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  6884. break;
  6885. }
  6886. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6887. *dst = dstpixel;
  6888. ++src;
  6889. ++dst;
  6890. }
  6891. info->src += info->src_pitch;
  6892. info->dst += info->dst_pitch;
  6893. }
  6894. }
  6895. static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  6896. {
  6897. const int flags = info->flags;
  6898. Uint32 srcpixel;
  6899. Uint32 srcR, srcG, srcB, srcA;
  6900. Uint32 dstpixel;
  6901. Uint32 dstR, dstG, dstB, dstA;
  6902. int srcy, srcx;
  6903. int posy, posx;
  6904. int incy, incx;
  6905. srcy = 0;
  6906. posy = 0;
  6907. incy = (info->src_h << 16) / info->dst_h;
  6908. incx = (info->src_w << 16) / info->dst_w;
  6909. while (info->dst_h--) {
  6910. Uint32 *src = 0;
  6911. Uint32 *dst = (Uint32 *)info->dst;
  6912. int n = info->dst_w;
  6913. srcx = -1;
  6914. posx = 0x10000L;
  6915. while (posy >= 0x10000L) {
  6916. ++srcy;
  6917. posy -= 0x10000L;
  6918. }
  6919. while (n--) {
  6920. if (posx >= 0x10000L) {
  6921. while (posx >= 0x10000L) {
  6922. ++srcx;
  6923. posx -= 0x10000L;
  6924. }
  6925. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  6926. }
  6927. srcpixel = *src;
  6928. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  6929. dstpixel = *dst;
  6930. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  6931. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  6932. /* This goes away if we ever use premultiplied alpha */
  6933. if (srcA < 255) {
  6934. srcR = (srcR * srcA) / 255;
  6935. srcG = (srcG * srcA) / 255;
  6936. srcB = (srcB * srcA) / 255;
  6937. }
  6938. }
  6939. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  6940. case SDL_COPY_BLEND:
  6941. dstR = srcR + ((255 - srcA) * dstR) / 255;
  6942. dstG = srcG + ((255 - srcA) * dstG) / 255;
  6943. dstB = srcB + ((255 - srcA) * dstB) / 255;
  6944. dstA = srcA + ((255 - srcA) * dstA) / 255;
  6945. break;
  6946. case SDL_COPY_ADD:
  6947. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  6948. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  6949. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  6950. break;
  6951. case SDL_COPY_MOD:
  6952. dstR = (srcR * dstR) / 255;
  6953. dstG = (srcG * dstG) / 255;
  6954. dstB = (srcB * dstB) / 255;
  6955. break;
  6956. case SDL_COPY_MUL:
  6957. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  6958. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  6959. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  6960. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  6961. break;
  6962. }
  6963. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  6964. *dst = dstpixel;
  6965. posx += incx;
  6966. ++dst;
  6967. }
  6968. posy += incy;
  6969. info->dst += info->dst_pitch;
  6970. }
  6971. }
  6972. static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  6973. {
  6974. const int flags = info->flags;
  6975. const Uint32 modulateR = info->r;
  6976. const Uint32 modulateG = info->g;
  6977. const Uint32 modulateB = info->b;
  6978. const Uint32 modulateA = info->a;
  6979. Uint32 pixel;
  6980. Uint32 R, G, B, A;
  6981. while (info->dst_h--) {
  6982. Uint32 *src = (Uint32 *)info->src;
  6983. Uint32 *dst = (Uint32 *)info->dst;
  6984. int n = info->dst_w;
  6985. while (n--) {
  6986. pixel = *src;
  6987. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  6988. if (flags & SDL_COPY_MODULATE_COLOR) {
  6989. R = (R * modulateR) / 255;
  6990. G = (G * modulateG) / 255;
  6991. B = (B * modulateB) / 255;
  6992. }
  6993. if (flags & SDL_COPY_MODULATE_ALPHA) {
  6994. A = (A * modulateA) / 255;
  6995. }
  6996. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  6997. *dst = pixel;
  6998. ++src;
  6999. ++dst;
  7000. }
  7001. info->src += info->src_pitch;
  7002. info->dst += info->dst_pitch;
  7003. }
  7004. }
  7005. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  7006. {
  7007. const int flags = info->flags;
  7008. const Uint32 modulateR = info->r;
  7009. const Uint32 modulateG = info->g;
  7010. const Uint32 modulateB = info->b;
  7011. const Uint32 modulateA = info->a;
  7012. Uint32 pixel;
  7013. Uint32 R, G, B, A;
  7014. int srcy, srcx;
  7015. int posy, posx;
  7016. int incy, incx;
  7017. srcy = 0;
  7018. posy = 0;
  7019. incy = (info->src_h << 16) / info->dst_h;
  7020. incx = (info->src_w << 16) / info->dst_w;
  7021. while (info->dst_h--) {
  7022. Uint32 *src = 0;
  7023. Uint32 *dst = (Uint32 *)info->dst;
  7024. int n = info->dst_w;
  7025. srcx = -1;
  7026. posx = 0x10000L;
  7027. while (posy >= 0x10000L) {
  7028. ++srcy;
  7029. posy -= 0x10000L;
  7030. }
  7031. while (n--) {
  7032. if (posx >= 0x10000L) {
  7033. while (posx >= 0x10000L) {
  7034. ++srcx;
  7035. posx -= 0x10000L;
  7036. }
  7037. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7038. }
  7039. pixel = *src;
  7040. B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  7041. if (flags & SDL_COPY_MODULATE_COLOR) {
  7042. R = (R * modulateR) / 255;
  7043. G = (G * modulateG) / 255;
  7044. B = (B * modulateB) / 255;
  7045. }
  7046. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7047. A = (A * modulateA) / 255;
  7048. }
  7049. pixel = (A << 24) | (R << 16) | (G << 8) | B;
  7050. *dst = pixel;
  7051. posx += incx;
  7052. ++dst;
  7053. }
  7054. posy += incy;
  7055. info->dst += info->dst_pitch;
  7056. }
  7057. }
  7058. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  7059. {
  7060. const int flags = info->flags;
  7061. const Uint32 modulateR = info->r;
  7062. const Uint32 modulateG = info->g;
  7063. const Uint32 modulateB = info->b;
  7064. const Uint32 modulateA = info->a;
  7065. Uint32 srcpixel;
  7066. Uint32 srcR, srcG, srcB, srcA;
  7067. Uint32 dstpixel;
  7068. Uint32 dstR, dstG, dstB, dstA;
  7069. while (info->dst_h--) {
  7070. Uint32 *src = (Uint32 *)info->src;
  7071. Uint32 *dst = (Uint32 *)info->dst;
  7072. int n = info->dst_w;
  7073. while (n--) {
  7074. srcpixel = *src;
  7075. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  7076. dstpixel = *dst;
  7077. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  7078. if (flags & SDL_COPY_MODULATE_COLOR) {
  7079. srcR = (srcR * modulateR) / 255;
  7080. srcG = (srcG * modulateG) / 255;
  7081. srcB = (srcB * modulateB) / 255;
  7082. }
  7083. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7084. srcA = (srcA * modulateA) / 255;
  7085. }
  7086. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7087. /* This goes away if we ever use premultiplied alpha */
  7088. if (srcA < 255) {
  7089. srcR = (srcR * srcA) / 255;
  7090. srcG = (srcG * srcA) / 255;
  7091. srcB = (srcB * srcA) / 255;
  7092. }
  7093. }
  7094. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  7095. case SDL_COPY_BLEND:
  7096. dstR = srcR + ((255 - srcA) * dstR) / 255;
  7097. dstG = srcG + ((255 - srcA) * dstG) / 255;
  7098. dstB = srcB + ((255 - srcA) * dstB) / 255;
  7099. dstA = srcA + ((255 - srcA) * dstA) / 255;
  7100. break;
  7101. case SDL_COPY_ADD:
  7102. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7103. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7104. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7105. break;
  7106. case SDL_COPY_MOD:
  7107. dstR = (srcR * dstR) / 255;
  7108. dstG = (srcG * dstG) / 255;
  7109. dstB = (srcB * dstB) / 255;
  7110. break;
  7111. case SDL_COPY_MUL:
  7112. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  7113. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  7114. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  7115. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  7116. break;
  7117. }
  7118. dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
  7119. *dst = dstpixel;
  7120. ++src;
  7121. ++dst;
  7122. }
  7123. info->src += info->src_pitch;
  7124. info->dst += info->dst_pitch;
  7125. }
  7126. }
  7127. static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  7128. {
  7129. const int flags = info->flags;
  7130. const Uint32 modulateR = info->r;
  7131. const Uint32 modulateG = info->g;
  7132. const Uint32 modulateB = info->b;
  7133. const Uint32 modulateA = info->a;
  7134. Uint32 srcpixel;
  7135. Uint32 srcR, srcG, srcB, srcA;
  7136. Uint32 dstpixel;
  7137. Uint32 dstR, dstG, dstB, dstA;
  7138. int srcy, srcx;
  7139. int posy, posx;
  7140. int incy, incx;
  7141. srcy = 0;
  7142. posy = 0;
  7143. incy = (info->src_h << 16) / info->dst_h;
  7144. incx = (info->src_w << 16) / info->dst_w;
  7145. while (info->dst_h--) {
  7146. Uint32 *src = 0;
  7147. Uint32 *dst = (Uint32 *)info->dst;
  7148. int n = info->dst_w;
  7149. srcx = -1;
  7150. posx = 0x10000L;
  7151. while (posy >= 0x10000L) {
  7152. ++srcy;
  7153. posy -= 0x10000L;
  7154. }
  7155. while (n--) {
  7156. if (posx >= 0x10000L) {
  7157. while (posx >= 0x10000L) {
  7158. ++srcx;
  7159. posx -= 0x10000L;
  7160. }
  7161. src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  7162. }
  7163. srcpixel = *src;
  7164. srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  7165. dstpixel = *dst;
  7166. dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
  7167. if (flags & SDL_COPY_MODULATE_COLOR) {
  7168. srcR = (srcR * modulateR) / 255;
  7169. srcG = (srcG * modulateG) / 255;
  7170. srcB = (srcB * modulateB) / 255;
  7171. }
  7172. if (flags & SDL_COPY_MODULATE_ALPHA) {
  7173. srcA = (srcA * modulateA) / 255;
  7174. }
  7175. if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  7176. /* This goes away if we ever use premultiplied alpha */
  7177. if (srcA < 255) {
  7178. srcR = (srcR * srcA) / 255;
  7179. srcG = (srcG * srcA) / 255;
  7180. srcB = (srcB * srcA) / 255;
  7181. }
  7182. }
  7183. switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
  7184. case SDL_COPY_BLEND:
  7185. dstR = srcR + ((255 - srcA) * dstR) / 255;
  7186. dstG = srcG + ((255 - srcA) * dstG) / 255;
  7187. dstB = srcB + ((255 - srcA) * dstB) / 255;
  7188. dstA = srcA + ((255 - srcA) * dstA) / 255;
  7189. break;
  7190. case SDL_COPY_ADD:
  7191. dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  7192. dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  7193. dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  7194. break;
  7195. case SDL_COPY_MOD:
  7196. dstR = (srcR * dstR) / 255;
  7197. dstG = (srcG * dstG) / 255;
  7198. dstB = (srcB * dstB) / 255;
  7199. break;
  7200. case SDL_COPY_MUL:
  7201. dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; if (dstR > 255) dstR = 255;
  7202. dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; if (dstG > 255) dstG = 255;
  7203. dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; if (dstB > 255) dstB = 255;
  7204. dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255; if (dstA > 255) dstA = 255;
  7205. break;
  7206. }
  7207. dstpixel = (dstA << 24) | (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. SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
  7217. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
  7218. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
  7219. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
  7220. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate },
  7221. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Scale },
  7222. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend },
  7223. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale },
  7224. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Scale },
  7225. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend },
  7226. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale },
  7227. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate },
  7228. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Scale },
  7229. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend },
  7230. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale },
  7231. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Scale },
  7232. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend },
  7233. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend_Scale },
  7234. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate },
  7235. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Scale },
  7236. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend },
  7237. { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale },
  7238. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale },
  7239. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend },
  7240. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale },
  7241. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate },
  7242. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Scale },
  7243. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend },
  7244. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale },
  7245. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Scale },
  7246. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend },
  7247. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale },
  7248. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate },
  7249. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Scale },
  7250. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend },
  7251. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale },
  7252. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Scale },
  7253. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend },
  7254. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend_Scale },
  7255. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate },
  7256. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Scale },
  7257. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend },
  7258. { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale },
  7259. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale },
  7260. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend },
  7261. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale },
  7262. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate },
  7263. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Scale },
  7264. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend },
  7265. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale },
  7266. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Scale },
  7267. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend },
  7268. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale },
  7269. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate },
  7270. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Scale },
  7271. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend },
  7272. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale },
  7273. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale },
  7274. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
  7275. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
  7276. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate },
  7277. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale },
  7278. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
  7279. { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
  7280. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale },
  7281. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend },
  7282. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale },
  7283. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate },
  7284. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Scale },
  7285. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend },
  7286. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale },
  7287. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Scale },
  7288. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend },
  7289. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale },
  7290. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate },
  7291. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Scale },
  7292. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend },
  7293. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale },
  7294. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale },
  7295. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
  7296. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
  7297. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate },
  7298. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale },
  7299. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
  7300. { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
  7301. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale },
  7302. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend },
  7303. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale },
  7304. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate },
  7305. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Scale },
  7306. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend },
  7307. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale },
  7308. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Scale },
  7309. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend },
  7310. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale },
  7311. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate },
  7312. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Scale },
  7313. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend },
  7314. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale },
  7315. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale },
  7316. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
  7317. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
  7318. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate },
  7319. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale },
  7320. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
  7321. { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
  7322. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale },
  7323. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend },
  7324. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale },
  7325. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate },
  7326. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Scale },
  7327. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend },
  7328. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale },
  7329. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Scale },
  7330. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend },
  7331. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale },
  7332. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate },
  7333. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Scale },
  7334. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend },
  7335. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale },
  7336. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale },
  7337. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
  7338. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
  7339. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate },
  7340. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale },
  7341. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
  7342. { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
  7343. { 0, 0, 0, 0, NULL }
  7344. };
  7345. /* *INDENT-ON* */
  7346. #endif /* SDL_HAVE_BLIT_AUTO */
  7347. /* vi: set ts=4 sw=4 expandtab: */