зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1652894 - allow SWGL contexts to have multiple strong references. r=jimb
Differential Revision: https://phabricator.services.mozilla.com/D86337
This commit is contained in:
Родитель
68cd54888e
Коммит
9875e7ea3f
|
@ -21,6 +21,11 @@ pub extern "C" fn wr_swgl_create_context() -> *mut c_void {
|
|||
swgl::Context::create().into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_swgl_reference_context(ctx: *mut c_void) {
|
||||
swgl::Context::from(ctx).reference();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_swgl_destroy_context(ctx: *mut c_void) {
|
||||
swgl::Context::from(ctx).destroy();
|
||||
|
|
|
@ -512,6 +512,8 @@ struct ObjectStore {
|
|||
};
|
||||
|
||||
struct Context {
|
||||
int32_t references = 1;
|
||||
|
||||
ObjectStore<Query> queries;
|
||||
ObjectStore<Buffer> buffers;
|
||||
ObjectStore<Texture> textures;
|
||||
|
@ -4093,8 +4095,11 @@ void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
|
|||
|
||||
void Finish() {}
|
||||
|
||||
void MakeCurrent(void* ctx_ptr) {
|
||||
ctx = (Context*)ctx_ptr;
|
||||
void MakeCurrent(Context* c) {
|
||||
if (ctx == c) {
|
||||
return;
|
||||
}
|
||||
ctx = c;
|
||||
if (ctx) {
|
||||
setup_program(ctx->current_program);
|
||||
blend_key = ctx->blend ? ctx->blend_key : BLEND_KEY_NONE;
|
||||
|
@ -4104,16 +4109,28 @@ void MakeCurrent(void* ctx_ptr) {
|
|||
}
|
||||
}
|
||||
|
||||
void* CreateContext() { return new Context; }
|
||||
Context* CreateContext() { return new Context; }
|
||||
|
||||
void DestroyContext(void* ctx_ptr) {
|
||||
if (!ctx_ptr) {
|
||||
void ReferenceContext(Context* c) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
if (ctx == ctx_ptr) {
|
||||
++c->references;
|
||||
}
|
||||
|
||||
void DestroyContext(Context* c) {
|
||||
if (!c) {
|
||||
return;
|
||||
}
|
||||
assert(c->references > 0);
|
||||
--c->references;
|
||||
if (c->references > 0) {
|
||||
return;
|
||||
}
|
||||
if (ctx == c) {
|
||||
MakeCurrent(nullptr);
|
||||
}
|
||||
delete (Context*)ctx_ptr;
|
||||
delete c;
|
||||
}
|
||||
|
||||
typedef Texture LockedTexture;
|
||||
|
|
|
@ -300,6 +300,7 @@ extern "C" {
|
|||
flip: GLboolean,
|
||||
);
|
||||
fn CreateContext() -> *mut c_void;
|
||||
fn ReferenceContext(ctx: *mut c_void);
|
||||
fn DestroyContext(ctx: *mut c_void);
|
||||
fn MakeCurrent(ctx: *mut c_void);
|
||||
}
|
||||
|
@ -312,6 +313,12 @@ impl Context {
|
|||
Context(unsafe { CreateContext() })
|
||||
}
|
||||
|
||||
pub fn reference(&self) {
|
||||
unsafe {
|
||||
ReferenceContext(self.0);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn destroy(&self) {
|
||||
unsafe {
|
||||
DestroyContext(self.0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче