Qt 4.8
Public Functions | List of all members
QGL2PaintEngineEx Class Reference

#include <qpaintengineex_opengl2_p.h>

Inheritance diagram for QGL2PaintEngineEx:
QPaintEngineEx QPaintEngine

Public Functions

bool begin (QPaintDevice *device)
 Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev. More...
 
void beginNativePainting ()
 
virtual void brushChanged ()
 
virtual void brushOriginChanged ()
 
virtual void clip (const QVectorPath &path, Qt::ClipOperation op)
 
virtual void clipEnabledChanged ()
 
virtual void compositionModeChanged ()
 
virtual QPainterStatecreateState (QPainterState *orig) const
 
virtual void drawImage (const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
 Reimplement this function to draw the part of the image specified by the sr rectangle in the given rectangle using the given conversion flags flags, to convert it to a pixmap. More...
 
virtual void drawPixmap (const QRectF &r, const QPixmap &pm, const QRectF &sr)
 Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r. More...
 
virtual void drawPixmapFragments (const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
 
virtual void drawPixmapFragments (const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
 
virtual void drawStaticTextItem (QStaticTextItem *textItem)
 
virtual void drawTextItem (const QPointF &p, const QTextItem &textItem)
 This function draws the text item textItem at position p. More...
 
bool drawTexture (const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr)
 
bool end ()
 Reimplement this function to finish painting on the current paint device. More...
 
void endNativePainting ()
 
void ensureActive ()
 
virtual void fill (const QVectorPath &path, const QBrush &brush)
 
void invalidateState ()
 
bool isNativePaintingActive () const
 
virtual void opacityChanged ()
 
virtual void penChanged ()
 
QPixmapFilterpixmapFilter (int type, const QPixmapFilter *prototype)
 
 QGL2PaintEngineEx ()
 
virtual void renderHintsChanged ()
 
void setRenderTextActive (bool)
 
virtual void setState (QPainterState *s)
 
QOpenGL2PaintEngineStatestate ()
 
const QOpenGL2PaintEngineStatestate () const
 
virtual void stroke (const QVectorPath &path, const QPen &pen)
 
bool supportsTransformations (qreal, const QTransform &) const
 
virtual void transformChanged ()
 
Type type () const
 Reimplement this function to return the paint engine Type. More...
 
 ~QGL2PaintEngineEx ()
 
- Public Functions inherited from QPaintEngineEx
virtual void clip (const QRect &rect, Qt::ClipOperation op)
 
virtual void clip (const QRegion &region, Qt::ClipOperation op)
 
virtual void clip (const QPainterPath &path, Qt::ClipOperation op)
 
virtual void draw (const QVectorPath &path)
 
virtual void drawEllipse (const QRectF &r)
 Reimplement this function to draw the largest ellipse that can be contained within rectangle rect. More...
 
virtual void drawEllipse (const QRect &r)
 The default implementation of this function calls the floating point version of this function. More...
 
virtual void drawImage (const QPointF &pos, const QImage &image)
 
virtual void drawLines (const QLine *lines, int lineCount)
 The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function. More...
 
virtual void drawLines (const QLineF *lines, int lineCount)
 The default implementation splits the list of lines in lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine. More...
 
virtual void drawPath (const QPainterPath &path)
 The default implementation ignores the path and does nothing. More...
 
virtual void drawPixmap (const QPointF &pos, const QPixmap &pm)
 
virtual void drawPoints (const QPointF *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
virtual void drawPoints (const QPoint *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
virtual void drawPolygon (const QPointF *points, int pointCount, PolygonDrawMode mode)
 Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode. More...
 
virtual void drawPolygon (const QPoint *points, int pointCount, PolygonDrawMode mode)
 Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode. More...
 
virtual void drawRects (const QRect *rects, int rectCount)
 The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF and calls the floating point version of this function. More...
 
virtual void drawRects (const QRectF *rects, int rectCount)
 Draws the first rectCount rectangles in the buffer rects. More...
 
virtual void drawRoundedRect (const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
 
virtual void drawTiledPixmap (const QRectF &r, const QPixmap &pixmap, const QPointF &s)
 Reimplement this function to draw the pixmap in the given rect, starting at the given p. More...
 
virtual void fillRect (const QRectF &rect, const QBrush &brush)
 
virtual void fillRect (const QRectF &rect, const QColor &color)
 
virtual uint flags () const
 
 QPaintEngineEx ()
 
QPainterStatestate ()
 
const QPainterStatestate () const
 
virtual void sync ()
 
virtual void updateState (const QPaintEngineState &state)
 Reimplement this function to update the state of a paint engine. More...
 
- Public Functions inherited from QPaintEngine
void clearDirty (DirtyFlags df)
 
virtual QPoint coordinateOffset () const
 Returns the offset from the painters origo to the engines origo. More...
 
void fix_neg_rect (int *x, int *y, int *w, int *h)
 
virtual HDC getDC () const
 Empty default implementation. More...
 
bool hasFeature (PaintEngineFeatures feature) const
 Returns true if the paint engine supports the specified feature; otherwise returns false. More...
 
bool isActive () const
 Returns true if the paint engine is actively drawing; otherwise returns false. More...
 
bool isExtended () const
 Returns true if the paint engine is a QPaintEngineEx derivative. More...
 
QPaintDevicepaintDevice () const
 Returns the device that this engine is painting on, if painting is active; otherwise returns 0. More...
 
QPainterpainter () const
 Returns the paint engine's painter. More...
 
 QPaintEngine (PaintEngineFeatures features=0)
 Creates a paint engine with the featureset specified by caps. More...
 
virtual void releaseDC (HDC hdc) const
 Empty default implementation. More...
 
void setActive (bool newState)
 Sets the active state of the paint engine to state. More...
 
void setDirty (DirtyFlags df)
 
void setPaintDevice (QPaintDevice *device)
 
void setSystemClip (const QRegion &baseClip)
 Sets the system clip for this engine. More...
 
void setSystemRect (const QRect &rect)
 Sets the target rect for drawing within the backing store. More...
 
void syncState ()
 Updates all dirty states in this engine. More...
 
QRegion systemClip () const
 Returns the system clip. More...
 
QRect systemRect () const
 Retrieves the rect for drawing within the backing store. More...
 
bool testDirty (DirtyFlags df)
 
virtual ~QPaintEngine ()
 Destroys the paint engine. More...
 

Additional Inherited Members

- Public Types inherited from QPaintEngineEx
enum  Flags { DoNotEmulate = 0x01, IsEmulationEngine = 0x02 }
 
- Public Types inherited from QPaintEngine
enum  DirtyFlag {
  DirtyPen = 0x0001, DirtyBrush = 0x0002, DirtyBrushOrigin = 0x0004, DirtyFont = 0x0008,
  DirtyBackground = 0x0010, DirtyBackgroundMode = 0x0020, DirtyTransform = 0x0040, DirtyClipRegion = 0x0080,
  DirtyClipPath = 0x0100, DirtyHints = 0x0200, DirtyCompositionMode = 0x0400, DirtyClipEnabled = 0x0800,
  DirtyOpacity = 0x1000, AllDirty = 0xffff
}
 QPaintEngine::updateState(). More...
 
enum  PaintEngineFeature {
  PrimitiveTransform = 0x00000001, PatternTransform = 0x00000002, PixmapTransform = 0x00000004, PatternBrush = 0x00000008,
  LinearGradientFill = 0x00000010, RadialGradientFill = 0x00000020, ConicalGradientFill = 0x00000040, AlphaBlend = 0x00000080,
  PorterDuff = 0x00000100, PainterPaths = 0x00000200, Antialiasing = 0x00000400, BrushStroke = 0x00000800,
  ConstantOpacity = 0x00001000, MaskedBrush = 0x00002000, PerspectiveTransform = 0x00004000, BlendModes = 0x00008000,
  ObjectBoundingModeGradients = 0x00010000, RasterOpModes = 0x00020000, PaintOutsidePaintEvent = 0x20000000, AllFeatures = 0xffffffff
}
 This enum is used to describe the features or capabilities that the paint engine has. More...
 
enum  PolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode }
 
enum  Type {
  X11, Windows, QuickDraw, CoreGraphics,
  MacPrinter, QWindowSystem, PostScript, OpenGL,
  Picture, SVG, Raster, Direct3D,
  Pdf, OpenVG, OpenGL2, PaintBuffer,
  Blitter, User = 50, MaxUser = 100
}
 
- Protected Functions inherited from QPaintEngineEx
 QPaintEngineEx (QPaintEngineExPrivate &data)
 
- Protected Functions inherited from QPaintEngine
 QPaintEngine (QPaintEnginePrivate &data, PaintEngineFeatures devcaps=0)
 
- Protected Variables inherited from QPaintEngine
uint active: 1
 
QScopedPointer< QPaintEnginePrivated_ptr
 
uint extended: 1
 
PaintEngineFeatures gccaps
 
uint selfDestruct: 1
 
QPaintEngineStatestate
 

Detailed Description

Definition at line 107 of file qpaintengineex_opengl2_p.h.

Constructors and Destructors

◆ QGL2PaintEngineEx()

QGL2PaintEngineEx::QGL2PaintEngineEx ( )

◆ ~QGL2PaintEngineEx()

QGL2PaintEngineEx::~QGL2PaintEngineEx ( )

Definition at line 1203 of file qpaintengineex_opengl2.cpp.

1204 {
1205 }

Functions

◆ begin()

bool QGL2PaintEngineEx::begin ( QPaintDevice pdev)
virtual

Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev.

Return true if the initialization was successful; otherwise return false.

See also
end() isActive()

Implements QPaintEngine.

Definition at line 2099 of file qpaintengineex_opengl2.cpp.

2100 {
2102 
2103 // qDebug("QGL2PaintEngineEx::begin()");
2104  if (pdev->devType() == QInternal::OpenGL)
2105  d->device = static_cast<QGLPaintDevice*>(pdev);
2106  else
2107  d->device = QGLPaintDevice::getDevice(pdev);
2108 
2109  if (!d->device)
2110  return false;
2111 
2112  d->ctx = d->device->context();
2113 #ifdef Q_OS_SYMBIAN
2114  if (!d->ctx)
2115  return false;
2116 #endif
2117  d->ctx->d_ptr->active_engine = this;
2118 
2119  const QSize sz = d->device->size();
2120  d->width = sz.width();
2121  d->height = sz.height();
2122  d->mode = BrushDrawingMode;
2123  d->imageDrawingMode = false;
2124  d->brushTextureDirty = true;
2125  d->brushUniformsDirty = true;
2126  d->matrixUniformDirty = true;
2127  d->matrixDirty = true;
2128  d->compositionModeDirty = true;
2129  d->opacityUniformDirty = true;
2130  d->needsSync = true;
2131  d->useSystemClip = !systemClip().isEmpty();
2132  d->currentBrush = QBrush();
2133 
2134  d->dirtyStencilRegion = QRect(0, 0, d->width, d->height);
2135  d->stencilClean = true;
2136 
2137  // Calling begin paint should make the correct context current. So, any
2138  // code which calls into GL or otherwise needs a current context *must*
2139  // go after beginPaint:
2140  d->device->beginPaint();
2141 
2142 #if !defined(QT_OPENGL_ES_2)
2144  d->hasCompatibilityExtension = extensions.match("GL_ARB_compatibility");
2145 
2146  bool success = qt_resolve_version_2_0_functions(d->ctx)
2150  Q_ASSERT(success);
2151  Q_UNUSED(success);
2152 #endif
2153 
2154  d->shaderManager = new QGLEngineShaderManager(d->ctx);
2155 
2156  glDisable(GL_STENCIL_TEST);
2157  glDisable(GL_DEPTH_TEST);
2158  glDisable(GL_SCISSOR_TEST);
2159 
2160 #if !defined(QT_OPENGL_ES_2)
2161  glDisable(GL_MULTISAMPLE);
2162 #endif
2163 
2164  d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
2165 
2166 #if !defined(QT_OPENGL_ES_2)
2167 #if defined(Q_WS_WIN)
2170 #endif
2171 #if defined(Q_WS_MAC)
2173 #endif
2174  d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask;
2175 #endif
2176 
2177 #if defined(QT_OPENGL_ES_2)
2178  // OpenGL ES can't switch MSAA off, so if the gl paint device is
2179  // multisampled, it's always multisampled.
2180  d->multisamplingAlwaysEnabled = d->device->format().sampleBuffers();
2181 #else
2182  d->multisamplingAlwaysEnabled = false;
2183 #endif
2184 
2185  return true;
2186 }
double d
Definition: qnumeric_p.h:62
static bool hasOpenGLFramebufferObjects()
Returns true if the OpenGL GL_EXT_framebuffer_object extension is present on this system; otherwise r...
#define GL_DEPTH_TEST
bool qt_resolve_framebufferobject_extensions(QGLContext *ctx)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define GL_STENCIL_TEST
Q_GUI_EXPORT QString extensions()
Definition: qegl.cpp:785
#define Q_D(Class)
Definition: qglobal.h:2482
virtual int devType() const
Definition: qpaintdevice.h:167
#define GL_SCISSOR_TEST
bool qt_resolve_buffer_extensions(QGLContext *ctx)
int width() const
Returns the width.
Definition: qsize.h:126
#define GL_MULTISAMPLE
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
bool qt_resolve_version_2_0_functions(QGLContext *ctx)
Q_GUI_EXPORT bool qt_cleartype_enabled
static bool fontSmoothingApproximately(qreal target)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool match(const char *str) const
Definition: qgl_p.h:906
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static QGLPaintDevice * getDevice(QPaintDevice *)
QRegion systemClip() const
Returns the system clip.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
bool qt_applefontsmoothing_enabled

◆ beginNativePainting()

void QGL2PaintEngineEx::beginNativePainting ( )
virtual

Reimplemented from QPaintEngineEx.

Definition at line 553 of file qpaintengineex_opengl2.cpp.

554 {
556  ensureActive();
557  d->transferMode(BrushDrawingMode);
558 
559  d->nativePaintingActive = true;
560 
561  QGLContext *ctx = d->ctx;
562  glUseProgram(0);
563 
564  // Disable all the vertex attribute arrays:
565  for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
567 
568 #ifndef QT_OPENGL_ES_2
569  const QGLFormat &fmt = d->device->format();
570  if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1)
571  || (fmt.majorVersion() == 3 && fmt.minorVersion() == 1 && d->hasCompatibilityExtension)
573  {
574  // be nice to people who mix OpenGL 1.x code with QPainter commands
575  // by setting modelview and projection matrices to mirror the GL 1
576  // paint engine
577  const QTransform& mtx = state()->matrix;
578 
579  float mv_matrix[4][4] =
580  {
581  { float(mtx.m11()), float(mtx.m12()), 0, float(mtx.m13()) },
582  { float(mtx.m21()), float(mtx.m22()), 0, float(mtx.m23()) },
583  { 0, 0, 1, 0 },
584  { float(mtx.dx()), float(mtx.dy()), 0, float(mtx.m33()) }
585  };
586 
587  const QSize sz = d->device->size();
588 
589  glMatrixMode(GL_PROJECTION);
590  glLoadIdentity();
591  glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999);
592 
593  glMatrixMode(GL_MODELVIEW);
594  glLoadMatrixf(&mv_matrix[0][0]);
595  }
596 #else
597  Q_UNUSED(ctx);
598 #endif
599 
600  d->lastTextureUsed = GLuint(-1);
601  d->dirtyStencilRegion = QRect(0, 0, d->width, d->height);
602  d->resetGLState();
603 
604  d->shaderManager->setDirty();
605 
606  d->needsSync = true;
607 }
double d
Definition: qnumeric_p.h:62
qreal dy() const
Returns the vertical translation factor.
Definition: qtransform.h:277
#define glUseProgram
qreal m21() const
Returns the horizontal shearing factor.
Definition: qtransform.h:249
qreal m22() const
Returns the vertical scaling factor.
Definition: qtransform.h:253
QTransform matrix
Definition: qpainter_p.h:161
int majorVersion() const
Returns the OpenGL major version.
Definition: qgl.cpp:1223
#define Q_D(Class)
Definition: qglobal.h:2482
OpenGLContextProfile profile() const
Returns the OpenGL context profile.
Definition: qgl.cpp:1286
qreal m12() const
Returns the vertical shearing factor.
Definition: qtransform.h:241
#define QT_GL_VERTEX_ARRAY_TRACKED_COUNT
Definition: qgl_p.h:343
The QGLFormat class specifies the display format of an OpenGL rendering context.
Definition: qgl.h:175
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
QOpenGL2PaintEngineState * state()
#define glDisableVertexAttribArray
int minorVersion() const
Returns the OpenGL minor version.
Definition: qgl.cpp:1238
#define ctx
Definition: qgl.cpp:6094
qreal m23() const
Returns the vertical projection factor.
Definition: qtransform.h:257
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal dx() const
Returns the horizontal translation factor.
Definition: qtransform.h:273
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
qreal m13() const
Returns the horizontal projection factor.
Definition: qtransform.h:245
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
qreal m11() const
Returns the horizontal scaling factor.
Definition: qtransform.h:237
qreal m33() const
Returns the division factor.
Definition: qtransform.h:269
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ brushChanged()

void QGL2PaintEngineEx::brushChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 1321 of file qpaintengineex_opengl2.cpp.

1321 { }

◆ brushOriginChanged()

void QGL2PaintEngineEx::brushOriginChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 1322 of file qpaintengineex_opengl2.cpp.

1322 { }

◆ clip()

void QGL2PaintEngineEx::clip ( const QVectorPath path,
Qt::ClipOperation  op 
)
virtual

Implements QPaintEngineEx.

Definition at line 2403 of file qpaintengineex_opengl2.cpp.

Referenced by QGL2PaintEngineExPrivate::stroke().

2404 {
2405 // qDebug("QGL2PaintEngineEx::clip()");
2407 
2408  state()->clipChanged = true;
2409 
2410  ensureActive();
2411 
2412  if (op == Qt::ReplaceClip) {
2413  op = Qt::IntersectClip;
2414  if (d->hasClipOperations()) {
2415  d->systemStateChanged();
2416  state()->canRestoreClip = false;
2417  }
2418  }
2419 
2420 #ifndef QT_GL_NO_SCISSOR_TEST
2421  if (!path.isEmpty() && op == Qt::IntersectClip && (path.shape() == QVectorPath::RectangleHint)) {
2422  const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());
2423  QRectF rect(points[0], points[2]);
2424 
2425  if (state()->matrix.type() <= QTransform::TxScale
2427  && qFuzzyIsNull(state()->matrix.m11())
2428  && qFuzzyIsNull(state()->matrix.m22())))
2429  {
2430  state()->rectangleClip = state()->rectangleClip.intersected(state()->matrix.mapRect(rect).toRect());
2431  d->updateClipScissorTest();
2432  return;
2433  }
2434  }
2435 #endif
2436 
2437  const QRect pathRect = state()->matrix.mapRect(path.controlPointRect()).toAlignedRect();
2438 
2439  switch (op) {
2440  case Qt::NoClip:
2441  if (d->useSystemClip) {
2442  state()->clipTestEnabled = true;
2443  state()->currentClip = 1;
2444  } else {
2445  state()->clipTestEnabled = false;
2446  }
2447  state()->rectangleClip = QRect(0, 0, d->width, d->height);
2448  state()->canRestoreClip = false;
2449  d->updateClipScissorTest();
2450  break;
2451  case Qt::IntersectClip:
2453  d->updateClipScissorTest();
2454  d->resetClipIfNeeded();
2455  ++d->maxClip;
2456  d->writeClip(path, d->maxClip);
2457  state()->currentClip = d->maxClip;
2458  state()->clipTestEnabled = true;
2459  break;
2460  case Qt::UniteClip: {
2461  d->resetClipIfNeeded();
2462  ++d->maxClip;
2463  if (state()->rectangleClip.isValid()) {
2464  QPainterPath path;
2465  path.addRect(state()->rectangleClip);
2466 
2467  // flush the existing clip rectangle to the depth buffer
2468  d->writeClip(qtVectorPathForPath(state()->matrix.inverted().map(path)), d->maxClip);
2469  }
2470 
2471  state()->clipTestEnabled = false;
2472 #ifndef QT_GL_NO_SCISSOR_TEST
2473  QRect oldRectangleClip = state()->rectangleClip;
2474 
2475  state()->rectangleClip = state()->rectangleClip.united(pathRect);
2476  d->updateClipScissorTest();
2477 
2478  QRegion extendRegion = QRegion(state()->rectangleClip) - oldRectangleClip;
2479 
2480  if (!extendRegion.isEmpty()) {
2481  QPainterPath extendPath;
2482  extendPath.addRegion(extendRegion);
2483 
2484  // first clear the depth buffer in the extended region
2485  d->writeClip(qtVectorPathForPath(state()->matrix.inverted().map(extendPath)), 0);
2486  }
2487 #endif
2488  // now write the clip path
2489  d->writeClip(path, d->maxClip);
2490  state()->canRestoreClip = false;
2491  state()->currentClip = d->maxClip;
2492  state()->clipTestEnabled = true;
2493  break;
2494  }
2495  default:
2496  break;
2497  }
2498 }
double d
Definition: qnumeric_p.h:62
void addRegion(const QRegion &region)
Adds the given region to the path by adding each rectangle in the region as a separate closed subpath...
bool isEmpty() const
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QRect united(const QRect &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: qrect.h:491
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal m22() const
Returns the vertical scaling factor.
Definition: qtransform.h:253
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
QTransform matrix
Definition: qpainter_p.h:161
TransformationType type() const
Returns the transformation type of this matrix.
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF controlPointRect() const
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QOpenGL2PaintEngineState * state()
const qreal * points() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043
Hint shape() const

◆ clipEnabledChanged()

void QGL2PaintEngineEx::clipEnabledChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2305 of file qpaintengineex_opengl2.cpp.

2306 {
2308 
2309  state()->clipChanged = true;
2310 
2311  if (painter()->hasClipping())
2312  d->regenerateClip();
2313  else
2314  d->systemStateChanged();
2315 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QPainter * painter() const
Returns the paint engine&#39;s painter.
QOpenGL2PaintEngineState * state()

◆ compositionModeChanged()

void QGL2PaintEngineEx::compositionModeChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 1335 of file qpaintengineex_opengl2.cpp.

1336 {
1337 // qDebug("QGL2PaintEngineEx::compositionModeChanged()");
1339  state()->compositionModeChanged = true;
1340  d->compositionModeDirty = true;
1341 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QOpenGL2PaintEngineState * state()

◆ createState()

QPainterState * QGL2PaintEngineEx::createState ( QPainterState orig) const
virtual

Reimplemented from QPaintEngineEx.

Definition at line 2597 of file qpaintengineex_opengl2.cpp.

2598 {
2599  if (orig)
2600  const_cast<QGL2PaintEngineEx *>(this)->ensureActive();
2601 
2603  if (!orig)
2604  s = new QOpenGL2PaintEngineState();
2605  else
2606  s = new QOpenGL2PaintEngineState(*static_cast<QOpenGL2PaintEngineState *>(orig));
2607 
2608  s->matrixChanged = false;
2609  s->compositionModeChanged = false;
2610  s->opacityChanged = false;
2611  s->renderHintsChanged = false;
2612  s->clipChanged = false;
2613 
2614  return s;
2615 }

◆ drawImage()

void QGL2PaintEngineEx::drawImage ( const QRectF r,
const QImage pm,
const QRectF sr,
Qt::ImageConversionFlags  flags = Qt::AutoColor 
)
virtual

Reimplement this function to draw the part of the image specified by the sr rectangle in the given rectangle using the given conversion flags flags, to convert it to a pixmap.

Implements QPaintEngineEx.

Definition at line 1411 of file qpaintengineex_opengl2.cpp.

1413 {
1415  QGLContext *ctx = d->ctx;
1416 
1417  int max_texture_size = ctx->d_func()->maxTextureSize();
1418  if (image.width() > max_texture_size || image.height() > max_texture_size) {
1419  QImage scaled = image.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);
1420 
1421  const qreal sx = scaled.width() / qreal(image.width());
1422  const qreal sy = scaled.height() / qreal(image.height());
1423 
1424  drawImage(dest, scaled, scaleRect(src, sx, sy));
1425  return;
1426  }
1427 
1428  ensureActive();
1429  d->transferMode(ImageDrawingMode);
1430 
1432 
1433  QGLTexture *texture = ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
1434  GLuint id = texture->id;
1435 
1436  d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
1437  state()->renderHints & QPainter::SmoothPixmapTransform, id);
1438  d->drawTexture(dest, src, image.size(), !image.hasAlphaChannel());
1439 }
double d
Definition: qnumeric_p.h:62
#define GL_CLAMP_TO_EDGE
Definition: glfunctions.h:62
double qreal
Definition: qglobal.h:1193
#define QT_IMAGE_TEXTURE_UNIT
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
#define Q_D(Class)
Definition: qglobal.h:2482
GLuint bindTexture(const QImage &image, GLenum target, GLint format, BindOptions options)
Generates and binds a 2D GL texture to the current context, based on image.
Definition: qgl.cpp:2854
static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy)
#define GL_TEXTURE_2D
#define GL_TEXTURE0
Definition: glfunctions.h:61
GLuint id
Definition: qgl_p.h:608
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QOpenGL2PaintEngineState * state()
#define glActiveTexture
Definition: glfunctions.h:69
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
#define ctx
Definition: qgl.cpp:6094
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
#define GL_RGBA
QImage scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
Definition: qimage.h:232

◆ drawPixmap()

void QGL2PaintEngineEx::drawPixmap ( const QRectF r,
const QPixmap pm,
const QRectF sr 
)
virtual

Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.

Implements QPaintEngineEx.

Definition at line 1374 of file qpaintengineex_opengl2.cpp.

1375 {
1377  QGLContext *ctx = d->ctx;
1378 
1379  int max_texture_size = ctx->d_func()->maxTextureSize();
1380  if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) {
1381  QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);
1382 
1383  const qreal sx = scaled.width() / qreal(pixmap.width());
1384  const qreal sy = scaled.height() / qreal(pixmap.height());
1385 
1386  drawPixmap(dest, scaled, scaleRect(src, sx, sy));
1387  return;
1388  }
1389 
1390  ensureActive();
1391  d->transferMode(ImageDrawingMode);
1392 
1394  QGLTexture *texture =
1395  ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA,
1398 
1399  GLfloat top = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.top()) : src.top();
1400  GLfloat bottom = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.bottom()) : src.bottom();
1401  QGLRect srcRect(src.left(), top, src.right(), bottom);
1402 
1403  bool isBitmap = pixmap.isQBitmap();
1404  bool isOpaque = !isBitmap && !pixmap.hasAlpha();
1405 
1406  d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
1407  state()->renderHints & QPainter::SmoothPixmapTransform, texture->id);
1408  d->drawTexture(dest, srcRect, pixmap.size(), isOpaque, isBitmap);
1409 }
double d
Definition: qnumeric_p.h:62
#define GL_CLAMP_TO_EDGE
Definition: glfunctions.h:62
double qreal
Definition: qglobal.h:1193
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
#define QT_IMAGE_TEXTURE_UNIT
QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
Definition: qpixmap.h:132
#define Q_D(Class)
Definition: qglobal.h:2482
GLuint bindTexture(const QImage &image, GLenum target, GLint format, BindOptions options)
Generates and binds a 2D GL texture to the current context, based on image.
Definition: qgl.cpp:2854
static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy)
QGLContext::BindOptions options
Definition: qgl_p.h:611
#define GL_TEXTURE_2D
#define GL_TEXTURE0
Definition: glfunctions.h:61
GLuint id
Definition: qgl_p.h:608
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r...
QOpenGL2PaintEngineState * state()
#define glActiveTexture
Definition: glfunctions.h:69
#define ctx
Definition: qgl.cpp:6094
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
#define GL_RGBA
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645

