Deleted Added
sdiff udiff text old ( 10810:683ab55819fd ) new ( 10839:10cac0f0f419 )
full compact
1/*
2 * Copyright (c) 2010 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 45 unchanged lines hidden (view full) ---

56
57#include <fcntl.h>
58#include <poll.h>
59#include <sys/types.h>
60#include <unistd.h>
61
62#include <cerrno>
63#include <cstdio>
64
65#include "base/atomicio.hh"
66#include "base/bitmap.hh"
67#include "base/misc.hh"
68#include "base/output.hh"
69#include "base/socket.hh"
70#include "base/trace.hh"
71#include "debug/VNC.hh"
72#include "sim/byteswap.hh"
73#include "sim/core.hh"
74
75using namespace std;
76
77/** @file
78 * Implementiation of a VNC server
79 */
80
81/**
82 * Poll event for the listen socket
83 */
84VncServer::ListenEvent::ListenEvent(VncServer *vs, int fd, int e)

--- 32 unchanged lines hidden (view full) ---

117 dataFd(-1), sendUpdate(false),
118 supportsRawEnc(false), supportsResizeEnc(false)
119{
120 if (p->port)
121 listen(p->port);
122
123 curState = WaitForProtocolVersion;
124
125 // currently we only support this one pixel format
126 // unpacked 32bit rgb (rgb888 + 8 bits of nothing/alpha)
127 // keep it around for telling the client and making
128 // sure the client cooperates
129 pixelFormat.bpp = 32;
130 pixelFormat.depth = 24;
131 pixelFormat.bigendian = 0;
132 pixelFormat.truecolor = 1;
133 pixelFormat.redmax = 0xff;
134 pixelFormat.greenmax = 0xff;
135 pixelFormat.bluemax = 0xff;
136 pixelFormat.redshift = 16;
137 pixelFormat.greenshift = 8;
138 pixelFormat.blueshift = 0;
139
140 DPRINTF(VNC, "Vnc server created at port %d\n", p->port);
141}
142
143VncServer::~VncServer()
144{
145 if (dataFd != -1)
146 ::close(dataFd);

--- 463 unchanged lines hidden (view full) ---

610
611}
612
613
614void
615VncServer::sendFrameBufferUpdate()
616{
617
618 if (!fbPtr || dataFd <= 0 || curState != NormalPhase || !sendUpdate) {
619 DPRINTF(VNC, "NOT sending framebuffer update\n");
620 return;
621 }
622
623 assert(vc);
624
625 // The client will request data constantly, unless we throttle it
626 sendUpdate = false;
627
628 DPRINTF(VNC, "Sending framebuffer update\n");
629
630 FrameBufferUpdate fbu;
631 FrameBufferRect fbr;
632

--- 12 unchanged lines hidden (view full) ---

645 fbr.width = htobe(fbr.width);
646 fbr.height = htobe(fbr.height);
647 fbr.encoding = htobe(fbr.encoding);
648
649 // send headers to client
650 write(&fbu);
651 write(&fbr);
652
653 assert(fbPtr);
654
655 uint8_t *tmp = vc->convert(fbPtr);
656 uint64_t num_pixels = videoWidth() * videoHeight();
657 write(tmp, num_pixels * sizeof(uint32_t));
658 delete [] tmp;
659
660}
661
662void
663VncServer::sendFrameBufferResized()
664{
665 assert(fbPtr && dataFd > 0 && curState == NormalPhase);
666 DPRINTF(VNC, "Sending framebuffer resize\n");
667
668 FrameBufferUpdate fbu;
669 FrameBufferRect fbr;
670
671 fbu.type = ServerFrameBufferUpdate;
672 fbu.num_rects = 1;
673 fbr.x = 0;

--- 13 unchanged lines hidden (view full) ---

687 // send headers to client
688 write(&fbu);
689 write(&fbr);
690
691 // No actual data is sent in this message
692}
693
694void
695VncServer::setFrameBufferParams(VideoConvert::Mode mode, uint16_t width,
696 uint16_t height)
697{
698 VncInput::setFrameBufferParams(mode, width, height);
699
700 if (mode != videoMode || width != videoWidth() || height != videoHeight()) {
701 if (dataFd > 0 && fbPtr && curState == NormalPhase) {
702 if (supportsResizeEnc)
703 sendFrameBufferResized();
704 else
705 // The frame buffer changed size and we can't update the client
706 detach();
707 }
708 }
709}
710
711// create the VNC server object
712VncServer *
713VncServerParams::create()
714{
715 return new VncServer(this);
716}
717