From 91eeebda2fe582ff3a302c95eebd7a3a3bfcf663 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Fri, 29 Jan 2010 22:45:39 +0000 Subject: [PATCH] Workaround for OSX tiled image rendering bug. Mingw atomics fix. Fix for compiling atomics on 10.4. Added a 'new folder' button to the directory chooser on Mac. --- build/macosx/Juce.xcodeproj/project.pbxproj | 8 ++++++++ juce_amalgamated.cpp | 16 +++++++++++++--- juce_amalgamated.h | 12 ++++++------ src/core/juce_Atomic.h | 12 ++++++------ src/native/mac/juce_mac_CoreGraphicsContext.mm | 4 +++- src/native/mac/juce_mac_FileChooser.mm | 3 +++ src/native/windows/juce_win32_Threads.cpp | 2 +- 7 files changed, 40 insertions(+), 17 deletions(-) diff --git a/build/macosx/Juce.xcodeproj/project.pbxproj b/build/macosx/Juce.xcodeproj/project.pbxproj index 7755ab100a..27c8eb363d 100644 --- a/build/macosx/Juce.xcodeproj/project.pbxproj +++ b/build/macosx/Juce.xcodeproj/project.pbxproj @@ -21,6 +21,10 @@ 8414DE8511122A8D00DAF75A /* juce_DynamicObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 8414DE8311122A8D00DAF75A /* juce_DynamicObject.h */; }; 843D4A3B10D3C54500624BA6 /* juce_ValueTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 843D4A3910D3C54500624BA6 /* juce_ValueTree.cpp */; }; 843D4A3C10D3C54500624BA6 /* juce_ValueTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 843D4A3A10D3C54500624BA6 /* juce_ValueTree.h */; }; + 843E5C6F1113949F006F959F /* juce_NamedValueSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8414DE76111229B300DAF75A /* juce_NamedValueSet.cpp */; }; + 843E5C701113949F006F959F /* juce_NamedValueSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 8414DE77111229B300DAF75A /* juce_NamedValueSet.h */; }; + 843E5C71111394A2006F959F /* juce_DynamicObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8414DE8211122A8D00DAF75A /* juce_DynamicObject.cpp */; }; + 843E5C72111394A3006F959F /* juce_DynamicObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 8414DE8311122A8D00DAF75A /* juce_DynamicObject.h */; }; 844BB95B10C5578800DF5536 /* juce_TargetPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 8481730E10832513008FEC33 /* juce_TargetPlatform.h */; }; 844BB95C10C5579A00DF5536 /* juce_FillType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F29A9D10C2EFA5005014DF /* juce_FillType.cpp */; }; 844BB95D10C5579B00DF5536 /* juce_FillType.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F29A9E10C2EFA5005014DF /* juce_FillType.h */; }; @@ -3244,6 +3248,8 @@ 84AF419B10F0008E0035D74F /* juce_ScopedPointer.h in Headers */, 84842F9610F6559400490977 /* juce_Value.h in Headers */, 84CAC0C1110478D50088D64D /* juce_TemporaryFile.h in Headers */, + 843E5C701113949F006F959F /* juce_NamedValueSet.h in Headers */, + 843E5C72111394A3006F959F /* juce_DynamicObject.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3923,6 +3929,8 @@ 84B2053F10D535EC008B4A79 /* juce_ValueTree.cpp in Sources */, 84842F9510F6559300490977 /* juce_Value.cpp in Sources */, 84CAC0C0110478D50088D64D /* juce_TemporaryFile.cpp in Sources */, + 843E5C6F1113949F006F959F /* juce_NamedValueSet.cpp in Sources */, + 843E5C71111394A2006F959F /* juce_DynamicObject.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index e2a24745cc..b83607584f 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -212367,7 +212367,7 @@ int SystemStats::getPageSize() throw() extern HWND juce_messageWindowHandle; #endif -#if ! (JUCE_USE_INTRINSICS || JUCE_GCC) +#if ! JUCE_USE_INTRINSICS // In newer compilers, the inline versions of these are used (in juce_Atomic.h), but in // older ones we have to actually call the ops as win32 functions.. void Atomic::increment (int32& variable) { InterlockedIncrement (reinterpret_cast (&variable)); } @@ -240472,7 +240472,9 @@ public: CGContextDrawTiledImage (context, imageRect, image); #else #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (CGContextDrawTiledImage != 0) + // There's a bug in CGContextDrawTiledImage that makes it incredibly slow + // if it's doing a transformation - it's quicker to just draw lots of images manually + if (CGContextDrawTiledImage != 0 && transform.isOnlyTranslation()) CGContextDrawTiledImage (context, imageRect, image); else #endif @@ -241996,6 +241998,9 @@ void FileChooser::showPlatformDialog (Array& results, [panel setDelegate: delegate]; + if (isSaveDialogue || selectsDirectory) + [panel setCanCreateDirectories: YES]; + String directory, filename; if (currentFileOrDirectory.isDirectory()) @@ -244894,7 +244899,9 @@ public: CGContextDrawTiledImage (context, imageRect, image); #else #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (CGContextDrawTiledImage != 0) + // There's a bug in CGContextDrawTiledImage that makes it incredibly slow + // if it's doing a transformation - it's quicker to just draw lots of images manually + if (CGContextDrawTiledImage != 0 && transform.isOnlyTranslation()) CGContextDrawTiledImage (context, imageRect, image); else #endif @@ -248196,6 +248203,9 @@ void FileChooser::showPlatformDialog (Array& results, [panel setDelegate: delegate]; + if (isSaveDialogue || selectsDirectory) + [panel setCanCreateDirectories: YES]; + String directory, filename; if (currentFileOrDirectory.isDirectory()) diff --git a/juce_amalgamated.h b/juce_amalgamated.h index d0a5b1c3bc..eb80014df8 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -3100,14 +3100,14 @@ public: #if (JUCE_MAC || JUCE_IPHONE) // Mac and iPhone... -inline void Atomic::increment (int32& variable) { OSAtomicIncrement32 ((volatile int32_t*) &variable); } -inline int32 Atomic::incrementAndReturn (int32& variable) { return OSAtomicIncrement32 ((volatile int32_t*) &variable); } -inline void Atomic::decrement (int32& variable) { OSAtomicDecrement32 ((volatile int32_t*) &variable); } -inline int32 Atomic::decrementAndReturn (int32& variable) { return OSAtomicDecrement32 ((volatile int32_t*) &variable); } +inline void Atomic::increment (int32& variable) { OSAtomicIncrement32 ((int32_t*) &variable); } +inline int32 Atomic::incrementAndReturn (int32& variable) { return OSAtomicIncrement32 ((int32_t*) &variable); } +inline void Atomic::decrement (int32& variable) { OSAtomicDecrement32 ((int32_t*) &variable); } +inline int32 Atomic::decrementAndReturn (int32& variable) { return OSAtomicDecrement32 ((int32_t*) &variable); } inline int32 Atomic::compareAndExchange (int32& destination, int32 newValue, int32 oldValue) - { return OSAtomicCompareAndSwap32Barrier (oldValue, newValue, (volatile int32_t*) &destination); } + { return OSAtomicCompareAndSwap32Barrier (oldValue, newValue, (int32_t*) &destination); } -#elif JUCE_GCC // Linux... +#elif JUCE_LINUX // Linux... inline void Atomic::increment (int32& variable) { __sync_add_and_fetch (&variable, 1); } inline int32 Atomic::incrementAndReturn (int32& variable) { return __sync_add_and_fetch (&variable, 1); } diff --git a/src/core/juce_Atomic.h b/src/core/juce_Atomic.h index ec67e6a9a6..12a61fd9be 100644 --- a/src/core/juce_Atomic.h +++ b/src/core/juce_Atomic.h @@ -56,14 +56,14 @@ public: //============================================================================== #if (JUCE_MAC || JUCE_IPHONE) // Mac and iPhone... -inline void Atomic::increment (int32& variable) { OSAtomicIncrement32 ((volatile int32_t*) &variable); } -inline int32 Atomic::incrementAndReturn (int32& variable) { return OSAtomicIncrement32 ((volatile int32_t*) &variable); } -inline void Atomic::decrement (int32& variable) { OSAtomicDecrement32 ((volatile int32_t*) &variable); } -inline int32 Atomic::decrementAndReturn (int32& variable) { return OSAtomicDecrement32 ((volatile int32_t*) &variable); } +inline void Atomic::increment (int32& variable) { OSAtomicIncrement32 ((int32_t*) &variable); } +inline int32 Atomic::incrementAndReturn (int32& variable) { return OSAtomicIncrement32 ((int32_t*) &variable); } +inline void Atomic::decrement (int32& variable) { OSAtomicDecrement32 ((int32_t*) &variable); } +inline int32 Atomic::decrementAndReturn (int32& variable) { return OSAtomicDecrement32 ((int32_t*) &variable); } inline int32 Atomic::compareAndExchange (int32& destination, int32 newValue, int32 oldValue) - { return OSAtomicCompareAndSwap32Barrier (oldValue, newValue, (volatile int32_t*) &destination); } + { return OSAtomicCompareAndSwap32Barrier (oldValue, newValue, (int32_t*) &destination); } -#elif JUCE_GCC // Linux... +#elif JUCE_LINUX // Linux... //============================================================================== inline void Atomic::increment (int32& variable) { __sync_add_and_fetch (&variable, 1); } diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index 485d41fcbf..129f1f001d 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -402,7 +402,9 @@ public: CGContextDrawTiledImage (context, imageRect, image); #else #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (CGContextDrawTiledImage != 0) + // There's a bug in CGContextDrawTiledImage that makes it incredibly slow + // if it's doing a transformation - it's quicker to just draw lots of images manually + if (CGContextDrawTiledImage != 0 && transform.isOnlyTranslation()) CGContextDrawTiledImage (context, imageRect, image); else #endif diff --git a/src/native/mac/juce_mac_FileChooser.mm b/src/native/mac/juce_mac_FileChooser.mm index 4bf6f2f6f2..14210c0343 100644 --- a/src/native/mac/juce_mac_FileChooser.mm +++ b/src/native/mac/juce_mac_FileChooser.mm @@ -115,6 +115,9 @@ void FileChooser::showPlatformDialog (Array& results, [panel setDelegate: delegate]; + if (isSaveDialogue || selectsDirectory) + [panel setCanCreateDirectories: YES]; + String directory, filename; if (currentFileOrDirectory.isDirectory()) diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index e688b1a530..9553ff40dd 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -32,7 +32,7 @@ #endif //============================================================================== -#if ! (JUCE_USE_INTRINSICS || JUCE_GCC) +#if ! JUCE_USE_INTRINSICS // In newer compilers, the inline versions of these are used (in juce_Atomic.h), but in // older ones we have to actually call the ops as win32 functions.. void Atomic::increment (int32& variable) { InterlockedIncrement (reinterpret_cast (&variable)); }