зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1652894 - add SWGL utility bindings for managing textures. r=jimb
Differential Revision: https://phabricator.services.mozilla.com/D86338
This commit is contained in:
Родитель
7a6953c9a3
Коммит
8c69cf96f0
|
@ -47,6 +47,50 @@ pub extern "C" fn wr_swgl_init_default_framebuffer(
|
|||
swgl::Context::from(ctx).init_default_framebuffer(width, height, stride, buf);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_swgl_gen_texture(ctx: *mut c_void) -> u32 {
|
||||
swgl::Context::from(ctx).gen_textures(1)[0]
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_swgl_delete_texture(ctx: *mut c_void, tex: u32) {
|
||||
swgl::Context::from(ctx).delete_textures(&[tex]);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_swgl_set_texture_parameter(
|
||||
ctx: *mut c_void,
|
||||
tex: u32,
|
||||
pname: u32,
|
||||
param: i32,
|
||||
) {
|
||||
swgl::Context::from(ctx).set_texture_parameter(tex, pname, param);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_swgl_set_texture_buffer(
|
||||
ctx: *mut c_void,
|
||||
tex: u32,
|
||||
internal_format: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
stride: i32,
|
||||
buf: *mut c_void,
|
||||
min_width: i32,
|
||||
min_height: i32,
|
||||
) {
|
||||
swgl::Context::from(ctx).set_texture_buffer(
|
||||
tex,
|
||||
internal_format,
|
||||
width,
|
||||
height,
|
||||
stride,
|
||||
buf,
|
||||
min_width,
|
||||
min_height,
|
||||
);
|
||||
}
|
||||
|
||||
pub struct SwTile {
|
||||
x: i32,
|
||||
y: i32,
|
||||
|
|
|
@ -1539,8 +1539,8 @@ void GenerateMipmap(UNUSED GLenum target) {
|
|||
// TODO: support mipmaps
|
||||
}
|
||||
|
||||
void TexParameteri(GLenum target, GLenum pname, GLint param) {
|
||||
Texture& t = ctx->textures[ctx->get_binding(target)];
|
||||
void SetTextureParameter(GLuint texid, GLenum pname, GLint param) {
|
||||
Texture& t = ctx->textures[texid];
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_WRAP_S:
|
||||
assert(param == GL_CLAMP_TO_EDGE);
|
||||
|
@ -1559,6 +1559,10 @@ void TexParameteri(GLenum target, GLenum pname, GLint param) {
|
|||
}
|
||||
}
|
||||
|
||||
void TexParameteri(GLenum target, GLenum pname, GLint param) {
|
||||
SetTextureParameter(ctx->get_binding(target), pname, param);
|
||||
}
|
||||
|
||||
void GenTextures(int n, GLuint* result) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
Texture t;
|
||||
|
|
|
@ -273,6 +273,7 @@ extern "C" {
|
|||
min_width: GLsizei,
|
||||
min_height: GLsizei,
|
||||
);
|
||||
fn SetTextureParameter(tex: GLuint, pname: GLenum, param: GLint);
|
||||
fn DeleteTexture(n: GLuint);
|
||||
fn DeleteRenderbuffer(n: GLuint);
|
||||
fn DeleteFramebuffer(n: GLuint);
|
||||
|
@ -372,6 +373,12 @@ impl Context {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_texture_parameter(&self, tex: GLuint, pname: GLenum, param: GLint) {
|
||||
unsafe {
|
||||
SetTextureParameter(tex, pname, param);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lock_framebuffer(&self, fbo: GLuint) -> Option<LockedResource> {
|
||||
unsafe {
|
||||
let resource = LockFramebuffer(fbo);
|
||||
|
|
Загрузка…
Ссылка в новой задаче