[Scummvm-cvs-logs] scummvm master -> 0a06942e4e46783a6a56e7f42bf3e57280fe003a
lordhoto
lordhoto at gmail.com
Sun Feb 21 14:42:26 CET 2016
This automated email contains information about 9 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
16aac72b60 GRAPHICS: Add comments about safe divisions in VectorRendererSpec.cpp.
0e7facad76 GRAPHICS: Skip empty rects in VectorRendererSpec::drawTriangleVertAlg.
5bc3a5aa3f GRAPHICS: Let drawLineAlg in VectorRenderer code take unsigned dx, dy.
610d2eec00 GRAPHICS: Make VectorRendererAA::drawLineAlg never divide by zero.
5f61de0e68 GRAPHICS: Skip empty rects in VectorRender*'s drawTabAlg.
df65bad9d2 GRAPHICS: Skip empty rects in VectorRendererSpec::drawSquareAlg.
1c4f41feed GRAPHICS: Skip empty rects in VectorRendererSpec::drawTriangleFast.
edaff1bdea GRAPHICS: Skip empty rects in VectorRenderer*'s drawInteriorRoundedSquareAlg.
0a06942e4e GRAPHICS: Skip empty rects and empty shadows in VectorRendererSpec::drawSquareShadow.
Commit: 16aac72b60d43c6d7ca0dbadfbbfc3b38d057f00
https://github.com/scummvm/scummvm/commit/16aac72b60d43c6d7ca0dbadfbbfc3b38d057f00
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Add comments about safe divisions in VectorRendererSpec.cpp.
Changed paths:
graphics/VectorRendererSpec.cpp
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 81a0c04..c087113 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
Commit: 0e7facad7640a67aafac54ae2b63ac07a4c1cbda
https://github.com/scummvm/scummvm/commit/0e7facad7640a67aafac54ae2b63ac07a4c1cbda
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Skip empty rects in VectorRendererSpec::drawTriangleVertAlg.
Changed paths:
graphics/VectorRendererSpec.cpp
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index c087113..64a4a5c 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -1394,6 +1394,12 @@ drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawTriangleVertAlg(int x1, int y1, int w, int h, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) {
+ // Don't draw anything for empty rects. This assures dy is always different
+ // from zero.
+ if (w <= 0 || h <= 0) {
+ return;
+ }
+
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int gradient_h = 0;
if (!inverted) {
Commit: 5bc3a5aa3f1ed9eeb5a65b509d1bccb50ec43015
https://github.com/scummvm/scummvm/commit/5bc3a5aa3f1ed9eeb5a65b509d1bccb50ec43015
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Let drawLineAlg in VectorRenderer code take unsigned dx, dy.
Changed paths:
graphics/VectorRendererSpec.cpp
graphics/VectorRendererSpec.h
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 64a4a5c..c5a1d7b 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -774,8 +774,8 @@ drawLine(int x1, int y1, int x2, int y2) {
SWAP(y1, y2);
}
- int dx = ABS(x2 - x1);
- int dy = ABS(y2 - y1);
+ uint dx = ABS(x2 - x1);
+ uint dy = ABS(y2 - y1);
// this is a point, not a line. stoopid.
if (dy == 0 && dx == 0)
@@ -1327,7 +1327,7 @@ drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, P
/** GENERIC LINE ALGORITHM **/
template<typename PixelType>
void VectorRendererSpec<PixelType>::
-drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
+drawLineAlg(int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color) {
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1);
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int xdir = (x2 > x1) ? 1 : -1;
@@ -1966,7 +1966,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
/** LINES **/
template<typename PixelType>
void VectorRendererAA<PixelType>::
-drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
+drawLineAlg(int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color) {
PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel;
@@ -1977,7 +1977,7 @@ drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
*ptr = (PixelType)color;
if (dx > dy) {
- gradient = (uint32)(dy << 16) / (uint32)dx;
+ gradient = (dy << 16) / dx;
error_acc = 0;
while (--dx) {
@@ -1994,7 +1994,7 @@ drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color) {
this->blendPixelPtr(ptr + pitch, color, alpha);
}
} else {
- gradient = (uint32)(dx << 16) / (uint32)dy;
+ gradient = (dx << 16) / dy;
error_acc = 0;
while (--dy) {
diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h
index f47cc39..3e54608 100644
--- a/graphics/VectorRendererSpec.h
+++ b/graphics/VectorRendererSpec.h
@@ -150,7 +150,7 @@ protected:
* @see VectorRendererAA::drawCircleAlg
*/
virtual void drawLineAlg(int x1, int y1, int x2, int y2,
- int dx, int dy, PixelType color);
+ uint dx, uint dy, PixelType color);
virtual void drawCircleAlg(int x, int y, int r,
PixelType color, FillMode fill_m);
@@ -278,7 +278,7 @@ protected:
*
* @see VectorRenderer::drawLineAlg()
*/
- virtual void drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color);
+ virtual void drawLineAlg(int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color);
/**
* "Wu's Circle Antialiasing Algorithm" as published by Xiaolin Wu, July 1991
Commit: 610d2eec0054af40b82f38ddb81afc09b5bdf73b
https://github.com/scummvm/scummvm/commit/610d2eec0054af40b82f38ddb81afc09b5bdf73b
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Make VectorRendererAA::drawLineAlg never divide by zero.
It won't crash any longer in the case dx = dy = 0.
Changed paths:
graphics/VectorRendererSpec.cpp
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index c5a1d7b..260e621 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -1967,7 +1967,6 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) {
template<typename PixelType>
void VectorRendererAA<PixelType>::
drawLineAlg(int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color) {
-
PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel;
int xdir = (x2 > x1) ? 1 : -1;
@@ -1993,7 +1992,7 @@ drawLineAlg(int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color) {
this->blendPixelPtr(ptr, color, ~alpha);
this->blendPixelPtr(ptr + pitch, color, alpha);
}
- } else {
+ } else if (dy != 0) {
gradient = (dx << 16) / dy;
error_acc = 0;
Commit: 5f61de0e683a34df6fbe66a8264318f2a049ef04
https://github.com/scummvm/scummvm/commit/5f61de0e683a34df6fbe66a8264318f2a049ef04
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Skip empty rects in VectorRender*'s drawTabAlg.
Changed paths:
graphics/VectorRendererSpec.cpp
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 260e621..fda0021 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -1035,6 +1035,11 @@ drawTriangle(int x, int y, int w, int h, TriangleOrientation orient) {
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawTabAlg(int x1, int y1, int w, int h, int r, PixelType color, VectorRenderer::FillMode fill_m, int baseLeft, int baseRight) {
+ // Don't draw anything for empty rects.
+ if (w <= 0 || h <= 0) {
+ return;
+ }
+
int f, ddF_x, ddF_y;
int x, y, px, py;
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
@@ -2018,6 +2023,11 @@ drawLineAlg(int x1, int y1, int x2, int y2, uint dx, uint dy, PixelType color) {
template<typename PixelType>
void VectorRendererAA<PixelType>::
drawTabAlg(int x1, int y1, int w, int h, int r, PixelType color, VectorRenderer::FillMode fill_m, int baseLeft, int baseRight) {
+ // Don't draw anything for empty rects.
+ if (w <= 0 || h <= 0) {
+ return;
+ }
+
int x, y, px, py;
int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel;
int sw = 0, sp = 0, hp = 0;
Commit: df65bad9d23c77e2d2c57c3db8fee53b5470e1ff
https://github.com/scummvm/scummvm/commit/df65bad9d23c77e2d2c57c3db8fee53b5470e1ff
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Skip empty rects in VectorRendererSpec::drawSquareAlg.
Changed paths:
graphics/VectorRendererSpec.cpp
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index fda0021..b9ad82b 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -1244,6 +1244,11 @@ drawBevelTabAlg(int x, int y, int w, int h, int bevel, PixelType top_color, Pixe
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawSquareAlg(int x, int y, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
+ // Do not draw anything for empty rects.
+ if (w <= 0 || h <= 0) {
+ return;
+ }
+
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x, y);
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int max_h = h;
Commit: 1c4f41feedb5a92714964b701b61f12fbde0b2f1
https://github.com/scummvm/scummvm/commit/1c4f41feedb5a92714964b701b61f12fbde0b2f1
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Skip empty rects in VectorRendererSpec::drawTriangleFast.
Changed paths:
graphics/VectorRendererSpec.cpp
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index b9ad82b..065be50 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -1584,6 +1584,11 @@ drawTriangleVertAlg(int x1, int y1, int w, int h, bool inverted, PixelType color
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawTriangleFast(int x1, int y1, int size, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) {
+ // Do not draw anything for empty rects.
+ if (size <= 0) {
+ return;
+ }
+
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
if (!inverted) {
Commit: edaff1bdeaddac9e86417bbc4121f3e7bee1e983
https://github.com/scummvm/scummvm/commit/edaff1bdeaddac9e86417bbc4121f3e7bee1e983
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Skip empty rects in VectorRenderer*'s drawInteriorRoundedSquareAlg.
Changed paths:
graphics/VectorRendererSpec.cpp
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 065be50..5e53e61 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -1710,6 +1710,11 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color,
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
+ // Do not draw empty space rounded squares.
+ if (w <= 0 || h <= 0) {
+ return;
+ }
+
int f, ddF_x, ddF_y;
int x, y, px, py;
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
@@ -2246,6 +2251,11 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color,
template<typename PixelType>
void VectorRendererAA<PixelType>::
drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) {
+ // Do not draw empty space rounded squares.
+ if (w <= 0 || h <= 0) {
+ return;
+ }
+
int x, y;
const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel;
int px, py;
Commit: 0a06942e4e46783a6a56e7f42bf3e57280fe003a
https://github.com/scummvm/scummvm/commit/0a06942e4e46783a6a56e7f42bf3e57280fe003a
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-02-21T14:41:29+01:00
Commit Message:
GRAPHICS: Skip empty rects and empty shadows in VectorRendererSpec::drawSquareShadow.
Changed paths:
graphics/VectorRendererSpec.cpp
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 5e53e61..b360327 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -1865,6 +1865,11 @@ drawCircleAlg(int x1, int y1, int r, PixelType color, VectorRenderer::FillMode f
template<typename PixelType>
void VectorRendererSpec<PixelType>::
drawSquareShadow(int x, int y, int w, int h, int offset) {
+ // Do nothing for empty rects or no shadow offset.
+ if (w <= 0 || h <= 0 || offset <= 0) {
+ return;
+ }
+
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x + w - 1, y + offset);
int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel;
int i, j;
More information about the Scummvm-git-logs
mailing list