Fix AA performance

This commit is contained in:
Sahin Habermann 2018-02-25 15:09:30 +01:00 committed by Adubbz
parent 60e23002f5
commit 6a505dd096

View File

@ -201,7 +201,6 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
} }
color_t frontWaveGradient[720]; color_t frontWaveGradient[720];
color_t aaColors[3][256*256*256][10];
void computeFrontGradient(color_t baseColor, int height) { void computeFrontGradient(color_t baseColor, int height) {
int y; int y;
@ -245,9 +244,8 @@ color_t waveBlendAdd(color_t a, color_t b, float alpha) {
void drawWave(int id, float timer, color_t color, int height, float phase, float speed) { void drawWave(int id, float timer, color_t color, int height, float phase, float speed) {
int x, y; int x, y;
float wave_top_y, alpha; float wave_top_y, alpha, one_minus_alpha;
color_t existing_color, new_color; color_t existing_color, new_color;
color_t *aa_color_ptr;
height = 720 - height; height = 720 - height;
@ -264,22 +262,20 @@ void drawWave(int id, float timer, color_t color, int height, float phase, float
existing_color = FetchPixelColor(x, y); existing_color = FetchPixelColor(x, y);
new_color = waveBlendAdd(existing_color, color, clamp(alpha, 0.0, 1.0) * 0.3); new_color = waveBlendAdd(existing_color, color, clamp(alpha, 0.0, 1.0) * 0.3);
} }
else if (alpha < 0.3) { // anti-aliasing else if (alpha >= 0.3) {
existing_color = FetchPixelColor(x, y); if (id == 2) {
alpha = fabs(alpha);
aa_color_ptr = &aaColors[id][existing_color.abgr & 0xFFFFFF][(int)(alpha * 10) - 1];
new_color = *aa_color_ptr;
if (new_color.abgr == 0) {
new_color = *aa_color_ptr = MakeColor(color.r * (1.0 - alpha) + existing_color.r * alpha, color.g * (1.0 - alpha) + existing_color.g * alpha, color.b * (1.0 - alpha) + existing_color.b * alpha, 255);
}
}
else if (id == 2) { // darken closer to bottom of the front wave
new_color = frontWaveGradient[y]; new_color = frontWaveGradient[y];
} }
else { else { // no anti-aliasing
new_color = color; new_color = color;
} }
}
else { // anti-aliasing
existing_color = FetchPixelColor(x, y);
alpha = fabs(alpha);
one_minus_alpha = (1.0 - alpha);
new_color = MakeColor(color.r * one_minus_alpha + existing_color.r * alpha, color.g * one_minus_alpha + existing_color.g * alpha, color.b * one_minus_alpha + existing_color.b * alpha, 255);
}
DrawPixelRaw(x, y, new_color); DrawPixelRaw(x, y, new_color);
} }