[Scummvm-cvs-logs] SF.net SVN: scummvm: [32021] scummvm/branches/gsoc2008-gui/graphics
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Sun May 11 16:05:59 CEST 2008
Revision: 32021
http://scummvm.svn.sourceforge.net/scummvm/?rev=32021&view=rev
Author: Tanoku
Date: 2008-05-11 07:05:59 -0700 (Sun, 11 May 2008)
Log Message:
-----------
- Aliased rounded squares + stroking.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp 2008-05-11 13:11:01 UTC (rev 32020)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp 2008-05-11 14:05:59 UTC (rev 32021)
@@ -65,7 +65,7 @@
vr->setFgColor(255, 0, 0);
vr->setBgColor(25, 25, 175);
vr->setFillMode(VectorRenderer::kForegroundFill);
- vr->setStrokeWidth(1);
+ vr->setStrokeWidth(6);
vr->shadowEnable(1, 1);
vr->drawLine(25, 25, 125, 300);
@@ -155,7 +155,7 @@
break;
case kBackgroundFill:
- VectorRendererSpec::drawRoundedSquareAlg(x + 1, y + 1, r, w - 1, h - 1, _bgColor, true);
+ VectorRendererSpec::drawRoundedSquareAlg(x, y, r, w, h, _bgColor, true);
drawRoundedSquareAlg(x, y, r, w, h, _fgColor, false);
break;
@@ -397,14 +397,14 @@
}
#define __BE_DRAWCIRCLE(ptr1,ptr2,ptr3,ptr4,x,y,px,py) { \
- *(ptr1 + x + py) = color; \
- *(ptr1 + y - px) = color; \
- *(ptr1 - x - py) = color; \
- *(ptr1 - y - px) = color; \
- *(ptr1 - y + px) = color; \
- *(ptr1 - x + py) = color; \
- *(ptr1 + y + px) = color; \
- *(ptr1 + x - py) = color; \
+ *(ptr1 + (y) - (px)) = color; \
+ *(ptr1 + (x) - (py)) = color; \
+ *(ptr2 - (x) - (py)) = color; \
+ *(ptr2 - (y) - (px)) = color; \
+ *(ptr3 - (y) + (px)) = color; \
+ *(ptr3 - (x) + (py)) = color; \
+ *(ptr4 + (x) + (py)) = color; \
+ *(ptr4 + (y) + (px)) = color; \
}
#define __BE_RESET() { \
@@ -456,6 +456,71 @@
}
}
+template<typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, bool fill) {
+ int f, ddF_x, ddF_y;
+ int x, y, px, py;
+ int pitch = Base::surfacePitch();
+ int sw = 0, sp = 0, hp = h * pitch;
+
+ 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);
+
+ int short_h = h - (2 * r) + 2;
+ int real_radius = r;
+
+ if (fill == false) {
+ while (sw++ < Base::_strokeWidth) {
+ Common::set_to(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color);
+ Common::set_to(ptr_fill + hp - sp + r, ptr_fill + w + hp + 1 - sp - r, color);
+ sp += pitch;
+
+ __BE_RESET();
+ r--;
+
+ while (x++ < y) {
+ __BE_ALGORITHM();
+ __BE_DRAWCIRCLE(ptr_tr, ptr_tl, ptr_bl, ptr_br, x, y, px, py);
+
+ if (Base::_strokeWidth > 1) {
+ __BE_DRAWCIRCLE(ptr_tr, ptr_tl, ptr_bl, ptr_br, x - 1, y, px, py);
+ __BE_DRAWCIRCLE(ptr_tr, ptr_tl, ptr_bl, ptr_br, x, y, px - pitch, py);
+ }
+ }
+ }
+
+ ptr_fill += pitch * real_radius;
+ while (short_h--) {
+ Common::set_to(ptr_fill, ptr_fill + Base::_strokeWidth, color);
+ Common::set_to(ptr_fill + w - Base::_strokeWidth + 1, ptr_fill + w + 1, color);
+ ptr_fill += pitch;
+ }
+ } else {
+ __BE_RESET();
+ while (x++ < y) {
+ __BE_ALGORITHM();
+
+ Common::set_to(ptr_tl - x - py, ptr_tr + x - py, color);
+ Common::set_to(ptr_tl - y - px, ptr_tr + y - px, color);
+
+ Common::set_to(ptr_bl - x + py, ptr_br + x + py, color);
+ Common::set_to(ptr_bl - y + px, ptr_br + y + px, color);
+
+ __BE_DRAWCIRCLE(ptr_tr, ptr_tl, ptr_bl, ptr_br, x, y, px, py);
+ }
+
+ ptr_fill += pitch * r;
+ while (short_h--) {
+ Common::set_to(ptr_fill, ptr_fill + w + 1, color);
+ ptr_fill += pitch;
+ }
+ }
+}
+
#define __WU_DRAWCIRCLE(ptr1,ptr2,ptr3,ptr4,x,y,px,py,a) { \
blendPixelPtr(ptr1 + (y) - (px), color, a); \
blendPixelPtr(ptr1 + (x) - (py), color, a); \
Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-05-11 13:11:01 UTC (rev 32020)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-05-11 14:05:59 UTC (rev 32021)
@@ -351,7 +351,7 @@
*/
virtual void drawLineAlg(int x1, int y1, int x2, int y2, int dx, int dy, PixelType color);
virtual void drawCircleAlg(int x, int y, int r, PixelType color, bool fill = false);
- virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, bool fill = false) {}
+ virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, bool fill = false);
virtual void drawSquareAlg(int x, int y, int w, int h, PixelType color, bool fill = false);
PixelType _fgColor; /** Foreground color currently being used to draw on the renderer */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list