43 #include <private/qfontengine_p.h> 45 #include <private/qmath_p.h> 46 #include <private/qdrawhelper_p.h> 47 #include <private/qpaintengine_p.h> 51 #include <private/qgl_p.h> 52 #include <private/qglpaintdevice_p.h> 53 #include <private/qpainter_p.h> 55 #include <private/qpaintengine_opengl_p.h> 56 #include <private/qdatabuffer_p.h> 59 #include <private/qpainter_p.h> 60 #include <private/qglpixelbuffer_p.h> 61 #include <private/qbezier_p.h> 63 #include <private/qstatictext_p.h> 65 #include "private/qtessellator_p.h" 70 #include "private/qglwindowsurface_qws_p.h" 72 #include "private/qwsmanager_p.h" 75 #define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(device->context()); 83 #ifdef QT_MAC_USE_COCOA 84 extern void *qt_current_nsopengl_context();
87 #define QREAL_MAX 9e100 88 #define QREAL_MIN -9e100 92 #define DISABLE_DEBUG_ONCE 96 #ifdef DISABLE_DEBUG_ONCE 97 #define DEBUG_OVERRIDE(state) ; 98 #define DEBUG_ONCE_STR(str) ; 99 #define DEBUG_ONCE if (0) 101 static int DEBUG_OVERRIDE_FLAG = 0;
102 static bool DEBUG_TEMP_FLAG;
103 #define DEBUG_OVERRIDE(state) { state ? ++DEBUG_OVERRIDE_FLAG : --DEBUG_OVERRIDE_FLAG; } 104 #define DEBUG_ONCE if ((DEBUG_TEMP_FLAG = DEBUG_OVERRIDE_FLAG) && 0) ; else for (static int DEBUG_ONCE_FLAG = false; !DEBUG_ONCE_FLAG || DEBUG_TEMP_FLAG; DEBUG_ONCE_FLAG = true, DEBUG_TEMP_FLAG = false) 105 #define DEBUG_ONCE_STR(str) DEBUG_ONCE qDebug() << (str); 114 glColor4f(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, col[3]/255.0f);
131 topRightX(topRightX_),
132 bottomLeftX(bottomLeftX_),
133 bottomRightX(bottomRightX_)
149 trap.
top += delta.
y();
166 void setOffscreenSize(
const QSize &offscreenSize);
167 void setDrawableSize(
const QSize &drawableSize);
178 path(p), matrix(m), stroke_width(w), age(0) {}
200 enum {block_size = 64};
203 void maintainCache();
218 void quadtreeUpdate(
int channel,
int node,
int current_block_size);
219 void quadtreeAllocate(
quint64 key,
const QSize &size,
QRect *rect,
int *channel);
221 bool quadtreeFindAvailableLocation(
const QSize &size,
QRect *rect,
int *channel);
222 void quadtreeFindExistingLocation(
const QSize &size,
QRect *rect,
int *channel);
224 void quadtreeInsert(
int channel,
quint64 key,
const QRect &rect,
int node = 0);
225 void quadtreeClear(
int channel,
const QRect &rect,
int node = 0);
227 int quadtreeBlocksize(
int node);
228 QPoint quadtreeLocation(
int node);
258 inline void release();
260 inline bool isBound()
const;
262 inline QSize drawableSize()
const;
263 inline QSize offscreenSize()
const;
265 inline GLuint offscreenTexture()
const;
269 static bool isSupported();
271 inline void initialize();
273 inline bool isValid()
const;
277 if (context ==
ctx) {
306 device = static_cast<QGLPaintDevice*>(pdev);
338 bool would_fail = last_failed_size.isValid() &&
339 (device->size().width() >= last_failed_size.width() ||
340 device->size().height() >= last_failed_size.height());
341 bool needs_refresh = dim > mask_dim || !shared_context;
343 if (needs_refresh && !would_fail) {
344 DEBUG_ONCE qDebug() <<
"QGLOffscreen::initialize(): creating offscreen of size" << dim;
349 if (!offscreen->isValid()) {
350 qWarning(
"QGLOffscreen: Invalid offscreen fbo (size %dx%d)", mask_dim, mask_dim);
354 last_failed_size = device->size();
358 qt_mask_texture_cache()->setOffscreenSize(offscreenSize());
359 qt_mask_texture_cache()->setDrawableSize(device->size());
360 ctx = device->context();
373 #ifdef DEBUG_DISPLAY_MASK_TEXTURE 376 glMatrixMode(GL_MODELVIEW);
378 glColor4f(1, 1, 1, 1);
386 glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0);
387 glTexCoord2f(1.0, 1.0); glVertex2f(drawable.size().width(), 0.0);
388 glTexCoord2f(1.0, 0.0); glVertex2f(drawable.size().width(), drawable.size().height());
389 glTexCoord2f(0.0, 0.0); glVertex2f(0.0, drawable.size().height());
402 if (!offscreen || bound)
410 glViewport(0, 0, offscreenSize().width(), offscreenSize().height());
412 glMatrixMode(GL_PROJECTION);
414 glOrtho(0, offscreenSize().width(), offscreenSize().height(), 0, -999999, 999999);
415 glMatrixMode(GL_MODELVIEW);
422 if (!offscreen || !bound)
434 device->ensureActiveTarget();
436 offscreen->release();
438 QSize sz(device->size());
439 glViewport(0, 0, sz.width(), sz.height());
441 glMatrixMode(GL_PROJECTION);
444 glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999);
446 glOrthof(0, sz.width(), sz.height(), 0, -999999, 999999);
448 glMatrixMode(GL_MODELVIEW);
461 return device->size();
466 return QSize(mask_dim, mask_dim);
471 return offscreen ? offscreen->texture() : 0;
494 brush_origin(_brush_origion),
495 composition_mode(_composition_mode),
538 for (
int i=0; i<progs.
size(); ++i) {
552 for (
int i=0; i<contexts.
size(); ++i) {
556 for (
int k=0; k<progs.
size(); ++k) {
560 programs.insert(ctx, prg);
565 programs.insert(ctx, prg);
578 prg.
mask = mask_mode;
581 const char *src = mask_mode
585 const GLbyte *gl_src =
reinterpret_cast<const GLbyte *
>(src);
589 int(strlen(src)), gl_src);
597 programs.insert(ctx, prg);
605 while (it != programs.end()) {
606 if (it.key() == context) {
615 it = programs.erase(it);
644 void cleanupGLContextRefs(
const QGLContext *context);
656 , composition_mode(
QPainter::CompositionMode_SourceOver)
659 , has_fast_pen(false)
660 , use_stencil_method(false)
661 , dirty_drawable_texture(false)
662 , has_stencil_face_ext(false)
663 , use_fragment_programs(false)
664 , high_quality_antialiasing(false)
665 , use_smooth_pixmap_transform(false)
666 , use_emulation(false)
670 , last_created_state(0)
674 , drawable_texture(0)
683 pen_color[3] = alpha;
691 brush_color[3] = alpha;
694 inline void setGradientOps(
const QBrush &brush,
const QRectF &bounds);
695 void createGradientPaletteTexture(
const QGradient& g);
697 void updateGradient(
const QBrush &brush,
const QRectF &bounds);
703 void drawVertexArrays();
705 void fillPolygon_dev(
const QPointF *polygonPoints,
int pointCount,
708 void drawFastRect(
const QRectF &rect);
709 void strokePath(
const QPainterPath &path,
bool use_cache);
713 void updateDepthClip();
714 void systemStateChanged();
717 if (context == shader_ctx)
722 qreal pen_width = cpen.widthF();
725 || cpen.isCosmetic())
731 void disableClipping();
732 void enableClipping();
733 void ensureDrawableTexture();
761 void updateUseEmulation();
764 GLubyte pen_color[4];
765 GLubyte brush_color[4];
775 bool isFastRect(
const QRectF &r);
783 void composite(GLuint primitive,
const GLfloat *vertexArray,
int vertexCount,
const QPoint &maskOffset =
QPoint());
785 bool createFragmentPrograms();
786 void deleteFragmentPrograms();
787 void updateFragmentProgramData(
int locations[]);
789 void cacheItemErased(
int channel,
const QRect &rect);
793 void flushDrawQueue();
795 void copyDrawable(
const QRectF &rect);
797 void updateGLMatrix()
const;
807 float inv_matrix_data[3][4];
809 float fmp2_m_radius2_data[4];
811 float linear_data[4];
813 float porterduff_ab_data[4];
814 float porterduff_xyz_data[4];
816 float mask_offset_data[4];
817 float mask_channel_data[4];
822 void setPorterDuffData(
float a,
float b,
float x,
float y,
float z);
823 void setInvMatrixData(
const QTransform &inv_matrix);
833 GLdouble projection_matrix[4][4];
835 #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) 836 GLfloat mv_matrix[4][4];
838 GLdouble mv_matrix[4][4];
874 glMatrixMode(GL_MODELVIEW);
890 glMatrixMode(GL_MODELVIEW);
899 p->cleanupGLContextRefs(context);
905 if (smoothPixmapTransform) {
944 path(p), stroked_path(sp), pen(stroke_pen) {}
956 for (
int i = 0; i < path.
elementCount() && i <= 2; i++) {
961 QGLStrokeTableHash::const_iterator
it = cache.constFind(hash_val);
963 if (it == cache.constEnd())
964 return addCacheElement(hash_val, path, pen);
967 const CacheInfo &cache_info = it.value();
968 if (cache_info.
path == path && cache_info.
pen == pen)
971 }
while (it != cache.constEnd() && it.key() == hash_val);
973 return addCacheElement(hash_val, path, pen);
980 if (cache.size() == maxCacheSize()) {
981 int elem_to_remove =
qrand() % maxCacheSize();
982 cache.remove(cache.keys()[elem_to_remove]);
985 CacheInfo cache_entry(path, stroke, pen);
986 return cache.insert(hash_val, cache_entry).value().stroked_path;
1000 stops(s), opacity(op), interpolationMode(mode) {}
1027 for (
int i = 0; i < stops.
size() && i <= 2; i++)
1028 hash_val += stops[i].second.rgba();
1030 QGLGradientColorTableHash::const_iterator
it = cache.constFind(hash_val);
1032 if (it == cache.constEnd())
1033 return addCacheElement(hash_val, gradient, opacity);
1036 const CacheInfo &cache_info = it.value();
1038 return cache_info.
texId;
1041 }
while (it != cache.constEnd() && it.key() == hash_val);
1043 return addCacheElement(hash_val, gradient, opacity);
1051 inline void generateGradientColorTable(
const QGradient& g,
1053 int size,
qreal opacity)
const;
1055 if (cache.size() == maxCacheSize()) {
1056 int elem_to_remove =
qrand() % maxCacheSize();
1060 QGLGradientColorTableHash::const_iterator
it = cache.constFind(key);
1062 glDeleteTextures(1, &it.value().texId);
1063 }
while (++it != cache.constEnd() && it.key() ==
key);
1068 generateGradientColorTable(gradient, buffer, paletteSize(), opacity);
1069 glGenTextures(1, &cache_entry.texId);
1070 #ifndef QT_OPENGL_ES 1071 glBindTexture(GL_TEXTURE_1D, cache_entry.texId);
1072 glTexImage1D(GL_TEXTURE_1D, 0,
GL_RGBA, paletteSize(),
1077 return cache.insert(hash_val, cache_entry).value().texId;
1082 QGLGradientColorTableHash::const_iterator
it = cache.constBegin();
1083 for (; it != cache.constEnd(); ++
it) {
1084 const CacheInfo &cache_info = it.value();
1085 glDeleteTextures(1, &cache_info.
texId);
1096 if (context == buffer_ctx) {
1105 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN 1108 return ( (c << 24) & 0xff000000)
1109 | ((c >> 24) & 0x000000ff)
1110 | ((c << 8) & 0x00ff0000)
1111 | ((c >> 8) & 0x0000ff00);
1112 #endif // Q_BYTE_ORDER 1121 for (
int i = 0; i < s.
size(); ++i)
1122 colors[i] = s[i].second.rgba();
1129 qreal fpos = 1.5 * incr;
1133 colorTable[pos] = colorTable[pos - 1];
1138 if (colorInterpolation)
1139 current_color =
PREMUL(current_color);
1141 for (
int i = 0; i < s.
size() - 1; ++i) {
1144 if (colorInterpolation)
1145 next_color =
PREMUL(next_color);
1147 while (fpos < s[i+1].first && pos < size) {
1148 int dist = int(256 * ((fpos - s[i].first) * delta));
1149 int idist = 256 - dist;
1150 if (colorInterpolation)
1157 current_color = next_color;
1163 for (;pos < size; ++pos)
1164 colorTable[pos] = last_color;
1167 colorTable[size-1] = last_color;
1176 #ifdef QT_OPENGL_ES //### 1179 GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, device->
context());
1180 glBindTexture(GL_TEXTURE_1D, texId);
1181 grad_palette = texId;
1198 current_style = brush.
style();
1201 setGLBrush(brush.
color());
1205 updateGradient(brush, bounds);
1207 #ifndef QT_OPENGL_ES //### GLES does not have GL_TEXTURE_GEN_ so we are falling back for gradients 1208 glDisable(GL_TEXTURE_GEN_S);
1209 glDisable(GL_TEXTURE_1D);
1212 if (high_quality_antialiasing || !has_fast_composition_mode) {
1215 glEnable(GL_TEXTURE_GEN_S);
1216 glEnable(GL_TEXTURE_1D);
1219 if (use_fragment_programs) {
1222 else if (current_style == Qt::ConicalGradientPattern)
1249 d->device = static_cast<QGLPaintDevice*>(pdev);
1256 d->offscreen.setDevice(pdev);
1257 d->has_fast_pen =
false;
1258 d->inverseScale = 1;
1260 d->device->beginPaint();
1262 d->has_antialiasing =
false;
1263 d->high_quality_antialiasing =
false;
1265 QSize sz(
d->device->size());
1266 d->dirty_stencil =
QRect(0, 0, sz.width(), sz.height());
1268 d->use_emulation =
false;
1270 for (
int i = 0; i < 4; ++i)
1271 for (
int j = 0; j < 4; ++j)
1272 d->mv_matrix[i][j] = (i == j ?
qreal(1) :
qreal(0));
1279 qWarning() <<
"QOpenGLPaintEngine: paint device doesn't have a valid GL context.";
1283 if (has_frag_program)
1286 d->use_stencil_method =
d->device->format().stencil()
1288 if (
d->device->format().directRendering()
1293 static bool nvidia_workaround_needs_init =
true;
1294 if (nvidia_workaround_needs_init) {
1299 const int pos = versionString.
indexOf(
"NVIDIA");
1301 const float nvidiaDriverVersion = versionString.
mid(pos + strlen(
"NVIDIA")).
toFloat();
1304 nvidia_workaround_needs_init =
false;
1308 #ifndef QT_OPENGL_ES 1310 glGetDoublev(GL_PROJECTION_MATRIX, &
d->projection_matrix[0][0]);
1311 glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
1312 glPushAttrib(GL_ALL_ATTRIB_BITS);
1314 glDisableClientState(GL_EDGE_FLAG_ARRAY);
1315 glDisableClientState(GL_INDEX_ARRAY);
1317 glDisable(GL_TEXTURE_1D);
1318 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1319 glPixelTransferi(GL_MAP_COLOR,
false);
1320 glPixelTransferi(GL_MAP_STENCIL,
false);
1321 glDisable(GL_TEXTURE_GEN_S);
1323 glPixelStorei(GL_PACK_SWAP_BYTES,
false);
1324 glPixelStorei(GL_PACK_LSB_FIRST,
false);
1325 glPixelStorei(GL_PACK_ROW_LENGTH, 0);
1326 glPixelStorei(GL_PACK_SKIP_ROWS, 0);
1327 glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
1330 glPixelStorei(GL_UNPACK_SWAP_BYTES,
false);
1331 glPixelStorei(GL_UNPACK_LSB_FIRST,
false);
1332 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
1333 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
1334 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
1347 glMatrixMode(GL_MODELVIEW);
1352 glDisableClientState(GL_COLOR_ARRAY);
1353 glDisableClientState(GL_NORMAL_ARRAY);
1354 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1355 glDisableClientState(GL_VERTEX_ARRAY);
1364 glDisable(GL_LIGHTING);
1368 d->offscreen.begin();
1370 glViewport(0, 0, sz.width(), sz.height());
1371 glMatrixMode(GL_PROJECTION);
1374 glOrthof(0, sz.width(), sz.height(), 0, -999999, 999999);
1376 glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999);
1378 glMatrixMode(GL_MODELVIEW);
1384 d->max_texture_size = ctx->d_func()->maxTextureSize();
1389 d->max_texture_size =
d->shader_ctx->d_func()->maxTextureSize();
1391 d->max_texture_size = ctx->d_func()->maxTextureSize();
1393 if (
d->shader_ctx) {
1394 d->shader_ctx->makeCurrent();
1395 glBindTexture(GL_TEXTURE_1D, 0);
1396 glDeleteTextures(1, &
d->grad_palette);
1398 if (has_frag_program &&
d->use_fragment_programs)
1399 glDeleteTextures(1, &
d->drawable_texture);
1402 d->shader_ctx =
d->device->context();
1403 glGenTextures(1, &
d->grad_palette);
1405 qt_mask_texture_cache()->clearCache();
1406 d->use_fragment_programs = has_frag_program;
1409 if (
d->use_fragment_programs && (!shared_ctx || sz.width() >
d->drawable_texture_size.width()
1410 || sz.height() >
d->drawable_texture_size.height()))
1414 glDeleteTextures(1, &
d->drawable_texture);
1416 d->dirty_drawable_texture =
true;
1435 d->flushDrawQueue();
1441 glMatrixMode(GL_MODELVIEW);
1444 #ifndef QT_OPENGL_ES 1448 glMatrixMode(GL_PROJECTION);
1449 glLoadMatrixd(&
d->projection_matrix[0][0]);
1451 glPopClientAttrib();
1454 d->device->endPaint();
1455 qt_mask_texture_cache()->maintainCache();
1457 #if defined(Q_WS_X11) 1460 ctx->d_func()->boundPixmaps.clear();
1468 QPaintEngine::DirtyFlags
flags = state.
state();
1470 bool update_fast_pen =
false;
1473 update_fast_pen =
true;
1475 if (
d->opacity > 1.0f)
1477 if (
d->opacity < 0.f)
1485 update_fast_pen =
true;
1493 update_fast_pen =
true;
1530 if (update_fast_pen) {
1532 qreal pen_width =
d->cpen.widthF();
1535 ||
d->cpen.isCosmetic())
1537 &&
d->cpen.isSolid();
1544 inv_matrix_data[0][0] = inv_matrix.
m11();
1545 inv_matrix_data[1][0] = inv_matrix.
m21();
1546 inv_matrix_data[2][0] = inv_matrix.
m31();
1548 inv_matrix_data[0][1] = inv_matrix.
m12();
1549 inv_matrix_data[1][1] = inv_matrix.
m22();
1550 inv_matrix_data[2][1] = inv_matrix.
m32();
1552 inv_matrix_data[0][2] = inv_matrix.
m13();
1553 inv_matrix_data[1][2] = inv_matrix.
m23();
1554 inv_matrix_data[2][2] = inv_matrix.
m33();
1576 stop = m.
map(realFinal);
1581 qreal odx = realFinal.
x() - realStart.
x();
1582 qreal ody = realFinal.
y() - realStart.
y();
1591 qreal lx = 1 / (dx - dy*nx/ny);
1592 qreal ly = 1 / (dy - dx*ny/nx);
1595 stop = start +
QPointF(-ny, nx) * l/
qSqrt(nx*nx+ny*ny);
1599 tr[0] = stop.
x() - start.
x();
1600 tr[1] = stop.
y() - start.
y();
1601 f = 1.0 / (tr[0]*tr[0] + tr[1]*tr[1]);
1605 tr[3] = -(start.
x()*tr[0] + start.
y()*tr[1]);
1606 brush_color[0] = brush_color[1] = brush_color[2] = brush_color[3] = 255;
1608 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
1609 glTexGenfv(GL_S, GL_OBJECT_PLANE, tr);
1612 if (use_fragment_programs) {
1618 QTransform translate(1, 0, 0, 1, -realFocal.
x(), -realFocal.
y());
1619 QTransform gl_to_qt(1, 0, 0, -1, 0, pdev->height());
1623 setInvMatrixData(inv_matrix);
1625 fmp_data[0] = realCenter.
x() - realFocal.
x();
1626 fmp_data[1] = realCenter.
y() - realFocal.
y();
1628 fmp2_m_radius2_data[0] = -fmp_data[0] * fmp_data[0] - fmp_data[1] * fmp_data[1] + realRadius * realRadius;
1632 QTransform translate(1, 0, 0, 1, -realCenter.
x(), -realCenter.
y());
1633 QTransform gl_to_qt(1, 0, 0, -1, 0, pdev->height());
1637 setInvMatrixData(inv_matrix);
1639 angle_data[0] = -(g->
angle() * 2 *
Q_PI) / 360.0;
1645 QTransform translate(1, 0, 0, 1, -realStart.
x(), -realStart.
y());
1646 QTransform gl_to_qt(1, 0, 0, -1, 0, pdev->height());
1650 setInvMatrixData(inv_matrix);
1654 linear_data[0] = l.
x();
1655 linear_data[1] = l.
y();
1657 linear_data[2] = 1.0f / (l.
x() * l.
x() + l.
y() * l.
y());
1659 QTransform gl_to_qt(1, 0, 0, -1, 0, pdev->height());
1663 setInvMatrixData(inv_matrix);
1668 createGradientPaletteTexture(*brush.
gradient());
1716 trapezoids.reserve(trapezoids.size() + nPoints);
1717 setWinding(winding);
1726 trapezoids.append(toGLTrapezoid(trap));
1729 #ifndef QT_OPENGL_ES 1739 const qreal xpadding = 1.0;
1740 const qreal ypadding = 1.0;
1742 qreal topDist = offscreenHeight - trap.
top;
1745 qreal reciprocal = bottomDist / (bottomDist - topDist);
1752 reciprocal = topZero ? 1.0 / bottomDist : 1.0 / topDist;
1761 glTexCoord4f(topDist, bottomDist, invLeftA, -invRightA);
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;
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());
1777 qreal left_padding = xpadding /
qAbs(leftNormal.x());
1778 qreal right_padding = xpadding /
qAbs(rightNormal.x());
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);
1785 glTexCoord4f(0.0f, 0.0f, 0.0f, 1.0f);
1801 setWinding(winding);
1809 #ifndef QT_OPENGL_ES 1810 if (size > allocated - 8) {
1812 if (size > allocated - 12) {
1814 allocated =
qMax(2*allocated, 512);
1815 vertices = (GLfloat *)realloc(vertices, allocated *
sizeof(GLfloat));
1820 #ifndef QT_OPENGL_ES 1822 vertices[size++] = t.
top;
1824 vertices[size++] = t.
top;
1826 vertices[size++] = t.
bottom;
1828 vertices[size++] = t.
bottom;
1832 vertices[size++] = t.
top;
1834 vertices[size++] = t.
top;
1836 vertices[size++] = t.
bottom;
1840 vertices[size++] = t.
bottom;
1842 vertices[size++] = t.
top;
1844 vertices[size++] = t.
bottom;
1855 DEBUG_ONCE qDebug() <<
"QOpenGLPaintEnginePrivate: Drawing polygon with" << pointCount <<
"points using fillPolygon_dev";
1857 setGradientOps(cbrush, tessellator.
bounds);
1862 #ifndef QT_OPENGL_ES 1863 GLenum geometry_mode = GL_QUADS;
1868 if (use_fragment_programs && !(fast_style && has_fast_composition_mode)) {
1869 composite(geometry_mode, tessellator.
vertices, tessellator.
size / 2);
1872 glEnableClientState(GL_VERTEX_ARRAY);
1873 glDrawArrays(geometry_mode, 0, tessellator.
size/2);
1874 glDisableClientState(GL_VERTEX_ARRAY);
1881 tess_points.add(
QPointF(x, y));
1895 qreal inverseScaleHalf = inverseScale / 2;
1900 while (b >= beziers) {
1904 if (l > inverseScale) {
1905 d =
qAbs( (b->x4 - b->x1)*(b->y1 - b->y2) - (b->y4 - b->y1)*(b->x1 - b->x2) )
1906 +
qAbs( (b->x4 - b->x1)*(b->y1 - b->y3) - (b->y4 - b->y1)*(b->x1 - b->x3) );
1909 d =
qAbs(b->x1 - b->x2) +
qAbs(b->y1 - b->y2) +
1910 qAbs(b->x1 - b->x3) +
qAbs(b->y1 - b->y3);
1912 if (d < inverseScaleHalf || b == beziers + 31) {
1914 lineToStencil(b->x4, b->y4);
1928 min_x = max_x = first.
x;
1929 min_y = max_y = first.
y;
1931 tess_points.reset();
1932 tess_points_stops.clear();
1933 lineToStencil(first.
x, first.
y);
1939 tess_points_stops.append(tess_points.size());
1940 lineToStencil(e.
x, e.
y);
1943 lineToStencil(e.
x, e.
y);
1953 lineToStencil(first.
x, first.
y);
1954 tess_points_stops.append(tess_points.size());
1960 if (tess_points_stops.count() == 0)
1962 glEnableClientState(GL_VERTEX_ARRAY);
1963 glVertexPointer(2, GL_DOUBLE, 0, tess_points.data());
1964 int previous_stop = 0;
1965 foreach(
int stop, tess_points_stops) {
1967 previous_stop = stop;
1969 glDisableClientState(GL_VERTEX_ARRAY);
1978 if (use_system_clip)
1979 rect = q->systemClip().
intersected(dirty_stencil).boundingRect();
1989 const int width = rect.
width();
1991 const int height = rect.
height();
1993 glScissor(left, bottom, width, height);
1997 dirty_stencil -= rect;
2010 GLuint stencilMask = 0;
2016 glStencilMask(stencilMask);
2028 if (has_stencil_face_ext) {
2061 glStencilMask(stencilMask);
2063 setGradientOps(cbrush,
QRectF(
QPointF(min_x, min_y),
QSizeF(max_x - min_x, max_y - min_y)));
2067 if (use_fragment_programs && !fast_fill) {
2068 DEBUG_ONCE qDebug() <<
"QOpenGLPaintEnginePrivate: Drawing polygon using stencil method (fragment programs)";
2076 DEBUG_ONCE qDebug() <<
"QOpenGLPaintEnginePrivate: Drawing polygon using stencil method (no fragment programs)";
2081 #ifndef QT_OPENGL_ES 2083 glVertex2f(min_x, min_y);
2084 glVertex2f(max_x, min_y);
2085 glVertex2f(max_x, max_y);
2086 glVertex2f(min_x, max_y);
2102 if (use_stencil_method && !high_quality_antialiasing) {
2103 pathToVertexArrays(path);
2108 glMatrixMode(GL_MODELVIEW);
2111 if (high_quality_antialiasing)
2112 drawOffscreenPath(path);
2115 fillPolygon_dev(poly.
data(), poly.
count(),
2133 use_emulation = (!use_fragment_programs
2147 d->updateUseEmulation();
2150 GLfloat width = pen.
widthF() == 0.0f ? 1.0f : pen.
widthF();
2160 d->setGLPen(pen.
color());
2170 d->brush_style = brush.
style();
2171 d->brush_origin = origin;
2173 d->updateUseEmulation();
2186 d->mv_matrix[0][0] = mtx.
m11();
2187 d->mv_matrix[0][1] = mtx.
m12();
2188 d->mv_matrix[0][2] = 0;
2189 d->mv_matrix[0][3] = mtx.
m13();
2191 d->mv_matrix[1][0] = mtx.
m21();
2192 d->mv_matrix[1][1] = mtx.
m22();
2193 d->mv_matrix[1][2] = 0;
2194 d->mv_matrix[1][3] = mtx.
m23();
2196 d->mv_matrix[2][0] = 0;
2197 d->mv_matrix[2][1] = 0;
2198 d->mv_matrix[2][2] = 1;
2199 d->mv_matrix[2][3] = 0;
2201 d->mv_matrix[3][0] = mtx.
dx();
2202 d->mv_matrix[3][1] = mtx.
dy();
2203 d->mv_matrix[3][2] = 0;
2204 d->mv_matrix[3][3] = mtx.
m33();
2206 d->txop = mtx.
type();
2214 d->updateGLMatrix();
2220 glMatrixMode(GL_MODELVIEW);
2221 #ifndef QT_OPENGL_ES 2222 glLoadMatrixd(&mv_matrix[0][0]);
2224 glLoadMatrixf(&mv_matrix[0][0]);
2237 if (!q->state()->hasClipping)
2240 if (q->state()->fastClip.isEmpty())
2250 ++q->state()->depthClipId;
2255 if (!q->state()->hasClipping)
2259 if (q->state()->clipEnabled) {
2260 fastClip = q->state()->fastClip;
2261 }
else if (use_system_clip && q->systemClip().rects().count() == 1) {
2262 fastClip = q->systemClip().rects().at(0);
2269 const int width = fastClip.
width();
2271 const int height = fastClip.
height();
2273 glScissor(left, bottom, width, height);
2277 #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) 2278 glClearDepthf(0.0f);
2290 const QVector<QRect> rects = q->state()->clipEnabled ? q->state()->clipRegion.rects() : q->systemClip().rects();
2294 for (
int i = 0; i < rects.
size(); ++i) {
2295 GLfloat x = GLfloat(rects.
at(i).
left());
2296 GLfloat w = GLfloat(rects.
at(i).
width());
2297 GLfloat h = GLfloat(rects.
at(i).
height());
2298 GLfloat y = GLfloat(rects.
at(i).
top());
2305 clipVertex.add(y + h);
2307 clipVertex.add(x + w);
2312 clipVertex.add(y + h);
2314 clipVertex.add(x + w);
2315 clipVertex.add(y + h);
2317 clipVertex.add (x + w);
2322 glMatrixMode(GL_MODELVIEW);
2325 glEnableClientState(GL_VERTEX_ARRAY);
2326 glVertexPointer(2,
GL_FLOAT, 0, clipVertex.data());
2329 glDisableClientState(GL_VERTEX_ARRAY);
2341 if (q->painter()->hasClipping())
2353 if (!
d->device->format().depth())
2356 d->use_system_clip =
false;
2360 d->use_system_clip =
true;
2364 if (
d->currentClipWidget) {
2372 d->flushDrawQueue();
2377 d->updateDepthClip();
2381 bool isScreenClip =
false;
2382 if (!
d->use_system_clip) {
2385 if (untransformedRects.
size() == 1) {
2387 path.
addRect(untransformedRects[0]);
2388 path =
d->matrix.map(path);
2391 isScreenClip =
true;
2398 if (!
d->use_system_clip)
2405 if (
state()->hasClipping) {
2411 if (
d->use_system_clip)
2418 if (
d->use_system_clip)
2437 d->updateDepthClip();
2444 d->flushDrawQueue();
2448 && (hints & QPainter::HighQualityAntialiasing)) {
2449 d->high_quality_antialiasing =
true;
2451 d->high_quality_antialiasing =
false;
2456 d->high_quality_antialiasing =
false;
2461 if (
d->high_quality_antialiasing) {
2462 d->offscreen.initialize();
2464 if (!
d->offscreen.isValid()) {
2465 DEBUG_ONCE_STR(
"Unable to initialize offscreen, disabling high quality antialiasing");
2466 d->high_quality_antialiasing =
false;
2472 d->has_antialiasing =
d->high_quality_antialiasing
2480 porterduff_ab_data[0] =
a;
2481 porterduff_ab_data[1] = b;
2483 porterduff_xyz_data[0] = x;
2484 porterduff_xyz_data[1] = y;
2485 porterduff_xyz_data[2] = z;
2496 d->composition_mode = composition_mode;
2507 if (
d->has_fast_composition_mode)
2512 switch (composition_mode) {
2550 switch(composition_mode) {
2553 d->setPorterDuffData(0, 1, 1, 1, 1);
2557 d->setPorterDuffData(0, 0, 0, 0, 0);
2561 d->setPorterDuffData(1, 0, 1, 1, 0);
2565 d->setPorterDuffData(0, 1, 1, 0, 1);
2569 d->setPorterDuffData(1, 0, 1, 0, 0);
2573 d->setPorterDuffData(0, 1, 1, 0, 0);
2577 d->setPorterDuffData(0, 0, 0, 1, 0);
2581 d->setPorterDuffData(0, 0, 0, 0, 1);
2585 d->setPorterDuffData(1, 0, 1, 0, 1);
2589 d->setPorterDuffData(0, 1, 1, 1, 0);
2593 d->setPorterDuffData(0, 0, 0, 1, 1);
2597 d->setPorterDuffData(1, 0, 1, 1, 1);
2601 d->setPorterDuffData(1, 1, 1, 1, 1);
2618 virtual QRect screenRect() = 0;
2619 virtual void drawMask(
const QRect &rect) = 0;
2637 if (offscreenSize != sz) {
2647 int quad_tree_size = 1;
2649 for (
int i = block_size; i < offscreenSize.width(); i *= 2)
2650 quad_tree_size += quad_tree_size * 4;
2652 for (
int i = 0; i < 4; ++i) {
2653 occupied_quadtree[i].resize(quad_tree_size);
2655 occupied_quadtree[i][0].key = 0;
2656 occupied_quadtree[i][0].largest_available_block = offscreenSize.width();
2657 occupied_quadtree[i][0].largest_used_block = 0;
2659 DEBUG_ONCE qDebug() <<
"QGLMaskTextureCache:: created quad tree of size" << quad_tree_size;
2670 QGLTextureCacheHash::iterator
it = cache.begin();
2671 QGLTextureCacheHash::iterator
end = cache.end();
2677 if (cache_info.
age > 1) {
2679 it = cache.erase(it);
2690 #ifndef DISABLE_MASK_CACHE 2700 QGLTextureCacheHash::iterator
it = cache.find(key);
2702 while (it != cache.end() && it.key() ==
key) {
2705 DEBUG_ONCE_STR(
"QGLMaskTextureCache::getMask(): Using cached mask");
2708 return cache_info.
loc;
2715 DEBUG_ONCE_STR(
"QGLMaskTextureCache::getMask(): Creating new mask...");
2717 createMask(key,
info, maskGenerator);
2719 cache.insert(key,
info);
2724 createMask(0,
info, maskGenerator);
2729 #ifndef FloatToQuint64 2730 #define FloatToQuint64(i) (quint64)((i) * 32) 2746 #ifndef Q_OS_WINCE // ### 2776 glColorMask(ch == 0, ch == 1, ch == 2, ch == 3);
2787 int blocksize = offscreenSize.width();
2790 node = (node - 1) / 4;
2800 int blocksize = quadtreeBlocksize(node);
2806 location.
setX(location.
x() + blocksize);
2809 location.
setY(location.
y() + blocksize);
2821 node = (node - 1) / 4;
2823 int first_child = node * 4 + 1;
2825 int largest_available = 0;
2826 int largest_used = 0;
2828 bool all_empty =
true;
2830 for (
int i = 0; i < 4; ++i) {
2831 largest_available =
qMax(largest_available, occupied_quadtree[channel][first_child + i].largest_available_block);
2832 largest_used =
qMax(largest_used, occupied_quadtree[channel][first_child + i].largest_used_block);
2834 if (occupied_quadtree[channel][first_child + i].largest_available_block < current_block_size)
2838 current_block_size *= 2;
2841 occupied_quadtree[channel][node].largest_available_block = current_block_size;
2842 occupied_quadtree[channel][node].largest_used_block = 0;
2844 occupied_quadtree[channel][node].largest_available_block = largest_available;
2845 occupied_quadtree[channel][node].largest_used_block = largest_used;
2852 int current_block_size = quadtreeBlocksize(node);
2856 if (relative.
left() >= current_block_size || relative.
top() >= current_block_size
2860 if (current_block_size == block_size
2861 || (relative.
top() < block_size && relative.
bottom() >= (current_block_size - block_size)
2862 && relative.
left() < block_size && relative.
right() >= (current_block_size - block_size)))
2865 occupied_quadtree[channel][node].largest_available_block = 0;
2866 occupied_quadtree[channel][node].largest_used_block = rect.
width() * rect.
height();
2868 occupied_quadtree[channel][node].largest_available_block = current_block_size;
2869 occupied_quadtree[channel][node].largest_used_block = 0;
2872 occupied_quadtree[channel][node].key =
key;
2874 quadtreeUpdate(channel, node, current_block_size);
2876 if (key && occupied_quadtree[channel][node].largest_available_block == current_block_size) {
2878 int half_block_size = current_block_size / 2;
2880 int temp = node * 4 + 1;
2881 for (
int sibling = 0; sibling < 4; ++sibling) {
2882 occupied_quadtree[channel][temp + sibling].largest_available_block = half_block_size;
2883 occupied_quadtree[channel][temp + sibling].largest_used_block = 0;
2884 occupied_quadtree[channel][temp + sibling].key = 0;
2888 node = node * 4 + 1;
2890 for (
int sibling = 0; sibling < 4; ++sibling)
2891 quadtreeInsert(channel, key, rect, node + sibling);
2897 const quint64 &
key = occupied_quadtree[channel][node].key;
2899 int current_block_size = quadtreeBlocksize(node);
2904 if (relative.
left() >= current_block_size || relative.
top() >= current_block_size
2909 QGLTextureCacheHash::iterator
it = cache.find(key);
2913 while (it != cache.end() && it.key() ==
key) {
2914 const CacheInfo &cache_info = it.value();
2922 quadtreeInsert(channel, 0, cache_info.
loc.
rect);
2923 engine->cacheItemErased(channel, cache_info.
loc.
rect);
2934 Q_ASSERT(occupied_quadtree[channel][node].key == 0);
2935 }
else if (occupied_quadtree[channel][node].largest_available_block < current_block_size) {
2936 Q_ASSERT(current_block_size >= block_size);
2938 node = node * 4 + 1;
2940 for (
int sibling = 0; sibling < 4; ++sibling)
2941 quadtreeClear(channel, rect, node + sibling);
2949 for (
int i = 0; i < 4; ++i) {
2950 int current_block_size = offscreenSize.width();
2952 if (occupied_quadtree[i][0].largest_available_block >= needed_block_size) {
2955 while (current_block_size != occupied_quadtree[i][node].largest_available_block) {
2956 Q_ASSERT(current_block_size > block_size);
2957 Q_ASSERT(current_block_size > occupied_quadtree[i][node].largest_available_block);
2959 node = node * 4 + 1;
2960 current_block_size /= 2;
2964 while (occupied_quadtree[i][node + sibling].largest_available_block < needed_block_size)
2972 *rect =
QRect(quadtreeLocation(node), size);
2984 *channel =
qrand() % 4;
2985 for (
int i = 0; i < 4; ++i)
2986 if (occupied_quadtree[i][0].largest_used_block < occupied_quadtree[*channel][0].largest_used_block)
2992 int current_block_size = offscreenSize.width();
2994 while (current_block_size > block_size
2995 && current_block_size >= needed_block_size * 2
2996 && occupied_quadtree[*channel][node].
key == 0)
2998 node = node * 4 + 1;
3002 for (
int i = 1; i < 4; ++i) {
3003 if (occupied_quadtree[*channel][node + i].largest_used_block
3004 <= occupied_quadtree[*channel][node + sibling].largest_used_block)
3011 current_block_size /= 2;
3014 *rect =
QRect(quadtreeLocation(node), size);
3019 #ifndef DISABLE_MASK_CACHE 3020 if (!quadtreeFindAvailableLocation(size, rect, channel)) {
3021 quadtreeFindExistingLocation(size, rect, channel);
3022 quadtreeClear(*channel, *rect);
3025 quadtreeInsert(*channel, key, *rect);
3038 void drawMask(
const QRect &rect);
3049 virtual QRect computeScreenRect() = 0;
3059 QRect computeScreenRect();
3071 QRect computeScreenRect();
3083 QRect computeScreenRect();
3094 void drawMask(
const QRect &rect);
3107 float vertexArray[4 * 2];
3112 , has_screen_rect(false)
3114 , maskFragmentProgram(program)
3126 glMatrixMode(GL_MODELVIEW);
3133 glDisable(GL_TEXTURE_GEN_S);
3134 glDisable(GL_TEXTURE_1D);
3136 GLfloat vertexArray[4 * 2];
3141 if (needs_scissor) {
3150 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
3151 glEnableClientState(GL_VERTEX_ARRAY);
3153 glDisableClientState(GL_VERTEX_ARRAY);
3161 for (
int i = 0; i < trapezoids.size(); ++i)
3170 glMatrixMode(GL_MODELVIEW);
3268 tessellator.tessellateRect(first, last, width);
3272 for (
int i = 0; i < 5; ++i)
3275 tessellator.tessellateConvex(points, 5);
3277 return tessellator.trapezoids;
3292 maskVariableLocations(locations)
3309 for (
int i = 0; i < 4; ++i) {
3313 delta /=
qSqrt(delta.
x() * delta.
x() + delta.
y() * delta.
y());
3318 min_screen_delta_len =
qMin(min_screen_delta_len,
3319 qreal(
qSqrt(screen_delta.x() * screen_delta.x() + screen_delta.y() * screen_delta.y())));
3322 const qreal padding = 2.0f;
3324 qreal grow = padding / min_screen_delta_len;
3346 glDisable(GL_TEXTURE_GEN_S);
3347 glDisable(GL_TEXTURE_1D);
3357 float m[3][4] = { { float(inv_matrix.m11()),
float(inv_matrix.m12()),
float(inv_matrix.m13()) },
3358 { float(inv_matrix.m21()),
float(inv_matrix.m22()),
float(inv_matrix.m23()) },
3359 { float(inv_matrix.m31()),
float(inv_matrix.m32()),
float(inv_matrix.m33()) } };
3365 float ellipse_offset[4] = { float(offs.x()),
float(offs.y()), 0.0f, 1.0f };
3380 glEnableClientState(GL_VERTEX_ARRAY);
3381 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
3383 glDisableClientState(GL_VERTEX_ARRAY);
3393 DEBUG_ONCE_STR(
"QOpenGLPaintEnginePrivate::drawOffscreenPath()");
3397 GLuint program = qt_gl_program_cache()->getProgram(device->
context(),
3400 addItem(qt_mask_texture_cache()->getMask(maskGenerator,
this));
3409 DEBUG_ONCE_STR(
"QOpenGLPaintEngine::drawRects(): drawing fast rect");
3420 bool temp = high_quality_antialiasing;
3421 high_quality_antialiasing =
false;
3423 q->updateCompositionMode(composition_mode);
3425 setGradientOps(cbrush, r);
3430 if (fast_style && has_fast_composition_mode) {
3431 glEnableClientState(GL_VERTEX_ARRAY);
3432 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
3434 glDisableClientState(GL_VERTEX_ARRAY);
3439 high_quality_antialiasing = temp;
3441 q->updateCompositionMode(composition_mode);
3445 if (has_fast_pen && !high_quality_antialiasing) {
3446 setGradientOps(cpen.
brush(), r);
3448 vertexArray[8] = vertexArray[0];
3449 vertexArray[9] = vertexArray[1];
3451 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
3452 glEnableClientState(GL_VERTEX_ARRAY);
3454 glDisableClientState(GL_VERTEX_ARRAY);
3466 path.
lineTo(right, bottom);
3467 path.
lineTo(left, bottom);
3470 strokePath(path,
false);
3500 while (i < rectCount && i < 256) {
3501 fr[i].x = rects[i].
x();
3502 fr[i].y = rects[i].
y();
3503 fr[i].w = rects[i].
width();
3504 fr[i].h = rects[i].
height();
3517 if (
d->use_emulation) {
3522 for (
int i=0; i<rectCount; ++i) {
3523 const QRectF &r = rects[i];
3526 if (!
d->high_quality_antialiasing ||
d->isFastRect(r)) {
3533 d->disableClipping();
3534 GLuint program = qt_gl_program_cache()->getProgram(
d->device->context(),
3539 d->addItem(qt_mask_texture_cache()->getMask(maskGenerator,
d));
3542 d->addItem(qt_mask_texture_cache()->getMask(maskGenerator,
d));
3545 d->enableClipping();
3549 if (
d->has_fast_pen)
3550 d->strokeLines(path);
3552 d->strokePath(path,
false);
3560 triangle[0] = quad[0];
3561 triangle[1] = quad[1];
3563 triangle[2] = quad[2];
3564 triangle[3] = quad[3];
3566 triangle[4] = quad[4];
3567 triangle[5] = quad[5];
3569 triangle[6] = quad[4];
3570 triangle[7] = quad[5];
3572 triangle[8] = quad[6];
3573 triangle[9] = quad[7];
3575 triangle[10] = quad[0];
3576 triangle[11] = quad[1];
3583 while (pointCount) {
3585 while (i < pointCount && i < 256) {
3586 fp[i].
x = points[i].
x();
3587 fp[i].
y = points[i].
y();
3600 if (
d->use_emulation) {
3605 d->setGradientOps(
d->cpen.brush(),
QRectF());
3607 if (!
d->cpen.isCosmetic() ||
d->high_quality_antialiasing) {
3612 d->cpen.setCapStyle(capStyle);
3616 d->flushDrawQueue();
3618 if (
d->has_fast_pen) {
3621 glMatrixMode(GL_MODELVIEW);
3626 for (
int i = 0; i < pointCount; ++i) {
3629 GLfloat x = GLfloat(
qRound(mapped.
x()));
3630 GLfloat y = GLfloat(
qRound(mapped.
y()));
3632 vertexArray[j++] = x;
3633 vertexArray[j++] = y - 0.5f;
3635 vertexArray[j++] = x + 1.5f;
3636 vertexArray[j++] = y + 1.0f;
3638 vertexArray[j++] = x;
3639 vertexArray[j++] = y + 1.0f;
3642 glEnableClientState(GL_VERTEX_ARRAY);
3647 glDisableClientState(GL_VERTEX_ARRAY);
3655 if (
sizeof(
qreal) ==
sizeof(double)) {
3657 glVertexPointer(2, GL_DOUBLE, 0, vertexArray);
3661 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
3664 glEnableClientState(GL_VERTEX_ARRAY);
3666 glDisableClientState(GL_VERTEX_ARRAY);
3684 while (i < lineCount && i < 256) {
3685 fl[i].p1.x = lines[i].
x1();
3686 fl[i].p1.y = lines[i].
y1();
3687 fl[i].p2.x = lines[i].
x2();
3688 fl[i].p2.y = lines[i].
y2();
3701 if (
d->use_emulation) {
3708 if (
d->has_fast_pen && !
d->high_quality_antialiasing) {
3710 d->setGradientOps(
d->cpen.brush(),
QRectF());
3712 bool useRects =
false;
3715 || (!
d->cpen.isCosmetic()
3718 &&
d->matrix.m11() == 0 &&
d->matrix.m22() == 0)))) {
3720 for (
int i = 0; i < lineCount; ++i) {
3721 if (lines[i].p1().x() != lines[i].
p2().
x()
3722 && lines[i].
p1().
y() != lines[i].
p2().
y()) {
3729 GLfloat endCap =
d->cpen.capStyle() ==
Qt::FlatCap ? 0.0f : 0.5f;
3734 for (
int i = 0; i < lineCount; ++i) {
3735 GLfloat x1 = lines[i].
x1();
3736 GLfloat x2 = lines[i].
x2();
3737 GLfloat y1 = lines[i].
y1();
3738 GLfloat y2 = lines[i].
y2();
3744 quad[0] = x1 - 0.5f;
3745 quad[1] = y1 - endCap;
3747 quad[2] = x1 + 0.5f;
3748 quad[3] = y1 - endCap;
3750 quad[4] = x1 + 0.5f;
3751 quad[5] = y2 + endCap;
3753 quad[6] = x1 - 0.5f;
3754 quad[7] = y2 + endCap;
3759 quad[0] = x1 - endCap;
3760 quad[1] = y1 + 0.5f;
3762 quad[2] = x1 - endCap;
3763 quad[3] = y1 - 0.5f;
3765 quad[4] = x2 + endCap;
3766 quad[5] = y1 - 0.5f;
3768 quad[6] = x2 + endCap;
3769 quad[7] = y1 + 0.5f;
3775 glEnableClientState(GL_VERTEX_ARRAY);
3780 glDisableClientState(GL_VERTEX_ARRAY);
3783 for (
int i = 0; i < lineCount; ++i) {
3784 vertexArray[4*i] = lines[i].
x1();
3785 vertexArray[4*i+1] = lines[i].
y1();
3786 vertexArray[4*i+2] = lines[i].
x2();
3787 vertexArray[4*i+3] = lines[i].
y2();
3790 glEnableClientState(GL_VERTEX_ARRAY);
3793 glDrawArrays(
GL_LINES, 0, lineCount*2);
3798 glDisableClientState(GL_VERTEX_ARRAY);
3803 for (
int i=0; i<lineCount; ++i) {
3806 if (l.
p1() == l.
p2()) {
3818 if (
d->has_fast_pen &&
d->high_quality_antialiasing)
3819 d->strokeLines(path);
3821 d->strokePath(path,
false);
3830 for (
int i=0; i<pointCount; ++i) {
3831 p[i].x = points[i].
x();
3832 p[i].y = points[i].
y();
3834 drawPolygon((
QPointF *)p.
data(), pointCount, mode);
3843 if (
d->use_emulation) {
3849 if ((mode == ConvexMode && !
d->high_quality_antialiasing && state()->brushNeedsResolving()) ||
3850 ((
d->has_fast_pen && !
d->high_quality_antialiasing) && state()->penNeedsResolving())) {
3851 qreal minx = points[0].
x(), miny = points[0].
y(),
3852 maxx = points[0].
x(), maxy = points[0].
y();
3853 for (
int i = 1; i < pointCount; ++i) {
3854 const QPointF &pt = points[i];
3864 bounds =
QRectF(minx, maxx, maxx-minx, maxy-miny);
3869 if (
d->has_brush && mode != PolylineMode) {
3870 if (mode == ConvexMode && !
d->high_quality_antialiasing) {
3872 d->setGradientOps(
d->cbrush, bounds);
3876 if (
sizeof(
qreal) ==
sizeof(double)) {
3878 glVertexPointer(2, GL_DOUBLE, 0, vertexArray);
3882 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
3885 glEnableClientState(GL_VERTEX_ARRAY);
3887 glDisableClientState(GL_VERTEX_ARRAY);
3892 for (
int i=1; i<pointCount; ++i)
3899 if (
d->has_fast_pen && !
d->high_quality_antialiasing) {
3900 d->setGradientOps(
d->cpen.brush(), bounds);
3904 for (i=0; i<pointCount; ++i) {
3905 vertexArray[i*2] = points[i].
x();
3906 vertexArray[i*2+1] = points[i].
y();
3909 glEnableClientState(GL_VERTEX_ARRAY);
3910 if (mode != PolylineMode) {
3911 vertexArray[i*2] = vertexArray[0];
3912 vertexArray[i*2+1] = vertexArray[1];
3916 glDrawArrays(
GL_POINTS, pointCount-1, 1);
3918 glDisableClientState(GL_VERTEX_ARRAY);
3921 for (
int i = 1; i < pointCount; ++i)
3923 if (mode != PolylineMode)
3926 if (
d->has_fast_pen)
3927 d->strokeLines(path);
3929 d->strokePath(path,
true);
3940 GLuint program = qt_gl_program_cache()->getProgram(device->
context(),
3943 offscreen, program);
3948 QPointF origin = brush_origin;
3950 cbrush = cpen.
brush();
3953 addItem(qt_mask_texture_cache()->getMask(maskGenerator,
this));
3956 brush_origin = origin;
3965 QBrush old_brush = cbrush;
3966 cbrush = cpen.
brush();
3974 if (has_antialiasing) {
3977 float offs_matrix[] =
3982 glLoadMatrixf(offs_matrix);
3989 fillPath(qt_opengl_stroke_cache()->getStrokedPath(temp.
map(path), pen));
3995 }
else if (use_cache) {
3996 fillPath(qt_opengl_stroke_cache()->getStrokedPath(path, cpen));
4006 #ifndef QT_OPENGL_ES 4010 setGradientOps(cpen.
brush(), bounds);
4020 glVertex2d(e.
x, e.
y);
4024 glVertex2d(e.
x, e.
y);
4034 qreal inverseScaleHalf = inverseScale / 2;
4037 while (b >= beziers) {
4041 if (l > inverseScale) {
4043 - (b->
y4 - b->
y1)*(b->
x1 - b->
x2) )
4045 - (b->
y4 - b->
y1)*(b->
x1 - b->
x3) );
4051 if (d < inverseScaleHalf || b == beziers + 31) {
4053 glVertex2d(b->
x4, b->
y4);
4072 setGradientOps(cpen.
brush(), bounds);
4074 glEnableClientState(GL_VERTEX_ARRAY);
4075 tess_points.reset();
4082 glVertexPointer(2,
GL_FLOAT, 0, tess_points.data());
4084 tess_points.reset();
4100 qreal inverseScaleHalf = inverseScale / 2;
4103 while (b >= beziers) {
4107 if (l > inverseScale) {
4109 - (b->
y4 - b->
y1)*(b->
x1 - b->
x2) )
4111 - (b->
y4 - b->
y1)*(b->
x1 - b->
x3) );
4117 if (d < inverseScaleHalf || b == beziers + 31) {
4132 glVertexPointer(2,
GL_FLOAT, 0, tess_points.data());
4134 glDisableClientState(GL_VERTEX_ARRAY);
4141 QPointF lastPoint = lastMoveTo;
4147 if (lastMoveTo != lastPoint)
4149 lastMoveTo = lastPoint = e;
4163 return lastMoveTo == lastPoint;
4173 if (
d->use_emulation) {
4183 bool has_thick_pen =
4187 &&
d->cpen.isSolid()
4188 &&
d->cpen.color().alpha() == 255
4190 &&
d->cpen.widthF() >= 2 /
qSqrt(
qMin(
d->matrix.m11() *
d->matrix.m11()
4191 +
d->matrix.m21() *
d->matrix.m21(),
4192 d->matrix.m12() *
d->matrix.m12()
4193 +
d->matrix.m22() *
d->matrix.m22()));
4195 if (has_thick_pen) {
4196 DEBUG_ONCE qDebug() <<
"QOpenGLPaintEngine::drawPath(): Using thick pen optimization, style:" <<
d->cbrush.style();
4198 d->flushDrawQueue();
4200 bool temp =
d->high_quality_antialiasing;
4201 d->high_quality_antialiasing =
false;
4203 updateCompositionMode(
d->composition_mode);
4207 d->high_quality_antialiasing = temp;
4208 updateCompositionMode(
d->composition_mode);
4215 if (
d->has_fast_pen && !
d->high_quality_antialiasing)
4216 d->strokePathFastPen(path, state()->penNeedsResolving());
4218 d->strokePath(path,
true);
4224 QBrush old_brush = cbrush;
4225 QPointF old_brush_origin = brush_origin;
4231 brush_matrix.
scale(scaleX, scaleY);
4243 brush_origin = old_brush_origin;
4249 QBrush old_brush = cbrush;
4250 QPointF old_brush_origin = brush_origin;
4253 brush_matrix.
scale(sx, sy);
4265 brush_origin = old_brush_origin;
4273 template <
typename T>
4281 const T sub = image.copy(sx1, sy1, sx2 - sx1, sy2 - sy1);
4292 if (pm.
depth() == 1) {
4299 drawPixmap(r, tpx, sr);
4303 const int sz =
d->max_texture_size;
4309 drawPixmap(r, sub, subsr);
4315 drawPixmap(r, scaled,
scaleRect(subsr, sx, sy));
4322 d->drawImageAsPath(r, pm.
toImage(), sr);
4325 d->flushDrawQueue();
4327 d->device->context()->d_func()->bindTexture(pm, target,
GL_RGBA,
4329 drawTextureRect(pm.
width(), pm.
height(), r, sr, target, tex);
4336 if (pm.
depth() == 1) {
4343 drawTiledPixmap(r, tpx, offset);
4348 const int sz =
d->max_texture_size;
4353 drawTiledPixmap(r, pm.
copy(0, 0, rw, rh), offset);
4362 d->drawTiledImageAsPath(r, pm.
toImage(), 1, 1, offset);
4366 d->drawTiledImageAsPath(r, scaled, sx, sy, offset);
4369 d->flushDrawQueue();
4380 #ifndef QT_OPENGL_ES 4381 glPushAttrib(GL_CURRENT_BIT);
4382 glDisable(GL_TEXTURE_GEN_S);
4384 glColor4f(
d->opacity,
d->opacity,
d->opacity,
d->opacity);
4395 glRotatef(180.0, 0.0, 1.0, 0.0);
4396 glRotatef(180.0, 0.0, 0.0, 1.0);
4400 GLfloat texCoordArray[4*2];
4402 double offset_x = offset.
x() / pm.
width();
4403 double offset_y = offset.
y() / pm.
height();
4407 tc_w + offset_x, tc_h + offset_y, texCoordArray);
4409 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
4410 glTexCoordPointer(2,
GL_FLOAT, 0, texCoordArray);
4412 glEnableClientState(GL_VERTEX_ARRAY);
4413 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
4415 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
4416 glDisableClientState(GL_VERTEX_ARRAY);
4421 #ifndef QT_OPENGL_ES 4428 Qt::ImageConversionFlags)
4432 const int sz =
d->max_texture_size;
4438 drawImage(r, sub, subsr, 0);
4444 drawImage(r, scaled,
scaleRect(subsr, sx, sy), 0);
4450 d->drawImageAsPath(r, image, sr);
4453 d->flushDrawQueue();
4455 d->device->context()->d_func()->bindTexture(image, target,
GL_RGBA,
4457 drawTextureRect(image.
width(), image.
height(), r, sr, target, tex);
4465 #ifndef QT_OPENGL_ES 4466 glPushAttrib(GL_CURRENT_BIT);
4467 glDisable(GL_TEXTURE_GEN_S);
4469 glColor4f(
d->opacity,
d->opacity,
d->opacity,
d->opacity);
4473 qreal x1, x2, y1, y2;
4475 x1 = sr.
x() / tx_width;
4476 x2 = x1 + sr.
width() / tx_width;
4478 y1 = 1 - (sr.
bottom() / tx_height);
4479 y2 = 1 - (sr.
y() / tx_height);
4481 y1 = sr.
bottom() / tx_height;
4482 y2 = sr.
y() / tx_height;
4492 GLfloat texCoordArray[4*2];
4497 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
4498 glTexCoordPointer(2,
GL_FLOAT, 0, texCoordArray);
4500 glEnableClientState(GL_VERTEX_ARRAY);
4501 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
4503 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
4504 glDisableClientState(GL_VERTEX_ARRAY);
4507 #ifndef QT_OPENGL_ES 4572 void fontEngineDestroyed(
QObject *);
4573 void widgetDestroyed(
QObject *);
4594 for (
int i=0; i < keys.
size(); ++i) {
4595 QGLFontGlyphHash *font_cache = qt_context_cache.value(keys.
at(i));
4596 if (font_cache->
find(fe) != font_cache->
end()) {
4598 QGLGlyphHash *cache = font_cache->
take(fe);
4609 # ifndef QT_MAC_USE_COCOA
4610 aglGetCurrentContext() != 0
4612 qt_current_nsopengl_context() != 0
4616 glDeleteTextures(1, &tex->
texture);
4630 QGLFontGlyphHash *font_cache = qt_context_cache.take(ctx);
4634 for (
int i=0; i < keys.
size(); ++i) {
4642 # ifndef QT_MAC_USE_COCOA
4643 aglGetCurrentContext() == 0
4645 qt_current_nsopengl_context() != 0
4649 glDeleteTextures(1, &font_tex->
texture);
4662 while (it != qt_font_textures.constEnd()) {
4663 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) 4664 if (qt_current_nsopengl_context() == 0)
4667 glDeleteTextures(1, &it.
value()->texture);
4672 qt_font_textures.clear();
4675 for (
int i=0; i < keys.
size(); ++i) {
4676 QGLFontGlyphHash *font_cache = qt_context_cache.
value(keys.
at(i));
4678 for (; it != font_cache->
end(); ++
it)
4680 font_cache->
clear();
4683 qt_context_cache.clear();
4691 #ifndef QT_OPENGL_ES 4707 for (
int y=0; y<font_tex->
height; ++y) {
4708 for (
int x=0; x<font_tex->
width; ++x) {
4709 im.
setPixel(x, y, ((*(old_tex_data+x+y*font_tex->
width)) << 24) | (0x00ffffff & color.
rgb()));
4712 delete old_tex_data;
4718 glyph_t *glyphs,
int numGlyphs)
4721 QGLFontGlyphHash *font_cache = 0;
4724 if (dev_it == qt_context_cache.constEnd()) {
4727 for (
int i=0; i<contexts.
size(); ++i) {
4731 dev_it = qt_context_cache.constFind(context_key);
4737 if (dev_it == qt_context_cache.constEnd()) {
4741 qt_context_cache.insert(context, font_cache);
4752 font_cache = dev_it.
value();
4757 QGLGlyphHash *cache = 0;
4758 if (cache_it == font_cache->
constEnd()) {
4760 font_cache->
insert(fontEngine, cache);
4763 cache = cache_it.
value();
4765 current_cache = cache;
4767 quint64 font_key = (
reinterpret_cast<quint64>(context_key ? context_key : context) << 32)
4768 |
reinterpret_cast<quint64>(fontEngine);
4771 if (it == qt_font_textures.constEnd()) {
4772 GLuint font_texture;
4773 glGenTextures(1, &font_texture);
4779 if (tex_width > max_tex_size)
4780 tex_width = max_tex_size;
4782 font_tex->
texture = font_texture;
4785 font_tex->
width = tex_width;
4786 font_tex->
height = tex_height;
4787 allocTexture(font_tex);
4790 qt_font_textures.insert(font_key, font_tex);
4792 font_tex = it.
value();
4796 for (
int i=0; i< numGlyphs; ++i) {
4802 int glyph_width = glyph_im.
width();
4806 if (glyph_width % 2 != 0)
4809 if (font_tex->
x_offset + glyph_width + x_margin > font_tex->
width) {
4812 font_tex->
y_offset += strip_height;
4816 int old_tex_height = font_tex->
height;
4819 glDeleteTextures(1, &font_tex->
texture);
4820 glGenTextures(1, &font_tex->
texture);
4822 allocTexture(font_tex);
4827 memcpy(font_tex->
data, old_tex_data, font_tex->
width*old_tex_height*2);
4833 while (it != cache->
end()) {
4834 it.
value()->height = (it.
value()->height * old_tex_height) / font_tex->
height;
4841 glyph_height =
qMin(glyph_height, glyph_im.height());
4846 qgl_glyph->width =
qreal(glyph_width) / font_tex->
width;
4847 qgl_glyph->height =
qreal(glyph_height) / font_tex->
height;
4848 qgl_glyph->log_width =
qreal(glyph_width);
4849 qgl_glyph->log_height = qgl_glyph->height * font_tex->
height;
4851 qgl_glyph->x_offset = -metrics.
x + 1;
4852 qgl_glyph->y_offset = metrics.
y - 2;
4854 qgl_glyph->x_offset = -metrics.
x;
4855 qgl_glyph->y_offset = metrics.
y;
4858 if (!glyph_im.isNull()) {
4860 uchar *tex_data = (
uchar *) malloc(glyph_width*glyph_height*2);
4861 memset(tex_data, 0, glyph_width*glyph_height*2);
4863 bool is8BitGray =
false;
4871 for (
int y=0; y<glyph_height; ++y) {
4873 int lineStart = idx;
4874 for (
int x=0; x<glyph_im.width(); ++x) {
4875 uchar alpha = is8BitGray ? *s :
qAlpha(glyph_im.color(*s));
4876 tex_data[idx] = alpha;
4877 tex_data[idx+1] = alpha;
4881 if (glyph_im.width()%2 != 0)
4884 memcpy(font_tex->
data+cacheLineStart, tex_data+lineStart, glyph_width*2);
4885 cacheLineStart += font_tex->
width*2;
4888 glyph_width, glyph_height,
4895 cache->
insert(glyphs[i], qgl_glyph);
4905 if (it == current_cache->constEnd())
4919 qt_glyph_cache()->cleanupContext(ctx);
4926 d->flushDrawQueue();
4929 qt_glyph_cache()->cacheGlyphs(
d->device->context(), textItem->
fontEngine(), textItem->
glyphs,
4945 GLfloat texCoordArray[4*2];
4947 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
4948 glTexCoordPointer(2,
GL_FLOAT, 0, texCoordArray);
4950 glEnableClientState(GL_VERTEX_ARRAY);
4951 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
4957 for (
int i=0; i< textItem->
numGlyphs; ++i) {
4964 qreal x1, x2, y1, y2;
4979 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
4980 glDisableClientState(GL_VERTEX_ARRAY);
5019 drawStaticTextItem(&staticTextItem);
5030 if (
d->use_emulation) {
5035 if (
d->high_quality_antialiasing) {
5037 d->disableClipping();
5039 glMatrixMode(GL_MODELVIEW);
5043 GLuint program = qt_gl_program_cache()->getProgram(
d->device->context(),
5051 d->addItem(qt_mask_texture_cache()->getMask(maskGenerator,
d));
5053 d->enableClipping();
5055 glMatrixMode(GL_MODELVIEW);
5063 d->strokePath(path,
false);
5066 DEBUG_ONCE_STR(
"QOpenGLPaintEngine::drawEllipse(): falling back to drawPath()");
5087 float inv_mask_size_data[4] = { 1.0f / sz.
width(), 1.0f / sz.
height(), 0.0f, 0.0f };
5089 sz = drawable_texture_size;
5091 float inv_dst_size_data[4] = { 1.0f / sz.
width(), 1.0f / sz.
height(), 0.0f, 0.0f };
5094 float inv_brush_texture_size_data[4] = { 0.125f, 0.125f };
5100 inv_brush_texture_size_data[0] = 1.0f / sz.
width();
5101 inv_brush_texture_size_data[1] = 1.0f / sz.
height();
5160 qDebug() <<
"QOpenGLPaintEnginePrivate: Unhandled fragment variable:" << i;
5172 ensureDrawableTexture();
5174 DEBUG_ONCE qDebug() <<
"Refreshing drawable_texture for rectangle" << rect;
5177 int left =
qMax(0, static_cast<int>(screen_rect.
left()));
5181 int height =
qMin(device->
size().
height() - bottom,
static_cast<int>(screen_rect.
height()) + 1);
5184 glCopyTexSubImage2D(
GL_TEXTURE_2D, 0, left, bottom, left, bottom, width, height);
5217 DEBUG_ONCE qDebug() <<
"QOpenGLPaintEnginePrivate: Using compositing program: fragment_brush =" 5218 << fragment_brush <<
", fragment_composition_mode =" << fragment_composition_mode;
5220 if (has_fast_composition_mode)
5221 q->updateCompositionMode(composition_mode);
5223 qreal minX = 1e9, minY = 1e9, maxX = -1e9, maxY = -1e9;
5225 for (
int i = 0; i < vertexCount; ++i) {
5226 qreal x = vertexArray[2 * i];
5227 qreal y = vertexArray[2 * i + 1];
5230 matrix.
map(x, y, &tx, &ty);
5232 minX =
qMin(minX, tx);
5233 minY =
qMin(minY, ty);
5234 maxX =
qMax(maxX, tx);
5235 maxY =
qMax(maxY, ty);
5238 QRectF r(minX, minY, maxX - minX, maxY - minY);
5256 GLuint textures[] = { drawable_texture,
5260 const int num_textures =
sizeof(textures) /
sizeof(*textures);
5262 Q_ASSERT(num_textures ==
sizeof(texture_locations) /
sizeof(*texture_locations));
5263 Q_ASSERT(num_textures ==
sizeof(texture_targets) /
sizeof(*texture_targets));
5265 for (
int i = 0; i < num_textures; ++i)
5266 if (texture_locations[i] >= 0) {
5268 glBindTexture(texture_targets[i], textures[i]);
5271 if (brush_texture_location >= 0) {
5285 glEnableClientState(GL_VERTEX_ARRAY);
5286 glVertexPointer(2,
GL_FLOAT, 0, vertexArray);
5288 GLuint program = qt_gl_program_cache()->getProgram(device->
context(),
5290 fragment_composition_mode,
false);
5293 mask_offset_data[0] = maskOffset.
x();
5294 mask_offset_data[1] = -maskOffset.
y();
5296 updateFragmentProgramData(locations);
5298 glDrawArrays(primitive, 0, vertexCount);
5301 glDisableClientState(GL_VERTEX_ARRAY);
5303 for (
int i = 0; i < num_textures; ++i)
5304 if (texture_locations[i] >= 0) {
5306 glBindTexture(texture_targets[i], 0);
5309 if (brush_texture_location >= 0) {
5316 if (!has_fast_composition_mode)
5317 q->updateCompositionMode(composition_mode);
5323 bool isInDrawQueue =
false;
5327 isInDrawQueue =
true;
5338 drawQueue <<
QDrawQueueItem(opacity, cbrush, brush_origin, composition_mode, matrix, location);
5349 cbrush = item.
brush;
5365 #ifndef QT_OPENGL_ES 5370 if (!drawQueue.isEmpty()) {
5371 DEBUG_ONCE qDebug() <<
"QOpenGLPaintEngine::flushDrawQueue():" << drawQueue.size() <<
"items";
5375 qreal old_opacity = opacity;
5376 QPointF old_brush_origin = brush_origin;
5379 QBrush old_brush = cbrush;
5381 bool hqaa_old = high_quality_antialiasing;
5383 high_quality_antialiasing =
true;
5388 opacity = old_opacity;
5389 brush_origin = old_brush_origin;
5390 q->updateCompositionMode(old_composition_mode);
5391 matrix = old_matrix;
5393 brush_style = old_brush.
style();
5395 high_quality_antialiasing = hqaa_old;
5397 setGLBrush(old_brush.
color());
5411 d->updateDepthClip();
5416 updatePen(state()->pen);
5421 updateBrush(state()->brush, state()->brushOrigin);
5426 updateBrush(state()->brush, state()->brushOrigin);
5440 updateCompositionMode(state()->composition_mode);
5445 updateRenderHints(state()->renderHints);
5450 updateMatrix(state()->matrix);
5471 QBrush old_brush = state()->brush;
5472 updateBrush(brush, state()->brushOrigin);
5477 QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]);
5478 QPen old_pen = state()->pen;
5486 updateBrush(old_brush, state()->brushOrigin);
5489 template <
typename T>
static inline bool isRect(
const T *pts,
int elementCount) {
5490 return (elementCount == 5
5491 && pts[0] == pts[8] && pts[1] == pts[9]
5492 && pts[0] == pts[6] && pts[2] == pts[4]
5493 && pts[1] == pts[3] && pts[5] == pts[7]
5496 && pts[0] == pts[6] && pts[2] == pts[4]
5497 && pts[1] == pts[3] && pts[5] == pts[7]
5506 QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]);
5525 QPointF p1(points[
id], points[
id+1]);
5526 QPointF p2(points[
id+2], points[
id+3]);
5527 QPointF p3(points[
id+4], points[
id+5]);
5561 if (s ==
d->last_created_state) {
5562 d->last_created_state = 0;
5568 d->updateDepthClip();
5572 compositionModeChanged();
5573 renderHintsChanged();
5588 d->last_created_state = s;
5617 if (!dirty_drawable_texture)
5620 dirty_drawable_texture =
false;
5622 #ifndef QT_OPENGL_ES 5623 glGenTextures(1, &drawable_texture);
5627 drawable_texture_size.width(),
5628 drawable_texture_size.height(), 0,
5640 #include "qpaintengine_opengl.moc" ElementType type
the type of element
bool qt_resolve_version_1_3_functions(QGLContext *ctx)
void setOffscreenSize(const QSize &offscreenSize)
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
#define GL_ONE_MINUS_SRC_ALPHA
The QPainter class performs low-level painting on widgets and other paint devices.
Qt::BrushStyle current_style
#define glMultiTexCoord4f
The QColor class provides colors based on RGB, HSV or CMYK values.
void setDashOffset(qreal offset)
Sets the dash offset for the generated outlines to offset.
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
QOpenGLPaintEnginePrivate * d
QPointF bottomRight() const
Returns the position of the rectangle's bottom-right corner.
CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode)
static uint hash(const uchar *p, int n)
QGLEllipseMaskGenerator(const QRectF &rect, const QTransform &matrix, QGLOffscreen &offscreen, GLuint maskFragmentProgram, int *maskVariableLocations)
#define DEBUG_ONCE_STR(str)
QPointF focalPoint() const
Returns the focal point of this radial gradient in logical coordinates.
The QPainterPath::Element class specifies the position and type of a subpath.
const T * constData() const
QImage toImage() const
Converts the pixmap to a QImage.
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
ElementType
This enum describes the types of elements used to connect vertices in subpaths.
GLuint maskFragmentProgram
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
void drawMask(const QRect &rect)
#define glDeleteProgramsARB
qreal y() const
Returns the y-coordinate of the rectangle's top edge.
QScopedPointer< QGLContextPrivate > d_ptr
static QPainterPath ellipseRectToPath(const QRectF &rect)
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert)
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
#define GL_TEXTURE_MIN_FILTER
virtual QImage alphaMapForGlyph(glyph_t)
virtual ~QGLMaskGenerator()
static mach_timebase_info_data_t info
qreal opacity() const
Returns the opacity in the current paint engine state.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
const QColor & color() const
Returns the brush color.
void allocTexture(QGLFontTexture *)
QFontEngine * fontEngine() const
uint use_fragment_programs
int width() const
Returns the width of the pixmap.
QPointer< QWidget > widget
QSize size() const
Returns the size of the pixmap.
QHash< const QGLContext *, QGLFontGlyphHash * > QGLContextHash
void clear()
Removes all items from the hash.
void clipEnabledChanged()
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
Qt::BrushStyle brush_style
static const unsigned int num_fragment_masks
#define GL_PROGRAM_FORMAT_ASCII_ARB
QOpenGLPaintEnginePrivate * engine
void drawStaticTextItem(QStaticTextItem *staticTextItem)
CompositionMode
Defines the modes supported for digital image compositing.
The QLine class provides a two-dimensional vector using integer precision.
QDrawQueueItem(qreal _opacity, QBrush _brush, const QPointF &_brush_origion, QPainter::CompositionMode _composition_mode, const QTransform &_matrix, QGLMaskTextureCache::CacheLocation _location)
T * data() const
Returns the value of the pointer referenced by this object.
#define GL_MAX_TEXTURE_SIZE
const QGradient * gradient() const
Returns the gradient describing this brush.
#define it(className, varName)
QGLFontTexHash qt_font_textures
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
QFixedPoint * glyphPositions
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void setTransform(const QTransform &)
Sets matrix as an explicit transformation matrix on the current brush.
uint has_stencil_face_ext
qreal x2() const
Returns the x-coordinate of the line's end point.
void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush)
Qt::PenStyle style() const
Returns the pen style.
void addItem(const QGLMaskTextureCache::CacheLocation &location)
void quadtreeInsert(int channel, quint64 key, const QRect &rect, int node=0)
QPainterPath transformedPath
void drawMask(const QRect &rect)
The QGLFramebufferObject class encapsulates an OpenGL framebuffer object.
QPointF p1() const
Returns the line's start point.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
static bool isSupported()
void updateMatrix(const QTransform &matrix)
#define GL_STENCIL_BUFFER_BIT
T & first()
Returns a reference to the first item in the vector.
The QByteArray class provides an array of bytes.
bool quadtreeFindAvailableLocation(const QSize &size, QRect *rect, int *channel)
The QConicalGradient class is used in combination with QBrush to specify a conical gradient brush...
QGLTrapezoidMaskGenerator(const QPainterPath &path, const QTransform &matrix, QGLOffscreen &offscreen, GLuint maskFragmentProgram, qreal strokeWidth=-1.0)
QTransform transform() const
Returns the matrix in the current paint engine state.
qreal y2() const
Returns the y-coordinate of the line's end point.
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
QOpenGLTrapezoidToArrayTessellator()
The QPointF class defines a point in the plane using floating point precision.
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
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...
const Vertex * bottomLeft
static QGLSignalProxy * instance()
QGLMaskTextureCache::CacheLocation location
#define Q27Dot5ToDouble(i)
QRectF tessellate(const QPointF *points, int nPoints)
QGLContextHash qt_context_cache
static bool pathClosed(const QPainterPath &path)
#define GL_UNPACK_IMAGE_HEIGHT
QPointF topLeft() const
Returns the position of the rectangle's top-left corner.
bool isLineTo() const
Returns true if the element is a line, otherwise returns false.
void drawImageAsPath(const QRectF &r, const QImage &img, const QRectF &sr)
int left() const
Returns the x-coordinate of the rectangle's left edge.
QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
#define GL_PACK_ALIGNMENT
QColor color() const
Returns the color of this pen's brush.
QVector< QGLTrapezoid > generateTrapezoids()
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation)
int width() const
Returns the width of the rectangle.
void fillPolygon_dev(const QPointF *polygonPoints, int pointCount, Qt::FillRule fill)
virtual uint flags() const
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
void renderHintsChanged()
QGLMaskGenerator(const QPainterPath &path, const QTransform &matrix, qreal stroke_width=-1)
#define GL_TEXTURE_WRAP_S
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
QHash< quint64, QGLFontTexture * > QGLFontTexHash
QGLTrapezoid toGLTrapezoid(const Trapezoid &trap)
void setDevice(QPaintDevice *pdev)
long ASN1_INTEGER_get ASN1_INTEGER * a
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
QRect boundingRect() const
Returns the bounding rectangle of this region.
void updateUseEmulation()
T & value() const
Returns a modifiable reference to the current item's value.
void fontEngineDestroyed(QObject *)
bool isCurveTo() const
Returns true if the element is a curve, otherwise returns false.
int depth() const
Returns the depth of the pixmap.
ushort red
Returns the red color component of this color.
static void qt_glColor4ubv(unsigned char *col)
int height() const
Returns the height of the rectangle.
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush...
qreal y
the y coordinate of the element's position.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
bool contains(const QPointF &pt) const
Returns true if the given point is inside the path, otherwise returns false.
virtual QSize size() const =0
Q_CORE_EXPORT int qrand()
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it...
#define GL_STENCIL_TEST_TWO_SIDE_EXT
The QHash class is a template class that provides a hash-table-based dictionary.
void drawOffscreenPath(const QPainterPath &path)
static const unsigned int num_fragment_composition_modes
static void drawTrapezoid(const QGLTrapezoid &trap, const qreal offscreenHeight, QGLContext *ctx)
Q_DECL_CONSTEXPR T qAbs(const T &t)
QRectF boundingRect() const
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty...
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
int qt_next_power_of_two(int v)
void widgetDestroyed(QObject *)
void tessellate(const QPointF *points, int nPoints, bool winding)
QTransform transform() const
Returns the current transformation matrix for the brush.
void strokePathFastPen(const QPainterPath &path, bool needsResolving)
qreal angle() const
Returns the start angle of the conical gradient in logical coordinates.
QGradient::InterpolationMode interpolationMode
The QPen class defines how a QPainter should draw lines and outlines of shapes.
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.
QPolygon toPolygon() const
Creates and returns a QPolygon by converting each QPointF to a QPoint.
virtual int devType() const
The QSizeF class defines the size of a two-dimensional object using floating point precision...
QGLContext::BindOptions options
const QPainterPath::ElementType * elements() const
void setMiterLimit(qreal length)
Sets the miter limit of the generated outlines to limit.
void cleanupGLContextRefs(const QGLContext *context)
The QChar class provides a 16-bit Unicode character.
int y1() const
Returns the y-coordinate of the line's start point.
virtual QGLContext * context() const =0
uint high_quality_antialiasing
QGLTextureCacheHash cache
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
QVector< qreal > dashPattern() const
Returns the dash pattern of this pen.
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void setFontEngine(QFontEngine *fe)
void strokePath(const QPainterPath &path, bool use_cache)
GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity)
InterpolationMode interpolationMode() const
Returns the interpolation mode of this gradient.
virtual void drawMask(const QRect &rect)=0
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
QMultiHash< quint64, CacheInfo > QGLTextureCacheHash
static void disableOffset(QOpenGLPaintEnginePrivate *d)
QOpenGLPaintEnginePrivate()
qreal x() const
Returns the x-coordinate of this point.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QPointF center() const
Returns the center of the conical gradient in logical coordinates.
static const QGLContext * currentContext()
Returns the current context, i.e.
void updateClipRegion(const QRegion ®ion, Qt::ClipOperation op)
QGLPathMaskGenerator(const QPainterPath &path, const QTransform &matrix, QGLOffscreen &offscreen, GLuint maskFragmentProgram)
The QLineF class provides a two-dimensional vector using floating point precision.
QFuture< T > mapped(const Sequence &sequence, MapFunction function)
void setInvMatrixData(const QTransform &inv_matrix)
void copyDrawable(const QRectF &rect)
void setDashPattern(Qt::PenStyle)
Sets the dash pattern for the generated outlines to style.
static bool areSharing(const QGLContext *context1, const QGLContext *context2)
Returns true if context1 and context2 are sharing their GL resources such as textures, shader programs, etc; otherwise returns false.
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define GL_ONE_MINUS_DST_ALPHA
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
Q_CORE_EXPORT void qDebug(const char *,...)
QGradientStops stops() const
Returns the stop points for this gradient.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
static const unsigned int num_fragment_brushes
QVector< QGLTrapezoid > generateTrapezoids()
void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, GLfloat *array)
void drawLines(const QLineF *lines, int lineCount)
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
static QBezier fromPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
int width() const
Returns the width.
QPainterPath transformedPath
QRegion clipRegion() const
Returns the currently set clip region.
#define ARGB_COMBINE_ALPHA(argb, alpha)
QPainter * painter() const
Returns the paint engine's painter.
GLenum qt_gl_preferredTextureTarget()
#define QT_BEGIN_NAMESPACE
This macro expands to.
QBrush brush() const
Returns the brush in the current paint engine state.
QSize drawableSize() const
QVector< QGLTrapezoid > generateTrapezoids()
void pathToVertexArrays(const QPainterPath &path)
#define GL_MIRRORED_REPEAT_IBM
The QRectF class defines a rectangle in the plane using floating point precision. ...
QPainterState * createState(QPainterState *orig) const
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static void enableOffset(QOpenGLPaintEnginePrivate *d)
QOpenGLPaintEngineState * state()
Qt::ClipOperation clipOperation() const
Returns the clip operation in the current paint engine state.
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
void updateFont(const QFont &font)
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
The QGLContext class encapsulates an OpenGL rendering context.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x)
static const QCssKnownValue positions[NumKnownPositionModes - 1]
#define GL_PACK_SKIP_IMAGES
void addTrap(const Trapezoid &trap)
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b)
QFont font() const
Returns the font in the current paint engine state.
static void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface)
void drawItem(const QDrawQueueItem &item)
void quadtreeUpdate(int channel, int node, int current_block_size)
qreal height() const
Returns the height of the rectangle.
QPainterPath getStrokedPath(const QPainterPath &path, const QPen &pen)
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
QSize size() const
Returns the size of the rectangle.
const T & at(int i) const
Returns the item at index position i in the list.
virtual QFixed ascent() const =0
void updateFragmentProgramData(int locations[])
QGLGlyphCoord * lookup(QFontEngine *, glyph_t)
qreal y1() const
Returns the y-coordinate of the line's start point.
void quadtreeFindExistingLocation(const QSize &size, QRect *rect, int *channel)
QHash< glyph_t, QGLGlyphCoord * > QGLGlyphHash
virtual QFixed descent() const =0
The QPolygonF class provides a vector of points using floating point precision.
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
const T & value() const
Returns the current item's value.
Q_CORE_EXPORT void qWarning(const char *,...)
void updateGLMatrix() const
The QImage class provides a hardware-independent image representation that allows direct access to th...
int x2() const
Returns the x-coordinate of the line's end point.
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
QOpenGLPaintEnginePrivate * p
#define FloatToQuint64(i)
static const char * data(const QByteArray &arr)
bool isQBitmap() const
Returns true if this is a QBitmap; otherwise returns false.
QTransform::TransformationType txop
static int painter_variable_locations[num_fragment_brushes][num_fragment_composition_modes][num_fragment_variables]
void drawTextItem(const QPointF &p, const QTextItem &ti)
This function draws the text item textItem at position p.
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
void setGradientOps(const QBrush &brush, const QRectF &bounds)
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
GLuint getBuffer(const QGradient &gradient, qreal opacity, QGLContext *ctx)
#define GL_LUMINANCE_ALPHA
qreal width() const
Returns the width of the rectangle.
QPaintDevice * device() const
Returns the paint device set for this context.
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
The QRegion class specifies a clip region for a painter.
T value(int i) const
Returns the value at index position i in the list.
Qt::BrushStyle pen_brush_style
virtual void setState(QPainterState *s)
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
void drawPoints(const QPointF *p, int pointCount)
Draws the first pointCount points in the buffer points.
float toFloat(bool *ok=0) const
Returns the byte array converted to a float value.
void drawRects(const QRectF *r, int rectCount)
Draws the first rectCount rectangles in the buffer rects.
GLuint maskFragmentProgram
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
int quadtreeBlocksize(int node)
Qt::FillRule fillRule() const
Returns the painter path's currently set fill rule.
void drawImage(const QRectF &r, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags conversionFlags)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
QHash< QFontEngine *, QGLGlyphHash * > QGLFontGlyphHash
Qt::BrushStyle style() const
Returns the brush style.
QList< QDrawQueueItem > drawQueue
QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
const Vertex * bottomRight
QOpenGLCoordinateOffset(QOpenGLPaintEnginePrivate *d)
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
QSize drawable_texture_size
handler setDevice(device)
QPainter::CompositionMode composition_mode
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
QOpenGLPaintEngineState()
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
void setState(QPainterState *s)
QPointF start() const
Returns the start point of this linear gradient in logical coordinates.
#define glActiveStencilFaceEXT
void updateCompositionMode(QPainter::CompositionMode composition_mode)
QRect toRect() const
Returns a QRect based on the values of this rectangle.
GLuint getProgram(const QGLContext *ctx, int brush, int mode, bool mask_mode)
static const char * mask_fragment_program_sources[num_fragment_masks]
#define glProgramLocalParameter4fvARB
QPainter::CompositionMode composition_mode
void fill(const QVectorPath &path, const QBrush &brush)
void qSwap(T &value1, T &value2)
const T & at(int i) const
Returns the item at index position i in the vector.
virtual QRect screenRect()=0
void generateGradientColorTable(const QGradient &g, uint *colorTable, int size, qreal opacity) const
#define GL_UNPACK_ALIGNMENT
#define GL_DEPTH_BUFFER_BIT
void cleanupContext(const QGLContext *)
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
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 point...
const QBrush & brush() const
Returns the painter's current brush.
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
void setPorterDuffData(float a, float b, float x, float y, float z)
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
virtual void drawLines(const QLine *lines, int lineCount)
The default implementation converts the first lineCount lines in lines to a QLineF and calls the floa...
uint dirty_drawable_texture
The QBrush class defines the fill pattern of shapes drawn by QPainter.
static bool isRect(const T *pts, int elementCount)
int largest_available_block
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
#define GL_TEXTURE_WRAP_T
QGLTrapezoid(qreal top_, qreal bottom_, qreal topLeftX_, qreal topRightX_, qreal bottomLeftX_, qreal bottomRightX_)
QPainterPath stroked_path
void setPixel(int x, int y, uint index_or_rgb)
Sets the pixel index or color at (x, y) to index_or_rgb.
static bool qt_nvidiaFboNeedsFinish
static void addQuadAsTriangle(GLfloat *quad, GLfloat *triangle)
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
int top() const
Returns the y-coordinate of the rectangle's top edge.
GLuint offscreenTexture() const
int width() const
Returns the width of the image.
void cleanupPrograms(const QGLContext *context)
#define Q_DECLARE_PUBLIC(Class)
static const unsigned int num_fragment_variables
ushort blue
Returns the blue color component of this color.
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
void ensureDrawableTexture()
QVector< int > tess_points_stops
void clip(const QVectorPath &path, Qt::ClipOperation op)
int right() const
Returns the x-coordinate of the rectangle's right edge.
void updateBrush(const QBrush &brush, const QPointF &pt)
CacheInfo(const QPainterPath &p, const QTransform &m, qreal w=-1)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
~QOpenGLTrapezoidToArrayTessellator()
void cleanupGLContextRefs(const QGLContext *context)
QRectF controlPointRect() const
Returns the rectangle containing all the points and control points in this path.
void compositionModeChanged()
Type type() const
Returns the type of gradient.
bool isSharing() const
Returns true if this context is sharing its GL context with another QGLContext, otherwise false is re...
ushort alpha
Returns the alpha color component of this color.
bool isValid() const
Returns true if a GL rendering context has been successfully created; otherwise returns false...
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
QPainterPath addCacheElement(quint64 hash_val, QPainterPath path, const QPen &pen)
The QFont class specifies a font used for drawing text.
int y() const
Returns the y-coordinate of the rectangle's top edge.
The QGradient class is used in combination with QBrush to specify gradient fills. ...
void lineToStencil(qreal x, qreal y)
const QGLTrapezoid translated(const QPointF &delta) const
qreal x() const
Returns the x-coordinate of the rectangle's left edge.
qreal strokeWidth() const
void cacheItemErased(int channel, const QRect &rect)
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
void setWidthF(qreal width)
Sets the pen width to the given width in pixels with floating point precision.
QRect computeScreenRect()
qreal miterLimit() const
Returns the miter limit of the pen.
QPainterState * last_created_state
static const int y_margin
static void updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform)
int x() const
Returns the x-coordinate of the rectangle's left edge.
FragmentCompositionModeType
static QTestResult::TestLocation location
The QPoint class defines a point in the plane using integer precision.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
~QOpenGLPaintEngineState()
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
#define GL_TEXTURE_RECTANGLE_NV
int size() const
Returns the number of items in the list.
bool isFastRect(const QRectF &r)
const qreal * points() const
QGLPrivateCleanup ref_cleaner
static uint endianColor(uint c)
void quadtreeClear(int channel, const QRect &rect, int node=0)
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
QPointF p2() const
Returns the line's end point.
void createGradientPaletteTexture(const QGradient &g)
int height() const
Returns the height.
qreal widthF() const
Returns the pen width with floating point precision.
static const char * painter_fragment_program_sources[num_fragment_brushes][num_fragment_composition_modes]
#define GL_UNPACK_SKIP_IMAGES
The QRect class defines a rectangle in the plane using integer precision.
QTransform matrix() const
uint use_smooth_pixmap_transform
#define GL_FRAGMENT_PROGRAM_ARB
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
CacheLocation getMask(QGLMaskGenerator &maskGenerator, QOpenGLPaintEnginePrivate *engine)
qreal radius() const
Returns the radius of this radial gradient in logical coordinates.
FragmentCompositionModeType fragment_composition_mode
QRect computeScreenRect()
Spread spread() const
Returns the spread method use by this gradient.
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
int height() const
Returns the height of the image.
void quadtreeAllocate(quint64 key, const QSize &size, QRect *rect, int *channel)
void createMask(quint64 key, CacheInfo &info, QGLMaskGenerator &maskGenerator)
void split(QBezier *firstHalf, QBezier *secondHalf) const
void fillVertexArray(Qt::FillRule fillRule)
static Extensions glExtensions()
int y() const
Returns the y coordinate of this point.
qreal x
the x coordinate of the element's position.
static void drawPoints(const T *points, int n, const QTransform &transform, IDirectFBSurface *surface)
QSize offscreenSize() const
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...
qreal y() const
Returns the y-coordinate of this point.
void cacheGlyphs(QGLContext *, QFontEngine *, glyph_t *glyphs, int numGlyphs)
QPointF center() const
Returns the center of this radial gradient in logical coordinates.
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...
#define GL_FRONT_AND_BACK
The QPixmap class is an off-screen image representation that can be used as a paint device...
uint has_fast_composition_mode
QRect computeScreenRect()
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
Q_STATIC_INLINE_FUNCTION int qt_div_255(int x)
qreal dashOffset() const
Returns the dash offset for the pen.
QPoint quadtreeLocation(int node)
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
int height() const
Returns the height of the pixmap.
QList< QAElement > lookup(const QList< QAInterface > &interfaces)
QGLRectMaskGenerator(const QPainterPath &path, const QTransform &matrix, QGLOffscreen &offscreen, GLuint maskFragmentProgram)
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
The QPaintEngineState class provides information about the active paint engine's current state...
virtual QRect computeScreenRect()=0
~QOpenGLCoordinateOffset()
void strokeLines(const QPainterPath &path)
bool begin(QPaintDevice *pdev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
QGLContext * context() const
The QSize class defines the size of a two-dimensional object using integer point precision.
T * data()
Returns a pointer to the data stored in the vector.
static QGLPaintDevice * getDevice(QPaintDevice *)
int elementCount() const
Returns the number of path elements in the painter path.
void cleanupGLContextRefs(const QGLContext *context)
QGLLineMaskGenerator(const QPainterPath &path, const QTransform &matrix, qreal width, QGLOffscreen &offscreen, GLuint maskFragmentProgram)
int y2() const
Returns the y-coordinate of the line's end point.
int x() const
Returns the x coordinate of this point.
static int mask_variable_locations[num_fragment_masks][num_fragment_variables]
QPen pen() const
Returns the pen in the current paint engine state.
FragmentBrushType fragment_brush
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
void tessellateRect(const QPointF &a, const QPointF &b, qreal width)
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
void cleanupGLContextRefs(const QGLContext *context)
QGLPrivateCleanup(QOpenGLPaintEnginePrivate *priv)
qreal bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
static int grow(int size)
#define GL_TEXTURE_MAG_FILTER
QGLFramebufferObject * offscreen
static void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface)
void systemStateChanged()
static bool needsEmulation(Qt::BrushStyle style)
The QTextItem class provides all the information required to draw text in a custom paint engine...
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...
QDataBuffer< QPointF > tess_points
QPixmap copy(int x, int y, int width, int height) const
Returns a deep copy of the subset of the pixmap that is specified by the rectangle QRect( x...
QImage scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
void drawTextureRect(int tx_width, int tx_height, const QRectF &r, const QRectF &sr, GLenum target, QGLTexture *tex)
void fillPath(const QPainterPath &path)
Qt::PenCapStyle capStyle() const
Returns the pen's cap style.
bool qt_resolve_frag_program_extensions(QGLContext *ctx)
void composite(const QRectF &rect, const QPoint &maskOffset=QPoint())
static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy)
static const KeyPair *const end
#define GL_PACK_IMAGE_HEIGHT
qreal x1() const
Returns the x-coordinate of the line's start point.
void updateRenderHints(QPainter::RenderHints hints)
int x1() const
Returns the x-coordinate of the line's start point.
void qt_add_rect_to_array(const QRectF &r, GLfloat *array)
CacheInfo(QPainterPath p, QPainterPath sp, QPen stroke_pen)
QImage textureImage() const
Returns the custom brush pattern, or a null image if no custom brush pattern has been set...
void setDrawableSize(const QSize &drawableSize)
QMultiHash< quint64, CacheInfo > QGLStrokeTableHash
QMultiHash< quint64, CacheInfo > QGLGradientColorTableHash
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
QPointF center() const
Returns the center point of the rectangle.
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
bool qt_resolve_stencil_face_extension(QGLContext *ctx)
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...
ushort green
Returns the green color component of this color.
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
#define glProgramStringARB
void curveToStencil(const QPointF &cp1, const QPointF &cp2, const QPointF &ep)
bool end()
Reimplement this function to finish painting on the current paint device.
int size() const
Returns the number of items in the vector.
virtual QVector< QGLTrapezoid > generateTrapezoids()=0
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
static void qt_delete_glyph_hash(QGLGlyphHash *hash)
QGLGlyphHash * current_cache
quint64 hash(const QPainterPath &p, const QTransform &m, qreal w)
static QPainterPath strokeForPath(const QPainterPath &path, const QPen &cpen)
void updatePen(const QPen &pen)
void brushOriginChanged()
void drawEllipse(const QRectF &rect)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
QRgb rgb() const
Returns the RGB value of the color.
Q_DECL_CONSTEXPR int qRound(qreal d)
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
QGLGradientColorTableHash cache
Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path)
void setGLBrush(const QColor &c)
void qgl_cleanup_glyph_cache(QGLContext *ctx)
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...
void drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy, const QPointF &offset)
static const T qSubImage(const T &image, const QRectF &src, QRectF *srcNew)
int * maskVariableLocations
static qreal toReal(Register *reg, int type, bool *ok=0)
QPointF finalStop() const
Returns the final stop point of this linear gradient in logical coordinates.
void setGLPen(const QColor &c)
void updateGradient(const QBrush &brush, const QRectF &bounds)
The QList class is a template class that provides lists.
static bool needsResolving(const QBrush &brush)
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
void drawFastRect(const QRectF &rect)
QPainterPath path() const
QScopedPointer< QPainterPrivate > d_ptr
static const int x_margin
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
QMultiHash< const QGLContext *, GLProgram > QGLProgramHash
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.