Support cursor in android display
1. Handle cursor scanout as well 2. Add set_android_surface_position to handle cursor move event Bug: 327559087 Test: check cursor in vm Change-Id: I5429cb88a0f7983df015e05745070bf71f7c15ad Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5569432 Commit-Queue: Frederick Mayle <fmayle@google.com> Reviewed-by: Jiyong Park <jiyong@google.com> Reviewed-by: Frederick Mayle <fmayle@google.com>
This commit is contained in:
parent
909a54913e
commit
fa3f917c34
2 changed files with 20 additions and 5 deletions
|
|
@ -78,6 +78,7 @@ extern "C" {
|
|||
ctx: *mut AndroidDisplayContext,
|
||||
width: u32,
|
||||
height: u32,
|
||||
for_cursor: bool,
|
||||
) -> *mut ANativeWindow;
|
||||
|
||||
/// Destroys the Android surface created from `create_android_surface`.
|
||||
|
|
@ -97,6 +98,8 @@ extern "C" {
|
|||
out_buffer: *mut ANativeWindow_Buffer,
|
||||
) -> bool;
|
||||
|
||||
fn set_android_surface_position(ctx: *mut AndroidDisplayContext, x: u32, y: u32);
|
||||
|
||||
/// Posts the buffer obtained from `get_android_surface_buffer` to the Android display system
|
||||
/// so that it can be displayed on the screen. Once this is called, the caller shouldn't use
|
||||
/// the buffer any more.
|
||||
|
|
@ -179,6 +182,11 @@ impl GpuDisplaySurface for AndroidSurface {
|
|||
// SAFETY: context and surface are opaque handles.
|
||||
unsafe { post_android_surface_buffer(self.context.0.as_ptr(), self.surface.as_ptr()) }
|
||||
}
|
||||
|
||||
fn set_position(&mut self, x: u32, y: u32) {
|
||||
// SAFETY: context is an opaque handle.
|
||||
unsafe { set_android_surface_position(self.context.0.as_ptr(), x, y) };
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DisplayAndroid {
|
||||
|
|
@ -213,14 +221,15 @@ impl DisplayT for DisplayAndroid {
|
|||
display_params: &DisplayParameters,
|
||||
_surf_type: SurfaceType,
|
||||
) -> GpuDisplayResult<Box<dyn GpuDisplaySurface>> {
|
||||
if parent_surface_id.is_some() {
|
||||
return Err(GpuDisplayError::Unsupported);
|
||||
}
|
||||
|
||||
let (requested_width, requested_height) = display_params.get_virtual_display_size();
|
||||
// SAFETY: context is an opaque handle.
|
||||
let surface = NonNull::new(unsafe {
|
||||
create_android_surface(self.context.0.as_ptr(), requested_width, requested_height)
|
||||
create_android_surface(
|
||||
self.context.0.as_ptr(),
|
||||
requested_width,
|
||||
requested_height,
|
||||
parent_surface_id.is_some(),
|
||||
)
|
||||
})
|
||||
.ok_or(GpuDisplayError::CreateSurface)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ extern "C" fn create_android_surface(
|
|||
_ctx: *mut AndroidDisplayContext,
|
||||
_width: u32,
|
||||
_height: u32,
|
||||
_for_cursor: bool,
|
||||
) -> *mut ANativeWindow {
|
||||
unimplemented!();
|
||||
}
|
||||
|
|
@ -45,6 +46,11 @@ extern "C" fn destroy_android_surface(
|
|||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn set_android_surface_position(_ctx: *mut AndroidDisplayContext, _x: u32, _y: u32) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn get_android_surface_buffer(
|
||||
_ctx: *mut AndroidDisplayContext,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue