48void BasicEGLSurfaceTextureWayland::destroy()
 
   51    m_bufferType = BufferType::None;
 
   63bool BasicEGLSurfaceTextureWayland::loadShmTexture(
GraphicsBuffer *buffer)
 
   66    if (Q_UNLIKELY(!view.image())) {
 
   76    texture->setWrapMode(GL_CLAMP_TO_EDGE);
 
   81    m_bufferType = BufferType::Shm;
 
   86void BasicEGLSurfaceTextureWayland::updateShmTexture(GraphicsBuffer *buffer, 
const QRegion ®ion)
 
   88    if (Q_UNLIKELY(m_bufferType != BufferType::Shm)) {
 
   94    const GraphicsBufferView view(buffer);
 
   95    if (Q_UNLIKELY(!view.image())) {
 
   99    for (
const QRect &rect : region) {
 
  104bool BasicEGLSurfaceTextureWayland::loadDmabufTexture(GraphicsBuffer *buffer)
 
  106    auto createTexture = [
this](
EGLImageKHR image, 
const QSize &size, 
bool isExternalOnly) -> std::shared_ptr<GLTexture> {
 
  107        if (Q_UNLIKELY(image == EGL_NO_IMAGE_KHR)) {
 
  108            qCritical(KWIN_OPENGL) << 
"Invalid dmabuf-based wl_buffer";
 
  112        GLint target = isExternalOnly ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D;
 
  113        auto texture = std::make_shared<GLTexture>(target);
 
  118        texture->setWrapMode(GL_CLAMP_TO_EDGE);
 
  121        glEGLImageTargetTexture2DOES(target, 
static_cast<GLeglImageOES
>(image));
 
  129    const auto attribs = buffer->dmabufAttributes();
 
  130    if (
auto itConv = s_drmConversions.find(buffer->dmabufAttributes()->format); itConv != s_drmConversions.end()) {
 
  131        QList<std::shared_ptr<GLTexture>> textures;
 
  132        Q_ASSERT(itConv->plane.count() == uint(buffer->dmabufAttributes()->planeCount));
 
  134        for (uint plane = 0; plane < itConv->plane.count(); ++plane) {
 
  135            const auto ¤tPlane = itConv->plane[plane];
 
  136            QSize size = buffer->size();
 
  137            size.rwidth() /= currentPlane.widthDivisor;
 
  138            size.rheight() /= currentPlane.heightDivisor;
 
  141            auto t = createTexture(
backend()->importBufferAsImage(buffer, plane, currentPlane.format, size), size, isExternal);
 
  150        auto texture = createTexture(
backend()->importBufferAsImage(buffer), buffer->size(), isExternal);
 
  156    m_bufferType = BufferType::DmaBuf;
 
  161void BasicEGLSurfaceTextureWayland::updateDmabufTexture(GraphicsBuffer *buffer)
 
  163    if (Q_UNLIKELY(m_bufferType != BufferType::DmaBuf)) {
 
  169    const GLint target = GL_TEXTURE_2D;
 
  170    if (
auto itConv = s_drmConversions.find(buffer->dmabufAttributes()->format); itConv != s_drmConversions.end()) {
 
  171        Q_ASSERT(itConv->plane.count() == uint(buffer->dmabufAttributes()->planeCount));
 
  172        for (uint plane = 0; plane < itConv->plane.count(); ++plane) {
 
  173            const auto ¤tPlane = itConv->plane[plane];
 
  174            QSize size = buffer->size();
 
  175            size.rwidth() /= currentPlane.widthDivisor;
 
  176            size.rheight() /= currentPlane.heightDivisor;
 
  179            glEGLImageTargetTexture2DOES(target, 
static_cast<GLeglImageOES
>(
backend()->importBufferAsImage(buffer, plane, currentPlane.format, size)));
 
  185        glEGLImageTargetTexture2DOES(target, 
static_cast<GLeglImageOES
>(
backend()->importBufferAsImage(buffer)));
 
EglDisplay * eglDisplayObject() const
void update(const QRegion ®ion) override
AbstractEglBackend * backend() const
BasicEGLSurfaceTextureWayland(OpenGLBackend *backend, SurfacePixmap *pixmap)
~BasicEGLSurfaceTextureWayland() override
bool isExternalOnly(uint32_t format, uint64_t modifier) const
static std::unique_ptr< GLTexture > upload(const QImage &image)
virtual const DmaBufAttributes * dmabufAttributes() const
virtual const ShmAttributes * shmAttributes() const
The OpenGLBackend creates and holds the OpenGL context and is responsible for Texture from Pixmap.
QList< std::shared_ptr< GLTexture > > planes
OpenGLSurfaceContents m_texture
OpenGLBackend * m_backend
OpenGLSurfaceContents texture() const
GraphicsBuffer * buffer() const
GraphicsBufferOrigin bufferOrigin() const