Qt 4.8
Classes | Macros | Typedefs | Functions | Variables
qpaintengine_opengl.cpp File Reference
#include <qdebug.h>
#include <private/qfontengine_p.h>
#include <qmath.h>
#include <private/qmath_p.h>
#include <private/qdrawhelper_p.h>
#include <private/qpaintengine_p.h>
#include "qapplication.h"
#include "qbrush.h"
#include "qgl.h"
#include <private/qgl_p.h>
#include <private/qglpaintdevice_p.h>
#include <private/qpainter_p.h>
#include "qmap.h"
#include <private/qpaintengine_opengl_p.h>
#include <private/qdatabuffer_p.h>
#include "qpen.h"
#include "qvarlengtharray.h"
#include <private/qglpixelbuffer_p.h>
#include <private/qbezier_p.h>
#include <qglframebufferobject.h>
#include <private/qstatictext_p.h>
#include "private/qtessellator_p.h"
#include "util/fragmentprograms_p.h"
#include "private/qglwindowsurface_qws_p.h"
#include "qwsmanager_qws.h"
#include "private/qwsmanager_p.h"
#include <stdlib.h>
#include "qpaintengine_opengl_p.h"
#include "qpaintengine_opengl.moc"

Go to the source code of this file.

Classes

struct  GLProgram
 
struct  QDrawQueueItem
 
class  QGLEllipseMaskGenerator
 
struct  QGLFontTexture
 
class  QGLGlyphCache
 
struct  QGLGlyphCoord
 
class  QGLGradientCache
 
struct  QGLGradientCache::CacheInfo
 
class  QGLLineMaskGenerator
 
class  QGLMaskGenerator
 
class  QGLMaskTextureCache
 
struct  QGLMaskTextureCache::CacheInfo
 
struct  QGLMaskTextureCache::CacheLocation
 
struct  QGLMaskTextureCache::QuadTreeNode
 
class  QGLOffscreen
 
class  QGLPathMaskGenerator
 
class  QGLPrivateCleanup
 
class  QGLProgramCache
 
class  QGLRectMaskGenerator
 
class  QGLStrokeCache
 
struct  QGLStrokeCache::CacheInfo
 
struct  QGLTrapezoid
 
class  QGLTrapezoidMaskGenerator
 
class  QOpenGLCoordinateOffset
 
class  QOpenGLImmediateModeTessellator
 
class  QOpenGLPaintEnginePrivate
 
class  QOpenGLTessellator
 
class  QOpenGLTrapezoidToArrayTessellator
 
struct  QT_PointF
 

Macros

#define DEBUG_ONCE   if (0)
 
#define DEBUG_ONCE_STR(str)   ;
 
#define DEBUG_OVERRIDE(state)   ;
 
#define DISABLE_DEBUG_ONCE
 
#define FloatToQuint64(i)   (quint64)((i) * 32)
 
#define QGL_FUNC_CONTEXT   QGLContext *ctx = const_cast<QGLContext *>(device->context());
 
#define QREAL_MAX   9e100
 
#define QREAL_MIN   -9e100
 

Typedefs

typedef QHash< const QGLContext *, QGLFontGlyphHash * > QGLContextHash
 
typedef QHash< QFontEngine *, QGLGlyphHash * > QGLFontGlyphHash
 
typedef QHash< quint64, QGLFontTexture * > QGLFontTexHash
 
typedef QHash< glyph_t, QGLGlyphCoord * > QGLGlyphHash
 
typedef QMultiHash< const QGLContext *, GLProgramQGLProgramHash
 

Functions

static void addQuadAsTriangle (GLfloat *quad, GLfloat *triangle)
 
static void drawTrapezoid (const QGLTrapezoid &trap, const qreal offscreenHeight, QGLContext *ctx)
 
static QPainterPath ellipseRectToPath (const QRectF &rect)
 
static uint endianColor (uint c)
 
template<typename T >
static bool isRect (const T *pts, int elementCount)
 
static bool needsEmulation (Qt::BrushStyle style)
 
static bool pathClosed (const QPainterPath &path)
 
void qgl_cleanup_glyph_cache (QGLContext *ctx)
 
template<typename T >
static const T qSubImage (const T &image, const QRectF &src, QRectF *srcNew)
 
void qt_add_rect_to_array (const QRectF &r, GLfloat *array)
 