◆ drawPixmapFragments() [1/2]

void QGL2PaintEngineEx::drawPixmapFragments ( const QPainter::PixmapFragment fragments,
int  fragmentCount,
const QPixmap pixmap,
QPainter::PixmapFragmentHints  hints 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1895 of file qpaintengineex_opengl2.cpp.

1897 {
1899  // Use fallback for extended composition modes.
1900  if (state()->composition_mode > QPainter::CompositionMode_Plus) {
1901  QPaintEngineEx::drawPixmapFragments(fragments, fragmentCount, pixmap, hints);
1902  return;
1903  }
1904 
1905  QSize size = pixmap.size();
1906 
1907  ensureActive();
1908  int max_texture_size = d->ctx->d_func()->maxTextureSize();
1909  if (size.width() > max_texture_size || size.height() > max_texture_size) {
1910  QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);
1911  d->drawPixmapFragments(fragments, fragmentCount, scaled, size, hints);
1912  } else {
1913  d->drawPixmapFragments(fragments, fragmentCount, pixmap, size, hints);
1914  }
1915 }
double d
Definition: qnumeric_p.h:62
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
Definition: qpixmap.h:132
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
Returns the width.
Definition: qsize.h:126
QOpenGL2PaintEngineState * state()
int height() const
Returns the height.
Definition: qsize.h:129
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ drawPixmapFragments() [2/2]

