XenevaOS
Loading...
Searching...
No Matches
Macros | Functions
compose3d.h File Reference
#include <stdint.h>
#include <chitralekha.h>
#include "window.h"
Include dependency graph for compose3d.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEODHAI3D_MAX_WINDOWS   128
 
#define DEODHAI3D_MAX_REGIONS   64
 

Functions

void Deodhai3DInitialise (ChCanvas *canvas)
 Deodhai3DInitialise – set up the 3D compositor. Call once after the wallpaper is in the back surface and the screen blur is baked. Snapshots the flat wallpaper (used as the fallback panorama and to restore 2D mode). 3D mode starts disabled.
 
bool Deodhai3DLoadPanorama (const char *path)
 Deodhai3DLoadPanorama – load a 360 degree cylindrical panorama (JPEG). Without one, the flat wallpaper is wrapped with mirror repeat.
 
void Deodhai3DSetEnabled (bool enable)
 Deodhai3DSetEnabled – switch between 3D and the classic 2D compositor. Enabling places every window where it is on screen now; disabling restores the flat wallpaper and the 2D layout.
 
void Deodhai3DToggle ()
 Deodhai3DToggle – flips 3D mode.
 
bool Deodhai3DEnabled ()
 Deodhai3DEnabled – returns true while 3D mode is active.
 
void XRComposeFrame3D (ChCanvas *canvas)
 XRComposeFrame3D – the 3D compose pipeline; drop-in for XRComposeFrame (falls back to it while 3D mode is off or a window is zoomed).
 
bool Deodhai3DHandleMouse (ChCanvas *canvas, int x, int y, int button)
 Deodhai3DHandleMouse – 3D input: drag on empty space turns the camera, drag a titlebar to move a window around you, Ctrl + titlebar drag pushes it away / pulls it closer. Everything else is forwarded to the window under the cursor in the coordinates the client expects.
 
void Deodhai3DSetCamera (float yaw, float pitch)
 Deodhai3DSetCamera – set camera orientation (radians)
 
void Deodhai3DGetCamera (float *yaw, float *pitch)
 Deodhai3DGetCamera – get camera orientation (radians)
 
bool Deodhai3DWindowSetPosition (Window *win, float x, float y, float z)
 Deodhai3DWindowSetPosition – translate a window in 3D space. The window turns to face the camera.
 
bool Deodhai3DWindowGetPosition (Window *win, float *x, float *y, float *z)
 Deodhai3DWindowGetPosition – get the world position of a window.
 
bool Deodhai3DWindowPushDepth (Window *win, float factor)
 Deodhai3DWindowPushDepth – move a window along its view ray (it stays under the same screen spot, only grows / shrinks). Eased over a few frames.
 
bool Deodhai3DWindowSendToBack (Window *win)
 Deodhai3DWindowSendToBack – eases a window behind every other window (painter order is by distance, so it draws first)
 
bool Deodhai3DWindowBringToFront (Window *win)
 Deodhai3DWindowBringToFront – eases a window in front of every other window.
 
bool Deodhai3DHandleKey (int key, bool ctrl)
 Deodhai3DHandleKey – 3D keyboard shortcuts, all with Ctrl held: Ctrl+3 toggle 3D compositing Ctrl+- push the focused window back Ctrl+= pull it closer Ctrl+[ send it behind every window Ctrl+] bring it to the front.
 
bool Deodhai3DScreenToWindow (Window *win, int sx, int sy, int *lx, int *ly)
 Deodhai3DScreenToWindow – maps a screen pixel onto a window's own pixel grid using the last composed frame.
 

Macro Definition Documentation

◆ DEODHAI3D_MAX_REGIONS

#define DEODHAI3D_MAX_REGIONS   64

◆ DEODHAI3D_MAX_WINDOWS

#define DEODHAI3D_MAX_WINDOWS   128

BSD 2-Clause License

Copyright (c) 2022-2026, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. DeodhaiXR 3D compositor (software).

World model – the camera sits at the origin and can only rotate:

  • yaw : true 3D rotation about the vertical axis
  • pitch : y-shearing (the screen image slides vertically), which keeps every window a planar, perspective-correct quad and keeps the panorama lookup a pure table walk World units are window pixels: a window at a depth equal to the focal length (screen width / 2 at the 90 degree field of view) facing the camera appears exactly 1:1, which is where every window is placed when 3D mode is switched on (so nothing jumps).

