Merge "Merge remote-tracking branch 'origin/master' into api_changes" into refs/staging/api_changes

This commit is contained in:
Sergio Ahumada 2012-04-17 10:38:24 +02:00 committed by Qt by Nokia
commit 16b53b2f0e
378 changed files with 6394 additions and 3835 deletions

1
.gitignore vendored
View File

@ -215,6 +215,7 @@ examples/tools/plugandpaint/plugins
include/*
include/*/*
lib/*
imports/*
!lib/fonts
!lib/README
plugins/*/*

View File

@ -227,7 +227,7 @@ sub classNames {
$line =~ s,//.*$,,; #remove c++ comments
$line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro
$line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro
$line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro
$line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE(_[A-Z]+)*[\r\n]*$/); #qt macro
$line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro
$parsable .= " " . $line;
}

191
configure vendored
View File

@ -688,6 +688,7 @@ CFG_AUDIO_BACKEND=auto
CFG_V8SNAPSHOT=auto
CFG_QML_DEBUG=yes
CFG_JAVASCRIPTCORE_JIT=auto
CFG_PKGCONFIG=auto
# Target architecture
CFG_ARCH=
@ -704,6 +705,7 @@ CFG_XKB=auto
CFG_XCB=auto
CFG_XCB_LIMITED=yes
CFG_EGLFS=auto
CFG_DIRECTFB=auto
CFG_LIBUDEV=auto
CFG_OBSOLETE_WAYLAND=no
CFG_EVDEV=auto
@ -887,7 +889,7 @@ while [ "$#" -gt 0 ]; do
VAL=no
;;
#Qt style yes options
-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-xinput2|-egl|-reduce-exports|-pch|-separate-debug-info|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-xcb|-eglfs|-nis|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-debug-and-release|-exceptions|-harfbuzz|-prefix-install|-silent|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-phonon-backend|-audio-backend|-qml-debug|-javascript-jit|-rpath|-force-pkg-config|-icu|-force-asserts|-testcocoon)
-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-xinput2|-egl|-reduce-exports|-pch|-separate-debug-info|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-xcb|-eglfs|-directfb|-nis|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-debug-and-release|-exceptions|-harfbuzz|-prefix-install|-silent|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-phonon-backend|-audio-backend|-qml-debug|-javascript-jit|-rpath|-pkg-config|-force-pkg-config|-icu|-force-asserts|-testcocoon)
VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
VAL=yes
;;
@ -1077,8 +1079,15 @@ while [ "$#" -gt 0 ]; do
hostbindir)
QT_HOST_BINS="$VAL"
;;
pkg-config)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_PKGCONFIG="$VAL"
else
UNKNOWN_OPT=yes
fi
;;
force-pkg-config)
QT_FORCE_PKGCONFIG=yes
CFG_PKGCONFIG="force"
;;
docdir)
QT_INSTALL_DOCS="$VAL"
@ -1619,6 +1628,13 @@ while [ "$#" -gt 0 ]; do
UNKNOWN_OPT=yes
fi
;;
directfb)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_DIRECTFB="$VAL"
else
UNKNOWN_OPT=yes
fi
;;
libudev)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_LIBUDEV="$VAL"
@ -2153,19 +2169,19 @@ if [ -z "$PLATFORM" ]; then
case "$UNAME_SYSTEM:$UNAME_RELEASE" in
Darwin:*)
OSX_VERSION=`uname -r | cut -d. -f1`
if [ "$OSX_VERSION" -ge 11 ]; then
# We're on Lion or above. Check if we have a supported Clang version
# Select compiler. Use g++ unless we find a usable Clang version
PLATFORM=macx-g++
if [ "$OSX_VERSION" -ge 12 ]; then
# We're on Mountain Lion or above. Use Clang. Don't advertise gcc.
PLATFORM=macx-clang
elif [ "$OSX_VERSION" -eq 11 ]; then
# We're on Lion. Check if we have a supported Clang version
case "$(clang -v 2>&1 | grep -Po '(?<=version )\d[\d.]+')" in
3.*)
PLATFORM=macx-clang
PLATFORM_NOTES="\n - Also available for Mac OS X: macx-g++\n"
;;
*)
PLATFORM=macx-g++
;;
esac
else
PLATFORM=macx-g++
fi
;;
AIX:*)
@ -2441,50 +2457,6 @@ if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
QT_CONFIG="$QT_CONFIG build_all"
fi
if [ -z "$PKG_CONFIG" ]; then
# See if PKG_CONFIG is set in the mkspec:
PKG_CONFIG=`getXQMakeConf PKG_CONFIG`
fi
if [ -z "$PKG_CONFIG" ]; then
PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
fi
# Work out if we can use pkg-config
if [ "$QT_CROSS_COMPILE" = "yes" ]; then
if [ "$QT_FORCE_PKGCONFIG" = "yes" ]; then
echo >&2 ""
echo >&2 "You have asked to use pkg-config and are cross-compiling."
echo >&2 "Please make sure you have a correctly set-up pkg-config"
echo >&2 "environment!"
echo >&2 ""
if [ -z "$PKG_CONFIG_LIBDIR" ]; then
echo >&2 ""
echo >&2 "Warning: PKG_CONFIG_LIBDIR has not been set. This could mean"
echo >&2 "the host's .pc files will be used (even if you set PKG_CONFIG_PATH)."
echo >&2 "This is probably not what you want."
echo >&2 ""
elif [ -z "$PKG_CONFIG_SYSROOT" ] && [ -z "$PKG_CONFIG_SYSROOT_DIR" ]; then
echo >&2 ""
echo >&2 "Warning: PKG_CONFIG_SYSROOT/PKG_CONFIG_SYSROOT_DIR has not"
echo >&2 "been set. This means your toolchain's .pc files must contain"
echo >&2 "the paths to the toolchain's libraries & headers. If configure"
echo >&2 "tests are failing, please check these files."
echo >&2 ""
fi
else
echo >&2 ""
echo >&2 "You have not explicitly asked to use pkg-config and are cross-compiling."
echo >&2 "pkg-config will not be used to automatically query cflag/lib parameters for"
echo >&2 "dependencies"
echo >&2 ""
PKG_CONFIG=""
fi
fi
if [ ! -n "$PKG_CONFIG" ]; then
QT_CONFIG="$QT_CONFIG no-pkg-config"
fi
# pass on $CFG_SDK to the configure tests.
if [ '!' -z "$CFG_SDK" ]; then
MAC_CONFIG_TEST_COMMANDLINE="$MAC_CONFIG_TEST_COMMANDLINE -sdk $CFG_SDK"
@ -2844,6 +2816,13 @@ if [ "$OPT_HELP" = "yes" ]; then
EGLFSN=" "
fi
if [ "$CFG_DIRECTFB" = "no"]; then
DFBY=" "
DFBN="*"
else
DFBY="*"
DFBN=" "
fi
if [ "$CFG_XINPUT2" = "no" ]; then
X2Y=" "
X2N="*"
@ -3036,6 +3015,13 @@ Configure options:
-I <string> ........ Add an explicit include path.
-L <string> ........ Add an explicit library path.
+ -pkg-config ........ Use pkg-config to detect include and library paths. By default,
configure determines whether to use pkg-config or not with
some heuristics such as checking the environment variables.
-no-pkg-config ..... Disable use of pkg-config.
-force-pkg-config .. Force usage of pkg-config (skips pkg-config usability
detection heuristic).
-help, -h .......... Display this information.
Third Party Libraries:
@ -3128,6 +3114,9 @@ Additional options:
$EGLFSN -no-eglfs .......... Do not compile EGLFS (EGL Full Screen/Single Surface) support.
$EGLFSY -eglfs ............. Compile EGLFS support.
$DFBN -no-directfb ....... Do not compile DirectFB support.
$DFBY -directfb .......... Compile DirectFB support.
-xplatform target ... The target platform when cross-compiling.
-sysroot <dir> ...... Sets <dir> as the target compiler's and qmake's sysroot.
@ -3607,6 +3596,70 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
[ "$QMAKE_BUILD_ERROR" = "yes" ] && exit 2
fi # Build qmake
#-------------------------------------------------------------------------------
# Detect pkg-config
#-------------------------------------------------------------------------------
if [ -z "$PKG_CONFIG" ]; then
# See if PKG_CONFIG is set in the mkspec:
PKG_CONFIG=`getXQMakeConf PKG_CONFIG`
fi
if [ -z "$PKG_CONFIG" ]; then
PKG_CONFIG=`"$WHICH" pkg-config 2>/dev/null`
fi
if [ "$CFG_PKGCONFIG" = "no" ]; then
PKG_CONFIG=
elif [ "$CFG_PKGCONFIG" = "force" ]; then
echo >&2 ""
echo >&2 "You have asked to use pkg-config. Please make sure you have"
echo >&2 "a correctly setup pkg-config environment!"
echo >&2 ""
elif [ -n "$PKG_CONFIG" ]; then
# found a pkg-config
if [ "$QT_CROSS_COMPILE" = "yes" ]; then
# when xcompiling, check environment to see if it's actually usable
if [ -z "$PKG_CONFIG_LIBDIR" ]; then
if [ -n "$CFG_SYSROOT" ] && [ -d "$CFG_SYSROOT/usr/lib/pkgconfig" ]; then
PKG_CONFIG_LIBDIR=$CFG_SYSROOT/usr/lib/pkgconfig:$CFG_SYSROOT/usr/share/pkgconfig
export PKG_CONFIG_LIBDIR
echo >&2 "Note: PKG_CONFIG_LIBDIR automatically set to $PKG_CONFIG_LIBDIR"
elif [ "$CFG_PKGCONFIG" = "yes" ]; then
echo >&2 "Error: PKG_CONFIG_LIBDIR has not been set. This could mean"
echo >&2 "the host's .pc files will be used (even if you set PKG_CONFIG_PATH)."
echo >&2 "Set this variable to the directory that contains target .pc files"
echo >&2 "for pkg-config to function correctly when cross-compiling or"
echo >&2 "use -force-pkg-config to override this test."
exit 101
else
PKG_CONFIG=
echo >&2 "Warning: Disabling pkg-config since PKG_CONFIG_LIBDIR is not set."
fi
fi
if [ -z "$PKG_CONFIG_SYSROOT_DIR" ]; then
if [ -n "$CFG_SYSROOT" ]; then
PKG_CONFIG_SYSROOT_DIR=$CFG_SYSROOT
export PKG_CONFIG_SYSROOT_DIR
echo >&2 "Note: PKG_CONFIG_SYSROOT_DIR automatically set to $PKG_CONFIG_SYSROOT_DIR"
elif [ "$CFG_PKGCONFIG" = "yes" ]; then
echo >&2 "Error: PKG_CONFIG_SYSROOT_DIR has not been set. Set this variable"
echo >&2 "to your sysroot for pkg-config to function correctly when cross-compiling"
echo >&2 "or use -force-pkg-config to override this test."
exit 101
else
PKG_CONFIG=
echo >&2 "Warning: Disabling pkg-config since PKG_CONFIG_SYSROOT_DIR is not set."
fi
fi
fi
elif [ "$CFG_PKGCONFIG" = "yes" ]; then
echo >&2 "Could not detect pkg-config from mkspec or PATH."
exit 101
fi
if [ -z "$PKG_CONFIG" ]; then
QT_CONFIG="$QT_CONFIG no-pkg-config"
fi
#-------------------------------------------------------------------------------
# tests that need qmake
#-------------------------------------------------------------------------------
@ -4404,6 +4457,7 @@ fi
# Save these for a check later
ORIG_CFG_XCB="$CFG_XCB"
ORIG_CFG_EGLFS="$CFG_EGLFS"
ORIG_CFG_DIRECTFB="$CFG_DIRECTFB"
if [ "$CFG_LIBUDEV" != "no" ]; then
if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists libudev 2>/dev/null; then
@ -4511,6 +4565,16 @@ if [ "$CFG_XCB" != "no" ]; then
fi
fi
if [ "$CFG_DIRECTFB" != "no" ]; then
if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists directfb 2>/dev/null; then
QMAKE_CFLAGS_DIRECTFB=`$PKG_CONFIG --cflags directfb 2>/dev/null`
QMAKE_LIBS_DIRECTFB=`$PKG_CONFIG --libs directfb 2>/dev/null`
QT_CONFIG="$QT_CONFIG directfb"
else
CFG_DIRECTFB=no
fi
fi
# Detect libxkbcommon
if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists xkbcommon 2>/dev/null; then
QMAKE_CFLAGS_XKBCOMMON="`$PKG_CONFIG --cflags xkbcommon 2>/dev/null`"
@ -4558,6 +4622,10 @@ if [ -n "$QMAKE_CFLAGS_XCB" ] || [ -n "$QMAKE_LIBS_XCB" ]; then
QMakeVar set QMAKE_LIBS_XCB "$QMAKE_LIBS_XCB"
QMakeVar set QMAKE_DEFINES_XCB "$QMAKE_DEFINES_XCB"
fi
if [ -n "$QMAKE_CFLAGS_DIRECTFB" ] || [ -n "$QMAKE_LIBS_DIRECTFB" ]; then
QMakeVar set QMAKE_CFLAGS_DIRECTFB "$QMAKE_CFLAGS_DIRECTFB"
QMakeVar set QMAKE_LIBS_DIRECTFB "$QMAKE_LIBS_DIRECTFB"
fi
if [ "$BUILD_ON_MAC" = "yes" ]; then
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/coreservices "CoreServices" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
@ -4568,12 +4636,12 @@ if [ "$BUILD_ON_MAC" = "yes" ]; then
fi
if [ "$BUILD_ON_MAC" = "no" ] && [ "$XPLATFORM_MINGW" = "no" ]; then
if [ "$CFG_XCB" = "no" ] && [ "$CFG_EGLFS" = "no" ]; then
if [ "$CFG_XCB" = "no" ] && [ "$CFG_EGLFS" = "no" ] && [ "$CFG_DIRECTFB" = "no" ]; then
if [ "$QPA_PLATFORM_GUARD" = "yes" ] &&
( [ "$ORIG_CFG_XCB" = "auto" ] || [ "$ORIG_CFG_EGLFS" = "auto" ] ); then
( [ "$ORIG_CFG_XCB" = "auto" ] || [ "$ORIG_CFG_EGLFS" = "auto" ] || [ "$ORIG_CFG_DIRECTFB" = "auto" ] ); then
echo "No QPA platform plugin enabled!"
echo " If you really want to build without a QPA platform plugin you must pass"
echo " -no-xcb and -no-eglfs to configure. Doing this will"
echo " -no-xcb, -no-eglfs and -no-directfb to configure. Doing this will"
echo " produce a Qt that cannot run GUI applications."
echo " The dependencies needed for xcb to build are listed in"
echo " src/plugins/platforms/xcb/README"
@ -5759,6 +5827,7 @@ fi
#-------------------------------------------------------------------------------
# give feedback on configuration
#-------------------------------------------------------------------------------
exec 3>&1 1>$outpath/config.summary # redirect output temporarily to config.summary
case "$COMPILER" in
g++*)
@ -5836,6 +5905,11 @@ if [ "$CFG_DEBUG_RELEASE" = "yes" ]; then
else
echo "Debug .................. $CFG_DEBUG"
fi
if [ -n "$PKG_CONFIG" ]; then
echo "pkg-config ............. yes"
else
echo "pkg-config ............. no"
fi
[ "$CFG_DBUS" = "no" ] && echo "QtDBus module .......... no"
[ "$CFG_DBUS" = "yes" ] && echo "QtDBus module .......... yes (run-time)"
[ "$CFG_DBUS" = "linked" ] && echo "QtDBus module .......... yes (linked)"
@ -5949,6 +6023,7 @@ if [ "$XPLATFORM_MAEMO" = "yes" ] && [ "$CFG_XCB" = "yes" ]; then
echo "XInput2 support ........ $CFG_XINPUT2"
fi
echo "EGLFS support .......... $CFG_EGLFS"
echo "DirectFB support ....... $CFG_DIRECTFB"
echo
# complain about not being able to use dynamic plugins if we are using a static build
@ -5967,6 +6042,10 @@ if [ "$CFG_OPENSSL" = "linked" ] && [ "$OPENSSL_LIBS" = "" ]; then
echo " OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked"
echo
fi
exec 1>&3 3>&- # restore stdout
cat $outpath/config.summary # display config feedback to user
if [ "$BUILD_ON_MAC" = "yes" ] && [ "$CFG_FRAMEWORK" = "yes" ] && [ "$CFG_DEBUG" = "yes" ] && [ "$CFG_DEBUG_RELEASE" = "no" ]; then
echo
echo "Error: debug-only framework builds are not supported. Configure with -no-framework"

View File

@ -30,7 +30,7 @@ QMAKE_LIBS_NIS = -lnsl
QMAKE_LIBS_EGL = -lEGL
QMAKE_LIBS_OPENGL = -lGL
QMAKE_LIBS_OPENGL_QT = -lGL
QMAKE_LIBS_OPENGL_ES1 = -lGLES_CM
QMAKE_LIBS_OPENGL_ES1 = -lGLESv1_CM
QMAKE_LIBS_OPENGL_ES2 = -lGLESv2
QMAKE_LIBS_OPENVG = -lOpenVG
QMAKE_LIBS_THREAD = -lpthread

View File

@ -7,10 +7,9 @@
#
# 1) -pipe is removed as it's on by default in qcc (and has an analogous -nopipe option)
# 2) -Wno-psabi is added to silence harmless warnings about va_list mangling
# 3) -fstack-protector -fstack-protector-all is added to enable stack smashing protection
#
QMAKE_CFLAGS += -Wno-psabi -fstack-protector -fstack-protector-all
QMAKE_CFLAGS += -Wno-psabi
QMAKE_CFLAGS_DEPS += -M
QMAKE_CFLAGS_WARN_ON += -Wall -W
QMAKE_CFLAGS_WARN_OFF += -w

View File

