aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas/webgl_thread.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-11-13 11:50:44 -0600
committerGitHub <noreply@github.com>2017-11-13 11:50:44 -0600
commitf1cf41da00b7973194104aa147f73fe55b0ad3db (patch)
tree1446ee673f55500c52a604d7b30009aa96b18536 /components/canvas/webgl_thread.rs
parentc261ff38c76c584fc93a4cded2ffe0d724d318fd (diff)
parentc22674481b04a017576174376b4258edde1c4127 (diff)
downloadservo-f1cf41da00b7973194104aa147f73fe55b0ad3db.tar.gz
servo-f1cf41da00b7973194104aa147f73fe55b0ad3db.zip
Auto merge of #19192 - MortimerGoro:webgl2_glsl, r=jdm
Set the correct Angle GLSL output when using WebGL 2 Set the correct Angle GLSL output when using WebGL 2 <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19192) <!-- Reviewable:end -->
Diffstat (limited to 'components/canvas/webgl_thread.rs')
-rw-r--r--components/canvas/webgl_thread.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs
index 383873ff7dc..106027523f4 100644
--- a/components/canvas/webgl_thread.rs
+++ b/components/canvas/webgl_thread.rs
@@ -91,13 +91,18 @@ impl<VR: WebVRRenderHandler + 'static, OB: WebGLThreadObserver> WebGLThread<VR,
match msg {
WebGLMsg::CreateContext(version, size, attributes, result_sender) => {
let result = self.create_webgl_context(version, size, attributes);
- result_sender.send(result.map(|(id, limits, share_mode)|
+ result_sender.send(result.map(|(id, limits, share_mode)| {
+ let ctx = Self::make_current_if_needed(id, &self.contexts, &mut self.bound_context_id)
+ .expect("WebGLContext not found");
+ let glsl_version = Self::get_glsl_version(ctx);
+
WebGLCreateContextResult {
sender: WebGLMsgSender::new(id, webgl_chan.clone()),
- limits: limits,
- share_mode: share_mode,
+ limits,
+ share_mode,
+ glsl_version,
}
- )).unwrap();
+ })).unwrap();
},
WebGLMsg::ResizeContext(ctx_id, size, sender) => {
self.resize_webgl_context(ctx_id, size, sender);
@@ -519,6 +524,20 @@ impl<VR: WebVRRenderHandler + 'static, OB: WebGLThreadObserver> WebGLThread<VR,
byte_swap(&mut pixels);
pixels
}
+
+ /// Gets the GLSL Version supported by a GLContext.
+ fn get_glsl_version(context: &GLContextWrapper) -> WebGLSLVersion {
+ let version = context.gl().get_string(gl::SHADING_LANGUAGE_VERSION);
+ // Fomat used by SHADING_LANGUAGE_VERSION query : major.minor[.release] [vendor info]
+ let mut values = version.split(&['.', ' '][..]);
+ let major = values.next().and_then(|v| v.parse::<u32>().ok()).unwrap_or(1);
+ let minor = values.next().and_then(|v| v.parse::<u32>().ok()).unwrap_or(20);
+
+ WebGLSLVersion {
+ major,
+ minor,
+ }
+ }
}
impl<VR: WebVRRenderHandler + 'static, OB: WebGLThreadObserver> Drop for WebGLThread<VR, OB> {