all: use trait upcasting
This commit is contained in:
parent
f0caafc862
commit
09e5f89174
44 changed files with 90 additions and 269 deletions
|
|
@ -14,7 +14,7 @@ use {
|
|||
ImageTiling, ImageType, ImageViewCreateInfo, ImageViewType, SampleCountFlags, SharingMode,
|
||||
},
|
||||
gpu_alloc::UsageFlags,
|
||||
std::{any::Any, cell::Cell, collections::hash_map::Entry, rc::Rc},
|
||||
std::{cell::Cell, collections::hash_map::Entry, rc::Rc},
|
||||
};
|
||||
|
||||
impl VulkanRenderer {
|
||||
|
|
@ -113,8 +113,4 @@ impl VulkanRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
impl GfxBlendBuffer for VulkanImage {
|
||||
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
|
||||
self
|
||||
}
|
||||
}
|
||||
impl GfxBlendBuffer for VulkanImage {}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ use {
|
|||
},
|
||||
gpu_alloc::UsageFlags,
|
||||
std::{
|
||||
any::Any,
|
||||
cell::Cell,
|
||||
fmt::{Debug, Formatter},
|
||||
mem,
|
||||
|
|
@ -591,10 +590,6 @@ impl GfxFramebuffer for VulkanImage {
|
|||
}
|
||||
|
||||
impl GfxInternalFramebuffer for VulkanImage {
|
||||
fn into_fb(self: Rc<Self>) -> Rc<dyn GfxFramebuffer> {
|
||||
self
|
||||
}
|
||||
|
||||
fn stride(&self) -> i32 {
|
||||
let VulkanImageMemory::Internal(shm) = &self.ty else {
|
||||
unreachable!();
|
||||
|
|
@ -637,14 +632,6 @@ impl GfxTexture for VulkanImage {
|
|||
(self.width as _, self.height as _)
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
|
||||
self
|
||||
}
|
||||
|
||||
fn dmabuf(&self) -> Option<&DmaBuf> {
|
||||
match &self.ty {
|
||||
VulkanImageMemory::DmaBuf(b) => Some(&b.template.dmabuf),
|
||||
|
|
@ -658,11 +645,7 @@ impl GfxTexture for VulkanImage {
|
|||
}
|
||||
}
|
||||
|
||||
impl ShmGfxTexture for VulkanImage {
|
||||
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
|
||||
self
|
||||
}
|
||||
}
|
||||
impl ShmGfxTexture for VulkanImage {}
|
||||
|
||||
impl AsyncShmGfxTexture for VulkanImage {
|
||||
fn staging_size(&self) -> usize {
|
||||
|
|
@ -711,10 +694,6 @@ impl AsyncShmGfxTexture for VulkanImage {
|
|||
&& self.height == height as u32
|
||||
&& self.stride == stride as u32
|
||||
}
|
||||
|
||||
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl AsyncShmGfxTextureTransferCancellable for VulkanImage {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ use {
|
|||
jay_algorithms::rect::Tag,
|
||||
linearize::{Linearize, LinearizeExt, StaticMap, static_map},
|
||||
std::{
|
||||
any::Any,
|
||||
borrow::Cow,
|
||||
cell::{Cell, RefCell},
|
||||
collections::hash_map::Entry,
|
||||
|
|
@ -1967,8 +1968,7 @@ impl VulkanImage {
|
|||
|
||||
impl dyn GfxTexture {
|
||||
fn as_vk(&self, device: &Device) -> &VulkanImage {
|
||||
let img: &VulkanImage = self
|
||||
.as_any()
|
||||
let img: &VulkanImage = (self as &dyn Any)
|
||||
.downcast_ref()
|
||||
.expect("Non-vulkan texture passed into vulkan");
|
||||
img.assert_device(device);
|
||||
|
|
@ -1976,8 +1976,7 @@ impl dyn GfxTexture {
|
|||
}
|
||||
|
||||
pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanImage> {
|
||||
let img: Rc<VulkanImage> = self
|
||||
.into_any()
|
||||
let img: Rc<VulkanImage> = (self as Rc<dyn Any>)
|
||||
.downcast()
|
||||
.expect("Non-vulkan texture passed into vulkan");
|
||||
img.assert_device(device);
|
||||
|
|
@ -1987,8 +1986,7 @@ impl dyn GfxTexture {
|
|||
|
||||
impl dyn GfxBlendBuffer {
|
||||
pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanImage> {
|
||||
let img: Rc<VulkanImage> = self
|
||||
.into_any()
|
||||
let img: Rc<VulkanImage> = (self as Rc<dyn Any>)
|
||||
.downcast()
|
||||
.expect("Non-vulkan blend buffer passed into vulkan");
|
||||
img.assert_device(device);
|
||||
|
|
|
|||
|
|
@ -178,10 +178,6 @@ impl GfxStagingBuffer for VulkanStagingShell {
|
|||
fn size(&self) -> usize {
|
||||
self.size as _
|
||||
}
|
||||
|
||||
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanStagingShell {
|
||||
|
|
@ -196,8 +192,7 @@ impl VulkanStagingShell {
|
|||
|
||||
impl dyn GfxStagingBuffer {
|
||||
pub(super) fn into_vk(self: Rc<Self>, device: &Device) -> Rc<VulkanStagingShell> {
|
||||
let shell: Rc<VulkanStagingShell> = self
|
||||
.into_any()
|
||||
let shell: Rc<VulkanStagingShell> = (self as Rc<dyn Any>)
|
||||
.downcast()
|
||||
.expect("Non-vulkan staging buffer passed into vulkan");
|
||||
shell.assert_device(device);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue