diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-09-15 23:57:55 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-09-15 23:57:55 (GMT) |
commit | f380892b03fbb4cefc18b9ecc4edf27e88340b97 (patch) | |
tree | d36e9e11d495a6ca280310bf94c77eda30741295 /src | |
parent | 21ecd608105ed576fd0c76b48c25e599cb160f32 (diff) | |
parent | c878fde1d0ddd54c8dff485e7c7146b3d8962fb9 (diff) | |
download | Qt-f380892b03fbb4cefc18b9ecc4edf27e88340b97.zip Qt-f380892b03fbb4cefc18b9ecc4edf27e88340b97.tar.gz Qt-f380892b03fbb4cefc18b9ecc4edf27e88340b97.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/qlinecontrol_p.h | 13 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 7 | ||||
-rw-r--r-- | src/opengl/qglpixmapfilter.cpp | 38 |
3 files changed, 49 insertions, 9 deletions
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 8ad0452..68898b6 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -220,6 +220,9 @@ public: QString cancelText() const; void setCancelText(const QString &text); + const QPalette &palette() const; + void setPalette(const QPalette &); + enum DrawFlags { DrawText = 0x01, DrawSelections = 0x02, @@ -741,6 +744,16 @@ inline void QLineControl::setCancelText(const QString &text) m_cancelText = text; } +inline const QPalette & QLineControl::palette() const +{ + return m_palette; +} + +inline void QLineControl::setPalette(const QPalette &p) +{ + m_palette = p; +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 37e57cf..629e839 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1434,7 +1434,6 @@ void QLineEdit::mousePressEvent(QMouseEvent* e) #ifndef QT_NO_DRAGANDDROP if (!mark && d->dragEnabled && d->control->echoMode() == Normal && e->button() == Qt::LeftButton && d->control->inSelection(e->pos().x())) { - d->control->moveCursor(cursor); d->dndPos = e->pos(); if (!d->dndTimer.isActive()) d->dndTimer.start(QApplication::startDragTime(), this); @@ -1851,8 +1850,12 @@ void QLineEdit::paintEvent(QPaintEvent *) #ifdef QT_KEYPAD_NAVIGATION if (!QApplication::keypadNavigationEnabled() || hasEditFocus()) #endif - if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())) + if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){ flags |= QLineControl::DrawSelections; + // Palette only used for selections/mask and may not be in sync + if(d->control->palette() != pal) + d->control->setPalette(pal); + } // Asian users see an IM selection text as cursor on candidate // selection phase of input method, so the ordinary cursor should be diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 7876661..43f1990 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -71,13 +71,12 @@ void QGLPixmapFilterBase::drawImpl(QPainter *painter, const QPointF &pos, const class QGLPixmapColorizeFilter: public QGLCustomShaderStage, public QGLPixmapFilter<QPixmapColorizeFilter> { public: + QGLPixmapColorizeFilter(); + void setUniforms(QGLShaderProgram *program); protected: bool processGL(QPainter *painter, const QPointF &pos, const QPixmap &pixmap, const QRectF &srcRect) const; - -private: - mutable QGLShader *m_shader; }; class QGLPixmapConvolutionFilter: public QGLPixmapFilter<QPixmapConvolutionFilter> @@ -103,6 +102,8 @@ private: class QGLPixmapBlurFilter : public QGLCustomShaderStage, public QGLPixmapFilter<QPixmapBlurFilter> { public: + QGLPixmapBlurFilter(); + void setUniforms(QGLShaderProgram *program); protected: @@ -111,11 +112,13 @@ protected: private: static QByteArray generateBlurShader(int radius, bool gaussianBlur); - mutable QGLShader *m_shader; - mutable QSize m_textureSize; mutable bool m_horizontalBlur; + + mutable bool m_haveCached; + mutable int m_cachedRadius; + mutable Qt::TransformationMode m_cachedQuality; }; extern QGLWidget *qt_gl_share_widget(); @@ -187,10 +190,14 @@ static const char *qt_gl_colorize_filter = " return vec4(mix(srcPixel.rgb, colorized * srcPixel.a, colorizeStrength), srcPixel.a);" "}"; +QGLPixmapColorizeFilter::QGLPixmapColorizeFilter() +{ + setSource(qt_gl_colorize_filter); +} + bool QGLPixmapColorizeFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const { QGLPixmapColorizeFilter *filter = const_cast<QGLPixmapColorizeFilter *>(this); - filter->setSource(qt_gl_colorize_filter); filter->setOnPainter(painter); painter->drawPixmap(pos, src); @@ -297,10 +304,27 @@ bool QGLPixmapConvolutionFilter::processGL(QPainter *, const QPointF &pos, const return true; } +QGLPixmapBlurFilter::QGLPixmapBlurFilter() + : m_haveCached(false), m_cachedRadius(5), + m_cachedQuality(Qt::FastTransformation) +{ +} + bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const { QGLPixmapBlurFilter *filter = const_cast<QGLPixmapBlurFilter *>(this); - filter->setSource(generateBlurShader(radius(), quality() == Qt::SmoothTransformation)); + + int radius = this->radius(); + Qt::TransformationMode quality = this->quality(); + + if (!m_haveCached || radius != m_cachedRadius || + quality != m_cachedQuality) { + // Only regenerate the shader from source if parameters have changed. + m_haveCached = true; + m_cachedRadius = radius; + m_cachedQuality = quality; + filter->setSource(generateBlurShader(radius, quality == Qt::SmoothTransformation)); + } QGLFramebufferObjectFormat format; format.setInternalTextureFormat(GLenum(src.hasAlphaChannel() ? GL_RGBA : GL_RGB)); |