Skip to content

Commit

Permalink
Auto-detect UI painter.
Browse files Browse the repository at this point in the history
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
sphery committed Feb 16, 2011
1 parent 16ad5de commit fb45eb9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 39 deletions.
58 changes: 36 additions & 22 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -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")
Expand All @@ -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)
{
Expand Down
17 changes: 0 additions & 17 deletions mythtv/programs/mythfrontend/globalsettings.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fb45eb9

Please sign in to comment.