[Scummvm-git-logs] scummvm master -> 68adead085f9f090b77b626df13c1a7f4cc35de3
dreammaster
dreammaster at scummvm.org
Mon Feb 15 02:08:42 UTC 2021
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:
68adead085 AGS: Implement fade in/out alpha blending
Commit: 68adead085f9f090b77b626df13c1a7f4cc35de3
https://github.com/scummvm/scummvm/commit/68adead085f9f090b77b626df13c1a7f4cc35de3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-02-14T18:08:23-08:00
Commit Message:
AGS: Implement fade in/out alpha blending
Changed paths:
engines/ags/lib/allegro/color.cpp
engines/ags/lib/allegro/color.h
engines/ags/lib/allegro/gfx.cpp
engines/ags/lib/allegro/gfx.h
diff --git a/engines/ags/lib/allegro/color.cpp b/engines/ags/lib/allegro/color.cpp
index 3c8e7af253..8da34cb41c 100644
--- a/engines/ags/lib/allegro/color.cpp
+++ b/engines/ags/lib/allegro/color.cpp
@@ -49,6 +49,7 @@ int _rgb_a_shift_32 = 0;
RGB_MAP *rgb_map;
COLOR_MAP *color_map;
+int trans_blend_alpha = -1;
void color::readFromFile(AGS::Shared::Stream *file) {
r = file->ReadByte();
@@ -273,7 +274,7 @@ void set_blender_mode_ex(BLENDER_FUNC b15, BLENDER_FUNC b16, BLENDER_FUNC b24, B
}
void set_alpha_blender(void) {
- // TODO: set_alpha_blender
+ trans_blend_alpha = -1;
}
void set_write_alpha_blender(void) {
@@ -281,7 +282,8 @@ void set_write_alpha_blender(void) {
}
void set_trans_blender(int r, int g, int b, int a) {
- // TODO: set_trans_blender
+ assert(r == 0 && g == 0 && b == 0);
+ trans_blend_alpha = a;
}
void set_add_blender(int r, int g, int b, int a) {
diff --git a/engines/ags/lib/allegro/color.h b/engines/ags/lib/allegro/color.h
index 8c9922502e..870d7d756c 100644
--- a/engines/ags/lib/allegro/color.h
+++ b/engines/ags/lib/allegro/color.h
@@ -77,6 +77,7 @@ AL_VAR(PALETTE, default_palette);
AL_VAR(RGB_MAP *, rgb_map);
AL_VAR(COLOR_MAP *, color_map);
+extern int trans_blend_alpha;
AL_VAR(PALETTE, _current_palette);
diff --git a/engines/ags/lib/allegro/gfx.cpp b/engines/ags/lib/allegro/gfx.cpp
index cc7faadab9..bc7d401417 100644
--- a/engines/ags/lib/allegro/gfx.cpp
+++ b/engines/ags/lib/allegro/gfx.cpp
@@ -21,6 +21,7 @@
*/
#include "ags/lib/allegro/gfx.h"
+#include "ags/lib/allegro/color.h"
#include "ags/lib/allegro/flood.h"
#include "ags/ags.h"
#include "common/textconsole.h"
@@ -35,10 +36,13 @@ int color_conversion;
#define TRANSPARENT_COLOR(BITMAP) ((BITMAP).format.bytesPerPixel == 1 ? 0 : \
(BITMAP).format.RGBToColor(255, 0, 255))
+// Arbitrary RGBA tuplet that should never be encountered
+#define NO_TRANSPARENT_COLOR 0x88888888
+
/*-------------------------------------------------------------------*/
BITMAP::BITMAP(Graphics::ManagedSurface *owner) : _owner(owner),
- w(owner->w), h(owner->h), format(owner->format),
+ w(owner->w), h(owner->h), pitch(owner->pitch), format(owner->format),
clip(false), ct(0), cl(0), cr(owner->w), cb(owner->h) {
line.resize(h);
for (uint y = 0; y < h; ++y)
@@ -303,7 +307,28 @@ void stretch_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y, int w, int
}
void draw_trans_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y) {
- bmp->getSurface().blitFrom(sprite->getSurface(), Common::Point(x, y));
+ assert(sprite->format.bytesPerPixel == 4);
+
+ if (trans_blend_alpha == -1) {
+ bmp->getSurface().blitFrom(sprite->getSurface(), Common::Point(x, y));
+
+ } else {
+ // Create a temporary ManagedSurface with a pointer to the sprite's pixels,
+ // and a pixel format that matches the sprite, but has no alpha.
+ // This will prevent it being applied from the sprite in transBlitFrom
+ Graphics::ManagedSurface spr;
+ spr.format = sprite->format;
+ spr.format.aLoss = 8;
+ spr.format.aShift = 0;
+ spr.setPixels(sprite->getPixels());
+ spr.w = sprite->w;
+ spr.h = sprite->h;
+ spr.pitch = sprite->pitch;
+
+ bmp->getSurface().transBlitFrom(spr, Common::Rect(0, 0, spr.w, spr.h),
+ Common::Rect(x, y, x + spr.w, y + spr.h), NO_TRANSPARENT_COLOR,
+ false, 0, trans_blend_alpha);
+ }
}
void draw_lit_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y, int color) {
diff --git a/engines/ags/lib/allegro/gfx.h b/engines/ags/lib/allegro/gfx.h
index dfa900e46a..91c9f62ce1 100644
--- a/engines/ags/lib/allegro/gfx.h
+++ b/engines/ags/lib/allegro/gfx.h
@@ -177,7 +177,7 @@ class BITMAP {
private:
Graphics::ManagedSurface *_owner;
public:
- uint16 &w, &h;
+ uint16 &w, &h, &pitch;
Graphics::PixelFormat &format;
bool clip;
int ct, cb, cl, cr;
More information about the Scummvm-git-logs
mailing list