gfx: return formats by reference
This commit is contained in:
parent
b921c81e5d
commit
0f556fc054
7 changed files with 12 additions and 12 deletions
|
|
@ -103,7 +103,7 @@ fn create_fd_data(ctx: &dyn GfxContext) -> (Vec<u8>, AHashMap<(u32, Modifier), u
|
|||
let mut vec = vec![];
|
||||
let mut map = AHashMap::new();
|
||||
let mut pos = 0;
|
||||
for (format, info) in &*ctx.formats() {
|
||||
for (format, info) in &**ctx.formats() {
|
||||
for modifier in &info.read_modifiers {
|
||||
vec.write_u32::<NativeEndian>(*format).unwrap();
|
||||
vec.write_u32::<NativeEndian>(0).unwrap();
|
||||
|
|
|
|||
|
|
@ -747,7 +747,7 @@ pub trait GfxContext: Debug {
|
|||
|
||||
fn render_node(&self) -> Option<Rc<CString>>;
|
||||
|
||||
fn formats(&self) -> Rc<AHashMap<u32, GfxFormat>>;
|
||||
fn formats(&self) -> &Rc<AHashMap<u32, GfxFormat>>;
|
||||
|
||||
fn fast_ram_access(&self) -> bool;
|
||||
|
||||
|
|
|
|||
|
|
@ -187,8 +187,8 @@ impl GlRenderContext {
|
|||
self.render_node.clone()
|
||||
}
|
||||
|
||||
pub fn formats(&self) -> Rc<AHashMap<u32, GfxFormat>> {
|
||||
self.ctx.formats.clone()
|
||||
pub fn formats(&self) -> &Rc<AHashMap<u32, GfxFormat>> {
|
||||
&self.ctx.formats
|
||||
}
|
||||
|
||||
fn dmabuf_fb(self: &Rc<Self>, buf: &DmaBuf) -> Result<Rc<Framebuffer>, RenderError> {
|
||||
|
|
@ -253,7 +253,7 @@ impl GfxContext for GlRenderContext {
|
|||
Some(self.render_node())
|
||||
}
|
||||
|
||||
fn formats(&self) -> Rc<AHashMap<u32, GfxFormat>> {
|
||||
fn formats(&self) -> &Rc<AHashMap<u32, GfxFormat>> {
|
||||
self.formats()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -263,8 +263,8 @@ impl GfxContext for Context {
|
|||
Some(self.0.device.render_node.clone())
|
||||
}
|
||||
|
||||
fn formats(&self) -> Rc<AHashMap<u32, GfxFormat>> {
|
||||
self.0.formats.clone()
|
||||
fn formats(&self) -> &Rc<AHashMap<u32, GfxFormat>> {
|
||||
&self.0.formats
|
||||
}
|
||||
|
||||
fn fast_ram_access(&self) -> bool {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ impl ZwpLinuxBufferParamsV1 {
|
|||
Some(ctx) => ctx,
|
||||
None => return Err(ZwpLinuxBufferParamsV1Error::NoRenderContext),
|
||||
};
|
||||
let formats = ctx.formats();
|
||||
let formats = ctx.formats().clone();
|
||||
let format = match formats.get(&format) {
|
||||
Some(f) => f,
|
||||
None => return Err(ZwpLinuxBufferParamsV1Error::InvalidFormat(format)),
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ impl GfxContext for TestGfxCtx {
|
|||
None
|
||||
}
|
||||
|
||||
fn formats(&self) -> Rc<AHashMap<u32, GfxFormat>> {
|
||||
self.formats.clone()
|
||||
fn formats(&self) -> &Rc<AHashMap<u32, GfxFormat>> {
|
||||
&self.formats
|
||||
}
|
||||
|
||||
fn fast_ram_access(&self) -> bool {
|
||||
|
|
|
|||
|
|
@ -211,9 +211,9 @@ impl UsrJayRenderCtxOwner for PortalDisplay {
|
|||
if let Some(ctx) = render_ctx {
|
||||
let client_formats = ctx.ctx.formats();
|
||||
let usable_formats = match &server_formats {
|
||||
None => client_formats,
|
||||
None => client_formats.clone(),
|
||||
Some(server_formats) => {
|
||||
Rc::new(cross_intersect_formats(&client_formats, server_formats))
|
||||
Rc::new(cross_intersect_formats(client_formats, server_formats))
|
||||
}
|
||||
};
|
||||
self.render_ctx.set(Some(Rc::new(PortalServerRenderCtx {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue