direct2d qpa: fix text selection

1cdcf64ad5 recently introduced a rendering
bug whereby certain clips would be handled incorrectly.

Change-Id: I3f486819c66b1d665243c8dc1e9d077dd2f64f25
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
This commit is contained in:
Louai Al-Khanji 2014-09-22 11:19:04 +03:00
parent 3312ac9169
commit 4918623f76
3 changed files with 13 additions and 5 deletions

View File

@ -300,6 +300,14 @@ public:
: D2D1_ANTIALIAS_MODE_ALIASED; : D2D1_ANTIALIAS_MODE_ALIASED;
} }
inline D2D1_LAYER_OPTIONS1 layerOptions() const
{
if (flags & QWindowsDirect2DPaintEngine::TranslucentTopLevelWindow)
return D2D1_LAYER_OPTIONS1_NONE;
else
return D2D1_LAYER_OPTIONS1_INITIALIZE_FROM_BACKGROUND;
}
void updateTransform(const QTransform &transform) void updateTransform(const QTransform &transform)
{ {
dc()->SetTransform(to_d2d_matrix_3x2_f(transform)); dc()->SetTransform(to_d2d_matrix_3x2_f(transform));
@ -345,7 +353,7 @@ public:
D2D1::IdentityMatrix(), D2D1::IdentityMatrix(),
1.0, 1.0,
NULL, NULL,
D2D1_LAYER_OPTIONS1_NONE), layerOptions()),
NULL); NULL);
pushedClips.push(LayerClip); pushedClips.push(LayerClip);
} }
@ -870,7 +878,7 @@ public:
const bool antiAlias = bool((q->state()->renderHints & QPainter::TextAntialiasing) const bool antiAlias = bool((q->state()->renderHints & QPainter::TextAntialiasing)
&& !(fontDef.styleStrategy & QFont::NoAntialias)); && !(fontDef.styleStrategy & QFont::NoAntialias));
const D2D1_TEXT_ANTIALIAS_MODE antialiasMode = (flags & QWindowsDirect2DPaintEngine::UseGrayscaleAntialiasing) const D2D1_TEXT_ANTIALIAS_MODE antialiasMode = (flags & QWindowsDirect2DPaintEngine::TranslucentTopLevelWindow)
? D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE : D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE; ? D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE : D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
dc()->SetTextAntialiasMode(antiAlias ? antialiasMode : D2D1_TEXT_ANTIALIAS_MODE_ALIASED); dc()->SetTextAntialiasMode(antiAlias ? antialiasMode : D2D1_TEXT_ANTIALIAS_MODE_ALIASED);
@ -956,7 +964,7 @@ bool QWindowsDirect2DPaintEngine::begin(QPaintDevice * pdev)
D2D1::IdentityMatrix(), D2D1::IdentityMatrix(),
1.0, 1.0,
NULL, NULL,
D2D1_LAYER_OPTIONS1_NONE), d->layerOptions()),
NULL); NULL);
} else { } else {
QRect clip(0, 0, pdev->width(), pdev->height()); QRect clip(0, 0, pdev->width(), pdev->height());

View File

@ -61,7 +61,7 @@ class QWindowsDirect2DPaintEngine : public QPaintEngineEx
public: public:
enum Flag { enum Flag {
NoFlag = 0, NoFlag = 0,
UseGrayscaleAntialiasing = 1, TranslucentTopLevelWindow = 1
}; };
Q_DECLARE_FLAGS(Flags, Flag) Q_DECLARE_FLAGS(Flags, Flag)

View File

@ -310,7 +310,7 @@ void QWindowsDirect2DWindow::setupBitmap()
QWindowsDirect2DPaintEngine::Flags flags = QWindowsDirect2DPaintEngine::NoFlag; QWindowsDirect2DPaintEngine::Flags flags = QWindowsDirect2DPaintEngine::NoFlag;
if (!m_directRendering) if (!m_directRendering)
flags |= QWindowsDirect2DPaintEngine::UseGrayscaleAntialiasing; flags |= QWindowsDirect2DPaintEngine::TranslucentTopLevelWindow;
QWindowsDirect2DPlatformPixmap *pp = new QWindowsDirect2DPlatformPixmap(QPlatformPixmap::PixmapType, QWindowsDirect2DPlatformPixmap *pp = new QWindowsDirect2DPlatformPixmap(QPlatformPixmap::PixmapType,
flags, flags,
m_bitmap.data()); m_bitmap.data());