summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qtriangulatingstroker.cpp28
-rw-r--r--src/opengl/qgl.cpp3
-rw-r--r--src/opengl/qgl_x11.cpp8
-rw-r--r--src/opengl/qglshaderprogram.cpp19
5 files changed, 50 insertions, 12 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index a163fa9..f5ba2d6 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -217,7 +217,9 @@ void QGL2PaintEngineExPrivate::updateBrushTexture()
const QPixmap& texPixmap = currentBrush.texture();
glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT);
- QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
+ QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA,
+ QGLContext::InternalBindOption |
+ QGLContext::CanFlipNativePixmapBindOption);
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform);
textureInvertedY = tex->options & QGLContext::InvertedYBindOption ? -1 : 1;
}
diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
index d952988..16340a1 100644
--- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
+++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
@@ -111,7 +111,7 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, co
// depending on if the pen is cosmetic or not.
//
// The curvyness value of PI/14 was based on,
- // arcLength=2*PI*r/4=PI/2 and splitting length into somewhere
+ // arcLength = 2*PI*r/4 = PI*r/2 and splitting length into somewhere
// between 3 and 8 where 5 seemed to be give pretty good results
// hence: Q_PI/14. Lower divisors will give more detail at the
// direct cost of performance.
@@ -487,6 +487,8 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c
const QPainterPath::ElementType *types = path.elements();
int count = path.elementCount();
+ bool cosmetic = pen.isCosmetic();
+
m_points.reset();
m_types.reset();
@@ -495,10 +497,26 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c
width = 1;
m_dash_stroker.setDashPattern(pen.dashPattern());
- m_dash_stroker.setStrokeWidth(pen.isCosmetic() ? width * m_inv_scale : width);
+ m_dash_stroker.setStrokeWidth(cosmetic ? width * m_inv_scale : width);
m_dash_stroker.setMiterLimit(pen.miterLimit());
m_dash_stroker.setClipRect(clip);
- qreal curvyness = sqrt(width) * m_inv_scale / 8;
+
+ float curvynessAdd, curvynessMul, roundness = 0;
+
+ // simplfy pens that are thin in device size (2px wide or less)
+ if (width < 2.5 && (cosmetic || m_inv_scale == 1)) {
+ curvynessAdd = 0.5;
+ curvynessMul = CURVE_FLATNESS / m_inv_scale;
+ roundness = 1;
+ } else if (cosmetic) {
+ curvynessAdd= width / 2;
+ curvynessMul= CURVE_FLATNESS;
+ roundness = qMax<int>(4, width * CURVE_FLATNESS);
+ } else {
+ curvynessAdd = width * m_inv_scale;
+ curvynessMul = CURVE_FLATNESS / m_inv_scale;
+ roundness = qMax<int>(4, width * curvynessMul);
+ }
if (count < 2)
return;
@@ -533,9 +551,11 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c
*(((const QPointF *) pts) + 1),
*(((const QPointF *) pts) + 2));
QRectF bounds = b.bounds();
- int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * curvyness);
+ float rad = qMax(bounds.width(), bounds.height());
+ int threshold = qMin<float>(64, (rad + curvynessAdd) * curvynessMul);
if (threshold < 4)
threshold = 4;
+
qreal threshold_minus_1 = threshold - 1;
for (int i=0; i<threshold; ++i) {
QPointF pt = b.pointAt(i / threshold_minus_1);
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index e56b149..5595e02 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -2442,7 +2442,8 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
// Try to use texture_from_pixmap
const QX11Info *xinfo = qt_x11Info(paintDevice);
if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType
- && xinfo && xinfo->screen() == pixmap.x11Info().screen())
+ && xinfo && xinfo->screen() == pixmap.x11Info().screen()
+ && target == GL_TEXTURE_2D)
{
texture = bindTextureFromNativePixmap(const_cast<QPixmap*>(&pixmap), key, options);
if (texture) {
diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp
index e1a202f..d203646 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -1677,6 +1677,14 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
#if !defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX)
return 0;
#else
+
+ // Check we have GLX 1.3, as it is needed for glXCreatePixmap & glXDestroyPixmap
+ int majorVersion = 0;
+ int minorVersion = 0;
+ glXQueryVersion(X11->display, &majorVersion, &minorVersion);
+ if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 3))
+ return 0;
+
Q_Q(QGLContext);
QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pixmap->data_ptr().data());
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index 55fd922..83b4b21 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -999,17 +999,18 @@ GLuint QGLShaderProgram::programId() const
Any attributes that have not been explicitly bound when the program
is linked will be assigned locations automatically.
+ When this function is called after the program has been linked,
+ the program will need to be relinked for the change to take effect.
+
\sa attributeLocation()
*/
void QGLShaderProgram::bindAttributeLocation(const char *name, int location)
{
Q_D(QGLShaderProgram);
- if (!d->linked) {
- glBindAttribLocation(d->programGuard.id(), location, name);
- } else {
- qWarning() << "QGLShaderProgram::bindAttributeLocation(" << name
- << "): cannot bind after shader program is linked";
- }
+ if (!init())
+ return;
+ glBindAttribLocation(d->programGuard.id(), location, name);
+ d->linked = false; // Program needs to be relinked.
}
/*!
@@ -1020,6 +1021,9 @@ void QGLShaderProgram::bindAttributeLocation(const char *name, int location)
Any attributes that have not been explicitly bound when the program
is linked will be assigned locations automatically.
+ When this function is called after the program has been linked,
+ the program will need to be relinked for the change to take effect.
+
\sa attributeLocation()
*/
void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int location)
@@ -1035,6 +1039,9 @@ void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int locatio
Any attributes that have not been explicitly bound when the program
is linked will be assigned locations automatically.
+ When this function is called after the program has been linked,
+ the program will need to be relinked for the change to take effect.
+
\sa attributeLocation()
*/
void QGLShaderProgram::bindAttributeLocation(const QString& name, int location)