Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:08:14

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QPAINTENGINE_H
0005 #define QPAINTENGINE_H
0006 
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtCore/qnamespace.h>
0009 #include <QtCore/qobjectdefs.h>
0010 #include <QtCore/qscopedpointer.h>
0011 #include <QtGui/qpainter.h>
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 
0016 class QFontEngine;
0017 class QLineF;
0018 class QPaintDevice;
0019 class QPaintEnginePrivate;
0020 class QPainterPath;
0021 class QPointF;
0022 class QPolygonF;
0023 class QRectF;
0024 struct QGlyphLayout;
0025 class QTextItemInt;
0026 class QPaintEngineState;
0027 
0028 class Q_GUI_EXPORT QTextItem {
0029 public:
0030     enum RenderFlag {
0031         RightToLeft = 0x1,
0032         Overline = 0x10,
0033         Underline = 0x20,
0034         StrikeOut = 0x40,
0035 
0036         Dummy = 0xffffffff
0037     };
0038     Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
0039     qreal descent() const;
0040     qreal ascent() const;
0041     qreal width() const;
0042 
0043     RenderFlags renderFlags() const;
0044     QString text() const;
0045     QFont font() const;
0046 };
0047 Q_DECLARE_TYPEINFO(QTextItem, Q_PRIMITIVE_TYPE);
0048 
0049 
0050 class Q_GUI_EXPORT QPaintEngine
0051 {
0052     Q_DECLARE_PRIVATE(QPaintEngine)
0053 public:
0054     enum PaintEngineFeature {
0055         PrimitiveTransform          = 0x00000001, // Can transform primitives brushes
0056         PatternTransform            = 0x00000002, // Can transform pattern brushes
0057         PixmapTransform             = 0x00000004, // Can transform pixmaps
0058         PatternBrush                = 0x00000008, // Can fill with pixmaps and standard patterns
0059         LinearGradientFill          = 0x00000010, // Can fill gradient areas
0060         RadialGradientFill          = 0x00000020, // Can render radial gradients
0061         ConicalGradientFill         = 0x00000040, // Can render conical gradients
0062         AlphaBlend                  = 0x00000080, // Can do source over alpha blend
0063         PorterDuff                  = 0x00000100, // Can do general porter duff compositions
0064         PainterPaths                = 0x00000200, // Can fill, outline and clip paths
0065         Antialiasing                = 0x00000400, // Can antialias lines
0066         BrushStroke                 = 0x00000800, // Can render brush based pens
0067         ConstantOpacity             = 0x00001000, // Can render at constant opacity
0068         MaskedBrush                 = 0x00002000, // Can fill with textures that has an alpha channel or mask
0069         PerspectiveTransform        = 0x00004000, // Can do perspective transformations
0070         BlendModes                  = 0x00008000, // Can do extended Porter&Duff composition
0071         ObjectBoundingModeGradients = 0x00010000, // Can do object bounding mode gradients
0072         RasterOpModes               = 0x00020000, // Can do logical raster operations
0073         PaintOutsidePaintEvent      = 0x20000000, // Engine is capable of painting outside paint events
0074         /*                          0x10000000, // Used for emulating
0075                                     QGradient::StretchToDevice,
0076                                     defined in qpainter.cpp
0077 
0078                                     0x40000000, // Used internally for emulating opaque backgrounds
0079         */
0080 
0081         AllFeatures               = 0xffffffff  // For convenience
0082     };
0083     Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)
0084 
0085     enum DirtyFlag {
0086         DirtyPen                = 0x0001,
0087         DirtyBrush              = 0x0002,
0088         DirtyBrushOrigin        = 0x0004,
0089         DirtyFont               = 0x0008,
0090         DirtyBackground         = 0x0010,
0091         DirtyBackgroundMode     = 0x0020,
0092         DirtyTransform          = 0x0040,
0093         DirtyClipRegion         = 0x0080,
0094         DirtyClipPath           = 0x0100,
0095         DirtyHints              = 0x0200,
0096         DirtyCompositionMode    = 0x0400,
0097         DirtyClipEnabled        = 0x0800,
0098         DirtyOpacity            = 0x1000,
0099 
0100         AllDirty                = 0xffff
0101     };
0102     Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)
0103 
0104     enum PolygonDrawMode {
0105         OddEvenMode,
0106         WindingMode,
0107         ConvexMode,
0108         PolylineMode
0109     };
0110 
0111     explicit QPaintEngine(PaintEngineFeatures features=PaintEngineFeatures());
0112     virtual ~QPaintEngine();
0113 
0114     bool isActive() const { return active; }
0115     void setActive(bool newState) { active = newState; }
0116 
0117     virtual bool begin(QPaintDevice *pdev) = 0;
0118     virtual bool end() = 0;
0119 
0120     virtual void updateState(const QPaintEngineState &state) = 0;
0121 
0122     virtual void drawRects(const QRect *rects, int rectCount);
0123     virtual void drawRects(const QRectF *rects, int rectCount);
0124 
0125     virtual void drawLines(const QLine *lines, int lineCount);
0126     virtual void drawLines(const QLineF *lines, int lineCount);
0127 
0128     virtual void drawEllipse(const QRectF &r);
0129     virtual void drawEllipse(const QRect &r);
0130 
0131     virtual void drawPath(const QPainterPath &path);
0132 
0133     virtual void drawPoints(const QPointF *points, int pointCount);
0134     virtual void drawPoints(const QPoint *points, int pointCount);
0135 
0136     virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
0137     virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
0138 
0139     virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) = 0;
0140     virtual void drawTextItem(const QPointF &p, const QTextItem &textItem);
0141     virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
0142     virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
0143                            Qt::ImageConversionFlags flags = Qt::AutoColor);
0144 
0145     void setPaintDevice(QPaintDevice *device);
0146     QPaintDevice *paintDevice() const;
0147 
0148     void setSystemClip(const QRegion &baseClip);
0149     QRegion systemClip() const;
0150 
0151     void setSystemRect(const QRect &rect);
0152     QRect systemRect() const;
0153 
0154 
0155     virtual QPoint coordinateOffset() const;
0156 
0157     enum Type {
0158         X11,
0159         Windows,
0160         QuickDraw, CoreGraphics, MacPrinter,
0161         QWindowSystem,
0162         OpenGL,
0163         Picture,
0164         SVG,
0165         Raster,
0166         Direct3D,
0167         Pdf,
0168         OpenVG,
0169         OpenGL2,
0170         PaintBuffer,
0171         Blitter,
0172         Direct2D,
0173 
0174         User = 50,    // first user type id
0175         MaxUser = 100 // last user type id
0176     };
0177     virtual Type type() const = 0;
0178 
0179     inline void fix_neg_rect(int *x, int *y, int *w, int *h);
0180 
0181     inline bool testDirty(DirtyFlags df);
0182     inline void setDirty(DirtyFlags df);
0183     inline void clearDirty(DirtyFlags df);
0184 
0185     bool hasFeature(PaintEngineFeatures feature) const { return bool(gccaps & feature); }
0186 
0187     QPainter *painter() const;
0188 
0189     void syncState();
0190     inline bool isExtended() const { return extended; }
0191 
0192     virtual QPixmap createPixmap(QSize size);
0193     virtual QPixmap createPixmapFromImage(QImage image, Qt::ImageConversionFlags flags = Qt::AutoColor);
0194 
0195 protected:
0196     QPaintEngine(QPaintEnginePrivate &data, PaintEngineFeatures devcaps=PaintEngineFeatures());
0197 
0198     QPaintEngineState *state;
0199     PaintEngineFeatures gccaps;
0200 
0201     uint active : 1;
0202     uint selfDestruct : 1;
0203     uint extended : 1;
0204 
0205     QScopedPointer<QPaintEnginePrivate> d_ptr;
0206 
0207 private:
0208     void setAutoDestruct(bool autoDestr) { selfDestruct = autoDestr; }
0209     bool autoDestruct() const { return selfDestruct; }
0210     Q_DISABLE_COPY(QPaintEngine)
0211 
0212     friend class QPainterReplayer;
0213     friend class QFontEngineBox;
0214     friend class QFontEngineMac;
0215     friend class QFontEngineWin;
0216     friend class QMacPrintEngine;
0217     friend class QMacPrintEnginePrivate;
0218     friend class QFontEngineQPF2;
0219     friend class QPainter;
0220     friend class QPainterPrivate;
0221     friend class QWidget;
0222     friend class QWidgetPrivate;
0223     friend class QWin32PaintEngine;
0224     friend class QWin32PaintEnginePrivate;
0225     friend class QMacCGContext;
0226     friend class QPreviewPaintEngine;
0227     friend class QX11GLPlatformPixmap;
0228 };
0229 
0230 
0231 class Q_GUI_EXPORT QPaintEngineState
0232 {
0233 public:
0234     QPaintEngine::DirtyFlags state() const { return dirtyFlags; }
0235 
0236     QPen pen() const;
0237     QBrush brush() const;
0238     QPointF brushOrigin() const;
0239     QBrush backgroundBrush() const;
0240     Qt::BGMode backgroundMode() const;
0241     QFont font() const;
0242     QTransform transform() const;
0243 
0244     Qt::ClipOperation clipOperation() const;
0245     QRegion clipRegion() const;
0246     QPainterPath clipPath() const;
0247     bool isClipEnabled() const;
0248 
0249     QPainter::RenderHints renderHints() const;
0250     QPainter::CompositionMode compositionMode() const;
0251     qreal opacity() const;
0252 
0253     QPainter *painter() const;
0254 
0255     bool brushNeedsResolving() const;
0256     bool penNeedsResolving() const;
0257 
0258 protected:
0259     friend class QPaintEngine;
0260     friend class QRasterPaintEngine;
0261     friend class QWidget;
0262     friend class QPainter;
0263     friend class QPainterPrivate;
0264     friend class QMacPrintEnginePrivate;
0265 
0266     QPaintEngine::DirtyFlags dirtyFlags;
0267 };
0268 
0269 //
0270 // inline functions
0271 //
0272 
0273 inline void QPaintEngine::fix_neg_rect(int *x, int *y, int *w, int *h)
0274 {
0275     if (*w < 0) {
0276         *w = -*w;
0277         *x -= *w - 1;
0278     }
0279     if (*h < 0) {
0280         *h = -*h;
0281         *y -= *h - 1;
0282     }
0283 }
0284 
0285 inline bool QPaintEngine::testDirty(DirtyFlags df) {
0286     Q_ASSERT(state);
0287     return bool(state->dirtyFlags & df);
0288 }
0289 
0290 inline void QPaintEngine::setDirty(DirtyFlags df) {
0291     Q_ASSERT(state);
0292     state->dirtyFlags |= df;
0293 }
0294 
0295 inline void QPaintEngine::clearDirty(DirtyFlags df)
0296 {
0297     Q_ASSERT(state);
0298     state->dirtyFlags &= ~df;
0299 }
0300 
0301 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextItem::RenderFlags)
0302 Q_DECLARE_OPERATORS_FOR_FLAGS(QPaintEngine::PaintEngineFeatures)
0303 Q_DECLARE_OPERATORS_FOR_FLAGS(QPaintEngine::DirtyFlags)
0304 
0305 QT_END_NAMESPACE
0306 
0307 #endif // QPAINTENGINE_H