Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
env:
# Prevent accidentally slower type-checking due to missing arm wheels.
# Fail rather than accidentally compile C/binary extensions from sdist.
UV_NO_BUILD: ${{ !(matrix.python-version == '3.15' && matrix.os == 'windows-latest') }} # winrt-Windows no wheels for 3.15 yet
UV_NO_BUILD: true
# Per-package no-binary overrides no-build, allowing
# known pure-Python source-only dependencies to still build.
# The Build job intentionally builds some binary packages from source.
Expand Down
17 changes: 8 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ dependencies = [
"pygrabber >=0.2; sys_platform == 'win32'", # Completed types
"pywin32 >=312; sys_platform == 'win32'", # Python 3.15 support
"typed-D3DShot[numpy] >=1.1.1; sys_platform == 'win32'",
# winrt: 3.14 wheels # TODO: Bump when 3.15 wheels
"winrt-Windows.Foundation >=3.2.1; sys_platform == 'win32'",
"winrt-Windows.Graphics >=3.2.1; sys_platform == 'win32'",
"winrt-Windows.Graphics.Capture >=3.2.1; sys_platform == 'win32'",
"winrt-Windows.Graphics.Capture.Interop >=3.2.1; sys_platform == 'win32'",
"winrt-Windows.Graphics.DirectX >=3.2.1; sys_platform == 'win32'",
"winrt-Windows.Graphics.DirectX.Direct3D11 >=3.2.1; sys_platform == 'win32'",
"winrt-Windows.Graphics.DirectX.Direct3D11.Interop >=3.2.1; sys_platform == 'win32'",
"winrt-Windows.Graphics.Imaging >=3.2.1; sys_platform == 'win32'",
# winrt v4: 3.15 wheels
"winrt-Windows.Graphics >=4.0.0; sys_platform == 'win32'",
"winrt-Windows.Graphics.Capture >=4.0.0; sys_platform == 'win32'",
"winrt-Windows.Graphics.Capture.Interop >=4.0.0; sys_platform == 'win32'",
"winrt-Windows.Graphics.DirectX >=4.0.0; sys_platform == 'win32'",
"winrt-Windows.Graphics.DirectX.Direct3D11 >=4.0.0; sys_platform == 'win32'",
"winrt-Windows.Graphics.DirectX.Direct3D11.Interop >=4.1.0; sys_platform == 'win32'", # Added create_direct3d11_device
"winrt-Windows.Graphics.Imaging >=4.0.0; sys_platform == 'win32'",
#
# Linux-only dependencies
"python-xlib >=0.33; sys_platform == 'linux'",
Expand Down
6 changes: 0 additions & 6 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ ignore = [
"RUF028", # invalid-formatter-suppression-comment, Is meant for the formatter, but false-positives
]

[lint.per-file-ignores]
"src/d3d11.py" = [
# Following windows API/ctypes like naming conventions
"N801", # invalid-class-name
]

[lint.isort]
# gen/ is fully generated and won't exist on CI so Ruff can't detect it as first-party
known-first-party = ["gen"]
5 changes: 2 additions & 3 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ try {
$arguments += @(
'--onefile',
"--name=AutoSplit-$version$buildNumber$pythonVersionTag-$arch$(if ($WineCompat) {'-WineCompat'} else {''})"
# Hidden import by winrt.windows.graphics.imaging.SoftwareBitmap.create_copy_from_surface_async
'--hidden-import=winrt.windows.foundation')
)
}
else {
if (Test-Path build/AppDir) { Remove-Item build/AppDir -Recurse -Force }
$arguments += @(
'--distpath=build/AppDir'
'--distpath=build/AppDir',
# Apply a symbol-table strip to the executable and shared libs (not recommended for Windows)
'--strip')
}
Expand Down
17 changes: 5 additions & 12 deletions src/capture_method/WindowsGraphicsCaptureMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if sys.platform != "win32":
raise OSError
import asyncio
from typing import TYPE_CHECKING, cast, override
from typing import TYPE_CHECKING, override

import cv2
import numpy as np
Expand All @@ -18,7 +18,6 @@
from winrt.windows.graphics.imaging import BitmapBufferAccessMode, SoftwareBitmap

from capture_method.CaptureMethodBase import CaptureMethodBase
from d3d11 import D3D11_CREATE_DEVICE_FLAG, D3D_DRIVER_TYPE, D3D11CreateDevice
from utils import ALPHA_CHANNEL_COUNT, WGC_MIN_BUILD, WINDOWS_BUILD_NUMBER, is_valid_hwnd

if TYPE_CHECKING:
Expand All @@ -32,6 +31,7 @@

try:
# Wine hasn't implemented CreateDirect3D11DeviceFromDXGIDevice yet
# (called by winrt's create_direct3d11_device)
# https://bugs.winehq.org/show_bug.cgi?id=52487
# Keep this check for a while even after it's implemented
# TODO: Fix these pywin32 types in typeshed
Expand All @@ -48,9 +48,7 @@

if TYPE_CHECKING or IS_WGC_SUPPORTED:
# This pyd hard-fails to load when the d3d11 export is missing (UPX+Wine)
from winrt.windows.graphics.directx.direct3d11.interop import (
create_direct3d11_device_from_dxgi_device,
)
from winrt.windows.graphics.directx.direct3d11.interop import create_direct3d11_device


async def convert_d3d_surface_to_software_bitmap(surface: IDirect3DSurface):
Expand All @@ -77,11 +75,7 @@ def __init__(self, autosplit: AutoSplit):
if not is_valid_hwnd(autosplit.hwnd):
return

dxgi, *_ = D3D11CreateDevice(
DriverType=D3D_DRIVER_TYPE.HARDWARE,
Flags=D3D11_CREATE_DEVICE_FLAG.BGRA_SUPPORT,
)
direct3d_device = create_direct3d11_device_from_dxgi_device(dxgi.value)
direct3d_device = create_direct3d11_device()
item = create_for_window(autosplit.hwnd)
frame_pool = Direct3D11CaptureFramePool.create_free_threaded(
direct3d_device,
Expand Down Expand Up @@ -158,8 +152,7 @@ def get_frame(self) -> MatLike | None:
bitmap_buffer = software_bitmap.lock_buffer(BitmapBufferAccessMode.READ_WRITE)
if not bitmap_buffer:
raise ValueError("Unable to obtain the BitmapBuffer from SoftwareBitmap.")
reference = bitmap_buffer.create_reference()
image = np.frombuffer(cast("bytes", reference), dtype=np.uint8)
image = np.frombuffer(bitmap_buffer, dtype=np.uint8)
image = image.reshape((self.size.height, self.size.width, ALPHA_CHANNEL_COUNT))
image = image[
selection["y"] : selection["y"] + selection["height"],
Expand Down
228 changes: 0 additions & 228 deletions src/d3d11.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_import_all_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"capture_method.DesktopDuplicationCaptureMethod",
"capture_method.ForceFullContentRenderingCaptureMethod",
"capture_method.WindowsGraphicsCaptureMethod",
"d3d11",
},
"linux": {
"capture_method.Screenshot using QT attempt",
Expand Down
Loading
Loading