aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webgltexture.rs
diff options
context:
space:
mode:
authorImanol Fernandez <mortimergoro@gmail.com>2017-09-21 15:16:46 +0200
committerImanol Fernandez <mortimergoro@gmail.com>2017-10-16 20:56:53 +0200
commit8ae0739bab8a3c74e0685d9f53bbb155e4458aba (patch)
treee1521882893206d2dd3bf06de5260f7bf0994cb7 /components/script/dom/webgltexture.rs
parenta9022be0c3e30249845ca5947ac0c0a6743c7991 (diff)
downloadservo-8ae0739bab8a3c74e0685d9f53bbb155e4458aba.tar.gz
servo-8ae0739bab8a3c74e0685d9f53bbb155e4458aba.zip
Implement DOM to texture
Diffstat (limited to 'components/script/dom/webgltexture.rs')
-rw-r--r--components/script/dom/webgltexture.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs
index 59be8681337..6927fd10a48 100644
--- a/components/script/dom/webgltexture.rs
+++ b/components/script/dom/webgltexture.rs
@@ -5,6 +5,7 @@
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLError, WebGLMsgSender, WebGLResult, WebGLTextureId};
+use canvas_traits::webgl::DOMToTextureCommand;
use dom::bindings::cell::DomRefCell;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use dom::bindings::codegen::Bindings::WebGLTextureBinding;
@@ -45,6 +46,8 @@ pub struct WebGLTexture {
mag_filter: Cell<Option<u32>>,
#[ignore_heap_size_of = "Defined in ipc-channel"]
renderer: WebGLMsgSender,
+ /// True if this texture is used for the DOMToTexture feature.
+ attached_to_dom: Cell<bool>,
}
impl WebGLTexture {
@@ -62,6 +65,7 @@ impl WebGLTexture {
mag_filter: Cell::new(None),
image_info_array: DomRefCell::new([ImageInfo::new(); MAX_LEVEL_COUNT * MAX_FACE_COUNT]),
renderer: renderer,
+ attached_to_dom: Cell::new(false),
}
}
@@ -179,6 +183,10 @@ impl WebGLTexture {
pub fn delete(&self) {
if !self.is_deleted.get() {
self.is_deleted.set(true);
+ // Notify WR to release the frame output when using DOMToTexture feature
+ if self.attached_to_dom.get() {
+ let _ = self.renderer.send_dom_to_texture(DOMToTextureCommand::Detach(self.id));
+ }
let _ = self.renderer.send(WebGLCommand::DeleteTexture(self.id));
}
}
@@ -374,6 +382,10 @@ impl WebGLTexture {
Some(self.image_info_at_face(0, self.base_mipmap_level))
}
+
+ pub fn set_attached_to_dom(&self) {
+ self.attached_to_dom.set(true);
+ }
}
impl Drop for WebGLTexture {