use of common.BitmapOrder in project cloudstack by apache.
the class ServerBitmapUpdate method handleData.
@Override
public void handleData(ByteBuffer buf, Link link) {
if (verbose)
System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
// * DEBUG */System.out.println(buf.toHexString(buf.length));
BitmapOrder order = new BitmapOrder();
// (2 bytes): A 16-bit, unsigned integer. The update type. This field MUST
// be set to UPDATETYPE_BITMAP (0x0001).
int updateType = buf.readSignedShortLE();
if (updateType != UPDATETYPE_BITMAP)
throw new RuntimeException("Unknown update type. Expected update type: UPDATETYPE_BITMAP (0x1). Actual update type: " + updateType + ", buf: " + buf + ".");
// (2 bytes): A 16-bit, unsigned integer. The number of screen rectangles
// present in the rectangles field.
int numberRectangles = buf.readSignedShortLE();
// (variable): Variable-length array of TS_BITMAP_DATA structures, each of
// which contains a rectangular clipping taken from the server-side screen
// frame buffer. The number of screen clippings in the array is specified by
// the numberRectangles field.
BitmapRectangle[] rectangles = new BitmapRectangle[numberRectangles];
for (int i = 0; i < numberRectangles; i++) {
rectangles[i] = readRectangle(buf);
}
order.rectangles = rectangles;
buf.assertThatBufferIsFullyRead();
ByteBuffer data = new ByteBuffer(order);
pushDataToAllOuts(data);
buf.unref();
}
use of common.BitmapOrder in project cloudstack by apache.
the class AwtCanvasAdapter method handleData.
@Override
public void handleData(ByteBuffer buf, Link link) {
if (verbose)
System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
Order order = buf.getOrder();
switch((OrderType) order.type) {
case BITMAP_UPDATE:
handleBitmap((BitmapOrder) order, buf);
break;
case COPY_RECT:
handleCopyRect((CopyRectOrder) order, buf);
break;
default:
throw new RuntimeException("Order is not implemented: " + buf + ".");
}
buf.unref();
}
use of common.BitmapOrder in project cloudstack by apache.
the class VncMessageHandler method handleRawRectangle.
private boolean handleRawRectangle(ByteBuffer buf, Link link, int x, int y, int width, int height) {
// Raw rectangle is just array of pixels to draw on screen.
int rectDataLength = width * height * screen.getBytesPerPixel();
// rectangles.
if (!cap(buf, rectDataLength, UNLIMITED, link, true))
return false;
if (verbose)
System.out.println("[" + this + "] INFO: Raw rect. X: " + x + ", y: " + y + ", width: " + width + ", height: " + height + ", data length: " + rectDataLength + ".");
BitmapRectangle rectangle = new BitmapRectangle();
rectangle.x = x;
rectangle.y = y;
rectangle.width = width;
rectangle.height = height;
rectangle.bufferWidth = width;
rectangle.bufferHeight = height;
rectangle.bitmapDataStream = buf.readBytes(rectDataLength);
rectangle.colorDepth = screen.getColorDeph();
BitmapOrder order = new BitmapOrder();
order.rectangles = new BitmapRectangle[] { rectangle };
pushDataToPad(PIXEL_ADAPTER_PAD, new ByteBuffer(order));
return true;
}
Aggregations