Make threads iterate over horizontal strips rather than squares to be more cache-friendly. This should also simplify the thread arguments.
Example
Change from this...
public Boolean call() {
for (int y = offsetY, x; y < offsetY + pixelsY; y++) {
for (x = offsetX; x < offsetX + pixelsX; x++) {
gradientPG.pixels[gradientPG.width * (y + renderOffsetY)
+ (x + renderOffsetX)] = col;
}
}
return true;
}
...to something like this:
public Boolean call() {
int pixel = startRow * p.width; // start at correct index; some row at x=0
for (int y = 0, x; y < rows; y++) {
for (x = 0; x < p.width; x++) { // FULL WIDTH
gradientPG.pixels[pixel] = col;
pixel++;
}
}
return true;
}
Make threads iterate over horizontal strips rather than squares to be more cache-friendly. This should also simplify the thread arguments.
Example
Change from this...
...to something like this: