2012-04-21 23:13:50 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 18:06:50 +01:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2012-07-25 01:22:49 -04:00
|
|
|
*
|
2012-04-21 23:13:50 +02:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2011-03-26 18:34:58 +01:00
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-04-21 23:13:50 +02:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2011-03-26 18:34:58 +01:00
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
2012-04-21 23:31:57 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2011-03-26 18:34:58 +01:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-19 01:49:08 +01:00
|
|
|
#include "win32_dwm_common.h"
|
|
|
|
#include "../../general.h"
|
2012-07-15 18:37:34 +02:00
|
|
|
|
2012-07-15 19:12:58 +02:00
|
|
|
#if defined(_WIN32) && !defined(_XBOX)
|
2011-08-07 15:00:34 +02:00
|
|
|
#include <windows.h>
|
2015-01-19 01:49:08 +01:00
|
|
|
#include "../../dynamic.h"
|
2014-09-08 17:57:18 +02:00
|
|
|
|
|
|
|
/* We only load this library once, so we let it be
|
|
|
|
* unloaded at application shutdown, since unloading
|
|
|
|
* it early seems to cause issues on some systems.
|
|
|
|
*/
|
2011-08-07 22:31:59 +02:00
|
|
|
|
2014-02-25 19:11:03 +01:00
|
|
|
static dylib_t dwmlib;
|
|
|
|
static bool dwm_composition_disabled;
|
2011-08-07 22:31:59 +02:00
|
|
|
|
|
|
|
static void gfx_dwm_shutdown(void)
|
|
|
|
{
|
|
|
|
if (dwmlib)
|
|
|
|
dylib_close(dwmlib);
|
2014-08-03 02:16:02 +02:00
|
|
|
dwmlib = NULL;
|
2011-08-07 22:31:59 +02:00
|
|
|
}
|
|
|
|
|
2014-09-13 17:59:25 -04:00
|
|
|
static bool gfx_init_dwm(void)
|
2011-08-07 15:00:34 +02:00
|
|
|
{
|
2014-09-13 17:59:25 -04:00
|
|
|
static bool inited = false;
|
2014-08-03 03:30:59 +02:00
|
|
|
|
2011-08-07 15:00:34 +02:00
|
|
|
if (inited)
|
2014-09-13 17:59:25 -04:00
|
|
|
return true;
|
2011-08-07 15:00:34 +02:00
|
|
|
|
2011-08-07 22:31:59 +02:00
|
|
|
dwmlib = dylib_load("dwmapi.dll");
|
|
|
|
if (!dwmlib)
|
2011-08-07 15:00:34 +02:00
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_LOG("Did not find dwmapi.dll.\n");
|
2014-09-13 17:59:25 -04:00
|
|
|
return false;
|
2011-08-07 15:00:34 +02:00
|
|
|
}
|
2011-08-07 22:31:59 +02:00
|
|
|
atexit(gfx_dwm_shutdown);
|
2011-08-07 15:00:34 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
HRESULT (WINAPI *mmcss)(BOOL) =
|
|
|
|
(HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS");
|
2011-08-07 21:15:50 +02:00
|
|
|
if (mmcss)
|
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_LOG("Setting multimedia scheduling for DWM.\n");
|
2011-08-07 21:15:50 +02:00
|
|
|
mmcss(TRUE);
|
|
|
|
}
|
2014-09-13 17:59:25 -04:00
|
|
|
|
|
|
|
inited = true;
|
|
|
|
return true;
|
2014-02-25 19:11:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void gfx_set_dwm(void)
|
|
|
|
{
|
2015-01-09 01:23:58 +01:00
|
|
|
HRESULT ret;
|
2015-03-20 22:08:36 +01:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
2014-09-13 17:59:25 -04:00
|
|
|
if (!gfx_init_dwm())
|
2014-02-25 19:11:03 +01:00
|
|
|
return;
|
2011-08-07 21:15:50 +02:00
|
|
|
|
2015-03-20 22:08:36 +01:00
|
|
|
if (settings->video.disable_composition == dwm_composition_disabled)
|
2011-08-07 22:31:59 +02:00
|
|
|
return;
|
2011-08-07 21:15:50 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
HRESULT (WINAPI *composition_enable)(UINT) =
|
|
|
|
(HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition");
|
2011-08-07 15:00:34 +02:00
|
|
|
if (!composition_enable)
|
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_ERR("Did not find DwmEnableComposition ...\n");
|
2011-08-07 15:00:34 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-20 22:08:36 +01:00
|
|
|
ret = composition_enable(!settings->video.disable_composition);
|
2011-08-07 15:00:34 +02:00
|
|
|
if (FAILED(ret))
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_ERR("Failed to set composition state ...\n");
|
2015-03-20 22:08:36 +01:00
|
|
|
dwm_composition_disabled = settings->video.disable_composition;
|
2011-08-07 15:00:34 +02:00
|
|
|
}
|
2011-08-11 05:59:32 +02:00
|
|
|
#endif
|