[]在开启webgl模式下,每次运行texture类的getPixels方法内存都会增加
我使用的版本是1.7.12
测试代码如下:
测试代码如下:
module Main {
import Sprite = Laya.Sprite
import Texture = Laya.Texture
import Handler = Laya.Handler
export class MaskDemo {
private Res: string;
private img: Laya.Image;
constructor() {
//Laya.init(400, 640, Laya.WebGL);
//设置舞台背景色
Laya.stage.bgColor = "#ffffff"
Laya.Stat.show()
//资源路径
this.Res = "test.png";
this.img = new Laya.Image();
this.img.pos(200, 200)
//获取图片资源,绘制到画布
this.img.skin = this.Res
//添加到舞台
Laya.stage.addChild(this.img);
}
private cacheCanvas: Laya.HTMLCanvas
private cacheTexture: Laya.Texture
init(){
let rect = this.img.getSelfBounds()
this.img.pivot(Math.round(rect.width / 2), Math.round(rect.height / 2))
let bound = this.img.getBounds()
this.cacheCanvas = this.img.drawToCanvas(Math.ceil(bound.width),
Math.ceil(bound.height),
Math.round(bound.width / 2),
Math.round(bound.height / 2))
this.cacheTexture = new Laya.Texture()
this.cacheTexture.setTo(this.cacheCanvas)
}
getPixels(){
this.cacheTexture.getPixels(0,0,120,120)
}
}
}
Laya.init(400, 640, Laya.WebGL)
var app=new Main.MaskDemo()
Laya.timer.frameOnce(5, app, ()=>{
app.init()
Laya.timer.frameLoop(2, app, app.getPixels)
})
没有找到相关结果
已邀请:
1 个回复
wudi199553
赞同来自: