aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti2008-05-07 22:51:45 +0000
committerVicent Marti2008-05-07 22:51:45 +0000
commit46fada31b72c4fab68d857a5fa16b57d059f4117 (patch)
tree224b5fa44eb92d693ea0987d41f726d0d53ca774
parentba6c4a6239d5496f0f218d8fa76c11e77bf9139e (diff)
downloadscummvm-rg350-46fada31b72c4fab68d857a5fa16b57d059f4117.tar.gz
scummvm-rg350-46fada31b72c4fab68d857a5fa16b57d059f4117.tar.bz2
scummvm-rg350-46fada31b72c4fab68d857a5fa16b57d059f4117.zip
- Fixed compiling in MSVC2008
- Aliased circles optimized (drawn using pointers directly) - Filling for aliased circles - Rounded squares - Filling for rounded squares svn-id: r31936
-rw-r--r--dists/msvc9/scumm.vcproj4
-rw-r--r--graphics/VectorRenderer.cpp144
-rw-r--r--graphics/VectorRenderer.h13
3 files changed, 138 insertions, 23 deletions
diff --git a/dists/msvc9/scumm.vcproj b/dists/msvc9/scumm.vcproj
index 4acecd4517..230102db35 100644
--- a/dists/msvc9/scumm.vcproj
+++ b/dists/msvc9/scumm.vcproj
@@ -43,7 +43,7 @@
AdditionalOptions="/wd4201 /wd4512 /wd4511 /wd4100 /wd4121 /wd4310 /wd4706 /wd4127 /wd4189 /wd4702 /wd4996"
Optimization="0"
AdditionalIncludeDirectories="../..;../../engines"
- PreprocessorDefinitions="WIN32;_DEBUG;USE_ZLIB;USE_MAD;USE_VORBIS"
+ PreprocessorDefinitions="WIN32;_DEBUG;ENABLE_SCUMM_7_8;ENABLE_HE;USE_ZLIB;USE_MAD;USE_VORBIS"
MinimalRebuild="true"
ExceptionHandling="1"
BasicRuntimeChecks="3"
@@ -116,7 +116,7 @@
InlineFunctionExpansion="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="../..;../../engines"
- PreprocessorDefinitions="WIN32;NDEBUG;USE_ZLIB;USE_MAD;USE_VORBIS"
+ PreprocessorDefinitions="WIN32;NDEBUG;ENABLE_SCUMM_7_8;ENABLE_HE;USE_ZLIB;USE_MAD;USE_VORBIS"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp
index 4a88eb94b4..f779c9c09a 100644
--- a/graphics/VectorRenderer.cpp
+++ b/graphics/VectorRenderer.cpp
@@ -65,8 +65,9 @@ void vector_renderer_test(OSystem *_system) {
vr->fillSurface();
vr->setColor(255, 0, 0 );
vr->drawLine(25, 25, 125, 300);
- vr->drawCircle(250, 250, 10);
- vr->drawSquare(150, 25, 100, 100, true);
+ vr->drawCircle(250, 250, 100);
+// vr->drawSquare(150, 25, 100, 100, true);
+ vr->drawRoundedSquare( 150, 25, 8, 100, 75 );
_system->copyRectToOverlay((OverlayColor*)_screen.getBasePtr(0, 0), _screen.w, 0, 0, _screen.w, _screen.w);
_system->updateScreen();
@@ -288,37 +289,138 @@ inline uint32 fp_sqroot(uint32 x) {
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawCircleAlg(int x1, int y1, int r) {
+ int f = 1 - r;
+ int ddF_x = 0, ddF_y = -2 * r;
+ int x = 0, y = r, px, py;
+ int pitch = Base::surfacePitch();
+ PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
+ bool fill = true;
-#define __CIRCLE_SIM(x,y) { \
- putPixel(x1 + (x), y1 + (y)); /* 1st quad */ \
- putPixel(x1 + (y), y1 - (x)); \
- putPixel(x1 - (x), y1 - (y)); /* 2nd quad */ \
- putPixel(x1 - (y), y1 - (x)); \
- putPixel(x1 - (y), y1 + (x)); /* 3rd quad */ \
- putPixel(x1 - (x), y1 + (y)); \
- putPixel(x1 + (y), y1 + (x)); /* 4th quad */ \
- putPixel(x1 + (x), y1 - (y)); \
-}
+ px = 0;
+ py = pitch*y;
- int f = 1 - r;
- int ddF_x = 0;
- int ddF_y = -2 * r;
- int x = 0;
- int y = r;
+ *(ptr + y) = _color;
+ *(ptr - y) = _color;
+ *(ptr + py) = _color;
+ *(ptr - py) = _color;
- __CIRCLE_SIM(x,y);
+ if (fill) Common::set_to(ptr - r, ptr + r, _color);
while (x++ < y) {
if (f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
+ py -= pitch;
}
+ px += pitch;
ddF_x += 2;
- f += ddF_x + 1;
-
- __CIRCLE_SIM(x,y);
+ f += ddF_x + 1;
+
+ if (fill) {
+ Common::set_to(ptr - x + py, ptr + x + py, _color);
+ Common::set_to(ptr - x - py, ptr + x - py, _color);
+ Common::set_to(ptr - y + px, ptr + y + px, _color);
+ Common::set_to(ptr - y - px, ptr + y - px, _color);
+ }
+
+ *(ptr + x + py) = _color;
+ *(ptr + y - px) = _color;
+ *(ptr - x - py) = _color;
+ *(ptr - y - px) = _color;
+ *(ptr - y + px) = _color;
+ *(ptr - x + py) = _color;
+ *(ptr + y + px) = _color;
+ *(ptr + x - py) = _color;
+ }
+}
+
+template<typename PixelType, typename PixelFormat>
+void VectorRendererAA<PixelType, PixelFormat>::
+drawRoundedSquareAlg(int x1, int y1, int r, int w, int h) {
+ int x = r;
+ int y = 0;
+ int p = Base::surfacePitch(), px, py;
+ uint32 rsq = (r * r) << 16;
+ uint32 T = 0, oldT;
+ uint8 a1, a2;
+ bool fill = true;
+
+ PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r);
+ PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + r);
+ PixelType *ptr_bl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + h - r);
+ PixelType *ptr_br = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + h - r);
+ PixelType *ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
+
+ Common::set_to(ptr_fill + r, ptr_fill + w - r + 1, Base::_color);
+ Common::set_to(ptr_fill + r + h*p, ptr_fill + w - r + 1 + h*p, Base::_color);
+
+ h -= 2*r;
+ ptr_fill += p*r;
+
+ if (!fill) {
+ while (h-- >= 0) {
+ *(ptr_fill) = (PixelType)Base::_color;
+ *(ptr_fill + w) = (PixelType)Base::_color;
+ ptr_fill += p;
+ }
+ } else {
+ while (h-- >= 0) {
+ Common::set_to(ptr_fill, ptr_fill + w + 1, Base::_color);
+ ptr_fill += p;
+ }
+ }
+
+ px = p*x;
+ py = 0;
+
+ while (x > y++)
+ {
+ oldT = T;
+ T = fp_sqroot(rsq - ((y * y) << 16)) ^ 0xFFFF;
+
+ py += p;
+
+ if (T < oldT) {
+ x--;
+ px -= p;
+ }
+
+ a2 = (T >> 8);
+ a1 = ~a2;
+
+ if (fill) {
+ Common::set_to( ptr_tl - x - py, ptr_tr + x - py, Base::_color );
+ Common::set_to( ptr_tl - y - px, ptr_tr + y - px, Base::_color );
+
+ Common::set_to( ptr_bl - x + py, ptr_br + x + py, Base::_color );
+ Common::set_to( ptr_bl - y + px, ptr_br + y + px, Base::_color );
+ } else {
+ blendPixelPtr(ptr_tr + y - (px-p), a2);
+ blendPixelPtr(ptr_tr + x - 1 - py, a2);
+
+ blendPixelPtr(ptr_tl - x + 1 - py, a2);
+ blendPixelPtr(ptr_tl - y - (px-p), a2);
+
+ blendPixelPtr(ptr_bl - y + (px-p), a2);
+ blendPixelPtr(ptr_bl - x + 1 + py, a2);
+
+ blendPixelPtr(ptr_br + x - 1 + py, a2);
+ blendPixelPtr(ptr_br + y + (px-p), a2);
+ }
+
+ blendPixelPtr(ptr_tr + y - px, a1);
+ blendPixelPtr(ptr_tr + x - py, a1);
+
+ blendPixelPtr(ptr_tl - x - py, a1);
+ blendPixelPtr(ptr_tl - y - px, a1);
+
+ blendPixelPtr(ptr_bl - y + px, a1);
+ blendPixelPtr(ptr_bl - x + py, a1);
+
+ blendPixelPtr(ptr_br + x + py, a1);
+ blendPixelPtr(ptr_br + y + px, a1);
}
}
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 96b0698de7..a49170c56a 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -77,6 +77,8 @@ public:
virtual void drawSquare(int x, int y, int w, int h, bool fill) = 0;
+ virtual void drawRoundedSquare(int x1, int y1, int r, int w, int h) = 0;
+
/**
* Gets the pixel pitch for the current drawing surface.
* Note: This is a real pixel-pitch, not a byte-pitch.
@@ -178,6 +180,8 @@ protected:
*/
virtual void drawCircleAlg(int x, int y, int r) = 0;
+ virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h) = 0;
+
Surface *_activeSurface; /** Pointer to the surface currently being drawn */
};
@@ -218,6 +222,10 @@ public:
void drawSquare(int x, int y, int w, int h, bool fill);
+ void drawRoundedSquare(int x1, int y1, int r, int w, int h) {
+ drawRoundedSquareAlg( x1, y1, r, w, h );
+ }
+
/**
* @see VectorRenderer::setColor()
*/
@@ -269,6 +277,9 @@ protected:
*/
virtual void drawCircleAlg(int x, int y, int r);
+ virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h) {
+ }
+
PixelType _color; /** Color currently being used to draw on the renderer */
};
@@ -337,6 +348,8 @@ protected:
* @see VectorRenderer::drawCircleAlg()
*/
virtual void drawCircleAlg(int x, int y, int r);
+
+ virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h);
};
} // end of namespace Graphics