2c2
< * Copyright (c) 2010 ARM Limited
---
> * Copyright (c) 2010, 2015 ARM Limited
63a64
> #include <cstddef>
76a78,83
> const PixelConverter VncServer::pixelConverter(
> 4, // 4 bytes / pixel
> 16, 8, 0, // R in [23, 16], G in [15, 8], B in [7, 0]
> 8, 8, 8, // 8 bits / channel
> LittleEndianByteOrder);
>
125,131c132,137
< // currently we only support this one pixel format
< // unpacked 32bit rgb (rgb888 + 8 bits of nothing/alpha)
< // keep it around for telling the client and making
< // sure the client cooperates
< pixelFormat.bpp = 32;
< pixelFormat.depth = 24;
< pixelFormat.bigendian = 0;
---
> // We currently only support one pixel format. Extract the pixel
> // representation from our PixelConverter instance and keep it
> // around for telling the client and making sure it cooperates
> pixelFormat.bpp = 8 * pixelConverter.length;
> pixelFormat.depth = pixelConverter.depth;
> pixelFormat.bigendian = pixelConverter.byte_order == BigEndianByteOrder;
133,138c139,144
< pixelFormat.redmax = 0xff;
< pixelFormat.greenmax = 0xff;
< pixelFormat.bluemax = 0xff;
< pixelFormat.redshift = 16;
< pixelFormat.greenshift = 8;
< pixelFormat.blueshift = 0;
---
> pixelFormat.redmax = pixelConverter.ch_r.mask;
> pixelFormat.greenmax = pixelConverter.ch_g.mask;
> pixelFormat.bluemax = pixelConverter.ch_b.mask;
> pixelFormat.redshift = pixelConverter.ch_r.offset;
> pixelFormat.greenshift = pixelConverter.ch_g.offset;
> pixelFormat.blueshift = pixelConverter.ch_b.offset;
618c624
< if (!fbPtr || dataFd <= 0 || curState != NormalPhase || !sendUpdate) {
---
> if (dataFd <= 0 || curState != NormalPhase || !sendUpdate) {
623,624d628
< assert(vc);
<
653c657
< assert(fbPtr);
---
> assert(fb);
655,658c659,666
< uint8_t *tmp = vc->convert(fbPtr);
< uint64_t num_pixels = videoWidth() * videoHeight();
< write(tmp, num_pixels * sizeof(uint32_t));
< delete [] tmp;
---
> std::vector<uint8_t> line_buffer(pixelConverter.length * fb->width());
> for (int y = 0; y < fb->height(); ++y) {
> // Convert and send a line at a time
> uint8_t *raw_pixel(line_buffer.data());
> for (unsigned x = 0; x < fb->width(); ++x) {
> pixelConverter.fromPixel(raw_pixel, fb->pixel(x, y));
> raw_pixel += pixelConverter.length;
> }
659a668,669
> write(line_buffer.data(), line_buffer.size());
> }
665c675
< assert(fbPtr && dataFd > 0 && curState == NormalPhase);
---
> assert(fb && dataFd > 0 && curState == NormalPhase);
695,696c705
< VncServer::setFrameBufferParams(VideoConvert::Mode mode, uint16_t width,
< uint16_t height)
---
> VncServer::setDirty()
698c707
< VncInput::setFrameBufferParams(mode, width, height);
---
> VncInput::setDirty();
700,707c709,721
< if (mode != videoMode || width != videoWidth() || height != videoHeight()) {
< if (dataFd > 0 && fbPtr && curState == NormalPhase) {
< if (supportsResizeEnc)
< sendFrameBufferResized();
< else
< // The frame buffer changed size and we can't update the client
< detach();
< }
---
> sendUpdate = true;
> sendFrameBufferUpdate();
> }
>
> void
> VncServer::frameBufferResized()
> {
> if (dataFd > 0 && curState == NormalPhase) {
> if (supportsResizeEnc)
> sendFrameBufferResized();
> else
> // The frame buffer changed size and we can't update the client
> detach();