void QGL2PaintEngineEx::drawPixmapFragments ( const QRectF targetRects,
const QRectF sourceRects,
int  fragmentCount,
const QPixmap pixmap,
QPainter::PixmapFragmentHints  hints 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1917 of file qpaintengineex_opengl2.cpp.

1919 {
1921  // Use fallback for extended composition modes.
1922  if (state()->composition_mode > QPainter::CompositionMode_Plus) {
1923  QPaintEngineEx::drawPixmapFragments(targetRects, sourceRects, fragmentCount, pixmap, hints);
1924  return;
1925  }
1926 
1927  QSize size = pixmap.size();
1928 
1929  ensureActive();
1930  int max_texture_size = d->ctx->d_func()->maxTextureSize();
1931  if (size.width() > max_texture_size || size.height() > max_texture_size) {
1932  QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);
1933  d->drawPixmapFragments(targetRects, sourceRects, fragmentCount, scaled, size, hints);
1934  } else {
1935  d->drawPixmapFragments(targetRects, sourceRects, fragmentCount, pixmap, size, hints);
1936  }
1937 }
double d
Definition: qnumeric_p.h:62
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
Definition: qpixmap.h:132
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
Returns the width.
Definition: qsize.h:126
QOpenGL2PaintEngineState * state()
int height() const
Returns the height.
Definition: qsize.h:129
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ drawStaticTextItem()

void QGL2PaintEngineEx::drawStaticTextItem ( QStaticTextItem textItem)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1441 of file qpaintengineex_opengl2.cpp.

1442 {
1444 
1445  ensureActive();
1446 
1447  QPainterState *s = state();
1448  float det = s->matrix.determinant();
1449 
1450  // don't try to cache huge fonts or vastly transformed fonts
1451  QFontEngine *fontEngine = textItem->fontEngine();
1452  const qreal pixelSize = fontEngine->fontDef.pixelSize;
1453  if (pixelSize * pixelSize * qAbs(det) < QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE && det >= 0.25f && det <= 4.f) {
1454  QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0
1456  : d->glyphCacheType;
1457  if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
1459  || d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate
1462  {
1464  }
1465  }
1466 
1467  d->drawCachedGlyphs(glyphType, textItem);
1468  } else {
1470  }
1471 }
double d
Definition: qnumeric_p.h:62
static bool hasOpenGLFramebufferObjects()
Returns true if the OpenGL GL_EXT_framebuffer_object extension is present on this system; otherwise r...
double qreal
Definition: qglobal.h:1193
qreal determinant() const
Returns the matrix&#39;s determinant.
Definition: qtransform.h:228
QFontEngine * fontEngine() const
QPainter::CompositionMode composition_mode
Definition: qpainter_p.h:174
QTransform matrix
Definition: qpainter_p.h:161
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
TransformationType type() const
Returns the transformation type of this matrix.
#define Q_D(Class)
Definition: qglobal.h:2482
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
#define QT_MAX_CACHED_GLYPH_SIZE
QOpenGL2PaintEngineState * state()
qreal pixelSize
Definition: qfont_p.h:90
virtual void drawStaticTextItem(QStaticTextItem *)
if(void) toggleToolbarShown
QFontDef fontDef

◆ drawTextItem()

void QGL2PaintEngineEx::drawTextItem ( const QPointF p,
const QTextItem textItem 
)
virtual

This function draws the text item textItem at position p.

The default implementation of this function converts the text to a QPainterPath and paints the resulting path.

Reimplemented from QPaintEngine.

Definition at line 1496 of file qpaintengineex_opengl2.cpp.

1497 {
1499 
1500  ensureActive();
1502 
1503  const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
1504 
1506 
1507  float det = s->matrix.determinant();
1508  bool drawCached = txtype < QTransform::TxProject;
1509 
1510  // don't try to cache huge fonts or vastly transformed fonts
1512  if (pixelSize * pixelSize * qAbs(det) >= QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE ||
1513  det < 0.25f || det > 4.f)
1514  drawCached = false;
1515 
1518  : d->glyphCacheType;
1519 
1520 
1521  if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
1523  || d->device->alphaRequested() || txtype > QTransform::TxTranslate
1526  {
1528  }
1529  }
1530 
1531  if (drawCached) {
1533  QVarLengthArray<glyph_t> glyphs;
1534  QTransform matrix = QTransform::fromTranslate(p.x(), p.y());
1535  ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
1536 
1537  {
1538  QStaticTextItem staticTextItem;
1539  staticTextItem.chars = const_cast<QChar *>(ti.chars);
1540  staticTextItem.setFontEngine(ti.fontEngine);
1541  staticTextItem.glyphs = glyphs.data();
1542  staticTextItem.numChars = ti.num_chars;
1543  staticTextItem.numGlyphs = glyphs.size();
1544  staticTextItem.glyphPositions = positions.data();
1545 
1546  d->drawCachedGlyphs(glyphType, &staticTextItem);
1547  }
1548  return;
1549  }
1550 
1552 }
double d
Definition: qnumeric_p.h:62
static bool hasOpenGLFramebufferObjects()
Returns true if the OpenGL GL_EXT_framebuffer_object extension is present on this system; otherwise r...
QFontEngine * fontEngine
double qreal
Definition: qglobal.h:1193
qreal determinant() const
Returns the matrix&#39;s determinant.
Definition: qtransform.h:228
QPainter::CompositionMode composition_mode
Definition: qpainter_p.h:174
const QChar * chars
QFixedPoint * glyphPositions
RenderFlags flags
QTransform matrix
Definition: qpainter_p.h:161
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
TransformationType type() const
Returns the transformation type of this matrix.
#define Q_D(Class)
Definition: qglobal.h:2482
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void setFontEngine(QFontEngine *fe)
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
QGlyphLayout glyphs
TransformationType
Definition: qtransform.h:68
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
Internal QTextItem.
#define QT_MAX_CACHED_GLYPH_SIZE
QOpenGL2PaintEngineState * state()
qreal pixelSize
Definition: qfont_p.h:90
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
QFontDef fontDef
int size() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
glyph_t * glyphs
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.

