aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--graphics/managed_surface.cpp11
-rw-r--r--graphics/managed_surface.h5
2 files changed, 12 insertions, 4 deletions
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 1595a32ecb..7dca33a619 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -124,6 +124,17 @@ void ManagedSurface::free() {
_offsetFromOwner = Common::Point(0, 0);
}
+void ManagedSurface::copyFrom(const ManagedSurface &surf) {
+ // Surface::copyFrom free pixel pointer so let's free up ManagedSurface to be coherent
+ free();
+
+ _innerSurface.copyFrom(surf._innerSurface);
+ clearDirtyRects();
+
+ // Pixels data is now owned by us
+ _disposeAfterUse = DisposeAfterUse::YES;
+}
+
bool ManagedSurface::clip(Common::Rect &srcBounds, Common::Rect &destBounds) {
if (destBounds.left >= this->w || destBounds.top >= this->h ||
destBounds.right <= 0 || destBounds.bottom <= 0)
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index a11d05c557..c143222bbc 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -307,10 +307,7 @@ public:
* Copy the data from another Surface, reinitializing the
* surface to match the dimensions of the passed surface
*/
- void copyFrom(const ManagedSurface &surf) {
- clearDirtyRects();
- _innerSurface.copyFrom(surf._innerSurface);
- }
+ void copyFrom(const ManagedSurface &surf);
/**
* Draw a line.