| 2591 | } |
| 2592 | |
| 2593 | bool ScriptingObjects::ScriptedLookAndFeel::callWithGraphics(Graphics& g_, const Identifier& functionname, var argsObject, Component* c) |
| 2594 | { |
| 2595 | #if PERFETTO |
| 2596 | |
| 2597 | dispatch::StringBuilder n; |
| 2598 | |
| 2599 | if(c != nullptr) |
| 2600 | n << c->getName() << "."; |
| 2601 | |
| 2602 | n << functionname << "()"; |
| 2603 | |
| 2604 | TRACE_SCRIPTING(DYNAMIC_STRING_BUILDER(n)); |
| 2605 | |
| 2606 | #endif |
| 2607 | |
| 2608 | // If this hits, you need to add that id to the array above. |
| 2609 | jassert(getAllFunctionNames().contains(functionname)); |
| 2610 | |
| 2611 | |
| 2612 | if (!lastResult.wasOk()) |
| 2613 | return false; |
| 2614 | |
| 2615 | auto f = functions.getProperty(functionname, {}); |
| 2616 | |
| 2617 | if (HiseJavascriptEngine::isJavascriptFunction(f)) |
| 2618 | { |
| 2619 | ReferenceCountedObjectPtr<GraphicsObject> g; |
| 2620 | |
| 2621 | for(auto& gr: graphics) |
| 2622 | { |
| 2623 | if(gr.c == c && gr.functionName == functionname) |
| 2624 | { |
| 2625 | g = gr.g; |
| 2626 | break; |
| 2627 | } |
| 2628 | } |
| 2629 | |
| 2630 | if(g == nullptr) |
| 2631 | { |
| 2632 | GraphicsWithComponent gr; |
| 2633 | gr.g = new GraphicsObject(getScriptProcessor(), this); |
| 2634 | gr.c = c; |
| 2635 | gr.functionName = functionname; |
| 2636 | graphics.add(gr); |
| 2637 | g = gr.g; |
| 2638 | } |
| 2639 | |
| 2640 | var args[2]; |
| 2641 | |
| 2642 | args[0] = var(g.get()); |
| 2643 | args[1] = argsObject; |
| 2644 | |
| 2645 | var thisObject(this); |
| 2646 | |
| 2647 | |
| 2648 | |
| 2649 | { |
| 2650 | if (auto sl = SimpleReadWriteLock::ScopedTryReadLock(getScriptProcessor()->getMainController_()->getJavascriptThreadPool().getLookAndFeelRenderLock())) |
no test coverage detected