Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KWin
Commits
c30339cc
Commit
c30339cc
authored
Mar 29, 2022
by
Xaver Hugl
Browse files
backends/drm: move texture creation for gbm buffers into GbmBuffer
parent
3d038b71
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/backends/drm/drm_buffer_gbm.cpp
View file @
c30339cc
...
...
@@ -11,6 +11,8 @@
#include
"gbm_surface.h"
#include
"drm_gpu.h"
#include
"kwineglimagetexture.h"
#include
"kwineglutils_p.h"
#include
"logging.h"
// system
...
...
@@ -129,6 +131,19 @@ uint32_t GbmBuffer::stride() const
return
m_stride
;
}
QSharedPointer
<
GLTexture
>
GbmBuffer
::
createTexture
(
EGLDisplay
eglDisplay
)
const
{
if
(
!
m_bo
)
{
return
nullptr
;
}
EGLImageKHR
image
=
eglCreateImageKHR
(
eglDisplay
,
nullptr
,
EGL_NATIVE_PIXMAP_KHR
,
m_bo
,
nullptr
);
if
(
image
==
EGL_NO_IMAGE_KHR
)
{
qCWarning
(
KWIN_DRM
)
<<
"Failed to record frame: Error creating EGLImageKHR - "
<<
getEglErrorString
();
return
nullptr
;
}
return
QSharedPointer
<
EGLImageTexture
>::
create
(
eglDisplay
,
image
,
GL_RGBA8
,
QSize
(
gbm_bo_get_width
(
m_bo
),
gbm_bo_get_height
(
m_bo
)));
}
DrmGbmBuffer
::
DrmGbmBuffer
(
DrmGpu
*
gpu
,
GbmSurface
*
surface
,
gbm_bo
*
bo
)
:
DrmBuffer
(
gpu
,
gbm_bo_get_format
(
bo
),
gbm_bo_get_modifier
(
bo
))
,
GbmBuffer
(
surface
,
bo
)
...
...
src/backends/drm/drm_buffer_gbm.h
View file @
c30339cc
...
...
@@ -13,6 +13,7 @@
#include
"drm_buffer.h"
#include
<QSharedPointer>
#include
<epoxy/egl.h>
struct
gbm_bo
;
...
...
@@ -26,6 +27,7 @@ namespace KWin
{
class
GbmSurface
;
class
GLTexture
;
class
GbmBuffer
:
public
QObject
{
...
...
@@ -42,6 +44,7 @@ public:
uint32_t
stride
()
const
;
KWaylandServer
::
ClientBuffer
*
clientBuffer
()
const
;
gbm_bo
*
getBo
()
const
;
QSharedPointer
<
GLTexture
>
createTexture
(
EGLDisplay
eglDisplay
)
const
;
protected:
GbmSurface
*
m_surface
=
nullptr
;
...
...
src/backends/drm/egl_gbm_layer.cpp
View file @
c30339cc
...
...
@@ -294,26 +294,16 @@ bool EglGbmLayer::doesSwapchainFit(DumbSwapchain *swapchain) const
QSharedPointer
<
GLTexture
>
EglGbmLayer
::
texture
()
const
{
const
auto
createImage
=
[
this
](
GbmBuffer
*
gbmBuffer
)
{
EGLImageKHR
image
=
eglCreateImageKHR
(
m_eglBackend
->
eglDisplay
(),
nullptr
,
EGL_NATIVE_PIXMAP_KHR
,
gbmBuffer
->
getBo
(),
nullptr
);
if
(
image
==
EGL_NO_IMAGE_KHR
)
{
qCWarning
(
KWIN_DRM
)
<<
"Failed to record frame: Error creating EGLImageKHR - "
<<
getEglErrorString
();
return
QSharedPointer
<
EGLImageTexture
>
(
nullptr
);
}
return
QSharedPointer
<
EGLImageTexture
>::
create
(
m_eglBackend
->
eglDisplay
(),
image
,
GL_RGBA8
,
m_pipeline
->
sourceSize
());
};
if
(
m_scanoutBuffer
)
{
return
createImage
(
dynamic_cast
<
GbmBuffer
*>
(
m_scanoutBuffer
.
data
()));
}
if
(
m_shadowBuffer
)
{
return
m_scanoutBuffer
->
createTexture
(
m_eglBackend
->
eglDisplay
());
}
else
if
(
m_shadowBuffer
)
{
return
m_shadowBuffer
->
texture
();
}
GbmBuffer
*
gbmBuffer
=
m_gbmSurface
->
currentBuffer
().
data
(
);
if
(
!
gbmBuffer
)
{
}
else
if
(
GbmBuffer
*
gbmBuffer
=
m_gbmSurface
->
currentBuffer
().
data
())
{
return
gbmBuffer
->
createTexture
(
m_eglBackend
->
eglDisplay
()
);
}
else
{
qCWarning
(
KWIN_DRM
)
<<
"Failed to record frame: No gbm buffer!"
;
return
nullptr
;
}
return
createImage
(
gbmBuffer
);
}
QSharedPointer
<
DrmBuffer
>
EglGbmLayer
::
importBuffer
()
...
...
src/backends/drm/egl_gbm_layer.h
View file @
c30339cc
...
...
@@ -29,6 +29,7 @@ class GbmSurface;
class
DumbSwapchain
;
class
ShadowBuffer
;
class
EglGbmBackend
;
class
DrmGbmBuffer
;
class
EglGbmLayer
:
public
DrmPipelineLayer
{
...
...
@@ -75,7 +76,7 @@ private:
bool
attemptedThisFrame
=
false
;
}
m_scanoutCandidate
;
QSharedPointer
<
DrmBuffer
>
m_scanoutBuffer
;
QSharedPointer
<
Drm
Gbm
Buffer
>
m_scanoutBuffer
;
QSharedPointer
<
DrmBuffer
>
m_currentBuffer
;
QRegion
m_currentDamage
;
QSharedPointer
<
GbmSurface
>
m_gbmSurface
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment