Auto merge of #18127 - MortimerGoro:webgl_bind_tex2d, r=emilio

Fix bound textures and framebuffers when a WebGL Canvas is resized

<!-- Please describe your changes on the following line: -->

Fix bound textures and framebuffers when a WebGL Canvas is resized. This causes some invisible textures in WebGL based games.

---
<!-- 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/18127)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-17 14:06:10 -05:00 committed by GitHub
commit e23ae30489

View file

@ -279,6 +279,22 @@ impl WebGLRenderingContext {
// default scissor when the canvas was created or the last scissor that the user set.
let rect = self.current_scissor.get();
self.send_command(WebGLCommand::Scissor(rect.0, rect.1, rect.2, rect.3));
// Bound texture must not change when the canvas is resized.
// Right now offscreen_gl_context generates a new FBO and the bound texture is changed
// in order to create a new render to texture attachment.
// Send a command to re-bind the TEXTURE_2D, if any.
if let Some(texture) = self.bound_texture_2d.get() {
self.send_command(WebGLCommand::BindTexture(constants::TEXTURE_2D, Some(texture.id())));
}
// Bound framebuffer must not change when the canvas is resized.
// Right now offscreen_gl_context generates a new FBO on resize.
// Send a command to re-bind the framebuffer, if any.
if let Some(fbo) = self.bound_framebuffer.get() {
let id = WebGLFramebufferBindingRequest::Explicit(fbo.id());
self.send_command(WebGLCommand::BindFramebuffer(constants::FRAMEBUFFER, id));
}
}
pub fn webgl_sender(&self) -> WebGLMsgSender {