@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qeglfs_hooks.h"
#include "qeglfshooks.h"
#include <EGL/fbdev_window.h>
#include <stdio.h>
#include <sys/ioctl.h>
@ -48,20 +48,15 @@
#include <fcntl.h>
#include <linux/fb.h>
void QEglFSHooks::platformInit()
class QEglFS8726MHooks : public QEglFSHooks
{
}
public:
virtual QSize screenSize() const;
virtual EGLNativeWindowType createNativeWindow(const QSize &size);
virtual void destroyNativeWindow(EGLNativeWindowType window);
};
void QEglFSHooks::platformDestroy()
{
}
EGLNativeDisplayType QEglFSHooks::platformDisplay() const
{
return EGL_DEFAULT_DISPLAY;
}
QSize QEglFSHooks::screenSize() const
QSize QEglFS8726MHooks::screenSize() const
{
int fd = open("/dev/fb0", O_RDONLY);
if (fd == -1) {
@ -78,7 +73,7 @@ QSize QEglFSHooks::screenSize() const
return QSize(vinfo.xres, vinfo.yres);
}
EGLNativeWindowType QEglFSHooks::createNativeWindow(const QSize &size)
EGLNativeWindowType QEglFS8726MHooks::createNativeWindow(const QSize &size)
{
fbdev_window *window = new fbdev_window;
window->width = size.width();
@ -87,9 +82,11 @@ EGLNativeWindowType QEglFSHooks::createNativeWindow(const QSize &size)
return window;
}
void QEglFSHooks::destroyNativeWindow(EGLNativeWindowType window)
void QEglFS8726MHooks::destroyNativeWindow(EGLNativeWindowType window)
{
delete window;
}
QEglFSHooks platform_hooks;
QEglFS8726MHooks eglFS8726MHooks;
QEglFSHooks *platformHooks = &eglFS8726MHooks;

View File

@ -31,6 +31,6 @@ QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE
deviceSanityCheckCompiler()
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfs_hooks_8726m.cpp
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_8726m.cpp
load(qt_config)

View File

@ -0,0 +1,66 @@
#
# qmake configuration for building with arm-linux-uclibcgnueabi-g++
#
# http://wiki.qt-project.org/Devices/Shiner
#
MAKEFILE_GENERATOR = UNIX
TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl gdb_dwarf_index
QT += core gui
QMAKE_INCREMENTAL_STYLE = sublib
include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
load(device_config)
# Sanity checks
isEmpty(TRIDENT_SHINER_SDK_BUILDTREE): error("TRIDENT_SHINER_SDK_BUILDTREE needs to be set via -device-option TRIDENT_SHINER_SDK_BUILDTREE=<path>")
isEmpty(CROSS_COMPILE): error("CROSS_COMPILE needs to be set via -device-option CROSS_COMPILE=<path>")
isEmpty(TRIDENT_SHINER_SDK_BUILDSPEC): error("TRIDENT_SHINER_SDK_BUILDSPEC needs to be set via -device-option TRIDENT_SHINER_SDK_BUILDSPEC=<build spec>")
isEmpty(TRIDENT_SHINER_SDK_INCDIR_EGL_OPENGL_ES2): error("TRIDENT_SHINER_SDK_INCDIR_EGL_OPENGL_ES2 needs to be set via -device-option TRIDENT_SHINER_SDK_INCDIR_EGL_OPENGL_ES2=<path>")
isEmpty(TRIDENT_SHINER_SDK_LIBDIR_EGL_OPENGL_ES2): error("TRIDENT_SHINER_SDK_LIBDIR_EGL_OPENGL_ES2 needs to be set via -device-option TRIDENT_SHINER_SDK_LIBDIR_EGL_OPENGL_ES2=<path>")
QMAKE_CC = $${CROSS_COMPILE}gcc
QMAKE_CXX = $${CROSS_COMPILE}g++
QMAKE_LINK = $${CROSS_COMPILE}g++
QMAKE_LINK_SHLIB = $${CROSS_COMPILE}g++
#
# Usage configure options "-sysroot <sysroot path>" with "--prefix=<qt installation path>" results into installation of Qt at "<sysroot path><qt installation path>".
# Trident Shiner SDK expects all libs to be in "Application file system" which is not <sysroot path>
#
# Because of this fact not using "-sysroot <sysroot path>" and hence following code is required
#
QMAKE_CFLAGS += --sysroot=$${TRIDENT_SHINER_SDK_BUILDTREE}/open_source_archive/linux/toolchains/gcc-4.5.2_uclibc/
QMAKE_CXXFLAGS += --sysroot=$${TRIDENT_SHINER_SDK_BUILDTREE}/open_source_archive/linux/toolchains/gcc-4.5.2_uclibc/
QMAKE_LFLAGS += --sysroot=$${TRIDENT_SHINER_SDK_BUILDTREE}/open_source_archive/linux/toolchains/gcc-4.5.2_uclibc/
# Compiler Sanity check
deviceSanityCheckCompiler()
QMAKE_CFLAGS_RELEASE = -O2 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard
QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
# modifications to linux.conf
QMAKE_AR = $${CROSS_COMPILE}ar cqs
QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
QMAKE_STRIP = $${CROSS_COMPILE}strip
QMAKE_INCDIR += $${TRIDENT_SHINER_SDK_BUILDTREE}/target/output/objs/$${TRIDENT_SHINER_SDK_BUILDSPEC}/comps/generic_apps/usr/include
QMAKE_LIBDIR += $${TRIDENT_SHINER_SDK_BUILDTREE}/target/output/objs/$${TRIDENT_SHINER_SDK_BUILDSPEC}/comps/generic_apps/usr/lib
QMAKE_LIBDIR += $${TRIDENT_SHINER_SDK_BUILDTREE}/target/output/objs/$${TRIDENT_SHINER_SDK_BUILDSPEC}/comps/generated/lib/armgnu_linux_el_cortex-a9
QMAKE_INCDIR_EGL = $${TRIDENT_SHINER_SDK_INCDIR_EGL_OPENGL_ES2}
QMAKE_LIBDIR_EGL = $${TRIDENT_SHINER_SDK_LIBDIR_EGL_OPENGL_ES2}
QMAKE_INCDIR_OPENGL_ES2 = $${TRIDENT_SHINER_SDK_INCDIR_EGL_OPENGL_ES2}
QMAKE_LIBDIR_OPENGL_ES2 = $${TRIDENT_SHINER_SDK_LIBDIR_EGL_OPENGL_ES2}
QMAKE_LIBS_EGL = -lEGL -lIMGegl -lsrv_um -lusc
QMAKE_LIBS_OPENGL_ES2 = $$QMAKE_LIBS_EGL -lGLESv2 -lGLES_CM
load(qt_config)

View File

@ -0,0 +1,43 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the qmake spec 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$
**
****************************************************************************/
#include "../../linux-g++/qplatformdefs.h"

View File

@ -0,0 +1,71 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the qmake spec 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$
**
****************************************************************************/
#include "qdirectfbeglhooks.h"
#include "qdirectfbconvenience.h"
#include "default_directfb.h"
// Exported to the directfb plugin
QDirectFBEGLHooks platform_hook;
static void *dbpl_handle;
void QDirectFBEGLHooks::platformInit()
{
DBPL_RegisterDirectFBDisplayPlatform(&dbpl_handle, QDirectFbConvenience::dfbInterface());
}
void QDirectFBEGLHooks::platformDestroy()
{
DBPL_UnregisterDirectFBDisplayPlatform(&dbpl_handle);
dbpl_handle = 0;
}
bool QDirectFBEGLHooks::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case QPlatformIntegration::ThreadedOpenGL:
return true;
default:
return false;
}
}

View File

@ -55,11 +55,13 @@ QMAKE_LIBS_OPENGL_ES2 = -lv3ddriver -lrt
INCLUDEPATH += $${BRCM_APPLIBS_PATH}/opensource/zlib/zlib-1.2.3
QMAKE_LIBDIR += $${BRCM_APPLIBS_PATH}/opensource/zlib/zlib-1.2.3
# DirectFB, needs to be changed once -directfb is added to configure
DIRECTFB_INCLUDEPATH = $${BRCM_APPLIBS_PATH}/opensource/directfb/bin/DirectFB-1.4.15_multi_$${BRCM_BUILD_TYPE}_build.97425B1/usr/local/include/directfb $${BRCM_ROCKFORD_PATH}/middleware/platform/directfb
DIRECTFB_LIBS = -L$${BRCM_APPLIBS_PATH}/opensource/directfb/bin/DirectFB-1.4.15_multi_$${BRCM_BUILD_TYPE}_build.97425B1/usr/local/lib -L$${BRCM_ROCKFORD_PATH}/middleware/platform/directfb/lib_$${BRCM_PLATFORM}_$${BRCM_BUILD_TYPE} -ldirectfb -lfusion -ldirect -lpthread -lnexus -ldbpl -lz
QMAKE_LFLAGS += -Wl,-rpath-link,$$QMAKE_LIBDIR_OPENGL_ES2 -Wl,-rpath-link,$${BRCM_APPLIBS_PATH}/opensource/zlib/zlib-1.2.3
# DirectFB platform hooks for this hardware
QT_CONFIG += directfb_egl
DIRECTFB_PLATFORM_HOOKS_SOURCES = $$PWD/qdirectfbeglhooks_bcm97425.cpp
DIRECTFB_PLATFORM_HOOKS_INCLUDEPATH = $${BRCM_ROCKFORD_PATH}/middleware/platform/directfb
DIRECTFB_PLATFORM_HOOKS_LIBS = -ldbpl
DIRECTFB_PLATFORM_HOOKS_LIBDIR = $${BRCM_ROCKFORD_PATH}/middleware/platform/directfb/lib_$${BRCM_PLATFORM}_$${BRCM_BUILD_TYPE}
load(qt_config)

View File

@ -39,7 +39,7 @@
**
****************************************************************************/
#include "qeglfs_hooks.h"
#include "qeglfshooks.h"
#include <bcm_host.h>
@ -55,23 +55,35 @@
static DISPMANX_DISPLAY_HANDLE_T dispman_display = 0;
static DISPMANX_UPDATE_HANDLE_T dispman_update = 0;
void QEglFSHooks::platformInit()
class QEglFSPiHooks : public QEglFSHooks
{
public:
virtual void platformInit();
virtual void platformDestroy();
virtual EGLNativeDisplayType platformDisplay() const;
virtual QSize screenSize() const;
virtual EGLNativeWindowType createNativeWindow(const QSize &size);
virtual void destroyNativeWindow(EGLNativeWindowType window);
virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
};
void QEglFSPiHooks::platformInit()
{
bcm_host_init();
}
EGLNativeDisplayType QEglFSHooks::platformDisplay() const
EGLNativeDisplayType QEglFSPiHooks::platformDisplay() const
{
dispman_display = vc_dispmanx_display_open(0/* LCD */);
return EGL_DEFAULT_DISPLAY;
}
void QEglFSHooks::platformDestroy()
void QEglFSPiHooks::platformDestroy()
{
vc_dispmanx_display_close(dispman_display);
}
QSize QEglFSHooks::screenSize() const
QSize QEglFSPiHooks::screenSize() const
{
//both mechanisms work
#if 1
@ -98,7 +110,7 @@ QSize QEglFSHooks::screenSize() const
#endif
}
EGLNativeWindowType QEglFSHooks::createNativeWindow(const QSize &size)
EGLNativeWindowType QEglFSPiHooks::createNativeWindow(const QSize &size)
{
VC_RECT_T dst_rect;
dst_rect.x = 0;
@ -133,11 +145,25 @@ EGLNativeWindowType QEglFSHooks::createNativeWindow(const QSize &size)
return eglWindow;
}
void QEglFSHooks::destroyNativeWindow(EGLNativeWindowType window)
void QEglFSPiHooks::destroyNativeWindow(EGLNativeWindowType window)
{
EGL_DISPMANX_WINDOW_T *eglWindow = static_cast<EGL_DISPMANX_WINDOW_T *>(window);
vc_dispmanx_element_remove(dispman_update, eglWindow->element);
delete eglWindow;
}
QEglFSHooks platform_hooks;
bool QEglFSPiHooks::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case QPlatformIntegration::ThreadedPixmaps:
case QPlatformIntegration::OpenGL:
case QPlatformIntegration::ThreadedOpenGL:
case QPlatformIntegration::BufferQueueingOpenGL:
return true;
default:
return false;
}
}
QEglFSPiHooks eglFSPiHooks;
QEglFSHooks *platformHooks = &eglFSPiHooks;

View File

@ -48,7 +48,7 @@ QMAKE_CFLAGS_RELEASE += \
QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfs_hooks.cpp
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_pi.cpp
# Sanity check
deviceSanityCheckCompiler()

View File

@ -0,0 +1,35 @@
#
# qmake configuration for linux-g++ using the sh4-linux-g++ crosscompiler
#
# http://wiki.qt-project.org/Devices/ST7108
#
MAKEFILE_GENERATOR = UNIX
TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl gdb_dwarf_index
QT += core gui
QMAKE_INCREMENTAL_STYLE = sublib
include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
load(device_config)
isEmpty(CROSS_COMPILE): error("CROSS_COMPILE needs to be set via -device-option CROSS_COMPILE=<path>")
QMAKE_CC = $${CROSS_COMPILE}gcc
QMAKE_CXX = $${CROSS_COMPILE}g++
QMAKE_LINK = $${QMAKE_CXX}
QMAKE_LINK_SHLIB = $${QMAKE_CXX}
QMAKE_AR = $${CROSS_COMPILE}ar cqs
QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
QMAKE_STRIP = $${CROSS_COMPILE}strip
deviceSanityCheckCompiler()
QMAKE_LIBS_EGL += -lMali
load(qt_config)

View File

@ -0,0 +1,43 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the qmake spec 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$
**
****************************************************************************/
#include "../../linux-g++/qplatformdefs.h"

View File

@ -0,0 +1,47 @@
#
# qmake configuration for linux-g++ using the sh4-linux-g++ crosscompiler
#
# http://wiki.qt-project.org/Devices/ST7540
#
MAKEFILE_GENERATOR = UNIX
TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl gdb_dwarf_index
QT += core gui
QMAKE_INCREMENTAL_STYLE = sublib
include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
load(device_config)
isEmpty(CROSS_COMPILE): error("CROSS_COMPILE needs to be set via -device-option CROSS_COMPILE=<path>")
QMAKE_CC = $${CROSS_COMPILE}gcc
QMAKE_CXX = $${CROSS_COMPILE}g++
QMAKE_LINK = $${QMAKE_CXX}
QMAKE_LINK_SHLIB = $${QMAKE_CXX}
QMAKE_AR = $${CROSS_COMPILE}ar cqs
QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
QMAKE_STRIP = $${CROSS_COMPILE}strip
deviceSanityCheckCompiler()
QMAKE_INCDIR_EGL += $$[QT_SYSROOT]/root/modules/include/
QMAKE_LIBDIR_EGL += $$[QT_SYSROOT]/root/modules/
#
# The EGL library used for ST7540 is based on DirectFB so it has to be linked with
# 1. libdirectfb.so 2. libfusion.so 3. libdirect.so
#
QMAKE_LIBS_EGL += -lMali -ldirectfb -lfusion -ldirect
QMAKE_INCDIR_OPENGL_ES2 += $$QMAKE_INCDIR_EGL
QMAKE_LIBDIR_OPENGL_ES2 += $$QMAKE_LIBDIR_EGL
QMAKE_LIBS_OPENGL_ES2 += $$QMAKE_LIBS_EGL
load(qt_config)

View File

@ -0,0 +1,43 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the qmake spec 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$
**
****************************************************************************/
#include "../../linux-g++/qplatformdefs.h"

View File

@ -6,4 +6,7 @@ DEFINES += Q_OS_BLACKBERRY
CONFIG += blackberry
LIBS += -lbps
# Blackberry also has support for stack smashing protection in its libc
QMAKE_CFLAGS += -fstack-protector -fstack-protector-all
include(../qnx-armv7le-qcc/qmake.conf)

View File

@ -6,4 +6,7 @@ DEFINES += Q_OS_BLACKBERRY
CONFIG += blackberry
LIBS += -lbps
# Blackberry also has support for stack smashing protection in its libc
QMAKE_CFLAGS += -fstack-protector -fstack-protector-all
include(../qnx-x86-qcc/qmake.conf)

View File

