mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-15 15:58:57 +00:00
support WEBGL_lose_context
This commit is contained in:
@@ -61,7 +61,7 @@ pub const Extension = union(enum) {
|
|||||||
WEBGL_debug_shaders: void,
|
WEBGL_debug_shaders: void,
|
||||||
WEBGL_depth_texture: void,
|
WEBGL_depth_texture: void,
|
||||||
WEBGL_draw_buffers: void,
|
WEBGL_draw_buffers: void,
|
||||||
WEBGL_lose_context: void,
|
WEBGL_lose_context: Type.WEBGL_lose_context,
|
||||||
WEBGL_multi_draw: void,
|
WEBGL_multi_draw: void,
|
||||||
WEBGL_polygon_mode: void,
|
WEBGL_polygon_mode: void,
|
||||||
|
|
||||||
@@ -117,6 +117,12 @@ pub const Extension = union(enum) {
|
|||||||
return UNMASKED_RENDERER_WEBGL;
|
return UNMASKED_RENDERER_WEBGL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const WEBGL_lose_context = struct {
|
||||||
|
_: u8 = 0,
|
||||||
|
pub fn _loseContext(_: *const WEBGL_lose_context) void {}
|
||||||
|
pub fn _restoreContext(_: *const WEBGL_lose_context) void {}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -128,6 +134,7 @@ pub fn _getExtension(self: *const WebGLRenderingContext, name: []const u8) ?Exte
|
|||||||
|
|
||||||
return switch (tag) {
|
return switch (tag) {
|
||||||
.WEBGL_debug_renderer_info => @unionInit(Extension, "WEBGL_debug_renderer_info", .{}),
|
.WEBGL_debug_renderer_info => @unionInit(Extension, "WEBGL_debug_renderer_info", .{}),
|
||||||
|
.WEBGL_lose_context => @unionInit(Extension, "WEBGL_lose_context", .{}),
|
||||||
inline else => |comptime_enum| @unionInit(Extension, @tagName(comptime_enum), {}),
|
inline else => |comptime_enum| @unionInit(Extension, @tagName(comptime_enum), {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ pub const Interfaces = .{
|
|||||||
CanvasRenderingContext2D,
|
CanvasRenderingContext2D,
|
||||||
WebGLRenderingContext,
|
WebGLRenderingContext,
|
||||||
Extension.Type.WEBGL_debug_renderer_info,
|
Extension.Type.WEBGL_debug_renderer_info,
|
||||||
|
Extension.Type.WEBGL_lose_context,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -102,4 +102,15 @@
|
|||||||
testing.expectEqual(rendererInfo.UNMASKED_VENDOR_WEBGL, 0x9245);
|
testing.expectEqual(rendererInfo.UNMASKED_VENDOR_WEBGL, 0x9245);
|
||||||
testing.expectEqual(rendererInfo.UNMASKED_RENDERER_WEBGL, 0x9246);
|
testing.expectEqual(rendererInfo.UNMASKED_RENDERER_WEBGL, 0x9246);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WEBGL_lose_context
|
||||||
|
{
|
||||||
|
const element = document.createElement("canvas");
|
||||||
|
const ctx = element.getContext("webgl");
|
||||||
|
const loseContext = ctx.getExtension("WEBGL_lose_context");
|
||||||
|
testing.expectEqual(true, loseContext instanceof WEBGL_lose_context);
|
||||||
|
|
||||||
|
loseContext.loseContext();
|
||||||
|
loseContext.restoreContext();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user