void qt_add_texcoords_to_array (qreal x1, qreal y1, qreal x2, qreal y2, GLfloat *array)
 
static void qt_delete_glyph_hash (QGLGlyphHash *hash)
 
static void qt_glColor4ubv (unsigned char *col)
 
Q_GUI_EXPORT QImage qt_imageForBrush (int brushStyle, bool invert)
 
Q_GUI_EXPORT bool qt_isExtendedRadialGradient (const QBrush &brush)
 
int qt_next_power_of_two (int v)
 
Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath (const QVectorPath &path)
 
Q_GUI_EXPORT bool qt_scaleForTransform (const QTransform &transform, qreal *scale)
 
static const QRectF scaleRect (const QRectF &r, qreal sx, qreal sy)
 
static QPainterPath strokeForPath (const QPainterPath &path, const QPen &cpen)
 
static void updateTextureFilter (GLenum target, GLenum wrapMode, bool smoothPixmapTransform)
 

Variables

static bool qt_nvidiaFboNeedsFinish = false
 
static const int x_margin = 1
 
static const int y_margin = 0
 

Macro Definition Documentation

◆ DEBUG_ONCE

#define DEBUG_ONCE   if (0)

◆ DEBUG_ONCE_STR

#define DEBUG_ONCE_STR (   str)    ;

◆ DEBUG_OVERRIDE

#define DEBUG_OVERRIDE (   state)    ;

Definition at line 97 of file qpaintengine_opengl.cpp.

◆ DISABLE_DEBUG_ONCE

#define DISABLE_DEBUG_ONCE

Definition at line 92 of file qpaintengine_opengl.cpp.

◆ FloatToQuint64

#define FloatToQuint64 (   i)    (quint64)((i) * 32)

Definition at line 2730 of file qpaintengine_opengl.cpp.

Referenced by QGLMaskTextureCache::hash().

◆ QGL_FUNC_CONTEXT

#define QGL_FUNC_CONTEXT   QGLContext *ctx = const_cast<QGLContext *>(device->context());

◆ QREAL_MAX

#define QREAL_MAX   9e100

Definition at line 87 of file qpaintengine_opengl.cpp.

Referenced by QGLEllipseMaskGenerator::screenRect().

◆ QREAL_MIN

#define QREAL_MIN   -9e100

Definition at line 88 of file qpaintengine_opengl.cpp.

Typedef Documentation

◆ QGLContextHash

Definition at line 4551 of file qpaintengine_opengl.cpp.

◆ QGLFontGlyphHash

Definition at line 4549 of file qpaintengine_opengl.cpp.

◆ QGLFontTexHash

Definition at line 4550 of file qpaintengine_opengl.cpp.

◆ QGLGlyphHash

Definition at line 4548 of file qpaintengine_opengl.cpp.

◆ QGLProgramHash

Definition at line 516 of file qpaintengine_opengl.cpp.

Function Documentation

◆ addQuadAsTriangle()

static void addQuadAsTriangle ( GLfloat *  quad,
GLfloat *  triangle 
)
static

Definition at line 3558 of file qpaintengine_opengl.cpp.

Referenced by QOpenGLPaintEngine::drawLines().

3559 {
3560  triangle[0] = quad[0];
3561  triangle[1] = quad[1];
3562 
3563  triangle[2] = quad[2];
3564  triangle[3] = quad[3];
3565 
3566  triangle[4] = quad[4];
3567  triangle[5] = quad[5];
3568 
3569  triangle[6] = quad[4];
3570  triangle[7] = quad[5];
3571 
3572  triangle[8] = quad[6];
3573  triangle[9] = quad[7];
3574 
3575  triangle[10] = quad[0];
3576  triangle[11] = quad[1];
3577 }

◆ drawTrapezoid()

static void drawTrapezoid ( const QGLTrapezoid trap,
const qreal  offscreenHeight,
QGLContext ctx 
)
static

Definition at line 1730 of file qpaintengine_opengl.cpp.

Referenced by QGLTrapezoidMaskGenerator::drawMask().

