Browse Source

Handle CopyRect like any other encoding

Avoids having to special case things. Keeps the code simpler.
tags/v1.3.90
Pierre Ossman 10 years ago
parent
commit
d704e4ae77

+ 1
- 0
common/rfb/CMakeLists.txt View File

@@ -13,6 +13,7 @@ set(RFB_SOURCES
ComparingUpdateTracker.cxx
Configuration.cxx
ConnParams.cxx
CopyRectDecoder.cxx
Cursor.cxx
Decoder.cxx
d3des.c

+ 8
- 20
common/rfb/CMsgReader.cxx View File

@@ -198,35 +198,23 @@ void CMsgReader::readRect(const Rect& r, int encoding)

handler->beginRect(r, encoding);

if (encoding == encodingCopyRect) {
readCopyRect(r);
} else {
if (!Decoder::supported(encoding)) {
fprintf(stderr, "Unknown rect encoding %d\n", encoding);
throw Exception("Unknown rect encoding");
}

if (!Decoder::supported(encoding)) {
if (!decoders[encoding]) {
decoders[encoding] = Decoder::createDecoder(encoding, this);
if (!decoders[encoding]) {
fprintf(stderr, "Unknown rect encoding %d\n", encoding);
throw Exception("Unknown rect encoding");
}

if (!decoders[encoding]) {
decoders[encoding] = Decoder::createDecoder(encoding, this);
if (!decoders[encoding]) {
fprintf(stderr, "Unknown rect encoding %d\n", encoding);
throw Exception("Unknown rect encoding");
}
}
decoders[encoding]->readRect(r, handler);
}
decoders[encoding]->readRect(r, handler);

handler->endRect(r, encoding);
}

void CMsgReader::readCopyRect(const Rect& r)
{
int srcX = is->readU16();
int srcY = is->readU16();
handler->copyRect(r, srcX, srcY);
}

void CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
{
int data_len = width * height * (handler->cp.pf().bpp/8);

+ 0
- 1
common/rfb/CMsgReader.h View File

@@ -62,7 +62,6 @@ namespace rfb {
void readFramebufferUpdate();

void readRect(const Rect& r, int encoding);
void readCopyRect(const Rect& r);

void readSetCursor(int width, int height, const Point& hotspot);
void readSetDesktopName(int x, int y, int w, int h);

+ 2
- 0
common/rfb/CMsgWriter.cxx View File

@@ -113,9 +113,11 @@ void CMsgWriter::writeSetEncodings(int preferredEncoding, bool useCopyRect)
// Remaining encodings
for (int i = encodingMax; i >= 0; i--) {
switch (i) {
case encodingCopyRect:
case encodingTight:
case encodingZRLE:
case encodingHextile:
/* These have already been sent earlier */
break;
default:
if ((i != preferredEncoding) && Decoder::supported(i))

+ 39
- 0
common/rfb/CopyRectDecoder.cxx View File

@@ -0,0 +1,39 @@
/* Copyright 2014 Pierre Ossman <ossman@cendio.se> for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <rdr/InStream.h>
#include <rfb/CMsgReader.h>
#include <rfb/CMsgHandler.h>
#include <rfb/PixelBuffer.h>
#include <rfb/CopyRectDecoder.h>

using namespace rfb;

CopyRectDecoder::CopyRectDecoder(CMsgReader* reader) : Decoder(reader)
{
}

CopyRectDecoder::~CopyRectDecoder()
{
}

void CopyRectDecoder::readRect(const Rect& r, CMsgHandler* handler)
{
int srcX = reader->getInStream()->readU16();
int srcY = reader->getInStream()->readU16();
handler->copyRect(r, srcX, srcY);
}

+ 32
- 0
common/rfb/CopyRectDecoder.h View File

@@ -0,0 +1,32 @@
/* Copyright 2014 Pierre Ossman <ossman@cendio.se> for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#ifndef __RFB_COPYRECTDECODER_H__
#define __RFB_COPYRECTDECODER_H__

#include <rfb/Decoder.h>

namespace rfb {

class CopyRectDecoder : public Decoder {
public:
CopyRectDecoder(CMsgReader* reader);
virtual ~CopyRectDecoder();
virtual void readRect(const Rect& r, CMsgHandler* handler);
};
}
#endif

+ 4
- 0
common/rfb/Decoder.cxx View File

@@ -20,6 +20,7 @@
#include <rfb/encodings.h>
#include <rfb/Decoder.h>
#include <rfb/RawDecoder.h>
#include <rfb/CopyRectDecoder.h>
#include <rfb/RREDecoder.h>
#include <rfb/HextileDecoder.h>
#include <rfb/ZRLEDecoder.h>
@@ -39,6 +40,7 @@ bool Decoder::supported(int encoding)
{
switch (encoding) {
case encodingRaw:
case encodingCopyRect:
case encodingRRE:
case encodingHextile:
case encodingZRLE:
@@ -54,6 +56,8 @@ Decoder* Decoder::createDecoder(int encoding, CMsgReader* reader)
switch (encoding) {
case encodingRaw:
return new RawDecoder(reader);
case encodingCopyRect:
return new CopyRectDecoder(reader);
case encodingRRE:
return new RREDecoder(reader);
case encodingHextile:

Loading…
Cancel
Save