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[9] = lookup[13] =
lookup[15] = lookup[16] = format.RGBToColor(0, 0, 0);
_format = format;
}
void DotMatrixPlugin::scale(const uint8 *srcPtr, uint32 srcPitch,
uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) {
if (!_doScale) {
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
return;
}
switch (_factor) {
case 1:
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
break;
case 2:
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) {
//InitLUT(format);
_format = format;
}
void HQPlugin::deinitialize() {
@ -35,12 +36,12 @@ void HQPlugin::deinitialize() {
void HQPlugin::scale(const uint8 *srcPtr, uint32 srcPitch,
uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) {
if (!_doScale) {
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
return;
}
switch (_factor) {
case 1:
Normal1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
scale1x(srcPtr, srcPitch, dstPtr, dstPitch, width, height, _format.bytesPerPixel);
break;
case 2:
HQ2x(srcPtr, srcPitch, dstPtr, dstPitch, width, height);

View file

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

View file

@ -20,6 +20,7 @@
*/
#include "graphics/scalerplugin.h"
#include "graphics/scaler.h"
ScalerPluginObject::ScalerPluginObject() {
_doScale = true;
@ -32,3 +33,15 @@ void ScalerPluginObject::disableScaling() {
void ScalerPluginObject::enableScaling() {
_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;
/**
* 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
virtual void disableScaling();
@ -82,6 +94,7 @@ public:
protected:
uint _factor;
Graphics::PixelFormat _format;
bool _doScale; // < temporary
};