aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webgltexture.rs
diff options
context:
space:
mode:
authorAlan Jeffrey <ajeffrey@mozilla.com>2020-07-29 17:06:45 -0500
committerAlan Jeffrey <ajeffrey@mozilla.com>2020-07-29 17:14:51 -0500
commitdfc641d64841bab44cdca2cba0009901416f78f6 (patch)
tree52959338cee741e150b8001de851ef062ca0503f /components/script/dom/webgltexture.rs
parent0d77e0f6cfe889efdf5b00c9fc729fcceb0899d8 (diff)
downloadservo-dfc641d64841bab44cdca2cba0009901416f78f6.tar.gz
servo-dfc641d64841bab44cdca2cba0009901416f78f6.zip
Don't delete GL textures created by WebXR
Diffstat (limited to 'components/script/dom/webgltexture.rs')
-rw-r--r--components/script/dom/webgltexture.rs38
1 files changed, 36 insertions, 2 deletions
diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs
index 2f46bb47198..02cedeb5755 100644
--- a/components/script/dom/webgltexture.rs
+++ b/components/script/dom/webgltexture.rs
@@ -29,6 +29,14 @@ pub enum TexParameterValue {
Bool(bool),
}
+// Textures generated for WebXR are owned by the WebXR device, not by the WebGL thread
+// so the GL texture should not be deleted when the texture is garbage collected.
+#[derive(Clone, Copy, Debug, Eq, JSTraceable, MallocSizeOf, PartialEq)]
+enum WebGLTextureOwner {
+ WebGL,
+ WebXR,
+}
+
const MAX_LEVEL_COUNT: usize = 31;
const MAX_FACE_COUNT: usize = 6;
@@ -41,6 +49,7 @@ pub struct WebGLTexture {
/// The target to which this texture was bound the first time
target: Cell<Option<u32>>,
is_deleted: Cell<bool>,
+ owner: WebGLTextureOwner,
/// Stores information about mipmap levels and cubemap faces.
#[ignore_malloc_size_of = "Arrays are cumbersome"]
image_info_array: DomRefCell<[Option<ImageInfo>; MAX_LEVEL_COUNT * MAX_FACE_COUNT]>,
@@ -59,12 +68,17 @@ pub struct WebGLTexture {
}
impl WebGLTexture {
- fn new_inherited(context: &WebGLRenderingContext, id: WebGLTextureId) -> Self {
+ fn new_inherited(
+ context: &WebGLRenderingContext,
+ id: WebGLTextureId,
+ owner: WebGLTextureOwner,
+ ) -> Self {
Self {
webgl_object: WebGLObject::new_inherited(context),
id: id,
target: Cell::new(None),
is_deleted: Cell::new(false),
+ owner: owner,
immutable_levels: Cell::new(None),
face_count: Cell::new(0),
base_mipmap_level: 0,
@@ -87,7 +101,22 @@ impl WebGLTexture {
pub fn new(context: &WebGLRenderingContext, id: WebGLTextureId) -> DomRoot<Self> {
reflect_dom_object(
- Box::new(WebGLTexture::new_inherited(context, id)),
+ Box::new(WebGLTexture::new_inherited(
+ context,
+ id,
+ WebGLTextureOwner::WebGL,
+ )),
+ &*context.global(),
+ )
+ }
+
+ pub fn new_webxr(context: &WebGLRenderingContext, id: WebGLTextureId) -> DomRoot<Self> {
+ reflect_dom_object(
+ Box::new(WebGLTexture::new_inherited(
+ context,
+ id,
+ WebGLTextureOwner::WebXR,
+ )),
&*context.global(),
)
}
@@ -216,6 +245,11 @@ impl WebGLTexture {
let _ = fb.detach_texture(self);
}
+ // We don't delete textures owned by WebXR
+ if self.owner == WebGLTextureOwner::WebXR {
+ return;
+ }
+
let cmd = WebGLCommand::DeleteTexture(self.id);
match operation_fallibility {
Operation::Fallible => context.send_command_ignored(cmd),