Просмотр исходного кода

Remove indirect capability attributes

Better to check the actual list of supported encodings directly.
Makes parts more readable, and no risk of getting out of sync.
tags/v1.9.90
Pierre Ossman 6 лет назад
Родитель
Сommit
b114f5cfb7

+ 33
- 54
common/rfb/ClientParams.cxx Просмотреть файл

@@ -26,14 +26,6 @@ using namespace rfb;

ClientParams::ClientParams()
: majorVersion(0), minorVersion(0),
useCopyRect(false),
supportsLocalCursor(false), supportsLocalXCursor(false),
supportsLocalCursorWithAlpha(false),
supportsDesktopResize(false), supportsExtendedDesktopSize(false),
supportsDesktopRename(false), supportsLastRect(false),
supportsLEDState(false), supportsQEMUKeyEvent(false),
supportsSetDesktopSize(false), supportsFence(false),
supportsContinuousUpdates(false),
compressLevel(2), qualityLevel(-1), fineQualityLevel(-1),
subsampling(subsampleUndefined),
width_(0), height_(0), name_(0),
@@ -93,14 +85,6 @@ bool ClientParams::supportsEncoding(rdr::S32 encoding) const

void ClientParams::setEncodings(int nEncodings, const rdr::S32* encodings)
{
useCopyRect = false;
supportsLocalCursor = false;
supportsLocalCursorWithAlpha = false;
supportsDesktopResize = false;
supportsExtendedDesktopSize = false;
supportsLocalXCursor = false;
supportsLastRect = false;
supportsQEMUKeyEvent = false;
compressLevel = -1;
qualityLevel = -1;
fineQualityLevel = -1;
@@ -111,42 +95,6 @@ void ClientParams::setEncodings(int nEncodings, const rdr::S32* encodings)

for (int i = nEncodings-1; i >= 0; i--) {
switch (encodings[i]) {
case encodingCopyRect:
useCopyRect = true;
break;
case pseudoEncodingCursor:
supportsLocalCursor = true;
break;
case pseudoEncodingXCursor:
supportsLocalXCursor = true;
break;
case pseudoEncodingCursorWithAlpha:
supportsLocalCursorWithAlpha = true;
break;
case pseudoEncodingDesktopSize:
supportsDesktopResize = true;
break;
case pseudoEncodingExtendedDesktopSize:
supportsExtendedDesktopSize = true;
break;
case pseudoEncodingDesktopName:
supportsDesktopRename = true;
break;
case pseudoEncodingLastRect:
supportsLastRect = true;
break;
case pseudoEncodingLEDState:
supportsLEDState = true;
break;
case pseudoEncodingQEMUKeyEvent:
supportsQEMUKeyEvent = true;
break;
case pseudoEncodingFence:
supportsFence = true;
break;
case pseudoEncodingContinuousUpdates:
supportsContinuousUpdates = true;
break;
case pseudoEncodingSubsamp1X:
subsampling = subsampleNone;
break;
@@ -179,8 +127,7 @@ void ClientParams::setEncodings(int nEncodings, const rdr::S32* encodings)
encodings[i] <= pseudoEncodingFineQualityLevel100)
fineQualityLevel = encodings[i] - pseudoEncodingFineQualityLevel0;

if (encodings[i] > 0)
encodings_.insert(encodings[i]);
encodings_.insert(encodings[i]);
}
}

@@ -188,3 +135,35 @@ void ClientParams::setLEDState(unsigned int state)
{
ledState_ = state;
}

bool ClientParams::supportsLocalCursor() const
{
if (supportsEncoding(pseudoEncodingCursorWithAlpha))
return true;
if (supportsEncoding(pseudoEncodingCursor))
return true;
if (supportsEncoding(pseudoEncodingXCursor))
return true;
return false;
}

bool ClientParams::supportsLEDState() const
{
if (supportsEncoding(pseudoEncodingLEDState))
return true;
return false;
}

bool ClientParams::supportsFence() const
{
if (supportsEncoding(pseudoEncodingFence))
return true;
return false;
}

bool ClientParams::supportsContinuousUpdates() const
{
if (supportsEncoding(pseudoEncodingContinuousUpdates))
return true;
return false;
}

