From 66febd27cb3bacf5a4996f184725f318bce0f4fc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 31 May 2011 10:22:55 +0200 Subject: Windows: Bring back the HDC to the raster engine, Q_OS_WIN. --- src/gui/kernel/kernel.pri | 2 + src/gui/kernel/qwindowdefs.h | 6 +- src/gui/kernel/qwindowdefs_win.h | 130 +++++++++++++++++++++++++++++++ src/gui/painting/qpaintengine_raster.cpp | 57 +++++++++----- src/gui/painting/qpaintengine_raster_p.h | 7 +- 5 files changed, 175 insertions(+), 27 deletions(-) create mode 100644 src/gui/kernel/qwindowdefs_win.h (limited to 'src/gui') diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 8662329a2d..827ed21cf4 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -91,3 +91,5 @@ qpa { LIBS_PRIVATE +=$$QT_LIBS_GLIB } } + +win32:HEADERS+=kernel/qwindowdefs_win.h diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h index 1dc1aeb6c1..3414c8cfc5 100644 --- a/src/gui/kernel/qwindowdefs.h +++ b/src/gui/kernel/qwindowdefs.h @@ -105,9 +105,9 @@ typedef long WId; #endif // Q_WS_MAC -#if defined(Q_WS_WIN) -#include -#endif // Q_WS_WIN +#if defined(Q_OS_WIN) +# include +#endif // Q_OS_WIN #if defined(Q_WS_X11) diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h new file mode 100644 index 0000000000..fbcc73ad2a --- /dev/null +++ b/src/gui/kernel/qwindowdefs_win.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWDEFS_WIN_H +#define QWINDOWDEFS_WIN_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +QT_END_NAMESPACE + +#if !defined(Q_NOWINSTRICT) +#define Q_WINSTRICT +#endif + +#if defined(Q_WINSTRICT) + +#if !defined(STRICT) +#define STRICT +#endif +#undef NO_STRICT +#define Q_DECLARE_HANDLE(name) struct name##__; typedef struct name##__ *name + +#else + +#if !defined(NO_STRICT) +#define NO_STRICT +#endif +#undef STRICT +#define Q_DECLARE_HANDLE(name) typedef HANDLE name + +#endif + +#ifndef HINSTANCE +Q_DECLARE_HANDLE(HINSTANCE); +#endif +#ifndef HDC +Q_DECLARE_HANDLE(HDC); +#endif +#ifndef HWND +Q_DECLARE_HANDLE(HWND); +#endif +#ifndef HFONT +Q_DECLARE_HANDLE(HFONT); +#endif +#ifndef HPEN +Q_DECLARE_HANDLE(HPEN); +#endif +#ifndef HBRUSH +Q_DECLARE_HANDLE(HBRUSH); +#endif +#ifndef HBITMAP +Q_DECLARE_HANDLE(HBITMAP); +#endif +#ifndef HICON +Q_DECLARE_HANDLE(HICON); +#endif +#ifndef HCURSOR +typedef HICON HCURSOR; +#endif +#ifndef HPALETTE +Q_DECLARE_HANDLE(HPALETTE); +#endif +#ifndef HRGN +Q_DECLARE_HANDLE(HRGN); +#endif +#ifndef HMONITOR +Q_DECLARE_HANDLE(HMONITOR); +#endif +#ifndef HRESULT +typedef long HRESULT; +#endif + +typedef struct tagMSG MSG; + +QT_BEGIN_NAMESPACE + +Q_CORE_EXPORT HINSTANCE qWinAppInst(); +Q_CORE_EXPORT HINSTANCE qWinAppPrevInst(); +Q_CORE_EXPORT int qWinAppCmdShow(); +Q_GUI_EXPORT HDC qt_win_display_dc(); + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QWINDOWDEFS_WIN_H diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 61d7216230..7232f9c910 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -75,7 +75,7 @@ // #include "qbezier_p.h" #include "qoutlinemapper_p.h" -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) # include # include # include @@ -92,7 +92,7 @@ # include #endif -#if defined(Q_WS_WIN64) +#if defined(Q_OS_WIN64) # include #endif #include @@ -118,9 +118,22 @@ void dumpClip(int width, int height, const QClipData *clip); // 4 pixels. #define int_dim(pos, dim) (int(pos+dim) - int(pos)) -#ifdef Q_WS_WIN -extern bool qt_cleartype_enabled; -#endif +#ifdef Q_OS_WIN + +static inline bool winClearTypeFontsEnabled() +{ + UINT result = 0; + SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0); + return result == FE_FONTSMOOTHINGCLEARTYPE; +} + +bool QRasterPaintEngine::clearTypeFontsEnabled() +{ + static const bool result = winClearTypeFontsEnabled(); + return result; +} + +#endif // Q_OS_WIN #ifdef Q_WS_MAC extern bool qt_applefontsmoothing_enabled; @@ -316,7 +329,7 @@ void QRasterPaintEngine::init() Q_D(QRasterPaintEngine); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN d->hdc = 0; #endif @@ -462,14 +475,14 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) } #endif -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) d->isPlain45DegreeRotation = true; #endif if (d->mono_surface) d->glyphCacheType = QFontEngineGlyphCache::Raster_Mono; -#if defined(Q_WS_WIN) - else if (qt_cleartype_enabled) +#if defined(Q_OS_WIN) + else if (clearTypeFontsEnabled()) #elif defined (Q_WS_MAC) else if (qt_applefontsmoothing_enabled) #else @@ -570,7 +583,7 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix) ensureOutlineMapper(); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN Q_D(QRasterPaintEngine); d->isPlain45DegreeRotation = false; if (txop >= QTransform::TxRotate) { @@ -3038,7 +3051,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte ensurePen(); ensureState(); -#if defined (Q_WS_WIN) || defined(Q_WS_MAC) +#if defined (Q_OS_WIN) || defined(Q_WS_MAC) bool drawCached = true; @@ -3054,8 +3067,9 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte // ### cases we should delegate painting to the font engine // ### directly... -#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) - QFontEngine::Type fontEngineType = ti.fontEngine->type(); +/* + #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + conQFontEngine::Type fontEngineType = ti.fontEngine->type(); // qDebug() << "type" << fontEngineType << s->matrix.type(); if ((fontEngineType == QFontEngine::Win && !((QFontEngineWin *) ti.fontEngine)->ttf && s->matrix.type() > QTransform::TxTranslate) || (s->matrix.type() <= QTransform::TxTranslate @@ -3064,9 +3078,10 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte drawCached = false; } #else +*/ if (s->matrix.type() > QTransform::TxTranslate) drawCached = false; -#endif +// #endif if (drawCached) { QRasterPaintEngineState *s = state(); @@ -3082,14 +3097,14 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte return; } -#elif defined (Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) // Q_WS_WIN || Q_WS_MAC +#elif defined (Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) // Q_OS_WIN || Q_WS_MAC if (s->matrix.type() <= QTransform::TxTranslate || (s->matrix.type() == QTransform::TxScale && (qFuzzyCompare(s->matrix.m11(), s->matrix.m22())))) { drawGlyphsS60(p, ti); return; } -#else // Q_WS_WIN || Q_WS_MAC +#else // Q_OS_WIN || Q_WS_MAC QFontEngine *fontEngine = ti.fontEngine; @@ -3314,7 +3329,7 @@ CGContextRef QRasterPaintEngine::getCGContext() const } #endif -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN /*! \internal */ @@ -3630,7 +3645,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, const int rasterPoolInitialSize = MINIMUM_POOL_SIZE; int rasterPoolSize = rasterPoolInitialSize; unsigned char *rasterPoolBase; -#if defined(Q_WS_WIN64) +#if defined(Q_OS_WIN64) rasterPoolBase = // We make use of setjmp and longjmp in qgrayraster.c which requires // 16-byte alignment, hence we hardcode this requirement here.. @@ -3683,7 +3698,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, rendered_spans += q_gray_rendered_spans(*grayRaster.data()); -#if defined(Q_WS_WIN64) +#if defined(Q_OS_WIN64) _aligned_free(rasterPoolBase); #else if (rasterPoolBase != rasterPoolOnStack) // initially on the stack @@ -3692,7 +3707,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, rasterPoolSize = new_size; rasterPoolBase = -#if defined(Q_WS_WIN64) +#if defined(Q_OS_WIN64) // We make use of setjmp and longjmp in qgrayraster.c which requires // 16-byte alignment, hence we hardcode this requirement here.. (unsigned char *) _aligned_malloc(rasterPoolSize, sizeof(void*) * 2); @@ -3709,7 +3724,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, } } -#if defined(Q_WS_WIN64) +#if defined(Q_OS_WIN64) _aligned_free(rasterPoolBase); #else if (rasterPoolBase != rasterPoolOnStack) // initially on the stack diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 5c3f2dfd06..6d0388bfa3 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -224,10 +224,11 @@ public: CGContextRef getCGContext() const; #endif -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN void setDC(HDC hdc); HDC getDC() const; void releaseDC(HDC hdc) const; + static bool clearTypeFontsEnabled(); #endif void alphaPenBlt(const void* src, int bpl, int depth, int rx,int ry,int w,int h); @@ -324,7 +325,7 @@ public: QScopedPointer outlineMapper; QScopedPointer rasterBuffer; -#if defined (Q_WS_WIN) +#if defined (Q_OS_WIN) HDC hdc; #elif defined(Q_WS_MAC) CGContextRef cgContext; @@ -352,7 +353,7 @@ public: uint mono_surface : 1; uint outlinemapper_xform_dirty : 1; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN uint isPlain45DegreeRotation : 1; #endif -- cgit v1.2.3