@ -115,11 +115,13 @@ DotNET which_dotnet_version()
current_version = NET2002;
QStringList warnPath;
QHash<DotNET, QString> installPaths;
int installed = 0;
int i = 0;
for(; dotNetCombo[i].version; ++i) {
QString path = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey);
if(!path.isEmpty()) {
if (!path.isEmpty() && installPaths.value(dotNetCombo[i].version) != path) {
installPaths.insert(dotNetCombo[i].version, path);
++installed;
current_version = dotNetCombo[i].version;
warnPath += QString("%1").arg(dotNetCombo[i].versionStr);

View File

@ -179,7 +179,7 @@ XmlOutput& XmlOutput::operator<<(const xml_output& o)
break;
case tTagValue:
addRaw(QString("\n%1<%2>").arg(currentIndent).arg(o.xo_text));
addRaw(QString("%1").arg(o.xo_value));
addRaw(doConversion(o.xo_value));
addRaw(QString("</%1>").arg(o.xo_text));
break;
case tValueTag:

6
src/3rdparty/README vendored
View File

@ -15,9 +15,3 @@ library directory, following the latest clean version update commit.
The 'patches' subdirectory contains certain patches applied prior to
the start of the public git history, where the library has not been
updated since.
--
The pvr2d.h & wsegl.h in the powervr directory are required for building
the PowerVR plugin on Qt for Embedded Linux. These headers are for SGX
based SoCs, but may also work on MBX SoCs.

View File

@ -1,502 +0,0 @@
/*!****************************************************************************
@File pvr2d.h
@Title PVR2D external header file
@Author Imagination Technologies
@Copyright Copyright (c) by Imagination Technologies Limited.
This specification is protected by copyright laws and contains
material proprietary to Imagination Technologies Limited.
You may use and distribute this specification free of charge for implementing
the functionality therein, without altering or removing any trademark, copyright,
or other notice from the specification.
@Platform Generic
@Description PVR2D definitions for PVR2D clients
******************************************************************************/
/******************************************************************************
Modifications :-
$Log: pvr2d.h $
******************************************************************************/
#ifndef _PVR2D_H_
#define _PVR2D_H_
#ifdef __cplusplus
extern "C" {
#endif
/* PVR2D Platform-specific definitions */
#define PVR2D_EXPORT
#define PVR2D_IMPORT
#define PVR2D_REV_MAJOR 2
#define PVR2D_REV_MINOR 1
typedef enum
{
PVR2D_FALSE = 0,
PVR2D_TRUE
} PVR2D_BOOL;
/* error codes */
typedef enum
{
PVR2D_OK = 0,
PVR2DERROR_INVALID_PARAMETER = -1,
PVR2DERROR_DEVICE_UNAVAILABLE = -2,
PVR2DERROR_INVALID_CONTEXT = -3,
PVR2DERROR_MEMORY_UNAVAILABLE = -4,
PVR2DERROR_DEVICE_NOT_PRESENT = -5,
PVR2DERROR_IOCTL_ERROR = -6,
PVR2DERROR_GENERIC_ERROR = -7,
PVR2DERROR_BLT_NOTCOMPLETE = -8,
PVR2DERROR_HW_FEATURE_NOT_SUPPORTED = -9,
PVR2DERROR_NOT_YET_IMPLEMENTED = -10,
PVR2DERROR_MAPPING_FAILED = -11
}PVR2DERROR;
/* pixel formats */
typedef enum
{
PVR2D_1BPP = 0,
PVR2D_RGB565,
PVR2D_ARGB4444,
PVR2D_RGB888,
PVR2D_ARGB8888,
PVR2D_ARGB1555,
PVR2D_ALPHA8,
PVR2D_ALPHA4,
PVR2D_PAL2,
PVR2D_PAL4,
PVR2D_PAL8,
PVR2D_VGAEMU
}PVR2DFORMAT;
/* wrap surface type */
typedef enum
{
PVR2D_WRAPFLAG_NONCONTIGUOUS = 0,
PVR2D_WRAPFLAG_CONTIGUOUS = 1,
}PVR2DWRAPFLAGS;
/* flags for control information of additional blits */
typedef enum
{
PVR2D_BLIT_DISABLE_ALL = 0x0000, /* disable all additional controls */
PVR2D_BLIT_CK_ENABLE = 0x0001, /* enable colour key */
PVR2D_BLIT_GLOBAL_ALPHA_ENABLE = 0x0002, /* enable standard global alpha */
PVR2D_BLIT_PERPIXEL_ALPHABLEND_ENABLE = 0x0004, /* enable per-pixel alpha bleding */
PVR2D_BLIT_PAT_SURFACE_ENABLE = 0x0008, /* enable pattern surf (disable fill) */
PVR2D_BLIT_FULLY_SPECIFIED_ALPHA_ENABLE = 0x0010, /* enable fully specified alpha */
PVR2D_BLIT_ROT_90 = 0x0020, /* apply 90 degree rotation to the blt */
PVR2D_BLIT_ROT_180 = 0x0040, /* apply 180 degree rotation to the blt */
PVR2D_BLIT_ROT_270 = 0x0080, /* apply 270 degree rotation to the blt */
PVR2D_BLIT_COPYORDER_TL2BR = 0x0100, /* copy order overrides */
PVR2D_BLIT_COPYORDER_BR2TL = 0x0200,
PVR2D_BLIT_COPYORDER_TR2BL = 0x0400,
PVR2D_BLIT_COPYORDER_BL2TR = 0x0800,
PVR2D_BLIT_COLKEY_SOURCE = 0x1000, /* Key colour is on the source surface */
PVR2D_BLIT_COLKEY_DEST = 0x2000 /* Key colour is on the destination surface */
} PVR2DBLITFLAGS;
/* standard alpha-blending functions, AlphaBlendingFunc field of PVR2DBLTINFO */
typedef enum
{
PVR2D_ALPHA_OP_SRC_DSTINV = 1, /* source alpha : Cdst = Csrc*Asrc + Cdst*(1-Asrc) */
PVR2D_ALPHA_OP_SRCP_DSTINV = 2 /* premultiplied source alpha : Cdst = Csrc + Cdst*(1-Asrc) */
} PVR2D_ALPHABLENDFUNC;
/* blend ops for fully specified alpha */
typedef enum
{
PVR2D_BLEND_OP_ZERO = 0,
PVR2D_BLEND_OP_ONE = 1,
PVR2D_BLEND_OP_SRC = 2,
PVR2D_BLEND_OP_DST = 3,
PVR2D_BLEND_OP_GLOBAL = 4,
PVR2D_BLEND_OP_SRC_PLUS_GLOBAL = 5,
PVR2D_BLEND_OP_DST_PLUS_GLOBAL = 6
}PVR2D_BLEND_OP;
typedef void* PVR2D_HANDLE;
/* Fully specified alpha blend : pAlpha field of PVR2DBLTINFO structure */
/* a fully specified Alpha Blend operation is defined as */
/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (ALPHA_3 * DST (ALPHA)) */
/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (ALPHA_4 * DST (RGB)) */
/* if the pre-multiplication stage is enabled then the equations become the following: */
/* PRE_MUL = ((SRC(A)) * (Global Alpha Value)) */
/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (PRE_MUL * DST (ALPHA)) */
/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (PRE_MUL * DST (RGB)) */
/* if the transparent source alpha stage is enabled then a source alpha of zero forces the */
/* source to be transparent for that pixel regardless of the blend equation being used. */
typedef struct _PVR2D_ALPHABLT
{
PVR2D_BLEND_OP eAlpha1;
PVR2D_BOOL bAlpha1Invert;
PVR2D_BLEND_OP eAlpha2;
PVR2D_BOOL bAlpha2Invert;
PVR2D_BLEND_OP eAlpha3;
PVR2D_BOOL bAlpha3Invert;
PVR2D_BLEND_OP eAlpha4;
PVR2D_BOOL bAlpha4Invert;
PVR2D_BOOL bPremulAlpha; /* enable pre-multiplication stage */
PVR2D_BOOL bTransAlpha; /* enable transparent source alpha stage */
PVR2D_BOOL bUpdateAlphaLookup; /* enable and update the 1555-Lookup alpha table */
unsigned char uAlphaLookup0; /* 8 bit alpha when A=0 in a 1555-Lookup surface */
unsigned char uAlphaLookup1; /* 8 bit alpha when A=1 in a 1555-Lookup surface */
unsigned char uGlobalRGB; /* Global Alpha Value for RGB, 0=transparent 255=opaque */
unsigned char uGlobalA; /* Global Alpha Value for Alpha */
} PVR2D_ALPHABLT, *PPVR2D_ALPHABLT;
/* surface memory info structure */
typedef struct _PVR2DMEMINFO
{
void *pBase;
unsigned long ui32MemSize;
unsigned long ui32DevAddr;
unsigned long ulFlags;
void *hPrivateData;
void *hPrivateMapData;
}PVR2DMEMINFO, *PPVR2DMEMINFO;
#define PVR2D_MAX_DEVICE_NAME 20
typedef struct _PVR2DDEVICEINFO
{
unsigned long ulDevID;
char szDeviceName[PVR2D_MAX_DEVICE_NAME];
}PVR2DDEVICEINFO;
typedef struct _PVR2DISPLAYINFO
{
unsigned long ulMaxFlipChains;
unsigned long ulMaxBuffersInChain;
PVR2DFORMAT eFormat;
unsigned long ulWidth;
unsigned long ulHeight;
long lStride;
unsigned long ulMinFlipInterval;
unsigned long ulMaxFlipInterval;
}PVR2DDISPLAYINFO;
typedef struct _PVR2DBLTINFO
{
unsigned long CopyCode; /* rop code */
unsigned long Colour; /* fill colour */
unsigned long ColourKey; /* colour key */
unsigned char GlobalAlphaValue; /* global alpha blending */
unsigned char AlphaBlendingFunc; /* per-pixel alpha-blending function */
PVR2DBLITFLAGS BlitFlags; /* additional blit control information */
PVR2DMEMINFO *pDstMemInfo; /* destination memory */
unsigned long DstOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */
long DstStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */
long DstX, DstY; /* pixel offset from start of dest surface to start of blt rectangle */
long DSizeX,DSizeY; /* blt size */
PVR2DFORMAT DstFormat; /* dest format */
unsigned long DstSurfWidth; /* size of dest surface in pixels */
unsigned long DstSurfHeight; /* size of dest surface in pixels */
PVR2DMEMINFO *pSrcMemInfo; /* source mem, (source fields are also used for patterns) */
unsigned long SrcOffset; /* byte offset from start of allocation to src/pat surface pixel 0,0 */
long SrcStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */
long SrcX, SrcY; /* pixel offset from start of surface to start of source rectangle */
/* for patterns this is the start offset within the pattern */
long SizeX,SizeY; /* source rectangle size or pattern size in pixels */
PVR2DFORMAT SrcFormat; /* source/pattern format */
PVR2DMEMINFO *pPalMemInfo; /* source/pattern palette memory containing argb8888 colour table */
unsigned long PalOffset; /* byte offset from start of allocation to start of palette */
unsigned long SrcSurfWidth; /* size of source surface in pixels */
unsigned long SrcSurfHeight; /* size of source surface in pixels */
PVR2DMEMINFO *pMaskMemInfo; /* mask memory, 1bpp format implied */
unsigned long MaskOffset; /* byte offset from start of allocation to mask surface pixel 0,0 */
long MaskStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */
long MaskX, MaskY; /* mask rect top left (mask size = blt size) */
unsigned long MaskSurfWidth; /* size of mask surface in pixels */
unsigned long MaskSurfHeight; /* size of mask surface in pixels */
PPVR2D_ALPHABLT pAlpha; /* fully specified alpha blend */
}PVR2DBLTINFO, *PPVR2DBLTINFO;
typedef struct _PVR2DRECT
{
long left, top;
long right, bottom;
} PVR2DRECT;
typedef struct
{
PVR2DMEMINFO *pSurfMemInfo; /* surface memory */
unsigned long SurfOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */
long Stride; /* signed stride */
PVR2DFORMAT Format;
unsigned long SurfWidth; /* surface size in pixels */
unsigned long SurfHeight;
} PVR2D_SURFACE, *PPVR2D_SURFACE;
typedef struct
{
unsigned long *pUseCode; /* USSE code */
unsigned long UseCodeSize; /* usse code size in bytes */
} PVR2D_USECODE, *PPVR2D_USECODE;
typedef struct
{
PVR2D_SURFACE sDst; /* destination surface */
PVR2D_SURFACE sSrc; /* source surface */
PVR2DRECT rcDest; /* destination rectangle */
PVR2DRECT rcSource; /* source rectangle */
PVR2D_HANDLE hUseCode; /* custom USE code (NULL implies source copy) */
unsigned long UseParams[2]; /* per-blt params for use code */
} PVR2D_3DBLT, *PPVR2D_3DBLT;
#define MAKE_COPY_BLIT(src,soff,dest,doff,sx,sy,dx,dy,sz)
typedef void* PVR2DCONTEXTHANDLE;
typedef void* PVR2DFLIPCHAINHANDLE;
// CopyCode field of PVR2DBLTINFO structure:
// the CopyCode field of the PVR2DBLTINFO structure should contain a rop3 or rop4 code.
// a rop3 is an 8 bit code that describes a blt with three inputs : source dest and pattern
// rop4 is a 16 bit code that describes a blt with four inputs : source dest pattern and mask
// common rop3 codes are defined below
// a colour fill blt is processed in the pattern channel as a constant colour with a rop code of 0xF0
// PVR2D_BLIT_PAT_SURFACE_ENABLE defines whether the pattern channel is a surface or a fill colour.
// a rop4 is defined by two rop3 codes, and the 1 bit-per-pixel mask surface defines which is used.
// a common rop4 is 0xAAF0 which is the mask copy blt used for text glyphs.
// CopyCode is taken to be a rop4 when pMaskMemInfo is non zero, otherwise it is assumed to be a rop3
// use the PVR2DMASKROP4 macro below to construct a rop4 from two rop3's
// rop3a is the rop used when mask pixel = 1, and rop3b when mask = 0
#define PVR2DROP4(rop3b, rop3a) ((rop3b<<8)|rop3a)
/* common rop codes */
#define PVR2DROPclear 0x00 /* 0 (whiteness) */
#define PVR2DROPset 0xFF /* 1 (blackness) */
#define PVR2DROPnoop 0xAA /* dst (used for masked blts) */
/* source and dest rop codes */
#define PVR2DROPand 0x88 /* src AND dst */
#define PVR2DROPandReverse 0x44 /* src AND NOT dst */
#define PVR2DROPcopy 0xCC /* src (used for source copy and alpha blts) */
#define PVR2DROPandInverted 0x22 /* NOT src AND dst */
#define PVR2DROPxor 0x66 /* src XOR dst */
#define PVR2DROPor 0xEE /* src OR dst */
#define PVR2DROPnor 0x11 /* NOT src AND NOT dst */
#define PVR2DROPequiv 0x99 /* NOT src XOR dst */
#define PVR2DROPinvert 0x55 /* NOT dst */
#define PVR2DROPorReverse 0xDD /* src OR NOT dst */
#define PVR2DROPcopyInverted 0x33 /* NOT src */
#define PVR2DROPorInverted 0xBB /* NOT src OR dst */
#define PVR2DROPnand 0x77 /* NOT src OR NOT dst */
/* pattern rop codes */
#define PVR2DPATROPand 0xA0 /* pat AND dst */
#define PVR2DPATROPandReverse 0x50 /* pat AND NOT dst */
#define PVR2DPATROPcopy 0xF0 /* pat (used for solid color fills and pattern blts) */
#define PVR2DPATROPandInverted 0x0A /* NOT pat AND dst */
#define PVR2DPATROPxor 0x5A /* pat XOR dst */
#define PVR2DPATROPor 0xFA /* pat OR dst */
#define PVR2DPATROPnor 0x05 /* NOT pat AND NOT dst */
#define PVR2DPATROPequiv 0xA5 /* NOT pat XOR dst */
#define PVR2DPATROPinvert 0x55 /* NOT dst */
#define PVR2DPATROPorReverse 0xF5 /* pat OR NOT dst */
#define PVR2DPATROPcopyInverted 0x0F /* NOT pat */
#define PVR2DPATROPorInverted 0xAF /* NOT pat OR dst */
#define PVR2DPATROPnand 0x5F /* NOT pat OR NOT dst */
/* common rop4 codes */
#define PVR2DROP4MaskedCopy PVR2DROP4(PVR2DROPnoop,PVR2DROPcopy) /* masked source copy blt (used for rounded window corners etc) */
#define PVR2DROP4MaskedFill PVR2DROP4(PVR2DROPnoop,PVR2DPATROPcopy) /* masked colour fill blt (used for text) */
/* Legacy support */
#define PVR2DROP3_PATMASK PVR2DPATROPcopy
#define PVR2DROP3_SRCMASK PVR2DROPcopy
/* pixmap memory alignment */
#define PVR2D_ALIGNMENT_4 4 /* DWORD alignment */
#define PVR2D_ALIGNMENT_ANY 0 /* no alignment */
#define PVR2D_ALIGNMENT_PALETTE 16 /* 16 byte alignment is required for palettes */
/* Heap number for PVR2DGetFrameBuffer */
#define PVR2D_FB_PRIMARY_SURFACE 0
#define PVR2D_PRESENT_PROPERTY_SRCSTRIDE (1 << 0)
#define PVR2D_PRESENT_PROPERTY_DSTSIZE (1 << 1)
#define PVR2D_PRESENT_PROPERTY_DSTPOS (1 << 2)
#define PVR2D_PRESENT_PROPERTY_CLIPRECTS (1 << 3)
#define PVR2D_PRESENT_PROPERTY_INTERVAL (1 << 4)
#define PVR2D_CREATE_FLIPCHAIN_SHARED (1 << 0)
#define PVR2D_CREATE_FLIPCHAIN_QUERY (1 << 1)
/* Functions that the library exports */
PVR2D_IMPORT
int PVR2DEnumerateDevices(PVR2DDEVICEINFO *pDevInfo);
PVR2D_IMPORT
PVR2DERROR PVR2DCreateDeviceContext(unsigned long ulDevID,
PVR2DCONTEXTHANDLE* phContext,
unsigned long ulFlags);
PVR2D_IMPORT
PVR2DERROR PVR2DDestroyDeviceContext(PVR2DCONTEXTHANDLE hContext);
PVR2D_IMPORT
PVR2DERROR PVR2DGetDeviceInfo(PVR2DCONTEXTHANDLE hContext,
PVR2DDISPLAYINFO *pDisplayInfo);
PVR2D_IMPORT
PVR2DERROR PVR2DGetScreenMode(PVR2DCONTEXTHANDLE hContext,
PVR2DFORMAT *pFormat,
long *plWidth,
long *plHeight,
long *plStride,
int *piRefreshRate);
PVR2D_IMPORT
PVR2DERROR PVR2DGetFrameBuffer(PVR2DCONTEXTHANDLE hContext,
int nHeap,
PVR2DMEMINFO **ppsMemInfo);
PVR2D_IMPORT
PVR2DERROR PVR2DMemAlloc(PVR2DCONTEXTHANDLE hContext,
unsigned long ulBytes,
unsigned long ulAlign,
unsigned long ulFlags,
PVR2DMEMINFO **ppsMemInfo);
PVR2D_IMPORT
PVR2DERROR PVR2DMemWrap(PVR2DCONTEXTHANDLE hContext,
void *pMem,
unsigned long ulFlags,
unsigned long ulBytes,
unsigned long alPageAddress[],
PVR2DMEMINFO **ppsMemInfo);
PVR2D_IMPORT
PVR2DERROR PVR2DMemMap(PVR2DCONTEXTHANDLE hContext,
unsigned long ulFlags,
void *hPrivateMapData,
PVR2DMEMINFO **ppsDstMem);
PVR2D_IMPORT
PVR2DERROR PVR2DMemFree(PVR2DCONTEXTHANDLE hContext,
PVR2DMEMINFO *psMemInfo);
PVR2D_IMPORT
PVR2DERROR PVR2DBlt(PVR2DCONTEXTHANDLE hContext,
PVR2DBLTINFO *pBltInfo);
PVR2D_IMPORT
PVR2DERROR PVR2DBltClipped(PVR2DCONTEXTHANDLE hContext,
PVR2DBLTINFO *pBltInfo,
unsigned long ulNumClipRects,
PVR2DRECT *pClipRects);
PVR2D_IMPORT
PVR2DERROR PVR2DQueryBlitsComplete(PVR2DCONTEXTHANDLE hContext,
PVR2DMEMINFO *pMemInfo,
unsigned int uiWaitForComplete);
PVR2D_IMPORT
PVR2DERROR PVR2DSetPresentBltProperties(PVR2DCONTEXTHANDLE hContext,
unsigned long ulPropertyMask,
long lSrcStride,
unsigned long ulDstWidth,
unsigned long ulDstHeight,
long lDstXPos,
long lDstYPos,
unsigned long ulNumClipRects,
PVR2DRECT *pClipRects,
unsigned long ulSwapInterval);
PVR2D_IMPORT
PVR2DERROR PVR2DPresentBlt(PVR2DCONTEXTHANDLE hContext,
PVR2DMEMINFO *pMemInfo,
long lRenderID);
PVR2D_IMPORT
PVR2DERROR PVR2DCreateFlipChain(PVR2DCONTEXTHANDLE hContext,
unsigned long ulFlags,
unsigned long ulNumBuffers,
unsigned long ulWidth,
unsigned long ulHeight,
PVR2DFORMAT eFormat,
long *plStride,
unsigned long *pulFlipChainID,
PVR2DFLIPCHAINHANDLE *phFlipChain);
PVR2D_IMPORT
PVR2DERROR PVR2DDestroyFlipChain(PVR2DCONTEXTHANDLE hContext,
PVR2DFLIPCHAINHANDLE hFlipChain);
PVR2D_IMPORT
PVR2DERROR PVR2DGetFlipChainBuffers(PVR2DCONTEXTHANDLE hContext,
PVR2DFLIPCHAINHANDLE hFlipChain,
unsigned long *pulNumBuffers,
PVR2DMEMINFO *psMemInfo[]);
PVR2D_IMPORT
PVR2DERROR PVR2DSetPresentFlipProperties(PVR2DCONTEXTHANDLE hContext,
PVR2DFLIPCHAINHANDLE hFlipChain,
unsigned long ulPropertyMask,
long lDstXPos,
long lDstYPos,
unsigned long ulNumClipRects,
PVR2DRECT *pClipRects,
unsigned long ulSwapInterval);
PVR2D_IMPORT
PVR2DERROR PVR2DPresentFlip(PVR2DCONTEXTHANDLE hContext,
PVR2DFLIPCHAINHANDLE hFlipChain,
PVR2DMEMINFO *psMemInfo,
long lRenderID);
PVR2D_IMPORT
PVR2DERROR PVR2DGetAPIRev(long *lRevMajor, long *lRevMinor);
PVR2D_IMPORT
PVR2DERROR PVR2DLoadUseCode (const PVR2DCONTEXTHANDLE hContext, const unsigned char *pUseCode,
const unsigned long UseCodeSize, PVR2D_HANDLE *pUseCodeHandle);
PVR2D_IMPORT
PVR2DERROR PVR2DFreeUseCode (const PVR2DCONTEXTHANDLE hContext, const PVR2D_HANDLE hUseCodeHandle);
PVR2D_IMPORT
PVR2DERROR PVR2DBlt3D (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT pBlt3D);
#ifdef __cplusplus
}
#endif
#endif /* _PVR2D_H_ */
/******************************************************************************
End of file (pvr2d.h)
******************************************************************************/

View File

@ -1,240 +0,0 @@
/******************************************************************************
Name : wsegl.h
Copyright : Copyright (c) Imagination Technologies Limited.
This specification is protected by copyright laws and contains
material proprietary to Imagination Technologies Limited.
You may use and distribute this specification free of charge for implementing
the functionality therein, without altering or removing any trademark, copyright,
or other notice from the specification.
Platform : ANSI
*****************************************************************************/
#if !defined(__WSEGL_H__)
#define __WSEGL_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
// WSEGL Platform-specific definitions
*/
#define WSEGL_EXPORT
#define WSEGL_IMPORT
/*
// WSEGL API Version Number
*/
#define WSEGL_VERSION 1
#define WSEGL_DEFAULT_DISPLAY 0
#define WSEGL_DEFAULT_NATIVE_ENGINE 0
#define WSEGL_FALSE 0
#define WSEGL_TRUE 1
#define WSEGL_NULL 0
#define WSEGL_UNREFERENCED_PARAMETER(param) (param) = (param)
/*
// WSEGL handles
*/
typedef void *WSEGLDisplayHandle;
typedef void *WSEGLDrawableHandle;
/*
// Display capability type
*/
typedef enum WSEGLCapsType_TAG
{
WSEGL_NO_CAPS = 0,
WSEGL_CAP_MIN_SWAP_INTERVAL = 1, /* System default value = 1 */
WSEGL_CAP_MAX_SWAP_INTERVAL = 2, /* System default value = 1 */
WSEGL_CAP_WINDOWS_USE_HW_SYNC = 3, /* System default value = 0 (FALSE) */
WSEGL_CAP_PIXMAPS_USE_HW_SYNC = 4, /* System default value = 0 (FALSE) */
} WSEGLCapsType;
/*
// Display capability
*/
typedef struct WSEGLCaps_TAG
{
WSEGLCapsType eCapsType;
unsigned long ui32CapsValue;
} WSEGLCaps;
/*
// Drawable type
*/
#define WSEGL_NO_DRAWABLE 0x0
#define WSEGL_DRAWABLE_WINDOW 0x1
#define WSEGL_DRAWABLE_PIXMAP 0x2
/*
// Pixel format of display/drawable
*/
typedef enum WSEGLPixelFormat_TAG
{
WSEGL_PIXELFORMAT_565 = 0,
WSEGL_PIXELFORMAT_4444 = 1,
WSEGL_PIXELFORMAT_8888 = 2,
WSEGL_PIXELFORMAT_1555 = 3
} WSEGLPixelFormat;
/*
// Transparent of display/drawable
*/
typedef enum WSEGLTransparentType_TAG
{
WSEGL_OPAQUE = 0,
WSEGL_COLOR_KEY = 1,
} WSEGLTransparentType;
/*
// Display/drawable configuration
*/
typedef struct WSEGLConfig_TAG
{
/*
// Type of drawables this configuration applies to -
// OR'd values of drawable types.
*/
unsigned long ui32DrawableType;
/* Pixel format */
WSEGLPixelFormat ePixelFormat;
/* Native Renderable - set to WSEGL_TRUE if native renderable */
unsigned long ulNativeRenderable;
/* FrameBuffer Level Parameter */
unsigned long ulFrameBufferLevel;
/* Native Visual ID */
unsigned long ulNativeVisualID;
/* Native Visual */
void *hNativeVisual;
/* Transparent Type */
WSEGLTransparentType eTransparentType;
/* Transparent Color - only used if transparent type is COLOR_KEY */
unsigned long ulTransparentColor; /* packed as 0x00RRGGBB */
} WSEGLConfig;
/*
// WSEGL errors
*/
typedef enum WSEGLError_TAG
{
WSEGL_SUCCESS = 0,
WSEGL_CANNOT_INITIALISE = 1,
WSEGL_BAD_NATIVE_DISPLAY = 2,
WSEGL_BAD_NATIVE_WINDOW = 3,
WSEGL_BAD_NATIVE_PIXMAP = 4,
WSEGL_BAD_NATIVE_ENGINE = 5,
WSEGL_BAD_DRAWABLE = 6,
WSEGL_BAD_CONFIG = 7,
WSEGL_OUT_OF_MEMORY = 8
} WSEGLError;
/*
// Drawable orientation (in degrees anti-clockwise)
*/
typedef enum WSEGLRotationAngle_TAG
{
WSEGL_ROTATE_0 = 0,
WSEGL_ROTATE_90 = 1,
WSEGL_ROTATE_180 = 2,
WSEGL_ROTATE_270 = 3
} WSEGLRotationAngle;
/*
// Drawable information required by OpenGL-ES driver
*/
typedef struct WSEGLDrawableParams_TAG
{
/* Width in pixels of the drawable */
unsigned long ui32Width;
/* Height in pixels of the drawable */
unsigned long ui32Height;
/* Stride in pixels of the drawable */
unsigned long ui32Stride;
/* Pixel format of the drawable */
WSEGLPixelFormat ePixelFormat;
/* User space cpu virtual address of the drawable */
void *pvLinearAddress;
/* HW address of the drawable */
unsigned long ui32HWAddress;
/* Private data for the drawable */
void *hPrivateData;
} WSEGLDrawableParams;
/*
// Table of function pointers that is returned by WSEGL_GetFunctionTablePointer()
//
// The first entry in the table is the version number of the wsegl.h header file that
// the module has been written against, and should therefore be set to WSEGL_VERSION
*/
typedef struct WSEGL_FunctionTable_TAG
{
unsigned long ui32WSEGLVersion;
WSEGLError (*pfnWSEGL_IsDisplayValid)(NativeDisplayType);
WSEGLError (*pfnWSEGL_InitialiseDisplay)(NativeDisplayType, WSEGLDisplayHandle *, const WSEGLCaps **, WSEGLConfig **);
WSEGLError (*pfnWSEGL_CloseDisplay)(WSEGLDisplayHandle);
WSEGLError (*pfnWSEGL_CreateWindowDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativeWindowType, WSEGLRotationAngle *);
WSEGLError (*pfnWSEGL_CreatePixmapDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativePixmapType, WSEGLRotationAngle *);
WSEGLError (*pfnWSEGL_DeleteDrawable)(WSEGLDrawableHandle);
WSEGLError (*pfnWSEGL_SwapDrawable)(WSEGLDrawableHandle, unsigned long);
WSEGLError (*pfnWSEGL_SwapControlInterval)(WSEGLDrawableHandle, unsigned long);
WSEGLError (*pfnWSEGL_WaitNative)(WSEGLDrawableHandle, unsigned long);
WSEGLError (*pfnWSEGL_CopyFromDrawable)(WSEGLDrawableHandle, NativePixmapType);
WSEGLError (*pfnWSEGL_CopyFromPBuffer)(void *, unsigned long, unsigned long, unsigned long, WSEGLPixelFormat, NativePixmapType);
WSEGLError (*pfnWSEGL_GetDrawableParameters)(WSEGLDrawableHandle, WSEGLDrawableParams *, WSEGLDrawableParams *);
} WSEGL_FunctionTable;
WSEGL_IMPORT const WSEGL_FunctionTable *WSEGL_GetFunctionTablePointer(void);
#ifdef __cplusplus
}
#endif
#endif /* __WSEGL_H__ */
/******************************************************************************
End of file (wsegl.h)
******************************************************************************/

View File

@ -1,4 +1,5 @@
CONFIG(release, debug|release):DEFINES *= NDEBUG
DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE
!contains(CONFIG, largefile):DEFINES += SQLITE_DISABLE_LFS
INCLUDEPATH += $$PWD/sqlite
SOURCES += $$PWD/sqlite/sqlite3.c

View File

@ -58,7 +58,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4)
// U+FDEF (inclusive)
return (ucs4 & 0xfffe) == 0xfffe
|| (ucs4 - 0xfdd0U) < 16;
|| (ucs4 - 0xfdd0U) < 32;
}
QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state)
@ -127,7 +127,7 @@ QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::Conve
continue;
}
if (u > 0xffff) {
if (QChar::requiresSurrogates(u)) {
*cursor++ = 0xf0 | ((uchar) (u >> 18));
*cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f);
} else {
@ -196,7 +196,7 @@ QString QUtf8::convertToUnicode(const char *chars, int len, QTextCodec::Converte
bool nonCharacter;
if (!headerdone && uc == 0xfeff) {
// don't do anything, just skip the BOM
} else if (!(nonCharacter = isUnicodeNonCharacter(uc)) && uc > 0xffff && uc < 0x110000) {
} else if (!(nonCharacter = isUnicodeNonCharacter(uc)) && QChar::requiresSurrogates(uc) && uc < 0x110000) {
// surrogate pair
Q_ASSERT((qch - (ushort*)result.unicode()) + 2 < result.length());
*qch++ = QChar::highSurrogate(uc);
@ -487,7 +487,7 @@ QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::Convert
}
}
uint code = (endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple);
if (code >= 0x10000) {
if (QChar::requiresSurrogates(code)) {
*qch++ = QChar::highSurrogate(code);
*qch++ = QChar::lowSurrogate(code);
} else {

View File

@ -13,7 +13,8 @@ HEADERS += \
global/qtypeinfo.h \
global/qsysinfo.h \
global/qisenum.h \
global/qtypetraits.h
global/qtypetraits.h \
global/qflags.h
SOURCES += \
global/qglobal.cpp \

View File

@ -157,9 +157,11 @@
# define Q_UNREACHABLE() __builtin_unreachable()
# else
/* Plain GCC */
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
# define Q_ASSUME(expr) if (expr){} else __builtin_unreachable()
# define Q_UNREACHABLE() __builtin_unreachable()
# endif
# endif
# define Q_ALIGNOF(type) __alignof__(type)
# define Q_TYPEOF(expr) __typeof__(expr)

139
src/corelib/global/qflags.h Normal file
View File

@ -0,0 +1,139 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the QtCore 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 QFLAGS_H
#define QFLAGS_H
#include <QtCore/qglobal.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QFlag
{
int i;
public:
inline QFlag(int i);
inline operator int() const { return i; }
};
inline QFlag::QFlag(int ai) : i(ai) {}
class QIncompatibleFlag
{
int i;
public:
inline explicit QIncompatibleFlag(int i);
inline operator int() const { return i; }
};
inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
#ifndef Q_NO_TYPESAFE_FLAGS
template<typename Enum>
class QFlags
{
typedef void **Zero;
int i;
public:
typedef Enum enum_type;
// compiler-generated copy/move ctor/assignment operators are fine!
#ifdef qdoc
inline QFlags(const QFlags &other);
inline QFlags &operator=(const QFlags &other);
#endif
Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
inline QFlags(QFlag f) : i(f) {}
inline QFlags &operator&=(int mask) { i &= mask; return *this; }
inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
inline QFlags &operator|=(Enum f) { i |= f; return *this; }
inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
Q_DECL_CONSTEXPR inline operator int() const { return i; }
Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); }
Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); }
Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); }
Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); }
Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); }
Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); }
Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); }
Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); }
Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
};
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef QFlags<Enum> Flags;
#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
{ return QIncompatibleFlag(int(f1) | f2); }
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
{ return QFlags<Flags::enum_type>(f1) | f2; } \
Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
{ return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
#else /* Q_NO_TYPESAFE_FLAGS */
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef uint Flags;
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
#endif /* Q_NO_TYPESAFE_FLAGS */
QT_END_NAMESPACE
QT_END_HEADER
#endif // QFLAGS_H

View File

@ -1711,6 +1711,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
winver = QSysInfo::WV_VISTA;
} else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) {
winver = QSysInfo::WV_WINDOWS7;
} else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) {
winver = QSysInfo::WV_WINDOWS8;
} else {
qWarning("Qt: Untested Windows version %d.%d detected!",
int(osver.dwMajorVersion), int(osver.dwMinorVersion));
@ -1742,6 +1744,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
winver = QSysInfo::WV_VISTA;
else if (override == "WINDOWS7")
winver = QSysInfo::WV_WINDOWS7;
else if (override == "WINDOWS8")
winver = QSysInfo::WV_WINDOWS8;
}
#endif
@ -2511,7 +2515,9 @@ int qrand()
\list
\li \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old
data) type with no constructor or destructor.
data) type with no constructor or destructor, or else a type where
every bit pattern is a valid object and memcpy() creates a valid
independent copy of the object.
\li \c Q_MOVABLE_TYPE specifies that \a Type has a constructor
and/or a destructor but can be moved in memory using \c
memcpy().
@ -2524,6 +2530,11 @@ int qrand()
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 38
An example of a non-POD "primitive" type is QUuid: Even though
QUuid has constructors (and therefore isn't POD), every bit
pattern still represents a valid object, and memcpy() can be used
to create a valid independent copy of a QUuid object.
Example of a movable type:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 39

View File

@ -1231,90 +1231,6 @@ Q_CORE_EXPORT void qFreeAligned(void *ptr);
# endif
#endif
class Q_CORE_EXPORT QFlag
{
int i;
public:
inline QFlag(int i);
inline operator int() const { return i; }
};
inline QFlag::QFlag(int ai) : i(ai) {}
class Q_CORE_EXPORT QIncompatibleFlag
{
int i;
public:
inline explicit QIncompatibleFlag(int i);
inline operator int() const { return i; }
};
inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
#ifndef Q_NO_TYPESAFE_FLAGS
template<typename Enum>
class QFlags
{
typedef void **Zero;
int i;
public:
typedef Enum enum_type;
// compiler-generated copy/move ctor/assignment operators are fine!
#ifdef qdoc
inline QFlags(const QFlags &other);
inline QFlags &operator=(const QFlags &other);
#endif
Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
inline QFlags(QFlag f) : i(f) {}
inline QFlags &operator&=(int mask) { i &= mask; return *this; }
inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
inline QFlags &operator|=(Enum f) { i |= f; return *this; }
inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
Q_DECL_CONSTEXPR inline operator int() const { return i; }
Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); }
Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); }
Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); }
Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); }
Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); }
Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); }
Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); }
Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); }
Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
};
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef QFlags<Enum> Flags;
#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
{ return QIncompatibleFlag(int(f1) | f2); }
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
{ return QFlags<Flags::enum_type>(f1) | f2; } \
Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
{ return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
#else /* Q_NO_TYPESAFE_FLAGS */
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef uint Flags;
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
#endif /* Q_NO_TYPESAFE_FLAGS */
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
/* make use of typeof-extension */
template <typename T>
@ -1495,7 +1411,7 @@ QT_END_HEADER
// qDebug and friends
#include <QtCore/qlogging.h>
#include <QtCore/qflags.h>
#include <QtCore/qsysinfo.h>
#include <QtCore/qtypeinfo.h>

View File

@ -88,7 +88,7 @@ public:
#endif
SettingsPath = 100
};
static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path()
static QString location(LibraryLocation); // ### Qt 6: consider renaming it to path()
#ifdef QT_BUILD_QMAKE
static QString rawLocation(LibraryLocation);
#endif