1731 {
1732  qreal minX = qMin(trap.topLeftX, trap.bottomLeftX);
1733  qreal maxX = qMax(trap.topRightX, trap.bottomRightX);
1734 
1735  if (qFuzzyCompare(trap.top, trap.bottom) || qFuzzyCompare(minX, maxX) ||
1737  return;
1738 
1739  const qreal xpadding = 1.0;
1740  const qreal ypadding = 1.0;
1741 
1742  qreal topDist = offscreenHeight - trap.top;
1743  qreal bottomDist = offscreenHeight - trap.bottom;
1744 
1745  qreal reciprocal = bottomDist / (bottomDist - topDist);
1746 
1747  qreal leftB = trap.bottomLeftX + (trap.topLeftX - trap.bottomLeftX) * reciprocal;
1748  qreal rightB = trap.bottomRightX + (trap.topRightX - trap.bottomRightX) * reciprocal;
1749 
1750  const bool topZero = qFuzzyIsNull(topDist);
1751 
1752  reciprocal = topZero ? 1.0 / bottomDist : 1.0 / topDist;
1753 
1754  qreal leftA = topZero ? (trap.bottomLeftX - leftB) * reciprocal : (trap.topLeftX - leftB) * reciprocal;
1755  qreal rightA = topZero ? (trap.bottomRightX - rightB) * reciprocal : (trap.topRightX - rightB) * reciprocal;
1756 
1757  qreal invLeftA = qFuzzyIsNull(leftA) ? 0.0 : 1.0 / leftA;
1758  qreal invRightA = qFuzzyIsNull(rightA) ? 0.0 : 1.0 / rightA;
1759 
1760  // fragment program needs the negative of invRightA as it mirrors the line
1761  glTexCoord4f(topDist, bottomDist, invLeftA, -invRightA);
1762  glMultiTexCoord4f(GL_TEXTURE1, leftA, leftB, rightA, rightB);
1763 
1764  qreal topY = trap.top - ypadding;
1765  qreal bottomY = trap.bottom + ypadding;
1766 
1767  qreal bounds_bottomLeftX = leftA * (offscreenHeight - bottomY) + leftB;
1768  qreal bounds_bottomRightX = rightA * (offscreenHeight - bottomY) + rightB;
1769  qreal bounds_topLeftX = leftA * (offscreenHeight - topY) + leftB;
1770  qreal bounds_topRightX = rightA * (offscreenHeight - topY) + rightB;
1771 
1772  QPointF leftNormal(1, -leftA);
1773  leftNormal /= qSqrt(leftNormal.x() * leftNormal.x() + leftNormal.y() * leftNormal.y());
1774  QPointF rightNormal(1, -rightA);
1775  rightNormal /= qSqrt(rightNormal.x() * rightNormal.x() + rightNormal.y() * rightNormal.y());
1776 
1777  qreal left_padding = xpadding / qAbs(leftNormal.x());
1778  qreal right_padding = xpadding / qAbs(rightNormal.x());
1779 
1780  glVertex2d(bounds_topLeftX - left_padding, topY);
1781  glVertex2d(bounds_topRightX + right_padding, topY);
1782  glVertex2d(bounds_bottomRightX + right_padding, bottomY);
1783  glVertex2d(bounds_bottomLeftX - left_padding, bottomY);
1784 
1785  glTexCoord4f(0.0f, 0.0f, 0.0f, 1.0f);
1786 }
#define glMultiTexCoord4f
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define GL_TEXTURE1
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
The qFuzzyCompare function is for comparing two matrices using a fuzziness factor.
Definition: qmatrix.h:172
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043
qreal qSqrt(qreal v)
Definition: qmath.h:205

◆ ellipseRectToPath()

static QPainterPath ellipseRectToPath ( const QRectF rect)
static

Definition at line 3280 of file qpaintengine_opengl.cpp.

3281 {
3282  QPainterPath path;
3283  path.addEllipse(rect);
3284  return path;
3285 }
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...

◆ endianColor()

static uint endianColor ( uint  c)
inlinestatic

Definition at line 1103 of file qpaintengine_opengl.cpp.

Referenced by QGLGradientCache::generateGradientColorTable().

1104 {
1105 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1106  return c;
1107 #else
1108  return ( (c << 24) & 0xff000000)
1109  | ((c >> 24) & 0x000000ff)
1110  | ((c << 8) & 0x00ff0000)
1111  | ((c >> 8) & 0x0000ff00);
1112 #endif // Q_BYTE_ORDER
1113 }
unsigned char c[8]
Definition: qnumeric_p.h:62

◆ isRect()

template<typename T >
static bool isRect ( const T *  pts,
int  elementCount 
)
inlinestatic

Definition at line 5489 of file qpaintengine_opengl.cpp.

5489  {
5490  return (elementCount == 5 // 5-point polygon, check for closed rect
5491  && pts[0] == pts[8] && pts[1] == pts[9] // last point == first point
5492  && pts[0] == pts[6] && pts[2] == pts[4] // x values equal
5493  && pts[1] == pts[3] && pts[5] == pts[7] // y values equal...
5494  ) ||
5495  (elementCount == 4 // 4-point polygon, check for unclosed rect
5496  && pts[0] == pts[6] && pts[2] == pts[4] // x values equal
5497  && pts[1] == pts[3] && pts[5] == pts[7] // y values equal...
5498  );
5499 }

◆ needsEmulation()

static bool needsEmulation ( Qt::BrushStyle  style)
inlinestatic

◆ pathClosed()

static bool pathClosed ( const QPainterPath path)
static

Definition at line 4138 of file qpaintengine_opengl.cpp.

Referenced by QOpenGLPaintEngine::drawPath().

4139 {
4140  QPointF lastMoveTo = path.elementAt(0);
4141  QPointF lastPoint = lastMoveTo;
4142 
4143  for (int i = 1; i < path.elementCount(); ++i) {
4144  const QPainterPath::Element &e = path.elementAt(i);
4145  switch (e.type) {
4147  if (lastMoveTo != lastPoint)
4148  return false;
4149  lastMoveTo = lastPoint = e;
4150  break;
4152  lastPoint = e;
4153  break;
4155  lastPoint = path.elementAt(i + 2);
4156  i+=2;
4157  break;
4158  default:
4159  break;
4160  }
4161  }
4162 
4163  return lastMoveTo == lastPoint;
4164 }
ElementType type
the type of element
Definition: qpainterpath.h:81
The QPainterPath::Element class specifies the position and type of a subpath.
Definition: qpainterpath.h:77
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Definition: qpainterpath.h:402
int elementCount() const
Returns the number of path elements in the painter path.
Definition: qpainterpath.h:397

◆ qgl_cleanup_glyph_cache()

void qgl_cleanup_glyph_cache ( QGLContext ctx)

Definition at line 4917 of file qpaintengine_opengl.cpp.

Referenced by QGLPixelBuffer::~QGLPixelBuffer().

4918 {
4919  qt_glyph_cache()->cleanupContext(ctx);
4920 }

◆ qSubImage()

template<typename T >
static const T qSubImage ( const T &  image,
const QRectF src,
QRectF srcNew 
)
static

Definition at line 4274 of file qpaintengine_opengl.cpp.

Referenced by QOpenGLPaintEngine::drawImage(), and QOpenGLPaintEngine::drawPixmap().

4275 {
4276  const int sx1 = qMax(0, qFloor(src.left()));
4277  const int sy1 = qMax(0, qFloor(src.top()));
4278  const int sx2 = qMin(image.width(), qCeil(src.right()));
4279  const int sy2 = qMin(image.height(), qCeil(src.bottom()));
4280 
4281  const T sub = image.copy(sx1, sy1, sx2 - sx1, sy2 - sy1);
4282 
4283  if (srcNew)
4284  *srcNew = src.translated(-sx1, -sy1);
4285 
4286  return sub;
4287 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int qCeil(qreal v)
Definition: qmath.h:63
int qFloor(qreal v)
Definition: qmath.h:73
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:740

◆ qt_add_rect_to_array()

void qt_add_rect_to_array ( const QRectF r,
GLfloat *  array 
)

Definition at line 2972 of file qgl.cpp.

Referenced by QOpenGLPaintEnginePrivate::composite(), QOpenGLPaintEnginePrivate::drawFastRect(), QGLTrapezoidMaskGenerator::drawMask(), QGLEllipseMaskGenerator::drawMask(), QOpenGLPaintEngine::drawStaticTextItem(), drawTexture(), QOpenGLPaintEngine::drawTextureRect(), QOpenGLPaintEngine::drawTiledPixmap(), and QGLTrapezoidMaskGenerator::QGLTrapezoidMaskGenerator().

2973 {
2974  qreal left = r.left();
2975  qreal right = r.right();
2976  qreal top = r.top();
2977  qreal bottom = r.bottom();
2978 
2979  array[0] = left;
2980  array[1] = top;
2981  array[2] = right;
2982  array[3] = top;
2983  array[4] = right;
2984  array[5] = bottom;
2985  array[6] = left;
2986  array[7] = bottom;
2987 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
double qreal
Definition: qglobal.h:1193
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
QTextStream & right(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) on stream and returns stream...
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528
QTextStream & left(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) on stream and returns stream...

◆ qt_add_texcoords_to_array()

void qt_add_texcoords_to_array ( qreal  x1,
qreal  y1,
qreal  x2,
qreal  y2,
GLfloat *  array 
)

Definition at line 2989 of file qgl.cpp.

Referenced by QOpenGLPaintEngine::drawStaticTextItem(), QOpenGLPaintEngine::drawTextureRect(), QOpenGLPaintEngine::drawTiledPixmap(), and QGLTrapezoidMaskGenerator::QGLTrapezoidMaskGenerator().

2990 {
2991  array[0] = x1;
2992  array[1] = y1;
2993  array[2] = x2;
2994  array[3] = y1;
2995  array[4] = x2;
2996  array[5] = y2;
2997  array[6] = x1;
2998  array[7] = y2;
2999 }

◆ qt_delete_glyph_hash()

static void qt_delete_glyph_hash ( QGLGlyphHash hash)
inlinestatic

Definition at line 4553 of file qpaintengine_opengl.cpp.

Referenced by QGLGlyphCache::cleanCache(), QGLGlyphCache::cleanupContext(), and QGLGlyphCache::fontEngineDestroyed().

4554 {
4555  qDeleteAll(*hash);
4556  delete hash;
4557 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ qt_glColor4ubv()

static void qt_glColor4ubv ( unsigned char *  col)
inlinestatic

Definition at line 112 of file qpaintengine_opengl.cpp.

Referenced by QOpenGLPaintEngine::drawStaticTextItem(), QOpenGLPaintEnginePrivate::flushDrawQueue(), QOpenGLPaintEnginePrivate::setGradientOps(), and QOpenGLPaintEnginePrivate::updateGradient().

113 {
114  glColor4f(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, col[3]/255.0f);
115 }

◆ qt_imageForBrush()

Q_GUI_EXPORT QImage qt_imageForBrush ( int  brushStyle,
bool  invert 
)

Definition at line 167 of file qbrush.cpp.

Referenced by QOpenGLPaintEnginePrivate::composite().

168 {
169  return qt_brushPatternImageCache()->getImage(brushStyle, invert);
170 }

◆ qt_isExtendedRadialGradient()

Q_GUI_EXPORT bool qt_isExtendedRadialGradient ( const QBrush brush)

Definition at line 881 of file qbrush.cpp.

Referenced by QOpenGLPaintEngine::fill(), QOpenGLPaintEnginePrivate::fillPath(), QBrush::isOpaque(), QVGPaintEnginePrivate::needsEmulation(), and QOpenGLPaintEnginePrivate::updateUseEmulation().

882 {
883  if (brush.style() == Qt::RadialGradientPattern) {
884  const QGradient *g = brush.gradient();
885  const QRadialGradient *rg = static_cast<const QRadialGradient *>(g);
886 
887  if (!qFuzzyIsNull(rg->focalRadius()))
888  return true;
889 
890  QPointF delta = rg->focalPoint() - rg->center();
891  if (delta.x() * delta.x() + delta.y() * delta.y() > rg->radius() * rg->radius())
892  return true;
893  }
894 
895  return false;
896 }
qreal focalRadius() const
Returns the focal radius of this radial gradient in logical coordinates.
Definition: qbrush.cpp:2211
QPointF focalPoint() const
Returns the focal point of this radial gradient in logical coordinates.
Definition: qbrush.cpp:2251
const QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush...
Definition: qbrush.h:297
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Definition: qbrush.h:201
qreal radius() const
Returns the radius of this radial gradient in logical coordinates.
Definition: qbrush.cpp:2150
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QPointF center() const
Returns the center of this radial gradient in logical coordinates.
Definition: qbrush.cpp:2102
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043

◆ qt_next_power_of_two()

int qt_next_power_of_two ( int  v)

Definition at line 1886 of file qgl.cpp.

Referenced by QOpenGLPaintEngine::begin(), QGLGlyphCache::cacheGlyphs(), QGLOffscreen::initialize(), and QGLMaskTextureCache::quadtreeFindExistingLocation().

1887 {
1888  v--;
1889  v |= v >> 1;
1890  v |= v >> 2;
1891  v |= v >> 4;
1892  v |= v >> 8;
1893  v |= v >> 16;
1894  ++v;
1895  return v;
1896 }

◆ qt_painterPathFromVectorPath()

Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath ( const QVectorPath path)

Definition at line 1033 of file qpaintengineex.cpp.

Referenced by QOpenGLPaintEngine::fill(), and QOpenGLPaintEngine::transformChanged().

1034 {
1035  const qreal *points = path.points();
1036  const QPainterPath::ElementType *types = path.elements();
1037 
1038  QPainterPath p;
1039  if (types) {
1040  int id = 0;
1041  for (int i=0; i<path.elementCount(); ++i) {
1042  switch(types[i]) {
1044  p.moveTo(QPointF(points[id], points[id+1]));
1045  id+=2;
1046  break;
1048  p.lineTo(QPointF(points[id], points[id+1]));
1049  id+=2;
1050  break;
1052  QPointF p1(points[id], points[id+1]);
1053  QPointF p2(points[id+2], points[id+3]);
1054  QPointF p3(points[id+4], points[id+5]);
1055  p.cubicTo(p1, p2, p3);
1056  id+=6;
1057  break;
1058  }
1060  ;
1061  break;
1062  }
1063  }
1064  } else {
1065  p.moveTo(QPointF(points[0], points[1]));
1066  int id = 2;
1067  for (int i=1; i<path.elementCount(); ++i) {
1068  p.lineTo(QPointF(points[id], points[id+1]));
1069  id+=2;
1070  }
1071  }
1072  if (path.hints() & QVectorPath::WindingFill)
1074 
1075  return p;
1076 }
ElementType
This enum describes the types of elements used to connect vertices in subpaths.
Definition: qpainterpath.h:70
double qreal
Definition: qglobal.h:1193
int elementCount() const
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
const QPainterPath::ElementType * elements() const
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
uint hints() const
static const struct @32 types[]
const qreal * points() const
void cubicTo(const QPointF &ctrlPt1, const QPointF &ctrlPt2, const QPointF &endPt)
Adds a cubic Bezier curve between the current position and the given endPoint using the control point...

◆ qt_scaleForTransform()

Q_GUI_EXPORT bool qt_scaleForTransform ( const QTransform transform,
qreal scale 
)

Definition at line 2407 of file qtransform.cpp.

Referenced by QOpenGLPaintEnginePrivate::strokeLines(), and QOpenGLPaintEnginePrivate::strokePath().

2408 {
2409  const QTransform::TransformationType type = transform.type();
2410  if (type <= QTransform::TxTranslate) {
2411  if (scale)
2412  *scale = 1;
2413  return true;
2414  } else if (type == QTransform::TxScale) {
2415  const qreal xScale = qAbs(transform.m11());
2416  const qreal yScale = qAbs(transform.m22());
2417  if (scale)
2418  *scale = qMax(xScale, yScale);
2419  return qFuzzyCompare(xScale, yScale);
2420  }
2421 
2422  const qreal xScale = transform.m11() * transform.m11()
2423  + transform.m21() * transform.m21();
2424  const qreal yScale = transform.m12() * transform.m12()
2425  + transform.m22() * transform.m22();
2426  if (scale)
2427  *scale = qSqrt(qMax(xScale, yScale));
2428  return type == QTransform::TxRotate && qFuzzyCompare(xScale, yScale);
2429 }
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
qreal m21() const
Returns the horizontal shearing factor.
Definition: qtransform.h:249
qreal m22() const
Returns the vertical scaling factor.
Definition: qtransform.h:253
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
TransformationType type() const
Returns the transformation type of this matrix.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal m12() const
Returns the vertical shearing factor.
Definition: qtransform.h:241
TransformationType
Definition: qtransform.h:68
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
The qFuzzyCompare function is for comparing two matrices using a fuzziness factor.
Definition: qmatrix.h:172
qreal qSqrt(qreal v)
Definition: qmath.h:205
qreal m11() const
Returns the horizontal scaling factor.
Definition: qtransform.h:237

◆ scaleRect()

static const QRectF scaleRect ( const QRectF r,
qreal  sx,
qreal  sy 
)
static

Definition at line 4268 of file qpaintengine_opengl.cpp.

Referenced by QOpenGLPaintEngine::drawImage(), and QOpenGLPaintEngine::drawPixmap().

4269 {
4270  return QRectF(r.x() * sx, r.y() * sy, r.width() * sx, r.height() * sy);
4271 }
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664

◆ strokeForPath()

static QPainterPath strokeForPath ( const QPainterPath path,
const QPen cpen 
)
inlinestatic

Definition at line 916 of file qpaintengine_opengl.cpp.

Referenced by QGLStrokeCache::addCacheElement(), and QOpenGLPaintEnginePrivate::strokePath().

916  {
917  QPainterPathStroker stroker;
918  if (cpen.style() == Qt::CustomDashLine)
919  stroker.setDashPattern(cpen.dashPattern());
920  else
921  stroker.setDashPattern(cpen.style());
922 
923  stroker.setCapStyle(cpen.capStyle());
924  stroker.setJoinStyle(cpen.joinStyle());
925  stroker.setMiterLimit(cpen.miterLimit());
926  stroker.setDashOffset(cpen.dashOffset());
927 
928  qreal width = cpen.widthF();
929  if (width == 0)
930  stroker.setWidth(1);
931  else
932  stroker.setWidth(width);
933 
934  QPainterPath stroke = stroker.createStroke(path);
936  return stroke;
937 }
void setDashOffset(qreal offset)
Sets the dash offset for the generated outlines to offset.
double qreal
Definition: qglobal.h:1193
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
void setMiterLimit(qreal length)
Sets the miter limit of the generated outlines to limit.
QVector< qreal > dashPattern() const
Returns the dash pattern of this pen.
Definition: qpen.cpp:466
void setDashPattern(Qt::PenStyle)
Sets the dash pattern for the generated outlines to style.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
Qt::PenJoinStyle joinStyle() const
Returns the pen&#39;s join style.
Definition: qpen.cpp:736
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
Definition: qpainterpath.h:264
qreal miterLimit() const
Returns the miter limit of the pen.
Definition: qpen.cpp:589
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
qreal dashOffset() const
Returns the dash offset for the pen.
Definition: qpen.cpp:547
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.

◆ updateTextureFilter()

static void updateTextureFilter ( GLenum  target,
GLenum  wrapMode,
bool  smoothPixmapTransform 
)
inlinestatic

Definition at line 903 of file qpaintengine_opengl.cpp.

Referenced by QOpenGLPaintEnginePrivate::composite(), QGL2PaintEngineExPrivate::drawCachedGlyphs(), QGL2PaintEngineExPrivate::drawPixmapFragments(), QOpenGLPaintEngine::drawTextureRect(), QOpenGLPaintEngine::drawTiledPixmap(), and QGL2PaintEngineExPrivate::QGL2PaintEngineExPrivate().

904 {
905  if (smoothPixmapTransform) {
906  glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
907  glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
908  } else {
909  glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
910  glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
911  }
912  glTexParameterf(target, GL_TEXTURE_WRAP_S, wrapMode);
913  glTexParameterf(target, GL_TEXTURE_WRAP_T, wrapMode);
914 }
#define GL_TEXTURE_MIN_FILTER
#define GL_TEXTURE_WRAP_S
#define GL_TEXTURE_WRAP_T
#define GL_LINEAR
#define GL_TEXTURE_MAG_FILTER
#define GL_NEAREST

Variable Documentation

◆ qt_nvidiaFboNeedsFinish

bool qt_nvidiaFboNeedsFinish = false
static

Definition at line 109 of file qpaintengine_opengl.cpp.

Referenced by QOpenGLPaintEngine::begin(), and QGLOffscreen::release().

◆ x_margin

const int x_margin = 1
static

Definition at line 4522 of file qpaintengine_opengl.cpp.

Referenced by QGLGlyphCache::cacheGlyphs().

◆ y_margin

const int y_margin = 0
static

Definition at line 4523 of file qpaintengine_opengl.cpp.

Referenced by QGLGlyphCache::cacheGlyphs().