2
我试着为剪切纹理创建蒙版。用户在屏幕上移动手指,以及何时会弹起手指遮罩。我的问题,用户有很长一段时间移动在屏幕上了手指之后,面膜开始创建,和我有ANR符合PolygonRegion创建anr
PolygonRegion polyReg = new PolygonRegion(textRegion, coord);
其中坐标是浮点数组和textRegion它与纹理对象TextureRegion其中需要画。当用户长时间在屏幕上移动时会出现问题。第一次我认为PolygonRegion不能解决很多问题,但是在了解了它不算点问题之后(有时候我有160点的anr,有时候我没有1000点的anr)。也许有人采取同样的问题,并可以说它可能是什么。
代码:
if(maskBufferer != null){
maskBufferer.dispose();
}
maskBufferer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
mask = createMaskImageMask(aspectRatioCrop, maskBufferer);
...
private Texture createMaskImageMask(boolean aspectRatioCrop, FrameBuffer maskBufferer) {
maskBufferer.begin();
Gdx.gl.glClearColor(COLOR_FOR_MASK, COLOR_FOR_MASK, COLOR_FOR_MASK, ALPHA_FOR_MASK);
Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
float[] coord = null;
coord = mCoodrinateArray.getCoodrinatesInScreenSize();
mCoodrinateArray.clean();
PolygonRegion polyReg = new PolygonRegion(new TextureRegion(new Texture(Gdx.files.internal(texturePolygon))),
coord);
PolygonSprite poly = new PolygonSprite(polyReg);
PolygonSpriteBatch polyBatch = new PolygonSpriteBatch();
polyBatch.begin();
poly.draw(polyBatch);
polyBatch.end();
maskBufferer.end();
texture.dispose();
polyBatch.dispose();
return maskBufferer.getColorBufferTexture();
}
在onMove代码:
Vector3 vec = MathUtils.toGlFromScreenV3(detector.getCurrEvent().getX(), detector.getCurrEvent().getY(), mWidth, mHeight);
mCoodrinateArray.addCoordinate(vi.x, vi.y);