1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-16 08:29:15 +01:00

LP-29 fix constant resize triggering on high dpi devices

dpr was not handled well...
This commit is contained in:
Philippe Renon 2016-04-13 23:22:20 +02:00
parent e3379a169b
commit 7212d65a1f

View File

@ -506,13 +506,15 @@ public:
// check if viewport needs to be resized // check if viewport needs to be resized
// a redraw will be requested if necessary // a redraw will be requested if necessary
osg::Viewport *viewport = h->view->getCamera()->getViewport(); osg::Viewport *viewport = h->view->getCamera()->getViewport();
if ((viewport->width() != item->width()) || (viewport->height() != item->height())) { int dpr = h->self->window()->devicePixelRatio();
// qDebug() << "*** RESIZE" << frameCount << viewport->width() << "x" << viewport->height() << "->" << item->width() << "x" << item->height(); int width = item->width() * dpr;
int height = item->height() * dpr;
if ((viewport->width() != width) || (viewport->height() != height)) {
// qDebug() << "*** RESIZE" << frameCount << viewport->width() << "x" << viewport->height() << "->" << width << "x" << height;
needToDoFrame = true; needToDoFrame = true;
// h->view->getCamera()->resize(item->width(), item->height()); // h->view->getCamera()->resize(width, height);
int dpr = h->self->window()->devicePixelRatio(); h->view->getCamera()->getGraphicsContext()->resized(0, 0, width, height);
h->view->getCamera()->getGraphicsContext()->resized(0, 0, item->width() * dpr, item->height() * dpr);
// trick to force a "home" on first few frames to absorb initial spurious resizes // trick to force a "home" on first few frames to absorb initial spurious resizes
if (frameCount <= 2) { if (frameCount <= 2) {
@ -531,13 +533,15 @@ public:
if (!needToDoFrame) { if (!needToDoFrame) {
needToDoFrame = h->viewer->checkNeedToDoFrame(); needToDoFrame = h->viewer->checkNeedToDoFrame();
} }
// workarounds to osg issues
if (!needToDoFrame) { if (!needToDoFrame) {
// workarounds to osg issues
// issue 1 : if only root node has an update callback checkNeedToDoFrame should return true but does not // issue 1 : if only root node has an update callback checkNeedToDoFrame should return true but does not
// a fix will be submitted to osg (current version is 3.5.1) // a fix will be submitted to osg (current version is 3.5.1)
if (h->view->getSceneData()) { if (h->view->getSceneData()) {
needToDoFrame |= !(h->view->getSceneData()->getUpdateCallback() == NULL); needToDoFrame |= !(h->view->getSceneData()->getUpdateCallback() == NULL);
} }
}
if (!needToDoFrame) {
// issue 2 : UI events don't trigger a redraw // issue 2 : UI events don't trigger a redraw
// this issue should be fixed here... // this issue should be fixed here...
// event handling needs a lot of attention : // event handling needs a lot of attention :