gfx: add ShmGfxTexture
This commit is contained in:
parent
ed4ef3c8e7
commit
c968024905
10 changed files with 51 additions and 22 deletions
|
|
@ -4,7 +4,7 @@ use {
|
|||
format::{Format, XRGB8888},
|
||||
gfx_api::{
|
||||
BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage,
|
||||
GfxTexture, ResetStatus,
|
||||
ResetStatus, ShmGfxTexture,
|
||||
},
|
||||
gfx_apis::gl::{
|
||||
egl::{context::EglContext, display::EglDisplay, image::EglImage},
|
||||
|
|
@ -265,17 +265,17 @@ impl GfxContext for GlRenderContext {
|
|||
|
||||
fn shmem_texture(
|
||||
self: Rc<Self>,
|
||||
_old: Option<Rc<dyn GfxTexture>>,
|
||||
_old: Option<Rc<dyn ShmGfxTexture>>,
|
||||
data: &[Cell<u8>],
|
||||
format: &'static Format,
|
||||
width: i32,
|
||||
height: i32,
|
||||
stride: i32,
|
||||
_damage: Option<&[Rect]>,
|
||||
) -> Result<Rc<dyn GfxTexture>, GfxError> {
|
||||
) -> Result<Rc<dyn ShmGfxTexture>, GfxError> {
|
||||
(&self)
|
||||
.shmem_texture(data, format, width, height, stride)
|
||||
.map(|w| w as Rc<dyn GfxTexture>)
|
||||
.map(|w| w as Rc<dyn ShmGfxTexture>)
|
||||
.map_err(|e| e.into())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
format::Format,
|
||||
gfx_api::{GfxError, GfxTexture},
|
||||
gfx_api::{GfxError, GfxTexture, ShmGfxTexture},
|
||||
gfx_apis::gl::{
|
||||
gl::texture::GlTexture,
|
||||
renderer::{context::GlRenderContext, framebuffer::Framebuffer},
|
||||
|
|
@ -82,3 +82,9 @@ impl GfxTexture for Texture {
|
|||
self.format
|
||||
}
|
||||
}
|
||||
|
||||
impl ShmGfxTexture for Texture {
|
||||
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use {
|
|||
async_engine::AsyncEngine,
|
||||
format::Format,
|
||||
gfx_api::{
|
||||
GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage, GfxTexture, ResetStatus,
|
||||
GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage, ResetStatus, ShmGfxTexture,
|
||||
},
|
||||
gfx_apis::vulkan::{
|
||||
image::VulkanImageMemory, instance::VulkanInstance, renderer::VulkanRenderer,
|
||||
|
|
@ -249,16 +249,16 @@ impl GfxContext for Context {
|
|||
|
||||
fn shmem_texture(
|
||||
self: Rc<Self>,
|
||||
old: Option<Rc<dyn GfxTexture>>,
|
||||
old: Option<Rc<dyn ShmGfxTexture>>,
|
||||
data: &[Cell<u8>],
|
||||
format: &'static Format,
|
||||
width: i32,
|
||||
height: i32,
|
||||
stride: i32,
|
||||
damage: Option<&[Rect]>,
|
||||
) -> Result<Rc<dyn GfxTexture>, GfxError> {
|
||||
) -> Result<Rc<dyn ShmGfxTexture>, GfxError> {
|
||||
if let Some(old) = old {
|
||||
let old = old.into_vk(&self.0.device.device);
|
||||
let old = old.into_texture().into_vk(&self.0.device.device);
|
||||
let shm = match &old.ty {
|
||||
VulkanImageMemory::DmaBuf(_) => unreachable!(),
|
||||
VulkanImageMemory::Internal(shm) => shm,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use {
|
||||
crate::{
|
||||
format::Format,
|
||||
gfx_api::{GfxApiOpt, GfxError, GfxFramebuffer, GfxImage, GfxTexture, SyncFile},
|
||||
gfx_api::{
|
||||
GfxApiOpt, GfxError, GfxFramebuffer, GfxImage, GfxTexture, ShmGfxTexture, SyncFile,
|
||||
},
|
||||
gfx_apis::vulkan::{
|
||||
allocator::VulkanAllocation, device::VulkanDevice, format::VulkanModifierLimits,
|
||||
renderer::VulkanRenderer, shm_image::VulkanShmImage, VulkanError,
|
||||
|
|
@ -530,3 +532,9 @@ impl GfxTexture for VulkanImage {
|
|||
self.format
|
||||
}
|
||||
}
|
||||
|
||||
impl ShmGfxTexture for VulkanImage {
|
||||
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue