📄 qdrawhelper_p.h
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.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 GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#ifndef QDRAWHELPER_P_H#define QDRAWHELPER_P_H//// W A R N I N G// -------------//// This file is not part of the Qt API. It exists purely as an// implementation detail. This header file may change from version to// version without notice, or even be removed.//// We mean it.//#include "QtCore/qglobal.h"#include "QtGui/qcolor.h"#include "QtGui/qpainter.h"#include "QtGui/qimage.h"#ifndef QT_FT_BEGIN_HEADER#define QT_FT_BEGIN_HEADER#define QT_FT_END_HEADER#endif#include "private/qrasterdefs_p.h"#ifdef Q_WS_QWS#include "QtGui/qscreen_qws.h"#define Q_GUI_QWS_EXPORT Q_GUI_EXPORT#else#define Q_GUI_QWS_EXPORT#endif#define QT_ROTATION_CACHEDREAD 1#define QT_ROTATION_CACHEDWRITE 2#define QT_ROTATION_PACKING 3#define QT_ROTATION_TILED 4#ifndef QT_ROTATION_ALGORITHM#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN#define QT_ROTATION_ALGORITHM QT_ROTATION_TILED#else#define QT_ROTATION_ALGORITHM QT_ROTATION_CACHEDREAD#endif#endif/******************************************************************************* * QSpan * * duplicate definition of FT_Span */typedef QT_FT_Span QSpan;struct SolidData;struct TextureData;struct GradientData;struct LinearGradientData;struct RadialGradientData;struct ConicalGradientData;struct QSpanData;class QGradient;class QRasterBuffer;typedef QT_FT_SpanFunc ProcessSpans;typedef void (*BitmapBlitFunc)(QRasterBuffer *rasterBuffer, int x, int y, quint32 color, const uchar *bitmap, int mapWidth, int mapHeight, int mapStride);typedef void (*AlphamapBlitFunc)(QRasterBuffer *rasterBuffer, int x, int y, quint32 color, const uchar *bitmap, int mapWidth, int mapHeight, int mapStride);typedef void (*RectFillFunc)(QRasterBuffer *rasterBuffer, int x, int y, int width, int height, quint32 color);struct DrawHelper { ProcessSpans blendColor; ProcessSpans blendGradient; BitmapBlitFunc bitmapBlit; AlphamapBlitFunc alphamapBlit; RectFillFunc fillRect;};extern DrawHelper qDrawHelper[QImage::NImageFormats];void qBlendTexture(int count, const QSpan *spans, void *userData);#ifdef Q_WS_QWSextern DrawHelper qDrawHelperCallback[QImage::NImageFormats];void qBlendTextureCallback(int count, const QSpan *spans, void *userData);#endiftypedef 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);void qInitDrawhelperAsm();class QRasterPaintEngine;struct SolidData{ uint color;};struct LinearGradientData{ struct { qreal x; qreal y; } origin; struct { qreal x; qreal y; } end;};struct RadialGradientData{ struct { qreal x; qreal y; } center; struct { qreal x; qreal y; } focal; qreal radius;};struct ConicalGradientData{ struct { qreal x; qreal y; } center; qreal angle;};struct GradientData{ QGradient::Spread spread; union { LinearGradientData linear; RadialGradientData radial; ConicalGradientData conical; }; // need to keep track of these as the same gradient might be used for several objects union { LinearGradientData unresolvedLinear; RadialGradientData unresolvedRadial; ConicalGradientData unresolvedConical; };#ifdef Q_WS_QWS#define GRADIENT_STOPTABLE_SIZE 256#else#define GRADIENT_STOPTABLE_SIZE 1024#endif uint* colorTable; //[GRADIENT_STOPTABLE_SIZE]; uint alphaColor : 1; uint needsResolving : 1;};struct TextureData{ const uchar *imageData; const uchar *scanLine(int y) const { return imageData + y*bytesPerLine; } int width; int height; int bytesPerLine; QImage::Format format; const QVector<QRgb> *colorTable; bool hasAlpha; enum Type { Plain, Tiled }; Type type; int const_alpha;};struct QSpanData{ QRasterBuffer *rasterBuffer;#ifdef Q_WS_QWS QRasterPaintEngine *rasterEngine;#endif ProcessSpans blend; ProcessSpans unclipped_blend; BitmapBlitFunc bitmapBlit; AlphamapBlitFunc alphamapBlit; RectFillFunc fillRect; qreal m11, m12, m13, m21, m22, m23, dx, dy; // inverse xform matrix enum Type { None, Solid, LinearGradient, RadialGradient, ConicalGradient, Texture } type : 8; int txop : 8; bool bilinear; QImage tempImage; union { SolidData solid; GradientData gradient; TextureData texture; }; void init(QRasterBuffer *rb, QRasterPaintEngine *pe = 0); void setup(const QBrush &brush, int alpha); void setupMatrix(const QTransform &matrix, int bilinear); void initTexture(const QImage *image, int alpha, TextureData::Type = TextureData::Plain); void adjustSpanMethods();};template <class DST, class SRC>inline DST qt_colorConvert(SRC color, DST dummy){ Q_UNUSED(dummy); return color;}template <>inline quint32 qt_colorConvert(quint16 color, quint32 dummy){ Q_UNUSED(dummy); const int r = (color & 0xf800); const int g = (color & 0x07e0); const int b = (color & 0x001f); const int tr = (r >> 8) | (r >> 13); const int tg = (g >> 3) | (g >> 9); const int tb = (b << 3) | (b >> 2); return qRgb(tr, tg, tb);}template <>inline quint16 qt_colorConvert(quint32 color, quint16 dummy){ Q_UNUSED(dummy); const int r = qRed(color) << 8; const int g = qGreen(color) << 3; const int b = qBlue(color) >> 3; return (r & 0xf800) | (g & 0x07e0)| (b & 0x001f);}#ifdef QT_QWS_DEPTH_8template <>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#ifdef QT_QWS_DEPTH_24// hw: endianess??class quint24{public: inline quint24(quint32 v) { data[0] = qBlue(v); data[1] = qGreen(v); data[2] = qRed(v); } inline operator quint32 () { return qRgb(data[2], data[1], data[0]); }private: uchar data[3];} Q_PACKED;template <>inline quint24 qt_colorConvert(quint32 color, quint24 dummy){ Q_UNUSED(dummy); return quint24(color);}#endif // QT_QWS_DEPTH_24#ifdef QT_QWS_DEPTH_18// hw: endianess??class quint18{public: inline quint18(quint32 v) { uchar b = qBlue(v); uchar g = qGreen(v); uchar r = qRed(v); uint p = (b >> 2) | ((g >> 2) << 6) | ((r >> 2) << 12); data[0] = qBlue(p); data[1] = qGreen(p); data[2] = qRed(p); } inline operator quint32 () { const uchar r = (data[2] << 6) | ((data[1] & 0xf0) >> 2) | (data[2] & 0x3); const uchar g = (data[1] << 4) | ((data[0] & 0xc0) >> 4) | ((data[1] & 0x0f) >> 2); const uchar b = (data[0] << 2) | ((data[0] & 0x3f) >> 4); return qRgb(r, g, b); }private: uchar data[3];} Q_PACKED;template <>inline quint18 qt_colorConvert(quint32 color, quint18 dummy){ Q_UNUSED(dummy); return quint18(color);}#endif // QT_QWS_DEPTH_18#ifdef QT_QWS_DEPTH_GENERICstruct qrgb{public: static int bpp;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -