aboutsummaryrefslogtreecommitdiff
path: root/graphics/VectorRenderer.cpp
diff options
context:
space:
mode:
authorVicent Marti2008-07-26 22:58:02 +0000
committerVicent Marti2008-07-26 22:58:02 +0000
commite8d15277465c850fbad56b7ee3757e7b5cee0b2a (patch)
tree658f53a3388021addea4d54fd2f98342108202c9 /graphics/VectorRenderer.cpp
parent078ac062e764b9b6a46110861f924e3df6328f20 (diff)
downloadscummvm-rg350-e8d15277465c850fbad56b7ee3757e7b5cee0b2a.tar.gz
scummvm-rg350-e8d15277465c850fbad56b7ee3757e7b5cee0b2a.tar.bz2
scummvm-rg350-e8d15277465c850fbad56b7ee3757e7b5cee0b2a.zip
Convolution filters for the vector renderer. Pretty cool.
svn-id: r33319
Diffstat (limited to 'graphics/VectorRenderer.cpp')
-rw-r--r--graphics/VectorRenderer.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp
index 352ab971a3..a708d5ac1f 100644
--- a/graphics/VectorRenderer.cpp
+++ b/graphics/VectorRenderer.cpp
@@ -50,6 +50,15 @@ VectorRenderer *createRenderer(int mode) {
}
}
+const VectorRenderer::ConvolutionDataSet VectorRenderer::_convolutionData[VectorRenderer::kConvolutionMAX] = {
+ { {{1, 1, 1}, {1, 8, 1}, {1, 1, 1}}, 16, 0 }, // soft blur matrix
+ { {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, 18, 0 }, // hard blur matrix
+ { {{1, 2, 1}, {2, 4, 2}, {1, 2, 1}}, 16, 0 }, // gaussian blur matrix
+ { {{2, 0, 0}, {0, -1, 0}, {0, 0, -1}}, 1, 127}, // emboss matrix
+ { {{-1, -1, -1}, {-1, 9, -1}, {-1, -1, -1}}, 1, 0}, // sharpen matrix
+ { {{1, 1, 1}, {1, -7, 1}, {1, 1, 1}}, 1, 0} // edge find matrix
+};
+
/********************************************************************
* DRAWSTEP handling functions
********************************************************************/
@@ -159,6 +168,39 @@ void VectorRenderer::stepGetPositions(const DrawStep &step, const Common::Rect &
/********************************************************************
* MISCELANEOUS functions
********************************************************************/
+template <typename PixelType, typename PixelFormat>
+void VectorRendererSpec<PixelType, PixelFormat>::
+areaConvolution(const Common::Rect &area, const int filter[3][3], int filterDiv, int offset) {
+ PixelType *ptr = 0;
+ int newR, newG, newB;
+ uint8 r, g, b;
+ int yVal;
+
+ for (int y = area.top; y < area.bottom; ++y) {
+ for (int x = area.left; x < area.right; ++x) {
+ for (int j = 0; j < 3; ++j) {
+ yVal = MIN(MAX(y - 1 + j, 0), area.bottom - 1);
+
+ for (int i = 0; i < 3; ++i) {
+ ptr = (PixelType *)Base::_activeSurface->getBasePtr(MIN(MAX(x - 1 + j, 0), area.right - 1), yVal);
+ colorToRGB<PixelFormat>((uint32)*ptr, r, g, b);
+
+ newR += r * filter[j][i];
+ newG += g * filter[j][i];
+ newB += b * filter[j][i];
+ }
+ }
+
+ newR = (newR / filterDiv) + offset;
+ newG = (newG / filterDiv) + offset;
+ newB = (newB / filterDiv) + offset;
+
+ ptr = (PixelType *)Base::_activeSurface->getBasePtr(x, y);
+ *ptr = RGBToColor<PixelFormat>(CLIP(newR, 0, 255), CLIP(newG, 0, 255), CLIP(newB, 0, 255));
+ }
+ }
+}
+
/** Fixed point SQUARE ROOT **/
inline uint32 fp_sqroot(uint32 x) {
register uint32 root, remHI, remLO, testDIV, count;