8#include "GPUDriverCounters.h"
45 virtual void OnIdle(
double utilization) {}
243#if defined(__APPLE__)
287 if (
this != &other) {
311 explicit operator bool()
const {
return id_ != 0; }
316 static void CancelInterval(uint64_t timer_id);
514 virtual bool RunOnce(
double max_wait_seconds = 0.0) = 0;
531 virtual void PostTask(
void (*task)(
void* user_data),
void* user_data,
532 void (*destroy_user_data)(
void* user_data) =
nullptr)
553 virtual void PostDelayedTask(
double delay_ms,
void (*task)(
void* user_data),
void* user_data,
554 void (*destroy_user_data)(
void* user_data) =
nullptr)
580 void (*callback)(
void* user_data),
582 void (*destroy_user_data)(
void* user_data)
594 template <
typename F,
typename = std::enable_if_t<std::is_invocable_v<std::decay_t<F>&>>>
596 using Fn = std::decay_t<F>;
597 auto* fn =
new Fn(std::forward<F>(callback));
598 PostTask(&detail::InvokeTaskCallable<Fn>, fn, &detail::DeleteTaskCallable<Fn>);
610 template <
typename F,
typename = std::enable_if_t<std::is_invocable_v<std::decay_t<F>&>>>
612 using Fn = std::decay_t<F>;
613 auto* fn =
new Fn(std::forward<F>(callback));
615 &detail::DeleteTaskCallable<Fn>);
631 template <
typename F,
typename = std::enable_if_t<std::is_invocable_v<std::decay_t<F>&>>>
633 using Fn = std::decay_t<F>;
634 auto* fn =
new Fn(std::forward<F>(callback));
635 return SetInterval(interval_ms, &detail::InvokeTaskCallable<Fn>, fn,
636 &detail::DeleteTaskCallable<Fn>);
676 virtual bool GetGPUDriverCounters(GPUDriverCounters& counters) {
return false; }
677 virtual bool HasDisplayLinkForTesting()
const {
return false; }
678 virtual bool DisplayLinkPausedForTesting()
const {
return false; }
#define AExport
Definition Defines.h:41
Main application singleton (use this if you want to let the library manage window creation).
Definition App.h:390
virtual Monitor * monitor(uint32_t index)
Get a monitor by index (from 0 to monitor_count() - 1).
Definition App.h:473
TimerHandle SetInterval(double interval_ms, F &&callback)
Create a repeating timer that invokes a callable on the main thread.
Definition App.h:632
virtual bool GetGPUMemoryStats(GPUMemoryStats &stats)
Get GPU memory statistics from the App's GPU driver.
Definition App.h:672
virtual TimerHandle SetInterval(double interval_ms, void(*callback)(void *user_data), void *user_data, void(*destroy_user_data)(void *user_data)=nullptr)=0
Create a repeating timer that fires on the main thread.
virtual bool is_profiler_active() const =0
Whether or not the built-in profiler is active (see Settings::enable_profiler).
virtual void PostTask(void(*task)(void *user_data), void *user_data, void(*destroy_user_data)(void *user_data)=nullptr)=0
Post a task to run on the main thread during a future update of the app's loop.
virtual void PostDelayedTask(double delay_ms, void(*task)(void *user_data), void *user_data, void(*destroy_user_data)(void *user_data)=nullptr)=0
Post a task to run on the main thread once a delay has elapsed.
virtual uint32_t monitor_count() const
Get the number of connected monitors.
Definition App.h:456
virtual RefPtr< Renderer > renderer()=0
Get the underlying Renderer instance.
virtual const Settings & settings() const =0
Get the settings this App was created with.
void PostDelayedTask(double delay_ms, F &&callback)
Post a callable to run on the main thread once a delay has elapsed.
Definition App.h:611
virtual double thread_utilization() const =0
Get the current main-thread CPU utilization (0.0-1.0), averaged over the last ~1 second.
static App * instance()
Get the App singleton (nullptr before App::Create()).
static RefPtr< App > Create(Settings settings=Settings(), Config config=Config())
Create the App singleton.
virtual Monitor * main_monitor()=0
Get the main monitor (this is never NULL).
virtual void Quit()=0
Quit the application.
virtual void Run()=0
Run the main loop (this returns after Quit()).
virtual const char * profiler_trace_path() const =0
Get the file path of the active profiler trace file.
virtual AppListener * listener()=0
Get the AppListener (can be nullptr).
virtual bool RunOnce(double max_wait_seconds=0.0)=0
Advance the app by one iteration of the main loop, on behalf of your own run loop.
virtual bool is_idle() const =0
Whether or not the app is currently considered idle (low CPU utilization and no recent user input,...
void PostTask(F &&callback)
Post a callable to run on the main thread during a future update of the app's loop.
Definition App.h:595
virtual bool is_running() const =0
Whether or not the App is running.
virtual void set_listener(AppListener *listener)=0
Set an AppListener to receive callbacks for app-related events.
Interface for all App-related events.
Definition App.h:24
virtual ~AppListener()
Definition App.h:26
virtual void OnUpdate()
Called on every update of the app's loop.
Definition App.h:33
virtual void OnIdle(double utilization)
Called when the app has been idle (low CPU use and no recent input) for a while.
Definition App.h:45
A platform-specific monitor.
Definition Monitor.h:25
Interface for all ref-counted objects that will be managed using the RefPtr<> smart pointer.
Definition RefPtr.h:49
A nullable smart pointer.
Definition RefPtr.h:126
Unicode string container with conversions for UTF-8, UTF-16, and UTF-32.
Definition String.h:31
Handle to a repeating timer created with App::SetInterval().
Definition App.h:266
TimerHandle()
Create an empty handle that refers to no timer.
Definition App.h:271
friend class AppImpl
Definition App.h:314
TimerHandle(const TimerHandle &)=delete
~TimerHandle()
Cancel the timer, if any.
Definition App.h:276
TimerHandle(TimerHandle &&other) noexcept
Move constructor (the source is left empty).
Definition App.h:281
void Cancel()
Stop the timer and destroy its user data.
Definition App.h:301
TimerHandle & operator=(const TimerHandle &)=delete
TimerHandle & operator=(TimerHandle &&other) noexcept
Move assignment.
Definition App.h:286
A native OS window that displays web content.
Definition Window.h:660
Root namespace for every public Ultralight type, function, and enumeration.
Core configuration for the renderer.
Definition Config.h:336
GPU memory statistics reported by the App's GPU driver.
Definition GPUMemoryStats.h:29
App-specific settings.
Definition App.h:51
double idle_threshold
The minimum duration of user inactivity (in seconds) before idle detection begins.
Definition App.h:139
bool enable_profiler
Whether or not to enable the built-in trace file profiler.
Definition App.h:176
double device_scale_override
Override the device scale factor for all windows.
Definition App.h:101
bool match_native_editing_behavior
Whether or not text editing in the Views this app creates should follow the host OS's native conventi...
Definition App.h:134
bool auto_font_profile
Whether or not to pick the font-appearance preset from the operating system, so text matches the plat...
Definition App.h:112
RefPtr< Bitmap > app_icon
The application icon, as a 32-bit BGRA bitmap with straight (unpremultiplied) alpha.
Definition App.h:255
bool sync_animations_to_present
Whether or not to time animations for the moment each frame appears on screen.
Definition App.h:222
double idle_utilization_threshold
The thread CPU utilization (0.0-1.0) below which the app is considered idle.
Definition App.h:150
bool use_async_gpu_driver
Whether or not to run the GPU driver's work on its own thread.
Definition App.h:246
double sustained_idle_time
The time (in seconds) the app must remain continuously idle before AppListener::OnIdle() fires,...
Definition App.h:145
String app_name
The name of this app, used with developer_name to build the per-app folders (see developer_name).
Definition App.h:76
String file_system_path
The root folder for file:/// URLs.
Definition App.h:87
bool force_cpu_renderer
Whether or not to always use the CPU renderer.
Definition App.h:93
bool full_speed_loop
Whether or not to run the app's update loop at full speed, without sleeping between updates.
Definition App.h:201
bool auto_font_families
Whether or not to pick the default font families (serif, sans-serif, monospace, etc....
Definition App.h:124
uint32_t headless_paint_fps
The paint rate (in frames per second) for windows created with WindowFlags::Hidden.
Definition App.h:186
String developer_name
The name of the developer of this app.
Definition App.h:70