Grain and Add Noise stay with the document on the canvas; the GPU canvas's contracts judged and pinned on the CPU canvas (13.9b)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-01 17:47:52 -04:00
1 parent 06843364fe
commit d2c8507fc7
8 files changed
+402 -31

No files matched your search

+4
View File
@@ -430,6 +430,10 @@ void CanvasView::drawLayers(const CanvasDocument &document, double scale, const
live.adjustment = [&](QUuid id) { return byID.contains(id) ? byID.at(id).adjustment : std::nullopt; };
live.adjustmentOpacity = [&](QUuid id) { return byID.at(id).effectiveOpacity(byID); };
live.adjustmentScale = scale;
const QPointF corner = center(QPointF(0, 0));
live.adjustmentRegion = [corner, scale](const QRectF &rect) {
return QRectF((rect.left() - corner.x()) / scale, (rect.top() - corner.y()) / scale, rect.width() / scale, rect.height() / scale);
};
live.adjustmentClip = [&](QUuid id, const QPainter &painter, QImage &coverage) {
const ImageLayer &layer = byID.at(id);
if (!layer.mask || !layer.mask->isEnabled)
+4 -3
View File
@@ -208,8 +208,9 @@ void LiveMaskRenderer::adjust(QUuid id, QPainter &context, const QImage &clip)
qCWarning(lcRendering) << "an adjustment passes its pixel budget:" << device->size();
return;
}
// The document the device shows, where Grain's pattern sits.
const QRectF region = context.deviceTransform().inverted().mapRect(QRectF(device->rect()));
// What the device shows; Grain and Noise keep the document.
const QRectF shown = context.deviceTransform().inverted().mapRect(QRectF(device->rect()));
const QRectF region = adjustmentRegion ? adjustmentRegion(shown) : shown;
try {
// The kernels' byte order, one image pixel a device pixel.
QImage original = device->convertToFormat(QImage::Format_RGBA8888_Premultiplied).copy();
@@ -217,7 +218,7 @@ void LiveMaskRenderer::adjust(QUuid id, QPainter &context, const QImage &clip)
throw ExportError(ExportError::Kind::render);
original.setDevicePixelRatio(1);
// Device pixels a document pixel, where Swift's surface counts points.
QImage adjusted = adjustment(id).value().apply(original, region, adjustmentScale * device->width() / region.width());
QImage adjusted = adjustment(id).value().apply(original, region, adjustmentScale * device->width() / shown.width());
const auto found = m_modes.find(id);
const LayerBlendMode mode = found != m_modes.end() ? found->second : LayerBlendMode::normal;
if (mode != LayerBlendMode::normal)
+2
View File
@@ -31,6 +31,8 @@ public:
std::function<void(QUuid, const QPainter &, QImage &coverage)> adjustmentClip = [](QUuid, const QPainter &, QImage &) {};
// Painter units a document pixel: the canvas's zoom.
double adjustmentScale = 1;
// The document a painter region shows: the canvas maps it.
std::function<QRectF(const QRectF &)> adjustmentRegion;
private:
// The pixels beneath, adjusted and mixed back through coverage.