draw-affine.c 151 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124
  1. // Copyright (C) 2004-2025 Artifex Software, Inc.
  2. //
  3. // This file is part of MuPDF.
  4. //
  5. // MuPDF is free software: you can redistribute it and/or modify it under the
  6. // terms of the GNU Affero General Public License as published by the Free
  7. // Software Foundation, either version 3 of the License, or (at your option)
  8. // any later version.
  9. //
  10. // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
  11. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. // details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
  17. //
  18. // Alternative licensing terms are available from the licensor.
  19. // For commercial licensing, see <https://www.artifex.com/> or contact
  20. // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
  21. // CA 94129, USA, for further information.
  22. #include "mupdf/fitz.h"
  23. #include "draw-imp.h"
  24. #include <math.h>
  25. #include <float.h>
  26. #include <assert.h>
  27. typedef int64_t affint;
  28. /* Number of fraction bits for fixed point math */
  29. #define PREC 14
  30. #define ONE (((affint)1)<<PREC)
  31. #define MASK (ONE-1)
  32. #define HALF (((affint)1)<<(PREC-1))
  33. #define LIMIT (((affint)1)<<((sizeof(affint)*8-1)-PREC))
  34. typedef unsigned char byte;
  35. typedef void (paintfn_t)(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop);
  36. static fz_forceinline int lerp(int a, int b, int f)
  37. {
  38. return a + (((b - a) * f) >> PREC);
  39. }
  40. static fz_forceinline int bilerp(int a, int b, int c, int d, int uf, int vf)
  41. {
  42. return lerp(lerp(a, b, uf), lerp(c, d, uf), vf);
  43. }
  44. static fz_forceinline const byte *sample_nearest(const byte *s, affint w, affint h, ptrdiff_t str, int n, affint u, affint v)
  45. {
  46. if (u < 0) u = 0;
  47. if (v < 0) v = 0;
  48. if (u >= (w>>PREC)) u = (w>>PREC) - 1;
  49. if (v >= (h>>PREC)) v = (h>>PREC) - 1;
  50. return s + v * str + u * n;
  51. }
  52. /* Blend premultiplied source image in constant alpha over destination */
  53. static fz_forceinline void
  54. template_affine_alpha_N_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  55. {
  56. int k;
  57. do
  58. {
  59. if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
  60. {
  61. affint ui = u >> PREC;
  62. affint vi = v >> PREC;
  63. int uf = u & MASK;
  64. int vf = v & MASK;
  65. const byte *a = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi);
  66. const byte *b = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi);
  67. const byte *c = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi+1);
  68. const byte *d = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi+1);
  69. int x = sa ? bilerp(a[sn1], b[sn1], c[sn1], d[sn1], uf, vf) : 255;
  70. int xa = sa ? fz_mul255(x, alpha) : alpha;
  71. if (xa != 0)
  72. {
  73. int t = 255 - xa;
  74. for (k = 0; k < sn1; k++)
  75. {
  76. int z = bilerp(a[k], b[k], c[k], d[k], uf, vf);
  77. dp[k] = fz_mul255(z, alpha) + fz_mul255(dp[k], t);
  78. }
  79. for (; k < dn1; k++)
  80. dp[k] = 0;
  81. if (da)
  82. dp[dn1] = xa + fz_mul255(dp[dn1], t);
  83. if (hp)
  84. hp[0] = x + fz_mul255(hp[0], 255 - x);
  85. if (gp)
  86. gp[0] = xa + fz_mul255(gp[0], t);
  87. }
  88. }
  89. dp += dn1+da;
  90. if (hp)
  91. hp++;
  92. if (gp)
  93. gp++;
  94. u += fa;
  95. v += fb;
  96. }
  97. while (--w);
  98. }
  99. static fz_forceinline void
  100. template_affine_alpha_N_lerp_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  101. {
  102. int k;
  103. do
  104. {
  105. if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
  106. {
  107. affint ui = u >> PREC;
  108. affint vi = v >> PREC;
  109. int uf = u & MASK;
  110. int vf = v & MASK;
  111. const byte *a = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi);
  112. const byte *b = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi);
  113. const byte *c = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi+1);
  114. const byte *d = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi+1);
  115. int x = sa ? bilerp(a[sn1], b[sn1], c[sn1], d[sn1], uf, vf) : 255;
  116. int xa = sa ? fz_mul255(x, alpha) : alpha;
  117. if (xa != 0)
  118. {
  119. int t = 255 - xa;
  120. for (k = 0; k < sn1; k++)
  121. {
  122. if (fz_overprint_component(eop, k))
  123. {
  124. int z = bilerp(a[k], b[k], c[k], d[k], uf, vf);
  125. dp[k] = fz_mul255(z, alpha) + fz_mul255(dp[k], t);
  126. }
  127. }
  128. for (; k < dn1; k++)
  129. if (fz_overprint_component(eop, k))
  130. dp[k] = 0;
  131. if (da)
  132. dp[dn1] = xa + fz_mul255(dp[dn1], t);
  133. if (hp)
  134. hp[0] = x + fz_mul255(hp[0], 255-x);
  135. if (gp)
  136. gp[0] = xa + fz_mul255(gp[0], t);
  137. }
  138. }
  139. dp += dn1+da;
  140. if (hp)
  141. hp++;
  142. if (gp)
  143. gp++;
  144. u += fa;
  145. v += fb;
  146. }
  147. while (--w);
  148. }
  149. /* Special case code for gray -> rgb */
  150. static fz_forceinline void
  151. template_affine_alpha_g2rgb_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  152. {
  153. do
  154. {
  155. if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
  156. {
  157. affint ui = u >> PREC;
  158. affint vi = v >> PREC;
  159. int uf = u & MASK;
  160. int vf = v & MASK;
  161. const byte *a = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi);
  162. const byte *b = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi);
  163. const byte *c = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi+1);
  164. const byte *d = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi+1);
  165. int y = sa ? bilerp(a[1], b[1], c[1], d[1], uf, vf) : 255;
  166. int ya = (sa ? fz_mul255(y, alpha) : alpha);
  167. if (ya != 0)
  168. {
  169. int x = bilerp(a[0], b[0], c[0], d[0], uf, vf);
  170. int t = 255 - ya;
  171. x = fz_mul255(x, alpha);
  172. dp[0] = x + fz_mul255(dp[0], t);
  173. dp[1] = x + fz_mul255(dp[1], t);
  174. dp[2] = x + fz_mul255(dp[2], t);
  175. if (da)
  176. dp[3] = ya + fz_mul255(dp[3], t);
  177. if (hp)
  178. hp[0] = y + fz_mul255(hp[0], 255 - y);
  179. if (gp)
  180. gp[0] = ya + fz_mul255(gp[0], t);
  181. }
  182. }
  183. dp += 3+da;
  184. if (hp)
  185. hp++;
  186. if (gp)
  187. gp++;
  188. u += fa;
  189. v += fb;
  190. }
  191. while (--w);
  192. }
  193. static fz_forceinline void
  194. template_affine_alpha_N_near_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  195. {
  196. int k;
  197. affint ui = u >> PREC;
  198. TRACK_FN();
  199. if (ui < 0 || ui >= sw)
  200. return;
  201. sp += ui * (sn1+sa);
  202. do
  203. {
  204. affint vi = v >> PREC;
  205. if (vi >= 0 && vi < sh)
  206. {
  207. const byte *sample = sp + (vi * ss);
  208. int a = sa ? sample[sn1] : 255;
  209. int aa = (sa ? fz_mul255(a, alpha) : alpha);
  210. if (aa != 0)
  211. {
  212. int t = 255 - aa;
  213. for (k = 0; k < sn1; k++)
  214. dp[k] = fz_mul255(sample[k], alpha) + fz_mul255(dp[k], t);
  215. for (; k < dn1; k++)
  216. dp[k] = 0;
  217. if (da)
  218. dp[dn1] = aa + fz_mul255(dp[dn1], t);
  219. if (hp)
  220. hp[0] = a + fz_mul255(hp[0], 255 - a);
  221. if (gp)
  222. gp[0] = aa + fz_mul255(gp[0], t);
  223. }
  224. }
  225. dp += dn1+da;
  226. if (hp)
  227. hp++;
  228. if (gp)
  229. gp++;
  230. v += fb;
  231. }
  232. while (--w);
  233. }
  234. static fz_forceinline void
  235. template_affine_alpha_N_near_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  236. {
  237. int k;
  238. affint vi = v >> PREC;
  239. if (vi < 0 || vi >= sh)
  240. return;
  241. sp += vi * ss;
  242. do
  243. {
  244. affint ui = u >> PREC;
  245. if (ui >= 0 && ui < sw)
  246. {
  247. const byte *sample = sp + (ui * (sn1+sa));
  248. int a = sa ? sample[sn1] : 255;
  249. int aa = (sa ? fz_mul255(a, alpha) : alpha);
  250. if (aa != 0)
  251. {
  252. int t = 255 - aa;
  253. for (k = 0; k < sn1; k++)
  254. dp[k] = fz_mul255(sample[k], alpha) + fz_mul255(dp[k], t);
  255. for (; k < dn1; k++)
  256. dp[k] = 0;
  257. if (da)
  258. dp[dn1] = aa + fz_mul255(dp[dn1], t);
  259. if (hp)
  260. hp[0] = a + fz_mul255(hp[0], 255 - a);
  261. if (gp)
  262. gp[0] = aa + fz_mul255(gp[0], t);
  263. }
  264. }
  265. dp += dn1+da;
  266. if (hp)
  267. hp++;
  268. if (gp)
  269. gp++;
  270. u += fa;
  271. }
  272. while (--w);
  273. }
  274. static fz_forceinline void
  275. template_affine_alpha_N_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  276. {
  277. int k;
  278. do
  279. {
  280. affint ui = u >> PREC;
  281. affint vi = v >> PREC;
  282. if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
  283. {
  284. const byte *sample = sp + (vi * ss) + (ui * (sn1+sa));
  285. int a = sa ? sample[sn1] : 255;
  286. int aa = (sa ? fz_mul255(a, alpha) : alpha);
  287. if (aa != 0)
  288. {
  289. int t = 255 - aa;
  290. for (k = 0; k < sn1; k++)
  291. dp[k] = fz_mul255(sample[k], alpha) + fz_mul255(dp[k], t);
  292. for (; k < dn1; k++)
  293. dp[k] = 0;
  294. if (da)
  295. dp[dn1] = aa + fz_mul255(dp[dn1], t);
  296. if (hp)
  297. hp[0] = a + fz_mul255(hp[0], 255 - a);
  298. if (gp)
  299. gp[0] = aa + fz_mul255(gp[0], t);
  300. }
  301. }
  302. dp += dn1+da;
  303. if (hp)
  304. hp++;
  305. if (gp)
  306. gp++;
  307. u += fa;
  308. v += fb;
  309. }
  310. while (--w);
  311. }
  312. static fz_forceinline void
  313. template_affine_alpha_N_near_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  314. {
  315. int k;
  316. do
  317. {
  318. affint ui = u >> PREC;
  319. affint vi = v >> PREC;
  320. if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
  321. {
  322. const byte *sample = sp + (vi * ss) + (ui * (sn1+sa));
  323. int a = sa ? sample[sn1] : 255;
  324. int aa = (sa ? fz_mul255(a, alpha) : alpha);
  325. if (aa != 0)
  326. {
  327. int t = 255 - aa;
  328. for (k = 0; k < sn1; k++)
  329. if (fz_overprint_component(eop, k))
  330. dp[k] = fz_mul255(sample[k], alpha) + fz_mul255(dp[k], t);
  331. for (; k < dn1; k++)
  332. if (fz_overprint_component(eop, k))
  333. dp[k] = 0;
  334. if (da)
  335. dp[dn1] = aa + fz_mul255(dp[dn1], t);
  336. if (hp)
  337. hp[0] = a + fz_mul255(hp[0], 255 - a);
  338. if (gp)
  339. gp[0] = aa + fz_mul255(gp[0], t);
  340. }
  341. }
  342. dp += dn1+da;
  343. if (hp)
  344. hp++;
  345. if (gp)
  346. gp++;
  347. u += fa;
  348. v += fb;
  349. }
  350. while (--w);
  351. }
  352. static fz_forceinline void
  353. template_affine_alpha_g2rgb_near_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  354. {
  355. affint ui = u >> PREC;
  356. if (ui < 0 || ui >= sw)
  357. return;
  358. sp += ui * (1+sa);
  359. do
  360. {
  361. affint vi = v >> PREC;
  362. if (vi >= 0 && vi < sh)
  363. {
  364. const byte *sample = sp + (vi * ss);
  365. int x = fz_mul255(sample[0], alpha);
  366. int a = sa ? sample[1] : 255;
  367. int aa = (sa ? fz_mul255(a, alpha) : alpha);
  368. if (aa != 0)
  369. {
  370. int t = 255 - aa;
  371. dp[0] = x + fz_mul255(dp[0], t);
  372. dp[1] = x + fz_mul255(dp[1], t);
  373. dp[2] = x + fz_mul255(dp[2], t);
  374. if (da)
  375. dp[3] = aa + fz_mul255(dp[3], t);
  376. if (hp)
  377. hp[0] = a + fz_mul255(hp[0], 255 - a);
  378. if (gp)
  379. gp[0] = aa + fz_mul255(gp[0], t);
  380. }
  381. }
  382. dp += 3 + da;
  383. if (hp)
  384. hp++;
  385. if (gp)
  386. gp++;
  387. v += fb;
  388. }
  389. while (--w);
  390. }
  391. static fz_forceinline void
  392. template_affine_alpha_g2rgb_near_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  393. {
  394. affint vi = v >> PREC;
  395. if (vi < 0 || vi >= sh)
  396. return;
  397. sp += vi * ss;
  398. do
  399. {
  400. affint ui = u >> PREC;
  401. if (ui >= 0 && ui < sw)
  402. {
  403. const byte *sample = sp + (ui * (1+sa));
  404. int x = fz_mul255(sample[0], alpha);
  405. int a = sa ? sample[1] : 255;
  406. int aa = (sa ? fz_mul255(a, alpha) : alpha);
  407. if (aa != 0)
  408. {
  409. int t = 255 - aa;
  410. dp[0] = x + fz_mul255(dp[0], t);
  411. dp[1] = x + fz_mul255(dp[1], t);
  412. dp[2] = x + fz_mul255(dp[2], t);
  413. if (da)
  414. dp[3] = aa + fz_mul255(dp[3], t);
  415. if (hp)
  416. hp[0] = a + fz_mul255(hp[0], 255 - a);
  417. if (gp)
  418. gp[0] = aa + fz_mul255(gp[0], t);
  419. }
  420. }
  421. dp += 3 + da;
  422. if (hp)
  423. hp++;
  424. if (gp)
  425. gp++;
  426. u += fa;
  427. }
  428. while (--w);
  429. }
  430. static fz_forceinline void
  431. template_affine_alpha_g2rgb_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  432. {
  433. do
  434. {
  435. affint ui = u >> PREC;
  436. affint vi = v >> PREC;
  437. if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
  438. {
  439. const byte *sample = sp + (vi * ss) + (ui * (1+sa));
  440. int x = fz_mul255(sample[0], alpha);
  441. int a = sa ? sample[1] : 255;
  442. int aa = (sa ? fz_mul255(a, alpha): alpha);
  443. if (aa != 0)
  444. {
  445. int t = 255 - aa;
  446. dp[0] = x + fz_mul255(dp[0], t);
  447. dp[1] = x + fz_mul255(dp[1], t);
  448. dp[2] = x + fz_mul255(dp[2], t);
  449. if (da)
  450. dp[3] = aa + fz_mul255(dp[3], t);
  451. if (hp)
  452. hp[0] = a + fz_mul255(hp[0], 255 - a);
  453. if (gp)
  454. gp[0] = aa + fz_mul255(gp[0], t);
  455. }
  456. }
  457. dp += 3 + da;
  458. if (hp)
  459. hp++;
  460. if (gp)
  461. gp++;
  462. u += fa;
  463. v += fb;
  464. }
  465. while (--w);
  466. }
  467. /* Blend premultiplied source image over destination */
  468. static fz_forceinline void
  469. template_affine_N_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  470. {
  471. int k;
  472. do
  473. {
  474. if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
  475. {
  476. affint ui = u >> PREC;
  477. affint vi = v >> PREC;
  478. int uf = u & MASK;
  479. int vf = v & MASK;
  480. const byte *a = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi);
  481. const byte *b = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi);
  482. const byte *c = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi+1);
  483. const byte *d = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi+1);
  484. int y = sa ? bilerp(a[sn1], b[sn1], c[sn1], d[sn1], uf, vf) : 255;
  485. if (y != 0)
  486. {
  487. int t = 255 - y;
  488. for (k = 0; k < sn1; k++)
  489. {
  490. int x = bilerp(a[k], b[k], c[k], d[k], uf, vf);
  491. dp[k] = x + fz_mul255(dp[k], t);
  492. }
  493. for (; k < dn1; k++)
  494. dp[k] = 0;
  495. if (da)
  496. dp[dn1] = y + fz_mul255(dp[dn1], t);
  497. if (hp)
  498. hp[0] = y + fz_mul255(hp[0], t);
  499. if (gp)
  500. gp[0] = y + fz_mul255(gp[0], t);
  501. }
  502. }
  503. dp += dn1 + da;
  504. if (hp)
  505. hp++;
  506. if (gp)
  507. gp++;
  508. u += fa;
  509. v += fb;
  510. }
  511. while (--w);
  512. }
  513. static fz_forceinline void
  514. template_affine_N_lerp_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  515. {
  516. int k;
  517. do
  518. {
  519. if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
  520. {
  521. affint ui = u >> PREC;
  522. affint vi = v >> PREC;
  523. int uf = u & MASK;
  524. int vf = v & MASK;
  525. const byte *a = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi);
  526. const byte *b = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi);
  527. const byte *c = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi+1);
  528. const byte *d = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi+1);
  529. int y = sa ? bilerp(a[sn1], b[sn1], c[sn1], d[sn1], uf, vf) : 255;
  530. if (y != 0)
  531. {
  532. int t = 255 - y;
  533. for (k = 0; k < sn1; k++)
  534. if (fz_overprint_component(eop, k))
  535. {
  536. int x = bilerp(a[k], b[k], c[k], d[k], uf, vf);
  537. dp[k] = x + fz_mul255(dp[k], t);
  538. }
  539. for (; k < dn1; k++)
  540. if (fz_overprint_component(eop, k))
  541. dp[k] = 0;
  542. if (da)
  543. dp[dn1] = y + fz_mul255(dp[dn1], t);
  544. if (hp)
  545. hp[0] = y + fz_mul255(hp[0], t);
  546. if (gp)
  547. gp[0] = y + fz_mul255(gp[0], t);
  548. }
  549. }
  550. dp += dn1 + da;
  551. if (hp)
  552. hp++;
  553. if (gp)
  554. gp++;
  555. u += fa;
  556. v += fb;
  557. }
  558. while (--w);
  559. }
  560. static fz_forceinline void
  561. template_affine_solid_g2rgb_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  562. {
  563. do
  564. {
  565. if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
  566. {
  567. affint ui = u >> PREC;
  568. affint vi = v >> PREC;
  569. int uf = u & MASK;
  570. int vf = v & MASK;
  571. const byte *a = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi);
  572. const byte *b = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi);
  573. const byte *c = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi+1);
  574. const byte *d = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi+1);
  575. int y = (sa ? bilerp(a[1], b[1], c[1], d[1], uf, vf) : 255);
  576. if (y != 0)
  577. {
  578. int t = 255 - y;
  579. int x = bilerp(a[0], b[0], c[0], d[0], uf, vf);
  580. dp[0] = x + fz_mul255(dp[0], t);
  581. dp[1] = x + fz_mul255(dp[1], t);
  582. dp[2] = x + fz_mul255(dp[2], t);
  583. if (da)
  584. dp[3] = y + fz_mul255(dp[3], t);
  585. if (hp)
  586. hp[0] = y + fz_mul255(hp[0], t);
  587. if (gp)
  588. gp[0] = y + fz_mul255(gp[0], t);
  589. }
  590. }
  591. dp += 3 + da;
  592. if (hp)
  593. hp++;
  594. if (gp)
  595. gp++;
  596. u += fa;
  597. v += fb;
  598. }
  599. while (--w);
  600. }
  601. static fz_forceinline void
  602. template_affine_N_near_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  603. {
  604. int k;
  605. affint ui = u >> PREC;
  606. if (ui < 0 || ui >= sw)
  607. return;
  608. sp += ui*(sn1+sa);
  609. do
  610. {
  611. affint vi = v >> PREC;
  612. if (vi >= 0 && vi < sh)
  613. {
  614. const byte *sample = sp + (vi * ss);
  615. int a = (sa ? sample[sn1] : 255);
  616. /* If a is 0, then sample[k] = 0 for all k, as premultiplied */
  617. if (a != 0)
  618. {
  619. int t = 255 - a;
  620. if (t == 0)
  621. {
  622. if (dn1+da == 4 && dn1+sa == 4)
  623. {
  624. *(int32_t *)dp = *(int32_t *)sample;
  625. }
  626. else
  627. {
  628. dp[0] = sample[0];
  629. if (sn1 > 1)
  630. dp[1] = sample[1];
  631. if (sn1 > 2)
  632. dp[2] = sample[2];
  633. for (k = 3; k < sn1; k++)
  634. dp[k] = sample[k];
  635. for (k = sn1; k < dn1; k++)
  636. dp[k] = 0;
  637. if (da)
  638. dp[dn1] = a;
  639. }
  640. if (hp)
  641. hp[0] = a;
  642. if (gp)
  643. gp[0] = a;
  644. }
  645. else
  646. {
  647. for (k = 0; k < sn1; k++)
  648. dp[k] = sample[k] + fz_mul255(dp[k], t);
  649. for (; k < dn1; k++)
  650. dp[k] = 0;
  651. if (da)
  652. dp[dn1] = a + fz_mul255(dp[dn1], t);
  653. if (hp)
  654. hp[0] = a + fz_mul255(hp[0], t);
  655. if (gp)
  656. gp[0] = a + fz_mul255(gp[0], t);
  657. }
  658. }
  659. }
  660. dp += dn1+da;
  661. if (hp)
  662. hp++;
  663. if (gp)
  664. gp++;
  665. v += fb;
  666. }
  667. while (--w);
  668. }
  669. static fz_forceinline void
  670. template_affine_N_near_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  671. {
  672. int k;
  673. affint vi = v >> PREC;
  674. if (vi < 0 || vi >= sh)
  675. return;
  676. sp += vi * ss;
  677. do
  678. {
  679. affint ui = u >> PREC;
  680. if (ui >= 0 && ui < sw)
  681. {
  682. const byte *sample = sp + (ui * (sn1+sa));
  683. int a = sa ? sample[sn1] : 255;
  684. /* If a is 0, then sample[k] = 0 for all k, as premultiplied */
  685. if (a != 0)
  686. {
  687. int t = 255 - a;
  688. if (t == 0)
  689. {
  690. if (dn1+da == 4 && sn1+sa == 4)
  691. {
  692. *(int32_t *)dp = *(int32_t *)sample;
  693. }
  694. else
  695. {
  696. dp[0] = sample[0];
  697. if (sn1 > 1)
  698. dp[1] = sample[1];
  699. if (sn1 > 2)
  700. dp[2] = sample[2];
  701. for (k = 3; k < sn1; k++)
  702. dp[k] = sample[k];
  703. for (k = sn1; k < dn1; k++)
  704. dp[k] = 0;
  705. if (da)
  706. dp[dn1] = a;
  707. }
  708. if (hp)
  709. hp[0] = a;
  710. if (gp)
  711. gp[0] = a;
  712. }
  713. else
  714. {
  715. for (k = 0; k < sn1; k++)
  716. dp[k] = sample[k] + fz_mul255(dp[k], t);
  717. for (; k < dn1; k++)
  718. dp[k] = 0;
  719. if (da)
  720. dp[dn1] = a + fz_mul255(dp[dn1], t);
  721. if (hp)
  722. hp[0] = a + fz_mul255(hp[0], t);
  723. if (gp)
  724. gp[0] = a + fz_mul255(gp[0], t);
  725. }
  726. }
  727. }
  728. dp += dn1+da;
  729. if (hp)
  730. hp++;
  731. if (gp)
  732. gp++;
  733. u += fa;
  734. }
  735. while (--w);
  736. }
  737. static fz_forceinline void
  738. template_affine_N_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  739. {
  740. int k;
  741. do
  742. {
  743. affint ui = u >> PREC;
  744. affint vi = v >> PREC;
  745. if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
  746. {
  747. const byte *sample = sp + (vi * ss) + (ui * (sn1+sa));
  748. int a = sa ? sample[sn1] : 255;
  749. /* If a is 0, then sample[k] = 0 for all k, as premultiplied */
  750. if (a != 0)
  751. {
  752. int t = 255 - a;
  753. if (t == 0)
  754. {
  755. if (dn1+da == 4 && sn1+sa == 4)
  756. {
  757. *(int32_t *)dp = *(int32_t *)sample;
  758. }
  759. else
  760. {
  761. dp[0] = sample[0];
  762. if (sn1 > 1)
  763. dp[1] = sample[1];
  764. if (sn1 > 2)
  765. dp[2] = sample[2];
  766. for (k = 3; k < sn1; k++)
  767. dp[k] = sample[k];
  768. for (; k < dn1; k++)
  769. dp[k] = 0;
  770. if (da)
  771. dp[dn1] = a;
  772. }
  773. if (hp)
  774. hp[0] = a;
  775. if (gp)
  776. gp[0] = a;
  777. }
  778. else
  779. {
  780. for (k = 0; k < sn1; k++)
  781. dp[k] = sample[k] + fz_mul255(dp[k], t);
  782. for (; k < dn1; k++)
  783. dp[k] = 0;
  784. if (da)
  785. dp[dn1] = a + fz_mul255(dp[dn1], t);
  786. if (hp)
  787. hp[0] = a + fz_mul255(hp[0], t);
  788. if (gp)
  789. gp[0] = a + fz_mul255(gp[0], t);
  790. }
  791. }
  792. }
  793. dp += dn1+da;
  794. if (hp)
  795. hp++;
  796. if (gp)
  797. gp++;
  798. u += fa;
  799. v += fb;
  800. }
  801. while (--w);
  802. }
  803. static fz_forceinline void
  804. template_affine_N_near_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  805. {
  806. int k;
  807. do
  808. {
  809. affint ui = u >> PREC;
  810. affint vi = v >> PREC;
  811. if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
  812. {
  813. const byte *sample = sp + (vi * ss) + (ui * (sn1+sa));
  814. int a = sa ? sample[sn1] : 255;
  815. /* If a is 0, then sample[k] = 0 for all k, as premultiplied */
  816. if (a != 0)
  817. {
  818. int t = 255 - a;
  819. if (t == 0)
  820. {
  821. if (fz_overprint_component(eop, 0))
  822. dp[0] = sample[0];
  823. if (sn1 > 1)
  824. if (fz_overprint_component(eop, 1))
  825. dp[1] = sample[1];
  826. if (sn1 > 2)
  827. if (fz_overprint_component(eop, 2))
  828. dp[2] = sample[2];
  829. for (k = 3; k < sn1; k++)
  830. if (fz_overprint_component(eop, k))
  831. dp[k] = sample[k];
  832. for (; k < dn1; k++)
  833. if (fz_overprint_component(eop, k))
  834. dp[k] = 0;
  835. if (da)
  836. dp[dn1] = a;
  837. if (hp)
  838. hp[0] = a;
  839. if (gp)
  840. gp[0] = a;
  841. }
  842. else
  843. {
  844. for (k = 0; k < sn1; k++)
  845. if (fz_overprint_component(eop, k))
  846. dp[k] = sample[k] + fz_mul255(dp[k], t);
  847. for (; k < dn1; k++)
  848. if (fz_overprint_component(eop, k))
  849. dp[k] = 0;
  850. if (da)
  851. dp[dn1] = a + fz_mul255(dp[dn1], t);
  852. if (hp)
  853. hp[0] = a + fz_mul255(hp[0], t);
  854. if (gp)
  855. gp[0] = a + fz_mul255(gp[0], t);
  856. }
  857. }
  858. }
  859. dp += dn1+da;
  860. if (hp)
  861. hp++;
  862. if (gp)
  863. gp++;
  864. u += fa;
  865. v += fb;
  866. }
  867. while (--w);
  868. }
  869. static fz_forceinline void
  870. template_affine_solid_g2rgb_near_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  871. {
  872. affint ui = u >> PREC;
  873. if (ui < 0 || ui >= sw)
  874. return;
  875. sp += ui * (1+sa);
  876. do
  877. {
  878. affint vi = v >> PREC;
  879. if (vi >= 0 && vi < sh)
  880. {
  881. const byte *sample = sp + (vi * ss);
  882. int a = (sa ? sample[1] : 255);
  883. if (a != 0)
  884. {
  885. int x = sample[0];
  886. int t = 255 - a;
  887. if (t == 0)
  888. {
  889. dp[0] = x;
  890. dp[1] = x;
  891. dp[2] = x;
  892. if (da)
  893. dp[3] = a;
  894. if (hp)
  895. hp[0] = a;
  896. if (gp)
  897. gp[0] = a;
  898. }
  899. else
  900. {
  901. dp[0] = x + fz_mul255(dp[0], t);
  902. dp[1] = x + fz_mul255(dp[1], t);
  903. dp[2] = x + fz_mul255(dp[2], t);
  904. if (da)
  905. dp[3] = a + fz_mul255(dp[3], t);
  906. if (hp)
  907. hp[0] = a + fz_mul255(hp[0], t);
  908. if (gp)
  909. gp[0] = a + fz_mul255(gp[0], t);
  910. }
  911. }
  912. }
  913. dp += 3 + da;
  914. if (hp)
  915. hp++;
  916. if (gp)
  917. gp++;
  918. v += fb;
  919. }
  920. while (--w);
  921. }
  922. static fz_forceinline void
  923. template_affine_solid_g2rgb_near_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  924. {
  925. affint vi = v >> PREC;
  926. if (vi < 0 || vi >= sh)
  927. return;
  928. sp += vi * ss;
  929. do
  930. {
  931. affint ui = u >> PREC;
  932. if (ui >= 0 && ui < sw)
  933. {
  934. const byte *sample = sp + (ui * (1+sa));
  935. int a = (sa ? sample[1] : 255);
  936. if (a != 0)
  937. {
  938. int x = sample[0];
  939. int t = 255 - a;
  940. if (t == 0)
  941. {
  942. dp[0] = x;
  943. dp[1] = x;
  944. dp[2] = x;
  945. if (da)
  946. dp[3] = a;
  947. if (hp)
  948. hp[0] = a;
  949. if (gp)
  950. gp[0] = a;
  951. }
  952. else
  953. {
  954. dp[0] = x + fz_mul255(dp[0], t);
  955. dp[1] = x + fz_mul255(dp[1], t);
  956. dp[2] = x + fz_mul255(dp[2], t);
  957. if (da)
  958. dp[3] = a + fz_mul255(dp[3], t);
  959. if (hp)
  960. hp[0] = a + fz_mul255(hp[0], t);
  961. if (gp)
  962. gp[0] = a + fz_mul255(gp[0], t);
  963. }
  964. }
  965. }
  966. dp += 3 + da;
  967. if (hp)
  968. hp++;
  969. if (gp)
  970. gp++;
  971. u += fa;
  972. }
  973. while (--w);
  974. }
  975. static fz_forceinline void
  976. template_affine_solid_g2rgb_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  977. {
  978. do
  979. {
  980. affint ui = u >> PREC;
  981. affint vi = v >> PREC;
  982. if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
  983. {
  984. const byte *sample = sp + (vi * ss) + (ui * (1+sa));
  985. int a = sa ? sample[1] : 255;
  986. if (a != 0)
  987. {
  988. int x = sample[0];
  989. int t = 255 - a;
  990. if (t == 0)
  991. {
  992. dp[0] = x;
  993. dp[1] = x;
  994. dp[2] = x;
  995. if (da)
  996. dp[3] = a;
  997. if (hp)
  998. hp[0] = a;
  999. if (gp)
  1000. gp[0] = a;
  1001. }
  1002. else
  1003. {
  1004. dp[0] = x + fz_mul255(dp[0], t);
  1005. dp[1] = x + fz_mul255(dp[1], t);
  1006. dp[2] = x + fz_mul255(dp[2], t);
  1007. if (da)
  1008. dp[3] = a + fz_mul255(dp[3], t);
  1009. if (hp)
  1010. hp[0] = a + fz_mul255(hp[0], t);
  1011. if (gp)
  1012. gp[0] = a + fz_mul255(gp[0], t);
  1013. }
  1014. }
  1015. }
  1016. dp += 3 + da;
  1017. if (hp)
  1018. hp++;
  1019. if (gp)
  1020. gp++;
  1021. u += fa;
  1022. v += fb;
  1023. }
  1024. while (--w);
  1025. }
  1026. /* Blend non-premultiplied color in source image mask over destination */
  1027. static fz_forceinline void
  1028. template_affine_color_N_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  1029. {
  1030. int sa = color[dn1];
  1031. int k;
  1032. do
  1033. {
  1034. if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
  1035. {
  1036. affint ui = u >> PREC;
  1037. affint vi = v >> PREC;
  1038. int uf = u & MASK;
  1039. int vf = v & MASK;
  1040. const byte *a = sample_nearest(sp, sw, sh, ss, 1, ui, vi);
  1041. const byte *b = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi);
  1042. const byte *c = sample_nearest(sp, sw, sh, ss, 1, ui, vi+1);
  1043. const byte *d = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi+1);
  1044. int ma = bilerp(a[0], b[0], c[0], d[0], uf, vf);
  1045. int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
  1046. if (masa != 0)
  1047. {
  1048. for (k = 0; k < dn1; k++)
  1049. dp[k] = FZ_BLEND(color[k], dp[k], masa);
  1050. if (da)
  1051. dp[dn1] = FZ_BLEND(255, dp[dn1], masa);
  1052. if (hp)
  1053. hp[0] = FZ_BLEND(255, hp[0], ma);
  1054. if (gp)
  1055. gp[0] = FZ_BLEND(255, gp[0], masa);
  1056. }
  1057. }
  1058. dp += dn1 + da;
  1059. if (hp)
  1060. hp++;
  1061. if (gp)
  1062. gp++;
  1063. u += fa;
  1064. v += fb;
  1065. }
  1066. while (--w);
  1067. }
  1068. static fz_forceinline void
  1069. template_affine_color_N_lerp_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1070. {
  1071. int sa = color[dn1];
  1072. int k;
  1073. do
  1074. {
  1075. if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
  1076. {
  1077. affint ui = u >> PREC;
  1078. affint vi = v >> PREC;
  1079. int uf = u & MASK;
  1080. int vf = v & MASK;
  1081. const byte *a = sample_nearest(sp, sw, sh, ss, 1, ui, vi);
  1082. const byte *b = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi);
  1083. const byte *c = sample_nearest(sp, sw, sh, ss, 1, ui, vi+1);
  1084. const byte *d = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi+1);
  1085. int ma = bilerp(a[0], b[0], c[0], d[0], uf, vf);
  1086. int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
  1087. if (masa != 0)
  1088. {
  1089. for (k = 0; k < dn1; k++)
  1090. if (fz_overprint_component(eop, k))
  1091. dp[k] = FZ_BLEND(color[k], dp[k], masa);
  1092. if (da)
  1093. dp[dn1] = FZ_BLEND(255, dp[dn1], masa);
  1094. if (hp)
  1095. hp[0] = FZ_BLEND(255, hp[0], ma);
  1096. if (gp)
  1097. gp[0] = FZ_BLEND(255, gp[0], masa);
  1098. }
  1099. }
  1100. dp += dn1 + da;
  1101. if (hp)
  1102. hp++;
  1103. if (gp)
  1104. gp++;
  1105. u += fa;
  1106. v += fb;
  1107. }
  1108. while (--w);
  1109. }
  1110. static fz_forceinline void
  1111. template_affine_color_N_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
  1112. {
  1113. int sa = color[dn1];
  1114. int k;
  1115. do
  1116. {
  1117. affint ui = u >> PREC;
  1118. affint vi = v >> PREC;
  1119. if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
  1120. {
  1121. int ma = sp[vi * ss + ui];
  1122. int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
  1123. if (masa)
  1124. {
  1125. for (k = 0; k < dn1; k++)
  1126. dp[k] = FZ_BLEND(color[k], dp[k], masa);
  1127. if (da)
  1128. dp[dn1] = FZ_BLEND(255, dp[dn1], masa);
  1129. if (hp)
  1130. hp[0] = FZ_BLEND(255, hp[0], ma);
  1131. if (gp)
  1132. gp[0] = FZ_BLEND(255, gp[0], masa);
  1133. }
  1134. }
  1135. dp += dn1+da;
  1136. if (hp)
  1137. hp++;
  1138. if (gp)
  1139. gp++;
  1140. u += fa;
  1141. v += fb;
  1142. }
  1143. while (--w);
  1144. }
  1145. static fz_forceinline void
  1146. template_affine_color_N_near_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1147. {
  1148. int sa = color[dn1];
  1149. int k;
  1150. do
  1151. {
  1152. affint ui = u >> PREC;
  1153. affint vi = v >> PREC;
  1154. if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
  1155. {
  1156. int ma = sp[vi * ss + ui];
  1157. int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
  1158. if (masa)
  1159. {
  1160. for (k = 0; k < dn1; k++)
  1161. if (fz_overprint_component(eop, k))
  1162. dp[k] = FZ_BLEND(color[k], dp[k], masa);
  1163. if (da)
  1164. dp[dn1] = FZ_BLEND(255, dp[dn1], masa);
  1165. if (hp)
  1166. hp[0] = FZ_BLEND(255, hp[0], ma);
  1167. if (gp)
  1168. gp[0] = FZ_BLEND(255, gp[0], masa);
  1169. }
  1170. }
  1171. dp += dn1+da;
  1172. if (hp)
  1173. hp++;
  1174. if (gp)
  1175. gp++;
  1176. u += fa;
  1177. v += fb;
  1178. }
  1179. while (--w);
  1180. }
  1181. static void
  1182. paint_affine_lerp_da_sa_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1183. {
  1184. TRACK_FN();
  1185. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, hp, gp);
  1186. }
  1187. static void
  1188. paint_affine_lerp_da_sa_alpha_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1189. {
  1190. TRACK_FN();
  1191. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
  1192. }
  1193. static void
  1194. paint_affine_lerp_da_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1195. {
  1196. TRACK_FN();
  1197. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, hp, gp);
  1198. }
  1199. static void
  1200. paint_affine_lerp_da_alpha_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1201. {
  1202. TRACK_FN();
  1203. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
  1204. }
  1205. static void
  1206. paint_affine_lerp_da_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1207. {
  1208. TRACK_FN();
  1209. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
  1210. }
  1211. static void
  1212. paint_affine_lerp_da_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1213. {
  1214. TRACK_FN();
  1215. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1216. }
  1217. static void
  1218. paint_affine_lerp_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1219. {
  1220. TRACK_FN();
  1221. template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
  1222. }
  1223. static void
  1224. paint_affine_lerp_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1225. {
  1226. TRACK_FN();
  1227. template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1228. }
  1229. #if FZ_PLOTTERS_G
  1230. static void
  1231. paint_affine_lerp_da_sa_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1232. {
  1233. TRACK_FN();
  1234. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
  1235. }
  1236. static void
  1237. paint_affine_lerp_da_sa_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1238. {
  1239. TRACK_FN();
  1240. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1241. }
  1242. static void
  1243. paint_affine_lerp_sa_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1244. {
  1245. TRACK_FN();
  1246. template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
  1247. }
  1248. static void
  1249. paint_affine_lerp_sa_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1250. {
  1251. TRACK_FN();
  1252. template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1253. }
  1254. #endif /* FZ_PLOTTERS_G */
  1255. #if FZ_PLOTTERS_RGB
  1256. static void
  1257. paint_affine_lerp_da_sa_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1258. {
  1259. TRACK_FN();
  1260. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
  1261. }
  1262. static void
  1263. paint_affine_lerp_da_sa_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1264. {
  1265. TRACK_FN();
  1266. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  1267. }
  1268. static void
  1269. paint_affine_lerp_da_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1270. {
  1271. TRACK_FN();
  1272. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
  1273. }
  1274. static void
  1275. paint_affine_lerp_da_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1276. {
  1277. TRACK_FN();
  1278. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  1279. }
  1280. static void
  1281. paint_affine_lerp_sa_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1282. {
  1283. TRACK_FN();
  1284. template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
  1285. }
  1286. static void
  1287. paint_affine_lerp_sa_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1288. {
  1289. TRACK_FN();
  1290. template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  1291. }
  1292. static void
  1293. paint_affine_lerp_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1294. {
  1295. TRACK_FN();
  1296. template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
  1297. }
  1298. static void
  1299. paint_affine_lerp_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1300. {
  1301. TRACK_FN();
  1302. template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  1303. }
  1304. #endif /* FZ_PLOTTERS_RGB */
  1305. #if FZ_PLOTTERS_CMYK
  1306. static void
  1307. paint_affine_lerp_da_sa_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1308. {
  1309. TRACK_FN();
  1310. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
  1311. }
  1312. static void
  1313. paint_affine_lerp_da_sa_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1314. {
  1315. TRACK_FN();
  1316. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  1317. }
  1318. static void
  1319. paint_affine_lerp_da_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1320. {
  1321. TRACK_FN();
  1322. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
  1323. }
  1324. static void
  1325. paint_affine_lerp_da_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1326. {
  1327. TRACK_FN();
  1328. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  1329. }
  1330. static void
  1331. paint_affine_lerp_sa_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1332. {
  1333. TRACK_FN();
  1334. template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
  1335. }
  1336. static void
  1337. paint_affine_lerp_sa_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1338. {
  1339. TRACK_FN();
  1340. template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  1341. }
  1342. static void
  1343. paint_affine_lerp_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1344. {
  1345. TRACK_FN();
  1346. template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
  1347. }
  1348. static void
  1349. paint_affine_lerp_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1350. {
  1351. TRACK_FN();
  1352. template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  1353. }
  1354. #endif /* FZ_PLOTTERS_CMYK */
  1355. #if FZ_PLOTTERS_N
  1356. static void
  1357. paint_affine_lerp_da_sa_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1358. {
  1359. TRACK_FN();
  1360. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
  1361. }
  1362. static void
  1363. paint_affine_lerp_da_sa_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1364. {
  1365. TRACK_FN();
  1366. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  1367. }
  1368. static void
  1369. paint_affine_lerp_da_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1370. {
  1371. TRACK_FN();
  1372. template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
  1373. }
  1374. static void
  1375. paint_affine_lerp_da_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1376. {
  1377. TRACK_FN();
  1378. template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  1379. }
  1380. static void
  1381. paint_affine_lerp_sa_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1382. {
  1383. TRACK_FN();
  1384. template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
  1385. }
  1386. static void
  1387. paint_affine_lerp_sa_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1388. {
  1389. TRACK_FN();
  1390. template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  1391. }
  1392. static void
  1393. paint_affine_lerp_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1394. {
  1395. TRACK_FN();
  1396. template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
  1397. }
  1398. static void
  1399. paint_affine_lerp_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1400. {
  1401. TRACK_FN();
  1402. template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  1403. }
  1404. #endif /* FZ_PLOTTERS_N */
  1405. #if FZ_ENABLE_SPOT_RENDERING
  1406. static void
  1407. paint_affine_lerp_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1408. {
  1409. TRACK_FN();
  1410. template_affine_N_lerp_op(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, hp, gp, eop);
  1411. }
  1412. static void
  1413. paint_affine_lerp_alpha_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1414. {
  1415. TRACK_FN();
  1416. template_affine_alpha_N_lerp_op(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, alpha, hp, gp, eop);
  1417. }
  1418. #endif /* FZ_ENABLE_SPOT_RENDERING */
  1419. static paintfn_t *
  1420. fz_paint_affine_lerp(int da, int sa, affint fa, affint fb, int n, int alpha, const fz_overprint * FZ_RESTRICT eop)
  1421. {
  1422. #if FZ_ENABLE_SPOT_RENDERING
  1423. if (fz_overprint_required(eop))
  1424. {
  1425. if (alpha == 255)
  1426. return paint_affine_lerp_N_op;
  1427. else if (alpha > 0)
  1428. return paint_affine_lerp_alpha_N_op;
  1429. else
  1430. return NULL;
  1431. }
  1432. #endif /* FZ_ENABLE_SPOT_RENDERING */
  1433. switch(n)
  1434. {
  1435. case 0:
  1436. if (da)
  1437. {
  1438. if (sa)
  1439. {
  1440. if (alpha == 255)
  1441. return paint_affine_lerp_da_sa_0;
  1442. else if (alpha > 0)
  1443. return paint_affine_lerp_da_sa_alpha_0;
  1444. }
  1445. else
  1446. {
  1447. if (alpha == 255)
  1448. return paint_affine_lerp_da_0;
  1449. else if (alpha > 0)
  1450. return paint_affine_lerp_da_alpha_0;
  1451. }
  1452. }
  1453. break;
  1454. case 1:
  1455. if (sa)
  1456. {
  1457. #if FZ_PLOTTERS_G
  1458. if (da)
  1459. {
  1460. if (alpha == 255)
  1461. return paint_affine_lerp_da_sa_1;
  1462. else if (alpha > 0)
  1463. return paint_affine_lerp_da_sa_alpha_1;
  1464. }
  1465. else
  1466. {
  1467. if (alpha == 255)
  1468. return paint_affine_lerp_sa_1;
  1469. else if (alpha > 0)
  1470. return paint_affine_lerp_sa_alpha_1;
  1471. }
  1472. #else
  1473. goto fallback;
  1474. #endif /* FZ_PLOTTERS_H */
  1475. }
  1476. else
  1477. {
  1478. if (da)
  1479. {
  1480. if (alpha == 255)
  1481. return paint_affine_lerp_da_1;
  1482. else if (alpha > 0)
  1483. return paint_affine_lerp_da_alpha_1;
  1484. }
  1485. else
  1486. {
  1487. if (alpha == 255)
  1488. return paint_affine_lerp_1;
  1489. else if (alpha > 0)
  1490. return paint_affine_lerp_alpha_1;
  1491. }
  1492. }
  1493. break;
  1494. #if FZ_PLOTTERS_RGB
  1495. case 3:
  1496. if (da)
  1497. {
  1498. if (sa)
  1499. {
  1500. if (alpha == 255)
  1501. return paint_affine_lerp_da_sa_3;
  1502. else if (alpha > 0)
  1503. return paint_affine_lerp_da_sa_alpha_3;
  1504. }
  1505. else
  1506. {
  1507. if (alpha == 255)
  1508. return paint_affine_lerp_da_3;
  1509. else if (alpha > 0)
  1510. return paint_affine_lerp_da_alpha_3;
  1511. }
  1512. }
  1513. else
  1514. {
  1515. if (sa)
  1516. {
  1517. if (alpha == 255)
  1518. return paint_affine_lerp_sa_3;
  1519. else if (alpha > 0)
  1520. return paint_affine_lerp_sa_alpha_3;
  1521. }
  1522. else
  1523. {
  1524. if (alpha == 255)
  1525. return paint_affine_lerp_3;
  1526. else if (alpha > 0)
  1527. return paint_affine_lerp_alpha_3;
  1528. }
  1529. }
  1530. break;
  1531. #endif /* FZ_PLOTTERS_RGB */
  1532. #if FZ_PLOTTERS_CMYK
  1533. case 4:
  1534. if (da)
  1535. {
  1536. if (sa)
  1537. {
  1538. if (alpha == 255)
  1539. return paint_affine_lerp_da_sa_4;
  1540. else if (alpha > 0)
  1541. return paint_affine_lerp_da_sa_alpha_4;
  1542. }
  1543. else
  1544. {
  1545. if (alpha == 255)
  1546. return paint_affine_lerp_da_4;
  1547. else if (alpha > 0)
  1548. return paint_affine_lerp_da_alpha_4;
  1549. }
  1550. }
  1551. else
  1552. {
  1553. if (sa)
  1554. {
  1555. if (alpha == 255)
  1556. return paint_affine_lerp_sa_4;
  1557. else if (alpha > 0)
  1558. return paint_affine_lerp_sa_alpha_4;
  1559. }
  1560. else
  1561. {
  1562. if (alpha == 255)
  1563. return paint_affine_lerp_4;
  1564. else if (alpha > 0)
  1565. return paint_affine_lerp_alpha_4;
  1566. }
  1567. }
  1568. break;
  1569. #endif /* FZ_PLOTTERS_CMYK */
  1570. #if !FZ_PLOTTERS_G
  1571. fallback:
  1572. #endif /* FZ_PLOTTERS_G */
  1573. default:
  1574. #if FZ_PLOTTERS_N
  1575. if (da)
  1576. {
  1577. if (sa)
  1578. {
  1579. if (alpha == 255)
  1580. return paint_affine_lerp_da_sa_N;
  1581. else if (alpha > 0)
  1582. return paint_affine_lerp_da_sa_alpha_N;
  1583. }
  1584. else
  1585. {
  1586. if (alpha == 255)
  1587. return paint_affine_lerp_da_N;
  1588. else if (alpha > 0)
  1589. return paint_affine_lerp_da_alpha_N;
  1590. }
  1591. }
  1592. else
  1593. {
  1594. if (sa)
  1595. {
  1596. if (alpha == 255)
  1597. return paint_affine_lerp_sa_N;
  1598. else if (alpha > 0)
  1599. return paint_affine_lerp_sa_alpha_N;
  1600. }
  1601. else
  1602. {
  1603. if (alpha == 255)
  1604. return paint_affine_lerp_N;
  1605. else if (alpha > 0)
  1606. return paint_affine_lerp_alpha_N;
  1607. }
  1608. }
  1609. #endif /* FZ_PLOTTERS_N */
  1610. break;
  1611. }
  1612. return NULL;
  1613. }
  1614. #if FZ_ENABLE_SPOT_RENDERING
  1615. static paintfn_t *
  1616. fz_paint_affine_lerp_spots(int da, int sa, affint fa, affint fb, int dn, int sn, int alpha, const fz_overprint * FZ_RESTRICT eop)
  1617. {
  1618. if (fz_overprint_required(eop))
  1619. {
  1620. if (alpha == 255)
  1621. return paint_affine_lerp_N_op;
  1622. else if (alpha > 0)
  1623. return paint_affine_lerp_alpha_N_op;
  1624. }
  1625. else if (da)
  1626. {
  1627. if (sa)
  1628. {
  1629. if (alpha == 255)
  1630. return paint_affine_lerp_da_sa_N;
  1631. else if (alpha > 0)
  1632. return paint_affine_lerp_da_sa_alpha_N;
  1633. }
  1634. else
  1635. {
  1636. if (alpha == 255)
  1637. return paint_affine_lerp_da_N;
  1638. else if (alpha > 0)
  1639. return paint_affine_lerp_da_alpha_N;
  1640. }
  1641. }
  1642. else
  1643. {
  1644. if (sa)
  1645. {
  1646. if (alpha == 255)
  1647. return paint_affine_lerp_sa_N;
  1648. else if (alpha > 0)
  1649. return paint_affine_lerp_sa_alpha_N;
  1650. }
  1651. else
  1652. {
  1653. if (alpha == 255)
  1654. return paint_affine_lerp_N;
  1655. else if (alpha > 0)
  1656. return paint_affine_lerp_alpha_N;
  1657. }
  1658. }
  1659. return NULL;
  1660. }
  1661. #endif /* FZ_ENABLE_SPOT_RENDERING */
  1662. #if FZ_PLOTTERS_RGB
  1663. static void
  1664. paint_affine_lerp_da_sa_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1665. {
  1666. TRACK_FN();
  1667. template_affine_solid_g2rgb_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
  1668. }
  1669. static void
  1670. paint_affine_lerp_da_sa_g2rgb_alpha(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1671. {
  1672. TRACK_FN();
  1673. template_affine_alpha_g2rgb_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
  1674. }
  1675. static void
  1676. paint_affine_lerp_da_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1677. {
  1678. TRACK_FN();
  1679. template_affine_solid_g2rgb_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
  1680. }
  1681. static void
  1682. paint_affine_lerp_da_g2rgb_alpha(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1683. {
  1684. TRACK_FN();
  1685. template_affine_alpha_g2rgb_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
  1686. }
  1687. static void
  1688. paint_affine_lerp_sa_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1689. {
  1690. TRACK_FN();
  1691. template_affine_solid_g2rgb_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
  1692. }
  1693. static void
  1694. paint_affine_lerp_sa_g2rgb_alpha(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1695. {
  1696. TRACK_FN();
  1697. template_affine_alpha_g2rgb_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
  1698. }
  1699. static void
  1700. paint_affine_lerp_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1701. {
  1702. TRACK_FN();
  1703. template_affine_solid_g2rgb_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
  1704. }
  1705. static void
  1706. paint_affine_lerp_g2rgb_alpha(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1707. {
  1708. TRACK_FN();
  1709. template_affine_alpha_g2rgb_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
  1710. }
  1711. static paintfn_t *
  1712. fz_paint_affine_g2rgb_lerp(int da, int sa, affint fa, affint fb, int n, int alpha)
  1713. {
  1714. if (da)
  1715. {
  1716. if (sa)
  1717. {
  1718. if (alpha == 255)
  1719. return paint_affine_lerp_da_sa_g2rgb;
  1720. else if (alpha > 0)
  1721. return paint_affine_lerp_da_sa_g2rgb_alpha;
  1722. }
  1723. else
  1724. {
  1725. if (alpha == 255)
  1726. return paint_affine_lerp_da_g2rgb;
  1727. else if (alpha > 0)
  1728. return paint_affine_lerp_da_g2rgb_alpha;
  1729. }
  1730. }
  1731. else
  1732. {
  1733. if (sa)
  1734. {
  1735. if (alpha == 255)
  1736. return paint_affine_lerp_sa_g2rgb;
  1737. else if (alpha > 0)
  1738. return paint_affine_lerp_sa_g2rgb_alpha;
  1739. }
  1740. else
  1741. {
  1742. if (alpha == 255)
  1743. return paint_affine_lerp_g2rgb;
  1744. else if (alpha > 0)
  1745. return paint_affine_lerp_g2rgb_alpha;
  1746. }
  1747. }
  1748. return NULL;
  1749. }
  1750. #endif /* FZ_PLOTTERS_RGB */
  1751. static void
  1752. paint_affine_near_da_sa_0_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1753. {
  1754. TRACK_FN();
  1755. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, hp, gp);
  1756. }
  1757. static void
  1758. paint_affine_near_da_sa_alpha_0_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1759. {
  1760. TRACK_FN();
  1761. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
  1762. }
  1763. static void
  1764. paint_affine_near_da_0_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1765. {
  1766. TRACK_FN();
  1767. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, hp, gp);
  1768. }
  1769. static void
  1770. paint_affine_near_da_alpha_0_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1771. {
  1772. TRACK_FN();
  1773. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
  1774. }
  1775. static void
  1776. paint_affine_near_da_sa_0_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1777. {
  1778. TRACK_FN();
  1779. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, hp, gp);
  1780. }
  1781. static void
  1782. paint_affine_near_da_sa_alpha_0_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1783. {
  1784. TRACK_FN();
  1785. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
  1786. }
  1787. static void
  1788. paint_affine_near_da_0_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1789. {
  1790. TRACK_FN();
  1791. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, hp, gp);
  1792. }
  1793. static void
  1794. paint_affine_near_da_alpha_0_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1795. {
  1796. TRACK_FN();
  1797. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
  1798. }
  1799. static void
  1800. paint_affine_near_da_sa_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1801. {
  1802. TRACK_FN();
  1803. template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, hp, gp);
  1804. }
  1805. static void
  1806. paint_affine_near_da_sa_alpha_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1807. {
  1808. TRACK_FN();
  1809. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
  1810. }
  1811. static void
  1812. paint_affine_near_da_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1813. {
  1814. TRACK_FN();
  1815. template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, hp, gp);
  1816. }
  1817. static void
  1818. paint_affine_near_da_alpha_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1819. {
  1820. TRACK_FN();
  1821. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
  1822. }
  1823. static void
  1824. paint_affine_near_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int snn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1825. {
  1826. TRACK_FN();
  1827. template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
  1828. }
  1829. static void
  1830. paint_affine_near_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1831. {
  1832. TRACK_FN();
  1833. template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
  1834. }
  1835. static void
  1836. paint_affine_near_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1837. {
  1838. TRACK_FN();
  1839. template_affine_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
  1840. }
  1841. static void
  1842. paint_affine_near_alpha_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1843. {
  1844. TRACK_FN();
  1845. template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1846. }
  1847. static void
  1848. paint_affine_near_alpha_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1849. {
  1850. TRACK_FN();
  1851. template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1852. }
  1853. static void
  1854. paint_affine_near_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1855. {
  1856. TRACK_FN();
  1857. template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1858. }
  1859. static void
  1860. paint_affine_near_da_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1861. {
  1862. TRACK_FN();
  1863. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
  1864. }
  1865. static void
  1866. paint_affine_near_da_alpha_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1867. {
  1868. TRACK_FN();
  1869. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1870. }
  1871. static void
  1872. paint_affine_near_da_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1873. {
  1874. TRACK_FN();
  1875. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
  1876. }
  1877. static void
  1878. paint_affine_near_da_alpha_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1879. {
  1880. TRACK_FN();
  1881. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1882. }
  1883. static void
  1884. paint_affine_near_da_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1885. {
  1886. TRACK_FN();
  1887. template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
  1888. }
  1889. static void
  1890. paint_affine_near_da_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1891. {
  1892. TRACK_FN();
  1893. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1894. }
  1895. #if FZ_PLOTTERS_G
  1896. static void
  1897. paint_affine_near_da_sa_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1898. {
  1899. TRACK_FN();
  1900. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
  1901. }
  1902. static void
  1903. paint_affine_near_da_sa_alpha_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1904. {
  1905. TRACK_FN();
  1906. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1907. }
  1908. static void
  1909. paint_affine_near_sa_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1910. {
  1911. TRACK_FN();
  1912. template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
  1913. }
  1914. static void
  1915. paint_affine_near_sa_alpha_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1916. {
  1917. TRACK_FN();
  1918. template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1919. }
  1920. static void
  1921. paint_affine_near_da_sa_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1922. {
  1923. TRACK_FN();
  1924. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
  1925. }
  1926. static void
  1927. paint_affine_near_da_sa_alpha_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1928. {
  1929. TRACK_FN();
  1930. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1931. }
  1932. static void
  1933. paint_affine_near_sa_alpha_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1934. {
  1935. TRACK_FN();
  1936. template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1937. }
  1938. static void
  1939. paint_affine_near_da_sa_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1940. {
  1941. TRACK_FN();
  1942. template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
  1943. }
  1944. static void
  1945. paint_affine_near_sa_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1946. {
  1947. TRACK_FN();
  1948. template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
  1949. }
  1950. static void
  1951. paint_affine_near_da_sa_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1952. {
  1953. TRACK_FN();
  1954. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1955. }
  1956. static void
  1957. paint_affine_near_sa_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1958. {
  1959. TRACK_FN();
  1960. template_affine_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
  1961. }
  1962. static void
  1963. paint_affine_near_sa_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1964. {
  1965. TRACK_FN();
  1966. template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
  1967. }
  1968. #endif /* FZ_PLOTTERS_G */
  1969. #if FZ_PLOTTERS_RGB
  1970. static void
  1971. paint_affine_near_da_sa_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1972. {
  1973. TRACK_FN();
  1974. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
  1975. }
  1976. static void
  1977. paint_affine_near_da_sa_alpha_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1978. {
  1979. TRACK_FN();
  1980. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  1981. }
  1982. static void
  1983. paint_affine_near_da_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1984. {
  1985. TRACK_FN();
  1986. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
  1987. }
  1988. static void
  1989. paint_affine_near_da_alpha_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1990. {
  1991. TRACK_FN();
  1992. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  1993. }
  1994. static void
  1995. paint_affine_near_sa_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  1996. {
  1997. TRACK_FN();
  1998. template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
  1999. }
  2000. static void
  2001. paint_affine_near_sa_alpha_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2002. {
  2003. TRACK_FN();
  2004. template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2005. }
  2006. static void
  2007. paint_affine_near_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2008. {
  2009. TRACK_FN();
  2010. template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
  2011. }
  2012. static void
  2013. paint_affine_near_alpha_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2014. {
  2015. TRACK_FN();
  2016. template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2017. }
  2018. static void
  2019. paint_affine_near_da_sa_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2020. {
  2021. TRACK_FN();
  2022. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
  2023. }
  2024. static void
  2025. paint_affine_near_da_sa_alpha_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2026. {
  2027. TRACK_FN();
  2028. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2029. }
  2030. static void
  2031. paint_affine_near_da_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2032. {
  2033. TRACK_FN();
  2034. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
  2035. }
  2036. static void
  2037. paint_affine_near_da_alpha_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2038. {
  2039. TRACK_FN();
  2040. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2041. }
  2042. static void
  2043. paint_affine_near_sa_alpha_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2044. {
  2045. TRACK_FN();
  2046. template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2047. }
  2048. static void
  2049. paint_affine_near_da_sa_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2050. {
  2051. TRACK_FN();
  2052. template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
  2053. }
  2054. static void
  2055. paint_affine_near_alpha_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2056. {
  2057. TRACK_FN();
  2058. template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2059. }
  2060. static void
  2061. paint_affine_near_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2062. {
  2063. TRACK_FN();
  2064. template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
  2065. }
  2066. static void
  2067. paint_affine_near_sa_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2068. {
  2069. TRACK_FN();
  2070. template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
  2071. }
  2072. static void
  2073. paint_affine_near_da_sa_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2074. {
  2075. TRACK_FN();
  2076. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2077. }
  2078. static void
  2079. paint_affine_near_da_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2080. {
  2081. TRACK_FN();
  2082. template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
  2083. }
  2084. static void
  2085. paint_affine_near_sa_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2086. {
  2087. TRACK_FN();
  2088. template_affine_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
  2089. }
  2090. static void
  2091. paint_affine_near_da_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2092. {
  2093. TRACK_FN();
  2094. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2095. }
  2096. static void
  2097. paint_affine_near_sa_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2098. {
  2099. TRACK_FN();
  2100. template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2101. }
  2102. static void
  2103. paint_affine_near_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2104. {
  2105. TRACK_FN();
  2106. template_affine_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
  2107. }
  2108. static void
  2109. paint_affine_near_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2110. {
  2111. TRACK_FN();
  2112. template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
  2113. }
  2114. #endif /* FZ_PLOTTERS_RGB */
  2115. #if FZ_PLOTTERS_CMYK
  2116. static void
  2117. paint_affine_near_da_sa_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2118. {
  2119. TRACK_FN();
  2120. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
  2121. }
  2122. static void
  2123. paint_affine_near_da_sa_alpha_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2124. {
  2125. TRACK_FN();
  2126. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2127. }
  2128. static void
  2129. paint_affine_near_da_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2130. {
  2131. TRACK_FN();
  2132. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
  2133. }
  2134. static void
  2135. paint_affine_near_da_alpha_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2136. {
  2137. TRACK_FN();
  2138. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2139. }
  2140. static void
  2141. paint_affine_near_sa_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2142. {
  2143. TRACK_FN();
  2144. template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
  2145. }
  2146. static void
  2147. paint_affine_near_sa_alpha_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2148. {
  2149. TRACK_FN();
  2150. template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2151. }
  2152. static void
  2153. paint_affine_near_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2154. {
  2155. TRACK_FN();
  2156. template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
  2157. }
  2158. static void
  2159. paint_affine_near_alpha_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2160. {
  2161. TRACK_FN();
  2162. template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2163. }
  2164. static void
  2165. paint_affine_near_da_sa_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2166. {
  2167. TRACK_FN();
  2168. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
  2169. }
  2170. static void
  2171. paint_affine_near_da_sa_alpha_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2172. {
  2173. TRACK_FN();
  2174. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2175. }
  2176. static void
  2177. paint_affine_near_da_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2178. {
  2179. TRACK_FN();
  2180. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
  2181. }
  2182. static void
  2183. paint_affine_near_da_alpha_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2184. {
  2185. TRACK_FN();
  2186. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2187. }
  2188. static void
  2189. paint_affine_near_sa_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2190. {
  2191. TRACK_FN();
  2192. template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
  2193. }
  2194. static void
  2195. paint_affine_near_sa_alpha_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2196. {
  2197. TRACK_FN();
  2198. template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2199. }
  2200. static void
  2201. paint_affine_near_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2202. {
  2203. TRACK_FN();
  2204. template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
  2205. }
  2206. static void
  2207. paint_affine_near_alpha_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2208. {
  2209. TRACK_FN();
  2210. template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2211. }
  2212. static void
  2213. paint_affine_near_da_sa_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2214. {
  2215. TRACK_FN();
  2216. template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
  2217. }
  2218. static void
  2219. paint_affine_near_da_sa_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2220. {
  2221. TRACK_FN();
  2222. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2223. }
  2224. static void
  2225. paint_affine_near_da_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2226. {
  2227. TRACK_FN();
  2228. template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
  2229. }
  2230. static void
  2231. paint_affine_near_da_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2232. {
  2233. TRACK_FN();
  2234. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2235. }
  2236. static void
  2237. paint_affine_near_sa_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2238. {
  2239. TRACK_FN();
  2240. template_affine_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
  2241. }
  2242. static void
  2243. paint_affine_near_sa_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2244. {
  2245. TRACK_FN();
  2246. template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2247. }
  2248. static void
  2249. paint_affine_near_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2250. {
  2251. TRACK_FN();
  2252. template_affine_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
  2253. }
  2254. static void
  2255. paint_affine_near_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2256. {
  2257. TRACK_FN();
  2258. template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
  2259. }
  2260. #endif /* FZ_PLOTTERS_CMYK */
  2261. #if FZ_PLOTTERS_N
  2262. static void
  2263. paint_affine_near_da_sa_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2264. {
  2265. TRACK_FN();
  2266. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
  2267. }
  2268. static void
  2269. paint_affine_near_da_sa_alpha_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2270. {
  2271. TRACK_FN();
  2272. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2273. }
  2274. static void
  2275. paint_affine_near_da_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2276. {
  2277. TRACK_FN();
  2278. template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
  2279. }
  2280. static void
  2281. paint_affine_near_da_alpha_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2282. {
  2283. TRACK_FN();
  2284. template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2285. }
  2286. static void
  2287. paint_affine_near_sa_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2288. {
  2289. TRACK_FN();
  2290. template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
  2291. }
  2292. static void
  2293. paint_affine_near_sa_alpha_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2294. {
  2295. TRACK_FN();
  2296. template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2297. }
  2298. static void
  2299. paint_affine_near_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2300. {
  2301. TRACK_FN();
  2302. template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
  2303. }
  2304. static void
  2305. paint_affine_near_alpha_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2306. {
  2307. TRACK_FN();
  2308. template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2309. }
  2310. static void
  2311. paint_affine_near_da_sa_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2312. {
  2313. TRACK_FN();
  2314. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
  2315. }
  2316. static void
  2317. paint_affine_near_da_sa_alpha_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2318. {
  2319. TRACK_FN();
  2320. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2321. }
  2322. static void
  2323. paint_affine_near_da_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2324. {
  2325. TRACK_FN();
  2326. template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
  2327. }
  2328. static void
  2329. paint_affine_near_da_alpha_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2330. {
  2331. TRACK_FN();
  2332. template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2333. }
  2334. static void
  2335. paint_affine_near_sa_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2336. {
  2337. TRACK_FN();
  2338. template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
  2339. }
  2340. static void
  2341. paint_affine_near_sa_alpha_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2342. {
  2343. TRACK_FN();
  2344. template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2345. }
  2346. static void
  2347. paint_affine_near_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2348. {
  2349. TRACK_FN();
  2350. template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
  2351. }
  2352. static void
  2353. paint_affine_near_alpha_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2354. {
  2355. TRACK_FN();
  2356. template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2357. }
  2358. static void
  2359. paint_affine_near_da_sa_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2360. {
  2361. TRACK_FN();
  2362. template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
  2363. }
  2364. static void
  2365. paint_affine_near_da_sa_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2366. {
  2367. TRACK_FN();
  2368. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2369. }
  2370. static void
  2371. paint_affine_near_da_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2372. {
  2373. TRACK_FN();
  2374. template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
  2375. }
  2376. static void
  2377. paint_affine_near_da_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2378. {
  2379. TRACK_FN();
  2380. template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2381. }
  2382. static void
  2383. paint_affine_near_sa_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2384. {
  2385. TRACK_FN();
  2386. template_affine_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
  2387. }
  2388. static void
  2389. paint_affine_near_sa_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2390. {
  2391. TRACK_FN();
  2392. template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2393. }
  2394. static void
  2395. paint_affine_near_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2396. {
  2397. TRACK_FN();
  2398. template_affine_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
  2399. }
  2400. static void
  2401. paint_affine_near_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2402. {
  2403. TRACK_FN();
  2404. template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
  2405. }
  2406. #endif /* FZ_PLOTTERS_N */
  2407. #if FZ_ENABLE_SPOT_RENDERING
  2408. static void
  2409. paint_affine_near_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2410. {
  2411. TRACK_FN();
  2412. template_affine_N_near_op(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, hp, gp, eop);
  2413. }
  2414. static void
  2415. paint_affine_near_alpha_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2416. {
  2417. TRACK_FN();
  2418. template_affine_alpha_N_near_op(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, alpha, hp, gp, eop);
  2419. }
  2420. #endif /* FZ_ENABLE_SPOT_RENDERING */
  2421. static paintfn_t *
  2422. fz_paint_affine_near(int da, int sa, affint fa, affint fb, int n, int alpha, const fz_overprint * FZ_RESTRICT eop)
  2423. {
  2424. #if FZ_ENABLE_SPOT_RENDERING
  2425. if (fz_overprint_required(eop))
  2426. {
  2427. if (alpha == 255)
  2428. return paint_affine_near_N_op;
  2429. else if (alpha > 0)
  2430. return paint_affine_near_alpha_N_op;
  2431. else
  2432. return NULL;
  2433. }
  2434. #endif /* FZ_ENABLE_SPOT_RENDERING */
  2435. switch(n)
  2436. {
  2437. case 0:
  2438. if (da)
  2439. {
  2440. if (sa)
  2441. {
  2442. if (alpha == 255)
  2443. {
  2444. if (fa == 0)
  2445. return paint_affine_near_da_sa_0_fa0;
  2446. else if (fb == 0)
  2447. return paint_affine_near_da_sa_0_fb0;
  2448. else
  2449. return paint_affine_near_da_sa_0;
  2450. }
  2451. else if (alpha > 0)
  2452. {
  2453. if (fa == 0)
  2454. return paint_affine_near_da_sa_alpha_0_fa0;
  2455. else if (fb == 0)
  2456. return paint_affine_near_da_sa_alpha_0_fb0;
  2457. else
  2458. return paint_affine_near_da_sa_alpha_0;
  2459. }
  2460. }
  2461. else
  2462. {
  2463. if (alpha == 255)
  2464. {
  2465. if (fa == 0)
  2466. return paint_affine_near_da_0_fa0;
  2467. else if (fb == 0)
  2468. return paint_affine_near_da_0_fb0;
  2469. else
  2470. return paint_affine_near_da_0;
  2471. }
  2472. else if (alpha > 0)
  2473. {
  2474. if (fa == 0)
  2475. return paint_affine_near_da_alpha_0_fa0;
  2476. else if (fb == 0)
  2477. return paint_affine_near_da_alpha_0_fb0;
  2478. else
  2479. return paint_affine_near_da_alpha_0;
  2480. }
  2481. }
  2482. }
  2483. break;
  2484. case 1:
  2485. if (sa)
  2486. {
  2487. #if FZ_PLOTTERS_G
  2488. if (da)
  2489. {
  2490. if (alpha == 255)
  2491. {
  2492. if (fa == 0)
  2493. return paint_affine_near_da_sa_1_fa0;
  2494. else if (fb == 0)
  2495. return paint_affine_near_da_sa_1_fb0;
  2496. else
  2497. return paint_affine_near_da_sa_1;
  2498. }
  2499. else if (alpha > 0)
  2500. {
  2501. if (fa == 0)
  2502. return paint_affine_near_da_sa_alpha_1_fa0;
  2503. else if (fb == 0)
  2504. return paint_affine_near_da_sa_alpha_1_fb0;
  2505. else
  2506. return paint_affine_near_da_sa_alpha_1;
  2507. }
  2508. }
  2509. else
  2510. {
  2511. if (alpha == 255)
  2512. {
  2513. if (fa == 0)
  2514. return paint_affine_near_sa_1_fa0;
  2515. else if (fb == 0)
  2516. return paint_affine_near_sa_1_fb0;
  2517. else
  2518. return paint_affine_near_sa_1;
  2519. }
  2520. else if (alpha > 0)
  2521. {
  2522. if (fa == 0)
  2523. return paint_affine_near_sa_alpha_1_fa0;
  2524. else if (fb == 0)
  2525. return paint_affine_near_sa_alpha_1_fb0;
  2526. else
  2527. return paint_affine_near_sa_alpha_1;
  2528. }
  2529. }
  2530. #else
  2531. goto fallback;
  2532. #endif /* FZ_PLOTTERS_G */
  2533. }
  2534. else
  2535. {
  2536. if (da)
  2537. {
  2538. if (alpha == 255)
  2539. {
  2540. if (fa == 0)
  2541. return paint_affine_near_da_1_fa0;
  2542. else if (fb == 0)
  2543. return paint_affine_near_da_1_fb0;
  2544. else
  2545. return paint_affine_near_da_1;
  2546. }
  2547. else if (alpha > 0)
  2548. {
  2549. if (fa == 0)
  2550. return paint_affine_near_da_alpha_1_fa0;
  2551. else if (fb == 0)
  2552. return paint_affine_near_da_alpha_1_fb0;
  2553. else
  2554. return paint_affine_near_da_alpha_1;
  2555. }
  2556. }
  2557. else
  2558. {
  2559. if (alpha == 255)
  2560. {
  2561. if (fa == 0)
  2562. return paint_affine_near_1_fa0;
  2563. else if (fb == 0)
  2564. return paint_affine_near_1_fb0;
  2565. else
  2566. return paint_affine_near_1;
  2567. }
  2568. else if (alpha > 0)
  2569. {
  2570. if (fa == 0)
  2571. return paint_affine_near_alpha_1_fa0;
  2572. else if (fb == 0)
  2573. return paint_affine_near_alpha_1_fb0;
  2574. else
  2575. return paint_affine_near_alpha_1;
  2576. }
  2577. }
  2578. }
  2579. break;
  2580. #if FZ_PLOTTERS_RGB
  2581. case 3:
  2582. if (da)
  2583. {
  2584. if (sa)
  2585. {
  2586. if (alpha == 255)
  2587. {
  2588. if (fa == 0)
  2589. return paint_affine_near_da_sa_3_fa0;
  2590. else if (fb == 0)
  2591. return paint_affine_near_da_sa_3_fb0;
  2592. else
  2593. return paint_affine_near_da_sa_3;
  2594. }
  2595. else if (alpha > 0)
  2596. {
  2597. if (fa == 0)
  2598. return paint_affine_near_da_sa_alpha_3_fa0;
  2599. else if (fb == 0)
  2600. return paint_affine_near_da_sa_alpha_3_fb0;
  2601. else
  2602. return paint_affine_near_da_sa_alpha_3;
  2603. }
  2604. }
  2605. else
  2606. {
  2607. if (alpha == 255)
  2608. {
  2609. if (fa == 0)
  2610. return paint_affine_near_da_3_fa0;
  2611. else if (fb == 0)
  2612. return paint_affine_near_da_3_fb0;
  2613. else
  2614. return paint_affine_near_da_3;
  2615. }
  2616. else if (alpha > 0)
  2617. {
  2618. if (fa == 0)
  2619. return paint_affine_near_da_alpha_3_fa0;
  2620. else if (fb == 0)
  2621. return paint_affine_near_da_alpha_3_fb0;
  2622. else
  2623. return paint_affine_near_da_alpha_3;
  2624. }
  2625. }
  2626. }
  2627. else
  2628. {
  2629. if (sa)
  2630. {
  2631. if (alpha == 255)
  2632. {
  2633. if (fa == 0)
  2634. return paint_affine_near_sa_3_fa0;
  2635. else if (fb == 0)
  2636. return paint_affine_near_sa_3_fb0;
  2637. else
  2638. return paint_affine_near_sa_3;
  2639. }
  2640. else if (alpha > 0)
  2641. {
  2642. if (fa == 0)
  2643. return paint_affine_near_sa_alpha_3_fa0;
  2644. else if (fb == 0)
  2645. return paint_affine_near_sa_alpha_3_fb0;
  2646. else
  2647. return paint_affine_near_sa_alpha_3;
  2648. }
  2649. }
  2650. else
  2651. {
  2652. if (alpha == 255)
  2653. {
  2654. if (fa == 0)
  2655. return paint_affine_near_3_fa0;
  2656. else if (fb == 0)
  2657. return paint_affine_near_3_fb0;
  2658. else
  2659. return paint_affine_near_3;
  2660. }
  2661. else if (alpha > 0)
  2662. {
  2663. if (fa == 0)
  2664. return paint_affine_near_alpha_3_fa0;
  2665. else if (fb == 0)
  2666. return paint_affine_near_alpha_3_fb0;
  2667. else
  2668. return paint_affine_near_alpha_3;
  2669. }
  2670. }
  2671. }
  2672. break;
  2673. #endif /* FZ_PLOTTERS_RGB */
  2674. #if FZ_PLOTTERS_CMYK
  2675. case 4:
  2676. if (da)
  2677. {
  2678. if (sa)
  2679. {
  2680. if (alpha == 255)
  2681. {
  2682. if (fa == 0)
  2683. return paint_affine_near_da_sa_4_fa0;
  2684. else if (fb == 0)
  2685. return paint_affine_near_da_sa_4_fb0;
  2686. else
  2687. return paint_affine_near_da_sa_4;
  2688. }
  2689. else if (alpha > 0)
  2690. {
  2691. if (fa == 0)
  2692. return paint_affine_near_da_sa_alpha_4_fa0;
  2693. else if (fb == 0)
  2694. return paint_affine_near_da_sa_alpha_4_fb0;
  2695. else
  2696. return paint_affine_near_da_sa_alpha_4;
  2697. }
  2698. }
  2699. else
  2700. {
  2701. if (alpha == 255)
  2702. {
  2703. if (fa == 0)
  2704. return paint_affine_near_da_4_fa0;
  2705. else if (fb == 0)
  2706. return paint_affine_near_da_4_fb0;
  2707. else
  2708. return paint_affine_near_da_4;
  2709. }
  2710. else if (alpha > 0)
  2711. {
  2712. if (fa == 0)
  2713. return paint_affine_near_da_alpha_4_fa0;
  2714. else if (fb == 0)
  2715. return paint_affine_near_da_alpha_4_fb0;
  2716. else
  2717. return paint_affine_near_da_alpha_4;
  2718. }
  2719. }
  2720. }
  2721. else
  2722. {
  2723. if (sa)
  2724. {
  2725. if (alpha == 255)
  2726. {
  2727. if (fa == 0)
  2728. return paint_affine_near_sa_4_fa0;
  2729. else if (fb == 0)
  2730. return paint_affine_near_sa_4_fb0;
  2731. else
  2732. return paint_affine_near_sa_4;
  2733. }
  2734. else if (alpha > 0)
  2735. {
  2736. if (fa == 0)
  2737. return paint_affine_near_sa_alpha_4_fa0;
  2738. else if (fb == 0)
  2739. return paint_affine_near_sa_alpha_4_fb0;
  2740. else
  2741. return paint_affine_near_sa_alpha_4;
  2742. }
  2743. }
  2744. else
  2745. {
  2746. if (alpha == 255)
  2747. {
  2748. if (fa == 0)
  2749. return paint_affine_near_4_fa0;
  2750. else if (fb == 0)
  2751. return paint_affine_near_4_fb0;
  2752. else
  2753. return paint_affine_near_4;
  2754. }
  2755. else if (alpha > 0)
  2756. {
  2757. if (fa == 0)
  2758. return paint_affine_near_alpha_4_fa0;
  2759. else if (fb == 0)
  2760. return paint_affine_near_alpha_4_fb0;
  2761. else
  2762. return paint_affine_near_alpha_4;
  2763. }
  2764. }
  2765. }
  2766. break;
  2767. #endif /* FZ_PLOTTERS_CMYK */
  2768. #if !FZ_PLOTTERS_G
  2769. fallback:
  2770. #endif /* FZ_PLOTTERS_G */
  2771. default:
  2772. #if FZ_PLOTTERS_N
  2773. if (da)
  2774. {
  2775. if (sa)
  2776. {
  2777. if (alpha == 255)
  2778. {
  2779. if (fa == 0)
  2780. return paint_affine_near_da_sa_N_fa0;
  2781. else if (fb == 0)
  2782. return paint_affine_near_da_sa_N_fb0;
  2783. else
  2784. return paint_affine_near_da_sa_N;
  2785. }
  2786. else if (alpha > 0)
  2787. {
  2788. if (fa == 0)
  2789. return paint_affine_near_da_sa_alpha_N_fa0;
  2790. else if (fb == 0)
  2791. return paint_affine_near_da_sa_alpha_N_fb0;
  2792. else
  2793. return paint_affine_near_da_sa_alpha_N;
  2794. }
  2795. }
  2796. else
  2797. {
  2798. if (alpha == 255)
  2799. {
  2800. if (fa == 0)
  2801. return paint_affine_near_da_N_fa0;
  2802. else if (fb == 0)
  2803. return paint_affine_near_da_N_fb0;
  2804. else
  2805. return paint_affine_near_da_N;
  2806. }
  2807. else if (alpha > 0)
  2808. {
  2809. if (fa == 0)
  2810. return paint_affine_near_da_alpha_N_fa0;
  2811. else if (fb == 0)
  2812. return paint_affine_near_da_alpha_N_fb0;
  2813. else
  2814. return paint_affine_near_da_alpha_N;
  2815. }
  2816. }
  2817. }
  2818. else
  2819. {
  2820. if (sa)
  2821. {
  2822. if (alpha == 255)
  2823. {
  2824. if (fa == 0)
  2825. return paint_affine_near_sa_N_fa0;
  2826. else if (fb == 0)
  2827. return paint_affine_near_sa_N_fb0;
  2828. else
  2829. return paint_affine_near_sa_N;
  2830. }
  2831. else if (alpha > 0)
  2832. {
  2833. if (fa == 0)
  2834. return paint_affine_near_sa_alpha_N_fa0;
  2835. else if (fb == 0)
  2836. return paint_affine_near_sa_alpha_N_fb0;
  2837. else
  2838. return paint_affine_near_sa_alpha_N;
  2839. }
  2840. }
  2841. else
  2842. {
  2843. if (alpha == 255)
  2844. {
  2845. if (fa == 0)
  2846. return paint_affine_near_N_fa0;
  2847. else if (fb == 0)
  2848. return paint_affine_near_N_fb0;
  2849. else
  2850. return paint_affine_near_N;
  2851. }
  2852. else if (alpha > 0)
  2853. {
  2854. if (fa == 0)
  2855. return paint_affine_near_alpha_N_fa0;
  2856. else if (fb == 0)
  2857. return paint_affine_near_alpha_N_fb0;
  2858. else
  2859. return paint_affine_near_alpha_N;
  2860. }
  2861. }
  2862. }
  2863. #endif /* FZ_PLOTTERS_N */
  2864. break;
  2865. }
  2866. return NULL;
  2867. }
  2868. #if FZ_ENABLE_SPOT_RENDERING
  2869. static paintfn_t *
  2870. fz_paint_affine_near_spots(int da, int sa, affint fa, affint fb, int dn, int sn, int alpha, const fz_overprint * FZ_RESTRICT eop)
  2871. {
  2872. if (fz_overprint_required(eop))
  2873. {
  2874. if (alpha == 255)
  2875. return paint_affine_near_N_op;
  2876. else if (alpha > 0)
  2877. return paint_affine_near_alpha_N_op;
  2878. }
  2879. else if (da)
  2880. {
  2881. if (sa)
  2882. {
  2883. if (alpha == 255)
  2884. {
  2885. if (fa == 0)
  2886. return paint_affine_near_da_sa_N_fa0;
  2887. else if (fb == 0)
  2888. return paint_affine_near_da_sa_N_fb0;
  2889. else
  2890. return paint_affine_near_da_sa_N;
  2891. }
  2892. else if (alpha > 0)
  2893. {
  2894. if (fa == 0)
  2895. return paint_affine_near_da_sa_alpha_N_fa0;
  2896. else if (fb == 0)
  2897. return paint_affine_near_da_sa_alpha_N_fb0;
  2898. else
  2899. return paint_affine_near_da_sa_alpha_N;
  2900. }
  2901. }
  2902. else
  2903. {
  2904. if (alpha == 255)
  2905. {
  2906. if (fa == 0)
  2907. return paint_affine_near_da_N_fa0;
  2908. else if (fb == 0)
  2909. return paint_affine_near_da_N_fb0;
  2910. else
  2911. return paint_affine_near_da_N;
  2912. }
  2913. else if (alpha > 0)
  2914. {
  2915. if (fa == 0)
  2916. return paint_affine_near_da_alpha_N_fa0;
  2917. else if (fb == 0)
  2918. return paint_affine_near_da_alpha_N_fb0;
  2919. else
  2920. return paint_affine_near_da_alpha_N;
  2921. }
  2922. }
  2923. }
  2924. else
  2925. {
  2926. if (sa)
  2927. {
  2928. if (alpha == 255)
  2929. {
  2930. if (fa == 0)
  2931. return paint_affine_near_sa_N_fa0;
  2932. else if (fb == 0)
  2933. return paint_affine_near_sa_N_fb0;
  2934. else
  2935. return paint_affine_near_sa_N;
  2936. }
  2937. else if (alpha > 0)
  2938. {
  2939. if (fa == 0)
  2940. return paint_affine_near_sa_alpha_N_fa0;
  2941. else if (fb == 0)
  2942. return paint_affine_near_sa_alpha_N_fb0;
  2943. else
  2944. return paint_affine_near_sa_alpha_N;
  2945. }
  2946. }
  2947. else
  2948. {
  2949. if (alpha == 255)
  2950. {
  2951. if (fa == 0)
  2952. return paint_affine_near_N_fa0;
  2953. else if (fb == 0)
  2954. return paint_affine_near_N_fb0;
  2955. else
  2956. return paint_affine_near_N;
  2957. }
  2958. else if (alpha > 0)
  2959. {
  2960. if (fa == 0)
  2961. return paint_affine_near_alpha_N_fa0;
  2962. else if (fb == 0)
  2963. return paint_affine_near_alpha_N_fb0;
  2964. else
  2965. return paint_affine_near_alpha_N;
  2966. }
  2967. }
  2968. }
  2969. return NULL;
  2970. }
  2971. #endif /* FZ_ENABLE_SPOT_RENDERING */
  2972. #if FZ_PLOTTERS_RGB
  2973. static void
  2974. paint_affine_near_da_sa_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2975. {
  2976. TRACK_FN();
  2977. template_affine_solid_g2rgb_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
  2978. }
  2979. static void
  2980. paint_affine_near_da_sa_alpha_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2981. {
  2982. TRACK_FN();
  2983. template_affine_alpha_g2rgb_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
  2984. }
  2985. static void
  2986. paint_affine_near_da_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2987. {
  2988. TRACK_FN();
  2989. template_affine_solid_g2rgb_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
  2990. }
  2991. static void
  2992. paint_affine_near_da_alpha_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2993. {
  2994. TRACK_FN();
  2995. template_affine_alpha_g2rgb_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
  2996. }
  2997. static void
  2998. paint_affine_near_sa_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  2999. {
  3000. TRACK_FN();
  3001. template_affine_solid_g2rgb_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
  3002. }
  3003. static void
  3004. paint_affine_near_sa_alpha_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3005. {
  3006. TRACK_FN();
  3007. template_affine_alpha_g2rgb_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
  3008. }
  3009. static void
  3010. paint_affine_near_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3011. {
  3012. TRACK_FN();
  3013. template_affine_solid_g2rgb_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
  3014. }
  3015. static void
  3016. paint_affine_near_alpha_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3017. {
  3018. TRACK_FN();
  3019. template_affine_alpha_g2rgb_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
  3020. }
  3021. static void
  3022. paint_affine_near_da_sa_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3023. {
  3024. TRACK_FN();
  3025. template_affine_solid_g2rgb_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
  3026. }
  3027. static void
  3028. paint_affine_near_da_sa_alpha_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3029. {
  3030. TRACK_FN();
  3031. template_affine_alpha_g2rgb_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
  3032. }
  3033. static void
  3034. paint_affine_near_da_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3035. {
  3036. TRACK_FN();
  3037. template_affine_solid_g2rgb_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
  3038. }
  3039. static void
  3040. paint_affine_near_da_alpha_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3041. {
  3042. TRACK_FN();
  3043. template_affine_alpha_g2rgb_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
  3044. }
  3045. static void
  3046. paint_affine_near_sa_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3047. {
  3048. TRACK_FN();
  3049. template_affine_solid_g2rgb_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
  3050. }
  3051. static void
  3052. paint_affine_near_sa_alpha_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3053. {
  3054. TRACK_FN();
  3055. template_affine_alpha_g2rgb_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
  3056. }
  3057. static void
  3058. paint_affine_near_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3059. {
  3060. TRACK_FN();
  3061. template_affine_solid_g2rgb_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
  3062. }
  3063. static void
  3064. paint_affine_near_alpha_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3065. {
  3066. TRACK_FN();
  3067. template_affine_alpha_g2rgb_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
  3068. }
  3069. static void
  3070. paint_affine_near_da_sa_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3071. {
  3072. TRACK_FN();
  3073. template_affine_solid_g2rgb_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
  3074. }
  3075. static void
  3076. paint_affine_near_da_sa_alpha_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3077. {
  3078. TRACK_FN();
  3079. template_affine_alpha_g2rgb_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
  3080. }
  3081. static void
  3082. paint_affine_near_da_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3083. {
  3084. TRACK_FN();
  3085. template_affine_solid_g2rgb_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
  3086. }
  3087. static void
  3088. paint_affine_near_da_alpha_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3089. {
  3090. TRACK_FN();
  3091. template_affine_alpha_g2rgb_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
  3092. }
  3093. static void
  3094. paint_affine_near_sa_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3095. {
  3096. TRACK_FN();
  3097. template_affine_solid_g2rgb_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
  3098. }
  3099. static void
  3100. paint_affine_near_sa_alpha_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3101. {
  3102. TRACK_FN();
  3103. template_affine_alpha_g2rgb_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
  3104. }
  3105. static void
  3106. paint_affine_near_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3107. {
  3108. TRACK_FN();
  3109. template_affine_solid_g2rgb_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
  3110. }
  3111. static void
  3112. paint_affine_near_alpha_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3113. {
  3114. TRACK_FN();
  3115. template_affine_alpha_g2rgb_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
  3116. }
  3117. static paintfn_t *
  3118. fz_paint_affine_g2rgb_near(int da, int sa, affint fa, affint fb, int n, int alpha)
  3119. {
  3120. if (da)
  3121. {
  3122. if (sa)
  3123. {
  3124. if (fa == 0)
  3125. {
  3126. if (alpha == 255)
  3127. return paint_affine_near_da_sa_g2rgb_fa0;
  3128. else if (alpha > 0)
  3129. return paint_affine_near_da_sa_alpha_g2rgb_fa0;
  3130. }
  3131. else if (fb == 0)
  3132. {
  3133. if (alpha == 255)
  3134. return paint_affine_near_da_sa_g2rgb_fb0;
  3135. else if (alpha > 0)
  3136. return paint_affine_near_da_sa_alpha_g2rgb_fb0;
  3137. }
  3138. else
  3139. {
  3140. if (alpha == 255)
  3141. return paint_affine_near_da_sa_g2rgb;
  3142. else if (alpha > 0)
  3143. return paint_affine_near_da_sa_alpha_g2rgb;
  3144. }
  3145. }
  3146. else
  3147. {
  3148. if (fa == 0)
  3149. {
  3150. if (alpha == 255)
  3151. return paint_affine_near_da_g2rgb_fa0;
  3152. else if (alpha > 0)
  3153. return paint_affine_near_da_alpha_g2rgb_fa0;
  3154. }
  3155. else if (fb == 0)
  3156. {
  3157. if (alpha == 255)
  3158. return paint_affine_near_da_g2rgb_fb0;
  3159. else if (alpha > 0)
  3160. return paint_affine_near_da_alpha_g2rgb_fb0;
  3161. }
  3162. else
  3163. {
  3164. if (alpha == 255)
  3165. return paint_affine_near_da_g2rgb;
  3166. else if (alpha > 0)
  3167. return paint_affine_near_da_alpha_g2rgb;
  3168. }
  3169. }
  3170. }
  3171. else
  3172. {
  3173. if (sa)
  3174. {
  3175. if (fa == 0)
  3176. {
  3177. if (alpha == 255)
  3178. return paint_affine_near_sa_g2rgb_fa0;
  3179. else if (alpha > 0)
  3180. return paint_affine_near_sa_alpha_g2rgb_fa0;
  3181. }
  3182. else if (fb == 0)
  3183. {
  3184. if (alpha == 255)
  3185. return paint_affine_near_sa_g2rgb_fb0;
  3186. else if (alpha > 0)
  3187. return paint_affine_near_sa_alpha_g2rgb_fb0;
  3188. }
  3189. else
  3190. {
  3191. if (alpha == 255)
  3192. return paint_affine_near_sa_g2rgb;
  3193. else if (alpha > 0)
  3194. return paint_affine_near_sa_alpha_g2rgb;
  3195. }
  3196. }
  3197. else
  3198. {
  3199. if (fa == 0)
  3200. {
  3201. if (alpha == 255)
  3202. return paint_affine_near_g2rgb_fa0;
  3203. else if (alpha > 0)
  3204. return paint_affine_near_alpha_g2rgb_fa0;
  3205. }
  3206. else if (fb == 0)
  3207. {
  3208. if (alpha == 255)
  3209. return paint_affine_near_g2rgb_fb0;
  3210. else if (alpha > 0)
  3211. return paint_affine_near_alpha_g2rgb_fb0;
  3212. }
  3213. else
  3214. {
  3215. if (alpha == 255)
  3216. return paint_affine_near_g2rgb;
  3217. else if (alpha > 0)
  3218. return paint_affine_near_alpha_g2rgb;
  3219. }
  3220. }
  3221. }
  3222. return NULL;
  3223. }
  3224. #endif /* FZ_PLOTTERS_RGB */
  3225. static void
  3226. paint_affine_color_lerp_da_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3227. {
  3228. TRACK_FN();
  3229. template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 0, 0, color, hp, gp);
  3230. }
  3231. #if FZ_PLOTTERS_G
  3232. static void
  3233. paint_affine_color_lerp_da_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3234. {
  3235. TRACK_FN();
  3236. template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 1, 1, color, hp, gp);
  3237. }
  3238. static void
  3239. paint_affine_color_lerp_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3240. {
  3241. TRACK_FN();
  3242. template_affine_color_N_lerp(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 1, 1, color, hp, gp);
  3243. }
  3244. #endif /* FZ_PLOTTERS_G */
  3245. #if FZ_PLOTTERS_RGB
  3246. static void
  3247. paint_affine_color_lerp_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3248. {
  3249. TRACK_FN();
  3250. template_affine_color_N_lerp(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 3, 3, color, hp, gp);
  3251. }
  3252. static void
  3253. paint_affine_color_lerp_da_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3254. {
  3255. TRACK_FN();
  3256. template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 3, 3, color, hp, gp);
  3257. }
  3258. #endif /* FZ_PLOTTERS_RGB */
  3259. #if FZ_PLOTTERS_CMYK
  3260. static void
  3261. paint_affine_color_lerp_da_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3262. {
  3263. TRACK_FN();
  3264. template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 4, 4, color, hp, gp);
  3265. }
  3266. static void
  3267. paint_affine_color_lerp_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3268. {
  3269. TRACK_FN();
  3270. template_affine_color_N_lerp(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 4, 4, color, hp, gp);
  3271. }
  3272. #endif /* FZ_PLOTTERS_G */
  3273. #if FZ_PLOTTERS_N
  3274. static void
  3275. paint_affine_color_lerp_da_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3276. {
  3277. TRACK_FN();
  3278. template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp);
  3279. }
  3280. static void
  3281. paint_affine_color_lerp_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3282. {
  3283. TRACK_FN();
  3284. template_affine_color_N_lerp(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp);
  3285. }
  3286. #endif /* FZ_PLOTTERS_N */
  3287. #if FZ_ENABLE_SPOT_RENDERING
  3288. static void
  3289. paint_affine_color_lerp_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3290. {
  3291. TRACK_FN();
  3292. template_affine_color_N_lerp_op(dp, da, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp, eop);
  3293. }
  3294. #endif /* FZ_ENABLE_SPOT_RENDERING */
  3295. static paintfn_t *
  3296. fz_paint_affine_color_lerp(int da, int sa, affint fa, affint fb, int n, int alpha, const fz_overprint * FZ_RESTRICT eop)
  3297. {
  3298. #if FZ_ENABLE_SPOT_RENDERING
  3299. if (fz_overprint_required(eop))
  3300. return paint_affine_color_lerp_N_op;
  3301. #endif /* FZ_ENABLE_SPOT_RENDERING */
  3302. switch (n)
  3303. {
  3304. case 0: return da ? paint_affine_color_lerp_da_0 : NULL;
  3305. #if FZ_PLOTTERS_G
  3306. case 1: return da ? paint_affine_color_lerp_da_1 : paint_affine_color_lerp_1;
  3307. #endif /* FZ_PLOTTERS_G */
  3308. #if FZ_PLOTTERS_RGB
  3309. case 3: return da ? paint_affine_color_lerp_da_3 : paint_affine_color_lerp_3;
  3310. #endif /* FZ_PLOTTERS_RGB */
  3311. #if FZ_PLOTTERS_CMYK
  3312. case 4: return da ? paint_affine_color_lerp_da_4 : paint_affine_color_lerp_4;
  3313. #endif /* FZ_PLOTTERS_CMYK */
  3314. #if FZ_PLOTTERS_N
  3315. default: return da ? paint_affine_color_lerp_da_N : paint_affine_color_lerp_N;
  3316. #endif /* FZ_PLOTTERS_N */
  3317. }
  3318. }
  3319. #if FZ_ENABLE_SPOT_RENDERING
  3320. static paintfn_t *
  3321. fz_paint_affine_color_lerp_spots(int da, int sa, affint fa, affint fb, int dn, int sn, int alpha, const fz_overprint * FZ_RESTRICT eop)
  3322. {
  3323. if (fz_overprint_required(eop))
  3324. return paint_affine_color_lerp_N_op;
  3325. return da ? paint_affine_color_lerp_da_N : paint_affine_color_lerp_N;
  3326. }
  3327. #endif /* FZ_ENABLE_SPOT_RENDERING */
  3328. static void
  3329. paint_affine_color_near_da_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3330. {
  3331. TRACK_FN();
  3332. template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 0, 0, color, hp, gp);
  3333. }
  3334. #if FZ_PLOTTERS_G
  3335. static void
  3336. paint_affine_color_near_da_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3337. {
  3338. TRACK_FN();
  3339. template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 1, 1, color, hp, gp);
  3340. }
  3341. static void
  3342. paint_affine_color_near_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3343. {
  3344. TRACK_FN();
  3345. template_affine_color_N_near(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 1, 1, color, hp, gp);
  3346. }
  3347. #endif /* FZ_PLOTTERS_G */
  3348. #if FZ_PLOTTERS_RGB
  3349. static void
  3350. paint_affine_color_near_da_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3351. {
  3352. TRACK_FN();
  3353. template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 3, 3, color, hp, gp);
  3354. }
  3355. static void
  3356. paint_affine_color_near_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3357. {
  3358. TRACK_FN();
  3359. template_affine_color_N_near(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 3, 3, color, hp, gp);
  3360. }
  3361. #endif /* FZ_PLOTTERS_RGB */
  3362. #if FZ_PLOTTERS_CMYK
  3363. static void
  3364. paint_affine_color_near_da_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3365. {
  3366. TRACK_FN();
  3367. template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 4, 4, color, hp, gp);
  3368. }
  3369. static void
  3370. paint_affine_color_near_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3371. {
  3372. TRACK_FN();
  3373. template_affine_color_N_near(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 4, 4, color, hp, gp);
  3374. }
  3375. #endif /* FZ_PLOTTERS_CMYK */
  3376. #if FZ_PLOTTERS_N
  3377. static void
  3378. paint_affine_color_near_da_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3379. {
  3380. TRACK_FN();
  3381. template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp);
  3382. }
  3383. static void
  3384. paint_affine_color_near_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3385. {
  3386. TRACK_FN();
  3387. template_affine_color_N_near(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp);
  3388. }
  3389. #endif /* FZ_PLOTTERS_N */
  3390. #if FZ_ENABLE_SPOT_RENDERING
  3391. static void
  3392. paint_affine_color_near_da_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3393. {
  3394. TRACK_FN();
  3395. template_affine_color_N_near_op(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp, eop);
  3396. }
  3397. static void
  3398. paint_affine_color_near_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
  3399. {
  3400. TRACK_FN();
  3401. template_affine_color_N_near_op(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp, eop);
  3402. }
  3403. #endif /* FZ_ENABLE_SPOT_RENDERING */
  3404. static paintfn_t *
  3405. fz_paint_affine_color_near(int da, int sa, affint fa, affint fb, int n, int alpha, const fz_overprint * FZ_RESTRICT eop)
  3406. {
  3407. #if FZ_ENABLE_SPOT_RENDERING
  3408. if (fz_overprint_required(eop))
  3409. return da ? paint_affine_color_near_da_N_op : paint_affine_color_near_N_op;
  3410. #endif /* FZ_ENABLE_SPOT_RENDERING */
  3411. switch (n)
  3412. {
  3413. case 0: return da ? paint_affine_color_near_da_0 : NULL;
  3414. #if FZ_PLOTTERS_G
  3415. case 1: return da ? paint_affine_color_near_da_1 : paint_affine_color_near_1;
  3416. #endif /* FZ_PLOTTERS_G */
  3417. #if FZ_PLOTTERS_RGB
  3418. case 3: return da ? paint_affine_color_near_da_3 : paint_affine_color_near_3;
  3419. #endif /* FZ_PLOTTERS_RGB */
  3420. #if FZ_PLOTTERS_CMYK
  3421. case 4: return da ? paint_affine_color_near_da_4 : paint_affine_color_near_4;
  3422. #endif /* FZ_PLOTTERS_CMYK */
  3423. #if FZ_PLOTTERS_N
  3424. default: return da ? paint_affine_color_near_da_N : paint_affine_color_near_N;
  3425. #else
  3426. default: return NULL;
  3427. #endif /* FZ_PLOTTERS_N */
  3428. }
  3429. }
  3430. #if FZ_ENABLE_SPOT_RENDERING
  3431. static paintfn_t *
  3432. fz_paint_affine_color_near_spots(int da, int sa, affint fa, affint fb, int dn, int sn, int alpha, const fz_overprint * FZ_RESTRICT eop)
  3433. {
  3434. if (fz_overprint_required(eop))
  3435. return da ? paint_affine_color_near_da_N_op : paint_affine_color_near_N_op;
  3436. return da ? paint_affine_color_near_da_N : paint_affine_color_near_N;
  3437. }
  3438. #endif /* FZ_ENABLE_SPOT_RENDERING */
  3439. /* RJW: The following code was originally written to be sensitive to
  3440. * FLT_EPSILON. Given the way the 'minimum representable difference'
  3441. * between 2 floats changes size as we scale, we now pick a larger
  3442. * value to ensure idempotency even with rounding problems. The
  3443. * value we pick is still far smaller than would ever show up with
  3444. * antialiasing.
  3445. */
  3446. #define MY_EPSILON 0.001f
  3447. /* We have 2 possible ways of gridfitting images. The first way, considered
  3448. * 'safe' in all cases, is to expand an image out to fill a box that entirely
  3449. * covers all the pixels touched by the current image. This is our 'standard'
  3450. * mechanism.
  3451. *
  3452. * The alternative, used when we know images are tiled across a page, is to
  3453. * round the edge of each image to the closest integer pixel boundary. This
  3454. * would not be safe in the general case, but gives less distortion across
  3455. * neighbouring images when tiling is used.
  3456. */
  3457. fz_matrix
  3458. fz_gridfit_matrix(int as_tiled, fz_matrix m)
  3459. {
  3460. if (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON)
  3461. {
  3462. if (as_tiled)
  3463. {
  3464. float f;
  3465. /* Nearest boundary for left */
  3466. f = (float)(int)(m.e + 0.5f);
  3467. m.a += m.e - f; /* Adjust width for change */
  3468. m.e = f;
  3469. /* Nearest boundary for right (width really) */
  3470. m.a = (float)(int)(m.a + 0.5f);
  3471. }
  3472. else if (m.a > 0)
  3473. {
  3474. float f;
  3475. /* Adjust left hand side onto pixel boundary */
  3476. f = (float)(int)(m.e);
  3477. if (f - m.e > MY_EPSILON)
  3478. f -= 1.0f; /* Ensure it moves left */
  3479. m.a += m.e - f; /* width gets wider as f <= m.e */
  3480. m.e = f;
  3481. /* Adjust right hand side onto pixel boundary */
  3482. f = (float)(int)(m.a);
  3483. if (m.a - f > MY_EPSILON)
  3484. f += 1.0f; /* Ensure it moves right */
  3485. m.a = f;
  3486. }
  3487. else if (m.a < 0)
  3488. {
  3489. float f;
  3490. /* Adjust right hand side onto pixel boundary */
  3491. f = (float)(int)(m.e);
  3492. if (m.e - f > MY_EPSILON)
  3493. f += 1.0f; /* Ensure it moves right */
  3494. m.a += m.e - f; /* width gets wider (more -ve) */
  3495. m.e = f;
  3496. /* Adjust left hand side onto pixel boundary */
  3497. f = (float)(int)(m.a);
  3498. if (f - m.a > MY_EPSILON)
  3499. f -= 1.0f; /* Ensure it moves left */
  3500. m.a = f;
  3501. }
  3502. if (as_tiled)
  3503. {
  3504. float f;
  3505. /* Nearest boundary for top */
  3506. f = (float)(int)(m.f + 0.5f);
  3507. m.d += m.f - f; /* Adjust width for change */
  3508. m.f = f;
  3509. /* Nearest boundary for bottom (height really) */
  3510. m.d = (float)(int)(m.d + 0.5f);
  3511. }
  3512. else if (m.d > 0)
  3513. {
  3514. float f;
  3515. /* Adjust top onto pixel boundary */
  3516. f = (float)(int)(m.f);
  3517. if (f - m.f > MY_EPSILON)
  3518. f -= 1.0f; /* Ensure it moves upwards */
  3519. m.d += m.f - f; /* width gets wider as f <= m.f */
  3520. m.f = f;
  3521. /* Adjust bottom onto pixel boundary */
  3522. f = (float)(int)(m.d);
  3523. if (m.d - f > MY_EPSILON)
  3524. f += 1.0f; /* Ensure it moves down */
  3525. m.d = f;
  3526. }
  3527. else if (m.d < 0)
  3528. {
  3529. float f;
  3530. /* Adjust bottom onto pixel boundary */
  3531. f = (float)(int)(m.f);
  3532. if (m.f - f > MY_EPSILON)
  3533. f += 1.0f; /* Ensure it moves down */
  3534. m.d += m.f - f; /* width gets wider (more -ve) */
  3535. m.f = f;
  3536. /* Adjust top onto pixel boundary */
  3537. f = (float)(int)(m.d);
  3538. if (f - m.d > MY_EPSILON)
  3539. f -= 1.0f; /* Ensure it moves up */
  3540. m.d = f;
  3541. }
  3542. }
  3543. else if (fabsf(m.a) < FLT_EPSILON && fabsf(m.d) < FLT_EPSILON)
  3544. {
  3545. if (as_tiled)
  3546. {
  3547. float f;
  3548. /* Nearest boundary for left */
  3549. f = (float)(int)(m.e + 0.5f);
  3550. m.b += m.e - f; /* Adjust width for change */
  3551. m.e = f;
  3552. /* Nearest boundary for right (width really) */
  3553. m.b = (float)(int)(m.b + 0.5f);
  3554. }
  3555. else if (m.b > 0)
  3556. {
  3557. float f;
  3558. /* Adjust left hand side onto pixel boundary */
  3559. f = (float)(int)(m.f);
  3560. if (f - m.f > MY_EPSILON)
  3561. f -= 1.0f; /* Ensure it moves left */
  3562. m.b += m.f - f; /* width gets wider as f <= m.f */
  3563. m.f = f;
  3564. /* Adjust right hand side onto pixel boundary */
  3565. f = (float)(int)(m.b);
  3566. if (m.b - f > MY_EPSILON)
  3567. f += 1.0f; /* Ensure it moves right */
  3568. m.b = f;
  3569. }
  3570. else if (m.b < 0)
  3571. {
  3572. float f;
  3573. /* Adjust right hand side onto pixel boundary */
  3574. f = (float)(int)(m.f);
  3575. if (m.f - f > MY_EPSILON)
  3576. f += 1.0f; /* Ensure it moves right */
  3577. m.b += m.f - f; /* width gets wider (more -ve) */
  3578. m.f = f;
  3579. /* Adjust left hand side onto pixel boundary */
  3580. f = (float)(int)(m.b);
  3581. if (f - m.b > MY_EPSILON)
  3582. f -= 1.0f; /* Ensure it moves left */
  3583. m.b = f;
  3584. }
  3585. if (as_tiled)
  3586. {
  3587. float f;
  3588. /* Nearest boundary for left */
  3589. f = (float)(int)(m.f + 0.5f);
  3590. m.c += m.f - f; /* Adjust width for change */
  3591. m.f = f;
  3592. /* Nearest boundary for right (width really) */
  3593. m.c = (float)(int)(m.c + 0.5f);
  3594. }
  3595. else if (m.c > 0)
  3596. {
  3597. float f;
  3598. /* Adjust top onto pixel boundary */
  3599. f = (float)(int)(m.e);
  3600. if (f - m.e > MY_EPSILON)
  3601. f -= 1.0f; /* Ensure it moves upwards */
  3602. m.c += m.e - f; /* width gets wider as f <= m.e */
  3603. m.e = f;
  3604. /* Adjust bottom onto pixel boundary */
  3605. f = (float)(int)(m.c);
  3606. if (m.c - f > MY_EPSILON)
  3607. f += 1.0f; /* Ensure it moves down */
  3608. m.c = f;
  3609. }
  3610. else if (m.c < 0)
  3611. {
  3612. float f;
  3613. /* Adjust bottom onto pixel boundary */
  3614. f = (float)(int)(m.e);
  3615. if (m.e - f > MY_EPSILON)
  3616. f += 1.0f; /* Ensure it moves down */
  3617. m.c += m.e - f; /* width gets wider (more -ve) */
  3618. m.e = f;
  3619. /* Adjust top onto pixel boundary */
  3620. f = (float)(int)(m.c);
  3621. if (f - m.c > MY_EPSILON)
  3622. f -= 1.0f; /* Ensure it moves up */
  3623. m.c = f;
  3624. }
  3625. }
  3626. return m;
  3627. }
  3628. /* Draw an image with an affine transform on destination */
  3629. static void
  3630. fz_paint_image_imp(fz_context *ctx,
  3631. fz_pixmap *dst,
  3632. const fz_irect *scissor,
  3633. fz_pixmap *shape,
  3634. fz_pixmap *group_alpha,
  3635. fz_pixmap *img,
  3636. fz_matrix ctm,
  3637. const byte *color,
  3638. int alpha,
  3639. int lerp_allowed,
  3640. const fz_overprint *eop)
  3641. {
  3642. byte *dp, *sp, *hp, *gp;
  3643. affint u, v, fa, fb, fc, fd;
  3644. int x, y, w, h;
  3645. affint sw, sh, sa, sn, hs, da, dn, gs;
  3646. ptrdiff_t ss;
  3647. fz_irect bbox;
  3648. int dolerp;
  3649. paintfn_t *paintfn;
  3650. int is_rectilinear;
  3651. if (alpha == 0)
  3652. return;
  3653. /* turn on interpolation for upscaled and non-rectilinear transforms */
  3654. dolerp = 0;
  3655. is_rectilinear = fz_is_rectilinear(ctm);
  3656. if (!is_rectilinear)
  3657. dolerp = lerp_allowed;
  3658. if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w)
  3659. dolerp = lerp_allowed;
  3660. if (sqrtf(ctm.c * ctm.c + ctm.d * ctm.d) > img->h)
  3661. dolerp = lerp_allowed;
  3662. /* except when we shouldn't, at large magnifications */
  3663. if (!(img->flags & FZ_PIXMAP_FLAG_INTERPOLATE))
  3664. {
  3665. if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w * 2)
  3666. dolerp = 0;
  3667. if (sqrtf(ctm.c * ctm.c + ctm.d * ctm.d) > img->h * 2)
  3668. dolerp = 0;
  3669. }
  3670. bbox = fz_irect_from_rect(fz_transform_rect(fz_unit_rect, ctm));
  3671. bbox = fz_intersect_irect(bbox, *scissor);
  3672. x = bbox.x0;
  3673. if (shape && shape->x > x)
  3674. x = shape->x;
  3675. if (group_alpha && group_alpha->x > x)
  3676. x = group_alpha->x;
  3677. y = bbox.y0;
  3678. if (shape && shape->y > y)
  3679. y = shape->y;
  3680. if (group_alpha && group_alpha->y > y)
  3681. y = group_alpha->y;
  3682. w = bbox.x1;
  3683. if (shape && shape->x + shape->w < w)
  3684. w = shape->x + shape->w;
  3685. if (group_alpha && group_alpha->x + group_alpha->w < w)
  3686. w = group_alpha->x + group_alpha->w;
  3687. if (w <= x)
  3688. return;
  3689. w -= x;
  3690. h = bbox.y1;
  3691. if (shape && shape->y + shape->h < h)
  3692. h = shape->y + shape->h;
  3693. if (group_alpha && group_alpha->y + group_alpha->h < h)
  3694. h = group_alpha->y + group_alpha->h;
  3695. if (h <= y)
  3696. return;
  3697. h -= y;
  3698. /* map from screen space (x,y) to image space (u,v) */
  3699. ctm = fz_pre_scale(ctm, 1.0f / img->w, 1.0f / img->h);
  3700. ctm = fz_invert_matrix(ctm);
  3701. fa = (affint)(ctm.a *= ONE);
  3702. fb = (affint)(ctm.b *= ONE);
  3703. fc = (affint)(ctm.c *= ONE);
  3704. fd = (affint)(ctm.d *= ONE);
  3705. ctm.e *= ONE;
  3706. ctm.f *= ONE;
  3707. /* Calculate initial texture positions. Do a half step to start. */
  3708. /* Bug 693021: Keep calculation in float for as long as possible to
  3709. * avoid overflow. */
  3710. u = (int)((ctm.a * x) + (ctm.c * y) + ctm.e + ((ctm.a + ctm.c) * .5f));
  3711. v = (int)((ctm.b * x) + (ctm.d * y) + ctm.f + ((ctm.b + ctm.d) * .5f));
  3712. dp = dst->samples + (y - dst->y) * (size_t)dst->stride + (x - dst->x) * (size_t)dst->n;
  3713. da = dst->alpha;
  3714. dn = dst->n - da;
  3715. sp = img->samples;
  3716. sw = img->w;
  3717. sh = img->h;
  3718. ss = img->stride;
  3719. sa = img->alpha;
  3720. sn = img->n - sa;
  3721. if (shape)
  3722. {
  3723. hs = shape->stride;
  3724. hp = shape->samples + (y - shape->y) * (size_t)shape->stride + x - shape->x;
  3725. }
  3726. else
  3727. {
  3728. hs = 0;
  3729. hp = NULL;
  3730. }
  3731. if (group_alpha)
  3732. {
  3733. gs = group_alpha->stride;
  3734. gp = group_alpha->samples + (y - group_alpha->y) * (size_t)group_alpha->stride + x - group_alpha->x;
  3735. }
  3736. else
  3737. {
  3738. gs = 0;
  3739. gp = NULL;
  3740. }
  3741. /* image size overflows fixed point math */
  3742. if (sw >= LIMIT || sh >= LIMIT)
  3743. {
  3744. /* Note this may cause compile warning because fz_warn() is marked as
  3745. being like printf(), but actually it treats %ld as matching int64_t. */
  3746. fz_warn(ctx, "image too large for fixed point math: %ld x %ld", (int64_t)sw, (int64_t)sh);
  3747. return;
  3748. }
  3749. /* TODO: if (fb == 0 && fa == 1) call fz_paint_span */
  3750. /* Sometimes we can get an alpha only input to be
  3751. * plotted. In this case treat it as a greyscale
  3752. * input. */
  3753. if (img->n == sa && color)
  3754. {
  3755. sa = 0;
  3756. sn = 1;
  3757. }
  3758. #if FZ_PLOTTERS_RGB
  3759. if (dn == 3 && dst->s == 0 && img->n == 1 + sa && !color && !fz_overprint_required(eop))
  3760. {
  3761. if (dolerp)
  3762. paintfn = fz_paint_affine_g2rgb_lerp(da, sa, fa, fb, dn, alpha);
  3763. else
  3764. paintfn = fz_paint_affine_g2rgb_near(da, sa, fa, fb, dn, alpha);
  3765. }
  3766. else
  3767. #endif /* FZ_PLOTTERS_RGB */
  3768. #if FZ_ENABLE_SPOT_RENDERING
  3769. if (sn != dn)
  3770. {
  3771. if (dolerp)
  3772. {
  3773. if (color)
  3774. paintfn = fz_paint_affine_color_lerp_spots(da, sa, fa, fb, dn, sn, alpha, eop);
  3775. else
  3776. paintfn = fz_paint_affine_lerp_spots(da, sa, fa, fb, dn, sn, alpha, eop);
  3777. }
  3778. else
  3779. {
  3780. if (color)
  3781. paintfn = fz_paint_affine_color_near_spots(da, sa, fa, fb, dn, sn, alpha, eop);
  3782. else
  3783. paintfn = fz_paint_affine_near_spots(da, sa, fa, fb, dn, sn, alpha, eop);
  3784. }
  3785. }
  3786. else
  3787. #endif /* FZ_ENABLE_SPOT_RENDERING */
  3788. {
  3789. assert((!color && sn == dn) || (color && sn + sa == 1));
  3790. if (dolerp)
  3791. {
  3792. if (color)
  3793. paintfn = fz_paint_affine_color_lerp(da, sa, fa, fb, dn, alpha, eop);
  3794. else
  3795. paintfn = fz_paint_affine_lerp(da, sa, fa, fb, dn, alpha, eop);
  3796. }
  3797. else
  3798. {
  3799. if (color)
  3800. paintfn = fz_paint_affine_color_near(da, sa, fa, fb, dn, alpha, eop);
  3801. else
  3802. paintfn = fz_paint_affine_near(da, sa, fa, fb, dn, alpha, eop);
  3803. }
  3804. }
  3805. assert(paintfn);
  3806. if (paintfn == NULL)
  3807. return;
  3808. if (dolerp)
  3809. {
  3810. u -= HALF;
  3811. v -= HALF;
  3812. sw = (sw<<PREC) + HALF;
  3813. sh = (sh<<PREC) + HALF;
  3814. }
  3815. while (h--)
  3816. {
  3817. paintfn(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, alpha, color, hp, gp, eop);
  3818. dp += dst->stride;
  3819. hp += hs;
  3820. gp += gs;
  3821. u += fc;
  3822. v += fd;
  3823. }
  3824. }
  3825. void
  3826. fz_paint_image_with_color(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, const fz_irect * FZ_RESTRICT scissor, fz_pixmap * FZ_RESTRICT shape, fz_pixmap * FZ_RESTRICT group_alpha, fz_pixmap * FZ_RESTRICT img, fz_matrix ctm, const byte * FZ_RESTRICT color, int lerp_allowed, const fz_overprint * FZ_RESTRICT eop)
  3827. {
  3828. assert(img->n == 1);
  3829. fz_paint_image_imp(ctx, dst, scissor, shape, group_alpha, img, ctm, color, 255, lerp_allowed, eop);
  3830. }
  3831. void
  3832. fz_paint_image(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, const fz_irect * FZ_RESTRICT scissor, fz_pixmap * FZ_RESTRICT shape, fz_pixmap * FZ_RESTRICT group_alpha, fz_pixmap * FZ_RESTRICT img, fz_matrix ctm, int alpha, int lerp_allowed, const fz_overprint * FZ_RESTRICT eop)
  3833. {
  3834. fz_paint_image_imp(ctx, dst, scissor, shape, group_alpha, img, ctm, NULL, alpha, lerp_allowed, eop);
  3835. }