Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add ability to switch render modes under Qt 6 #917

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions plugins/quickinspector/quickinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,10 @@ void RenderModeRequest::apply()
if (connection)
disconnect(connection);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// crashes in qrhigles2..bindShaderResources sometimes
return;
#endif

if (window && window->rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGL)
return;

if (window) {
if (window->rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGL)
return;

emit aboutToCleanSceneGraph();
const QByteArray mode = renderModeToString(RenderModeRequest::mode);
QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(window);
Expand Down
13 changes: 10 additions & 3 deletions plugins/quickinspector/quickscreengrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,14 @@ UnsupportedScreenGrabber::~UnsupportedScreenGrabber()

void UnsupportedScreenGrabber::requestGrabWindow(const QRectF & /*userViewport*/)
{
const qreal ratio = m_window->effectiveDevicePixelRatio();
const int width = m_window->width(),
height = m_window->height();
m_grabbedFrame.image = m_window->grabWindow();
m_grabbedFrame.image.setDevicePixelRatio(m_window->effectiveDevicePixelRatio());
if (ratio == 1.0)
m_grabbedFrame.image = m_grabbedFrame.image.copy(0, 0, width, height);
else
m_grabbedFrame.image = m_grabbedFrame.image.copy(0, 0, width, height).scaledToHeight(height * ratio);

int alpha = 120;
if (m_grabbedFrame.image.isNull()) {
Expand All @@ -819,14 +825,15 @@ void UnsupportedScreenGrabber::requestGrabWindow(const QRectF & /*userViewport*/
p.setRenderHint(QPainter::TextAntialiasing);
QColor gray(Qt::black);
gray.setAlpha(alpha);
p.fillRect(QRect(QPoint {}, m_window->size()), gray);
auto textBoxRect = QRect(QPoint(4, 4), m_window->size() - QSize(8, 8));
p.fillRect(textBoxRect, gray);
p.setPen(Qt::white);
auto font = qApp->font();
font.setPointSize(font.pointSize() + 1);
p.setFont(font);
QString backend = VariantHandler::displayString(QVariant::fromValue(m_window->graphicsApi()));
QString txt = backend + QStringLiteral(" is not supported yet, please use OpenGL or Software backend");
p.drawText(QRect { QPoint(0, 0), m_window->size() }, Qt::AlignCenter | Qt::TextWordWrap, txt);
p.drawText(textBoxRect, Qt::AlignCenter | Qt::TextWordWrap, txt);

emit sceneGrabbed(m_grabbedFrame);
}
Expand Down
Loading