◆ drawTexture()

bool QGL2PaintEngineEx::drawTexture ( const QRectF r,
GLuint  textureId,
const QSize size,
const QRectF sr 
)

Definition at line 1473 of file qpaintengineex_opengl2.cpp.

Referenced by QGLPixmapDropShadowFilter::processGL().

1474 {
1476  if (!d->shaderManager)
1477  return false;
1478 
1479  ensureActive();
1480  d->transferMode(ImageDrawingMode);
1481 
1482 #ifndef QT_OPENGL_ES_2
1483  QGLContext *ctx = d->ctx;
1484 #endif
1486  glBindTexture(GL_TEXTURE_2D, textureId);
1487 
1488  QGLRect srcRect(src.left(), src.bottom(), src.right(), src.top());
1489 
1490  d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
1491  state()->renderHints & QPainter::SmoothPixmapTransform, textureId);
1492  d->drawTexture(dest, srcRect, size, false);
1493  return true;
1494 }
double d
Definition: qnumeric_p.h:62
#define GL_CLAMP_TO_EDGE
Definition: glfunctions.h:62
#define QT_IMAGE_TEXTURE_UNIT
#define Q_D(Class)
Definition: qglobal.h:2482
#define GL_TEXTURE_2D
#define GL_TEXTURE0
Definition: glfunctions.h:61
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
QOpenGL2PaintEngineState * state()
#define glActiveTexture
Definition: glfunctions.h:69
#define ctx
Definition: qgl.cpp:6094

