It looks strange to me that the MirSurface API needs methods to both get a shared pointer to the texture, and a "weak" pointer. Your solution indicates there are times MirSurfaceItem need to take shared ownership of a texture, and there are times MirSurfaceItem needs to peek to see what the current texture actually is.
But instead of peeking for every frame to check if the MirSurface backing texture matches the one the textureProvider is holding though, wouldn't it just be easier to set the texture each and every frame? Something like:
if (!m_textureProvider) { m_textureProvider = new MirTextureProvider(m_surface->texture());
- } else if (!m_textureProvider->texture()) {
- m_textureProvider->setTexture(m_surface->texture());
}
+ m_textureProvider->setTexture(m_surface->texture());
}
(P.S. I've noticed that QSGTextureProvider has a textureChanged signal we're not emitting, might that have an impact at all?)
It looks strange to me that the MirSurface API needs methods to both get a shared pointer to the texture, and a "weak" pointer. Your solution indicates there are times MirSurfaceItem need to take shared ownership of a texture, and there are times MirSurfaceItem needs to peek to see what the current texture actually is.
But instead of peeking for every frame to check if the MirSurface backing texture matches the one the textureProvider is holding though, wouldn't it just be easier to set the texture each and every frame? Something like:
if (!m_textureProv ider) {
m_textureProv ider = new MirTextureProvi der(m_surface- >texture( )); ider->texture( )) { er->setTexture( m_surface- >texture( )); er->setTexture( m_surface- >texture( ));
- } else if (!m_textureProv
- m_textureProvid
}
+ m_textureProvid
}
(P.S. I've noticed that QSGTextureProvider has a textureChanged signal we're not emitting, might that have an impact at all?)