View File

@ -153,7 +153,7 @@ public:
NoButton = 0x00000000,
LeftButton = 0x00000001,
RightButton = 0x00000002,
MidButton = 0x00000004, // ### Qt 5: remove me
MidButton = 0x00000004, // ### Qt 6: remove me
MiddleButton = MidButton,
XButton1 = 0x00000008,
BackButton = XButton1,

View File

@ -96,6 +96,7 @@ public:
WV_2003 = 0x0040,
WV_VISTA = 0x0080,
WV_WINDOWS7 = 0x0090,
WV_WINDOWS8 = 0x00a0,
WV_NT_based = 0x00f0,
/* version numbers */
@ -105,6 +106,7 @@ public:
WV_5_2 = WV_2003,
WV_6_0 = WV_VISTA,
WV_6_1 = WV_WINDOWS7,
WV_6_2 = WV_WINDOWS8,
WV_CE = 0x0100,
WV_CENET = 0x0200,

View File

@ -113,9 +113,15 @@ win32 {
SOURCES += io/qsettings_mac.cpp
}
macx-*: {
contains(QT_CONFIG, coreservices) {
SOURCES += io/qstandardpaths_mac.cpp
} else {
SOURCES += io/qstandardpaths_unix.cpp
}
} else:standardpathsjson {
SOURCES += io/qstandardpaths_json.cpp
} else:blackberry {
SOURCES += io/qstandardpaths_blackberry.cpp
} else {
SOURCES += io/qstandardpaths_unix.cpp
}

View File

@ -830,7 +830,7 @@ QString QFileInfo::suffix() const
QDir QFileInfo::dir() const
{
Q_D(const QFileInfo);
// ### Qt5: Maybe rename this to parentDirectory(), considering what it actually do?
// ### Qt 6: Maybe rename this to parentDirectory(), considering what it actually does?
return QDir(d->fileEntry.path());
}

View File

@ -102,7 +102,7 @@ public:
virtual bool open(OpenMode mode);
virtual void close();
// ### Qt 5: pos() and seek() should not be virtual, and
// ### Qt 6: pos() and seek() should not be virtual, and
// ### seek() should call a virtual seekData() function.
virtual qint64 pos() const;
virtual qint64 size() const;

View File

