macOS: Correctly scale CALayer contentsRect for child NSViews
When flushing parts of a QBackingStore onto child QWindows, and we're in layer-backed mode, we need to set the contentsRect of the layer so that the layer will only show the part of the top-level-owned backingstore image that's relevant for the child window. Since the contentsRect is in unit coordinate system, we need to apply a transform, but this must be based on the top level view's size, not the image size, as the latter will be twice as big on a retina screen, giving the wrong unit rect. Change-Id: I7d6f378ed46a98272efb13406a2878ec1efe734e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
8316131dab
commit
8aa14a84a9
@ -127,10 +127,11 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo
|
||||
// FIXME: Figure out if there's a way to do partial updates
|
||||
view.layer.contents = (__bridge id)static_cast<CGImageRef>(cgImage);
|
||||
if (view != topLevelView) {
|
||||
const CGSize topLevelSize = topLevelView.bounds.size;
|
||||
view.layer.contentsRect = CGRectApplyAffineTransform(
|
||||
[view convertRect:view.bounds toView:topLevelView],
|
||||
// The contentsRect is in unit coordinate system
|
||||
CGAffineTransformMakeScale(1.0 / m_image.width(), 1.0 / m_image.height()));
|
||||
CGAffineTransformMakeScale(1.0 / topLevelSize.width, 1.0 / topLevelSize.height));
|
||||
}
|
||||
} else {
|
||||
// Normally a NSView is drawn via drawRect, as part of the display cycle in the
|
||||
|
Loading…
Reference in New Issue
Block a user