[Scummvm-git-logs] scummvm master -> 3676b3919494494647959c73065b39d8c235d6ad
bluegr
noreply at scummvm.org
Thu Jul 4 19:54:24 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4bbcf77f70 GRAPHICS: Add move constructors to ManagedSurface
3676b39194 GRAPHICS: Deprecate the ManagedSurface copy constructor
Commit: 4bbcf77f70dc2046c86061b3e622d00002390c8e
https://github.com/scummvm/scummvm/commit/4bbcf77f70dc2046c86061b3e622d00002390c8e
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-07-04T22:54:21+03:00
Commit Message:
GRAPHICS: Add move constructors to ManagedSurface
Changed paths:
graphics/managed_surface.cpp
graphics/managed_surface.h
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 45652f99e69..38e9731f5d0 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -44,6 +44,28 @@ ManagedSurface::ManagedSurface(const ManagedSurface &surf) :
this->copyFrom(surf);
}
+ManagedSurface::ManagedSurface(ManagedSurface &&surf) :
+ w(_innerSurface.w), h(_innerSurface.h), pitch(_innerSurface.pitch), format(_innerSurface.format),
+ _disposeAfterUse(surf._disposeAfterUse), _owner(surf._owner), _offsetFromOwner(surf._offsetFromOwner),
+ _transparentColor(surf._transparentColor), _transparentColorSet(surf._transparentColorSet),
+ _palette(surf._palette) {
+
+ _innerSurface.setPixels(surf.getPixels());
+ _innerSurface.w = surf.w;
+ _innerSurface.h = surf.h;
+ _innerSurface.pitch = surf.pitch;
+ _innerSurface.format = surf.format;
+
+ // Reset the old surface
+ surf._innerSurface.init(0, 0, 0, NULL, PixelFormat());
+ surf._disposeAfterUse = DisposeAfterUse::NO;
+ surf._owner = nullptr;
+ surf._offsetFromOwner = Common::Point();
+ surf._transparentColor = 0;
+ surf._transparentColorSet = false;
+ surf._palette = nullptr;
+}
+
ManagedSurface::ManagedSurface(int width, int height) :
w(_innerSurface.w), h(_innerSurface.h), pitch(_innerSurface.pitch), format(_innerSurface.format),
_disposeAfterUse(DisposeAfterUse::NO), _owner(nullptr),
@@ -140,6 +162,37 @@ ManagedSurface &ManagedSurface::operator=(const ManagedSurface &surf) {
return *this;
}
+ManagedSurface &ManagedSurface::operator=(ManagedSurface &&surf) {
+ // Free any current surface
+ free();
+
+ _disposeAfterUse = surf._disposeAfterUse;
+ _owner = surf._owner;
+ _offsetFromOwner = surf._offsetFromOwner;
+
+ _innerSurface.setPixels(surf.getPixels());
+ _innerSurface.w = surf.w;
+ _innerSurface.h = surf.h;
+ _innerSurface.pitch = surf.pitch;
+ _innerSurface.format = surf.format;
+
+ // Copy miscellaneous properties
+ _transparentColorSet = surf._transparentColorSet;
+ _transparentColor = surf._transparentColor;
+ _palette = surf._palette;
+
+ // Reset the old surface
+ surf._innerSurface.init(0, 0, 0, NULL, PixelFormat());
+ surf._disposeAfterUse = DisposeAfterUse::NO;
+ surf._owner = nullptr;
+ surf._offsetFromOwner = Common::Point();
+ surf._transparentColor = 0;
+ surf._transparentColorSet = false;
+ surf._palette = nullptr;
+
+ return *this;
+}
+
void ManagedSurface::setPixels(void *newPixels) {
free();
_innerSurface.setPixels(newPixels);
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index 2e705a64bc6..cb2e8c7f9c7 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -133,6 +133,11 @@ public:
*/
ManagedSurface(const ManagedSurface &surf);
+ /**
+ * Create a managed surface from another one.
+ */
+ ManagedSurface(ManagedSurface &&surf);
+
/**
* Create the managed surface.
*/
@@ -195,6 +200,11 @@ public:
WARN_DEPRECATED("Use copyFrom() instead")
ManagedSurface &operator=(const ManagedSurface &surf);
+ /**
+ * Reassign one managed surface to another one.
+ */
+ ManagedSurface &operator=(ManagedSurface &&surf);
+
/**
* Return true if the surface has not yet been allocated.
*/
Commit: 3676b3919494494647959c73065b39d8c235d6ad
https://github.com/scummvm/scummvm/commit/3676b3919494494647959c73065b39d8c235d6ad
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-07-04T22:54:21+03:00
Commit Message:
GRAPHICS: Deprecate the ManagedSurface copy constructor
Also reverted the changes from commit 81f566a.
Changed paths:
graphics/managed_surface.cpp
graphics/managed_surface.h
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 38e9731f5d0..bf342e806c4 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -41,7 +41,7 @@ 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), _palette(nullptr) {
- this->copyFrom(surf);
+ *this = surf;
}
ManagedSurface::ManagedSurface(ManagedSurface &&surf) :
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index cb2e8c7f9c7..e6590a5406d 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -131,6 +131,7 @@ public:
* this surface will create its own surface of the same size and copy
* the contents from the source surface.
*/
+ WARN_DEPRECATED("Use copyFrom(), a move constructor or supply bounds")
ManagedSurface(const ManagedSurface &surf);
/**
@@ -197,7 +198,7 @@ public:
*
* @note If the source has a managed surface, it will be duplicated.
*/
- WARN_DEPRECATED("Use copyFrom() instead")
+ WARN_DEPRECATED("Use copyFrom() or a move constructor instead")
ManagedSurface &operator=(const ManagedSurface &surf);
/**
More information about the Scummvm-git-logs
mailing list