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
+22
−10
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Only apply nvidia hack with nvidia drivers
Check the GLX vendor string for nvidia before applying nvidia driver hack.
- Loading branch information
commit c0442e25f495f4adcc2b2be26da998c8a2d1ecad
| @@ -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}; | ||
| @@ -27,6 +27,7 @@ use opengles::gl2; | ||
| use std::cast; | ||
| use std::c_str::CString; | ||
| use std::ptr; | ||
| use std::str::raw::from_c_str; | ||
| use xlib::xlib::{Display, Pixmap, XCreateGC, XCreateImage, XCreatePixmap, XDefaultScreen}; | ||
| use xlib::xlib::{XDisplayString, XFreePixmap, XGetGeometry, XOpenDisplay, XPutImage, XRootWindow}; | ||
| use xlib::xlib::{XVisualInfo, ZPixmap}; | ||
| @@ -93,17 +94,27 @@ 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]))); | ||
|
||
| assert!(glXGetClientString as *c_void != ptr::null()); | ||
| let glx_client_vendor = glXGetClientString(display, 1); | ||
bjwbell
Author
Contributor
|
||
| if from_c_str(glx_client_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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Use the
std::c_strfunctionality instead.