◆ end()

bool QGL2PaintEngineEx::end ( )
virtual

Reimplement this function to finish painting on the current paint device.

Return true if painting was finished successfully; otherwise return false.

See also
begin() isActive()

Implements QPaintEngine.

Definition at line 2188 of file qpaintengineex_opengl2.cpp.

2189 {
2191  QGLContext *ctx = d->ctx;
2192 
2193  glUseProgram(0);
2194  d->transferMode(BrushDrawingMode);
2195  d->device->endPaint();
2196 
2197 #if defined(Q_WS_X11)
2198  // On some (probably all) drivers, deleting an X pixmap which has been bound to a texture
2199  // before calling glFinish/swapBuffers renders garbage. Presumably this is because X deletes
2200  // the pixmap behind the driver's back before it's had a chance to use it. To fix this, we
2201  // reference all QPixmaps which have been bound to stop them being deleted and only deref
2202  // them here, after swapBuffers, where they can be safely deleted.
2203  ctx->d_func()->boundPixmaps.clear();
2204 #endif
2205  d->ctx->d_ptr->active_engine = 0;
2206 
2207  d->resetGLState();
2208 
2209  delete d->shaderManager;
2210  d->shaderManager = 0;
2211  d->currentBrush = QBrush();
2212 
2213 #ifdef QT_OPENGL_CACHE_AS_VBOS
2214  if (!d->unusedVBOSToClean.isEmpty()) {
2215  glDeleteBuffers(d->unusedVBOSToClean.size(), d->unusedVBOSToClean.constData());
2216  d->unusedVBOSToClean.clear();
2217  }
2218  if (!d->unusedIBOSToClean.isEmpty()) {
2219  glDeleteBuffers(d->unusedIBOSToClean.size(), d->unusedIBOSToClean.constData());
2220  d->unusedIBOSToClean.clear();
2221  }
2222 #endif
2223 
2224  return false;
2225 }
double d
Definition: qnumeric_p.h:62
#define glUseProgram
#define Q_D(Class)
Definition: qglobal.h:2482
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
#define glDeleteBuffers
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
#define ctx
Definition: qgl.cpp:6094

◆ endNativePainting()

void QGL2PaintEngineEx::endNativePainting ( )
virtual

Reimplemented from QPaintEngineEx.

Definition at line 632 of file qpaintengineex_opengl2.cpp.

