Image coords should be multiply devicePixelRatio.
I hope this fixes #17277.
This commit is contained in:
parent
963694330d
commit
3b4ed03105
1 changed files with 11 additions and 9 deletions
|
@ -56,6 +56,7 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
||||||
const CacheBackgroundRequest &request) {
|
const CacheBackgroundRequest &request) {
|
||||||
Expects(!request.area.isEmpty());
|
Expects(!request.area.isEmpty());
|
||||||
|
|
||||||
|
const auto ratio = style::DevicePixelRatio();
|
||||||
const auto gradient = request.background.gradientForFill.isNull()
|
const auto gradient = request.background.gradientForFill.isNull()
|
||||||
? QImage()
|
? QImage()
|
||||||
: (request.gradientRotationAdd != 0)
|
: (request.gradientRotationAdd != 0)
|
||||||
|
@ -70,13 +71,13 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
||||||
|| request.background.prepared.isNull()) {
|
|| request.background.prepared.isNull()) {
|
||||||
auto result = gradient.isNull()
|
auto result = gradient.isNull()
|
||||||
? QImage(
|
? QImage(
|
||||||
request.area * style::DevicePixelRatio(),
|
request.area * ratio,
|
||||||
QImage::Format_ARGB32_Premultiplied)
|
QImage::Format_ARGB32_Premultiplied)
|
||||||
: gradient.scaled(
|
: gradient.scaled(
|
||||||
request.area * style::DevicePixelRatio(),
|
request.area * ratio,
|
||||||
Qt::IgnoreAspectRatio,
|
Qt::IgnoreAspectRatio,
|
||||||
Qt::SmoothTransformation);
|
Qt::SmoothTransformation);
|
||||||
result.setDevicePixelRatio(style::DevicePixelRatio());
|
result.setDevicePixelRatio(ratio);
|
||||||
if (!request.background.prepared.isNull()) {
|
if (!request.background.prepared.isNull()) {
|
||||||
QPainter p(&result);
|
QPainter p(&result);
|
||||||
if (!gradient.isNull()) {
|
if (!gradient.isNull()) {
|
||||||
|
@ -90,13 +91,13 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
||||||
}
|
}
|
||||||
const auto tiled = request.background.isPattern
|
const auto tiled = request.background.isPattern
|
||||||
? request.background.prepared.scaled(
|
? request.background.prepared.scaled(
|
||||||
request.area.height() * style::DevicePixelRatio(),
|
request.area.height() * ratio,
|
||||||
request.area.height() * style::DevicePixelRatio(),
|
request.area.height() * ratio,
|
||||||
Qt::KeepAspectRatio,
|
Qt::KeepAspectRatio,
|
||||||
Qt::SmoothTransformation)
|
Qt::SmoothTransformation)
|
||||||
: request.background.preparedForTiled;
|
: request.background.preparedForTiled;
|
||||||
const auto w = tiled.width() / float(style::DevicePixelRatio());
|
const auto w = tiled.width() / float(ratio);
|
||||||
const auto h = tiled.height() / float(style::DevicePixelRatio());
|
const auto h = tiled.height() / float(ratio);
|
||||||
const auto cx = int(std::ceil(request.area.width() / w));
|
const auto cx = int(std::ceil(request.area.width() / w));
|
||||||
const auto cy = int(std::ceil(request.area.height() / h));
|
const auto cy = int(std::ceil(request.area.height() / h));
|
||||||
const auto rows = cy;
|
const auto rows = cy;
|
||||||
|
@ -104,11 +105,12 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
||||||
? (((cx / 2) * 2) + 1)
|
? (((cx / 2) * 2) + 1)
|
||||||
: cx;
|
: cx;
|
||||||
const auto xshift = request.background.isPattern
|
const auto xshift = request.background.isPattern
|
||||||
? (request.area.width() - cols * w) / 2
|
? (request.area.width() * ratio - cols * tiled.width()) / 2
|
||||||
: 0;
|
: 0;
|
||||||
|
const auto useshift = xshift / float(ratio);
|
||||||
for (auto y = 0; y != rows; ++y) {
|
for (auto y = 0; y != rows; ++y) {
|
||||||
for (auto x = 0; x != cols; ++x) {
|
for (auto x = 0; x != cols; ++x) {
|
||||||
p.drawImage(QPointF(xshift + x * w, y * h), tiled);
|
p.drawImage(QPointF(useshift + x * w, y * h), tiled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!gradient.isNull()
|
if (!gradient.isNull()
|
||||||
|
|
Loading…
Reference in a new issue