inline memory rotation functions and mark them static

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2020-07-23 15:09:19 +00:00
parent 1b2973cafc
commit 0bc6d12352
4 changed files with 71 additions and 121 deletions

View file

@ -780,7 +780,6 @@ set(GUI_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/painting/qdrawutil.cpp
${CMAKE_CURRENT_SOURCE_DIR}/painting/qgraphicssystem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/painting/qmatrix.cpp
${CMAKE_CURRENT_SOURCE_DIR}/painting/qmemrotate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/painting/qoutlinemapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/painting/qpaintdevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/painting/qpaintengine.cpp

View file

@ -4629,7 +4629,7 @@ int QImage::metric(PaintDeviceMetric metric) const
line for the destination data, \a p_inc is the offset that we advance for
every scanline and \a dHeight is the height of the destination image.
\a sprt is the pointer to the source data, \a sbpl specifies the bits per
\a sptr is the pointer to the source data, \a sbpl specifies the bits per
line of the source data, \a sWidth and \a sHeight are the width and height of
the source data.
*/

View file

@ -1,111 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016-2020 Ivailo Monev
**
** This file is part of the QtGui module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qmemrotate_p.h"
QT_BEGIN_NAMESPACE
template <class DST, class SRC>
static inline void qt_memrotate90_template(const SRC *src,
int srcWidth, int srcHeight, int srcStride,
DST *dest, int dstStride)
{
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
const char *s = reinterpret_cast<const char*>(src);
char *d = reinterpret_cast<char*>(dest);
for (int y = 0; y < srcHeight; ++y) {
for (int x = srcWidth - 1; x >= 0; --x) {
DST *destline = reinterpret_cast<DST*>(d + (srcWidth - x - 1) * dstStride);
destline[y] = src[x];
}
s += srcStride;
src = reinterpret_cast<const SRC*>(s);
}
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
for (int x = srcWidth - 1; x >= 0; --x) {
DST *d = dest + (srcWidth - x - 1) * dstStride;
for (int y = 0; y < srcHeight; ++y) {
*d++ = src[y * srcStride + x];
}
}
#endif
}
template <class DST, class SRC>
static inline void qt_memrotate270_template(const SRC *src,
int srcWidth, int srcHeight, int srcStride,
DST *dest, int dstStride)
{
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
const char *s = reinterpret_cast<const char*>(src);
char *d = reinterpret_cast<char*>(dest);
s += (srcHeight - 1) * srcStride;
for (int y = srcHeight - 1; y >= 0; --y) {
src = reinterpret_cast<const SRC*>(s);
for (int x = 0; x < srcWidth; ++x) {
DST *destline = reinterpret_cast<DST*>(d + x * dstStride);
destline[srcHeight - y - 1] = src[x];
}
s -= srcStride;
}
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
for (int x = 0; x < srcWidth; ++x) {
DST *d = dest + x * dstStride;
for (int y = srcHeight - 1; y >= 0; --y) {
*d++ = src[y * srcStride + x];
}
}
#endif
}
#define QT_IMPL_MEMROTATE(srctype, desttype) \
void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate90_template(src, w, h, sstride, dest, dstride); \
} \
void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate270_template(src, w, h, sstride, dest, dstride); \
}
QT_IMPL_MEMROTATE(quint8, quint8)
QT_IMPL_MEMROTATE(quint16, quint16)
QT_IMPL_MEMROTATE(quint24, quint24)
QT_IMPL_MEMROTATE(quint32, quint32)
#undef QT_IMPL_MEMROTATE
QT_END_NAMESPACE

View file

@ -56,16 +56,78 @@ QT_BEGIN_NAMESPACE
#define QT_ROTATION_ALGORITHM QT_ROTATION_CACHEDREAD
#endif
#define QT_DECL_MEMROTATE(srctype, desttype) \
void qt_memrotate90(const srctype*, int, int, int, desttype*, int); \
void qt_memrotate270(const srctype*, int, int, int, desttype*, int)
QT_DECL_MEMROTATE(quint8, quint8);
QT_DECL_MEMROTATE(quint16, quint16);
QT_DECL_MEMROTATE(quint24, quint24);
QT_DECL_MEMROTATE(quint32, quint32);
template <class DST, class SRC>
static inline void qt_memrotate90_template(const SRC *src,
int srcWidth, int srcHeight, int srcStride,
DST *dest, int dstStride)
{
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
const char *s = reinterpret_cast<const char*>(src);
char *d = reinterpret_cast<char*>(dest);
for (int y = 0; y < srcHeight; ++y) {
for (int x = srcWidth - 1; x >= 0; --x) {
DST *destline = reinterpret_cast<DST*>(d + (srcWidth - x - 1) * dstStride);
destline[y] = src[x];
}
s += srcStride;
src = reinterpret_cast<const SRC*>(s);
}
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
for (int x = srcWidth - 1; x >= 0; --x) {
DST *d = dest + (srcWidth - x - 1) * dstStride;
for (int y = 0; y < srcHeight; ++y) {
*d++ = src[y * srcStride + x];
}
}
#endif
}
#undef QT_DECL_MEMROTATE
template <class DST, class SRC>
static inline void qt_memrotate270_template(const SRC *src,
int srcWidth, int srcHeight, int srcStride,
DST *dest, int dstStride)
{
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
const char *s = reinterpret_cast<const char*>(src);
char *d = reinterpret_cast<char*>(dest);
s += (srcHeight - 1) * srcStride;
for (int y = srcHeight - 1; y >= 0; --y) {
src = reinterpret_cast<const SRC*>(s);
for (int x = 0; x < srcWidth; ++x) {
DST *destline = reinterpret_cast<DST*>(d + x * dstStride);
destline[srcHeight - y - 1] = src[x];
}
s -= srcStride;
}
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
for (int x = 0; x < srcWidth; ++x) {
DST *d = dest + x * dstStride;
for (int y = srcHeight - 1; y >= 0; --y) {
*d++ = src[y * srcStride + x];
}
}
#endif
}
#define QT_IMPL_MEMROTATE(srctype, desttype) \
static inline void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate90_template(src, w, h, sstride, dest, dstride); \
} \
static inline void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate270_template(src, w, h, sstride, dest, dstride); \
}
QT_IMPL_MEMROTATE(quint8, quint8)
QT_IMPL_MEMROTATE(quint16, quint16)
QT_IMPL_MEMROTATE(quint24, quint24)
QT_IMPL_MEMROTATE(quint32, quint32)
#undef QT_IMPL_MEMROTATE
QT_END_NAMESPACE