diff options
author | Johannes Schickel | 2016-02-21 14:41:29 +0100 |
---|---|---|
committer | Johannes Schickel | 2016-02-21 14:41:29 +0100 |
commit | 16aac72b60d43c6d7ca0dbadfbbfc3b38d057f00 (patch) | |
tree | f41ad4e8d80b35f7e44b6ec6b75b5a335add350a /graphics/VectorRendererSpec.cpp | |
parent | 7b9c15634fe39fecbd7b1f8e020fa4b0e4f4f725 (diff) | |
download | scummvm-rg350-16aac72b60d43c6d7ca0dbadfbbfc3b38d057f00.tar.gz scummvm-rg350-16aac72b60d43c6d7ca0dbadfbbfc3b38d057f00.tar.bz2 scummvm-rg350-16aac72b60d43c6d7ca0dbadfbbfc3b38d057f00.zip |
GRAPHICS: Add comments about safe divisions in VectorRendererSpec.cpp.
Diffstat (limited to 'graphics/VectorRendererSpec.cpp')
-rw-r--r-- | graphics/VectorRendererSpec.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 81a0c04441..c08711379b 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -441,13 +441,14 @@ template<typename PixelType> void VectorRendererSpec<PixelType>:: gradientFill(PixelType *ptr, int width, int x, int y) { bool ox = ((y & 1) == 1); - int stripSize; int curGrad = 0; while (_gradIndexes[curGrad + 1] <= y) curGrad++; - stripSize = _gradIndexes[curGrad + 1] - _gradIndexes[curGrad]; + // precalcGradient assures that _gradIndexes entries always differ in + // their value. This assures stripSize is always different from zero. + int stripSize = _gradIndexes[curGrad + 1] - _gradIndexes[curGrad]; int grad = (((y - _gradIndexes[curGrad]) % stripSize) << 2) / stripSize; @@ -1422,6 +1423,9 @@ drawTriangleVertAlg(int x1, int y1, int w, int h, bool inverted, PixelType color blendPixelPtr(floor, color, 50); #if FIXED_POINT + // In this branch dx is always different from zero. This is because + // abs(dx) is strictly greater than abs(dy), and abs returns zero + // as minimal value. int gradient = (dy << 8) / dx; int intery = (y1 << 8) + gradient; #else |