Skip to content

Commit

Permalink
promote opengl module to top-level
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Aug 3, 2024
1 parent aca8ada commit 111afa5
Show file tree
Hide file tree
Showing 28 changed files with 37 additions and 40 deletions.
1 change: 0 additions & 1 deletion packaging/debian/xpra/xpra-client-gtk3.files
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ usr/bin/run_scaled
usr/bin/xpra_launcher
usr/lib/python3*/*/xpra/client/gui/
usr/lib/python3*/*/xpra/client/gtk3/
usr/lib/python3*/*/xpra/client/gl/
usr/lib/python3*/*/xpra/client/mixins/
usr/libexec/xpra/xpra_signal_listener
etc/xpra/conf.d/42_client_keyboard.conf
Expand Down
1 change: 1 addition & 0 deletions packaging/debian/xpra/xpra-common.files
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ usr/lib/python3*/*/xpra/dbus/
usr/lib/python3*/*/xpra/gstreamer/
usr/lib/python3*/*/xpra/gtk/
usr/lib/python3*/*/xpra/keyboard/
usr/lib/python3*/*/xpra/opengl/
usr/lib/python3*/*/xpra/net/
usr/lib/python3*/*/xpra/platform/
usr/lib/python3*/*/xpra/scripts/
Expand Down
2 changes: 1 addition & 1 deletion packaging/rpm/xpra.spec
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ rm -rf $RPM_BUILD_ROOT
%{python3_sitearch}/xpra/gtk/
%{python3_sitearch}/xpra/keyboard/
%{python3_sitearch}/xpra/net/
%{python3_sitearch}/xpra/opengl/
%{python3_sitearch}/xpra/platform/
%{python3_sitearch}/xpra/scripts/
%{python3_sitearch}/xpra-*.egg-info
Expand Down Expand Up @@ -709,7 +710,6 @@ rm -rf $RPM_BUILD_ROOT
%files -n %{package_prefix}-client-gtk3
%{python3_sitearch}/xpra/client/gui/
%{python3_sitearch}/xpra/client/gtk3/
%{python3_sitearch}/xpra/client/gl/
%{python3_sitearch}/xpra/client/mixins/
%{_libexecdir}/xpra/xpra_signal_listener
%{_datadir}/applications/xpra-launcher.desktop
Expand Down
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ def add_service_exe(script, icon, base_name) -> None:
# add_console_exe("xpra/audio/src.py", "microphone.ico", "Audio_Record")
# add_console_exe("xpra/audio/sink.py", "speaker.ico", "Audio_Play")
if opengl_ENABLED:
add_console_exe("xpra/client/gl/check.py", "opengl.ico", "OpenGL_check")
add_console_exe("xpra/opengl/check.py", "opengl.ico", "OpenGL_check")
if webcam_ENABLED:
add_console_exe("xpra/platform/webcam.py", "webcam.ico", "Webcam_info")
add_console_exe("xpra/scripts/show_webcam.py", "webcam.ico", "Webcam_Test")
Expand Down Expand Up @@ -2490,8 +2490,8 @@ def bundle_tests() -> None:
add_modules("xpra.scripts.server")

toggle_packages(not WIN32, "xpra.platform.pycups_printing")
toggle_packages(client_ENABLED and opengl_ENABLED, "xpra.client.gl")
toggle_packages(client_ENABLED and opengl_ENABLED and gtk3_ENABLED, "xpra.client.gl.gtk3")
toggle_packages(opengl_ENABLED, "xpra.opengl")
toggle_packages(client_ENABLED and opengl_ENABLED and gtk3_ENABLED, "xpra.client.gtk3.opengl")

toggle_modules(audio_ENABLED, "xpra.audio")
toggle_modules(audio_ENABLED and not (OSX or WIN32), "xpra.audio.pulseaudio")
Expand Down Expand Up @@ -2650,15 +2650,16 @@ def ax(base):
if not x.endswith("__init__.py"):
mod = x[:-3].replace(os.path.sep, ".")
ace(mod)

