diff options
author | Explorer09 <explorer09@gmail.com> | 2023-08-26 16:56:06 +0800 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2023-08-29 21:47:56 +0200 |
commit | 25cb42f0e4be70f02dc094d81e033ba21ec18b27 (patch) | |
tree | 98bfff2502ecee0a09800f034cb960ad862db0b2 /Meter.c | |
parent | 8ecdb75d74c393895c68be7a311db959b1f373e9 (diff) |
Rework ZramMeter and remove MeterClass.comprisedValues
The 'comprisedValues' boolean property unnecessarily complicates the
drawing algorithms of Bar meters and Graph meters. Since the only user
of 'comprisedValues' is ZramMeter, it is better to rework the meter so
that it no longer needs 'comprisedValues'.
The 'values[ZRAM_METER_UNCOMPRESSED]' now stores the difference between
uncompressed and compressed data size.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Diffstat (limited to 'Meter.c')
-rw-r--r-- | Meter.c | 13 |
1 files changed, 1 insertions, 12 deletions
@@ -219,7 +219,6 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { assert(startPos + w <= RichString_sizeVal(bar)); int blockSizes[10]; - int blockSizeSum = 0; // First draw in the bar[] buffer... int offset = 0; @@ -232,12 +231,6 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { } else { blockSizes[i] = 0; } - - if (Meter_comprisedValues(this)) { - blockSizes[i] = MAXIMUM(blockSizes[i] - blockSizeSum, 0); - blockSizeSum += blockSizes[i]; - } - int nextOffset = offset + blockSizes[i]; // (Control against invalid values) nextOffset = CLAMP(nextOffset, 0, w); @@ -331,11 +324,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { for (int i = 0; i < nValues - 1; i++) data->values[i] = data->values[i + 1]; - if (Meter_comprisedValues(this)) { - data->values[nValues - 1] = (this->curItems > 0) ? this->values[this->curItems - 1] : 0.0; - } else { - data->values[nValues - 1] = sumPositiveValues(this->values, this->curItems); - } + data->values[nValues - 1] = sumPositiveValues(this->values, this->curItems); } int i = nValues - (w * 2), k = 0; |