[Scummvm-git-logs] scummvm master -> b59d4448d7ac89fd3cbb7e9c3a30638d77803220
aquadran
noreply at scummvm.org
Thu Jun 19 18:16:37 UTC 2025
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
e5037fd5b6 GRAPHICS: Add ManagedSurface::blendBlitFrom to match other functions
76b9d6bb52 TESTS: Switch to ManagedSurface::blendBlitFrom
6cc2761a14 NGI: Switch to ManagedSurface::blendBlitFrom
bb46f9741d SWORD25: Switch to ManagedSurface::blendBlitFrom
b59d4448d7 WINTERMUTE: Switch to ManagedSurface::blendBlitFrom
Commit: e5037fd5b664ab74aa57e41591703c5911f79165
https://github.com/scummvm/scummvm/commit/e5037fd5b664ab74aa57e41591703c5911f79165
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-19T20:16:30+02:00
Commit Message:
GRAPHICS: Add ManagedSurface::blendBlitFrom to match other functions
Changed paths:
graphics/managed_surface.cpp
graphics/managed_surface.h
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 26abb1c9551..3a90fd66063 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -891,6 +891,129 @@ void ManagedSurface::transBlitFromInner(const Surface &src, const Common::Rect &
#undef HANDLE_BLIT
+void ManagedSurface::blendBlitFrom(const Surface &src, const int flipping, const uint colorMod,
+ const TSpriteBlendMode blend, const AlphaType alphaType) {
+ blendBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(0, 0, this->w, this->h),
+ flipping, colorMod, blend, alphaType);
+}
+
+void ManagedSurface::blendBlitFrom(const Surface &src, const Common::Point &destPos,
+ const int flipping, const uint colorMod, const TSpriteBlendMode blend, const
+ AlphaType alphaType) {
+ blendBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(destPos.x, destPos.y,
+ destPos.x + src.w, destPos.y + src.h), flipping, colorMod, blend, alphaType);
+}
+
+void ManagedSurface::blendBlitFrom(const Surface &src, const Common::Rect &srcRect,
+ const Common::Point &destPos, const int flipping, const uint colorMod,
+ const TSpriteBlendMode blend, const AlphaType alphaType) {
+ blendBlitFrom(src, srcRect, Common::Rect(destPos.x, destPos.y,
+ destPos.x + srcRect.width(), destPos.y + srcRect.height()), flipping, colorMod, blend, alphaType);
+}
+
+void ManagedSurface::blendBlitFrom(const Surface &src, const Common::Rect &srcRect,
+ const Common::Rect &destRect, const int flipping, const uint colorMod,
+ const TSpriteBlendMode blend, const AlphaType alphaType) {
+ blendBlitFromInner(src, srcRect, destRect, flipping, colorMod, blend, alphaType);
+}
+
+void ManagedSurface::blendBlitFrom(const ManagedSurface &src, const int flipping, const uint colorMod,
+ const TSpriteBlendMode blend, const AlphaType alphaType) {
+ blendBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(0, 0, this->w, this->h),
+ flipping, colorMod, blend, alphaType);
+}
+
+void ManagedSurface::blendBlitFrom(const ManagedSurface &src, const Common::Point &destPos,
+ const int flipping, const uint colorMod, const TSpriteBlendMode blend, const
+ AlphaType alphaType) {
+ blendBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(destPos.x, destPos.y,
+ destPos.x + src.w, destPos.y + src.h), flipping, colorMod, blend, alphaType);
+}
+
+void ManagedSurface::blendBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect,
+ const Common::Point &destPos, const int flipping, const uint colorMod,
+ const TSpriteBlendMode blend, const AlphaType alphaType) {
+ blendBlitFrom(src, srcRect, Common::Rect(destPos.x, destPos.y,
+ destPos.x + srcRect.width(), destPos.y + srcRect.height()), flipping, colorMod, blend, alphaType);
+}
+
+void ManagedSurface::blendBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect,
+ const Common::Rect &destRect, const int flipping, const uint colorMod,
+ const TSpriteBlendMode blend, const AlphaType alphaType) {
+ blendBlitFromInner(src._innerSurface, srcRect, destRect, flipping, colorMod, blend, alphaType);
+}
+
+void ManagedSurface::blendBlitFromInner(const Surface &src, const Common::Rect &srcRect,
+ const Common::Rect &destRect, const int flipping, const uint colorMod,
+ const TSpriteBlendMode blend, const AlphaType alphaType) {
+ Common::Rect srcRectC = srcRect;
+ Common::Rect destRectC = destRect;
+
+ if (!isBlendBlitPixelFormatSupported(src.format, format)) {
+ warning("ManagedSurface::blendBlitFrom only accepts RGBA32!");
+ return;
+ }
+
+ // Alpha is zero
+ if ((colorMod & MS_ARGB(255, 0, 0, 0)) == 0) return;
+
+ const int scaleX = BlendBlit::getScaleFactor(srcRectC.width(), destRectC.width());
+ const int scaleY = BlendBlit::getScaleFactor(srcRectC.height(), destRectC.height());
+ int scaleXoff = 0, scaleYoff = 0;
+
+ if (destRectC.left < 0) {
+ scaleXoff = (-destRectC.left * scaleX) % BlendBlit::SCALE_THRESHOLD;
+ srcRectC.left += -destRectC.left * scaleX / BlendBlit::SCALE_THRESHOLD;
+ destRectC.left = 0;
+ }
+
+ if (destRectC.top < 0) {
+ scaleYoff = (-destRectC.top * scaleY) % BlendBlit::SCALE_THRESHOLD;
+ srcRectC.top += -destRectC.top * scaleY / BlendBlit::SCALE_THRESHOLD;
+ destRectC.top = 0;
+ }
+
+ if (destRectC.right > w) {
+ srcRectC.right -= (destRectC.right - src.w) * scaleX / BlendBlit::SCALE_THRESHOLD;
+ destRectC.right = w;
+ }
+
+ if (destRectC.bottom > h) {
+ srcRectC.bottom -= (destRectC.bottom - src.h) * scaleY / BlendBlit::SCALE_THRESHOLD;
+ destRectC.bottom = h;
+ }
+
+ if (flipping & FLIP_H) {
+ int tmp_w = srcRectC.width();
+ srcRectC.left = src.w - srcRectC.right;
+ srcRectC.right = srcRectC.left + tmp_w;
+ scaleXoff = (BlendBlit::SCALE_THRESHOLD - (scaleXoff + destRectC.width() * scaleX)) % BlendBlit::SCALE_THRESHOLD;
+ }
+
+ if (flipping & FLIP_V) {
+ int tmp_h = srcRectC.height();
+ srcRectC.top = src.h - srcRectC.bottom;
+ srcRectC.bottom = srcRectC.top + tmp_h;
+ scaleYoff = (BlendBlit::SCALE_THRESHOLD - (scaleYoff + destRectC.height() * scaleY)) % BlendBlit::SCALE_THRESHOLD;
+ }
+
+ if (!destRectC.isEmpty() && !srcRectC.isEmpty()) {
+ BlendBlit::blit(
+ (byte *)getBasePtr(0, 0),
+ (const byte *)src.getBasePtr(srcRectC.left, srcRectC.top),
+ pitch, src.pitch,
+ destRectC.left, destRectC.top,
+ destRectC.width(), destRectC.height(),
+ scaleX, scaleY,
+ scaleXoff, scaleYoff,
+ colorMod, flipping,
+ blend, alphaType);
+
+ // Mark the affected area
+ addDirtyRect(destRectC);
+ }
+}
+
Common::Rect ManagedSurface::blendBlitTo(ManagedSurface &target,
const int posX, const int posY,
const int flipping,
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index 13be310975f..23831d07e83 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -111,6 +111,14 @@ protected:
void transBlitFromInner(const Surface &src, const Common::Rect &srcRect,
const Common::Rect &destRect, uint32 transColor, bool flipped, uint32 srcAlpha,
const Palette *srcPalette, const Palette *dstPalette);
+
+ /**
+ * Inner method for copying another surface into this one at a given destination position with alpha blending.
+ */
+ void blendBlitFromInner(const Surface &src, const Common::Rect &srcRect,
+ const Common::Rect &destRect, const int flipping, const uint colorMod,
+ const TSpriteBlendMode blend, const AlphaType alphaType);
+
public:
/**
* Clip the given source bounds so the passed destBounds will be entirely on-screen.
@@ -560,6 +568,174 @@ public:
return BlendBlit::getSupportedPixelFormat() == src && BlendBlit::getSupportedPixelFormat() == dst;
}
+ /**
+ * Copy another surface into this one, using alpha blending.
+ *
+ * @param src Source surface.
+ * @param transColor Transparency color to ignore copying of.
+ * @param flipped Whether to horizontally flip the image.
+ * @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
+ * @param flipping Flipping flags to use (use Graphics::FLIP_FLAGS)
+ * @param colorMod What color to multiply by (0xffffffff does nothing)
+ * @param blend The blending mode to use.
+ * @param alphaType what alpha mode to use. FULL is default
+ */
+ void blendBlitFrom(const Surface &src,
+ const int flipping = FLIP_NONE,
+ const uint colorMod = MS_ARGB(255, 255, 255, 255),
+ const TSpriteBlendMode blend = BLEND_NORMAL,
+ const AlphaType alphaType = ALPHA_FULL);
+
+ /**
+ * Copy another surface into this one, using alpha blending.
+ *
+ * @param src Source surface.
+ * @param destPos Destination position to draw the surface.
+ * @param transColor Transparency color to ignore copying of.
+ * @param flipped Whether to horizontally flip the image.
+ * @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
+ * @param flipping Flipping flags to use (use Graphics::FLIP_FLAGS)
+ * @param colorMod What color to multiply by (0xffffffff does nothing)
+ * @param blend The blending mode to use.
+ * @param alphaType what alpha mode to use. FULL is default
+ */
+ void blendBlitFrom(const Surface &src, const Common::Point &destPos,
+ const int flipping = FLIP_NONE,
+ const uint colorMod = MS_ARGB(255, 255, 255, 255),
+ const TSpriteBlendMode blend = BLEND_NORMAL,
+ const AlphaType alphaType = ALPHA_FULL);
+
+ /**
+ * Copy another surface into this one, using alpha blending.
+ *
+ * @param src Source surface.
+ * @param srcRect Subsection of the source surface to draw.
+ * @param destPos Destination position to draw the surface.
+ * @param transColor Transparency color to ignore copying of.
+ * @param flipped Whether to horizontally flip the image.
+ * @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
+ * @param flipping Flipping flags to use (use Graphics::FLIP_FLAGS)
+ * @param colorMod What color to multiply by (0xffffffff does nothing)
+ * @param blend The blending mode to use.
+ * @param alphaType what alpha mode to use. FULL is default
+ */
+ void blendBlitFrom(const Surface &src, const Common::Rect &srcRect,
+ const Common::Point &destPos,
+ const int flipping = FLIP_NONE,
+ const uint colorMod = MS_ARGB(255, 255, 255, 255),
+ const TSpriteBlendMode blend = BLEND_NORMAL,
+ const AlphaType alphaType = ALPHA_FULL);
+
+ /**
+ * Copy another surface into this one, using alpha blending.
+ *
+ * @param src Source surface.
+ * @param srcRect Subsection of the source surface to draw.
+ * @param destRect Destination area to draw the surface in. This can be sized differently
+ * then @p srcRect, allowing for arbitrary scaling of the image.
+ * @param transColor Transparency color to ignore copying of.
+ * @param flipped Whether to horizontally flip the image.
+ * @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
+ * @param flipping Flipping flags to use (use Graphics::FLIP_FLAGS)
+ * @param colorMod What color to multiply by (0xffffffff does nothing)
+ * @param blend The blending mode to use.
+ * @param alphaType what alpha mode to use. FULL is default
+ */
+ void blendBlitFrom(const Surface &src, const Common::Rect &srcRect,
+ const Common::Rect &destRect,
+ const int flipping = FLIP_NONE,
+ const uint colorMod = MS_ARGB(255, 255, 255, 255),
+ const TSpriteBlendMode blend = BLEND_NORMAL,
+ const AlphaType alphaType = ALPHA_FULL);
+
+ /**
+ * Copy another surface into this one, using alpha blending.
+ *
+ * @param src Source surface.
+ * @param transColor Transparency color to ignore copying of.
+ * @param flipped Whether to horizontally flip the image.
+ * @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
+ * @param flipping Flipping flags to use (use Graphics::FLIP_FLAGS)
+ * @param colorMod What color to multiply by (0xffffffff does nothing)
+ * @param blend The blending mode to use.
+ * @param alphaType what alpha mode to use. FULL is default
+ */
+ void blendBlitFrom(const ManagedSurface &src,
+ const int flipping = FLIP_NONE,
+ const uint colorMod = MS_ARGB(255, 255, 255, 255),
+ const TSpriteBlendMode blend = BLEND_NORMAL,
+ const AlphaType alphaType = ALPHA_FULL);
+
+ /**
+ * Copy another surface into this one, using alpha blending.
+ *
+ * @param src Source surface.
+ * @param destPos Destination position to draw the surface.
+ * @param transColor Transparency color to ignore copying of.
+ * @param flipped Whether to horizontally flip the image.
+ * @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
+ * @param flipping Flipping flags to use (use Graphics::FLIP_FLAGS)
+ * @param colorMod What color to multiply by (0xffffffff does nothing)
+ * @param blend The blending mode to use.
+ * @param alphaType what alpha mode to use. FULL is default
+ */
+ void blendBlitFrom(const ManagedSurface &src, const Common::Point &destPos,
+ const int flipping = FLIP_NONE,
+ const uint colorMod = MS_ARGB(255, 255, 255, 255),
+ const TSpriteBlendMode blend = BLEND_NORMAL,
+ const AlphaType alphaType = ALPHA_FULL);
+
+ /**
+ * Copy another surface into this one, using alpha blending.
+ *
+ * @param src Source surface.
+ * @param srcRect Subsection of the source surface to draw.
+ * @param destPos Destination position to draw the surface.
+ * @param transColor Transparency color to ignore copying of.
+ * @param flipped Whether to horizontally flip the image.
+ * @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
+ * @param flipping Flipping flags to use (use Graphics::FLIP_FLAGS)
+ * @param colorMod What color to multiply by (0xffffffff does nothing)
+ * @param blend The blending mode to use.
+ * @param alphaType what alpha mode to use. FULL is default
+ */
+ void blendBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect,
+ const Common::Point &destPos,
+ const int flipping = FLIP_NONE,
+ const uint colorMod = MS_ARGB(255, 255, 255, 255),
+ const TSpriteBlendMode blend = BLEND_NORMAL,
+ const AlphaType alphaType = ALPHA_FULL);
+
+ /**
+ * Copy another surface into this one, using alpha blending.
+ *
+ * @param src Source surface.
+ * @param srcRect Subsection of the source surface to draw.
+ * @param destRect Destination area to draw the surface in. This can be sized differently
+ * then @p srcRect, allowing for arbitrary scaling of the image.
+ * @param transColor Transparency color to ignore copying of.
+ * @param flipped Whether to horizontally flip the image.
+ * @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
+ * @param flipping Flipping flags to use (use Graphics::FLIP_FLAGS)
+ * @param colorMod What color to multiply by (0xffffffff does nothing)
+ * @param blend The blending mode to use.
+ * @param alphaType what alpha mode to use. FULL is default
+ */
+ void blendBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect,
+ const Common::Rect &destRect,
+ const int flipping = FLIP_NONE,
+ const uint colorMod = MS_ARGB(255, 255, 255, 255),
+ const TSpriteBlendMode blend = BLEND_NORMAL,
+ const AlphaType alphaType = ALPHA_FULL);
+
/**
* @brief Renders this surface onto target
* @param target renders this surface onto this one
Commit: 76b9d6bb52ab0b8b7343a2172d7324e82634c4b0
https://github.com/scummvm/scummvm/commit/76b9d6bb52ab0b8b7343a2172d7324e82634c4b0
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-19T20:16:30+02:00
Commit Message:
TESTS: Switch to ManagedSurface::blendBlitFrom
Changed paths:
test/image/blending.h
diff --git a/test/image/blending.h b/test/image/blending.h
index dc6a4770c5f..40bbe9bdac7 100644
--- a/test/image/blending.h
+++ b/test/image/blending.h
@@ -852,7 +852,7 @@ public:
oldTime += g_system->getMillis() - oldStart;
uint32 newStart = g_system->getMillis();
for (int i = 0; i < iters; i++) {
- managedSurf.blendBlitTo(managedSurfDest, 0, 0, flipping, nullptr, color, -1, -1, (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
+ managedSurfDest.blendBlitFrom(managedSurf, flipping, color, (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
}
newTime += g_system->getMillis() - newStart;
managedSurfDest.fillRect(Common::Rect(0, 0, managedSurfDest.w, managedSurfDest.h), managedSurfDest.format.ARGBToColor(255, 255, 255, 255));
@@ -860,7 +860,7 @@ public:
Graphics::BlendBlit::blitFunc = Graphics::BlendBlit::blitGeneric;
uint32 genericStart = g_system->getMillis();
for (int i = 0; i < iters; i++) {
- managedSurf.blendBlitTo(managedSurfDest, 0, 0, flipping, nullptr, color, -1, -1, (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
+ managedSurfDest.blendBlitFrom(managedSurf, flipping, color, (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
}
Graphics::BlendBlit::blitFunc = oldFunc;
genericTime += g_system->getMillis() - genericStart;
@@ -877,14 +877,14 @@ public:
oldTimeScaled += g_system->getMillis() - oldStart;
newStart = g_system->getMillis();
for (int i = 0; i < iters; i++) {
- managedSurf.blendBlitTo(managedSurfDest, 0, 0, flipping, nullptr, color, managedSurfDest.w, managedSurfDest.h, (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
+ managedSurfDest.blendBlitFrom(managedSurf, Common::Rect(managedSurf.w, managedSurf.h), Common::Rect(managedSurfDest.w, managedSurfDest.h), flipping, color, (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
}
newTimeScaled += g_system->getMillis() - newStart;
managedSurfDest.fillRect(Common::Rect(0, 0, managedSurfDest.w, managedSurfDest.h), managedSurfDest.format.ARGBToColor(255, 255, 255, 255));
Graphics::BlendBlit::blitFunc = Graphics::BlendBlit::blitGeneric;
genericStart = g_system->getMillis();
for (int i = 0; i < iters; i++) {
- managedSurf.blendBlitTo(managedSurfDest, 0, 0, flipping, nullptr, color, managedSurfDest.w, managedSurfDest.h, (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
+ managedSurfDest.blendBlitFrom(managedSurf, Common::Rect(managedSurf.w, managedSurf.h), Common::Rect(managedSurfDest.w, managedSurfDest.h), flipping, color, (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
}
Graphics::BlendBlit::blitFunc = oldFunc;
genericTimeScaled += g_system->getMillis() - genericStart;
@@ -895,11 +895,11 @@ public:
} // blend
debug("Old TransparentSurface::blit avg time per %d iters (in milliseconds): %f\n", iters, oldTime / numIters);
- debug("New ManagedSurface::blendBlitTo (non SIMD) avg time per %d iters (in milliseconds): %f\n", iters, genericTime / numIters);
- debug("New ManagedSurface::blendBlitTo avg time per %d iters (in milliseconds): %f\n", iters, newTime / numIters);
+ debug("New ManagedSurface::blendBlitFrom (non SIMD) avg time per %d iters (in milliseconds): %f\n", iters, genericTime / numIters);
+ debug("New ManagedSurface::blendBlitFrom avg time per %d iters (in milliseconds): %f\n", iters, newTime / numIters);
debug("Old SCALING TransparentSurface::blit avg time per %d iters (in milliseconds): %f\n", iters, oldTimeScaled / numItersScaled);
- debug("New SCALING ManagedSurface::blendBlitTo (non SIMD) avg time per %d iters (in milliseconds): %f\n", iters, genericTimeScaled / numItersScaled);
- debug("New SCALING ManagedSurface::blendBlitTo avg time per %d iters (in milliseconds): %f\n", iters, newTimeScaled / numItersScaled);
+ debug("New SCALING ManagedSurface::blendBlitFrom (non SIMD) avg time per %d iters (in milliseconds): %f\n", iters, genericTimeScaled / numItersScaled);
+ debug("New SCALING ManagedSurface::blendBlitFrom avg time per %d iters (in milliseconds): %f\n", iters, newTimeScaled / numItersScaled);
baseSurface.free();
#endif
@@ -937,8 +937,8 @@ public:
OldTransparentSurface::OldTransparentSurface oldSurf(baseSurface, true);
OldTransparentSurface::OldTransparentSurface oldSurfDest(destSurface, true);
- Graphics::ManagedSurface managedSurf(&baseSurface, DisposeAfterUse::NO);
- Graphics::ManagedSurface managedSurfDest(&destSurface, DisposeAfterUse::NO);
+ Graphics::ManagedSurface &managedSurf = baseSurface;
+ Graphics::ManagedSurface &managedSurfDest = destSurface;
const char *blendModes[] = {
"BLEND_NORMAL",
"BLEND_ADDITIVE",
@@ -977,19 +977,11 @@ public:
for (int rect = 0; rect < (int)(sizeof(srcs)/sizeof(srcs[0])); rect++) {
oldSurfDest.fillRect(Common::Rect(0, 0, oldSurfDest.w, oldSurfDest.h), oldSurfDest.format.ARGBToColor(ba, br, bg, bb));
oldSurf._alphaMode = (Graphics::AlphaType)alphaType;
- Common::Rect ret1 = oldSurf.blit(oldSurfDest, dsts[rect].left, dsts[rect].top, flipping, &srcs[rect], MS_ARGB(a, r, g, b), dsts[rect].width(), dsts[rect].height(), (Graphics::TSpriteBlendMode)blendMode);
+ oldSurf.blit(oldSurfDest, dsts[rect].left, dsts[rect].top, flipping, &srcs[rect], MS_ARGB(a, r, g, b), dsts[rect].width(), dsts[rect].height(), (Graphics::TSpriteBlendMode)blendMode);
managedSurfDest.fillRect(Common::Rect(0, 0, managedSurfDest.w, managedSurfDest.h), managedSurfDest.format.ARGBToColor(ba, br, bg, bb));
- Common::Rect ret3 = managedSurf.blendBlitTo(managedSurfDest, dsts[rect].left, dsts[rect].top, flipping, &srcs[rect], MS_ARGB(a, r, g, b), dsts[rect].width(), dsts[rect].height(), (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
-
- if (ret1 != ret3) {
- warning("blendMode: %s, alphaType: %s, a: %d, r: %d, g: %d, b: %d, flipping: %s, test rect id: %s",
- blendModes[blendMode], alphaTypes[alphaType], a, r, g, b, flipNames[flipping], rectNames[rect]);
- warning("old: Rect(%d, %d, %d, %d)", ret1.left, ret1.top, ret1.width(), ret1.height());
- warning("managed: Rect(%d, %d, %d, %d)", ret3.left, ret3.top, ret3.width(), ret3.height());
- TS_FAIL("Return sizes are not equal!");
- }
+ managedSurfDest.blendBlitFrom(managedSurf, srcs[rect], dsts[rect], flipping, MS_ARGB(a, r, g, b), (Graphics::TSpriteBlendMode)blendMode, (Graphics::AlphaType)alphaType);
- if (!areSurfacesEqual(&oldSurfDest, managedSurfDest.surfacePtr())) {
+ if (!areSurfacesEqual(&oldSurfDest, &managedSurfDest)) {
warning("blendMode: %s, alphaType: %s, a: %d, r: %d, g: %d, b: %d, flipping: %s, test rect id: %s",
blendModes[blendMode], alphaTypes[alphaType], a, r, g, b, flipNames[flipping], rectNames[rect]);
#ifdef TEST_IMAGE_BLENDING_SAVE
Commit: 6cc2761a14e2ab082768e24a3f365338c79b12d8
https://github.com/scummvm/scummvm/commit/6cc2761a14e2ab082768e24a3f365338c79b12d8
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-19T20:16:30+02:00
Commit Message:
NGI: Switch to ManagedSurface::blendBlitFrom
Changed paths:
engines/ngi/gfx.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index fbd5498fd2f..1fd6d50c5fa 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -785,7 +785,7 @@ void Bitmap::putDib(int x, int y, const Palette &palette, byte alpha) {
uint32 alphac = MS_ARGB(alpha, 0xff, 0xff, 0xff);
- _surface->blendBlitTo(g_nmi->_backgroundSurface, x1, y1, _flipping, &sub, alphac);
+ g_nmi->_backgroundSurface.blendBlitFrom(*_surface, sub, Common::Point(x1, y1), _flipping, alphac);
g_nmi->_system->copyRectToScreen(g_nmi->_backgroundSurface.getBasePtr(x1, y1), g_nmi->_backgroundSurface.pitch, x1, y1, sub.width(), sub.height());
}
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 0db2f996a3d..6861ae87d25 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -30,7 +30,7 @@
#include "common/random.h"
#include "common/savefile.h"
#include "common/system.h"
-#include "graphics/surface.h"
+#include "graphics/managed_surface.h"
#include "engines/engine.h"
#include "ngi/console.h"
@@ -140,7 +140,7 @@ public:
void updateEvents();
- Graphics::Surface _backgroundSurface;
+ Graphics::ManagedSurface _backgroundSurface;
Graphics::PixelFormat _origFormat;
Common::ScopedPtr<GameLoader> _gameLoader;
Commit: bb46f9741d971292bcf6cac71f46e0b286b0d312
https://github.com/scummvm/scummvm/commit/bb46f9741d971292bcf6cac71f46e0b286b0d312
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-19T20:16:30+02:00
Commit Message:
SWORD25: Switch to ManagedSurface::blendBlitFrom
Changed paths:
engines/sword25/gfx/image/renderedimage.cpp
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 6a00d2edfd6..d139fe90ad9 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -229,9 +229,12 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe
int cg = (color >> BS_GSHIFT) & 0xff;
int cb = (color >> BS_BSHIFT) & 0xff;
- if (width == -1) width = pPartRect ? pPartRect->width() : _surface.w;
- if (height == -1) height = pPartRect ? pPartRect->height() : _surface.h;
- _surface.blendBlitTo(*_backSurface, posX, posY, newFlipping, pPartRect, _surface.format.ARGBToColor(ca, cr, cg, cb), width, height, Graphics::BLEND_NORMAL, _alphaType);
+ Common::Rect srcRect = pPartRect ? *pPartRect : Common::Rect(_surface.w, _surface.h);
+ if (width == -1) width = srcRect.width();
+ if (height == -1) height = srcRect.height();
+
+ _backSurface->blendBlitFrom(_surface, srcRect, Common::Rect(posX, posY, posX + width, posY + height),
+ newFlipping, _surface.format.ARGBToColor(ca, cr, cg, cb), Graphics::BLEND_NORMAL, _alphaType);
return true;
}
Commit: b59d4448d7ac89fd3cbb7e9c3a30638d77803220
https://github.com/scummvm/scummvm/commit/b59d4448d7ac89fd3cbb7e9c3a30638d77803220
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-19T20:16:30+02:00
Commit Message:
WINTERMUTE: Switch to ManagedSurface::blendBlitFrom
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.h
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/base/gfx/osystem/render_ticket.h
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 7faca688d27..c4068a3b5cc 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -49,7 +49,7 @@ BaseRenderer *makeOSystemRenderer(BaseGame *inGame) {
//////////////////////////////////////////////////////////////////////////
BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) {
- _renderSurface = new Graphics::Surface();
+ _renderSurface = new Graphics::ManagedSurface();
_lastFrameIter = _renderQueue.end();
_needsFlip = true;
_skipThisFrame = false;
@@ -479,7 +479,7 @@ bool BaseRenderOSystem::fillRect(int x, int y, int w, int h, uint32 color) {
BaseImage *BaseRenderOSystem::takeScreenshot(int newWidth, int newHeight) {
// TODO: Clip by viewport.
BaseImage *screenshot = new BaseImage();
- screenshot->copyFrom(_renderSurface, newWidth, newHeight);
+ screenshot->copyFrom(_renderSurface->surfacePtr(), newWidth, newHeight);
return screenshot;
}
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
index 6713524e383..c9493f6216a 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
@@ -33,7 +33,7 @@
#include "common/rect.h"
#include "common/list.h"
-#include "graphics/surface.h"
+#include "graphics/managed_surface.h"
#include "graphics/transform_struct.h"
namespace Wintermute {
@@ -133,7 +133,7 @@ private:
bool _needsFlip;
RenderQueueIterator _lastFrameIter;
Common::Rect _renderRect;
- Graphics::Surface *_renderSurface;
+ Graphics::ManagedSurface *_renderSurface;
int _borderLeft;
int _borderTop;
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index 03641d9f89f..ad633f5770f 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -92,10 +92,7 @@ bool RenderTicket::operator==(const RenderTicket &t) const {
}
// Replacement for SDL2's SDL_RenderCopy
-void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const {
- Graphics::ManagedSurface src;
- src.copyFrom(*getSurface());
-
+void RenderTicket::drawToSurface(Graphics::ManagedSurface *_targetSurface) const {
Common::Rect clipRect;
clipRect.setWidth(getSurface()->w);
clipRect.setHeight(getSurface()->h);
@@ -119,18 +116,15 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const {
for (int ry = 0; ry < _transform._numTimesY; ++ry) {
int x = _dstRect.left;
for (int rx = 0; rx < _transform._numTimesX; ++rx) {
- src.blendBlitTo(*_targetSurface, x, y, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height(),
- Graphics::BLEND_NORMAL, alphaMode);
+ _targetSurface->blendBlitFrom(*getSurface(), clipRect, Common::Point(x, y),
+ _transform._flip, _transform._rgbaMod, Graphics::BLEND_NORMAL, alphaMode);
x += w;
}
y += h;
}
}
-void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const {
- Graphics::ManagedSurface src;
- src.copyFrom(*getSurface());
-
+void RenderTicket::drawToSurface(Graphics::ManagedSurface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const {
bool doDelete = false;
if (!clipRect) {
doDelete = true;
@@ -152,8 +146,8 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
}
if (_transform._numTimesX * _transform._numTimesY == 1) {
- src.blendBlitTo(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(),
- clipRect->height(), _transform._blendMode, alphaMode);
+ _targetSurface->blendBlitFrom(*getSurface(), *clipRect, Common::Point(dstRect->left, dstRect->top),
+ _transform._flip, _transform._rgbaMod, _transform._blendMode, alphaMode);
} else {
// clipRect is a subrect of the full numTimesX*numTimesY rect
Common::Rect subRect;
@@ -178,8 +172,9 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
if (subRect.intersects(*clipRect)) {
subRect.clip(*clipRect);
subRect.translate(-x, -y);
- src.blendBlitTo(*_targetSurface, basex + x + subRect.left, basey + y + subRect.top, _transform._flip, &subRect,
- _transform._rgbaMod, subRect.width(), subRect.height(), _transform._blendMode, alphaMode);
+ _targetSurface->blendBlitFrom(*getSurface(), subRect,
+ Common::Point(basex + x + subRect.left, basey + y + subRect.top),
+ _transform._flip, _transform._rgbaMod, _transform._blendMode, alphaMode);
}
x += w;
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.h b/engines/wintermute/base/gfx/osystem/render_ticket.h
index 0674f09ed61..057058be418 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.h
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.h
@@ -28,7 +28,7 @@
#ifndef WINTERMUTE_RENDER_TICKET_H
#define WINTERMUTE_RENDER_TICKET_H
-#include "graphics/surface.h"
+#include "graphics/managed_surface.h"
#include "common/rect.h"
@@ -55,9 +55,9 @@ public:
~RenderTicket();
const Graphics::Surface *getSurface() const { return _surface; }
// Non-dirty-rects:
- void drawToSurface(Graphics::Surface *_targetSurface) const;
+ void drawToSurface(Graphics::ManagedSurface *_targetSurface) const;
// Dirty-rects:
- void drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const;
+ void drawToSurface(Graphics::ManagedSurface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const;
Common::Rect _dstRect;
More information about the Scummvm-git-logs
mailing list