~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/painting/qpaintengine_raster_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the painting module of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
**/
 
28
 
 
29
#ifndef QPAINTENGINE_RASTER_P_H
 
30
#define QPAINTENGINE_RASTER_P_H
 
31
 
 
32
//
 
33
//  W A R N I N G
 
34
//  -------------
 
35
//
 
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.
 
39
//
 
40
// We mean it.
 
41
//
 
42
 
 
43
#include <QtGui/qpaintengine.h>
 
44
#include <QtGui/qpainterpath.h>
 
45
 
 
46
#include <private/qpaintengine_p.h>
 
47
#include <private/qdatabuffer_p.h>
 
48
#include <private/qdrawhelper_p.h>
 
49
 
 
50
class QFTOutlineMapper;
 
51
class QRasterPaintEnginePrivate;
 
52
class QRasterBuffer;
 
53
 
 
54
struct FillData;
 
55
struct SolidFillData;
 
56
struct TextureFillData;
 
57
struct LinearGradientData;
 
58
struct RadialGradientData;
 
59
struct ConicalGradientData;
 
60
 
 
61
/*******************************************************************************
 
62
 * QRasterPaintEngine
 
63
 */
 
64
class QRasterPaintEngine : public QPaintEngine
 
65
{
 
66
    Q_DECLARE_PRIVATE(QRasterPaintEngine)
 
67
public:
 
68
    QRasterPaintEngine();
 
69
    ~QRasterPaintEngine();
 
70
    bool begin(QPaintDevice *device);
 
71
    bool end();
 
72
 
 
73
    void updateState(const QPaintEngineState &state);
 
74
 
 
75
    void updateClipRegion(const QRegion &region, Qt::ClipOperation op);
 
76
    void updateClipPath(const QPainterPath &path, Qt::ClipOperation op);
 
77
 
 
78
    void drawPath(const QPainterPath &path);
 
79
    void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
 
80
 
 
81
    void fillPath(const QPainterPath &path, FillData *fillData);
 
82
 
 
83
    void drawEllipse(const QRectF &rect);
 
84
    void drawRects(const QRectF *rects, int rectCount);
 
85
 
 
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);
 
91
 
 
92
    void drawLines(const QLineF *line, int lineCount);
 
93
    void drawPoints(const QPointF *points, int pointCount);
 
94
 
 
95
    void setFlushOnEnd(bool flush);
 
96
    void flush(QPaintDevice *device, const QPoint &offset);
 
97
 
 
98
#ifdef Q_WS_WIN
 
99
    HDC getDC() const;
 
100
    void releaseDC(HDC hdc) const;
 
101
#endif
 
102
#ifdef Q_WS_QWS
 
103
    //QWS hack
 
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);
 
106
#endif
 
107
 
 
108
    Type type() const { return Raster; }
 
109
 
 
110
    QPoint coordinateOffset() const;
 
111
};
 
112
 
 
113
 
 
114
/*******************************************************************************
 
115
 * QRasterPaintEnginePrivate
 
116
 */
 
117
class QRasterPaintEnginePrivate : public QPaintEnginePrivate
 
118
{
 
119
    Q_DECLARE_PUBLIC(QRasterPaintEngine)
 
120
public:
 
121
 
 
122
    FillData fillForBrush(const QBrush &brush);
 
123
    FillData clipForFill(FillData *data);
 
124
    void updateClip_helper(const QPainterPath &path, Qt::ClipOperation);
 
125
 
 
126
    void drawBitmap(const QPointF &pos, const QPixmap &image, FillData *fill);
 
127
    QImage colorizeBitmap(const QImage &image, const QColor &color);
 
128
 
 
129
    QMatrix brushMatrix() const {
 
130
        QMatrix m(matrix);
 
131
        m.translate(brushOffset.x(), brushOffset.y());
 
132
        return m;
 
133
    }
 
134
#ifdef Q_WS_X11
 
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);
 
138
#endif
 
139
 
 
140
    qreal *gradientStopPoints(const QGradient *gradient);
 
