Reputation: 1001
I'm trying to implement my own mirroring protocol. I'm using websockets to retrieve a compressed pixels buffer. After I decompress this buffer I got a big array of position with color that I should display.
I'm using canvas with a for loop on a huge arraylist (2 millions elements) in onDraw like following :
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
for (int i = 0; i < this.pixelsList.size(); i++) { //SIZE = 2.073.600 pixels
canvas.drawPoint(this.pixelsList.get(i).getPosition().x, this.pixelsList.get(i).getPosition().y, this.pixelsList.get(i).getPaint());
}
}
I'm looking for an efficient way to display this huge packet. I was on OpenGL ES but I did not find any way to display one pixel in one position.. Maybe should I take a look with OpenCV ?
Upvotes: 1
Views: 238
Reputation: 1066
Don't dereference each pixel address and use a texture in OpenGL. This might be the fastest way.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture[texture_id].texture_width, texture[texture_id].texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelsList);
or if it's frequently updated
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, **pixelsList**);
Upvotes: 1