633 {
635  d->needsSync = true;
636  d->nativePaintingActive = false;
637 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ ensureActive()

void QGL2PaintEngineEx::ensureActive ( )

Definition at line 2227 of file qpaintengineex_opengl2.cpp.

Referenced by clip(), createState(), drawImage(), drawPixmap(), drawPixmapFragments(), drawStaticTextItem(), drawTextItem(), drawTexture(), fill(), and stroke().

2228 {
2230  QGLContext *ctx = d->ctx;
2231 
2232  if (isActive() && ctx->d_ptr->active_engine != this) {
2233  ctx->d_ptr->active_engine = this;
2234  d->needsSync = true;
2235  }
2236 
2237  d->device->ensureActiveTarget();
2238 
2239  if (d->needsSync) {
2240  d->transferMode(BrushDrawingMode);
2241  glViewport(0, 0, d->width, d->height);
2242  d->needsSync = false;
2243  d->lastMaskTextureUsed = 0;
2244  d->shaderManager->setDirty();
2245  d->ctx->d_func()->syncGlState();
2246  for (int i = 0; i < 3; ++i)
2247  d->vertexAttribPointers[i] = (GLfloat*)-1; // Assume the pointers are clobbered
2248  setState(state());
2249  }
2250 }
double d
Definition: qnumeric_p.h:62
QScopedPointer< QGLContextPrivate > d_ptr
Definition: qgl.h:430
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
virtual void setState(QPainterState *s)
QOpenGL2PaintEngineState * state()
#define ctx
Definition: qgl.cpp:6094
QPaintEngine * active_engine
Definition: qgl_p.h:458

◆ fill()

void QGL2PaintEngineEx::fill ( const QVectorPath path,
const QBrush brush 
)
virtual

Implements QPaintEngineEx.

Definition at line 1207 of file qpaintengineex_opengl2.cpp.

1208 {
1210 
1211  if (qbrush_style(brush) == Qt::NoBrush)
1212  return;
1213  ensureActive();
1214  d->setBrush(brush);
1215  d->fill(path);
1216 }
double d
Definition: qnumeric_p.h:62
Qt::BrushStyle qbrush_style(const QBrush &b)
Definition: qpainter_p.h:96
#define Q_D(Class)
Definition: qglobal.h:2482

◆ invalidateState()

void QGL2PaintEngineEx::invalidateState ( )

Definition at line 639 of file qpaintengineex_opengl2.cpp.

640 {
642  d->needsSync = true;
643 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ isNativePaintingActive()

bool QGL2PaintEngineEx::isNativePaintingActive ( ) const

Definition at line 645 of file qpaintengineex_opengl2.cpp.

645  {
646  Q_D(const QGL2PaintEngineEx);
647  return d->nativePaintingActive;
648 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ opacityChanged()

void QGL2PaintEngineEx::opacityChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 1324 of file qpaintengineex_opengl2.cpp.

1325 {
1326 // qDebug("QGL2PaintEngineEx::opacityChanged()");
1328  state()->opacityChanged = true;
1329 
1330  Q_ASSERT(d->shaderManager);
1331  d->brushUniformsDirty = true;
1332  d->opacityUniformDirty = true;
1333 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
QOpenGL2PaintEngineState * state()

◆ penChanged()

void QGL2PaintEngineEx::penChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 1320 of file qpaintengineex_opengl2.cpp.

1320 { }

◆ pixmapFilter()

QPixmapFilter * QGL2PaintEngineEx::pixmapFilter ( int  type,
const QPixmapFilter prototype 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 130 of file qglpixmapfilter.cpp.

131 {
133  switch (type) {
135  if (!d->colorizeFilter)
136  d->colorizeFilter.reset(new QGLPixmapColorizeFilter);
137  return d->colorizeFilter.data();
138 
140  if (!d->blurFilter)
141  d->blurFilter.reset(new QGLPixmapBlurFilter());
142  return d->blurFilter.data();
143  }
144 
146  if (!d->dropShadowFilter)
147  d->dropShadowFilter.reset(new QGLPixmapDropShadowFilter());
148  return d->dropShadowFilter.data();
149  }
150 
152  if (!d->convolutionFilter)
153  d->convolutionFilter.reset(new QGLPixmapConvolutionFilter);
154  return d->convolutionFilter.data();
155 
156  default: break;
157  }
158  return QPaintEngineEx::pixmapFilter(type, prototype);
159 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QPixmapFilter * pixmapFilter(int, const QPixmapFilter *)
Type type() const
Reimplement this function to return the paint engine Type.

◆ renderHintsChanged()

void QGL2PaintEngineEx::renderHintsChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 1343 of file qpaintengineex_opengl2.cpp.

Referenced by setState().

1344 {
1345  state()->renderHintsChanged = true;
1346 
1347 #if !defined(QT_OPENGL_ES_2)
1348  if ((state()->renderHints & QPainter::Antialiasing)
1349  || (state()->renderHints & QPainter::HighQualityAntialiasing))
1350  glEnable(GL_MULTISAMPLE);
1351  else
1352  glDisable(GL_MULTISAMPLE);
1353 #endif
1354 
1356  d->lastTextureUsed = GLuint(-1);
1357  d->brushTextureDirty = true;
1358 // qDebug("QGL2PaintEngineEx::renderHintsChanged() not implemented!");
1359 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define GL_MULTISAMPLE
QOpenGL2PaintEngineState * state()

◆ setRenderTextActive()

void QGL2PaintEngineEx::setRenderTextActive ( bool  )

◆ setState()

void QGL2PaintEngineEx::setState ( QPainterState s)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 2554 of file qpaintengineex_opengl2.cpp.

Referenced by ensureActive().

2555 {
2556  // qDebug("QGL2PaintEngineEx::setState()");
2557 
2559 
2560  QOpenGL2PaintEngineState *s = static_cast<QOpenGL2PaintEngineState *>(new_state);
2561  QOpenGL2PaintEngineState *old_state = state();
2562 
2564 
2565  if (s->isNew) {
2566  // Newly created state object. The call to setState()
2567  // will either be followed by a call to begin(), or we are
2568  // setting the state as part of a save().
2569  s->isNew = false;
2570  return;
2571  }
2572 
2573  // Setting the state as part of a restore().
2574 
2575  if (old_state == s || old_state->renderHintsChanged)
2577 
2578  if (old_state == s || old_state->matrixChanged)
2579  d->matrixDirty = true;
2580 
2581  if (old_state == s || old_state->compositionModeChanged)
2582  d->compositionModeDirty = true;
2583 
2584  if (old_state == s || old_state->opacityChanged)
2585  d->opacityUniformDirty = true;
2586 
2587  if (old_state == s || old_state->clipChanged) {
2588  if (old_state && old_state != s && old_state->canRestoreClip) {
2589  d->updateClipScissorTest();
2590  glDepthFunc(GL_LEQUAL);
2591  } else {
2592  d->regenerateClip();
2593  }
2594  }
2595 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void setState(QPainterState *s)
#define GL_LEQUAL
QOpenGL2PaintEngineState * state()

◆ state() [1/2]

QOpenGL2PaintEngineState* QGL2PaintEngineEx::state ( )
inline

◆ state() [2/2]

const QOpenGL2PaintEngineState* QGL2PaintEngineEx::state ( ) const
inline

Definition at line 150 of file qpaintengineex_opengl2_p.h.

150  {
151  return static_cast<const QOpenGL2PaintEngineState *>(QPaintEngineEx::state());
152  }
QPainterState * state()

◆ stroke()

void QGL2PaintEngineEx::stroke ( const QVectorPath path,
const QPen pen 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1221 of file qpaintengineex_opengl2.cpp.

1222 {
1224 
1225  const QBrush &penBrush = qpen_brush(pen);
1226  if (qpen_style(pen) == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush)
1227  return;
1228 
1230  if (pen.isCosmetic() && !qt_scaleForTransform(s->transform(), 0)) {
1231  // QTriangulatingStroker class is not meant to support cosmetically sheared strokes.
1232  QPaintEngineEx::stroke(path, pen);
1233  return;
1234  }
1235 
1236  ensureActive();
1237  d->setBrush(penBrush);
1238  d->stroke(path, pen);
1239 }
double d
Definition: qnumeric_p.h:62
Qt::BrushStyle qbrush_style(const QBrush &b)
Definition: qpainter_p.h:96
QTransform transform() const
Returns the matrix in the current paint engine state.
Definition: qpainter.cpp:9377
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void stroke(const QVectorPath &path, const QPen &pen)
QBrush qpen_brush(const QPen &p)
Definition: qpainter_p.h:87
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
Definition: qpen.cpp:840
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
QOpenGL2PaintEngineState * state()
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
Qt::PenStyle qpen_style(const QPen &p)
Definition: qpainter_p.h:89

◆ supportsTransformations()

bool QGL2PaintEngineEx::supportsTransformations ( qreal  ,
const QTransform  
) const
inlinevirtual

Reimplemented from QPaintEngineEx.

Definition at line 164 of file qpaintengineex_opengl2_p.h.

164 { return true; }

◆ transformChanged()

void QGL2PaintEngineEx::transformChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 1361 of file qpaintengineex_opengl2.cpp.

1362 {
1364  d->matrixDirty = true;
1365  state()->matrixChanged = true;
1366 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QOpenGL2PaintEngineState * state()

◆ type()

Type QGL2PaintEngineEx::type ( ) const
inlinevirtual

Reimplement this function to return the paint engine Type.

Implements QPaintEngine.

Definition at line 143 of file qpaintengineex_opengl2_p.h.

143 { return OpenGL2; }

The documentation for this class was generated from the following files: