GRAPHICS: add static methods for 1x and 1.5x scale

This commit is contained in:
Eric Culp 2012-05-30 13:48:34 -04:00 committed by Filippos Karapetis
parent d350e2c7a8
commit d56a7d610c
5 changed files with 34 additions and 7 deletions

View file

@ -31,18 +31,18 @@ void DotMatrixPlugin::initialize(Graphics::PixelFormat format) {
lookup[5] = lookup[7] = lookup[5] = lookup[7] =
lookup[9] = lookup[13] = lookup[9] = lookup[13] =
lookup[15] = lookup[16] = format.RGBToColor(0, 0, 0); lookup[15] = lookup[16] = format.RGBToColor(0, 0, 0);
_format = format;
} }
void DotMatrixPlugin::scale(const uint8 *srcPtr, uint32 srcPitch, void DotMatrixPlugin::scale(const uint8 *srcPtr, uint32 srcPitch,
uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) { uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) {
if (!_doScale) { if (!_doScale) {
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
return; return;
} }
switch (_factor) { switch (_factor) {
case 1: case 1:
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
break; break;
case 2: case 2:
scaleIntern(srcPtr, srcPitch, dstPtr, dstPitch, width, height, x, y); scaleIntern(srcPtr, srcPitch, dstPtr, dstPitch, width, height, x, y);

View file

@ -26,6 +26,7 @@ void InitLUT(Graphics::PixelFormat format);
void HQPlugin::initialize(Graphics::PixelFormat format) { void HQPlugin::initialize(Graphics::PixelFormat format) {
//InitLUT(format); //InitLUT(format);
_format = format;
} }
void HQPlugin::deinitialize() { void HQPlugin::deinitialize() {
@ -35,12 +36,12 @@ void HQPlugin::deinitialize() {
void HQPlugin::scale(const uint8 *srcPtr, uint32 srcPitch, void HQPlugin::scale(const uint8 *srcPtr, uint32 srcPitch,
uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) { uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) {
if (!_doScale) { if (!_doScale) {
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
return; return;
} }
switch (_factor) { switch (_factor) {
case 1: case 1:
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
break; break;
case 2: case 2:
HQ2x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); HQ2x(srcPtr, srcPitch, dstPtr, dstPitch, width, height);

View file

@ -33,12 +33,12 @@ void SAIPlugin::deinitialize() {
void SAIPlugin::scale(const uint8 *srcPtr, uint32 srcPitch, void SAIPlugin::scale(const uint8 *srcPtr, uint32 srcPitch,
uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) { uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) {
if (!_doScale) { if (!_doScale) {
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
return; return;
} }
switch (_factor) { switch (_factor) {
case 1: case 1:
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height); scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
break; break;
case 2: case 2:
_2xSaI(srcPtr, srcPitch, dstPtr, dstPitch, width, height); _2xSaI(srcPtr, srcPitch, dstPtr, dstPitch, width, height);

View file

@ -20,6 +20,7 @@
*/ */
#include "graphics/scalerplugin.h" #include "graphics/scalerplugin.h"
#include "graphics/scaler.h"
ScalerPluginObject::ScalerPluginObject() { ScalerPluginObject::ScalerPluginObject() {
_doScale = true; _doScale = true;
@ -32,3 +33,15 @@ void ScalerPluginObject::disableScaling() {
void ScalerPluginObject::enableScaling() { void ScalerPluginObject::enableScaling() {
_doScale = true; _doScale = true;
} }
void ScalerPluginObject::scale1x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
uint32 dstPitch, int width, int height, int bytesPerPixel) {
assert(bytesPerPixel == 2); // TODO add support for 4 bytes
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
}
void ScalerPluginObject::scale1o5x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
uint32 dstPitch, int width, int height, int bytesPerPixel) {
assert(bytesPerPixel == 2); // TODO add support for 4 bytes
Normal1o5x(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
}

View file

@ -75,6 +75,18 @@ public:
*/ */
virtual bool canDrawCursor() const = 0; virtual bool canDrawCursor() const = 0;
/**
* Usable for any scaler when 1x scaling is desired
*/
static void scale1x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
uint32 dstPitch, int width, int height, int bytesPerPixel);
/**
* Useful for scaling the mouse
*/
static void scale1o5x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
uint32 dstPitch, int width, int height, int bytesPerPixel);
// temporary HACK // temporary HACK
virtual void disableScaling(); virtual void disableScaling();
@ -82,6 +94,7 @@ public:
protected: protected:
uint _factor; uint _factor;
Graphics::PixelFormat _format;
bool _doScale; // < temporary bool _doScale; // < temporary
}; };