+ 6
- 15
common/rfb/ClientParams.h Просмотреть файл

@@ -84,21 +84,12 @@ namespace rfb {
unsigned int ledState() { return ledState_; }
void setLEDState(unsigned int state);

bool useCopyRect;

bool supportsLocalCursor;
bool supportsLocalXCursor;
bool supportsLocalCursorWithAlpha;
bool supportsDesktopResize;
bool supportsExtendedDesktopSize;
bool supportsDesktopRename;
bool supportsLastRect;
bool supportsLEDState;
bool supportsQEMUKeyEvent;

bool supportsSetDesktopSize;
bool supportsFence;
bool supportsContinuousUpdates;
// Wrappers to check for functionality rather than specific
// encodings
bool supportsLocalCursor() const;
bool supportsLEDState() const;
bool supportsFence() const;
bool supportsContinuousUpdates() const;

int compressLevel;
int qualityLevel;

+ 4
- 4
common/rfb/EncodeManager.cxx Просмотреть файл

@@ -325,7 +325,7 @@ void EncodeManager::doUpdate(bool allowLossy, const Region& changed_,

changed = changed_;

if (!conn->client.useCopyRect)
if (!conn->client.supportsEncoding(encodingCopyRect))
changed.assign_union(copied);

/*
@@ -337,7 +337,7 @@ void EncodeManager::doUpdate(bool allowLossy, const Region& changed_,
changed.assign_subtract(renderedCursor->getEffectiveRect());
}

if (conn->client.supportsLastRect)
if (conn->client.supportsEncoding(pseudoEncodingLastRect))
nRects = 0xFFFF;
else {
nRects = copied.numRects();
@@ -347,14 +347,14 @@ void EncodeManager::doUpdate(bool allowLossy, const Region& changed_,

conn->writer()->writeFramebufferUpdateStart(nRects);

if (conn->client.useCopyRect)
if (conn->client.supportsEncoding(encodingCopyRect))
writeCopyRects(copied, copyDelta);

/*
* We start by searching for solid rects, which are then removed
* from the changed region.
*/
if (conn->client.supportsLastRect)
if (conn->client.supportsEncoding(pseudoEncodingLastRect))
writeSolidRects(&changed, pb);

writeRects(changed, pb);

+ 9
- 8
common/rfb/SMsgHandler.cxx Просмотреть файл

@@ -19,6 +19,7 @@
#include <rfb/Exception.h>
#include <rfb/SMsgHandler.h>
#include <rfb/ScreenSet.h>
#include <rfb/encodings.h>

using namespace rfb;

@@ -44,22 +45,22 @@ void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings)
bool firstFence, firstContinuousUpdates, firstLEDState,
firstQEMUKeyEvent;

firstFence = !client.supportsFence;
firstContinuousUpdates = !client.supportsContinuousUpdates;
firstLEDState = !client.supportsLEDState;
firstQEMUKeyEvent = !client.supportsQEMUKeyEvent;
firstFence = !client.supportsFence();
firstContinuousUpdates = !client.supportsContinuousUpdates();
firstLEDState = !client.supportsLEDState();
firstQEMUKeyEvent = !client.supportsEncoding(pseudoEncodingQEMUKeyEvent);

client.setEncodings(nEncodings, encodings);

supportsLocalCursor();

if (client.supportsFence && firstFence)
if (client.supportsFence() && firstFence)
supportsFence();
if (client.supportsContinuousUpdates && firstContinuousUpdates)
if (client.supportsContinuousUpdates() && firstContinuousUpdates)
supportsContinuousUpdates();
if (client.supportsLEDState && firstLEDState)
if (client.supportsLEDState() && firstLEDState)
supportsLEDState();
if (client.supportsQEMUKeyEvent && firstQEMUKeyEvent)
if (client.supportsEncoding(pseudoEncodingQEMUKeyEvent) && firstQEMUKeyEvent)
supportsQEMUKeyEvent();
}


+ 19
- 19
common/rfb/SMsgWriter.cxx Просмотреть файл

@@ -90,7 +90,7 @@ void SMsgWriter::writeServerCutText(const char* str, int len)

void SMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[])
{
if (!client->supportsFence)
if (!client->supportsEncoding(pseudoEncodingFence))
throw Exception("Client does not support fences");
if (len > 64)
throw Exception("Too large fence payload");
@@ -112,7 +112,7 @@ void SMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[])

void SMsgWriter::writeEndOfContinuousUpdates()
{
if (!client->supportsContinuousUpdates)
if (!client->supportsEncoding(pseudoEncodingContinuousUpdates))
throw Exception("Client does not support continuous updates");

startMsg(msgTypeEndOfContinuousUpdates);
@@ -120,7 +120,7 @@ void SMsgWriter::writeEndOfContinuousUpdates()
}

bool SMsgWriter::writeSetDesktopSize() {
if (!client->supportsDesktopResize)
if (!client->supportsEncoding(pseudoEncodingDesktopSize))
return false;

needSetDesktopSize = true;
@@ -129,7 +129,7 @@ bool SMsgWriter::writeSetDesktopSize() {
}

bool SMsgWriter::writeExtendedDesktopSize() {
if (!client->supportsExtendedDesktopSize)
if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
return false;

needExtendedDesktopSize = true;
@@ -142,7 +142,7 @@ bool SMsgWriter::writeExtendedDesktopSize(rdr::U16 reason, rdr::U16 result,
const ScreenSet& layout) {
ExtendedDesktopSizeMsg msg;

if (!client->supportsExtendedDesktopSize)
if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
return false;

msg.reason = reason;
@@ -157,7 +157,7 @@ bool SMsgWriter::writeExtendedDesktopSize(rdr::U16 reason, rdr::U16 result,
}

bool SMsgWriter::writeSetDesktopName() {
if (!client->supportsDesktopRename)
if (!client->supportsEncoding(pseudoEncodingDesktopName))
return false;

needSetDesktopName = true;
@@ -167,7 +167,7 @@ bool SMsgWriter::writeSetDesktopName() {

bool SMsgWriter::writeSetCursor()
{
if (!client->supportsLocalCursor)
if (!client->supportsEncoding(pseudoEncodingCursor))
return false;

needSetCursor = true;
@@ -177,7 +177,7 @@ bool SMsgWriter::writeSetCursor()

bool SMsgWriter::writeSetXCursor()
{
if (!client->supportsLocalXCursor)
if (!client->supportsEncoding(pseudoEncodingXCursor))
return false;

needSetXCursor = true;
@@ -187,7 +187,7 @@ bool SMsgWriter::writeSetXCursor()

bool SMsgWriter::writeSetCursorWithAlpha()
{
if (!client->supportsLocalCursorWithAlpha)
if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
return false;

needSetCursorWithAlpha = true;
@@ -197,7 +197,7 @@ bool SMsgWriter::writeSetCursorWithAlpha()

bool SMsgWriter::writeLEDState()
{
if (!client->supportsLEDState)
if (!client->supportsEncoding(pseudoEncodingLEDState))
return false;
if (client->ledState() == ledUnknown)
return false;
@@ -209,7 +209,7 @@ bool SMsgWriter::writeLEDState()

bool SMsgWriter::writeQEMUKeyEvent()
{
if (!client->supportsQEMUKeyEvent)
if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
return false;

needQEMUKeyEvent = true;
@@ -437,7 +437,7 @@ void SMsgWriter::writeNoDataRects()

void SMsgWriter::writeSetDesktopSizeRect(int width, int height)
{
if (!client->supportsDesktopResize)
if (!client->supportsEncoding(pseudoEncodingDesktopSize))
throw Exception("Client does not support desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
@@ -457,7 +457,7 @@ void SMsgWriter::writeExtendedDesktopSizeRect(rdr::U16 reason,
{
ScreenSet::const_iterator si;

if (!client->supportsExtendedDesktopSize)
if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
throw Exception("Client does not support extended desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
@@ -483,7 +483,7 @@ void SMsgWriter::writeExtendedDesktopSizeRect(rdr::U16 reason,

void SMsgWriter::writeSetDesktopNameRect(const char *name)
{
if (!client->supportsDesktopRename)
if (!client->supportsEncoding(pseudoEncodingDesktopName))
throw Exception("Client does not support desktop rename");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
@@ -500,7 +500,7 @@ void SMsgWriter::writeSetCursorRect(int width, int height,
int hotspotX, int hotspotY,
const void* data, const void* mask)
{
if (!client->supportsLocalCursor)
if (!client->supportsEncoding(pseudoEncodingCursor))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetCursorRect: nRects out of sync");
@@ -518,7 +518,7 @@ void SMsgWriter::writeSetXCursorRect(int width, int height,
int hotspotX, int hotspotY,
const void* data, const void* mask)
{
if (!client->supportsLocalXCursor)
if (!client->supportsEncoding(pseudoEncodingXCursor))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetXCursorRect: nRects out of sync");
@@ -544,7 +544,7 @@ void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height,
int hotspotX, int hotspotY,
const rdr::U8* data)
{
if (!client->supportsLocalCursorWithAlpha)
if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
@@ -570,7 +570,7 @@ void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height,

void SMsgWriter::writeLEDStateRect(rdr::U8 state)
{
if (!client->supportsLEDState)
if (!client->supportsEncoding(pseudoEncodingLEDState))
throw Exception("Client does not support LED state updates");
if (client->ledState() == ledUnknown)
throw Exception("Server does not support LED state updates");
@@ -587,7 +587,7 @@ void SMsgWriter::writeLEDStateRect(rdr::U8 state)

void SMsgWriter::writeQEMUKeyEventRect()
{
if (!client->supportsQEMUKeyEvent)
if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
throw Exception("Client does not support QEMU extended key events");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");

+ 7
- 8
common/rfb/VNCSConnectionST.cxx Просмотреть файл

@@ -385,8 +385,7 @@ bool VNCSConnectionST::needRenderedCursor()
if (state() != RFBSTATE_NORMAL)
return false;

if (!client.supportsLocalCursorWithAlpha &&
!client.supportsLocalCursor && !client.supportsLocalXCursor)
if (!client.supportsLocalCursor())
return true;
if (!server->cursorPos.equals(pointerEventPos) &&
(time(0) - pointerEventTime) > 0)
@@ -572,7 +571,7 @@ void VNCSConnectionST::keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down) {

// Lock key heuristics
// (only for clients that do not support the LED state extension)
if (!client.supportsLEDState) {
if (!client.supportsLEDState()) {
// Always ignore ScrollLock as we don't have a heuristic
// for that
if (keysym == XK_Scroll_Lock) {
@@ -787,7 +786,7 @@ void VNCSConnectionST::enableContinuousUpdates(bool enable,
{
Rect rect;

if (!client.supportsFence || !client.supportsContinuousUpdates)
if (!client.supportsFence() || !client.supportsContinuousUpdates())
throw Exception("Client tried to enable continuous updates when not allowed");

continuousUpdates = enable;
@@ -803,7 +802,7 @@ void VNCSConnectionST::enableContinuousUpdates(bool enable,
}

// supportsLocalCursor() is called whenever the status of
// client.supportsLocalCursor has changed. If the client does now support local
// client.supportsLocalCursor() has changed. If the client does now support local
// cursor, we make sure that the old server-side rendered cursor is cleaned up
// and the cursor is sent to the client.

@@ -825,7 +824,7 @@ void VNCSConnectionST::supportsContinuousUpdates()
{
// We refuse to use continuous updates if we cannot monitor the buffer
// usage using fences.
if (!client.supportsFence)
if (!client.supportsFence())
return;

writer()->writeEndOfContinuousUpdates();
@@ -868,7 +867,7 @@ void VNCSConnectionST::writeRTTPing()
{
char type;

if (!client.supportsFence)
if (!client.supportsFence())
return;

congestion.updatePosition(sock->outStream().length());
@@ -895,7 +894,7 @@ bool VNCSConnectionST::isCongested()
if (sock->outStream().bufferUsage() > 0)
return true;

if (!client.supportsFence)
if (!client.supportsFence())
return false;

congestion.updatePosition(sock->outStream().length());

Загрузка…
Отмена
Сохранить