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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Scale requestGrabWindow()'s image to fit size of window grab
grabbedFrame.image is sized according to display scaling, but
the contents of the image itself remain at their original,
non-scaled, resolution. There's a slim chance that the image is
scaled to fit the scaled canvas, and the quickinspectortest
passes. Most of the times, however, the image won't be scaled
to fit the canvas.

In this change we manually scale the image according to
devicePixelRatio to fit the image's canvas. This allows the test
to pass while keeping it unmodified.
  • Loading branch information
Cuperino committed May 3, 2024
commit 05e8566e082234de0ccd8629dbe281990514d88c
8 changes: 7 additions & 1 deletion 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 Down