2011-08-08 12:02:51 +00:00
|
|
|
#ifndef NALL_COMPOSITOR_HPP
|
|
|
|
#define NALL_COMPOSITOR_HPP
|
|
|
|
|
2011-09-29 12:08:22 +00:00
|
|
|
#include <nall/intrinsics.hpp>
|
2011-08-08 12:02:51 +00:00
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
struct compositor {
|
|
|
|
inline static bool enabled();
|
|
|
|
inline static bool enable(bool status);
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
|
|
|
|
#if defined(PLATFORM_X)
|
|
|
|
enum class Compositor : unsigned { Unknown, Metacity, Xfwm4 };
|
|
|
|
inline static Compositor detect();
|
|
|
|
|
|
|
|
inline static bool enabled_metacity();
|
|
|
|
inline static bool enable_metacity(bool status);
|
|
|
|
|
|
|
|
inline static bool enabled_xfwm4();
|
|
|
|
inline static bool enable_xfwm4(bool status);
|
|
|
|
#endif
|
2011-08-08 12:02:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(PLATFORM_X)
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
//Metacity
|
|
|
|
|
|
|
|
bool compositor::enabled_metacity() {
|
2013-05-02 11:25:45 +00:00
|
|
|
FILE* fp = popen("gconftool-2 --get /apps/metacity/general/compositing_manager", "r");
|
2013-03-15 13:11:33 +00:00
|
|
|
if(!fp) return false;
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
|
|
|
|
char buffer[512];
|
2013-03-15 13:11:33 +00:00
|
|
|
if(!fgets(buffer, sizeof buffer, fp)) return false;
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
|
|
|
|
if(!memcmp(buffer, "true", 4)) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool compositor::enable_metacity(bool status) {
|
2013-05-02 11:25:45 +00:00
|
|
|
FILE* fp;
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
if(status) {
|
|
|
|
fp = popen("gconftool-2 --set --type bool /apps/metacity/general/compositing_manager true", "r");
|
|
|
|
} else {
|
|
|
|
fp = popen("gconftool-2 --set --type bool /apps/metacity/general/compositing_manager false", "r");
|
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
if(!fp) return false;
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
pclose(fp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Xfwm4
|
|
|
|
|
|
|
|
bool compositor::enabled_xfwm4() {
|
2013-05-02 11:25:45 +00:00
|
|
|
FILE* fp = popen("xfconf-query -c xfwm4 -p '/general/use_compositing'", "r");
|
2013-03-15 13:11:33 +00:00
|
|
|
if(!fp) return false;
|
2011-08-08 12:02:51 +00:00
|
|
|
|
|
|
|
char buffer[512];
|
2013-03-15 13:11:33 +00:00
|
|
|
if(!fgets(buffer, sizeof buffer, fp)) return false;
|
2011-08-08 12:02:51 +00:00
|
|
|
|
|
|
|
if(!memcmp(buffer, "true", 4)) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
bool compositor::enable_xfwm4(bool status) {
|
2013-05-02 11:25:45 +00:00
|
|
|
FILE* fp;
|
2011-08-08 12:02:51 +00:00
|
|
|
if(status) {
|
|
|
|
fp = popen("xfconf-query -c xfwm4 -p '/general/use_compositing' -t 'bool' -s 'true'", "r");
|
|
|
|
} else {
|
|
|
|
fp = popen("xfconf-query -c xfwm4 -p '/general/use_compositing' -t 'bool' -s 'false'", "r");
|
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
if(!fp) return false;
|
2011-08-08 12:02:51 +00:00
|
|
|
pclose(fp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
//General
|
|
|
|
|
|
|
|
compositor::Compositor compositor::detect() {
|
|
|
|
Compositor result = Compositor::Unknown;
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
FILE* fp;
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
char buffer[512];
|
|
|
|
|
|
|
|
fp = popen("pidof metacity", "r");
|
|
|
|
if(fp && fgets(buffer, sizeof buffer, fp)) result = Compositor::Metacity;
|
|
|
|
pclose(fp);
|
|
|
|
|
|
|
|
fp = popen("pidof xfwm4", "r");
|
|
|
|
if(fp && fgets(buffer, sizeof buffer, fp)) result = Compositor::Xfwm4;
|
|
|
|
pclose(fp);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool compositor::enabled() {
|
|
|
|
switch(detect()) {
|
|
|
|
case Compositor::Metacity: return enabled_metacity();
|
|
|
|
case Compositor::Xfwm4: return enabled_xfwm4();
|
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool compositor::enable(bool status) {
|
|
|
|
switch(detect()) {
|
|
|
|
case Compositor::Metacity: return enable_metacity(status);
|
|
|
|
case Compositor::Xfwm4: return enable_xfwm4(status);
|
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 12:08:22 +00:00
|
|
|
#elif defined(PLATFORM_WINDOWS)
|
2011-08-08 12:02:51 +00:00
|
|
|
|
|
|
|
bool compositor::enabled() {
|
|
|
|
HMODULE module = GetModuleHandleW(L"dwmapi");
|
2013-03-15 13:11:33 +00:00
|
|
|
if(module == nullptr) module = LoadLibraryW(L"dwmapi");
|
|
|
|
if(module == nullptr) return false;
|
2011-08-08 12:02:51 +00:00
|
|
|
|
|
|
|
auto pDwmIsCompositionEnabled = (HRESULT (WINAPI*)(BOOL*))GetProcAddress(module, "DwmIsCompositionEnabled");
|
2013-03-15 13:11:33 +00:00
|
|
|
if(pDwmIsCompositionEnabled == nullptr) return false;
|
2011-08-08 12:02:51 +00:00
|
|
|
|
|
|
|
BOOL result;
|
|
|
|
if(pDwmIsCompositionEnabled(&result) != S_OK) return false;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool compositor::enable(bool status) {
|
|
|
|
HMODULE module = GetModuleHandleW(L"dwmapi");
|
2013-03-15 13:11:33 +00:00
|
|
|
if(module == nullptr) module = LoadLibraryW(L"dwmapi");
|
|
|
|
if(module == nullptr) return false;
|
2011-08-08 12:02:51 +00:00
|
|
|
|
|
|
|
auto pDwmEnableComposition = (HRESULT (WINAPI*)(UINT))GetProcAddress(module, "DwmEnableComposition");
|
2013-03-15 13:11:33 +00:00
|
|
|
if(pDwmEnableComposition == nullptr) return false;
|
2011-08-08 12:02:51 +00:00
|
|
|
|
|
|
|
if(pDwmEnableComposition(status) != S_OK) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
bool compositor::enabled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool compositor::enable(bool) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|