aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorColin Snover2017-10-15 16:11:47 -0500
committerColin Snover2017-10-15 16:11:47 -0500
commitea2fa9093d87f4e0864c421922fab37700ac260e (patch)
treef4974bc881a3b579f02019bd8a1da46c8b6061c6 /backends/platform
parent2ef10faa1e33d9b71f03ef32288786bee5e26b32 (diff)
downloadscummvm-rg350-ea2fa9093d87f4e0864c421922fab37700ac260e.tar.gz
scummvm-rg350-ea2fa9093d87f4e0864c421922fab37700ac260e.tar.bz2
scummvm-rg350-ea2fa9093d87f4e0864c421922fab37700ac260e.zip
PSP: Improve const-correctness
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/psp/default_display_client.h6
-rw-r--r--backends/platform/psp/display_client.cpp6
-rw-r--r--backends/platform/psp/display_client.h42
-rw-r--r--backends/platform/psp/psppixelformat.cpp2
-rw-r--r--backends/platform/psp/psppixelformat.h14
5 files changed, 36 insertions, 34 deletions
diff --git a/backends/platform/psp/default_display_client.h b/backends/platform/psp/default_display_client.h
index d46b7f1a8a..f2972e0b49 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 b238631e62..6e1ae9a10a 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 5e81947e20..a25d9f9ecc 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 2d7d524b45..83f5935eee 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 ede5a97d6f..3cb3b8fcae 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) {