use rust_widgets::core::PlatformFamily;
use rust_widgets::platform::portable::copy_rows;
use rust_widgets::platform::profile;
use rust_widgets::platform::types::default_capabilities_for;
#[cfg(not(alloc_frugal))]
use rust_widgets::platform::{self};
use rust_widgets::platform::{FrameBuffer, PlatformCapabilities, SurfaceGeometry};
fn main() {
println!("DEMO_PROFILE={}", profile::profile_name());
#[cfg(not(alloc_frugal))]
println!("BACKEND={}", platform::backend_name());
println!("HAS_OS_RUNTIME={}", profile::has_os_runtime());
println!("FULL_WIDGET_SET={}", profile::full_widget_set());
println!("ALLOC_FRUGAL={}", profile::is_alloc_frugal());
println!("SUPPORTS_SURFACES={}", rust_widgets::supports_surfaces());
let applied = rust_widgets::render_engine::set_embedded_target_fps(60);
println!("APPLIED_FPS={applied}");
println!("TARGET_FPS={}", rust_widgets::render_engine::embedded_target_fps());
let task_id =
rust_widgets::render_engine::submit_embedded_task("embedded-host-tick", |frame_index| {
println!("TASK_RAN_ON_FRAME={frame_index}");
});
println!("TASK_ID={task_id}");
let width = 320u32;
let height = 240u32;
let geometry = SurfaceGeometry { width, height, stride: width as usize * 4 + 16 };
let mut frame = FrameBuffer::new();
if !frame.resize(geometry) {
eprintln!("surface geometry rejected");
return;
}
println!("SURFACE_BYTES={}", frame.frame().len());
let row_count = geometry.stride * height as usize;
let source = vec![0xABu8; row_count];
let mut destination = vec![0u8; row_count];
let copied = copy_rows(&source, &mut destination, geometry);
println!("COPY_ROWS_OK={copied}");
let stats = rust_widgets::render_engine::embedded_engine_stats();
println!("ENGINE_INITIALIZED={}", stats.initialized);
println!("ENGINE_RUNNING={}", stats.running);
println!("FRAME_COUNT={}", stats.frame_count);
println!("PENDING_TASKS={}", stats.pending_task_count);
println!("WINDOW_COUNT={}", stats.window_count);
println!("BUTTON_COUNT={}", stats.button_count);
let expected: PlatformCapabilities = default_capabilities_for(PlatformFamily::Embedded);
println!("EXPECTED_EMBEDDED_DPI_SCALING={}", expected.dpi_scaling);
println!("EXPECTED_EMBEDDED_IME={}", expected.ime);
println!("EXPECTED_EMBEDDED_NATIVE_MENU={}", expected.native_menu);
#[cfg(not(alloc_frugal))]
{
let live = platform::capabilities();
println!("LIVE_DPI_SCALING={}", live.dpi_scaling);
println!("LIVE_IME={}", live.ime);
println!("LIVE_NATIVE_MENU={}", live.native_menu);
}
#[cfg(not(alloc_frugal))]
platform::quit();
println!("DONE");
}