From 3f68ec0b84e66b79843aa4a1dc161a020f34659a Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Sat, 15 May 2010 22:30:43 +0100 Subject: [PATCH] Improved software glyph rendering. Misc fixes. --- .../jucer_ComponentEditorCanvas.h | 1 + juce_amalgamated.cpp | 54 ++++++++++++------- juce_amalgamated.h | 7 ++- src/containers/juce_Identifier.cpp | 4 +- .../juce_LowLevelGraphicsSoftwareRenderer.cpp | 7 ++- .../graphics/geometry/juce_RectangleList.cpp | 6 ++- .../graphics/geometry/juce_RectangleList.h | 4 +- src/native/windows/juce_win32_Fonts.cpp | 2 + src/utilities/juce_DeletedAtShutdown.cpp | 36 ++++++++----- src/utilities/juce_DeletedAtShutdown.h | 3 ++ 10 files changed, 85 insertions(+), 39 deletions(-) diff --git a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h index be5046be39..532c165700 100644 --- a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h +++ b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h @@ -236,6 +236,7 @@ private: ~ComponentHolder() { + deleteAllChildren(); } void updateColour() diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index d76b17b596..48f185ab0b 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -3885,8 +3885,8 @@ BEGIN_JUCE_NAMESPACE class Identifier::Pool : public DeletedAtShutdown { public: - Pool() {} - ~Pool() {} + Pool() {} + ~Pool() { clearSingletonInstance(); } StringPool pool; @@ -17934,19 +17934,16 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_DeletedAtShutdown.cpp ***/ BEGIN_JUCE_NAMESPACE -static Array objectsToDelete; -static CriticalSection lock; - DeletedAtShutdown::DeletedAtShutdown() { - const ScopedLock sl (lock); - objectsToDelete.add (this); + const ScopedLock sl (getLock()); + getObjects().add (this); } DeletedAtShutdown::~DeletedAtShutdown() { - const ScopedLock sl (lock); - objectsToDelete.removeValue (this); + const ScopedLock sl (getLock()); + getObjects().removeValue (this); } void DeletedAtShutdown::deleteAll() @@ -17956,8 +17953,8 @@ void DeletedAtShutdown::deleteAll() Array localCopy; { - const ScopedLock sl (lock); - localCopy = objectsToDelete; + const ScopedLock sl (getLock()); + localCopy = getObjects(); } for (int i = localCopy.size(); --i >= 0;) @@ -17968,8 +17965,8 @@ void DeletedAtShutdown::deleteAll() // double-check that it's not already been deleted during another object's destructor. { - const ScopedLock sl (lock); - if (! objectsToDelete.contains (deletee)) + const ScopedLock sl (getLock()); + if (! getObjects().contains (deletee)) deletee = 0; } @@ -17980,9 +17977,21 @@ void DeletedAtShutdown::deleteAll() // if no objects got re-created during shutdown, this should have been emptied by their // destructors - jassert (objectsToDelete.size() == 0); + jassert (getObjects().size() == 0); - objectsToDelete.clear(); // just to make sure the array doesn't have any memory still allocated + getObjects().clear(); // just to make sure the array doesn't have any memory still allocated +} + +CriticalSection& DeletedAtShutdown::getLock() +{ + static CriticalSection lock; + return lock; +} + +Array & DeletedAtShutdown::getObjects() +{ + static Array objects; + return objects; } END_JUCE_NAMESPACE @@ -82374,7 +82383,12 @@ public: const Ptr clipToRectangleList (const RectangleList& r) { - edgeTable.clipToEdgeTable (EdgeTable (r)); + RectangleList inverse (edgeTable.getMaximumBounds()); + + if (inverse.subtract (r)) + for (RectangleList::Iterator iter (inverse); iter.next();) + edgeTable.excludeRectangle (*iter.getRectangle()); + return edgeTable.isEmpty() ? 0 : this; } @@ -91077,10 +91091,12 @@ void RectangleList::subtract (const Rectangle& rect) } } -void RectangleList::subtract (const RectangleList& otherList) +bool RectangleList::subtract (const RectangleList& otherList) { - for (int i = otherList.rects.size(); --i >= 0;) + for (int i = otherList.rects.size(); --i >= 0 && rects.size() > 0;) subtract (otherList.rects.getReference (i)); + + return rects.size() > 0; } bool RectangleList::clipTo (const Rectangle& rect) @@ -239396,6 +239412,8 @@ public: return true; } + + juce_UseDebuggingNewOperator }; const Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 7f5942e6c4..808cf2288a 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -24114,8 +24114,10 @@ public: Any rectangles in the list which overlap this will be clipped and subdivided if necessary. + + @returns true if the resulting list is non-empty. */ - void subtract (const RectangleList& otherList); + bool subtract (const RectangleList& otherList); /** Removes any areas of the region that lie outside a given rectangle. @@ -27147,6 +27149,9 @@ public: private: DeletedAtShutdown (const DeletedAtShutdown&); DeletedAtShutdown& operator= (const DeletedAtShutdown&); + + static CriticalSection& getLock(); + static Array & getObjects(); }; #endif // __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ diff --git a/src/containers/juce_Identifier.cpp b/src/containers/juce_Identifier.cpp index 0d00961ce6..7064927a40 100644 --- a/src/containers/juce_Identifier.cpp +++ b/src/containers/juce_Identifier.cpp @@ -37,8 +37,8 @@ BEGIN_JUCE_NAMESPACE class Identifier::Pool : public DeletedAtShutdown { public: - Pool() {} - ~Pool() {} + Pool() {} + ~Pool() { clearSingletonInstance(); } StringPool pool; diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index a0aa5a17ef..de32266f3d 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -1198,7 +1198,12 @@ public: const Ptr clipToRectangleList (const RectangleList& r) { - edgeTable.clipToEdgeTable (EdgeTable (r)); + RectangleList inverse (edgeTable.getMaximumBounds()); + + if (inverse.subtract (r)) + for (RectangleList::Iterator iter (inverse); iter.next();) + edgeTable.excludeRectangle (*iter.getRectangle()); + return edgeTable.isEmpty() ? 0 : this; } diff --git a/src/gui/graphics/geometry/juce_RectangleList.cpp b/src/gui/graphics/geometry/juce_RectangleList.cpp index 80feb78e6d..34312762c7 100644 --- a/src/gui/graphics/geometry/juce_RectangleList.cpp +++ b/src/gui/graphics/geometry/juce_RectangleList.cpp @@ -266,10 +266,12 @@ void RectangleList::subtract (const Rectangle& rect) } } -void RectangleList::subtract (const RectangleList& otherList) +bool RectangleList::subtract (const RectangleList& otherList) { - for (int i = otherList.rects.size(); --i >= 0;) + for (int i = otherList.rects.size(); --i >= 0 && rects.size() > 0;) subtract (otherList.rects.getReference (i)); + + return rects.size() > 0; } bool RectangleList::clipTo (const Rectangle& rect) diff --git a/src/gui/graphics/geometry/juce_RectangleList.h b/src/gui/graphics/geometry/juce_RectangleList.h index 53187352da..ef73dc0d87 100644 --- a/src/gui/graphics/geometry/juce_RectangleList.h +++ b/src/gui/graphics/geometry/juce_RectangleList.h @@ -118,8 +118,10 @@ public: Any rectangles in the list which overlap this will be clipped and subdivided if necessary. + + @returns true if the resulting list is non-empty. */ - void subtract (const RectangleList& otherList); + bool subtract (const RectangleList& otherList); /** Removes any areas of the region that lie outside a given rectangle. diff --git a/src/native/windows/juce_win32_Fonts.cpp b/src/native/windows/juce_win32_Fonts.cpp index 9cf77d5b40..80dccd64f9 100644 --- a/src/native/windows/juce_win32_Fonts.cpp +++ b/src/native/windows/juce_win32_Fonts.cpp @@ -383,6 +383,8 @@ public: return true; } + + juce_UseDebuggingNewOperator }; const Typeface::Ptr Typeface::createSystemTypefaceFor (const Font& font) diff --git a/src/utilities/juce_DeletedAtShutdown.cpp b/src/utilities/juce_DeletedAtShutdown.cpp index f3fea9bd24..09a7b631f6 100644 --- a/src/utilities/juce_DeletedAtShutdown.cpp +++ b/src/utilities/juce_DeletedAtShutdown.cpp @@ -33,21 +33,17 @@ BEGIN_JUCE_NAMESPACE #include "../application/juce_Application.h" -//============================================================================== -static Array objectsToDelete; -static CriticalSection lock; - //============================================================================== DeletedAtShutdown::DeletedAtShutdown() { - const ScopedLock sl (lock); - objectsToDelete.add (this); + const ScopedLock sl (getLock()); + getObjects().add (this); } DeletedAtShutdown::~DeletedAtShutdown() { - const ScopedLock sl (lock); - objectsToDelete.removeValue (this); + const ScopedLock sl (getLock()); + getObjects().removeValue (this); } void DeletedAtShutdown::deleteAll() @@ -57,8 +53,8 @@ void DeletedAtShutdown::deleteAll() Array localCopy; { - const ScopedLock sl (lock); - localCopy = objectsToDelete; + const ScopedLock sl (getLock()); + localCopy = getObjects(); } for (int i = localCopy.size(); --i >= 0;) @@ -69,8 +65,8 @@ void DeletedAtShutdown::deleteAll() // double-check that it's not already been deleted during another object's destructor. { - const ScopedLock sl (lock); - if (! objectsToDelete.contains (deletee)) + const ScopedLock sl (getLock()); + if (! getObjects().contains (deletee)) deletee = 0; } @@ -81,9 +77,21 @@ void DeletedAtShutdown::deleteAll() // if no objects got re-created during shutdown, this should have been emptied by their // destructors - jassert (objectsToDelete.size() == 0); + jassert (getObjects().size() == 0); - objectsToDelete.clear(); // just to make sure the array doesn't have any memory still allocated + getObjects().clear(); // just to make sure the array doesn't have any memory still allocated +} + +CriticalSection& DeletedAtShutdown::getLock() +{ + static CriticalSection lock; + return lock; +} + +Array & DeletedAtShutdown::getObjects() +{ + static Array objects; + return objects; } END_JUCE_NAMESPACE diff --git a/src/utilities/juce_DeletedAtShutdown.h b/src/utilities/juce_DeletedAtShutdown.h index 39aa234673..e739d4cfac 100644 --- a/src/utilities/juce_DeletedAtShutdown.h +++ b/src/utilities/juce_DeletedAtShutdown.h @@ -65,6 +65,9 @@ public: private: DeletedAtShutdown (const DeletedAtShutdown&); DeletedAtShutdown& operator= (const DeletedAtShutdown&); + + static CriticalSection& getLock(); + static Array & getObjects(); }; #endif // __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__