[Scummvm-git-logs] scummvm master -> ea2fa9093d87f4e0864c421922fab37700ac260e

csnover csnover at users.noreply.github.com
Sun Oct 15 23:12:25 CEST 2017


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:
ea2fa9093d PSP: Improve const-correctness


Commit: ea2fa9093d87f4e0864c421922fab37700ac260e
    https://github.com/scummvm/scummvm/commit/ea2fa9093d87f4e0864c421922fab37700ac260e
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-10-15T16:11:47-05:00

Commit Message:
PSP: Improve const-correctness

Changed paths:
    backends/platform/psp/default_display_client.h
    backends/platform/psp/display_client.cpp
    backends/platform/psp/display_client.h
    backends/platform/psp/psppixelformat.cpp
    backends/platform/psp/psppixelformat.h


diff --git a/backends/platform/psp/default_display_client.h b/backends/platform/psp/default_display_client.h
index d46b7f1..f2972e0 100644
--- a/backends/platform/psp/default_display_client.h
+++ b/backends/platform/psp/default_display_client.h
@@ -40,10 +40,10 @@ public:
 	void clearBuffer();
 	void clearPalette();
 	void render() { _renderer.render(); }
-	uint32 getWidth() { return _buffer.getSourceWidth(); }
-	uint32 getHeight() { return _buffer.getSourceHeight(); }
+	uint32 getWidth() const { return _buffer.getSourceWidth(); }
+	uint32 getHeight() const { return _buffer.getSourceHeight(); }
 	void setPartialPalette(const byte *colors, uint start, uint num) { setDirty(); return _palette.setPartial(colors, start, num); }
