29#include <private/qopenglgradientcache_p.h>
30#include <private/qopengltexturecache_p.h>
37#include <private/qopengl_p.h>
38#include <private/qopenglcontext_p.h>
39#include <private/qopenglextensions_p.h>
40#include <private/qpaintengineex_p.h>
41#include <QPaintEngine>
42#include <private/qpainter_p.h>
43#include <private/qfontengine_p.h>
44#include <private/qdatabuffer_p.h>
45#include <private/qstatictext_p.h>
46#include <private/qtriangulator_p.h>
48#include <private/qopenglengineshadermanager_p.h>
49#include <private/qopengl2pexvertexarray_p.h>
50#include <private/qopengltextureglyphcache_p.h>
54#include <qtopengl_tracepoints_p.h>
56#ifndef GL_KHR_blend_equation_advanced
57#define GL_KHR_blend_equation_advanced 1
58#define GL_MULTIPLY_KHR 0x9294
59#define GL_SCREEN_KHR 0x9295
60#define GL_OVERLAY_KHR 0x9296
61#define GL_DARKEN_KHR 0x9297
62#define GL_LIGHTEN_KHR 0x9298
63#define GL_COLORDODGE_KHR 0x9299
64#define GL_COLORBURN_KHR 0x929A
65#define GL_HARDLIGHT_KHR 0x929B
66#define GL_SOFTLIGHT_KHR 0x929C
67#define GL_DIFFERENCE_KHR 0x929E
68#define GL_EXCLUSION_KHR 0x92A0
71#ifndef GL_KHR_blend_equation_advanced_coherent
72#define GL_KHR_blend_equation_advanced_coherent 1
73#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285
104 c.setGreenF(
c.greenF() *
alpha);
163 bool newTextureCreated =
false;
169 if (newTextureCreated)
201 if (newTextureCreated)
202 *newTextureCreated =
false;
214 if (newTextureCreated)
223 if (newTextureCreated)
252 imageWithOptions.
image,
254 if (newTextureCreated)
262 return x == (
x & -
x);
272 GLenum filterMode = smoothPixmapTransform ? GL_LINEAR : GL_NEAREST;
287 wrapMode = GL_REPEAT;
296 int max_texture_size =
ctx->d_func()->maxTextureSize();
298 newSize = newSize.
boundedTo(
QSize(max_texture_size, max_texture_size));
308 GLuint wrapMode = GL_REPEAT;
325 bool isCosmetic =
false;
350 translationPoint = realStart;
352 QPointF l = realFinal - realStart;
357 1.0f / (l.
x() * l.
x() + l.
y() * l.
y())
367 translationPoint =
g->center();
379 QPointF realFocal =
g->focalPoint();
380 qreal realRadius =
g->centerRadius() -
g->focalRadius();
381 translationPoint = realFocal;
389 GLfloat(1.0 / (2.0*fmp2_m_radius2)));
391 GLfloat(
g->focalRadius() *
g->focalRadius()));
393 GLfloat(2 * (
g->centerRadius() -
g->focalRadius()) *
g->focalRadius()),
395 g->centerRadius() -
g->focalRadius());
415 qWarning(
"QOpenGL2PaintEngineEx: Unimplemented fill style");
417 const QPointF &brushOrigin =
q->state()->brushOrigin;
421 matrix.translate(brushOrigin.
x(), brushOrigin.
y());
481 dx = std::ceil(dx - 0.5f);
482 dy = std::ceil(dy - 0.5f);
529 qWarning(
"Unsupported composition mode");
534 switch(
q->state()->composition_mode) {
608 qWarning(
"Unsupported composition mode");
671 d->nativePaintingActive =
true;
673 d->funcs.glUseProgram(0);
677 d->funcs.glDisableVertexAttribArray(
i);
679#if !QT_CONFIG(opengles2) && !defined(QT_OPENGL_DYNAMIC)
683 if (
fmt.majorVersion() < 3 || (
fmt.majorVersion() == 3 &&
fmt.minorVersion() < 1)
692 float mv_matrix[4][4] =
694 { float(mtx.
m11()), float(mtx.
m12()), 0, float(mtx.
m13()) },
695 { float(mtx.
m21()), float(mtx.
m22()), 0, float(mtx.
m23()) },
697 { float(mtx.
dx()), float(mtx.
dy()), 0, float(mtx.
m33()) }
700 const QSize sz =
d->device->size();
702 glMatrixMode(GL_PROJECTION);
704 glOrtho(0, sz.
width(), sz.
height(), 0, -999999, 999999);
706 glMatrixMode(GL_MODELVIEW);
707 glLoadMatrixf(&mv_matrix[0][0]);
717 d->lastTextureUsed =
GLuint(-1);
719 d->dirtyStencilRegion =
QRect(0, 0,
d->width,
d->height);
721 d->shaderManager->setDirty();
745 float color[] = { 1.0f, 1.0f, 1.0f, 1.0f };
759 d->nativePaintingActive =
false;
770 return d->nativePaintingActive;
806#ifdef QT_OPENGL_CACHE_AS_VBOS
823#ifdef QT_OPENGL_CACHE_AS_VBOS
827 d->unusedIBOSToClean <<
c->ibo;
862 }
else if (
path.isConvex()) {
864 if (
path.isCacheable()) {
868 bool updateCache =
false;
874 if (scaleFactor < 0.5 || scaleFactor > 2.0) {
875#ifdef QT_OPENGL_CACHE_AS_VBOS
876 glDeleteBuffers(1, &
cache->vbo);
880 free(
cache->vertices);
896 int floatSizeInBytes = vertexCount * 2 *
sizeof(float);
897 cache->vertexCount = vertexCount;
898 cache->indexCount = 0;
899 cache->primitiveType = GL_TRIANGLE_FAN;
901#ifdef QT_OPENGL_CACHE_AS_VBOS
907 cache->vertices = (
float *) malloc(floatSizeInBytes);
909 cache->indices =
nullptr;
914#ifdef QT_OPENGL_CACHE_AS_VBOS
926 path.makeCacheable();
934 bool useCache =
path.isCacheable();
948 bool updateCache =
false;
954 if (scaleFactor < 0.5 || scaleFactor > 2.0) {
955#ifdef QT_OPENGL_CACHE_AS_VBOS
956 glDeleteBuffers(1, &
cache->vbo);
957 glDeleteBuffers(1, &
cache->ibo);
959 free(
cache->vertices);
960 free(
cache->indices);
975 cache->primitiveType = GL_TRIANGLES;
978#ifdef QT_OPENGL_CACHE_AS_VBOS
1008#ifdef QT_OPENGL_CACHE_AS_VBOS
1029 path.makeCacheable();
1054 qWarning(
"Painter path exceeds +/-32767 pixels.");
1068 if (
q->state()->clipTestEnabled) {
1071 }
else if (
path.hasWindingFill()) {
1105#ifndef QT_GL_NO_SCISSOR_TEST
1113#ifndef QT_GL_NO_SCISSOR_TEST
1121 if (
ctx->format().stencilBufferSize() <= 0)
1122 qWarning(
"OpenGL paint engine: attempted to use stencil test without requesting a stencil buffer.");
1128 if (
q->state()->clipTestEnabled) {
1149 if (
q->state()->clipTestEnabled) {
1171 if (
q->state()->clipTestEnabled) {
1218 q->state()->currentClip = 1;
1219 q->state()->canRestoreClip =
false;
1252 const bool stateHasOpacity =
q->state()->opacity < 0.99f;
1255 && srcPixelsAreOpaque && !stateHasOpacity))
1320 int previousStop = 0;
1321 for (
int i=0;
i<stopCount; ++
i) {
1322 int stop = stops[
i];
1325 previousStop = stop;
1371 d->setBrush(penBrush);
1372 d->stroke(
path, pen);
1385 const bool opaque = penBrush.
isOpaque() &&
s->opacity > 0.99;
1394 QRectF clip =
q->state()->matrix.inverted().mapRect(
q->state()->clipEnabled
1395 ?
q->state()->rectangleClip
1455 d->brushUniformsDirty =
true;
1465 d->brushUniformsDirty =
true;
1466 d->opacityUniformDirty =
true;
1474 d->compositionModeDirty =
true;
1481#if !QT_CONFIG(opengles2)
1496 d->lastTextureUsed =
GLuint(-1);
1498 d->brushTextureDirty =
true;
1499 d->brushUniformsDirty =
true;
1505 d->matrixDirty =
true;
1512 return QRectF(
r.x() * sx,
r.y() * sy,
r.width() * sx,
r.height() * sy);
1525 int max_texture_size =
ctx->d_func()->maxTextureSize();
1526 if (
pixmap.width() > max_texture_size ||
pixmap.height() > max_texture_size) {
1542 bool isBitmap =
pixmap.isQBitmap();
1543 bool isOpaque = !isBitmap && !
pixmap.hasAlpha();
1548 d->drawTexture(dest, srcRect,
pixmap.size(), isOpaque, isBitmap);
1552 Qt::ImageConversionFlags)
1557 int max_texture_size =
ctx->d_func()->maxTextureSize();
1558 if (
image.width() > max_texture_size ||
image.height() > max_texture_size) {
1573 switch (
image.format()) {
1606 d->drawTexture(dest,
src,
image.size(), !
image.hasAlphaChannel());
1630 d->drawCachedGlyphs(glyphFormat, textItem);
1639 if (!
d->shaderManager)
1651 d->drawTexture(dest, srcRect,
size,
false);
1692 d->drawCachedGlyphs(glyphFormat, &staticTextItem);
1705 QOpenGLStaticTextUserData()
1710 ~QOpenGLStaticTextUserData()
1718 int cacheSerialNumber;
1740 float det =
t.determinant();
1741 if (det >= 0.25f && det <= 4.f) {
1767 void *cacheKey =
ctx;
1768 bool recreateVertexArrays =
false;
1785 if (!
cache ||
cache->glyphFormat() != glyphFormat ||
cache->contextGroup() ==
nullptr) {
1788 recreateVertexArrays =
true;
1791 if (staticTextItem->userDataNeedsUpdate) {
1792 recreateVertexArrays =
true;
1793 }
else if (staticTextItem->userData() ==
nullptr) {
1794 recreateVertexArrays =
true;
1796 recreateVertexArrays =
true;
1798 QOpenGLStaticTextUserData *userData =
static_cast<QOpenGLStaticTextUserData *
>(staticTextItem->userData());
1799 if (userData->glyphFormat != glyphFormat) {
1800 recreateVertexArrays =
true;
1801 }
else if (userData->cacheSerialNumber !=
cache->serialNumber()) {
1802 recreateVertexArrays =
true;
1809 if (recreateVertexArrays) {
1810 cache->setPaintEnginePrivate(
this);
1811 if (!
cache->populate(fe, staticTextItem->numGlyphs,
1812 staticTextItem->glyphs, staticTextItem->glyphPositions,
1816 cache->populate(fe, staticTextItem->numGlyphs,
1817 staticTextItem->glyphs, staticTextItem->glyphPositions,
1821 if (
cache->hasPendingGlyphs()) {
1828 activateTextureUnit(glypchCacheTextureUnit);
1830 cache->fillInPendingGlyphs();
1833 lastTextureUsed =
cache->texture();
1839 cache->setPaintEnginePrivate(
nullptr);
1842 if (
cache->width() == 0 ||
cache->height() == 0)
1859 if (staticTextItem->useBackendOptimizations) {
1860 QOpenGLStaticTextUserData *userData =
nullptr;
1862 if (staticTextItem->userData() ==
nullptr
1865 userData =
new QOpenGLStaticTextUserData();
1866 staticTextItem->setUserData(userData);
1869 userData =
static_cast<QOpenGLStaticTextUserData*
>(staticTextItem->userData());
1872 userData->glyphFormat = glyphFormat;
1873 userData->cacheSerialNumber =
cache->serialNumber();
1876 vertexCoordinates = &userData->vertexCoordinateArray;
1877 textureCoordinates = &userData->textureCoordinateArray;
1880 if (userData->cacheSize !=
size) {
1881 recreateVertexArrays =
true;
1882 userData->cacheSize =
size;
1886 if (recreateVertexArrays) {
1887 vertexCoordinates->
clear();
1888 textureCoordinates->
clear();
1893 for (
int i=0;
i<staticTextItem->numGlyphs; ++
i) {
1895 if (supportsSubPixelPositions) {
1897 if (!verticalSubPixelPositions)
1898 subPixelPosition.
y = 0;
1907 int x =
qFloor(staticTextItem->glyphPositions[
i].x.toReal() *
cache->transform().m11()) +
c.baseLineX - margin;
1908 int y = verticalSubPixelPositions
1909 ?
qRound(staticTextItem->glyphPositions[
i].y.toReal() *
cache->transform().m22())
1910 :
qFloor(staticTextItem->glyphPositions[
i].y.toReal() *
cache->transform().m22());
1911 y -=
c.baseLineY + margin;
1917 staticTextItem->userDataNeedsUpdate =
false;
1924 if (elementIndices.size() <
numGlyphs*6) {
1925 Q_ASSERT(elementIndices.size() % 6 == 0);
1926 int j = elementIndices.size() / 6 * 4;
1928 elementIndices.append(
j + 0);
1929 elementIndices.append(
j + 0);
1930 elementIndices.append(
j + 1);
1931 elementIndices.append(
j + 2);
1932 elementIndices.append(
j + 3);
1933 elementIndices.append(
j + 3);
1938#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
1939 if (elementIndicesVBOId == 0)
1940 funcs.glGenBuffers(1, &elementIndicesVBOId);
1947#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
1957 if (!snapToPixelGrid) {
1958 snapToPixelGrid =
true;
1962 QBrush pensBrush =
q->state()->pen.brush();
1963 setBrush(pensBrush);
1978 qreal oldOpacity =
q->state()->opacity;
1981 q->state()->opacity = 1;
1982 opacityUniformDirty =
true;
1985 compositionModeDirty =
false;
1986 prepareForCachedGlyphDraw(*
cache);
1990 q->state()->opacity = oldOpacity;
1991 opacityUniformDirty =
true;
1994 funcs.glEnable(GL_BLEND);
1996 funcs.glBlendColor(
c.redF(),
c.greenF(),
c.blueF(),
c.alphaF());
2000 qreal oldOpacity =
q->state()->opacity;
2002 q->state()->opacity = 1;
2003 opacityUniformDirty =
true;
2005 setBrush(pensBrush);
2008 compositionModeDirty =
false;
2009 prepareForCachedGlyphDraw(*
cache);
2010 funcs.glEnable(GL_BLEND);
2011 funcs.glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
2015#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
2016 funcs.glDrawElements(GL_TRIANGLE_STRIP, 6 *
numGlyphs, GL_UNSIGNED_SHORT, 0);
2018 const bool useIndexVbo = uploadIndexData(elementIndices.data(), GL_UNSIGNED_SHORT, 6 *
numGlyphs);
2019 funcs.glDrawElements(GL_TRIANGLE_STRIP, 6 *
numGlyphs, GL_UNSIGNED_SHORT, useIndexVbo ?
nullptr : elementIndices.data());
2025 q->state()->opacity = oldOpacity;
2026 opacityUniformDirty =
true;
2027 pensBrush =
q->state()->pen.brush();
2028 setBrush(pensBrush);
2031 compositionModeDirty =
false;
2032 prepareForCachedGlyphDraw(*
cache);
2033 funcs.glEnable(GL_BLEND);
2034 funcs.glBlendFunc(GL_ONE, GL_ONE);
2036 compositionModeDirty =
true;
2038 currentBrush = noBrush;
2040 if (prepareForCachedGlyphDraw(*
cache))
2046 prepareForCachedGlyphDraw(*
cache);
2059 if (
cache->filterMode() != filterMode) {
2060 updateMode = ForceUpdate;
2061 cache->setFilterMode(filterMode);
2064 updateTexture(textureUnit,
cache->texture(), GL_REPEAT, glFilterMode, updateMode);
2066#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
2067 funcs.glDrawElements(GL_TRIANGLE_STRIP, 6 *
numGlyphs, GL_UNSIGNED_SHORT, 0);
2070 const bool useIndexVbo = uploadIndexData(elementIndices.data(), GL_UNSIGNED_SHORT, 6 *
numGlyphs);
2071 funcs.glDrawElements(GL_TRIANGLE_STRIP, 6 *
numGlyphs, GL_UNSIGNED_SHORT, useIndexVbo ?
nullptr : elementIndices.data());
2078 QPainter::PixmapFragmentHints hints)
2088 int max_texture_size =
d->ctx->d_func()->maxTextureSize();
2089 if (
pixmap.width() > max_texture_size ||
pixmap.height() > max_texture_size) {
2091 d->drawPixmapFragments(fragments, fragmentCount,
scaled, hints);
2093 d->drawPixmapFragments(fragments, fragmentCount,
pixmap, hints);
2100 QPainter::PixmapFragmentHints hints)
2114 bool allOpaque =
true;
2116 for (
int i = 0;
i < fragmentCount; ++
i) {
2119 if (fragments[
i].rotation != 0) {
2137 (fragments[
i].sourceLeft + fragments[
i].
width) * dx,
2138 (fragments[
i].sourceTop + fragments[
i].
height) * dy);
2148 opacityArray << opacity << opacity << opacity << opacity << opacity << opacity;
2149 allOpaque &= (opacity >= 0.99f);
2161 bool isBitmap =
pixmap.isQBitmap();
2189 d->device->ensureActiveTarget();
2192 qWarning(
"QPainter::begin(): QOpenGLPaintDevice's context needs to be current");
2198 d->vertexBuffer.destroy();
2199 d->texCoordBuffer.destroy();
2200 d->opacityBuffer.destroy();
2201 d->indexBuffer.destroy();
2206 d->ctx->d_func()->active_engine =
this;
2210 d->funcs.initializeOpenGLFunctions();
2219 &&
d->ctx->format().version() >=
qMakePair(3, 2);
2220 if (needsVAO && !
d->vao.isCreated()) {
2221 bool created =
d->vao.create();
2229 if (!
d->vertexBuffer.isCreated()) {
2230 d->vertexBuffer.create();
2234 if (!
d->texCoordBuffer.isCreated()) {
2235 d->texCoordBuffer.create();
2238 if (!
d->opacityBuffer.isCreated()) {
2239 d->opacityBuffer.create();
2242 if (!
d->indexBuffer.isCreated()) {
2243 d->indexBuffer.create();
2248 d->vertexAttributeArraysEnabledState[
i] =
false;
2250 const QSize sz =
d->device->size();
2254 d->brushTextureDirty =
true;
2255 d->brushUniformsDirty =
true;
2256 d->matrixUniformDirty =
true;
2257 d->matrixDirty =
true;
2258 d->compositionModeDirty =
true;
2259 d->opacityUniformDirty =
true;
2260 d->needsSync =
true;
2264 d->dirtyStencilRegion =
QRect(0, 0,
d->width,
d->height);
2265 d->stencilClean =
true;
2269 d->funcs.glDisable(GL_STENCIL_TEST);
2270 d->funcs.glDisable(GL_DEPTH_TEST);
2271 d->funcs.glDisable(GL_SCISSOR_TEST);
2275#if !QT_CONFIG(opengles2)
2279 d->multisamplingAlwaysEnabled =
false;
2285 d->multisamplingAlwaysEnabled =
d->device->context()->format().samples() > 1;
2298 d->funcs.glUseProgram(0);
2301 ctx->d_func()->active_engine =
nullptr;
2305 delete d->shaderManager;
2306 d->shaderManager =
nullptr;
2309#ifdef QT_OPENGL_CACHE_AS_VBOS
2310 if (!
d->unusedVBOSToClean.isEmpty()) {
2311 glDeleteBuffers(
d->unusedVBOSToClean.size(),
d->unusedVBOSToClean.constData());
2312 d->unusedVBOSToClean.clear();
2314 if (!
d->unusedIBOSToClean.isEmpty()) {
2315 glDeleteBuffers(
d->unusedIBOSToClean.size(),
d->unusedIBOSToClean.constData());
2316 d->unusedIBOSToClean.clear();
2328 if (
d->vao.isCreated())
2331 if (
isActive() &&
ctx->d_func()->active_engine !=
this) {
2332 ctx->d_func()->active_engine =
this;
2333 d->needsSync =
true;
2337 d->device->ensureActiveTarget();
2340 d->funcs.glViewport(0, 0,
d->width,
d->height);
2341 d->needsSync =
false;
2342 d->shaderManager->setDirty();
2344 for (
int i = 0;
i < 3; ++
i)
2345 d->vertexAttribPointers[
i] = (
GLfloat*)-1;
2353 if (
q->state()->clipTestEnabled) {
2355 if (
ctx->format().stencilBufferSize() <= 0)
2356 qWarning(
"OpenGL paint engine: attempted to use stencil test for clipping without requesting a stencil buffer.");
2365#ifdef QT_GL_NO_SCISSOR_TEST
2368 QRect bounds =
q->state()->rectangleClip;
2369 if (!
q->state()->clipEnabled) {
2412 d->regenerateClip();
2414 d->systemStateChanged();
2426 q->state()->needsClipBufferClear =
false;
2443 const bool singlePass = !
path.hasWindingFill()
2444 && (((
q->state()->currentClip ==
maxClip - 1) &&
q->state()->clipTestEnabled)
2445 ||
q->state()->needsClipBufferClear);
2446 const uint referenceClipValue =
q->state()->needsClipBufferClear ? 1 :
q->state()->currentClip;
2448 if (
q->state()->needsClipBufferClear)
2451 if (
path.isEmpty()) {
2457 if (
q->state()->clipTestEnabled)
2485 if (!
q->state()->clipTestEnabled &&
path.hasWindingFill()) {
2514 if (
d->hasClipOperations()) {
2515 d->systemStateChanged();
2520#ifndef QT_GL_NO_SCISSOR_TEST
2531 d->updateClipScissorTest();
2541 if (
d->useSystemClip) {
2549 d->updateClipScissorTest();
2553 d->updateClipScissorTest();
2554 d->resetClipIfNeeded();
2556 d->writeClip(
path,
d->maxClip);
2575 q->state()->clipChanged =
true;
2589 q->state()->clipTestEnabled =
false;
2590 q->state()->needsClipBufferClear =
true;
2592 q->state()->currentClip = 1;
2601#ifndef QT_GL_NO_SCISSOR_TEST
2613 q->state()->currentClip = 0;
2615 q->state()->currentClip = 1;
2616 q->state()->clipTestEnabled =
true;
2645 d->matrixDirty =
true;
2648 d->compositionModeDirty =
true;
2651 d->opacityUniformDirty =
true;
2655 d->updateClipScissorTest();
2656 d->funcs.glDepthFunc(GL_LEQUAL);
2658 d->regenerateClip();
2674 s->matrixChanged =
false;
2675 s->compositionModeChanged =
false;
2676 s->opacityChanged =
false;
2677 s->renderHintsChanged =
false;
2678 s->clipChanged =
false;
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
const QGradient * gradient() const
Returns the gradient describing this brush.
QImage textureImage() const
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set.
const QColor & color() const
Returns the brush color.
Qt::BrushStyle style() const
Returns the brush style.
QTransform transform() const
The QColor class provides colors based on RGB, HSV or CMYK values.
float alphaF() const noexcept
Returns the alpha color component of this color.
QPainterPath::ElementType * elementTypes() const
void process(const QVectorPath &path, const QPen &pen, const QRectF &clip, QPainter::RenderHints hints)
void setInvScale(qreal invScale)
void setGlyphCache(const void *key, QFontEngineGlyphCache *data)
virtual int glyphMargin(GlyphFormat format)
virtual bool supportsVerticalSubPixelPositions() const
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
virtual bool supportsTransformation(const QTransform &transform) const
bool supportsSubPixelPositions() const
QFontEngineGlyphCache * glyphCache(const void *key, GlyphFormat format, const QTransform &transform, const QColor &color=QColor()) const
virtual QFixedPoint subPixelPositionFor(const QFixedPoint &position) const
Spread spread() const
Returns the spread method use by this gradient.
Type type() const
Returns the type of gradient.
QImage scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QSize size() const
Returns the size of the image, i.e.
int width() const
Returns the width of the image.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
int height() const
Returns the height of the image.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
static QOpenGL2GradientCache * cacheForContext(QOpenGLContext *context)
GLuint getBuffer(const QGradient &gradient, qreal opacity)
void addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline=true)
void addQuad(const QRectF &rect)
QOpenGLRect boundingRect() const
void addVertex(const GLfloat x, const GLfloat y)
QOpenGLEngineShaderManager * shaderManager
GLfloat staticVertexCoordinateArray[8]
void updateBrushUniforms()
bool uploadIndexData(const void *data, GLenum indexValueType, GLuint count)
GLuint elementIndicesVBOId
static void cleanupVectorPath(QPaintEngineEx *engine, void *data)
void writeClip(const QVectorPath &path, uint value)
void updateCompositionMode()
void updateTexture(GLenum textureUnit, const T &texture, GLenum wrapMode, GLenum filterMode, TextureUpdateMode updateMode=UpdateIfNeeded)
QOpenGL2PEXVertexArray vertexCoordinateArray
GLfloat staticTextureCoordinateArray[8]
void systemStateChanged() override
QOpenGLBuffer vertexBuffer
QDashedStrokeProcessor dasher
void transferMode(EngineMode newMode)
~QOpenGL2PaintEngineExPrivate()
QRect currentScissorBounds
QOpenGLBuffer opacityBuffer
void composite(const QOpenGLRect &boundingRect)
GLuint bindTexture(const T &texture, bool *newTextureCreated)
bool prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache)
void stroke(const QVectorPath &path, const QPen &pen)
QOpenGL2PEXVertexArray textureCoordinateArray
void updateBrushTexture()
QOpenGLBuffer texCoordBuffer
void drawTexture(const QOpenGLRect &dest, const QOpenGLRect &src, const QSize &textureSize, bool opaque, bool pattern=false)
void activateTextureUnit(GLenum textureUnit)
bool compositionModeDirty
QRegion dirtyStencilRegion
QTriangulatingStroker stroker
void setVertexAttribArrayEnabled(int arrayIndex, bool enabled=true)
QOpenGLPaintDevice * device
void uploadData(unsigned int arrayIndex, const GLfloat *data, GLuint count)
QOpenGLBuffer indexBuffer
void fill(const QVectorPath &path)
void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
bool prepareForDraw(bool srcPixelsAreOpaque)
void fillStencilWithVertexArray(const float *data, int count, int *stops, int stopCount, const QOpenGLRect &bounds, StencilFillMode mode)
QOpenGLVertexArrayObject vao
void setBrush(const QBrush &brush)
void drawVertexArrays(const float *data, int *stops, int stopCount, GLenum primitive)
void setScissor(const QRect &rect)
bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT]
QDataBuffer< GLfloat > opacityArray
GLenum lastTextureUnitUsed
void updateClipScissorTest()
void clearClip(uint value)
bool end() override
Reimplement this function to finish painting on the current paint device.
virtual void drawStaticTextItem(QStaticTextItem *textItem) override
void endNativePainting() override
virtual void clip(const QVectorPath &path, Qt::ClipOperation op) override
virtual void brushChanged() override
virtual void stroke(const QVectorPath &path, const QPen &pen) override
virtual void brushOriginChanged() override
virtual void penChanged() override
bool begin(QPaintDevice *device) override
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
friend class QOpenGLEngineShaderManager
virtual void setState(QPainterState *s) override
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.
virtual void transformChanged() override
virtual QPainterState * createState(QPainterState *orig) const override
bool isNativePaintingActive() const
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem) override
This function draws the text item textItem at position p.
virtual void renderHintsChanged() override
bool shouldDrawCachedGlyphs(QFontEngine *, const QTransform &) const override
virtual void clipEnabledChanged() override
bool drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr)
virtual void fill(const QVectorPath &path, const QBrush &brush) override
QOpenGL2PaintEngineState * state()
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor) override
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
void beginNativePainting() override
virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints) override
virtual void compositionModeChanged() override
virtual void opacityChanged() override
uint compositionModeChanged
uint needsClipBufferClear
QOpenGL2PaintEngineState()
~QOpenGL2PaintEngineState()
void destroy()
Destroys this buffer object, including the storage being used in the OpenGL server.
QSurfaceFormat format() const
Returns the format of the underlying platform context, if create() has been called.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
QOpenGLShaderProgram * currentProgram()
void setSrcPixelType(Qt::BrushStyle)
void setOpacityMode(OpacityMode)
void setMaskType(MaskType)
bool hasComplexGeometry() const
void optimiseForBrushTransform(QTransform::TransformationType transformType)
@ NonPremultipliedImageSrc
void setHasComplexGeometry(bool hasComplexGeometry)
bool useCorrectShaderProg()
void setCompositionMode(QPainter::CompositionMode)
bool hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension extension) const
Returns true if extension is present on this system's OpenGL implementation; false otherwise.
void glStencilFunc(GLenum func, GLint ref, GLuint mask)
Convenience function that calls glStencilFunc(func, ref, mask).
void glBlendFunc(GLenum sfactor, GLenum dfactor)
Convenience function that calls glBlendFunc(sfactor, dfactor).
void glBufferData(GLenum target, qopengl_GLsizeiptr size, const void *data, GLenum usage)
Convenience function that calls glBufferData(target, size, data, usage).
void glDeleteBuffers(GLsizei n, const GLuint *buffers)
Convenience function that calls glDeleteBuffers(n, buffers).
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
Convenience function that calls glDrawElements(mode, count, type, indices).
void glDrawArrays(GLenum mode, GLint first, GLsizei count)
Convenience function that calls glDrawArrays(mode, first, count).
void glClearDepthf(GLclampf depth)
Convenience function that calls glClearDepth(depth) on desktop OpenGL systems and glClearDepthf(depth...
void glClear(GLbitfield mask)
Convenience function that calls glClear(mask).
void glBindBuffer(GLenum target, GLuint buffer)
Convenience function that calls glBindBuffer(target, buffer).
void glClearStencil(GLint s)
Convenience function that calls glClearStencil(s).
void glDisableVertexAttribArray(GLuint index)
Convenience function that calls glDisableVertexAttribArray(index).
void glTexParameteri(GLenum target, GLenum pname, GLint param)
Convenience function that calls glTexParameteri(target, pname, param).
void glVertexAttrib4fv(GLuint indx, const GLfloat *values)
Convenience function that calls glVertexAttrib4fv(indx, values).
void glEnableVertexAttribArray(GLuint index)
Convenience function that calls glEnableVertexAttribArray(index).
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
Convenience function that calls glColorMask(red, green, blue, alpha).
void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
Convenience function that calls glScissor(x, y, width, height).
void glBindTexture(GLenum target, GLuint texture)
Convenience function that calls glBindTexture(target, texture).
void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
Convenience function that calls glStencilOp(fail, zfail, zpass).
void glDepthMask(GLboolean flag)
Convenience function that calls glDepthMask(flag).
void glActiveTexture(GLenum texture)
Convenience function that calls glActiveTexture(texture).
void glDisable(GLenum cap)
Convenience function that calls glDisable(cap).
void glGenBuffers(GLsizei n, GLuint *buffers)
Convenience function that calls glGenBuffers(n, buffers).
void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
Convenience function that calls glStencilOpSeparate(face, fail, zfail, zpass).
void glBlendEquation(GLenum mode)
Convenience function that calls glBlendEquation(mode).
void glEnable(GLenum cap)
Convenience function that calls glEnable(cap).
void glStencilMask(GLuint mask)
Convenience function that calls glStencilMask(mask).
void glDepthFunc(GLenum func)
Convenience function that calls glDepthFunc(func).
void glVertexAttrib3fv(GLuint indx, const GLfloat *values)
Convenience function that calls glVertexAttrib3fv(indx, values).
virtual void beginPaint()
static QOpenGLPaintDevicePrivate * get(QOpenGLPaintDevice *dev)
The QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter.
bool paintFlipped() const
Returns true if painting is flipped around the Y-axis.
QOpenGLContext * context() const
Returns the OpenGL context associated with the paint device.
void setUniformValue(int location, GLfloat value)
Sets the uniform variable at location in the current context to value.
BindResult bindTexture(QOpenGLContext *context, const QPixmap &pixmap, QOpenGLTextureUploader::BindOptions options=QOpenGLTextureUploader::PremultipliedAlphaBindOption)
static QOpenGLTextureCache * cacheForContext(QOpenGLContext *context)
@ PremultipliedAlphaBindOption
@ UseRedForAlphaAndLuminanceBindOption
void destroy()
Destroys the underlying OpenGL vertex array object.
void release()
Unbinds this vertex array object by binding the default vertex array object (id = 0).
bool isCreated() const
Returns true is the underlying OpenGL vertex array object has been created.
virtual int devType() const
void replayClipOperations()
virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QFlags< QPainter::PixmapFragmentHint > hints)
virtual void stroke(const QVectorPath &path, const QPen &pen)
virtual bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const
virtual void setState(QPainterState *s)
virtual void drawStaticTextItem(QStaticTextItem *)
QPaintDevice * currentClipDevice
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
QPainter * painter() const
Returns the paint engine's painter.
virtual ~QPaintEngine()
Destroys the paint engine.
PaintEngineFeatures gccaps
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
QRegion systemClip() const
QPainter::CompositionMode composition_mode
QPainter::RenderHints renderHints
This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a ...
@ NonCosmeticBrushPatterns
@ VerticalSubpixelPositioning
CompositionMode
Defines the modes supported for digital image compositing.
@ CompositionMode_Destination
@ CompositionMode_Lighten
@ CompositionMode_ColorDodge
@ CompositionMode_DestinationAtop
@ CompositionMode_SourceOver
@ CompositionMode_DestinationOut
@ CompositionMode_SourceAtop
@ CompositionMode_Overlay
@ CompositionMode_Multiply
@ CompositionMode_DestinationOver
@ CompositionMode_HardLight
@ CompositionMode_Exclusion
@ CompositionMode_ColorBurn
@ CompositionMode_Difference
@ CompositionMode_SoftLight
@ CompositionMode_DestinationIn
@ CompositionMode_SourceOut
@ CompositionMode_SourceIn
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
qreal miterLimit() const
Returns the miter limit of the pen.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
int height() const
Returns the height of the pixmap.
int width() const
Returns the width of the pixmap.
bool isQBitmap() const
Returns true if this is a QBitmap; otherwise returns false.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
\inmodule QtCore\reentrant
QRect intersected(const QRect &other) const noexcept
The QRegion class specifies a clip region for a painter.
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
int rectCount() const noexcept
bool intersects(const QRegion &r) const
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
QRegion intersected(const QRegion &r) const
constexpr QSize boundedTo(const QSize &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
QFontEngine * fontEngine() const
QFixedPoint * glyphPositions
void setFontEngine(QFontEngine *fe)
const float * vertices() const
void setInvScale(qreal invScale)
void process(const QVectorPath &path, const QPen &pen, const QRectF &clip, QPainter::RenderHints hints)
constexpr size_type size() const noexcept
const T * constData() const
The QVector2D class represents a vector or vertex in 2D space.
float length() const noexcept
Returns the length of the vector from the origin.
The QVector3D class represents a vector or vertex in 3D space.
const void * data() const
static VulkanServerBufferGlFunctions * funcs
QCache< int, Employee > cache
[0]
Combined button and popup list for selecting options.
Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert)
bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush &brush)
#define QByteArrayLiteral(str)
#define QT_WARNING_DISABLE_MSVC(number)
static const QCssKnownValue positions[NumKnownPositionModes - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyIsNull(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
constexpr quint32 qNextPowerOfTwo(quint32 v)
constexpr float qDegreesToRadians(float degrees)
QRect qt_mapFillRect(const QRectF &rect, const QTransform &xf)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
static const GLuint QT_TEXTURE_COORDS_ATTR
static const GLuint QT_PMV_MATRIX_2_ATTR
static const GLuint QT_OPACITY_ATTR
static const GLuint QT_PMV_MATRIX_1_ATTR
static QT_BEGIN_NAMESPACE const GLuint QT_VERTEX_COORDS_ATTR
static const GLuint QT_PMV_MATRIX_3_ATTR
n uniform mediump vec2 halfViewportSize
GLint GLint GLint GLint GLint x
[0]
#define GL_BLEND_ADVANCED_COHERENT_KHR
typedef GLfloat(GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC)(GLuint path
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
#define GL_DIFFERENCE_KHR
GLsizei const GLubyte GLsizei GLenum const void * coords
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum const void GLbitfield GLsizei numGlyphs
#define GL_COLORDODGE_KHR
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define GL_MIRRORED_REPEAT
GLuint GLenum GLenum transform
GLfixed GLfixed GLint GLint GLfixed points
#define GL_CONSTANT_COLOR
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLfloat GLfloat GLfloat alpha
GLenum GLenum GLenum GLenum GLenum scale
#define GL_ELEMENT_ARRAY_BUFFER
typedef GLushort(APIENTRYP PFNGLGETSTAGEINDEXNVPROC)(GLenum shadertype)
static void setCoords(GLfloat *coords, const QOpenGLRect &rect)
static bool isPowerOfTwo(int x)
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
QT_BEGIN_NAMESPACE Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert)
static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy)
QColor qt_premultiplyColor(QColor c, GLfloat opacity)
#define QT_GL_VERTEX_ARRAY_TRACKED_COUNT
@ ImageOpacityArrayDrawingMode
#define QT_UNKNOWN_TEXTURE_UNIT
#define QT_MASK_TEXTURE_UNIT
#define QT_IMAGE_TEXTURE_UNIT
#define QT_DEFAULT_TEXTURE_UNIT
#define QT_BRUSH_TEXTURE_UNIT
#define GL_STENCIL_HIGH_BIT
static quint64 cacheSize()
static const QRectF boundingRect(const QPointF *points, int pointCount)
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
qreal qpen_widthf(const QPen &p)
Qt::BrushStyle qbrush_style(const QBrush &b)
Qt::PenStyle qpen_style(const QPen &p)
QBrush qpen_brush(const QPen &p)
bool qbrush_fast_equals(const QBrush &a, const QBrush &b)
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
#define Q_TRACE_PARAM_REPLACE(in, out)
#define Q_TRACE_SCOPE(x,...)
#define Q_TRACE_INSTRUMENT(provider)
Q_GUI_EXPORT QTriangleSet qTriangulate(const qreal *polygon, int count, uint hint, const QTransform &matrix, bool allowUintIndices)
QVideoFrameFormat::PixelFormat fmt
static bool translate(xcb_connection_t *connection, xcb_window_t child, xcb_window_t parent, int *x, int *y)
QImage scaled(const QImage &image)
[0]
QOpenGLTextureUploader::BindOptions options
QVertexIndexVector::Type indexType
QVertexIndexVector indices