Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only apply nvidia hack with nvidia drivers #67

Merged
merged 3 commits into from May 27, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -13,7 +13,7 @@ use platform::surface::NativeSurfaceMethods;
use texturegl::Texture;

use geom::size::Size2D;
use libc::{c_int, c_uint, c_void};
use libc::{c_char, c_int, c_uint, c_void};
use opengles::glx::{GLXFBConfig, GLXDrawable};
use opengles::glx::{GLX_BIND_TO_TEXTURE_RGBA_EXT};
use opengles::glx::{GLX_DRAWABLE_TYPE, GLX_FRONT_EXT, GLX_PIXMAP_BIT};
@@ -22,6 +22,7 @@ use opengles::glx::{GLX_TEXTURE_TARGET_EXT, glXCreatePixmap, glXDestroyPixmap};
use opengles::glx::{glXGetProcAddress, glXChooseFBConfig};
use opengles::glx::{glXGetVisualFromFBConfig};
use opengles::glx::{GLX_RGBA_BIT, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_DOUBLEBUFFER};
use opengles::glx::{GLX_VENDOR};
use opengles::gl2::NO_ERROR;
use opengles::gl2;
use std::cast;
@@ -93,17 +94,28 @@ impl NativeCompositingGraphicsContext {
let mut number_of_configs = 0;
let configs = glXChooseFBConfig(glx_display, screen,
&fbconfig_attributes[0], &mut number_of_configs);
// NVidia drives have RGBA configurations that use 24-bit XVisual, not capable of
// representing an alpha-channel in Pixmap form, so we look for the configuration
// with a full set of 32 bits.
for i in range(0, number_of_configs as int) {
let config = *configs.offset(i);
let visual_info : *XVisualInfo = cast::transmute(glXGetVisualFromFBConfig(glx_display, config));
if (*visual_info).depth == 32 {
return (visual_info, Some(config))
let glXGetClientString: extern "C" fn(*Display, c_int) -> *c_char =
cast::transmute(glXGetProcAddress(cast::transmute(&"glXGetClientString\x00"[0])));

This comment has been minimized.

Copy link
@pcwalton

pcwalton May 27, 2014

Contributor

Use the std::c_str functionality instead.

assert!(glXGetClientString as *c_void != ptr::null());
let glx_cli_vendor_c_str = CString::new(glXGetClientString(display, GLX_VENDOR), false);
let glx_cli_vendor = match glx_cli_vendor_c_str.as_str() { Some(s) => s,
None => fail!("Can't get glx client vendor.") };
if glx_cli_vendor.to_ascii().eq_ignore_case("NVIDIA".to_ascii()) {
// NVidia drives have RGBA configurations that use 24-bit XVisual, not capable of
// representing an alpha-channel in Pixmap form, so we look for the configuration
// with a full set of 32 bits.
for i in range(0, number_of_configs as int) {
let config = *configs.offset(i);
let visual_info : *XVisualInfo = cast::transmute(glXGetVisualFromFBConfig(glx_display, config));
if (*visual_info).depth == 32 {
return (visual_info, Some(config))
}
}
} else if number_of_configs != 0 {
let fbconfig = *configs.offset(0);
let vi = glXGetVisualFromFBConfig(glx_display, fbconfig);
return (cast::transmute(vi), Some(fbconfig));
}

fail!("Unable to locate a GLX FB configuration that supports RGBA.");
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.