| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
#ifndef QPAINTENGINE_H |
| 41 |
#define QPAINTENGINE_H |
| 42 |
|
| 43 |
#include <QtGui/qtguiglobal.h> |
| 44 |
#include <QtCore/qnamespace.h> |
| 45 |
#include <QtCore/qobjectdefs.h> |
| 46 |
#include <QtCore/qscopedpointer.h> |
| 47 |
#include <QtGui/qpainter.h> |
| 48 |
|
| 49 |
QT_BEGIN_NAMESPACE |
| 50 |
|
| 51 |
|
| 52 |
class QFontEngine; |
| 53 |
class QLineF; |
| 54 |
class QPaintDevice; |
| 55 |
class QPaintEnginePrivate; |
| 56 |
class QPainterPath; |
| 57 |
class QPointF; |
| 58 |
class QPolygonF; |
| 59 |
class QRectF; |
| 60 |
struct QGlyphLayout; |
| 61 |
class QTextItemInt; |
| 62 |
class QPaintEngineState; |
| 63 |
|
| 64 |
class Q_GUI_EXPORT QTextItem { |
| 65 |
public: |
| 66 |
enum RenderFlag { |
| 67 |
RightToLeft = 0x1, |
| 68 |
Overline = 0x10, |
| 69 |
Underline = 0x20, |
| 70 |
StrikeOut = 0x40, |
| 71 |
|
| 72 |
Dummy = 0xffffffff |
| 73 |
}; |
| 74 |
Q_DECLARE_FLAGS(RenderFlags, RenderFlag) |
| 75 |
qreal descent() const; |
| 76 |
qreal ascent() const; |
| 77 |
qreal width() const; |
| 78 |
|
| 79 |
RenderFlags renderFlags() const; |
| 80 |
QString text() const; |
| 81 |
QFont font() const; |
| 82 |
}; |
| 83 |
Q_DECLARE_TYPEINFO(QTextItem, Q_PRIMITIVE_TYPE); |
| 84 |
|
| 85 |
|
| 86 |
class Q_GUI_EXPORT QPaintEngine |
| 87 |
{ |
| 88 |
Q_DECLARE_PRIVATE(QPaintEngine) |
| 89 |
public: |
| 90 |
enum PaintEngineFeature { |
| 91 |
PrimitiveTransform = 0x00000001, |
| 92 |
PatternTransform = 0x00000002, |
| 93 |
PixmapTransform = 0x00000004, |
| 94 |
PatternBrush = 0x00000008, |
| 95 |
LinearGradientFill = 0x00000010, |
| 96 |
RadialGradientFill = 0x00000020, |
| 97 |
ConicalGradientFill = 0x00000040, |
| 98 |
AlphaBlend = 0x00000080, |
| 99 |
PorterDuff = 0x00000100, |
| 100 |
PainterPaths = 0x00000200, |
| 101 |
Antialiasing = 0x00000400, |
| 102 |
BrushStroke = 0x00000800, |
| 103 |
ConstantOpacity = 0x00001000, |
| 104 |
MaskedBrush = 0x00002000, |
| 105 |
PerspectiveTransform = 0x00004000, |
| 106 |
BlendModes = 0x00008000, |
| 107 |
ObjectBoundingModeGradients = 0x00010000, |
| 108 |
RasterOpModes = 0x00020000, |
| 109 |
PaintOutsidePaintEvent = 0x20000000, |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
AllFeatures = 0xffffffff |
| 118 |
}; |
| 119 |
Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature) |
| 120 |
|
| 121 |
enum DirtyFlag { |
| 122 |
DirtyPen = 0x0001, |
| 123 |
DirtyBrush = 0x0002, |
| 124 |
DirtyBrushOrigin = 0x0004, |
| 125 |
DirtyFont = 0x0008, |
| 126 |
DirtyBackground = 0x0010, |
| 127 |
DirtyBackgroundMode = 0x0020, |
| 128 |
DirtyTransform = 0x0040, |
| 129 |
DirtyClipRegion = 0x0080, |
| 130 |
DirtyClipPath = 0x0100, |
| 131 |
DirtyHints = 0x0200, |
| 132 |
DirtyCompositionMode = 0x0400, |
| 133 |
DirtyClipEnabled = 0x0800, |
| 134 |
DirtyOpacity = 0x1000, |
| 135 |
|
| 136 |
AllDirty = 0xffff |
| 137 |
}; |
| 138 |
Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag) |
| 139 |
|
| 140 |
enum PolygonDrawMode { |
| 141 |
OddEvenMode, |
| 142 |
WindingMode, |
| 143 |
ConvexMode, |
| 144 |
PolylineMode |
| 145 |
}; |
| 146 |
|
| 147 |
explicit QPaintEngine(PaintEngineFeatures features=PaintEngineFeatures()); |
| 148 |
virtual ~QPaintEngine(); |
| 149 |
|
| 150 |
bool isActive() const { return active; } |
| 151 |
void setActive(bool newState) { active = newState; } |
| 152 |
|
| 153 |
virtual bool begin(QPaintDevice *pdev) = 0; |
| 154 |
virtual bool end() = 0; |
| 155 |
|
| 156 |
virtual void updateState(const QPaintEngineState &state) = 0; |
| 157 |
|
| 158 |
virtual void drawRects(const QRect *rects, int rectCount); |
| 159 |
virtual void drawRects(const QRectF *rects, int rectCount); |
| 160 |
|
| 161 |
virtual void drawLines(const QLine *lines, int lineCount); |
| 162 |
virtual void drawLines(const QLineF *lines, int lineCount); |
| 163 |
|
| 164 |
virtual void drawEllipse(const QRectF &r); |
| 165 |
virtual void drawEllipse(const QRect &r); |
| 166 |
|
| 167 |
virtual void drawPath(const QPainterPath &path); |
| 168 |
|
| 169 |
virtual void drawPoints(const QPointF *points, int pointCount); |
| 170 |
virtual void drawPoints(const QPoint *points, int pointCount); |
| 171 |
|
| 172 |
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode); |
| 173 |
virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode); |
| 174 |
|
| 175 |
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) = 0; |
| 176 |
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem); |
| 177 |
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s); |
| 178 |
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, |
| 179 |
Qt::ImageConversionFlags flags = Qt::AutoColor); |
| 180 |
|
| 181 |
void setPaintDevice(QPaintDevice *device); |
| 182 |
QPaintDevice *paintDevice() const; |
| 183 |
|
| 184 |
void setSystemClip(const QRegion &baseClip); |
| 185 |
QRegion systemClip() const; |
| 186 |
|
| 187 |
void setSystemRect(const QRect &rect); |
| 188 |
QRect systemRect() const; |
| 189 |
|
| 190 |
|
| 191 |
virtual QPoint coordinateOffset() const; |
| 192 |
|
| 193 |
enum Type { |
| 194 |
X11, |
| 195 |
Windows, |
| 196 |
QuickDraw, CoreGraphics, MacPrinter, |
| 197 |
QWindowSystem, |
| 198 |
PostScript, |
| 199 |
OpenGL, |
| 200 |
Picture, |
| 201 |
SVG, |
| 202 |
Raster, |
| 203 |
Direct3D, |
| 204 |
Pdf, |
| 205 |
OpenVG, |
| 206 |
OpenGL2, |
| 207 |
PaintBuffer, |
| 208 |
Blitter, |
| 209 |
Direct2D, |
| 210 |
|
| 211 |
User = 50, |
| 212 |
MaxUser = 100 |
| 213 |
}; |
| 214 |
virtual Type type() const = 0; |
| 215 |
|
| 216 |
inline void fix_neg_rect(int *x, int *y, int *w, int *h); |
| 217 |
|
| 218 |
inline bool testDirty(DirtyFlags df); |
| 219 |
inline void setDirty(DirtyFlags df); |
| 220 |
inline void clearDirty(DirtyFlags df); |
| 221 |
|
| 222 |
bool hasFeature(PaintEngineFeatures feature) const { return gccaps & feature; } |
| 223 |
|
| 224 |
QPainter *painter() const; |
| 225 |
|
| 226 |
void syncState(); |
| 227 |
inline bool isExtended() const { return extended; } |
| 228 |
|
| 229 |
protected: |
| 230 |
QPaintEngine(QPaintEnginePrivate &data, PaintEngineFeatures devcaps=PaintEngineFeatures()); |
| 231 |
|
| 232 |
QPaintEngineState *state; |
| 233 |
PaintEngineFeatures gccaps; |
| 234 |
|
| 235 |
uint active : 1; |
| 236 |
uint selfDestruct : 1; |
| 237 |
uint extended : 1; |
| 238 |
|
| 239 |
QScopedPointer<QPaintEnginePrivate> d_ptr; |
| 240 |
|
| 241 |
private: |
| 242 |
void setAutoDestruct(bool autoDestr) { selfDestruct = autoDestr; } |
| 243 |
bool autoDestruct() const { return selfDestruct; } |
| 244 |
Q_DISABLE_COPY(QPaintEngine) |
| 245 |
|
| 246 |
friend class QPainterReplayer; |
| 247 |
friend class QFontEngineBox; |
| 248 |
friend class QFontEngineMac; |
| 249 |
friend class QFontEngineWin; |
| 250 |
friend class QMacPrintEngine; |
| 251 |
friend class QMacPrintEnginePrivate; |
| 252 |
friend class QFontEngineQPF2; |
| 253 |
friend class QPainter; |
| 254 |
friend class QPainterPrivate; |
| 255 |
friend class QWidget; |
| 256 |
friend class QWidgetPrivate; |
| 257 |
friend class QWin32PaintEngine; |
| 258 |
friend class QWin32PaintEnginePrivate; |
| 259 |
friend class QMacCGContext; |
| 260 |
friend class QPreviewPaintEngine; |
| 261 |
friend class QX11GLPlatformPixmap; |
| 262 |
}; |
| 263 |
|
| 264 |
|
| 265 |
class Q_GUI_EXPORT QPaintEngineState |
| 266 |
{ |
| 267 |
public: |
| 268 |
QPaintEngine::DirtyFlags state() const { return dirtyFlags; } |
| 269 |
|
| 270 |
QPen pen() const; |
| 271 |
QBrush brush() const; |
| 272 |
QPointF brushOrigin() const; |
| 273 |
QBrush backgroundBrush() const; |
| 274 |
Qt::BGMode backgroundMode() const; |
| 275 |
QFont font() const; |
| 276 |
#if QT_DEPRECATED_SINCE(5, 15) |
| 277 |
QT_DEPRECATED_X("Use transform()") QMatrix matrix() const; |
| 278 |
#endif |
| 279 |
QTransform transform() const; |
| 280 |
|
| 281 |
Qt::ClipOperation clipOperation() const; |
| 282 |
QRegion clipRegion() const; |
| 283 |
QPainterPath clipPath() const; |
| 284 |
bool isClipEnabled() const; |
| 285 |
|
| 286 |
QPainter::RenderHints renderHints() const; |
| 287 |
QPainter::CompositionMode compositionMode() const; |
| 288 |
qreal opacity() const; |
| 289 |
|
| 290 |
QPainter *painter() const; |
| 291 |
|
| 292 |
bool brushNeedsResolving() const; |
| 293 |
bool penNeedsResolving() const; |
| 294 |
|
| 295 |
protected: |
| 296 |
friend class QPaintEngine; |
| 297 |
friend class QRasterPaintEngine; |
| 298 |
friend class QWidget; |
| 299 |
friend class QPainter; |
| 300 |
friend class QPainterPrivate; |
| 301 |
friend class QMacPrintEnginePrivate; |
| 302 |
|
| 303 |
QPaintEngine::DirtyFlags dirtyFlags; |
| 304 |
}; |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
inline void QPaintEngine::fix_neg_rect(int *x, int *y, int *w, int *h) |
| 311 |
{ |
| 312 |
if (*w < 0) { |
| 313 |
*w = -*w; |
| 314 |
*x -= *w - 1; |
| 315 |
} |
| 316 |
if (*h < 0) { |
| 317 |
*h = -*h; |
| 318 |
*y -= *h - 1; |
| 319 |
} |
| 320 |
} |
| 321 |
|
| 322 |
inline bool QPaintEngine::testDirty(DirtyFlags df) { |
| 323 |
Q_ASSERT(state); |
| 324 |
return state->dirtyFlags & df; |
| 325 |
} |
| 326 |
|
| 327 |
inline void QPaintEngine::setDirty(DirtyFlags df) { |
| 328 |
Q_ASSERT(state); |
| 329 |
state->dirtyFlags |= df; |
| 330 |
} |
| 331 |
|
| 332 |
inline void QPaintEngine::clearDirty(DirtyFlags df) |
| 333 |
{ |
| 334 |
Q_ASSERT(state); |
| 335 |
state->dirtyFlags &= ~static_cast<uint>(df); |
| 336 |
} |
| 337 |
|
| 338 |
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextItem::RenderFlags) |
| 339 |
Q_DECLARE_OPERATORS_FOR_FLAGS(QPaintEngine::PaintEngineFeatures) |
| 340 |
Q_DECLARE_OPERATORS_FOR_FLAGS(QPaintEngine::DirtyFlags) |
| 341 |
|
| 342 |
QT_END_NAMESPACE |
| 343 |
|
| 344 |
#endif |