It is much more natural than custom methods for this very common operation.pull/1587/head
@@ -740,7 +740,7 @@ void CConnection::setQualityLevel(int level) | |||
void CConnection::setPF(const PixelFormat& pf) | |||
{ | |||
if (server.pf().equal(pf) && !formatChange) | |||
if (server.pf() == pf && !formatChange) | |||
return; | |||
nextPF = pf; |
@@ -90,7 +90,7 @@ bool ComparingUpdateTracker::compare() | |||
for (i = rects.begin(); i != rects.end(); i++) | |||
missedPixels += i->area(); | |||
if (changed.equals(newChanged)) | |||
if (changed == newChanged) | |||
return false; | |||
changed = newChanged; |
@@ -697,7 +697,7 @@ void EncodeManager::findSolidRect(const Rect& rect, Region *changed, | |||
extendSolidAreaByBlock(sr, colourValue, pb, &erb); | |||
// Did we end up getting the entire rectangle? | |||
if (erb.equals(rect)) | |||
if (erb == rect) | |||
erp = erb; | |||
else { | |||
// Don't bother with sending tiny rectangles | |||
@@ -1000,7 +1000,7 @@ PixelBuffer* EncodeManager::preparePixelBuffer(const Rect& rect, | |||
int stride; | |||
// Do wo need to convert the data? | |||
if (convert && !conn->client.pf().equal(pb->getPF())) { | |||
if (convert && conn->client.pf() != pb->getPF()) { | |||
convertedPixelBuffer.setPF(conn->client.pf()); | |||
convertedPixelBuffer.setSize(rect.width(), rect.height()); | |||
@@ -39,7 +39,7 @@ namespace rfb { | |||
ModifiablePixelBuffer* /*pb*/) {} | |||
void reset(); | |||
inline bool isEqualRect(const Rect &r) const { return r.equals(rect); } | |||
inline bool isEqualRect(const Rect &r) const { return r == rect; } | |||
bool isReady(); | |||
protected: |
@@ -182,13 +182,13 @@ void JpegCompressor::compress(const uint8_t *buf, volatile int stride, | |||
#ifdef JCS_EXTENSIONS | |||
// Try to have libjpeg output directly to our native format | |||
// libjpeg can only handle some "standard" formats | |||
if (pfRGBX.equal(pf)) | |||
if (pfRGBX == pf) | |||
cinfo->in_color_space = JCS_EXT_RGBX; | |||
else if (pfBGRX.equal(pf)) | |||
else if (pfBGRX == pf) | |||
cinfo->in_color_space = JCS_EXT_BGRX; | |||
else if (pfXRGB.equal(pf)) | |||
else if (pfXRGB == pf) | |||
cinfo->in_color_space = JCS_EXT_XRGB; | |||
else if (pfXBGR.equal(pf)) | |||
else if (pfXBGR == pf) | |||
cinfo->in_color_space = JCS_EXT_XBGR; | |||
if (cinfo->in_color_space != JCS_RGB) { |
@@ -184,13 +184,13 @@ void JpegDecompressor::decompress(const uint8_t *jpegBuf, | |||
#ifdef JCS_EXTENSIONS | |||
// Try to have libjpeg output directly to our native format | |||
// libjpeg can only handle some "standard" formats | |||
if (pfRGBX.equal(pf)) | |||
if (pfRGBX == pf) | |||
dinfo->out_color_space = JCS_EXT_RGBX; | |||
else if (pfBGRX.equal(pf)) | |||
else if (pfBGRX == pf) | |||
dinfo->out_color_space = JCS_EXT_BGRX; | |||
else if (pfXRGB.equal(pf)) | |||
else if (pfXRGB == pf) | |||
dinfo->out_color_space = JCS_EXT_XRGB; | |||
else if (pfXBGR.equal(pf)) | |||
else if (pfXBGR == pf) | |||
dinfo->out_color_space = JCS_EXT_XBGR; | |||
if (dinfo->out_color_space != JCS_RGB) { |
@@ -101,7 +101,7 @@ void PixelBuffer::getImage(const PixelFormat& pf, void* imageBuf, | |||
const uint8_t* srcBuffer; | |||
int srcStride; | |||
if (format.equal(pf)) { | |||
if (format == pf) { | |||
getImage(imageBuf, r, stride); | |||
return; | |||
} |
@@ -99,7 +99,7 @@ PixelFormat::PixelFormat() | |||
updateState(); | |||
} | |||
bool PixelFormat::equal(const PixelFormat& other) const | |||
bool PixelFormat::operator==(const PixelFormat& other) const | |||
{ | |||
if (bpp != other.bpp || depth != other.depth) | |||
return false; | |||
@@ -148,6 +148,11 @@ bool PixelFormat::equal(const PixelFormat& other) const | |||
return true; | |||
} | |||
bool PixelFormat::operator!=(const PixelFormat& other) const | |||
{ | |||
return !(*this == other); | |||
} | |||
void PixelFormat::read(rdr::InStream* is) | |||
{ | |||
bpp = is->readU8(); | |||
@@ -381,7 +386,7 @@ void PixelFormat::bufferFromBuffer(uint8_t* dst, const PixelFormat &srcPF, | |||
const uint8_t* src, int w, int h, | |||
int dstStride, int srcStride) const | |||
{ | |||
if (equal(srcPF)) { | |||
if (*this == srcPF) { | |||
// Trivial case | |||
while (h--) { | |||
memcpy(dst, src, w * bpp/8); |
@@ -49,7 +49,8 @@ namespace rfb { | |||
// Checks if the formats have identical buffer representation. | |||
// They might still have different pixel representation, endianness | |||
// or true colour state. | |||
bool equal(const PixelFormat& other) const; | |||
bool operator==(const PixelFormat& other) const; | |||
bool operator!=(const PixelFormat& other) const; | |||
void read(rdr::InStream* is); | |||
void write(rdr::OutStream* os) const; |
@@ -50,7 +50,8 @@ namespace rfb { | |||
inline Point negate() const | |||
__attribute__ ((warn_unused_result)) | |||
{return Point(-x, -y);} | |||
inline bool equals(const Point &p) const {return x==p.x && y==p.y;} | |||
inline bool operator==(const Point &p) const {return x==p.x && y==p.y;} | |||
inline bool operator!=(const Point &p) const {return x!=p.x || y!=p.y;} | |||
inline Point translate(const Point &p) const | |||
__attribute__ ((warn_unused_result)) | |||
{return Point(x+p.x, y+p.y);} | |||
@@ -105,7 +106,8 @@ namespace rfb { | |||
{ | |||
return Rect(tl.translate(p), br.translate(p)); | |||
} | |||
inline bool equals(const Rect &r) const {return r.tl.equals(tl) && r.br.equals(br);} | |||
inline bool operator==(const Rect &r) const {return r.tl == tl && r.br == br;} | |||
inline bool operator!=(const Rect &r) const {return r.tl != tl || r.br != br;} | |||
inline bool is_empty() const {return (tl.x >= br.x) || (tl.y >= br.y);} | |||
inline void clear() {tl = Point(); br = Point();} | |||
inline bool enclosed_by(const Rect &r) const { |
@@ -101,10 +101,14 @@ rfb::Region rfb::Region::subtract(const rfb::Region& r) const { | |||
return ret; | |||
} | |||
bool rfb::Region::equals(const rfb::Region& r) const { | |||
bool rfb::Region::operator==(const rfb::Region& r) const { | |||
return pixman_region_equal(rgn, r.rgn); | |||
} | |||
bool rfb::Region::operator!=(const rfb::Region& r) const { | |||
return !pixman_region_equal(rgn, r.rgn); | |||
} | |||
int rfb::Region::numRects() const { | |||
return pixman_region_n_rects(rgn); | |||
} |
@@ -60,7 +60,8 @@ namespace rfb { | |||
Region subtract(const Region& r) const | |||
__attribute__ ((warn_unused_result)); | |||
bool equals(const Region& b) const; | |||
bool operator==(const Region& b) const; | |||
bool operator!=(const Region& b) const; | |||
int numRects() const; | |||
bool is_empty() const { return numRects() == 0; } | |||
@@ -44,7 +44,7 @@ namespace rfb { | |||
inline bool operator==(const Screen& r) const { | |||
if (id != r.id) | |||
return false; | |||
if (!dimensions.equals(r.dimensions)) | |||
if (dimensions != r.dimensions) | |||
return false; | |||
if (flags != r.flags) | |||
return false; |
@@ -400,7 +400,7 @@ void TightDecoder::decodeRect(const Rect& r, const void* buffer, | |||
uint8_t* outbuf; | |||
int stride; | |||
if (pb->getPF().equal(pf)) { | |||
if (pb->getPF() == pf) { | |||
// Decode directly into the framebuffer (fast path) | |||
directDecode = true; | |||
} else { |
@@ -403,7 +403,7 @@ bool VNCSConnectionST::needRenderedCursor() | |||
if (!client.supportsLocalCursor()) | |||
return true; | |||
if (!server->getCursorPos().equals(pointerEventPos) && | |||
if ((server->getCursorPos() != pointerEventPos) && | |||
(time(0) - pointerEventTime) > 0) | |||
return true; | |||
@@ -432,7 +432,7 @@ void VNCServerST::setCursor(int width, int height, const Point& newHotspot, | |||
void VNCServerST::setCursorPos(const Point& pos, bool warped) | |||
{ | |||
if (!cursorPos.equals(pos)) { | |||
if (cursorPos != pos) { | |||
cursorPos = pos; | |||
renderedCursorInvalid = true; | |||
std::list<VNCSConnectionST*>::iterator ci; |
@@ -304,7 +304,7 @@ bool EmulateMB::handleTimeout(rfb::Timer *t) | |||
// Pointer move events are not sent when waiting for the timeout. | |||
// However, we can't let the position get out of sync so when | |||
// the pointer has moved we have to send the latest position here. | |||
if (!origPos.equals(lastPos)) { | |||
if (origPos != lastPos) { | |||
buttonMask = createButtonMask(buttonMask); | |||
sendPointerEvent(lastPos, buttonMask); | |||
} |
@@ -468,8 +468,8 @@ SDisplay::recreatePixelBuffer(bool force) { | |||
// If nothing has changed & a recreate has not been forced, delete | |||
// the new device context and return | |||
if (pb && !force && | |||
newScreenRect.equals(screenRect) && | |||
new_device->getPF().equal(pb->getPF())) { | |||
newScreenRect == screenRect && | |||
new_device->getPF() == pb->getPF()) { | |||
delete new_device; | |||
return; | |||
} |
@@ -71,7 +71,7 @@ win32::SPointer::pointerEvent(const Point& pos, int buttonmask) | |||
DWORD flags = MOUSEEVENTF_ABSOLUTE; | |||
// - Has the pointer moved since the last event? | |||
if (!last_position.equals(pos)) | |||
if (last_position != pos) | |||
flags |= MOUSEEVENTF_MOVE; | |||
// - If the system swaps left and right mouse buttons then we must |
@@ -43,7 +43,7 @@ namespace rfb { | |||
Info() : cursor(0), visible(false) {} | |||
bool operator!=(const Info& info) { | |||
return ((cursor != info.cursor) || | |||
(!position.equals(info.position)) || | |||
(position != info.position) || | |||
(visible != info.visible)); | |||
} | |||
}; |
@@ -45,7 +45,7 @@ rfb::win32::WMCopyRect::processEvent() { | |||
if (IsWindow(window) && IsWindowVisible(window) && GetWindowRect(window, &wrect)) { | |||
Rect winrect(wrect.left, wrect.top, wrect.right, wrect.bottom); | |||
if (fg_window == window) { | |||
if (!fg_window_rect.tl.equals(winrect.tl) && ut) { | |||
if (fg_window_rect.tl != winrect.tl && ut) { | |||
// Window has moved - mark both the previous and new position as changed | |||
// (we can't use add_copied() here because we aren't that properly synced | |||
// with the actual state of the framebuffer) |