Subtle optimizing of drawing functions

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago committed by GitHub
parent 8fa2d738da
commit 2c9357ab6a
  1. 45
      src/sig/DrawLoop.java

@ -164,6 +164,46 @@ public class DrawLoop {
boolean horizontal = transform==Transform.HORIZONTAL||transform==Transform.HORIZ_VERTIC;
boolean vertical = transform==Transform.VERTICAL||transform==Transform.HORIZ_VERTIC;
byte[] p = panel.pixel;
if (transform==Transform.NONE&&col==PaletteColor.NORMAL) {
for(int X=(int)xOffset;X<(int)(w+xOffset);X++){
for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){
if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) {
continue;
} else {
int index = ((int)y)*RabiClone.BASE_WIDTH+(int)x;
if (sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||index<0||index>=p.length) {
continue;
} else {
Draw(p,index,sprite.getBi_array()[Y*sprite.getCanvasWidth()+X],alpha);
}
}
}
}
} else
if (col==PaletteColor.NORMAL) {
for(int X=(int)xOffset;X<(int)(w+xOffset);X++){
for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){
if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) {
continue;
} else {
int index =
((vertical?
sprite.getHeight()-(Y-(int)yOffset):
(Y-(int)yOffset))
+(int)y)*RabiClone.BASE_WIDTH+
(horizontal?
sprite.getWidth()-(X-(int)xOffset):
(X-(int)xOffset))
+(int)x;
if (sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||index<0||index>=p.length) {
continue;
} else {
Draw(p,index,sprite.getBi_array()[Y*sprite.getCanvasWidth()+X],alpha);
}
}
}
}
} else {
for(int X=(int)xOffset;X<(int)(w+xOffset);X++){
for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){
if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) {
@ -178,10 +218,11 @@ public class DrawLoop {
sprite.getWidth()-(X-(int)xOffset):
(X-(int)xOffset))
+(int)x;
if (index<0||index>=p.length||sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||p[index]==sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]) {
if (sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||index<0||index>=p.length) {
continue;
} else {
Draw(p,index,col==PaletteColor.NORMAL?sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]:(byte)col.ordinal(),alpha);
Draw(p,index,(byte)col.ordinal(),alpha);
}
}
}
}

Loading…
Cancel
Save