2012-06-13 15:02:44 -04:00
|
|
|
/* 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";
|
|
|
|
}
|
|
|
|
|
2012-06-14 11:41:52 -04:00
|
|
|
template<typename ColorMask>
|
2012-06-13 15:02:44 -04:00
|
|
|
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);
|