@ -772,7 +772,8 @@ static pid_t doSpawn(int fd_count, int fd_map[], char **argv, char **envp,
qWarning("ThreadCtl(): cannot hold threads: %s", qPrintable(qt_error_string(errno)));
oldWorkingDir = QT_GETCWD(buff, PATH_MAX + 1);
QT_CHDIR(workingDir);
if (QT_CHDIR(workingDir) == -1)
qWarning("ThreadCtl(): failed to chdir to %s", workingDir);
}
pid_t childPid;
@ -783,7 +784,8 @@ static pid_t doSpawn(int fd_count, int fd_map[], char **argv, char **envp,
}
if (oldWorkingDir) {
QT_CHDIR(oldWorkingDir);
if (QT_CHDIR(oldWorkingDir) == -1)
qWarning("ThreadCtl(): failed to chdir to %s", oldWorkingDir);
if (ThreadCtl(_NTO_TCTL_THREADS_CONT, 0) == -1)
qFatal("ThreadCtl(): cannot resume threads: %s", qPrintable(qt_error_string(errno)));
@ -853,8 +855,10 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv
qt_safe_close(childStartedPipe[0]);
// enter the working directory
if (workingDir)
QT_CHDIR(workingDir);
if (workingDir) {
if (QT_CHDIR(workingDir) == -1)
qWarning("QProcessPrivate::execChild() failed to chdir to %s", workingDir);
}
// this is a virtual call, and it base behavior is to do nothing.
q->setupChildProcess();
@ -1372,8 +1376,10 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
if (doubleForkPid == 0) {
qt_safe_close(pidPipe[1]);
if (!encodedWorkingDirectory.isEmpty())
QT_CHDIR(encodedWorkingDirectory.constData());
if (!encodedWorkingDirectory.isEmpty()) {
if (QT_CHDIR(encodedWorkingDirectory.constData()) == -1)
qWarning("QProcessPrivate::startDetached: failed to chdir to %s", encodedWorkingDirectory.constData());
}
char **argv = new char *[arguments.size() + 2];
for (int i = 0; i < arguments.size(); ++i) {
@ -1426,7 +1432,8 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
qt_safe_close(startedPipe[1]);
qt_safe_write(pidPipe[1], (const char *)&doubleForkPid, sizeof(pid_t));
QT_CHDIR("/");
if (QT_CHDIR("/") == -1)
qWarning("QProcessPrivate::startDetached: failed to chdir to /");
::_exit(1);
}

View File

@ -173,8 +173,8 @@ public:
static void setDefaultFormat(Format format);
static Format defaultFormat();
static void setSystemIniPath(const QString &dir); // ### remove in 5.0 (use setPath() instead)
static void setUserIniPath(const QString &dir); // ### remove in 5.0 (use setPath() instead)
static void setSystemIniPath(const QString &dir); // ### Qt 6: remove (use setPath() instead)
static void setUserIniPath(const QString &dir); // ### Qt 6: remove (use setPath() instead)
static void setPath(Format format, Scope scope, const QString &path);
typedef QMap<QString, QVariant> SettingsMap;

View File

@ -0,0 +1,103 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
** Contact: http://www.qt-project.org/
**
** 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$
**
****************************************************************************/
#include "qstandardpaths.h"
#include <qdir.h>
#ifndef QT_NO_STANDARDPATHS
QT_BEGIN_NAMESPACE
QString QStandardPaths::writableLocation(StandardLocation type)
{
QDir sharedDir = QDir::home();
sharedDir.cd(QLatin1String("../shared"));
const QString sharedRoot = sharedDir.absolutePath();
switch (type) {
case DataLocation:
case DesktopLocation:
case HomeLocation:
return QDir::homePath();
case RuntimeLocation:
case TempLocation:
return QDir::tempPath();
case CacheLocation:
case GenericCacheLocation:
return QDir::homePath() + QLatin1String("/Cache");
case ConfigLocation:
return QDir::homePath() + QLatin1String("/Settings");
case GenericDataLocation:
return sharedRoot + QLatin1String("/misc");
case DocumentsLocation:
return sharedRoot + QLatin1String("/documents");
case PicturesLocation:
return sharedRoot + QLatin1String("/photos");
case FontsLocation:
// this is not a writable location
return QString();
case MusicLocation:
return sharedRoot + QLatin1String("/music");
case MoviesLocation:
return sharedRoot + QLatin1String("/videos");
case DownloadLocation:
return sharedRoot + QLatin1String("/downloads");
case ApplicationsLocation:
return QString();
default:
break;
}
return QString();
}
QStringList QStandardPaths::standardLocations(StandardLocation type)
{
if (type == FontsLocation)
return QStringList(QLatin1String("/base/usr/fonts"));
return QStringList(writableLocation(type));
}
QT_END_NAMESPACE
#endif // QT_NO_STANDARDPATHS

View File

@ -87,6 +87,8 @@ QJsonArray::QJsonArray()
QJsonArray::QJsonArray(QJsonPrivate::Data *data, QJsonPrivate::Array *array)
: d(data), a(array)
{
Q_ASSERT(data);
Q_ASSERT(array);
d->ref.ref();
}

View File

@ -731,7 +731,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4)
// U+FDEF (inclusive)
return (ucs4 & 0xfffe) == 0xfffe
|| (ucs4 - 0xfdd0U) < 16;
|| (ucs4 - 0xfdd0U) < 32;
}
static inline bool scanUtf8Char(const char *&json, const char *end, uint *result)
@ -769,9 +769,10 @@ static inline bool scanUtf8Char(const char *&json, const char *end, uint *result
uc = (uc << 6) | (ch & 0x3f);
}
if (isUnicodeNonCharacter(uc) || uc >= 0x110000 ||
(uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff))
if (uc < min_uc || isUnicodeNonCharacter(uc) ||
(uc >= 0xd800 && uc <= 0xdfff) || uc >= 0x110000) {
return false;
}
*result = uc;
return true;
@ -850,7 +851,7 @@ bool Parser::parseString(bool *latin1)
return false;
}
}
if (ch > 0xffff) {
if (QChar::requiresSurrogates(ch)) {
int pos = reserveSpace(4);
*(QJsonPrivate::qle_ushort *)(data + pos) = QChar::highSurrogate(ch);
*(QJsonPrivate::qle_ushort *)(data + pos + 2) = QChar::lowSurrogate(ch);

View File

@ -449,9 +449,17 @@ bool QJsonValue::operator==(const QJsonValue &other) const
case String:
return toString() == other.toString();
case Array:
if (base == other.base)
return true;
if (!base || !other.base)
return false;
return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base))
== QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base));
case Object:
if (base == other.base)
return true;
if (!base || !other.base)
return false;
return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base))
== QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base));
}

View File

@ -61,7 +61,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4)
// U+FDEF (inclusive)
return (ucs4 & 0xfffe) == 0xfffe
|| (ucs4 - 0xfdd0U) < 16;
|| (ucs4 - 0xfdd0U) < 32;
}
static inline uchar hexdig(uint u)
@ -160,7 +160,7 @@ static QByteArray escapedString(const QString &s)
continue;
}
if (u > 0xffff) {
if (QChar::requiresSurrogates(u)) {
*cursor++ = 0xf0 | ((uchar) (u >> 18));
*cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f);
} else {

View File

@ -202,6 +202,7 @@ QT_BEGIN_NAMESPACE
\value OkRequest Ok button in decoration pressed. Supported only for Windows CE.
\value TabletEnterProximity Wacom tablet enter proximity event (QTabletEvent), sent to QApplication.
\value TabletLeaveProximity Wacom tablet leave proximity event (QTabletEvent), sent to QApplication.
\value ThreadChange The object is moved to another thread. This is the last event sent to this object in the previous thread. See QObject::moveToThread().
\value Timer Regular timer events (QTimerEvent).
\value ToolBarChange The toolbar button is toggled on Mac OS X.
\value ToolTip A tooltip was requested (QHelpEvent).
@ -264,7 +265,6 @@ QT_BEGIN_NAMESPACE
\omitvalue ShowWindowRequest
\omitvalue Speech
\omitvalue Style
\omitvalue ThreadChange
\omitvalue ZeroTimerEvent
\omitvalue ApplicationActivated
\omitvalue ApplicationDeactivated

View File

@ -3949,8 +3949,8 @@ void qDeleteInEventHandler(QObject *o)
}
/*!
\fn QMetaObject::Connection QObject::connect(const QObject *sender, (T::*signal)(...), const QObject *receiver, (T::*method)(...), Qt::ConnectionType type)
\fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
\overload connect()
\threadsafe
Creates a connection of the given \a type from the \a signal in
@ -4006,18 +4006,14 @@ void qDeleteInEventHandler(QObject *o)
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 25
make sure to declare the argument type with Q_DECLARE_METATYPE
A signal is emitted for every connection you make;
two signals are emitted for duplicate connections.
This overload does not support the type Qt::UniqueConnection
*/
/*!
\fn QMetaObject::Connection QObject::connect(const QObject *sender, (T::*signal)(...), Functor functor)
\fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
\threadsafe
\overload
\overload connect()
Creates a connection of the given \a type from the \a signal in
the \a sender object to the \a functor and returns a handle to the connection
@ -4166,9 +4162,9 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
return true;
}
/*! \fn bool QObject::disconnect(const QObject *sender, (T::*signal)(...), const Qbject *receiver, (T::*method)(...))
/*! \fn bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
\overload diconnect()
\threadsafe
\overload
Disconnects \a signal in object \a sender from \a method in object
\a receiver. Returns true if the connection is successfully broken;
@ -4225,6 +4221,7 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
\sa connect()
*/
bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject)
{
if (sender == 0 || (receiver == 0 && slot != 0)) {
@ -4286,7 +4283,7 @@ QMetaObject::Connection::~Connection()
}
/*!
\fn bool QMetaObject::Connection::operator bool()
\fn QMetaObject::Connection::operator bool() const
Returns true if the connection is valid.

View File

@ -221,8 +221,8 @@ public:
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
#ifdef Q_QDOC
QMetaObject::Connection QObject::connect(const QObject *sender, (T::*signal)(...), const QObject *receiver, (T::*method)(...), Qt::ConnectionType type)
QMetaObject::Connection QObject::connect(const QObject *sender, (T::*signal)(...), Functor functor)
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type);
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
#else
//Connect a signal to a pointer to qobject member function
template <typename Func1, typename Func2>
@ -301,7 +301,7 @@ public:
static bool disconnect(const QMetaObject::Connection &);
#ifdef Q_QDOC
bool QObject::disconnect(const QObject *sender, (T::*signal)(...), const Qbject *receiver, (T::*method)(...))
static bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method);
#else
template <typename Func1, typename Func2>
static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,

View File

@ -465,7 +465,7 @@ public:
Connection();
Connection(const Connection &other);
Connection &operator=(const Connection &other);
#ifdef qdoc
#ifdef Q_QDOC
operator bool() const;
#else
typedef void *Connection::*RestrictedBool;

View File

@ -555,13 +555,8 @@ void qt_eval_init_widget(QWidget *w)
{
if (qt_eval_days_left() == -2)
return;
if (w->isTopLevel()) {
QString windowTitle = w->windowTitle();
if (windowTitle.isEmpty()) {
if (w->isTopLevel() && w->windowTitle().isEmpty() && w->windowType() != Qt::Desktop ) {
w->setWindowTitle(QLatin1String(" "));
} else if (!windowTitle.startsWith(qt_eval_title_prefix())) {
qt_eval_adapt_window_title(windowTitle);
}
}
}
#endif

View File

@ -366,7 +366,7 @@ public:
QByteArray &setNum(qulonglong, int base = 10);
QByteArray &setNum(float, char f = 'g', int prec = 6);
QByteArray &setNum(double, char f = 'g', int prec = 6);
QByteArray &setRawData(const char *a, uint n); // ### Qt 5: use an int
QByteArray &setRawData(const char *a, uint n); // ### Qt 6: use an int
static QByteArray number(int, int base = 10);
static QByteArray number(uint, int base = 10);

View File

@ -50,19 +50,12 @@
#include "qchar.h"
#include "qdatastream.h"
#include "qtextcodec.h"
#include "qunicodetables_p.h"
#include "qunicodetables.cpp"
QT_BEGIN_NAMESPACE
#ifndef QT_NO_CODEC_FOR_C_STRINGS
# ifdef QT_NO_TEXTCODEC
# define QT_NO_CODEC_FOR_C_STRINGS
# endif
#endif
#define FLAG(x) (1 << (x))
/*!
@ -71,8 +64,7 @@ QT_BEGIN_NAMESPACE
\ingroup string-processing
This class is only useful to avoid the codec for C strings business
in the QChar(ch) constructor. You can avoid it by writing QChar(ch, 0).
This class is only useful to construct a QChar with 8-bit character.
\sa QChar, QLatin1String, QString
*/
@ -565,17 +557,24 @@ bool QChar::isLetter(ushort ucs2)
}
/*!
\fn bool QChar::isNumber() const
Returns true if the character is a number (Number_* categories,
not just 0-9); otherwise returns false.
\sa isDigit()
*/
bool QChar::isNumber() const
/*!
\internal
\overload
*/
bool QChar::isNumber(ushort ucs2)
{
const int test = FLAG(Number_DecimalDigit) |
FLAG(Number_Letter) |
FLAG(Number_Other);
return FLAG(qGetProp(ucs)->category) & test;
return FLAG(qGetProp(ucs2)->category) & test;
}
/*!
@ -725,7 +724,7 @@ int QChar::digitValue(ushort ucs2)
int QChar::digitValue(uint ucs4)
{
if (ucs4 > UNICODE_LAST_CODEPOINT)
return 0;
return -1;
return qGetProp(ucs4)->digitValue;
}
@ -1239,9 +1238,23 @@ ushort QChar::toCaseFolded(ushort ucs2)
Returns the Latin-1 character equivalent to the QChar, or 0. This
is mainly useful for non-internationalized software.
\note It is not possible to distinguish a non-Latin-1 character from a Latin-1 0
(NUL) character. Prefer to use unicode(), which does not have this ambiguity.
\sa toAscii(), unicode()
*/
/*!
\fn QChar QChar::fromLatin1(char)
Converts the Latin-1 character \a c to its equivalent QChar. This
is mainly useful for non-internationalized software.
An alternative is to use QLatin1Char.
\sa fromAscii(), unicode()
*/
/*!
\fn char QChar::toAscii() const
@ -1255,6 +1268,9 @@ ushort QChar::toCaseFolded(ushort ucs2)
\note It is not possible to distinguish a non-Latin 1 character from an ASCII 0
(NUL) character. Prefer to use unicode(), which does not have this ambiguity.
\note This function does not check whether the character value is inside
the valid range of US-ASCII.
\sa toLatin1(), unicode()
*/
@ -1308,7 +1324,7 @@ QDataStream &operator>>(QDataStream &in, QChar &chr)
/*!
\fn ushort QChar::unicode() const
\overload
Returns the numeric Unicode value of the QChar.
*/
/*****************************************************************************

View File

@ -233,35 +233,31 @@ public:
bool isPrint() const;
bool isPunct() const;
inline bool isSpace() const {
// note that [0x09..0x0d] + 0x85 are exceptional Cc-s and must be handled explicitly
return ucs == 0x20 || (ucs <= 0x0D && ucs >= 0x09)
|| (ucs > 127 && (ucs == 0x0085 || isSpace(ucs)));
|| (ucs > 127 && (ucs == 0x85 || ucs == 0xa0 || isSpace(ucs)));
}
bool isMark() const;
inline bool isLetter() const {
return (ucs >= 'a' && ucs <= 'z')
|| (ucs <= 'Z' && ucs >= 'A')
return (ucs >= 'A' && ucs <= 'z' && (ucs >= 'a' || ucs <= 'Z'))
|| (ucs > 127 && isLetter(ucs));
}
bool isNumber() const;
inline bool isNumber() const
{ return (ucs <= '9' && ucs >= '0') || (ucs > 127 && isNumber(ucs)); }
inline bool isLetterOrNumber() const
{
return (ucs >= 'a' && ucs <= 'z')
|| (ucs <= 'Z' && ucs >= 'A')
|| (ucs <= '9' && ucs >= '0')
return (ucs >= 'A' && ucs <= 'z' && (ucs >= 'a' || ucs <= 'Z'))
|| (ucs >= '0' && ucs <= '9')
|| (ucs > 127 && isLetterOrNumber(ucs));
}
inline bool isDigit() const
{ return (ucs <= '9' && ucs >= '0') || (ucs > 127 && isDigit(ucs)); }
bool isSymbol() const;
inline bool isLower() const {
return (ucs >= 'a' && ucs <= 'z')
|| (ucs > 127 && category(ucs) == Letter_Lowercase);
}
inline bool isUpper() const {
return (ucs <= 'Z' && ucs >= 'A')
|| (ucs > 127 && category(ucs) == Letter_Uppercase);
}
inline bool isTitleCase() const { return category() == Letter_Titlecase; }
inline bool isLower() const
{ return (ucs <= 'z' && ucs >= 'a') || (ucs > 127 && category() == Letter_Lowercase); }
inline bool isUpper() const
{ return (ucs <= 'Z' && ucs >= 'A') || (ucs > 127 && category() == Letter_Uppercase); }
inline bool isTitleCase() const { return ucs > 127 && category() == Letter_Titlecase; }
inline bool isHighSurrogate() const {
return ((ucs & 0xfc00) == 0xd800);
@ -331,6 +327,7 @@ public:
private:
static bool QT_FASTCALL isDigit(ushort ucs2);
static bool QT_FASTCALL isLetter(ushort ucs2);
static bool QT_FASTCALL isNumber(ushort ucs2);
static bool QT_FASTCALL isLetterOrNumber(ushort ucs2);
static bool QT_FASTCALL isSpace(ushort ucs2);

View File

@ -245,7 +245,7 @@ public:
QLineF unitVector() const;
Q_DECL_CONSTEXPR inline QLineF normalVector() const;
// ### Qt 5: rename intersects() or intersection() and rename IntersectType IntersectionType
// ### Qt 6: rename intersects() or intersection() and rename IntersectType IntersectionType
IntersectType intersect(const QLineF &l, QPointF *intersectionPoint) const;
qreal angle(const QLineF &l) const;

View File

@ -288,7 +288,7 @@ QT_BEGIN_NAMESPACE
Partial matching is mainly useful in two scenarios: validating user input
in real time and incremental/multi-segment matching.
\target
\target validating user input
\section2 Validating user input
Suppose that we would like the user to input a date in a specific
@ -796,6 +796,7 @@ struct QRegularExpressionPrivate : QSharedData
int offset,
QRegularExpression::MatchType matchType,
QRegularExpression::MatchOptions matchOptions,
bool checkSubjectString = true,
const QRegularExpressionMatchPrivate *previous = 0) const;
int captureIndexForName(const QString &name) const;
@ -1165,7 +1166,8 @@ static int pcre16SafeExec(const pcre16 *code, const pcre16_extra *extra,
Performs a match of type \a matchType on the given \a subject string with
options \a matchOptions and returns the QRegularExpressionMatchPrivate of
the result. It also advances a match if a previous result is given as \a
previous.
previous. The \a subject string goes a Unicode validity check if
\a checkSubjectString is true (PCRE doesn't like illegal UTF-16 sequences).
Advancing a match is a tricky algorithm. If the previous match matched a
non-empty string, we just do an ordinary match at the offset position.
@ -1182,6 +1184,7 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString
int offset,
QRegularExpression::MatchType matchType,
QRegularExpression::MatchOptions matchOptions,
bool checkSubjectString,
const QRegularExpressionMatchPrivate *previous) const
{
if (offset < 0)
@ -1211,6 +1214,9 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString
else if (matchType == QRegularExpression::PartialPreferFirstMatch)
pcreOptions |= PCRE_PARTIAL_HARD;
if (!checkSubjectString)
pcreOptions |= PCRE_NO_UTF16_CHECK;
bool previousMatchWasEmpty = false;
if (previous && previous->hasMatch &&
(previous->capturedOffsets.at(0) == previous->capturedOffsets.at(1))) {
@ -1318,10 +1324,15 @@ QRegularExpressionMatch QRegularExpressionMatchPrivate::nextMatch() const
Q_ASSERT(isValid);
Q_ASSERT(hasMatch || hasPartialMatch);
// Note the "false" passed for the check of the subject string:
// if we're advancing a match on the same subject,
// then that subject was already checked at least once (when this object
// was created, or when the object that created this one was created, etc.)
QRegularExpressionMatchPrivate *nextPrivate = regularExpression.d->doMatch(subject,
capturedOffsets.at(1),
matchType,
matchOptions,
false,
this);
return QRegularExpressionMatch(*nextPrivate);
}

View File

@ -6538,8 +6538,8 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::
return;
if (version == QChar::Unicode_Unassigned) {
version = UNICODE_DATA_VERSION;
} else if (version != UNICODE_DATA_VERSION) {
version = QChar::currentUnicodeVersion();
} else if (int(version) <= NormalizationCorrectionsVersionMax) {
const QString &s = *data;
QChar *d = 0;
for (int i = 0; i < NumNormalizationCorrections; ++i) {

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,7 @@
#include <qvariant.h>
#include <qvector.h>
#include <qbuffer.h>
#include <qmath.h>
#include <private/qsimd_p.h>
#include <stdio.h> // jpeglib needs this to be pre-included
@ -321,27 +322,31 @@ static bool read_jpeg_image(QImage *outImage,
}
// Determine the scale factor to pass to libjpeg for quick downscaling.
if (!scaledSize.isEmpty()) {
if (!scaledSize.isEmpty() && info->image_width && info->image_height) {
if (clipRect.isEmpty()) {
info->scale_denom =
qMin(info->image_width / scaledSize.width(),
info->image_height / scaledSize.height());
} else {
info->scale_denom =
qMin(clipRect.width() / scaledSize.width(),
clipRect.height() / scaledSize.height());
}
if (info->scale_denom < 2) {
info->scale_denom = 1;
} else if (info->scale_denom < 4) {
info->scale_denom = 2;
} else if (info->scale_denom < 8) {
info->scale_denom = 4;
} else {
double f = qMin(double(info->image_width) / scaledSize.width(),
double(info->image_height) / scaledSize.height());
// libjpeg supports M/8 scaling with M=[1,16]. All downscaling factors
// are a speed improvement, but upscaling during decode is slower.
info->scale_num = qBound(1, qCeil(8/f), 8);
info->scale_denom = 8;
} else {
info->scale_denom = qMin(clipRect.width() / scaledSize.width(),
clipRect.height() / scaledSize.height());
// Only scale by powers of two when clipping so we can
// keep the exact pixel boundaries
if (info->scale_denom < 2)
info->scale_denom = 1;
else if (info->scale_denom < 4)
info->scale_denom = 2;
else if (info->scale_denom < 8)
info->scale_denom = 4;
else
info->scale_denom = 8;
}
info->scale_num = 1;
if (!clipRect.isEmpty()) {
// Correct the scale factor so that we clip accurately.
// It is recommended that the clip rectangle be aligned
// on an 8-pixel boundary for best performance.

View File

@ -151,7 +151,7 @@ void QRasterPlatformPixmap::fromImageReader(QImageReader *imageReader,
createPixmapForImage(image, flags, /* inplace = */true);
}
// from qwindowsurface.cpp
// from qbackingstore.cpp
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
void QRasterPlatformPixmap::copy(const QPlatformPixmap *data, const QRect &rect)

