stats[klass][activeType].rects++;
stats[klass][activeType].pixels += rect.area();
- equiv = 12 + rect.area() * conn->cp.pf().bpp/8;
+ equiv = 12 + rect.area() * (conn->cp.pf().bpp/8);
stats[klass][activeType].equivalent += equiv;
encoder = encoders[klass];
copyStats.rects++;
copyStats.pixels += rect->area();
- equiv = 12 + rect->area() * conn->cp.pf().bpp/8;
+ equiv = 12 + rect->area() * (conn->cp.pf().bpp/8);
copyStats.equivalent += equiv;
conn->writer()->writeCopyRect(*rect, rect->tl.x - delta.x,
const Point &move_by_delta)
{
int srcStride, dstStride;
+ int bytesPerPixel;
const U8* srcData;
U8* dstData;
srect.width(), srect.height(),
srect.tl.x, srect.tl.y, width_, height_);
+ bytesPerPixel = format.bpp/8;
+
srcData = getBuffer(srect, &srcStride);
dstData = getBufferRW(drect, &dstStride);
// Possible overlap. Be careful and use memmove().
int h = drect.height();
while (h--) {
- memmove(dstData, srcData, drect.width() * format.bpp/8);
- dstData += dstStride * format.bpp/8;
- srcData += srcStride * format.bpp/8;
+ memmove(dstData, srcData, drect.width() * bytesPerPixel);
+ dstData += dstStride * bytesPerPixel;
+ srcData += srcStride * bytesPerPixel;
}
} else if (move_by_delta.y < 0) {
// The data shifted upwards. Copy from top to bottom.
int h = drect.height();
while (h--) {
- memcpy(dstData, srcData, drect.width() * format.bpp/8);
- dstData += dstStride * format.bpp/8;
- srcData += srcStride * format.bpp/8;
+ memcpy(dstData, srcData, drect.width() * bytesPerPixel);
+ dstData += dstStride * bytesPerPixel;
+ srcData += srcStride * bytesPerPixel;
}
} else {
// The data shifted downwards. Copy from bottom to top.
int h = drect.height();
- dstData += (h-1) * dstStride * format.bpp/8;
- srcData += (h-1) * srcStride * format.bpp/8;
+ dstData += (h-1) * dstStride * bytesPerPixel;
+ srcData += (h-1) * srcStride * bytesPerPixel;
while (h--) {
- memcpy(dstData, srcData, drect.width() * format.bpp/8);
- dstData -= dstStride * format.bpp/8;
- srcData -= srcStride * format.bpp/8;
+ memcpy(dstData, srcData, drect.width() * bytesPerPixel);
+ dstData -= dstStride * bytesPerPixel;
+ srcData -= srcStride * bytesPerPixel;
}
}
r.tl.x, r.tl.y, width_, height_);
*stride_ = stride;
- return &data[(r.tl.x + (r.tl.y * stride)) * format.bpp/8];
+ return &data[(r.tl.x + (r.tl.y * stride)) * (format.bpp/8)];
}
void FullFramePixelBuffer::commitBufferRW(const Rect& r)
r.tl.x, r.tl.y, width_, height_);
*stride_ = stride;
- return &data[(r.tl.x + (r.tl.y * stride)) * format.bpp/8];
+ return &data[(r.tl.x + (r.tl.y * stride)) * (format.bpp/8)];
}
// -=- Managed pixel buffer class
void RawDecoder::readRect(const Rect& r, rdr::InStream* is,
const ConnParams& cp, rdr::OutStream* os)
{
- os->copyBytes(is, r.area() * cp.pf().bpp/8);
+ os->copyBytes(is, r.area() * (cp.pf().bpp/8));
}
void RawDecoder::decodeRect(const Rect& r, const void* buffer,
size_t buflen, const ConnParams& cp,
ModifiablePixelBuffer* pb)
{
- assert(buflen >= (size_t)r.area() * cp.pf().bpp/8);
+ assert(buflen >= (size_t)r.area() * (cp.pf().bpp/8));
pb->imageRect(cp.pf(), r, buffer);
}