if opengl_ENABLED:
ax("xpra.opengl")
if client_ENABLED:
ax("xpra.client.base")
ax("xpra.client.auth")
if opengl_ENABLED:
ax("xpra.client.gl")
if gtk3_ENABLED:
ax("xpra.client.gl.gtk3")
if gtk3_ENABLED:
ax("xpra.client.gtk3")
if opengl_ENABLED:
ax("xpra.client.gtk3.opengl")
ax("xpra.client.gui")
ax("xpra.client.mixins")
if qt6_client_ENABLED:
Expand Down
2 changes: 1 addition & 1 deletion tests/xpra/clients/gl_scroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from xpra.util.objects import typedict
from xpra.gtk.window import add_close_accel
from xpra.gtk.signals import install_signal_handlers
from xpra.client.gl.window import get_gl_client_window_module
from xpra.opengl.window import get_gl_client_window_module
from xpra.common import force_size_constraint
from xpra.client.gui.fake_client import FakeClient
from xpra.client.gui.window_border import WindowBorder
Expand Down
4 changes: 0 additions & 4 deletions xpra/client/gl/__init__.py

This file was deleted.

8 changes: 4 additions & 4 deletions xpra/client/gtk3/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,9 @@ def err(msg: str, err):
opengllog.warn(" %s", warning)
self.opengl_props["info"] = "enabled despite: %s" % csv(warnings)
try:
opengllog("init_opengl: going to import xpra.client.gl")
__import__("xpra.client.gl", {}, {}, [])
from xpra.client.gl.window import get_gl_client_window_module, test_gl_client_window
opengllog("init_opengl: going to import xpra.opengl")
__import__("xpra.opengl", {}, {}, [])
from xpra.opengl.window import get_gl_client_window_module, test_gl_client_window
self.opengl_props, gl_client_window_module = get_gl_client_window_module(enable_opengl)
if not gl_client_window_module:
opengllog.warn("Warning: no OpenGL backend module found")
Expand Down Expand Up @@ -1295,7 +1295,7 @@ def glwarn(warning: str) -> None:
opengllog.warn("Warning: OpenGL is disabled:")
opengllog.warn(" %s", warning)

from xpra.client.gl.check import MIN_SIZE
from xpra.opengl.check import MIN_SIZE
if min(self.gl_max_viewport_dims) < MIN_SIZE:
glwarn("the maximum viewport size is too low: %s" % (self.gl_max_viewport_dims,))
if self.gl_texture_size_limit < MIN_SIZE:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from xpra.os_util import gi_import
from xpra.util.str_fn import Ellipsizer
from xpra.client.gl.backing import GLWindowBackingBase
from xpra.opengl.backing import GLWindowBackingBase
from xpra.platform.gl_context import GLContext
from xpra.log import Logger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from xpra.common import noop
from xpra.os_util import gi_import
from xpra.util.str_fn import Ellipsizer
from xpra.client.gl.backing import GLWindowBackingBase
from xpra.opengl.backing import GLWindowBackingBase
from xpra.log import Logger

log = Logger("opengl", "paint")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any

from xpra.os_util import gi_import
from xpra.client.gl.gtk3.client_window import GLClientWindowBase
from xpra.client.gtk3.opengl.client_window import GLClientWindowBase
from xpra.log import Logger

log = Logger("opengl", "paint")
Expand All @@ -18,7 +18,7 @@
class GLClientWindow(GLClientWindowBase):

def get_backing_class(self):
from xpra.client.gl.gtk3.glarea_backing import GLAreaBacking
from xpra.client.gtk3.opengl.glarea_backing import GLAreaBacking
return GLAreaBacking

