The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

803 lines
22KB

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