From ea19c4162d24d6bf32246671aa5fab285ca7ad39 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 20 Aug 2013 18:00:17 +0200 Subject: WINTERMUTE: Add binary alpha-blitting. For now, no RLE, or anything, but the infrastructure for it is put in place here. --- .../base/gfx/osystem/base_surface_osystem.cpp | 18 +++++++++--------- .../wintermute/base/gfx/osystem/base_surface_osystem.h | 4 +++- engines/wintermute/base/gfx/osystem/render_ticket.cpp | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'engines/wintermute/base/gfx') diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index aed0129b3a..6506abd29c 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -48,7 +48,7 @@ namespace Wintermute { BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { _surface = new Graphics::Surface(); _alphaMask = nullptr; - _alphaType = ALPHA_FULL; + _alphaType = TransparentSurface::ALPHA_FULL; _lockPixels = nullptr; _lockPitch = 0; _loaded = false; @@ -71,10 +71,10 @@ BaseSurfaceOSystem::~BaseSurfaceOSystem() { renderer->invalidateTicketsFromSurface(this); } -AlphaType hasTransparencyType(const Graphics::Surface *surf) { +TransparentSurface::AlphaType hasTransparencyType(const Graphics::Surface *surf) { if (surf->format.bytesPerPixel != 4) { warning("hasTransparencyType:: non 32 bpp surface passed as argument"); - return ALPHA_OPAQUE; + return TransparentSurface::ALPHA_OPAQUE; } uint8 r, g, b, a; bool seenAlpha = false; @@ -96,11 +96,11 @@ AlphaType hasTransparencyType(const Graphics::Surface *surf) { } } if (seenFullAlpha) { - return ALPHA_FULL; + return TransparentSurface::ALPHA_FULL; } else if (seenAlpha) { - return ALPHA_BINARY; + return TransparentSurface::ALPHA_BINARY; } else { - return ALPHA_OPAQUE; + return TransparentSurface::ALPHA_OPAQUE; } } @@ -438,7 +438,7 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, // But no checking is in place for that yet. // Optimize by not doing alpha-blits if we lack alpha - if (_alphaType == ALPHA_OPAQUE && !transform._alphaDisable) { + if (_alphaType == TransparentSurface::ALPHA_OPAQUE && !transform._alphaDisable) { transform._alphaDisable = true; } @@ -457,9 +457,9 @@ bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAl _surface->free(); _surface->copyFrom(surface); if (hasAlpha) { - _alphaType = ALPHA_FULL; + _alphaType = TransparentSurface::ALPHA_FULL; } else { - _alphaType = ALPHA_OPAQUE; + _alphaType = TransparentSurface::ALPHA_OPAQUE; } BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index ad1e9cf737..6cf19d00fb 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BASE_SURFACESDL_H #include "graphics/surface.h" +#include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/base/gfx/base_surface.h" #include "common/list.h" @@ -81,6 +82,7 @@ public: return _height; } + TransparentSurface::AlphaType getAlphaType() const { return _alphaType; } private: Graphics::Surface *_surface; bool _loaded; @@ -90,7 +92,7 @@ private: uint32 getPixelAt(Graphics::Surface *surface, int x, int y); uint32 _rotation; - AlphaType _alphaType; + TransparentSurface::AlphaType _alphaType; void *_lockPixels; int _lockPitch; byte *_alphaMask; diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp index 98739e0778..b1720c1b0b 100644 --- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp +++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/gfx/osystem/render_ticket.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/graphics/transform_tools.h" #include "common/textconsole.h" @@ -104,7 +105,13 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const { clipRect.setWidth(getSurface()->w); clipRect.setHeight(getSurface()->h); - src._enableAlphaBlit = !_transform._alphaDisable; + if (_owner) { + if (_transform._alphaDisable) { + src._alphaMode = TransparentSurface::ALPHA_OPAQUE; + } else { + src._alphaMode = _owner->getAlphaType(); + } + } src.blit(*_targetSurface, _dstRect.left, _dstRect.top, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height()); } @@ -118,7 +125,13 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect clipRect->setHeight(getSurface()->h); } - src._enableAlphaBlit = !_transform._alphaDisable; + if (_owner) { + if (_transform._alphaDisable) { + src._alphaMode = TransparentSurface::ALPHA_OPAQUE; + } else { + src._alphaMode = _owner->getAlphaType(); + } + } src.blit(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(), clipRect->height()); if (doDelete) { delete clipRect; -- cgit v1.2.3