def repaint(self, x: int, y: int, w: int, h: int) -> None:
Expand All @@ -37,7 +37,7 @@ def check_support(force_enable=False) -> dict[str, Any]:
window.resize(400, 400)
window.set_decorated(False)
window.realize()
from xpra.client.gl.gtk3.glarea_backing import GLArea
from xpra.client.gtk3.opengl.glarea_backing import GLArea
glarea = GLArea(True)
from xpra.gtk.window import set_visual
set_visual(glarea, True)
Expand All @@ -46,7 +46,7 @@ def check_support(force_enable=False) -> dict[str, Any]:
gl_context = glarea.get_context()
gl_context.make_current()
try:
from xpra.client.gl.check import check_PyOpenGL_support
from xpra.opengl.check import check_PyOpenGL_support
return check_PyOpenGL_support(force_enable)
finally:
window.destroy()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any

from xpra.os_util import gi_import
from xpra.client.gl.gtk3.client_window import GLClientWindowBase
from xpra.client.gtk3.opengl.client_window import GLClientWindowBase
from xpra.platform.gl_context import GLContext

GObject = gi_import("GObject")
Expand All @@ -26,7 +26,7 @@ class GLClientWindow(GLClientWindowBase):
def get_backing_class(self):
# delay the import so we can trap warnings in gl.check
# and use the numpy import context:
from xpra.client.gl.gtk3.drawing_area import GLDrawingArea
from xpra.client.gtk3.opengl.drawing_area import GLDrawingArea
return GLDrawingArea


Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/configure/opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def create_twin_test_windows(parent: Gtk.Window) -> tuple[dict[str, Any], list[G
from xpra.gtk.window import add_close_accel
from xpra.client.gui.fake_client import FakeClient
from xpra.client.gui.window_border import WindowBorder
from xpra.client.gl.window import get_gl_client_window_module
from xpra.opengl.window import get_gl_client_window_module
from xpra.client.gtk3.window import ClientWindow
opengl_props, gl_client_window_module = get_gl_client_window_module("force")
if not gl_client_window_module:
Expand Down
2 changes: 1 addition & 1 deletion xpra/gtk/examples/opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def main(argv=()):
consume_verbose_argv(argv, "opengl")
try:
from xpra.util.system import is_X11
from xpra.client.gl.window import get_gl_client_window_module, test_gl_client_window
from xpra.opengl.window import get_gl_client_window_module, test_gl_client_window
if is_X11():
from xpra.x11.gtk.display_source import init_gdk_display_source
init_gdk_display_source()
Expand Down
Empty file added xpra/opengl/__init__.py
Empty file.
10 changes: 5 additions & 5 deletions xpra/client/gl/backing.py → xpra/opengl/backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
from xpra.client.gui.window_border import WindowBorder
from xpra.client.gui.paint_colors import get_paint_box_color
from xpra.client.gui.window_backing_base import fire_paint_callbacks, WindowBackingBase, WEBP_PILLOW
from xpra.client.gl.check import GL_ALPHA_SUPPORTED, get_max_texture_size
from xpra.client.gl.debug import context_init_debug, gl_marker, gl_frame_terminator
from xpra.client.gl.util import (
from xpra.opengl.check import GL_ALPHA_SUPPORTED, get_max_texture_size
from xpra.opengl.debug import context_init_debug, gl_marker, gl_frame_terminator
from xpra.opengl.util import (
save_fbo, SAVE_BUFFERS,
zerocopy_upload, pixels_for_upload, set_alignment, upload_rgba_texture,
)
Expand Down Expand Up @@ -393,7 +393,7 @@ def init_shaders(self) -> None:
# Create and assign fragment programs
from OpenGL.GL import GL_FRAGMENT_SHADER, GL_VERTEX_SHADER
vertex_shader = self.init_shader("vertex", GL_VERTEX_SHADER)
from xpra.client.gl.shaders import SOURCE
from xpra.opengl.shaders import SOURCE
for name, source in SOURCE.items():
if name in ("overlay", "vertex", "fixed-color"):
continue
Expand Down Expand Up @@ -474,7 +474,7 @@ def init_shader(self, name: str, shader_type) -> int:
GL_COMPILE_STATUS, GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, GL_FALSE,
)
assert shader_type in (GL_VERTEX_SHADER, GL_FRAGMENT_SHADER)
from xpra.client.gl.shaders import SOURCE
from xpra.opengl.shaders import SOURCE
progstr = SOURCE[name]
shader = glCreateShader(shader_type)
self.shaders[name] = shader
Expand Down
2 changes: 1 addition & 1 deletion xpra/client/gl/check.py → xpra/opengl/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from xpra.util.str_fn import csv, print_nested_dict
from xpra.util.env import envint, envbool, numpy_import_context
from xpra.log import Logger, CaptureHandler, consume_verbose_argv
from xpra.client.gl.drivers import GL_MATCH_LIST, WHITELIST, GREYLIST, BLACKLIST, OpenGLFatalError
from xpra.opengl.drivers import GL_MATCH_LIST, WHITELIST, GREYLIST, BLACKLIST, OpenGLFatalError

log = Logger("opengl")

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion xpra/client/gl/window.py → xpra/opengl/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_gl_client_window_module(opengl="on") -> tuple[dict[str, Any], Any]:
def test_window_module(module_name="glarea", force_enable=False) -> tuple[dict, Any]:
from importlib import import_module
try:
mod = import_module(f"xpra.client.gl.gtk3.{module_name}_window")
mod = import_module(f"xpra.client.gtk3.opengl.{module_name}_window")
log(f"gl client window module {module_name!r}={mod}")
except (AttributeError, ImportError) as e:
log(f"cannot import opengl window module {module_name}", exc_info=True)
Expand Down
2 changes: 1 addition & 1 deletion xpra/platform/darwin/gl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
)
from xpra.gtk.window import GDKWindow
from xpra.client.gl.check import check_PyOpenGL_support
from xpra.opengl.check import check_PyOpenGL_support
from xpra.platform.darwin.gdk3_bindings import get_nsview_ptr, enable_transparency, get_backing_scale_factor
from xpra.util.env import envbool
from xpra.os_util import gi_import
Expand Down
2 changes: 1 addition & 1 deletion xpra/platform/posix/gl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from xpra.os_util import gi_import
from xpra.util.env import envbool, envfloat, numpy_import_context
from xpra.client.gl.check import check_PyOpenGL_support
from xpra.opengl.check import check_PyOpenGL_support
from xpra.x11.bindings.display_source import get_display_ptr
from xpra.gtk.error import xsync
from xpra.gtk.window import set_visual
Expand Down
2 changes: 1 addition & 1 deletion xpra/platform/win32/gl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ctypes.wintypes import LPCWSTR
from contextlib import nullcontext, AbstractContextManager

from xpra.client.gl.check import check_PyOpenGL_support
from xpra.opengl.check import check_PyOpenGL_support
from xpra.util.io import CaptureStdErr
from xpra.platform.win32.gui import get_window_handle
from xpra.platform.win32.constants import (
Expand Down
2 changes: 1 addition & 1 deletion xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,7 @@ def do_run_glcheck(opts, show=False) -> dict[str, Any]:
saved_level = logging.root.getEffectiveLevel()
logging.root.setLevel(logging.WARN)
try:
from xpra.client.gl.window import get_gl_client_window_module, test_gl_client_window
from xpra.opengl.window import get_gl_client_window_module, test_gl_client_window
opengl_str = (opts.opengl or "").lower()
opengl_props, gl_client_window_module = get_gl_client_window_module(opengl_str)
log("do_run_glcheck() opengl_props=%s, gl_client_window_module=%s", opengl_props, gl_client_window_module)
Expand Down
2 changes: 1 addition & 1 deletion xpra/server/mixins/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def query_opengl(self) -> dict[str, Any]:
try:
with OSEnvContext():
os.environ["XPRA_VERIFY_MAIN_THREAD"] = "0"
from xpra.client.gl import backing
from xpra.opengl import backing
assert backing
except ImportError:
return {
Expand Down

0 comments on commit 111afa5

Please sign in to comment.