Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
- Updated Gyroflow Core.
- Added `getLensIdentifier()` Rust Function.
- We now cache a Lens Profile lookup dictionary.
- Various improvements to alerts and settings.
  • Loading branch information
latenitefilms committed Aug 3, 2023
1 parent eca0171 commit 1b93bab
Show file tree
Hide file tree
Showing 5 changed files with 437 additions and 106 deletions.
2 changes: 1 addition & 1 deletion Source/Frameworks/gyroflow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ argh = "*"
serde = "1.0"
serde_json = "1.0"
libc = "0.2"
gyroflow-core = { git = "https://github.com/gyroflow/gyroflow.git", default-features = false, rev = "10c8853", features = ["bundle-lens-profiles"] }
gyroflow-core = { git = "https://github.com/gyroflow/gyroflow.git", default-features = false, rev = "2c1cd24", features = ["bundle-lens-profiles"] }
log = "0.4.17"
oslog = "0.2.0"
lazy_static = "1.4.0"
Expand Down
9 changes: 9 additions & 0 deletions Source/Frameworks/gyroflow/inc/gyroflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,12 @@ const char* loadPreset(
const char* gyroflow_project_data,
const char* lens_profile_path
);

//---------------------------------------------------------
// Gets the Lens Identifier:
//---------------------------------------------------------
const char* getLensIdentifier(
const char* gyroflow_project_data
);


72 changes: 72 additions & 0 deletions Source/Frameworks/gyroflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,78 @@ pub extern "C" fn getDefaultValues(
}
}

/// Gets the lens identifier.
///
/// # Arguments
///
/// * `gyroflow_project_data` - A pointer to a C-style string containing the Gyroflow Project data.
///
/// # Returns
///
/// A pointer to a C-style string containing the lens identifier or "FAIL".
///
/// # Safety
///
/// This function is marked as unsafe because it accepts a raw pointer as an argument. It is the caller's responsibility to ensure that the pointer is valid and points to a null-terminated string.
#[no_mangle]
pub extern "C" fn getLensIdentifier(
gyroflow_project_data: *const c_char,
) -> *const c_char {
//---------------------------------------------------------
// Convert the Gyroflow Project data to a `&str`:
//---------------------------------------------------------
let gyroflow_project_data_pointer = unsafe { CStr::from_ptr(gyroflow_project_data) };
let gyroflow_project_data_string = gyroflow_project_data_pointer.to_string_lossy();

let mut stab = StabilizationManager::default();
{
//---------------------------------------------------------
// Find first lens profile database with loaded profiles:
//---------------------------------------------------------
let lock = MANAGER_CACHE.lock().unwrap();
for (_, v) in lock.iter() {
if v.lens_profile_db.read().loaded {
stab.lens_profile_db = v.lens_profile_db.clone();
break;
}
}
}

//---------------------------------------------------------
// Import the `gyroflow_project_data_string`:
//---------------------------------------------------------
let blocking = true;
let cancel_flag = Arc::new(AtomicBool::new(false));
let mut is_preset = false;
match stab.import_gyroflow_data(
gyroflow_project_data_string.as_bytes(),
blocking,
None,
|_|(),
cancel_flag,
&mut is_preset
) {
Ok(_) => {
//---------------------------------------------------------
// Get the Lens Identifier:
//---------------------------------------------------------
let identifier = stab.lens.read().identifier.to_string();
let result = CString::new(identifier).unwrap();
return result.into_raw();
},
Err(e) => {
//---------------------------------------------------------
// An error has occurred:
//---------------------------------------------------------
log::error!("[Gyroflow Toolbox Rust] Error importing gyroflow data: {:?}", e);

let error_msg = format!("{}", e);
let result = CString::new(error_msg).unwrap();
return result.into_raw()
},
}
}

/// Checks if the official lens is loaded.
///
/// # Arguments
Expand Down
5 changes: 5 additions & 0 deletions Source/Gyroflow/Plugin/GyroflowPlugIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
NSView* exportGyroflowProjectView;
NSView* openUserGuideView;
NSView* settingsView;

//---------------------------------------------------------
// Cached Lens Profile Lookup:
//---------------------------------------------------------
NSDictionary *lensProfilesLookup;
}
@property (assign) id<PROAPIAccessing> _Nonnull apiManager;
@end
Loading

0 comments on commit 1b93bab

Please sign in to comment.