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

When transform scale larger than 10000, opengl paintdevice get wrong result for Rount Cap/Join style.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Not Evaluated
    • None
    • 5.12.0, 5.13.0
    • GUI: OpenGL, GUI: Painting
    • None
    • All

    Description

      //代码占位符
      #include <QApplication>
      #include <QOpenGLWidget>
      #include <QPainter>
      #include <QTransform>
      #include <QPainterPath>
      #include <QTimer>
      #include <QHBoxLayout>
      #include <QPaintEngine>
      #include <QMetaEnum>
      
      class Helper: public QObject{
        Q_OBJECT
      public:
        //copy from QPaintEngine
        enum Type {
          X11,
          Windows,
          QuickDraw, CoreGraphics, MacPrinter,
          QWindowSystem,
          PostScript,   // ### Qt 6: Remove, update documentation
          OpenGL,
          Picture,
          SVG,
          Raster,
          Direct3D,
          Pdf,
          OpenVG,
          OpenGL2,
          PaintBuffer,
          Blitter,
          Direct2D,
      
          User = 50,    // first user type id
          MaxUser = 100 // last user type id
        };
        Q_ENUM(Type) //
      };
      
      void draw(QPaintDevice *device, double scale) {
        QPainter pt(device);
      
        auto e = pt.paintEngine();
        auto t = (Helper::Type)e->type();
        auto mataEnum = QMetaEnum::fromType<Helper::Type>();
      
        pt.fillRect(0, 0, device->width(), device->height(), Qt::GlobalColor::white);
        pt.drawText(0, 50, QString("Transform Scale:%0").arg(scale));
        pt.drawText(0, 20, QString("PaintEngine Type:%0").arg(mataEnum.valueToKey(t)));
      
        QTransform tran;
      
        tran.scale(scale, scale);
        pt.setTransform(tran);
        QPen pen;
        pen.setWidthF(50 / scale);
        pen.setJoinStyle(Qt::PenJoinStyle::RoundJoin);
        pen.setCapStyle(Qt::PenCapStyle::RoundCap);
      
        QPainterPath path;
        path.moveTo(100 / scale, 100 / scale);
        path.lineTo(300 / scale, 300 / scale);
        path.lineTo(500 / scale, 300 / scale);
        pt.strokePath(path, pen);
      }
      
      class GLDrawWidget : public QOpenGLWidget {
      public:
        double mScale{1000};
      protected:
        void paintGL() override {
          draw(this, mScale);
        }
      };
      
      class DrawWidget : public QWidget {
      protected:
        virtual void paintEvent(QPaintEvent *event) override {
          draw(this, mScale);
        }
      
      public:
        double mScale{1000};
      
      };
      
      int main(int argc, char **argv) {
        QApplication app(argc, argv);
      
        QWidget mainWidget;
        mainWidget.resize(1300, 600);
        auto l = new QHBoxLayout();
        mainWidget.setLayout(l);
      
        GLDrawWidget glDrawWidget;
        DrawWidget rasterDrawWidget;
      
        l->addWidget(&glDrawWidget);
        l->addWidget(&rasterDrawWidget);
      
        QTimer timer;
      
        QObject::connect(&timer, &QTimer::timeout, [&glDrawWidget, &rasterDrawWidget](auto) {
          glDrawWidget.mScale += 1000;
          rasterDrawWidget.mScale += 1000;
          glDrawWidget.repaint();
          rasterDrawWidget.repaint();
        });
        timer.start(200);
      
        mainWidget.show();
      
        return app.exec();
      }
      
      #include <main.moc>
      
      

      test on windows and macOS

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lagocs Laszlo Agocs
            zhouqi zhouqi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes