mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-07 03:18:17 +00:00
GRAPHICS: Add TV scaler plugin
This commit is contained in:
parent
7fd8107c76
commit
a3a9736754
@ -172,6 +172,7 @@ public:
|
||||
LINK_PLUGIN(SUPERSAI)
|
||||
LINK_PLUGIN(SUPEREAGLE)
|
||||
LINK_PLUGIN(DOTMATRIX)
|
||||
LINK_PLUGIN(TV)
|
||||
#endif
|
||||
|
||||
return pl;
|
||||
|
@ -91,7 +91,8 @@ MODULE_OBJS += \
|
||||
scaler/downscaler.o \
|
||||
scaler/scale2x.o \
|
||||
scaler/scale3x.o \
|
||||
scaler/scalebit.o
|
||||
scaler/scalebit.o \
|
||||
scaler/tv.o
|
||||
|
||||
ifdef USE_ARM_SCALER_ASM
|
||||
MODULE_OBJS += \
|
||||
|
@ -79,39 +79,6 @@ void AdvMame3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPi
|
||||
scale(3, dstPtr, dstPitch, srcPtr - srcPitch, srcPitch, 2, width, height);
|
||||
}
|
||||
|
||||
template<typename ColorMask>
|
||||
void TV2xTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
|
||||
int width, int height) {
|
||||
const uint32 nextlineSrc = srcPitch / sizeof(uint16);
|
||||
const uint16 *p = (const uint16 *)srcPtr;
|
||||
|
||||
const uint32 nextlineDst = dstPitch / sizeof(uint16);
|
||||
uint16 *q = (uint16 *)dstPtr;
|
||||
|
||||
while (height--) {
|
||||
for (int i = 0, j = 0; i < width; ++i, j += 2) {
|
||||
uint16 p1 = *(p + i);
|
||||
uint32 pi;
|
||||
|
||||
pi = (((p1 & ColorMask::kRedBlueMask) * 7) >> 3) & ColorMask::kRedBlueMask;
|
||||
pi |= (((p1 & ColorMask::kGreenMask) * 7) >> 3) & ColorMask::kGreenMask;
|
||||
|
||||
*(q + j) = p1;
|
||||
*(q + j + 1) = p1;
|
||||
*(q + j + nextlineDst) = (uint16)pi;
|
||||
*(q + j + nextlineDst + 1) = (uint16)pi;
|
||||
}
|
||||
p += nextlineSrc;
|
||||
q += nextlineDst << 1;
|
||||
}
|
||||
}
|
||||
|
||||
void TV2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
|
||||
if (gBitFormat == 565)
|
||||
TV2xTemplate<Graphics::ColorMasks<565> >(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
|
||||
else
|
||||
TV2xTemplate<Graphics::ColorMasks<555> >(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
|
||||
}
|
||||
|
||||
static inline uint16 DOT_16(const uint16 *dotmatrix, uint16 c, int j, int i) {
|
||||
return c - ((c >> 2) & dotmatrix[((j & 3) << 2) + (i & 3)]);
|
||||
|
87
graphics/scaler/tv.cpp
Normal file
87
graphics/scaler/tv.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "graphics/scaler/tv.h"
|
||||
#include "graphics/scaler.h"
|
||||
#include "graphics/colormasks.h"
|
||||
|
||||
TVPlugin::TVPlugin() {
|
||||
_factor = 2;
|
||||
_factors.push_back(2);
|
||||
}
|
||||
|
||||
void TVPlugin::initialize(Graphics::PixelFormat format) {
|
||||
_format = format;
|
||||
}
|
||||
|
||||
void TVPlugin::scale(const uint8 *srcPtr, uint32 srcPitch,
|
||||
uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) {
|
||||
if (_format.gLoss == 2)
|
||||
scaleIntern<Graphics::ColorMasks<565> >(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
|
||||
else
|
||||
scaleIntern<Graphics::ColorMasks<555> >(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
|
||||
|
||||
}
|
||||
|
||||
uint TVPlugin::increaseFactor() {
|
||||
return _factor;
|
||||
}
|
||||
|
||||
uint TVPlugin::decreaseFactor() {
|
||||
return _factor;
|
||||
}
|
||||
|
||||
const char *TVPlugin::getName() const {
|
||||
return "tv";
|
||||
}
|
||||
|
||||
const char *TVPlugin::getPrettyName() const {
|
||||
return "TV";
|
||||
}
|
||||
|
||||
template <typename ColorMask>
|
||||
void TVPlugin::scaleIntern(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
|
||||
int width, int height) {
|
||||
const uint32 nextlineSrc = srcPitch / sizeof(uint16);
|
||||
const uint16 *p = (const uint16 *)srcPtr;
|
||||
|
||||
const uint32 nextlineDst = dstPitch / sizeof(uint16);
|
||||
uint16 *q = (uint16 *)dstPtr;
|
||||
|
||||
while (height--) {
|
||||
for (int i = 0, j = 0; i < width; ++i, j += 2) {
|
||||
uint16 p1 = *(p + i);
|
||||
uint32 pi;
|
||||
|
||||
pi = (((p1 & ColorMask::kRedBlueMask) * 7) >> 3) & ColorMask::kRedBlueMask;
|
||||
pi |= (((p1 & ColorMask::kGreenMask) * 7) >> 3) & ColorMask::kGreenMask;
|
||||
|
||||
*(q + j) = p1;
|
||||
*(q + j + 1) = p1;
|
||||
*(q + j + nextlineDst) = (uint16)pi;
|
||||
*(q + j + nextlineDst + 1) = (uint16)pi;
|
||||
}
|
||||
p += nextlineSrc;
|
||||
q += nextlineDst << 1;
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_PLUGIN_STATIC(TV, PLUGIN_TYPE_SCALER, TVPlugin);
|
47
graphics/scaler/tv.h
Normal file
47
graphics/scaler/tv.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program 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 program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef GRAPHICS_SCALER_TV_H
|
||||
#define GRAPHICS_SCALER_TV_H
|
||||
|
||||
#include "graphics/scalerplugin.h"
|
||||
|
||||
class TVPlugin : public ScalerPluginObject {
|
||||
public:
|
||||
TVPlugin();
|
||||
virtual void initialize(Graphics::PixelFormat format);
|
||||
virtual void scale(const uint8 *srcPtr, uint32 srcPitch,
|
||||
uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y);
|
||||
virtual uint increaseFactor();
|
||||
virtual uint decreaseFactor();
|
||||
virtual uint getFactor() const { return _factor; }
|
||||
virtual bool canDrawCursor() const { return false; }
|
||||
virtual uint extraPixels() const { return 0; }
|
||||
virtual const char *getName() const;
|
||||
virtual const char *getPrettyName() const;
|
||||
private:
|
||||
template <typename ColorMask>
|
||||
void scaleIntern(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
|
||||
uint32 dstPitch, int width, int height);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user