Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/neutrinolabs/ulalaca-xrdp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGyuhwan Park★ <unstabler@unstabler.pl>2023-02-08 20:59:50 +0300
committerGyuhwan Park★ <unstabler@unstabler.pl>2023-02-08 20:59:50 +0300
commitcde4c930a26f8b483bfef7e84e3b6e3990585593 (patch)
tree5052793b64b09c885dd0121e0ea30dd315f386a6
parent93c352b20d2ffa483824d30aec5e9bb4a717e084 (diff)
checkpoint: reimplement createCopyRects() to prevent overlap
-rw-r--r--XrdpUlalacaPrivate.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/XrdpUlalacaPrivate.cpp b/XrdpUlalacaPrivate.cpp
index d2a49cf..a374c9b 100644
--- a/XrdpUlalacaPrivate.cpp
+++ b/XrdpUlalacaPrivate.cpp
@@ -98,27 +98,37 @@ std::unique_ptr<std::vector<ULIPCRect>> XrdpUlalacaPrivate::createCopyRects(
return std::move(blocks);
}
+ int mapWidth = ceil((float) _sessionSize.width / rectSize);
+ int mapHeight = ceil((float) _sessionSize.height / rectSize);
+ int mapSize = mapWidth * mapHeight;
+ std::unique_ptr<uint8_t> rectMap(new uint8_t[mapSize]);
+ memset(rectMap.get(), 0x00, mapSize);
+
for (auto &dirtyRect : dirtyRects) {
if (_sessionSize.width <= dirtyRect.x ||
_sessionSize.height <= dirtyRect.y) {
continue;
}
- auto width = std::min(dirtyRect.width, (short) (_sessionSize.width - dirtyRect.x));
- auto height = std::min(dirtyRect.height, (short) (_sessionSize.height - dirtyRect.y));
-
- auto baseX = dirtyRect.x - (dirtyRect.x % rectSize);
- auto baseY = dirtyRect.y - (dirtyRect.y % rectSize);
+ int mapX1 = dirtyRect.x / rectSize;
+ int mapY1 = dirtyRect.y / rectSize;
+ int mapX2 = (dirtyRect.x + dirtyRect.width) / rectSize;
+ int mapY2 = (dirtyRect.y + dirtyRect.height) / rectSize;
- auto blockCountX = ((width + dirtyRect.x % rectSize) + (rectSize - 1)) / rectSize;
- auto blockCountY = ((height + dirtyRect.y % rectSize) + (rectSize - 1)) / rectSize;
+ for (int y = mapY1; y <= mapY2; y++) {
+ for (int x = mapX1; x <= mapX2; x++) {
+ rectMap.get()[(y * mapWidth) + x] = 0x01;
+ }
+ }
+ }
- for (int j = 0; j < blockCountY; j++) {
- for (int i = 0; i < blockCountX; i++) {
- short x = baseX + (rectSize * i);
- short y = baseY + (rectSize * j);
+ for (int y = 0; y < mapHeight; y++) {
+ for (int x = 0; x < mapWidth; x++) {
+ if (rectMap.get()[(y * mapWidth) + x] == 0x01) {
+ int rectX = x * rectSize;
+ int rectY = y * rectSize;
- blocks->emplace_back(ULIPCRect {x, y, (short) rectSize, (short) rectSize });
+ blocks->emplace_back(ULIPCRect{(short) rectX, (short) rectY, (short) rectSize, (short) rectSize});
}
}
}