diff options
author | Even Oscar Andersen <[email protected]> | 2024-03-13 15:46:05 +0100 |
---|---|---|
committer | Even Oscar Andersen <[email protected]> | 2024-03-22 13:51:33 +0100 |
commit | 043ceca40ffda0a87871e1800578c99273916e60 (patch) | |
tree | c42ed3480703445927c6cdecaf7e4d79fcde3677 /tests/auto/wasm/selenium/qwasmwindow.py | |
parent | a5b9ba15e2be40e9d638628d84a7689783dc95a0 (diff) |
wasm: Document and test OpenGLContext limitations
There is a limit in WebGL that OpenGL context sharing is not supported.
There is a proposal from 2013
(https://www.khronos.org/webgl/wiki/SharedResouces), but it seems that
it never was implemented.
There is an additional limit in that there is exactly one WebGL context
for each canvas (i.e. window).
A part of the problem here is that the identifier for an OpenGL context
is essentially a surface-thread-context triplet. And the thread part
might be more difficult to handle in a javascript setting.
Regardless of why, we need to have an opinion about what the
consequences are, and what we support to what extent.
As such this commit:
1) Adds a comment on the QOpenGLContext describing the limitations
2) Adds a qWarning() on the first activation of a shared context.
The second item is not complete. We will have problems with multiple
individual contexts also, It is just not possible to warn for these
cases. The second item covers, maybe, the most common case.
Change-Id: I51550a6acb0a7f6f6fa5e9e2c3da080a1d2b498f
Reviewed-by: Morten Johan Sørvig <[email protected]>
Diffstat (limited to 'tests/auto/wasm/selenium/qwasmwindow.py')
-rw-r--r-- | tests/auto/wasm/selenium/qwasmwindow.py | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/tests/auto/wasm/selenium/qwasmwindow.py b/tests/auto/wasm/selenium/qwasmwindow.py index 1932feb4bb9..dbec21f61a7 100644 --- a/tests/auto/wasm/selenium/qwasmwindow.py +++ b/tests/auto/wasm/selenium/qwasmwindow.py @@ -13,6 +13,7 @@ from selenium.webdriver.support.expected_conditions import presence_of_element_l from selenium.webdriver.support.ui import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager +import time import unittest from enum import Enum, auto @@ -436,7 +437,40 @@ class WidgetTestCase(unittest.TestCase): self.assertEqual(w1_w1_w1.color_at(0, 0), Color(r=255, g=255, b=0)) - #TODO FIX IN CI + def test_opengl_painting(self): + screen = Screen(self._driver, ScreenPosition.FIXED, + x=0, y=0, width=800, height=800) + bottom = Window(parent=screen, rect=Rect(x=0, y=0, width=400, height=400), title='root',opengl=1) + bottom.set_background_color(Color(r=255, g=0, b=0)) + wait_for_animation_frame(self._driver) + time.sleep(1) + + self.assertEqual(bottom.window_color_at_0_0(), Color(r=255, g=0, b=0)) + + w1 = Window(parent=screen, rect=Rect(x=100, y=100, width=600, height=600), title='w1', opengl=1) + w1.set_background_color(Color(r=0, g=255, b=0)) + wait_for_animation_frame(self._driver) + time.sleep(1) + + self.assertEqual(w1.window_color_at_0_0(), Color(r=0, g=255, b=0)) + + w1_w1 = Window(parent=screen, rect=Rect(x=100, y=100, width=400, height=400), title='w1_w1', opengl=1) + w1_w1.set_parent(w1) + w1_w1.set_background_color(Color(r=0, g=0, b=255)) + wait_for_animation_frame(self._driver) + time.sleep(1) + + self.assertEqual(w1_w1.window_color_at_0_0(), Color(r=0, g=0, b=255)) + + w1_w1_w1 = Window(parent=screen, rect=Rect(x=100, y=100, width=200, height=200), title='w1_w1_w1', opengl=1) + w1_w1_w1.set_parent(w1_w1) + w1_w1_w1.set_background_color(Color(r=255, g=255, b=0)) + wait_for_animation_frame(self._driver) + time.sleep(1) + + self.assertEqual(w1_w1_w1.window_color_at_0_0(), Color(r=255, g=255, b=0)) + +#TODO FIX IN CI @unittest.skip('Does not work in CI') def test_keyboard_input(self): screen = Screen(self._driver, ScreenPosition.FIXED, @@ -607,8 +641,9 @@ class Widget: class Window: - def __init__(self, parent=None, rect=None, title=None, element=None, visible=True): + def __init__(self, parent=None, rect=None, title=None, element=None, visible=True, opengl=0): self.driver = parent.driver + self.opengl = opengl if element is not None: self.element = element self.title = element.find_element( @@ -621,7 +656,7 @@ class Window: if isinstance(parent, Window): self.driver.execute_script( f''' - instance.createWindow({rect.x}, {rect.y}, {rect.width}, {rect.height}, 'window', '{parent.title}', '{title}'); + instance.createWindow({rect.x}, {rect.y}, {rect.width}, {rect.height}, 'window', '{parent.title}', '{title}', {opengl}); ''' ) self.screen = parent.screen @@ -629,7 +664,7 @@ class Window: assert(isinstance(parent, Screen)) self.driver.execute_script( f''' - instance.createWindow({rect.x}, {rect.y}, {rect.width}, {rect.height}, 'screen', '{parent.name}', '{title}'); + instance.createWindow({rect.x}, {rect.y}, {rect.width}, {rect.height}, 'screen', '{parent.name}', '{title}', {opengl}); ''' ) self.screen = parent @@ -766,6 +801,16 @@ class Window: ''' ) + def window_color_at_0_0(self): + color = call_instance_function_arg(self.driver, 'getOpenGLColorAt_0_0', self.title) + + wcol = color[0] + r = wcol['r'] + g = wcol['g'] + b = wcol['b'] + + return Color(r,g,b) + def color_at(self, x, y): raw = self.driver.execute_script( f''' |