Skip to content

Commit c43a005

Browse files
Treehugger Robotandroid-build-merge-worker-robot
authored andcommitted
Merge "Improve formatting of doc comments and add more details." into main am: bcd6336
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/3315653 Change-Id: I798c16aa6f675018e700aca2c93ae499e9f74a35 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2 parents 849c93e + bcd6336 commit c43a005

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

  • libs/nativewindow/rust/src

libs/nativewindow/rust/src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ impl HardwareBuffer {
203203
Self(buffer_ptr)
204204
}
205205

206-
/// Creates a new Rust HardwareBuffer to wrap the given AHardwareBuffer without taking ownership
207-
/// of it.
206+
/// Creates a new Rust HardwareBuffer to wrap the given `AHardwareBuffer` without taking
207+
/// ownership of it.
208208
///
209209
/// Unlike [`from_raw`](Self::from_raw) this method will increment the refcount on the buffer.
210210
/// This means that the caller can continue to use the raw buffer it passed in, and must call
@@ -220,14 +220,20 @@ impl HardwareBuffer {
220220
Self(buffer)
221221
}
222222

223-
/// Get the internal `AHardwareBuffer` pointer that is only valid when this `HardwareBuffer`
224-
/// exists. This can be used to provide a pointer to the AHB for a C/C++ API over the FFI.
223+
/// Returns the internal `AHardwareBuffer` pointer.
224+
///
225+
/// This is only valid as long as this `HardwareBuffer` exists, so shouldn't be stored. It can
226+
/// be used to provide a pointer for a C/C++ API over FFI.
225227
pub fn as_raw(&self) -> NonNull<AHardwareBuffer> {
226228
self.0
227229
}
228230

229-
/// Get the internal `AHardwareBuffer` pointer without decrementing the refcount. This can
230-
/// be used to provide a pointer to the AHB for a C/C++ API over the FFI.
231+
/// Gets the internal `AHardwareBuffer` pointer without decrementing the refcount. This can
232+
/// be used for a C/C++ API which takes ownership of the pointer.
233+
///
234+
/// The caller is responsible for releasing the `AHardwareBuffer` pointer by calling
235+
/// `AHardwareBuffer_release` when it is finished with it, or may convert it back to a Rust
236+
/// `HardwareBuffer` by calling [`HardwareBuffer::from_raw`].
231237
pub fn into_raw(self) -> NonNull<AHardwareBuffer> {
232238
let buffer = ManuallyDrop::new(self);
233239
buffer.0

0 commit comments

Comments
 (0)