|
PebbleOS
|
Composes the app framebuffer and modal windows into the display framebuffer. More...
Modules | |
| Display flush | |
| Copies the dirty region of the system framebuffer to the display driver. | |
| Transitions | |
| Ready-made compositor transitions and helpers to build new ones. | |
| Default transitions | |
| Compositor transitions of the current design. | |
| Legacy transitions | |
| Slide transitions used on 1-bit displays. | |
| Screenshot protocol | |
| Pebble Protocol endpoint that sends the system framebuffer to the phone. | |
Data Structures | |
| struct | CompositorTransition |
| Implementation of a compositor transition animation. More... | |
Typedefs | |
| typedef void(* | CompositorTransitionInitFunc) (Animation *animation) |
| Set up the transition animation. | |
| typedef void(* | CompositorTransitionUpdateFunc) (GContext *ctx, Animation *animation, uint32_t distance_normalized) |
| Draw one frame of a transition. | |
| typedef void(* | CompositorTransitionTeardownFunc) (Animation *animation) |
| Clean up after a transition finished or was cancelled. | |
| typedef struct FrameBuffer | FrameBuffer |
Opaque framebuffer type, see applib/graphics/framebuffer.h. | |
| typedef void(* | CompositorFrozenCallback) (void *data) |
| Called once the compositor is frozen. | |
Enumerations | |
| enum | CompositorTransitionDirection { CompositorTransitionDirectionUp , CompositorTransitionDirectionDown , CompositorTransitionDirectionLeft , CompositorTransitionDirectionRight , CompositorTransitionDirectionNone } |
| Transition direction, from the current position to the next. More... | |
Functions | |
| void | compositor_init (void) |
| Initialize the compositor. | |
| void | compositor_transition (const CompositorTransition *impl) |
| Start a transition. | |
| void | compositor_transition_render (CompositorTransitionUpdateFunc func, Animation *animation, const AnimationProgress distance_normalized) |
| Render one transition frame with the given update function. | |
| void | compositor_render_app (void) |
| Write the app framebuffer into the system framebuffer. | |
| void | compositor_render_modal (void) |
| Render the modal window stack into the system framebuffer. | |
| void | compositor_modal_render_ready (void) |
| Notify that the modal needs to redraw itself to the display. | |
| void | compositor_app_render_ready (void) |
| Notify that the app has a new frame for the display. | |
| FrameBuffer * | compositor_get_framebuffer (void) |
| Get the system framebuffer. | |
| GBitmap | compositor_get_framebuffer_as_bitmap (void) |
| Get the system framebuffer as a bitmap. | |
| GBitmap | compositor_get_app_framebuffer_as_bitmap (void) |
| Get the app framebuffer as a bitmap. | |
| bool | compositor_is_animating (void) |
| Check whether a transition between apps or modals is in progress. | |
| void | compositor_set_modal_transition_offset (GPoint modal_offset) |
| Set the offset at which modals are drawn during transitions that redraw them. | |
| void | compositor_transition_cancel (void) |
| Stop the current transition, if any; its teardown completes the switch. | |
| void | compositor_freeze (CompositorFrozenCallback callback, void *data) |
| Stop new frames from the app or the modal reaching the display. | |
| void | compositor_unfreeze (void) |
| Resume pushing frames to the display, undoing compositor_freeze(). | |
| void | compositor_scaled_app_fb_copy (const GRect update_rect, bool copy_relative_to_origin) |
| Copy part of the app framebuffer into the system framebuffer. | |
| void | compositor_scaled_app_fb_copy_offset (const GRect update_rect, bool copy_relative_to_origin, int16_t offset_y) |
| compositor_scaled_app_fb_copy() with a vertical offset applied to the source. | |
| void | compositor_app_framebuffer_fill_callback (GContext *ctx, int16_t y, Fixed_S16_3 x_range_begin, Fixed_S16_3 x_range_end, Fixed_S16_3 delta_begin, Fixed_S16_3 delta_end, void *user_data) |
| GPathDrawFilledCallback filling a span with the app framebuffer. | |
Composes the app framebuffer and modal windows into the display framebuffer.
The compositor owns the system framebuffer and flushes it to the display. It manages two sources:
Changes between apps or modals can be animated with a CompositorTransition. All functions run on KernelMain unless noted otherwise.
| struct CompositorTransition |
Implementation of a compositor transition animation.
| Data Fields | ||
|---|---|---|
| CompositorTransitionInitFunc | init | Mandatory initialization function. |
| bool | skip_modal_render_after_update | If false, modals are rendered after each update; if true, they are skipped. |
| CompositorTransitionTeardownFunc | teardown | Optional teardown function. |
| CompositorTransitionUpdateFunc | update | Mandatory update function. |
| typedef void(* CompositorFrozenCallback) (void *data) |
Called once the compositor is frozen.
| data | Data passed to compositor_freeze(). |
| typedef void(* CompositorTransitionInitFunc) (Animation *animation) |
Set up the transition animation.
Typically sets the duration and curve, and may stash configuration in the animation context.
| animation | Animation driving the transition. |
| typedef void(* CompositorTransitionTeardownFunc) (Animation *animation) |
Clean up after a transition finished or was cancelled.
| animation | Animation driving the transition. |
| typedef void(* CompositorTransitionUpdateFunc) (GContext *ctx, Animation *animation, uint32_t distance_normalized) |
Draw one frame of a transition.
| ctx | Kernel graphics context drawing into the system framebuffer. Its draw state is restored after the call. |
| animation | Animation driving the transition. |
| distance_normalized | Animation progress, 0 to ANIMATION_NORMALIZED_MAX. |
| typedef struct FrameBuffer FrameBuffer |
Opaque framebuffer type, see applib/graphics/framebuffer.h.
Transition direction, from the current position to the next.
For example, Up is a transition to an item that lies above the current screen.
| void compositor_app_framebuffer_fill_callback | ( | GContext * | ctx, |
| int16_t | y, | ||
| Fixed_S16_3 | x_range_begin, | ||
| Fixed_S16_3 | x_range_end, | ||
| Fixed_S16_3 | delta_begin, | ||
| Fixed_S16_3 | delta_end, | ||
| void * | user_data | ||
| ) |
GPathDrawFilledCallback filling a span with the app framebuffer.
Copies the matching pixels of the app framebuffer into the span, for transitions that reveal the app through a path.
| ctx | Graphics context being drawn into. |
| y | Row of the span. |
| x_range_begin | Start of the span. |
| x_range_end | End of the span. |
| delta_begin | Unused. |
| delta_end | Unused. |
| user_data | Optional const GPoint * offset of the app framebuffer, or NULL. |
| void compositor_app_render_ready | ( | void | ) |
Notify that the app has a new frame for the display.
Also starts a pending app transition once the app has rendered its first frame. The app framebuffer is released back to the app once copied, or when the transition completes.
| void compositor_freeze | ( | CompositorFrozenCallback | callback, |
| void * | data | ||
| ) |
Stop new frames from the app or the modal reaching the display.
Callable from any task. callback runs on KernelMain once the freeze is in effect and no display update is in flight, at which point the system framebuffer is stable until compositor_unfreeze(). Only one freeze may be outstanding at a time.
| callback | Called once frozen. |
| data | Passed to callback. |
| GBitmap compositor_get_app_framebuffer_as_bitmap | ( | void | ) |
Get the app framebuffer as a bitmap.
The bounds are set from app_manager_get_framebuffer_size() rather than the size stored in the app framebuffer, which the app could modify.
| FrameBuffer * compositor_get_framebuffer | ( | void | ) |
Get the system framebuffer.
| GBitmap compositor_get_framebuffer_as_bitmap | ( | void | ) |
Get the system framebuffer as a bitmap.
| void compositor_init | ( | void | ) |
Initialize the compositor.
Clears the system framebuffer and resets the state to showing the app.
| bool compositor_is_animating | ( | void | ) |
Check whether a transition between apps or modals is in progress.
| void compositor_modal_render_ready | ( | void | ) |
Notify that the modal needs to redraw itself to the display.
Ignored while a transition drives the display or a display update is in progress.
| void compositor_render_app | ( | void | ) |
Write the app framebuffer into the system framebuffer.
Clears the system framebuffer to black, copies the app framebuffer (scaled or centered as needed) and renders the modals on top when they are transparent. Must run on KernelMain.
| void compositor_render_modal | ( | void | ) |
Render the modal window stack into the system framebuffer.
Uses the kernel graphics context, offset by the modal transition offset.
| void compositor_scaled_app_fb_copy | ( | const GRect | update_rect, |
| bool | copy_relative_to_origin | ||
| ) |
Copy part of the app framebuffer into the system framebuffer.
The app framebuffer content is scaled or centered in the destination as needed, based on user preference. The region is clipped to the display.
| update_rect | Region of the system framebuffer to update. |
| copy_relative_to_origin | If false, the region is filled from the origin of the app framebuffer; if true, from the same region of the app framebuffer. |
| void compositor_scaled_app_fb_copy_offset | ( | const GRect | update_rect, |
| bool | copy_relative_to_origin, | ||
| int16_t | offset_y | ||
| ) |
compositor_scaled_app_fb_copy() with a vertical offset applied to the source.
| update_rect | Region of the system framebuffer to update. |
| copy_relative_to_origin | See compositor_scaled_app_fb_copy(). |
| offset_y | Vertical offset of the source, in pixels. |
| void compositor_set_modal_transition_offset | ( | GPoint | modal_offset | ) |
Set the offset at which modals are drawn during transitions that redraw them.
| modal_offset | Offset from the display origin. |
| void compositor_transition | ( | const CompositorTransition * | impl | ) |
Start a transition.
A transition already underway is cancelled and replaced by this one. If a display update is in flight or the compositor is frozen, the start is deferred until it can render.
For modal windows, the destination modal must already be on top of the modal window stack. For apps, the destination app must be running, and the animation only begins once it has rendered its first frame.
| impl | Transition implementation, or NULL to switch without animation. |
| void compositor_transition_cancel | ( | void | ) |
Stop the current transition, if any; its teardown completes the switch.
| void compositor_transition_render | ( | CompositorTransitionUpdateFunc | func, |
| Animation * | animation, | ||
| const AnimationProgress | distance_normalized | ||
| ) |
Render one transition frame with the given update function.
The animation set up by compositor_transition() calls this automatically. Call it from an animation scheduled inside a transition (e.g. one in an animation sequence) so its frames are rendered, deferred and flushed like those of the transition itself.
| func | Update function drawing the frame. |
| animation | Animation passed to func. |
| distance_normalized | Animation progress passed to func. |
| void compositor_unfreeze | ( | void | ) |
Resume pushing frames to the display, undoing compositor_freeze().
Renders deferred while frozen run on KernelMain.