141
    uint *gradientStopColors(const QGradient *gradient);
 
142
 
 
143
    QPointF brushOffset;
 
144
    QBrush brush;
 
145
    QBrush bgBrush;
 
146
    QPen pen;
 
147
    QMatrix matrix;
 
148
    QPainter::CompositionMode compositionMode;
 
149
 
 
150
    QPaintDevice *device;
 
151
    QFTOutlineMapper *outlineMapper;
 
152
    QRasterBuffer *rasterBuffer;
 
153
    QRasterBuffer *fontRasterBuffer;
 
154
 
 
155
    QDataBuffer<qreal> stopPoints;
 
156
    QDataBuffer<uint> stopColors;
 
157
 
 
158
    QPainterPath baseClip;
 
159
    QRect deviceRect;
 
160
 
 
161
    FillData *fillData;
 
162
    SolidFillData *solidFillData;
 
163
    TextureFillData *textureFillData;
 
164
    LinearGradientData *linearGradientData;
 
165
    RadialGradientData *radialGradientData;
 
166
    ConicalGradientData *conicalGradientData;
 
167
 
 
168
    DrawHelper *drawHelper;
 
169
 
 
170
    QImage tempImage;
 
171
 
 
172
    int deviceDepth;
 
173
 
 
174
    uint txop;
 
175
 
 
176
    uint opaqueBackground : 1;
 
177
    uint clipEnabled : 1;
 
178
    uint antialiased : 1;
 
179
    uint bilinear : 1;
 
180
    uint flushOnEnd : 1;
 
181
    uint mono_surface : 1;
 
182
};
 
183
 
 
184
/*******************************************************************************
 
185
 * QRasterBuffer
 
186
 */
 
187
class QRasterBuffer
 
188
{
 
189
public:
 
190
#if defined(Q_WS_WIN)
 
191
    QRasterBuffer() : m_hdc(0), m_bitmap(0), m_width(0), m_height(0), m_buffer(0) { init(); }
 
192
 
 
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)
 
199
    GWorldPtr m_data;
 
200
# else
 
201
    CGImageRef m_data;
 
202
#endif
 
203
#endif
 
204
    ~QRasterBuffer();
 
205
 
 
206
    void init();
 
207
 
 
208
    void prepare(QImage *image);
 
209
#ifdef Q_WS_QWS
 
210
    void prepare(QPixmap *pix);
 
211
#endif
 
212
    void prepare(int w, int h);
 
213
    void prepareBuffer(int w, int h);
 
214
    void prepareClip(int w, int h);
 
215
 
 
216
    void resetBuffer(int val=0);
 
217
    void resetClip();
 
218
 
 
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);
 
223
 
 
224
    uchar *scanLine(int y) { Q_ASSERT(y>=0); Q_ASSERT(y<m_height); return m_buffer + y * bytes_per_line; }
 
225
 
 
226
#ifndef QT_NO_DEBUG
 
227
    QImage clipImage() const;
 
228
    QImage bufferImage() const;
 
229
#endif
 
230
 
 
231
    void flushToARGBImage(QImage *image) const;
 
232
 
 
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]; }
 
235
 
 
236
    int width() const { return m_width; }
 
237
    int height() const { return m_height; }
 
238
    int bytesPerLine() const { return bytes_per_line; }
 
239
 
 
240
    uchar *buffer() const { return m_buffer; }
 
241
 
 
242
private:
 
243
#if defined(Q_WS_WIN)
 
244
    HDC m_hdc;
 
245
    HBITMAP m_bitmap;
 
246
#endif
 
247
 
 
248
    int m_width;
 
249
    int m_height;
 
250
    int bytes_per_line;
 
251
    uchar *m_buffer;
 
252
 
 
253
    int m_clipSpanHeight;
 
254
    int *m_clipSpanCount;
 
255
    int *m_clipSpanCapacity;
 
256
    QSpan **m_clipSpans;
 
257
};
 
258
 
 
259
#endif // QPAINTENGINE_RASTER_P_H