pango 3.1.1-x64-mingw32 → 3.1.2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +27 -5
  3. data/ext/pango/depend +2 -2
  4. data/ext/pango/extconf.rb +32 -28
  5. data/ext/pango/pango.def +0 -16
  6. data/ext/pango/rb-pango-attr-list.c +64 -0
  7. data/ext/pango/rb-pango-attribute.c +147 -0
  8. data/ext/pango/rb-pango-context.c +79 -0
  9. data/ext/pango/{rbpangoconversions.h → rb-pango-conversions.h} +4 -6
  10. data/ext/pango/rb-pango-private.h +27 -0
  11. data/ext/pango/rb-pango.c +32 -0
  12. data/ext/pango/rb-pango.h +29 -0
  13. data/extconf.rb +25 -9
  14. data/lib/2.2/pango.so +0 -0
  15. data/lib/2.3/pango.so +0 -0
  16. data/lib/2.4/pango.so +0 -0
  17. data/lib/pango.rb +24 -68
  18. data/lib/pango/cairo-loader.rb +63 -0
  19. data/lib/pango/color.rb +31 -0
  20. data/lib/pango/deprecated.rb +37 -0
  21. data/lib/pango/font-description.rb +29 -0
  22. data/lib/pango/language.rb +29 -0
  23. data/lib/pango/layout.rb +41 -0
  24. data/lib/pango/loader.rb +87 -0
  25. data/lib/pango/markup.rb +31 -0
  26. data/lib/pango/matrix.rb +64 -0
  27. data/lib/pango/rectangle.rb +28 -0
  28. data/lib/pango/version.rb +30 -0
  29. data/test/pango-test-utils.rb +7 -7
  30. data/test/run-test.rb +34 -8
  31. data/test/test-attr-list.rb +28 -0
  32. data/test/test-color.rb +1 -3
  33. data/test/test-context.rb +4 -4
  34. data/test/test-enum.rb +37 -0
  35. data/test/test-font-description.rb +31 -0
  36. data/test/test-language.rb +2 -1
  37. data/test/test-layout.rb +12 -0
  38. data/test/test-markup.rb +30 -0
  39. data/test/test-matrix.rb +131 -5
  40. data/test/test-rectangle.rb +16 -3
  41. data/vendor/local/bin/derb.exe +0 -0
  42. data/vendor/local/bin/genbrk.exe +0 -0
  43. data/vendor/local/bin/genccode.exe +0 -0
  44. data/vendor/local/bin/gencfu.exe +0 -0
  45. data/vendor/local/bin/gencmn.exe +0 -0
  46. data/vendor/local/bin/gencnval.exe +0 -0
  47. data/vendor/local/bin/gendict.exe +0 -0
  48. data/vendor/local/bin/gennorm2.exe +0 -0
  49. data/vendor/local/bin/genrb.exe +0 -0
  50. data/vendor/local/bin/gensprep.exe +0 -0
  51. data/vendor/local/bin/hb-ot-shape-closure.exe +0 -0
  52. data/vendor/local/bin/hb-shape.exe +0 -0
  53. data/vendor/local/bin/hb-view.exe +0 -0
  54. data/vendor/local/bin/icuinfo.exe +0 -0
  55. data/vendor/local/bin/icupkg.exe +0 -0
  56. data/vendor/local/bin/libgraphene-1.0-0.dll +0 -0
  57. data/vendor/local/bin/libharfbuzz-0.dll +0 -0
  58. data/vendor/local/bin/libpango-1.0-0.dll +0 -0
  59. data/vendor/local/bin/libpangocairo-1.0-0.dll +0 -0
  60. data/vendor/local/bin/libpangoft2-1.0-0.dll +0 -0
  61. data/vendor/local/bin/libpangowin32-1.0-0.dll +0 -0
  62. data/vendor/local/bin/makeconv.exe +0 -0
  63. data/vendor/local/bin/pango-view.exe +0 -0
  64. data/vendor/local/bin/pkgdata.exe +0 -0
  65. data/vendor/local/bin/uconv.exe +0 -0
  66. data/vendor/local/include/graphene-1.0/graphene-box.h +148 -0
  67. data/vendor/local/include/graphene-1.0/graphene-euler.h +140 -0
  68. data/vendor/local/include/graphene-1.0/graphene-frustum.h +93 -0
  69. data/vendor/local/include/graphene-1.0/graphene-gobject.h +119 -0
  70. data/vendor/local/include/graphene-1.0/graphene-macros.h +105 -0
  71. data/vendor/local/include/graphene-1.0/graphene-matrix.h +288 -0
  72. data/vendor/local/include/graphene-1.0/graphene-plane.h +99 -0
  73. data/vendor/local/include/graphene-1.0/graphene-point.h +120 -0
  74. data/vendor/local/include/graphene-1.0/graphene-point3d.h +140 -0
  75. data/vendor/local/include/graphene-1.0/graphene-quad.h +80 -0
  76. data/vendor/local/include/graphene-1.0/graphene-quaternion.h +136 -0
  77. data/vendor/local/include/graphene-1.0/graphene-ray.h +98 -0
  78. data/vendor/local/include/graphene-1.0/graphene-rect.h +180 -0
  79. data/vendor/local/include/graphene-1.0/graphene-simd4f.h +1870 -0
  80. data/vendor/local/include/graphene-1.0/graphene-simd4x4f.h +1045 -0
  81. data/vendor/local/include/graphene-1.0/graphene-size.h +105 -0
  82. data/vendor/local/include/graphene-1.0/graphene-sphere.h +97 -0
  83. data/vendor/local/include/graphene-1.0/graphene-triangle.h +105 -0
  84. data/vendor/local/include/graphene-1.0/graphene-types.h +88 -0
  85. data/vendor/local/include/graphene-1.0/graphene-vec2.h +130 -0
  86. data/vendor/local/include/graphene-1.0/graphene-vec3.h +155 -0
  87. data/vendor/local/include/graphene-1.0/graphene-vec4.h +156 -0
  88. data/vendor/local/include/graphene-1.0/graphene-version-macros.h +185 -0
  89. data/vendor/local/include/graphene-1.0/graphene-version.h +70 -0
  90. data/vendor/local/include/graphene-1.0/graphene.h +61 -0
  91. data/vendor/local/include/harfbuzz/hb-common.h +36 -0
  92. data/vendor/local/include/harfbuzz/hb-font.h +18 -1
  93. data/vendor/local/include/harfbuzz/hb-ot-var.h +105 -0
  94. data/vendor/local/include/harfbuzz/hb-ot.h +1 -0
  95. data/vendor/local/include/harfbuzz/hb-shape.h +0 -16
  96. data/vendor/local/include/harfbuzz/hb-version.h +2 -2
  97. data/vendor/local/include/pango-1.0/pango/pango-engine.h +6 -6
  98. data/vendor/local/include/pango-1.0/pango/pango-features.h +2 -2
  99. data/vendor/local/include/pango-1.0/pango/pango-layout.h +1 -1
  100. data/vendor/local/lib/girepository-1.0/Graphene-1.0.typelib +0 -0
  101. data/vendor/local/lib/girepository-1.0/Pango-1.0.typelib +0 -0
  102. data/vendor/local/lib/graphene-1.0/include/graphene-config.h +89 -0
  103. data/vendor/local/lib/icudt.dll +0 -0
  104. data/vendor/local/lib/icudt58.dll +0 -0
  105. data/vendor/local/lib/icuin.dll +0 -0
  106. data/vendor/local/lib/icuin58.dll +0 -0
  107. data/vendor/local/lib/icuio.dll +0 -0
  108. data/vendor/local/lib/icuio58.dll +0 -0
  109. data/vendor/local/lib/icutest.dll +0 -0
  110. data/vendor/local/lib/icutest58.dll +0 -0
  111. data/vendor/local/lib/icutu.dll +0 -0
  112. data/vendor/local/lib/icutu58.dll +0 -0
  113. data/vendor/local/lib/icuuc.dll +0 -0
  114. data/vendor/local/lib/icuuc58.dll +0 -0
  115. data/vendor/local/lib/libgraphene-1.0.dll.a +0 -0
  116. data/vendor/local/lib/libgraphene-1.0.la +41 -0
  117. data/vendor/local/lib/libharfbuzz-icu.a +0 -0
  118. data/vendor/local/lib/libharfbuzz-icu.la +1 -1
  119. data/vendor/local/lib/libharfbuzz.dll.a +0 -0
  120. data/vendor/local/lib/libharfbuzz.la +1 -1
  121. data/vendor/local/lib/libicudt.dll.a +0 -0
  122. data/vendor/local/lib/libicuin.dll.a +0 -0
  123. data/vendor/local/lib/libicuio.dll.a +0 -0
  124. data/vendor/local/lib/libicutest.dll.a +0 -0
  125. data/vendor/local/lib/libicutu.dll.a +0 -0
  126. data/vendor/local/lib/libicuuc.dll.a +0 -0
  127. data/vendor/local/lib/libpango-1.0.dll.a +0 -0
  128. data/vendor/local/lib/libpango-1.0.la +1 -1
  129. data/vendor/local/lib/libpangocairo-1.0.dll.a +0 -0
  130. data/vendor/local/lib/libpangocairo-1.0.la +1 -1
  131. data/vendor/local/lib/libpangoft2-1.0.dll.a +0 -0
  132. data/vendor/local/lib/libpangoft2-1.0.la +1 -1
  133. data/vendor/local/lib/libpangowin32-1.0.dll.a +0 -0
  134. data/vendor/local/lib/libpangowin32-1.0.la +1 -1
  135. data/vendor/local/lib/pkgconfig/graphene-1.0.pc +15 -0
  136. data/vendor/local/lib/pkgconfig/graphene-gobject-1.0.pc +15 -0
  137. data/vendor/local/lib/pkgconfig/harfbuzz-icu.pc +1 -1
  138. data/vendor/local/lib/pkgconfig/harfbuzz.pc +1 -1
  139. data/vendor/local/lib/pkgconfig/pango.pc +1 -1
  140. data/vendor/local/lib/pkgconfig/pangocairo.pc +1 -1
  141. data/vendor/local/lib/pkgconfig/pangoft2.pc +1 -1
  142. data/vendor/local/lib/pkgconfig/pangowin32.pc +1 -1
  143. data/vendor/local/share/gir-1.0/Graphene-1.0.gir +8180 -0
  144. data/vendor/local/share/gir-1.0/Pango-1.0.gir +12 -16
  145. data/vendor/local/share/gtk-doc/html/graphene/annotation-glossary.html +57 -0
  146. data/vendor/local/share/gtk-doc/html/graphene/api-index.html +1985 -0
  147. data/vendor/local/share/gtk-doc/html/graphene/ch01.html +97 -0
  148. data/vendor/local/share/gtk-doc/html/graphene/deprecated-api-index.html +34 -0
  149. data/vendor/local/share/gtk-doc/html/graphene/graphene-Box.html +1252 -0
  150. data/vendor/local/share/gtk-doc/html/graphene/graphene-Euler.html +886 -0
  151. data/vendor/local/share/gtk-doc/html/graphene/graphene-Frustum.html +527 -0
  152. data/vendor/local/share/gtk-doc/html/graphene/graphene-GObject-integration.html +147 -0
  153. data/vendor/local/share/gtk-doc/html/graphene/graphene-Matrix.html +2959 -0
  154. data/vendor/local/share/gtk-doc/html/graphene/graphene-Plane.html +641 -0
  155. data/vendor/local/share/gtk-doc/html/graphene/graphene-Point.html +689 -0
  156. data/vendor/local/share/gtk-doc/html/graphene/graphene-Point3D.html +916 -0
  157. data/vendor/local/share/gtk-doc/html/graphene/graphene-Quad.html +418 -0
  158. data/vendor/local/share/gtk-doc/html/graphene/graphene-Quaternion.html +1056 -0
  159. data/vendor/local/share/gtk-doc/html/graphene/graphene-Ray.html +596 -0
  160. data/vendor/local/share/gtk-doc/html/graphene/graphene-Rectangle.html +1483 -0
  161. data/vendor/local/share/gtk-doc/html/graphene/graphene-SIMD-matrix.html +1475 -0
  162. data/vendor/local/share/gtk-doc/html/graphene/graphene-SIMD-vector.html +3046 -0
  163. data/vendor/local/share/gtk-doc/html/graphene/graphene-Size.html +489 -0
  164. data/vendor/local/share/gtk-doc/html/graphene/graphene-Sphere.html +641 -0
  165. data/vendor/local/share/gtk-doc/html/graphene/graphene-Triangle.html +705 -0
  166. data/vendor/local/share/gtk-doc/html/graphene/graphene-Vectors.html +3715 -0
  167. data/vendor/local/share/gtk-doc/html/graphene/graphene-Versioning-information.html +104 -0
  168. data/vendor/local/share/gtk-doc/html/graphene/graphene.devhelp2 +534 -0
  169. data/vendor/local/share/gtk-doc/html/graphene/home.png +0 -0
  170. data/vendor/local/share/gtk-doc/html/graphene/index.html +107 -0
  171. data/vendor/local/share/gtk-doc/html/graphene/ix03.html +1313 -0
  172. data/vendor/local/share/gtk-doc/html/graphene/ix04.html +582 -0
  173. data/vendor/local/share/gtk-doc/html/graphene/ix05.html +151 -0
  174. data/vendor/local/share/gtk-doc/html/graphene/ix06.html +34 -0
  175. data/vendor/local/share/gtk-doc/html/graphene/left-insensitive.png +0 -0
  176. data/vendor/local/share/gtk-doc/html/graphene/left.png +0 -0
  177. data/vendor/local/share/gtk-doc/html/{pango/api-index-1-40.html → graphene/object-tree.html} +14 -11
  178. data/vendor/local/share/gtk-doc/html/graphene/rectangle-intersection.png +0 -0
  179. data/vendor/local/share/gtk-doc/html/graphene/rectangle-union.png +0 -0
  180. data/vendor/local/share/gtk-doc/html/graphene/rectangle.png +0 -0
  181. data/vendor/local/share/gtk-doc/html/graphene/right-insensitive.png +0 -0
  182. data/vendor/local/share/gtk-doc/html/graphene/right.png +0 -0
  183. data/vendor/local/share/gtk-doc/html/graphene/style.css +479 -0
  184. data/vendor/local/share/gtk-doc/html/graphene/triangle-barycentric.png +0 -0
  185. data/vendor/local/share/gtk-doc/html/graphene/up-insensitive.png +0 -0
  186. data/vendor/local/share/gtk-doc/html/graphene/up.png +0 -0
  187. data/vendor/local/share/gtk-doc/html/harfbuzz/api-index-1-2-3.html +2 -2
  188. data/vendor/local/share/gtk-doc/html/harfbuzz/{api-index-1-4-0.html → api-index-1-3-3.html} +2 -2
  189. data/vendor/local/share/gtk-doc/html/harfbuzz/api-index-full.html +104 -0
  190. data/vendor/local/share/gtk-doc/html/harfbuzz/deprecated-api-index.html +9 -2
  191. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-Shaping.html +1 -1
  192. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-font.html +156 -40
  193. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-gobject.html +73 -0
  194. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-graphite2.html +1 -0
  195. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-ot-layout.html +49 -0
  196. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-ot-math.html +174 -177
  197. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-shape-plan.html +40 -0
  198. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-version.html +2 -2
  199. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz.devhelp2 +28 -10
  200. data/vendor/local/share/gtk-doc/html/harfbuzz/index.html +1 -1
  201. data/vendor/local/share/gtk-doc/html/harfbuzz/pt02.html +2 -2
  202. data/vendor/local/share/gtk-doc/html/pango/PangoEngineLang.html +2 -2
  203. data/vendor/local/share/gtk-doc/html/pango/PangoEngineShape.html +2 -2
  204. data/vendor/local/share/gtk-doc/html/pango/PangoFcDecoder.html +1 -1
  205. data/vendor/local/share/gtk-doc/html/pango/PangoFcFont.html +1 -1
  206. data/vendor/local/share/gtk-doc/html/pango/PangoFcFontMap.html +3 -3
  207. data/vendor/local/share/gtk-doc/html/pango/PangoMarkupFormat.html +1 -1
  208. data/vendor/local/share/gtk-doc/html/pango/PangoRenderer.html +2 -2
  209. data/vendor/local/share/gtk-doc/html/pango/annotation-glossary.html +1 -1
  210. data/vendor/local/share/gtk-doc/html/pango/api-index-full.html +1 -1
  211. data/vendor/local/share/gtk-doc/html/pango/index.html +2 -23
  212. data/vendor/local/share/gtk-doc/html/pango/lowlevel.html +1 -1
  213. data/vendor/local/share/gtk-doc/html/pango/pango-Bidirectional-Text.html +1 -1
  214. data/vendor/local/share/gtk-doc/html/pango/pango-Cairo-Rendering.html +69 -69
  215. data/vendor/local/share/gtk-doc/html/pango/pango-CoreText-Fonts.html +1 -1
  216. data/vendor/local/share/gtk-doc/html/pango/pango-Coverage-Maps.html +1 -1
  217. data/vendor/local/share/gtk-doc/html/pango/pango-Engines.html +5 -1
  218. data/vendor/local/share/gtk-doc/html/pango/pango-Fonts.html +5 -4
  219. data/vendor/local/share/gtk-doc/html/pango/pango-FreeType-Fonts-and-Rendering.html +8 -4
  220. data/vendor/local/share/gtk-doc/html/pango/pango-Glyph-Storage.html +3 -3
  221. data/vendor/local/share/gtk-doc/html/pango/pango-Layout-Objects.html +4 -4
  222. data/vendor/local/share/gtk-doc/html/pango/pango-Miscellaneous-Utilities.html +1 -1
  223. data/vendor/local/share/gtk-doc/html/pango/pango-Modules.html +3 -1
  224. data/vendor/local/share/gtk-doc/html/pango/pango-OpenType-Font-Handling.html +1 -1
  225. data/vendor/local/share/gtk-doc/html/pango/pango-Scripts-and-Languages.html +3 -3
  226. data/vendor/local/share/gtk-doc/html/pango/pango-Tab-Stops.html +1 -1
  227. data/vendor/local/share/gtk-doc/html/pango/pango-Text-Attributes.html +1 -1
  228. data/vendor/local/share/gtk-doc/html/pango/pango-Text-Processing.html +3 -3
  229. data/vendor/local/share/gtk-doc/html/pango/pango-Version-Checking.html +3 -3
  230. data/vendor/local/share/gtk-doc/html/pango/pango-Vertical-Text.html +1 -1
  231. data/vendor/local/share/gtk-doc/html/pango/pango-Win32-Fonts-and-Rendering.html +3 -3
  232. data/vendor/local/share/gtk-doc/html/pango/pango-Xft-Fonts-and-Rendering.html +1 -1
  233. data/vendor/local/share/gtk-doc/html/pango/pango-hierarchy.html +1 -1
  234. data/vendor/local/share/gtk-doc/html/pango/pango.html +1 -1
  235. data/vendor/local/share/gtk-doc/html/pango/rendering.html +1 -1
  236. data/vendor/local/share/man/man1/pango-view.1 +2 -2
  237. metadata +119 -78
  238. data/README +0 -32
  239. data/ext/pango/rbpango.c +0 -356
  240. data/ext/pango/rbpango.h +0 -95
  241. data/ext/pango/rbpangoanalysis.c +0 -218
  242. data/ext/pango/rbpangoattribute.c +0 -506
  243. data/ext/pango/rbpangoattriterator.c +0 -141
  244. data/ext/pango/rbpangoattrlist.c +0 -101
  245. data/ext/pango/rbpangocairo.c +0 -122
  246. data/ext/pango/rbpangocairocontext.c +0 -131
  247. data/ext/pango/rbpangocolor.c +0 -120
  248. data/ext/pango/rbpangocontext.c +0 -344
  249. data/ext/pango/rbpangocoverage.c +0 -106
  250. data/ext/pango/rbpangoengine.c +0 -73
  251. data/ext/pango/rbpangofont.c +0 -110
  252. data/ext/pango/rbpangofontdescription.c +0 -282
  253. data/ext/pango/rbpangofontface.c +0 -73
  254. data/ext/pango/rbpangofontfamily.c +0 -79
  255. data/ext/pango/rbpangofontmap.c +0 -102
  256. data/ext/pango/rbpangofontmetrics.c +0 -85
  257. data/ext/pango/rbpangofontset.c +0 -69
  258. data/ext/pango/rbpangofontsetsimple.c +0 -60
  259. data/ext/pango/rbpangoglyphinfo.c +0 -123
  260. data/ext/pango/rbpangoglyphitem.c +0 -125
  261. data/ext/pango/rbpangoglyphstring.c +0 -151
  262. data/ext/pango/rbpangogravity.c +0 -54
  263. data/ext/pango/rbpangoitem.c +0 -95
  264. data/ext/pango/rbpangolanguage.c +0 -94
  265. data/ext/pango/rbpangolayout.c +0 -583
  266. data/ext/pango/rbpangolayoutiter.c +0 -189
  267. data/ext/pango/rbpangolayoutline.c +0 -243
  268. data/ext/pango/rbpangologattr.c +0 -109
  269. data/ext/pango/rbpangomatrix.c +0 -143
  270. data/ext/pango/rbpangoprivate.h +0 -49
  271. data/ext/pango/rbpangorectangle.c +0 -170
  272. data/ext/pango/rbpangorenderer.c +0 -193
  273. data/ext/pango/rbpangoscript.c +0 -84
  274. data/ext/pango/rbpangoscriptiter.c +0 -92
  275. data/ext/pango/rbpangotabarray.c +0 -128
  276. data/sample/attribute.rb +0 -82
  277. data/sample/break.rb +0 -28
  278. data/sample/gdk_layout.rb +0 -27
  279. data/sample/glyphstring.rb +0 -61
  280. data/sample/item.rb +0 -37
  281. data/sample/label.rb +0 -23
  282. data/sample/layout.rb +0 -102
  283. data/sample/pango_cairo.rb +0 -66
  284. data/sample/parse.rb +0 -33
  285. data/sample/sample.txt +0 -10
  286. data/sample/script.rb +0 -23
  287. data/vendor/local/share/gtk-doc/html/pango/api-index-1-10.html +0 -134
  288. data/vendor/local/share/gtk-doc/html/pango/api-index-1-12.html +0 -48
  289. data/vendor/local/share/gtk-doc/html/pango/api-index-1-14.html +0 -63
  290. data/vendor/local/share/gtk-doc/html/pango/api-index-1-16.html +0 -227
  291. data/vendor/local/share/gtk-doc/html/pango/api-index-1-18.html +0 -151
  292. data/vendor/local/share/gtk-doc/html/pango/api-index-1-2.html +0 -121
  293. data/vendor/local/share/gtk-doc/html/pango/api-index-1-20.html +0 -86
  294. data/vendor/local/share/gtk-doc/html/pango/api-index-1-22.html +0 -123
  295. data/vendor/local/share/gtk-doc/html/pango/api-index-1-24.html +0 -96
  296. data/vendor/local/share/gtk-doc/html/pango/api-index-1-26.html +0 -45
  297. data/vendor/local/share/gtk-doc/html/pango/api-index-1-30.html +0 -38
  298. data/vendor/local/share/gtk-doc/html/pango/api-index-1-31-0.html +0 -38
  299. data/vendor/local/share/gtk-doc/html/pango/api-index-1-32-4.html +0 -52
  300. data/vendor/local/share/gtk-doc/html/pango/api-index-1-32.html +0 -41
  301. data/vendor/local/share/gtk-doc/html/pango/api-index-1-34.html +0 -38
  302. data/vendor/local/share/gtk-doc/html/pango/api-index-1-38.html +0 -79
  303. data/vendor/local/share/gtk-doc/html/pango/api-index-1-4.html +0 -200
  304. data/vendor/local/share/gtk-doc/html/pango/api-index-1-6.html +0 -164
  305. data/vendor/local/share/gtk-doc/html/pango/api-index-1-8.html +0 -170
  306. data/vendor/local/share/gtk-doc/html/pango/api-index-deprecated.html +0 -441
