OPENGL: Move color key handling for CLUT8 to TextureCLUT8.
This commit is contained in:
parent
db2917dde5
commit
618adec7b0
3 changed files with 30 additions and 20 deletions
|
@ -1208,20 +1208,7 @@ void OpenGLGraphicsManager::updateCursorPalette() {
|
|||
_cursor->setPalette(0, 256, _gamePalette);
|
||||
}
|
||||
|
||||
// We remove all alpha bits from the palette entry of the color key.
|
||||
// This makes sure its properly handled as color key.
|
||||
const Graphics::PixelFormat &hardwareFormat = _cursor->getHardwareFormat();
|
||||
const uint32 aMask = (0xFF >> hardwareFormat.aLoss) << hardwareFormat.aShift;
|
||||
|
||||
if (hardwareFormat.bytesPerPixel == 2) {
|
||||
uint16 *palette = (uint16 *)_cursor->getPalette() + _cursorKeyColor;
|
||||
*palette &= ~aMask;
|
||||
} else if (hardwareFormat.bytesPerPixel == 4) {
|
||||
uint32 *palette = (uint32 *)_cursor->getPalette() + _cursorKeyColor;
|
||||
*palette &= ~aMask;
|
||||
} else {
|
||||
warning("OpenGLGraphicsManager::updateCursorPalette: Unsupported pixel depth %d", hardwareFormat.bytesPerPixel);
|
||||
}
|
||||
_cursor->setColorKey(_cursorKeyColor);
|
||||
}
|
||||
|
||||
void OpenGLGraphicsManager::recalculateCursorScaling() {
|
||||
|
|
|
@ -346,6 +346,26 @@ Graphics::PixelFormat TextureCLUT8::getFormat() const {
|
|||
return Graphics::PixelFormat::createFormatCLUT8();
|
||||
}
|
||||
|
||||
void TextureCLUT8::setColorKey(uint colorKey) {
|
||||
// We remove all alpha bits from the palette entry of the color key.
|
||||
// This makes sure its properly handled as color key.
|
||||
const Graphics::PixelFormat &hardwareFormat = getHardwareFormat();
|
||||
const uint32 aMask = (0xFF >> hardwareFormat.aLoss) << hardwareFormat.aShift;
|
||||
|
||||
if (hardwareFormat.bytesPerPixel == 2) {
|
||||
uint16 *palette = (uint16 *)_palette + colorKey;
|
||||
*palette &= ~aMask;
|
||||
} else if (hardwareFormat.bytesPerPixel == 4) {
|
||||
uint32 *palette = (uint32 *)_palette + colorKey;
|
||||
*palette &= ~aMask;
|
||||
} else {
|
||||
warning("TextureCLUT8::setColorKey: Unsupported pixel depth %d", hardwareFormat.bytesPerPixel);
|
||||
}
|
||||
|
||||
// A palette changes means we need to refresh the whole surface.
|
||||
flagDirty();
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename ColorType>
|
||||
inline void convertPalette(ColorType *dst, const byte *src, uint colors, const Graphics::PixelFormat &format) {
|
||||
|
|
|
@ -190,10 +190,15 @@ public:
|
|||
*/
|
||||
virtual bool hasPalette() const { return false; }
|
||||
|
||||
/**
|
||||
* Set color key for paletted textures.
|
||||
*
|
||||
* This needs to be called after any palette update affecting the color
|
||||
* key. Calling this multiple times will result in multiple color indices
|
||||
* to be treated as color keys.
|
||||
*/
|
||||
virtual void setColorKey(uint colorKey) {}
|
||||
virtual void setPalette(uint start, uint colors, const byte *palData) {}
|
||||
|
||||
virtual void *getPalette() { return 0; }
|
||||
virtual const void *getPalette() const { return 0; }
|
||||
protected:
|
||||
virtual void updateTexture();
|
||||
|
||||
|
@ -222,11 +227,9 @@ public:
|
|||
|
||||
virtual bool hasPalette() const { return true; }
|
||||
|
||||
virtual void setColorKey(uint colorKey);
|
||||
virtual void setPalette(uint start, uint colors, const byte *palData);
|
||||
|
||||
virtual void *getPalette() { return _palette; }
|
||||
virtual const void *getPalette() const { return _palette; }
|
||||
|
||||
virtual Graphics::Surface *getSurface() { return &_clut8Data; }
|
||||
virtual const Graphics::Surface *getSurface() const { return &_clut8Data; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue