Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

836 lines
22KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6263 6386)
  16. EdgeTable::EdgeTable (Rectangle<int> area, const Path& path, const AffineTransform& transform)
  17. : bounds (area),
  18. // this is a very vague heuristic to make a rough guess at a good table size
  19. // for a given path, such that it's big enough to mostly avoid remapping, but also
  20. // not so big that it's wasteful for simple paths.
  21. maxEdgesPerLine (jmax (defaultEdgesPerLine / 2,
  22. 4 * (int) std::sqrt (path.data.size()))),
  23. lineStrideElements (maxEdgesPerLine * 2 + 1)
  24. {
  25. allocate();
  26. int* t = table;
  27. for (int i = bounds.getHeight(); --i >= 0;)
  28. {
  29. *t = 0;
  30. t += lineStrideElements;
  31. }
  32. auto leftLimit = scale * bounds.getX();
  33. auto topLimit = scale * bounds.getY();
  34. auto rightLimit = scale * bounds.getRight();
  35. auto heightLimit = scale * bounds.getHeight();
  36. PathFlatteningIterator iter (path, transform);
  37. while (iter.next())
  38. {
  39. auto y1 = roundToInt (iter.y1 * 256.0f);
  40. auto y2 = roundToInt (iter.y2 * 256.0f);
  41. if (y1 != y2)
  42. {
  43. y1 -= topLimit;
  44. y2 -= topLimit;
  45. auto startY = y1;
  46. int direction = -1;
  47. if (y1 > y2)
  48. {
  49. std::swap (y1, y2);
  50. direction = 1;
  51. }
  52. if (y1 < 0)
  53. y1 = 0;
  54. if (y2 > heightLimit)
  55. y2 = heightLimit;
  56. if (y1 < y2)
  57. {
  58. const double startX = 256.0f * iter.x1;
  59. const double multiplier = (iter.x2 - iter.x1) / (iter.y2 - iter.y1);
  60. auto stepSize = jlimit (1, 256, 256 / (1 + (int) std::abs (multiplier)));
  61. do
  62. {
  63. auto step = jmin (stepSize, y2 - y1, 256 - (y1 & 255));
  64. auto x = roundToInt (startX + multiplier * ((y1 + (step >> 1)) - startY));
  65. if (x < leftLimit)
  66. x = leftLimit;
  67. else if (x >= rightLimit)
  68. x = rightLimit - 1;
  69. addEdgePoint (x, y1 / scale, direction * step);
  70. y1 += step;
  71. }
  72. while (y1 < y2);
  73. }
  74. }
  75. }
  76. sanitiseLevels (path.isUsingNonZeroWinding());
  77. }
  78. EdgeTable::EdgeTable (Rectangle<int> rectangleToAdd)
  79. : bounds (rectangleToAdd),
  80. maxEdgesPerLine (defaultEdgesPerLine),
  81. lineStrideElements (defaultEdgesPerLine * 2 + 1)
  82. {
  83. allocate();
  84. table[0] = 0;
  85. auto x1 = scale * rectangleToAdd.getX();
  86. auto x2 = scale * rectangleToAdd.getRight();
  87. int* t = table;
  88. for (int i = rectangleToAdd.getHeight(); --i >= 0;)
  89. {
  90. t[0] = 2;
  91. t[1] = x1;
  92. t[2] = 255;
  93. t[3] = x2;
  94. t[4] = 0;
  95. t += lineStrideElements;
  96. }
  97. }
  98. EdgeTable::EdgeTable (const RectangleList<int>& rectanglesToAdd)
  99. : bounds (rectanglesToAdd.getBounds()),
  100. maxEdgesPerLine (defaultEdgesPerLine),
  101. lineStrideElements (defaultEdgesPerLine * 2 + 1),
  102. needToCheckEmptiness (true)
  103. {
  104. allocate();
  105. clearLineSizes();
  106. for (auto& r : rectanglesToAdd)
  107. {
  108. auto x1 = scale * r.getX();
  109. auto x2 = scale * r.getRight();
  110. auto y = r.getY() - bounds.getY();
  111. for (int j = r.getHeight(); --j >= 0;)
  112. addEdgePointPair (x1, x2, y++, 255);
  113. }
  114. sanitiseLevels (true);
  115. }
  116. EdgeTable::EdgeTable (const RectangleList<float>& rectanglesToAdd)
  117. : bounds (rectanglesToAdd.getBounds().getSmallestIntegerContainer()),
  118. maxEdgesPerLine (rectanglesToAdd.getNumRectangles() * 2),
  119. lineStrideElements (rectanglesToAdd.getNumRectangles() * 4 + 1)
  120. {
  121. bounds.setHeight (bounds.getHeight() + 1);
  122. allocate();
  123. clearLineSizes();
  124. for (auto& r : rectanglesToAdd)
  125. {
  126. auto x1 = roundToInt ((float) scale * r.getX());
  127. auto x2 = roundToInt ((float) scale * r.getRight());
  128. auto y1 = roundToInt ((float) scale * r.getY()) - (bounds.getY() * scale);
  129. auto y2 = roundToInt ((float) scale * r.getBottom()) - (bounds.getY() * scale);
  130. if (x2 <= x1 || y2 <= y1)
  131. continue;
  132. auto y = y1 / scale;
  133. auto lastLine = y2 / scale;
  134. if (y == lastLine)
  135. {
  136. addEdgePointPair (x1, x2, y, y2 - y1);
  137. }
  138. else
  139. {
  140. addEdgePointPair (x1, x2, y++, 255 - (y1 & 255));
  141. while (y < lastLine)
  142. addEdgePointPair (x1, x2, y++, 255);
  143. jassert (y < bounds.getHeight());
  144. addEdgePointPair (x1, x2, y, y2 & 255);
  145. }
  146. }
  147. sanitiseLevels (true);
  148. }
  149. EdgeTable::EdgeTable (Rectangle<float> rectangleToAdd)
  150. : bounds ((int) std::floor (rectangleToAdd.getX()),
  151. roundToInt (rectangleToAdd.getY() * 256.0f) / scale,
  152. 2 + (int) rectangleToAdd.getWidth(),
  153. 2 + (int) rectangleToAdd.getHeight()),
  154. maxEdgesPerLine (defaultEdgesPerLine),
  155. lineStrideElements ((defaultEdgesPerLine * 2) + 1)
  156. {
  157. jassert (! rectangleToAdd.isEmpty());
  158. allocate();
  159. table[0] = 0;
  160. auto x1 = roundToInt ((float) scale * rectangleToAdd.getX());
  161. auto x2 = roundToInt ((float) scale * rectangleToAdd.getRight());
  162. auto y1 = roundToInt ((float) scale * rectangleToAdd.getY()) - (bounds.getY() * scale);
  163. auto y2 = roundToInt ((float) scale * rectangleToAdd.getBottom()) - (bounds.getY() * scale);
  164. jassert (y1 < 256);
  165. if (x2 <= x1 || y2 <= y1)
  166. {
  167. bounds.setHeight (0);
  168. return;
  169. }
  170. int lineY = 0;
  171. int* t = table;
  172. if ((y1 / scale) == (y2 / scale))
  173. {
  174. t[0] = 2;
  175. t[1] = x1;
  176. t[2] = y2 - y1;
  177. t[3] = x2;
  178. t[4] = 0;
  179. ++lineY;
  180. t += lineStrideElements;
  181. }
  182. else
  183. {
  184. t[0] = 2;
  185. t[1] = x1;
  186. t[2] = 255 - (y1 & 255);
  187. t[3] = x2;
  188. t[4] = 0;
  189. ++lineY;
  190. t += lineStrideElements;
  191. while (lineY < (y2 / scale))
  192. {
  193. t[0] = 2;
  194. t[1] = x1;
  195. t[2] = 255;
  196. t[3] = x2;
  197. t[4] = 0;
  198. ++lineY;
  199. t += lineStrideElements;
  200. }
  201. jassert (lineY < bounds.getHeight());
  202. t[0] = 2;
  203. t[1] = x1;
  204. t[2] = y2 & 255;
  205. t[3] = x2;
  206. t[4] = 0;
  207. ++lineY;
  208. t += lineStrideElements;
  209. }
  210. while (lineY < bounds.getHeight())
  211. {
  212. t[0] = 0;
  213. t += lineStrideElements;
  214. ++lineY;
  215. }
  216. }
  217. EdgeTable::EdgeTable (const EdgeTable& other)
  218. {
  219. operator= (other);
  220. }
  221. EdgeTable& EdgeTable::operator= (const EdgeTable& other)
  222. {
  223. bounds = other.bounds;
  224. maxEdgesPerLine = other.maxEdgesPerLine;
  225. lineStrideElements = other.lineStrideElements;
  226. needToCheckEmptiness = other.needToCheckEmptiness;
  227. allocate();
  228. copyEdgeTableData (table, lineStrideElements, other.table, lineStrideElements, bounds.getHeight());
  229. return *this;
  230. }
  231. EdgeTable::~EdgeTable()
  232. {
  233. }
  234. //==============================================================================
  235. static size_t getEdgeTableAllocationSize (int lineStride, int height) noexcept
  236. {
  237. // (leave an extra line at the end for use as scratch space)
  238. return (size_t) (lineStride * (2 + jmax (0, height)));
  239. }
  240. void EdgeTable::allocate()
  241. {
  242. table.malloc (getEdgeTableAllocationSize (lineStrideElements, bounds.getHeight()));
  243. }
  244. void EdgeTable::clearLineSizes() noexcept
  245. {
  246. int* t = table;
  247. for (int i = bounds.getHeight(); --i >= 0;)
  248. {
  249. *t = 0;
  250. t += lineStrideElements;
  251. }
  252. }
  253. void EdgeTable::copyEdgeTableData (int* dest, int destLineStride, const int* src, int srcLineStride, int numLines) noexcept
  254. {
  255. while (--numLines >= 0)
  256. {
  257. memcpy (dest, src, (size_t) (src[0] * 2 + 1) * sizeof (int));
  258. src += srcLineStride;
  259. dest += destLineStride;
  260. }
  261. }
  262. void EdgeTable::sanitiseLevels (const bool useNonZeroWinding) noexcept
  263. {
  264. // Convert the table from relative windings to absolute levels..
  265. int* lineStart = table;
  266. for (int y = bounds.getHeight(); --y >= 0;)
  267. {
  268. auto num = lineStart[0];
  269. if (num > 0)
  270. {
  271. auto* items = reinterpret_cast<LineItem*> (lineStart + 1);
  272. auto* itemsEnd = items + num;
  273. // sort the X coords
  274. std::sort (items, itemsEnd);
  275. auto* src = items;
  276. auto correctedNum = num;
  277. int level = 0;
  278. while (src < itemsEnd)
  279. {
  280. level += src->level;
  281. auto x = src->x;
  282. ++src;
  283. while (src < itemsEnd && src->x == x)
  284. {
  285. level += src->level;
  286. ++src;
  287. --correctedNum;
  288. }
  289. auto corrected = std::abs (level);
  290. if (corrected / scale)
  291. {
  292. if (useNonZeroWinding)
  293. {
  294. corrected = 255;
  295. }
  296. else
  297. {
  298. corrected &= 511;
  299. if (corrected / scale)
  300. corrected = 511 - corrected;
  301. }
  302. }
  303. items->x = x;
  304. items->level = corrected;
  305. ++items;
  306. }
  307. lineStart[0] = correctedNum;
  308. (items - 1)->level = 0; // force the last level to 0, just in case something went wrong in creating the table
  309. }
  310. lineStart += lineStrideElements;
  311. }
  312. }
  313. void EdgeTable::remapTableForNumEdges (const int newNumEdgesPerLine)
  314. {
  315. if (newNumEdgesPerLine != maxEdgesPerLine)
  316. {
  317. maxEdgesPerLine = newNumEdgesPerLine;
  318. jassert (bounds.getHeight() > 0);
  319. auto newLineStrideElements = maxEdgesPerLine * 2 + 1;
  320. HeapBlock<int> newTable (getEdgeTableAllocationSize (newLineStrideElements, bounds.getHeight()));
  321. copyEdgeTableData (newTable, newLineStrideElements, table, lineStrideElements, bounds.getHeight());
  322. table.swapWith (newTable);
  323. lineStrideElements = newLineStrideElements;
  324. }
  325. }
  326. inline void EdgeTable::remapWithExtraSpace (int numPoints)
  327. {
  328. remapTableForNumEdges (numPoints * 2);
  329. jassert (numPoints < maxEdgesPerLine);
  330. }
  331. void EdgeTable::optimiseTable()
  332. {
  333. int maxLineElements = 0;
  334. for (int i = bounds.getHeight(); --i >= 0;)
  335. maxLineElements = jmax (maxLineElements, table[i * lineStrideElements]);
  336. remapTableForNumEdges (maxLineElements);
  337. }
  338. void EdgeTable::addEdgePoint (const int x, const int y, const int winding)
  339. {
  340. jassert (y >= 0 && y < bounds.getHeight());
  341. auto* line = table + lineStrideElements * y;
  342. auto numPoints = line[0];
  343. if (numPoints >= maxEdgesPerLine)
  344. {
  345. remapWithExtraSpace (numPoints);
  346. line = table + lineStrideElements * y;
  347. }
  348. line[0] = numPoints + 1;
  349. line += numPoints * 2;
  350. line[1] = x;
  351. line[2] = winding;
  352. }
  353. void EdgeTable::addEdgePointPair (int x1, int x2, int y, int winding)
  354. {
  355. jassert (y >= 0 && y < bounds.getHeight());
  356. auto* line = table + lineStrideElements * y;
  357. auto numPoints = line[0];
  358. if (numPoints + 1 >= maxEdgesPerLine)
  359. {
  360. remapWithExtraSpace (numPoints + 1);
  361. line = table + lineStrideElements * y;
  362. }
  363. line[0] = numPoints + 2;
  364. line += numPoints * 2;
  365. line[1] = x1;
  366. line[2] = winding;
  367. line[3] = x2;
  368. line[4] = -winding;
  369. }
  370. void EdgeTable::translate (float dx, int dy) noexcept
  371. {
  372. bounds.translate ((int) std::floor (dx), dy);
  373. int* lineStart = table;
  374. auto intDx = (int) (dx * 256.0f);
  375. for (int i = bounds.getHeight(); --i >= 0;)
  376. {
  377. auto* line = lineStart;
  378. lineStart += lineStrideElements;
  379. auto num = *line++;
  380. while (--num >= 0)
  381. {
  382. *line += intDx;
  383. line += 2;
  384. }
  385. }
  386. }
  387. void EdgeTable::multiplyLevels (float amount)
  388. {
  389. int* lineStart = table;
  390. auto multiplier = (int) (amount * 256.0f);
  391. for (int y = 0; y < bounds.getHeight(); ++y)
  392. {
  393. auto numPoints = lineStart[0];
  394. auto* item = reinterpret_cast<LineItem*> (lineStart + 1);
  395. lineStart += lineStrideElements;
  396. while (--numPoints > 0)
  397. {
  398. item->level = jmin (255, (item->level * multiplier) / scale);
  399. ++item;
  400. }
  401. }
  402. }
  403. void EdgeTable::intersectWithEdgeTableLine (const int y, const int* const otherLine)
  404. {
  405. jassert (y >= 0 && y < bounds.getHeight());
  406. auto* srcLine = table + lineStrideElements * y;
  407. auto srcNum1 = *srcLine;
  408. if (srcNum1 == 0)
  409. return;
  410. auto srcNum2 = *otherLine;
  411. if (srcNum2 == 0)
  412. {
  413. *srcLine = 0;
  414. return;
  415. }
  416. auto right = bounds.getRight() * scale;
  417. // optimise for the common case where our line lies entirely within a
  418. // single pair of points, as happens when clipping to a simple rect.
  419. if (srcNum2 == 2 && otherLine[2] >= 255)
  420. {
  421. clipEdgeTableLineToRange (srcLine, otherLine[1], jmin (right, otherLine[3]));
  422. return;
  423. }
  424. bool isUsingTempSpace = false;
  425. const int* src1 = srcLine + 1;
  426. auto x1 = *src1++;
  427. const int* src2 = otherLine + 1;
  428. auto x2 = *src2++;
  429. int destIndex = 0, destTotal = 0;
  430. int level1 = 0, level2 = 0;
  431. int lastX = std::numeric_limits<int>::min(), lastLevel = 0;
  432. while (srcNum1 > 0 && srcNum2 > 0)
  433. {
  434. int nextX;
  435. if (x1 <= x2)
  436. {
  437. if (x1 == x2)
  438. {
  439. level2 = *src2++;
  440. x2 = *src2++;
  441. --srcNum2;
  442. }
  443. nextX = x1;
  444. level1 = *src1++;
  445. x1 = *src1++;
  446. --srcNum1;
  447. }
  448. else
  449. {
  450. nextX = x2;
  451. level2 = *src2++;
  452. x2 = *src2++;
  453. --srcNum2;
  454. }
  455. if (nextX > lastX)
  456. {
  457. if (nextX >= right)
  458. break;
  459. lastX = nextX;
  460. auto nextLevel = (level1 * (level2 + 1)) / scale;
  461. jassert (isPositiveAndBelow (nextLevel, 256));
  462. if (nextLevel != lastLevel)
  463. {
  464. if (destTotal >= maxEdgesPerLine)
  465. {
  466. srcLine[0] = destTotal;
  467. if (isUsingTempSpace)
  468. {
  469. auto tempSize = (size_t) srcNum1 * 2 * sizeof (int);
  470. auto oldTemp = static_cast<int*> (alloca (tempSize));
  471. memcpy (oldTemp, src1, tempSize);
  472. remapTableForNumEdges (jmax (256, destTotal * 2));
  473. srcLine = table + lineStrideElements * y;
  474. auto* newTemp = table + lineStrideElements * bounds.getHeight();
  475. memcpy (newTemp, oldTemp, tempSize);
  476. src1 = newTemp;
  477. }
  478. else
  479. {
  480. remapTableForNumEdges (jmax (256, destTotal * 2));
  481. srcLine = table + lineStrideElements * y;
  482. }
  483. }
  484. ++destTotal;
  485. lastLevel = nextLevel;
  486. if (! isUsingTempSpace)
  487. {
  488. isUsingTempSpace = true;
  489. auto* temp = table + lineStrideElements * bounds.getHeight();
  490. memcpy (temp, src1, (size_t) srcNum1 * 2 * sizeof (int));
  491. src1 = temp;
  492. }
  493. srcLine[++destIndex] = nextX;
  494. srcLine[++destIndex] = nextLevel;
  495. }
  496. }
  497. }
  498. if (lastLevel > 0)
  499. {
  500. if (destTotal >= maxEdgesPerLine)
  501. {
  502. srcLine[0] = destTotal;
  503. remapTableForNumEdges (jmax (256, destTotal * 2));
  504. srcLine = table + lineStrideElements * y;
  505. }
  506. ++destTotal;
  507. srcLine[++destIndex] = right;
  508. srcLine[++destIndex] = 0;
  509. }
  510. srcLine[0] = destTotal;
  511. }
  512. void EdgeTable::clipEdgeTableLineToRange (int* dest, const int x1, const int x2) noexcept
  513. {
  514. int* lastItem = dest + (dest[0] * 2 - 1);
  515. if (x2 < lastItem[0])
  516. {
  517. if (x2 <= dest[1])
  518. {
  519. dest[0] = 0;
  520. return;
  521. }
  522. while (x2 < lastItem[-2])
  523. {
  524. --(dest[0]);
  525. lastItem -= 2;
  526. }
  527. lastItem[0] = x2;
  528. lastItem[1] = 0;
  529. }
  530. if (x1 > dest[1])
  531. {
  532. while (lastItem[0] > x1)
  533. lastItem -= 2;
  534. auto itemsRemoved = (int) (lastItem - (dest + 1)) / 2;
  535. if (itemsRemoved > 0)
  536. {
  537. dest[0] -= itemsRemoved;
  538. memmove (dest + 1, lastItem, (size_t) dest[0] * (sizeof (int) * 2));
  539. }
  540. dest[1] = x1;
  541. }
  542. }
  543. //==============================================================================
  544. void EdgeTable::clipToRectangle (Rectangle<int> r)
  545. {
  546. auto clipped = r.getIntersection (bounds);
  547. if (clipped.isEmpty())
  548. {
  549. needToCheckEmptiness = false;
  550. bounds.setHeight (0);
  551. }
  552. else
  553. {
  554. auto top = clipped.getY() - bounds.getY();
  555. auto bottom = clipped.getBottom() - bounds.getY();
  556. if (bottom < bounds.getHeight())
  557. bounds.setHeight (bottom);
  558. for (int i = 0; i < top; ++i)
  559. table[lineStrideElements * i] = 0;
  560. if (clipped.getX() > bounds.getX() || clipped.getRight() < bounds.getRight())
  561. {
  562. auto x1 = scale * clipped.getX();
  563. auto x2 = scale * jmin (bounds.getRight(), clipped.getRight());
  564. int* line = table + lineStrideElements * top;
  565. for (int i = bottom - top; --i >= 0;)
  566. {
  567. if (line[0] != 0)
  568. clipEdgeTableLineToRange (line, x1, x2);
  569. line += lineStrideElements;
  570. }
  571. }
  572. needToCheckEmptiness = true;
  573. }
  574. }
  575. void EdgeTable::excludeRectangle (Rectangle<int> r)
  576. {
  577. auto clipped = r.getIntersection (bounds);
  578. if (! clipped.isEmpty())
  579. {
  580. auto top = clipped.getY() - bounds.getY();
  581. auto bottom = clipped.getBottom() - bounds.getY();
  582. const int rectLine[] = { 4, std::numeric_limits<int>::min(), 255,
  583. scale * clipped.getX(), 0,
  584. scale * clipped.getRight(), 255,
  585. std::numeric_limits<int>::max(), 0 };
  586. for (int i = top; i < bottom; ++i)
  587. intersectWithEdgeTableLine (i, rectLine);
  588. needToCheckEmptiness = true;
  589. }
  590. }
  591. void EdgeTable::clipToEdgeTable (const EdgeTable& other)
  592. {
  593. auto clipped = other.bounds.getIntersection (bounds);
  594. if (clipped.isEmpty())
  595. {
  596. needToCheckEmptiness = false;
  597. bounds.setHeight (0);
  598. }
  599. else
  600. {
  601. auto top = clipped.getY() - bounds.getY();
  602. auto bottom = clipped.getBottom() - bounds.getY();
  603. if (bottom < bounds.getHeight())
  604. bounds.setHeight (bottom);
  605. if (clipped.getRight() < bounds.getRight())
  606. bounds.setRight (clipped.getRight());
  607. for (int i = 0; i < top; ++i)
  608. table[lineStrideElements * i] = 0;
  609. auto* otherLine = other.table + other.lineStrideElements * (clipped.getY() - other.bounds.getY());
  610. for (int i = top; i < bottom; ++i)
  611. {
  612. intersectWithEdgeTableLine (i, otherLine);
  613. otherLine += other.lineStrideElements;
  614. }
  615. needToCheckEmptiness = true;
  616. }
  617. }
  618. void EdgeTable::clipLineToMask (int x, int y, const uint8* mask, int maskStride, int numPixels)
  619. {
  620. y -= bounds.getY();
  621. if (y < 0 || y >= bounds.getHeight())
  622. return;
  623. needToCheckEmptiness = true;
  624. if (numPixels <= 0)
  625. {
  626. table[lineStrideElements * y] = 0;
  627. return;
  628. }
  629. auto* tempLine = static_cast<int*> (alloca ((size_t) (numPixels * 2 + 4) * sizeof (int)));
  630. int destIndex = 0, lastLevel = 0;
  631. while (--numPixels >= 0)
  632. {
  633. auto alpha = *mask;
  634. mask += maskStride;
  635. if (alpha != lastLevel)
  636. {
  637. tempLine[++destIndex] = (x * scale);
  638. tempLine[++destIndex] = alpha;
  639. lastLevel = alpha;
  640. }
  641. ++x;
  642. }
  643. if (lastLevel > 0)
  644. {
  645. tempLine[++destIndex] = (x * scale);
  646. tempLine[++destIndex] = 0;
  647. }
  648. tempLine[0] = destIndex >> 1;
  649. intersectWithEdgeTableLine (y, tempLine);
  650. }
  651. bool EdgeTable::isEmpty() noexcept
  652. {
  653. if (needToCheckEmptiness)
  654. {
  655. needToCheckEmptiness = false;
  656. int* t = table;
  657. for (int i = bounds.getHeight(); --i >= 0;)
  658. {
  659. if (t[0] > 1)
  660. return false;
  661. t += lineStrideElements;
  662. }
  663. bounds.setHeight (0);
  664. }
  665. return bounds.getHeight() == 0;
  666. }
  667. JUCE_END_IGNORE_WARNINGS_MSVC
  668. } // namespace juce