@@ -0,0 +1,180 @@
1
+ /* graphene-rect.h: Rectangular type
2
+ *
3
+ * Copyright 2014 Emmanuele Bassi
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
22
+ */
23
+
24
+ #ifndef __GRAPHENE_RECT_H__
25
+ #define __GRAPHENE_RECT_H__
26
+
27
+ #if !defined(GRAPHENE_H_INSIDE) && !defined(GRAPHENE_COMPILATION)
28
+ #error "Only graphene.h can be included directly."
29
+ #endif
30
+
31
+ #include "graphene-types.h"
32
+ #include "graphene-point.h"
33
+ #include "graphene-size.h"
34
+ #include "graphene-vec2.h"
35
+
36
+ GRAPHENE_BEGIN_DECLS
37
+
38
+ /**
39
+ * GRAPHENE_RECT_INIT:
40
+ * @_x: the X coordinate of the origin
41
+ * @_y: the Y coordinate of the origin
42
+ * @_w: the width
43
+ * @_h: the height
44
+ *
45
+ * Initializes a #graphene_rect_t when declaring it.
46
+ *
47
+ * Since: 1.0
48
+ */
49
+ #define GRAPHENE_RECT_INIT(_x,_y,_w,_h) \
50
+ (graphene_rect_t) { .origin = { .x = (_x), .y = (_y) }, .size = { .width = (_w), .height = (_h) } }
51
+
52
+ /**
53
+ * graphene_rect_t:
54
+ * @origin: the coordinates of the origin of the rectangle
55
+ * @size: the size of the rectangle
56
+ *
57
+ * The location and size of a rectangle region.
58
+ *
59
+ * The width and height of a #graphene_rect_t can be negative; for instance,
60
+ * a #graphene_rect_t with an origin of [ 0, 0 ] and a size of [ 10, 10 ] is
61
+ * equivalent to a #graphene_rect_t with an origin of [ 10, 10 ] and a size
62
+ * of [ -10, -10 ].
63
+ *
64
+ * Application code can normalize rectangles using graphene_rect_normalize();
65
+ * this function will ensure that the width and height of a rectangle are
66
+ * positive values. All functions taking a #graphene_rect_t as an argument
67
+ * will internally operate on a normalized copy; all functions returning a
68
+ * #graphene_rect_t will always return a normalized rectangle.
69
+ *
70
+ * Since: 1.0
71
+ */
72
+ struct _graphene_rect_t
73
+ {
74
+ graphene_point_t origin;
75
+ graphene_size_t size;
76
+ };
77
+
78
+ GRAPHENE_AVAILABLE_IN_1_0
79
+ graphene_rect_t * graphene_rect_alloc (void);
80
+ GRAPHENE_AVAILABLE_IN_1_0
81
+ void graphene_rect_free (graphene_rect_t *r);
82
+ GRAPHENE_AVAILABLE_IN_1_0
83
+ graphene_rect_t * graphene_rect_init (graphene_rect_t *r,
84
+ float x,
85
+ float y,
86
+ float width,
87
+ float height);
88
+ GRAPHENE_AVAILABLE_IN_1_0
89
+ graphene_rect_t * graphene_rect_init_from_rect (graphene_rect_t *r,
90
+ const graphene_rect_t *src);
91
+
92
+ GRAPHENE_AVAILABLE_IN_1_0
93
+ bool graphene_rect_equal (const graphene_rect_t *a,
94
+ const graphene_rect_t *b);
95
+ GRAPHENE_AVAILABLE_IN_1_0
96
+ graphene_rect_t * graphene_rect_normalize (graphene_rect_t *r);
97
+ GRAPHENE_AVAILABLE_IN_1_4
98
+ void graphene_rect_normalize_r (const graphene_rect_t *r,
99
+ graphene_rect_t *res);
100
+ GRAPHENE_AVAILABLE_IN_1_0
101
+ void graphene_rect_get_center (const graphene_rect_t *r,
102
+ graphene_point_t *p);
103
+ GRAPHENE_AVAILABLE_IN_1_0
104
+ void graphene_rect_get_top_left (const graphene_rect_t *r,
105
+ graphene_point_t *p);
106
+ GRAPHENE_AVAILABLE_IN_1_0
107
+ void graphene_rect_get_top_right (const graphene_rect_t *r,
108
+ graphene_point_t *p);
109
+ GRAPHENE_AVAILABLE_IN_1_0
110
+ void graphene_rect_get_bottom_right (const graphene_rect_t *r,
111
+ graphene_point_t *p);
112
+ GRAPHENE_AVAILABLE_IN_1_0
113
+ void graphene_rect_get_bottom_left (const graphene_rect_t *r,
114
+ graphene_point_t *p);
115
+ GRAPHENE_AVAILABLE_IN_1_4
116
+ void graphene_rect_get_vertices (const graphene_rect_t *r,
117
+ graphene_vec2_t vertices[]);
118
+ GRAPHENE_AVAILABLE_IN_1_0
119
+ float graphene_rect_get_x (const graphene_rect_t *r);
120
+ GRAPHENE_AVAILABLE_IN_1_0
121
+ float graphene_rect_get_y (const graphene_rect_t *r);
122
+ GRAPHENE_AVAILABLE_IN_1_0
123
+ float graphene_rect_get_width (const graphene_rect_t *r);
124
+ GRAPHENE_AVAILABLE_IN_1_0
125
+ float graphene_rect_get_height (const graphene_rect_t *r);
126
+
127
+ GRAPHENE_AVAILABLE_IN_1_0
128
+ void graphene_rect_union (const graphene_rect_t *a,
129
+ const graphene_rect_t *b,
130
+ graphene_rect_t *res);
131
+ GRAPHENE_AVAILABLE_IN_1_0
132
+ bool graphene_rect_intersection (const graphene_rect_t *a,
133
+ const graphene_rect_t *b,
134
+ graphene_rect_t *res);
135
+ GRAPHENE_AVAILABLE_IN_1_0
136
+ bool graphene_rect_contains_point (const graphene_rect_t *r,
137
+ const graphene_point_t *p);
138
+ GRAPHENE_AVAILABLE_IN_1_0
139
+ bool graphene_rect_contains_rect (const graphene_rect_t *a,
140
+ const graphene_rect_t *b);
141
+ GRAPHENE_AVAILABLE_IN_1_0
142
+ graphene_rect_t * graphene_rect_offset (graphene_rect_t *r,
143
+ float d_x,
144
+ float d_y);
145
+ GRAPHENE_AVAILABLE_IN_1_4
146
+ void graphene_rect_offset_r (const graphene_rect_t *r,
147
+ float d_x,
148
+ float d_y,
149
+ graphene_rect_t *res);
150
+ GRAPHENE_AVAILABLE_IN_1_0
151
+ graphene_rect_t * graphene_rect_inset (graphene_rect_t *r,
152
+ float d_x,
153
+ float d_y);
154
+ GRAPHENE_AVAILABLE_IN_1_4
155
+ void graphene_rect_inset_r (const graphene_rect_t *r,
156
+ float d_x,
157
+ float d_y,
158
+ graphene_rect_t *res);
159
+ GRAPHENE_DEPRECATED_IN_1_4_FOR (graphene_rect_round)
160
+ graphene_rect_t * graphene_rect_round_to_pixel (graphene_rect_t *r);
161
+ GRAPHENE_AVAILABLE_IN_1_4
162
+ void graphene_rect_round (const graphene_rect_t *r,
163
+ graphene_rect_t *res);
164
+ GRAPHENE_AVAILABLE_IN_1_0
165
+ void graphene_rect_interpolate (const graphene_rect_t *a,
166
+ const graphene_rect_t *b,
167
+ double factor,
168
+ graphene_rect_t *res);
169
+
170
+ GRAPHENE_AVAILABLE_IN_1_4
171
+ void graphene_rect_expand (const graphene_rect_t *r,
172
+ const graphene_point_t *p,
173
+ graphene_rect_t *res);
174
+
175
+ GRAPHENE_AVAILABLE_IN_1_4
176
+ const graphene_rect_t * graphene_rect_zero (void);
177
+
178
+ GRAPHENE_END_DECLS
179
+
180
+ #endif /* __GRAPHENE_RECT_H__ */
@@ -0,0 +1,1870 @@
1
+ /* graphene-simd4f.h: SIMD wrappers and operations
2
+ *
3
+ * Copyright 2014 Emmanuele Bassi
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SH1_0 THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
22
+ */
23
+
24
+ #ifndef __GRAPHENE_SIMD4F_H__
25
+ #define __GRAPHENE_SIMD4F_H__
26
+
27
+ #if !defined(GRAPHENE_H_INSIDE) && !defined(GRAPHENE_COMPILATION)
28
+ #error "Only graphene.h can be included directly."
29
+ #endif
30
+
31
+ /* needed for memcpy() */
32
+ #include <string.h>
33
+ #include <math.h>
34
+
35
+ #include "graphene-config.h"
36
+ #include "graphene-macros.h"
37
+ #include "graphene-version-macros.h"
38
+
39
+ GRAPHENE_BEGIN_DECLS
40
+
41
+ /* Platform specific operations */
42
+
43
+ GRAPHENE_AVAILABLE_IN_1_0
44
+ graphene_simd4f_t graphene_simd4f_init (float x,
45
+ float y,
46
+ float z,
47
+ float w);
48
+ GRAPHENE_AVAILABLE_IN_1_0
49
+ graphene_simd4f_t graphene_simd4f_init_zero (void);
50
+ GRAPHENE_AVAILABLE_IN_1_0
51
+ graphene_simd4f_t graphene_simd4f_init_4f (const float *v);
52
+ GRAPHENE_AVAILABLE_IN_1_0
53
+ graphene_simd4f_t graphene_simd4f_init_3f (const float *v);
54
+ GRAPHENE_AVAILABLE_IN_1_0
55
+ graphene_simd4f_t graphene_simd4f_init_2f (const float *v);
56
+
57
+ GRAPHENE_AVAILABLE_IN_1_0
58
+ void graphene_simd4f_dup_4f (const graphene_simd4f_t s,
59
+ float *v);
60
+ GRAPHENE_AVAILABLE_IN_1_0
61
+ void graphene_simd4f_dup_3f (const graphene_simd4f_t s,
62
+ float *v);
63
+ GRAPHENE_AVAILABLE_IN_1_0
64
+ void graphene_simd4f_dup_2f (const graphene_simd4f_t s,
65
+ float *v);
66
+
67
+ GRAPHENE_AVAILABLE_IN_1_2
68
+ float graphene_simd4f_get (const graphene_simd4f_t s,
69
+ unsigned int i);
70
+ GRAPHENE_AVAILABLE_IN_1_0
71
+ float graphene_simd4f_get_x (const graphene_simd4f_t s);
72
+ GRAPHENE_AVAILABLE_IN_1_0
73
+ float graphene_simd4f_get_y (const graphene_simd4f_t s);
74
+ GRAPHENE_AVAILABLE_IN_1_0
75
+ float graphene_simd4f_get_z (const graphene_simd4f_t s);
76
+ GRAPHENE_AVAILABLE_IN_1_0
77
+ float graphene_simd4f_get_w (const graphene_simd4f_t s);
78
+
79
+ GRAPHENE_AVAILABLE_IN_1_0
80
+ graphene_simd4f_t graphene_simd4f_splat (float v);
81
+ GRAPHENE_AVAILABLE_IN_1_0
82
+ graphene_simd4f_t graphene_simd4f_splat_x (const graphene_simd4f_t s);
83
+ GRAPHENE_AVAILABLE_IN_1_0
84
+ graphene_simd4f_t graphene_simd4f_splat_y (const graphene_simd4f_t s);
85
+ GRAPHENE_AVAILABLE_IN_1_0
86
+ graphene_simd4f_t graphene_simd4f_splat_z (const graphene_simd4f_t s);
87
+ GRAPHENE_AVAILABLE_IN_1_0
88
+ graphene_simd4f_t graphene_simd4f_splat_w (const graphene_simd4f_t s);
89
+
90
+ GRAPHENE_AVAILABLE_IN_1_0
91
+ graphene_simd4f_t graphene_simd4f_add (const graphene_simd4f_t a,
92
+ const graphene_simd4f_t b);
93
+ GRAPHENE_AVAILABLE_IN_1_0
94
+ graphene_simd4f_t graphene_simd4f_sub (const graphene_simd4f_t a,
95
+ const graphene_simd4f_t b);
96
+ GRAPHENE_AVAILABLE_IN_1_0
97
+ graphene_simd4f_t graphene_simd4f_mul (const graphene_simd4f_t a,
98
+ const graphene_simd4f_t b);
99
+ GRAPHENE_AVAILABLE_IN_1_0
100
+ graphene_simd4f_t graphene_simd4f_div (const graphene_simd4f_t a,
101
+ const graphene_simd4f_t b);
102
+
103
+ GRAPHENE_AVAILABLE_IN_1_0
104
+ graphene_simd4f_t graphene_simd4f_sqrt (const graphene_simd4f_t s);
105
+ GRAPHENE_AVAILABLE_IN_1_0
106
+ graphene_simd4f_t graphene_simd4f_reciprocal (const graphene_simd4f_t s);
107
+ GRAPHENE_AVAILABLE_IN_1_0
108
+ graphene_simd4f_t graphene_simd4f_rsqrt (const graphene_simd4f_t s);
109
+
110
+ GRAPHENE_AVAILABLE_IN_1_0
111
+ graphene_simd4f_t graphene_simd4f_cross3 (const graphene_simd4f_t a,
112
+ const graphene_simd4f_t b);
113
+ GRAPHENE_AVAILABLE_IN_1_0
114
+ graphene_simd4f_t graphene_simd4f_dot3 (const graphene_simd4f_t a,
115
+ const graphene_simd4f_t b);
116
+ GRAPHENE_AVAILABLE_IN_1_4
117
+ float graphene_simd4f_dot3_scalar (const graphene_simd4f_t a,
118
+ const graphene_simd4f_t b);
119
+
120
+ GRAPHENE_AVAILABLE_IN_1_0
121
+ graphene_simd4f_t graphene_simd4f_min (const graphene_simd4f_t a,
122
+ const graphene_simd4f_t b);
123
+ GRAPHENE_AVAILABLE_IN_1_0
124
+ graphene_simd4f_t graphene_simd4f_max (const graphene_simd4f_t a,
125
+ const graphene_simd4f_t b);
126
+
127
+ GRAPHENE_AVAILABLE_IN_1_0
128
+ graphene_simd4f_t graphene_simd4f_shuffle_wxyz (const graphene_simd4f_t s);
129
+ GRAPHENE_AVAILABLE_IN_1_0
130
+ graphene_simd4f_t graphene_simd4f_shuffle_zwxy (const graphene_simd4f_t s);
131
+ GRAPHENE_AVAILABLE_IN_1_0
132
+ graphene_simd4f_t graphene_simd4f_shuffle_yzwx (const graphene_simd4f_t s);
133
+
134
+ GRAPHENE_AVAILABLE_IN_1_0
135
+ graphene_simd4f_t graphene_simd4f_zero_w (const graphene_simd4f_t s);
136
+ GRAPHENE_AVAILABLE_IN_1_0
137
+ graphene_simd4f_t graphene_simd4f_zero_zw (const graphene_simd4f_t s);
138
+
139
+ GRAPHENE_AVAILABLE_IN_1_0
140
+ graphene_simd4f_t graphene_simd4f_merge_high (const graphene_simd4f_t a,
141
+ const graphene_simd4f_t b);
142
+ GRAPHENE_AVAILABLE_IN_1_0
143
+ graphene_simd4f_t graphene_simd4f_merge_low (const graphene_simd4f_t a,
144
+ const graphene_simd4f_t b);
145
+ GRAPHENE_AVAILABLE_IN_1_0
146
+ graphene_simd4f_t graphene_simd4f_merge_w (const graphene_simd4f_t s,
147
+ float v);
148
+
149
+ GRAPHENE_AVAILABLE_IN_1_0
150
+ graphene_simd4f_t graphene_simd4f_flip_sign_0101 (const graphene_simd4f_t s);
151
+ GRAPHENE_AVAILABLE_IN_1_0
152
+ graphene_simd4f_t graphene_simd4f_flip_sign_1010 (const graphene_simd4f_t s);
153
+
154
+ GRAPHENE_AVAILABLE_IN_1_0
155
+ bool graphene_simd4f_cmp_eq (const graphene_simd4f_t a,
156
+ const graphene_simd4f_t b);
157
+ GRAPHENE_AVAILABLE_IN_1_0
158
+ bool graphene_simd4f_cmp_neq (const graphene_simd4f_t a,
159
+ const graphene_simd4f_t b);
160
+ GRAPHENE_AVAILABLE_IN_1_2
161
+ bool graphene_simd4f_cmp_lt (const graphene_simd4f_t a,
162
+ const graphene_simd4f_t b);
163
+ GRAPHENE_AVAILABLE_IN_1_2
164
+ bool graphene_simd4f_cmp_le (const graphene_simd4f_t a,
165
+ const graphene_simd4f_t b);
166
+ GRAPHENE_AVAILABLE_IN_1_2
167
+ bool graphene_simd4f_cmp_ge (const graphene_simd4f_t a,
168
+ const graphene_simd4f_t b);
169
+ GRAPHENE_AVAILABLE_IN_1_2
170
+ bool graphene_simd4f_cmp_gt (const graphene_simd4f_t a,
171
+ const graphene_simd4f_t b);
172
+ GRAPHENE_AVAILABLE_IN_1_0
173
+ graphene_simd4f_t graphene_simd4f_neg (const graphene_simd4f_t s);
174
+
175
+ #if !defined(__GI_SCANNER__) && defined(GRAPHENE_USE_SSE)
176
+
177
+ /* SSE2 implementation of SIMD 4f */
178
+
179
+ /* Union type used to do single lane reading without memcpy */
180
+ typedef union {
181
+ graphene_simd4f_t s;
182
+ float f[4];
183
+ } graphene_simd4f_union_t;
184
+
185
+ /* On GCC, we use __extension__ macros to avoid a static inline */
186
+ # if defined(__GNUC__)
187
+
188
+ /* Use GCC statement __extension__ to inline all these functions */
189
+
190
+ # define graphene_simd4f_init(x,y,z,w) \
191
+ (__extension__ ({ \
192
+ (graphene_simd4f_t) { (x), (y), (z), (w) }; \
193
+ }))
194
+
195
+ # define graphene_simd4f_init_zero() \
196
+ (__extension__ ({ \
197
+ (graphene_simd4f_t) _mm_setzero_ps(); \
198
+ }))
199
+
200
+ # define graphene_simd4f_init_4f(v) \
201
+ (__extension__ ({ \
202
+ (graphene_simd4f_t) _mm_loadu_ps (v); \
203
+ }))
204
+
205
+ # define graphene_simd4f_init_3f(v) \
206
+ (__extension__ ({ \
207
+ (graphene_simd4f_t) { (v)[0], (v)[1], (v)[2], 0.f }; \
208
+ }))
209
+
210
+ # define graphene_simd4f_init_2f(v) \
211
+ (__extension__ ({ \
212
+ (graphene_simd4f_t) { (v)[0], (v)[1], 0.f, 0.f }; \
213
+ }))
214
+
215
+ # define graphene_simd4f_dup_4f(s,v) \
216
+ (__extension__ ({ \
217
+ _mm_storeu_ps ((v), (s)); \
218
+ }))
219
+
220
+ # define graphene_simd4f_dup_3f(s,v) \
221
+ (__extension__ ({ \
222
+ memcpy ((v), &(s), sizeof (float) * 3); \
223
+ }))
224
+
225
+ # define graphene_simd4f_dup_2f(s,v) \
226
+ (__extension__ ({ \
227
+ memcpy ((v), &(s), sizeof (float) * 2); \
228
+ }))
229
+
230
+ # define graphene_simd4f_get(s,i) \
231
+ (__extension__ ({ \
232
+ graphene_simd4f_union_t __u = { (s) }; \
233
+ (float) __u.f[(i)]; \
234
+ }))
235
+
236
+ # define graphene_simd4f_get_x(s) graphene_simd4f_get (s, 0)
237
+ # define graphene_simd4f_get_y(s) graphene_simd4f_get (s, 1)
238
+ # define graphene_simd4f_get_z(s) graphene_simd4f_get (s, 2)
239
+ # define graphene_simd4f_get_w(s) graphene_simd4f_get (s, 3)
240
+
241
+ # define graphene_simd4f_splat(v) \
242
+ (__extension__ ({ \
243
+ (graphene_simd4f_t) _mm_set1_ps ((v)); \
244
+ }))
245
+
246
+ # define graphene_simd4f_splat_x(v) \
247
+ (__extension__ ({ \
248
+ (graphene_simd4f_t) _mm_shuffle_ps ((v), (v), _MM_SHUFFLE (0, 0, 0, 0)); \
249
+ }))
250
+
251
+ # define graphene_simd4f_splat_y(v) \
252
+ (__extension__ ({ \
253
+ (graphene_simd4f_t) _mm_shuffle_ps ((v), (v), _MM_SHUFFLE (1, 1, 1, 1)); \
254
+ }))
255
+
256
+ # define graphene_simd4f_splat_z(v) \
257
+ (__extension__ ({ \
258
+ (graphene_simd4f_t) _mm_shuffle_ps ((v), (v), _MM_SHUFFLE (2, 2, 2, 2)); \
259
+ }))
260
+
261
+ # define graphene_simd4f_splat_w(v) \
262
+ (__extension__ ({ \
263
+ (graphene_simd4f_t) _mm_shuffle_ps ((v), (v), _MM_SHUFFLE (3, 3, 3, 3)); \
264
+ }))
265
+
266
+ # define graphene_simd4f_add(a,b) \
267
+ (__extension__ ({ \
268
+ (graphene_simd4f_t) _mm_add_ps ((a), (b)); \
269
+ }))
270
+
271
+ # define graphene_simd4f_sub(a,b) \
272
+ (__extension__ ({ \
273
+ (graphene_simd4f_t) _mm_sub_ps ((a), (b)); \
274
+ }))
275
+
276
+ # define graphene_simd4f_mul(a,b) \
277
+ (__extension__ ({ \
278
+ (graphene_simd4f_t) _mm_mul_ps ((a), (b)); \
279
+ }))
280
+
281
+ # define graphene_simd4f_div(a,b) \
282
+ (__extension__ ({ \
283
+ (graphene_simd4f_t) _mm_div_ps ((a), (b)); \
284
+ }))
285
+
286
+ # define graphene_simd4f_sqrt(v) \
287
+ (__extension__ ({ \
288
+ (graphene_simd4f_t) _mm_sqrt_ps ((v)); \
289
+ }))
290
+
291
+ # define graphene_simd4f_reciprocal(v) \
292
+ (__extension__ ({ \
293
+ const graphene_simd4f_t __two = graphene_simd4f_init (2.0f, 2.0f, 2.0f, 2.0f); \
294
+ graphene_simd4f_t __s = _mm_rcp_ps ((v)); \
295
+ graphene_simd4f_mul (__s, graphene_simd4f_sub (__two, graphene_simd4f_mul ((v), __s))); \
296
+ }))
297
+
298
+ # define graphene_simd4f_rsqrt(v) \
299
+ (__extension__ ({ \
300
+ const graphene_simd4f_t __half = graphene_simd4f_init (0.5f, 0.5f, 0.5f, 0.5f); \
301
+ const graphene_simd4f_t __three = graphene_simd4f_init (3.0f, 3.0f, 3.0f, 3.0f); \
302
+ graphene_simd4f_t __s = _mm_rsqrt_ps ((v)); \
303
+ graphene_simd4f_mul (graphene_simd4f_mul (__s, __half), \
304
+ graphene_simd4f_sub (__three, \
305
+ graphene_simd4f_mul (__s, graphene_simd4f_mul ((v), __s)))); \
306
+ }))
307
+
308
+ # define graphene_simd4f_cross3(a,b) \
309
+ (__extension__ ({ \
310
+ const graphene_simd4f_t __a_yzx = _mm_shuffle_ps ((a), (a), _MM_SHUFFLE (3, 0, 2, 1)); \
311
+ const graphene_simd4f_t __a_zxy = _mm_shuffle_ps ((a), (a), _MM_SHUFFLE (3, 1, 0, 2)); \
312
+ const graphene_simd4f_t __b_yzx = _mm_shuffle_ps ((b), (b), _MM_SHUFFLE (3, 0, 2, 1)); \
313
+ const graphene_simd4f_t __b_zxy = _mm_shuffle_ps ((b), (b), _MM_SHUFFLE (3, 1, 0, 2)); \
314
+ (graphene_simd4f_t) _mm_sub_ps (_mm_mul_ps (__a_yzx, __b_zxy), _mm_mul_ps (__a_zxy, __b_yzx)); \
315
+ }))
316
+
317
+ # if defined(GRAPHENE_USE_SSE4_1)
318
+ # define graphene_simd4f_dot3(a,b) \
319
+ (__extension__ ({ \
320
+ (graphene_simd4f_t) _mm_dp_ps ((a), (b), 0x7f); \
321
+ }))
322
+ # else
323
+ # define graphene_simd4f_dot3(a,b) \
324
+ (__extension__ ({ \
325
+ GRAPHENE_ALIGN16 const unsigned int __mask_bits[] = { 0xffffffff, 0xffffffff, 0xffffffff, 0 }; \
326
+ const graphene_simd4f_t __mask = _mm_load_ps ((const float *) __mask_bits); \
327
+ const graphene_simd4f_t __m = _mm_mul_ps ((a), (b)); \
328
+ const graphene_simd4f_t __s0 = _mm_and_ps (__m, __mask); \
329
+ const graphene_simd4f_t __s1 = _mm_add_ps (__s0, _mm_movehl_ps (__s0, __s0)); \
330
+ const graphene_simd4f_t __s2 = _mm_add_ss (__s1, _mm_shuffle_ps (__s1, __s1, 1)); \
331
+ (graphene_simd4f_t) _mm_shuffle_ps (__s2, __s2, 0); \
332
+ }))
333
+ # endif
334
+
335
+ # define graphene_simd4f_dot3_scalar(a,b) \
336
+ (__extension__ ({ \
337
+ float __res; \
338
+ _mm_store_ss (&__res, graphene_simd4f_dot3 (a, b)); \
339
+ __res; \
340
+ }))
341
+
342
+ # define graphene_simd4f_min(a,b) \
343
+ (__extension__ ({ \
344
+ (graphene_simd4f_t) _mm_min_ps ((a), (b)); \
345
+ }))
346
+
347
+ # define graphene_simd4f_max(a,b) \
348
+ (__extension__ ({ \
349
+ (graphene_simd4f_t) _mm_max_ps ((a), (b)); \
350
+ }))
351
+
352
+ # define graphene_simd4f_shuffle_wxyz(v) \
353
+ (__extension__ ({ \
354
+ (graphene_simd4f_t) _mm_shuffle_ps ((v), (v), _MM_SHUFFLE (2, 1, 0, 3)); \
355
+ }))
356
+
357
+ # define graphene_simd4f_shuffle_zwxy(v) \
358
+ (__extension__ ({ \
359
+ (graphene_simd4f_t) _mm_shuffle_ps ((v), (v), _MM_SHUFFLE (1, 0, 3, 2)); \
360
+ }))
361
+
362
+ # define graphene_simd4f_shuffle_yzwx(v) \
363
+ (__extension__ ({ \
364
+ (graphene_simd4f_t) _mm_shuffle_ps ((v), (v), _MM_SHUFFLE (0, 3, 2, 1)); \
365
+ }))
366
+
367
+ # define graphene_simd4f_zero_w(v) \
368
+ (__extension__ ({ \
369
+ graphene_simd4f_t __s = _mm_unpackhi_ps ((v), _mm_setzero_ps ()); \
370
+ (graphene_simd4f_t) _mm_movelh_ps ((v), __s); \
371
+ }))
372
+
373
+ # define graphene_simd4f_zero_zw(v) \
374
+ (__extension__ ({ \
375
+ (graphene_simd4f_t) _mm_movelh_ps ((v), _mm_setzero_ps ()); \
376
+ }))
377
+
378
+ # define graphene_simd4f_merge_w(s,v) \
379
+ (__extension__ ({ \
380
+ graphene_simd4f_t __s = _mm_unpackhi_ps ((s), _mm_set1_ps ((v))); \
381
+ (graphene_simd4f_t) _mm_movelh_ps ((s), __s); \
382
+ }))
383
+
384
+ # define graphene_simd4f_merge_high(a,b) \
385
+ (__extension__ ({ \
386
+ (graphene_simd4f_t) _mm_movehl_ps ((b), (a)); \
387
+ }))
388
+
389
+ # define graphene_simd4f_merge_low(a,b) \
390
+ (__extension__ ({ \
391
+ (graphene_simd4f_t) _mm_movelh_ps ((a), (b)); \
392
+ }))
393
+
394
+ typedef GRAPHENE_ALIGN16 union {
395
+ unsigned int ui[4];
396
+ float f[4];
397
+ } graphene_simd4f_uif_t;
398
+
399
+ # define graphene_simd4f_flip_sign_0101(v) \
400
+ (__extension__ ({ \
401
+ const graphene_simd4f_uif_t __pnpn = { { \
402
+ 0x00000000, \
403
+ 0x80000000, \
404
+ 0x00000000, \
405
+ 0x80000000 \
406
+ } }; \
407
+ (graphene_simd4f_t) _mm_xor_ps ((v), _mm_load_ps (__pnpn.f)); \
408
+ }))
409
+
410
+ # define graphene_simd4f_flip_sign_1010(v) \
411
+ (__extension__ ({ \
412
+ const graphene_simd4f_uif_t __npnp = { { \
413
+ 0x80000000, \
414
+ 0x00000000, \
415
+ 0x80000000, \
416
+ 0x00000000, \
417
+ } }; \
418
+ (graphene_simd4f_t) _mm_xor_ps ((v), _mm_load_ps (__npnp.f)); \
419
+ }))
420
+
421
+ # define graphene_simd4f_cmp_eq(a,b) \
422
+ (__extension__ ({ \
423
+ __m128i __res = (__m128i) _mm_cmpneq_ps ((a), (b)); \
424
+ (bool) (_mm_movemask_epi8 (__res) == 0); \
425
+ }))
426
+
427
+ # define graphene_simd4f_cmp_neq(a,b) \
428
+ (__extension__ ({ \
429
+ __m128i __res = (__m128i) _mm_cmpneq_ps ((a), (b)); \
430
+ (bool) (_mm_movemask_epi8 (__res) != 0); \
431
+ }))
432
+
433
+ # define graphene_simd4f_cmp_lt(a,b) \
434
+ (__extension__ ({ \
435
+ __m128i __res = (__m128i) _mm_cmplt_ps ((a), (b)); \
436
+ (bool) (_mm_movemask_epi8 (__res) == 0xffff); \
437
+ }))
438
+
439
+ # define graphene_simd4f_cmp_le(a,b) \
440
+ (__extension__ ({ \
441
+ __m128i __res = (__m128i) _mm_cmple_ps ((a), (b)); \
442
+ (bool) (_mm_movemask_epi8 (__res) == 0xffff); \
443
+ }))
444
+
445
+ # define graphene_simd4f_cmp_ge(a,b) \
446
+ (__extension__ ({ \
447
+ __m128i __res = (__m128i) _mm_cmpge_ps ((a), (b)); \
448
+ (bool) (_mm_movemask_epi8 (__res) == 0xffff); \
449
+ }))
450
+
451
+ # define graphene_simd4f_cmp_gt(a,b) \
452
+ (__extension__ ({ \
453
+ __m128i __res = (__m128i) _mm_cmpgt_ps ((a), (b)); \
454
+ (bool) (_mm_movemask_epi8 (__res) == 0xffff); \
455
+ }))
456
+
457
+ # define graphene_simd4f_neg(s) \
458
+ (__extension__ ({ \
459
+ const graphene_simd4f_uif_t __mask = { { \
460
+ 0x80000000, \
461
+ 0x80000000, \
462
+ 0x80000000, \
463
+ 0x80000000, \
464
+ } }; \
465
+ (graphene_simd4f_t) _mm_xor_ps ((s), _mm_load_ps (__mask.f)); \
466
+ }))
467
+
468
+ /* On MSVC, we use static inlines */
469
+ # elif defined (_MSC_VER)
470
+
471
+ /* Use static inline to inline all these functions */
472
+
473
+ #define graphene_simd4f_init(x,y,z,w) _simd4f_init(x,y,z,w)
474
+
475
+ static inline graphene_simd4f_t
476
+ _simd4f_init (float x, float y, float z, float w)
477
+ {
478
+ graphene_simd4f_t __s = { x, y, z, w };
479
+ return __s;
480
+ }
481
+
482
+ #define graphene_simd4f_init_zero() \
483
+ _mm_setzero_ps()
484
+
485
+ #define graphene_simd4f_init_4f(v) \
486
+ _mm_loadu_ps(v)
487
+
488
+ #define graphene_simd4f_init_3f(v) \
489
+ graphene_simd4f_init (v[0], v[1], v[2], 0.f)
490
+
491
+ #define graphene_simd4f_init_2f(v) \
492
+ graphene_simd4f_init (v[0], v[1], 0.f, 0.f)
493
+
494
+ #define graphene_simd4f_dup_4f(s,v) \
495
+ _mm_storeu_ps (v, s)
496
+
497
+ #define graphene_simd4f_dup_3f(s,v) \
498
+ memcpy (v, &s, sizeof (float) * 3)
499
+
500
+ #define graphene_simd4f_dup_2f(s,v) \
501
+ memcpy (v, &s, sizeof (float) * 2)
502
+
503
+ #define graphene_simd4f_get(s,i) _simd4f_get_xyzw(s, i)
504
+ #define graphene_simd4f_get_x(s) _simd4f_get_xyzw(s, 0)
505
+ #define graphene_simd4f_get_y(s) _simd4f_get_xyzw(s, 1)
506
+ #define graphene_simd4f_get_z(s) _simd4f_get_xyzw(s, 2)
507
+ #define graphene_simd4f_get_w(s) _simd4f_get_xyzw(s, 3)
508
+
509
+ static inline float
510
+ _simd4f_get_xyzw (graphene_simd4f_t s, int mode)
511
+ {
512
+ /* mode: get_x=0
513
+ get_y=1
514
+ get_z=2
515
+ get_w=3 */
516
+
517
+ graphene_simd4f_union_t u;
518
+ u.s = s;
519
+ return u.f[mode];
520
+ }
521
+
522
+ #define graphene_simd4f_splat(v) \
523
+ _mm_set1_ps (v)
524
+
525
+ #define graphene_simd4f_splat_x(v) \
526
+ _mm_shuffle_ps (v, v, _MM_SHUFFLE (0, 0, 0, 0))
527
+
528
+ #define graphene_simd4f_splat_y(v) \
529
+ _mm_shuffle_ps (v, v, _MM_SHUFFLE (1, 1, 1, 1))
530
+
531
+ #define graphene_simd4f_splat_z(v) \
532
+ _mm_shuffle_ps (v, v, _MM_SHUFFLE (2, 2, 2, 2))
533
+
534
+ #define graphene_simd4f_splat_w(v) \
535
+ _mm_shuffle_ps (v, v, _MM_SHUFFLE (3, 3, 3, 3))
536
+
537
+ #define graphene_simd4f_add(a,b) \
538
+ _mm_add_ps (a, b)
539
+
540
+ #define graphene_simd4f_sub(a,b) \
541
+ _mm_sub_ps (a, b)
542
+
543
+ #define graphene_simd4f_mul(a,b) \
544
+ _mm_mul_ps (a, b)
545
+
546
+ #define graphene_simd4f_div(a,b) \
547
+ _mm_div_ps (a, b)
548
+
549
+ #define graphene_simd4f_sqrt(v) \
550
+ _mm_sqrt_ps (v)
551
+
552
+ #define graphene_simd4f_reciprocal(v) _simd4f_reciprocal(v)
553
+
554
+ static inline graphene_simd4f_t
555
+ _simd4f_reciprocal(const graphene_simd4f_t v)
556
+ {
557
+ const graphene_simd4f_t __two = graphene_simd4f_init (2.0f, 2.0f, 2.0f, 2.0f);
558
+ graphene_simd4f_t __s = _mm_rcp_ps (v);
559
+ return graphene_simd4f_mul (__s,
560
+ graphene_simd4f_sub (__two,
561
+ graphene_simd4f_mul (v, __s)));
562
+ }
563
+
564
+ #define graphene_simd4f_rsqrt(v) _simd4f_rsqrt(v)
565
+
566
+ static inline graphene_simd4f_t
567
+ _simd4f_rsqrt(const graphene_simd4f_t v)
568
+ {
569
+ const graphene_simd4f_t __half = graphene_simd4f_init (0.5f, 0.5f, 0.5f, 0.5f);
570
+ const graphene_simd4f_t __three = graphene_simd4f_init (3.0f, 3.0f, 3.0f, 3.0f);
571
+ graphene_simd4f_t __s = _mm_rsqrt_ps (v);
572
+ return graphene_simd4f_mul (graphene_simd4f_mul (__s, __half),
573
+ graphene_simd4f_sub (__three,
574
+ graphene_simd4f_mul (__s, graphene_simd4f_mul (v, __s))));
575
+ }
576
+
577
+ #define graphene_simd4f_cross3(a,b) \
578
+ _simd4f_cross3(a,b)
579
+
580
+ static inline graphene_simd4f_t
581
+ _simd4f_cross3 (const graphene_simd4f_t a,
582
+ const graphene_simd4f_t b)
583
+ {
584
+ const graphene_simd4f_t __a_yzx = _mm_shuffle_ps (a, a, _MM_SHUFFLE (3, 0, 2, 1));
585
+ const graphene_simd4f_t __a_zxy = _mm_shuffle_ps (a, a, _MM_SHUFFLE (3, 1, 0, 2));
586
+ const graphene_simd4f_t __b_yzx = _mm_shuffle_ps (b, b, _MM_SHUFFLE (3, 0, 2, 1));
587
+ const graphene_simd4f_t __b_zxy = _mm_shuffle_ps (b, b, _MM_SHUFFLE (3, 1, 0, 2));
588
+
589
+ return _mm_sub_ps (_mm_mul_ps (__a_yzx, __b_zxy), _mm_mul_ps (__a_zxy, __b_yzx));
590
+ }
591
+
592
+ #define graphene_simd4f_dot3(a,b) \
593
+ _simd4f_dot3(a,b)
594
+
595
+ static inline graphene_simd4f_t
596
+ _simd4f_dot3 (const graphene_simd4f_t a,
597
+ const graphene_simd4f_t b)
598
+ {
599
+ #if defined(GRAPHENE_USE_SSE4_1)
600
+ return _mm_dp_ps (a, b, 0x7f);
601
+ #else
602
+ GRAPHENE_ALIGN16 const unsigned int __mask_bits[] = { 0xffffffff, 0xffffffff, 0xffffffff, 0 };
603
+ const graphene_simd4f_t __mask = _mm_load_ps ((const float *) __mask_bits);
604
+ const graphene_simd4f_t __m = _mm_mul_ps ((a), (b));
605
+ const graphene_simd4f_t __s0 = _mm_and_ps (__m, __mask);
606
+ const graphene_simd4f_t __s1 = _mm_add_ps (__s0, _mm_movehl_ps (__s0, __s0));
607
+ const graphene_simd4f_t __s2 = _mm_add_ss (__s1, _mm_shuffle_ps (__s1, __s1, 1));
608
+
609
+ return _mm_shuffle_ps (__s2, __s2, 0);
610
+ #endif
611
+ }
612
+
613
+ #define graphene_simd4f_dot3_scalar(a,b) \
614
+ _simd4f_dot3_scalar(a,b)
615
+
616
+ static inline float
617
+ _simd4f_dot3_scalar (const graphene_simd4f_t a,
618
+ const graphene_simd4f_t b)
619
+ {
620
+ float __res;
621
+ _mm_store_ss (&__res, graphene_simd4f_dot3 (a, b));
622
+ return __res;
623
+ }
624
+
625
+ #define graphene_simd4f_min(a,b) \
626
+ _mm_min_ps (a, b)
627
+
628
+ #define graphene_simd4f_max(a,b) \
629
+ _mm_max_ps (a, b)
630
+
631
+
632
+ #define graphene_simd4f_shuffle_wxyz(v) \
633
+ _mm_shuffle_ps (v, v, _MM_SHUFFLE (2, 1, 0, 3))
634
+
635
+ #define graphene_simd4f_shuffle_zwxy(v) \
636
+ _mm_shuffle_ps (v, v, _MM_SHUFFLE (1, 0, 3, 2))
637
+
638
+ #define graphene_simd4f_shuffle_yzwx(v) \
639
+ _mm_shuffle_ps (v, v, _MM_SHUFFLE (0, 3, 2, 1))
640
+
641
+ #define graphene_simd4f_zero_w(v) \
642
+ _mm_movelh_ps (v, _mm_unpackhi_ps (v, _mm_setzero_ps ()))
643
+
644
+ #define graphene_simd4f_zero_zw(v) \
645
+ _mm_movelh_ps (v, _mm_setzero_ps ())
646
+
647
+ #define graphene_simd4f_merge_w(s,v) \
648
+ _mm_movelh_ps (s, _mm_unpackhi_ps (s, _mm_set1_ps (v)))
649
+
650
+ #define graphene_simd4f_merge_high(a,b) \
651
+ _mm_movehl_ps (b, a)
652
+
653
+ #define graphene_simd4f_merge_low(a,b) \
654
+ _mm_movelh_ps (a, b)
655
+
656
+ typedef GRAPHENE_ALIGN16 union {
657
+ unsigned int ui[4];
658
+ float f[4];
659
+ } graphene_simd4f_uif_t;
660
+
661
+ #define graphene_simd4f_flip_sign_0101(v) _simd4f_flip_sign_0101(v)
662
+
663
+ static inline graphene_simd4f_t
664
+ _simd4f_flip_sign_0101 (const graphene_simd4f_t v)
665
+ {
666
+ const graphene_simd4f_uif_t __pnpn = { {
667
+ 0x00000000,
668
+ 0x80000000,
669
+ 0x00000000,
670
+ 0x80000000
671
+ } };
672
+
673
+ return _mm_xor_ps (v, _mm_load_ps (__pnpn.f));
674
+ }
675
+
676
+ #define graphene_simd4f_flip_sign_1010(v) _simd4f_flip_sign_1010(v)
677
+
678
+ static inline graphene_simd4f_t
679
+ _simd4f_flip_sign_1010(const graphene_simd4f_t v)
680
+ {
681
+ const graphene_simd4f_uif_t __npnp = { {
682
+ 0x80000000,
683
+ 0x00000000,
684
+ 0x80000000,
685
+ 0x00000000,
686
+ } };
687
+
688
+ return _mm_xor_ps (v, _mm_load_ps (__npnp.f));
689
+ }
690
+
691
+ #define graphene_simd4f_cmp_eq(a,b) _simd4f_cmp_eq(a,b)
692
+
693
+ static inline bool
694
+ _simd4f_cmp_eq (const graphene_simd4f_t a,
695
+ const graphene_simd4f_t b)
696
+ {
697
+ __m128i __res = _mm_castps_si128 (_mm_cmpneq_ps (a, b));
698
+ return (_mm_movemask_epi8 (__res) == 0);
699
+ }
700
+
701
+ #define graphene_simd4f_cmp_neq(a,b) _simd4f_cmp_neq(a,b)
702
+
703
+ static inline bool
704
+ _simd4f_cmp_neq (const graphene_simd4f_t a,
705
+ const graphene_simd4f_t b)
706
+ {
707
+ __m128i __res = _mm_castps_si128 (_mm_cmpneq_ps (a, b));
708
+ return (_mm_movemask_epi8 (__res) != 0);
709
+ }
710
+
711
+ #define graphene_simd4f_cmp_lt(a,b) _simd4f_cmp_lt(a,b)
712
+
713
+ static inline bool
714
+ _simd4f_cmp_lt (const graphene_simd4f_t a,
715
+ const graphene_simd4f_t b)
716
+ {
717
+ __m128i __res = _mm_castps_si128 (_mm_cmplt_ps (a, b));
718
+ return (_mm_movemask_epi8 (__res) == 0xffff);
719
+ }
720
+
721
+ #define graphene_simd4f_cmp_le(a,b) _simd4f_cmp_le(a,b)
722
+
723
+ static inline bool
724
+ _simd4f_cmp_le (const graphene_simd4f_t a,
725
+ const graphene_simd4f_t b)
726
+ {
727
+ __m128i __res = _mm_castps_si128 (_mm_cmple_ps (a, b));
728
+ return (_mm_movemask_epi8 (__res) == 0xffff);
729
+ }
730
+
731
+ #define graphene_simd4f_cmp_ge(a,b) _simd4f_cmp_ge(a,b)
732
+
733
+ static inline bool
734
+ _simd4f_cmp_ge (const graphene_simd4f_t a,
735
+ const graphene_simd4f_t b)
736
+ {
737
+ __m128i __res = _mm_castps_si128 (_mm_cmpge_ps (a, b));
738
+ return (_mm_movemask_epi8 (__res) == 0xffff);
739
+ }
740
+
741
+ #define graphene_simd4f_cmp_gt(a,b) _simd4f_cmp_gt(a,b)
742
+
743
+ static inline bool
744
+ _simd4f_cmp_gt (const graphene_simd4f_t a,
745
+ const graphene_simd4f_t b)
746
+ {
747
+ __m128i __res = _mm_castps_si128 (_mm_cmpgt_ps (a, b));
748
+ return (_mm_movemask_epi8 (__res) == 0xffff);
749
+ }
750
+
751
+ #define graphene_simd4f_neg(s) _simd4f_neg(s)
752
+
753
+ static inline graphene_simd4f_t
754
+ _simd4f_neg (const graphene_simd4f_t s)
755
+ {
756
+ const graphene_simd4f_uif_t __mask = { {
757
+ 0x80000000,
758
+ 0x80000000,
759
+ 0x80000000,
760
+ 0x80000000,
761
+ } };
762
+
763
+ return _mm_xor_ps (s, _mm_load_ps (__mask.f));
764
+ }
765
+
766
+ #else
767
+
768
+ # error "Need GCC-compatible or Visual Studio compiler for SSE extensions."
769
+
770
+ /* Use static inline to inline all these functions */
771
+
772
+ # endif /* __GNUC__ */
773
+
774
+ #elif !defined(__GI_SCANNER__) && defined(GRAPHENE_USE_GCC)
775
+
776
+ /* GCC vector intrinsic implementation of SIMD 4f */
777
+
778
+ typedef int graphene_simd4i_t __attribute__((vector_size (16)));
779
+
780
+ # define graphene_simd4f_init(x,y,z,w) \
781
+ (__extension__ ({ \
782
+ (graphene_simd4f_t) { (x), (y), (z), (w) }; \
783
+ }))
784
+
785
+ # define graphene_simd4f_init_zero() \
786
+ (__extension__ ({ \
787
+ (graphene_simd4f_t) { 0.f, 0.f, 0.f, 0.f }; \
788
+ }))
789
+
790
+ # define graphene_simd4f_init_4f(v) \
791
+ (__extension__ ({ \
792
+ (graphene_simd4f_t) { (v)[0], (v)[1], (v)[2], (v)[3] }; \
793
+ }))
794
+
795
+ # define graphene_simd4f_init_3f(v) \
796
+ (__extension__ ({ \
797
+ (graphene_simd4f_t) { (v)[0], (v)[1], (v)[2], 0.f }; \
798
+ }))
799
+
800
+ # define graphene_simd4f_init_2f(v) \
801
+ (__extension__ ({ \
802
+ (graphene_simd4f_t) { (v)[0], (v)[1], 0.f, 0.f }; \
803
+ }))
804
+
805
+ # define graphene_simd4f_dup_4f(s,v) \
806
+ (__extension__ ({ \
807
+ memcpy ((v), &(s), sizeof (float) * 4); \
808
+ }))
809
+
810
+ # define graphene_simd4f_dup_3f(s,v) \
811
+ (__extension__ ({ \
812
+ memcpy ((v), &(s), sizeof (float) * 3); \
813
+ }))
814
+
815
+ # define graphene_simd4f_dup_2f(s,v) \
816
+ (__extension__ ({ \
817
+ memcpy ((v), &(s), sizeof (float) * 2); \
818
+ }))
819
+
820
+ # define graphene_simd4f_get(s,i) (__extension__ ({ (float) (s)[(i)]; }))
821
+ # define graphene_simd4f_get_x(s) graphene_simd4f_get ((s), 0)
822
+ # define graphene_simd4f_get_y(s) graphene_simd4f_get ((s), 1)
823
+ # define graphene_simd4f_get_z(s) graphene_simd4f_get ((s), 2)
824
+ # define graphene_simd4f_get_w(s) graphene_simd4f_get ((s), 3)
825
+
826
+ # define graphene_simd4f_splat(v) \
827
+ (__extension__ ({ \
828
+ (graphene_simd4f_t) { (v), (v), (v), (v) }; \
829
+ }))
830
+
831
+ # define graphene_simd4f_splat_x(v) \
832
+ (__extension__ ({ \
833
+ float __val = graphene_simd4f_get_x ((v)); \
834
+ (graphene_simd4f_t) { __val, __val, __val, __val }; \
835
+ }))
836
+
837
+ # define graphene_simd4f_splat_y(v) \
838
+ (__extension__ ({ \
839
+ float __val = graphene_simd4f_get_y ((v)); \
840
+ (graphene_simd4f_t) { __val, __val, __val, __val }; \
841
+ }))
842
+
843
+ # define graphene_simd4f_splat_z(v) \
844
+ (__extension__ ({ \
845
+ float __val = graphene_simd4f_get_z ((v)); \
846
+ (graphene_simd4f_t) { __val, __val, __val, __val }; \
847
+ }))
848
+
849
+ # define graphene_simd4f_splat_w(v) \
850
+ (__extension__ ({ \
851
+ float __val = graphene_simd4f_get_w ((v)); \
852
+ (graphene_simd4f_t) { __val, __val, __val, __val }; \
853
+ }))
854
+
855
+ # define graphene_simd4f_reciprocal(v) \
856
+ (__extension__ ({ \
857
+ (graphene_simd4f_t) { \
858
+ (v)[0] != 0.f ? 1.f / (v)[0] : 0.f, \
859
+ (v)[1] != 0.f ? 1.f / (v)[1] : 0.f, \
860
+ (v)[2] != 0.f ? 1.f / (v)[2] : 0.f, \
861
+ (v)[3] != 0.f ? 1.f / (v)[3] : 0.f, \
862
+ }; \
863
+ }))
864
+
865
+ # define graphene_simd4f_sqrt(v) \
866
+ (__extension__ ({ \
867
+ (graphene_simd4f_t) { \
868
+ sqrtf ((v)[0]), \
869
+ sqrtf ((v)[1]), \
870
+ sqrtf ((v)[2]), \
871
+ sqrtf ((v)[3]), \
872
+ }; \
873
+ }))
874
+
875
+ # define graphene_simd4f_rsqrt(v) \
876
+ (__extension__ ({ \
877
+ (graphene_simd4f_t) { \
878
+ (v)[0] != 0.f ? 1.f / sqrtf ((v)[0]) : 0.f, \
879
+ (v)[1] != 0.f ? 1.f / sqrtf ((v)[1]) : 0.f, \
880
+ (v)[2] != 0.f ? 1.f / sqrtf ((v)[2]) : 0.f, \
881
+ (v)[3] != 0.f ? 1.f / sqrtf ((v)[3]) : 0.f, \
882
+ }; \
883
+ }))
884
+
885
+ # define graphene_simd4f_add(a,b) (__extension__ ({ (graphene_simd4f_t) ((a) + (b)); }))
886
+ # define graphene_simd4f_sub(a,b) (__extension__ ({ (graphene_simd4f_t) ((a) - (b)); }))
887
+ # define graphene_simd4f_mul(a,b) (__extension__ ({ (graphene_simd4f_t) ((a) * (b)); }))
888
+ # define graphene_simd4f_div(a,b) (__extension__ ({ (graphene_simd4f_t) ((a) / (b)); }))
889
+
890
+ # define graphene_simd4f_cross3(a,b) \
891
+ (__extension__ ({ \
892
+ const graphene_simd4f_t __a = (a); \
893
+ const graphene_simd4f_t __b = (b); \
894
+ graphene_simd4f_init (__a[1] * __b[2] - __a[2] * __b[1], \
895
+ __a[2] * __b[0] - __a[0] * __b[2], \
896
+ __a[0] * __b[1] - __a[1] * __b[0], \
897
+ 0.f); \
898
+ }))
899
+
900
+ # define graphene_simd4f_dot3(a,b) \
901
+ (__extension__ ({ \
902
+ const graphene_simd4f_t __a = (a); \
903
+ const graphene_simd4f_t __b = (b); \
904
+ const float __res = __a[0] * __b[0] + __a[1] * __b[1] + __a[2] * __b[2]; \
905
+ graphene_simd4f_init (__res, __res, __res, __res); \
906
+ }))
907
+
908
+ # define graphene_simd4f_dot3_scalar(a,b) \
909
+ (__extension__ ({ \
910
+ graphene_simd4f_get_x (graphene_simd4f_dot3 (a, b)); \
911
+ }))
912
+
913
+ # define graphene_simd4f_min(a,b) \
914
+ (__extension__ ({ \
915
+ const graphene_simd4f_t __a = (a); \
916
+ const graphene_simd4f_t __b = (b); \
917
+ graphene_simd4f_init (__a[0] < __b[0] ? __a[0] : __b[0], \
918
+ __a[1] < __b[1] ? __a[1] : __b[1], \
919
+ __a[2] < __b[2] ? __a[2] : __b[2], \
920
+ __a[3] < __b[3] ? __a[3] : __b[3]); \
921
+ }))
922
+
923
+ # define graphene_simd4f_max(a,b) \
924
+ (__extension__ ({ \
925
+ const graphene_simd4f_t __a = (a); \
926
+ const graphene_simd4f_t __b = (b); \
927
+ graphene_simd4f_init (__a[0] > __b[0] ? __a[0] : __b[0], \
928
+ __a[1] > __b[1] ? __a[1] : __b[1], \
929
+ __a[2] > __b[2] ? __a[2] : __b[2], \
930
+ __a[3] > __b[3] ? __a[3] : __b[3]); \
931
+ }))
932
+
933
+ # define graphene_simd4f_shuffle_wxyz(v) \
934
+ (__extension__ ({ \
935
+ const graphene_simd4i_t __mask = { 3, 0, 1, 2 }; \
936
+ (graphene_simd4f_t) __builtin_shuffle ((v), __mask); \
937
+ }))
938
+
939
+ # define graphene_simd4f_shuffle_zwxy(v) \
940
+ (__extension__ ({ \
941
+ const graphene_simd4i_t __mask = { 2, 3, 0, 1 }; \
942
+ (graphene_simd4f_t) __builtin_shuffle ((v), __mask); \
943
+ }))
944
+
945
+ # define graphene_simd4f_shuffle_yzwx(v) \
946
+ (__extension__ ({ \
947
+ const graphene_simd4i_t __mask = { 1, 2, 3, 0 }; \
948
+ (graphene_simd4f_t) __builtin_shuffle ((v), __mask); \
949
+ }))
950
+
951
+ # define graphene_simd4f_zero_w(v) \
952
+ (__extension__ ({ \
953
+ const graphene_simd4i_t __mask = { 0, 1, 2, 4 }; \
954
+ (graphene_simd4f_t) __builtin_shuffle ((v), graphene_simd4f_init_zero (), __mask); \
955
+ }))
956
+
957
+ # define graphene_simd4f_zero_zw(v) \
958
+ (__extension__ ({ \
959
+ const graphene_simd4i_t __mask = { 0, 1, 4, 4 }; \
960
+ (graphene_simd4f_t) __builtin_shuffle ((v), graphene_simd4f_init_zero (), __mask); \
961
+ }))
962
+
963
+ # define graphene_simd4f_merge_w(s,v) \
964
+ (__extension__ ({ \
965
+ const graphene_simd4i_t __mask = { 0, 1, 2, 4 }; \
966
+ (graphene_simd4f_t) __builtin_shuffle ((s), graphene_simd4f_splat ((v)), __mask); \
967
+ }))
968
+
969
+ # define graphene_simd4f_merge_high(a,b) \
970
+ (__extension__ ({ \
971
+ const graphene_simd4i_t __mask = { 2, 3, 6, 7 }; \
972
+ (graphene_simd4f_t) __builtin_shuffle ((a), (b), __mask); \
973
+ }))
974
+
975
+ # define graphene_simd4f_merge_low(a,b) \
976
+ (__extension__ ({ \
977
+ const graphene_simd4i_t __mask = { 0, 1, 4, 5 }; \
978
+ (graphene_simd4f_t) __builtin_shuffle ((a), (b), __mask); \
979
+ }))
980
+
981
+ # define graphene_simd4f_flip_sign_0101(v) \
982
+ (__extension__ ({ \
983
+ const graphene_simd4f_t __v = (v); \
984
+ graphene_simd4f_init (__v[0], -__v[1], __v[2], -__v[3]); \
985
+ }))
986
+
987
+ # define graphene_simd4f_flip_sign_1010(v) \
988
+ (__extension__ ({ \
989
+ const graphene_simd4f_t __v = (v); \
990
+ graphene_simd4f_init (-__v[0], __v[1], -__v[2], __v[3]); \
991
+ }))
992
+
993
+ # define graphene_simd4f_cmp_eq(a,b) \
994
+ (__extension__ ({ \
995
+ const graphene_simd4i_t __res = (a) == (b); \
996
+ (bool) (__res[0] != 0 && \
997
+ __res[1] != 0 && \
998
+ __res[2] != 0 && \
999
+ __res[3] != 0); \
1000
+ }))
1001
+
1002
+ # define graphene_simd4f_cmp_neq(a,b) (!graphene_simd4f_cmp_eq (a,b))
1003
+
1004
+ # define graphene_simd4f_cmp_lt(a,b) \
1005
+ (__extension__ ({ \
1006
+ const graphene_simd4i_t __res = (a) < (b); \
1007
+ (bool) (__res[0] != 0 && \
1008
+ __res[1] != 0 && \
1009
+ __res[2] != 0 && \
1010
+ __res[3] != 0); \
1011
+ }))
1012
+
1013
+ # define graphene_simd4f_cmp_le(a,b) \
1014
+ (__extension__ ({ \
1015
+ const graphene_simd4i_t __res = (a) <= (b); \
1016
+ (bool) (__res[0] != 0 && \
1017
+ __res[1] != 0 && \
1018
+ __res[2] != 0 && \
1019
+ __res[3] != 0); \
1020
+ }))
1021
+
1022
+ # define graphene_simd4f_cmp_ge(a,b) \
1023
+ (__extension__ ({ \
1024
+ const graphene_simd4i_t __res = (a) >= (b); \
1025
+ (bool) (__res[0] != 0 && \
1026
+ __res[1] != 0 && \
1027
+ __res[2] != 0 && \
1028
+ __res[3] != 0); \
1029
+ }))
1030
+
1031
+ # define graphene_simd4f_cmp_gt(a,b) \
1032
+ (__extension__ ({ \
1033
+ const graphene_simd4i_t __res = (a) > (b); \
1034
+ (bool) (__res[0] != 0 && \
1035
+ __res[1] != 0 && \
1036
+ __res[2] != 0 && \
1037
+ __res[3] != 0); \
1038
+ }))
1039
+
1040
+ # define graphene_simd4f_neg(s) \
1041
+ (__extension__ ({ \
1042
+ const graphene_simd4f_t __s = (s); \
1043
+ const graphene_simd4f_t __minus_one = graphene_simd4f_splat (-1.f); \
1044
+ graphene_simd4f_mul (__s, __minus_one); \
1045
+ }))
1046
+
1047
+ #elif !defined(__GI_SCANNER__) && defined(GRAPHENE_USE_ARM_NEON)
1048
+
1049
+ /* ARM Neon implementation of SIMD4f */
1050
+ # warning "The ARM Neon implementation of graphene_simd4f_t is experimental."
1051
+
1052
+ /* Union type used for single lane reading without memcpy */
1053
+ typedef union {
1054
+ graphene_simd4f_t s;
1055
+ float f[4];
1056
+ } graphene_simd4f_union_t;
1057
+
1058
+ /* NEON has optimised 2-lanes vectors we can use */
1059
+ typedef float32x2_t graphene_simd2f_t;
1060
+
1061
+ # define graphene_simd4f_init(x,y,z,w) \
1062
+ (__extension__ ({ \
1063
+ const float32_t __v[4] = { (x), (y), (z), (w) }; \
1064
+ (graphene_simd4f_t) vld1q_f32 (__v); \
1065
+ }))
1066
+
1067
+ # define graphene_simd4f_init_zero() \
1068
+ (__extension__ ({ \
1069
+ (graphene_simd4f_t) vdupq_n_f32 (0.f); \
1070
+ }))
1071
+
1072
+ # define graphene_simd4f_init_4f(v) \
1073
+ (__extension__ ({ \
1074
+ const float32_t *__v32 = (const float32_t *) (v); \
1075
+ (graphene_simd4f_t) vld1q_f32 (__v32); \
1076
+ }))
1077
+
1078
+ # define graphene_simd4f_init_3f(v) \
1079
+ (__extension__ ({ \
1080
+ graphene_simd4f_init (v[0], v[1], v[2], 0.f); \
1081
+ }))
1082
+
1083
+ # define graphene_simd4f_init_2f(v) \
1084
+ (__extension__ ({ \
1085
+ const float32_t *__v32 = (const float32_t *) (v); \
1086
+ const graphene_simd2f_t __low = vld1_f32 (__v32); \
1087
+ const float32_t __zero = 0; \
1088
+ const graphene_simd2f_t __high = vld1_dup_f32 (&__zero); \
1089
+ (graphene_simd4f_t) vcombine_f32 (__low, __high); \
1090
+ }))
1091
+
1092
+ # define graphene_simd4f_dup_4f(s,v) \
1093
+ (__extension__ ({ \
1094
+ vst1q_f32 ((float32_t *) (v), (s)); \
1095
+ }))
1096
+
1097
+ # define graphene_simd4f_dup_3f(s,v) \
1098
+ (__extension__ ({ \
1099
+ float *__v = (v); \
1100
+ vst1q_lane_f32 (__v++, (s), 0); \
1101
+ vst1q_lane_f32 (__v++, (s), 1); \
1102
+ vst1q_lane_f32 (__v, (s), 2); \
1103
+ }))
1104
+
1105
+ # define graphene_simd4f_dup_2f(s,v) \
1106
+ (__extension__ ({ \
1107
+ const graphene_simd2f_t __low = vget_low_f32 ((s)); \
1108
+ vst1_f32 ((float32_t *) (v), __low); \
1109
+ }))
1110
+
1111
+ # define graphene_simd4f_get(s,i) \
1112
+ (__extension__ ({ \
1113
+ (float) vgetq_lane_f32 ((s), (i)); \
1114
+ }))
1115
+
1116
+ # define graphene_simd4f_get_x(s) graphene_simd4f_get (s, 0)
1117
+ # define graphene_simd4f_get_y(s) graphene_simd4f_get (s, 1)
1118
+ # define graphene_simd4f_get_z(s) graphene_simd4f_get (s, 2)
1119
+ # define graphene_simd4f_get_w(s) graphene_simd4f_get (s, 3)
1120
+
1121
+ # define graphene_simd4f_splat(v) \
1122
+ (__extension__ ({ \
1123
+ (graphene_simd4f_t) vdupq_n_f32 ((v)); \
1124
+ }))
1125
+
1126
+ # define graphene_simd4f_splat_x(s) \
1127
+ (__extension__ ({ \
1128
+ graphene_simd4f_splat (graphene_simd4f_get_x ((s))); \
1129
+ }))
1130
+
1131
+ # define graphene_simd4f_splat_y(s) \
1132
+ (__extension__ ({ \
1133
+ graphene_simd4f_splat (graphene_simd4f_get_y ((s))); \
1134
+ }))
1135
+
1136
+ # define graphene_simd4f_splat_z(s) \
1137
+ (__extension__ ({ \
1138
+ graphene_simd4f_splat (graphene_simd4f_get_z ((s))); \
1139
+ }))
1140
+
1141
+ # define graphene_simd4f_splat_w(s) \
1142
+ (__extension__ ({ \
1143
+ graphene_simd4f_splat (graphene_simd4f_get_w ((s))); \
1144
+ }))
1145
+
1146
+ # define graphene_simd4f_reciprocal(s) \
1147
+ (__extension__ ({ \
1148
+ graphene_simd4f_t __est = vrecpeq_f32 ((s)); \
1149
+ __est = vmulq_f32 (vrecpsq_f32 (__est, (s)), __est); \
1150
+ (graphene_simd4f_t) vmulq_f32 (vrecpsq_f32 (__est, (s)), __est); \
1151
+ }))
1152
+
1153
+ # define graphene_simd4f_add(a,b) \
1154
+ (__extension__ ({ \
1155
+ (graphene_simd4f_t) vaddq_f32 ((a), (b)); \
1156
+ }))
1157
+
1158
+ # define graphene_simd4f_sub(a,b) \
1159
+ (__extension__ ({ \
1160
+ (graphene_simd4f_t) vsubq_f32 ((a), (b)); \
1161
+ }))
1162
+
1163
+ # define graphene_simd4f_mul(a,b) \
1164
+ (__extension__ ({ \
1165
+ (graphene_simd4f_t) vmulq_f32 ((a), (b)); \
1166
+ }))
1167
+
1168
+ # define graphene_simd4f_div(a,b) \
1169
+ (__extension__ ({ \
1170
+ graphene_simd4f_t __rec = graphene_simd4f_reciprocal ((b)); \
1171
+ (graphene_simd4f_t) vmulq_f32 ((a), __rec); \
1172
+ }))
1173
+
1174
+ # define _simd4f_rsqrt_iter(v,estimate) \
1175
+ (__extension__ ({ \
1176
+ const graphene_simd4f_t __est1 = vmulq_f32 ((estimate), (v)); \
1177
+ (graphene_simd4f_t) vmulq_f32 ((estimate), vrsqrtsq_f32 (__est1, (estimate))); \
1178
+ }))
1179
+
1180
+ # define graphene_simd4f_rsqrt(s) \
1181
+ (__extension__ ({ \
1182
+ graphene_simd4f_t __estimate = vrsqrteq_f32 ((s)); \
1183
+ __estimate = _simd4f_rsqrt_iter ((s), __estimate); \
1184
+ __estimate = _simd4f_rsqrt_iter ((s), __estimate); \
1185
+ _simd4f_rsqrt_iter ((s), __estimate); \
1186
+ }))
1187
+
1188
+ # define graphene_simd4f_sqrt(s) \
1189
+ (__extension__ ({ \
1190
+ graphene_simd4f_t __rsq = graphene_simd4f_rsqrt ((s)); \
1191
+ graphene_simd4f_t __rrsq = graphene_simd4f_reciprocal (__rsq); \
1192
+ uint32x4_t __tmp = vreinterpretq_u32_f32 ((s)); \
1193
+ (graphene_simd4f_t) vreinterpretq_f32_u32 (vandq_u32 (vtstq_u32 (__tmp, __tmp), vreinterpretq_u32_f32 (__rrsq))); \
1194
+ }))
1195
+
1196
+ # define graphene_simd4f_cross3(a,b) \
1197
+ (__extension__ ({ \
1198
+ const uint32_t __mask_bits[] = { 0xffffffff, 0xffffffff, 0xffffffff, 0 }; \
1199
+ const int32x4_t __mask = vld1q_s32 ((const int32_t *) __mask_bits); \
1200
+ const graphene_simd4f_t __a = (a), __b = (b); \
1201
+ const graphene_simd2f_t __a_low = vget_low_f32 (__a); \
1202
+ const graphene_simd2f_t __b_low = vget_low_f32 (__b); \
1203
+ const graphene_simd4f_t __a_yzx = vcombine_f32 (vext_f32 (__a_low, vget_high_f32 (__a), 1), __a_low); \
1204
+ const graphene_simd4f_t __b_yzx = vcombine_f32 (vext_f32 (__b_low, vget_high_f32 (__b), 1), __b_low); \
1205
+ graphene_simd4f_t __s3 = graphene_simd4f_sub (graphene_simd4f_mul (__b_yzx, __a), \
1206
+ graphene_simd4f_mul (__a_yzx, __b)); \
1207
+ graphene_simd2f_t __s3_low = vget_low_f32 (__s3); \
1208
+ __s3 = vcombine_f32 (vext_f32 (__s3_low, vget_high_f32 (__s3), 1), __s3_low); \
1209
+ (graphene_simd4f_t) vandq_s32 ((int32x4_t) __s3, __mask); \
1210
+ }))
1211
+
1212
+ # define graphene_simd4f_dot3(a,b) \
1213
+ (__extension__ ({ \
1214
+ graphene_simd4f_splat (graphene_simd4f_dot3_scalar (a, b)); \
1215
+ }))
1216
+
1217
+ # define graphene_simd4f_dot3_scalar(a,b) \
1218
+ (__extension__ ({ \
1219
+ const graphene_simd4f_t __m = graphene_simd4f_mul (a, b); \
1220
+ const graphene_simd2f_t __s1 = vpadd_f32 (vget_low_f32 (__m), vget_low_f32 (__m)); \
1221
+ (float) vget_lane_f32 (vadd_f32 (__s1, vget_high_f32 (__m)), 0); \
1222
+ }))
1223
+
1224
+ # define graphene_simd4f_min(a,b) \
1225
+ (__extension__ ({ \
1226
+ (graphene_simd4f_t) vminq_f32 ((a), (b)); \
1227
+ }))
1228
+
1229
+ # define graphene_simd4f_max(a,b) \
1230
+ (__extension__ ({ \
1231
+ (graphene_simd4f_t) vmaxq_f32 (a, b); \
1232
+ }))
1233
+
1234
+ # define graphene_simd4f_shuffle_wxyz(v) \
1235
+ (__extension__ ({ \
1236
+ graphene_simd4f_union_t __u = { (v) }; \
1237
+ graphene_simd4f_init (__u.f[3], __u.f[0], __u.f[1], __u.f[2]); \
1238
+ }))
1239
+
1240
+ # define graphene_simd4f_shuffle_zwxy(v) \
1241
+ (__extension__ ({ \
1242
+ graphene_simd4f_union_t __u = { (v) }; \
1243
+ graphene_simd4f_init (__u.f[2], __u.f[3], __u.f[0], __u.f[1]); \
1244
+ }))
1245
+
1246
+ # define graphene_simd4f_shuffle_yzwx(v) \
1247
+ (__extension__ ({ \
1248
+ graphene_simd4f_union_t __u = { (v) }; \
1249
+ graphene_simd4f_init (__u.f[1], __u.f[2], __u.f[3], __u.f[0]); \
1250
+ }))
1251
+
1252
+ # define graphene_simd4f_zero_w(v) \
1253
+ (__extension__ ({ \
1254
+ graphene_simd4f_union_t __u = { (v) }; \
1255
+ graphene_simd4f_init (__u.f[0], __u.f[1], __u.f[2], 0.f); \
1256
+ }))
1257
+
1258
+ # define graphene_simd4f_zero_zw(v) \
1259
+ (__extension__ ({ \
1260
+ graphene_simd4f_union_t __u = { (v) }; \
1261
+ graphene_simd4f_init (__u.f[0], __u.f[1], 0.f, 0.f); \
1262
+ }))
1263
+
1264
+ # define graphene_simd4f_merge_w(s,v) \
1265
+ (__extension__ ({ \
1266
+ graphene_simd4f_union_t __u = { (s) }; \
1267
+ graphene_simd4f_init (__u.f[0], __u.f[1], __u.f[2], (v)); \
1268
+ }))
1269
+
1270
+ # define graphene_simd4f_merge_high(a,b) \
1271
+ (__extension__ ({ \
1272
+ graphene_simd4f_union_t __u_a = { (a) }; \
1273
+ graphene_simd4f_union_t __u_b = { (b) }; \
1274
+ graphene_simd4f_init (__u_a.f[2], __u_a.f[3], __u_b.f[2], __u_b.f[3]); \
1275
+ }))
1276
+
1277
+ # define graphene_simd4f_merge_low(a,b) \
1278
+ (__extension__ ({ \
1279
+ graphene_simd4f_union_t __u_a = { (a) }; \
1280
+ graphene_simd4f_union_t __u_b = { (b) }; \
1281
+ graphene_simd4f_init (__u_a.f[0], __u_a.f[1], __u_b.f[0], __u_b.f[1]); \
1282
+ }))
1283
+
1284
+ # define graphene_simd4f_flip_sign_0101(s) \
1285
+ (__extension__ ({ \
1286
+ const unsigned int __upnpn[4] = { \
1287
+ 0x00000000, \
1288
+ 0x80000000, \
1289
+ 0x00000000, \
1290
+ 0x80000000 \
1291
+ }; \
1292
+ const uint32x4_t __pnpn = vld1q_u32 (__upnpn); \
1293
+ (graphene_simd4f_t) vreinterpretq_f32_u32 (veorq_u32 (vreinterpretq_u32_f32 ((s)), __pnpn)); \
1294
+ }))
1295
+
1296
+ # define graphene_simd4f_flip_sign_1010(s) \
1297
+ (__extension__ ({ \
1298
+ const unsigned int __unpnp[4] = { \
1299
+ 0x80000000, \
1300
+ 0x00000000, \
1301
+ 0x80000000, \
1302
+ 0x00000000 \
1303
+ }; \
1304
+ const uint32x4_t __npnp = vld1q_u32 (__unpnp); \
1305
+ (graphene_simd4f_t) vreinterpretq_f32_u32 (veorq_u32 (vreinterpretq_u32_f32 ((s)), __npnp)); \
1306
+ }))
1307
+
1308
+ # define _graphene_movemask(a) \
1309
+ (__extension__ ({ \
1310
+ const int8_t __attribute__ ((aligned (16))) __xr[8] = { -7,-6,-5,-4,-3,-2,-1,0 }; \
1311
+ const uint8x8_t __mask_and = vdup_n_u8 (0x80); \
1312
+ const int8x8_t __mask_shift = vld1_s8 (__xr); \
1313
+ uint8x8_t __lo = vget_low_u8 ((a)); \
1314
+ uint8x8_t __hi = vget_high_u8 ((a)); \
1315
+ __lo = vand_u8 (__lo, __mask_and); \
1316
+ __lo = vshl_u8 (__lo, __mask_shift); \
1317
+ __hi = vand_u8 (__hi, __mask_and); \
1318
+ __hi = vshl_u8 (__hi, __mask_shift); \
1319
+ __lo = vpadd_u8 (__lo, __lo); \
1320
+ __lo = vpadd_u8 (__lo, __lo); \
1321
+ __lo = vpadd_u8 (__lo, __lo); \
1322
+ __hi = vpadd_u8 (__hi, __hi); \
1323
+ __hi = vpadd_u8 (__hi, __hi); \
1324
+ __hi = vpadd_u8 (__hi, __hi); \
1325
+ (bool) ((__hi[0] << 8) | (__lo[0] & 0xff)); \
1326
+ }))
1327
+
1328
+ # define graphene_simd4f_cmp_eq(a,b) \
1329
+ (__extension__ ({ \
1330
+ const graphene_simd4f_union_t __u_a = { (a) }; \
1331
+ const graphene_simd4f_union_t __u_b = { (b) }; \
1332
+ (bool) (__u_a.f[0] == __u_b.f[0] && \
1333
+ __u_a.f[1] == __u_b.f[1] && \
1334
+ __u_a.f[2] == __u_b.f[2] && \
1335
+ __u_a.f[3] == __u_b.f[3]); \
1336
+ }))
1337
+
1338
+ # define graphene_simd4f_cmp_neq(a,b) \
1339
+ (__extension__ ({ \
1340
+ const graphene_simd4f_union_t __u_a = { (a) }; \
1341
+ const graphene_simd4f_union_t __u_b = { (b) }; \
1342
+ (bool) (__u_a.f[0] != __u_b.f[0] && \
1343
+ __u_a.f[1] != __u_b.f[1] && \
1344
+ __u_a.f[2] != __u_b.f[2] && \
1345
+ __u_a.f[3] != __u_b.f[3]); \
1346
+ }))
1347
+
1348
+ # define graphene_simd4f_cmp_lt(a,b) \
1349
+ (__extension__ ({ \
1350
+ const uint8x16_t __mask = vreinterpretq_u8_u32 (vcltq_f32 ((a), (b))); \
1351
+ (bool) (_graphene_movemask (__mask) != 0); \
1352
+ }))
1353
+
1354
+ # define graphene_simd4f_cmp_le(a,b) \
1355
+ (__extension__ ({ \
1356
+ const uint8x16_t __mask = vreinterpretq_u8_u32 (vcleq_f32 ((a), (b))); \
1357
+ (bool) (_graphene_movemask (__mask) != 0); \
1358
+ }))
1359
+
1360
+ # define graphene_simd4f_cmp_ge(a,b) \
1361
+ (__extension__ ({ \
1362
+ const uint8x16_t __mask = vreinterpretq_u8_u32 (vcgeq_f32 ((a), (b))); \
1363
+ (bool) (_graphene_movemask (__mask) != 0); \
1364
+ }))
1365
+
1366
+ # define graphene_simd4f_cmp_gt(a,b) \
1367
+ (__extension__ ({ \
1368
+ const uint8x16_t __mask = vreinterpretq_u8_u32 (vcgeq_f32 ((a), (b))); \
1369
+ (bool) (_graphene_movemask (__mask) != 0); \
1370
+ }))
1371
+
1372
+ # define graphene_simd4f_neg(s) \
1373
+ (__extension__ ({ \
1374
+ const unsigned int __umask[4] = { \
1375
+ 0x80000000, \
1376
+ 0x80000000, \
1377
+ 0x80000000, \
1378
+ 0x80000000 \
1379
+ }; \
1380
+ const uint32x4_t __mask = vld1q_u32 (__umask); \
1381
+ (graphene_simd4f_t) vreinterpretq_f32_u32 (veorq_u32 (vreinterpretq_u32_f32 ((s)), __mask)); \
1382
+ }))
1383
+
1384
+ #elif defined(__GI_SCANNER__) || defined(GRAPHENE_USE_SCALAR)
1385
+
1386
+ /* Fallback implementation using scalar types */
1387
+
1388
+ #define graphene_simd4f_init(x,y,z,w) \
1389
+ (graphene_simd4f_init ((x), (y), (z), (w)))
1390
+ #define graphene_simd4f_init_zero() \
1391
+ (graphene_simd4f_init_zero ())
1392
+ #define graphene_simd4f_init_4f(v) \
1393
+ (graphene_simd4f_init_4f ((const float *) (v)))
1394
+ #define graphene_simd4f_init_3f(v) \
1395
+ (graphene_simd4f_init_3f ((const float *) (v)))
1396
+ #define graphene_simd4f_init_2f(v) \
1397
+ (graphene_simd4f_init_2f ((const float *) (v)))
1398
+ #define graphene_simd4f_dup_4f(s,v) \
1399
+ (graphene_simd4f_dup_4f ((s), (float *) (v)))
1400
+ #define graphene_simd4f_dup_3f(s,v) \
1401
+ (graphene_simd4f_dup_3f ((s), (float *) (v)))
1402
+ #define graphene_simd4f_dup_2f(s,v) \
1403
+ (graphene_simd4f_dup_2f ((s), (float *) (v)))
1404
+ #define graphene_simd4f_get(s,i) \
1405
+ (graphene_simd4f_get ((s), (i)))
1406
+ #define graphene_simd4f_get_x(s) \
1407
+ (graphene_simd4f_get_x ((s)))
1408
+ #define graphene_simd4f_get_y(s) \
1409
+ (graphene_simd4f_get_y ((s)))
1410
+ #define graphene_simd4f_get_z(s) \
1411
+ (graphene_simd4f_get_z ((s)))
1412
+ #define graphene_simd4f_get_w(s) \
1413
+ (graphene_simd4f_get_w ((s)))
1414
+ #define graphene_simd4f_splat(v) \
1415
+ (graphene_simd4f_splat ((v)))
1416
+ #define graphene_simd4f_splat_x(s) \
1417
+ (graphene_simd4f_splat_x ((s)))
1418
+ #define graphene_simd4f_splat_y(s) \
1419
+ (graphene_simd4f_splat_y ((s)))
1420
+ #define graphene_simd4f_splat_z(s) \
1421
+ (graphene_simd4f_splat_z ((s)))
1422
+ #define graphene_simd4f_splat_w(s) \
1423
+ (graphene_simd4f_splat_w ((s)))
1424
+ #define graphene_simd4f_add(a,b) \
1425
+ (graphene_simd4f_add ((a), (b)))
1426
+ #define graphene_simd4f_sub(a,b) \
1427
+ (graphene_simd4f_sub ((a), (b)))
1428
+ #define graphene_simd4f_mul(a,b) \
1429
+ (graphene_simd4f_mul ((a), (b)))
1430
+ #define graphene_simd4f_div(a,b) \
1431
+ (graphene_simd4f_div ((a), (b)))
1432
+ #define graphene_simd4f_sqrt(s) \
1433
+ (graphene_simd4f_sqrt ((s)))
1434
+ #define graphene_simd4f_rsqrt(s) \
1435
+ (graphene_simd4f_rsqrt ((s)))
1436
+ #define graphene_simd4f_reciprocal(s) \
1437
+ (graphene_simd4f_reciprocal ((s)))
1438
+ #define graphene_simd4f_cross3(a,b) \
1439
+ (graphene_simd4f_cross3 ((a), (b)))
1440
+ #define graphene_simd4f_dot3(a,b) \
1441
+ (graphene_simd4f_dot3 ((a), (b)))
1442
+ #define graphene_simd4f_dot3_scalar(a,b) \
1443
+ (graphene_simd4f_dot3_scalar ((a), (b)))
1444
+ #define graphene_simd4f_min(a,b) \
1445
+ (graphene_simd4f_min ((a), (b)))
1446
+ #define graphene_simd4f_max(a,b) \
1447
+ (graphene_simd4f_max ((a), (b)))
1448
+ #define graphene_simd4f_shuffle_wxyz(s) \
1449
+ (graphene_simd4f_shuffle_wxyz ((s)))
1450
+ #define graphene_simd4f_shuffle_zwxy(s) \
1451
+ (graphene_simd4f_shuffle_zwxy ((s)))
1452
+ #define graphene_simd4f_shuffle_yzwx(s) \
1453
+ (graphene_simd4f_shuffle_yzwx ((s)))
1454
+ #define graphene_simd4f_flip_sign_0101(s) \
1455
+ (graphene_simd4f_flip_sign_0101 ((s)))
1456
+ #define graphene_simd4f_flip_sign_1010(s) \
1457
+ (graphene_simd4f_flip_sign_1010 ((s)))
1458
+ #define graphene_simd4f_zero_w(v) \
1459
+ (graphene_simd4f_zero_w ((v)))
1460
+ #define graphene_simd4f_zero_zw(v) \
1461
+ (graphene_simd4f_zero_zw ((v)))
1462
+ #define graphene_simd4f_merge_w(s,v) \
1463
+ (graphene_simd4f_merge_w ((s), (v)))
1464
+ #define graphene_simd4f_merge_high(a,b) \
1465
+ (graphene_simd4f_merge_high ((a), (b)))
1466
+ #define graphene_simd4f_merge_low(a,b) \
1467
+ (graphene_simd4f_merge_low ((a), (b)))
1468
+ #define graphene_simd4f_cmp_eq(a,b) \
1469
+ (graphene_simd4f_cmp_eq ((a), (b)))
1470
+ #define graphene_simd4f_cmp_neq(a,b) \
1471
+ (graphene_simd4f_cmp_neq ((a), (b)))
1472
+ #define graphene_simd4f_cmp_lt(a,b) \
1473
+ (graphene_simd4f_cmp_lt ((a), (b)))
1474
+ #define graphene_simd4f_cmp_le(a,b) \
1475
+ (graphene_simd4f_cmp_le ((a), (b)))
1476
+ #define graphene_simd4f_cmp_ge(a,b) \
1477
+ (graphene_simd4f_cmp_ge ((a), (b)))
1478
+ #define graphene_simd4f_cmp_gt(a,b) \
1479
+ (graphene_simd4f_cmp_gt ((a), (b)))
1480
+ #define graphene_simd4f_neg(s) \
1481
+ (graphene_simd4f_neg ((s)))
1482
+
1483
+ #else
1484
+ # error "Unsupported simd4f implementation."
1485
+ #endif
1486
+
1487
+ /* Generic operations, inlined */
1488
+
1489
+ /**
1490
+ * graphene_simd4f_madd:
1491
+ * @m1: a #graphene_simd4f_t
1492
+ * @m2: a #graphene_simd4f_t
1493
+ * @a: a #graphene_simd4f_t
1494
+ *
1495
+ * Adds @a to the product of @m1 and @m2.
1496
+ *
1497
+ * Returns: the result vector
1498
+ *
1499
+ * Since: 1.0
1500
+ */
1501
+ static inline graphene_simd4f_t
1502
+ graphene_simd4f_madd (const graphene_simd4f_t m1,
1503
+ const graphene_simd4f_t m2,
1504
+ const graphene_simd4f_t a)
1505
+ {
1506
+ return graphene_simd4f_add (graphene_simd4f_mul (m1, m2), a);
1507
+ }
1508
+
1509
+ /**
1510
+ * graphene_simd4f_sum:
1511
+ * @v: a #graphene_simd4f_t
1512
+ *
1513
+ * Sums all components of the given vector.
1514
+ *
1515
+ * Returns: a vector with all components set to be the
1516
+ * sum of the passed #graphene_simd4f_t
1517
+ *
1518
+ * Since: 1.0
1519
+ */
1520
+ static inline graphene_simd4f_t
1521
+ graphene_simd4f_sum (const graphene_simd4f_t v)
1522
+ {
1523
+ const graphene_simd4f_t x = graphene_simd4f_splat_x (v);
1524
+ const graphene_simd4f_t y = graphene_simd4f_splat_y (v);
1525
+ const graphene_simd4f_t z = graphene_simd4f_splat_z (v);
1526
+ const graphene_simd4f_t w = graphene_simd4f_splat_w (v);
1527
+
1528
+ return graphene_simd4f_add (graphene_simd4f_add (x, y),
1529
+ graphene_simd4f_add (z, w));
1530
+ }
1531
+
1532
+ /**
1533
+ * graphene_simd4f_sum_scalar:
1534
+ * @v: a #graphene_simd4f_t
1535
+ *
1536
+ * Sums all the components of the given vector.
1537
+ *
1538
+ * Returns: a scalar value with the sum of the components
1539
+ * of the given #graphene_simd4f_t
1540
+ *
1541
+ * Since: 1.0
1542
+ */
1543
+ static inline float
1544
+ graphene_simd4f_sum_scalar (const graphene_simd4f_t v)
1545
+ {
1546
+ return graphene_simd4f_get_x (graphene_simd4f_sum (v));
1547
+ }
1548
+
1549
+ /**
1550
+ * graphene_simd4f_dot4:
1551
+ * @a: a #graphene_simd4f_t
1552
+ * @b: a #graphene_simd4f_t
1553
+ *
1554
+ * Computes the dot product of all the components of the two
1555
+ * given #graphene_simd4f_t.
1556
+ *
1557
+ * Returns: a vector whose components are all set to be the
1558
+ * dot product of the components of the two operands
1559
+ *
1560
+ * Since: 1.0
1561
+ */
1562
+ static inline graphene_simd4f_t
1563
+ graphene_simd4f_dot4 (const graphene_simd4f_t a,
1564
+ const graphene_simd4f_t b)
1565
+ {
1566
+ return graphene_simd4f_sum (graphene_simd4f_mul (a, b));
1567
+ }
1568
+
1569
+ /**
1570
+ * graphene_simd4f_dot2:
1571
+ * @a: a #graphene_simd4f_t
1572
+ * @b: a #graphene_simd4f_t
1573
+ *
1574
+ * Computes the dot product of the first two components of the
1575
+ * two given #graphene_simd4f_t.
1576
+ *
1577
+ * Returns: a vector whose components are all set to the
1578
+ * dot product of the components of the two operands
1579
+ *
1580
+ * Since: 1.0
1581
+ */
1582
+ static inline graphene_simd4f_t
1583
+ graphene_simd4f_dot2 (const graphene_simd4f_t a,
1584
+ const graphene_simd4f_t b)
1585
+ {
1586
+ const graphene_simd4f_t m = graphene_simd4f_mul (a, b);
1587
+ const graphene_simd4f_t x = graphene_simd4f_splat_x (m);
1588
+ const graphene_simd4f_t y = graphene_simd4f_splat_y (m);
1589
+
1590
+ return graphene_simd4f_add (x, y);
1591
+ }
1592
+
1593
+ /**
1594
+ * graphene_simd4f_length4:
1595
+ * @v: a #graphene_simd4f_t
1596
+ *
1597
+ * Computes the length of the given #graphene_simd4f_t vector,
1598
+ * using all four of its components.
1599
+ *
1600
+ * Returns: the length vector
1601
+ *
1602
+ * Since: 1.0
1603
+ */
1604
+ static inline graphene_simd4f_t
1605
+ graphene_simd4f_length4 (const graphene_simd4f_t v)
1606
+ {
1607
+ return graphene_simd4f_sqrt (graphene_simd4f_dot4 (v, v));
1608
+ }
1609
+
1610
+ /**
1611
+ * graphene_simd4f_length3:
1612
+ * @v: a #graphene_simd4f_t
1613
+ *
1614
+ * Computes the length of the given #graphene_simd4f_t vector,
1615
+ * using the first three of its components.
1616
+ *
1617
+ * Returns: the length vector
1618
+ *
1619
+ * Since: 1.0
1620
+ */
1621
+ static inline graphene_simd4f_t
1622
+ graphene_simd4f_length3 (const graphene_simd4f_t v)
1623
+ {
1624
+ return graphene_simd4f_sqrt (graphene_simd4f_dot3 (v, v));
1625
+ }
1626
+
1627
+ /**
1628
+ * graphene_simd4f_length2:
1629
+ * @v: a #graphene_simd4f_t
1630
+ *
1631
+ * Computes the length of the given #graphene_simd4f_t vector,
1632
+ * using the first two of its components.
1633
+ *
1634
+ * Returns: the length vector
1635
+ *
1636
+ * Since: 1.0
1637
+ */
1638
+ static inline graphene_simd4f_t
1639
+ graphene_simd4f_length2 (const graphene_simd4f_t v)
1640
+ {
1641
+ return graphene_simd4f_sqrt (graphene_simd4f_dot2 (v, v));
1642
+ }
1643
+
1644
+ /**
1645
+ * graphene_simd4f_normalize4:
1646
+ * @v: a #graphene_simd4f_t
1647
+ *
1648
+ * Computes the normalization of the given #graphene_simd4f_t vector,
1649
+ * using all of its components.
1650
+ *
1651
+ * Returns: the normalized vector
1652
+ *
1653
+ * Since: 1.0
1654
+ */
1655
+ static inline graphene_simd4f_t
1656
+ graphene_simd4f_normalize4 (const graphene_simd4f_t v)
1657
+ {
1658
+ graphene_simd4f_t invlen = graphene_simd4f_rsqrt (graphene_simd4f_dot4 (v, v));
1659
+ return graphene_simd4f_mul (v, invlen);
1660
+ }
1661
+
1662
+ /**
1663
+ * graphene_simd4f_normalize3:
1664
+ * @v: a #graphene_simd4f_t
1665
+ *
1666
+ * Computes the normalization of the given #graphene_simd4f_t vector,
1667
+ * using the first three of its components.
1668
+ *
1669
+ * Returns: the normalized vector
1670
+ *
1671
+ * Since: 1.0
1672
+ */
1673
+ static inline graphene_simd4f_t
1674
+ graphene_simd4f_normalize3 (const graphene_simd4f_t v)
1675
+ {
1676
+ graphene_simd4f_t invlen = graphene_simd4f_rsqrt (graphene_simd4f_dot3 (v, v));
1677
+ return graphene_simd4f_mul (v, invlen);
1678
+ }
1679
+
1680
+ /**
1681
+ * graphene_simd4f_normalize2:
1682
+ * @v: a #graphene_simd4f_t
1683
+ *
1684
+ * Computes the normalization of the given #graphene_simd4f_t vector,
1685
+ * using the first two of its components.
1686
+ *
1687
+ * Returns: the normalized vector
1688
+ *
1689
+ * Since: 1.0
1690
+ */
1691
+ static inline graphene_simd4f_t
1692
+ graphene_simd4f_normalize2 (const graphene_simd4f_t v)
1693
+ {
1694
+ graphene_simd4f_t invlen = graphene_simd4f_rsqrt (graphene_simd4f_dot2 (v, v));
1695
+ return graphene_simd4f_mul (v, invlen);
1696
+ }
1697
+
1698
+ /**
1699
+ * graphene_simd4f_is_zero4:
1700
+ * @v: a #graphene_simd4f_t
1701
+ *
1702
+ * Checks whether the given #graphene_simd4f_t has all its components
1703
+ * set to 0.
1704
+ *
1705
+ * Returns: `true` if all the vector components are zero
1706
+ *
1707
+ * Since: 1.0
1708
+ */
1709
+ static inline bool
1710
+ graphene_simd4f_is_zero4 (const graphene_simd4f_t v)
1711
+ {
1712
+ graphene_simd4f_t zero = graphene_simd4f_init_zero ();
1713
+ return graphene_simd4f_cmp_eq (v, zero);
1714
+ }
1715
+
1716
+ /**
1717
+ * graphene_simd4f_is_zero3:
1718
+ * @v: a #graphene_simd4f_t
1719
+ *
1720
+ * Checks whether the given #graphene_simd4f_t has the first three of
1721
+ * its components set to 0.
1722
+ *
1723
+ * Returns: `true` if the vector's components are zero
1724
+ *
1725
+ * Since: 1.0
1726
+ */
1727
+ static inline bool
1728
+ graphene_simd4f_is_zero3 (const graphene_simd4f_t v)
1729
+ {
1730
+ return graphene_simd4f_get_x (v) == 0.f &&
1731
+ graphene_simd4f_get_y (v) == 0.f &&
1732
+ graphene_simd4f_get_z (v) == 0.f;
1733
+ }
1734
+
1735
+ /**
1736
+ * graphene_simd4f_is_zero2:
1737
+ * @v: a #graphene_simd4f_t
1738
+ *
1739
+ * Checks whether the given #graphene_simd4f_t has the first two of
1740
+ * its components set to 0.
1741
+ *
1742
+ * Returns: `true` if the vector's components are zero
1743
+ *
1744
+ * Since: 1.0
1745
+ */
1746
+ static inline bool
1747
+ graphene_simd4f_is_zero2 (const graphene_simd4f_t v)
1748
+ {
1749
+ return graphene_simd4f_get_x (v) == 0.f &&
1750
+ graphene_simd4f_get_y (v) == 0.f;
1751
+ }
1752
+
1753
+ /**
1754
+ * graphene_simd4f_interpolate:
1755
+ * @a: a #graphene_simd4f_t
1756
+ * @b: a #graphene_simd4f_t
1757
+ * @f: the interpolation factor
1758
+ *
1759
+ * Linearly interpolates all components of the two given
1760
+ * #graphene_simd4f_t vectors using the given factor @f.
1761
+ *
1762
+ * Returns: the intrerpolated vector
1763
+ *
1764
+ * Since: 1.0
1765
+ */
1766
+ static inline graphene_simd4f_t
1767
+ graphene_simd4f_interpolate (const graphene_simd4f_t a,
1768
+ const graphene_simd4f_t b,
1769
+ float f)
1770
+ {
1771
+ const graphene_simd4f_t one_minus_f = graphene_simd4f_sub (graphene_simd4f_splat (1.f),
1772
+ graphene_simd4f_splat (f));
1773
+
1774
+ return graphene_simd4f_add (graphene_simd4f_mul (one_minus_f, a),
1775
+ graphene_simd4f_mul (graphene_simd4f_splat (f), b));
1776
+ }
1777
+
1778
+ /**
1779
+ * graphene_simd4f_clamp:
1780
+ * @v: a #graphene_simd4f_t
1781
+ * @min: the lower boundary
1782
+ * @max: the upper boundary
1783
+ *
1784
+ * Ensures that all components of the vector @v are within
1785
+ * the components of the @lower and @upper boundaries.
1786
+ *
1787
+ * Returns: the clamped vector
1788
+ *
1789
+ * Since: 1.2
1790
+ */
1791
+ static inline graphene_simd4f_t
1792
+ graphene_simd4f_clamp (const graphene_simd4f_t v,
1793
+ const graphene_simd4f_t min,
1794
+ const graphene_simd4f_t max)
1795
+ {
1796
+ const graphene_simd4f_t tmp = graphene_simd4f_max (min, v);
1797
+
1798
+ return graphene_simd4f_min (tmp, max);
1799
+ }
1800
+
1801
+ /**
1802
+ * graphene_simd4f_clamp_scalar:
1803
+ * @v: a #graphene_simd4f_t
1804
+ * @min: the lower boundary
1805
+ * @max: the upper boundary
1806
+ *
1807
+ * Ensures that all components of the vector @v are within
1808
+ * the @lower and @upper boundary scalar values.
1809
+ *
1810
+ * Returns: the clamped vector
1811
+ *
1812
+ * Since: 1.2
1813
+ */
1814
+ static inline graphene_simd4f_t
1815
+ graphene_simd4f_clamp_scalar (const graphene_simd4f_t v,
1816
+ float min,
1817
+ float max)
1818
+ {
1819
+ return graphene_simd4f_clamp (v,
1820
+ graphene_simd4f_splat (min),
1821
+ graphene_simd4f_splat (max));
1822
+ }
1823
+
1824
+ /**
1825
+ * graphene_simd4f_min_val:
1826
+ * @v: a #graphene_simd4f_t
1827
+ *
1828
+ * Computes the minimum value of all the channels in the given vector.
1829
+ *
1830
+ * Returns: a vector whose components are all set to the
1831
+ * minimum value in the original vector
1832
+ *
1833
+ * Since: 1.4
1834
+ */
1835
+ static inline graphene_simd4f_t
1836
+ graphene_simd4f_min_val (const graphene_simd4f_t v)
1837
+ {
1838
+ graphene_simd4f_t s = v;
1839
+
1840
+ s = graphene_simd4f_min (s, graphene_simd4f_shuffle_wxyz (s));
1841
+ s = graphene_simd4f_min (s, graphene_simd4f_shuffle_zwxy (s));
1842
+
1843
+ return s;
1844
+ }
1845
+
1846
+ /**
1847
+ * graphene_simd4f_max_val:
1848
+ * @v: a #graphene_simd4f_t
1849
+ *
1850
+ * Computes the maximum value of all the channels in the given vector.
1851
+ *
1852
+ * Returns: a vector whose components are all set to the
1853
+ * maximum value in the original vector
1854
+ *
1855
+ * Since: 1.4
1856
+ */
1857
+ static inline graphene_simd4f_t
1858
+ graphene_simd4f_max_val (const graphene_simd4f_t v)
1859
+ {
1860
+ graphene_simd4f_t s = v;
1861
+
1862
+ s = graphene_simd4f_max (s, graphene_simd4f_shuffle_wxyz (s));
1863
+ s = graphene_simd4f_max (s, graphene_simd4f_shuffle_zwxy (s));
1864
+
1865
+ return s;
1866
+ }
1867
+
1868
+ GRAPHENE_END_DECLS
1869
+
1870
+ #endif /* __GRAPHENE_SIMD4F_H__ */