graphicsdriver/metal: Bug fix: Release drawable correctly

Fixes #847
This commit is contained in:
Hajime Hoshi 2019-04-19 20:20:29 +09:00
parent 865523048d
commit c44accbfb5
4 changed files with 10 additions and 0 deletions

View File

@ -152,3 +152,7 @@ func (md MetalDrawable) Drawable() unsafe.Pointer { return md.metalDrawable }
func (md MetalDrawable) Texture() mtl.Texture { func (md MetalDrawable) Texture() mtl.Texture {
return mtl.NewTexture(C.MetalDrawable_Texture(md.metalDrawable)) return mtl.NewTexture(C.MetalDrawable_Texture(md.metalDrawable))
} }
func (md MetalDrawable) Release() {
C.MetalDrawable_Release(md.metalDrawable)
}

View File

@ -31,3 +31,4 @@ void MetalLayer_SetDrawableSize(void *metalLayer, double width, double height);
void *MetalLayer_NextDrawable(void *metalLayer); void *MetalLayer_NextDrawable(void *metalLayer);
void *MetalDrawable_Texture(void *drawable); void *MetalDrawable_Texture(void *drawable);
void MetalDrawable_Release(void *drawable);

View File

@ -89,3 +89,7 @@ void *MetalLayer_NextDrawable(void *metalLayer) {
void *MetalDrawable_Texture(void *metalDrawable) { void *MetalDrawable_Texture(void *metalDrawable) {
return ((id<CAMetalDrawable>)metalDrawable).texture; return ((id<CAMetalDrawable>)metalDrawable).texture;
} }
void MetalDrawable_Release(void *metalDrawable) {
[(id<CAMetalDrawable>)metalDrawable release];
}

View File

@ -598,6 +598,7 @@ func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode
} }
t = d.screenDrawable.Texture() t = d.screenDrawable.Texture()
} else { } else {
d.screenDrawable.Release()
d.screenDrawable = ca.MetalDrawable{} d.screenDrawable = ca.MetalDrawable{}
t = d.dst.texture t = d.dst.texture
} }