Layers, back to front:

  1. panorama – a cylindrical wallpaper rendered into the back surface (DeoGetBackSurface), so every existing restore path (DeodhaiBackSurfaceUpdate, alpha HUD blends, the glass blur bake) keeps working unchanged
  2. normal windows – textured quads, painter-sorted by depth; popups ride on their parent's plane
  3. HUD – always-on-top windows (dock, launcher, systray) stay screen-locked and go through the existing 2D composers
  4. cursor

Zoomed windows are screen-locked by definition: while one is visible the frame is delegated to XRComposeFrame unchanged.

Cost per frame (N windows, R repaint regions):

  • bookkeeping : O(N) – hash lookup by Window*, insertion sort on a nearly sorted list, one sync per frame
  • idle / client damage : O(damaged screen area x overlapping windows), same shape as the 2D dirty path
  • window moved/eased : O(old + new projected area)
  • camera moved : O(screen pixels) for the panorama: per column work hoisted to an O(W) table each frame, four columns per NEON step, 2x2 blocks while dragging
  • window pixels : O(projected area), exact per-scanline spans; 1:1 rows blend straight from the source with NEON, perspective rows sample exactly every <=16 pixels (error < 1/4 texel) and step in fixed point, then blend with NEON

Function Documentation

◆ Deodhai3DEnabled()

bool Deodhai3DEnabled ( )
extern

Deodhai3DEnabled – returns true while 3D mode is active.

◆ Deodhai3DGetCamera()

void Deodhai3DGetCamera ( float *  yaw,
float *  pitch 
)
extern

Deodhai3DGetCamera – get camera orientation (radians)

◆ Deodhai3DHandleKey()

bool Deodhai3DHandleKey ( int  key,
bool  ctrl 
)
extern

Deodhai3DHandleKey – 3D keyboard shortcuts, all with Ctrl held: Ctrl+3 toggle 3D compositing Ctrl+- push the focused window back Ctrl+= pull it closer Ctrl+[ send it behind every window Ctrl+] bring it to the front.

Parameters
key– character from ChitralekhaGetKeyPress
ctrl– Ctrl state
Returns
true if the key was consumed (do not forward to the window)

Deodhai3DHandleKey – 3D keyboard shortcuts, all with Ctrl held: Ctrl+3 toggle 3D compositing Ctrl+- push the focused window back Ctrl+= pull it closer Ctrl+[ send it behind every window Ctrl+] bring it to the front.

◆ Deodhai3DHandleMouse()

bool Deodhai3DHandleMouse ( ChCanvas *  canvas,
int  x,
int  y,
int  button 
)
extern

Deodhai3DHandleMouse – 3D input: drag on empty space turns the camera, drag a titlebar to move a window around you, Ctrl + titlebar drag pushes it away / pulls it closer. Everything else is forwarded to the window under the cursor in the coordinates the client expects.

Parameters
canvas– Pointer to the system canvas
x– Mouse x location
y– Mouse y location
button– Mouse button state
Returns
true if the event was consumed (skip the 2D handlers)

Deodhai3DHandleMouse – 3D input: drag on empty space turns the camera, drag a titlebar to move a window around you, Ctrl + titlebar drag pushes it away / pulls it closer. Everything else is forwarded to the window under the cursor in the coordinates the client expects.

◆ Deodhai3DInitialise()

void Deodhai3DInitialise ( ChCanvas *  canvas)
extern

Deodhai3DInitialise – set up the 3D compositor. Call once after the wallpaper is in the back surface and the screen blur is baked. Snapshots the flat wallpaper (used as the fallback panorama and to restore 2D mode). 3D mode starts disabled.

Parameters
canvas– Pointer to the system canvas

Deodhai3DInitialise – set up the 3D compositor. Call once after the wallpaper is in the back surface and the screen blur is baked. Snapshots the flat wallpaper (used as the fallback panorama and to restore 2D mode). 3D mode starts disabled.

◆ Deodhai3DLoadPanorama()

