virtual void setFineQualityLevel(int quality, int subsampling) {};
virtual int getNumRects(const Rect &r) { return 1; }
- // writeRect() tries to write the given rectangle. If it is unable to
- // write the whole rectangle it returns false and sets actual to the actual
- // rectangle which was updated.
- virtual bool writeRect(const Rect& r, TransImageGetter* ig,
- Rect* actual)=0;
+ // writeRect() is the main interface that encodes the given rectangle
+ // with data from the ImageGetter onto the SMsgWriter given at
+ // encoder creation.
+ virtual void writeRect(const Rect& r, TransImageGetter* ig)=0;
static bool supported(int encoding);
static Encoder* createEncoder(int encoding, SMsgWriter* writer);
{
}
-bool HextileEncoder::writeRect(const Rect& r, TransImageGetter* ig,
- Rect* actual)
+void HextileEncoder::writeRect(const Rect& r, TransImageGetter* ig)
{
writer->startRect(r, encodingHextile);
rdr::OutStream* os = writer->getOutStream();
break;
}
writer->endRect();
- return true;
}
public:
HextileEncoder(SMsgWriter* writer);
virtual ~HextileEncoder();
- virtual bool writeRect(const Rect& r, TransImageGetter* ig, Rect* actual);
+ virtual void writeRect(const Rect& r, TransImageGetter* ig);
private:
SMsgWriter* writer;
};
{
}
-bool RREEncoder::writeRect(const Rect& r, TransImageGetter* ig, Rect* actual)
+void RREEncoder::writeRect(const Rect& r, TransImageGetter* ig)
{
int w = r.width();
int h = r.height();
}
if (nSubrects < 0) {
- return writer->writeRect(r, encodingRaw, ig, actual);
+ writer->writeRect(r, encodingRaw, ig);
+ return;
}
writer->startRect(r, encodingRRE);
os->writeU32(nSubrects);
os->writeBytes(mos.data(), mos.length());
writer->endRect();
- return true;
}
public:
RREEncoder(SMsgWriter* writer);
virtual ~RREEncoder();
- virtual bool writeRect(const Rect& r, TransImageGetter* ig, Rect* actual);
+ virtual void writeRect(const Rect& r, TransImageGetter* ig);
private:
SMsgWriter* writer;
rdr::MemOutStream mos;
{
}
-bool RawEncoder::writeRect(const Rect& r, TransImageGetter* ig, Rect* actual)
+void RawEncoder::writeRect(const Rect& r, TransImageGetter* ig)
{
int x = r.tl.x;
int y = r.tl.y;
y += nRows;
}
writer->endRect();
- return true;
}
public:
RawEncoder(SMsgWriter* writer);
virtual ~RawEncoder();
- virtual bool writeRect(const Rect& r, TransImageGetter* ig, Rect* actual);
+ virtual void writeRect(const Rect& r, TransImageGetter* ig);
private:
SMsgWriter* writer;
};
writeFramebufferUpdateEnd();
}
-void SMsgWriter::writeRects(const UpdateInfo& ui, TransImageGetter* ig,
- Region* updatedRegion)
+void SMsgWriter::writeRects(const UpdateInfo& ui, TransImageGetter* ig)
{
std::vector<Rect> rects;
std::vector<Rect>::const_iterator i;
- updatedRegion->copyFrom(ui.changed);
- updatedRegion->assign_union(ui.copied);
ui.copied.get_rects(&rects, ui.copy_delta.x <= 0, ui.copy_delta.y <= 0);
for (i = rects.begin(); i != rects.end(); i++)
writeCopyRect(*i, i->tl.x - ui.copy_delta.x, i->tl.y - ui.copy_delta.y);
ui.changed.get_rects(&rects);
- for (i = rects.begin(); i != rects.end(); i++) {
- Rect actual;
- if (!writeRect(*i, ig, &actual)) {
- updatedRegion->assign_subtract(*i);
- updatedRegion->assign_union(actual);
- }
- }
+ for (i = rects.begin(); i != rects.end(); i++)
+ writeRect(*i, ig);
}
void SMsgWriter::writeFramebufferUpdateStart(int nRects)
endMsg();
}
-bool SMsgWriter::writeRect(const Rect& r, TransImageGetter* ig, Rect* actual)
+void SMsgWriter::writeRect(const Rect& r, TransImageGetter* ig)
{
- return writeRect(r, cp->currentEncoding(), ig, actual);
+ writeRect(r, cp->currentEncoding(), ig);
}
-bool SMsgWriter::writeRect(const Rect& r, int encoding,
- TransImageGetter* ig, Rect* actual)
+void SMsgWriter::writeRect(const Rect& r, int encoding, TransImageGetter* ig)
{
if (!encoders[encoding]) {
encoders[encoding] = Encoder::createEncoder(encoding, this);
assert(encoders[encoding]);
}
- return encoders[encoding]->writeRect(r, ig, actual);
+ encoders[encoding]->writeRect(r, ig);
}
void SMsgWriter::writeCopyRect(const Rect& r, int srcX, int srcY)
// ImageGetter to fetch pixels from. It then calls writeCopyRect() and
// writeRect() as appropriate. writeFramebufferUpdateStart() must be used
// before the first writeRects() call and writeFrameBufferUpdateEnd() after
- // the last one. It returns the actual region sent to the client, which
- // may be smaller than the update passed in.
- void writeRects(const UpdateInfo& update, TransImageGetter* ig,
- Region* updatedRegion);
+ // the last one.
+ void writeRects(const UpdateInfo& update, TransImageGetter* ig);
// To construct a framebuffer update you can call
// writeFramebufferUpdateStart(), followed by a number of writeCopyRect()s
void writeFramebufferUpdateStart(int nRects);
void writeFramebufferUpdateEnd();
- // writeRect() tries to write the given rectangle. If it is unable to
- // write the whole rectangle it returns false and sets actual to the actual
- // rectangle which was updated.
- bool writeRect(const Rect& r, TransImageGetter* ig, Rect* actual);
- bool writeRect(const Rect& r, int encoding,
- TransImageGetter* ig, Rect* actual);
+ // writeRect() writers the given rectangle using either the preferred
+ // encoder, or the one explicitly given.
+ void writeRect(const Rect& r, TransImageGetter* ig);
+ void writeRect(const Rect& r, int encoding, TransImageGetter* ig);
void writeCopyRect(const Rect& r, int srcX, int srcY);
}
}
-bool TightEncoder::writeRect(const Rect& _r, TransImageGetter* _ig,
- Rect* actual)
+void TightEncoder::writeRect(const Rect& _r, TransImageGetter* _ig)
{
ig = _ig;
serverpf = ig->getPixelBuffer()->getPF();
// Encode small rects as is.
if (!cp->supportsLastRect || w * h < TIGHT_MIN_SPLIT_RECT_SIZE) {
sendRectSimple(r);
- return true;
+ return;
}
// Split big rects into separately encoded subrects.
}
if (bestr.tl.x != x) {
sr.setXYWH(x, bestr.tl.y, bestr.tl.x - x, bestr.height());
- writeRect(sr, _ig, NULL);
+ writeRect(sr, _ig);
}
// Send solid-color rectangle.
if (bestr.br.x != r.br.x) {
sr.setXYWH(bestr.br.x, bestr.tl.y, r.br.x - bestr.br.x,
bestr.height());
- writeRect(sr, _ig, NULL);
+ writeRect(sr, _ig);
}
if (bestr.br.y != r.br.y) {
sr.setXYWH(x, bestr.br.y, w, r.br.y - bestr.br.y);
- writeRect(sr, _ig, NULL);
+ writeRect(sr, _ig);
}
- return true;
+ return;
}
}
}
// No suitable solid-color rectangles found.
sendRectSimple(r);
- return true;
+ return;
}
void TightEncoder::writeSubrect(const Rect& r, bool forceSolid)
virtual void setQualityLevel(int level);
virtual void setFineQualityLevel(int quality, int subsampling);
virtual int getNumRects(const Rect &r);
- virtual bool writeRect(const Rect& r, TransImageGetter* ig, Rect* actual);
+ virtual void writeRect(const Rect& r, TransImageGetter* ig);
private:
bool checkSolidTile(Rect& r, rdr::U32* colorPtr, bool needSameColor);
writer()->writeFramebufferUpdateStart(nRects);
- Region updatedRegion;
- writer()->writeRects(ui, &image_getter, &updatedRegion);
- updates.subtract(updatedRegion);
+ writer()->writeRects(ui, &image_getter);
+ updates.clear();
if (drawRenderedCursor)
writeRenderedCursorRect();
image_getter.setPixelBuffer(&server->renderedCursor);
image_getter.setOffset(server->renderedCursorTL);
- Rect actual;
- writer()->writeRect(renderedCursorRect, &image_getter, &actual);
+ writer()->writeRect(renderedCursorRect, &image_getter);
image_getter.setPixelBuffer(server->pb);
image_getter.setOffset(Point(0,0));
{
}
-bool ZRLEEncoder::writeRect(const Rect& r, TransImageGetter* ig, Rect* actual)
+void ZRLEEncoder::writeRect(const Rect& r, TransImageGetter* ig)
{
rdr::U8* imageBuf = writer->getImageBuf(64 * 64 * 4 + 4);
mos.clear();
- bool wroteAll = true;
- *actual = r;
switch (writer->bpp()) {
case 8:
- wroteAll = zrleEncode8(r, &mos, &zos, imageBuf, actual, ig);
+ zrleEncode8(r, &mos, &zos, imageBuf, ig);
break;
case 16:
- wroteAll = zrleEncode16(r, &mos, &zos, imageBuf, actual, ig);
+ zrleEncode16(r, &mos, &zos, imageBuf, ig);
break;
case 32:
{
if ((fitsInLS3Bytes && pf.isLittleEndian()) ||
(fitsInMS3Bytes && pf.isBigEndian()))
{
- wroteAll = zrleEncode24A(r, &mos, &zos, imageBuf, actual, ig);
+ zrleEncode24A(r, &mos, &zos, imageBuf, ig);
}
else if ((fitsInLS3Bytes && pf.isBigEndian()) ||
(fitsInMS3Bytes && pf.isLittleEndian()))
{
- wroteAll = zrleEncode24B(r, &mos, &zos, imageBuf, actual, ig);
+ zrleEncode24B(r, &mos, &zos, imageBuf, ig);
}
else
{
- wroteAll = zrleEncode32(r, &mos, &zos, imageBuf, actual, ig);
+ zrleEncode32(r, &mos, &zos, imageBuf, ig);
}
break;
}
}
- writer->startRect(*actual, encodingZRLE);
+ writer->startRect(r, encodingZRLE);
rdr::OutStream* os = writer->getOutStream();
os->writeU32(mos.length());
os->writeBytes(mos.data(), mos.length());
writer->endRect();
- return wroteAll;
}
public:
ZRLEEncoder(SMsgWriter* writer);
virtual ~ZRLEEncoder();
- virtual bool writeRect(const Rect& r, TransImageGetter* ig, Rect* actual);
+ virtual void writeRect(const Rect& r, TransImageGetter* ig);
private:
SMsgWriter* writer;
rdr::ZlibOutStream zos;
void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os);
-bool ZRLE_ENCODE (const Rect& r, rdr::OutStream* os,
- rdr::ZlibOutStream* zos, void* buf, Rect* actual
+void ZRLE_ENCODE (const Rect& r, rdr::OutStream* os,
+ rdr::ZlibOutStream* zos, void* buf
#ifdef EXTRA_ARGS
, EXTRA_ARGS
#endif
t.br.y = __rfbmin(r.br.y, t.tl.y + 64);
- // enough for width 16384 32-bit pixels
- if (os->length() + worstCaseLine > 4097 * 1024) {
- if (t.tl.y == r.tl.y)
- throw Exception("ZRLE: not enough space for first line?");
- actual->tl = r.tl;
- actual->br.x = r.br.x;
- actual->br.y = t.tl.y;
- return false;
- }
-
for (t.tl.x = r.tl.x; t.tl.x < r.br.x; t.tl.x += 64) {
t.br.x = __rfbmin(r.br.x, t.tl.x + 64);
zos->flush();
}
- return true;
}