Skip to content

Commit

Permalink
ndk: Add ASurfaceControl bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Aug 5, 2024
1 parent 6175ea0 commit 23cfdc7
Show file tree
Hide file tree
Showing 5 changed files with 1,251 additions and 5 deletions.
1 change: 1 addition & 0 deletions ndk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

- image_reader: Add `ImageReader::new_with_data_space()` constructor and `ImageReader::data_space()` getter from API level 34. (#474)
- Add `ASurfaceControl` and `ASurfaceTransaction` bindings. (#TODO)

# 0.9.0 (2024-04-26)

Expand Down
14 changes: 13 additions & 1 deletion ndk/src/data_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ pub enum DataSpace {
__Unknown(i32),
}

impl From<DataSpace> for ffi::ADataSpace {
fn from(val: DataSpace) -> Self {
Self(val.into())
}
}

impl From<ffi::ADataSpace> for DataSpace {
fn from(val: ffi::ADataSpace) -> Self {
Self::from(val.0)
}
}

impl fmt::Display for DataSpace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Expand Down Expand Up @@ -425,7 +437,7 @@ pub enum DataSpaceStandard {
/// Use the unadjusted `KR = 0.2627`, `KB = 0.0593` luminance interpretation for `RGB`
/// conversion using the linear domain.
#[doc(alias = "STANDARD_BT2020_CONSTANT_LUMINANCE")]
Bt2020ConstantLuminance = ffi::ADataSpace::STANDARD_BT2020_CONSTANT_LUMINANCE.0,
Bt2020ConstantLuminance = ffi::ADataSpace::ADATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE.0,
/// | Primaries | x | y |
/// | --------- | ----- | ---- |
/// | green | 0.21 |0.71 |
Expand Down
1 change: 1 addition & 0 deletions ndk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub mod media_error;
pub mod native_activity;
pub mod native_window;
pub mod shared_memory;
pub mod surface_control;
pub mod surface_texture;
pub mod sync;
pub mod trace;
Expand Down
8 changes: 4 additions & 4 deletions ndk/src/native_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl NativeWindow {
/// may choose a display refresh rate to better match this window's frame rate. Usage of this
/// API won't introduce frame rate throttling, or affect other aspects of the application's
/// frame production pipeline. However, because the system may change the display refresh rate,
/// calls to this function may result in changes to Choreographer callback timings, and changes
/// calls to this function may result in changes to `Choreographer` callback timings, and changes
/// to the time interval at which the system releases buffers back to the application.
///
/// Note that this only has an effect for windows presented on the display. If this
Expand Down Expand Up @@ -390,7 +390,7 @@ impl<'a> Drop for NativeWindowBufferLockGuard<'a> {
}
}

#[cfg(all(feature = "nativewindow", feature = "api-level-26"))]
#[cfg(feature = "api-level-26")]
bitflags::bitflags! {
/// Transforms that can be applied to buffers as they are displayed to a window.
///
Expand Down Expand Up @@ -426,7 +426,7 @@ bitflags::bitflags! {
doc = " and [`NativeWindow::set_frame_rate_with_change_strategy()`]"
)]
/// .
#[cfg(all(feature = "nativewindow", feature = "api-level-30"))]
#[cfg(feature = "api-level-30")]
#[repr(i8)]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
#[doc(alias = "ANativeWindow_FrameRateCompatibility")]
Expand All @@ -453,7 +453,7 @@ pub enum FrameRateCompatibility {
}

/// Change frame rate strategy value for [`NativeWindow::set_frame_rate_with_change_strategy()`].
#[cfg(all(feature = "nativewindow", feature = "api-level-31"))]
#[cfg(feature = "api-level-31")]
#[repr(i8)]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
#[doc(alias = "ANativeWindow_ChangeFrameRateStrategy")]
Expand Down
Loading

0 comments on commit 23cfdc7

Please sign in to comment.