[Scummvm-git-logs] scummvm master -> 085130c6da68db6fc2751e440178cdf79ba221db
ccawley2011
noreply at scummvm.org
Fri Jun 3 15:09:08 UTC 2022
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:
085130c6da GRAPHICS: Move ManagedSurface::clip() to the Surface class
Commit: 085130c6da68db6fc2751e440178cdf79ba221db
https://github.com/scummvm/scummvm/commit/085130c6da68db6fc2751e440178cdf79ba221db
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-06-03T16:00:46+01:00
Commit Message:
GRAPHICS: Move ManagedSurface::clip() to the Surface class
Changed paths:
graphics/managed_surface.cpp
graphics/managed_surface.h
graphics/surface.cpp
graphics/surface.h
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index ba535f71d0d..62be470f760 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -226,35 +226,6 @@ void ManagedSurface::copyFrom(const Surface &surf) {
Common::fill(&_palette[0], &_palette[256], 0);
}
-bool ManagedSurface::clip(Common::Rect &srcBounds, Common::Rect &destBounds) {
- if (destBounds.left >= this->w || destBounds.top >= this->h ||
- destBounds.right <= 0 || destBounds.bottom <= 0)
- return false;
-
- // Clip the bounds if necessary to fit on-screen
- if (destBounds.right > this->w) {
- srcBounds.right -= destBounds.right - this->w;
- destBounds.right = this->w;
- }
-
- if (destBounds.bottom > this->h) {
- srcBounds.bottom -= destBounds.bottom - this->h;
- destBounds.bottom = this->h;
- }
-
- if (destBounds.top < 0) {
- srcBounds.top += -destBounds.top;
- destBounds.top = 0;
- }
-
- if (destBounds.left < 0) {
- srcBounds.left += -destBounds.left;
- destBounds.left = 0;
- }
-
- return true;
-}
-
void ManagedSurface::blitFrom(const Surface &src) {
blitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Point(0, 0));
}
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index d48f6905df1..3b8d169ec28 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -96,7 +96,10 @@ public:
/**
* Clip the given source bounds so the passed destBounds will be entirely on-screen.
*/
- bool clip(Common::Rect &srcBounds, Common::Rect &destBounds);
+ bool clip(Common::Rect& srcBounds, Common::Rect& destBounds) const {
+ return _innerSurface.clip(srcBounds, destBounds);
+ }
+
public:
int16 &w; /*!< Width of the surface rectangle. */
int16 &h; /*!< Height of the surface rectangle. */
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 886796a8cf4..102f84a73a6 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -135,6 +135,35 @@ const Surface Surface::getSubArea(const Common::Rect &area) const {
return subSurface;
}
+bool Surface::clip(Common::Rect &srcBounds, Common::Rect &destBounds) const {
+ if (destBounds.left >= this->w || destBounds.top >= this->h ||
+ destBounds.right <= 0 || destBounds.bottom <= 0)
+ return false;
+
+ // Clip the bounds if necessary to fit on-screen
+ if (destBounds.right > this->w) {
+ srcBounds.right -= destBounds.right - this->w;
+ destBounds.right = this->w;
+ }
+
+ if (destBounds.bottom > this->h) {
+ srcBounds.bottom -= destBounds.bottom - this->h;
+ destBounds.bottom = this->h;
+ }
+
+ if (destBounds.top < 0) {
+ srcBounds.top += -destBounds.top;
+ destBounds.top = 0;
+ }
+
+ if (destBounds.left < 0) {
+ srcBounds.left += -destBounds.left;
+ destBounds.left = 0;
+ }
+
+ return true;
+}
+
void Surface::copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height) {
assert(buffer);
diff --git a/graphics/surface.h b/graphics/surface.h
index fd11c8bc4fe..cccb766f7be 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -259,6 +259,11 @@ public:
*/
const Surface getSubArea(const Common::Rect &area) const;
+ /**
+ * Clip the given source bounds so the passed destBounds will be entirely on-screen.
+ */
+ bool clip(Common::Rect &srcBounds, Common::Rect &destBounds) const;
+
/**
* Copy a bitmap to the internal buffer of the surface.
*
More information about the Scummvm-git-logs
mailing list