Might as well make these explicit so the cost is apparent.
rdr::U8* oldData = oldFb.getBufferRW(r, &oldStride);
int oldStrideBytes = oldStride * bytesPerPixel;
- std::vector<Rect> changedBlocks;
-
for (int blockTop = r.tl.y; blockTop < r.br.y; blockTop += BLOCK_SIZE)
{
// Get a strip of the source buffer
if (memcmp(oldPtr, newPtr, blockWidthInBytes) != 0)
{
// A block has changed - copy the remainder to the oldFb
- changedBlocks.push_back(Rect(blockLeft, blockTop,
- blockRight, blockBottom));
+ newChanged->assign_union(Region(Rect(blockLeft, blockTop,
+ blockRight, blockBottom)));
for (int y2 = y; y2 < blockBottom; y2++)
{
memcpy(oldPtr, newPtr, blockWidthInBytes);
}
oldFb.commitBufferRW(r);
-
- if (!changedBlocks.empty()) {
- Region temp;
- temp.setOrderedRects(changedBlocks);
- newChanged->assign_union(temp);
- }
}
void ComparingUpdateTracker::logStats()
pixman_region_translate(rgn, delta.x, delta.y);
}
-void rfb::Region::setOrderedRects(const std::vector<Rect>& rects) {
- clear();
- std::vector<Rect>::const_iterator i;
- for (i=rects.begin(); i != rects.end(); i++)
- pixman_region_union_rect(rgn, rgn, i->tl.x, i->tl.y, i->width(), i->height());
-}
-
-void rfb::Region::setExtentsAndOrderedRects(const ShortRect* extents,
- int nRects, const ShortRect* rects)
-{
- clear();
- std::vector<Rect>::const_iterator i;
- for (int i = 0; i < nRects; i++) {
- pixman_region_union_rect(rgn, rgn, rects[i].x1, rects[i].y1,
- rects[i].x2 - rects[i].x1,
- rects[i].y2 - rects[i].y1);
- }
-}
-
void rfb::Region::assign_intersect(const rfb::Region& r) {
pixman_region_intersect(rgn, rgn, r.rgn);
}
namespace rfb {
- struct ShortRect {
- short x1, y1, x2, y2;
- };
-
class Region {
public:
// Create an empty region
void clear();
void reset(const Rect& r);
void translate(const rfb::Point& delta);
- void setOrderedRects(const std::vector<Rect>& rects);
- void setExtentsAndOrderedRects(const ShortRect* extents, int nRects,
- const ShortRect* rects);
void assign_intersect(const Region& r);
void assign_union(const Region& r);
if (vncGetScreenCount() > MAXSCREENS)
vncFatalError("vncExtensionInit: too many screens");
- if (sizeof(ShortRect) != sizeof(struct UpdateRect))
- vncFatalError("vncExtensionInit: Incompatible ShortRect size");
-
vncAddExtension();
vncSelectionInit();
desktop[scr]->setLEDState(state);
}
-void vncAddChanged(int scrIdx, const struct UpdateRect *extents,
- int nRects, const struct UpdateRect *rects)
+void vncAddChanged(int scrIdx, int nRects,
+ const struct UpdateRect *rects)
{
- Region reg;
-
- reg.setExtentsAndOrderedRects((const ShortRect*)extents,
- nRects, (const ShortRect*)rects);
- desktop[scrIdx]->add_changed(reg);
+ for (int i = 0;i < nRects;i++) {
+ desktop[scrIdx]->add_changed(Region(Rect(rects[i].x1, rects[i].y1,
+ rects[i].x2, rects[i].y2)));
+ }
}
-void vncAddCopied(int scrIdx, const struct UpdateRect *extents,
- int nRects, const struct UpdateRect *rects,
+void vncAddCopied(int scrIdx, int nRects,
+ const struct UpdateRect *rects,
int dx, int dy)
{
- Region reg;
-
- reg.setExtentsAndOrderedRects((const ShortRect*)extents,
- nRects, (const ShortRect*)rects);
- desktop[scrIdx]->add_copied(reg, rfb::Point(dx, dy));
+ for (int i = 0;i < nRects;i++) {
+ desktop[scrIdx]->add_copied(Region(Rect(rects[i].x1, rects[i].y1,
+ rects[i].x2, rects[i].y2)),
+ Point(dx, dy));
+ }
}
void vncSetCursor(int width, int height, int hotX, int hotY,
short x1, y1, x2, y2;
};
-void vncAddChanged(int scrIdx, const struct UpdateRect *extents,
- int nRects, const struct UpdateRect *rects);
-void vncAddCopied(int scrIdx, const struct UpdateRect *extents,
- int nRects, const struct UpdateRect *rects,
+void vncAddChanged(int scrIdx, int nRects,
+ const struct UpdateRect *rects);
+void vncAddCopied(int scrIdx, int nRects,
+ const struct UpdateRect *rects,
int dx, int dy);
void vncSetCursor(int width, int height, int hotX, int hotY,
if (RegionNil(reg))
return;
vncAddChanged(pScreen->myNum,
- (const struct UpdateRect*)RegionExtents(reg),
RegionNumRects(reg),
(const struct UpdateRect*)RegionRects(reg));
}
if (RegionNil(dst))
return;
vncAddCopied(pScreen->myNum,
- (const struct UpdateRect*)RegionExtents(dst),
RegionNumRects(dst),
(const struct UpdateRect*)RegionRects(dst), dx, dy);
}