bool Deodhai3DLoadPanorama ( const char *  path)
extern

Deodhai3DLoadPanorama – load a 360 degree cylindrical panorama (JPEG). Without one, the flat wallpaper is wrapped with mirror repeat.

Parameters
path– path of the jpeg
Returns
true when the panorama replaced the current texture

Deodhai3DLoadPanorama – load a 360 degree cylindrical panorama (JPEG). Without one, the flat wallpaper is wrapped with mirror repeat.

◆ Deodhai3DScreenToWindow()

bool Deodhai3DScreenToWindow ( Window *  win,
int  sx,
int  sy,
int *  lx,
int *  ly 
)
extern

Deodhai3DScreenToWindow – maps a screen pixel onto a window's own pixel grid using the last composed frame.

Returns
true when the pixel lands on the window

Deodhai3DScreenToWindow – maps a screen pixel onto a window's own pixel grid using the last composed frame.

◆ Deodhai3DSetCamera()

void Deodhai3DSetCamera ( float  yaw,
float  pitch 
)
extern

Deodhai3DSetCamera – set camera orientation (radians)

Parameters
yaw– rotation about the vertical axis, + turns right
pitch– + looks up; clamped to +-DEODHAI3D_PITCH_LIMIT

◆ Deodhai3DSetEnabled()

void Deodhai3DSetEnabled ( bool  enable)
extern

Deodhai3DSetEnabled – switch between 3D and the classic 2D compositor. Enabling places every window where it is on screen now; disabling restores the flat wallpaper and the 2D layout.

Deodhai3DSetEnabled – switch between 3D and the classic 2D compositor. Enabling places every window where it is on screen now; disabling restores the flat wallpaper and the 2D layout.

◆ Deodhai3DToggle()

void Deodhai3DToggle ( )
extern

Deodhai3DToggle – flips 3D mode.

◆ Deodhai3DWindowBringToFront()

bool Deodhai3DWindowBringToFront ( Window *  win)
extern

Deodhai3DWindowBringToFront – eases a window in front of every other window.

Deodhai3DWindowBringToFront – eases a window in front of every other window.

◆ Deodhai3DWindowGetPosition()

bool Deodhai3DWindowGetPosition ( Window *  win,
float *  x,
float *  y,
float *  z 
)
extern

Deodhai3DWindowGetPosition – get the world position of a window.

◆ Deodhai3DWindowPushDepth()

bool Deodhai3DWindowPushDepth ( Window *  win,
float  factor 
)
extern

Deodhai3DWindowPushDepth – move a window along its view ray (it stays under the same screen spot, only grows / shrinks). Eased over a few frames.

Parameters
win– Pointer to window (a popup moves its parent)
factor– distance multiplier: > 1 pushes back, < 1 pulls closer

Deodhai3DWindowPushDepth – move a window along its view ray (it stays under the same screen spot, only grows / shrinks). Eased over a few frames.

◆ Deodhai3DWindowSendToBack()

bool Deodhai3DWindowSendToBack ( Window *  win)
extern

Deodhai3DWindowSendToBack – eases a window behind every other window (painter order is by distance, so it draws first)

Deodhai3DWindowSendToBack – eases a window behind every other window (painter order is by distance, so it draws first)

◆ Deodhai3DWindowSetPosition()

bool Deodhai3DWindowSetPosition ( Window *  win,
float  x,
float  y,
float  z 
)
extern

Deodhai3DWindowSetPosition – translate a window in 3D space. The window turns to face the camera.

Parameters
win– Pointer to window
x,y,z– world position of the window centre (pixel units, +x right, +y down, +z forward)
Returns
false if the window is unknown or the slot table is full

Deodhai3DWindowSetPosition – translate a window in 3D space. The window turns to face the camera.

◆ XRComposeFrame3D()

void XRComposeFrame3D ( ChCanvas *  canvas)
extern

XRComposeFrame3D – the 3D compose pipeline; drop-in for XRComposeFrame (falls back to it while 3D mode is off or a window is zoomed).

Parameters
canvas– Pointer to the system canvas

XRComposeFrame3D – the 3D compose pipeline; drop-in for XRComposeFrame (falls back to it while 3D mode is off or a window is zoomed).