Syntax clean up in qimagescale

Corrects a few white-spaces, return statements and else statements
to fit Qt coding style.

Comment updated to indicate how far the code is getting from its
original roots.

No semantic changes.

Change-Id: Ia2288c501788a291bfc4e8b70e8eb1efb7a90128
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Allan Sandfeld Jensen 2015-05-07 14:00:54 +02:00
parent e5d85ff44e
commit 71fe2df773

View File

@ -77,6 +77,8 @@ QT_BEGIN_NAMESPACE
* *
* Changes include formatting, namespaces and other C++'ings, removal of old * Changes include formatting, namespaces and other C++'ings, removal of old
* #ifdef'ed code, and removal of unneeded border calculation code. * #ifdef'ed code, and removal of unneeded border calculation code.
* Later the code has been refactored and an SSE4.1 optimizated path have been
* added instead of the removed MMX assembler.
* *
* Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code
* is by Willem Monsuwe <willem@stack.nl>. All other modifications are * is by Willem Monsuwe <willem@stack.nl>. All other modifications are
@ -100,13 +102,13 @@ using namespace QImageScale;
// //
const unsigned int** QImageScale::qimageCalcYPoints(const unsigned int *src, const unsigned int** QImageScale::qimageCalcYPoints(const unsigned int *src,
int sw, int sh, int dh) int sw, int sh, int dh)
{ {
const unsigned int **p; const unsigned int **p;
int j = 0, rv = 0; int j = 0, rv = 0;
qint64 val, inc; qint64 val, inc;
if(dh < 0){ if (dh < 0) {
dh = -dh; dh = -dh;
rv = 1; rv = 1;
} }
@ -134,7 +136,7 @@ int* QImageScale::qimageCalcXPoints(int sw, int dw)
int *p, j = 0, rv = 0; int *p, j = 0, rv = 0;
qint64 val, inc; qint64 val, inc;
if(dw < 0){ if (dw < 0) {
dw = -dw; dw = -dw;
rv = 1; rv = 1;
} }
@ -155,25 +157,23 @@ int* QImageScale::qimageCalcXPoints(int sw, int dw)
p[dw - i - 1] = tmp; p[dw - i - 1] = tmp;
} }
} }
return(p); return p;
} }
int* QImageScale::qimageCalcApoints(int s, int d, int up) int* QImageScale::qimageCalcApoints(int s, int d, int up)
{ {
int *p, j = 0, rv = 0; int *p, j = 0, rv = 0;
if(d < 0){ if (d < 0) {
rv = 1; rv = 1;
d = -d; d = -d;
} }
p = new int[d]; p = new int[d];
/* scaling up */ if (up) {
if(up){ /* scaling up */
qint64 val, inc; qint64 val = 0x8000 * s / d - 0x8000;
qint64 inc = (((qint64)s) << 16) / d;
val = 0x8000 * s / d - 0x8000;
inc = (((qint64)s) << 16) / d;
for (int i = 0; i < d; i++) { for (int i = 0; i < d; i++) {
int pos = val >> 16; int pos = val >> 16;
if (pos < 0) if (pos < 0)
@ -184,9 +184,8 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00); p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
val += inc; val += inc;
} }
} } else {
/* scaling down */ /* scaling down */
else {
qint64 val = 0; qint64 val = 0;
qint64 inc = (((qint64)s) << 16) / d; qint64 inc = (((qint64)s) << 16) / d;
int Cp = (((d << 14) + s - 1) / s); int Cp = (((d << 14) + s - 1) / s);
@ -197,7 +196,7 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
val += inc; val += inc;
} }
} }
if(rv){ if (rv) {
int tmp; int tmp;
for (int i = d / 2; --i >= 0; ) { for (int i = d / 2; --i >= 0; ) {
tmp = p[i]; tmp = p[i];
@ -210,7 +209,7 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi) QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi)
{ {
if(isi){ if (isi) {
delete[] isi->xpoints; delete[] isi->xpoints;
delete[] isi->ypoints; delete[] isi->ypoints;
delete[] isi->xapoints; delete[] isi->xapoints;
@ -231,28 +230,28 @@ QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img,
sch = dh * qlonglong(img.height()) / sh; sch = dh * qlonglong(img.height()) / sh;
isi = new QImageScaleInfo; isi = new QImageScaleInfo;
if(!isi) if (!isi)
return 0; return 0;
memset(isi, 0, sizeof(QImageScaleInfo)); memset(isi, 0, sizeof(QImageScaleInfo));
isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1); isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1);
isi->xpoints = qimageCalcXPoints(img.width(), scw); isi->xpoints = qimageCalcXPoints(img.width(), scw);
if(!isi->xpoints) if (!isi->xpoints)
return(qimageFreeScaleInfo(isi)); return qimageFreeScaleInfo(isi);
isi->ypoints = qimageCalcYPoints((const unsigned int *)img.scanLine(0), isi->ypoints = qimageCalcYPoints((const unsigned int *)img.scanLine(0),
img.bytesPerLine() / 4, img.height(), sch); img.bytesPerLine() / 4, img.height(), sch);
if (!isi->ypoints) if (!isi->ypoints)
return(qimageFreeScaleInfo(isi)); return qimageFreeScaleInfo(isi);
if(aa) { if (aa) {
isi->xapoints = qimageCalcApoints(img.width(), scw, isi->xup_yup & 1); isi->xapoints = qimageCalcApoints(img.width(), scw, isi->xup_yup & 1);
if(!isi->xapoints) if (!isi->xapoints)
return(qimageFreeScaleInfo(isi)); return qimageFreeScaleInfo(isi);
isi->yapoints = qimageCalcApoints(img.height(), sch, isi->xup_yup & 2); isi->yapoints = qimageCalcApoints(img.height(), sch, isi->xup_yup & 2);
if(!isi->yapoints) if (!isi->yapoints)
return(qimageFreeScaleInfo(isi)); return qimageFreeScaleInfo(isi);
} }
return(isi); return isi;
} }
@ -326,7 +325,7 @@ static void qt_qimageScaleAARGBA(QImageScaleInfo *isi, unsigned int *dest,
int dh, int dow, int sow) int dh, int dow, int sow)
{ {
/* scaling up both ways */ /* scaling up both ways */
if (isi->xup_yup == 3){ if (isi->xup_yup == 3) {
qt_qimageScaleAARGBA_up_xy(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow); qt_qimageScaleAARGBA_up_xy(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
} }
/* if we're scaling down vertically */ /* if we're scaling down vertically */