aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/managed_surface.cpp18
-rw-r--r--graphics/managed_surface.h12
2 files changed, 19 insertions, 11 deletions
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 6e7275cac6..583859ae04 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -236,25 +236,25 @@ void ManagedSurface::blitFrom(const Surface &src, const Common::Rect &srcRect,
addDirtyRect(Common::Rect(0, 0, this->w, this->h));
}
-void ManagedSurface::transBlitFrom(const Surface &src, uint transColor, bool flipped, uint overrideColor) {
+void ManagedSurface::transBlitFrom(const Surface &src, uint transColor, bool flipped, uint overrideColor, uint srcAlpha) {
transBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(0, 0, this->w, this->h),
transColor, flipped, overrideColor);
}
void ManagedSurface::transBlitFrom(const Surface &src, const Common::Point &destPos,
- uint transColor, bool flipped, uint overrideColor) {
+ uint transColor, bool flipped, uint overrideColor, uint srcAlpha) {
transBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(destPos.x, destPos.y,
destPos.x + src.w, destPos.y + src.h), transColor, flipped, overrideColor);
}
void ManagedSurface::transBlitFrom(const Surface &src, const Common::Rect &srcRect,
- const Common::Point &destPos, uint transColor, bool flipped, uint overrideColor) {
+ const Common::Point &destPos, uint transColor, bool flipped, uint overrideColor, uint srcAlpha) {
transBlitFrom(src, srcRect, Common::Rect(destPos.x, destPos.y,
destPos.x + srcRect.width(), destPos.y + srcRect.height()), transColor, flipped, overrideColor);
}
template<typename TSRC, typename TDEST>
-void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, const Common::Rect &destRect, TSRC transColor, bool flipped, uint overrideColor) {
+void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, const Common::Rect &destRect, TSRC transColor, bool flipped, uint overrideColor, uint srcAlpha) {
int scaleX = SCALE_THRESHOLD * srcRect.width() / destRect.width();
int scaleY = SCALE_THRESHOLD * srcRect.height() / destRect.height();
const Graphics::PixelFormat &srcFormat = src.format;
@@ -279,7 +279,7 @@ void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, c
if (srcVal == transColor)
continue;
- if (srcFormat == destFormat) {
+ if (srcFormat == destFormat && srcAlpha == 0xff) {
// Matching formats, so we can do a straight copy
destLine[xCtr] = overrideColor ? overrideColor : srcVal;
} else {
@@ -287,6 +287,10 @@ void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, c
srcFormat.colorToARGB(srcVal, aSrc, rSrc, gSrc, bSrc);
destFormat.colorToRGB(destLine[xCtr], rDest, gDest, bDest);
+ if (srcAlpha != 0xff) {
+ aSrc = aSrc * srcAlpha / 255;
+ }
+
if (aSrc == 0) {
// Completely transparent, so skip
continue;
@@ -311,11 +315,11 @@ void transBlit(const Surface &src, const Common::Rect &srcRect, Surface &dest, c
#define HANDLE_BLIT(SRC_BYTES, DEST_BYTES, SRC_TYPE, DEST_TYPE) \
if (src.format.bytesPerPixel == SRC_BYTES && format.bytesPerPixel == DEST_BYTES) \
- transBlit<SRC_TYPE, DEST_TYPE>(src, srcRect, _innerSurface, destRect, transColor, flipped, overrideColor); \
+ transBlit<SRC_TYPE, DEST_TYPE>(src, srcRect, _innerSurface, destRect, transColor, flipped, overrideColor, srcAlpha); \
else
void ManagedSurface::transBlitFrom(const Surface &src, const Common::Rect &srcRect,
- const Common::Rect &destRect, uint transColor, bool flipped, uint overrideColor) {
+ const Common::Rect &destRect, uint transColor, bool flipped, uint overrideColor, uint srcAlpha) {
if (src.w == 0 || src.h == 0 || destRect.width() == 0 || destRect.height() == 0)
return;
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index c143222bbc..b643d1b8cf 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -235,8 +235,9 @@ public:
* @param flipped Specifies whether to horizontally flip the image
* @param overrideColor Optional color to use instead of non-transparent pixels from
* the source surface
+ * @param srcAlpha Optional additional transparency applied to src
*/
- void transBlitFrom(const Surface &src, uint transColor = 0, bool flipped = false, uint overrideColor = 0);
+ void transBlitFrom(const Surface &src, uint transColor = 0, bool flipped = false, uint overrideColor = 0, uint srcAlpha = 0xff);
/**
* Copies another surface into this one ignoring pixels of a designated transparent color
@@ -246,9 +247,10 @@ public:
* @param flipped Specifies whether to horizontally flip the image
* @param overrideColor Optional color to use instead of non-transparent pixels from
* the source surface
+ * @param srcAlpha Optional additional transparency applied to src
*/
void transBlitFrom(const Surface &src, const Common::Point &destPos,
- uint transColor = 0, bool flipped = false, uint overrideColor = 0);
+ uint transColor = 0, bool flipped = false, uint overrideColor = 0, uint srcAlpha = 0xff);
/**
* Copies another surface into this one ignoring pixels of a designated transparent color
@@ -259,9 +261,10 @@ public:
* @param flipped Specifies whether to horizontally flip the image
* @param overrideColor Optional color to use instead of non-transparent pixels from
* the source surface
+ * @param srcAlpha Optional additional transparency applied to src
*/
void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos,
- uint transColor = 0, bool flipped = false, uint overrideColor = 0);
+ uint transColor = 0, bool flipped = false, uint overrideColor = 0, uint srcAlpha = 0xff);
/**
* Copies another surface into this one ignoring pixels of a designated transparent color
@@ -273,9 +276,10 @@ public:
* @param flipped Specifies whether to horizontally flip the image
* @param overrideColor Optional color to use instead of non-transparent pixels from
* the source surface
+ * @param srcAlpha Optional additional transparency applied to src
*/
void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect,
- uint transColor = 0, bool flipped = false, uint overrideColor = 0);
+ uint transColor = 0, bool flipped = false, uint overrideColor = 0, uint srcAlpha = 0xff);
/**
* Clear the entire surface