refactor: Simplify sort in GfxRenderer::fillPolygon (#1817)
## Summary Small simplification to node sorting algorithm in GfxRenderer::fillPolygon. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**NO**_
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include <Logging.h>
|
||||
#include <Utf8.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "FontCacheManager.h"
|
||||
|
||||
const uint8_t* GfxRenderer::getGlyphBitmap(const EpdFontData* fontData, const EpdGlyph* glyph) const {
|
||||
@@ -882,16 +884,8 @@ void GfxRenderer::fillPolygon(const int* xPoints, const int* yPoints, int numPoi
|
||||
j = i;
|
||||
}
|
||||
|
||||
// Sort nodes by X (simple bubble sort, numPoints is small)
|
||||
for (int i = 0; i < nodes - 1; i++) {
|
||||
for (int k = i + 1; k < nodes; k++) {
|
||||
if (nodeX[i] > nodeX[k]) {
|
||||
int temp = nodeX[i];
|
||||
nodeX[i] = nodeX[k];
|
||||
nodeX[k] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sort nodes by X
|
||||
std::sort(nodeX, nodeX + nodes);
|
||||
|
||||
// Fill between pairs of nodes
|
||||
for (int i = 0; i < nodes - 1; i += 2) {
|
||||
|
||||
Reference in New Issue
Block a user