[0]setSubPixels画布擦除不掉

 this.btn.label = Math.random().toString();
// console.log(Math.random());
let tex:Laya.Texture = Laya.Loader.getRes(this.bUrl);

let x:number = this._testStatus == true ? 0:50;//Math.random()>0.5 ? 50 : 0;
this._testStatus = !this._testStatus;

// let canvasInfo = this.getCanvasWidthHeight();

let ctx = new Laya.Context();
// let w = canvasInfo.w//tex.width;
// let h = canvasInfo.h//tex.height;

let w = tex.width;
let h = tex.height;

ctx.size(w,h);
ctx.asBitmap = true;
// ctx.clearRect(0,0,w,h);

let _targets= ctx['_targets'];
_targets.start();
ctx.clear();
this.drawTex(ctx,this.bUrl,x,0);
// this.drawTex(ctx,this.cUrl,x,0);
ctx.flush();
_targets.end();
_targets.restore();
let dt = _targets.getData(0, 0, w, h);//像素数据
ctx.destroy();

if(!this.aImg){
let aImg:Laya.Image = new Laya.Image(this.aUrl);
aImg.scaleX = aImg.scaleY = 2;
Laya.stage.addChild(aImg);
aImg.mouseEnabled = false;
this.aImg = aImg;
}

//清除目标纹理的像素
let _sourceTex:Laya.Texture = Laya.Loader.getRes(this.aUrl);
let ret = new Uint8Array(_sourceTex.width * _sourceTex.height * 4);
let tex2d:Laya.Texture2D = this.aImg.source["_bitmap"];
tex2d.setPixels(ret);//填充像素数据

//该操作在vulkan中会有杂点,directX opengl没有问题
tex2d.setSubPixels(0,0,w,h,dt);// 这里有问题 注释掉 在微信小游戏vulkan驱动环境下 没有清屏(噪点和上次画布残留像素数据)


// this.clearTexture();//清除目标纹理的像素

// tex2d.getPixels();
/*
let p1 = this.aImg.source.getPixels(0,0,tex2d.width,tex2d.height);
let tex1 = new Laya.Texture2D(tex2d.width,tex2d.height);
tex1.setPixels(p1);
let tex22:Laya.Texture = new Laya.Texture();
tex22.bitmap = tex1;
this.aImg.source = tex22;

console.log("time:"+Laya.timer.currTimer);

Laya.timer.once(1000,this,()=>{
console.log("time:"+Laya.timer.currTimer);
// tex2d
tex1.setSubPixels(0,0,w,h,dt);// 这里有问题
})
*/
1.jpg
已邀请:

小高

赞同来自:

给个示例吧,我们来复现下,这样不好定位问题。

要回复问题请先

商务合作
商务合作