Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-120206

QSGSoftwareInternalImageNode is always mirrored when the texture is a layer

    XMLWordPrintable

Details

    • All

    Description

      but the layer can have mirroring disabled...

      The problem appears in such a case:

      1. QT_QUICK_BACKEND=software is used;
      2. Сustom effect implemented:
      // qml file
      Item {
          ...
      
           layer.enabled: true
           layer.textureMirroring: ShaderEffectSource.NoMirroring
           layer.effect: CustomEffect {}
      
           ...
      }
      
      // custom effect cpp source
      QSGNode *CustomEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
      {
          ...
      
          // QQuickShaderEffectSource *m_source
          auto provider = m_source->textureProvider();
          auto texture = qobject_cast<QSGLayer *>(provider->texture());    
          auto node = static_cast<QSGInternalImageNode *>(oldNode);
      
          if (!node) {
              auto renderContext = QQuickItemPrivate::get(this)->sceneGraphRenderContext();
              node = context->createInternalImageNode(renderContext);
              node->setFlag(QSGNode::UsePreprocess);
              node->setTexture(texture);
              ...
           }
      
           ...
      }

      The resulting effect is mirrored.

      I think QSGSoftwareInternalImageNode::update is missing a check for mirroring when setting the transform :

       

      void QSGSoftwareInternalImageNode::update()
      {
          if (m_cachedMirroredPixmapIsDirty) {
              if (m_mirrorHorizontally || m_mirrorVertically || m_textureIsLayer) {
                  QTransform transform((m_mirrorHorizontally ? -1 : 1), 0, 0,
                                       (m_textureIsLayer ? -1 : 1) * (m_mirrorVertically ? -1 : 1), 0, 0);
                  m_cachedMirroredPixmap = pixmap().transformed(transform);
              } else {
                  // Cleanup cached pixmap if necessary
                  if (!m_cachedMirroredPixmap.isNull())
                      m_cachedMirroredPixmap = QPixmap();
              }
              m_cachedMirroredPixmapIsDirty = false;
          }
      } 

      Everything works correctly if layer mirroring is checked, for example like this:

      if (m_mirrorHorizontally || m_mirrorVertically || (m_textureIsLayer && m_textureIsMirrored)) {
          ...

       

      Attachments

        For Gerrit Dashboard: QTBUG-120206
        # Subject Branch Project Status CR V

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            maksimshapovalov Maksim Shapovalov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes