| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QPAINTENGINE_RASTER_P_H
|
|---|
| 43 | #define QPAINTENGINE_RASTER_P_H
|
|---|
| 44 |
|
|---|
| 45 | //
|
|---|
| 46 | // W A R N I N G
|
|---|
| 47 | // -------------
|
|---|
| 48 | //
|
|---|
| 49 | // This file is not part of the Qt API. It exists for the convenience
|
|---|
| 50 | // of other Qt classes. This header file may change from version to
|
|---|
| 51 | // version without notice, or even be removed.
|
|---|
| 52 | //
|
|---|
| 53 | // We mean it.
|
|---|
| 54 | //
|
|---|
| 55 |
|
|---|
| 56 | #include "private/qpaintengineex_p.h"
|
|---|
| 57 | #include "QtGui/qpainterpath.h"
|
|---|
| 58 | #include "private/qdatabuffer_p.h"
|
|---|
| 59 | #include "private/qdrawhelper_p.h"
|
|---|
| 60 | #include "private/qpaintengine_p.h"
|
|---|
| 61 | #include "private/qrasterizer_p.h"
|
|---|
| 62 | #include "private/qstroker_p.h"
|
|---|
| 63 | #include "private/qpainter_p.h"
|
|---|
| 64 | #include "private/qtextureglyphcache_p.h"
|
|---|
| 65 | #include "private/qoutlinemapper_p.h"
|
|---|
| 66 |
|
|---|
| 67 | #include <stdlib.h>
|
|---|
| 68 |
|
|---|
| 69 | QT_BEGIN_NAMESPACE
|
|---|
| 70 |
|
|---|
| 71 | class QOutlineMapper;
|
|---|
| 72 | class QRasterPaintEnginePrivate;
|
|---|
| 73 | class QRasterBuffer;
|
|---|
| 74 | class QClipData;
|
|---|
| 75 | class QCustomRasterPaintDevice;
|
|---|
| 76 |
|
|---|
| 77 | class QRasterPaintEngineState : public QPainterState
|
|---|
| 78 | {
|
|---|
| 79 | public:
|
|---|
| 80 | QRasterPaintEngineState(QRasterPaintEngineState &other);
|
|---|
| 81 | QRasterPaintEngineState();
|
|---|
| 82 | ~QRasterPaintEngineState();
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | QPen lastPen;
|
|---|
| 86 | QSpanData penData;
|
|---|
| 87 | QStrokerOps *stroker;
|
|---|
| 88 | uint strokeFlags;
|
|---|
| 89 |
|
|---|
| 90 | QBrush lastBrush;
|
|---|
| 91 | QSpanData brushData;
|
|---|
| 92 | uint fillFlags;
|
|---|
| 93 |
|
|---|
| 94 | uint pixmapFlags;
|
|---|
| 95 | int intOpacity;
|
|---|
| 96 |
|
|---|
| 97 | qreal txscale;
|
|---|
| 98 |
|
|---|
| 99 | QClipData *clip;
|
|---|
| 100 | // QRect clipRect;
|
|---|
| 101 | // QRegion clipRegion;
|
|---|
| 102 |
|
|---|
| 103 | // QPainter::RenderHints hints;
|
|---|
| 104 | // QPainter::CompositionMode compositionMode;
|
|---|
| 105 |
|
|---|
| 106 | uint dirty;
|
|---|
| 107 |
|
|---|
| 108 | struct Flags {
|
|---|
| 109 | uint has_clip_ownership : 1; // should delete the clip member..
|
|---|
| 110 | uint fast_pen : 1; // cosmetic 1-width pens, using midpoint drawlines
|
|---|
| 111 | uint non_complex_pen : 1; // can use rasterizer, rather than stroker
|
|---|
| 112 | uint antialiased : 1;
|
|---|
| 113 | uint bilinear : 1;
|
|---|
| 114 | uint fast_text : 1;
|
|---|
| 115 | uint int_xform : 1;
|
|---|
| 116 | uint tx_noshear : 1;
|
|---|
| 117 | uint fast_images : 1;
|
|---|
| 118 | };
|
|---|
| 119 |
|
|---|
| 120 | union {
|
|---|
| 121 | Flags flags;
|
|---|
| 122 | uint flag_bits;
|
|---|
| 123 | };
|
|---|
| 124 | };
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 | /*******************************************************************************
|
|---|
| 130 | * QRasterPaintEngine
|
|---|
| 131 | */
|
|---|
| 132 | class
|
|---|
| 133 | #ifdef Q_WS_QWS
|
|---|
| 134 | Q_GUI_EXPORT
|
|---|
| 135 | #endif
|
|---|
| 136 | QRasterPaintEngine : public QPaintEngineEx
|
|---|
| 137 | {
|
|---|
| 138 | Q_DECLARE_PRIVATE(QRasterPaintEngine)
|
|---|
| 139 | public:
|
|---|
| 140 |
|
|---|
| 141 | QRasterPaintEngine(QPaintDevice *device);
|
|---|
| 142 | ~QRasterPaintEngine();
|
|---|
| 143 | bool begin(QPaintDevice *device);
|
|---|
| 144 | bool end();
|
|---|
| 145 |
|
|---|
| 146 | void penChanged();
|
|---|
| 147 | void brushChanged();
|
|---|
| 148 | void brushOriginChanged();
|
|---|
| 149 | void opacityChanged();
|
|---|
| 150 | void compositionModeChanged();
|
|---|
| 151 | void renderHintsChanged();
|
|---|
| 152 | void transformChanged();
|
|---|
| 153 | void clipEnabledChanged();
|
|---|
| 154 |
|
|---|
| 155 | void setState(QPainterState *s);
|
|---|
| 156 | QPainterState *createState(QPainterState *orig) const;
|
|---|
| 157 | inline QRasterPaintEngineState *state() {
|
|---|
| 158 | return static_cast<QRasterPaintEngineState *>(QPaintEngineEx::state());
|
|---|
| 159 | }
|
|---|
| 160 | inline const QRasterPaintEngineState *state() const {
|
|---|
| 161 | return static_cast<const QRasterPaintEngineState *>(QPaintEngineEx::state());
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | void updateBrush(const QBrush &brush);
|
|---|
| 165 | void updatePen(const QPen &pen);
|
|---|
| 166 |
|
|---|
| 167 | void updateMatrix(const QTransform &matrix);
|
|---|
| 168 |
|
|---|
| 169 | void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
|
|---|
| 170 | void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
|
|---|
| 171 | void fillPath(const QPainterPath &path, QSpanData *fillData);
|
|---|
| 172 | void fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
|
|---|
| 173 |
|
|---|
| 174 | void drawEllipse(const QRectF &rect);
|
|---|
| 175 |
|
|---|
| 176 | void fillRect(const QRectF &rect, const QBrush &brush);
|
|---|
| 177 | void fillRect(const QRectF &rect, const QColor &color);
|
|---|
| 178 |
|
|---|
| 179 | void drawRects(const QRect *rects, int rectCount);
|
|---|
| 180 | void drawRects(const QRectF *rects, int rectCount);
|
|---|
| 181 |
|
|---|
| 182 | void drawPixmap(const QPointF &p, const QPixmap &pm);
|
|---|
| 183 | void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
|
|---|
| 184 | void drawImage(const QPointF &p, const QImage &img);
|
|---|
| 185 | void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
|
|---|
| 186 | Qt::ImageConversionFlags falgs = Qt::AutoColor);
|
|---|
| 187 | void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr);
|
|---|
| 188 | void drawTextItem(const QPointF &p, const QTextItem &textItem);
|
|---|
| 189 |
|
|---|
| 190 | void drawLines(const QLine *line, int lineCount);
|
|---|
| 191 | void drawLines(const QLineF *line, int lineCount);
|
|---|
| 192 |
|
|---|
| 193 | void drawPoints(const QPointF *points, int pointCount);
|
|---|
| 194 | void drawPoints(const QPoint *points, int pointCount);
|
|---|
| 195 |
|
|---|
| 196 | void stroke(const QVectorPath &path, const QPen &pen);
|
|---|
| 197 | void fill(const QVectorPath &path, const QBrush &brush);
|
|---|
| 198 |
|
|---|
| 199 | void strokePolygonCosmetic(const QPoint *pts, int pointCount, PolygonDrawMode mode);
|
|---|
| 200 | void strokePolygonCosmetic(const QPointF *pt, int pointCount, PolygonDrawMode mode);
|
|---|
| 201 |
|
|---|
| 202 | void clip(const QVectorPath &path, Qt::ClipOperation op);
|
|---|
| 203 | void clip(const QRect &rect, Qt::ClipOperation op);
|
|---|
| 204 | void clip(const QRegion ®ion, Qt::ClipOperation op);
|
|---|
| 205 |
|
|---|
| 206 | void drawStaticTextItem(QStaticTextItem *textItem);
|
|---|
| 207 |
|
|---|
| 208 | enum ClipType {
|
|---|
| 209 | RectClip,
|
|---|
| 210 | ComplexClip
|
|---|
| 211 | };
|
|---|
| 212 | ClipType clipType() const;
|
|---|
| 213 | QRect clipBoundingRect() const;
|
|---|
| 214 |
|
|---|
| 215 | #ifdef Q_NO_USING_KEYWORD
|
|---|
| 216 | inline void drawEllipse(const QRect &rect) { QPaintEngineEx::drawEllipse(rect); }
|
|---|
| 217 | #else
|
|---|
| 218 | using QPaintEngineEx::drawPolygon;
|
|---|
| 219 | using QPaintEngineEx::drawEllipse;
|
|---|
| 220 | #endif
|
|---|
| 221 |
|
|---|
| 222 | void releaseBuffer();
|
|---|
| 223 |
|
|---|
| 224 | QSize size() const;
|
|---|
| 225 |
|
|---|
| 226 | #ifndef QT_NO_DEBUG
|
|---|
| 227 | void saveBuffer(const QString &s) const;
|
|---|
| 228 | #endif
|
|---|
| 229 |
|
|---|
| 230 | #ifdef Q_WS_MAC
|
|---|
| 231 | void setCGContext(CGContextRef ref);
|
|---|
| 232 | CGContextRef getCGContext() const;
|
|---|
| 233 | #endif
|
|---|
| 234 |
|
|---|
| 235 | #ifdef Q_WS_WIN
|
|---|
| 236 | void setDC(HDC hdc);
|
|---|
| 237 | HDC getDC() const;
|
|---|
| 238 | void releaseDC(HDC hdc) const;
|
|---|
| 239 | #endif
|
|---|
| 240 |
|
|---|
| 241 | void alphaPenBlt(const void* src, int bpl, int depth, int rx,int ry,int w,int h);
|
|---|
| 242 |
|
|---|
| 243 | Type type() const { return Raster; }
|
|---|
| 244 |
|
|---|
| 245 | QPoint coordinateOffset() const;
|
|---|
| 246 |
|
|---|
| 247 | #if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
|
|---|
| 248 | virtual void drawColorSpans(const QSpan *spans, int count, uint color);
|
|---|
| 249 | virtual void drawBufferSpan(const uint *buffer, int bufsize,
|
|---|
| 250 | int x, int y, int length, uint const_alpha);
|
|---|
| 251 | #endif
|
|---|
| 252 |
|
|---|
| 253 | protected:
|
|---|
| 254 | QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *);
|
|---|
| 255 | private:
|
|---|
| 256 | friend struct QSpanData;
|
|---|
| 257 | void init();
|
|---|
| 258 |
|
|---|
| 259 | void fillRect(const QRectF &rect, QSpanData *data);
|
|---|
| 260 | void drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fill);
|
|---|
| 261 |
|
|---|
| 262 | void drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions,
|
|---|
| 263 | QFontEngine *fontEngine);
|
|---|
| 264 |
|
|---|
| 265 | #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
|
|---|
| 266 | void drawGlyphsS60(const QPointF &p, const QTextItemInt &ti);
|
|---|
| 267 | #endif // Q_OS_SYMBIAN && QT_NO_FREETYPE
|
|---|
| 268 |
|
|---|
| 269 | bool setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op);
|
|---|
| 270 |
|
|---|
| 271 | inline void ensureBrush(const QBrush &brush) {
|
|---|
| 272 | if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags))
|
|---|
| 273 | updateBrush(brush);
|
|---|
| 274 | }
|
|---|
| 275 | inline void ensureBrush() { ensureBrush(state()->brush); }
|
|---|
| 276 |
|
|---|
| 277 | inline void ensurePen(const QPen &pen) {
|
|---|
| 278 | if (!qpen_fast_equals(state()->lastPen, pen) || (pen.style() != Qt::NoPen && state()->strokeFlags))
|
|---|
| 279 | updatePen(pen);
|
|---|
| 280 | }
|
|---|
| 281 | inline void ensurePen() { ensurePen(state()->pen); }
|
|---|
| 282 |
|
|---|
| 283 | void updateOutlineMapper();
|
|---|
| 284 | inline void ensureOutlineMapper();
|
|---|
| 285 |
|
|---|
| 286 | void updateState();
|
|---|
| 287 | inline void ensureState() {
|
|---|
| 288 | if (state()->dirty)
|
|---|
| 289 | updateState();
|
|---|
| 290 | }
|
|---|
| 291 | };
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 | /*******************************************************************************
|
|---|
| 295 | * QRasterPaintEnginePrivate
|
|---|
| 296 | */
|
|---|
| 297 | class
|
|---|
| 298 | #ifdef Q_WS_QWS
|
|---|
| 299 | Q_GUI_EXPORT
|
|---|
| 300 | #endif
|
|---|
| 301 | QRasterPaintEnginePrivate : public QPaintEngineExPrivate
|
|---|
| 302 | {
|
|---|
| 303 | Q_DECLARE_PUBLIC(QRasterPaintEngine)
|
|---|
| 304 | public:
|
|---|
| 305 | QRasterPaintEnginePrivate();
|
|---|
| 306 |
|
|---|
| 307 | void rasterizeLine_dashed(QLineF line, qreal width,
|
|---|
| 308 | int *dashIndex, qreal *dashOffset, bool *inDash);
|
|---|
| 309 | void rasterize(QT_FT_Outline *outline, ProcessSpans callback, QSpanData *spanData, QRasterBuffer *rasterBuffer);
|
|---|
| 310 | void rasterize(QT_FT_Outline *outline, ProcessSpans callback, void *userData, QRasterBuffer *rasterBuffer);
|
|---|
| 311 | void updateMatrixData(QSpanData *spanData, const QBrush &brush, const QTransform &brushMatrix);
|
|---|
| 312 |
|
|---|
| 313 | void systemStateChanged();
|
|---|
| 314 |
|
|---|
| 315 | void drawImage(const QPointF &pt, const QImage &img, SrcOverBlendFunc func,
|
|---|
| 316 | const QRect &clip, int alpha, const QRect &sr = QRect());
|
|---|
| 317 |
|
|---|
| 318 | QTransform brushMatrix() const {
|
|---|
| 319 | Q_Q(const QRasterPaintEngine);
|
|---|
| 320 | const QRasterPaintEngineState *s = q->state();
|
|---|
| 321 | QTransform m(s->matrix);
|
|---|
| 322 | m.translate(s->brushOrigin.x(), s->brushOrigin.y());
|
|---|
| 323 | return m;
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | bool isUnclipped_normalized(const QRect &rect) const;
|
|---|
| 327 | bool isUnclipped(const QRect &rect, int penWidth) const;
|
|---|
| 328 | bool isUnclipped(const QRectF &rect, int penWidth) const;
|
|---|
| 329 | ProcessSpans getPenFunc(const QRect &rect, const QSpanData *data) const;
|
|---|
| 330 | ProcessSpans getPenFunc(const QRectF &rect, const QSpanData *data) const;
|
|---|
| 331 | ProcessSpans getBrushFunc(const QRect &rect, const QSpanData *data) const;
|
|---|
| 332 | ProcessSpans getBrushFunc(const QRectF &rect, const QSpanData *data) const;
|
|---|
| 333 |
|
|---|
| 334 | #ifdef Q_WS_QWS
|
|---|
| 335 | void prepare(QCustomRasterPaintDevice *);
|
|---|
| 336 | #endif
|
|---|
| 337 |
|
|---|
| 338 | inline const QClipData *clip() const;
|
|---|
| 339 |
|
|---|
| 340 | void initializeRasterizer(QSpanData *data);
|
|---|
| 341 |
|
|---|
| 342 | void recalculateFastImages();
|
|---|
| 343 |
|
|---|
| 344 | QPaintDevice *device;
|
|---|
| 345 | QScopedPointer<QOutlineMapper> outlineMapper;
|
|---|
| 346 | QScopedPointer<QRasterBuffer> rasterBuffer;
|
|---|
| 347 |
|
|---|
| 348 | #if defined (Q_WS_WIN)
|
|---|
| 349 | HDC hdc;
|
|---|
| 350 | #elif defined(Q_WS_MAC)
|
|---|
| 351 | CGContextRef cgContext;
|
|---|
| 352 | #endif
|
|---|
| 353 |
|
|---|
| 354 | QRect deviceRect;
|
|---|
| 355 |
|
|---|
| 356 | QStroker basicStroker;
|
|---|
| 357 | QScopedPointer<QDashStroker> dashStroker;
|
|---|
| 358 |
|
|---|
| 359 | QScopedPointer<QT_FT_Raster> grayRaster;
|
|---|
| 360 |
|
|---|
| 361 | QDataBuffer<QLineF> cachedLines;
|
|---|
| 362 | QSpanData image_filler;
|
|---|
| 363 | QSpanData image_filler_xform;
|
|---|
| 364 | QSpanData solid_color_filler;
|
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 | QFontEngineGlyphCache::Type glyphCacheType;
|
|---|
| 368 |
|
|---|
| 369 | QScopedPointer<QClipData> baseClip;
|
|---|
| 370 |
|
|---|
| 371 | int deviceDepth;
|
|---|
| 372 |
|
|---|
| 373 | uint mono_surface : 1;
|
|---|
| 374 | uint outlinemapper_xform_dirty : 1;
|
|---|
| 375 |
|
|---|
| 376 | #ifdef Q_WS_WIN
|
|---|
| 377 | uint isPlain45DegreeRotation : 1;
|
|---|
| 378 | #endif
|
|---|
| 379 |
|
|---|
| 380 | QScopedPointer<QRasterizer> rasterizer;
|
|---|
| 381 | };
|
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 | class
|
|---|
| 385 | #ifdef Q_WS_QWS
|
|---|
| 386 | Q_GUI_EXPORT
|
|---|
| 387 | #endif
|
|---|
| 388 | QClipData {
|
|---|
| 389 | public:
|
|---|
| 390 | QClipData(int height);
|
|---|
| 391 | ~QClipData();
|
|---|
| 392 |
|
|---|
| 393 | int clipSpanHeight;
|
|---|
| 394 | struct ClipLine {
|
|---|
| 395 | int count;
|
|---|
| 396 | QSpan *spans;
|
|---|
| 397 | } *m_clipLines;
|
|---|
| 398 |
|
|---|
| 399 | void initialize();
|
|---|
| 400 |
|
|---|
| 401 | inline ClipLine *clipLines() {
|
|---|
| 402 | if (!m_clipLines)
|
|---|
| 403 | initialize();
|
|---|
| 404 | return m_clipLines;
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | inline QSpan *spans() {
|
|---|
| 408 | if (!m_spans)
|
|---|
| 409 | initialize();
|
|---|
| 410 | return m_spans;
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | int allocated;
|
|---|
| 414 | int count;
|
|---|
| 415 | QSpan *m_spans;
|
|---|
| 416 | int xmin, xmax, ymin, ymax;
|
|---|
| 417 |
|
|---|
| 418 | QRect clipRect;
|
|---|
| 419 | QRegion clipRegion;
|
|---|
| 420 |
|
|---|
| 421 | uint enabled : 1;
|
|---|
| 422 | uint hasRectClip : 1;
|
|---|
| 423 | uint hasRegionClip : 1;
|
|---|
| 424 |
|
|---|
| 425 | void appendSpan(int x, int length, int y, int coverage);
|
|---|
| 426 | void appendSpans(const QSpan *s, int num);
|
|---|
| 427 |
|
|---|
| 428 | // ### Should optimize and actually kill the QSpans if the rect is
|
|---|
| 429 | // ### a subset of The current region. Thus the "fast" clipspan
|
|---|
| 430 | // ### callback can be used
|
|---|
| 431 | void setClipRect(const QRect &rect);
|
|---|
| 432 | void setClipRegion(const QRegion ®ion);
|
|---|
| 433 | void fixup();
|
|---|
| 434 | };
|
|---|
| 435 |
|
|---|
| 436 | inline void QClipData::appendSpan(int x, int length, int y, int coverage)
|
|---|
| 437 | {
|
|---|
| 438 | Q_ASSERT(m_spans); // initialize() has to be called prior to adding spans..
|
|---|
| 439 |
|
|---|
| 440 | if (count == allocated) {
|
|---|
| 441 | allocated *= 2;
|
|---|
| 442 | m_spans = (QSpan *)realloc(m_spans, allocated*sizeof(QSpan));
|
|---|
| 443 | }
|
|---|
| 444 | m_spans[count].x = x;
|
|---|
| 445 | m_spans[count].len = length;
|
|---|
| 446 | m_spans[count].y = y;
|
|---|
| 447 | m_spans[count].coverage = coverage;
|
|---|
| 448 | ++count;
|
|---|
| 449 | }
|
|---|
| 450 |
|
|---|
| 451 | inline void QClipData::appendSpans(const QSpan *s, int num)
|
|---|
| 452 | {
|
|---|
| 453 | Q_ASSERT(m_spans);
|
|---|
| 454 |
|
|---|
| 455 | if (count + num > allocated) {
|
|---|
| 456 | do {
|
|---|
| 457 | allocated *= 2;
|
|---|
| 458 | } while (count + num > allocated);
|
|---|
| 459 | m_spans = (QSpan *)realloc(m_spans, allocated*sizeof(QSpan));
|
|---|
| 460 | }
|
|---|
| 461 | memcpy(m_spans+count, s, num*sizeof(QSpan));
|
|---|
| 462 | count += num;
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | #ifdef Q_WS_QWS
|
|---|
| 466 | class Q_GUI_EXPORT QCustomRasterPaintDevice : public QPaintDevice
|
|---|
| 467 | {
|
|---|
| 468 | public:
|
|---|
| 469 | QCustomRasterPaintDevice(QWidget *w) : widget(w) {}
|
|---|
| 470 |
|
|---|
| 471 | int devType() const { return QInternal::CustomRaster; }
|
|---|
| 472 |
|
|---|
| 473 | virtual int metric(PaintDeviceMetric m) const;
|
|---|
| 474 |
|
|---|
| 475 | virtual void* memory() const { return 0; }
|
|---|
| 476 |
|
|---|
| 477 | virtual QImage::Format format() const {
|
|---|
| 478 | return QImage::Format_ARGB32_Premultiplied;
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| 481 | virtual int bytesPerLine() const;
|
|---|
| 482 |
|
|---|
| 483 | virtual QSize size() const {
|
|---|
| 484 | return static_cast<QRasterPaintEngine*>(paintEngine())->size();
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | private:
|
|---|
| 488 | QWidget *widget;
|
|---|
| 489 | };
|
|---|
| 490 | #endif // Q_WS_QWS
|
|---|
| 491 |
|
|---|
| 492 | /*******************************************************************************
|
|---|
| 493 | * QRasterBuffer
|
|---|
| 494 | */
|
|---|
| 495 | class
|
|---|
| 496 | #ifdef Q_WS_QWS
|
|---|
| 497 | Q_GUI_EXPORT
|
|---|
| 498 | #endif
|
|---|
| 499 | QRasterBuffer
|
|---|
| 500 | {
|
|---|
| 501 | public:
|
|---|
| 502 | QRasterBuffer() : m_width(0), m_height(0), m_buffer(0) { init(); }
|
|---|
| 503 |
|
|---|
| 504 | ~QRasterBuffer();
|
|---|
| 505 |
|
|---|
| 506 | void init();
|
|---|
| 507 |
|
|---|
| 508 | QImage::Format prepare(QImage *image);
|
|---|
| 509 | QImage::Format prepare(QPixmap *pix);
|
|---|
| 510 | #ifdef Q_WS_QWS
|
|---|
| 511 | void prepare(QCustomRasterPaintDevice *device);
|
|---|
| 512 | #endif
|
|---|
| 513 | void prepare(int w, int h);
|
|---|
| 514 | void prepareBuffer(int w, int h);
|
|---|
| 515 |
|
|---|
| 516 | void resetBuffer(int val=0);
|
|---|
| 517 |
|
|---|
| 518 | uchar *scanLine(int y) { Q_ASSERT(y>=0); Q_ASSERT(y<m_height); return m_buffer + y * bytes_per_line; }
|
|---|
| 519 |
|
|---|
| 520 | #ifndef QT_NO_DEBUG
|
|---|
| 521 | QImage bufferImage() const;
|
|---|
| 522 | #endif
|
|---|
| 523 |
|
|---|
| 524 | void flushToARGBImage(QImage *image) const;
|
|---|
| 525 |
|
|---|
| 526 | int width() const { return m_width; }
|
|---|
| 527 | int height() const { return m_height; }
|
|---|
| 528 | int bytesPerLine() const { return bytes_per_line; }
|
|---|
| 529 | int bytesPerPixel() const { return bytes_per_pixel; }
|
|---|
| 530 |
|
|---|
| 531 | uchar *buffer() const { return m_buffer; }
|
|---|
| 532 |
|
|---|
| 533 | bool monoDestinationWithClut;
|
|---|
| 534 | QRgb destColor0;
|
|---|
| 535 | QRgb destColor1;
|
|---|
| 536 |
|
|---|
| 537 | QPainter::CompositionMode compositionMode;
|
|---|
| 538 | QImage::Format format;
|
|---|
| 539 | DrawHelper *drawHelper;
|
|---|
| 540 | QImage colorizeBitmap(const QImage &image, const QColor &color);
|
|---|
| 541 |
|
|---|
| 542 | private:
|
|---|
| 543 | int m_width;
|
|---|
| 544 | int m_height;
|
|---|
| 545 | int bytes_per_line;
|
|---|
| 546 | int bytes_per_pixel;
|
|---|
| 547 | uchar *m_buffer;
|
|---|
| 548 | };
|
|---|
| 549 |
|
|---|
| 550 | inline void QRasterPaintEngine::ensureOutlineMapper() {
|
|---|
| 551 | if (d_func()->outlinemapper_xform_dirty)
|
|---|
| 552 | updateOutlineMapper();
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 | inline const QClipData *QRasterPaintEnginePrivate::clip() const {
|
|---|
| 556 | Q_Q(const QRasterPaintEngine);
|
|---|
| 557 | if (q->state() && q->state()->clip && q->state()->clip->enabled)
|
|---|
| 558 | return q->state()->clip;
|
|---|
| 559 | return baseClip.data();
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 |
|
|---|
| 563 | QT_END_NAMESPACE
|
|---|
| 564 | #endif // QPAINTENGINE_RASTER_P_H
|
|---|