diff options
Diffstat (limited to 'src')
23 files changed, 975 insertions, 399 deletions
diff --git a/src/corelib/arch/armv6/qatomic_generic_armv6.cpp b/src/corelib/arch/armv6/qatomic_generic_armv6.cpp index f638891..39d966a 100644 --- a/src/corelib/arch/armv6/qatomic_generic_armv6.cpp +++ b/src/corelib/arch/armv6/qatomic_generic_armv6.cpp @@ -46,6 +46,7 @@ #include <QtCore/qglobal.h> #ifdef QT_HAVE_ARMV6 +#ifndef SYMBIAN_E32_ATOMIC_API QT_BEGIN_NAMESPACE @@ -55,6 +56,24 @@ QT_USE_NAMESPACE #pragma push #pragma arm Q_CORE_EXPORT asm +bool QBasicAtomicInt_testAndSetRelaxed(volatile int *_q_value, int expectedValue, int newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +bool QBasicAtomicInt_testAndSetAcquire(volatile int *_q_value, int expectedValue, int newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +bool QBasicAtomicInt_testAndSetRelease(volatile int *_q_value, int expectedValue, int newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue) { CODE32 @@ -73,6 +92,24 @@ retry_testAndSetOrdered } Q_CORE_EXPORT asm +int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *_q_value, int newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *_q_value, int newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +int QBasicAtomicInt_fetchAndStoreRelease(volatile int *_q_value, int newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue) { CODE32 @@ -88,6 +125,24 @@ retry_fetchAndStoreOrdered } Q_CORE_EXPORT asm +int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *_q_value, int valueToAdd) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +int QBasicAtomicInt_fetchAndAddAcquire(volatile int *_q_value, int valueToAdd) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +int QBasicAtomicInt_fetchAndAddRelease(volatile int *_q_value, int valueToAdd) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd) { CODE32 @@ -105,6 +160,30 @@ retry_fetchAndAddOrdered } Q_CORE_EXPORT asm +bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +bool QBasicAtomicPointer_testAndSetRelease(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value, void *expectedValue, void *newValue) @@ -125,6 +204,24 @@ retryPointer_testAndSetOrdered } Q_CORE_EXPORT asm +void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *_q_value, void *newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *_q_value, void *newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *_q_value, void *newValue) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue) { CODE32 @@ -140,6 +237,24 @@ retryPointer_fetchAndStoreOrdered } Q_CORE_EXPORT asm +void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *_q_value, qptrdiff valueToAdd) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *_q_value, qptrdiff valueToAdd) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm +void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *_q_value, qptrdiff valueToAdd) +{ + CODE32 + //fall through +} +Q_CORE_EXPORT asm void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd) { CODE32 @@ -159,6 +274,21 @@ retryPointer_fetchAndAddOrdered #pragma pop #elif defined (Q_CC_GCCE) Q_CORE_EXPORT __declspec( naked ) +bool QBasicAtomicInt_testAndSetRelaxed(volatile int *_q_value, int expectedValue, int newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +bool QBasicAtomicInt_testAndSetAcquire(volatile int *_q_value, int expectedValue, int newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +bool QBasicAtomicInt_testAndSetRelease(volatile int *_q_value, int expectedValue, int newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue) { //R0 = _q_value @@ -176,6 +306,21 @@ bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue } Q_CORE_EXPORT __declspec( naked ) +int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *_q_value, int newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *_q_value, int newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +int QBasicAtomicInt_fetchAndStoreRelease(volatile int *_q_value, int newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue) { //R0 = _q_value @@ -190,6 +335,21 @@ int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue) } Q_CORE_EXPORT __declspec( naked ) +int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *_q_value, int valueToAdd) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +int QBasicAtomicInt_fetchAndAddAcquire(volatile int *_q_value, int valueToAdd) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +int QBasicAtomicInt_fetchAndAddRelease(volatile int *_q_value, int valueToAdd) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd) { //R0 = _q_value @@ -206,6 +366,27 @@ int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd) } Q_CORE_EXPORT __declspec( naked ) +bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +bool QBasicAtomicPointer_testAndSetRelease(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value, void *expectedValue, void *newValue) @@ -225,6 +406,21 @@ bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value, } Q_CORE_EXPORT __declspec( naked ) +void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *_q_value, void *newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *_q_value, void *newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *_q_value, void *newValue) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue) { //R0 = _q_value @@ -239,6 +435,21 @@ void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void * } Q_CORE_EXPORT __declspec( naked ) +void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *_q_value, qptrdiff valueToAdd) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *_q_value, qptrdiff valueToAdd) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) +void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *_q_value, qptrdiff valueToAdd) +{ + //fall through +} +Q_CORE_EXPORT __declspec( naked ) void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd) { //R0 = _q_value @@ -258,3 +469,4 @@ void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff #endif QT_END_NAMESPACE #endif +#endif diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h index fa4e4a9..893bb300 100644 --- a/src/corelib/arch/qatomic_symbian.h +++ b/src/corelib/arch/qatomic_symbian.h @@ -104,10 +104,28 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree() Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int); Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int); Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(volatile int *, int); +Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetRelaxed(volatile int *, int, int); +Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *, int); +Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *, int); +Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetAcquire(volatile int *, int, int); +Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *, int); +Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddAcquire(volatile int *, int); +Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetRelease(volatile int *, int, int); +Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreRelease(volatile int *, int); +Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddRelease(volatile int *, int); Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *); Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *); Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *, qptrdiff); +Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *, void *, void *); +Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *, void *); +Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *, qptrdiff); +Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *, void *, void *); +Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *, void *); +Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *, qptrdiff); +Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetRelease(void * volatile *, void *, void *); +Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *, void *); +Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *, qptrdiff); // Reference counting @@ -133,17 +151,17 @@ inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) { - return testAndSetOrdered(expectedValue, newValue); + return QBasicAtomicInt_testAndSetRelaxed(&_q_value, expectedValue, newValue); } inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) { - return testAndSetOrdered(expectedValue, newValue); + return QBasicAtomicInt_testAndSetAcquire(&_q_value, expectedValue, newValue); } inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) { - return testAndSetOrdered(expectedValue, newValue); + return QBasicAtomicInt_testAndSetRelease(&_q_value, expectedValue, newValue); } // Fetch and store for integers @@ -155,17 +173,17 @@ inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) { - return fetchAndStoreOrdered(newValue); + return QBasicAtomicInt_fetchAndStoreRelaxed(&_q_value, newValue); } inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue) { - return fetchAndStoreOrdered(newValue); + return QBasicAtomicInt_fetchAndStoreAcquire(&_q_value, newValue); } inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue) { - return fetchAndStoreOrdered(newValue); + return QBasicAtomicInt_fetchAndStoreRelease(&_q_value, newValue); } // Fetch and add for integers @@ -177,17 +195,17 @@ inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) { - return fetchAndAddOrdered(valueToAdd); + return QBasicAtomicInt_fetchAndAddRelaxed(&_q_value, valueToAdd); } inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd) { - return fetchAndAddOrdered(valueToAdd); + return QBasicAtomicInt_fetchAndAddAcquire(&_q_value, valueToAdd); } inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) { - return fetchAndAddOrdered(valueToAdd); + return QBasicAtomicInt_fetchAndAddRelease(&_q_value, valueToAdd); } // Test and set for pointers @@ -195,27 +213,29 @@ inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) template <typename T> Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue) { - union { T * volatile * typed; void * volatile * voidp; } pointer; - pointer.typed = &_q_value; - return QBasicAtomicPointer_testAndSetOrdered(pointer.voidp, expectedValue, newValue); + return QBasicAtomicPointer_testAndSetOrdered(reinterpret_cast<void * volatile *>(&_q_value), + expectedValue, newValue); } template <typename T> Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue) { - return testAndSetOrdered(expectedValue, newValue); + return QBasicAtomicPointer_testAndSetRelaxed(reinterpret_cast<void * volatile *>(&_q_value), + expectedValue, newValue); } template <typename T> Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue) { - return testAndSetOrdered(expectedValue, newValue); + return QBasicAtomicPointer_testAndSetAcquire(reinterpret_cast<void * volatile *>(&_q_value), + expectedValue, newValue); } template <typename T> Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue) { - return testAndSetOrdered(expectedValue, newValue); + return QBasicAtomicPointer_testAndSetRelease(reinterpret_cast<void * volatile *>(&_q_value), + expectedValue, newValue); } // Fetch and store for pointers @@ -223,29 +243,33 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValu template <typename T> Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue) { - union { T * volatile * typed; void * volatile * voidp; } pointer; - union { T *typed; void *voidp; } returnValue; - pointer.typed = &_q_value; - returnValue.voidp = QBasicAtomicPointer_fetchAndStoreOrdered(pointer.voidp, newValue); - return returnValue.typed; + return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreOrdered( + reinterpret_cast<void * volatile *>(&_q_value) + , newValue)); } template <typename T> Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue) { - return fetchAndStoreOrdered(newValue); + return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreRelaxed( + reinterpret_cast<void * volatile *>(&_q_value) + , newValue)); } template <typename T> Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue) { - return fetchAndStoreOrdered(newValue); + return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreAcquire( + reinterpret_cast<void * volatile *>(&_q_value) + , newValue)); } template <typename T> Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue) { - return fetchAndStoreOrdered(newValue); + return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreRelease( + reinterpret_cast<void * volatile *>(&_q_value) + , newValue)); } // Fetch and add for pointers @@ -253,29 +277,33 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue) template <typename T> Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd) { - union { T * volatile *typed; void * volatile *voidp; } pointer; - union { T *typed; void *voidp; } returnValue; - pointer.typed = &_q_value; - returnValue.voidp = QBasicAtomicPointer_fetchAndAddOrdered(pointer.voidp, valueToAdd * sizeof(T)); - return returnValue.typed; + return static_cast<T*>(QBasicAtomicPointer_fetchAndAddOrdered( + reinterpret_cast<void * volatile *>(&_q_value), + valueToAdd * sizeof(T))); } template <typename T> Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd) { - return fetchAndAddOrdered(valueToAdd); + return static_cast<T*>(QBasicAtomicPointer_fetchAndAddRelaxed( + reinterpret_cast<void * volatile *>(&_q_value), + valueToAdd * sizeof(T))); } template <typename T> Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd) { - return fetchAndAddOrdered(valueToAdd); + return static_cast<T*>(QBasicAtomicPointer_fetchAndAddAcquire( + reinterpret_cast<void * volatile *>(&_q_value), + valueToAdd * sizeof(T))); } template <typename T> Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd) { - return fetchAndAddOrdered(valueToAdd); + return static_cast<T*>(QBasicAtomicPointer_fetchAndAddRelease( + reinterpret_cast<void * volatile *>(&_q_value), + valueToAdd * sizeof(T))); } QT_END_NAMESPACE diff --git a/src/corelib/arch/symbian/qatomic_symbian.cpp b/src/corelib/arch/symbian/qatomic_symbian.cpp index a2228a1..568fb7a 100644 --- a/src/corelib/arch/symbian/qatomic_symbian.cpp +++ b/src/corelib/arch/symbian/qatomic_symbian.cpp @@ -42,6 +42,10 @@ #include <QtCore/qglobal.h> #include <QtCore/qatomic.h> +#ifdef SYMBIAN_E32_ATOMIC_API +#include <e32atomics.h> +#endif + #include <e32debug.h> QT_BEGIN_NAMESPACE @@ -79,7 +83,7 @@ struct QSymbianPrintExitInfo Q_CORE_EXPORT bool QBasicAtomicInt::isReferenceCountingNative() { -#ifdef QT_HAVE_ARMV6 +#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6) return true; #else return false; @@ -88,7 +92,7 @@ Q_CORE_EXPORT bool QBasicAtomicInt::isReferenceCountingNative() Q_CORE_EXPORT bool QBasicAtomicInt::isTestAndSetNative() { -#ifdef QT_HAVE_ARMV6 +#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6) return true; #else return false; @@ -97,7 +101,7 @@ Q_CORE_EXPORT bool QBasicAtomicInt::isTestAndSetNative() Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndStoreNative() { -#ifdef QT_HAVE_ARMV6 +#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6) return true; #else return false; @@ -106,7 +110,7 @@ Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndStoreNative() Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndAddNative() { -#ifdef QT_HAVE_ARMV6 +#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6) return true; #else return false; @@ -115,7 +119,7 @@ Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndAddNative() Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative() { -#ifdef QT_HAVE_ARMV6 +#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6) return true; #else return false; @@ -124,7 +128,7 @@ Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative() Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndStoreNative() { -#ifdef QT_HAVE_ARMV6 +#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6) return true; #else return false; @@ -133,13 +137,187 @@ Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndStoreNative() Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndAddNative() { -#ifdef QT_HAVE_ARMV6 +#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6) return true; #else return false; #endif } +#ifdef SYMBIAN_E32_ATOMIC_API +//Symbian's API is SMP-safe when using SMP kernel, and cheap when using uniprocessor kernel + +//generate compiler error if casting assumptions are wrong (symbian64?) +__ASSERT_COMPILE(sizeof(int) == sizeof(TUint32)); +__ASSERT_COMPILE(sizeof(void *) == sizeof(TUint32)); + +Q_CORE_EXPORT +bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue) +{ + return static_cast<bool>(__e32_atomic_cas_ord32(_q_value, + reinterpret_cast<TUint32*>(&expectedValue), newValue)); +} + +Q_CORE_EXPORT +bool QBasicAtomicInt_testAndSetRelaxed(volatile int *_q_value, int expectedValue, int newValue) +{ + return static_cast<bool>(__e32_atomic_cas_rlx32(_q_value, + reinterpret_cast<TUint32*>(&expectedValue), newValue)); +} + +Q_CORE_EXPORT +bool QBasicAtomicInt_testAndSetAcquire(volatile int *_q_value, int expectedValue, int newValue) +{ + return static_cast<bool>(__e32_atomic_cas_acq32(_q_value, + reinterpret_cast<TUint32*>(&expectedValue), newValue)); +} + +Q_CORE_EXPORT +bool QBasicAtomicInt_testAndSetRelease(volatile int *_q_value, int expectedValue, int newValue) +{ + return static_cast<bool>(__e32_atomic_cas_rel32(_q_value, + reinterpret_cast<TUint32*>(&expectedValue), newValue)); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue) +{ + return static_cast<int>(__e32_atomic_swp_ord32(_q_value, newValue)); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *_q_value, int newValue) +{ + return static_cast<int>(__e32_atomic_swp_rlx32(_q_value, newValue)); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *_q_value, int newValue) +{ + return static_cast<int>(__e32_atomic_swp_acq32(_q_value, newValue)); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndStoreRelease(volatile int *_q_value, int newValue) +{ + return static_cast<int>(__e32_atomic_swp_rel32(_q_value, newValue)); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd) +{ + return static_cast<int>(__e32_atomic_add_ord32(_q_value, valueToAdd)); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *_q_value, int valueToAdd) +{ + return static_cast<int>(__e32_atomic_add_rlx32(_q_value, valueToAdd)); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndAddAcquire(volatile int *_q_value, int valueToAdd) +{ + return static_cast<int>(__e32_atomic_add_acq32(_q_value, valueToAdd)); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndAddRelease(volatile int *_q_value, int valueToAdd) +{ + return static_cast<int>(__e32_atomic_add_rel32(_q_value, valueToAdd)); +} + +Q_CORE_EXPORT +bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + return static_cast<bool>(__e32_atomic_cas_ord_ptr(_q_value, + &expectedValue, + newValue)); +} + +Q_CORE_EXPORT +bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + return static_cast<bool>(__e32_atomic_cas_rlx_ptr(_q_value, + &expectedValue, + newValue)); +} + +Q_CORE_EXPORT +bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + return static_cast<bool>(__e32_atomic_cas_acq_ptr(_q_value, + &expectedValue, + newValue)); +} + +Q_CORE_EXPORT +bool QBasicAtomicPointer_testAndSetRelease(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + return static_cast<bool>(__e32_atomic_cas_rel_ptr(_q_value, + &expectedValue, + newValue)); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue) +{ + return __e32_atomic_swp_ord_ptr(_q_value, newValue); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *_q_value, void *newValue) +{ + return __e32_atomic_swp_rlx_ptr(_q_value, newValue); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *_q_value, void *newValue) +{ + return __e32_atomic_swp_acq_ptr(_q_value, newValue); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *_q_value, void *newValue) +{ + return __e32_atomic_swp_rel_ptr(_q_value, newValue); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd) +{ + return __e32_atomic_add_ord_ptr(_q_value, valueToAdd); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *_q_value, qptrdiff valueToAdd) +{ + return __e32_atomic_add_rlx_ptr(_q_value, valueToAdd); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *_q_value, qptrdiff valueToAdd) +{ + return __e32_atomic_add_acq_ptr(_q_value, valueToAdd); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *_q_value, qptrdiff valueToAdd) +{ + return __e32_atomic_add_rel_ptr(_q_value, valueToAdd); +} + +#else +//Symbian kernels 9.4 and earlier don't expose a suitable API + //For ARMv6, the generic atomics are machine coded #ifndef QT_HAVE_ARMV6 @@ -229,6 +407,121 @@ void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff return returnValue; } +Q_CORE_EXPORT +bool QBasicAtomicInt_testAndSetRelaxed(volatile int *_q_value, int expectedValue, int newValue) +{ + return QBasicAtomicInt_testAndSetOrdered(_q_value, expectedValue, newValue); +} + +Q_CORE_EXPORT +bool QBasicAtomicInt_testAndSetAcquire(volatile int *_q_value, int expectedValue, int newValue) +{ + return QBasicAtomicInt_testAndSetOrdered(_q_value, expectedValue, newValue); +} + +Q_CORE_EXPORT +bool QBasicAtomicInt_testAndSetRelease(volatile int *_q_value, int expectedValue, int newValue) +{ + return QBasicAtomicInt_testAndSetOrdered(_q_value, expectedValue, newValue); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *_q_value, int newValue) +{ + return QBasicAtomicInt_fetchAndStoreOrdered(_q_value, newValue); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *_q_value, int newValue) +{ + return QBasicAtomicInt_fetchAndStoreOrdered(_q_value, newValue); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndStoreRelease(volatile int *_q_value, int newValue) +{ + return QBasicAtomicInt_fetchAndStoreOrdered(_q_value, newValue); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *_q_value, int valueToAdd) +{ + return QBasicAtomicInt_fetchAndAddOrdered(_q_value, valueToAdd); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndAddAcquire(volatile int *_q_value, int valueToAdd) +{ + return QBasicAtomicInt_fetchAndAddOrdered(_q_value, valueToAdd); +} + +Q_CORE_EXPORT +int QBasicAtomicInt_fetchAndAddRelease(volatile int *_q_value, int valueToAdd) +{ + return QBasicAtomicInt_fetchAndAddOrdered(_q_value, valueToAdd); +} + +Q_CORE_EXPORT +bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + return QBasicAtomicPointer_testAndSetOrdered(_q_value, expectedValue, newValue); +} + +Q_CORE_EXPORT +bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + return QBasicAtomicPointer_testAndSetOrdered(_q_value, expectedValue, newValue); +} + +Q_CORE_EXPORT +bool QBasicAtomicPointer_testAndSetRelease(void * volatile *_q_value, + void *expectedValue, + void *newValue) +{ + return QBasicAtomicPointer_testAndSetOrdered(_q_value, expectedValue, newValue); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *_q_value, void *newValue) +{ + return QBasicAtomicPointer_fetchAndStoreOrdered(_q_value, newValue); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *_q_value, void *newValue) +{ + return QBasicAtomicPointer_fetchAndStoreOrdered(_q_value, newValue); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *_q_value, void *newValue) +{ + return QBasicAtomicPointer_fetchAndStoreOrdered(_q_value, newValue); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *_q_value, qptrdiff valueToAdd) +{ + return QBasicAtomicPointer_fetchAndAddOrdered(_q_value, valueToAdd); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *_q_value, qptrdiff valueToAdd) +{ + return QBasicAtomicPointer_fetchAndAddOrdered(_q_value, valueToAdd); +} + +Q_CORE_EXPORT +void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *_q_value, qptrdiff valueToAdd) +{ + return QBasicAtomicPointer_fetchAndAddOrdered(_q_value, valueToAdd); +} + #endif // QT_HAVE_ARMV6 +#endif // SYMBIAN_E32_ATOMIC_API QT_END_NAMESPACE diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp index e6abf7f..e9b5720 100644 --- a/src/gui/dialogs/qcolordialog.cpp +++ b/src/gui/dialogs/qcolordialog.cpp @@ -644,6 +644,7 @@ protected: void paintEvent(QPaintEvent*); void mouseMoveEvent(QMouseEvent *); void mousePressEvent(QMouseEvent *); + void resizeEvent(QResizeEvent *); private: int hue; @@ -654,7 +655,7 @@ private: int satPt(const QPoint &pt); void setCol(const QPoint &pt); - QPixmap *pix; + QPixmap pix; }; static int pWidth = 220; @@ -790,13 +791,27 @@ void QColorLuminancePicker::setCol(int h, int s , int v) } QPoint QColorPicker::colPt() -{ return QPoint((360-hue)*(pWidth-1)/360, (255-sat)*(pHeight-1)/255); } +{ + QRect r = contentsRect(); + return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255); +} + int QColorPicker::huePt(const QPoint &pt) -{ return 360 - pt.x()*360/(pWidth-1); } +{ + QRect r = contentsRect(); + return 360 - pt.x() * 360 / (r.width() - 1); +} + int QColorPicker::satPt(const QPoint &pt) -{ return 255 - pt.y()*255/(pHeight-1) ; } +{ + QRect r = contentsRect(); + return 255 - pt.y() * 255 / (r.height() - 1); +} + void QColorPicker::setCol(const QPoint &pt) -{ setCol(huePt(pt), satPt(pt)); } +{ + setCol(huePt(pt), satPt(pt)); +} QColorPicker::QColorPicker(QWidget* parent) : QFrame(parent) @@ -804,29 +819,12 @@ QColorPicker::QColorPicker(QWidget* parent) hue = 0; sat = 0; setCol(150, 255); - QImage img(pWidth, pHeight, QImage::Format_RGB32); - int x, y; - uint *pixel = (uint *) img.scanLine(0); - for (y = 0; y < pHeight; y++) { - const uint *end = pixel + pWidth; - x = 0; - while (pixel < end) { - QPoint p(x, y); - QColor c; - c.setHsv(huePt(p), satPt(p), 200); - *pixel = c.rgb(); - ++pixel; - ++x; - } - } - pix = new QPixmap(QPixmap::fromImage(img)); setAttribute(Qt::WA_NoSystemBackground); setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); } QColorPicker::~QColorPicker() { - delete pix; } QSize QColorPicker::sizeHint() const @@ -869,7 +867,7 @@ void QColorPicker::paintEvent(QPaintEvent* ) drawFrame(&p); QRect r = contentsRect(); - p.drawPixmap(r.topLeft(), *pix); + p.drawPixmap(r.topLeft(), pix); QPoint pt = colPt() + r.topLeft(); p.setPen(Qt::black); @@ -878,6 +876,31 @@ void QColorPicker::paintEvent(QPaintEvent* ) } +void QColorPicker::resizeEvent(QResizeEvent *ev) +{ + QFrame::resizeEvent(ev); + + int w = width() - frameWidth() * 2; + int h = height() - frameWidth() * 2; + QImage img(w, h, QImage::Format_RGB32); + int x, y; + uint *pixel = (uint *) img.scanLine(0); + for (y = 0; y < h; y++) { + const uint *end = pixel + w; + x = 0; + while (pixel < end) { + QPoint p(x, y); + QColor c; + c.setHsv(huePt(p), satPt(p), 200); + *pixel = c.rgb(); + ++pixel; + ++x; + } + } + pix = QPixmap::fromImage(img); +} + + class QColSpinBox : public QSpinBox { public: diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 121ba62..df8b525 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -118,14 +118,44 @@ public: } void setText(const QString &text) { textEdit->setPlainText(text); } QString text() const { return textEdit->toPlainText(); } - QString label(DetailButtonLabel label) - { return label == ShowLabel ? QMessageBox::tr("Show Details...") - : QMessageBox::tr("Hide Details..."); } private: TextEdit *textEdit; }; #endif // QT_NO_TEXTEDIT +class DetailButton : public QPushButton +{ +public: + DetailButton(QWidget *parent) : QPushButton(label(ShowLabel), parent) + { + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + } + + QString label(DetailButtonLabel label) const + { return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."); } + + void setLabel(DetailButtonLabel lbl) + { setText(label(lbl)); } + + QSize sizeHint() const + { + ensurePolished(); + QStyleOptionButton opt; + initStyleOption(&opt); + const QFontMetrics fm = fontMetrics(); + opt.text = label(ShowLabel); + QSize sz = fm.size(Qt::TextShowMnemonic, opt.text); + QSize ret = style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this). + expandedTo(QApplication::globalStrut()); + opt.text = label(HideLabel); + sz = fm.size(Qt::TextShowMnemonic, opt.text); + ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this). + expandedTo(QApplication::globalStrut())); + return ret; + } +}; + + class QMessageBoxPrivate : public QDialogPrivate { Q_DECLARE_PUBLIC(QMessageBox) @@ -181,7 +211,7 @@ public: QAbstractButton *escapeButton; QPushButton *defaultButton; QAbstractButton *clickedButton; - QPushButton *detailsButton; + DetailButton *detailsButton; #ifndef QT_NO_TEXTEDIT QMessageBoxDetailsText *detailsText; #endif @@ -421,7 +451,7 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) Q_Q(QMessageBox); #ifndef QT_NO_TEXTEDIT if (detailsButton && detailsText && button == detailsButton) { - detailsButton->setText(detailsText->isHidden() ? detailsText->label(HideLabel) : detailsText->label(ShowLabel)); + detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel); detailsText->setHidden(!detailsText->isHidden()); updateSize(); } else @@ -1891,7 +1921,7 @@ void QMessageBoxPrivate::retranslateStrings() { #ifndef QT_NO_TEXTEDIT if (detailsButton) - detailsButton->setText(detailsText->isHidden() ? detailsText->label(HideLabel) : detailsText->label(ShowLabel)); + detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel); #endif } @@ -2399,11 +2429,8 @@ void QMessageBox::setDetailedText(const QString &text) grid->addWidget(d->detailsText, grid->rowCount(), 0, 1, grid->columnCount()); d->detailsText->hide(); } - if (!d->detailsButton) { - d->detailsButton = new QPushButton(d->detailsText->label(ShowLabel), this); - QPushButton hideDetails(d->detailsText->label(HideLabel)); - d->detailsButton->setFixedSize(d->detailsButton->sizeHint().expandedTo(hideDetails.sizeHint())); - } + if (!d->detailsButton) + d->detailsButton = new DetailButton(this); d->detailsText->setText(text); } #endif // QT_NO_TEXTEDIT diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 4f3a719..a13c8c8 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -337,7 +337,7 @@ QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) if (!bitmap) return QPixmap(); - QScopedPointer<QS60PixmapData> data(new QS60PixmapData(QPixmapData::PixmapType)); + QScopedPointer<QPixmapData> data(QPixmapData::create(0,0, QPixmapData::PixmapType)); data->fromNativeType(reinterpret_cast<void*>(bitmap), QPixmapData::FbsBitmap); QPixmap pixmap(data.take()); return pixmap; @@ -735,7 +735,7 @@ QPixmap QPixmap::fromSymbianRSgImage(RSgImage *sgImage) if (!sgImage) return QPixmap(); - QScopedPointer<QS60PixmapData> data(new QS60PixmapData(QPixmapData::PixmapType)); + QScopedPointer<QPixmapData> data(QPixmapData::create(0,0, QPixmapData::PixmapType)); data->fromNativeType(reinterpret_cast<void*>(sgImage), QPixmapData::SgImage); QPixmap pixmap(data.take()); return pixmap; diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index eb3db21..586e5d4 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1698,13 +1698,10 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent, if (!d->sectionHidden.isEmpty()) { QBitArray sectionHidden(d->sectionHidden); sectionHidden.resize(sectionHidden.count() + insertCount); - //sectionHidden.fill(false, logicalFirst, logicalLast + 1); - for (int i = logicalFirst; i <= logicalLast; ++i) - // visual == logical in this range (see previous block) - sectionHidden.setBit(i, false); + sectionHidden.fill(false, logicalFirst, logicalLast + 1); for (int j = logicalLast + 1; j < sectionHidden.count(); ++j) - sectionHidden.setBit(d->visualIndex(j), - d->sectionHidden.testBit(d->visualIndex(j - insertCount))); + //here we simply copy the old sectionHidden + sectionHidden.setBit(j, d->sectionHidden.testBit(j - insertCount)); d->sectionHidden = sectionHidden; } diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 4135ba0..ada3936 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1997,6 +1997,24 @@ QModelIndex QTreeView::indexBelow(const QModelIndex &index) const void QTreeView::doItemsLayout() { Q_D(QTreeView); + if (d->hasRemovedItems) { + //clean the QSet that may contains old (and this invalid) indexes + d->hasRemovedItems = false; + QSet<QPersistentModelIndex>::iterator it = d->expandedIndexes.begin(); + while (it != d->expandedIndexes.constEnd()) { + if (!it->isValid()) + it = d->expandedIndexes.erase(it); + else + ++it; + } + it = d->hiddenIndexes.begin(); + while (it != d->hiddenIndexes.constEnd()) { + if (!it->isValid()) + it = d->hiddenIndexes.erase(it); + else + ++it; + } + } d->viewItems.clear(); // prepare for new layout QModelIndex parent = d->root; if (d->model->hasChildren(parent)) { @@ -2406,24 +2424,6 @@ void QTreeView::reexpand() } /*! - \internal - This function assume that left is a (grand-)child of the parent of left. -*/ -static bool treeViewItemLessThanInInsert(const QTreeViewItem &left, const QTreeViewItem &right) -{ - if (left.level != right.level) { - Q_ASSERT(left.level > right.level); - QModelIndex leftParent = left.index.parent(); - QModelIndex rightParent = right.index.parent(); - // computer parent, don't get - while (leftParent.isValid() && leftParent.parent() != rightParent) - leftParent = leftParent.parent(); - return (leftParent.row() < right.index.row()); - } - return (left.index.row() < right.index.row()); -} - -/*! Informs the view that the rows from the \a start row to the \a end row inclusive have been inserted into the \a parent model item. */ @@ -2452,83 +2452,6 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) const int parentItem = d->viewIndex(parent); if (((parentItem != -1) && d->viewItems.at(parentItem).expanded && updatesEnabled()) || (parent == d->root)) { - const uint childLevel = (parentItem == -1) - ? uint(0) : d->viewItems.at(parentItem).level + 1; - const int firstChildItem = parentItem + 1; - const int lastChildItem = firstChildItem + ((parentItem == -1) - ? d->viewItems.count() - : d->viewItems.at(parentItem).total) - 1; - - if (parentRowCount == end + 1 && start > 0) { - //need to Update hasMoreSiblings - int previousRow = start - 1; - QModelIndex previousSibilingModelIndex = d->model->index(previousRow, 0, parent); - bool isHidden = d->isRowHidden(previousSibilingModelIndex); - while (isHidden && previousRow > 0) { - previousRow--; - previousSibilingModelIndex = d->model->index(previousRow, 0, parent); - isHidden = d->isRowHidden(previousSibilingModelIndex); - } - if (!isHidden) { - const int previousSibilling = d->viewIndex(previousSibilingModelIndex); - if(previousSibilling != -1) - d->viewItems[previousSibilling].hasMoreSiblings = true; - } - } - - QVector<QTreeViewItem> insertedItems(delta); - for (int i = 0; i < delta; ++i) { - QTreeViewItem &item = insertedItems[i]; - item.index = d->model->index(i + start, 0, parent); - item.parentItem = parentItem; - item.level = childLevel; - item.hasChildren = d->hasVisibleChildren(item.index); - item.hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1)); - } - if (d->viewItems.isEmpty()) - d->defaultItemHeight = indexRowSizeHint(insertedItems[0].index); - - int insertPos; - if (lastChildItem < firstChildItem) { // no children - insertPos = firstChildItem; - } else { - // do a binary search to figure out where to insert - QVector<QTreeViewItem>::iterator it; - it = qLowerBound(d->viewItems.begin() + firstChildItem, - d->viewItems.begin() + lastChildItem + 1, - insertedItems.at(0), treeViewItemLessThanInInsert); - insertPos = it - d->viewItems.begin(); - - // update stale model indexes of siblings - for (int item = insertPos; item <= lastChildItem; ) { - Q_ASSERT(d->viewItems.at(item).level == childLevel); - const QModelIndex modelIndex = d->viewItems.at(item).index; - //Q_ASSERT(modelIndex.parent() == parent); - d->viewItems[item].index = d->model->index( - modelIndex.row() + delta, modelIndex.column(), parent); - - if (!d->viewItems[item].index.isValid()) { - // Something really bad is happening, a bad model is - // often the cause. We can't optimize in this case :( - qWarning() << "QTreeView::rowsInserted internal representation of the model has been corrupted, resetting."; - doItemsLayout(); - return; - } - - item += d->viewItems.at(item).total + 1; - } - } - - d->insertViewItems(insertPos, delta, insertedItems.at(0)); - if (delta > 1) { - qCopy(insertedItems.begin() + 1, insertedItems.end(), - d->viewItems.begin() + insertPos + 1); - } - - if (parentItem != -1) - d->viewItems[parentItem].hasChildren = true; - d->updateChildCount(parentItem, delta); - d->doDelayedItemsLayout(); } else if ((parentItem != -1) && d->viewItems.at(parentItem).expanded) { d->doDelayedItemsLayout(); @@ -2547,8 +2470,8 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) void QTreeView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { Q_D(QTreeView); - d->rowsRemoved(parent, start, end, false); QAbstractItemView::rowsAboutToBeRemoved(parent, start, end); + d->viewItems.clear(); } /*! @@ -2560,7 +2483,10 @@ void QTreeView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e void QTreeView::rowsRemoved(const QModelIndex &parent, int start, int end) { Q_D(QTreeView); - d->rowsRemoved(parent, start, end, true); + d->viewItems.clear(); + d->doDelayedItemsLayout(); + d->hasRemovedItems = true; + d->_q_rowsRemoved(parent, start, end); } /*! @@ -3398,7 +3324,7 @@ int QTreeViewPrivate::viewIndex(const QModelIndex &_index) const const int totalCount = viewItems.count(); const QModelIndex index = _index.sibling(_index.row(), 0); const int row = index.row(); - const quint64 internalId = index.internalId(); + const qint64 internalId = index.internalId(); // We start nearest to the lastViewedItem int localCount = qMin(lastViewedItem - 1, totalCount - lastViewedItem); @@ -3751,118 +3677,6 @@ bool QTreeViewPrivate::hasVisibleChildren(const QModelIndex& parent) const return false; } -void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, - int start, int end, bool after) -{ - // if we are going to do a complete relayout anyway, there is no need to update - if (delayedPendingLayout) { - _q_rowsRemoved(parent, start, end); - return; - } - - const int parentItem = viewIndex(parent); - if ((parentItem != -1) || (parent == root)) { - - const uint childLevel = (parentItem == -1) - ? uint(0) : viewItems.at(parentItem).level + 1; - Q_UNUSED(childLevel); // unused in release mode, used in assert below - - const int firstChildItem = parentItem + 1; - int lastChildItem = firstChildItem + ((parentItem == -1) - ? viewItems.count() - : viewItems.at(parentItem).total) - 1; - - const int delta = end - start + 1; - - int previousSibiling = -1; - int removedCount = 0; - for (int item = firstChildItem; item <= lastChildItem; ) { - Q_ASSERT(viewItems.at(item).level == childLevel); - const QModelIndex modelIndex = viewItems.at(item).index; - //Q_ASSERT(modelIndex.parent() == parent); - const int count = viewItems.at(item).total + 1; - if (modelIndex.row() < start) { - previousSibiling = item; - // not affected by the removal - item += count; - } else if (modelIndex.row() <= end) { - // removed - removeViewItems(item, count); - removedCount += count; - lastChildItem -= count; - } else { - if (after) { - // moved; update the model index - viewItems[item].index = model->index( - modelIndex.row() - delta, modelIndex.column(), parent); - } - item += count; - } - } - - if (previousSibiling != -1 && after && model->rowCount(parent) == start) - viewItems[previousSibiling].hasMoreSiblings = false; - - if (parentItem != -1) { - if (viewItems.at(parentItem).expanded) { - updateChildCount(parentItem, -removedCount); - if (viewItems.at(parentItem).total == 0) - viewItems[parentItem].hasChildren = false; //every children have been removed; - } else if (viewItems[parentItem].hasChildren && !hasVisibleChildren(parent)) { - viewItems[parentItem].hasChildren = false; - } - } - if (after) { - doDelayedItemsLayout(); - } else { - //we have removed items: we should at least update the scroll bar values. - // They are used to determine the item geometry. - updateScrollBars(); - } - } else { - // If an ancestor of root is removed then relayout - QModelIndex idx = root; - while (idx.isValid()) { - idx = idx.parent(); - if (idx == parent) { - doDelayedItemsLayout(); - break; - } - } - } - _q_rowsRemoved(parent, start, end); - - QSet<QPersistentModelIndex>::iterator it = expandedIndexes.begin(); - while (it != expandedIndexes.constEnd()) { - if (!it->isValid()) - it = expandedIndexes.erase(it); - else - ++it; - } - it = hiddenIndexes.begin(); - while (it != hiddenIndexes.constEnd()) { - if (!it->isValid()) - it = hiddenIndexes.erase(it); - else - ++it; - } -} - -void QTreeViewPrivate::updateChildCount(const int parentItem, const int delta) -{ - if ((parentItem != -1) && delta) { - int level = viewItems.at(parentItem).level; - int item = parentItem; - do { - Q_ASSERT(item >= 0); - for ( ; int(viewItems.at(item).level) != level; --item) ; - viewItems[item].total += delta; - --level; - } while (level >= 0); - } -} - - void QTreeViewPrivate::_q_sortIndicatorChanged(int column, Qt::SortOrder order) { model->sort(column, order); diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index 48997b7..261af31 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -91,7 +91,7 @@ public: expandsOnDoubleClick(true), allColumnsShowFocus(false), current(0), spanning(false), animationsEnabled(false), columnResizeTimerID(0), - autoExpandDelay(-1), hoverBranch(-1), geometryRecursionBlock(false) {} + autoExpandDelay(-1), hoverBranch(-1), geometryRecursionBlock(false), hasRemovedItems(false) {} ~QTreeViewPrivate() {} void initialize(); @@ -165,8 +165,6 @@ public: QPair<int,int> startAndEndColumns(const QRect &rect) const; void updateChildCount(const int parentItem, const int delta); - void rowsRemoved(const QModelIndex &parent, - int start, int end, bool before); void paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const; @@ -242,6 +240,9 @@ public: // used for blocking recursion when calling setViewportMargins from updateGeometries bool geometryRecursionBlock; + + // If we should clean the set + bool hasRemovedItems; }; QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index e5b3ac0..71e2e3b 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -7175,9 +7175,9 @@ static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int ) { int a = qGray(coverage); - sr = qt_div_255(sr * a); - sg = qt_div_255(sg * a); - sb = qt_div_255(sb * a); + sr = qt_div_255(qt_pow_rgb_invgamma[sr] * a); + sg = qt_div_255(qt_pow_rgb_invgamma[sg] * a); + sb = qt_div_255(qt_pow_rgb_invgamma[sb] * a); int ia = 255 - a; dr = qt_div_255(dr * ia); diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index f394ca4..4b37b18 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -54,12 +54,11 @@ #include <QtCore/qtimer.h> #include <QtCore/qdebug.h> -#include <QtMultimedia/qaudiodeviceinfo.h> #include <QtMultimedia/qaudioinput.h> #include "qaudio_mac_p.h" #include "qaudioinput_mac_p.h" - +#include "qaudiodeviceinfo_mac_p.h" QT_BEGIN_NAMESPACE @@ -241,7 +240,7 @@ public: m_flushTimer = new QTimer(this); connect(m_flushTimer, SIGNAL(timeout()), SLOT(flushBuffer())); - if (inputFormat.mSampleRate != outputFormat.mSampleRate) { + if (toQAudioFormat(inputFormat) != toQAudioFormat(outputFormat)) { if (AudioConverterNew(&m_inputFormat, &m_outputFormat, &m_audioConverter) != noErr) { qWarning() << "QAudioInput: Unable to create an Audio Converter"; m_audioConverter = 0; @@ -520,6 +519,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co if (QAudio::Mode(mode) == QAudio::AudioOutput) errorCode = QAudio::OpenError; else { + audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioInput); isOpen = false; audioDeviceId = AudioDeviceID(did); audioUnit = 0; @@ -540,6 +540,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co QAudioInputPrivate::~QAudioInputPrivate() { close(); + delete audioDeviceInfo; } bool QAudioInputPrivate::open() @@ -577,7 +578,7 @@ bool QAudioInputPrivate::open() 1, &enable, sizeof(enable)) != noErr) { - qWarning() << "QAudioInput: Unabled to switch to input mode (Enable Input)"; + qWarning() << "QAudioInput: Unable to switch to input mode (Enable Input)"; return false; } @@ -588,7 +589,7 @@ bool QAudioInputPrivate::open() 0, &enable, sizeof(enable)) != noErr) { - qWarning() << "QAudioInput: Unabled to switch to input mode (Disable output)"; + qWarning() << "QAudioInput: Unable to switch to input mode (Disable output)"; return false; } @@ -619,35 +620,40 @@ bool QAudioInputPrivate::open() } // Set format + // Wanted streamFormat = toAudioStreamBasicDescription(audioFormat); - size = sizeof(deviceFormat); - if (AudioUnitGetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 1, - &deviceFormat, - &size) != noErr) { - qWarning() << "QAudioInput: Unable to retrieve device format"; - return false; - } - - // If the device frequency is different to the requested use a converter - if (deviceFormat.mSampleRate != streamFormat.mSampleRate) { - AudioUnitSetProperty(audioUnit, + // Required on unit + if (audioFormat == audioDeviceInfo->preferredFormat()) { + deviceFormat = streamFormat; + AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &deviceFormat, - sizeof(streamFormat)); + sizeof(deviceFormat)); } else { - AudioUnitSetProperty(audioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Output, - 1, - &streamFormat, - sizeof(streamFormat)); + size = sizeof(deviceFormat); + if (AudioUnitGetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 1, + &deviceFormat, + &size) != noErr) { + qWarning() << "QAudioInput: Unable to retrieve device format"; + return false; + } + + if (AudioUnitSetProperty(audioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 1, + &deviceFormat, + sizeof(deviceFormat)) != noErr) { + qWarning() << "QAudioInput: Unable to set device format"; + return false; + } } // Setup buffers @@ -710,7 +716,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device) { QIODevice* op = device; - if (!open()) { + if (!audioFormat.isValid() || !open()) { stateCode = QAudio::StoppedState; errorCode = QAudio::OpenError; return audioIO; @@ -807,6 +813,12 @@ int QAudioInputPrivate::bufferSize() const void QAudioInputPrivate::setNotifyInterval(int milliSeconds) { + if (intervalTimer->interval() == milliSeconds) + return; + + if (milliSeconds <= 0) + milliSeconds = 0; + intervalTimer->setInterval(milliSeconds); } @@ -886,7 +898,8 @@ void QAudioInputPrivate::audioDeviceError() void QAudioInputPrivate::startTimers() { audioBuffer->startFlushTimer(); - intervalTimer->start(); + if (intervalTimer->interval() > 0) + intervalTimer->start(); } void QAudioInputPrivate::stopTimers() diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h index 42f90e2..7aa4168 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.h +++ b/src/multimedia/audio/qaudioinput_mac_p.h @@ -74,6 +74,7 @@ QT_BEGIN_NAMESPACE class QTimer; class QIODevice; +class QAbstractAudioDeviceInfo; namespace QtMultimediaInternal { @@ -104,6 +105,7 @@ public: QTimer* intervalTimer; AudioStreamBasicDescription streamFormat; AudioStreamBasicDescription deviceFormat; + QAbstractAudioDeviceInfo *audioDeviceInfo; QAudioInputPrivate(const QByteArray& device, QAudioFormat const& format); ~QAudioInputPrivate(); diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index 6f32257..9689101 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -435,7 +435,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device) { QIODevice* op = device; - if (!open()) { + if (!audioFormat.isValid() || !open()) { stateCode = QAudio::StoppedState; errorCode = QAudio::OpenError; return audioIO; @@ -536,6 +536,12 @@ int QAudioOutputPrivate::bufferSize() const void QAudioOutputPrivate::setNotifyInterval(int milliSeconds) { + if (intervalTimer->interval() == milliSeconds) + return; + + if (milliSeconds <= 0) + milliSeconds = 0; + intervalTimer->setInterval(milliSeconds); } @@ -622,7 +628,8 @@ void QAudioOutputPrivate::audioDeviceError() void QAudioOutputPrivate::startTimers() { audioBuffer->startFillTimer(); - intervalTimer->start(); + if (intervalTimer->interval() > 0) + intervalTimer->start(); } void QAudioOutputPrivate::stopTimers() diff --git a/src/opengl/qglbuffer.cpp b/src/opengl/qglbuffer.cpp index 7022a53..2ab7c32 100644 --- a/src/opengl/qglbuffer.cpp +++ b/src/opengl/qglbuffer.cpp @@ -369,6 +369,38 @@ void QGLBuffer::release() const glBindBuffer(d->type, 0); } +#undef ctx + +/*! + Binds a raw \a bufferId to the specified buffer \a type + in the current QGLContext. Returns false if there is + no context current or the GL buffer extension could + not be resolved. + + This function is a direct call to \c{glBindBuffer()} for + use when the caller does not have a QGLBuffer but does + have a raw \a bufferId. It can also be used to release + the current buffer when the caller does not know which + QGLBuffer object is currently bound: + + \code + QGLBuffer::bind(QGLBuffer::VertexBuffer, 0); + \endcode +*/ +bool QGLBuffer::bind(QGLBuffer::Type type, uint bufferId) +{ + const QGLContext *ctx = QGLContext::currentContext(); + if (ctx) { + if (qt_resolve_buffer_extensions(const_cast<QGLContext *>(ctx))) { + glBindBuffer(GLenum(type), GLuint(bufferId)); + return true; + } + } + return false; +} + +#define ctx d->guard.context() + /*! Returns the GL identifier associated with this buffer; zero if the buffer has not been created. diff --git a/src/opengl/qglbuffer.h b/src/opengl/qglbuffer.h index ecb86e2..a060733 100644 --- a/src/opengl/qglbuffer.h +++ b/src/opengl/qglbuffer.h @@ -97,6 +97,8 @@ public: bool bind() const; void release() const; + static bool bind(QGLBuffer::Type type, uint bufferId); + uint bufferId() const; int size() const; diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp index a01eec4..3ab385a 100644 --- a/src/opengl/qpixmapdata_x11gl_egl.cpp +++ b/src/opengl/qpixmapdata_x11gl_egl.cpp @@ -41,19 +41,22 @@ #include <QDebug> -#include <private/qgl_p.h> -#include <private/qegl_p.h> -#include <private/qeglproperties_p.h> -#include <private/qeglcontext_p.h> +#include <QtGui/private/qt_x11_p.h> +#include <QtGui/private/qegl_p.h> +#include <QtGui/private/qeglproperties_p.h> +#include <QtGui/private/qeglcontext_p.h> #if !defined(QT_OPENGL_ES_1) -#include <private/qpaintengineex_opengl2_p.h> +#include <QtOpenGL/private/qpaintengineex_opengl2_p.h> #endif #ifndef QT_OPENGL_ES_2 -#include <private/qpaintengine_opengl_p.h> +#include <QtOpenGL/private/qpaintengine_opengl_p.h> #endif +#include <QtOpenGL/private/qgl_p.h> +#include <QtOpenGL/private/qgl_egl_p.h> + #include "qpixmapdata_x11gl_p.h" QT_BEGIN_NAMESPACE @@ -185,6 +188,60 @@ QX11GLPixmapData::~QX11GLPixmapData() delete ctx; } + +void QX11GLPixmapData::fill(const QColor &color) +{ + if (ctx) { + ctx->makeCurrent(); + glFinish(); + eglWaitClient(); + } + + QX11PixmapData::fill(color); + XSync(X11->display, False); + + if (ctx) { + ctx->makeCurrent(); + eglWaitNative(EGL_CORE_NATIVE_ENGINE); + } +} + +void QX11GLPixmapData::copy(const QPixmapData *data, const QRect &rect) +{ + if (ctx) { + ctx->makeCurrent(); + glFinish(); + eglWaitClient(); + } + + QX11PixmapData::copy(data, rect); + XSync(X11->display, False); + + if (ctx) { + ctx->makeCurrent(); + eglWaitNative(EGL_CORE_NATIVE_ENGINE); + } +} + +bool QX11GLPixmapData::scroll(int dx, int dy, const QRect &rect) +{ + if (ctx) { + ctx->makeCurrent(); + glFinish(); + eglWaitClient(); + } + + bool success = QX11PixmapData::scroll(dx, dy, rect); + XSync(X11->display, False); + + if (ctx) { + ctx->makeCurrent(); + eglWaitNative(EGL_CORE_NATIVE_ENGINE); + } + + return success; +} + #if !defined(QT_OPENGL_ES_1) Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_pixmap_2_engine) #endif @@ -201,6 +258,8 @@ QPaintEngine* QX11GLPixmapData::paintEngine() const ctx = new QGLContext(glFormat()); Q_ASSERT(ctx->d_func()->eglContext == 0); ctx->d_func()->eglContext = hasAlphaChannel() ? argbContext : rgbContext; + // Update the glFormat for the QGLContext: + qt_glformat_from_eglconfig(ctx->d_func()->glFormat, ctx->d_func()->eglContext->config()); } QPaintEngine* engine; @@ -249,6 +308,7 @@ void QX11GLPixmapData::beginPaint() EGLConfig cfg = ctx->d_func()->eglContext->config(); Q_ASSERT(cfg != QEGL_NO_CONFIG); +// qDebug("QX11GLPixmapData - using EGL Config ID %d", ctx->d_func()->eglContext->configAttrib(EGL_CONFIG_ID)); EGLSurface surface = QEgl::createSurface(&tmpPixmap, cfg); if (surface == EGL_NO_SURFACE) { qWarning() << "Error creating EGL surface for pixmap:" << QEgl::errorString(); diff --git a/src/opengl/qpixmapdata_x11gl_p.h b/src/opengl/qpixmapdata_x11gl_p.h index 83cd780..8681336 100644 --- a/src/opengl/qpixmapdata_x11gl_p.h +++ b/src/opengl/qpixmapdata_x11gl_p.h @@ -71,6 +71,11 @@ public: QX11GLPixmapData(); virtual ~QX11GLPixmapData(); + // Re-implemented from QX11PixmapData: + void fill(const QColor &color); + void copy(const QPixmapData *data, const QRect &rect); + bool scroll(int dx, int dy, const QRect &rect); + // Re-implemented from QGLPaintDevice QPaintEngine* paintEngine() const; // Also re-implements QX11PixmapData::paintEngine void beginPaint(); diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp index 27b91ba..7befe03 100644 --- a/src/opengl/qwindowsurface_x11gl.cpp +++ b/src/opengl/qwindowsurface_x11gl.cpp @@ -51,14 +51,16 @@ QT_BEGIN_NAMESPACE QX11GLWindowSurface::QX11GLWindowSurface(QWidget* window) - : QWindowSurface(window), m_GC(0), m_window(window) + : QWindowSurface(window), m_windowGC(0), m_pixmapGC(0), m_window(window) { } QX11GLWindowSurface::~QX11GLWindowSurface() { - if (m_GC) - XFree(m_GC); + if (m_windowGC) + XFree(m_windowGC); + if (m_pixmapGC) + XFree(m_pixmapGC); } QPaintDevice *QX11GLWindowSurface::paintDevice() @@ -92,16 +94,22 @@ void QX11GLWindowSurface::flush(QWidget *widget, const QRegion &widgetRegion, co // for (int i = 0; i < num; ++i) // qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height; - if (m_GC == 0) { - m_GC = XCreateGC(X11->display, m_window->handle(), 0, 0); - XSetGraphicsExposures(X11->display, m_GC, False); + if (m_windowGC == 0) { + m_windowGC = XCreateGC(X11->display, m_window->handle(), 0, 0); + XSetGraphicsExposures(X11->display, m_windowGC, False); } - XSetClipRectangles(X11->display, m_GC, 0, 0, rects, rectCount, YXBanded); - XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_GC, + XSetClipRectangles(X11->display, m_windowGC, 0, 0, rects, rectCount, YXBanded); + XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_windowGC, boundingRect.x() + offset.x(), boundingRect.y() + offset.y(), boundingRect.width(), boundingRect.height(), windowBoundingRect.x(), windowBoundingRect.y()); + + QX11GLPixmapData* pmd = static_cast<QX11GLPixmapData*>(m_backBuffer.data_ptr().data()); + Q_ASSERT(pmd->context()); + pmd->context()->makeCurrent(); + XSync(X11->display, False); + eglWaitNative(EGL_CORE_NATIVE_ENGINE); } void QX11GLWindowSurface::setGeometry(const QRect &rect) @@ -113,6 +121,8 @@ void QX11GLWindowSurface::setGeometry(const QRect &rect) QX11GLPixmapData *pd = new QX11GLPixmapData; pd->resize(newSize.width(), newSize.height()); m_backBuffer = QPixmap(pd); + if (window()->testAttribute(Qt::WA_TranslucentBackground)) + m_backBuffer.fill(Qt::transparent); } // if (gc) @@ -124,10 +134,30 @@ void QX11GLWindowSurface::setGeometry(const QRect &rect) bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy) { - Q_UNUSED(area); - Q_UNUSED(dx); - Q_UNUSED(dy); - return false; + if (m_backBuffer.isNull()) + return false; + + Q_ASSERT(m_backBuffer.data_ptr()->classId() == QPixmapData::X11Class); + + QX11GLPixmapData* pmd = static_cast<QX11GLPixmapData*>(m_backBuffer.data_ptr().data()); + Q_ASSERT(pmd->context()); + pmd->context()->makeCurrent(); + glFinish(); + eglWaitClient(); + + if (!m_pixmapGC) + m_pixmapGC = XCreateGC(X11->display, m_backBuffer.handle(), 0, 0); + + foreach (const QRect& rect, area.rects()) { + XCopyArea(X11->display, m_backBuffer.handle(), m_backBuffer.handle(), m_pixmapGC, + rect.x(), rect.y(), rect.width(), rect.height(), + rect.x()+dx, rect.y()+dy); + } + + XSync(X11->display, False); + eglWaitNative(EGL_CORE_NATIVE_ENGINE); + + return true; } /* diff --git a/src/opengl/qwindowsurface_x11gl_p.h b/src/opengl/qwindowsurface_x11gl_p.h index 90f3ad5..3a952e8 100644 --- a/src/opengl/qwindowsurface_x11gl_p.h +++ b/src/opengl/qwindowsurface_x11gl_p.h @@ -70,7 +70,8 @@ public: bool scroll(const QRegion &area, int dx, int dy); private: - GC m_GC; + GC m_windowGC; + GC m_pixmapGC; QPixmap m_backBuffer; QWidget *m_window; }; diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp index bb7bac3..67d07e1 100644 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp +++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayercontrol.cpp @@ -87,7 +87,7 @@ DirectShowPlayerControl::DirectShowPlayerControl(DirectShowPlayerService *servic , m_muteVolume(-1) , m_position(0) , m_duration(0) - , m_playbackRate(0) + , m_playbackRate(1.0) , m_seekable(false) { } diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp index 317fa5c..d54d188 100644 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp +++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp @@ -274,7 +274,7 @@ void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker) } if (SUCCEEDED(hr)) { - m_executedTasks = SetSource; + m_executedTasks |= SetSource; m_pendingTasks |= Render; if (m_audioOutput) @@ -282,7 +282,7 @@ void DirectShowPlayerService::doSetUrlSource(QMutexLocker *locker) if (m_videoOutput) m_pendingTasks |= SetVideoOutput; - if (m_rate != 1.0) + if (m_rate != 1.0 && m_rate != 0.0) m_pendingTasks |= SetRate; m_source = source; @@ -319,7 +319,7 @@ void DirectShowPlayerService::doSetStreamSource(QMutexLocker *locker) source->setDevice(m_stream); if (SUCCEEDED(m_graph->AddFilter(source, L"Source"))) { - m_executedTasks = SetSource; + m_executedTasks |= SetSource; m_pendingTasks |= Render; if (m_audioOutput) @@ -327,7 +327,7 @@ void DirectShowPlayerService::doSetStreamSource(QMutexLocker *locker) if (m_videoOutput) m_pendingTasks |= SetVideoOutput; - if (m_rate != 1.0) + if (m_rate != 1.0 && m_rate != 0.0) m_pendingTasks |= SetRate; m_source = source; @@ -346,7 +346,10 @@ void DirectShowPlayerService::doSetStreamSource(QMutexLocker *locker) void DirectShowPlayerService::doRender(QMutexLocker *locker) { - m_pendingTasks |= m_executedTasks & (Play | Pause); + if (m_executedTasks & Pause) + m_pendingTasks |= Pause; + else if (m_executedTasks & Play && m_rate != 0.0) + m_pendingTasks |= Play; if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) { control->Stop(); @@ -624,8 +627,13 @@ void DirectShowPlayerService::play() { QMutexLocker locker(&m_mutex); - m_pendingTasks &= ~Pause; - m_pendingTasks |= Play; + if (m_rate != 0.0) { + m_pendingTasks &= ~Pause; + m_pendingTasks |= Play; + } else { + m_pendingTasks |= Pause; + m_executedTasks |= Play; + } if (m_executedTasks & Render) { if (m_executedTasks & Stop) { @@ -650,6 +658,7 @@ void DirectShowPlayerService::doPlay(QMutexLocker *locker) if (SUCCEEDED(hr)) { m_executedTasks |= Play; + m_executedTasks &= ~Pause; QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); } else { @@ -704,6 +713,9 @@ void DirectShowPlayerService::doPause(QMutexLocker *locker) m_executedTasks |= Pause; + if (m_rate != 0.0) + m_executedTasks &= ~Play; + QCoreApplication::postEvent(this, new QEvent(QEvent::Type(StatusChange))); } else { m_error = QMediaPlayer::ResourceError; @@ -764,9 +776,27 @@ void DirectShowPlayerService::setRate(qreal rate) { QMutexLocker locker(&m_mutex); - m_rate = rate; + if (m_rate == rate) + return; + + if (rate == 0.0) { + if (m_pendingTasks & Play) { + m_executedTasks |= Play; + m_pendingTasks &= ~(Play | SetRate); + + if (!((m_executingTask | m_executedTasks) & Pause)) + m_pendingTasks |= Pause; + } else if ((m_executingTask | m_executedTasks) & Play) { + m_pendingTasks |= Pause; + } + } else { + m_pendingTasks |= SetRate; + + if (m_rate == 0.0 && (m_executedTasks & Play) && !(m_executingTask & Play)) + m_pendingTasks |= Play; + } - m_pendingTasks |= SetRate; + m_rate = rate; if (m_executedTasks & FinalizeLoad) ::SetEvent(m_taskHandle); @@ -800,8 +830,9 @@ void DirectShowPlayerService::doSetRate(QMutexLocker *locker) seeking->Release(); } else if (m_rate != 1.0) { - m_rate = 1.0; + m_rate = 1.0; } + QCoreApplication::postEvent(this, new QEvent(QEvent::Type(RateChange))); } @@ -1344,16 +1375,16 @@ void DirectShowPlayerService::run() m_executingTask = Stop; doStop(&locker); - } else if (m_pendingTasks & SetRate) { - m_pendingTasks ^= SetRate; - m_executingTask = SetRate; - - doSetRate(&locker); } else if (m_pendingTasks & Pause) { m_pendingTasks ^= Pause; m_executingTask = Pause; doPause(&locker); + } else if (m_pendingTasks & SetRate) { + m_pendingTasks ^= SetRate; + m_executingTask = SetRate; + + doSetRate(&locker); } else if (m_pendingTasks & Seek) { m_pendingTasks ^= Seek; m_executingTask = Seek; diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 56f0610..df10406 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4399,22 +4399,22 @@ EXPORTS ?sender@SignalEvent@QStateMachine@@QBEPAVQObject@@XZ @ 4398 NONAME ; class QObject * QStateMachine::SignalEvent::sender(void) const ?signalIndex@SignalEvent@QStateMachine@@QBEHXZ @ 4399 NONAME ; int QStateMachine::SignalEvent::signalIndex(void) const ?disconnectOne@QMetaObject@@SA_NPBVQObject@@H0H@Z @ 4400 NONAME ; bool QMetaObject::disconnectOne(class QObject const *, int, class QObject const *, int) - ??0QString@@QAE@PBVQChar@@@Z @ 4401 NONAME ; QString::QString(class QChar const *) - ??0QTextDecoder@@QAE@PBVQTextCodec@@V?$QFlags@W4ConversionFlag@QTextCodec@@@@@Z @ 4402 NONAME ; QTextDecoder::QTextDecoder(class QTextCodec const *, class QFlags<enum QTextCodec::ConversionFlag>) - ??0QTextEncoder@@QAE@PBVQTextCodec@@V?$QFlags@W4ConversionFlag@QTextCodec@@@@@Z @ 4403 NONAME ; QTextEncoder::QTextEncoder(class QTextCodec const *, class QFlags<enum QTextCodec::ConversionFlag>) - ??0QVariant@@QAE@ABVQEasingCurve@@@Z @ 4404 NONAME ; QVariant::QVariant(class QEasingCurve const &) - ??5@YAAAVQDataStream@@AAV0@AAVQEasingCurve@@@Z @ 4405 NONAME ; class QDataStream & operator>>(class QDataStream &, class QEasingCurve &) - ??6@YAAAVQDataStream@@AAV0@ABVQEasingCurve@@@Z @ 4406 NONAME ; class QDataStream & operator<<(class QDataStream &, class QEasingCurve const &) - ?append@QListData@@QAEPAPAXH@Z @ 4407 NONAME ; void * * QListData::append(int) - ?detach@QListData@@QAEPAUData@1@H@Z @ 4408 NONAME ; struct QListData::Data * QListData::detach(int) - ?detach_grow@QListData@@QAEPAUData@1@PAHH@Z @ 4409 NONAME ; struct QListData::Data * QListData::detach_grow(int *, int) - ?isSharedWith@QByteArray@@QBE_NABV1@@Z @ 4410 NONAME ; bool QByteArray::isSharedWith(class QByteArray const &) const - ?isSharedWith@QString@@QBE_NABV1@@Z @ 4411 NONAME ; bool QString::isSharedWith(class QString const &) const - ?makeDecoder@QTextCodec@@QBEPAVQTextDecoder@@V?$QFlags@W4ConversionFlag@QTextCodec@@@@@Z @ 4412 NONAME ; class QTextDecoder * QTextCodec::makeDecoder(class QFlags<enum QTextCodec::ConversionFlag>) const - ?makeEncoder@QTextCodec@@QBEPAVQTextEncoder@@V?$QFlags@W4ConversionFlag@QTextCodec@@@@@Z @ 4413 NONAME ; class QTextEncoder * QTextCodec::makeEncoder(class QFlags<enum QTextCodec::ConversionFlag>) const - ?qDecodeDataUrl@@YA?AU?$QPair@VQString@@VQByteArray@@@@ABVQUrl@@@Z @ 4414 NONAME ; struct QPair<class QString, class QByteArray> qDecodeDataUrl(class QUrl const &) - ?qDetectCPUFeatures@@YAIXZ @ 4415 NONAME ; unsigned int qDetectCPUFeatures(void) - ?registerStreamOperators@QMetaType@@SAXHP6AXAAVQDataStream@@PBX@ZP6AX0PAX@Z@Z @ 4416 NONAME ; void QMetaType::registerStreamOperators(int, void (*)(class QDataStream &, void const *), void (*)(class QDataStream &, void *)) - ?replace@QByteArray@@QAEAAV1@HHPBDH@Z @ 4417 NONAME ; class QByteArray & QByteArray::replace(int, int, char const *, int) - ?toEasingCurve@QVariant@@QBE?AVQEasingCurve@@XZ @ 4418 NONAME ; class QEasingCurve QVariant::toEasingCurve(void) const + ?QBasicAtomicInt_fetchAndAddRelease@@YAHPCHH@Z @ 4401 NONAME ; int QBasicAtomicInt_fetchAndAddRelease(int volatile *, int) + ?QBasicAtomicPointer_testAndSetRelaxed@@YA_NPCRAXPAX1@Z @ 4402 NONAME ; bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *, void *, void *) + ?QBasicAtomicInt_fetchAndAddRelaxed@@YAHPCHH@Z @ 4403 NONAME ; int QBasicAtomicInt_fetchAndAddRelaxed(int volatile *, int) + ?QBasicAtomicPointer_testAndSetRelease@@YA_NPCRAXPAX1@Z @ 4404 NONAME ; bool QBasicAtomicPointer_testAndSetRelease(void * volatile *, void *, void *) + ?QBasicAtomicInt_fetchAndStoreRelease@@YAHPCHH@Z @ 4405 NONAME ; int QBasicAtomicInt_fetchAndStoreRelease(int volatile *, int) + ?QBasicAtomicPointer_fetchAndAddAcquire@@YAPAXPCRAXH@Z @ 4406 NONAME ; void * QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *, int) + ?QBasicAtomicPointer_fetchAndAddRelease@@YAPAXPCRAXH@Z @ 4407 NONAME ; void * QBasicAtomicPointer_fetchAndAddRelease(void * volatile *, int) + ?QBasicAtomicPointer_testAndSetAcquire@@YA_NPCRAXPAX1@Z @ 4408 NONAME ; bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *, void *, void *) + ?QBasicAtomicPointer_fetchAndStoreAcquire@@YAPAXPCRAXPAX@Z @ 4409 NONAME ; void * QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *, void *) + ?QBasicAtomicPointer_fetchAndAddRelaxed@@YAPAXPCRAXH@Z @ 4410 NONAME ; void * QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *, int) + ?QBasicAtomicInt_testAndSetAcquire@@YA_NPCHHH@Z @ 4411 NONAME ; bool QBasicAtomicInt_testAndSetAcquire(int volatile *, int, int) + ?QBasicAtomicPointer_fetchAndStoreRelaxed@@YAPAXPCRAXPAX@Z @ 4412 NONAME ; void * QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *, void *) + ?QBasicAtomicInt_fetchAndStoreRelaxed@@YAHPCHH@Z @ 4413 NONAME ; int QBasicAtomicInt_fetchAndStoreRelaxed(int volatile *, int) + ?QBasicAtomicInt_testAndSetRelaxed@@YA_NPCHHH@Z @ 4414 NONAME ; bool QBasicAtomicInt_testAndSetRelaxed(int volatile *, int, int) + ?QBasicAtomicPointer_fetchAndStoreRelease@@YAPAXPCRAXPAX@Z @ 4415 NONAME ; void * QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *, void *) + ?QBasicAtomicInt_testAndSetRelease@@YA_NPCHHH@Z @ 4416 NONAME ; bool QBasicAtomicInt_testAndSetRelease(int volatile *, int, int) + ?QBasicAtomicInt_fetchAndStoreAcquire@@YAHPCHH@Z @ 4417 NONAME ; int QBasicAtomicInt_fetchAndStoreAcquire(int volatile *, int) + ?QBasicAtomicInt_fetchAndAddAcquire@@YAHPCHH@Z @ 4418 NONAME ; int QBasicAtomicInt_fetchAndAddAcquire(int volatile *, int) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index c86eb8c..c648d87 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3634,24 +3634,22 @@ EXPORTS _ZTVN13QStateMachine11SignalEventE @ 3633 NONAME _ZTVN13QStateMachine12WrappedEventE @ 3634 NONAME _ZN11QMetaObject13disconnectOneEPK7QObjectiS2_i @ 3635 NONAME - _Z14qDecodeDataUrlRK4QUrl @ 3636 NONAME - _Z18qDetectCPUFeaturesv @ 3637 NONAME - _ZN10QByteArray7replaceEiiPKci @ 3638 NONAME - _ZN12QTextDecoderC1EPK10QTextCodec6QFlagsINS0_14ConversionFlagEE @ 3639 NONAME - _ZN12QTextDecoderC2EPK10QTextCodec6QFlagsINS0_14ConversionFlagEE @ 3640 NONAME - _ZN12QTextEncoderC1EPK10QTextCodec6QFlagsINS0_14ConversionFlagEE @ 3641 NONAME - _ZN12QTextEncoderC2EPK10QTextCodec6QFlagsINS0_14ConversionFlagEE @ 3642 NONAME - _ZN7QStringC1EPK5QChar @ 3643 NONAME - _ZN7QStringC2EPK5QChar @ 3644 NONAME - _ZN8QVariantC1ERK12QEasingCurve @ 3645 NONAME - _ZN8QVariantC2ERK12QEasingCurve @ 3646 NONAME - _ZN9QListData11detach_growEPii @ 3647 NONAME - _ZN9QListData6appendEi @ 3648 NONAME - _ZN9QListData6detachEi @ 3649 NONAME - _ZN9QMetaType23registerStreamOperatorsEiPFvR11QDataStreamPKvEPFvS1_PvE @ 3650 NONAME - _ZNK10QTextCodec11makeDecoderE6QFlagsINS_14ConversionFlagEE @ 3651 NONAME - _ZNK10QTextCodec11makeEncoderE6QFlagsINS_14ConversionFlagEE @ 3652 NONAME - _ZNK8QVariant13toEasingCurveEv @ 3653 NONAME - _ZlsR11QDataStreamRK12QEasingCurve @ 3654 NONAME - _ZrsR11QDataStreamR12QEasingCurve @ 3655 NONAME + _Z33QBasicAtomicInt_testAndSetAcquirePViii @ 3636 NONAME + _Z33QBasicAtomicInt_testAndSetRelaxedPViii @ 3637 NONAME + _Z33QBasicAtomicInt_testAndSetReleasePViii @ 3638 NONAME + _Z34QBasicAtomicInt_fetchAndAddAcquirePVii @ 3639 NONAME + _Z34QBasicAtomicInt_fetchAndAddRelaxedPVii @ 3640 NONAME + _Z34QBasicAtomicInt_fetchAndAddReleasePVii @ 3641 NONAME + _Z36QBasicAtomicInt_fetchAndStoreAcquirePVii @ 3642 NONAME + _Z36QBasicAtomicInt_fetchAndStoreRelaxedPVii @ 3643 NONAME + _Z36QBasicAtomicInt_fetchAndStoreReleasePVii @ 3644 NONAME + _Z37QBasicAtomicPointer_testAndSetAcquirePVPvS_S_ @ 3645 NONAME + _Z37QBasicAtomicPointer_testAndSetRelaxedPVPvS_S_ @ 3646 NONAME + _Z37QBasicAtomicPointer_testAndSetReleasePVPvS_S_ @ 3647 NONAME + _Z38QBasicAtomicPointer_fetchAndAddAcquirePVPvi @ 3648 NONAME + _Z38QBasicAtomicPointer_fetchAndAddRelaxedPVPvi @ 3649 NONAME + _Z38QBasicAtomicPointer_fetchAndAddReleasePVPvi @ 3650 NONAME + _Z40QBasicAtomicPointer_fetchAndStoreAcquirePVPvS_ @ 3651 NONAME + _Z40QBasicAtomicPointer_fetchAndStoreRelaxedPVPvS_ @ 3652 NONAME + _Z40QBasicAtomicPointer_fetchAndStoreReleasePVPvS_ @ 3653 NONAME |