| 4348 | |
| 4349 | |
| 4350 | bool ScriptingApi::Content::ScriptPanel::internalRepaintIdle(bool forceRepaint, Result& r) |
| 4351 | { |
| 4352 | jassert_locked_script_thread(dynamic_cast<Processor*>(getScriptProcessor())->getMainController()); |
| 4353 | |
| 4354 | uint64_t lastId = 0; |
| 4355 | |
| 4356 | #if PERFETTO |
| 4357 | lastId = flowManager.flushAllButLastOne("paint callback", getName()); |
| 4358 | #endif |
| 4359 | |
| 4360 | const bool parentHasMovedOn = !isChildPanel && !parent->hasComponent(this); |
| 4361 | |
| 4362 | if (parentHasMovedOn || !parent->asyncFunctionsAllowed()) |
| 4363 | { |
| 4364 | return true; |
| 4365 | } |
| 4366 | |
| 4367 | HiseJavascriptEngine* engine = dynamic_cast<JavascriptProcessor*>(getScriptProcessor())->getScriptEngine(); |
| 4368 | |
| 4369 | if (engine == nullptr) |
| 4370 | return true; |
| 4371 | |
| 4372 | auto imageBounds = getBoundsForImage(); |
| 4373 | |
| 4374 | int canvasWidth = imageBounds.getWidth(); |
| 4375 | int canvasHeight = imageBounds.getHeight(); |
| 4376 | |
| 4377 | if ((!forceRepaint && !isShowing()) || canvasWidth <= 0 || canvasHeight <= 0) |
| 4378 | { |
| 4379 | return true; |
| 4380 | } |
| 4381 | |
| 4382 | var thisObject(this); |
| 4383 | var arguments = var(graphics.get()); |
| 4384 | var::NativeFunctionArgs args(thisObject, &arguments, 1); |
| 4385 | |
| 4386 | |
| 4387 | Result::ok(); |
| 4388 | |
| 4389 | if (!engine->isInitialising()) |
| 4390 | { |
| 4391 | engine->maximumExecutionTime = HiseJavascriptEngine::getDefaultTimeOut(); |
| 4392 | } |
| 4393 | |
| 4394 | engine->callExternalFunction(paintRoutine, args, &r); |
| 4395 | |
| 4396 | if (r.failed()) |
| 4397 | { |
| 4398 | debugError(dynamic_cast<Processor*>(getScriptProcessor()), r.getErrorMessage()); |
| 4399 | } |
| 4400 | |
| 4401 | graphics->getDrawHandler().flush(lastId); |
| 4402 | |
| 4403 | return true; |
| 4404 | } |
| 4405 | |
| 4406 | void ScriptingApi::Content::ScriptPanel::setLoadingCallback(var loadingCallback) |
| 4407 | { |
no test coverage detected