MacOS: ensure 1:1 rendering on HiDPI screens (#23860)

pull/23863/head
Willem Melching 3 years ago committed by GitHub
parent 9c70e8bcad
commit ca8d4e417e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      selfdrive/ui/installer/installer.cc
  2. 2
      selfdrive/ui/main.cc
  3. 2
      selfdrive/ui/qt/setup/updater.cc
  4. 2
      selfdrive/ui/qt/spinner.cc
  5. 2
      selfdrive/ui/qt/text.cc
  6. 11
      selfdrive/ui/qt/util.cc
  7. 2
      selfdrive/ui/qt/util.h
  8. 2
      selfdrive/ui/watch3.cc

@ -221,7 +221,7 @@ void Installer::cloneFinished(int exitCode, QProcess::ExitStatus exitStatus) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
initApp(); initApp(argc, argv);
QApplication a(argc, argv); QApplication a(argc, argv);
Installer installer; Installer installer;
setMainWindow(&installer); setMainWindow(&installer);

@ -12,7 +12,7 @@ int main(int argc, char *argv[]) {
setpriority(PRIO_PROCESS, 0, -20); setpriority(PRIO_PROCESS, 0, -20);
qInstallMessageHandler(swagLogMessageHandler); qInstallMessageHandler(swagLogMessageHandler);
initApp(); initApp(argc, argv);
if (Hardware::EON()) { if (Hardware::EON()) {
QSslConfiguration ssl = QSslConfiguration::defaultConfiguration(); QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();

@ -190,7 +190,7 @@ bool Updater::eventFilter(QObject *obj, QEvent *event) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
initApp(); initApp(argc, argv);
QApplication a(argc, argv); QApplication a(argc, argv);
Updater updater(argv[1], argv[2]); Updater updater(argv[1], argv[2]);
setMainWindow(&updater); setMainWindow(&updater);

@ -111,7 +111,7 @@ void Spinner::update(int n) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
initApp(); initApp(argc, argv);
QApplication a(argc, argv); QApplication a(argc, argv);
Spinner spinner; Spinner spinner;
setMainWindow(&spinner); setMainWindow(&spinner);

@ -11,7 +11,7 @@
#include "selfdrive/ui/qt/widgets/scrollview.h" #include "selfdrive/ui/qt/widgets/scrollview.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
initApp(); initApp(argc, argv);
QApplication a(argc, argv); QApplication a(argc, argv);
QWidget window; QWidget window;
setMainWindow(&window); setMainWindow(&window);

@ -89,9 +89,18 @@ void setQtSurfaceFormat() {
QSurfaceFormat::setDefaultFormat(fmt); QSurfaceFormat::setDefaultFormat(fmt);
} }
void initApp() { void initApp(int argc, char *argv[]) {
Hardware::set_display_power(true); Hardware::set_display_power(true);
Hardware::set_brightness(65); Hardware::set_brightness(65);
#ifdef __APPLE__
{
// Get the devicePixelRatio, and scale accordingly to maintain 1:1 rendering
QApplication tmp(argc, argv);
qputenv("QT_SCALE_FACTOR", QString::number(1.0 / tmp.devicePixelRatio() ).toLocal8Bit());
}
#endif
setQtSurfaceFormat(); setQtSurfaceFormat();
if (Hardware::EON()) { if (Hardware::EON()) {
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);

@ -19,6 +19,6 @@ void clearLayout(QLayout* layout);
void setQtSurfaceFormat(); void setQtSurfaceFormat();
QString timeAgo(const QDateTime &date); QString timeAgo(const QDateTime &date);
void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg); void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
void initApp(); void initApp(int argc, char *argv[]);
QWidget* topWidget (QWidget* widget); QWidget* topWidget (QWidget* widget);
QPixmap loadPixmap(const QString &fileName, const QSize &size = {}, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio); QPixmap loadPixmap(const QString &fileName, const QSize &size = {}, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);

@ -6,7 +6,7 @@
#include "selfdrive/ui/qt/widgets/cameraview.h" #include "selfdrive/ui/qt/widgets/cameraview.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
setQtSurfaceFormat(); initApp(argc, argv);
QApplication a(argc, argv); QApplication a(argc, argv);
QWidget w; QWidget w;

Loading…
Cancel
Save