Skip to content

Commit f81c48f

Browse files
committed
Initial image implementation.
1 parent 18f5146 commit f81c48f

File tree

16 files changed

+530
-216
lines changed

16 files changed

+530
-216
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/images/logo.png

66.8 KB
Loading

crates/processing_ffi/src/lib.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,43 @@ pub extern "C" fn processing_init() {
2626
/// - window_handle is a valid GLFW window pointer.
2727
/// - This is called from the same thread as init.
2828
#[unsafe(no_mangle)]
29-
pub extern "C" fn processing_create_surface(
29+
pub extern "C" fn processing_surface_create(
3030
window_handle: u64,
3131
display_handle: u64,
3232
width: u32,
3333
height: u32,
3434
scale_factor: f32,
3535
) -> u64 {
3636
error::clear_error();
37-
error::check(|| create_surface(window_handle, display_handle, width, height, scale_factor))
37+
error::check(|| surface_create(window_handle, display_handle, width, height, scale_factor))
3838
.map(|e| e.to_bits())
3939
.unwrap_or(0)
4040
}
4141

4242
/// Destroy the surface associated with the given window ID.
4343
///
4444
/// SAFETY:
45-
/// - Init and create_surface have been called.
46-
/// - window_id is a valid ID returned from create_surface.
45+
/// - Init and surface_create have been called.
46+
/// - window_id is a valid ID returned from surface_create.
4747
/// - This is called from the same thread as init.
4848
#[unsafe(no_mangle)]
49-
pub extern "C" fn processing_destroy_surface(window_id: u64) {
49+
pub extern "C" fn processing_surface_destroy(window_id: u64) {
5050
error::clear_error();
5151
let window_entity = Entity::from_bits(window_id);
52-
error::check(|| destroy_surface(window_entity));
52+
error::check(|| surface_destroy(window_entity));
5353
}
5454

5555
/// Update window size when resized.
5656
///
5757
/// SAFETY:
58-
/// - Init and create_surface have been called.
59-
/// - window_id is a valid ID returned from create_surface.
58+
/// - Init and surface_create have been called.
59+
/// - window_id is a valid ID returned from surface_create.
6060
/// - This is called from the same thread as init.
6161
#[unsafe(no_mangle)]
62-
pub extern "C" fn processing_resize_surface(window_id: u64, width: u32, height: u32) {
62+
pub extern "C" fn processing_surface_resize(window_id: u64, width: u32, height: u32) {
6363
error::clear_error();
6464
let window_entity = Entity::from_bits(window_id);
65-
error::check(|| resize_surface(window_entity, width, height));
65+
error::check(|| surface_resize(window_entity, width, height));
6666
}
6767

6868
/// Set the background color for the given window.
@@ -126,8 +126,8 @@ pub extern "C" fn processing_exit(exit_code: u8) {
126126
/// Set the fill color.
127127
///
128128
/// SAFETY:
129-
/// - Init and create_surface have been called.
130-
/// - window_id is a valid ID returned from create_surface.
129+
/// - Init and surface_create have been called.
130+
/// - window_id is a valid ID returned from surface_create.
131131
/// - This is called from the same thread as init.
132132
#[unsafe(no_mangle)]
133133
pub extern "C" fn processing_set_fill(window_id: u64, r: f32, g: f32, b: f32, a: f32) {
@@ -140,8 +140,8 @@ pub extern "C" fn processing_set_fill(window_id: u64, r: f32, g: f32, b: f32, a:
140140
/// Set the stroke color.
141141
///
142142
/// SAFETY:
143-
/// - Init and create_surface have been called.
144-
/// - window_id is a valid ID returned from create_surface.
143+
/// - Init and surface_create have been called.
144+
/// - window_id is a valid ID returned from surface_create.
145145
/// - This is called from the same thread as init.
146146
#[unsafe(no_mangle)]
147147
pub extern "C" fn processing_set_stroke_color(window_id: u64, r: f32, g: f32, b: f32, a: f32) {
@@ -154,8 +154,8 @@ pub extern "C" fn processing_set_stroke_color(window_id: u64, r: f32, g: f32, b:
154154
/// Set the stroke weight.
155155
///
156156
/// SAFETY:
157-
/// - Init and create_surface have been called.
158-
/// - window_id is a valid ID returned from create_surface.
157+
/// - Init and surface_create have been called.
158+
/// - window_id is a valid ID returned from surface_create.
159159
/// - This is called from the same thread as init.
160160
#[unsafe(no_mangle)]
161161
pub extern "C" fn processing_set_stroke_weight(window_id: u64, weight: f32) {
@@ -167,8 +167,8 @@ pub extern "C" fn processing_set_stroke_weight(window_id: u64, weight: f32) {
167167
/// Disable fill for subsequent shapes.
168168
///
169169
/// SAFETY:
170-
/// - Init and create_surface have been called.
171-
/// - window_id is a valid ID returned from create_surface.
170+
/// - Init and surface_create have been called.
171+
/// - window_id is a valid ID returned from surface_create.
172172
/// - This is called from the same thread as init.
173173
#[unsafe(no_mangle)]
174174
pub extern "C" fn processing_no_fill(window_id: u64) {
@@ -180,8 +180,8 @@ pub extern "C" fn processing_no_fill(window_id: u64) {
180180
/// Disable stroke for subsequent shapes.
181181
///
182182
/// SAFETY:
183-
/// - Init and create_surface have been called.
184-
/// - window_id is a valid ID returned from create_surface.
183+
/// - Init and surface_create have been called.
184+
/// - window_id is a valid ID returned from surface_create.
185185
/// - This is called from the same thread as init.
186186
#[unsafe(no_mangle)]
187187
pub extern "C" fn processing_no_stroke(window_id: u64) {
@@ -193,8 +193,8 @@ pub extern "C" fn processing_no_stroke(window_id: u64) {
193193
/// Draw a rectangle.
194194
///
195195
/// SAFETY:
196-
/// - Init and create_surface have been called.
197-
/// - window_id is a valid ID returned from create_surface.
196+
/// - Init and surface_create have been called.
197+
/// - window_id is a valid ID returned from surface_create.
198198
/// - This is called from the same thread as init.
199199
#[unsafe(no_mangle)]
200200
pub extern "C" fn processing_rect(

crates/processing_render/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ raw-window-handle = "0.6"
1313
thiserror = "2"
1414
tracing = "0.1"
1515
tracing-subscriber = "0.3"
16+
half = "2.7"
17+
crossbeam-channel = "0.5"
1618

1719
[target.'cfg(target_os = "macos")'.dependencies]
1820
objc2 = { version = "0.6", default-features = false }

crates/processing_render/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ pub enum ProcessingError {
1414
HandleError(#[from] raw_window_handle::HandleError),
1515
#[error("Invalid window handle provided")]
1616
InvalidWindowHandle,
17+
#[error("Image not found")]
18+
ImageNotFound,
19+
#[error("Unsupported texture format")]
20+
UnsupportedTextureFormat,
1721
}

0 commit comments

Comments
 (0)