[Scummvm-git-logs] scummvm master -> 87594a052fedacb1183ad3c86841ce73da700241

aquadran noreply at scummvm.org
Tue Dec 7 21:12:02 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
87594a052f TINYGL: Cleanup more FrameBuffer class entries


Commit: 87594a052fedacb1183ad3c86841ce73da700241
    https://github.com/scummvm/scummvm/commit/87594a052fedacb1183ad3c86841ce73da700241
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2021-12-07T22:11:55+01:00

Commit Message:
TINYGL: Cleanup more FrameBuffer class entries

Changed paths:
    graphics/tinygl/zbuffer.cpp
    graphics/tinygl/zbuffer.h
    graphics/tinygl/zdirtyrect.cpp
    graphics/tinygl/zline.cpp
    graphics/tinygl/zmath.cpp
    graphics/tinygl/zmath.h
    graphics/tinygl/ztriangle.cpp


diff --git a/graphics/tinygl/zbuffer.cpp b/graphics/tinygl/zbuffer.cpp
index 742777d64b..55fca6688a 100644
--- a/graphics/tinygl/zbuffer.cpp
+++ b/graphics/tinygl/zbuffer.cpp
@@ -37,7 +37,7 @@
 namespace TinyGL {
 
 // adr must be aligned on an 'int'
-void memset_s(void *adr, int val, int count) {
+static void memset_s(void *adr, int val, int count) {
 	int n, v;
 	unsigned int *p;
 	unsigned short *q;
@@ -60,7 +60,7 @@ void memset_s(void *adr, int val, int count) {
 		*q++ = val;
 }
 
-void memset_l(void *adr, int val, int count) {
+static void memset_l(void *adr, int val, int count) {
 	int n, v;
 	unsigned int *p;
 
@@ -81,31 +81,29 @@ void memset_l(void *adr, int val, int count) {
 }
 
 FrameBuffer::FrameBuffer(int width, int height, const Graphics::PixelFormat &format) {
-	this->xsize = width;
-	this->ysize = height;
-	this->cmode = format;
-	this->pixelbytes = this->cmode.bytesPerPixel;
-	this->linesize = (xsize * this->pixelbytes + 3) & ~3;
+	_pbufWidth = width;
+	_pbufHeight = height;
+	_pbufFormat = format;
+	_pbufBpp = _pbufFormat.bytesPerPixel;
+	_pbufPitch = (_pbufWidth * _pbufBpp + 3) & ~3;
 
-	this->buffer.zbuf = this->_zbuf = (unsigned int *)gl_zalloc(this->xsize * this->ysize * sizeof(unsigned int));
+	_offscreenBuffer.zbuf = _zbuf = (uint *)gl_zalloc(_pbufWidth * _pbufHeight * sizeof(uint));
 
-	this->pbuf.set(this->cmode, new byte[this->ysize * this->linesize]);
-	this->buffer.pbuf = this->pbuf.getRawBuffer();
+	_pbuf.set(_pbufFormat, new byte[_pbufHeight * _pbufPitch]);
+	_offscreenBuffer.pbuf = _pbuf.getRawBuffer();
 
 	_currentTexture = nullptr;
 }
 
 FrameBuffer::~FrameBuffer() {
-	pbuf.free();
+	_pbuf.free();
 	gl_free(_zbuf);
 }
 
 Buffer *FrameBuffer::genOffscreenBuffer() {
 	Buffer *buf = (Buffer *)gl_malloc(sizeof(Buffer));
-	buf->pbuf = (byte *)gl_malloc(this->ysize * this->linesize);
-	int size = this->xsize * this->ysize * sizeof(unsigned int);
-	buf->zbuf = (unsigned int *)gl_malloc(size);
-
+	buf->pbuf = (byte *)gl_malloc(_pbufHeight * _pbufPitch);
+	buf->zbuf = (unsigned int *)gl_malloc(_pbufWidth * _pbufHeight * sizeof(uint));
 	return buf;
 }
 
@@ -122,32 +120,32 @@ void FrameBuffer::clear(int clearZ, int z, int clearColor, int r, int g, int b)
 		for (i = 1; i < sizeof(z) && zc[0] == zc[i]; i++) { ; }
 		if (i == sizeof(z)) {
 			// All "z" bytes are identical, use memset (fast)
-			memset(this->_zbuf, zc[0], sizeof(*this->_zbuf) * this->xsize * this->ysize);
+			memset(_zbuf, zc[0], sizeof(uint) * _pbufWidth * _pbufHeight);
 		} else {
 			// Cannot use memset, use a variant working on integers (slow)
-			memset_l(this->_zbuf, z, this->xsize * this->ysize);
+			memset_l(_zbuf, z, _pbufWidth * _pbufHeight);
 		}
 	}
 	if (clearColor) {
-		byte *pp = this->pbuf.getRawBuffer();
-		uint32 color = this->cmode.RGBToColor(r, g, b);
+		byte *pp = _pbuf.getRawBuffer();
+		uint32 color = _pbufFormat.RGBToColor(r, g, b);
 		const uint8 *colorc = (uint8 *)&color;
 		unsigned int i;
 		for (i = 1; i < sizeof(color) && colorc[0] == colorc[i]; i++) { ; }
 		if (i == sizeof(color)) {
 			// All "color" bytes are identical, use memset (fast)
-			memset(pp, colorc[0], this->linesize * this->ysize);
+			memset(pp, colorc[0], _pbufPitch * _pbufHeight);
 		} else {
 			// Cannot use memset, use a variant working on shorts/ints (slow)
-			switch(this->pixelbytes) {
+			switch(_pbufBpp) {
 			case 2:
-				memset_s(pp, color, this->xsize * this->ysize);
+				memset_s(pp, color, _pbufWidth * _pbufHeight);
 				break;
 			case 4:
-				memset_l(pp, color, this->xsize * this->ysize);
+				memset_l(pp, color, _pbufWidth * _pbufHeight);
 				break;
 			default:
-				error("Unsupported pixel size %i", this->pixelbytes);
+				error("Unsupported pixel size %i", _pbufBpp);
 			}
 		}
 	}
@@ -156,7 +154,7 @@ void FrameBuffer::clear(int clearZ, int z, int clearColor, int r, int g, int b)
 void FrameBuffer::clearRegion(int x, int y, int w, int h, int clearZ, int z, int clearColor, int r, int g, int b) {
 	if (clearZ) {
 		int height = h;
-		unsigned int *zbuf = this->_zbuf + (y * this->xsize);
+		unsigned int *zbuf = _zbuf + (y * _pbufWidth);
 		const uint8 *zc = (const uint8 *)&z;
 		unsigned int i;
 		for (i = 1; i < sizeof(z) && zc[0] == zc[i]; i++) { ; }
@@ -164,33 +162,33 @@ void FrameBuffer::clearRegion(int x, int y, int w, int h, int clearZ, int z, int
 			// All "z" bytes are identical, use memset (fast)
 			while (height--) {
 				memset(zbuf + x, zc[0], sizeof(*zbuf) * w);
-				zbuf += this->xsize;
+				zbuf += _pbufWidth;
 			}
 		} else {
 			// Cannot use memset, use a variant working on integers (slow)
 			while (height--) {
 				memset_l(zbuf + x, z, w);
-				zbuf += this->xsize;
+				zbuf += _pbufWidth;
 			}
 		}
 	}
 	if (clearColor) {
 		int height = h;
-		byte *pp = this->pbuf.getRawBuffer() + y * this->linesize + x * this->pixelbytes;
-		uint32 color = this->cmode.RGBToColor(r, g, b);
+		byte *pp = _pbuf.getRawBuffer() + y * _pbufPitch + x * _pbufBpp;
+		uint32 color = _pbufFormat.RGBToColor(r, g, b);
 		const uint8 *colorc = (uint8 *)&color;
 		unsigned int i;
 		for (i = 1; i < sizeof(color) && colorc[0] == colorc[i]; i++) { ; }
 		if (i == sizeof(color)) {
 			// All "color" bytes are identical, use memset (fast)
 			while (height--) {
-				memset(pp, colorc[0], this->pixelbytes * w);
-				pp += this->linesize;
+				memset(pp, colorc[0], _pbufBpp * w);
+				pp += _pbufPitch;
 			}
 		} else {
 			// Cannot use memset, use a variant working on shorts/ints (slow)
 			while (height--) {
-				switch(this->pixelbytes) {
+				switch(_pbufBpp) {
 				case 2:
 					memset_s(pp, color, w);
 					break;
@@ -198,9 +196,9 @@ void FrameBuffer::clearRegion(int x, int y, int w, int h, int clearZ, int z, int
 					memset_l(pp, color, w);
 					break;
 				default:
-					error("Unsupported pixel size %i", this->pixelbytes);
+					error("Unsupported pixel size %i", _pbufBpp);
 				}
-				pp += this->linesize;
+				pp += _pbufPitch;
 			}
 		}
 	}
@@ -218,13 +216,13 @@ void FrameBuffer::blitOffscreenBuffer(Buffer *buf) {
 	// TODO: could be faster, probably.
 #define UNROLL_COUNT 16
 	if (buf->used) {
-		const int pixel_bytes = this->pixelbytes;
+		const int pixel_bytes = _pbufBpp;
 		const int unrolled_pixel_bytes = pixel_bytes * UNROLL_COUNT;
-		byte *to = this->pbuf.getRawBuffer();
+		byte *to = _pbuf.getRawBuffer();
 		byte *from = buf->pbuf;
-		unsigned int *to_z = this->_zbuf;
+		unsigned int *to_z = _zbuf;
 		unsigned int *from_z = buf->zbuf;
-		int count = this->xsize * this->ysize;
+		int count = _pbufWidth * _pbufHeight;
 		while (count >= UNROLL_COUNT) {
 			blitPixel(0x0, from_z, to_z, sizeof(int), from, to, pixel_bytes);
 			blitPixel(0x1, from_z, to_z, sizeof(int), from, to, pixel_bytes);
@@ -271,18 +269,18 @@ void FrameBuffer::blitOffscreenBuffer(Buffer *buf) {
 
 void FrameBuffer::selectOffscreenBuffer(Buffer *buf) {
 	if (buf) {
-		this->pbuf = buf->pbuf;
-		this->_zbuf = buf->zbuf;
+		_pbuf = buf->pbuf;
+		_zbuf = buf->zbuf;
 		buf->used = true;
 	} else {
-		this->pbuf = this->buffer.pbuf;
-		this->_zbuf = this->buffer.zbuf;
+		_pbuf = _offscreenBuffer.pbuf;
+		_zbuf = _offscreenBuffer.zbuf;
 	}
 }
 
 void FrameBuffer::clearOffscreenBuffer(Buffer *buf) {
-	memset(buf->pbuf, 0, this->ysize * this->linesize);
-	memset(buf->zbuf, 0, this->ysize * this->xsize * sizeof(unsigned int));
+	memset(buf->pbuf, 0, _pbufHeight * _pbufPitch);
+	memset(buf->zbuf, 0, _pbufHeight * _pbufWidth * sizeof(uint));
 	buf->used = false;
 }
 
diff --git a/graphics/tinygl/zbuffer.h b/graphics/tinygl/zbuffer.h
index a7c854d07f..03d6a76acc 100644
--- a/graphics/tinygl/zbuffer.h
+++ b/graphics/tinygl/zbuffer.h
@@ -68,7 +68,7 @@ namespace TinyGL {
 #define ZB_POINT_ALPHA_FRAC_SHIFT (ZB_POINT_ALPHA_FRAC_BITS - 1)
 #define ZB_POINT_ALPHA_MAX        ( (1 << ZB_POINT_ALPHA_BITS) - 1 )
 
-#define RGB_TO_PIXEL(r, g, b) cmode.ARGBToColor(255, r, g, b) // Default to 255 alpha aka solid colour.
+#define RGB_TO_PIXEL(r, g, b)     _pbufFormat.ARGBToColor(255, r, g, b) // Default to 255 alpha aka solid colour.
 
 static const int DRAW_DEPTH_ONLY = 0;
 static const int DRAW_FLAT = 1;
@@ -117,19 +117,19 @@ public:
 	void clearRegion(int x, int y, int w, int h,int clear_z, int z, int clear_color, int r, int g, int b);
 
 	Graphics::PixelFormat getPixelFormat() {
-		return cmode;
+		return _pbufFormat;
 	}
 
 	byte *getPixelBuffer() {
-		return pbuf.getRawBuffer();
+		return _pbuf.getRawBuffer();
 	}
 
 	int getPixelBufferWidth() {
-		return xsize;
+		return _pbufWidth;
 	}
 
 	int getPixelBufferHeight() {
-		return ysize;
+		return _pbufHeight;
 	}
 
 	unsigned int *getZBuffer() {
@@ -137,7 +137,7 @@ public:
 	}
 
 	FORCEINLINE void readPixelRGB(int pixel, byte &r, byte &g, byte &b) {
-		pbuf.getRGBAt(pixel, r, g, b);
+		_pbuf.getRGBAt(pixel, r, g, b);
 	}
 
 	FORCEINLINE bool compareDepth(unsigned int &zSrc, unsigned int &zDst) {
@@ -228,13 +228,13 @@ private:
 	template <bool kEnableAlphaTest, bool kBlendingEnabled, bool kDepthWrite>
 	FORCEINLINE void writePixel(int pixel, int value, unsigned int z) {
 		if (kBlendingEnabled == false) {
-			this->pbuf.setPixelAt(pixel, value);
+			_pbuf.setPixelAt(pixel, value);
 			if (kDepthWrite) {
 				_zbuf[pixel] = z;
 			}
 		} else {
 			byte rSrc, gSrc, bSrc, aSrc;
-			this->pbuf.getFormat().colorToARGB(value, aSrc, rSrc, gSrc, bSrc);
+			_pbuf.getFormat().colorToARGB(value, aSrc, rSrc, gSrc, bSrc);
 
 			writePixel<kEnableAlphaTest, kBlendingEnabled, kDepthWrite>(pixel, aSrc, rSrc, gSrc, bSrc, z);
 		}
@@ -300,10 +300,10 @@ public:
 		}
 
 		if (kBlendingEnabled == false) {
-			this->pbuf.setPixelAt(pixel, aSrc, rSrc, gSrc, bSrc);
+			_pbuf.setPixelAt(pixel, aSrc, rSrc, gSrc, bSrc);
 		} else {
 			byte rDst, gDst, bDst, aDst;
-			this->pbuf.getARGBAt(pixel, aDst, rDst, gDst, bDst);
+			_pbuf.getARGBAt(pixel, aDst, rDst, gDst, bDst);
 			switch (_sourceBlendingFactor) {
 			case TGL_ZERO:
 				rSrc = gSrc = bSrc = 0;
@@ -397,18 +397,18 @@ public:
 			if (finalR > 255) { finalR = 255; }
 			if (finalG > 255) { finalG = 255; }
 			if (finalB > 255) { finalB = 255; }
-			this->pbuf.setPixelAt(pixel, 255, finalR, finalG, finalB);
+			_pbuf.setPixelAt(pixel, 255, finalR, finalG, finalB);
 		}
 	}
 
 	Graphics::Surface *copyToBuffer(const Graphics::PixelFormat &dstFormat) {
 		Graphics::Surface tmp;
-		tmp.init(xsize, ysize, linesize, pbuf.getRawBuffer(), cmode);
+		tmp.init(_pbufWidth, _pbufHeight, _pbufPitch, _pbuf.getRawBuffer(), _pbufFormat);
 		return tmp.convertTo(dstFormat);
 	}
 
 	void getSurfaceRef(Graphics::Surface &surface) {
-		surface.init(xsize, ysize, linesize, pbuf.getRawBuffer(), cmode);
+		surface.init(_pbufWidth, _pbufHeight, _pbufPitch, _pbuf.getRawBuffer(), _pbufFormat);
 	}
 
 	void setScissorRectangle(const Common::Rect &rect) {
@@ -543,15 +543,16 @@ private:
 	template <bool kInterpRGB, bool kInterpZ, bool kDepthWrite, bool kEnableScissor>
 	void drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2);
 
-	Buffer buffer;
+	Buffer _offscreenBuffer;
 
 	unsigned int *_zbuf;
-	Graphics::PixelBuffer pbuf;
 
-	int xsize, ysize;
-	int linesize; // line size, in bytes
-	Graphics::PixelFormat cmode;
-	int pixelbytes;
+	Graphics::PixelBuffer _pbuf;
+	int _pbufWidth;
+	int _pbufHeight;
+	int _pbufPitch;
+	Graphics::PixelFormat _pbufFormat;
+	int _pbufBpp;
 
 	int _textureSize;
 	int _textureSizeMask;
diff --git a/graphics/tinygl/zdirtyrect.cpp b/graphics/tinygl/zdirtyrect.cpp
index 3d765adffc..7f2ef7b216 100644
--- a/graphics/tinygl/zdirtyrect.cpp
+++ b/graphics/tinygl/zdirtyrect.cpp
@@ -70,10 +70,10 @@ struct DirtyRectangle {
 
 	DirtyRectangle() { }
 	DirtyRectangle(Common::Rect rect, int red, int green, int blue) {
-		this->rectangle = rect;
-		this->r = red;
-		this->g = green;
-		this->b = blue;
+		rectangle = rect;
+		r = red;
+		g = green;
+		b = blue;
 	}
 };
 
diff --git a/graphics/tinygl/zline.cpp b/graphics/tinygl/zline.cpp
index 23dbdcac95..2f5f857fdc 100644
--- a/graphics/tinygl/zline.cpp
+++ b/graphics/tinygl/zline.cpp
@@ -75,7 +75,7 @@ void FrameBuffer::drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2) {
 	// code duplication.
 
 	// Where we are in unidimensional framebuffer coordinate
-	unsigned int pixelOffset = p1->y * xsize + p1->x;
+	unsigned int pixelOffset = p1->y * _pbufWidth + p1->x;
 	// and in 2d
 	int x = p1->x;
 	int y = p1->y;
@@ -85,7 +85,7 @@ void FrameBuffer::drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2) {
 	const int inc_x = p1->x < p2->x ? 1 : -1;
 	const int dy = abs(p2->y - p1->y);
 	const int inc_y = p1->y < p2->y ? 1 : -1;
-	const int inc_y_pixel = p1->y < p2->y ? xsize : -xsize;
+	const int inc_y_pixel = p1->y < p2->y ? _pbufWidth : -_pbufWidth;
 
 	// When to move on each axis
 	int err = (dx > dy ? dx : -dy) / 2;
@@ -142,7 +142,7 @@ void FrameBuffer::drawLine(const ZBufferPoint *p1, const ZBufferPoint *p2) {
 }
 
 void FrameBuffer::plot(ZBufferPoint *p) {
-	const unsigned int pixelOffset = p->y * xsize + p->x;
+	const unsigned int pixelOffset = p->y * _pbufWidth + p->x;
 	const int col = RGB_TO_PIXEL(p->r, p->g, p->b);
 	const unsigned int z = p->z;
 	if (_depthWrite && _depthTestEnabled)
diff --git a/graphics/tinygl/zmath.cpp b/graphics/tinygl/zmath.cpp
index 24612e3cf3..7d09f43ff9 100644
--- a/graphics/tinygl/zmath.cpp
+++ b/graphics/tinygl/zmath.cpp
@@ -190,50 +190,50 @@ void Matrix4::identity() {
 Matrix4 Matrix4::transpose() const {
 	Matrix4 a;
 
-	a._m[0][0] = this->_m[0][0];
-	a._m[0][1] = this->_m[1][0];
-	a._m[0][2] = this->_m[2][0];
-	a._m[0][3] = this->_m[3][0];
-
-	a._m[1][0] = this->_m[0][1];
-	a._m[1][1] = this->_m[1][1];
-	a._m[1][2] = this->_m[2][1];
-	a._m[1][3] = this->_m[3][1];
-
-	a._m[2][0] = this->_m[0][2];
-	a._m[2][1] = this->_m[1][2];
-	a._m[2][2] = this->_m[2][2];
-	a._m[2][3] = this->_m[3][2];
-
-	a._m[3][0] = this->_m[0][3];
-	a._m[3][1] = this->_m[1][3];
-	a._m[3][2] = this->_m[2][3];
-	a._m[3][3] = this->_m[3][3];
+	a._m[0][0] = _m[0][0];
+	a._m[0][1] = _m[1][0];
+	a._m[0][2] = _m[2][0];
+	a._m[0][3] = _m[3][0];
+
+	a._m[1][0] = _m[0][1];
+	a._m[1][1] = _m[1][1];
+	a._m[1][2] = _m[2][1];
+	a._m[1][3] = _m[3][1];
+
+	a._m[2][0] = _m[0][2];
+	a._m[2][1] = _m[1][2];
+	a._m[2][2] = _m[2][2];
+	a._m[2][3] = _m[3][2];
+
+	a._m[3][0] = _m[0][3];
+	a._m[3][1] = _m[1][3];
+	a._m[3][2] = _m[2][3];
+	a._m[3][3] = _m[3][3];
 
 	return a;
 }
 
 void Matrix4::transpose() {
 	Matrix4 tmp = *this;
-	this->_m[0][0] = tmp._m[0][0];
-	this->_m[0][1] = tmp._m[1][0];
-	this->_m[0][2] = tmp._m[2][0];
-	this->_m[0][3] = tmp._m[3][0];
-
-	this->_m[1][0] = tmp._m[0][1];
-	this->_m[1][1] = tmp._m[1][1];
-	this->_m[1][2] = tmp._m[2][1];
-	this->_m[1][3] = tmp._m[3][1];
-
-	this->_m[2][0] = tmp._m[0][2];
-	this->_m[2][1] = tmp._m[1][2];
-	this->_m[2][2] = tmp._m[2][2];
-	this->_m[2][3] = tmp._m[3][2];
-
-	this->_m[3][0] = tmp._m[0][3];
-	this->_m[3][1] = tmp._m[1][3];
-	this->_m[3][2] = tmp._m[2][3];
-	this->_m[3][3] = tmp._m[3][3];
+	_m[0][0] = tmp._m[0][0];
+	_m[0][1] = tmp._m[1][0];
+	_m[0][2] = tmp._m[2][0];
+	_m[0][3] = tmp._m[3][0];
+
+	_m[1][0] = tmp._m[0][1];
+	_m[1][1] = tmp._m[1][1];
+	_m[1][2] = tmp._m[2][1];
+	_m[1][3] = tmp._m[3][1];
+
+	_m[2][0] = tmp._m[0][2];
+	_m[2][1] = tmp._m[1][2];
+	_m[2][2] = tmp._m[2][2];
+	_m[2][3] = tmp._m[3][2];
+
+	_m[3][0] = tmp._m[0][3];
+	_m[3][1] = tmp._m[1][3];
+	_m[3][2] = tmp._m[2][3];
+	_m[3][3] = tmp._m[3][3];
 }
 
 Matrix4 Matrix4::inverseOrtho() const {
@@ -241,7 +241,7 @@ Matrix4 Matrix4::inverseOrtho() const {
 
 	for (int i = 0; i < 3; i++) {
 		for (int j = 0; j < 3; j++) {
-			a._m[i][j] = this->_m[j][i];
+			a._m[i][j] = _m[j][i];
 		}
 	}
 	a._m[3][0] = 0.0f;
@@ -252,7 +252,7 @@ Matrix4 Matrix4::inverseOrtho() const {
 	for (int i = 0; i < 3; i++) {
 		float s = 0;
 		for (int j = 0; j < 3; j++) {
-			s -= this->_m[j][i] * this->_m[j][3];
+			s -= _m[j][i] * _m[j][3];
 		}
 		a._m[i][3] = s;
 	}
@@ -302,7 +302,7 @@ bool Matrix4::isIdentity() const {
 }
 
 void Matrix4::invert() {
-	MatrixInverse((float *)this->_m);
+	MatrixInverse((float *)_m);
 }
 
 Matrix4 Matrix4::frustum(float left, float right, float bottom, float top, float nearp, float farp) {
diff --git a/graphics/tinygl/zmath.h b/graphics/tinygl/zmath.h
index 8088d63c69..177e57475c 100644
--- a/graphics/tinygl/zmath.h
+++ b/graphics/tinygl/zmath.h
@@ -208,7 +208,7 @@ public:
 				s = 0.0;
 				for (int k = 0; k < 4; k++)
 					s += a._m[i][k] * b._m[k][j];
-				this->_m[i][j] = s;
+				_m[i][j] = s;
 			}
 		}
 		return *this;
diff --git a/graphics/tinygl/ztriangle.cpp b/graphics/tinygl/ztriangle.cpp
index a2d8b9541f..2eea588893 100644
--- a/graphics/tinygl/ztriangle.cpp
+++ b/graphics/tinygl/ztriangle.cpp
@@ -239,15 +239,15 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
 
 	// screen coordinates
 
-	int pp1 = xsize * p0->y;
-	pz1 = _zbuf + p0->y * xsize;
+	int pp1 = _pbufWidth * p0->y;
+	pz1 = _zbuf + p0->y * _pbufWidth;
 
 	switch (kDrawLogic) {
 	case DRAW_SHADOW_MASK:
-		pm1 = _shadowMaskBuf + p0->y * xsize;
+		pm1 = _shadowMaskBuf + p0->y * _pbufWidth;
 		break;
 	case DRAW_SHADOW:
-		pm1 = _shadowMaskBuf + p0->y * xsize;
+		pm1 = _shadowMaskBuf + p0->y * _pbufWidth;
 		r1 = _shadowColorR;
 		g1 = _shadowColorG;
 		b1 = _shadowColorB;
@@ -616,11 +616,11 @@ void FrameBuffer::fillTriangle(ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint
 			x2 += dx2dy2;
 
 			// screen coordinates
-			pp1 += xsize;
-			pz1 += xsize;
+			pp1 += _pbufWidth;
+			pz1 += _pbufWidth;
 
 			if (kDrawLogic == DRAW_SHADOW || kDrawLogic == DRAW_SHADOW_MASK)
-				pm1 = pm1 + xsize;
+				pm1 = pm1 + _pbufWidth;
 			nb_lines--;
 			y++;
 		}




More information about the Scummvm-git-logs mailing list