View File

@ -114,7 +114,6 @@ enum ApplicationResourceFlags
static unsigned applicationResourceFlags = 0;
QString *QGuiApplicationPrivate::platform_name = 0;
bool QGuiApplicationPrivate::app_do_modal = false;
QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette
@ -380,6 +379,132 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags
application_type = QCoreApplication::GuiClient;
}
/*!
Returns the most recently shown modal window. If no modal windows are
visible, this function returns zero.
A modal window is a window which has its
\l{QWindow::windowModality}{windowModality} property set to Qt::WindowModal
or Qt::ApplicationModal. A modal window must be closed before the user can
continue with other parts of the program.
Modal window are organized in a stack. This function returns the modal
window at the top of the stack.
\sa Qt::WindowModality, QWindow::setWindowModality()
*/
QWindow *QGuiApplication::modalWindow()
{
if (QGuiApplicationPrivate::self->modalWindowList.isEmpty())
return 0;
return QGuiApplicationPrivate::self->modalWindowList.first();
}
void QGuiApplicationPrivate::showModalWindow(QWindow *window)
{
self->modalWindowList.prepend(window);
QEvent e(QEvent::WindowBlocked);
QWindowList windows = QGuiApplication::topLevelWindows();
for (int i = 0; i < windows.count(); ++i) {
QWindow *window = windows.at(i);
if (!window->d_func()->blockedByModalWindow && window->windowType() != Qt::Tool && self->isWindowBlocked(window)) {
window->d_func()->blockedByModalWindow = true;
QGuiApplication::sendEvent(window, &e);
}
}
}
void QGuiApplicationPrivate::hideModalWindow(QWindow *window)
{
self->modalWindowList.removeAll(window);
QEvent e(QEvent::WindowUnblocked);
QWindowList windows = QGuiApplication::topLevelWindows();
for (int i = 0; i < windows.count(); ++i) {
QWindow *window = windows.at(i);
if (window->d_func()->blockedByModalWindow && window->windowType() != Qt::Tool && !self->isWindowBlocked(window)) {
window->d_func()->blockedByModalWindow = false;
QGuiApplication::sendEvent(window, &e);
}
}
}
/*
Returns true if \a window is blocked by a modal window. If \a
blockingWindow is non-zero, *blockingWindow will be set to the blocking
window (or to zero if \a window is not blocked).
*/
bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const
{
QWindow *unused = 0;
if (!blockingWindow)
blockingWindow = &unused;
if (modalWindowList.isEmpty()) {
*blockingWindow = 0;
return false;
}
for (int i = 0; i < modalWindowList.count(); ++i) {
QWindow *modalWindow = modalWindowList.at(i);
{
// check if the modal window is our window or a (transient) parent of our window
QWindow *w = window;
while (w) {
if (w == modalWindow) {
*blockingWindow = 0;
return false;
}
QWindow *p = w->parent();
if (!p)
p = w->transientParent();
w = p;
}
}
Qt::WindowModality windowModality = modalWindow->windowModality();
switch (windowModality) {
case Qt::ApplicationModal:
{
if (modalWindow != window) {
*blockingWindow = modalWindow;
return true;
}
break;
}
case Qt::WindowModal:
{
QWindow *w = window;
do {
QWindow *m = modalWindow;
do {
if (m == w) {
*blockingWindow = m;
return true;
}
QWindow *p = m->parent();
if (!p)
p = m->transientParent();
m = p;
} while (m);
QWindow *p = w->parent();
if (!p)
p = w->transientParent();
w = p;
} while (w);
break;
}
default:
Q_ASSERT_X(false, "QGuiApplication", "internal error, a modal widget cannot be modeless");
break;
}
}
*blockingWindow = 0;
return false;
}
/*!
Returns the QWindow that receives events tied to focus,
such as key events.
@ -1049,6 +1174,11 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
}
if (window) {
if (window->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow mouse events through
return;
}
QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers);
ev.setTimestamp(e->timestamp);
#ifndef QT_NO_CURSOR
@ -1111,6 +1241,11 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
QWindow *window = e->window.data();
if (window) {
if (window->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow wheel events through
return;
}
QWheelEvent ev(e->localPos, e->globalPos, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, buttons, e->modifiers);
ev.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(window, &ev);
@ -1128,6 +1263,10 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
window = QGuiApplication::activeWindow();
if (!window)
return;
if (window->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow key events through
return;
}
QKeyEvent ev(e->keyType, e->key, e->modifiers,
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers,
@ -1140,6 +1279,10 @@ void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::En
{
if (!e->enter)
return;
if (e->enter.data()->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow enter events through
return;
}
QEvent event(QEvent::Enter);
QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event);
@ -1149,6 +1292,10 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le
{
if (!e->leave)
return;
if (e->leave.data()->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow leave events through
return;
}
QEvent event(QEvent::Leave);
QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event);
@ -1263,6 +1410,10 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl
{
if (e->window.isNull())
return;
if (e->window.data()->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow close events through
return;
}
QCloseEvent event;
QGuiApplication::sendSpontaneousEvent(e->window.data(), &event);
@ -1451,6 +1602,11 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
break;
}
if (w->d_func()->blockedByModalWindow) {
// a modal window is blocking this window, don't allow touch events through
continue;
}
QTouchEvent touchEvent(eventType,
e->device,
e->modifiers,

View File

@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QGUIAPPLICATION_QPA_H
#define QGUIAPPLICATION_QPA_H
#ifndef QGUIAPPLICATION_H
#define QGUIAPPLICATION_H
#include <QtCore/qcoreapplication.h>
#include <QtGui/qwindowdefs.h>
@ -88,6 +88,8 @@ public:
static QString platformName();
static QWindow *modalWindow();
#ifdef QT_DEPRECATED
static QT_DEPRECATED QWindow *activeWindow() { return focusWindow(); }
#endif
@ -168,4 +170,4 @@ QT_END_NAMESPACE
QT_END_HEADER
#endif // QGUIAPPLICATION_QPA_H
#endif // QGUIAPPLICATION_H

View File

@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QGUIAPPLICATION_QPA_P_H
#define QGUIAPPLICATION_QPA_P_H
#ifndef QGUIAPPLICATION_P_H
#define QGUIAPPLICATION_P_H
#include <QtGui/qguiapplication.h>
@ -147,7 +147,11 @@ public:
static QGuiApplicationPrivate *instance() { return self; }
static QString *platform_name;
static bool app_do_modal;
QWindowList modalWindowList;
static void showModalWindow(QWindow *window);
static void hideModalWindow(QWindow *window);
virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const;
static Qt::MouseButtons buttons;
static ulong mousePressTime;
@ -226,4 +230,4 @@ QT_END_NAMESPACE
QT_END_HEADER
#endif // QGUIAPPLICATION_QPA_P_H
#endif // QGUIAPPLICATION_P_H

View File

@ -55,14 +55,14 @@
#endif
#include "qvariant.h"
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
#include <QtCore/private/qcore_mac_p.h>
#include <Carbon/Carbon.h>
#endif
QT_BEGIN_NAMESPACE
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
static bool qt_sequence_no_mnemonics = true;
struct MacSpecialKey {
int key;
@ -966,7 +966,7 @@ QKeySequence::QKeySequence(const QKeySequence& keysequence)
d->ref.ref();
}
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
static inline int maybeSwapShortcut(int shortcut)
{
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
@ -998,7 +998,7 @@ QList<QKeySequence> QKeySequence::keyBindings(StandardKey key)
QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i];
if (keyBinding.standardKey == key && (keyBinding.platform & platform)) {
uint shortcut =
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
maybeSwapShortcut(QKeySequencePrivate::keyBindings[i].shortcut);
#else
QKeySequencePrivate::keyBindings[i].shortcut;
@ -1200,7 +1200,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
if (nativeText) {
gmodifs = globalModifs();
if (gmodifs->isEmpty()) {
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
if (dontSwap)
*gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode));
@ -1240,7 +1240,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
modifs += *gmodifs; // Test non-translated ones last
QString sl = accel;
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
for (int i = 0; i < modifs.size(); ++i) {
const QModifKeyName &mkf = modifs.at(i);
if (sl.contains(mkf.name)) {
@ -1292,7 +1292,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
int fnum = 0;
if (accel.length() == 1) {
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
int qtKey = qtkeyForMacSymbol(accel[0]);
if (qtKey != -1) {
ret |= qtKey;
@ -1371,7 +1371,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
if (key == -1 || key == Qt::Key_unknown)
return s;
#if defined(Q_OS_MAC)
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
if (nativeText) {
// On Mac OS X the order (by default) is Meta, Alt, Shift, Control.
// If the AA_MacDontSwapCtrlAndMeta is enabled, then the order
@ -1427,7 +1427,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
: QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1);
} else if (key) {
int i=0;
#if defined(Q_OS_MAC)
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
if (nativeText) {
QChar ch = qt_macSymbolForQtKey(key);
if (!ch.isNull())
@ -1437,7 +1437,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
} else
#endif
{
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
NonSymbol:
#endif
while (keyname[i].name) {
@ -1463,7 +1463,7 @@ NonSymbol:
}
}
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
if (nativeText)
s += p;
else

View File

@ -51,9 +51,11 @@
#include <QtGui/QSurfaceFormat>
#ifdef __GLEW_H__
#if defined(Q_CC_GNU)
#warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
#warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h
#endif
#endif
#include <QtGui/qopengl.h>

View File

@ -38,8 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGRAPHICSSYSTEMCURSOR_H
#define QGRAPHICSSYSTEMCURSOR_H
#ifndef QPLATFORMCURSOR_QPA_H
#define QPLATFORMCURSOR_QPA_H
#include <QtCore/QList>
#include <QtGui/QImage>
@ -60,7 +60,7 @@ public:
QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
{ set(data, mask, width, height, hotX, hotY); }
QImage * image() { return &cursorImage; }
QPoint hotspot() { return hot; }
QPoint hotspot() const { return hot; }
void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
void set(const QImage &image, int hx, int hy);
void set(Qt::CursorShape);
@ -97,4 +97,4 @@ QT_END_NAMESPACE
QT_END_HEADER
#endif // QGRAPHICSSYSTEMCURSOR_H
#endif // QPLATFORMCURSOR_QPA_H

View File

@ -329,7 +329,7 @@ bool QPlatformWindow::setMouseGrabEnabled(bool grab)
However, it is not concerned with how Qt renders into the window it represents.
Visible QWindows will always have a QPlatformWindow. However, it is not necessary for
all windows to have a QWindowSurface. This is the case for QOpenGLWidget. And could be the case for
all windows to have a QBackingStore. This is the case for QOpenGLWidget. And could be the case for
windows where some 3.party renders into it.
The platform specific window handle can be retrieved by the winId function.
@ -340,7 +340,7 @@ bool QPlatformWindow::setMouseGrabEnabled(bool grab)
The only way to retrieve a QPlatformOpenGLContext in QPA is by calling the glContext() function
on QPlatformWindow.
\sa QWindowSurface, QWindow
\sa QBackingStore, QWindow
*/
QT_END_NAMESPACE

View File

@ -88,7 +88,9 @@ QSurface::QSurface(SurfaceClass type)
{
}
QSurface::~QSurface()
{
}
QSurface::SurfaceClass QSurface::surfaceClass() const
{

View File

@ -193,10 +193,6 @@ QWindow::~QWindow()
destroy();
}
QSurface::~QSurface()
{
}
/*!
Set the \a surfaceType of the window.
@ -253,6 +249,13 @@ void QWindow::setVisible(bool visible)
QGuiApplication::sendEvent(this, &showEvent);
}
if (isModal()) {
if (visible)
QGuiApplicationPrivate::showModalWindow(this);
else
QGuiApplicationPrivate::hideModalWindow(this);
}
d->platformWindow->setVisible(visible);
if (!visible) {
@ -1396,7 +1399,7 @@ void QWindow::resizeEvent(QResizeEvent *ev)
/*!
Override this to handle show events.
The show event is called when the window has requested becoming visible.
The function is called when the window has requested becoming visible.
If the window is successfully shown by the windowing system, this will
be followed by a resize and an expose event.
@ -1409,7 +1412,7 @@ void QWindow::showEvent(QShowEvent *ev)
/*!
Override this to handle hide evens.
The hide event is called when the window has requested being hidden in the
The function is called when the window has requested being hidden in the
windowing system.
*/
void QWindow::hideEvent(QHideEvent *ev)

View File

@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QWINDOW_QPA_H
#define QWINDOW_QPA_H
#ifndef QWINDOW_H
#define QWINDOW_H
#include <QtCore/QObject>
#include <QtCore/QEvent>
@ -249,7 +249,6 @@ public Q_SLOTS:
}
Q_SIGNALS:
void backBufferReady();
void screenChanged(QScreen *screen);
void windowModalityChanged(Qt::WindowModality windowModality);
@ -306,4 +305,4 @@ QT_END_NAMESPACE
QT_END_HEADER
#endif // QWINDOW_QPA_H
#endif // QWINDOW_H

View File

@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QWINDOW_QPA_P_H
#define QWINDOW_QPA_P_H
#ifndef QWINDOW_P_H
#define QWINDOW_P_H
#include <QtGui/qwindow.h>
#include <QtGui/qplatformwindow_qpa.h>
@ -81,6 +81,7 @@ public:
, windowOrientation(Qt::PrimaryOrientation)
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
, modality(Qt::NonModal)
, blockedByModalWindow(false)
, transientParent(0)
, screen(0)
{
@ -123,6 +124,8 @@ public:
QSize sizeIncrement;
Qt::WindowModality modality;
bool blockedByModalWindow;
QPointer<QWindow> transientParent;
QScreen *screen;
};
@ -132,4 +135,4 @@ QT_END_NAMESPACE
QT_END_HEADER
#endif // QWINDOW_QPA_P_H
#endif // QWINDOW_P_H

View File

@ -45,9 +45,11 @@
#ifndef QT_NO_OPENGL
#ifdef __GLEW_H__
#if defined(Q_CC_GNU)
#warning qopenglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
#warning To use GLEW with Qt, do not include <qopengl.h> or <QOpenGLFunctions> after glew.h
#endif
#endif
#include <QtGui/qopengl.h>
#include <QtGui/qopenglcontext.h>

View File

@ -53,7 +53,6 @@ SOURCES += \
painting/qoutlinemapper.cpp \
painting/qpagedpaintdevice.cpp \
painting/qpaintdevice.cpp \
painting/qpaintdevice_qpa.cpp \
painting/qpaintengine.cpp \
painting/qpaintengineex.cpp \
painting/qpainter.cpp \

View File

@ -2260,7 +2260,7 @@ QColor QColor::light(int factor) const
QColor hsv = toHsv();
int s = hsv.ct.ahsv.saturation;
int v = hsv.ct.ahsv.value;
uint v = hsv.ct.ahsv.value;
v = (factor*v)/100;
if (v > USHRT_MAX) {

View File

@ -44,6 +44,7 @@
#include "qmatrix.h"
#include "qregion.h"
#include "qpainterpath.h"
#include "qpainterpath_p.h"
#include "qvariant.h"
#include <qmath.h>

View File

@ -76,4 +76,20 @@ Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice
return device->metric(metric);
}
int QPaintDevice::metric(PaintDeviceMetric m) const
{
qWarning("QPaintDevice::metrics: Device has no metric information");
if (m == PdmDpiX) {
return 72;
} else if (m == PdmDpiY) {
return 72;
} else if (m == PdmNumColors) {
// FIXME: does this need to be a real value?
return 256;
} else {
qDebug("Unrecognised metric %d!",m);
return 0;
}
}
QT_END_NAMESPACE

View File

@ -150,7 +150,6 @@ public:
virtual void beginNativePainting() {}
virtual void endNativePainting() {}
// ### Qt5: remove, once QtGui is merged into QtGui and QtWidgets
// Return a pixmap filter of "type" that can render the parameters
// in "prototype". The returned filter is owned by the engine and
// will be destroyed when the engine is destroyed. The "prototype"

View File

