plugins/screencast: Handle failing to import dmabuf
This commit is contained in:
parent
9e9da67fc0
commit
5c2314a6bd
3 changed files with 18 additions and 5 deletions
|
@ -11,9 +11,9 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
ScreenCastDmaBufTexture::ScreenCastDmaBufTexture(std::shared_ptr<GLTexture> texture, GraphicsBuffer *buffer)
|
||||
: m_texture(texture)
|
||||
, m_framebuffer(std::make_unique<GLFramebuffer>(texture.get()))
|
||||
ScreenCastDmaBufTexture::ScreenCastDmaBufTexture(std::shared_ptr<GLTexture> texture, std::unique_ptr<GLFramebuffer> &&framebuffer, GraphicsBuffer *buffer)
|
||||
: m_texture(std::move(texture))
|
||||
, m_framebuffer(std::move(framebuffer))
|
||||
, m_buffer(buffer)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class GraphicsBuffer;
|
|||
class ScreenCastDmaBufTexture
|
||||
{
|
||||
public:
|
||||
explicit ScreenCastDmaBufTexture(std::shared_ptr<GLTexture> texture, GraphicsBuffer *buffer);
|
||||
explicit ScreenCastDmaBufTexture(std::shared_ptr<GLTexture> texture, std::unique_ptr<GLFramebuffer> &&framebuffer, GraphicsBuffer *buffer);
|
||||
virtual ~ScreenCastDmaBufTexture();
|
||||
|
||||
GraphicsBuffer *buffer() const;
|
||||
|
|
|
@ -929,7 +929,20 @@ std::shared_ptr<ScreenCastDmaBufTexture> ScreenCastStream::createDmaBufTexture(c
|
|||
}
|
||||
|
||||
backend->makeCurrent();
|
||||
return std::make_shared<ScreenCastDmaBufTexture>(backend->importDmaBufAsTexture(*attrs), buffer);
|
||||
|
||||
std::shared_ptr<GLTexture> texture = backend->importDmaBufAsTexture(*attrs);
|
||||
if (!texture) {
|
||||
buffer->drop();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<GLFramebuffer> framebuffer = std::make_unique<GLFramebuffer>(texture.get());
|
||||
if (!framebuffer->valid()) {
|
||||
buffer->drop();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<ScreenCastDmaBufTexture>(std::move(texture), std::move(framebuffer), buffer);
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
|
Loading…
Reference in a new issue