Initial project snapshot

This commit is contained in:
2026-04-28 22:29:50 +03:00
commit 8ba0561f4f
365 changed files with 91832 additions and 0 deletions
@@ -0,0 +1,74 @@
#include "rdp_worker/graphics/graphics_adapter.hpp"
#include <utility>
namespace rdp_worker::graphics {
GraphicsAdapter::GraphicsAdapter(GraphicsAdapterPolicy policy)
: policy_(policy) {}
const GraphicsAdapterPolicy& GraphicsAdapter::Policy() const {
return policy_;
}
RenderUpdate GraphicsAdapter::MakeFullBgraFrame(std::uint64_t sequence,
int width,
int height,
int stride,
std::vector<std::uint8_t> pixels,
bool baseline) const {
RenderUpdate update;
update.kind = RenderUpdateKind::kFullBgraFrame;
update.sequence = sequence;
update.desktop_width = width;
update.desktop_height = height;
update.frame_width = width;
update.frame_height = height;
update.stride = stride;
update.region = Rect{0, 0, width, height};
update.payload = std::move(pixels);
update.baseline = baseline;
update.droppable = !baseline;
return update;
}
std::optional<RenderUpdate> GraphicsAdapter::TryMakeBgraRegion(std::uint64_t sequence,
int desktop_width,
int desktop_height,
int stride,
Rect region,
std::vector<std::uint8_t> pixels) const {
if (!RegionAllowed(desktop_width, desktop_height, region)) {
return std::nullopt;
}
RenderUpdate update;
update.kind = RenderUpdateKind::kBgraRegion;
update.sequence = sequence;
update.desktop_width = desktop_width;
update.desktop_height = desktop_height;
update.frame_width = region.width;
update.frame_height = region.height;
update.stride = stride;
update.region = region;
update.payload = std::move(pixels);
update.baseline = false;
update.droppable = true;
return update;
}
bool GraphicsAdapter::RegionAllowed(int desktop_width, int desktop_height, const Rect& region) const {
if (desktop_width <= 0 || desktop_height <= 0 ||
region.x < 0 || region.y < 0 ||
region.width <= 0 || region.height <= 0 ||
region.x + region.width > desktop_width ||
region.y + region.height > desktop_height) {
return false;
}
const long long desktop_area = static_cast<long long>(desktop_width) * static_cast<long long>(desktop_height);
const long long region_area = static_cast<long long>(region.width) * static_cast<long long>(region.height);
return region_area * 100 <= desktop_area * policy_.max_region_area_percent;
}
} // namespace rdp_worker::graphics