重构:libop 模块结构并新增 Go C API 绑定#198
Merged
Merged
Conversation
把原先集中在 background/、core/、winapi/、imageProc/ 的代码 按领域重新组织为独立模块目录,并将文件/类型重命名为语义化命名。 目录重组: - background/ → 拆分为 binding/、capture/、hook/、input/ - core/ → 拆分为 runtime/、ipc/、memory/、window/ - winapi/ → 并入 window/、hook/、memory/ - imageProc/ → 拆分为 image/、ocr/、network/、yolo/ - include/ 公共头 → 归入 image/、ocr/、runtime/ 关键重命名: - com/OpInterface.* → com/OpAutomation.* - WinApi → WindowService - ImageProc/ImageLoc→ ImageSearchService/ImageSearchAlgorithms - OcrWrapper → OcrService;HttpWrapper → network/HttpClient - YoloWrapper → yolo/YoloDetector 新增: - client/ 分域实现层,将 libop.cpp 按域拆为 ClientImage/ClientInput /ClientWindow/ClientOcr/ClientYolo 等多个翻译单元 - .clang-tidy 静态检查配置 仅为结构性重构,对外 COM/C/Python 接口行为保持不变。
- 用 surface GetDesc 取代不可靠的 ContentSize 决定 staging 尺寸,消除窗口 resize 时 CopyResource 源/目标尺寸不一致导致的花屏/静默失败 - 客户区裁剪越界改为夹取而非整张失败;dx/dy 防负;IsIconic 双采样防最小化 ABA 竞态 - 能力探测改用 ApiInformation::IsPropertyPresent;关黄框前申请 Borderless 访问、关闭 光标捕获,避免黄框/光标污染找色找图 - override waitForBindReady 绑定后等首帧,消除 bind 后第一次截图假失败 - 监听 GraphicsCaptureItem.Closed,目标窗口关闭后干净失败而非空转 - 设备丢失(TDR/驱动更新/GPU reset)自动重建捕获会话 - 最小化恢复后等帧、必要时重启会话恢复出帧;恢复等待 2帧/700ms → 1帧/150ms 提速 新增 tests/wgc_test.cpp 回归用例:首帧+resize+关闭、最小化恢复。
把旧的 kiero vendoring 替换成 kiero2,第三方源码统一放到 3rd_party/kiero2 下,旧的 include/src 目录和合并后的方法表文件一并清掉。 DisplayHook 改成先用 kiero2 定位图形 API 方法地址,再交给 MinHook 做真正的 hook;InputHook 也补了自己的 MinHook 生命周期管理,避免和显示 hook 互相影响。CMake、tests、tools 的包含路径同步整理,删掉已经没有内容的第三方目录。
新增 normal.auto 显示模式,按窗口类型和系统能力在 WGC、DXGI、normal 之间选择并失败回退。 增强 DXGI 捕获:按目标窗口所在 HMONITOR 选择输出,绑定后预热首帧,并在窗口坐标变化时重新计算客户区偏移。 增强 WGC 捕获:申请 Borderless 访问并关闭边框/光标捕获,监听窗口关闭事件,resize/maximize/minimize/设备丢失后重启会话恢复出帧。 扩展 WGC 回归测试,覆盖 normal.auto、首帧、resize、窗口关闭、最小化恢复和最大化后完整客户区截图。
将 DisplayHook 收窄为渲染方法定位和 MinHook 生命周期管理,截图实现拆分到 D3D9、D3D10、D3D11、D3D12 和 OpenGL 独立模块。 新增 DxCaptureCommon 承载 CopyImageData、DXGI 格式归一化和图像格式判断,减少 D3D10/D3D11 捕获路径重复逻辑。 补强 DX hook 读回路径:D3D10/D3D11 对 MSAA 后备缓冲先 ResolveSubresource 再读回,D3D10/D3D11/D3D12 跳过 DXGI_PRESENT_TEST 测试帧。 统一 D3D12 命名,将旧 Dx12Hook 迁移为 D3D12Capture,并移除本地 vendor/d3dx12.h。 构建依赖改用 vcpkg directx-headers 和 Microsoft::DirectX-Headers 官方 target,同时为静态 MinHook triplet 提供 CMake package 查找路径。
同步暴露 normal.auto 显示模式,方便 Python 用户使用自动捕获后端选择。 移除 Python constants 中的兼容别名:Threshold.INV、ColorSpace.GREY、Thin.ZHANGSUEN、Thin.GUOHALL 和 Blur.MEAN。 C++ 字符串解析仍保留旧别名兼容,避免手写字符串调用被破坏。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
libop目录结构,拆分 binding、capture、hook、input、runtime、ipc、memory、window、image、ocr、network、yolo、client 等模块。normal.auto捕获链路,覆盖首帧等待、resize/maximize/minimize 恢复、关闭黄框、设备丢失重建和窗口关闭处理。kiero2,拆分 DX/OpenGL hook 捕获实现,并通过 vcpkg 使用官方 DirectX-Headers。libopclient 接口命名,清理 Python 公开常量兼容别名。bindings/goGo C API 绑定,并将 ctypes Python C API 包移动到bindings/python验证
python build.py -t Release -g vs2026 -a x64python build.py -t Release -g vs2026 -a x86cd bindings/go && go test ./...python -m compileall -q bindings\python\op