-	void getPartialPalette(byte *colors, uint start, uint num) {
+	void getPartialPalette(byte *colors, uint start, uint num) const {
 		return _palette.getPartial(colors, start, num);
 	}
 	void copyFromRect(const byte *buf, int pitch, int destX, int destY, int recWidth, int recHeight);
diff --git a/backends/platform/psp/display_client.cpp b/backends/platform/psp/display_client.cpp
index b238631..6e1ae9a 100644
--- a/backends/platform/psp/display_client.cpp
+++ b/backends/platform/psp/display_client.cpp
@@ -204,7 +204,7 @@ void Palette::deallocate() {
 
 // Copy some of the palette to an array of colors
 //
-void Palette::getPartial(byte *colors, uint start, uint num) {
+void Palette::getPartial(byte *colors, uint start, uint num) const {
 	DEBUG_ENTER_FUNC();
 
 	assert(_values);
@@ -286,13 +286,13 @@ void Palette::print(uint32 numToPrint /* = 0 */) {
 	}
 }
 
-uint32 Palette::getRawColorAt(uint32 position) {
+uint32 Palette::getRawColorAt(uint32 position) const {
 	byte *pcolor = &_values[_pixelFormat.pixelsToBytes(position)];
 	uint32 color = _pixelFormat.getColorValueAt(pcolor);
 	return color;
 }
 
-uint32 Palette::getRGBAColorAt(uint32 position) {
+uint32 Palette::getRGBAColorAt(uint32 position) const {
 	uint32 color = getRawColorAt(position);
 	uint32 r, g, b, a;
 	_pixelFormat.colorToRgba(color, r, g, b, a);
diff --git a/backends/platform/psp/display_client.h b/backends/platform/psp/display_client.h
index 5e81947..a25d9f9 100644
--- a/backends/platform/psp/display_client.h
+++ b/backends/platform/psp/display_client.h
@@ -85,18 +85,19 @@ public:
 	void clear();
 	void setPixelFormats(PSPPixelFormat::Type paletteType, PSPPixelFormat::Type bufferType, bool swapRedBlue = false);
 	void setNumOfEntries(uint32 num) {	_numOfEntries = num; }
-	uint32 getNumOfEntries() { return _numOfEntries; }
-	uint32 getSizeInBytes() { return _pixelFormat.pixelsToBytes(_numOfEntries); }
+	uint32 getNumOfEntries() const { return _numOfEntries; }
+	uint32 getSizeInBytes() const { return _pixelFormat.pixelsToBytes(_numOfEntries); }
 	void set(byte *values) { setPartial(values, 0, _numOfEntries); }
 	void setPartial(const byte *colors, uint start, uint num, bool supportsAlpha = false);
-	void getPartial(byte *colors, uint start, uint num);
-	uint32 getRawColorAt(uint32 position);
-	uint32 getRGBAColorAt(uint32 position);
+	void getPartial(byte *colors, uint start, uint num) const;
+	uint32 getRawColorAt(uint32 position) const;
+	uint32 getRGBAColorAt(uint32 position) const;
 	void setSingleColorRGBA(uint32 num, byte r, byte g, byte b, byte a);
 	void setColorPositionAlpha(uint32 position, bool alpha);
+	const byte *getRawValues() const { return _values; }
 	byte *getRawValues() { return _values; }
-	bool isAllocated() { return (_values != 0); }
-	PSPPixelFormat::Type getPixelFormat() { return _pixelFormat.format; }
+	bool isAllocated() const { return (_values != 0); }
+	PSPPixelFormat::Type getPixelFormat() const { return _pixelFormat.format; }
 	void print(uint32 numToPrint = 0);					// print to screen
 
 protected:
@@ -127,19 +128,20 @@ public:
 	void setPixelFormat(PSPPixelFormat::Type type, bool swapRedBlue = false);
 
 	// getters
-	uint32 getWidth() { return _width; }
-	uint32 getWidthInBytes() { return _pixelFormat.pixelsToBytes(getWidth()); }
-	uint32 getHeight() { return _height; }
-	uint32 getSourceWidth() { return _sourceSize.width; }
-	uint32 getSourceWidthInBytes() { return _pixelFormat.pixelsToBytes(_sourceSize.width); }
-	uint32 getSourceHeight() { return _sourceSize.height; }
-	uint32 getTextureWidth() { return _textureSize.width; }
-	uint32 getTextureHeight() { return _textureSize.height; }
-	PSPPixelFormat::Type getPixelFormat() { return _pixelFormat.format; }
-	uint32 getBitsPerPixel() { return _pixelFormat.bitsPerPixel; }
-	uint32 getBytesPerPixel() { return getBitsPerPixel() >> 3; } /* won't work for 4-bit */
+	uint32 getWidth() const { return _width; }
+	uint32 getWidthInBytes() const { return _pixelFormat.pixelsToBytes(getWidth()); }
+	uint32 getHeight() const { return _height; }
+	uint32 getSourceWidth() const { return _sourceSize.width; }
+	uint32 getSourceWidthInBytes() const { return _pixelFormat.pixelsToBytes(_sourceSize.width); }
+	uint32 getSourceHeight() const { return _sourceSize.height; }
+	uint32 getTextureWidth() const { return _textureSize.width; }
+	uint32 getTextureHeight() const { return _textureSize.height; }
+	PSPPixelFormat::Type getPixelFormat() const { return _pixelFormat.format; }
+	uint32 getBitsPerPixel() const { return _pixelFormat.bitsPerPixel; }
+	uint32 getBytesPerPixel() const { return getBitsPerPixel() >> 3; } /* won't work for 4-bit */
+	const byte *getPixels() const { return _pixels; }
 	byte *getPixels() { return _pixels; }
-	uint32 getSizeInBytes() { return _pixelFormat.pixelsToBytes(_width * _height); }
+	uint32 getSizeInBytes() const { return _pixelFormat.pixelsToBytes(_width * _height); }
 
 	bool hasPalette();
 	void copyFromArray(const byte *buffer, int pitch);
@@ -147,7 +149,7 @@ public:
 	void copyToArray(byte *dst, int pitch);
 	bool allocate(bool inVram = false);
 	void deallocate();
-	bool isAllocated() { return (_pixels != 0) ; }
+	bool isAllocated() const { return (_pixels != 0) ; }
 	void clear();
 	void flipNibbles();		// To handle peculiarities of PSP's 4 bit textures
 	static uint32 scaleUpToPowerOfTwo(uint32 size);
diff --git a/backends/platform/psp/psppixelformat.cpp b/backends/platform/psp/psppixelformat.cpp
index 2d7d524..83f5935 100644
--- a/backends/platform/psp/psppixelformat.cpp
+++ b/backends/platform/psp/psppixelformat.cpp
@@ -173,7 +173,7 @@ Graphics::PixelFormat PSPPixelFormat::convertToScummvmPixelFormat(PSPPixelFormat
 	return pf;
 }
 
-uint32 PSPPixelFormat::convertTo32BitColor(uint32 color) {
+uint32 PSPPixelFormat::convertTo32BitColor(uint32 color) const {
 	DEBUG_ENTER_FUNC();
 	uint32 r, g, b, a, output;
 
diff --git a/backends/platform/psp/psppixelformat.h b/backends/platform/psp/psppixelformat.h
index ede5a97..3cb3b8f 100644
--- a/backends/platform/psp/psppixelformat.h
+++ b/backends/platform/psp/psppixelformat.h
@@ -55,9 +55,9 @@ struct PSPPixelFormat {
 	        PSPPixelFormat::Type &paletteType,
 	        bool &swapRedBlue);
 	static Graphics::PixelFormat convertToScummvmPixelFormat(PSPPixelFormat::Type type);
-	uint32 convertTo32BitColor(uint32 color);
+	uint32 convertTo32BitColor(uint32 color) const;
 
-	inline uint32 rgbaToColor(uint32 r, uint32 g, uint32 b, uint32 a) {
+	inline uint32 rgbaToColor(uint32 r, uint32 g, uint32 b, uint32 a) const {
 		uint32 color;
 
 		switch (format) {
@@ -80,7 +80,7 @@ struct PSPPixelFormat {
 		return color;
 	}
 
-	inline void colorToRgba(uint32 color, uint32 &r, uint32 &g, uint32 &b, uint32 &a) {
+	inline void colorToRgba(uint32 color, uint32 &r, uint32 &g, uint32 &b, uint32 &a) const {
 		switch (format) {
 		case Type_4444:
 			a = (color >> 12) & 0xF; // Interpolate to get true colors
@@ -140,7 +140,7 @@ struct PSPPixelFormat {
 		return color;
 	}
 
-	inline uint32 pixelsToBytes(uint32 pixels) {
+	inline uint32 pixelsToBytes(uint32 pixels) const {
 		switch (bitsPerPixel) {
 		case 4:
 			pixels >>= 1;
@@ -160,7 +160,7 @@ struct PSPPixelFormat {
 		return pixels;
 	}
 
-	inline uint16 swapRedBlue16(uint16 color) {
+	inline uint16 swapRedBlue16(uint16 color) const {
 		uint16 output;
 
 		switch (format) {
@@ -181,7 +181,7 @@ struct PSPPixelFormat {
 		return output;
 	}
 
-	inline uint32 swapRedBlue32(uint32 color) {
+	inline uint32 swapRedBlue32(uint32 color) const {
 		uint32 output;
 
 		switch (format) {
@@ -211,7 +211,7 @@ struct PSPPixelFormat {
 	}
 
 	// Return whatever color we point at
-	inline uint32 getColorValueAt(byte *pointer) {
+	inline uint32 getColorValueAt(byte *pointer) const {
 		uint32 result;
 
 		switch (bitsPerPixel) {





More information about the Scummvm-git-logs mailing list