Get rid of QCustomRasterPaintDevice / QWS stuff in raster engine.

This commit is contained in:
Samuel Rødal 2011-05-04 10:13:43 +02:00
parent 8d5df33f9c
commit 19822fa60c
4 changed files with 44 additions and 1139 deletions

File diff suppressed because it is too large Load Diff

View File

@ -64,10 +64,6 @@
#include "private/qrasterdefs_p.h"
#include <private/qsimd_p.h>
#ifdef Q_WS_QWS
#include "QtGui/qscreen_qws.h"
#endif
QT_BEGIN_NAMESPACE
#if defined(Q_CC_MSVC) && _MSCVER <= 1300 && !defined(Q_CC_INTEL)
@ -170,10 +166,6 @@ extern MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3];
extern DrawHelper qDrawHelper[QImage::NImageFormats];
void qBlendTexture(int count, const QSpan *spans, void *userData);
#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
extern DrawHelper qDrawHelperCallback[QImage::NImageFormats];
void qBlendTextureCallback(int count, const QSpan *spans, void *userData);
#endif
typedef void (QT_FASTCALL *CompositionFunction)(uint *dest, const uint *src, int length, uint const_alpha);
typedef void (QT_FASTCALL *CompositionFunctionSolid)(uint *dest, int length, uint color, uint const_alpha);
@ -231,11 +223,7 @@ struct QGradientData
QConicalGradientData conical;
};
#ifdef Q_WS_QWS
#define GRADIENT_STOPTABLE_SIZE 256
#else
#define GRADIENT_STOPTABLE_SIZE 1024
#endif
uint* colorTable; //[GRADIENT_STOPTABLE_SIZE];
@ -272,9 +260,6 @@ struct QSpanData
~QSpanData() { delete tempImage; }
QRasterBuffer *rasterBuffer;
#ifdef Q_WS_QWS
QRasterPaintEngine *rasterEngine;
#endif
ProcessSpans blend;
ProcessSpans unclipped_blend;
BitmapBlitFunc bitmapBlit;
@ -1238,37 +1223,6 @@ inline quint32 qt_colorConvert(qrgb888 color, quint32 dummy)
return quint32(color);
}
#ifdef QT_QWS_DEPTH_8
template <>
inline quint8 qt_colorConvert(quint32 color, quint8 dummy)
{
Q_UNUSED(dummy);
uchar r = ((qRed(color) & 0xf8) + 0x19) / 0x33;
uchar g = ((qGreen(color) &0xf8) + 0x19) / 0x33;
uchar b = ((qBlue(color) &0xf8) + 0x19) / 0x33;
return r*6*6 + g*6 + b;
}
template <>
inline quint8 qt_colorConvert(quint16 color, quint8 dummy)
{
Q_UNUSED(dummy);
uchar r = (color & 0xf800) >> (11-3);
uchar g = (color & 0x07c0) >> (6-3);
uchar b = (color & 0x001f) << 3;
uchar tr = (r + 0x19) / 0x33;
uchar tg = (g + 0x19) / 0x33;
uchar tb = (b + 0x19) / 0x33;
return tr*6*6 + tg*6 + tb;
}
#endif // QT_QWS_DEPTH_8
// hw: endianess??
class quint24
{
@ -1505,84 +1459,6 @@ qrgb444 qrgb444::byte_mul(quint8 a) const
return result;
}
#ifdef QT_QWS_DEPTH_GENERIC
struct qrgb
{
public:
static int bpp;
static int len_red;
static int len_green;
static int len_blue;
static int len_alpha;
static int off_red;
static int off_green;
static int off_blue;
static int off_alpha;
} Q_PACKED;
template <typename SRC>
Q_STATIC_TEMPLATE_FUNCTION inline quint32 qt_convertToRgb(SRC color);
template <>
inline quint32 qt_convertToRgb(quint32 color)
{
const int r = qRed(color) >> (8 - qrgb::len_red);
const int g = qGreen(color) >> (8 - qrgb::len_green);
const int b = qBlue(color) >> (8 - qrgb::len_blue);
const int a = qAlpha(color) >> (8 - qrgb::len_alpha);
const quint32 v = (r << qrgb::off_red)
| (g << qrgb::off_green)
| (b << qrgb::off_blue)
| (a << qrgb::off_alpha);
return v;
}
template <>
inline quint32 qt_convertToRgb(quint16 color)
{
return qt_convertToRgb(qt_colorConvert<quint32, quint16>(color, 0));
}
class qrgb_generic16
{
public:
inline qrgb_generic16(quint32 color)
{
const int r = qRed(color) >> (8 - qrgb::len_red);
const int g = qGreen(color) >> (8 - qrgb::len_green);
const int b = qBlue(color) >> (8 - qrgb::len_blue);
const int a = qAlpha(color) >> (8 - qrgb::len_alpha);
data = (r << qrgb::off_red)
| (g << qrgb::off_green)
| (b << qrgb::off_blue)
| (a << qrgb::off_alpha);
}
inline operator quint16 () { return data; }
inline quint32 operator<<(int shift) const { return data << shift; }
private:
quint16 data;
} Q_PACKED;
template <>
inline qrgb_generic16 qt_colorConvert(quint32 color, qrgb_generic16 dummy)
{
Q_UNUSED(dummy);
return qrgb_generic16(color);
}
template <>
inline qrgb_generic16 qt_colorConvert(quint16 color, qrgb_generic16 dummy)
{
Q_UNUSED(dummy);
return qrgb_generic16(qt_colorConvert<quint32, quint16>(color, 0));
}
#endif // QT_QWS_DEPTH_GENERIC
template <class T>
void qt_memfill(T *dest, T value, int count);
@ -1790,16 +1666,6 @@ QT_RECTCONVERT_TRIVIAL_IMPL(qargb4444)
QT_RECTCONVERT_TRIVIAL_IMPL(qrgb444)
#undef QT_RECTCONVERT_TRIVIAL_IMPL
#ifdef QT_QWS_DEPTH_GENERIC
template <> void qt_rectconvert(qrgb *dest, const quint32 *src,
int x, int y, int width, int height,
int dstStride, int srcStride);
template <> void qt_rectconvert(qrgb *dest, const quint16 *src,
int x, int y, int width, int height,
int dstStride, int srcStride);
#endif // QT_QWS_DEPTH_GENERIC
#define QT_MEMFILL_UINT(dest, length, color) \
qt_memfill<quint32>(dest, color, length);
@ -1862,16 +1728,6 @@ inline ushort qConvertRgb32To16(uint c)
| (((c) >> 8) & 0xf800);
}
#if defined(Q_WS_QWS) || (QT_VERSION >= 0x040400)
inline quint32 qConvertRgb32To16x2(quint64 c)
{
c = (((c) >> 3) & Q_UINT64_C(0x001f0000001f))
| (((c) >> 5) & Q_UINT64_C(0x07e0000007e0))
| (((c) >> 8) & Q_UINT64_C(0xf8000000f800));
return c | (c >> 16);
}
#endif
inline QRgb qConvertRgb16To32(uint c)
{
return 0xff000000

View File

@ -85,14 +85,6 @@
# include <private/qt_mac_p.h>
# include <private/qpixmap_mac_p.h>
# include <private/qpaintengine_mac_p.h>
#elif defined(Q_WS_QWS)
# if !defined(QT_NO_FREETYPE)
# include <private/qfontengine_ft_p.h>
# endif
# if !defined(QT_NO_QWS_QPF2)
# include <private/qfontengine_qpf_p.h>
# endif
# include <private/qabstractfontengine_p.h>
#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
# include <private/qfontengine_s60_p.h>
#elif defined(Q_WS_QPA)
@ -383,11 +375,6 @@ void QRasterPaintEngine::init()
case QInternal::Image:
format = d->rasterBuffer->prepare(static_cast<QImage *>(d->device));
break;
#ifdef Q_WS_QWS
case QInternal::CustomRaster:
d->rasterBuffer->prepare(static_cast<QCustomRasterPaintDevice*>(d->device));
break;
#endif
default:
qWarning("QRasterPaintEngine: unsupported target device %d\n", d->device->devType());
d->device = 0;
@ -985,13 +972,6 @@ void QRasterPaintEngine::clipEnabledChanged()
}
}
#ifdef Q_WS_QWS
void QRasterPaintEnginePrivate::prepare(QCustomRasterPaintDevice *device)
{
rasterBuffer->prepare(device);
}
#endif
void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
const QImage &img,
SrcOverBlendFunc func,
@ -3455,22 +3435,6 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
QFontEngine *fontEngine = ti.fontEngine;
#if defined(Q_WS_QWS)
if (fontEngine->type() == QFontEngine::Box) {
fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti);
return;
}
if (s->matrix.type() < QTransform::TxScale
&& (fontEngine->type() == QFontEngine::QPF1 || fontEngine->type() == QFontEngine::QPF2
|| (fontEngine->type() == QFontEngine::Proxy
&& !(static_cast<QProxyFontEngine *>(fontEngine)->drawAsOutline()))
)) {
fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti);
return;
}
#endif // Q_WS_QWS
#ifdef Q_WS_QPA
if (s->matrix.type() < QTransform::TxScale) {
@ -3500,14 +3464,6 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_QPF2)
if (fontEngine->type() == QFontEngine::QPF2) {
QFontEngine *renderingEngine = static_cast<QFontEngineQPF *>(fontEngine)->renderingEngine();
if (renderingEngine)
fontEngine = renderingEngine;
}
#endif
if (fontEngine->type() != QFontEngine::Freetype) {
QPaintEngineEx::drawTextItem(p, ti);
return;
@ -3877,59 +3833,6 @@ QPoint QRasterPaintEngine::coordinateOffset() const
return QPoint(0, 0);
}
/*!
Draws the given color \a spans with the specified \a color. The \a
count parameter specifies the number of spans.
The default implementation does nothing; reimplement this function
to draw the given color \a spans with the specified \a color. Note
that this function \e must be reimplemented if the framebuffer is
not memory-mapped.
\sa drawBufferSpan()
*/
#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
void QRasterPaintEngine::drawColorSpans(const QSpan *spans, int count, uint color)
{
Q_UNUSED(spans);
Q_UNUSED(count);
Q_UNUSED(color);
qFatal("QRasterPaintEngine::drawColorSpans must be reimplemented on "
"a non memory-mapped device");
}
/*!
\fn void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int size, int x, int y, int length, uint alpha)
Draws the given \a buffer.
The default implementation does nothing; reimplement this function
to draw a buffer that contains more than one color. Note that this
function \e must be reimplemented if the framebuffer is not
memory-mapped.
The \a size parameter specifies the total size of the given \a
buffer, while the \a length parameter specifies the number of
pixels to draw. The buffer's position is given by (\a x, \a
y). The provided \a alpha value is added to each pixel in the
buffer when drawing.
\sa drawColorSpans()
*/
void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
int x, int y, int length, uint const_alpha)
{
Q_UNUSED(buffer);
Q_UNUSED(bufsize);
Q_UNUSED(x);
Q_UNUSED(y);
Q_UNUSED(length);
Q_UNUSED(const_alpha);
qFatal("QRasterPaintEngine::drawBufferSpan must be reimplemented on "
"a non memory-mapped device");
}
#endif // Q_WS_QWS
void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fg)
{
Q_ASSERT(fg);
@ -4377,127 +4280,6 @@ void QRasterBuffer::resetBuffer(int val)
memset(m_buffer, val, m_height*bytes_per_line);
}
#if defined(Q_WS_QWS)
void QRasterBuffer::prepare(QCustomRasterPaintDevice *device)
{
m_buffer = reinterpret_cast<uchar*>(device->memory());
m_width = qMin(QT_RASTER_COORD_LIMIT, device->width());
m_height = qMin(QT_RASTER_COORD_LIMIT, device->height());
bytes_per_pixel = device->depth() / 8;
bytes_per_line = device->bytesPerLine();
format = device->format();
#ifndef QT_NO_RASTERCALLBACKS
if (!m_buffer)
drawHelper = qDrawHelperCallback + format;
else
#endif
drawHelper = qDrawHelper + format;
}
int QCustomRasterPaintDevice::metric(PaintDeviceMetric m) const
{
switch (m) {
case PdmWidth:
return widget->frameGeometry().width();
case PdmHeight:
return widget->frameGeometry().height();
default:
break;
}
return qt_paint_device_metric(widget, m);
}
int QCustomRasterPaintDevice::bytesPerLine() const
{
return (width() * depth() + 7) / 8;
}
#elif defined(Q_OS_SYMBIAN)
void QRasterBuffer::prepareBuffer(int /* width */, int /* height */)
{
}
#endif // Q_OS_SYMBIAN
/*!
\class QCustomRasterPaintDevice
\preliminary
\ingroup qws
\since 4.2
\brief The QCustomRasterPaintDevice class is provided to activate
hardware accelerated paint engines in Qt for Embedded Linux.
Note that this class is only available in \l{Qt for Embedded Linux}.
In \l{Qt for Embedded Linux}, painting is a pure software
implementation. But starting with Qt 4.2, it is
possible to add an accelerated graphics driver to take advantage
of available hardware resources.
Hardware acceleration is accomplished by creating a custom screen
driver, accelerating the copying from memory to the screen, and
implementing a custom paint engine accelerating the various
painting operations. Then a custom paint device (derived from the
QCustomRasterPaintDevice class) and a custom window surface
(derived from QWSWindowSurface) must be implemented to make
\l{Qt for Embedded Linux} aware of the accelerated driver.
See the \l {Adding an Accelerated Graphics Driver to Qt for Embedded Linux}
documentation for details.
\sa QRasterPaintEngine, QPaintDevice
*/
/*!
\fn QCustomRasterPaintDevice::QCustomRasterPaintDevice(QWidget *widget)
Constructs a custom raster based paint device for the given
top-level \a widget.
*/
/*!
\fn int QCustomRasterPaintDevice::bytesPerLine() const
Returns the number of bytes per line in the framebuffer. Note that
this number might be larger than the framebuffer width.
*/
/*!
\fn int QCustomRasterPaintDevice::devType() const
\internal
*/
/*!
\fn QImage::Format QCustomRasterPaintDevice::format() const
Returns the format of the device's memory buffet.
The default format is QImage::Format_ARGB32_Premultiplied. The
only other valid format is QImage::Format_RGB16.
*/
/*!
\fn void * QCustomRasterPaintDevice::memory () const
Returns a pointer to the paint device's memory buffer, or 0 if no
such buffer exists.
*/
/*!
\fn int QCustomRasterPaintDevice::metric ( PaintDeviceMetric m ) const
\reimp
*/
/*!
\fn QSize QCustomRasterPaintDevice::size () const
\internal
*/
QClipData::QClipData(int height)
{
clipSpanHeight = height;
@ -5144,9 +4926,6 @@ Q_GLOBAL_STATIC(QGradientCache, qt_gradient_cache)
void QSpanData::init(QRasterBuffer *rb, const QRasterPaintEngine *pe)
{
rasterBuffer = rb;
#ifdef Q_WS_QWS
rasterEngine = const_cast<QRasterPaintEngine *>(pe);
#endif
type = None;
txop = 0;
bilinear = false;
@ -5291,16 +5070,7 @@ void QSpanData::adjustSpanMethods()
unclipped_blend = rasterBuffer->drawHelper->blendGradient;
break;
case Texture:
#ifdef Q_WS_QWS
#ifndef QT_NO_RASTERCALLBACKS
if (!rasterBuffer->buffer())
unclipped_blend = qBlendTextureCallback;
else
#endif
unclipped_blend = qBlendTexture;
#else
unclipped_blend = qBlendTexture;
#endif
if (!texture.imageData)
unclipped_blend = 0;

View File

@ -72,7 +72,6 @@ class QOutlineMapper;
class QRasterPaintEnginePrivate;
class QRasterBuffer;
class QClipData;
class QCustomRasterPaintDevice;
class QRasterPaintEngineState : public QPainterState
{
@ -129,11 +128,7 @@ public:
/*******************************************************************************
* QRasterPaintEngine
*/
class
#ifdef Q_WS_QWS
Q_GUI_EXPORT
#endif
QRasterPaintEngine : public QPaintEngineEx
class QRasterPaintEngine : public QPaintEngineEx
{
Q_DECLARE_PRIVATE(QRasterPaintEngine)
public:
@ -244,12 +239,6 @@ public:
QPoint coordinateOffset() const;
#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
virtual void drawColorSpans(const QSpan *spans, int count, uint color);
virtual void drawBufferSpan(const uint *buffer, int bufsize,
int x, int y, int length, uint const_alpha);
#endif
protected:
QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *);
private:
@ -296,11 +285,7 @@ private:
/*******************************************************************************
* QRasterPaintEnginePrivate
*/
class
#ifdef Q_WS_QWS
Q_GUI_EXPORT
#endif
QRasterPaintEnginePrivate : public QPaintEngineExPrivate
class QRasterPaintEnginePrivate : public QPaintEngineExPrivate
{
Q_DECLARE_PUBLIC(QRasterPaintEngine)
public:
@ -333,10 +318,6 @@ public:
ProcessSpans getBrushFunc(const QRect &rect, const QSpanData *data) const;
ProcessSpans getBrushFunc(const QRectF &rect, const QSpanData *data) const;
#ifdef Q_WS_QWS
void prepare(QCustomRasterPaintDevice *);
#endif
inline const QClipData *clip() const;
void initializeRasterizer(QSpanData *data);
@ -384,11 +365,7 @@ public:
};
class
#ifdef Q_WS_QWS
Q_GUI_EXPORT
#endif
QClipData {
class QClipData {
public:
QClipData(int height);
~QClipData();
@ -465,41 +442,10 @@ inline void QClipData::appendSpans(const QSpan *s, int num)
count += num;
}
#ifdef Q_WS_QWS
class Q_GUI_EXPORT QCustomRasterPaintDevice : public QPaintDevice
{
public:
QCustomRasterPaintDevice(QWidget *w) : widget(w) {}
int devType() const { return QInternal::CustomRaster; }
virtual int metric(PaintDeviceMetric m) const;
virtual void* memory() const { return 0; }
virtual QImage::Format format() const {
return QImage::Format_ARGB32_Premultiplied;
}
virtual int bytesPerLine() const;
virtual QSize size() const {
return static_cast<QRasterPaintEngine*>(paintEngine())->size();
}
private:
QWidget *widget;
};
#endif // Q_WS_QWS
/*******************************************************************************
* QRasterBuffer
*/
class
#ifdef Q_WS_QWS
Q_GUI_EXPORT
#endif
QRasterBuffer
class QRasterBuffer
{
public:
QRasterBuffer() : m_width(0), m_height(0), m_buffer(0) { init(); }
@ -510,9 +456,6 @@ public:
QImage::Format prepare(QImage *image);
QImage::Format prepare(QPixmap *pix);
#ifdef Q_WS_QWS
void prepare(QCustomRasterPaintDevice *device);
#endif
void prepare(int w, int h);
void prepareBuffer(int w, int h);