[Scummvm-git-logs] scummvm master -> 6a7985cc71cae6090e759c830afce738a057765e
sev-
noreply at scummvm.org
Sat Oct 28 23:45:12 UTC 2023
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
cfc596291f WINTERMUTE: Converted code to ManagedSurface
eae2fbeb4f TESTS: Remove tests for transparent_surface.h
6a7985cc71 GRAPHICS: Removed graphics/transparent_surface.*. \o/
Commit: cfc596291f89296e362202e1987a411e921a4dc3
https://github.com/scummvm/scummvm/commit/cfc596291f89296e362202e1987a411e921a4dc3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-10-29T01:28:47+02:00
Commit Message:
WINTERMUTE: Converted code to ManagedSurface
Changed paths:
engines/wintermute/base/gfx/osystem/render_ticket.cpp
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index e3318c61157..8b692a2b647 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -30,8 +30,7 @@
#include "engines/wintermute/base/gfx/osystem/render_ticket.h"
#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h"
-#include "graphics/transform_tools.h"
-#include "graphics/transparent_surface.h"
+#include "graphics/managed_surface.h"
#include "common/textconsole.h"
@@ -99,19 +98,21 @@ bool RenderTicket::operator==(const RenderTicket &t) const {
// Replacement for SDL2's SDL_RenderCopy
void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const {
- Graphics::TransparentSurface src(*getSurface(), false);
+ Graphics::ManagedSurface src(getSurface());
Common::Rect clipRect;
clipRect.setWidth(getSurface()->w);
clipRect.setHeight(getSurface()->h);
+ Graphics::AlphaType alphaMode = Graphics::ALPHA_FULL;
+
if (_owner) {
if (_transform._alphaDisable) {
- src.setAlphaMode(Graphics::ALPHA_OPAQUE);
+ alphaMode = Graphics::ALPHA_OPAQUE;
} else if (_transform._angle) {
- src.setAlphaMode(Graphics::ALPHA_FULL);
+ alphaMode = Graphics::ALPHA_FULL;
} else {
- src.setAlphaMode(_owner->getAlphaType());
+ alphaMode = _owner->getAlphaType();
}
}
@@ -122,7 +123,8 @@ 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.blit(*_targetSurface, x, y, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height());
+ src.blendBlitTo(*_targetSurface, x, y, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height(),
+ Graphics::BLEND_NORMAL, alphaMode);
x += w;
}
y += h;
@@ -130,7 +132,7 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const {
}
void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const {
- Graphics::TransparentSurface src(*getSurface(), false);
+ Graphics::ManagedSurface src(getSurface());
bool doDelete = false;
if (!clipRect) {
doDelete = true;
@@ -139,19 +141,22 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
clipRect->setHeight(getSurface()->h * _transform._numTimesY);
}
+ Graphics::AlphaType alphaMode = Graphics::ALPHA_FULL;
+
if (_owner) {
if (_transform._alphaDisable) {
- src.setAlphaMode(Graphics::ALPHA_OPAQUE);
+ alphaMode = Graphics::ALPHA_OPAQUE;
} else if (_transform._angle) {
- src.setAlphaMode(Graphics::ALPHA_FULL);
+ alphaMode = Graphics::ALPHA_FULL;
} else {
- src.setAlphaMode(_owner->getAlphaType());
+ alphaMode = _owner->getAlphaType();
}
}
if (_transform._numTimesX * _transform._numTimesY == 1) {
- src.blit(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(), clipRect->height(), _transform._blendMode);
+ src.blendBlitTo(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(),
+ clipRect->height(), _transform._blendMode, alphaMode);
} else {
@@ -179,7 +184,8 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
if (subRect.intersects(*clipRect)) {
subRect.clip(*clipRect);
subRect.translate(-x, -y);
- src.blit(*_targetSurface, basex + x + subRect.left, basey + y + subRect.top, _transform._flip, &subRect, _transform._rgbaMod, subRect.width(), subRect.height(), _transform._blendMode);
+ src.blendBlitTo(*_targetSurface, basex + x + subRect.left, basey + y + subRect.top, _transform._flip, &subRect,
+ _transform._rgbaMod, subRect.width(), subRect.height(), _transform._blendMode, alphaMode);
}
Commit: eae2fbeb4f7b56487e0a4e7e3f740e5392b29c58
https://github.com/scummvm/scummvm/commit/eae2fbeb4f7b56487e0a4e7e3f740e5392b29c58
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-10-29T01:41:29+02:00
Commit Message:
TESTS: Remove tests for transparent_surface.h
Changed paths:
test/image/blending.h
diff --git a/test/image/blending.h b/test/image/blending.h
index 31d3ffed8c4..0ecc753d3eb 100644
--- a/test/image/blending.h
+++ b/test/image/blending.h
@@ -32,7 +32,6 @@
#include "graphics/surface.h"
#include "graphics/managed_surface.h"
-#include "graphics/transparent_surface.h"
#include "common/algorithm.h"
#include "common/endian.h"
@@ -42,7 +41,6 @@
#include "common/textconsole.h"
#include "graphics/blit.h"
#include "graphics/primitives.h"
-#include "graphics/transparent_surface.h"
#include "graphics/transform_tools.h"
#include "../null_osystem.h"
@@ -944,8 +942,6 @@ public:
OldTransparentSurface::OldTransparentSurface oldSurf(baseSurface, true);
OldTransparentSurface::OldTransparentSurface oldSurfDest(destSurface, true);
- Graphics::TransparentSurface newSurf(baseSurface, true);
- Graphics::TransparentSurface newSurfDest(destSurface, true);
Graphics::ManagedSurface managedSurf(&baseSurface, DisposeAfterUse::NO);
Graphics::ManagedSurface managedSurfDest(&destSurface, DisposeAfterUse::NO);
const char *blendModes[] = {
@@ -987,33 +983,17 @@ public:
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);
- newSurfDest.fillRect(Common::Rect(0, 0, newSurfDest.w, newSurfDest.h), newSurfDest.format.ARGBToColor(ba, br, bg, bb));
- newSurf.setAlphaMode((Graphics::AlphaType)alphaType);
- Common::Rect ret2 = newSurf.blit(newSurfDest, 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 != ret2 || ret2 != ret3 || ret1 != ret3) {
+ 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("new: Rect(%d, %d, %d, %d)", ret2.left, ret2.top, ret2.width(), ret2.height());
warning("managed: Rect(%d, %d, %d, %d)", ret3.left, ret3.top, ret3.width(), ret3.height());
TS_FAIL("Return sizes are not equal!");
}
- if (!areSurfacesEqual(&oldSurfDest, &newSurfDest)) {
- 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
- save_bitmap("sourceSurf.bmp", &newSurf);
- save_bitmap("oldSurfDest.bmp", &oldSurfDest);
- save_bitmap("newSurfDest.bmp", &newSurfDest);
- save_bitmap("managedSurfDest.bmp", managedSurfDest.surfacePtr());
-#endif
- TS_FAIL("oldSurfDest and newSurfDest are not equal!");
- return;
- }
if (!areSurfacesEqual(&oldSurfDest, managedSurfDest.surfacePtr())) {
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]);
@@ -1026,46 +1006,6 @@ public:
TS_FAIL("oldSurfDest and managedSurfDest are not equal!");
return;
}
- if (!areSurfacesEqual(&newSurfDest, managedSurfDest.surfacePtr())) {
- 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
- save_bitmap("sourceSurf.bmp", &newSurf);
- save_bitmap("oldSurfDest.bmp", &oldSurfDest);
- save_bitmap("newSurfDest.bmp", &newSurfDest);
- save_bitmap("managedSurfDest.bmp", managedSurfDest.surfacePtr());
-#endif
- TS_FAIL("newSurfDest and managedSurfDest are not equal!");
- return;
- }
-
-
- oldSurfDest.fillRect(Common::Rect(0, 0, oldSurfDest.w, oldSurfDest.h), oldSurfDest.format.ARGBToColor(ba, br, bg, bb));
- oldSurf._alphaMode = (Graphics::AlphaType)alphaType;
- ret1 = oldSurf.blitClip(oldSurfDest, Common::Rect(2, 2, oldSurfDest.w - 2, oldSurfDest.h - 2), dsts[rect].left, dsts[rect].top, flipping, &srcs[rect], MS_ARGB(a, r, g, b), dsts[rect].width(), dsts[rect].height(), (Graphics::TSpriteBlendMode)blendMode);
- newSurfDest.fillRect(Common::Rect(0, 0, newSurfDest.w, newSurfDest.h), newSurfDest.format.ARGBToColor(ba, br, bg, bb));
- newSurf.setAlphaMode((Graphics::AlphaType)alphaType);
- ret2 = newSurf.blitClip(newSurfDest, Common::Rect(2, 2, oldSurfDest.w - 2, oldSurfDest.h - 2), dsts[rect].left, dsts[rect].top, flipping, &srcs[rect], MS_ARGB(a, r, g, b), dsts[rect].width(), dsts[rect].height(), (Graphics::TSpriteBlendMode)blendMode);
- if (!areSurfacesEqual(&oldSurfDest, &newSurfDest)) {
- warning("BLIT_CLIP 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
- save_bitmap("sourceSurfBlipClip.bmp", &newSurf);
- save_bitmap("oldSurfDestBlitClip.bmp", &oldSurfDest);
- save_bitmap("newSurfDestBlitClip.bmp", &newSurfDest);
- save_bitmap("managedSurfDest.bmp", managedSurfDest.surfacePtr());
-#endif
- TS_FAIL("oldSurfDest and newSurfDest are not equal with blipClip!");
- return;
- }
- if (ret1 != ret2) {
- 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("new: Rect(%d, %d, %d, %d)", ret2.left, ret2.top, ret2.width(), ret2.height());
- warning("managed: Rect(%d, %d, %d, %d)", ret3.left, ret3.top, ret3.width(), ret3.height());
- TS_FAIL("Return sizes are not equal for blitClip!");
- }
} // rect
} // flipping
} // b
Commit: 6a7985cc71cae6090e759c830afce738a057765e
https://github.com/scummvm/scummvm/commit/6a7985cc71cae6090e759c830afce738a057765e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-10-29T01:44:22+02:00
Commit Message:
GRAPHICS: Removed graphics/transparent_surface.*. \o/
Changed paths:
R graphics/transparent_surface.cpp
R graphics/transparent_surface.h
engines/groovie/video/roq.cpp
graphics/module.mk
diff --git a/engines/groovie/video/roq.cpp b/engines/groovie/video/roq.cpp
index 0556cbecd88..362b9cd8588 100644
--- a/engines/groovie/video/roq.cpp
+++ b/engines/groovie/video/roq.cpp
@@ -50,7 +50,7 @@
#include "image/bmp.h"
#endif
-/* copied from transparent_surface.cpp */
+/* copied from graphics/blit.h */
#ifdef SCUMM_LITTLE_ENDIAN
static const int kAIndex = 0;
static const int kBIndex = 1;
@@ -66,7 +66,7 @@ static const int kRIndex = 0;
namespace Groovie {
-// Overwrites one pixel of destination regardless of the alpha value
+// Overwrites one pixel of destination regardless of the alpha value
static inline void copyPixel(byte *dst, const byte *src) {
*(uint32 *)dst = *(const uint32 *)src;
}
@@ -362,7 +362,7 @@ void ROQPlayer::buildShowBuf() {
destOffset = screenOffset;
}
-
+
// _origY and _origX may be negative (11th hour uses this in the chapel puzzle against Stauf)
int startX, startY, stopX, stopY;
calcStartStop(startX, stopX, _origX, _screen->w);
diff --git a/graphics/module.mk b/graphics/module.mk
index 8bcca735735..e548d7012fe 100644
--- a/graphics/module.mk
+++ b/graphics/module.mk
@@ -57,7 +57,6 @@ MODULE_OBJS := \
svg.o \
transform_struct.o \
transform_tools.o \
- transparent_surface.o \
thumbnail.o \
VectorRenderer.o \
VectorRendererSpec.o \
diff --git a/graphics/transparent_surface.cpp b/graphics/transparent_surface.cpp
deleted file mode 100644
index d4eb0146688..00000000000
--- a/graphics/transparent_surface.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "common/algorithm.h"
-#include "common/endian.h"
-#include "common/util.h"
-#include "common/rect.h"
-#include "common/math.h"
-#include "common/textconsole.h"
-#include "graphics/blit.h"
-#include "graphics/primitives.h"
-#include "graphics/transparent_surface.h"
-#include "graphics/transform_tools.h"
-
-#include "graphics/managed_surface.h"
-
-namespace Graphics {
-
-TransparentSurface::TransparentSurface() : Surface(), _alphaMode(ALPHA_FULL) {}
-
-TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface(), _alphaMode(ALPHA_FULL) {
- if (copyData) {
- copyFrom(surf);
- } else {
- w = surf.w;
- h = surf.h;
- pitch = surf.pitch;
- format = surf.format;
- // We need to cast the const qualifier away here because 'pixels'
- // always needs to be writable. 'surf' however is a constant Surface,
- // thus getPixels will always return const pixel data.
- pixels = const_cast<void *>(surf.getPixels());
- }
-}
-
-Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height, TSpriteBlendMode blendMode) {
- Common::Rect retSize;
- retSize.top = 0;
- retSize.left = 0;
- retSize.setWidth(0);
- retSize.setHeight(0);
- // Check if we need to draw anything at all
- int ca = (color >> BlendBlit::kAModShift) & 0xff;
-
- if (ca == 0) {
- return retSize;
- }
-
- // Create an encapsulating surface for the data
- TransparentSurface srcImage(*this, false);
- // TODO: Is the data really in the screen format?
- if (format.bytesPerPixel != 4) {
- warning("TransparentSurface can only blit 32bpp images, but got %d", format.bytesPerPixel * 8);
- return retSize;
- }
-
- int xOffset = 0, yOffset = 0, srcW = srcImage.w, srcH = srcImage.h;
-
- if (pPartRect) {
- xOffset = pPartRect->left;
- yOffset = pPartRect->top;
- srcW = pPartRect->width();
- srcH = pPartRect->height();
- }
-
- if (width == -1) {
- width = srcW;
- }
- if (height == -1) {
- height = srcH;
- }
-
- int scaleX = BlendBlit::getScaleFactor(srcW, width), scaleXoff = 0;
- int scaleY = BlendBlit::getScaleFactor(srcH, height), scaleYoff = 0;
-
-#ifdef SCALING_TESTING
- // Hardcode scaling to 66% to test scaling
- width = width * 2 / 3;
- height = height * 2 / 3;
-#endif
-
- // Handle off-screen clipping
- if (posY < 0) {
- height = MAX(0, (int)height + posY);
- scaleYoff += (-posY * scaleY) % BlendBlit::SCALE_THRESHOLD;
- yOffset += -posY * scaleY / BlendBlit::SCALE_THRESHOLD;
- srcH = MAX(0, srcH + posY * scaleY / BlendBlit::SCALE_THRESHOLD);
- posY = 0;
- }
-
- if (posX < 0) {
- width = MAX(0, (int)width + posX);
- scaleXoff += (-posX * scaleX) % BlendBlit::SCALE_THRESHOLD;
- xOffset += -posX * scaleX / BlendBlit::SCALE_THRESHOLD;
- srcW = MAX(0, srcW + posX * scaleX / BlendBlit::SCALE_THRESHOLD);
- posX = 0;
- }
-
- if (width + posX > target.w) {
- srcW -= ((width + posX) - target.w) * scaleX / BlendBlit::SCALE_THRESHOLD;
- width = target.w - posX;
- }
-
- if (height + posY > target.h) {
- srcH -= ((height + posY) - target.h) * scaleY / BlendBlit::SCALE_THRESHOLD;
- height = target.h - posY;
- }
- if (flipping & FLIP_H) {
- scaleXoff = (BlendBlit::SCALE_THRESHOLD - (scaleXoff + width * scaleX)) % BlendBlit::SCALE_THRESHOLD;
- xOffset = this->w - (xOffset + srcW);
- }
-
- if (flipping & FLIP_V) {
- scaleYoff = (BlendBlit::SCALE_THRESHOLD - (scaleYoff + height * scaleY)) % BlendBlit::SCALE_THRESHOLD;
- yOffset = this->h - (yOffset + srcH);
- }
-
- // Flip surface
- if ((width > 0) && (height > 0)) {
- BlendBlit::blit(
- (byte *)target.getBasePtr(0, 0),
- (byte *)srcImage.getBasePtr(xOffset, yOffset),
- target.pitch, srcImage.pitch,
- posX, posY, width, height, scaleX, scaleY,
- scaleXoff, scaleYoff,
- color, flipping,
- blendMode, _alphaMode);
- }
-
- retSize.setWidth((int16)width);
- retSize.setHeight((int16)height);
-
- return retSize;
-}
-
-Common::Rect TransparentSurface::blitClip(Graphics::Surface &target, Common::Rect clippingArea, int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height, TSpriteBlendMode blendMode) {
- Common::Rect retSize;
- retSize.top = 0;
- retSize.left = 0;
- retSize.setWidth(0);
- retSize.setHeight(0);
- // Check if we need to draw anything at all
- int ca = (color >> BlendBlit::kAModShift) & 0xff;
-
- if (ca == 0) {
- return retSize;
- }
-
- // Create an encapsulating surface for the data
- TransparentSurface srcImage(*this, false);
- // TODO: Is the data really in the screen format?
- if (format.bytesPerPixel != 4) {
- warning("TransparentSurface can only blit 32bpp images, but got %d", format.bytesPerPixel * 8);
- return retSize;
- }
-
- int xOffset = 0, yOffset = 0, srcW = srcImage.w, srcH = srcImage.h;
-
- if (pPartRect) {
- xOffset = pPartRect->left;
- yOffset = pPartRect->top;
- srcW = pPartRect->width();
- srcH = pPartRect->height();
- }
-
- if (width == -1) {
- width = srcW;
- }
- if (height == -1) {
- height = srcH;
- }
-
- int scaleX = BlendBlit::getScaleFactor(srcW, width), scaleXoff = 0;;
- int scaleY = BlendBlit::getScaleFactor(srcH, height), scaleYoff = 0;;
-
-#ifdef SCALING_TESTING
- // Hardcode scaling to 66% to test scaling
- width = width * 2 / 3;
- height = height * 2 / 3;
-#endif
-
- // Handle off-screen clipping
- if (posY < clippingArea.top) {
- posY -= clippingArea.top;
- scaleYoff += (-posY * scaleY) % BlendBlit::SCALE_THRESHOLD;
- yOffset += -posY * scaleY / BlendBlit::SCALE_THRESHOLD;
- height = MAX(0, (int)height + posY);
- srcH = MAX(0, srcH + posY * scaleY / BlendBlit::SCALE_THRESHOLD);
- posY = clippingArea.top;
- }
-
- if (posX < clippingArea.left) {
- posX -= clippingArea.left;
- scaleXoff += (-posX * scaleX) % BlendBlit::SCALE_THRESHOLD;
- xOffset += -posX * scaleX / BlendBlit::SCALE_THRESHOLD;
- width = MAX(0, (int)width + posX);
- srcW = MAX(0, srcW + posX * scaleX / BlendBlit::SCALE_THRESHOLD);
- posX = clippingArea.left;
- }
-
- if (width + posX > clippingArea.right) {
- srcW -= ((width + posX) - clippingArea.right) * scaleX / BlendBlit::SCALE_THRESHOLD;
- width = clippingArea.right - posX;
- }
-
- if (height + posY > clippingArea.bottom) {
- srcH -= ((height + posY) - clippingArea.bottom) * scaleY / BlendBlit::SCALE_THRESHOLD;
- height = clippingArea.bottom - posY;
- }
- if (flipping & FLIP_H) {
- scaleXoff = (BlendBlit::SCALE_THRESHOLD - (scaleXoff + width * scaleX)) % BlendBlit::SCALE_THRESHOLD;
- xOffset = this->w - (xOffset + srcW);
- }
-
- if (flipping & FLIP_V) {
- scaleYoff = (BlendBlit::SCALE_THRESHOLD - (scaleYoff + height * scaleY)) % BlendBlit::SCALE_THRESHOLD;
- yOffset = this->h - (yOffset + srcH);
- }
-
- // Flip surface
- if ((width > 0) && (height > 0)) {
- BlendBlit::blit(
- (byte *)target.getBasePtr(0, 0),
- (byte *)srcImage.getBasePtr(xOffset, yOffset),
- target.pitch, srcImage.pitch,
- posX, posY, width, height, scaleX, scaleY,
- scaleXoff, scaleYoff,
- color, flipping,
- blendMode, _alphaMode);
- }
-
- retSize.setWidth(width);
- retSize.setHeight(height);
-
- return retSize;
-}
-
-AlphaType TransparentSurface::getAlphaMode() const {
- return _alphaMode;
-}
-
-void TransparentSurface::setAlphaMode(AlphaType mode) {
- _alphaMode = mode;
-}
-
-TransparentSurface *TransparentSurface::scale(int16 newWidth, int16 newHeight, bool filtering) const {
-
- TransparentSurface *target = new TransparentSurface();
-
- target->create(newWidth, newHeight, format);
-
- if (filtering) {
- scaleBlitBilinear((byte *)target->getPixels(), (const byte *)getPixels(), target->pitch, pitch, target->w, target->h, w, h, format);
- } else {
- scaleBlit((byte *)target->getPixels(), (const byte *)getPixels(), target->pitch, pitch, target->w, target->h, w, h, format);
- }
-
- return target;
-}
-
-TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transform, bool filtering) const {
-
- Common::Point newHotspot;
- Common::Rect rect = TransformTools::newRect(Common::Rect((int16)w, (int16)h), transform, &newHotspot);
-
- TransparentSurface *target = new TransparentSurface();
-
- target->create((uint16)rect.right - rect.left, (uint16)rect.bottom - rect.top, this->format);
-
- if (filtering) {
- rotoscaleBlitBilinear((byte *)target->getPixels(), (const byte *)getPixels(), target->pitch, pitch, target->w, target->h, w, h, format, transform, newHotspot);
- } else {
- rotoscaleBlit((byte *)target->getPixels(), (const byte *)getPixels(), target->pitch, pitch, target->w, target->h, w, h, format, transform, newHotspot);
- }
-
- return target;
-}
-
-TransparentSurface *TransparentSurface::convertTo(const PixelFormat &dstFormat, const byte *srcPalette, int srcPaletteCount, const byte *dstPalette, int dstPaletteCount, DitherMethod method) const {
- assert(pixels);
-
- TransparentSurface *surface = new TransparentSurface();
-
- // If the target format is the same, just copy
- if (format == dstFormat) {
- if (dstFormat.bytesPerPixel == 1) { // Checking if dithering could be skipped
- if (!srcPalette // No palette is specified
- || !dstPalette // No dst palette
- || (srcPaletteCount == dstPaletteCount // palettes are the same
- && !memcmp(srcPalette, dstPalette, srcPaletteCount * 3))) {
- surface->copyFrom(*this);
- return surface;
- }
- }
- }
-
- if (format.bytesPerPixel == 0 || format.bytesPerPixel > 4)
- error("Surface::convertTo(): Can only convert from 1Bpp, 2Bpp, 3Bpp, and 4Bpp but have %dbpp", format.bytesPerPixel);
-
- if (dstFormat.bytesPerPixel == 0 || dstFormat.bytesPerPixel > 4)
- error("Surface::convertTo(): Can only convert to 1Bpp, 2Bpp, 3Bpp and 4Bpp but requested %dbpp", dstFormat.bytesPerPixel);
-
- surface->create(w, h, dstFormat);
-
- // We are here when we are converting from a higher bpp or palettes are different
- if (dstFormat.bytesPerPixel == 1) {
- ditherFloyd(srcPalette, srcPaletteCount, surface, dstPalette, dstPaletteCount, method,
- dstFormat);
- return surface;
- }
-
- const byte *src = (const byte *)getPixels();
- byte *dst = (byte *)surface->getPixels();
-
- if (format.bytesPerPixel == 1) {
- // Converting from paletted to high color
- assert(srcPalette);
- uint32 map[256];
-
- convertPaletteToMap(map, srcPalette, 256, dstFormat);
- crossBlitMap(dst, src, surface->pitch, pitch, w, h, dstFormat.bytesPerPixel, map);
- } else {
- // Converting from high color to high color
- crossBlit(dst, src, surface->pitch, pitch, w, h, dstFormat, format);
- }
-
- return surface;
-}
-
-} // End of namespace Graphics
diff --git a/graphics/transparent_surface.h b/graphics/transparent_surface.h
deleted file mode 100644
index cd0d602410a..00000000000
--- a/graphics/transparent_surface.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef GRAPHICS_TRANSPARENTSURFACE_H
-#define GRAPHICS_TRANSPARENTSURFACE_H
-
-#include "graphics/surface.h"
-#include "graphics/managed_surface.h"
-#include "graphics/transform_struct.h"
-#include "graphics/blit.h"
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-namespace Graphics {
-
-/**
- * @defgroup graphics_transparent_surface Transparent surface
- * @ingroup graphics
- *
- * @brief TransparentSurface class.
- *
- * @{
- */
-
-/**
- * A transparent graphics surface, which implements alpha blitting.
- */
-struct TransparentSurface : public Graphics::Surface {
- TransparentSurface();
- TransparentSurface(const Graphics::Surface &surf, bool copyData = false);
-
- /**
- * Returns the pixel format all operations of TransparentSurface support.
- *
- * Unlike Surface TransparentSurface only works with a fixed pixel format.
- * This format can be queried using this static function.
- *
- * @return Supported pixel format.
- */
- static PixelFormat getSupportedPixelFormat() {
- return BlendBlit::getSupportedPixelFormat();
- }
-
- /**
- @brief renders the surface to another surface
- @param target a pointer to the target surface. In most cases this is the framebuffer.
- @param posX the position on the X-axis in the target image in pixels where the image is supposed to be rendered.<br>
- The default value is 0.
- @param posY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.<br>
- The default value is 0.
- @param flipping how the image should be flipped.<br>
- The default value is Graphics::FLIP_NONE (no flipping)
- @param pPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.<br>
- This referes to the unflipped and unscaled image.<br>
- The default value is NULL.
- @param color an ARGB color value, which determines the parameters for the color modulation und alpha blending.<br>
- The alpha component of the color determines the alpha blending parameter (0 = no covering, 255 = full covering).<br>
- The color components determines the color for color modulation.<br>
- The default value is MS_ARGB(255, 255, 255, 255) (full covering, no color modulation).
- The macros MS_RGB and MS_ARGB can be used for the creation of the color value.
- @param width the output width of the screen section.
- The images will be scaled if the output width of the screen section differs from the image section.<br>
- The value -1 determines that the image should not be scaled.<br>
- The default value is -1.
- @param height the output height of the screen section.
- The images will be scaled if the output width of the screen section differs from the image section.<br>
- The value -1 determines that the image should not be scaled.<br>
- The default value is -1.
- @return returns false if the rendering failed.
- */
- Common::Rect blit(Graphics::Surface &target, int posX = 0, int posY = 0,
- int flipping = FLIP_NONE,
- Common::Rect *pPartRect = nullptr,
- uint color = MS_ARGB(255, 255, 255, 255),
- int width = -1, int height = -1,
- TSpriteBlendMode blend = BLEND_NORMAL);
- Common::Rect blitClip(Graphics::Surface &target, Common::Rect clippingArea,
- int posX = 0, int posY = 0,
- int flipping = FLIP_NONE,
- Common::Rect *pPartRect = nullptr,
- uint color = MS_ARGB(255, 255, 255, 255),
- int width = -1, int height = -1,
- TSpriteBlendMode blend = BLEND_NORMAL);
-
- /**
- * @brief Scale function; this returns a transformed version of this surface after rotation and
- * scaling. Please do not use this if angle != 0, use rotoscale.
- *
- * @param newWidth the resulting width.
- * @param newHeight the resulting height.
- * @param filtering Whether or not to use bilinear filtering.
- * @see TransformStruct
- */
- TransparentSurface *scale(int16 newWidth, int16 newHeight, bool filtering = false) const;
-
- /**
- * @brief Rotoscale function; this returns a transformed version of this surface after rotation and
- * scaling. Please do not use this if angle == 0, use plain old scaling function.
- *
- * @param transform a TransformStruct wrapping the required info. @see TransformStruct
- * @param filtering Whether or not to use bilinear filtering.
- *
- */
- TransparentSurface *rotoscale(const TransformStruct &transform, bool filtering = false) const;
-
- TransparentSurface *convertTo(const PixelFormat &dstFormat, const byte *srcPalette = 0, int srcPaletteCount = 0, const byte *dstPalette = 0, int dstPaletteCount = 0, DitherMethod method = kDitherFloyd) const;
-
- float getRatio() {
- if (!w)
- return 0;
-
- return h / (float)w;
- }
-
- AlphaType getAlphaMode() const;
- void setAlphaMode(AlphaType);
-private:
- AlphaType _alphaMode;
-};
-
-/**
- * A deleter for Surface objects which can be used with SharedPtr.
- *
- * This deleter assures Surface::free is called on deletion.
- */
-/*struct SharedPtrTransparentSurfaceDeleter {
- void operator()(TransparentSurface *ptr) {
- ptr->free();
- delete ptr;
- }
-};*/
-/** @} */
-} // End of namespace Graphics
-
-
-#endif
More information about the Scummvm-git-logs
mailing list