[PATCH 3/3] tests: Add pixel blend mode test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a test that blends a plane with different pixel blend modes.

Signed-off-by: Takanari Hayama <taki@xxxxxxxxxx>
---
 tests/kms-test-plane-blendmode.py | 100 ++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
 create mode 100755 tests/kms-test-plane-blendmode.py

diff --git a/tests/kms-test-plane-blendmode.py b/tests/kms-test-plane-blendmode.py
new file mode 100755
index 000000000000..a9c009b74a8c
--- /dev/null
+++ b/tests/kms-test-plane-blendmode.py
@@ -0,0 +1,100 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Renesas Electronics Corporation
+
+import kmstest
+import pykms
+
+class PlaneBlendModeTest(kmstest.KMSTest):
+    """Test composition in different blend modes."""
+
+    def handle_page_flip(self, frame, time):
+        self.logger.log('Page flip complete')
+
+    def find_pipeline(self):
+        # Find a CRTC that has multiple planes with a connected connector
+        for connector in self.output_connectors():
+            # Skip disconnected connectors
+            if not connector.connected():
+                continue
+
+            # Add the connector to the map
+            for crtc in connector.get_possible_crtcs():
+                planes = []
+                for plane in self.card.planes:
+                    if plane.supports_crtc(crtc) and plane != crtc.primary_plane:
+                        planes.append(plane)
+
+                if len(planes):
+                    return crtc, connector, planes
+
+        return None, None, None
+
+    def main(self):
+        self.start('composition with blend modes')
+
+        crtc, connector, planes = self.find_pipeline()
+        if crtc is None:
+            self.skip('no suitable pipeline')
+            return
+
+        # Get the default mode
+        try:
+            mode = connector.get_default_mode()
+        except KeyError:
+            self.skip('no mode available')
+            return
+
+        self.logger.log(f'Testing connector {connector.fullname}, CRTC {crtc.id}, '
+                        f'mode {mode.name} with {len(planes)} planes '
+                        f'(P: {crtc.primary_plane.id}, O: {[plane.id for plane in planes]})')
+
+        # Create a primary plane
+        primary = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, 'XR24')
+        pykms.draw_test_pattern(primary)
+        #pykms.draw_rect(primary, 0, 0, mode.hdisplay, mode.vdisplay, pykms.RGB(0, 0, 255))
+
+        # Set the mode with a primary plane
+        ret = self.atomic_crtc_mode_set(crtc, connector, mode, primary)
+        if ret < 0:
+            self.fail(f'atomic mode set failed with {ret}')
+            return
+
+	# Create a overlay plane (half of the screen size)
+        fb = pykms.DumbFramebuffer(self.card, mode.hdisplay // 2, mode.vdisplay, 'AR24')
+        self.logger.log(f'Create fb: {fb} ({fb.width}x{fb.height})')
+        width = mode.hdisplay // 4
+        height = mode.vdisplay // 5
+        for n in range(0, 5):
+            v = 255 - 63 * n
+            pykms.draw_rect(fb, 0, height * n, width, height, pykms.RGB(v, 255, 255, 255))
+            pykms.draw_rect(fb, width, height * n, width, height, pykms.RGB(v, v, v, v))
+
+        self.run(3)
+
+        # Add all other planes one by one
+        source = kmstest.Rect(0, 0, fb.width, fb.height)
+        destination = kmstest.Rect(fb.width, 0, fb.width, fb.height)
+        alpha = '50%'
+        for blendmode in ('Pre-multiplied', 'Coverage', 'None'):
+            pykms.draw_text(fb, 10, 10, f'alpha={alpha}, mode={blendmode}          ', pykms.white)
+            ret = self.atomic_plane_set(planes[1], crtc, source, destination, fb, alpha=alpha, blendmode=blendmode)
+            if ret < 0:
+                self.fail(f'atomic plane set failed with {ret}')
+                break
+
+            self.logger.log(f'Adding plane {planes[1].id} with blendmode {blendmode}')
+            self.run(1)
+
+            if self.flips == 0:
+                self.fail('No page flip registered')
+                break
+
+            self.run(3)
+
+        else:
+            self.success()
+
+        self.atomic_crtc_disable(crtc)
+
+PlaneBlendModeTest().execute()
-- 
2.25.1




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux