GLES2Dbg: use liblzf for compressing images

liblzf is in external/liblzf

Change-Id: I5425529cbb24acaf5c41a9046784a8fa7c1791f9
Signed-off-by: David Li <davidxli@google.com>
This commit is contained in:
David Li
2011-03-30 12:43:55 -07:00
parent 773c80fdb1
commit 0a5638a10b
9 changed files with 35 additions and 37 deletions

View File

@@ -17,13 +17,14 @@
package com.android.glesv2debugger;
import com.android.glesv2debugger.DebuggerMessage.Message;
import com.android.glesv2debugger.DebuggerMessage.Message.Function;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
public class MessageData {
public Message.Function function;
public final Message msg;
public Image image; // texture
public String shader; // shader source
public String[] columns;
@@ -32,11 +33,12 @@ public class MessageData {
public GLEnum dataType; // could be float, int; mainly for formatting use
public MessageData(final Device device, final Message msg) {
this.msg = msg;
image = null;
shader = null;
data = null;
StringBuilder builder = new StringBuilder();
function = msg.getFunction();
final Function function = msg.getFunction();
ImageData imageData = null;
if (function != Message.Function.ACK)
assert msg.hasTime();

View File

@@ -30,35 +30,6 @@ public class MessageProcessor {
MessageDialog.openError(null, "MessageProcessor", message);
}
static byte[] RLEDecode(final byte[] data) {
byte dataSize = data[0];
int a = data[1] & 0xff, b = data[2] & 0xff, c = data[3] & 0xff, d = data[4] & 0xff;
int count = (d << 24) | (c << 16) | (b << 8) | a;
byte[] buffer = new byte[count * dataSize];
int write = 0;
int i = 5;
for (i = 5; i < data.length;) {
byte flag = data[i];
int repeat = (flag & 0x7f) + 1;
assert 0 < repeat && repeat < 129;
i++;
if (0x80 == (flag & 0x80)) {
for (int j = 0; j < repeat; j++)
for (int k = 0; k < dataSize; k++)
buffer[write++] = data[i + k];
i += dataSize;
} else // literal runs
{
for (int j = 0; j < repeat; j++)
for (int k = 0; k < dataSize; k++)
buffer[write++] = data[i++];
}
}
assert write == count * dataSize;
assert i == data.length;
return buffer;
}
public static ImageData ReceiveImage(int width, int height, int format,
int type, byte[] data) {
assert width > 0 && height > 0;
@@ -121,9 +92,12 @@ public class MessageProcessor {
showError("unsupported texture format: " + format);
return null;
}
// data = RLEDecode(data);
byte[] pixels = new byte[width * height * (bpp / 8)];
int decompressed = org.liblzf.CLZF.lzf_decompress(data, data.length, pixels, pixels.length);
assert decompressed == width * height * (bpp / 8);
PaletteData palette = new PaletteData(redMask, greenMask, blueMask);
return new ImageData(width, height, bpp, palette, 1, data);
return new ImageData(width, height, bpp, palette, 1, pixels);
}
static public float[] ReceiveData(final GLEnum type, final ByteString data) {

View File

@@ -90,7 +90,8 @@ public class MessageQueue implements Runnable {
DataOutputStream dos = null;
HashMap<Integer, ArrayList<Message>> incoming = new HashMap<Integer, ArrayList<Message>>();
try {
socket.connect(new java.net.InetSocketAddress("127.0.0.1", 5039));
socket.connect(new java.net.InetSocketAddress("127.0.0.1", Integer
.parseInt(sampleView.actionPort.getText())));
dis = new DataInputStream(socket.getInputStream());
dos = new DataOutputStream(socket.getOutputStream());
} catch (Exception e) {

View File

@@ -108,6 +108,7 @@ public class SampleView extends ViewPart implements Runnable {
Action actionAutoScroll;
Action actionFilter;
Action actionCapture;
Action actionPort;
Point origin = new Point(0, 0); // for smooth scrolling canvas
String[] filters = null;
@@ -473,6 +474,22 @@ public class SampleView extends ViewPart implements Runnable {
manager.update(true);
}
});
actionPort = new Action("5039", Action.AS_DROP_DOWN_MENU)
{
@Override
public void run() {
org.eclipse.jface.dialogs.InputDialog dialog = new org.eclipse.jface.dialogs.InputDialog(
shell, "Port",
"Debugger port",
actionPort.getText(), null);
if (Window.OK == dialog.open()) {
actionPort.setText(dialog.getValue());
manager.update(true);
}
}
};
manager.add(actionPort);
}
private void ConnectDisconnect() {
@@ -564,7 +581,7 @@ public class SampleView extends ViewPart implements Runnable {
MessageData msgData = (MessageData) objects[i];
if (null == msgData)
continue;
totalTime += Float.parseFloat(msgData.columns[1]);
totalTime += msgData.msg.getTime();
}
viewer.getTable().getColumn(1).setText(Float.toString(totalTime));
return;