| 84 | // anyone else. Call setFramebuffer again with NULL or a different |
| 85 | // PixelBuffer to delete the previous one. |
| 86 | public void setFramebuffer(ModifiablePixelBuffer fb) |
| 87 | { |
| 88 | decoder.flush(); |
| 89 | |
| 90 | if (fb != null) { |
| 91 | assert(fb.width() == server.width()); |
| 92 | assert(fb.height() == server.height()); |
| 93 | } |
| 94 | |
| 95 | if ((framebuffer != null) && (fb != null)) { |
| 96 | Rect rect = new Rect(); |
| 97 | |
| 98 | Raster data; |
| 99 | |
| 100 | byte[] black = new byte[4]; |
| 101 | |
| 102 | // Copy still valid area |
| 103 | |
| 104 | rect.setXYWH(0, 0, |
| 105 | Math.min(fb.width(), framebuffer.width()), |
| 106 | Math.min(fb.height(), framebuffer.height())); |
| 107 | data = framebuffer.getBuffer(rect); |
| 108 | fb.imageRect(framebuffer.getPF(), rect, data); |
| 109 | |
| 110 | // Black out any new areas |
| 111 | |
| 112 | if (fb.width() > framebuffer.width()) { |
| 113 | rect.setXYWH(framebuffer.width(), 0, |
| 114 | fb.width() - framebuffer.width(), |
| 115 | fb.height()); |
| 116 | fb.fillRect(rect, black); |
| 117 | } |
| 118 | |
| 119 | if (fb.height() > framebuffer.height()) { |
| 120 | rect.setXYWH(0, framebuffer.height(), |
| 121 | fb.width(), |
| 122 | fb.height() - framebuffer.height()); |
| 123 | fb.fillRect(rect, black); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | framebuffer = fb; |
| 128 | } |
| 129 | |
| 130 | // initialiseProtocol() should be called once the streams and security |
| 131 | // types are set. Subsequently, processMsg() should be called whenever |