GRAPHICS: Make copying sources as const

This commit is contained in:
Paul Gilbert 2018-04-08 23:15:09 -04:00 committed by Paul Gilbert
parent 179260c10d
commit 3a0c62e1e4
2 changed files with 5 additions and 5 deletions

View File

@ -35,7 +35,7 @@ ManagedSurface::ManagedSurface() :
Common::fill(&_palette[0], &_palette[256], 0);
}
ManagedSurface::ManagedSurface(ManagedSurface &surf) :
ManagedSurface::ManagedSurface(const ManagedSurface &surf) :
w(_innerSurface.w), h(_innerSurface.h), pitch(_innerSurface.pitch), format(_innerSurface.format),
_disposeAfterUse(DisposeAfterUse::NO), _owner(nullptr),
_transparentColor(0), _transparentColorSet(false), _paletteSet(false) {
@ -71,7 +71,7 @@ ManagedSurface::~ManagedSurface() {
free();
}
ManagedSurface &ManagedSurface::operator=(ManagedSurface &surf) {
ManagedSurface &ManagedSurface::operator=(const ManagedSurface &surf) {
// Free any current surface
free();
@ -84,7 +84,7 @@ ManagedSurface &ManagedSurface::operator=(ManagedSurface &surf) {
// Source isn't managed, so simply copy its fields
_owner = surf._owner;
_offsetFromOwner = surf._offsetFromOwner;
void *srcPixels = surf._innerSurface.getPixels();
void *srcPixels = const_cast<void *>(surf._innerSurface.getPixels());
_innerSurface.setPixels(srcPixels);
_innerSurface.w = surf.w;
_innerSurface.h = surf.h;

View File

@ -115,7 +115,7 @@ public:
* this surface will create it's own surface of the same size and copy
* the contents from the source surface
*/
ManagedSurface(ManagedSurface &surf);
ManagedSurface(const ManagedSurface &surf);
/**
* Create the managed surface
@ -150,7 +150,7 @@ public:
* Reassign one managed surface to another one
* Note that if the source has a managed surface, it will be duplicated
*/
ManagedSurface &operator=(ManagedSurface &surf);
ManagedSurface &operator=(const ManagedSurface &surf);
/**
* Returns true if the surface has not yet been allocated