mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
OpenGL fixes for flickering and rounding errors. RelativeCoordinate expression parsing work. Tweaks for AudioProcessorGraph params and OSX thread naming calls.
This commit is contained in:
parent
182473e8a7
commit
4d332b6bb3
8 changed files with 139 additions and 84 deletions
|
|
@ -105,7 +105,7 @@ namespace CodeHelpers
|
|||
}
|
||||
|
||||
static void writeEscapeChars (OutputStream& out, const char* utf8, const int numBytes,
|
||||
const int maxCharsOnLine, const bool breakAtNewLines,
|
||||
const int maxCharsOnLine, const bool breakAtNewLines,
|
||||
const bool replaceSingleQuotes, const bool allowStringBreaks)
|
||||
{
|
||||
int charsOnLine = 0;
|
||||
|
|
@ -399,7 +399,7 @@ namespace CodeHelpers
|
|||
else
|
||||
{
|
||||
out << "\"";
|
||||
writeEscapeChars (out, (const char*) data, (int) mb.getSize(),
|
||||
writeEscapeChars (out, (const char*) data, (int) mb.getSize(),
|
||||
maxCharsOnLine, breakAtNewLines, false, allowStringBreaks);
|
||||
out << "\";";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1138,8 +1138,10 @@ bool AudioProcessorGraph::disconnectNode (const uint32 nodeId)
|
|||
return doneAnything;
|
||||
}
|
||||
|
||||
bool AudioProcessorGraph::isConnectionLegal (Connection* const c) const
|
||||
bool AudioProcessorGraph::isConnectionLegal (const Connection* const c) const
|
||||
{
|
||||
jassert (c != nullptr);
|
||||
|
||||
const Node* const source = getNodeForId (c->sourceNodeId);
|
||||
const Node* const dest = getNodeForId (c->destNodeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ public:
|
|||
Even if a connection is valid when created, its status could change if
|
||||
a node changes its channel config.
|
||||
*/
|
||||
bool isConnectionLegal (Connection* connection) const;
|
||||
bool isConnectionLegal (const Connection* connection) const;
|
||||
|
||||
/** Performs a sanity checks of all the connections.
|
||||
|
||||
|
|
|
|||
|
|
@ -847,8 +847,8 @@ void Thread::killThread()
|
|||
|
||||
void Thread::setCurrentThreadName (const String& name)
|
||||
{
|
||||
#if JUCE_MAC && defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
|
||||
pthread_setname_np (name.toUTF8());
|
||||
#if JUCE_IOS || (JUCE_MAC && defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
|
||||
[[NSThread currentThread] setName: juceStringToNS (name)];
|
||||
#elif JUCE_LINUX
|
||||
prctl (PR_SET_NAME, name.toUTF8().getAddress(), 0, 0, 0);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,6 +25,76 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
//==============================================================================
|
||||
class MarkerListScope : public Expression::Scope
|
||||
{
|
||||
public:
|
||||
MarkerListScope (Component& component_) : component (component_) {}
|
||||
|
||||
Expression getSymbolValue (const String& symbol) const
|
||||
{
|
||||
switch (RelativeCoordinate::StandardStrings::getTypeOf (symbol))
|
||||
{
|
||||
case RelativeCoordinate::StandardStrings::width: return Expression ((double) component.getWidth());
|
||||
case RelativeCoordinate::StandardStrings::height: return Expression ((double) component.getHeight());
|
||||
default: break;
|
||||
}
|
||||
|
||||
MarkerList* list;
|
||||
const MarkerList::Marker* const marker = findMarker (component, symbol, list);
|
||||
|
||||
if (marker != nullptr)
|
||||
return Expression (marker->position.getExpression().evaluate (*this));
|
||||
|
||||
return Expression::Scope::getSymbolValue (symbol);
|
||||
}
|
||||
|
||||
void visitRelativeScope (const String& scopeName, Visitor& visitor) const
|
||||
{
|
||||
if (scopeName == RelativeCoordinate::Strings::parent)
|
||||
{
|
||||
Component* const parent = component.getParentComponent();
|
||||
|
||||
if (parent != nullptr)
|
||||
{
|
||||
visitor.visit (MarkerListScope (*parent));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Expression::Scope::visitRelativeScope (scopeName, visitor);
|
||||
}
|
||||
|
||||
String getScopeUID() const
|
||||
{
|
||||
return String::toHexString ((pointer_sized_int) (void*) &component) + "m";
|
||||
}
|
||||
|
||||
static const MarkerList::Marker* findMarker (Component& component, const String& name, MarkerList*& list)
|
||||
{
|
||||
const MarkerList::Marker* marker = nullptr;
|
||||
list = component.getMarkers (true);
|
||||
|
||||
if (list != nullptr)
|
||||
marker = list->getMarker (name);
|
||||
|
||||
if (marker == nullptr)
|
||||
{
|
||||
list = component.getMarkers (false);
|
||||
|
||||
if (list != nullptr)
|
||||
marker = list->getMarker (name);
|
||||
}
|
||||
|
||||
return marker;
|
||||
}
|
||||
|
||||
private:
|
||||
Component& component;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (MarkerListScope);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
RelativeCoordinatePositionerBase::ComponentScope::ComponentScope (Component& component_)
|
||||
: component (component_)
|
||||
|
|
@ -46,16 +116,18 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con
|
|||
default: break;
|
||||
}
|
||||
|
||||
MarkerList* list;
|
||||
const MarkerList::Marker* const marker = findMarker (symbol, list);
|
||||
Component* const parent = component.getParentComponent();
|
||||
|
||||
if (marker != nullptr)
|
||||
if (parent != nullptr)
|
||||
{
|
||||
Component* const parent = component.getParentComponent();
|
||||
jassert (parent != nullptr);
|
||||
MarkerList* list;
|
||||
const MarkerList::Marker* const marker = MarkerListScope::findMarker (*parent, symbol, list);
|
||||
|
||||
ComponentScope scope (*parent);
|
||||
return Expression (marker->position.getExpression().evaluate (scope));
|
||||
if (marker != nullptr)
|
||||
{
|
||||
MarkerListScope scope (*parent);
|
||||
return Expression (marker->position.getExpression().evaluate (scope));
|
||||
}
|
||||
}
|
||||
|
||||
return Expression::Scope::getSymbolValue (symbol);
|
||||
|
|
@ -63,12 +135,9 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con
|
|||
|
||||
void RelativeCoordinatePositionerBase::ComponentScope::visitRelativeScope (const String& scopeName, Visitor& visitor) const
|
||||
{
|
||||
Component* targetComp = nullptr;
|
||||
|
||||
if (scopeName == RelativeCoordinate::Strings::parent)
|
||||
targetComp = component.getParentComponent();
|
||||
else
|
||||
targetComp = findSiblingComponent (scopeName);
|
||||
Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent)
|
||||
? component.getParentComponent()
|
||||
: findSiblingComponent (scopeName);
|
||||
|
||||
if (targetComp != nullptr)
|
||||
visitor.visit (ComponentScope (*targetComp));
|
||||
|
|
@ -78,41 +147,15 @@ void RelativeCoordinatePositionerBase::ComponentScope::visitRelativeScope (const
|
|||
|
||||
String RelativeCoordinatePositionerBase::ComponentScope::getScopeUID() const
|
||||
{
|
||||
return String::toHexString ((int) (pointer_sized_int) (void*) &component);
|
||||
return String::toHexString ((pointer_sized_int) (void*) &component);
|
||||
}
|
||||
|
||||
Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponent (const String& componentID) const
|
||||
{
|
||||
Component* const parent = component.getParentComponent();
|
||||
|
||||
if (parent != nullptr)
|
||||
return parent->findChildWithID (componentID);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const MarkerList::Marker* RelativeCoordinatePositionerBase::ComponentScope::findMarker (const String& name, MarkerList*& list) const
|
||||
{
|
||||
const MarkerList::Marker* marker = nullptr;
|
||||
|
||||
Component* const parent = component.getParentComponent();
|
||||
|
||||
if (parent != nullptr)
|
||||
{
|
||||
list = parent->getMarkers (true);
|
||||
if (list != nullptr)
|
||||
marker = list->getMarker (name);
|
||||
|
||||
if (marker == nullptr)
|
||||
{
|
||||
list = parent->getMarkers (false);
|
||||
|
||||
if (list != nullptr)
|
||||
marker = list->getMarker (name);
|
||||
}
|
||||
}
|
||||
|
||||
return marker;
|
||||
return parent != nullptr ? parent->findChildWithID (componentID)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -126,29 +169,41 @@ public:
|
|||
|
||||
Expression getSymbolValue (const String& symbol) const
|
||||
{
|
||||
if (symbol == RelativeCoordinate::Strings::left || symbol == RelativeCoordinate::Strings::x
|
||||
|| symbol == RelativeCoordinate::Strings::width || symbol == RelativeCoordinate::Strings::right
|
||||
|| symbol == RelativeCoordinate::Strings::top || symbol == RelativeCoordinate::Strings::y
|
||||
|| symbol == RelativeCoordinate::Strings::height || symbol == RelativeCoordinate::Strings::bottom)
|
||||
switch (RelativeCoordinate::StandardStrings::getTypeOf (symbol))
|
||||
{
|
||||
positioner.registerComponentListener (component);
|
||||
}
|
||||
else
|
||||
{
|
||||
MarkerList* list;
|
||||
const MarkerList::Marker* const marker = findMarker (symbol, list);
|
||||
case RelativeCoordinate::StandardStrings::x:
|
||||
case RelativeCoordinate::StandardStrings::left:
|
||||
case RelativeCoordinate::StandardStrings::y:
|
||||
case RelativeCoordinate::StandardStrings::top:
|
||||
case RelativeCoordinate::StandardStrings::width:
|
||||
case RelativeCoordinate::StandardStrings::height:
|
||||
case RelativeCoordinate::StandardStrings::right:
|
||||
case RelativeCoordinate::StandardStrings::bottom:
|
||||
positioner.registerComponentListener (component);
|
||||
break;
|
||||
|
||||
if (marker != nullptr)
|
||||
default:
|
||||
{
|
||||
positioner.registerMarkerListListener (list);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The marker we want doesn't exist, so watch all lists in case they change and the marker appears later..
|
||||
positioner.registerMarkerListListener (component.getMarkers (true));
|
||||
positioner.registerMarkerListListener (component.getMarkers (false));
|
||||
ok = false;
|
||||
Component* const parent = component.getParentComponent();
|
||||
if (parent != nullptr)
|
||||
{
|
||||
MarkerList* list;
|
||||
const MarkerList::Marker* marker = MarkerListScope::findMarker (*parent, symbol, list);
|
||||
|
||||
if (marker != nullptr)
|
||||
{
|
||||
positioner.registerMarkerListListener (list);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The marker we want doesn't exist, so watch all lists in case they change and the marker appears later..
|
||||
positioner.registerMarkerListListener (parent->getMarkers (true));
|
||||
positioner.registerMarkerListListener (parent->getMarkers (false));
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ComponentScope::getSymbolValue (symbol);
|
||||
|
|
@ -156,12 +211,9 @@ public:
|
|||
|
||||
void visitRelativeScope (const String& scopeName, Visitor& visitor) const
|
||||
{
|
||||
Component* targetComp = nullptr;
|
||||
|
||||
if (scopeName == RelativeCoordinate::Strings::parent)
|
||||
targetComp = component.getParentComponent();
|
||||
else
|
||||
targetComp = findSiblingComponent (scopeName);
|
||||
Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent)
|
||||
? component.getParentComponent()
|
||||
: findSiblingComponent (scopeName);
|
||||
|
||||
if (targetComp != nullptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ public:
|
|||
Component& component;
|
||||
|
||||
Component* findSiblingComponent (const String& componentID) const;
|
||||
const MarkerList::Marker* findMarker (const String& name, MarkerList*& list) const;
|
||||
|
||||
private:
|
||||
JUCE_DECLARE_NON_COPYABLE (ComponentScope);
|
||||
|
|
|
|||
|
|
@ -397,10 +397,8 @@ bool OpenGLComponent::performRender()
|
|||
|
||||
renderOpenGL();
|
||||
|
||||
if (needToRepaint && (flags & allowSubComponents) != 0)
|
||||
if ((flags & allowSubComponents) != 0)
|
||||
{
|
||||
needToRepaint = false;
|
||||
|
||||
contextLock.exit(); // (MM must be locked before the context lock)
|
||||
MessageManagerLock mmLock (renderThread);
|
||||
contextLock.enter();
|
||||
|
|
@ -414,7 +412,10 @@ bool OpenGLComponent::performRender()
|
|||
const Rectangle<int> bounds (getLocalBounds());
|
||||
OpenGLFrameBuffer& frameBuffer = cachedImage->getFrameBuffer (bounds.getWidth(), bounds.getHeight());
|
||||
|
||||
if (needToRepaint)
|
||||
{
|
||||
needToRepaint = false;
|
||||
|
||||
RectangleList invalid (bounds);
|
||||
invalid.subtract (cachedImage->validArea);
|
||||
cachedImage->validArea = bounds;
|
||||
|
|
@ -442,8 +443,8 @@ bool OpenGLComponent::performRender()
|
|||
context->extensions.glActiveTexture (GL_TEXTURE0);
|
||||
glBindTexture (GL_TEXTURE_2D, frameBuffer.getTextureID());
|
||||
|
||||
context->copyTexture (bounds, Rectangle<int> (bounds.getWidth(),
|
||||
bounds.getHeight()));
|
||||
jassert (bounds.getPosition() == Point<int>());
|
||||
context->copyTexture (bounds, bounds);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -609,10 +609,11 @@ public:
|
|||
"void main()"
|
||||
"{"
|
||||
JUCE_HIGHP " vec2 texturePos = " JUCE_MATRIX_TIMES_FRAGCOORD ";"
|
||||
"if (texturePos.x >= imageLimits.x"
|
||||
"&& texturePos.y >= imageLimits.y"
|
||||
"&& texturePos.x < imageLimits.z"
|
||||
"&& texturePos.y < imageLimits.w)"
|
||||
"const float roundingError = 0.00001;"
|
||||
"if (texturePos.x >= imageLimits.x - roundingError"
|
||||
"&& texturePos.y >= imageLimits.y - roundingError"
|
||||
"&& texturePos.x <= imageLimits.z + roundingError"
|
||||
"&& texturePos.y <= imageLimits.w + roundingError)"
|
||||
"gl_FragColor = frontColour * " JUCE_GET_IMAGE_PIXEL ".a;"
|
||||
"else "
|
||||
"gl_FragColor = vec4 (0, 0, 0, 0);"
|
||||
|
|
@ -3208,7 +3209,7 @@ private:
|
|||
return fillType.transformed (transform.getTransform());
|
||||
}
|
||||
|
||||
void fillEdgeTable (EdgeTable& et)
|
||||
void fillEdgeTable (EdgeTable& et) const
|
||||
{
|
||||
clip->fillEdgeTable (et, getFillType());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue