Cocoa Port:

- Fix bug where switching between CPU-based and GPU-based filters in the DeSmuME Preferences display preview would sometimes fail.
- Fix bug where the DeSmuME Preferences display preview would show incorrect colors when using a CPU-based filter on PowerPC Macs.

Video Filters:
- Fix bug where the Scanline filter would show incorrect colors on big-endian systems.
This commit is contained in:
rogerman 2015-02-15 02:14:29 +00:00
parent 5254d7143a
commit cfb408d63b
3 changed files with 63 additions and 30 deletions

View File

@ -5287,18 +5287,10 @@ void OGLImage::SetCPUPixelScalerOGL(const VideoFilterTypeID filterID)
void OGLImage::LoadFrameOGL(const uint32_t *frameData, GLsizei w, GLsizei h)
{
const bool isUsingCPUPixelScaler = this->_pixelScaler != VideoFilterTypeID_None && !this->_useShaderBasedPixelScaler;
if (!isUsingCPUPixelScaler || this->_useDeposterize)
{
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texVideoInputDataID);
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, frameData);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
}
else
{
memcpy(this->_vf->GetSrcBufferPtr(), frameData, w * h * sizeof(uint32_t));
}
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, this->_texVideoInputDataID);
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, frameData);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
memcpy(this->_vf->GetSrcBufferPtr(), frameData, w * h * sizeof(uint32_t));
}
void OGLImage::ProcessOGL()

View File

@ -166,11 +166,36 @@
{
NSArray *imageRepArray = [previewImage representations];
const NSBitmapImageRep *imageRep = [imageRepArray objectAtIndex:0];
const NSSize previewImageSize = [previewImage size];
const size_t previewWidth = (GLsizei)[previewImage size].width;
const size_t previewHeight = (GLsizei)[previewImage size].height;
// When an NSImage is loaded from file, it is loaded as ABGR (or RGBA for big-endian).
// However, the OpenGL blitter takes BGRA format. Therefore, we need to convert the
// pixel format before sending to OpenGL.
uint32_t *bitmapData = (uint32_t *)[imageRep bitmapData];
for (size_t i = 0; i < previewWidth * previewHeight; i++)
{
const uint32_t color = bitmapData[i];
#if defined(__i386__) || defined(__x86_64__)
bitmapData[i] = 0xFF000000 | // lA
((color & 0x00FF0000) >> 16) | // lB -> lR
(color & 0x0000FF00) | // lG
((color & 0x000000FF) << 16); // lR -> lB
#else
bitmapData[i] = 0xFF000000 | // lA
((color & 0xFF000000) >> 8) | // bR -> lR
(color & 0x00FF0000) >> 8 | // bG -> lG
((color & 0x0000FF00) >> 8); // bB -> lB
#endif
}
// Send the NSImage to OpenGL.
CGLContextObj prevContext = CGLGetCurrentContext();
CGLSetCurrentContext(cglDisplayContext);
oglImage->LoadFrameOGL((const uint32_t *)[imageRep bitmapData], previewImageSize.width, previewImageSize.height);
oglImage->LoadFrameOGL(bitmapData, previewWidth, previewHeight);
oglImage->ProcessOGL();
CGLSetCurrentContext(prevContext);
}

View File

@ -1,20 +1,18 @@
/* Copyright (C) 2009 DeSmuME team
/*
Copyright (C) 2009-2015 DeSmuME team
This file is part of DeSmuME
This file 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 2 of the License, or
(at your option) any later version.
DeSmuME 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 2 of the License, or
(at your option) any later version.
This file 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.
DeSmuME 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 DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include "filter.h"
@ -31,19 +29,37 @@ FORCEINLINE void ScanLine32( uint32 *lpDst, uint32 *lpSrc, unsigned int Width, i
{
while(Width--)
{
#ifdef LOCAL_LE
u8* u8dst = (u8*)lpDst;
u8* u8src = (u8*)lpSrc;
*u8dst++ = *u8src++ * fac_left / 16;
*u8dst++ = *u8src++ * fac_left / 16;
*u8dst++ = *u8src++ * fac_left / 16;
u8dst++;
u8dst++;
u8src = (u8*)lpSrc;
*u8dst++ = *u8src++ * fac_right / 16;
*u8dst++ = *u8src++ * fac_right / 16;
*u8dst++ = *u8src++ * fac_right / 16;
u8dst++; u8src++;
u8dst++; u8src++;
lpDst+=2;
lpSrc++;
#else
u8* u8dst = (u8*)lpDst;
u8* u8src = (u8*)lpSrc;
u8dst++; u8src++;
*u8dst++ = *u8src++ * fac_left / 16;
*u8dst++ = *u8src++ * fac_left / 16;
*u8dst++ = *u8src * fac_left / 16;
u8src = (u8*)lpSrc;
u8dst++; u8src++;
*u8dst++ = *u8src++ * fac_right / 16;
*u8dst++ = *u8src++ * fac_right / 16;
*u8dst++ = *u8src++ * fac_right / 16;
lpDst+=2;
lpSrc++;
#endif
}
}