Merge pull request #1736 from pijyoi/remote_dpr
be hidpi-aware for remote rendering
This commit is contained in:
commit
9a77c223f0
@ -211,7 +211,10 @@ class Renderer(GraphicsView):
|
|||||||
## make sure shm is large enough and get its address
|
## make sure shm is large enough and get its address
|
||||||
if self.width() == 0 or self.height() == 0:
|
if self.width() == 0 or self.height() == 0:
|
||||||
return
|
return
|
||||||
size = self.width() * self.height() * 4
|
dpr = self.devicePixelRatioF()
|
||||||
|
iwidth = int(self.width() * dpr)
|
||||||
|
iheight = int(self.height() * dpr)
|
||||||
|
size = iwidth * iheight * 4
|
||||||
if size > self.shm.size():
|
if size > self.shm.size():
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
## windows says "WindowsError: [Error 87] the parameter is incorrect" if we try to resize the mmap
|
## windows says "WindowsError: [Error 87] the parameter is incorrect" if we try to resize the mmap
|
||||||
@ -240,13 +243,14 @@ class Renderer(GraphicsView):
|
|||||||
# PySide2, PySide6
|
# PySide2, PySide6
|
||||||
img_ptr = self.shm
|
img_ptr = self.shm
|
||||||
|
|
||||||
self.img = QtGui.QImage(img_ptr, self.width(), self.height(), QtGui.QImage.Format_ARGB32)
|
self.img = QtGui.QImage(img_ptr, iwidth, iheight, QtGui.QImage.Format_ARGB32)
|
||||||
|
self.img.setDevicePixelRatio(dpr)
|
||||||
|
|
||||||
self.img.fill(0xffffffff)
|
self.img.fill(0xffffffff)
|
||||||
p = QtGui.QPainter(self.img)
|
p = QtGui.QPainter(self.img)
|
||||||
self.render(p, self.viewRect(), self.rect())
|
self.render(p, self.viewRect(), self.rect())
|
||||||
p.end()
|
p.end()
|
||||||
self.sceneRendered.emit((self.width(), self.height(), self.shm.size(), self.shmFileName()))
|
self.sceneRendered.emit((iwidth, iheight, self.shm.size(), self.shmFileName()))
|
||||||
|
|
||||||
def deserialize_mouse_event(self, mouse_event):
|
def deserialize_mouse_event(self, mouse_event):
|
||||||
typ, pos, gpos, btn, btns, mods = mouse_event
|
typ, pos, gpos, btn, btns, mods = mouse_event
|
||||||
|
Loading…
Reference in New Issue
Block a user