Changeset 561 for trunk/src/opengl/qpaintengine_opengl.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/opengl/qpaintengine_opengl.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtOpenGL module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** 40 40 ****************************************************************************/ 41 41 42 #include <private/qtextengine_p.h>43 42 #include <qdebug.h> 44 43 #include <private/qfontengine_p.h> … … 51 50 #include "qgl.h" 52 51 #include <private/qgl_p.h> 52 #include <private/qglpaintdevice_p.h> 53 53 #include <private/qpainter_p.h> 54 54 #include "qmap.h" … … 58 58 #include "qvarlengtharray.h" 59 59 #include <private/qpainter_p.h> 60 #include <qglpixelbuffer.h>61 60 #include <private/qglpixelbuffer_p.h> 62 61 #include <private/qbezier_p.h> … … 64 63 65 64 #include "private/qtessellator_p.h" 66 #include "private/qwindowsurface_gl_p.h"67 65 68 66 #include "util/fragmentprograms_p.h" 69 67 70 68 #ifdef Q_WS_QWS 71 #include "private/qglpaintdevice_qws_p.h"72 69 #include "private/qglwindowsurface_qws_p.h" 73 70 #include "qwsmanager_qws.h" … … 79 76 #endif 80 77 81 #define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(d rawable.context());78 #define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(device->context()); 82 79 83 80 #include <stdlib.h> … … 114 111 static inline void qt_glColor4ubv(unsigned char *col) 115 112 { 116 #ifdef QT_OPENGL_ES 117 glColor4f(col[0]/255.0, col[1]/255.0, col[2]/255.0, col[3]/255.0); 118 #else 119 glColor4ubv(col); 120 #endif 113 glColor4f(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, col[3]/255.0f); 121 114 } 122 115 … … 125 118 qreal y; 126 119 }; 127 128 void qt_add_rect_to_array(const QRectF &r, q_vertexType *array)129 {130 qreal left = r.left();131 qreal right = r.right();132 qreal top = r.top();133 qreal bottom = r.bottom();134 135 array[0] = f2vt(left);136 array[1] = f2vt(top);137 array[2] = f2vt(right);138 array[3] = f2vt(top);139 array[4] = f2vt(right);140 array[5] = f2vt(bottom);141 array[6] = f2vt(left);142 array[7] = f2vt(bottom);143 }144 145 void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, q_vertexType *array)146 {147 array[0] = f2vt(x1);148 array[1] = f2vt(y1);149 array[2] = f2vt(x2);150 array[3] = f2vt(y1);151 array[4] = f2vt(x2);152 array[5] = f2vt(y2);153 array[6] = f2vt(x1);154 array[7] = f2vt(y2);155 }156 120 157 121 struct QGLTrapezoid … … 189 153 trap.bottomRightX += delta.x(); 190 154 return trap; 191 }192 193 class QGLDrawable {194 public:195 QGLDrawable() : widget(0), buffer(0), fbo(0)196 , wsurf(0)197 {}198 inline void setDevice(QPaintDevice *pdev);199 inline void swapBuffers();200 inline void makeCurrent();201 inline void doneCurrent();202 inline QSize size() const;203 inline QGLFormat format() const;204 inline GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA);205 inline GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA);206 inline QColor backgroundColor() const;207 inline QGLContext *context() const;208 inline bool autoFillBackground() const;209 210 private:211 bool wasBound;212 QGLWidget *widget;213 QGLPixelBuffer *buffer;214 QGLFramebufferObject *fbo;215 #ifdef Q_WS_QWS216 QWSGLWindowSurface *wsurf;217 #else218 QGLWindowSurface *wsurf;219 #endif220 };221 222 void QGLDrawable::setDevice(QPaintDevice *pdev)223 {224 wasBound = false;225 widget = 0;226 buffer = 0;227 fbo = 0;228 #ifdef Q_WS_QWS229 wsurf = 0;230 #endif231 if (pdev->devType() == QInternal::Widget)232 widget = static_cast<QGLWidget *>(pdev);233 else if (pdev->devType() == QInternal::Pbuffer)234 buffer = static_cast<QGLPixelBuffer *>(pdev);235 else if (pdev->devType() == QInternal::FramebufferObject)236 fbo = static_cast<QGLFramebufferObject *>(pdev);237 else if (pdev->devType() == QInternal::UnknownDevice)238 #ifdef Q_WS_QWS239 wsurf = static_cast<QWSGLPaintDevice*>(pdev)->windowSurface();240 #else241 wsurf = static_cast<QGLWindowSurface *>(pdev);242 #endif243 }244 245 inline void QGLDrawable::swapBuffers()246 {247 if (widget) {248 if (widget->autoBufferSwap())249 widget->swapBuffers();250 } else {251 glFlush();252 }253 }254 255 inline void QGLDrawable::makeCurrent()256 {257 if (widget)258 widget->makeCurrent();259 else if (buffer)260 buffer->makeCurrent();261 else if (wsurf)262 wsurf->context()->makeCurrent();263 else if (fbo) {264 wasBound = fbo->isBound();265 if (!wasBound)266 fbo->bind();267 }268 }269 270 inline void QGLDrawable::doneCurrent()271 {272 if (fbo && !wasBound)273 fbo->release();274 }275 276 inline QSize QGLDrawable::size() const277 {278 if (widget) {279 return QSize(widget->d_func()->glcx->device()->width(),280 widget->d_func()->glcx->device()->height());281 } else if (buffer) {282 return buffer->size();283 } else if (fbo) {284 return fbo->size();285 } else if (wsurf) {286 #ifdef Q_WS_QWS287 return wsurf->window()->frameSize();288 #else289 return QSize(wsurf->width(), wsurf->height());290 #endif291 }292 return QSize();293 }294 295 inline QGLFormat QGLDrawable::format() const296 {297 if (widget)298 return widget->format();299 else if (buffer)300 return buffer->format();301 else if (wsurf)302 return wsurf->context()->format();303 else if (fbo && QGLContext::currentContext()) {304 QGLFormat fmt = QGLContext::currentContext()->format();305 fmt.setStencil(fbo->attachment() == QGLFramebufferObject::CombinedDepthStencil);306 fmt.setDepth(fbo->attachment() != QGLFramebufferObject::NoAttachment);307 return fmt;308 }309 310 return QGLFormat();311 }312 313 inline GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format)314 {315 if (widget)316 return widget->d_func()->glcx->d_func()->bindTexture(image, target, format, true);317 else if (buffer)318 return buffer->d_func()->qctx->d_func()->bindTexture(image, target, format, true);319 else if (fbo && QGLContext::currentContext())320 return const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(image, target, format, true);321 else if (wsurf)322 return wsurf->context()->d_func()->bindTexture(image, target, format, true);323 return 0;324 }325 326 inline GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint format)327 {328 if (widget)329 return widget->d_func()->glcx->d_func()->bindTexture(pixmap, target, format, true);330 else if (buffer)331 return buffer->d_func()->qctx->d_func()->bindTexture(pixmap, target, format, true);332 else if (fbo && QGLContext::currentContext())333 return const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(pixmap, target, format, true);334 else if (wsurf)335 return wsurf->context()->d_func()->bindTexture(pixmap, target, format, true);336 return 0;337 }338 339 inline QColor QGLDrawable::backgroundColor() const340 {341 if (widget)342 return widget->palette().brush(widget->backgroundRole()).color();343 return QApplication::palette().brush(QPalette::Background).color();344 }345 346 inline QGLContext *QGLDrawable::context() const347 {348 if (widget)349 return widget->d_func()->glcx;350 else if (buffer)351 return buffer->d_func()->qctx;352 else if (fbo)353 return const_cast<QGLContext *>(QGLContext::currentContext());354 else if (wsurf)355 return wsurf->context();356 return 0;357 }358 359 inline bool QGLDrawable::autoFillBackground() const360 {361 if (widget)362 return widget->autoFillBackground();363 else364 return false;365 155 } 366 156 … … 455 245 { 456 246 connect(QGLSignalProxy::instance(), 457 SIGNAL(aboutToDestroyContext(const QGLContext 458 SLOT(cleanupGLContextRefs(const QGLContext 247 SIGNAL(aboutToDestroyContext(const QGLContext*)), 248 SLOT(cleanupGLContextRefs(const QGLContext*))); 459 249 } 460 250 … … 493 283 494 284 private: 495 QGL Drawable drawable;285 QGLPaintDevice* device; 496 286 497 287 QGLFramebufferObject *offscreen; … … 512 302 inline void QGLOffscreen::setDevice(QPaintDevice *pdev) 513 303 { 514 drawable.setDevice(pdev); 304 if (pdev->devType() == QInternal::OpenGL) 305 device = static_cast<QGLPaintDevice*>(pdev); 306 else 307 device = QGLPaintDevice::getDevice(pdev); 308 309 if (!device) 310 return; 515 311 516 312 drawable_fbo = (pdev->devType() == QInternal::FramebufferObject); … … 536 332 initialized = true; 537 333 538 int dim = qMax(2048, static_cast<int>(qt_next_power_of_two(qMax(d rawable.size().width(), drawable.size().height()))));539 540 bool shared_context = qgl_share_reg()->checkSharing(drawable.context(), ctx);334 int dim = qMax(2048, static_cast<int>(qt_next_power_of_two(qMax(device->size().width(), device->size().height())))); 335 336 bool shared_context = QGLContext::areSharing(device->context(), ctx); 541 337 bool would_fail = last_failed_size.isValid() && 542 (d rawable.size().width() >= last_failed_size.width() ||543 d rawable.size().height() >= last_failed_size.height());338 (device->size().width() >= last_failed_size.width() || 339 device->size().height() >= last_failed_size.height()); 544 340 bool needs_refresh = dim > mask_dim || !shared_context; 545 341 … … 555 351 offscreen = 0; 556 352 mask_dim = 0; 557 last_failed_size = d rawable.size();353 last_failed_size = device->size(); 558 354 } 559 355 } 560 356 561 357 qt_mask_texture_cache()->setOffscreenSize(offscreenSize()); 562 qt_mask_texture_cache()->setDrawableSize(d rawable.size());563 ctx = d rawable.context();358 qt_mask_texture_cache()->setDrawableSize(device->size()); 359 ctx = device->context(); 564 360 #endif 565 361 } … … 635 431 636 432 if (drawable_fbo) 637 d rawable.makeCurrent();433 device->ensureActiveTarget(); //### 638 434 else 639 435 offscreen->release(); 640 436 641 QSize sz(d rawable.size());437 QSize sz(device->size()); 642 438 glViewport(0, 0, sz.width(), sz.height()); 643 439 … … 662 458 inline QSize QGLOffscreen::drawableSize() const 663 459 { 664 return d rawable.size();460 return device->size(); 665 461 } 666 462 … … 726 522 // we have to know when a context is deleted so we can free 727 523 // any program handles it holds 728 connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext 729 SLOT(cleanupPrograms(const QGLContext 524 connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), 525 SLOT(cleanupPrograms(const QGLContext*))); 730 526 731 527 } … … 755 551 for (int i=0; i<contexts.size(); ++i) { 756 552 const QGLContext *cx = contexts.at(i); 757 if (cx != ctx && qgl_share_reg()->checkSharing(cx, ctx)) {553 if (cx != ctx && QGLContext::areSharing(cx, ctx)) { 758 554 QList<GLProgram> progs = programs.values(cx); 759 555 for (int k=0; k<progs.size(); ++k) { … … 840 636 { 841 637 connect(QGLSignalProxy::instance(), 842 SIGNAL(aboutToDestroyContext(const QGLContext 843 SLOT(cleanupGLContextRefs(const QGLContext 638 SIGNAL(aboutToDestroyContext(const QGLContext*)), 639 SLOT(cleanupGLContextRefs(const QGLContext*))); 844 640 } 845 641 … … 869 665 , inverseScale(1) 870 666 , moveToCount(0) 667 , last_created_state(0) 871 668 , shader_ctx(0) 872 669 , grad_palette(0) … … 946 743 uint has_fast_pen : 1; 947 744 uint use_stencil_method : 1; 948 uint dirty_stencil : 1;949 745 uint dirty_drawable_texture : 1; 950 746 uint has_stencil_face_ext : 1; … … 957 753 uint use_emulation : 1; 958 754 755 QRegion dirty_stencil; 756 959 757 void updateUseEmulation(); 960 758 … … 963 761 GLubyte brush_color[4]; 964 762 QTransform::TransformationType txop; 965 QGL Drawable drawable;763 QGLPaintDevice* device; 966 764 QGLOffscreen offscreen; 967 765 … … 974 772 975 773 void drawImageAsPath(const QRectF &r, const QImage &img, const QRectF &sr); 976 void drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy );774 void drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy, const QPointF &offset); 977 775 978 776 void drawOffscreenPath(const QPainterPath &path); … … 994 792 995 793 void updateGLMatrix() const; 794 795 mutable QPainterState *last_created_state; 996 796 997 797 QGLContext *shader_ctx; … … 1207 1007 { 1208 1008 connect(QGLSignalProxy::instance(), 1209 SIGNAL(aboutToDestroyContext(const QGLContext 1210 SLOT(cleanupGLContextRefs(const QGLContext 1009 SIGNAL(aboutToDestroyContext(const QGLContext*)), 1010 SLOT(cleanupGLContextRefs(const QGLContext*))); 1211 1011 } 1212 1012 1213 1013 inline GLuint getBuffer(const QGradient &gradient, qreal opacity, QGLContext *ctx) { 1214 if (buffer_ctx && ! qgl_share_reg()->checkSharing(buffer_ctx, ctx))1014 if (buffer_ctx && !QGLContext::areSharing(buffer_ctx, ctx)) 1215 1015 cleanCache(); 1216 1016 … … 1274 1074 1275 1075 void cleanCache() { 1076 QGLShareContextScope scope(buffer_ctx); 1276 1077 QGLGradientColorTableHash::const_iterator it = cache.constBegin(); 1277 1078 for (; it != cache.constEnd(); ++it) { … … 1371 1172 Q_UNUSED(g); 1372 1173 #else 1373 GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, d rawable.context());1174 GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, device->context()); 1374 1175 glBindTexture(GL_TEXTURE_1D, texId); 1375 1176 grad_palette = texId; … … 1418 1219 else if (current_style == Qt::SolidPattern) 1419 1220 fragment_brush = FRAGMENT_PROGRAM_BRUSH_SOLID; 1420 else if (current_style == Qt::TexturePattern )1221 else if (current_style == Qt::TexturePattern && !brush.texture().isQBitmap()) 1421 1222 fragment_brush = FRAGMENT_PROGRAM_BRUSH_TEXTURE; 1422 1223 else … … 1440 1241 Q_D(QOpenGLPaintEngine); 1441 1242 1442 d->drawable.setDevice(pdev); 1243 if (pdev->devType() == QInternal::OpenGL) 1244 d->device = static_cast<QGLPaintDevice*>(pdev); 1245 else 1246 d->device = QGLPaintDevice::getDevice(pdev); 1247 1248 if (!d->device) 1249 return false; 1250 1443 1251 d->offscreen.setDevice(pdev); 1444 1252 d->has_fast_pen = false; 1445 1253 d->inverseScale = 1; 1446 1254 d->opacity = 1; 1447 d->d rawable.makeCurrent();1255 d->device->beginPaint(); 1448 1256 d->matrix = QTransform(); 1449 1257 d->has_antialiasing = false; 1450 1258 d->high_quality_antialiasing = false; 1451 d->dirty_stencil = true; 1259 1260 QSize sz(d->device->size()); 1261 d->dirty_stencil = QRect(0, 0, sz.width(), sz.height()); 1452 1262 1453 1263 d->use_emulation = false; … … 1460 1270 && (pdev->devType() != QInternal::Pixmap); 1461 1271 1462 QGLContext *ctx = const_cast<QGLContext *>(d->d rawable.context());1272 QGLContext *ctx = const_cast<QGLContext *>(d->device->context()); 1463 1273 if (!ctx) { 1464 1274 qWarning() << "QOpenGLPaintEngine: paint device doesn't have a valid GL context."; … … 1469 1279 has_frag_program = qt_resolve_frag_program_extensions(ctx) && qt_resolve_version_1_3_functions(ctx); 1470 1280 1471 d->use_stencil_method = d->d rawable.format().stencil()1281 d->use_stencil_method = d->device->format().stencil() 1472 1282 && (QGLExtensions::glExtensions & QGLExtensions::StencilWrap); 1473 if (d->d rawable.format().directRendering()1283 if (d->device->format().directRendering() 1474 1284 && (d->use_stencil_method && QGLExtensions::glExtensions & QGLExtensions::StencilTwoSide)) 1475 1285 d->has_stencil_face_ext = qt_resolve_stencil_face_extension(ctx); … … 1537 1347 d->offscreen.begin(); 1538 1348 1539 const QColor &c = d->drawable.backgroundColor();1540 glClearColor(c.redF(), c.greenF(), c.blueF(), 1.0);1541 if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) {1542 GLbitfield clearBits = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;1543 #ifndef QT_OPENGL_ES1544 clearBits |= GL_ACCUM_BUFFER_BIT;1545 #endif1546 glClear(clearBits);1547 }1548 1549 QSize sz(d->drawable.size());1550 1349 glViewport(0, 0, sz.width(), sz.height()); // XXX (Embedded): We need a solution for GLWidgets that draw in a part or a bigger surface... 1551 1350 glMatrixMode(GL_PROJECTION); … … 1564 1363 d->max_texture_size = ctx->d_func()->maxTextureSize(); 1565 1364 #else 1566 bool shared_ctx = qgl_share_reg()->checkSharing(d->drawable.context(), d->shader_ctx);1365 bool shared_ctx = QGLContext::areSharing(d->device->context(), d->shader_ctx); 1567 1366 1568 1367 if (shared_ctx) { … … 1580 1379 ctx->makeCurrent(); 1581 1380 } 1582 d->shader_ctx = d->d rawable.context();1381 d->shader_ctx = d->device->context(); 1583 1382 glGenTextures(1, &d->grad_palette); 1584 1383 … … 1615 1414 d->flushDrawQueue(); 1616 1415 d->offscreen.end(); 1617 QGLContext *ctx = const_cast<QGLContext *>(d->d rawable.context());1416 QGLContext *ctx = const_cast<QGLContext *>(d->device->context()); 1618 1417 if (!ctx->d_ptr->internal_context) { 1619 1418 glMatrixMode(GL_TEXTURE); … … 1632 1431 } 1633 1432 #endif 1634 d->drawable.swapBuffers(); 1635 d->drawable.doneCurrent(); 1433 d->device->endPaint(); 1636 1434 qt_mask_texture_cache()->maintainCache(); 1637 1435 … … 1796 1594 QTransform translate(1, 0, 0, 1, -realFocal.x(), -realFocal.y()); 1797 1595 QTransform gl_to_qt(1, 0, 0, -1, 0, pdev->height()); 1798 QTransform inv_matrix = gl_to_qt * matrix.inverted() * brush.transform().inverted() * translate; 1596 QTransform m = QTransform(matrix).translate(brush_origin.x(), brush_origin.y()); 1597 QTransform inv_matrix = gl_to_qt * (brush.transform() * m).inverted() * translate; 1799 1598 1800 1599 setInvMatrixData(inv_matrix); … … 1809 1608 QTransform translate(1, 0, 0, 1, -realCenter.x(), -realCenter.y()); 1810 1609 QTransform gl_to_qt(1, 0, 0, -1, 0, pdev->height()); 1811 QTransform inv_matrix = gl_to_qt * matrix.inverted() * brush.transform().inverted() * translate; 1610 QTransform m = QTransform(matrix).translate(brush_origin.x(), brush_origin.y()); 1611 QTransform inv_matrix = gl_to_qt * (brush.transform() * m).inverted() * translate; 1812 1612 1813 1613 setInvMatrixData(inv_matrix); … … 1821 1621 QTransform translate(1, 0, 0, 1, -realStart.x(), -realStart.y()); 1822 1622 QTransform gl_to_qt(1, 0, 0, -1, 0, pdev->height()); 1823 1824 QTransform inv_matrix = gl_to_qt * matrix.inverted() * brush.transform().inverted() * translate;1623 QTransform m = QTransform(matrix).translate(brush_origin.x(), brush_origin.y()); 1624 QTransform inv_matrix = gl_to_qt * (brush.transform() * m).inverted() * translate; 1825 1625 1826 1626 setInvMatrixData(inv_matrix); … … 1833 1633 linear_data[2] = 1.0f / (l.x() * l.x() + l.y() * l.y()); 1834 1634 } else if (style != Qt::SolidPattern) { 1835 QTransform translate(1, 0, 0, 1, brush_origin.x(), brush_origin.y());1836 1635 QTransform gl_to_qt(1, 0, 0, -1, 0, pdev->height()); 1837 1838 QTransform inv_matrix = gl_to_qt * matrix.inverted() * brush.transform().inverted() * translate;1636 QTransform m = QTransform(matrix).translate(brush_origin.x(), brush_origin.y()); 1637 QTransform inv_matrix = gl_to_qt * (brush.transform() * m).inverted(); 1839 1638 1840 1639 setInvMatrixData(inv_matrix); … … 1925 1724 qreal rightB = trap.bottomRightX + (trap.topRightX - trap.bottomRightX) * reciprocal; 1926 1725 1927 const bool topZero = qFuzzy Compare(topDist + 1, 1);1726 const bool topZero = qFuzzyIsNull(topDist); 1928 1727 1929 1728 reciprocal = topZero ? 1.0 / bottomDist : 1.0 / topDist; … … 1932 1731 qreal rightA = topZero ? (trap.bottomRightX - rightB) * reciprocal : (trap.topRightX - rightB) * reciprocal; 1933 1732 1934 qreal invLeftA = qFuzzy Compare(leftA + 1, 1) ? 0.0 : 1.0 / leftA;1935 qreal invRightA = qFuzzy Compare(rightA + 1, 1) ? 0.0 : 1.0 / rightA;1733 qreal invLeftA = qFuzzyIsNull(leftA) ? 0.0 : 1.0 / leftA; 1734 qreal invRightA = qFuzzyIsNull(rightA) ? 0.0 : 1.0 / rightA; 1936 1735 1937 1736 // fragment program needs the negative of invRightA as it mirrors the line … … 1984 1783 { 1985 1784 // On OpenGL ES we convert the trap to 2 triangles 1986 #ifndef QT_OPENGL_ES _11785 #ifndef QT_OPENGL_ES 1987 1786 if (size > allocated - 8) { 1988 1787 #else … … 1995 1794 QGLTrapezoid t = toGLTrapezoid(trap); 1996 1795 1997 #ifndef QT_OPENGL_ES _11998 vertices[size++] = t.topLeftX;1999 vertices[size++] = t.top;2000 vertices[size++] = t.topRightX;2001 vertices[size++] = t.top;2002 vertices[size++] = t.bottomRightX;2003 vertices[size++] = t.bottom;2004 vertices[size++] = t.bottomLeftX;2005 vertices[size++] = t.bottom;1796 #ifndef QT_OPENGL_ES 1797 vertices[size++] = f2vt(t.topLeftX); 1798 vertices[size++] = f2vt(t.top); 1799 vertices[size++] = f2vt(t.topRightX); 1800 vertices[size++] = f2vt(t.top); 1801 vertices[size++] = f2vt(t.bottomRightX); 1802 vertices[size++] = f2vt(t.bottom); 1803 vertices[size++] = f2vt(t.bottomLeftX); 1804 vertices[size++] = f2vt(t.bottom); 2006 1805 #else 2007 1806 // First triangle 2008 vertices[size++] = t.topLeftX;2009 vertices[size++] = t.top;2010 vertices[size++] = t.topRightX;2011 vertices[size++] = t.top;2012 vertices[size++] = t.bottomRightX;2013 vertices[size++] = t.bottom;1807 vertices[size++] = f2vt(t.topLeftX); 1808 vertices[size++] = f2vt(t.top); 1809 vertices[size++] = f2vt(t.topRightX); 1810 vertices[size++] = f2vt(t.top); 1811 vertices[size++] = f2vt(t.bottomRightX); 1812 vertices[size++] = f2vt(t.bottom); 2014 1813 2015 1814 // Second triangle 2016 vertices[size++] = t.bottomLeftX;2017 vertices[size++] = t.bottom;2018 vertices[size++] = t.topLeftX;2019 vertices[size++] = t.top;2020 vertices[size++] = t.bottomRightX;2021 vertices[size++] = t.bottom;1815 vertices[size++] = f2vt(t.bottomLeftX); 1816 vertices[size++] = f2vt(t.bottom); 1817 vertices[size++] = f2vt(t.topLeftX); 1818 vertices[size++] = f2vt(t.top); 1819 vertices[size++] = f2vt(t.bottomRightX); 1820 vertices[size++] = f2vt(t.bottom); 2022 1821 #endif 2023 1822 } … … 2149 1948 Q_Q(QOpenGLPaintEngine); 2150 1949 2151 if (dirty_stencil) { 1950 QRect rect = dirty_stencil.boundingRect(); 1951 1952 if (use_system_clip) 1953 rect = q->systemClip().intersected(dirty_stencil).boundingRect(); 1954 1955 glStencilMask(~0); 1956 1957 if (!rect.isEmpty()) { 2152 1958 disableClipping(); 2153 1959 2154 if (use_system_clip) { 2155 glEnable(GL_SCISSOR_TEST); 2156 2157 QRect rect = q->systemClip().boundingRect(); 2158 2159 const int left = rect.left(); 2160 const int width = rect.width(); 2161 const int bottom = drawable.size().height() - (rect.bottom() + 1); 2162 const int height = rect.height(); 2163 2164 glScissor(left, bottom, width, height); 2165 } 1960 glEnable(GL_SCISSOR_TEST); 1961 1962 const int left = rect.left(); 1963 const int width = rect.width(); 1964 const int bottom = device->size().height() - (rect.bottom() + 1); 1965 const int height = rect.height(); 1966 1967 glScissor(left, bottom, width, height); 2166 1968 2167 1969 glClearStencil(0); 2168 1970 glClear(GL_STENCIL_BUFFER_BIT); 2169 dirty_stencil = false; 2170 2171 if (use_system_clip) 2172 glDisable(GL_SCISSOR_TEST); 1971 dirty_stencil -= rect; 1972 1973 glDisable(GL_SCISSOR_TEST); 2173 1974 2174 1975 enableClipping(); 2175 1976 } 2176 2177 glStencilMask(~0);2178 1977 2179 1978 // Enable stencil. … … 2234 2033 // Enable color writes. 2235 2034 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 2236 glStencilMask( 0);2035 glStencilMask(stencilMask); 2237 2036 2238 2037 setGradientOps(cbrush, QRectF(QPointF(min_x, min_y), QSizeF(max_x - min_x, max_y - min_y))); … … 2246 2045 // Enable stencil func. 2247 2046 glStencilFunc(GL_NOTEQUAL, 0, stencilMask); 2047 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); 2248 2048 composite(rect); 2249 2049 } else { … … 2252 2052 // Enable stencil func. 2253 2053 glStencilFunc(GL_NOTEQUAL, 0, stencilMask); 2054 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); 2254 2055 #ifndef QT_OPENGL_ES 2255 2056 glBegin(GL_QUADS); … … 2262 2063 } 2263 2064 2264 glStencilMask(~0);2265 glStencilFunc(GL_ALWAYS, 0, 0);2266 glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);2267 2268 // clear all stencil values to 02269 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);2270 2271 #ifndef QT_OPENGL_ES2272 glBegin(GL_QUADS);2273 glVertex2f(min_x, min_y);2274 glVertex2f(max_x, min_y);2275 glVertex2f(max_x, max_y);2276 glVertex2f(min_x, max_y);2277 glEnd();2278 #endif2279 2280 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);2281 2282 2065 // Disable stencil writes. 2283 2066 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); … … 2332 2115 d->pen_brush_style = pen.brush().style(); 2333 2116 d->cpen = pen; 2334 d->has_pen = (pen_style != Qt::NoPen) ;2117 d->has_pen = (pen_style != Qt::NoPen) && (d->pen_brush_style != Qt::NoBrush); 2335 2118 d->updateUseEmulation(); 2336 2119 … … 2436 2219 Q_Q(QOpenGLPaintEngine); 2437 2220 2221 ++q->state()->depthClipId; 2222 2438 2223 glDisable(GL_DEPTH_TEST); 2439 2224 glDisable(GL_SCISSOR_TEST); … … 2454 2239 const int left = fastClip.left(); 2455 2240 const int width = fastClip.width(); 2456 const int bottom = d rawable.size().height() - (fastClip.bottom() + 1);2241 const int bottom = device->size().height() - (fastClip.bottom() + 1); 2457 2242 const int height = fastClip.height(); 2458 2243 … … 2461 2246 } 2462 2247 2463 #ifndef QT_OPENGL_ES 2248 #if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_ES_1_CL) 2249 glClearDepthf(0.0f); 2250 #else 2464 2251 glClearDepth(0.0f); 2465 #else2466 glClearDepthf(0.0f);2467 2252 #endif 2253 2468 2254 glEnable(GL_DEPTH_TEST); 2469 2255 glDepthMask(GL_TRUE); … … 2524 2310 { 2525 2311 Q_Q(QOpenGLPaintEngine); 2526 if (q-> state()->hasClipping)2312 if (q->painter()->hasClipping()) 2527 2313 q->updateClipRegion(q->painter()->clipRegion(), Qt::ReplaceClip); 2528 2314 else … … 2536 2322 // clipping is only supported when a stencil or depth buffer is 2537 2323 // available 2538 if (!d->d rawable.format().depth())2324 if (!d->device->format().depth()) 2539 2325 return; 2540 2326 … … 2573 2359 path = d->matrix.map(path); 2574 2360 2575 if (path.contains(QRectF(QPointF(), d->d rawable.size())))2361 if (path.contains(QRectF(QPointF(), d->device->size()))) 2576 2362 isScreenClip = true; 2577 2363 } … … 3301 3087 } 3302 3088 3089 extern void qt_add_rect_to_array(const QRectF &r, q_vertexType *array); 3090 extern void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, q_vertexType *array); 3091 3303 3092 void QGLTrapezoidMaskGenerator::drawMask(const QRect &rect) 3304 3093 { … … 3446 3235 qreal width = qAbs(delta.x()) + qAbs(delta.y()); 3447 3236 3448 Q_ASSERT(qFuzzyCompare(delta.x() + 1, static_cast<qreal>(1)) 3449 || qFuzzyCompare(delta.y() + 1, static_cast<qreal>(1))); 3237 Q_ASSERT(qFuzzyIsNull(delta.x()) || qFuzzyIsNull(delta.y())); 3450 3238 3451 3239 tessellator.tessellateRect(first, last, width); … … 3578 3366 disableClipping(); 3579 3367 3580 GLuint program = qt_gl_program_cache()->getProgram(d rawable.context(),3368 GLuint program = qt_gl_program_cache()->getProgram(device->context(), 3581 3369 FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); 3582 3370 QGLPathMaskGenerator maskGenerator(path, matrix, offscreen, program); … … 3715 3503 if (d->has_brush) { 3716 3504 d->disableClipping(); 3717 GLuint program = qt_gl_program_cache()->getProgram(d->d rawable.context(),3505 GLuint program = qt_gl_program_cache()->getProgram(d->device->context(), 3718 3506 FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); 3719 QGLRectMaskGenerator maskGenerator(path, d->matrix, d->offscreen, program); 3720 d->addItem(qt_mask_texture_cache()->getMask(maskGenerator, d)); 3507 3508 if (d->matrix.type() >= QTransform::TxProject) { 3509 QGLPathMaskGenerator maskGenerator(path, d->matrix, d->offscreen, program); 3510 d->addItem(qt_mask_texture_cache()->getMask(maskGenerator, d)); 3511 } else { 3512 QGLRectMaskGenerator maskGenerator(path, d->matrix, d->offscreen, program); 3513 d->addItem(qt_mask_texture_cache()->getMask(maskGenerator, d)); 3514 } 3721 3515 3722 3516 d->enableClipping(); … … 3893 3687 // scale or 90 degree rotation? 3894 3688 if (d->matrix.type() <= QTransform::TxTranslate 3895 || !d->cpen.isCosmetic()3896 && (d->matrix.type() <= QTransform::TxScale3897 || (d->matrix.type() == QTransform::TxRotate3898 && d->matrix.m11() == 0 && d->matrix.m22() == 0))) {3689 || (!d->cpen.isCosmetic() 3690 && (d->matrix.type() <= QTransform::TxScale 3691 || (d->matrix.type() == QTransform::TxRotate 3692 && d->matrix.m11() == 0 && d->matrix.m22() == 0)))) { 3899 3693 useRects = true; 3900 3694 for (int i = 0; i < lineCount; ++i) { … … 4119 3913 qreal penWidth = cpen.widthF(); 4120 3914 4121 GLuint program = qt_gl_program_cache()->getProgram(d rawable.context(),3915 GLuint program = qt_gl_program_cache()->getProgram(device->context(), 4122 3916 FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); 4123 3917 QGLLineMaskGenerator maskGenerator(path, matrix, penWidth == 0 ? 1.0 : penWidth, … … 4166 3960 QPen pen = cpen; 4167 3961 if (txscale != 1) 4168 pen.setWidthF(pen.width () * txscale);3962 pen.setWidthF(pen.widthF() * txscale); 4169 3963 if (use_cache) 4170 3964 fillPath(qt_opengl_stroke_cache()->getStrokedPath(temp.map(path), pen)); … … 4409 4203 qreal scaleY = r.height() / sr.height(); 4410 4204 4411 QTransform brush_matrix; 4412 brush_matrix.translate(r.left(), r.top()); 4205 QTransform brush_matrix = QTransform::fromTranslate(r.left(), r.top()); 4413 4206 brush_matrix.scale(scaleX, scaleY); 4414 4207 brush_matrix.translate(-sr.left(), -sr.top()); … … 4426 4219 } 4427 4220 4428 void QOpenGLPaintEnginePrivate::drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy) 4221 void QOpenGLPaintEnginePrivate::drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy, 4222 const QPointF &offset) 4429 4223 { 4430 4224 QBrush old_brush = cbrush; 4431 4225 QPointF old_brush_origin = brush_origin; 4432 4226 4433 QTransform brush_matrix; 4434 brush_matrix.translate(r.left(), r.top()); 4227 QTransform brush_matrix = QTransform::fromTranslate(r.left(), r.top()); 4435 4228 brush_matrix.scale(sx, sy); 4229 brush_matrix.translate(-offset.x(), -offset.y()); 4436 4230 4437 4231 cbrush = QBrush(img); … … 4505 4299 GLenum target = qt_gl_preferredTextureTarget(); 4506 4300 d->flushDrawQueue(); 4507 d->drawable.bindTexture(pm, target); 4508 drawTextureRect(pm.width(), pm.height(), r, sr, target); 4509 } 4510 } 4511 4512 void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &) 4301 QGLTexture *tex = 4302 d->device->context()->d_func()->bindTexture(pm, target, GL_RGBA, 4303 QGLContext::InternalBindOption); 4304 drawTextureRect(pm.width(), pm.height(), r, sr, target, tex); 4305 } 4306 } 4307 4308 void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &offset) 4513 4309 { 4514 4310 Q_D(QOpenGLPaintEngine); 4311 if (pm.depth() == 1) { 4312 QPixmap tpx(pm.size()); 4313 tpx.fill(Qt::transparent); 4314 QPainter p(&tpx); 4315 p.setPen(d->cpen); 4316 p.drawPixmap(0, 0, pm); 4317 p.end(); 4318 drawTiledPixmap(r, tpx, offset); 4319 return; 4320 } 4515 4321 4516 4322 QImage scaled; … … 4520 4326 int rh = qCeil(r.height()); 4521 4327 if (rw < pm.width() && rh < pm.height()) { 4522 drawTiledPixmap(r, pm.copy(0, 0, rw, rh), QPointF());4328 drawTiledPixmap(r, pm.copy(0, 0, rw, rh), offset); 4523 4329 return; 4524 4330 } … … 4529 4335 if (d->composition_mode > QPainter::CompositionMode_Plus || (d->high_quality_antialiasing && !d->isFastRect(r))) { 4530 4336 if (scaled.isNull()) 4531 d->drawTiledImageAsPath(r, pm.toImage(), 1, 1 );4337 d->drawTiledImageAsPath(r, pm.toImage(), 1, 1, offset); 4532 4338 else { 4533 4339 const qreal sx = pm.width() / qreal(scaled.width()); 4534 4340 const qreal sy = pm.height() / qreal(scaled.height()); 4535 d->drawTiledImageAsPath(r, scaled, sx, sy );4341 d->drawTiledImageAsPath(r, scaled, sx, sy, offset); 4536 4342 } 4537 4343 } else { 4538 4344 d->flushDrawQueue(); 4539 4345 4346 QGLTexture *tex; 4540 4347 if (scaled.isNull()) 4541 d->drawable.bindTexture(pm); 4348 tex = d->device->context()->d_func()->bindTexture(pm, GL_TEXTURE_2D, GL_RGBA, 4349 QGLContext::InternalBindOption); 4542 4350 else 4543 d->drawable.bindTexture(scaled); 4351 tex = d->device->context()->d_func()->bindTexture(scaled, GL_TEXTURE_2D, GL_RGBA, 4352 QGLContext::InternalBindOption); 4544 4353 updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, d->use_smooth_pixmap_transform); 4545 4354 … … 4556 4365 // Rotate the texture so that it is aligned correctly and the 4557 4366 // wrapping is done correctly 4558 glMatrixMode(GL_TEXTURE); 4559 glPushMatrix(); 4560 glRotatef(180.0, 0.0, 1.0, 0.0); 4561 glRotatef(180.0, 0.0, 0.0, 1.0); 4367 if (tex->options & QGLContext::InvertedYBindOption) { 4368 glMatrixMode(GL_TEXTURE); 4369 glPushMatrix(); 4370 glRotatef(180.0, 0.0, 1.0, 0.0); 4371 glRotatef(180.0, 0.0, 0.0, 1.0); 4372 } 4562 4373 4563 4374 q_vertexType vertexArray[4*2]; 4564 4375 q_vertexType texCoordArray[4*2]; 4565 4376 4377 double offset_x = offset.x() / pm.width(); 4378 double offset_y = offset.y() / pm.height(); 4379 4566 4380 qt_add_rect_to_array(r, vertexArray); 4567 qt_add_texcoords_to_array(0, 0, tc_w, tc_h, texCoordArray); 4381 qt_add_texcoords_to_array(offset_x, offset_y, 4382 tc_w + offset_x, tc_h + offset_y, texCoordArray); 4568 4383 4569 4384 glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); … … 4575 4390 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 4576 4391 glDisableClientState(GL_VERTEX_ARRAY); 4577 glPopMatrix(); 4392 if (tex->options & QGLContext::InvertedYBindOption) 4393 glPopMatrix(); 4578 4394 4579 4395 glDisable(GL_TEXTURE_2D); … … 4611 4427 GLenum target = qt_gl_preferredTextureTarget(); 4612 4428 d->flushDrawQueue(); 4613 d->drawable.bindTexture(image, target); 4614 drawTextureRect(image.width(), image.height(), r, sr, target); 4429 QGLTexture *tex = 4430 d->device->context()->d_func()->bindTexture(image, target, GL_RGBA, 4431 QGLContext::InternalBindOption); 4432 drawTextureRect(image.width(), image.height(), r, sr, target, tex); 4615 4433 } 4616 4434 } 4617 4435 4618 4436 void QOpenGLPaintEngine::drawTextureRect(int tx_width, int tx_height, const QRectF &r, 4619 const QRectF &sr, GLenum target )4437 const QRectF &sr, GLenum target, QGLTexture *tex) 4620 4438 { 4621 4439 Q_D(QOpenGLPaintEngine); … … 4632 4450 x1 = sr.x() / tx_width; 4633 4451 x2 = x1 + sr.width() / tx_width; 4634 y1 = 1.0 - (sr.bottom() / tx_height); 4635 y2 = 1.0 - (sr.y() / tx_height); 4452 if (tex->options & QGLContext::InvertedYBindOption) { 4453 y1 = 1 - (sr.bottom() / tx_height); 4454 y2 = 1 - (sr.y() / tx_height); 4455 } else { 4456 y1 = sr.bottom() / tx_height; 4457 y2 = sr.y() / tx_height; 4458 } 4636 4459 } else { 4637 4460 x1 = sr.x(); 4638 4461 x2 = sr.right(); 4639 y1 = tx_height -sr.bottom();4640 y2 = tx_height -sr.y();4462 y1 = sr.bottom(); 4463 y2 = sr.y(); 4641 4464 } 4642 4465 … … 4700 4523 typedef QHash<const QGLContext*, QGLFontGlyphHash*> QGLContextHash; 4701 4524 4525 static inline void qt_delete_glyph_hash(QGLGlyphHash *hash) 4526 { 4527 qDeleteAll(*hash); 4528 delete hash; 4529 } 4530 4702 4531 class QGLGlyphCache : public QObject 4703 4532 { … … 4740 4569 ctx = keys.at(i); 4741 4570 QGLGlyphHash *cache = font_cache->take(fe); 4742 delete cache;4571 qt_delete_glyph_hash(cache); 4743 4572 break; 4744 4573 } … … 4777 4606 for (int i=0; i < keys.size(); ++i) { 4778 4607 QFontEngine *fe = keys.at(i); 4779 delete font_cache->take(fe);4608 qt_delete_glyph_hash(font_cache->take(fe)); 4780 4609 quint64 font_key = (reinterpret_cast<quint64>(ctx) << 32) | reinterpret_cast<quint64>(fe); 4781 4610 QGLFontTexture *font_tex = qt_font_textures.take(font_key); … … 4818 4647 for (int i=0; i < keys.size(); ++i) { 4819 4648 QGLFontGlyphHash *font_cache = qt_context_cache.value(keys.at(i)); 4820 qDeleteAll(*font_cache); 4649 QGLFontGlyphHash::Iterator it = font_cache->begin(); 4650 for (; it != font_cache->end(); ++it) 4651 qt_delete_glyph_hash(it.value()); 4821 4652 font_cache->clear(); 4822 4653 } … … 4869 4700 for (int i=0; i<contexts.size(); ++i) { 4870 4701 const QGLContext *ctx = contexts.at(i); 4871 if (ctx != context && qgl_share_reg()->checkSharing(context, ctx)) {4702 if (ctx != context && QGLContext::areSharing(context, ctx)) { 4872 4703 context_key = ctx; 4873 4704 dev_it = qt_context_cache.constFind(context_key); … … 4886 4717 connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*))); 4887 4718 connect(QGLSignalProxy::instance(), 4888 SIGNAL(aboutToDestroyContext(const QGLContext 4889 SLOT(cleanupContext(const QGLContext 4719 SIGNAL(aboutToDestroyContext(const QGLContext*)), 4720 SLOT(cleanupContext(const QGLContext*))); 4890 4721 } 4891 4722 } else { … … 4976 4807 } 4977 4808 4978 QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i]).convertToFormat(QImage::Format_Indexed8)); 4809 QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i])); 4810 glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); 4979 4811 glyph_width = glyph_im.width(); 4980 4812 Q_ASSERT(glyph_width >= 0); … … 5063 4895 // fall back to drawing a polygon if the scale factor is large, or 5064 4896 // we use a gradient pen 5065 if (ti.fontEngine->fontDef.pixelSize >= 64 5066 || (d->matrix.det() > 1) || (d->pen_brush_style >= Qt::LinearGradientPattern 5067 && d->pen_brush_style <= Qt::ConicalGradientPattern)) { 4897 if ((d->matrix.det() > 1) || (d->pen_brush_style >= Qt::LinearGradientPattern 4898 && d->pen_brush_style <= Qt::ConicalGradientPattern)) { 5068 4899 QPaintEngine::drawTextItem(p, textItem); 5069 4900 return; … … 5075 4906 QVarLengthArray<QFixedPoint> positions; 5076 4907 QVarLengthArray<glyph_t> glyphs; 5077 QTransform matrix; 5078 matrix.translate(qRound(p.x()), qRound(p.y())); 4908 QTransform matrix = QTransform::fromTranslate(qRound(p.x()), qRound(p.y())); 5079 4909 ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); 5080 4910 5081 4911 // make sure the glyphs we want to draw are in the cache 5082 qt_glyph_cache()->cacheGlyphs(d->d rawable.context(), ti, glyphs);4912 qt_glyph_cache()->cacheGlyphs(d->device->context(), ti, glyphs); 5083 4913 5084 4914 d->setGradientOps(Qt::SolidPattern, QRectF()); // turns off gradient ops … … 5158 4988 glLoadIdentity(); 5159 4989 5160 GLuint program = qt_gl_program_cache()->getProgram(d->d rawable.context(),4990 GLuint program = qt_gl_program_cache()->getProgram(d->device->context(), 5161 4991 FRAGMENT_PROGRAM_MASK_ELLIPSE_AA, 0, true); 5162 4992 QGLEllipseMaskGenerator maskGenerator(rect, … … 5293 5123 5294 5124 int left = qMax(0, static_cast<int>(screen_rect.left())); 5295 int width = qMin(d rawable.size().width() - left, static_cast<int>(screen_rect.width()) + 1);5296 5297 int bottom = qMax(0, static_cast<int>(d rawable.size().height() - screen_rect.bottom()));5298 int height = qMin(d rawable.size().height() - bottom, static_cast<int>(screen_rect.height()) + 1);5125 int width = qMin(device->size().width() - left, static_cast<int>(screen_rect.width()) + 1); 5126 5127 int bottom = qMax(0, static_cast<int>(device->size().height() - screen_rect.bottom())); 5128 int height = qMin(device->size().height() - bottom, static_cast<int>(screen_rect.height()) + 1); 5299 5129 5300 5130 glBindTexture(GL_TEXTURE_2D, drawable_texture); … … 5390 5220 5391 5221 if (current_style == Qt::TexturePattern) 5392 drawable.bindTexture(cbrush.textureImage()); 5222 device->context()->d_func()->bindTexture(cbrush.textureImage(), GL_TEXTURE_2D, GL_RGBA, 5223 QGLContext::InternalBindOption); 5393 5224 else 5394 drawable.bindTexture(qt_imageForBrush(current_style, true)); 5225 device->context()->d_func()->bindTexture(qt_imageForBrush(current_style, false), 5226 GL_TEXTURE_2D, GL_RGBA, 5227 QGLContext::InternalBindOption); 5395 5228 5396 5229 updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, use_smooth_pixmap_transform); … … 5400 5233 glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); 5401 5234 glEnable(GL_FRAGMENT_PROGRAM_ARB); 5402 GLuint program = qt_gl_program_cache()->getProgram(d rawable.context(),5235 GLuint program = qt_gl_program_cache()->getProgram(device->context(), 5403 5236 fragment_brush, 5404 5237 fragment_composition_mode, false); … … 5472 5305 5473 5306 composite(item.location.screen_rect, item.location.rect.topLeft() - item.location.screen_rect.topLeft() 5474 - QPoint(0, offscreen.offscreenSize().height() - d rawable.size().height()));5307 - QPoint(0, offscreen.offscreenSize().height() - device->size().height())); 5475 5308 } 5476 5309 … … 5621 5454 QBrush oldBrush = p->brush(); 5622 5455 p->setBrush(brush); 5623 qt_draw_helper(p->d_ptr , painterPathFromVectorPath(path), QPainterPrivate::FillDraw);5456 qt_draw_helper(p->d_ptr.data(), painterPathFromVectorPath(path), QPainterPrivate::FillDraw); 5624 5457 p->setBrush(oldBrush); 5625 5458 return; … … 5710 5543 { 5711 5544 Q_D(QOpenGLPaintEngine); 5545 QOpenGLPaintEngineState *new_state = static_cast<QOpenGLPaintEngineState *>(s); 5546 QOpenGLPaintEngineState *old_state = state(); 5547 5712 5548 QPaintEngineEx::setState(s); 5549 5550 // are we in a save() ? 5551 if (s == d->last_created_state) { 5552 d->last_created_state = 0; 5553 return; 5554 } 5555 5713 5556 if (isActive()) { 5714 d->updateDepthClip(); 5557 if (old_state->depthClipId != new_state->depthClipId) 5558 d->updateDepthClip(); 5715 5559 penChanged(); 5716 5560 brushChanged(); … … 5724 5568 QPainterState *QOpenGLPaintEngine::createState(QPainterState *orig) const 5725 5569 { 5570 const Q_D(QOpenGLPaintEngine); 5571 5726 5572 QOpenGLPaintEngineState *s; 5727 5573 if (!orig) … … 5730 5576 s = new QOpenGLPaintEngineState(*static_cast<QOpenGLPaintEngineState *>(orig)); 5731 5577 5578 d->last_created_state = s; 5732 5579 return s; 5733 5580 } … … 5743 5590 hasClipping = other.hasClipping; 5744 5591 fastClip = other.fastClip; 5592 depthClipId = other.depthClipId; 5745 5593 } 5746 5594 … … 5748 5596 { 5749 5597 hasClipping = false; 5598 depthClipId = 0; 5750 5599 } 5751 5600 … … 5777 5626 } 5778 5627 5779 QPixmapFilter *QOpenGLPaintEngine::createPixmapFilter(int type) const5780 {5781 if (QGLContext::currentContext())5782 return QGLContext::currentContext()->d_func()->createPixmapFilter(type);5783 else5784 return 0;5785 }5786 5787 5788 5628 QT_END_NAMESPACE 5789 5629
Note:
See TracChangeset
for help on using the changeset viewer.