diff options
43 files changed, 867 insertions, 234 deletions
@@ -0,0 +1,150 @@ + INSTALLING Qt Source Package Version %VERSION%. + +1. If you have the commercial edition of Qt, install your license + file as $HOME/.qt-license if you are on Unix. If you are on + Windows, copy the license file into your home directory + (this may be known as the userprofile environment variable) and + rename it to .qt-license. For example on Windows XP, + %USERPROFILE% should be something like C:\Documents and + Settings\username. + + For the open source version you do not need a license file. + +2. Unpack the archive if you have not done so already: + + On Unix (X11 and Mac): + cd /tmp + gunzip %DISTNAME%.tar.gz # uncompress the archive + tar xvf %DISTNAME%.tar # unpack it + + This creates the directory /tmp/%DISTNAME% containing the files + from the archive. We only support the GNU version of the tar + archiving utility. Note that on some systems it is called gtar. + + On Windows, uncompress the files into the directory you want Qt + installed, e.g. C:\Qt\%VERSION%. + + NOTE: The install path must not contain any spaces. + +4. Environment variables + + In order to build and use Qt, the PATH environment variable needs + to be extended to locate qmake, moc and other Qt tools + + On Windows, this is done by adding C:\Qt\%VERSION%\bin + to the PATH variable. On Unix, this is done by adding + /tmp/%DISTNAME%. + + For newer versions of Windows, PATH can be extended through + "Control Panel->System->Advanced->Environment variables" and for + older versions by editing C:\autoexec.bat. + + In .profile (if your Unix shell is bash), add the following lines: + + PATH=/usr/local/Trolltech/Qt-%VERSION%/bin:$PATH + export PATH + + In .login (in case your Unix shell is csh or tcsh), add the following line: + + setenv PATH /usr/local/Trolltech/Qt-%VERSION%/bin:$PATH + + If you use a different Unix shell, please modify your environment + variables accordingly. + + For some X11 compilers that do not support rpath you must also + extended the LD_LIBRARY_PATH environment variable to include + /usr/local/Trolltech/Qt-%VERSION%/lib. On Linux or Mac with GCC + this step is not needed. + +4. Building + +4.1 Building on Unix + + To configure the Qt library for your machine type, run the + ./configure script in the package directory. + + By default, Qt is configured for installation in the + /usr/local/Trolltech/Qt-%VERSION% directory, but this can be + changed by using the -prefix option. Alternatively, the + -prefix-install option can be used to specify a "local" + installation within the source directory. + + cd /tmp/%DISTNAME% + ./configure + + Type "./configure -help" to get a list of all available options. + + To create the library and compile all the demos, examples, tools, + and tutorials, type: + + make + + If you did not configure Qt using the -prefix-install option, + you need to install the library, demos, examples, tools, and + tutorials in the appropriate place. To do this, type: + + su -c "make install" + + and enter the root password. On some systems, you have to use the + sudo command as follows: + + sudo make install + + and enter your password, this requires that you have administrator access + to your machine. + + Note that on some systems the make utility is named differently, + e.g. gmake. The configure script tells you which make utility to + use. + + If you need to reconfigure and rebuild Qt from the same location, + ensure that all traces of the previous configuration are removed + by entering the build directory and typing + + make confclean + + before running the configure script again. + +4.2 Building on Windows + + To configure the Qt library for your machine type: + + C: + cd \Qt\%VERSION% + configure + + Type "configure -help" to get a list of all available options. + + If you are using the "-direct3d" option, make sure that you have + the Direct3D SDK installed, and that you have run the + %DXSDK_DIR%\Utilities\Bin\dx_setenv.cmd command, before attempting + to run configure. + + The actual commands needed to build Qt depends on your development + system. For Microsoft Visual Studio to create the library and + compile all the demos, examples, tools and tutorials type: + + nmake + + If you need to reconfigure and rebuild Qt from the same location, + ensure that all traces of the previous configuration are removed + by entering the build directory and typing + + nmake confclean + + before running the configure script again. + +5. That's all. Qt is now installed. + + If you are new to Qt, we suggest that you take a look at the demos + and examples to see Qt in action. Run the Qt Examples and Demos + either by typing 'qtdemo' on the command line or through the + desktop's Start menu. + + You might also want to try the following links: + + http://qt.nokia.com/doc/%VERSION%/how-to-learn-qt.html + http://qt.nokia.com/doc/%VERSION%/tutorial.html + http://qt.nokia.com/developer + + We hope you will enjoy using Qt. Good luck! diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 1bd85b0..861c772 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -959,7 +959,8 @@ General compiler options can as usual be set using \c QMAKE_CFLAGS and \c QMAKE_CXXFLAGS. In order to set specific compiler options, \c QMAKE_CFLAGS.<compiler> and \c QMAKE_CXXFLAGS.<compiler> can be used. \c <compiler> can be either \c CW for the WINSCW - architecture (emulator), or \c ARMCC for the ARMv5 architecture (hardware). + architecture (emulator), or \c ARMCC for the ARMv5 architecture (hardware), or \c GCCE for + the ARMv5 architecture (hardware). Here is an example: diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.cpp b/qmake/generators/symbian/initprojectdeploy_symbian.cpp index abff955..f27d1ba 100644 --- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp +++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp @@ -331,8 +331,13 @@ void initProjectDeploySymbian(QMakeProject* project, if (deployBinaries) { // Executables and libraries are deployed to \sys\bin QFileInfo releasePath(epocRoot() + "epoc32\\release\\" + platform + "\\" + build + "\\"); - deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "\\" + info.fileName(), false, true), - Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "\\") + info.fileName()))); + if(devicePathHasDriveLetter) { + deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "\\" + info.fileName(), false, true), + Option::fixPathToLocalOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "\\") + info.fileName()))); + } else { + deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "\\" + info.fileName(), false, true), + Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "\\") + info.fileName()))); + } } if (isPlugin(info, devicePath)) { createPluginStub(info, devicePath, deploymentList, generatedDirs, generatedFiles); diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index db69a4f..dd1dd5f 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -933,7 +933,7 @@ void SymbianMakefileGenerator::writeMmpFileCapabilityPart(QTextStream& t) void SymbianMakefileGenerator::writeMmpFileCompilerOptionPart(QTextStream& t) { - QString cw, armcc; + QString cw, armcc, gcce; if (0 != project->values("QMAKE_CXXFLAGS.CW").size()) { cw.append(project->values("QMAKE_CXXFLAGS.CW").join(" ")); @@ -945,6 +945,11 @@ void SymbianMakefileGenerator::writeMmpFileCompilerOptionPart(QTextStream& t) armcc.append(" "); } + if (0 != project->values("QMAKE_CXXFLAGS.GCCE").size()) { + gcce.append(project->values("QMAKE_CXXFLAGS.GCCE").join(" ")); + gcce.append(" "); + } + if (0 != project->values("QMAKE_CFLAGS.CW").size()) { cw.append(project->values("QMAKE_CFLAGS.CW").join(" ")); cw.append(" "); @@ -955,11 +960,18 @@ void SymbianMakefileGenerator::writeMmpFileCompilerOptionPart(QTextStream& t) armcc.append(" "); } + if (0 != project->values("QMAKE_CFLAGS.GCCE").size()) { + gcce.append(project->values("QMAKE_CXXFLAGS.GCCE").join(" ")); + gcce.append(" "); + } + if (0 != project->values("QMAKE_CXXFLAGS").size()) { cw.append(project->values("QMAKE_CXXFLAGS").join(" ")); cw.append(" "); armcc.append(project->values("QMAKE_CXXFLAGS").join(" ")); armcc.append(" "); + gcce.append(project->values("QMAKE_CXXFLAGS").join(" ")); + gcce.append(" "); } if (0 != project->values("QMAKE_CFLAGS").size()) { @@ -967,17 +979,23 @@ void SymbianMakefileGenerator::writeMmpFileCompilerOptionPart(QTextStream& t) cw.append(" "); armcc.append(project->values("QMAKE_CFLAGS").join(" ")); armcc.append(" "); + gcce.append(project->values("QMAKE_CFLAGS").join(" ")); + gcce.append(" "); } if (!cw.isEmpty() && cw[cw.size()-1] == ' ') cw.chop(1); if (!armcc.isEmpty() && armcc[armcc.size()-1] == ' ') armcc.chop(1); + if (!gcce.isEmpty() && gcce[gcce.size()-1] == ' ') + gcce.chop(1); if (!cw.isEmpty()) - t << "OPTION" << '\t' << " CW " << cw << endl; + t << "OPTION CW " << cw << endl; if (!armcc.isEmpty()) - t << "OPTION" << '\t' << " ARMCC " << armcc << endl; + t << "OPTION ARMCC " << armcc << endl; + if (!gcce.isEmpty()) + t << "OPTION GCCE " << gcce << endl; t << endl; } diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp index c538eb1..42e0b05 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp @@ -1182,8 +1182,9 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi goto vm_throw; \ } \ tickCount = globalData->timeoutChecker->ticksUntilNextCheck(); \ + CHECK_FOR_EXCEPTION(); \ } - + #if ENABLE(OPCODE_SAMPLING) #define SAMPLE(codeBlock, vPC) m_sampler->sample(codeBlock, vPC) #else diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp index 0a5eb07..7928593 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp @@ -717,7 +717,7 @@ DEFINE_STUB_FUNCTION(int, timeout_check) globalData->exception = createInterruptedExecutionException(globalData); VM_THROW_EXCEPTION_AT_END(); } - + CHECK_FOR_EXCEPTION_AT_END(); return timeoutChecker->ticksUntilNextCheck(); } diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 51e8d00..9283730 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -364,7 +364,7 @@ void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() QString app_location( QCoreApplication::applicationFilePath() ); app_location.truncate(app_location.lastIndexOf(QLatin1Char('/'))); app_location = QDir(app_location).canonicalPath(); - if (app_location != QLibraryInfo::location(QLibraryInfo::PluginsPath) && QFile::exists(app_location) && !app_libpaths->contains(app_location)) + if (QFile::exists(app_location) && !app_libpaths->contains(app_location)) # endif app_libpaths->append(app_location); #endif diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 31c106b..0145499 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -6953,10 +6953,12 @@ void QGraphicsItem::prepareGeometryChange() if (d_ptr->inSetPosHelper) return; - if (d_ptr->flags & ItemClipsChildrenToShape) + if (d_ptr->flags & ItemClipsChildrenToShape + || d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) { d_ptr->invalidateCachedClipPathRecursively(); - else + } else { d_ptr->invalidateCachedClipPath(); + } } /*! diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 4f145af..558ae54 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1678,12 +1678,15 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) operation, you can use QBitmap::fromImage() instead. In addition, on Windows, the QPixmap class supports conversion to - and from HBitmap: the toWinHBITMAP() function creates a HBITMAP + and from HBITMAP: the toWinHBITMAP() function creates a HBITMAP equivalent to the QPixmap, based on the given HBitmapFormat, and returns the HBITMAP handle. The fromWinHBITMAP() function returns a QPixmap that is equivalent to the given bitmap which has the - specified format. - + specified format. The QPixmap class also supports conversion to + and from HICON: the toWinHICON() function creates a HICON equivalent + to the QPixmap, and returns the HICON handle. The fromWinHICON() + function returns a QPixmap that is equivalent to the given icon. + In addition, on Symbian, the QPixmap class supports conversion to and from CFbsBitmap: the toSymbianCFbsBitmap() function creates CFbsBitmap equivalent to the QPixmap, based on given mode and returns @@ -2040,7 +2043,7 @@ QPixmapData* QPixmap::pixmapData() const \warning This function is only available on Windows. - \sa fromWinHBITMAP() + \sa fromWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} */ /*! \fn QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format) @@ -2054,6 +2057,31 @@ QPixmapData* QPixmap::pixmapData() const */ +/*! \fn HICON QPixmap::toWinHICON() const + \since 4.6 + + \bold{Win32 only:} Creates a \c HICON equivalent to the QPixmap. + Returns the \c HICON handle. + + It is the caller's responsibility to free the \c HICON data after use. + + \warning This function is only available on Windows. + + \sa fromWinHICON(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} +*/ + +/*! \fn QPixmap QPixmap::fromWinHICON(HICON icon) + \since 4.6 + + \bold{Win32 only:} Returns a QPixmap that is equivalent to the given + \a icon. + + \warning This function is only available on Windows. + + \sa toWinHICON(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} + +*/ + /*! \fn const QX11Info &QPixmap::x11Info() const \bold{X11 only:} Returns information about the configuration of the X display used to display the widget. diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 54e89ff..2ed65ea 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -149,7 +149,10 @@ public: }; HBITMAP toWinHBITMAP(HBitmapFormat format = NoAlpha) const; + HICON toWinHICON() const; + static QPixmap fromWinHBITMAP(HBITMAP hbitmap, HBitmapFormat format = NoAlpha); + static QPixmap fromWinHICON(HICON hicon); #endif #if defined(Q_WS_MAC) diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index 9042840..a9bcca2 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -236,6 +236,44 @@ QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format) return fromImage(result); } +HBITMAP qt_createIconMask(const QBitmap &bitmap) +{ + QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono); + int w = bm.width(); + int h = bm.height(); + int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment + uchar *bits = new uchar[bpl*h]; + bm.invertPixels(); + for (int y=0; y<h; y++) + memcpy(bits+y*bpl, bm.scanLine(y), bpl); + HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits); + delete [] bits; + return hbm; +} + +HICON QPixmap::toWinHICON() const +{ + QBitmap maskBitmap = mask(); + if (maskBitmap.isNull()) { + maskBitmap= QBitmap(size()); + maskBitmap.fill(Qt::color1); + } + + ICONINFO ii; + ii.fIcon = true; + ii.hbmMask = qt_createIconMask(maskBitmap); + ii.hbmColor = toWinHBITMAP(QPixmap::Alpha); + ii.xHotspot = 0; + ii.yHotspot = 0; + + HICON hIcon = CreateIconIndirect(&ii); + + DeleteObject(ii.hbmColor); + DeleteObject(ii.hbmMask); + + return hIcon; +} + #ifdef Q_WS_WIN #ifndef Q_WS_WINCE @@ -273,7 +311,7 @@ static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h) return image; } -QPixmap convertHIconToPixmap( const HICON icon) +QPixmap QPixmap::fromWinHICON(HICON icon) { bool foundAlpha = false; HDC screenDevice = GetDC(0); @@ -283,7 +321,7 @@ QPixmap convertHIconToPixmap( const HICON icon) ICONINFO iconinfo; bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center if (!result) - qWarning("convertHIconToPixmap(), failed to GetIconInfo()"); + qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()"); int w = iconinfo.xHotspot * 2; int h = iconinfo.yHotspot * 2; @@ -342,19 +380,25 @@ QPixmap convertHIconToPixmap( const HICON icon) return QPixmap::fromImage(image); } #else //ifndef Q_WS_WINCE -QPixmap convertHIconToPixmap( const HICON icon, bool large) +QPixmap QPixmap::fromWinHICON(HICON icon) { HDC screenDevice = GetDC(0); HDC hdc = CreateCompatibleDC(screenDevice); ReleaseDC(0, screenDevice); - int size = large ? 64 : 32; + ICONINFO iconinfo; + bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center + if (!result) + qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()"); + + int w = iconinfo.xHotspot * 2; + int h = iconinfo.yHotspot * 2; BITMAPINFO bmi; memset(&bmi, 0, sizeof(bmi)); bmi.bmiHeader.biSize = sizeof(BITMAPINFO); - bmi.bmiHeader.biWidth = size; - bmi.bmiHeader.biHeight = -size; + bmi.bmiHeader.biWidth = w; + bmi.bmiHeader.biHeight = -h; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; @@ -366,13 +410,13 @@ QPixmap convertHIconToPixmap( const HICON icon, bool large) if (winBitmap ) memset(bits, 0xff, size*size*4); if (!winBitmap) { - qWarning("convertHIconToPixmap(), failed to CreateDIBSection()"); + qWarning("QPixmap::fromWinHICON(), failed to CreateDIBSection()"); return QPixmap(); } HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap); if (!DrawIconEx( hdc, 0, 0, icon, size, size, 0, 0, DI_NORMAL)) - qWarning("convertHIconToPixmap(), failed to DrawIcon()"); + qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()"); uint mask = 0xff000000; // Create image and copy data into image. @@ -389,7 +433,7 @@ QPixmap convertHIconToPixmap( const HICON icon, bool large) } } if (!DrawIconEx( hdc, 0, 0, icon, size, size, 0, 0, DI_MASK)) - qWarning("convertHIconToPixmap(), failed to DrawIcon()"); + qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()"); if (!image.isNull()) { // failed to alloc? int bytes_per_line = size * sizeof(QRgb); for (int y=0; y<size; ++y) { @@ -407,25 +451,6 @@ QPixmap convertHIconToPixmap( const HICON icon, bool large) return QPixmap::fromImage(image); } #endif //ifndef Q_WS_WINCE - -QPixmap loadIconFromShell32( int resourceId, int size ) -{ -#ifdef Q_OS_WINCE - HMODULE hmod = LoadLibrary(L"ceshell.dll"); -#else - HMODULE hmod = LoadLibrary(L"shell32.dll"); -#endif - if( hmod ) { - HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0); - if( iconHandle ) { - QPixmap iconpixmap = convertHIconToPixmap( iconHandle ); - DestroyIcon(iconHandle); - return iconpixmap; - } - } - return QPixmap(); -} - -#endif +#endif //ifdef Q_WS_WIN QT_END_NAMESPACE diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index bac5065..5920a06 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -141,15 +141,6 @@ private: uint is_cached; }; -#ifdef Q_WS_WIN -#ifndef Q_WS_WINCE -QPixmap convertHIconToPixmap( const HICON icon); -#else -QPixmap convertHIconToPixmap( const HICON icon, bool large = false); -#endif -QPixmap loadIconFromShell32( int resourceId, int size ); -#endif - # define QT_XFORM_TYPE_MSBFIRST 0 # define QT_XFORM_TYPE_LSBFIRST 1 # if defined(Q_WS_WIN) diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp index 76e1a7e..4abdef9 100644 --- a/src/gui/itemviews/qfileiconprovider.cpp +++ b/src/gui/itemviews/qfileiconprovider.cpp @@ -51,7 +51,6 @@ #include <qt_windows.h> #include <commctrl.h> #include <objbase.h> -#include <private/qpixmapdata_p.h> #elif defined(Q_WS_MAC) #include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -262,9 +261,9 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const } if (pixmap.isNull()) { #ifndef Q_OS_WINCE - pixmap = convertHIconToPixmap(info.hIcon); + pixmap = QPixmap::fromWinHICON(info.hIcon); #else - pixmap = convertHIconToPixmap(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL)); + pixmap = QPixmap::fromWinHICON(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL)); #endif if (!pixmap.isNull()) { retIcon.addPixmap(pixmap); @@ -292,9 +291,9 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon); } #ifndef Q_OS_WINCE - pixmap = convertHIconToPixmap(info.hIcon); + pixmap = QPixmap::fromWinHICON(info.hIcon); #else - pixmap = convertHIconToPixmap(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL), true); + pixmap = QPixmap::fromWinHICON(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL)); #endif if (!pixmap.isNull()) { retIcon.addPixmap(pixmap); diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 2b1aaf5..6ecd535 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -220,7 +220,7 @@ static void resolveAygLibs() # define FE_FONTSMOOTHINGCLEARTYPE 0x0002 #endif -bool qt_cleartype_enabled; +Q_GUI_EXPORT bool qt_cleartype_enabled; Q_GUI_EXPORT bool qt_win_owndc_required; // CS_OWNDC is required if we use the GL graphicssystem as default typedef HCTX (API *PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL); diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index afb7698..45ecb5a 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -42,6 +42,7 @@ #include "qapplication.h" #include "qevent.h" #ifdef Q_WS_S60 +#include "qstyle.h" #include "private/qt_s60_p.h" #endif #include "private/qsoftkeymanager_p.h" @@ -197,7 +198,6 @@ bool QSoftKeyManager::event(QEvent *e) #ifdef Q_WS_S60 void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList<QAction*> &softkeys) { - CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer(); QT_TRAP_THROWING(nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS)); @@ -229,7 +229,9 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList<QAction*> &softkeys) : s60CommandStart + index; if (position != -1) { - TPtrC text = qt_QString2TPtrC(softKeyAction->text()); + const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut); + QString iconText = softKeyAction->iconText(); + TPtrC text = qt_QString2TPtrC( underlineShortCut ? softKeyAction->text() : iconText); QT_TRAP_THROWING(nativeContainer->SetCommandL(position, command, text)); } } diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 211e9d4..c705e2a 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -747,25 +747,6 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption) SetWindowText(q->internalWinId(), (wchar_t*)caption.utf16()); } -/* - Create an icon mask the way Windows wants it using CreateBitmap. -*/ - -HBITMAP qt_createIconMask(const QBitmap &bitmap) -{ - QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono); - int w = bm.width(); - int h = bm.height(); - int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment - uchar *bits = new uchar[bpl*h]; - bm.invertPixels(); - for (int y=0; y<h; y++) - memcpy(bits+y*bpl, bm.scanLine(y), bpl); - HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits); - delete [] bits; - return hbm; -} - HICON qt_createIcon(QIcon icon, int xSize, int ySize, QPixmap **cache) { HICON result = 0; @@ -775,27 +756,12 @@ HICON qt_createIcon(QIcon icon, int xSize, int ySize, QPixmap **cache) if (pm.isNull()) return 0; - QBitmap mask = pm.mask(); - if (mask.isNull()) { - mask = QBitmap(pm.size()); - mask.fill(Qt::color1); - } - - HBITMAP im = qt_createIconMask(mask); - ICONINFO ii; - ii.fIcon = true; - ii.hbmMask = im; - ii.hbmColor = pm.toWinHBITMAP(QPixmap::Alpha); - ii.xHotspot = 0; - ii.yHotspot = 0; - result = CreateIconIndirect(&ii); + result = pm.toWinHICON(); if (cache) { delete *cache; *cache = new QPixmap(pm);; } - DeleteObject(ii.hbmColor); - DeleteObject(im); } return result; } diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 742b5b0..f5aadb8 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -41,7 +41,6 @@ #include "qwindowsstyle.h" #include "qwindowsstyle_p.h" -#include <private/qpixmapdata_p.h> #include <private/qstylehelper_p.h> #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN) @@ -927,6 +926,24 @@ static const char *const question_xpm[] = { #endif //QT_NO_IMAGEFORMAT_XPM +static QPixmap loadIconFromShell32( int resourceId, int size ) +{ +#ifdef Q_OS_WINCE + HMODULE hmod = LoadLibrary(L"ceshell.dll"); +#else + HMODULE hmod = LoadLibrary(L"shell32.dll"); +#endif + if( hmod ) { + HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0); + if( iconHandle ) { + QPixmap iconpixmap = QPixmap::fromWinHICON( iconHandle ); + DestroyIcon(iconHandle); + return iconpixmap; + } + } + return QPixmap(); +} + /*! \reimp */ @@ -1016,28 +1033,28 @@ QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyl case SP_MessageBoxInformation: { HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION); - desktopIcon = convertHIconToPixmap( iconHandle ); + desktopIcon = QPixmap::fromWinHICON( iconHandle ); DestroyIcon(iconHandle); break; } case SP_MessageBoxWarning: { HICON iconHandle = LoadIcon(NULL, IDI_WARNING); - desktopIcon = convertHIconToPixmap( iconHandle ); + desktopIcon = QPixmap::fromWinHICON( iconHandle ); DestroyIcon(iconHandle); break; } case SP_MessageBoxCritical: { HICON iconHandle = LoadIcon(NULL, IDI_ERROR); - desktopIcon = convertHIconToPixmap( iconHandle ); + desktopIcon = QPixmap::fromWinHICON( iconHandle ); DestroyIcon(iconHandle); break; } case SP_MessageBoxQuestion: { HICON iconHandle = LoadIcon(NULL, IDI_QUESTION); - desktopIcon = convertHIconToPixmap( iconHandle ); + desktopIcon = QPixmap::fromWinHICON( iconHandle ); DestroyIcon(iconHandle); break; } @@ -1052,7 +1069,7 @@ QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyl memset(&iconInfo, 0, sizeof(iconInfo)); iconInfo.cbSize = sizeof(iconInfo); if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) { - pixmap = convertHIconToPixmap(iconInfo.hIcon); + pixmap = QPixmap::fromWinHICON(iconInfo.hIcon); DestroyIcon(iconInfo.hIcon); return pixmap; } @@ -3346,7 +3363,7 @@ QIcon QWindowsStyle::standardIconImplementation(StandardPixmap standardIcon, con memset(&iconInfo, 0, sizeof(iconInfo)); iconInfo.cbSize = sizeof(iconInfo); if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) { - icon.addPixmap(convertHIconToPixmap(iconInfo.hIcon)); + icon.addPixmap(QPixmap::fromWinHICON(iconInfo.hIcon)); DestroyIcon(iconInfo.hIcon); } } diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index fc3d527..362be5b 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -98,7 +98,6 @@ public: bool allowsMessages(); bool supportsMessages(); QRect findIconGeometry(const int a_iButtonID); - HBITMAP createIconMask(const QBitmap &bitmap); void createIcon(); HICON hIcon; QPoint globalPos; @@ -241,21 +240,6 @@ bool QSystemTrayIconSys::iconDrawItem(LPDRAWITEMSTRUCT lpdi) return true; } -HBITMAP QSystemTrayIconSys::createIconMask(const QBitmap &bitmap) -{ - QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono); - int w = bm.width(); - int h = bm.height(); - int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment - uchar *bits = new uchar[bpl*h]; - bm.invertPixels(); - for (int y=0; y<h; y++) - memcpy(bits+y*bpl, bm.scanLine(y), bpl); - HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits); - delete [] bits; - return hbm; -} - void QSystemTrayIconSys::createIcon() { hIcon = 0; @@ -270,23 +254,7 @@ void QSystemTrayIconSys::createIcon() if (pm.isNull()) return; - QBitmap mask = pm.mask(); - if (mask.isNull()) { - mask = QBitmap(pm.size()); - mask.fill(Qt::color1); - } - - HBITMAP im = createIconMask(mask); - ICONINFO ii; - ii.fIcon = true; - ii.hbmMask = im; - ii.hbmColor = pm.toWinHBITMAP(QPixmap::Alpha); - ii.xHotspot = 0; - ii.yHotspot = 0; - hIcon = CreateIconIndirect(&ii); - - DeleteObject(ii.hbmColor); - DeleteObject(im); + hIcon = pm.toWinHICON(); } bool QSystemTrayIconSys::winEvent( MSG *m, long *result ) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 00ceb98..13830ba 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -103,22 +103,6 @@ static bool hasContextMenu(QWidget* widget) } return false; } -// ### FIX THIS, copy/paste of original (faulty) stripped text implementation. -// Implementation should be removed from QAction implementation to some generic place -static QString qt_strippedText_copy_from_qaction(QString s) -{ - s.remove(QString::fromLatin1("...")); - int i = 0; - while (i < s.size()) { - ++i; - if (s.at(i-1) != QLatin1Char('&')) - continue; - if (i < s.size() && s.at(i) == QLatin1Char('&')) - ++i; - s.remove(i-1,1); - } - return s.trimmed(); -}; static SymbianMenuItem* qt_symbian_find_menu(int id, const QList<SymbianMenuItem*> &parent) { @@ -161,11 +145,9 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe if (action->action->isSeparator()) return; -// ### FIX THIS, the qt_strippedText2 doesn't work perfectly for stripping & marks. Same bug is in QAction -// New really working method is needed in a place where the implementation isn't copy/pasted - QString text = qt_strippedText_copy_from_qaction(action->action->text()); - TPtrC menuItemText(qt_QString2TPtrC(text)); - + const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut); + QString iconText = action->action->iconText(); + TPtrC menuItemText = qt_QString2TPtrC( underlineShortCut ? action->action->text() : iconText); if (action->action->menu()) { SymbianMenuItem* menuItem = new SymbianMenuItem(); menuItem->menuItemData.iCascadeId = action->command; diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index b3458af..eceed06 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -134,7 +134,8 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) code[ShockingPinkSrcFragmentShader] = qglslShockingPinkSrcFragmentShader; code[MaskFragmentShader] = qglslMaskFragmentShader; - code[RgbMaskFragmentShader] = ""; //### + code[RgbMaskFragmentShaderPass1] = qglslRgbMaskFragmentShaderPass1; + code[RgbMaskFragmentShaderPass2] = qglslRgbMaskFragmentShaderPass2; code[RgbMaskWithGammaFragmentShader] = ""; //### code[MultiplyCompositionModeFragmentShader] = ""; //### @@ -587,10 +588,15 @@ bool QGLEngineShaderManager::useCorrectShaderProg() if (maskType == PixelMask) { maskShaderName = QGLEngineSharedShaders::MaskFragmentShader; texCoords = true; - } else if (maskType == SubPixelMask) { - maskShaderName = QGLEngineSharedShaders::RgbMaskFragmentShader; + } else if (maskType == SubPixelMaskPass1) { + maskShaderName = QGLEngineSharedShaders::RgbMaskFragmentShaderPass1; + texCoords = true; + } else if (maskType == SubPixelMaskPass2) { + maskShaderName = QGLEngineSharedShaders::RgbMaskFragmentShaderPass2; + texCoords = true; } else if (maskType == SubPixelWithGammaMask) { maskShaderName = QGLEngineSharedShaders::RgbMaskWithGammaFragmentShader; + texCoords = true; } else { qCritical("QGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type"); } diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 3c5a5f5..47d9a2a 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -142,7 +142,8 @@ Masks are implementations of "qcolorp vec4 applyMask(qcolorp vec4 src)": qglslMaskFragmentShader - qglslRgbMaskFragmentShader + qglslRgbMaskFragmentShaderPass1 + qglslRgbMaskFragmentShaderPass2 qglslRgbMaskWithGammaFragmentShader Composition modes are "qcolorp vec4 compose(qcolorp vec4 src)": @@ -321,7 +322,8 @@ public: ShockingPinkSrcFragmentShader, MaskFragmentShader, - RgbMaskFragmentShader, + RgbMaskFragmentShaderPass1, + RgbMaskFragmentShaderPass2, RgbMaskWithGammaFragmentShader, MultiplyCompositionModeFragmentShader, @@ -376,7 +378,7 @@ public: QGLEngineShaderManager(QGLContext* context); ~QGLEngineShaderManager(); - enum MaskType {NoMask, PixelMask, SubPixelMask, SubPixelWithGammaMask}; + enum MaskType {NoMask, PixelMask, SubPixelMaskPass1, SubPixelMaskPass2, SubPixelWithGammaMask}; enum PixelSrcType { ImageSrc = Qt::TexturePattern+1, NonPremultipliedImageSrc = Qt::TexturePattern+2, diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 6bcf010..8ae86d3 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -401,6 +401,39 @@ static const char* const qglslMaskFragmentShader = "\ return src * mask.a; \ }"; +// For source over with subpixel antialiasing, the final color is calculated per component as follows +// (.a is alpha component, .c is red, green or blue component): +// alpha = src.a * mask.c * opacity +// dest.c = dest.c * (1 - alpha) + src.c * alpha +// +// In the first pass, calculate: dest.c = dest.c * (1 - alpha) with blend funcs: zero, 1 - source color +// In the second pass, calculate: dest.c = dest.c + src.c * alpha with blend funcs: one, one +// +// If source is a solid color (src is constant), only the first pass is needed, with blend funcs: constant, 1 - source color + +// For source composition with subpixel antialiasing, the final color is calculated per component as follows: +// alpha = src.a * mask.c * opacity +// dest.c = dest.c * (1 - mask.c) + src.c * alpha +// + +static const char* const qglslRgbMaskFragmentShaderPass1 = "\ + varying highp vec2 textureCoords;\ + uniform lowp sampler2D maskTexture;\ + lowp vec4 applyMask(lowp vec4 src) \ + {\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \ + return src.a * mask; \ + }"; + +static const char* const qglslRgbMaskFragmentShaderPass2 = "\ + varying highp vec2 textureCoords;\ + uniform lowp sampler2D maskTexture;\ + lowp vec4 applyMask(lowp vec4 src) \ + {\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \ + return src * mask; \ + }"; + /* Left to implement: RgbMaskFragmentShader, diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index b59328e..fb493e6 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -90,6 +90,10 @@ static const GLuint QT_IMAGE_TEXTURE_UNIT = 0; //Can be the same as brush static const GLuint QT_MASK_TEXTURE_UNIT = 1; static const GLuint QT_BACKGROUND_TEXTURE_UNIT = 2; +#ifdef Q_WS_WIN +extern Q_GUI_EXPORT bool qt_cleartype_enabled; +#endif + class QGLTextureGlyphCache : public QObject, public QTextureGlyphCache { Q_OBJECT @@ -100,6 +104,7 @@ public: virtual void createTextureData(int width, int height); virtual void resizeTextureData(int width, int height); virtual void fillTexture(const Coord &c, glyph_t glyph); + virtual int glyphMargin() const; inline GLuint texture() const { return m_texture; } @@ -290,7 +295,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) glBindTexture(GL_TEXTURE_2D, m_texture); if (mask.format() == QImage::Format_RGB32) { - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, m_height - c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); } else { #ifdef QT_OPENGL_ES2 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); @@ -310,6 +315,17 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) } } +int QGLTextureGlyphCache::glyphMargin() const +{ +#if defined(Q_WS_MAC) + return 2; +#elif defined (Q_WS_X11) + return 0; +#else + return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; +#endif +} + extern QImage qt_imageForBrush(int brushStyle, bool invert); ////////////////////////////////// Private Methods ////////////////////////////////////////// @@ -1210,6 +1226,12 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem if (ti.fontEngine->fontDef.pixelSize * qSqrt(s->matrix.determinant()) >= 64) drawCached = false; + if (d->glyphCacheType == QFontEngineGlyphCache::Raster_RGBMask + && state()->composition_mode != QPainter::CompositionMode_Source + && state()->composition_mode != QPainter::CompositionMode_SourceOver) { + drawCached = false; + } + if (drawCached) { d->drawCachedGlyphs(p, ti); return; @@ -1230,11 +1252,12 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) - : QFontEngineGlyphCache::Raster_A8; + : glyphCacheType; QGLTextureGlyphCache *cache = (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, s->matrix); - if (!cache) { + + if (!cache || cache->cacheType() != glyphType) { cache = new QGLTextureGlyphCache(ctx, glyphType, s->matrix); ti.fontEngine->setGlyphCache(ctx, cache); } @@ -1249,12 +1272,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte transferMode(BrushDrawingMode); transferMode(TextDrawingMode); - if (glyphType == QFontEngineGlyphCache::Raster_A8) - shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); - else if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) - shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMask); - //### TODO: Gamma correction - int margin = cache->glyphMargin(); GLfloat dx = 1.0 / cache->width(); @@ -1275,10 +1292,96 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte textureCoordinateArray.addRect(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy)); } + if (vertexCoordinateArray.data() != oldVertexCoordinateDataPtr) + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray.data()); + if (textureCoordinateArray.data() != oldTextureCoordinateDataPtr) + glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); + QBrush pensBrush = q->state()->pen.brush(); setBrush(&pensBrush); - prepareForDraw(false); // Text always causes src pixels to be transparent + if (glyphType == QFontEngineGlyphCache::Raster_A8) { + + // Greyscale antialiasing + + shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); + prepareForDraw(false); // Text always causes src pixels to be transparent + } else if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { + + // Subpixel antialiasing without gamma correction + + QPainter::CompositionMode compMode = q->state()->composition_mode; + Q_ASSERT(compMode == QPainter::CompositionMode_Source + || compMode == QPainter::CompositionMode_SourceOver); + + shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass1); + + if (pensBrush.style() == Qt::SolidPattern) { + // Solid patterns can get away with only one pass. + QColor c = pensBrush.color(); + qreal oldOpacity = q->state()->opacity; + if (compMode == QPainter::CompositionMode_Source) { + c = premultiplyColor(c, q->state()->opacity); + q->state()->opacity = 1; + opacityUniformDirty = true; + } + + compositionModeDirty = false; // I can handle this myself, thank you very much + prepareForDraw(false); // Text always causes src pixels to be transparent + + // prepareForDraw() have set the opacity on the current shader, so the opacity state can now be reset. + if (compMode == QPainter::CompositionMode_Source) { + q->state()->opacity = oldOpacity; + opacityUniformDirty = true; + } + + glEnable(GL_BLEND); + glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR); + glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); + } else { + // Other brush styles need two passes. + + qreal oldOpacity = q->state()->opacity; + if (compMode == QPainter::CompositionMode_Source) { + q->state()->opacity = 1; + opacityUniformDirty = true; + pensBrush = Qt::white; + setBrush(&pensBrush); + } + + compositionModeDirty = false; // I can handle this myself, thank you very much + prepareForDraw(false); // Text always causes src pixels to be transparent + glEnable(GL_BLEND); + glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); + + glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); + glBindTexture(GL_TEXTURE_2D, cache->texture()); + updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); + +#ifndef QT_OPENGL_ES_2 + if (inRenderText) + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), zValueForRenderText()); +#endif + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); + glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size()); + + shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass2); + + if (compMode == QPainter::CompositionMode_Source) { + q->state()->opacity = oldOpacity; + opacityUniformDirty = true; + pensBrush = q->state()->pen.brush(); + setBrush(&pensBrush); + } + + compositionModeDirty = false; + prepareForDraw(false); // Text always causes src pixels to be transparent + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + } + compositionModeDirty = true; + } + //### TODO: Gamma correction glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); glBindTexture(GL_TEXTURE_2D, cache->texture()); @@ -1288,14 +1391,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte if (inRenderText) shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), zValueForRenderText()); #endif - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); - - if (vertexCoordinateArray.data() != oldVertexCoordinateDataPtr) - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray.data()); - if (textureCoordinateArray.data() != oldTextureCoordinateDataPtr) - glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data()); - glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size()); } @@ -1355,6 +1451,18 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) glDisable(GL_MULTISAMPLE); #endif + d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; + +#if !defined(QT_OPENGL_ES_2) + if (!d->device->format().alpha() +#if defined(Q_WS_WIN) + && qt_cleartype_enabled +#endif + ) { + d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; + } +#endif + return true; } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 0b564b7..049994f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -60,6 +60,7 @@ #include <private/qgl2pexvertexarray_p.h> #include <private/qglpaintdevice_p.h> #include <private/qglpixmapfilter_p.h> +#include <private/qfontengine_p.h> enum EngineMode { ImageDrawingMode, @@ -205,6 +206,7 @@ public: int width, height; QGLContext *ctx; EngineMode mode; + QFontEngineGlyphCache::Type glyphCacheType; mutable QOpenGL2PaintEngineState *last_created_state; diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index 3699d62..c785d8a 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -391,8 +391,9 @@ bool qt_resolve_version_2_0_functions(QGLContext *ctx) if (glStencilOpSeparate) return gl2supported; + glBlendColor = (_glBlendColor) ctx->getProcAddress(QLatin1String("glBlendColor")); glStencilOpSeparate = (_glStencilOpSeparate) ctx->getProcAddress(QLatin1String("glStencilOpSeparate")); - if (!glStencilOpSeparate) + if (!glBlendColor || !glStencilOpSeparate) gl2supported = false; return gl2supported; diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 40840b5..3510765 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -152,6 +152,7 @@ typedef void (APIENTRY *_glActiveStencilFaceEXT) (GLenum ); // Needed for GL2 engine: typedef void (APIENTRY *_glStencilOpSeparate) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (APIENTRY *_glActiveTexture) (GLenum); +typedef void (APIENTRY *_glBlendColor) (GLclampf, GLclampf, GLclampf, GLclampf); // EXT_GL_framebuffer_object @@ -247,6 +248,7 @@ struct QGLExtensionFuncs // Extras for GL2 engine: qt_glActiveTexture = 0; qt_glStencilOpSeparate = 0; + qt_glBlendColor = 0; qt_glActiveStencilFaceEXT = 0; qt_glMultiTexCoord4f = 0; @@ -360,6 +362,8 @@ struct QGLExtensionFuncs // Extras needed for GL2 engine: _glActiveTexture qt_glActiveTexture; _glStencilOpSeparate qt_glStencilOpSeparate; + _glBlendColor qt_glBlendColor; + #endif // FBOs @@ -574,6 +578,10 @@ struct QGLExtensionFuncs #endif #ifndef GL_VERSION_1_4 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_INCR_WRAP 0x8507 #define GL_DECR_WRAP 0x8508 #endif @@ -717,6 +725,7 @@ struct QGLExtensionFuncs #if !defined(QT_OPENGL_ES_2) #define glStencilOpSeparate QGLContextPrivate::extensionFuncs(ctx).qt_glStencilOpSeparate +#define glBlendColor QGLContextPrivate::extensionFuncs(ctx).qt_glBlendColor #endif #if defined(QT_OPENGL_ES_2) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 1d73a8f..6a6381e 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -560,13 +560,8 @@ QScriptValue::QScriptValue(QScriptEngine *engine, int val) if (engine) { JSC::ExecState *exec = d_ptr->engine->currentFrame; d_ptr->initFrom(JSC::jsNumber(exec, val)); - } else { - JSC::JSValue immediate = JSC::JSImmediate::from(val); - if (immediate) - d_ptr->initFrom(immediate); - else - d_ptr->initFrom(val); - } + } else + d_ptr->initFrom(val); } /*! @@ -582,13 +577,8 @@ QScriptValue::QScriptValue(QScriptEngine *engine, uint val) if (engine) { JSC::ExecState *exec = d_ptr->engine->currentFrame; d_ptr->initFrom(JSC::jsNumber(exec, val)); - } else { - JSC::JSValue immediate = JSC::JSImmediate::from(val); - if (immediate) - d_ptr->initFrom(immediate); - else - d_ptr->initFrom(val); - } + } else + d_ptr->initFrom(val); } /*! @@ -604,13 +594,8 @@ QScriptValue::QScriptValue(QScriptEngine *engine, qsreal val) if (engine) { JSC::ExecState *exec = d_ptr->engine->currentFrame; d_ptr->initFrom(JSC::jsNumber(exec, val)); - } else { - JSC::JSValue immediate = JSC::JSImmediate::from(val); - if (immediate) - d_ptr->initFrom(immediate); - else - d_ptr->initFrom(val); - } + } else + d_ptr->initFrom(val); } /*! @@ -689,11 +674,7 @@ QScriptValue::QScriptValue(bool value) QScriptValue::QScriptValue(int value) : d_ptr(new (/*engine=*/0)QScriptValuePrivate(/*engine=*/0)) { - JSC::JSValue immediate = JSC::JSImmediate::from(value); - if (immediate) - d_ptr->initFrom(immediate); - else - d_ptr->initFrom(value); + d_ptr->initFrom(value); } /*! @@ -704,11 +685,7 @@ QScriptValue::QScriptValue(int value) QScriptValue::QScriptValue(uint value) : d_ptr(new (/*engine=*/0)QScriptValuePrivate(/*engine=*/0)) { - JSC::JSValue immediate = JSC::JSImmediate::from(value); - if (immediate) - d_ptr->initFrom(immediate); - else - d_ptr->initFrom(value); + d_ptr->initFrom(value); } /*! @@ -719,11 +696,7 @@ QScriptValue::QScriptValue(uint value) QScriptValue::QScriptValue(qsreal value) : d_ptr(new (/*engine=*/0)QScriptValuePrivate(/*engine=*/0)) { - JSC::JSValue immediate = JSC::JSImmediate::from(value); - if (immediate) - d_ptr->initFrom(immediate); - else - d_ptr->initFrom(value); + d_ptr->initFrom(value); } /*! @@ -1224,8 +1197,15 @@ bool QScriptValue::strictlyEquals(const QScriptValue &other) const "a different engine"); return false; } - if (d->type != other.d_ptr->type) + + if (d->type != other.d_ptr->type) { + if (d->type == QScriptValuePrivate::JavaScriptCore) + return JSC::JSValue::strictEqual(d->jscValue, d->engine->scriptValueToJSCValue(other)); + else if (other.d_ptr->type == QScriptValuePrivate::JavaScriptCore) + return JSC::JSValue::strictEqual(other.d_ptr->engine->scriptValueToJSCValue(*this), other.d_ptr->jscValue); + return false; + } switch (d->type) { case QScriptValuePrivate::JavaScriptCore: return JSC::JSValue::strictEqual(d->jscValue, other.d_ptr->jscValue); diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index e2a67af..0638679 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,20 +1,22 @@ QT = core TEMPLATE = subdirs -# Directories -!wince*:SUBDIRS += \ - headers - -SUBDIRS += \ +# These tests use host tools and therefore can't work for cross-compiled Qt. +!cross_compile:SUBDIRS += \ + headers \ bic \ - collections \ compiler \ compilerwarnings \ - exceptionsafety \ linguist \ + moc \ + uic \ + uic3 + +SUBDIRS += \ + collections \ + exceptionsafety \ mediaobject \ # mediaobject_wince_ds9 \ This is Windows CE only (we test the second phonon backend ds9 here) - moc \ modeltest \ networkselftest \ q3accel \ @@ -394,8 +396,6 @@ SUBDIRS += \ selftests \ symbols \ qrand \ - uic \ - uic3 \ utf8 contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 218e9d2..9b8ce1f 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -246,6 +246,7 @@ private slots: void itemClipsToShape(); void itemClipsChildrenToShape(); void itemClipsChildrenToShape2(); + void itemClipsChildrenToShape3(); void itemClipsTextChildToShape(); void itemClippingDiscovery(); void ancestorFlags(); @@ -5048,6 +5049,37 @@ void tst_QGraphicsItem::itemClipsChildrenToShape2() #endif } +void tst_QGraphicsItem::itemClipsChildrenToShape3() +{ + // Construct a scene with nested children, each 50 pixels offset from the elder. + // Set a top-level clipping flag + QGraphicsScene scene; + QGraphicsRectItem *parent = scene.addRect( 0, 0, 150, 150 ); + QGraphicsRectItem *child = scene.addRect( 0, 0, 150, 150 ); + QGraphicsRectItem *grandchild = scene.addRect( 0, 0, 150, 150 ); + child->setParentItem(parent); + grandchild->setParentItem(child); + child->setPos( 50, 50 ); + grandchild->setPos( 50, 50 ); + parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + QCOMPARE(scene.itemAt(25,25), (QGraphicsItem *)parent); + QCOMPARE(scene.itemAt(75,75), (QGraphicsItem *)child); + QCOMPARE(scene.itemAt(125,125), (QGraphicsItem *)grandchild); + QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0); + + // Move child to fully overlap the parent. The grandchild should + // now occupy two-thirds of the scene + child->prepareGeometryChange(); + child->setPos( 0, 0 ); + + QCOMPARE(scene.itemAt(25,25), (QGraphicsItem *)child); + QCOMPARE(scene.itemAt(75,75), (QGraphicsItem *)grandchild); + QCOMPARE(scene.itemAt(125,125), (QGraphicsItem *)grandchild); + QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0); +} + + void tst_QGraphicsItem::itemClipsTextChildToShape() { // Construct a scene with a rect that clips its children, with one text diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_32bpp.ico b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp.ico Binary files differnew file mode 100644 index 0000000..dbb55cd --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp.ico diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_16x16.png b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_16x16.png Binary files differnew file mode 100644 index 0000000..f23f398 --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_16x16.png diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_256x256.png b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_256x256.png Binary files differnew file mode 100644 index 0000000..293f1c5 --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_256x256.png diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_32x32.png b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_32x32.png Binary files differnew file mode 100644 index 0000000..bfdb1fe --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_32x32.png diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_48x48.png b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_48x48.png Binary files differnew file mode 100644 index 0000000..7dd2d13 --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_32bpp_48x48.png diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_8bpp.ico b/tests/auto/qpixmap/convertFromToHICON/icon_8bpp.ico Binary files differnew file mode 100644 index 0000000..4341a33 --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_8bpp.ico diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_16x16.png b/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_16x16.png Binary files differnew file mode 100644 index 0000000..e9a995e --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_16x16.png diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_32x32.png b/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_32x32.png Binary files differnew file mode 100644 index 0000000..41ef57f --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_32x32.png diff --git a/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_48x48.png b/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_48x48.png Binary files differnew file mode 100644 index 0000000..35d60d1 --- /dev/null +++ b/tests/auto/qpixmap/convertFromToHICON/icon_8bpp_48x48.png diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 4721d2d..1bfddc1 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -134,6 +134,11 @@ private slots: void toWinHBITMAP(); void fromWinHBITMAP_data(); void fromWinHBITMAP(); + + void toWinHICON_data(); + void toWinHICON(); + void fromWinHICON_data(); + void fromWinHICON(); #endif #if defined(Q_WS_S60) @@ -939,13 +944,13 @@ void tst_QPixmap::fromWinHBITMAP() HDC display_dc = GetDC(0); HDC bitmap_dc = CreateCompatibleDC(display_dc); HBITMAP bitmap = CreateCompatibleBitmap(display_dc, 100, 100); - HBITMAP null_bitmap = (HBITMAP) SelectObject(bitmap_dc, bitmap); + SelectObject(bitmap_dc, bitmap); SelectObject(bitmap_dc, GetStockObject(NULL_PEN)); HGDIOBJ old_brush = SelectObject(bitmap_dc, CreateSolidBrush(RGB(red, green, blue))); Rectangle(bitmap_dc, 0, 0, 100, 100); -#ifdef Q_OS_WINCE //the device context has to be deleted before ::fromWinHBITMAP() +#ifdef Q_OS_WINCE //the device context has to be deleted before QPixmap::fromWinHBITMAP() DeleteDC(bitmap_dc); #endif QPixmap pixmap = QPixmap::fromWinHBITMAP(bitmap); @@ -966,7 +971,111 @@ void tst_QPixmap::fromWinHBITMAP() ReleaseDC(0, display_dc); } -#endif +static void compareImages(const QImage &image1, const QImage &image2) +{ + QCOMPARE(image1.width(), image2.width()); + QCOMPARE(image1.height(), image2.height()); + QCOMPARE(image1.format(), image2.format()); + + static const int fuzz = 1; + + for (int y = 0; y < image1.height(); y++) + { + for (int x = 0; x < image2.width(); x++) + { + QRgb p1 = image1.pixel(x, y); + QRgb p2 = image2.pixel(x, y); + + bool pixelMatches = + qAbs(qRed(p1) - qRed(p2)) <= fuzz + && qAbs(qGreen(p1) - qGreen(p2)) <= fuzz + && qAbs(qBlue(p1) - qBlue(p2)) <= fuzz + && qAbs(qAlpha(p1) - qAlpha(p2)) <= fuzz; + + QVERIFY(pixelMatches); + } + } +} + +void tst_QPixmap::toWinHICON_data() +{ + QTest::addColumn<QString>("image"); + QTest::addColumn<int>("width"); + QTest::addColumn<int>("height"); + + const QString prefix = QLatin1String(SRCDIR) + "/convertFromToHICON"; + + QTest::newRow("32bpp_16x16") << prefix + QLatin1String("/icon_32bpp") << 16 << 16; + QTest::newRow("32bpp_32x32") << prefix + QLatin1String("/icon_32bpp") << 32 << 32; + QTest::newRow("32bpp_48x48") << prefix + QLatin1String("/icon_32bpp") << 48 << 48; + QTest::newRow("32bpp_256x256") << prefix + QLatin1String("/icon_32bpp") << 256 << 256; + + QTest::newRow("8bpp_16x16") << prefix + QLatin1String("/icon_8bpp") << 16 << 16; + QTest::newRow("8bpp_32x32") << prefix + QLatin1String("/icon_8bpp") << 32 << 32; + QTest::newRow("8bpp_48x48") << prefix + QLatin1String("/icon_8bpp") << 48 << 48; +} + +void tst_QPixmap::toWinHICON() +{ + QFETCH(int, width); + QFETCH(int, height); + QFETCH(QString, image); + + QPixmap empty(width, height); + empty.fill(Qt::transparent); + + HDC display_dc = GetDC(0); + HDC bitmap_dc = CreateCompatibleDC(display_dc); + HBITMAP bitmap = empty.toWinHBITMAP(QPixmap::Alpha); + SelectObject(bitmap_dc, bitmap); + + QImage imageFromFile(image + QString(QLatin1String("_%1x%2.png")).arg(width).arg(height)); + imageFromFile = imageFromFile.convertToFormat(QImage::Format_ARGB32_Premultiplied); + + HICON icon = QPixmap::fromImage(imageFromFile).toWinHICON(); + + DrawIconEx(bitmap_dc, 0, 0, icon, width, height, 0, 0, DI_NORMAL); + + DestroyIcon(icon); + DeleteDC(bitmap_dc); + + QImage imageFromHICON = QPixmap::fromWinHBITMAP(bitmap, QPixmap::Alpha).toImage(); + + ReleaseDC(0, display_dc); + + // fuzzy comparison must be used, as the pixel values change slightly during conversion + // between QImage::Format_ARGB32 and QImage::Format_ARGB32_Premultiplied, or elsewhere + + // QVERIFY(imageFromHICON == imageFromFile); + compareImages(imageFromHICON, imageFromFile); +} + +void tst_QPixmap::fromWinHICON_data() +{ + toWinHICON_data(); +} + +void tst_QPixmap::fromWinHICON() +{ + QFETCH(int, width); + QFETCH(int, height); + QFETCH(QString, image); + + HICON icon = (HICON)LoadImage(0, (wchar_t*)(image + QLatin1String(".ico")).utf16(), IMAGE_ICON, width, height, LR_LOADFROMFILE); + QImage imageFromHICON = QPixmap::fromWinHICON(icon).toImage(); + DestroyIcon(icon); + + QImage imageFromFile(image + QString(QLatin1String("_%1x%2.png")).arg(width).arg(height)); + imageFromFile = imageFromFile.convertToFormat(QImage::Format_ARGB32_Premultiplied); + + // fuzzy comparison must be used, as the pixel values change slightly during conversion + // between QImage::Format_ARGB32 and QImage::Format_ARGB32_Premultiplied, or elsewhere + + // QVERIFY(imageFromHICON == imageFromFile); + compareImages(imageFromHICON, imageFromFile); +} + +#endif // Q_WS_WIN #if defined(Q_WS_S60) Q_DECLARE_METATYPE(TDisplayMode) diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index cbf49d5..4d693af 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -2435,7 +2435,6 @@ public: void tst_QScriptEngine::throwErrorFromProcessEvents() { - QSKIP("Not implemented", SkipAll); QScriptEngine eng; EventReceiver2 receiver(&eng); diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index 36f910a..3dafbee 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -1816,10 +1816,17 @@ void tst_QTextCodec::codecForHtml() QCOMPARE(QTextCodec::codecForHtml(html)->mibEnum(), 4); // latin 1 - QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // utf-8 + QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // UTF-8 html = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-15\" /></head></html>"; QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 111); // latin 15 + + html = "<html><head><meta content=\"text/html; charset=ISO-8859-15\" http-equiv=\"content-type\" /></head></html>"; + QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 111); // latin 15 + + html = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=invalid-foo\" /></head></html>"; + QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // UTF-8 + QCOMPARE(QTextCodec::codecForHtml(html)->mibEnum(), 4); // latin 1 } void tst_QTextCodec::codecForUtfText_data() diff --git a/tests/auto/windowsmobile/test/tst_windowsmobile.cpp b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp index 4fc870e..2d7c9ea 100644 --- a/tests/auto/windowsmobile/test/tst_windowsmobile.cpp +++ b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp @@ -46,7 +46,7 @@ #include <QtGui> #ifdef Q_OS_WINCE_WM #include <windows.h> -#include <ddhelper.h> +#include "ddhelper.h" #endif diff --git a/util/webkit/mkdist-javascriptcore b/util/webkit/mkdist-javascriptcore new file mode 100755 index 0000000..dc33f6c --- /dev/null +++ b/util/webkit/mkdist-javascriptcore @@ -0,0 +1,187 @@ +#!/bin/bash + +die() { + echo $* + exit 1 +} + +default_tag="javascriptcore-4.6-snapshot-29072009" + +if [ $# -eq 0 ]; then + tag="$default_tag" +elif [ $# -eq 1 ]; then + tag=$1 +else + die "usage: $0 [commit (defaults to $default_tag)]" +fi + +repository=`git config qtwebkit.url` +if [ -z "$repository" ]; then + die "error: cannot locate webkit git repository. please run git config --global qtwebkit.url /path-or-url/to/webkit/repo" +fi + +excluded_directories="$excluded_directories JavaScriptCore/Makefile" +excluded_directories="$excluded_directories JavaScriptCore/GNUmakefile.am" +excluded_directories="$excluded_directories JavaScriptCore/Configurations" +excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.exp" +excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.xcodeproj" +excluded_directories="$excluded_directories JavaScriptCore/tests" +excluded_directories="$excluded_directories JavaScriptCore/API/tests" +excluded_directories="$excluded_directories JavaScriptCore/JavaScriptCore.vcproj" +excluded_directories="$excluded_directories JavaScriptCore/wtf/wx" +excluded_directories="$excluded_directories JavaScriptCore/wtf/gtk" +excluded_directories="$excluded_directories JavaScriptCore/wtf/mac" +excluded_directories="$excluded_directories JavaScriptCore/wtf/win" +excluded_directories="$excluded_directories JavaScriptCore/wtf/chromium" +excluded_directories="$excluded_directories JavaScriptCore/wtf/haiku" +excluded_directories="$excluded_directories JavaScriptCore/icu" + + +files_to_remove="" +files_to_remove="$files_to_remove JavaScriptCore/AllInOneFile.cpp" +files_to_remove="$files_to_remove JavaScriptCore/JavaScriptCoreSources.bkl" +files_to_remove="$files_to_remove JavaScriptCore/jscore.bkl" + +require_clean_work_tree() { + # test if working tree is dirty + git rev-parse --verify HEAD > /dev/null && + git update-index --refresh && + git diff-files --quiet && + git diff-index --cached --quiet HEAD || + die "Working tree is dirty" +} + +which qmake >/dev/null 2>/dev/null +if [ "$?" != 0 ]; then + die "abort: Could not locate qmake in your PATH" +fi + +test -z "$(git rev-parse --show-cdup)" || { + exit=$? + echo >&2 "You need to run this command from the toplevel of the working tree." + exit $exit +} + +echo "checking working tree" +require_clean_work_tree + +revCount=`git ls-remote $repository | grep $tag | awk '{print $1}' | wc -l` +if [ "$revCount" != 1 ]; then + die "Cannot parse $tag into a revision. It seems ambiguous". +fi + +rev=`git ls-remote $repository | grep -E "^.+$tag$" | awk '{print $1}'` + +tarball=`mktemp /tmp/webkit-snapshot.tar.XXXXXX` || exit 1 +echo "creating $tarball" + +echo "archiving webkit from $repository $tag ( $rev )" + +git archive --remote=$repository $rev JavaScriptCore WebKit.pri > $tarball || exit 1 + +echo "removing unwanted files and directories" +for dir in $excluded_directories; do + echo " removing $dir" + tar --delete --file=$tarball $dir +done + +for item in $exclude_with_exceptions_list; do + dir=`echo $item | awk -F : '{print $1}'` + include=`echo $item | awk -F : '{print $2}'` + echo " removing $dir except $include" + files=`tar --list --file=$tarball $dir | grep -v -E "^$dir\$" | grep -v $include` + tar --delete --file=$tarball $files +done + +for file in $files_to_remove; do + echo " removing $file" + tar --delete --file=$tarball $file +done + +echo "done!" + +srcdir=src/3rdparty/javascriptcore +absSrcDir=$PWD/$srcdir +localDiff= +lastImportRevison= + +echo "replacing $srcdir" +if [ -d $srcdir ]; then + git ls-files $srcdir | xargs rm + git ls-files -z src/3rdparty/javascriptcore | git update-index --force-remove -z --stdin +else + mkdir -p $srcdir +fi + +(cd $srcdir && tar xf $tarball) +git add $srcdir + +echo "generating extra sources" +( + for proj in JavaScriptCore; do + cd $absSrcDir/$proj && + rm -rf tmp && + mkdir tmp && + cd tmp && + mkdir -p ../generated && + qmake -o Makefile CONFIG-=QTDIR_build QT_CONFIG+=phonon GENERATED_SOURCES_DIR=`pwd`/../generated OUTPUT_DIR=`pwd` ../$proj.pro && + make generated_files && + perl -pi -e "s,$absSrcDir/,,g" ../generated/*.cpp ../generated/*.h && + git add ../generated && + cd .. && + rm -rf tmp && + cd .. + done +) +rm -rf $srcdir/WebKitBuild + +cat >$srcdir/VERSION <<EOT +This is a snapshot of JavaScriptCore from + + git://gitorious.org/qtwebkit/qtwebkit.git + +The commit imported was from the + + $tag branch/tag + +and has the sha1 checksum + + $rev +EOT +git add $srcdir/VERSION + +git diff-files --name-only -z | git update-index --remove -z --stdin + +echo "removing $tarball" +rm -f $tarball + +cat >commitlog.txt <<EOT +Updated JavaScriptCore from $repository to $tag ( $rev ) +EOT + +if [ -d "$repository/.git" -a -n "$lastImportRevison" ]; then + echo >>commitlog.txt + echo "Changes in WebKit/qt since the last update:" >>commitlog.txt + echo >>commitlog.txt + git --git-dir=$repository/.git diff $lastImportRevison $rev -- WebKit/qt/ChangeLog | sed -n -e "s,^\+\(.*\),\1,p" >>commitlog.txt +fi + +echo "Changes:" +echo +git --no-pager diff --name-status --cached $srcdir + +echo +echo "Wrote commitlog.txt. Use with" +echo +echo " git commit -e -F commitlog.txt" +echo +echo "to commit your changes" + +if [ -n "$localDiff" ]; then + echo + echo "The changes that were locally stored in Perforce are now stored as a git patch in $localDiff" + echo "You may want to appy them with" + echo + echo " git am -3 $localDiff" + echo +fi |