@ -478,14 +478,26 @@ static void qt_debug_path(const QPainterPath &path)
\sa ElementType, elementAt(), isEmpty()
*/
int QPainterPath::elementCount() const
{
return d_ptr ? d_ptr->elements.size() : 0;
}
/*!
\fn const QPainterPath::Element &QPainterPath::elementAt(int index) const
\fn QPainterPath::Element QPainterPath::elementAt(int index) const
Returns the element at the given \a index in the painter path.
\sa ElementType, elementCount(), isEmpty()
*/
QPainterPath::Element QPainterPath::elementAt(int i) const
{
Q_ASSERT(d_ptr);
Q_ASSERT(i >= 0 && i < elementCount());
return d_ptr->elements.at(i);
}
/*!
\fn void QPainterPath::setElementPositionAt(int index, qreal x, qreal y)
\since 4.2
@ -494,6 +506,17 @@ static void qt_debug_path(const QPainterPath &path)
x and \a y.
*/
void QPainterPath::setElementPositionAt(int i, qreal x, qreal y)
{
Q_ASSERT(d_ptr);
Q_ASSERT(i >= 0 && i < elementCount());
detach();
QPainterPath::Element &e = d_ptr->elements[i];
e.x = x;
e.y = y;
}
/*###
\fn QPainterPath &QPainterPath::operator +=(const QPainterPath &other)
@ -535,6 +558,13 @@ QPainterPath::QPainterPath(const QPointF &startPoint)
d_func()->elements << e;
}
void QPainterPath::detach()
{
if (d_ptr->ref.load() != 1)
detach_helper();
setDirty(true);
}
/*!
\internal
*/
@ -1451,6 +1481,11 @@ QRectF QPainterPath::controlPointRect() const
\sa elementCount()
*/
bool QPainterPath::isEmpty() const
{
return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement);
}
/*!
Creates and returns a reversed copy of the path.

View File

@ -165,7 +165,7 @@ public:
Qt::FillRule fillRule() const;
void setFillRule(Qt::FillRule fillRule);
inline bool isEmpty() const;
bool isEmpty() const;
QPainterPath toReversed() const;
QList<QPolygonF> toSubpathPolygons(const QMatrix &matrix = QMatrix()) const;
@ -175,9 +175,9 @@ public:
QList<QPolygonF> toFillPolygons(const QTransform &matrix) const;
QPolygonF toFillPolygon(const QTransform &matrix) const;
inline int elementCount() const;
inline const QPainterPath::Element &elementAt(int i) const;
inline void setElementPositionAt(int i, qreal x, qreal y);
int elementCount() const;
QPainterPath::Element elementAt(int i) const;
void setElementPositionAt(int i, qreal x, qreal y);
qreal length() const;
qreal percentAtLength(qreal t) const;
@ -211,7 +211,7 @@ private:
inline void ensureData() { if (!d_ptr) ensureData_helper(); }
void ensureData_helper();
inline void detach();
void detach();
void detach_helper();
void setDirty(bool);
void computeBoundingRect() const;
@ -233,29 +233,6 @@ private:
#endif
};
class QPainterPathPrivate
{
public:
friend class QPainterPath;
friend class QPainterPathData;
friend class QPainterPathStroker;
friend class QPainterPathStrokerPrivate;
friend class QMatrix;
friend class QTransform;
friend class QVectorPath;
friend struct QPainterPathPrivateDeleter;
#ifndef QT_NO_DATASTREAM
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
#endif
QPainterPathPrivate() : ref(1) {}
private:
QAtomicInt ref;
QVector<QPainterPath::Element> elements;
};
Q_DECLARE_TYPEINFO(QPainterPath::Element, Q_PRIMITIVE_TYPE);
#ifndef QT_NO_DATASTREAM
@ -391,40 +368,6 @@ inline void QPainterPath::translate(const QPointF &offset)
inline QPainterPath QPainterPath::translated(const QPointF &offset) const
{ return translated(offset.x(), offset.y()); }
inline bool QPainterPath::isEmpty() const
{
return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement);
}
inline int QPainterPath::elementCount() const
{
return d_ptr ? d_ptr->elements.size() : 0;
}
inline const QPainterPath::Element &QPainterPath::elementAt(int i) const
{
Q_ASSERT(d_ptr);
Q_ASSERT(i >= 0 && i < elementCount());
return d_ptr->elements.at(i);
}
inline void QPainterPath::setElementPositionAt(int i, qreal x, qreal y)
{
Q_ASSERT(d_ptr);
Q_ASSERT(i >= 0 && i < elementCount());
detach();
QPainterPath::Element &e = d_ptr->elements[i];
e.x = x;
e.y = y;
}
inline void QPainterPath::detach()
{
if (d_ptr->ref.load() != 1)
detach_helper();
setDirty(true);
}
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QPainterPath &);

View File

@ -65,6 +65,29 @@
QT_BEGIN_NAMESPACE
class QPainterPathPrivate
{
public:
friend class QPainterPath;
friend class QPainterPathData;
friend class QPainterPathStroker;
friend class QPainterPathStrokerPrivate;
friend class QMatrix;
friend class QTransform;
friend class QVectorPath;
friend struct QPainterPathPrivateDeleter;
#ifndef QT_NO_DATASTREAM
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
#endif
QPainterPathPrivate() : ref(1) {}
private:
QAtomicInt ref;
QVector<QPainterPath::Element> elements;
};
class QPainterPathStrokerPrivate
{
public:

View File

@ -114,9 +114,6 @@ QWindow* QPlatformBackingStore::window() const
This function is called before painting onto the surface begins,
with the \a region in which the painting will occur.
\note A platform providing a backing store with an alpha channel
needs to properly initialize the region to be painted.
\sa endPaint(), paintDevice()
*/

View File

@ -45,6 +45,7 @@
#include "qmatrix.h"
#include "qregion.h"
#include "qpainterpath.h"
#include "qpainterpath_p.h"
#include "qvariant.h"
#include <qmath.h>
#include <qnumeric.h>

View File

@ -75,35 +75,12 @@ void QFont::setRawName(const QString &)
QString QFont::defaultFamily() const
{
QString familyName;
switch(d->request.styleHint) {
case QFont::SansSerif:
familyName = QString::fromLatin1("sans-serif");
break;
case QFont::Serif:
familyName = QString::fromLatin1("serif");
break;
case QFont::TypeWriter:
case QFont::Monospace:
familyName = QString::fromLatin1("monospace");
break;
case QFont::Cursive:
familyName = QString::fromLatin1("cursive");
break;
case QFont::Fantasy:
familyName = QString::fromLatin1("fantasy");
break;
case QFont::Decorative:
familyName = QString::fromLatin1("decorative");
break;
case QFont::System:
default:
familyName = QString();
break;
}
return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->resolveFontFamilyAlias(familyName);
QPlatformFontDatabase *fontDB = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
const QStringList fallbacks = fontDB->fallbacksForFamily(QString(), QFont::StyleNormal
, QFont::StyleHint(d->request.styleHint), QUnicodeTables::Common);
if (!fallbacks.isEmpty())
return fallbacks.first();
return QString();
}
QString QFont::lastResortFamily() const

View File

