1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the painting module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
#ifndef QPAINTENGINE_RASTER_P_H
30
#define QPAINTENGINE_RASTER_P_H
36
// This file is not part of the Qt API. It exists for the convenience
37
// of other Qt classes. This header file may change from version to
38
// version without notice, or even be removed.
43
#include <QtGui/qpaintengine.h>
44
#include <QtGui/qpainterpath.h>
46
#include <private/qpaintengine_p.h>
47
#include <private/qdatabuffer_p.h>
48
#include <private/qdrawhelper_p.h>
50
class QFTOutlineMapper;
51
class QRasterPaintEnginePrivate;
56
struct TextureFillData;
57
struct LinearGradientData;
58
struct RadialGradientData;
59
struct ConicalGradientData;
61
/*******************************************************************************
64
class QRasterPaintEngine : public QPaintEngine
66
Q_DECLARE_PRIVATE(QRasterPaintEngine)
69
~QRasterPaintEngine();
70
bool begin(QPaintDevice *device);
73
void updateState(const QPaintEngineState &state);
75
void updateClipRegion(const QRegion ®ion, Qt::ClipOperation op);
76
void updateClipPath(const QPainterPath &path, Qt::ClipOperation op);
78
void drawPath(const QPainterPath &path);
79
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
81
void fillPath(const QPainterPath &path, FillData *fillData);
83
void drawEllipse(const QRectF &rect);
84
void drawRects(const QRectF *rects, int rectCount);
86
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
87
void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
88
Qt::ImageConversionFlags falgs = Qt::AutoColor);
89
void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr);
90
void drawTextItem(const QPointF &p, const QTextItem &textItem);
92
void drawLines(const QLineF *line, int lineCount);
93
void drawPoints(const QPointF *points, int pointCount);
95
void setFlushOnEnd(bool flush);
96
void flush(QPaintDevice *device, const QPoint &offset);
100
void releaseDC(HDC hdc) const;
104
void alphaPenBlt(const void* src, int bpl, bool mono, int rx,int ry,int w,int h);
105
void qwsFillRect(int x, int y, int w, int h, const QBrush &brush);
108
Type type() const { return Raster; }
110
QPoint coordinateOffset() const;
114
/*******************************************************************************
115
* QRasterPaintEnginePrivate
117
class QRasterPaintEnginePrivate : public QPaintEnginePrivate
119
Q_DECLARE_PUBLIC(QRasterPaintEngine)
122
FillData fillForBrush(const QBrush &brush);
123
FillData clipForFill(FillData *data);
124
void updateClip_helper(const QPainterPath &path, Qt::ClipOperation);
126
void drawBitmap(const QPointF &pos, const QPixmap &image, FillData *fill);
127
QImage colorizeBitmap(const QImage &image, const QColor &color);
129
QMatrix brushMatrix() const {
131
m.translate(brushOffset.x(), brushOffset.y());
135
void drawMulti(const QPointF &p, const QTextItem &textItem);
136
void drawBox(const QPointF &p, const QTextItem &textItem);
137
void drawXLFD(const QPointF &p, const QTextItem &textItem);
140
qreal *gradientStopPoints(const QGradient *gradient);
141
uint *gradientStopColors(const QGradient *gradient);
148
QPainter::CompositionMode compositionMode;
150
QPaintDevice *device;
151
QFTOutlineMapper *outlineMapper;
152
QRasterBuffer *rasterBuffer;
153
QRasterBuffer *fontRasterBuffer;
155
QDataBuffer<qreal> stopPoints;
156
QDataBuffer<uint> stopColors;
158
QPainterPath baseClip;
162
SolidFillData *solidFillData;
163
TextureFillData *textureFillData;
164
LinearGradientData *linearGradientData;
165
RadialGradientData *radialGradientData;
166
ConicalGradientData *conicalGradientData;
168
DrawHelper *drawHelper;
176
uint opaqueBackground : 1;
177
uint clipEnabled : 1;
178
uint antialiased : 1;
181
uint mono_surface : 1;
184
/*******************************************************************************
190
#if defined(Q_WS_WIN)
191
QRasterBuffer() : m_hdc(0), m_bitmap(0), m_width(0), m_height(0), m_buffer(0) { init(); }
193
HDC hdc() const { return m_hdc; }
194
#elif defined(Q_WS_X11)
195
QRasterBuffer() : m_width(0), m_height(0), m_buffer(0) { init(); }
196
#elif defined(Q_WS_MAC)
197
QRasterBuffer() : m_data(0), m_width(0), m_height(0), m_buffer(0) { init(); }
198
# if defined(QMAC_NO_COREGRAPHICS)
208
void prepare(QImage *image);
210
void prepare(QPixmap *pix);
212
void prepare(int w, int h);
213
void prepareBuffer(int w, int h);
214
void prepareClip(int w, int h);
216
void resetBuffer(int val=0);
219
void resizeClipSpan(int y, int size);
220
void appendClipSpan(int x, int y, int len, int coverage);
221
void replaceClipSpans(int y, QSpan *spans, int spanCount);
222
void resetClipSpans(int y, int count);
224
uchar *scanLine(int y) { Q_ASSERT(y>=0); Q_ASSERT(y<m_height); return m_buffer + y * bytes_per_line; }
227
QImage clipImage() const;
228
QImage bufferImage() const;
231
void flushToARGBImage(QImage *image) const;
233
QSpan *clipSpans(int y) const { Q_ASSERT(y >= 0 && y < m_height); return m_clipSpans[y]; }
234
int clipSpanCount(int y) const { Q_ASSERT(y >= 0 && y < m_height); return m_clipSpanCount[y]; }
236
int width() const { return m_width; }
237
int height() const { return m_height; }
238
int bytesPerLine() const { return bytes_per_line; }
240
uchar *buffer() const { return m_buffer; }
243
#if defined(Q_WS_WIN)
253
int m_clipSpanHeight;
254
int *m_clipSpanCount;
255
int *m_clipSpanCapacity;
259
#endif // QPAINTENGINE_RASTER_P_H