Permalink
Browse files

Auto-detect UI painter.

If running on Windows, use D3D9.  Else, try the OpenGL UI painter.  If
initialization fails or if OpenGL is not using direct rendering, fall
back to the Qt painter.  This also removes the ThemePainter setting.

The auto-detection will automatically choose the Qt painter for ssh X
forwarding and such, but will use OpenGL painter for local display (when
OpenGL is properly installed and configured on the underlying system) so
users shouldn't need to worry about overriding the painter.

Theme developers may test with a non-default painter by starting
with -O UIPainter=[opengl|qt|d3d9].
  • Loading branch information...
1 parent 16ad5de commit fb45eb9fef28a58e468c8db02c2d8621d510493a @sphery sphery committed Feb 16, 2011
Showing with 36 additions and 39 deletions.
  1. +36 −22 mythtv/libs/libmythui/mythmainwindow.cpp
  2. +0 −17 mythtv/programs/mythfrontend/globalsettings.cpp
@@ -944,32 +944,54 @@ void MythMainWindow::Init(void)
d->render = NULL;
}
- QString painter = GetMythDB()->GetSetting("ThemePainter", "qt");
+ QString painter = GetMythDB()->GetSetting("UIPainter", "auto");
+#ifdef USING_MINGW
+ if (painter == "auto" || painter == "d3d9")
+ {
+ VERBOSE(VB_GENERAL, "Using the D3D9 painter");
+ d->painter = new MythD3D9Painter();
+ d->paintwin = new MythPainterWindowD3D9(this, d);
+ }
+#endif
#ifdef USE_OPENGL_PAINTER
- if (painter == "opengl")
+ if (painter == "auto" && (!d->painter && !d->paintwin) ||
+ painter == "opengl")
{
- VERBOSE(VB_GENERAL, "Using the OpenGL painter");
+ VERBOSE(VB_GENERAL, "Trying the OpenGL painter");
d->painter = new MythOpenGLPainter();
QGLFormat fmt;
fmt.setDepth(false);
d->render = MythRenderOpenGL::Create(fmt);
MythRenderOpenGL *gl = dynamic_cast<MythRenderOpenGL*>(d->render);
d->paintwin = new MythPainterWindowGL(this, d, gl);
QGLWidget *qgl = dynamic_cast<QGLWidget *>(d->paintwin);
- if (qgl && !qgl->isValid())
+ if (qgl)
{
- VERBOSE(VB_IMPORTANT, "Failed to create OpenGL painter. "
- "Check your OpenGL installation.");
- delete d->painter;
- d->painter = NULL;
- delete d->paintwin;
- d->paintwin = NULL;
- d->render = NULL; // deleted by the painterwindow
+ bool teardown = false;
+ if (!qgl->isValid())
+ {
+ VERBOSE(VB_IMPORTANT, "Failed to create OpenGL painter. "
+ "Check your OpenGL installation.");
+ teardown = true;
+ }
+ else if (painter == "auto" && !qgl->format().directRendering())
+ {
+ VERBOSE(VB_IMPORTANT, "OpenGL is using software rendering. "
+ "Falling back to Qt painter.");
+ teardown = true;
+ }
+ if (teardown)
+ {
+ delete d->painter;
+ d->painter = NULL;
+ delete d->paintwin;
+ d->paintwin = NULL;
+ d->render = NULL; // deleted by the painterwindow
+ }
+ else
+ gl->Init();
}
- else
- gl->Init();
}
- else
#endif
#ifdef USING_VDPAU
if (painter == "vdpau")
@@ -979,14 +1001,6 @@ void MythMainWindow::Init(void)
d->paintwin = new MythPainterWindowVDPAU(this, d);
}
#endif
-#ifdef USING_MINGW
- if (painter == "d3d9")
- {
- VERBOSE(VB_GENERAL, "Using the D3D9 painter");
- d->painter = new MythD3D9Painter();
- d->paintwin = new MythPainterWindowD3D9(this, d);
- }
-#endif
if (!d->painter && !d->paintwin)
{
@@ -2227,22 +2227,6 @@ static HostComboBox *MythTimeFormat()
return gc;
}
-static HostComboBox *ThemePainter()
-{
- HostComboBox *gc = new HostComboBox("ThemePainter");
- gc->setLabel(QObject::tr("Paint engine"));
-#ifdef USING_MINGW
- gc->addSelection(QObject::tr("Direct3D"), "d3d9");
-#endif
- gc->addSelection(QObject::tr("Qt"), "qt");
-#ifdef USING_OPENGL
- gc->addSelection(QObject::tr("OpenGL"), "opengl");
-#endif
- gc->setHelpText(QObject::tr("This selects what MythTV uses to draw. If "
- "you have decent hardware, select OpenGL."));
- return gc;
-}
-
static HostComboBox *ChannelFormat()
{
HostComboBox *gc = new HostComboBox("ChannelFormat");
@@ -3657,7 +3641,6 @@ AppearanceSettings::AppearanceSettings()
VerticalConfigurationGroup* screen = new VerticalConfigurationGroup(false);
screen->setLabel(QObject::tr("Theme") + " / " + QObject::tr("Screen Settings"));
- screen->addChild(ThemePainter());
screen->addChild(MenuTheme());
if (MythDisplay::GetNumberXineramaScreens() > 1)

0 comments on commit fb45eb9

Please sign in to comment.