@ -735,12 +735,13 @@ static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDe
fontDef->family += QLatin1Char(']');
}
if (desc.style->smoothScalable)
if (desc.style->smoothScalable
|| QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable()
|| (desc.style->bitmapScalable && (request.styleStrategy & QFont::PreferMatch))) {
fontDef->pixelSize = request.pixelSize;
else if ((desc.style->bitmapScalable && (request.styleStrategy & QFont::PreferMatch)))
fontDef->pixelSize = request.pixelSize;
else
} else {
fontDef->pixelSize = desc.size->pixelSize;
}
fontDef->styleHint = request.styleHint;
fontDef->styleStrategy = request.styleStrategy;
@ -1534,6 +1535,9 @@ bool QFontDatabase::isScalable(const QString &family,
QList<int> QFontDatabase::pointSizes(const QString &family,
const QString &styleName)
{
if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
return standardSizes();
bool smoothScalable = false;
QString familyName, foundryName;
parseFontName(family, foundryName, familyName);
@ -1634,6 +1638,9 @@ QFont QFontDatabase::font(const QString &family, const QString &style,
QList<int> QFontDatabase::smoothSizes(const QString &family,
const QString &styleName)
{
if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
return standardSizes();
bool smoothScalable = false;
QString familyName, foundryName;
parseFontName(family, foundryName, familyName);
@ -1689,12 +1696,7 @@ QList<int> QFontDatabase::smoothSizes(const QString &family,
*/
QList<int> QFontDatabase::standardSizes()
{
QList<int> ret;
static const unsigned short standard[] =
{ 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72, 0 };
const unsigned short *sizes = standard;
while (*sizes) ret << *sizes++;
return ret;
return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->standardSizes();
}

View File

@ -46,8 +46,6 @@
#include <QtCore/qstring.h>
#include <QtGui/qfont.h>
class tst_QFont;
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@ -162,9 +160,6 @@ private:
friend class QFontEngineMultiXLFD;
friend class QFontEngineMultiQWS;
friend class QFontEngineMultiQPA;
#ifdef QT_BUILD_INTERNAL
friend class ::tst_QFont;
#endif
QFontDatabasePrivate *d;
};

View File

@ -161,9 +161,12 @@ QFontEngine *loadSingleEngine(int script,
Q_UNUSED(foundry);
Q_ASSERT(size);
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
int pixelSize = size->pixelSize;
if (!pixelSize || (style->smoothScalable && pixelSize == SMOOTH_SCALABLE))
if (!pixelSize || (style->smoothScalable && pixelSize == SMOOTH_SCALABLE)
|| pfdb->fontsAlwaysScalable()) {
pixelSize = request.pixelSize;
}
QFontDef def = request;
def.pixelSize = pixelSize;
@ -171,7 +174,6 @@ QFontEngine *loadSingleEngine(int script,
QFontCache::Key key(def,script);
QFontEngine *engine = QFontCache::instance()->findEngine(key);
if (!engine) {
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
engine = pfdb->fontEngine(def,QUnicodeTables::Script(script),size->handle);
if (engine) {
QFontCache::Key key(def,script);

View File

@ -384,6 +384,35 @@ QString QPlatformFontDatabase::resolveFontFamilyAlias(const QString &family) con
return family;
}
/*!
Return true if all fonts are considered scalable when using this font database.
Defaults to false.
\since 5.0
*/
bool QPlatformFontDatabase::fontsAlwaysScalable() const
{
return false;
}
/*!
Return list of standard font sizes when using this font database.
\since 5.0
*/
QList<int> QPlatformFontDatabase::standardSizes() const
{
QList<int> ret;
static const unsigned short standard[] =
{ 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72, 0 };
ret.reserve(int(sizeof(standard) / sizeof(standard[0])));
const unsigned short *sizes = standard;
while (*sizes) ret << *sizes++;
return ret;
}
/*!
\class QPlatformFontDatabase
\brief The QPlatformFontDatabase class makes it possible to customize how fonts

View File

@ -102,6 +102,8 @@ public:
virtual QFont defaultFont() const;
virtual QString resolveFontFamilyAlias(const QString &family) const;
virtual bool fontsAlwaysScalable() const;
virtual QList<int> standardSizes() const;
//callback
static void registerQPF2Font(const QByteArray &dataArray, void *handle);

View File

@ -2185,7 +2185,7 @@ int QTextEngine::formatIndex(const QScriptItem *si) const
int pos = si->position;
if (specialData && si->position >= specialData->preeditPosition) {
if (si->position < specialData->preeditPosition + specialData->preeditText.length())
pos = qMax(specialData->preeditPosition - 1, 0);
pos = qMax(qMin(block.length(), specialData->preeditPosition) - 1, 0);
else
pos -= specialData->preeditText.length();
}

View File

@ -3010,7 +3010,6 @@ QTextImageFormat::QTextImageFormat(const QTextFormat &fmt)
*/
// ### Qt5 qreal replace with a QTextLength
/*!
\fn qreal QTextImageFormat::width() const
@ -3029,7 +3028,6 @@ QTextImageFormat::QTextImageFormat(const QTextFormat &fmt)
*/
// ### Qt5 qreal replace with a QTextLength
/*!
\fn qreal QTextImageFormat::height() const

View File

@ -1051,7 +1051,7 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
&& !attributes.at(i + 1).isEmpty()) {
hasHref = true;
charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
charFormat.setForeground(Qt::blue); // ### Qt5: QApplication::palette().link());
charFormat.setForeground(Qt::blue);
}
}

View File

@ -145,7 +145,7 @@ QTextOption &QTextOption::operator=(const QTextOption &o)
\sa tabArray(), setTabStop(), setTabs()
*/
void QTextOption::setTabArray(QList<qreal> tabStops) // Qt5: const ref
void QTextOption::setTabArray(const QList<qreal> &tabStops)
{
if (!d)
d = new QTextOptionPrivate;
@ -165,7 +165,7 @@ void QTextOption::setTabArray(QList<qreal> tabStops) // Qt5: const ref
\sa tabStops()
*/
void QTextOption::setTabs(QList<QTextOption::Tab> tabStops) // Qt5: const ref
void QTextOption::setTabs(const QList<QTextOption::Tab> &tabStops)
{
if (!d)
d = new QTextOptionPrivate;

View File

@ -122,10 +122,10 @@ public:
inline void setTabStop(qreal tabStop);
inline qreal tabStop() const { return tab; }
void setTabArray(QList<qreal> tabStops);
void setTabArray(const QList<qreal> &tabStops);
QList<qreal> tabArray() const;
void setTabs(QList<Tab> tabStops);
void setTabs(const QList<Tab> &tabStops);
QList<Tab> tabs() const;
void setUseDesignMetrics(bool b) { design = b; }

View File

@ -65,3 +65,5 @@ SOURCES += \
access/qhttpmultipart.cpp
include($$PWD/../../3rdparty/zlib_dependency.pri)
mac:LIBS_PRIVATE += -framework Security

View File

@ -82,6 +82,64 @@ Q_GLOBAL_STATIC(QNetworkAccessFtpBackendFactory, ftpBackend)
Q_GLOBAL_STATIC(QNetworkAccessDebugPipeBackendFactory, debugpipeBackend)
#endif
#ifdef Q_OS_MAC
#include <CoreServices/CoreServices.h>
#include <SystemConfiguration/SystemConfiguration.h>
#include <Security/SecKeychain.h>
bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString& username, QString& password)
{
OSStatus err;
SecKeychainItemRef itemRef;
bool retValue = false;
SecProtocolType protocolType = kSecProtocolTypeAny;
if (scheme.compare(QLatin1String("ftp"),Qt::CaseInsensitive)==0) {
protocolType = kSecProtocolTypeFTP;
} else if (scheme.compare(QLatin1String("http"),Qt::CaseInsensitive)==0) {
protocolType = kSecProtocolTypeHTTP;
} else if (scheme.compare(QLatin1String("https"),Qt::CaseInsensitive)==0) {
protocolType = kSecProtocolTypeHTTPS;
}
QByteArray proxyHostnameUtf8(proxyHostname.toUtf8());
err = SecKeychainFindInternetPassword(NULL,
proxyHostnameUtf8.length(), proxyHostnameUtf8.constData(),
0,NULL,
0, NULL,
0, NULL,
0,
protocolType,
kSecAuthenticationTypeAny,
0, NULL,
&itemRef);
if (err == noErr) {
SecKeychainAttribute attr;
SecKeychainAttributeList attrList;
UInt32 length;
void *outData;
attr.tag = kSecAccountItemAttr;
attr.length = 0;
attr.data = NULL;
attrList.count = 1;
attrList.attr = &attr;
if (SecKeychainItemCopyContent(itemRef, NULL, &attrList, &length, &outData) == noErr) {
username = QString::fromUtf8((const char*)attr.data, attr.length);
password = QString::fromUtf8((const char*)outData, length);
SecKeychainItemFreeContent(&attrList,outData);
retValue = true;
}
CFRelease(itemRef);
}
return retValue;
}
#endif
static void ensureInitialized()
{
#ifndef QT_NO_FTP
@ -1128,6 +1186,18 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QAuthenticator *authen
return;
}
}
#ifdef Q_OS_MAC
//now we try to get the username and password from keychain
//if not successful signal will be emitted
QString username;
QString password;
if (getProxyAuth(proxy.hostName(),reply->request().url().scheme(),username,password)) {
authenticator->setUser(username);
authenticator->setPassword(password);
authenticationManager->cacheProxyCredentials(proxy, authenticator);
return;
}
#endif
// if we emit a signal here in synchronous mode, the user might spin
// an event loop, which might recurse and lead to problems

View File

@ -513,7 +513,8 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
QDateTime currentDateTime = QDateTime::currentDateTime();
QDateTime expirationDate = metaData.expirationDate();
#if 0
bool response_is_fresh;
if (!expirationDate.isValid()) {
/*
* age_value
* is the value of Age: header received by the cache with
@ -572,10 +573,11 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
// the cache-saving code below sets the expirationDate with date+max_age
// if "max-age" is present, or to Expires otherwise
int freshness_lifetime = dateHeader.secsTo(expirationDate);
bool response_is_fresh = (freshness_lifetime > current_age);
#else
bool response_is_fresh = currentDateTime.secsTo(expirationDate) >= 0;
#endif
response_is_fresh = (freshness_lifetime > current_age);
} else {
// expiration date was calculated earlier (e.g. when storing object to the cache)
response_is_fresh = currentDateTime.secsTo(expirationDate) >= 0;
}
if (!response_is_fresh)
return false;

View File

@ -33,7 +33,7 @@ win32: {
}
integrity:SOURCES += kernel/qdnslookup_unix.cpp kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation
mac:SOURCES += kernel/qnetworkproxy_mac.cpp
mac:LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation -framework CoreServices
mac:contains(QT_CONFIG, coreservices):SOURCES += kernel/qnetworkproxy_mac.cpp
else:win32:SOURCES += kernel/qnetworkproxy_win.cpp
else:SOURCES += kernel/qnetworkproxy_generic.cpp

View File

@ -55,7 +55,8 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN
{
// Perform DNS query.
PDNS_RECORD dns_records = 0;
const DNS_STATUS status = DnsQuery_UTF8(requestName, requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL);
const QString requestNameUtf16 = QString::fromUtf8(requestName.data(), requestName.size());
const DNS_STATUS status = DnsQuery_W(reinterpret_cast<const wchar_t*>(requestNameUtf16.utf16()), requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL);
switch (status) {
case ERROR_SUCCESS:
break;
@ -83,7 +84,7 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN
// Extract results.
for (PDNS_RECORD ptr = dns_records; ptr != NULL; ptr = ptr->pNext) {
const QString name = QUrl::fromAce((char*)ptr->pName);
const QString name = QUrl::fromAce( QString::fromWCharArray( ptr->pName ).toLatin1() );
if (ptr->wType == QDnsLookup::A) {
QDnsHostAddressRecord record;
record.d->name = name;
@ -103,12 +104,12 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN
QDnsDomainNameRecord record;
record.d->name = name;
record.d->timeToLive = ptr->dwTtl;
record.d->value = QUrl::fromAce((char*)ptr->Data.Cname.pNameHost);
record.d->value = QUrl::fromAce(QString::fromWCharArray(ptr->Data.Cname.pNameHost).toLatin1());
reply->canonicalNameRecords.append(record);
} else if (ptr->wType == QDnsLookup::MX) {
QDnsMailExchangeRecord record;
record.d->name = name;
record.d->exchange = QUrl::fromAce((char*)ptr->Data.Mx.pNameExchange);
record.d->exchange = QUrl::fromAce(QString::fromWCharArray(ptr->Data.Mx.pNameExchange).toLatin1());
record.d->preference = ptr->Data.Mx.wPreference;
record.d->timeToLive = ptr->dwTtl;
reply->mailExchangeRecords.append(record);
@ -116,18 +117,18 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN
QDnsDomainNameRecord record;
record.d->name = name;
record.d->timeToLive = ptr->dwTtl;
record.d->value = QUrl::fromAce((char*)ptr->Data.Ns.pNameHost);
record.d->value = QUrl::fromAce(QString::fromWCharArray(ptr->Data.Ns.pNameHost).toLatin1());
reply->nameServerRecords.append(record);
} else if (ptr->wType == QDnsLookup::PTR) {
QDnsDomainNameRecord record;
record.d->name = name;
record.d->timeToLive = ptr->dwTtl;
record.d->value = QUrl::fromAce((char*)ptr->Data.Ptr.pNameHost);
record.d->value = QUrl::fromAce(QString::fromWCharArray(ptr->Data.Ptr.pNameHost).toLatin1());
reply->pointerRecords.append(record);
} else if (ptr->wType == QDnsLookup::SRV) {
QDnsServiceRecord record;
record.d->name = name;
record.d->target = QUrl::fromAce((char*)ptr->Data.Srv.pNameTarget);
record.d->target = QUrl::fromAce(QString::fromWCharArray(ptr->Data.Srv.pNameTarget).toLatin1());
record.d->port = ptr->Data.Srv.wPort;
record.d->priority = ptr->Data.Srv.wPriority;
record.d->timeToLive = ptr->dwTtl;
@ -138,7 +139,7 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN
record.d->name = name;
record.d->timeToLive = ptr->dwTtl;
for (unsigned int i = 0; i < ptr->Data.Txt.dwStringCount; ++i) {
record.d->values << QByteArray((char*)ptr->Data.Txt.pStringArray[i]);
record.d->values << QString::fromWCharArray((ptr->Data.Txt.pStringArray[i])).toLatin1();;
}
reply->textRecords.append(record);
}

View File

@ -48,6 +48,7 @@
#include <QtCore/QRegExp>
#include <QtCore/QStringList>
#include <QtCore/QUrl>
#include <QtCore/qendian.h>
#include <QtCore/qstringlist.h>
#include "private/qcore_mac_p.h"
@ -146,6 +147,66 @@ static QNetworkProxy proxyFromDictionary(CFDictionaryRef dict, QNetworkProxy::Pr
return QNetworkProxy();
}
static QNetworkProxy proxyFromDictionary(CFDictionaryRef dict)
{
QNetworkProxy::ProxyType proxyType = QNetworkProxy::DefaultProxy;
QString hostName;
quint16 port = 0;
QString user;
QString password;
CFStringRef cfProxyType = (CFStringRef)CFDictionaryGetValue(dict, kCFProxyTypeKey);
if (CFStringCompare(cfProxyType, kCFProxyTypeNone, 0) == kCFCompareEqualTo) {
proxyType = QNetworkProxy::NoProxy;
} else if (CFStringCompare(cfProxyType, kCFProxyTypeFTP, 0) == kCFCompareEqualTo) {
proxyType = QNetworkProxy::FtpCachingProxy;
} else if (CFStringCompare(cfProxyType, kCFProxyTypeHTTP, 0) == kCFCompareEqualTo) {
proxyType = QNetworkProxy::HttpProxy;
} else if (CFStringCompare(cfProxyType, kCFProxyTypeHTTPS, 0) == kCFCompareEqualTo) {
proxyType = QNetworkProxy::HttpProxy;
} else if (CFStringCompare(cfProxyType, kCFProxyTypeSOCKS, 0) == kCFCompareEqualTo) {
proxyType = QNetworkProxy::Socks5Proxy;
}
hostName = QCFString::toQString((CFStringRef)CFDictionaryGetValue(dict, kCFProxyHostNameKey));
user = QCFString::toQString((CFStringRef)CFDictionaryGetValue(dict, kCFProxyUsernameKey));
password = QCFString::toQString((CFStringRef)CFDictionaryGetValue(dict, kCFProxyPasswordKey));
CFNumberRef portNumber = (CFNumberRef)CFDictionaryGetValue(dict, kCFProxyPortNumberKey);
if (portNumber) {
CFNumberGetValue(portNumber, kCFNumberSInt16Type, &port);
}
return QNetworkProxy(proxyType, hostName, port, user, password);
}
const char * cfurlErrorDescription(SInt32 errorCode)
{
switch (errorCode) {
case kCFURLUnknownError:
return "Unknown Error";
case kCFURLUnknownSchemeError:
return "Unknown Scheme";
case kCFURLResourceNotFoundError:
return "Resource Not Found";
case kCFURLResourceAccessViolationError:
return "Resource Access Violation";
case kCFURLRemoteHostUnavailableError:
return "Remote Host Unavailable";
case kCFURLImproperArgumentsError:
return "Improper Arguments";
case kCFURLUnknownPropertyKeyError:
return "Unknown Property Key";
case kCFURLPropertyKeyUnavailableError:
return "Property Key Unavailable";
case kCFURLTimeoutError:
return "Timeout";
default:
return "Really Unknown Error";
}
}
QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
{
QList<QNetworkProxy> result;
@ -168,11 +229,58 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
int enabled;
if (CFNumberGetValue(pacEnabled, kCFNumberIntType, &enabled) && enabled) {
// PAC is enabled
CFStringRef pacUrl =
(CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString);
QString url = QCFString::toQString(pacUrl);
CFStringRef cfPacLocation = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString);
// ### TODO: Use PAC somehow
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
QCFType<CFDataRef> pacData;
QCFType<CFURLRef> pacUrl = CFURLCreateWithString(kCFAllocatorDefault, cfPacLocation, NULL);
SInt32 errorCode;
if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, pacUrl, &pacData, NULL, NULL, &errorCode)) {
QString pacLocation = QCFString::toQString(cfPacLocation);
qWarning("Unable to get the PAC script at \"%s\" (%s)", qPrintable(pacLocation), cfurlErrorDescription(errorCode));
return result;
}
QCFType<CFStringRef> pacScript = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, pacData, kCFStringEncodingISOLatin1);
if (!pacScript) {
// This should never happen, but the documentation says it may return NULL if there was a problem creating the object.
QString pacLocation = QCFString::toQString(cfPacLocation);
qWarning("Unable to read the PAC script at \"%s\"", qPrintable(pacLocation));
return result;
}
QByteArray encodedURL = query.url().toEncoded(); // converted to UTF-8
if (encodedURL.isEmpty()) {
return result; // Invalid URL, abort
}
QCFType<CFURLRef> targetURL = CFURLCreateWithBytes(kCFAllocatorDefault, (UInt8*)encodedURL.data(), encodedURL.size(), kCFStringEncodingUTF8, NULL);
if (!targetURL) {
return result; // URL creation problem, abort
}
QCFType<CFErrorRef> pacError;
QCFType<CFArrayRef> proxies = CFNetworkCopyProxiesForAutoConfigurationScript(pacScript, targetURL, &pacError);
if (!proxies) {
QString pacLocation = QCFString::toQString(cfPacLocation);
QCFType<CFStringRef> pacErrorDescription = CFErrorCopyDescription(pacError);
qWarning("Execution of PAC script at \"%s\" failed: %s", qPrintable(pacLocation), qPrintable(QCFString::toQString(pacErrorDescription)));
return result;
}
CFIndex size = CFArrayGetCount(proxies);
for (CFIndex i = 0; i < size; ++i) {
CFDictionaryRef proxy = (CFDictionaryRef)CFArrayGetValueAtIndex(proxies, i);
result << proxyFromDictionary(proxy);
}
return result;
} else
#endif
{
QString pacLocation = QCFString::toQString(cfPacLocation);
qWarning("Mac system proxy: PAC script at \"%s\" not handled", qPrintable(pacLocation));
}
}
}

View File

@ -213,6 +213,9 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_flushWriteBuffer())
Q_PRIVATE_SLOT(d_func(), void _q_flushReadBuffer())
Q_PRIVATE_SLOT(d_func(), void _q_resumeImplementation())
#ifdef Q_OS_WIN
Q_PRIVATE_SLOT(d_func(), void _q_caRootLoaded(QSslCertificate,QSslCertificate))
#endif
friend class QSslSocketBackendPrivate;
};

View File

@ -62,7 +62,7 @@
QT_BEGIN_NAMESPACE
#if defined(Q_OS_MAC)
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
#define kSecTrustSettingsDomainSystem 2 // so we do not need to include the header file
PtrSecCertificateGetData QSslSocketPrivate::ptrSecCertificateGetData = 0;
PtrSecTrustSettingsCopyCertificates QSslSocketPrivate::ptrSecTrustSettingsCopyCertificates = 0;
@ -612,7 +612,7 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
resetDefaultCiphers();
//load symbols needed to receive certificates from system store
#if defined(Q_OS_MAC)
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
QLibrary securityLib("/System/Library/Frameworks/Security.framework/Versions/Current/Security");
if (securityLib.load()) {
ptrSecCertificateGetData = (PtrSecCertificateGetData) securityLib.resolve("SecCertificateGetData");
@ -661,6 +661,15 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
// if on-demand loading was not enabled, load the certs now
if (!s_loadRootCertsOnDemand)
setDefaultCaCertificates(systemCaCertificates());
#ifdef Q_OS_WIN
//Enabled for fetching additional root certs from windows update on windows 6+
//This flag is set false by setDefaultCaCertificates() indicating the app uses
//its own cert bundle rather than the system one.
//Same logic that disables the unix on demand cert loading.
//Unlike unix, we do preload the certificates from the cert store.
if ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_6_0)
s_loadRootCertsOnDemand = true;
#endif
}
/*!
@ -736,7 +745,7 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
timer.start();
#endif
QList<QSslCertificate> systemCerts;
#if defined(Q_OS_MAC)
#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
CFArrayRef cfCerts;
OSStatus status = 1;
@ -1221,8 +1230,47 @@ bool QSslSocketBackendPrivate::startHandshake()
if (!errors.isEmpty()) {
sslErrors = errors;
emit q->sslErrors(errors);
#ifdef Q_OS_WIN
//Skip this if not using system CAs, or if the SSL errors are configured in advance to be ignorable
if (s_loadRootCertsOnDemand
&& allowRootCertOnDemandLoading
&& !verifyErrorsHaveBeenIgnored()) {
//Windows desktop versions starting from vista ship with minimal set of roots
//and download on demand from the windows update server CA roots that are
//trusted by MS.
//However, this is only transparent if using WinINET - we have to trigger it
//ourselves.
for (int i=0; i< sslErrors.count(); i++) {
if (sslErrors.at(i).error() == QSslError::UnableToGetLocalIssuerCertificate) {
fetchCaRootForCert(sslErrors.at(i).certificate());
return false;
}
}
}
#endif
if (!checkSslErrors())
return false;
} else {
sslErrors.clear();
}
continueHandshake();
return true;
}
bool QSslSocketBackendPrivate::checkSslErrors()
{
Q_Q(QSslSocket);
if (sslErrors.isEmpty())
return true;
emit q->sslErrors(sslErrors);
bool doVerifyPeer = configuration.peerVerifyMode == QSslSocket::VerifyPeer
|| (configuration.peerVerifyMode == QSslSocket::AutoVerifyPeer
&& mode == QSslSocket::SslClientMode);
bool doEmitSslError = !verifyErrorsHaveBeenIgnored();
// check whether we need to emit an SSL handshake error
if (doVerifyPeer && doEmitSslError) {
@ -1237,14 +1285,176 @@ bool QSslSocketBackendPrivate::startHandshake()
}
return false;
}
} else {
sslErrors.clear();
}
continueHandshake();
return true;
}
#ifdef Q_OS_WIN
void QSslSocketBackendPrivate::fetchCaRootForCert(const QSslCertificate &cert)
{
Q_Q(QSslSocket);
//The root certificate is downloaded from windows update, which blocks for 15 seconds in the worst case
//so the request is done in a worker thread.
QWindowsCaRootFetcher *fetcher = new QWindowsCaRootFetcher(cert, mode);
QObject::connect(fetcher, SIGNAL(finished(QSslCertificate,QSslCertificate)), q, SLOT(_q_caRootLoaded(QSslCertificate,QSslCertificate)), Qt::QueuedConnection);
QMetaObject::invokeMethod(fetcher, "start", Qt::QueuedConnection);
pauseSocketNotifiers(q);
paused = true;
}
//This is the callback from QWindowsCaRootFetcher, trustedRoot will be invalid (default constructed) if it failed.
void QSslSocketBackendPrivate::_q_caRootLoaded(QSslCertificate cert, QSslCertificate trustedRoot)
{
Q_Q(QSslSocket);
if (trustedRoot.isValid()) {
if (s_loadRootCertsOnDemand) {
//Add the new root cert to default cert list for use by future sockets
QSslSocket::addDefaultCaCertificate(trustedRoot);
}
//Add the new root cert to this socket for future connections
q->addCaCertificate(trustedRoot);
//Remove the broken chain ssl errors (as chain is verified by windows)
for (int i=sslErrors.count() - 1; i >= 0; --i) {
if (sslErrors.at(i).certificate() == cert) {
switch (sslErrors.at(i).error()) {
case QSslError::UnableToGetLocalIssuerCertificate:
case QSslError::CertificateUntrusted:
case QSslError::UnableToVerifyFirstCertificate:
// error can be ignored if OS says the chain is trusted
sslErrors.removeAt(i);
break;
default:
// error cannot be ignored
break;
}
}
}
}
// Continue with remaining errors
if (plainSocket)
plainSocket->resume();
paused = false;
if (checkSslErrors())
continueHandshake();
}
Q_DECLARE_METATYPE(QSslCertificate);
class QWindowsCaRootFetcherThread : public QThread
{
public:
QWindowsCaRootFetcherThread()
{
qRegisterMetaType<QSslCertificate>();
setObjectName(QStringLiteral("QWindowsCaRootFetcher"));
start();
}
~QWindowsCaRootFetcherThread()
{
quit();
wait(15500); // worst case, a running request can block for 15 seconds
}
};
Q_GLOBAL_STATIC(QWindowsCaRootFetcherThread, windowsCaRootFetcherThread);
QWindowsCaRootFetcher::QWindowsCaRootFetcher(const QSslCertificate &certificate, QSslSocket::SslMode sslMode)
: cert(certificate), mode(sslMode)
{
moveToThread(windowsCaRootFetcherThread());
}
QWindowsCaRootFetcher::~QWindowsCaRootFetcher()
{
}
void QWindowsCaRootFetcher::start()
{
QByteArray der = cert.toDer();
PCCERT_CONTEXT wincert = CertCreateCertificateContext(X509_ASN_ENCODING, (const BYTE *)der.constData(), der.length());
if (!wincert) {
#ifdef QSSLSOCKET_DEBUG
qDebug("QWindowsCaRootFetcher failed to convert certificate to windows form");
#endif
emit finished(cert, QSslCertificate());
deleteLater();
return;
}
CERT_CHAIN_PARA parameters;
memset(&parameters, 0, sizeof(parameters));
parameters.cbSize = sizeof(parameters);
// set key usage constraint
parameters.RequestedUsage.dwType = USAGE_MATCH_TYPE_AND;
parameters.RequestedUsage.Usage.cUsageIdentifier = 1;
LPSTR oid = (mode == QSslSocket::SslClientMode ? szOID_PKIX_KP_SERVER_AUTH : szOID_PKIX_KP_CLIENT_AUTH);
parameters.RequestedUsage.Usage.rgpszUsageIdentifier = &oid;
#ifdef QSSLSOCKET_DEBUG
QElapsedTimer stopwatch;
stopwatch.start();
#endif
PCCERT_CHAIN_CONTEXT chain;
BOOL result = CertGetCertificateChain(
0, //default engine
wincert,
0, //current date/time
0, //default store
&parameters,
0, //default dwFlags
0, //reserved
&chain);
#ifdef QSSLSOCKET_DEBUG
qDebug() << "QWindowsCaRootFetcher" << stopwatch.elapsed() << "ms to get chain";
#endif
QSslCertificate trustedRoot;
if (result) {
#ifdef QSSLSOCKET_DEBUG
qDebug() << "QWindowsCaRootFetcher - examining windows chains";
if (chain->TrustStatus.dwErrorStatus == CERT_TRUST_NO_ERROR)
qDebug() << " - TRUSTED";
else
qDebug() << " - NOT TRUSTED" << chain->TrustStatus.dwErrorStatus;
if (chain->TrustStatus.dwInfoStatus & CERT_TRUST_IS_SELF_SIGNED)
qDebug() << " - SELF SIGNED";
qDebug() << "QSslSocketBackendPrivate::fetchCaRootForCert - dumping simple chains";
for (unsigned int i = 0; i < chain->cChain; i++) {
if (chain->rgpChain[i]->TrustStatus.dwErrorStatus == CERT_TRUST_NO_ERROR)
qDebug() << " - TRUSTED SIMPLE CHAIN" << i;
else
qDebug() << " - UNTRUSTED SIMPLE CHAIN" << i << "reason:" << chain->rgpChain[i]->TrustStatus.dwErrorStatus;
for (unsigned int j = 0; j < chain->rgpChain[i]->cElement; j++) {
QSslCertificate foundCert(QByteArray((const char *)chain->rgpChain[i]->rgpElement[j]->pCertContext->pbCertEncoded
, chain->rgpChain[i]->rgpElement[j]->pCertContext->cbCertEncoded), QSsl::Der);
qDebug() << " - " << foundCert;
}
}
qDebug() << " - and" << chain->cLowerQualityChainContext << "low quality chains"; //expect 0, we haven't asked for them
#endif
//based on http://msdn.microsoft.com/en-us/library/windows/desktop/aa377182%28v=vs.85%29.aspx
//about the final chain rgpChain[cChain-1] which must begin with a trusted root to be valid
if (chain->TrustStatus.dwErrorStatus == CERT_TRUST_NO_ERROR
&& chain->cChain > 0) {
const PCERT_SIMPLE_CHAIN finalChain = chain->rgpChain[chain->cChain - 1];
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa377544%28v=vs.85%29.aspx
// rgpElement[0] is the end certificate chain element. rgpElement[cElement-1] is the self-signed "root" certificate element.
if (finalChain->TrustStatus.dwErrorStatus == CERT_TRUST_NO_ERROR
&& finalChain->cElement > 0) {
trustedRoot = QSslCertificate(QByteArray((const char *)finalChain->rgpElement[finalChain->cElement - 1]->pCertContext->pbCertEncoded
, finalChain->rgpElement[finalChain->cElement - 1]->pCertContext->cbCertEncoded), QSsl::Der);
}
}
CertFreeCertificateChain(chain);
}
CertFreeCertificateContext(wincert);
emit finished(cert, trustedRoot);
deleteLater();
}
#endif
void QSslSocketBackendPrivate::disconnectFromHost()
{
if (ssl) {

View File

@ -117,6 +117,11 @@ public:
void disconnected();
QSslCipher sessionCipher() const;
void continueHandshake();
bool checkSslErrors();
#ifdef Q_OS_WIN
void fetchCaRootForCert(const QSslCertificate &cert);
void _q_caRootLoaded(QSslCertificate,QSslCertificate);
#endif
Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
static QSslCipher QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher);
@ -127,6 +132,23 @@ public:
static QString getErrorsFromOpenSsl();
};
#ifdef Q_OS_WIN
class QWindowsCaRootFetcher : public QObject
{
Q_OBJECT;
public:
QWindowsCaRootFetcher(const QSslCertificate &certificate, QSslSocket::SslMode sslMode);
~QWindowsCaRootFetcher();
public slots:
void start();
signals:
void finished(QSslCertificate brokenChain, QSslCertificate caroot);
private:
QSslCertificate cert;
QSslSocket::SslMode mode;
};
#endif
QT_END_NAMESPACE
#endif

Some files were not shown because too many files have changed in this diff Show More