aboutsummaryrefslogtreecommitdiff
path: root/graphics/VectorRenderer.cpp
diff options
context:
space:
mode:
authorVicent Marti2008-07-13 22:25:11 +0000
committerVicent Marti2008-07-13 22:25:11 +0000
commit23101e3dee59ee6f1e8604a06985a683b81acaf6 (patch)
treefbfb5fdea069d72041a2eda0f80c6ae2d9d57145 /graphics/VectorRenderer.cpp
parente7e7ff9b344356c0a9ffed2998b597328eb1331f (diff)
downloadscummvm-rg350-23101e3dee59ee6f1e8604a06985a683b81acaf6.tar.gz
scummvm-rg350-23101e3dee59ee6f1e8604a06985a683b81acaf6.tar.bz2
scummvm-rg350-23101e3dee59ee6f1e8604a06985a683b81acaf6.zip
Bugfix: Triangle AA at low resolutions.
svn-id: r33047
Diffstat (limited to 'graphics/VectorRenderer.cpp')
-rw-r--r--graphics/VectorRenderer.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp
index 19a4f75058..b5722c2f64 100644
--- a/graphics/VectorRenderer.cpp
+++ b/graphics/VectorRenderer.cpp
@@ -33,6 +33,8 @@
#include "gui/ThemeRenderer.h"
#include "graphics/VectorRenderer.h"
+#define VECTOR_RENDERER_FAST_TRIANGLES
+
namespace Graphics {
VectorRenderer *createRenderer(int mode) {
@@ -391,6 +393,12 @@ drawRoundedSquare(int x, int y, int r, int w, int h) {
template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
drawTriangle(int x, int y, int w, int h, TriangleOrientation orient) {
+ // Awesome hack: the AA messes up the last pixel triangles if their width is even
+ // ...fix the width instead of fixing the AA :p
+ if (w % 2 == 0) {
+ w++; h++;
+ }
+
if (x + w > Base::_activeSurface->w || y + h > Base::_activeSurface->h)
return;
@@ -643,7 +651,8 @@ template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType,PixelFormat>::
drawTriangleFast(int x1, int y1, int size, bool inverted, PixelType color, VectorRenderer::FillMode fill_m) {
int pitch = Base::surfacePitch();
- int hstep = 0;
+ int hstep = 0, dy = size;
+ bool grad = (fill_m == kFillGradient);
PixelType *ptr_right = 0, *ptr_left = 0;
@@ -656,15 +665,28 @@ drawTriangleFast(int x1, int y1, int size, bool inverted, PixelType color, Vecto
pitch = -pitch;
}
- while (ptr_left != ptr_right) {
- colorFill(ptr_left, ptr_right, color);
- ptr_left += pitch;
- ptr_right += pitch;
- if (hstep++ % 3) {
- ptr_left++;
- ptr_right--;
- }
- }
+ if (fill_m == kFillDisabled) {
+ while (ptr_left < ptr_right) {
+ *ptr_left = color;
+ *ptr_right = color;
+ ptr_left += pitch;
+ ptr_right += pitch;
+ if (hstep++ % 2) {
+ ptr_left++;
+ ptr_right--;
+ }
+ }
+ } else {
+ while (ptr_left < ptr_right) {
+ colorFill(ptr_left, ptr_right, grad ? calcGradient(dy--, size) : color);
+ ptr_left += pitch;
+ ptr_right += pitch;
+ if (hstep++ % 2) {
+ ptr_left++;
+ ptr_right--;
+ }
+ }
+ }
}
/** ROUNDED SQUARE ALGORITHM **/