GR32_Polygons.pas 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973
  1. unit GR32_Polygons;
  2. (* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1 or LGPL 2.1 with linking exception
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * Alternatively, the contents of this file may be used under the terms of the
  16. * Free Pascal modified version of the GNU Lesser General Public License
  17. * Version 2.1 (the "FPC modified LGPL License"), in which case the provisions
  18. * of this license are applicable instead of those above.
  19. * Please see the file LICENSE.txt for additional information concerning this
  20. * license.
  21. *
  22. * The Original Code is Vectorial Polygon Rasterizer for Graphics32
  23. *
  24. * The Initial Developer of the Original Code is
  25. * Mattias Andersson <[email protected]>
  26. *
  27. * Portions created by the Initial Developer are Copyright (C) 2008-2012
  28. * the Initial Developer. All Rights Reserved.
  29. *
  30. * Contributor(s):
  31. *
  32. * ***** END LICENSE BLOCK ***** *)
  33. interface
  34. {$I GR32.inc}
  35. uses
  36. Types, GR32, GR32_Containers, GR32_VPR, GR32_Transforms, GR32_Resamplers;
  37. type
  38. { Polygon join style - used by GR32_VectorUtils.Grow(). }
  39. { nb: jsRoundEx rounds both convex and concave joins unlike jsRound which
  40. only rounds convex joins. The depth of convex join rounding is controlled
  41. by Grow's MiterLimit parameter }
  42. TJoinStyle = (jsMiter, jsBevel, jsRound, jsRoundEx);
  43. { Polygon end style }
  44. TEndStyle = (esButt, esSquare, esRound);
  45. { Polygon fill mode }
  46. TPolyFillMode = (pfAlternate, pfWinding, pfEvenOdd = 0, pfNonZero);
  47. { TCustomPolygonRenderer }
  48. TCustomPolygonRenderer = class(TThreadPersistent)
  49. public
  50. procedure PolyPolygonFS(const Points: TArrayOfArrayOfFloatPoint;
  51. const ClipRect: TFloatRect; Transformation: TTransformation); overload; virtual;
  52. procedure PolyPolygonFS(const Points: TArrayOfArrayOfFloatPoint;
  53. const ClipRect: TFloatRect); overload; virtual;
  54. procedure PolygonFS(const Points: TArrayOfFloatPoint;
  55. const ClipRect: TFloatRect; Transformation: TTransformation); overload; virtual;
  56. procedure PolygonFS(const Points: TArrayOfFloatPoint;
  57. const ClipRect: TFloatRect); overload; virtual;
  58. // procedure PolyPolygonXS(const Points: TArrayOfArrayOfFixedPoint; const ClipRect: TFixedRect; Transformation: TTransformation); virtual; overload;
  59. // procedure PolyPolygonXS(const Points: TArrayOfArrayOfFixedPoint; const ClipRect: TFixedRect); virtual; overload;
  60. end;
  61. TCustomPolygonRendererClass = class of TCustomPolygonRenderer;
  62. TCustomPolygonFiller = class;
  63. { TPolygonRenderer32 }
  64. TPolygonRenderer32 = class(TCustomPolygonRenderer)
  65. private
  66. FBitmap: TCustomBitmap32;
  67. FFillMode: TPolyFillMode;
  68. FColor: TColor32;
  69. FFiller: TCustomPolygonFiller;
  70. procedure SetColor(const Value: TColor32);
  71. procedure SetFillMode(const Value: TPolyFillMode);
  72. procedure SetFiller(const Value: TCustomPolygonFiller);
  73. protected
  74. procedure SetBitmap(const Value: TCustomBitmap32); virtual;
  75. public
  76. constructor Create(Bitmap: TCustomBitmap32; Fillmode: TPolyFillMode = pfWinding); reintroduce; overload;
  77. procedure PolygonFS(const Points: TArrayOfFloatPoint); overload; virtual;
  78. procedure PolyPolygonFS(const Points: TArrayOfArrayOfFloatPoint); overload; virtual;
  79. property Bitmap: TCustomBitmap32 read FBitmap write SetBitmap;
  80. property FillMode: TPolyFillMode read FFillMode write SetFillMode;
  81. property Color: TColor32 read FColor write SetColor;
  82. property Filler: TCustomPolygonFiller read FFiller write SetFiller;
  83. end;
  84. TPolygonRenderer32Class = class of TPolygonRenderer32;
  85. { TPolygonRenderer32VPR }
  86. { Polygon renderer based on VPR. Computes exact coverages for optimal anti-aliasing. }
  87. TFillProc = procedure(Coverage: PSingleArray; AlphaValues: PColor32Array; Count: Integer; Color: TColor32);
  88. TPolygonRenderer32VPR = class(TPolygonRenderer32)
  89. private
  90. FFillProc: TFillProc;
  91. procedure UpdateFillProcs;
  92. protected
  93. procedure RenderSpan(const Span: TValueSpan; DstY: Integer); virtual;
  94. procedure FillSpan(const Span: TValueSpan; DstY: Integer); virtual;
  95. function GetRenderSpan: TRenderSpanEvent; virtual;
  96. public
  97. procedure PolyPolygonFS(const Points: TArrayOfArrayOfFloatPoint;
  98. const ClipRect: TFloatRect); override;
  99. end;
  100. { TPolygonRenderer32LCD }
  101. TPolygonRenderer32LCD = class(TPolygonRenderer32VPR)
  102. protected
  103. procedure RenderSpan(const Span: TValueSpan; DstY: Integer); override;
  104. public
  105. procedure PolyPolygonFS(const Points: TArrayOfArrayOfFloatPoint;
  106. const ClipRect: TFloatRect); override;
  107. end;
  108. { TPolygonRenderer32LCD2 }
  109. TPolygonRenderer32LCD2 = class(TPolygonRenderer32LCD)
  110. public
  111. procedure RenderSpan(const Span: TValueSpan; DstY: Integer); override;
  112. end;
  113. { TCustomPolygonFiller }
  114. TFillLineEvent = procedure(Dst: PColor32; DstX, DstY, Length: Integer;
  115. AlphaValues: PColor32; CombineMode: TCombineMode) of object;
  116. TCustomPolygonFiller = class
  117. protected
  118. function GetFillLine: TFillLineEvent; virtual; abstract;
  119. public
  120. procedure BeginRendering; virtual;
  121. procedure EndRendering; virtual;
  122. property FillLine: TFillLineEvent read GetFillLine;
  123. end;
  124. { TCallbackPolygonFiller }
  125. TCallbackPolygonFiller = class(TCustomPolygonFiller)
  126. private
  127. FFillLineEvent: TFillLineEvent;
  128. protected
  129. function GetFillLine: TFillLineEvent; override;
  130. public
  131. property FillLineEvent: TFillLineEvent read FFillLineEvent write FFillLineEvent;
  132. end;
  133. { TInvertPolygonFiller }
  134. TInvertPolygonFiller = class(TCustomPolygonFiller)
  135. protected
  136. function GetFillLine: TFillLineEvent; override;
  137. procedure FillLineBlend(Dst: PColor32; DstX, DstY, Length: Integer;
  138. AlphaValues: PColor32; CombineMode: TCombineMode);
  139. end;
  140. { TClearPolygonFiller }
  141. TClearPolygonFiller = class(TCustomPolygonFiller)
  142. private
  143. FColor: TColor32;
  144. protected
  145. function GetFillLine: TFillLineEvent; override;
  146. procedure FillLineClear(Dst: PColor32; DstX, DstY,
  147. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  148. public
  149. constructor Create(Color: TColor32 = $00808080); reintroduce; virtual;
  150. property Color: TColor32 read FColor write FColor;
  151. end;
  152. { TBitmapPolygonFiller }
  153. TBitmapPolygonFiller = class(TCustomPolygonFiller)
  154. private
  155. FPattern: TCustomBitmap32;
  156. FOffsetY: Integer;
  157. FOffsetX: Integer;
  158. protected
  159. function GetFillLine: TFillLineEvent; override;
  160. procedure FillLineOpaque(Dst: PColor32; DstX, DstY,
  161. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  162. procedure FillLineBlend(Dst: PColor32; DstX, DstY,
  163. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  164. procedure FillLineBlendMasterAlpha(Dst: PColor32; DstX, DstY,
  165. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  166. procedure FillLineCustomCombine(Dst: PColor32; DstX, DstY,
  167. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  168. public
  169. property Pattern: TCustomBitmap32 read FPattern write FPattern;
  170. property OffsetX: Integer read FOffsetX write FOffsetX;
  171. property OffsetY: Integer read FOffsetY write FOffsetY;
  172. end;
  173. { TSamplerFiller }
  174. TSamplerFiller = class(TCustomPolygonFiller)
  175. private
  176. FSampler: TCustomSampler;
  177. FGetSample: TGetSampleInt;
  178. procedure SetSampler(const Value: TCustomSampler);
  179. protected
  180. procedure SamplerChanged; virtual;
  181. function GetFillLine: TFillLineEvent; override;
  182. procedure SampleLineOpaque(Dst: PColor32; DstX, DstY, Length: Integer;
  183. AlphaValues: PColor32; CombineMode: TCombineMode);
  184. public
  185. constructor Create(Sampler: TCustomSampler = nil); reintroduce; virtual;
  186. procedure BeginRendering; override;
  187. procedure EndRendering; override;
  188. property Sampler: TCustomSampler read FSampler write SetSampler;
  189. end;
  190. procedure PolyPolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  191. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  192. Transformation: TTransformation = nil); overload;
  193. procedure PolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  194. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  195. Transformation: TTransformation = nil); overload;
  196. procedure PolyPolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  197. Filler: TCustomPolygonFiller; FillMode: TPolyFillMode = pfAlternate;
  198. Transformation: TTransformation = nil); overload;
  199. procedure PolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  200. Filler: TCustomPolygonFiller; FillMode: TPolyFillMode = pfAlternate;
  201. Transformation: TTransformation = nil); overload;
  202. procedure PolyPolygonFS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  203. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  204. Transformation: TTransformation = nil); overload;
  205. procedure PolygonFS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  206. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  207. Transformation: TTransformation = nil); overload;
  208. procedure PolyPolygonFS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  209. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  210. Transformation: TTransformation = nil); overload;
  211. procedure PolygonFS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  212. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  213. Transformation: TTransformation = nil); overload;
  214. procedure PolyPolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  215. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  216. Transformation: TTransformation = nil); overload;
  217. procedure PolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  218. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  219. Transformation: TTransformation = nil); overload;
  220. procedure PolyPolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  221. ClipRect: TRect; Filler: TCustomPolygonFiller; FillMode: TPolyFillMode = pfAlternate;
  222. Transformation: TTransformation = nil); overload;
  223. procedure PolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  224. ClipRect: TRect; Filler: TCustomPolygonFiller; FillMode: TPolyFillMode = pfAlternate;
  225. Transformation: TTransformation = nil); overload;
  226. procedure PolyPolygonFS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  227. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  228. Transformation: TTransformation = nil); overload;
  229. procedure PolygonFS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  230. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  231. Transformation: TTransformation = nil); overload;
  232. procedure PolyPolygonFS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  233. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  234. Transformation: TTransformation = nil); overload;
  235. procedure PolygonFS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  236. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  237. Transformation: TTransformation = nil); overload;
  238. procedure PolyPolylineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  239. Color: TColor32; Closed: Boolean = False; StrokeWidth: TFloat = 1.0;
  240. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  241. MiterLimit: TFloat = 4.0; Transformation: TTransformation = nil); overload;
  242. procedure PolyPolylineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  243. Filler: TCustomPolygonFiller; Closed: Boolean = False; StrokeWidth: TFloat = 1.0;
  244. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  245. MiterLimit: TFloat = 4.0; Transformation: TTransformation = nil); overload;
  246. procedure PolylineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  247. Color: TColor32; Closed: Boolean = False; StrokeWidth: TFloat = 1.0;
  248. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  249. MiterLimit: TFloat = 4.0; Transformation: TTransformation = nil); overload;
  250. procedure PolylineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  251. Filler: TCustomPolygonFiller; Closed: Boolean = False; StrokeWidth: TFloat = 1.0;
  252. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  253. MiterLimit: TFloat = 4.0; Transformation: TTransformation = nil); overload;
  254. //Filled only Dashes ...
  255. procedure DashLineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  256. const Dashes: TArrayOfFloat; Color: TColor32;
  257. Closed: Boolean = False; Width: TFloat = 1.0); overload;
  258. procedure DashLineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  259. const Dashes: TArrayOfFloat; FillColor, StrokeColor: TColor32;
  260. Closed: Boolean; Width: TFloat; StrokeWidth: TFloat = 2.0); overload;
  261. //Filled and stroked Dashes ...
  262. procedure DashLineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  263. const Dashes: TArrayOfFloat; Filler: TCustomPolygonFiller;
  264. Closed: Boolean = False; Width: TFloat = 1.0); overload;
  265. procedure DashLineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  266. const Dashes: TArrayOfFloat; Filler: TCustomPolygonFiller; StrokeColor: TColor32;
  267. Closed: Boolean; Width: TFloat; StrokeWidth: TFloat = 2.0); overload;
  268. procedure PolyPolygonXS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  269. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  270. Transformation: TTransformation = nil); overload;
  271. procedure PolygonXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  272. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  273. Transformation: TTransformation = nil); overload;
  274. procedure PolyPolygonXS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  275. Filler: TCustomPolygonFiller; FillMode: TPolyFillMode = pfAlternate;
  276. Transformation: TTransformation = nil); overload;
  277. procedure PolygonXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  278. Filler: TCustomPolygonFiller; FillMode: TPolyFillMode = pfAlternate;
  279. Transformation: TTransformation = nil); overload;
  280. procedure PolyPolygonXS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  281. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  282. Transformation: TTransformation = nil); overload;
  283. procedure PolygonXS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  284. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  285. Transformation: TTransformation = nil);
  286. procedure PolyPolygonXS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  287. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  288. Transformation: TTransformation = nil); overload;
  289. procedure PolygonXS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  290. Color: TColor32; FillMode: TPolyFillMode = pfAlternate;
  291. Transformation: TTransformation = nil);
  292. procedure PolyPolylineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  293. Color: TColor32; Closed: Boolean = False; StrokeWidth: TFixed = $10000;
  294. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  295. MiterLimit: TFixed = $40000; Transformation: TTransformation = nil); overload;
  296. procedure PolyPolylineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  297. Filler: TCustomPolygonFiller; Closed: Boolean = False; StrokeWidth: TFixed = $10000;
  298. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  299. MiterLimit: TFixed = $40000; Transformation: TTransformation = nil); overload;
  300. procedure PolylineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  301. Color: TColor32; Closed: Boolean = False; StrokeWidth: TFixed = $10000;
  302. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  303. MiterLimit: TFixed = $40000; Transformation: TTransformation = nil); overload;
  304. procedure PolylineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  305. Filler: TCustomPolygonFiller; Closed: Boolean = False; StrokeWidth: TFixed = $10000;
  306. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  307. MiterLimit: TFixed = $40000; Transformation: TTransformation = nil); overload;
  308. //Filled only Dashes ...
  309. procedure DashLineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  310. const Dashes: TArrayOfFixed; Color: TColor32;
  311. Closed: Boolean = False; Width: TFixed = $10000); overload;
  312. procedure DashLineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  313. const Dashes: TArrayOfFixed; FillColor, StrokeColor: TColor32;
  314. Closed: Boolean; Width: TFixed; StrokeWidth: TFixed = $20000); overload;
  315. //Filled and stroked Dashes ...
  316. procedure DashLineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  317. const Dashes: TArrayOfFixed; Filler: TCustomPolygonFiller;
  318. Closed: Boolean = False; Width: TFixed = $10000); overload;
  319. procedure DashLineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  320. const Dashes: TArrayOfFixed; Filler: TCustomPolygonFiller; StrokeColor: TColor32;
  321. Closed: Boolean; Width: TFixed; StrokeWidth: TFixed = $20000); overload;
  322. // fill entire bitmap with a given polygon filler
  323. procedure FillBitmap(Bitmap: TCustomBitmap32; Filler: TCustomPolygonFiller);
  324. { Registration routines }
  325. procedure RegisterPolygonRenderer(PolygonRendererClass: TCustomPolygonRendererClass);
  326. var
  327. PolygonRendererList: TClassList;
  328. DefaultPolygonRendererClass: TPolygonRenderer32Class = TPolygonRenderer32VPR;
  329. implementation
  330. uses
  331. Math, SysUtils, GR32_Math, GR32_LowLevel, GR32_Blend, GR32_Gamma,
  332. GR32_VectorUtils;
  333. resourcestring
  334. RCStrNoSamplerSpecified = 'No sampler specified!';
  335. type
  336. TBitmap32Access = class(TCustomBitmap32);
  337. procedure RegisterPolygonRenderer(PolygonRendererClass: TCustomPolygonRendererClass);
  338. begin
  339. if not Assigned(PolygonRendererList) then PolygonRendererList := TClassList.Create;
  340. PolygonRendererList.Add(PolygonRendererClass);
  341. end;
  342. // routines for color filling:
  343. procedure MakeAlphaNonZeroUP(Coverage: PSingleArray; AlphaValues: PColor32Array;
  344. Count: Integer; Color: TColor32);
  345. var
  346. I: Integer;
  347. M, V: Cardinal;
  348. Last: TFloat;
  349. C: TColor32Entry absolute Color;
  350. begin
  351. M := C.A * $101;
  352. Last := Infinity;
  353. for I := 0 to Count - 1 do
  354. begin
  355. if PInteger(@Last)^ <> PInteger(@Coverage[I])^ then
  356. begin
  357. Last := Coverage[I];
  358. V := Abs(Round(Last * $10000));
  359. if V > $10000 then V := $10000;
  360. V := V * M shr 24;
  361. {$IFDEF USEGR32GAMMA}
  362. V := GAMMA_ENCODING_TABLE[V];
  363. {$ENDIF}
  364. C.A := V;
  365. end;
  366. AlphaValues[I] := Color;
  367. end;
  368. end;
  369. (*
  370. procedure MakeAlphaNonZeroUP(Coverage: PSingleArray; AlphaValues: PColor32Array;
  371. Count: Integer; Color: TColor32);
  372. var
  373. I: Integer;
  374. M, V, C: Cardinal;
  375. begin
  376. M := Color shr 24 * $101;
  377. C := Color and $00ffffff;
  378. for I := 0 to Count - 1 do
  379. begin
  380. V := Abs(Round(Coverage[I] * $10000));
  381. if V > $10000 then V := $10000;
  382. {$IFDEF USEGR32GAMMA}
  383. V := GAMMA_ENCODING_TABLE[V * M shr 24];
  384. AlphaValues[I] := (V shl 24) or C;
  385. {$ELSE}
  386. AlphaValues[I] := (V * M and $ff000000) or C;
  387. {$ENDIF}
  388. end;
  389. end;
  390. *)
  391. procedure MakeAlphaEvenOddUP(Coverage: PSingleArray; AlphaValues: PColor32Array;
  392. Count: Integer; Color: TColor32);
  393. var
  394. I: Integer;
  395. M, V: Cardinal;
  396. Last: TFloat;
  397. C: TColor32Entry absolute Color;
  398. begin
  399. M := C.A * $101;
  400. Last := Infinity;
  401. for I := 0 to Count - 1 do
  402. begin
  403. if PInteger(@Last)^ <> PInteger(@Coverage[I])^ then
  404. begin
  405. Last := Coverage[I];
  406. V := Abs(Round(Coverage[I] * $10000));
  407. V := V and $01ffff;
  408. if V >= $10000 then
  409. V := V xor $1ffff;
  410. V := V * M shr 24;
  411. {$IFDEF USEGR32GAMMA}
  412. V := GAMMA_ENCODING_TABLE[V];
  413. {$ENDIF}
  414. C.A := V;
  415. end;
  416. AlphaValues[I] := Color;
  417. end;
  418. end;
  419. procedure MakeAlphaNonZeroP(Value: Single; AlphaValues: PColor32Array;
  420. Count: Integer; Color: TColor32);
  421. var
  422. M, V: Cardinal;
  423. C: TColor32Entry absolute Color;
  424. begin
  425. M := C.A * $101;
  426. V := Abs(Round(Value * $10000));
  427. if V > $10000 then V := $10000;
  428. V := V * M shr 24;
  429. {$IFDEF USEGR32GAMMA}
  430. V := GAMMA_ENCODING_TABLE[V];
  431. {$ENDIF}
  432. C.A := V;
  433. FillLongWord(AlphaValues[0], Count, Color);
  434. end;
  435. procedure MakeAlphaEvenOddP(Value: Single; AlphaValues: PColor32Array;
  436. Count: Integer; Color: TColor32);
  437. var
  438. M, V: Cardinal;
  439. C: TColor32Entry absolute Color;
  440. begin
  441. M := C.A * $101;
  442. V := Abs(Round(Value * $10000));
  443. V := V and $01ffff;
  444. if V > $10000 then V := V xor $1ffff;
  445. V := V * M shr 24;
  446. {$IFDEF USEGR32GAMMA}
  447. V := GAMMA_ENCODING_TABLE[V];
  448. {$ENDIF}
  449. C.A := V;
  450. FillLongWord(AlphaValues[0], Count, Color);
  451. end;
  452. // polygon filler routines (extract alpha only):
  453. procedure MakeAlphaNonZeroUPF(Coverage: PSingleArray; AlphaValues: PColor32Array;
  454. Count: Integer; Color: TColor32);
  455. var
  456. I: Integer;
  457. V: Integer;
  458. begin
  459. for I := 0 to Count - 1 do
  460. begin
  461. V := Clamp(Round(Abs(Coverage[I]) * 256));
  462. {$IFDEF USEGR32GAMMA}
  463. V := GAMMA_ENCODING_TABLE[V];
  464. {$ENDIF}
  465. AlphaValues[I] := V;
  466. end;
  467. end;
  468. procedure MakeAlphaEvenOddUPF(Coverage: PSingleArray; AlphaValues: PColor32Array;
  469. Count: Integer; Color: TColor32);
  470. var
  471. I: Integer;
  472. V: Integer;
  473. begin
  474. for I := 0 to Count - 1 do
  475. begin
  476. V := Round(Abs(Coverage[I]) * 256);
  477. V := V and $000001ff;
  478. if V >= $100 then V := V xor $1ff;
  479. {$IFDEF USEGR32GAMMA}
  480. V := GAMMA_ENCODING_TABLE[V];
  481. {$ENDIF}
  482. AlphaValues[I] := V;
  483. end;
  484. end;
  485. procedure MakeAlphaNonZeroPF(Value: Single; AlphaValues: PColor32Array;
  486. Count: Integer; Color: TColor32);
  487. var
  488. V: Integer;
  489. begin
  490. V := Clamp(Round(Abs(Value) * 256));
  491. {$IFDEF USEGR32GAMMA}
  492. V := GAMMA_ENCODING_TABLE[V];
  493. {$ENDIF}
  494. FillLongWord(AlphaValues[0], Count, V);
  495. end;
  496. procedure MakeAlphaEvenOddPF(Value: Single; AlphaValues: PColor32Array;
  497. Count: Integer; Color: TColor32);
  498. var
  499. V: Integer;
  500. begin
  501. V := Round(Abs(Value) * 256);
  502. V := V and $000001ff;
  503. if V >= $100 then V := V xor $1ff;
  504. {$IFDEF USEGR32GAMMA}
  505. V := GAMMA_ENCODING_TABLE[V];
  506. {$ENDIF}
  507. FillLongWord(AlphaValues[0], Count, V);
  508. end;
  509. procedure PolyPolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  510. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  511. var
  512. Renderer: TPolygonRenderer32VPR;
  513. begin
  514. Renderer := TPolygonRenderer32VPR.Create;
  515. try
  516. Renderer.Bitmap := Bitmap;
  517. Renderer.Color := Color;
  518. Renderer.FillMode := FillMode;
  519. Renderer.PolyPolygonFS(Points, FloatRect(Bitmap.ClipRect), Transformation);
  520. finally
  521. Renderer.Free;
  522. end;
  523. end;
  524. procedure PolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  525. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  526. var
  527. Renderer: TPolygonRenderer32VPR;
  528. begin
  529. Renderer := TPolygonRenderer32VPR.Create;
  530. try
  531. Renderer.Bitmap := Bitmap;
  532. Renderer.Color := Color;
  533. Renderer.FillMode := FillMode;
  534. Renderer.PolygonFS(Points, FloatRect(Bitmap.ClipRect), Transformation);
  535. finally
  536. Renderer.Free;
  537. end;
  538. end;
  539. procedure PolyPolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  540. Filler: TCustomPolygonFiller; FillMode: TPolyFillMode; Transformation: TTransformation);
  541. var
  542. Renderer: TPolygonRenderer32VPR;
  543. begin
  544. if not Assigned(Filler) then Exit;
  545. Renderer := TPolygonRenderer32VPR.Create;
  546. try
  547. Renderer.Bitmap := Bitmap;
  548. Renderer.Filler := Filler;
  549. Renderer.FillMode := FillMode;
  550. Renderer.PolyPolygonFS(Points, FloatRect(Bitmap.ClipRect), Transformation);
  551. finally
  552. Renderer.Free;
  553. end;
  554. end;
  555. procedure PolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  556. Filler: TCustomPolygonFiller; FillMode: TPolyFillMode; Transformation: TTransformation);
  557. var
  558. Renderer: TPolygonRenderer32VPR;
  559. begin
  560. if not Assigned(Filler) then Exit;
  561. Renderer := TPolygonRenderer32VPR.Create;
  562. try
  563. Renderer.Bitmap := Bitmap;
  564. Renderer.Filler := Filler;
  565. Renderer.FillMode := FillMode;
  566. Renderer.PolygonFS(Points, FloatRect(Bitmap.ClipRect), Transformation);
  567. finally
  568. Renderer.Free;
  569. end;
  570. end;
  571. procedure PolygonFS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  572. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  573. var
  574. Renderer: TPolygonRenderer32LCD;
  575. begin
  576. Renderer := TPolygonRenderer32LCD.Create;
  577. try
  578. Renderer.Bitmap := Bitmap;
  579. Renderer.FillMode := FillMode;
  580. Renderer.Color := Color;
  581. Renderer.PolygonFS(Points, FloatRect(Bitmap.ClipRect), Transformation);
  582. finally
  583. Renderer.Free;
  584. end;
  585. end;
  586. procedure PolyPolygonFS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  587. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  588. var
  589. Renderer: TPolygonRenderer32LCD;
  590. begin
  591. Renderer := TPolygonRenderer32LCD.Create;
  592. try
  593. Renderer.Bitmap := Bitmap;
  594. Renderer.FillMode := FillMode;
  595. Renderer.Color := Color;
  596. Renderer.PolyPolygonFS(Points, FloatRect(Bitmap.ClipRect), Transformation);
  597. finally
  598. Renderer.Free;
  599. end;
  600. end;
  601. procedure PolygonFS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  602. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  603. var
  604. Renderer: TPolygonRenderer32LCD2;
  605. begin
  606. Renderer := TPolygonRenderer32LCD2.Create;
  607. try
  608. Renderer.Bitmap := Bitmap;
  609. Renderer.FillMode := FillMode;
  610. Renderer.Color := Color;
  611. Renderer.PolygonFS(Points, FloatRect(Bitmap.ClipRect), Transformation);
  612. finally
  613. Renderer.Free;
  614. end;
  615. end;
  616. procedure PolyPolygonFS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  617. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  618. var
  619. Renderer: TPolygonRenderer32LCD2;
  620. begin
  621. Renderer := TPolygonRenderer32LCD2.Create;
  622. try
  623. Renderer.Bitmap := Bitmap;
  624. Renderer.FillMode := FillMode;
  625. Renderer.Color := Color;
  626. Renderer.PolyPolygonFS(Points, FloatRect(Bitmap.ClipRect), Transformation);
  627. finally
  628. Renderer.Free;
  629. end;
  630. end;
  631. procedure PolyPolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  632. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode;
  633. Transformation: TTransformation);
  634. var
  635. Renderer: TPolygonRenderer32VPR;
  636. IntersectedClipRect: TRect;
  637. begin
  638. Renderer := TPolygonRenderer32VPR.Create;
  639. try
  640. Renderer.Bitmap := Bitmap;
  641. Renderer.Color := Color;
  642. Renderer.FillMode := FillMode;
  643. GR32.IntersectRect(IntersectedClipRect, Bitmap.ClipRect, ClipRect);
  644. Renderer.PolyPolygonFS(Points, FloatRect(IntersectedClipRect), Transformation);
  645. finally
  646. Renderer.Free;
  647. end;
  648. end;
  649. procedure PolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  650. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode;
  651. Transformation: TTransformation);
  652. var
  653. Renderer: TPolygonRenderer32VPR;
  654. IntersectedClipRect: TRect;
  655. begin
  656. Renderer := TPolygonRenderer32VPR.Create;
  657. try
  658. Renderer.Bitmap := Bitmap;
  659. Renderer.Color := Color;
  660. Renderer.FillMode := FillMode;
  661. GR32.IntersectRect(IntersectedClipRect, Bitmap.ClipRect, ClipRect);
  662. Renderer.PolygonFS(Points, FloatRect(IntersectedClipRect), Transformation);
  663. finally
  664. Renderer.Free;
  665. end;
  666. end;
  667. procedure PolyPolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  668. ClipRect: TRect; Filler: TCustomPolygonFiller; FillMode: TPolyFillMode;
  669. Transformation: TTransformation);
  670. var
  671. Renderer: TPolygonRenderer32VPR;
  672. IntersectedClipRect: TRect;
  673. begin
  674. if not Assigned(Filler) then Exit;
  675. Renderer := TPolygonRenderer32VPR.Create;
  676. try
  677. Renderer.Bitmap := Bitmap;
  678. Renderer.Filler := Filler;
  679. Renderer.FillMode := FillMode;
  680. GR32.IntersectRect(IntersectedClipRect, Bitmap.ClipRect, ClipRect);
  681. Renderer.PolyPolygonFS(Points, FloatRect(IntersectedClipRect), Transformation);
  682. finally
  683. Renderer.Free;
  684. end;
  685. end;
  686. procedure PolygonFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  687. ClipRect: TRect; Filler: TCustomPolygonFiller; FillMode: TPolyFillMode;
  688. Transformation: TTransformation);
  689. var
  690. Renderer: TPolygonRenderer32VPR;
  691. IntersectedClipRect: TRect;
  692. begin
  693. if not Assigned(Filler) then Exit;
  694. Renderer := TPolygonRenderer32VPR.Create;
  695. try
  696. Renderer.Bitmap := Bitmap;
  697. Renderer.Filler := Filler;
  698. Renderer.FillMode := FillMode;
  699. GR32.IntersectRect(IntersectedClipRect, Bitmap.ClipRect, ClipRect);
  700. Renderer.PolygonFS(Points, FloatRect(IntersectedClipRect), Transformation);
  701. finally
  702. Renderer.Free;
  703. end;
  704. end;
  705. procedure PolygonFS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  706. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode;
  707. Transformation: TTransformation);
  708. var
  709. Renderer: TPolygonRenderer32LCD;
  710. IntersectedClipRect: TRect;
  711. begin
  712. Renderer := TPolygonRenderer32LCD.Create;
  713. try
  714. Renderer.Bitmap := Bitmap;
  715. Renderer.FillMode := FillMode;
  716. Renderer.Color := Color;
  717. GR32.IntersectRect(IntersectedClipRect, Bitmap.ClipRect, ClipRect);
  718. Renderer.PolygonFS(Points, FloatRect(IntersectedClipRect), Transformation);
  719. finally
  720. Renderer.Free;
  721. end;
  722. end;
  723. procedure PolyPolygonFS_LCD(Bitmap: TCustomBitmap32;
  724. const Points: TArrayOfArrayOfFloatPoint; ClipRect: TRect; Color: TColor32;
  725. FillMode: TPolyFillMode; Transformation: TTransformation);
  726. var
  727. Renderer: TPolygonRenderer32LCD;
  728. IntersectedClipRect: TRect;
  729. begin
  730. Renderer := TPolygonRenderer32LCD.Create;
  731. try
  732. Renderer.Bitmap := Bitmap;
  733. Renderer.FillMode := FillMode;
  734. Renderer.Color := Color;
  735. GR32.IntersectRect(IntersectedClipRect, Bitmap.ClipRect, ClipRect);
  736. Renderer.PolyPolygonFS(Points, FloatRect(IntersectedClipRect), Transformation);
  737. finally
  738. Renderer.Free;
  739. end;
  740. end;
  741. procedure PolygonFS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  742. ClipRect: TRect; Color: TColor32; FillMode: TPolyFillMode;
  743. Transformation: TTransformation);
  744. var
  745. Renderer: TPolygonRenderer32LCD2;
  746. IntersectedClipRect: TRect;
  747. begin
  748. Renderer := TPolygonRenderer32LCD2.Create;
  749. try
  750. Renderer.Bitmap := Bitmap;
  751. Renderer.FillMode := FillMode;
  752. Renderer.Color := Color;
  753. GR32.IntersectRect(IntersectedClipRect, Bitmap.ClipRect, ClipRect);
  754. Renderer.PolygonFS(Points, FloatRect(IntersectedClipRect), Transformation);
  755. finally
  756. Renderer.Free;
  757. end;
  758. end;
  759. procedure PolyPolygonFS_LCD2(Bitmap: TCustomBitmap32;
  760. const Points: TArrayOfArrayOfFloatPoint; ClipRect: TRect; Color: TColor32;
  761. FillMode: TPolyFillMode; Transformation: TTransformation);
  762. var
  763. Renderer: TPolygonRenderer32LCD2;
  764. IntersectedClipRect: TRect;
  765. begin
  766. Renderer := TPolygonRenderer32LCD2.Create;
  767. try
  768. Renderer.Bitmap := Bitmap;
  769. Renderer.FillMode := FillMode;
  770. Renderer.Color := Color;
  771. GR32.IntersectRect(IntersectedClipRect, Bitmap.ClipRect, ClipRect);
  772. Renderer.PolyPolygonFS(Points, FloatRect(IntersectedClipRect), Transformation);
  773. finally
  774. Renderer.Free;
  775. end;
  776. end;
  777. procedure PolyPolylineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  778. Color: TColor32; Closed: Boolean; StrokeWidth: TFloat;
  779. JoinStyle: TJoinStyle; EndStyle: TEndStyle;
  780. MiterLimit: TFloat; Transformation: TTransformation);
  781. var
  782. Dst: TArrayOfArrayOfFloatPoint;
  783. begin
  784. Dst := BuildPolyPolyLine(Points, Closed, StrokeWidth, JoinStyle, EndStyle, MiterLimit);
  785. PolyPolygonFS(Bitmap, Dst, Color, pfWinding, Transformation);
  786. end;
  787. procedure PolyPolylineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFloatPoint;
  788. Filler: TCustomPolygonFiller; Closed: Boolean = False; StrokeWidth: TFloat = 1.0;
  789. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  790. MiterLimit: TFloat = 4.0; Transformation: TTransformation = nil);
  791. var
  792. Dst: TArrayOfArrayOfFloatPoint;
  793. begin
  794. Dst := BuildPolyPolyLine(Points, Closed, StrokeWidth, JoinStyle, EndStyle, MiterLimit);
  795. PolyPolygonFS(Bitmap, Dst, Filler, pfWinding, Transformation);
  796. end;
  797. procedure PolylineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  798. Color: TColor32; Closed: Boolean; StrokeWidth: TFloat;
  799. JoinStyle: TJoinStyle; EndStyle: TEndStyle;
  800. MiterLimit: TFloat; Transformation: TTransformation);
  801. begin
  802. PolyPolylineFS(Bitmap, PolyPolygon(Points), Color, Closed, StrokeWidth,
  803. JoinStyle, EndStyle, MiterLimit, Transformation);
  804. end;
  805. procedure PolylineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  806. Filler: TCustomPolygonFiller; Closed: Boolean = False; StrokeWidth: TFloat = 1.0;
  807. JoinStyle: TJoinStyle = jsMiter; EndStyle: TEndStyle = esButt;
  808. MiterLimit: TFloat = 4.0; Transformation: TTransformation = nil);
  809. begin
  810. PolyPolylineFS(Bitmap, PolyPolygon(Points), Filler, Closed, StrokeWidth,
  811. JoinStyle, EndStyle, MiterLimit, Transformation);
  812. end;
  813. procedure DashLineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  814. const Dashes: TArrayOfFloat; Color: TColor32;
  815. Closed: Boolean = False; Width: TFloat = 1.0);
  816. var
  817. MultiPoly: TArrayOfArrayOfFloatPoint;
  818. begin
  819. MultiPoly := GR32_VectorUtils.BuildDashedLine(Points, Dashes, 0, Closed);
  820. PolyPolylineFS(Bitmap, MultiPoly, Color, False, Width);
  821. end;
  822. procedure DashLineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  823. const Dashes: TArrayOfFloat; FillColor, StrokeColor: TColor32;
  824. Closed: Boolean; Width: TFloat; StrokeWidth: TFloat = 2.0);
  825. var
  826. MultiPoly: TArrayOfArrayOfFloatPoint;
  827. begin
  828. MultiPoly := GR32_VectorUtils.BuildDashedLine(Points, Dashes, 0, Closed);
  829. MultiPoly := BuildPolyPolyLine(MultiPoly, False, Width);
  830. PolyPolygonFS(Bitmap, MultiPoly, FillColor);
  831. PolyPolylineFS(Bitmap, MultiPoly, StrokeColor, True, StrokeWidth);
  832. end;
  833. procedure DashLineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  834. const Dashes: TArrayOfFloat; Filler: TCustomPolygonFiller;
  835. Closed: Boolean = False; Width: TFloat = 1.0);
  836. var
  837. MultiPoly: TArrayOfArrayOfFloatPoint;
  838. begin
  839. MultiPoly := GR32_VectorUtils.BuildDashedLine(Points, Dashes, 0, Closed);
  840. PolyPolylineFS(Bitmap, MultiPoly, Filler, False, Width);
  841. end;
  842. procedure DashLineFS(Bitmap: TCustomBitmap32; const Points: TArrayOfFloatPoint;
  843. const Dashes: TArrayOfFloat; Filler: TCustomPolygonFiller; StrokeColor: TColor32;
  844. Closed: Boolean; Width: TFloat; StrokeWidth: TFloat = 2.0);
  845. var
  846. MultiPoly: TArrayOfArrayOfFloatPoint;
  847. begin
  848. MultiPoly := GR32_VectorUtils.BuildDashedLine(Points, Dashes, 0, Closed);
  849. MultiPoly := BuildPolyPolyLine(MultiPoly, False, Width);
  850. PolyPolygonFS(Bitmap, MultiPoly, Filler);
  851. PolyPolylineFS(Bitmap, MultiPoly, StrokeColor, True, StrokeWidth);
  852. end;
  853. procedure PolyPolygonXS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  854. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  855. var
  856. Renderer: TPolygonRenderer32VPR;
  857. begin
  858. Renderer := TPolygonRenderer32VPR.Create;
  859. try
  860. Renderer.Bitmap := Bitmap;
  861. Renderer.Color := Color;
  862. Renderer.FillMode := FillMode;
  863. Renderer.PolyPolygonFS(FixedPointToFloatPoint(Points),
  864. FloatRect(Bitmap.ClipRect), Transformation);
  865. finally
  866. Renderer.Free;
  867. end;
  868. end;
  869. procedure PolygonXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  870. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  871. var
  872. Renderer: TPolygonRenderer32VPR;
  873. begin
  874. Renderer := TPolygonRenderer32VPR.Create;
  875. try
  876. Renderer.Bitmap := Bitmap;
  877. Renderer.Color := Color;
  878. Renderer.FillMode := FillMode;
  879. Renderer.PolygonFS(FixedPointToFloatPoint(Points),
  880. FloatRect(Bitmap.ClipRect), Transformation);
  881. finally
  882. Renderer.Free;
  883. end;
  884. end;
  885. procedure PolyPolygonXS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  886. Filler: TCustomPolygonFiller; FillMode: TPolyFillMode; Transformation: TTransformation);
  887. var
  888. Renderer: TPolygonRenderer32VPR;
  889. begin
  890. Renderer := TPolygonRenderer32VPR.Create;
  891. try
  892. Renderer.Bitmap := Bitmap;
  893. Renderer.Filler := Filler;
  894. Renderer.FillMode := FillMode;
  895. Renderer.PolyPolygonFS(FixedPointToFloatPoint(Points),
  896. FloatRect(Bitmap.ClipRect), Transformation);
  897. finally
  898. Renderer.Free;
  899. end;
  900. end;
  901. procedure PolygonXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  902. Filler: TCustomPolygonFiller; FillMode: TPolyFillMode; Transformation: TTransformation);
  903. var
  904. Renderer: TPolygonRenderer32VPR;
  905. begin
  906. Renderer := TPolygonRenderer32VPR.Create;
  907. try
  908. Renderer.Bitmap := Bitmap;
  909. Renderer.Filler := Filler;
  910. Renderer.FillMode := FillMode;
  911. Renderer.PolygonFS(FixedPointToFloatPoint(Points),
  912. FloatRect(Bitmap.ClipRect), Transformation);
  913. finally
  914. Renderer.Free;
  915. end;
  916. end;
  917. procedure PolygonXS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  918. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  919. var
  920. Renderer: TPolygonRenderer32LCD;
  921. begin
  922. Renderer := TPolygonRenderer32LCD.Create;
  923. try
  924. Renderer.Bitmap := Bitmap;
  925. Renderer.FillMode := FillMode;
  926. Renderer.Color := Color;
  927. Renderer.PolygonFS(FixedPointToFloatPoint(Points),
  928. FloatRect(Bitmap.ClipRect), Transformation);
  929. finally
  930. Renderer.Free;
  931. end;
  932. end;
  933. procedure PolyPolygonXS_LCD(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  934. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  935. var
  936. Renderer: TPolygonRenderer32LCD;
  937. begin
  938. Renderer := TPolygonRenderer32LCD.Create;
  939. try
  940. Renderer.Bitmap := Bitmap;
  941. Renderer.FillMode := FillMode;
  942. Renderer.Color := Color;
  943. Renderer.PolyPolygonFS(FixedPointToFloatPoint(Points),
  944. FloatRect(Bitmap.ClipRect), Transformation);
  945. finally
  946. Renderer.Free;
  947. end;
  948. end;
  949. procedure PolygonXS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  950. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  951. var
  952. Renderer: TPolygonRenderer32LCD2;
  953. begin
  954. Renderer := TPolygonRenderer32LCD2.Create;
  955. try
  956. Renderer.Bitmap := Bitmap;
  957. Renderer.FillMode := FillMode;
  958. Renderer.Color := Color;
  959. Renderer.PolygonFS(FixedPointToFloatPoint(Points),
  960. FloatRect(Bitmap.ClipRect), Transformation);
  961. finally
  962. Renderer.Free;
  963. end;
  964. end;
  965. procedure PolyPolygonXS_LCD2(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  966. Color: TColor32; FillMode: TPolyFillMode; Transformation: TTransformation);
  967. var
  968. Renderer: TPolygonRenderer32LCD2;
  969. begin
  970. Renderer := TPolygonRenderer32LCD2.Create;
  971. try
  972. Renderer.Bitmap := Bitmap;
  973. Renderer.FillMode := FillMode;
  974. Renderer.Color := Color;
  975. Renderer.PolyPolygonFS(FixedPointToFloatPoint(Points),
  976. FloatRect(Bitmap.ClipRect), Transformation);
  977. finally
  978. Renderer.Free;
  979. end;
  980. end;
  981. procedure PolyPolylineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  982. Color: TColor32; Closed: Boolean; StrokeWidth: TFixed;
  983. JoinStyle: TJoinStyle; EndStyle: TEndStyle;
  984. MiterLimit: TFixed; Transformation: TTransformation);
  985. var
  986. Dst: TArrayOfArrayOfFixedPoint;
  987. begin
  988. Dst := BuildPolyPolyLine(Points, Closed, StrokeWidth, JoinStyle, EndStyle,
  989. MiterLimit);
  990. PolyPolygonXS(Bitmap, Dst, Color, pfWinding, Transformation);
  991. end;
  992. procedure PolyPolylineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfArrayOfFixedPoint;
  993. Filler: TCustomPolygonFiller; Closed: Boolean = False;
  994. StrokeWidth: TFixed = $10000; JoinStyle: TJoinStyle = jsMiter;
  995. EndStyle: TEndStyle = esButt; MiterLimit: TFixed = $40000;
  996. Transformation: TTransformation = nil);
  997. var
  998. Dst: TArrayOfArrayOfFixedPoint;
  999. begin
  1000. Dst := BuildPolyPolyLine(Points, Closed, StrokeWidth, JoinStyle, EndStyle,
  1001. MiterLimit);
  1002. PolyPolygonXS(Bitmap, Dst, Filler, pfWinding, Transformation);
  1003. end;
  1004. procedure PolylineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  1005. Color: TColor32; Closed: Boolean; StrokeWidth: TFixed;
  1006. JoinStyle: TJoinStyle; EndStyle: TEndStyle;
  1007. MiterLimit: TFixed; Transformation: TTransformation);
  1008. begin
  1009. PolyPolylineXS(Bitmap, PolyPolygon(Points), Color,
  1010. Closed, StrokeWidth, JoinStyle, EndStyle,
  1011. MiterLimit, Transformation);
  1012. end;
  1013. procedure PolylineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  1014. Filler: TCustomPolygonFiller; Closed: Boolean = False;
  1015. StrokeWidth: TFixed = $10000; JoinStyle: TJoinStyle = jsMiter;
  1016. EndStyle: TEndStyle = esButt; MiterLimit: TFixed = $40000;
  1017. Transformation: TTransformation = nil);
  1018. begin
  1019. PolyPolylineXS(Bitmap, PolyPolygon(Points), Filler, Closed, StrokeWidth,
  1020. JoinStyle, EndStyle, MiterLimit, Transformation);
  1021. end;
  1022. procedure DashLineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  1023. const Dashes: TArrayOfFixed; Color: TColor32;
  1024. Closed: Boolean = False; Width: TFixed = $10000);
  1025. var
  1026. MultiPoly: TArrayOfArrayOfFixedPoint;
  1027. begin
  1028. MultiPoly := GR32_VectorUtils.BuildDashedLine(Points, Dashes, 0, Closed);
  1029. PolyPolylineXS(Bitmap, MultiPoly, Color, False, Width);
  1030. end;
  1031. procedure DashLineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  1032. const Dashes: TArrayOfFixed; FillColor, StrokeColor: TColor32;
  1033. Closed: Boolean; Width: TFixed; StrokeWidth: TFixed = $20000);
  1034. var
  1035. MultiPoly: TArrayOfArrayOfFixedPoint;
  1036. begin
  1037. MultiPoly := GR32_VectorUtils.BuildDashedLine(Points, Dashes, 0, Closed);
  1038. PolyPolylineXS(Bitmap, MultiPoly, FillColor, False, Width);
  1039. MultiPoly := BuildPolyPolyLine(MultiPoly, False, Width);
  1040. PolyPolylineXS(Bitmap, MultiPoly, StrokeColor, True, strokeWidth);
  1041. end;
  1042. procedure DashLineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  1043. const Dashes: TArrayOfFixed; Filler: TCustomPolygonFiller;
  1044. Closed: Boolean = False; Width: TFixed = $10000);
  1045. var
  1046. MultiPoly: TArrayOfArrayOfFixedPoint;
  1047. begin
  1048. MultiPoly := GR32_VectorUtils.BuildDashedLine(Points, Dashes, 0, Closed);
  1049. PolyPolylineXS(Bitmap, MultiPoly, Filler, False, Width);
  1050. end;
  1051. procedure DashLineXS(Bitmap: TCustomBitmap32; const Points: TArrayOfFixedPoint;
  1052. const Dashes: TArrayOfFixed; Filler: TCustomPolygonFiller; StrokeColor: TColor32;
  1053. Closed: Boolean; Width: TFixed; StrokeWidth: TFixed = $20000);
  1054. var
  1055. MultiPoly: TArrayOfArrayOfFixedPoint;
  1056. begin
  1057. MultiPoly := GR32_VectorUtils.BuildDashedLine(Points, Dashes, 0, Closed);
  1058. PolyPolylineXS(Bitmap, MultiPoly, Filler, False, Width);
  1059. MultiPoly := BuildPolyPolyLine(MultiPoly, False, Width);
  1060. PolyPolylineXS(Bitmap, MultiPoly, StrokeColor, True, StrokeWidth);
  1061. end;
  1062. procedure FillBitmap(Bitmap: TCustomBitmap32; Filler: TCustomPolygonFiller);
  1063. var
  1064. AlphaValues: PColor32;
  1065. Y: Integer;
  1066. begin
  1067. {$IFDEF USESTACKALLOC}
  1068. AlphaValues := StackAlloc(Bitmap.Width * SizeOf(TColor32));
  1069. {$ELSE}
  1070. GetMem(AlphaValues, Bitmap.Width * SizeOf(TColor32));
  1071. {$ENDIF}
  1072. FillLongword(AlphaValues^, Bitmap.Width, $FF);
  1073. Filler.BeginRendering;
  1074. for Y := 0 to Bitmap.Height - 1 do
  1075. Filler.FillLine(PColor32(Bitmap.ScanLine[y]), 0, y, Bitmap.Width,
  1076. AlphaValues, Bitmap.CombineMode);
  1077. Filler.EndRendering;
  1078. {$IFDEF USESTACKALLOC}
  1079. StackFree(AlphaValues);
  1080. {$ELSE}
  1081. FreeMem(AlphaValues);
  1082. {$ENDIF}
  1083. end;
  1084. { LCD sub-pixel rendering (see http://www.grc.com/cttech.htm) }
  1085. type
  1086. PRGBTriple = ^TRGBTriple;
  1087. TRGBTriple = packed record
  1088. B, G, R: Byte;
  1089. end;
  1090. PRGBTripleArray = ^TRGBTripleArray;
  1091. TRGBTripleArray = array [0..0] of TRGBTriple;
  1092. TMakeAlphaProcLCD = procedure(Coverage: PSingleArray; AlphaValues: SysUtils.PByteArray;
  1093. Count: Integer; Color: TColor32);
  1094. procedure MakeAlphaNonZeroLCD(Coverage: PSingleArray; AlphaValues: SysUtils.PByteArray;
  1095. Count: Integer; Color: TColor32);
  1096. var
  1097. I: Integer;
  1098. M, V: Cardinal;
  1099. Last: TFloat;
  1100. C: TColor32Entry absolute Color;
  1101. begin
  1102. M := C.A * 86; // 86 = 258 / 3
  1103. Last := Infinity;
  1104. V := 0;
  1105. AlphaValues[0] := 0;
  1106. AlphaValues[1] := 0;
  1107. for I := 0 to Count - 1 do
  1108. begin
  1109. if PInteger(@Last)^ <> PInteger(@Coverage[I])^ then
  1110. begin
  1111. Last := Coverage[I];
  1112. V := Abs(Round(Last * $10000));
  1113. if V > $10000 then V := $10000;
  1114. V := V * M shr 24;
  1115. end;
  1116. Inc(AlphaValues[I], V);
  1117. {$IFDEF USEGR32GAMMA}
  1118. AlphaValues[I] := GAMMA_ENCODING_TABLE[AlphaValues[I]];
  1119. {$ENDIF}
  1120. Inc(AlphaValues[I + 1], V);
  1121. AlphaValues[I + 2] := V;
  1122. end;
  1123. AlphaValues[Count + 2] := 0;
  1124. AlphaValues[Count + 3] := 0;
  1125. end;
  1126. procedure MakeAlphaEvenOddLCD(Coverage: PSingleArray; AlphaValues: SysUtils.PByteArray;
  1127. Count: Integer; Color: TColor32);
  1128. var
  1129. I: Integer;
  1130. M, V: Cardinal;
  1131. Last: TFloat;
  1132. begin
  1133. M := Color shr 24 * 86; // 86 = 258 / 3
  1134. Last := Infinity;
  1135. V := 0;
  1136. AlphaValues[0] := 0;
  1137. AlphaValues[1] := 0;
  1138. for I := 0 to Count - 1 do
  1139. begin
  1140. if PInteger(@Last)^ <> PInteger(@Coverage[I])^ then
  1141. begin
  1142. Last := Coverage[I];
  1143. V := Abs(Round(Coverage[I] * $10000));
  1144. V := V and $01ffff;
  1145. if V >= $10000 then V := V xor $1ffff;
  1146. V := V * M shr 24;
  1147. end;
  1148. Inc(AlphaValues[I], V);
  1149. {$IFDEF USEGR32GAMMA}
  1150. AlphaValues[I] := GAMMA_ENCODING_TABLE[AlphaValues[I]];
  1151. {$ENDIF}
  1152. Inc(AlphaValues[I + 1], V);
  1153. AlphaValues[I + 2] := V;
  1154. end;
  1155. AlphaValues[Count + 2] := 0;
  1156. AlphaValues[Count + 3] := 0;
  1157. end;
  1158. procedure MakeAlphaNonZeroLCD2(Coverage: PSingleArray; AlphaValues: SysUtils.PByteArray;
  1159. Count: Integer; Color: TColor32);
  1160. var
  1161. I: Integer;
  1162. begin
  1163. MakeAlphaNonZeroLCD(Coverage, AlphaValues, Count, Color);
  1164. AlphaValues[Count + 2] := (AlphaValues[Count] + AlphaValues[Count + 1]) div 3;
  1165. AlphaValues[Count + 3] := AlphaValues[Count + 1] div 3;
  1166. for I := Count + 1 downto 2 do
  1167. begin
  1168. AlphaValues[I] := (AlphaValues[I] + AlphaValues[I - 1] + AlphaValues[I - 2]) div 3;
  1169. end;
  1170. AlphaValues[1] := (AlphaValues[0] + AlphaValues[1]) div 3;
  1171. AlphaValues[0] := AlphaValues[0] div 3;
  1172. end;
  1173. procedure MakeAlphaEvenOddLCD2(Coverage: PSingleArray; AlphaValues: SysUtils.PByteArray;
  1174. Count: Integer; Color: TColor32);
  1175. var
  1176. I: Integer;
  1177. begin
  1178. MakeAlphaEvenOddLCD(Coverage, AlphaValues, Count, Color);
  1179. AlphaValues[Count + 2] := (AlphaValues[Count] + AlphaValues[Count + 1]) div 3;
  1180. AlphaValues[Count + 3] := AlphaValues[Count + 1] div 3;
  1181. for I := Count + 1 downto 2 do
  1182. begin
  1183. AlphaValues[I] := (AlphaValues[I] + AlphaValues[I - 1] + AlphaValues[I - 2]) div 3;
  1184. end;
  1185. AlphaValues[1] := (AlphaValues[0] + AlphaValues[1]) div 3;
  1186. AlphaValues[0] := AlphaValues[0] div 3;
  1187. end;
  1188. procedure CombineLineLCD(Weights: PRGBTripleArray; Dst: PColor32Array; Color: TColor32; Count: Integer);
  1189. var
  1190. I: Integer;
  1191. {$IFDEF TEST_BLENDMEMRGB128SSE4}
  1192. Weights64: UInt64;
  1193. {$ENDIF}
  1194. begin
  1195. I := 0;
  1196. while Count <> 0 do
  1197. {$IFDEF TEST_BLENDMEMRGB128SSE4}
  1198. if (Count shr 1) = 0 then
  1199. {$ENDIF}
  1200. begin
  1201. if PColor32(@Weights[I])^ = $FFFFFFFF then
  1202. Dst[I] := Color
  1203. else
  1204. BlendMemRGB(Color, Dst[I], PColor32(@Weights[I])^);
  1205. Dec(Count);
  1206. Inc(I);
  1207. end
  1208. {$IFDEF TEST_BLENDMEMRGB128SSE4}
  1209. else
  1210. begin
  1211. Weights64 := (UInt64(PColor32(@Weights[I + 1])^) shl 32) or
  1212. PColor32(@Weights[I])^;
  1213. if Weights64 = $FFFFFFFFFFFFFFFF then
  1214. begin
  1215. Dst[I] := Color;
  1216. Dst[I + 1] := Color;
  1217. end
  1218. else
  1219. BlendMemRGB128(Color, Dst[I], Weights64);
  1220. Dec(Count, 2);
  1221. Inc(I, 2);
  1222. end
  1223. {$ENDIF};
  1224. EMMS;
  1225. end;
  1226. { TCustomPolygonFiller }
  1227. procedure TCustomPolygonFiller.BeginRendering;
  1228. begin
  1229. // implemented by descendants
  1230. end;
  1231. procedure TCustomPolygonFiller.EndRendering;
  1232. begin
  1233. // implemented by descendants
  1234. end;
  1235. { TCallbackPolygonFiller }
  1236. function TCallbackPolygonFiller.GetFillLine: TFillLineEvent;
  1237. begin
  1238. Result := FFillLineEvent;
  1239. end;
  1240. { TInvertPolygonFiller }
  1241. procedure TInvertPolygonFiller.FillLineBlend(Dst: PColor32; DstX, DstY,
  1242. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  1243. var
  1244. X: Integer;
  1245. BlendMemEx: TBlendMemEx;
  1246. begin
  1247. BlendMemEx := BLEND_MEM_EX[CombineMode]^;
  1248. for X := DstX to DstX + Length - 1 do
  1249. begin
  1250. BlendMemEx(InvertColor(Dst^), Dst^, AlphaValues^);
  1251. EMMS;
  1252. Inc(Dst);
  1253. Inc(AlphaValues);
  1254. end;
  1255. end;
  1256. function TInvertPolygonFiller.GetFillLine: TFillLineEvent;
  1257. begin
  1258. Result := FillLineBlend;
  1259. end;
  1260. { TClearPolygonFiller }
  1261. constructor TClearPolygonFiller.Create(Color: TColor32 = $00808080);
  1262. begin
  1263. inherited Create;
  1264. FColor := Color;
  1265. end;
  1266. procedure TClearPolygonFiller.FillLineClear(Dst: PColor32; DstX, DstY,
  1267. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  1268. begin
  1269. FillLongword(Dst^, Length, FColor);
  1270. end;
  1271. function TClearPolygonFiller.GetFillLine: TFillLineEvent;
  1272. begin
  1273. Result := FillLineClear;
  1274. end;
  1275. { TBitmapPolygonFiller }
  1276. procedure TBitmapPolygonFiller.FillLineOpaque(Dst: PColor32; DstX, DstY,
  1277. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  1278. var
  1279. PatternX, PatternY, X: Integer;
  1280. OpaqueAlpha: TColor32;
  1281. Src: PColor32;
  1282. BlendMemEx: TBlendMemEx;
  1283. begin
  1284. PatternX := (DstX - OffsetX) mod FPattern.Width;
  1285. if PatternX < 0 then PatternX := (FPattern.Width + PatternX) mod FPattern.Width;
  1286. PatternY := (DstY - OffsetY) mod FPattern.Height;
  1287. if PatternY < 0 then PatternY := (FPattern.Height + PatternY) mod FPattern.Height;
  1288. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1289. if Assigned(AlphaValues) then
  1290. begin
  1291. OpaqueAlpha := TColor32($FF shl 24);
  1292. BlendMemEx := BLEND_MEM_EX[FPattern.CombineMode]^;
  1293. for X := DstX to DstX + Length - 1 do
  1294. begin
  1295. BlendMemEx(Src^ and $00FFFFFF or OpaqueAlpha, Dst^, AlphaValues^);
  1296. Inc(Dst); Inc(Src); Inc(PatternX);
  1297. if PatternX >= FPattern.Width then
  1298. begin
  1299. PatternX := 0;
  1300. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1301. end;
  1302. Inc(AlphaValues);
  1303. end
  1304. end
  1305. else
  1306. for X := DstX to DstX + Length - 1 do
  1307. begin
  1308. Dst^ := Src^;
  1309. Inc(Dst); Inc(Src); Inc(PatternX);
  1310. if PatternX >= FPattern.Width then
  1311. begin
  1312. PatternX := 0;
  1313. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1314. end;
  1315. end;
  1316. end;
  1317. procedure TBitmapPolygonFiller.FillLineBlend(Dst: PColor32; DstX, DstY,
  1318. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  1319. var
  1320. PatternX, PatternY, X: Integer;
  1321. Src: PColor32;
  1322. BlendMemEx: TBlendMemEx;
  1323. BlendMem: TBlendMem;
  1324. begin
  1325. PatternX := (DstX - OffsetX) mod FPattern.Width;
  1326. if PatternX < 0 then PatternX := (FPattern.Width + PatternX) mod FPattern.Width;
  1327. PatternY := (DstY - OffsetY) mod FPattern.Height;
  1328. if PatternY < 0 then PatternY := (FPattern.Height + PatternY) mod FPattern.Height;
  1329. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1330. if Assigned(AlphaValues) then
  1331. begin
  1332. BlendMemEx := BLEND_MEM_EX[FPattern.CombineMode]^;
  1333. for X := DstX to DstX + Length - 1 do
  1334. begin
  1335. BlendMemEx(Src^, Dst^, AlphaValues^);
  1336. Inc(Dst); Inc(Src); Inc(PatternX);
  1337. if PatternX >= FPattern.Width then
  1338. begin
  1339. PatternX := 0;
  1340. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1341. end;
  1342. Inc(AlphaValues);
  1343. end
  1344. end
  1345. else
  1346. begin
  1347. BlendMem := BLEND_MEM[FPattern.CombineMode]^;
  1348. for X := DstX to DstX + Length - 1 do
  1349. begin
  1350. BlendMem(Src^, Dst^);
  1351. Inc(Dst); Inc(Src); Inc(PatternX);
  1352. if PatternX >= FPattern.Width then
  1353. begin
  1354. PatternX := 0;
  1355. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1356. end;
  1357. end;
  1358. end;
  1359. end;
  1360. procedure TBitmapPolygonFiller.FillLineBlendMasterAlpha(Dst: PColor32;
  1361. DstX, DstY, Length: Integer; AlphaValues: PColor32;
  1362. CombineMode: TCombineMode);
  1363. var
  1364. PatternX, PatternY, X: Integer;
  1365. Src: PColor32;
  1366. BlendMemEx: TBlendMemEx;
  1367. begin
  1368. PatternX := (DstX - OffsetX) mod FPattern.Width;
  1369. if PatternX < 0 then PatternX := (FPattern.Width + PatternX) mod FPattern.Width;
  1370. PatternY := (DstY - OffsetY) mod FPattern.Height;
  1371. if PatternY < 0 then PatternY := (FPattern.Height + PatternY) mod FPattern.Height;
  1372. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1373. BlendMemEx := BLEND_MEM_EX[FPattern.CombineMode]^;
  1374. if Assigned(AlphaValues) then
  1375. for X := DstX to DstX + Length - 1 do
  1376. begin
  1377. BlendMemEx(Src^, Dst^, Div255(AlphaValues^ * FPattern.MasterAlpha));
  1378. Inc(Dst); Inc(Src); Inc(PatternX);
  1379. if PatternX >= FPattern.Width then
  1380. begin
  1381. PatternX := 0;
  1382. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1383. end;
  1384. Inc(AlphaValues);
  1385. end
  1386. else
  1387. for X := DstX to DstX + Length - 1 do
  1388. begin
  1389. BlendMemEx(Src^, Dst^, FPattern.MasterAlpha);
  1390. Inc(Dst); Inc(Src); Inc(PatternX);
  1391. if PatternX >= FPattern.Width then
  1392. begin
  1393. PatternX := 0;
  1394. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1395. end;
  1396. end;
  1397. end;
  1398. procedure TBitmapPolygonFiller.FillLineCustomCombine(Dst: PColor32;
  1399. DstX, DstY, Length: Integer; AlphaValues: PColor32;
  1400. CombineMode: TCombineMode);
  1401. var
  1402. PatternX, PatternY, X: Integer;
  1403. Src: PColor32;
  1404. begin
  1405. PatternX := (DstX - OffsetX) mod FPattern.Width;
  1406. if PatternX < 0 then PatternX := (FPattern.Width + PatternX) mod FPattern.Width;
  1407. PatternY := (DstY - OffsetY) mod FPattern.Height;
  1408. if PatternY < 0 then PatternY := (FPattern.Height + PatternY) mod FPattern.Height;
  1409. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1410. if Assigned(AlphaValues) then
  1411. for X := DstX to DstX + Length - 1 do
  1412. begin
  1413. FPattern.OnPixelCombine(Src^, Dst^, Div255(AlphaValues^ * FPattern.MasterAlpha));
  1414. Inc(Dst); Inc(Src); Inc(PatternX);
  1415. if PatternX >= FPattern.Width then
  1416. begin
  1417. PatternX := 0;
  1418. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1419. end;
  1420. Inc(AlphaValues);
  1421. end
  1422. else
  1423. for X := DstX to DstX + Length - 1 do
  1424. begin
  1425. FPattern.OnPixelCombine(Src^, Dst^, FPattern.MasterAlpha);
  1426. Inc(Dst); Inc(Src); Inc(PatternX);
  1427. if PatternX >= FPattern.Width then
  1428. begin
  1429. PatternX := 0;
  1430. Src := @FPattern.Bits[PatternX + PatternY * FPattern.Width];
  1431. end;
  1432. end;
  1433. end;
  1434. function TBitmapPolygonFiller.GetFillLine: TFillLineEvent;
  1435. begin
  1436. if not Assigned(FPattern) then
  1437. begin
  1438. Result := nil;
  1439. end
  1440. else if FPattern.DrawMode = dmOpaque then
  1441. Result := FillLineOpaque
  1442. else if FPattern.DrawMode = dmBlend then
  1443. begin
  1444. if FPattern.MasterAlpha = 255 then
  1445. Result := FillLineBlend
  1446. else
  1447. Result := FillLineBlendMasterAlpha;
  1448. end
  1449. else if (FPattern.DrawMode = dmCustom) and Assigned(FPattern.OnPixelCombine) then
  1450. begin
  1451. Result := FillLineCustomCombine;
  1452. end
  1453. else
  1454. Result := nil;
  1455. end;
  1456. { TSamplerFiller }
  1457. constructor TSamplerFiller.Create(Sampler: TCustomSampler = nil);
  1458. begin
  1459. inherited Create;
  1460. FSampler := Sampler;
  1461. SamplerChanged;
  1462. end;
  1463. procedure TSamplerFiller.EndRendering;
  1464. begin
  1465. if Assigned(FSampler) then
  1466. FSampler.FinalizeSampling
  1467. else
  1468. raise Exception.Create(RCStrNoSamplerSpecified);
  1469. end;
  1470. procedure TSamplerFiller.SampleLineOpaque(Dst: PColor32; DstX, DstY,
  1471. Length: Integer; AlphaValues: PColor32; CombineMode: TCombineMode);
  1472. var
  1473. X: Integer;
  1474. BlendMemEx: TBlendMemEx;
  1475. begin
  1476. BlendMemEx := BLEND_MEM_EX[CombineMode]^;
  1477. for X := DstX to DstX + Length - 1 do
  1478. begin
  1479. BlendMemEx(FGetSample(X, DstY) and $00FFFFFF or $FF000000, Dst^, AlphaValues^);
  1480. EMMS;
  1481. Inc(Dst);
  1482. Inc(AlphaValues);
  1483. end;
  1484. end;
  1485. procedure TSamplerFiller.SamplerChanged;
  1486. begin
  1487. if Assigned(FSampler) then
  1488. FGetSample := FSampler.GetSampleInt;
  1489. end;
  1490. procedure TSamplerFiller.BeginRendering;
  1491. begin
  1492. if Assigned(FSampler) then
  1493. FSampler.PrepareSampling
  1494. else
  1495. raise Exception.Create(RCStrNoSamplerSpecified);
  1496. end;
  1497. function TSamplerFiller.GetFillLine: TFillLineEvent;
  1498. begin
  1499. Result := SampleLineOpaque;
  1500. end;
  1501. procedure TSamplerFiller.SetSampler(const Value: TCustomSampler);
  1502. begin
  1503. if FSampler <> Value then
  1504. begin
  1505. FSampler := Value;
  1506. SamplerChanged;
  1507. end;
  1508. end;
  1509. { TCustomPolygonRenderer }
  1510. procedure TCustomPolygonRenderer.PolygonFS(
  1511. const Points: TArrayOfFloatPoint; const ClipRect: TFloatRect;
  1512. Transformation: TTransformation);
  1513. begin
  1514. PolyPolygonFS(PolyPolygon(Points), ClipRect, Transformation);
  1515. end;
  1516. procedure TCustomPolygonRenderer.PolygonFS(
  1517. const Points: TArrayOfFloatPoint; const ClipRect: TFloatRect);
  1518. begin
  1519. PolyPolygonFS(PolyPolygon(Points), ClipRect);
  1520. end;
  1521. procedure TCustomPolygonRenderer.PolyPolygonFS(
  1522. const Points: TArrayOfArrayOfFloatPoint; const ClipRect: TFloatRect);
  1523. begin
  1524. // implemented by descendants
  1525. end;
  1526. procedure TCustomPolygonRenderer.PolyPolygonFS(
  1527. const Points: TArrayOfArrayOfFloatPoint; const ClipRect: TFloatRect;
  1528. Transformation: TTransformation);
  1529. var
  1530. APoints: TArrayOfArrayOfFloatPoint;
  1531. begin
  1532. if Assigned(Transformation) then
  1533. APoints := TransformPolyPolygon(Points, Transformation)
  1534. else
  1535. APoints := Points;
  1536. PolyPolygonFS(APoints, ClipRect);
  1537. end;
  1538. { TPolygonRenderer32 }
  1539. constructor TPolygonRenderer32.Create(Bitmap: TCustomBitmap32;
  1540. Fillmode: TPolyFillMode);
  1541. begin
  1542. inherited Create;
  1543. FBitmap := Bitmap;
  1544. FFillMode := Fillmode;
  1545. end;
  1546. procedure TPolygonRenderer32.PolygonFS(const Points: TArrayOfFloatPoint);
  1547. begin
  1548. PolyPolygonFS(PolyPolygon(Points), FloatRect(FBitmap.ClipRect));
  1549. end;
  1550. procedure TPolygonRenderer32.PolyPolygonFS(const Points: TArrayOfArrayOfFloatPoint);
  1551. begin
  1552. PolyPolygonFS(Points, FloatRect(FBitmap.ClipRect));
  1553. end;
  1554. procedure TPolygonRenderer32.SetBitmap(const Value: TCustomBitmap32);
  1555. begin
  1556. if FBitmap <> Value then
  1557. begin
  1558. FBitmap := Value;
  1559. Changed;
  1560. end;
  1561. end;
  1562. procedure TPolygonRenderer32.SetColor(const Value: TColor32);
  1563. begin
  1564. if FColor <> Value then
  1565. begin
  1566. FColor := Value;
  1567. Changed;
  1568. end;
  1569. end;
  1570. procedure TPolygonRenderer32.SetFiller(const Value: TCustomPolygonFiller);
  1571. begin
  1572. if FFiller <> Value then
  1573. begin
  1574. FFiller := Value;
  1575. Changed;
  1576. end;
  1577. end;
  1578. procedure TPolygonRenderer32.SetFillMode(const Value: TPolyFillMode);
  1579. begin
  1580. if FFillMode <> Value then
  1581. begin
  1582. FFillMode := Value;
  1583. Changed;
  1584. end;
  1585. end;
  1586. { TPolygonRenderer32VPR }
  1587. {$IFDEF USESTACKALLOC}
  1588. {$W+}
  1589. {$ENDIF}
  1590. procedure TPolygonRenderer32VPR.FillSpan(const Span: TValueSpan; DstY: Integer);
  1591. var
  1592. AlphaValues: PColor32Array;
  1593. Count: Integer;
  1594. begin
  1595. Count := Span.X2 - Span.X1 + 1;
  1596. {$IFDEF USESTACKALLOC}
  1597. AlphaValues := StackAlloc(Count * SizeOf(TColor32));
  1598. {$ELSE}
  1599. GetMem(AlphaValues, Count * SizeOf(TColor32));
  1600. {$ENDIF}
  1601. FFillProc(Span.Values, AlphaValues, Count, FColor);
  1602. FFiller.FillLine(@Bitmap.ScanLine[DstY][Span.X1], Span.X1, DstY, Count,
  1603. PColor32(AlphaValues), Bitmap.CombineMode);
  1604. EMMS;
  1605. {$IFDEF USESTACKALLOC}
  1606. StackFree(AlphaValues);
  1607. {$ELSE}
  1608. FreeMem(AlphaValues);
  1609. {$ENDIF}
  1610. end;
  1611. {$IFDEF USESTACKALLOC}
  1612. {$W-}
  1613. {$ENDIF}
  1614. function TPolygonRenderer32VPR.GetRenderSpan: TRenderSpanEvent;
  1615. begin
  1616. if Assigned(FFiller) then
  1617. Result := FillSpan
  1618. else
  1619. Result := RenderSpan;
  1620. end;
  1621. procedure TPolygonRenderer32VPR.PolyPolygonFS(
  1622. const Points: TArrayOfArrayOfFloatPoint; const ClipRect: TFloatRect);
  1623. {$IFDEF CHANGENOTIFICATIONS}
  1624. var
  1625. I: Integer;
  1626. {$ENDIF}
  1627. begin
  1628. UpdateFillProcs;
  1629. if Assigned(FFiller) then
  1630. begin
  1631. FFiller.BeginRendering;
  1632. RenderPolyPolygon(Points, ClipRect, GetRenderSpan());
  1633. FFiller.EndRendering;
  1634. end
  1635. else
  1636. RenderPolyPolygon(Points, ClipRect, GetRenderSpan());
  1637. {$IFDEF CHANGENOTIFICATIONS}
  1638. if TBitmap32Access(Bitmap).UpdateCount = 0 then
  1639. for I := 0 to High(Points) do
  1640. if Length(Points[I]) > 0 then
  1641. Bitmap.Changed(MakeRect(PolygonBounds(Points[I])));
  1642. {$ENDIF}
  1643. end;
  1644. {$W+}
  1645. procedure TPolygonRenderer32VPR.RenderSpan(const Span: TValueSpan;
  1646. DstY: Integer);
  1647. var
  1648. AlphaValues: PColor32Array;
  1649. Count: Integer;
  1650. begin
  1651. Count := Span.X2 - Span.X1 + 1;
  1652. {$IFDEF USESTACKALLOC}
  1653. AlphaValues := StackAlloc(Count * SizeOf(TColor32));
  1654. {$ELSE}
  1655. GetMem(AlphaValues, Count * SizeOf(TColor32));
  1656. {$ENDIF}
  1657. FFillProc(Span.Values, AlphaValues, Count, FColor);
  1658. if Bitmap.CombineMode = cmMerge then
  1659. MergeLine(@AlphaValues[0], @Bitmap.ScanLine[DstY][Span.X1], Count)
  1660. else
  1661. BlendLine(@AlphaValues[0], @Bitmap.ScanLine[DstY][Span.X1], Count);
  1662. EMMS;
  1663. {$IFDEF USESTACKALLOC}
  1664. StackFree(AlphaValues);
  1665. {$ELSE}
  1666. FreeMem(AlphaValues);
  1667. {$ENDIF}
  1668. end;
  1669. {$W-}
  1670. procedure TPolygonRenderer32VPR.UpdateFillProcs;
  1671. const
  1672. FillProcs: array [Boolean, TPolyFillMode] of TFillProc = (
  1673. (MakeAlphaEvenOddUP, MakeAlphaNonZeroUP),
  1674. (MakeAlphaEvenOddUPF, MakeAlphaNonZeroUPF)
  1675. );
  1676. begin
  1677. FFillProc := FillProcs[Assigned(FFiller), FillMode];
  1678. end;
  1679. { TPolygonRenderer32LCD }
  1680. procedure TPolygonRenderer32LCD.PolyPolygonFS(
  1681. const Points: TArrayOfArrayOfFloatPoint; const ClipRect: TFloatRect);
  1682. var
  1683. R: TFloatRect;
  1684. APoints: TArrayOfArrayOfFloatPoint;
  1685. {$IFDEF CHANGENOTIFICATIONS}
  1686. I: Integer;
  1687. {$ENDIF}
  1688. begin
  1689. APoints := ScalePolyPolygon(Points, 3, 1);
  1690. R.Top := ClipRect.Top;
  1691. R.Bottom := ClipRect.Bottom;
  1692. R.Left := ClipRect.Left * 3;
  1693. R.Right := ClipRect.Right * 3;
  1694. RenderPolyPolygon(APoints, R, RenderSpan);
  1695. {$IFDEF CHANGENOTIFICATIONS}
  1696. if TBitmap32Access(Bitmap).UpdateCount = 0 then
  1697. for I := 0 to High(Points) do
  1698. if length(Points[I]) > 0 then
  1699. Bitmap.Changed(MakeRect(PolygonBounds(Points[I])));
  1700. {$ENDIF}
  1701. end;
  1702. {$W+}
  1703. procedure TPolygonRenderer32LCD.RenderSpan(const Span: TValueSpan;
  1704. DstY: Integer);
  1705. const
  1706. PADDING = 5;
  1707. var
  1708. AlphaValues: SysUtils.PByteArray;
  1709. Count: Integer;
  1710. X1, Offset: Integer;
  1711. const
  1712. MakeAlpha: array [TPolyFillMode] of TMakeAlphaProcLCD = (MakeAlphaEvenOddLCD, MakeAlphaNonZeroLCD);
  1713. begin
  1714. Count := Span.X2 - Span.X1 + 1;
  1715. X1 := DivMod(Span.X1, 3, Offset);
  1716. // Left Padding + Right Padding + Filter Width = 2 + 2 + 2 = 6
  1717. {$IFDEF USESTACKALLOC}
  1718. AlphaValues := StackAlloc((Count + 6 + PADDING) * SizeOf(Byte));
  1719. {$ELSE}
  1720. GetMem(AlphaValues, (Count + 6 + PADDING) * SizeOf(Byte));
  1721. {$ENDIF}
  1722. AlphaValues[0] := 0;
  1723. AlphaValues[1] := 0;
  1724. if (X1 > 0) then
  1725. begin
  1726. Dec(X1);
  1727. Inc(Offset, 3);
  1728. AlphaValues[2] := 0;
  1729. AlphaValues[3] := 0;
  1730. AlphaValues[4] := 0;
  1731. end;
  1732. MakeAlpha[FFillMode](Span.Values, PByteArray(@AlphaValues[PADDING]), Count, FColor);
  1733. CombineLineLCD(@AlphaValues[PADDING - Offset], PColor32Array(@Bitmap.ScanLine[DstY][X1]), FColor, (Count + Offset + 2) div 3);
  1734. {$IFDEF USESTACKALLOC}
  1735. StackFree(AlphaValues);
  1736. {$ELSE}
  1737. FreeMem(AlphaValues);
  1738. {$ENDIF}
  1739. end;
  1740. {$W-}
  1741. { TPolygonRenderer32LCD2 }
  1742. {$W+}
  1743. procedure TPolygonRenderer32LCD2.RenderSpan(const Span: TValueSpan;
  1744. DstY: Integer);
  1745. const
  1746. PADDING = 5;
  1747. var
  1748. AlphaValues: SysUtils.PByteArray;
  1749. Count: Integer;
  1750. X1, Offset: Integer;
  1751. const
  1752. MakeAlpha: array [TPolyFillMode] of TMakeAlphaProcLCD = (MakeAlphaEvenOddLCD2, MakeAlphaNonZeroLCD2);
  1753. begin
  1754. Count := Span.X2 - Span.X1 + 1;
  1755. X1 := DivMod(Span.X1, 3, Offset);
  1756. // Left Padding + Right Padding + Filter Width = 2 + 2 + 2 = 6
  1757. {$IFDEF USESTACKALLOC}
  1758. AlphaValues := StackAlloc((Count + 6 + PADDING) * SizeOf(Byte));
  1759. {$ELSE}
  1760. GetMem(AlphaValues, (Count + 6 + PADDING) * SizeOf(Byte));
  1761. {$ENDIF}
  1762. AlphaValues[0] := 0;
  1763. AlphaValues[1] := 0;
  1764. if (X1 > 0) then
  1765. begin
  1766. Dec(X1);
  1767. Inc(Offset, 3);
  1768. AlphaValues[2] := 0;
  1769. AlphaValues[3] := 0;
  1770. AlphaValues[4] := 0;
  1771. end;
  1772. Dec(Offset, 1);
  1773. MakeAlpha[FFillMode](Span.Values, PByteArray(@AlphaValues[PADDING]), Count, FColor);
  1774. Inc(Count);
  1775. CombineLineLCD(@AlphaValues[PADDING - Offset], PColor32Array(@Bitmap.ScanLine[DstY][X1]), FColor, (Count + Offset + 2) div 3);
  1776. {$IFDEF USESTACKALLOC}
  1777. StackFree(AlphaValues);
  1778. {$ELSE}
  1779. FreeMem(AlphaValues);
  1780. {$ENDIF}
  1781. end;
  1782. {$W-}
  1783. initialization
  1784. RegisterPolygonRenderer(TPolygonRenderer32VPR);
  1785. RegisterPolygonRenderer(TPolygonRenderer32LCD);
  1786. RegisterPolygonRenderer(TPolygonRenderer32LCD2);
  1787. finalization
  1788. PolygonRendererList.Free;
  1789. end.