[kms-tests] [PATCH 4/6] tests: crc: Introduce Composer class

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

 



The Composer gathers the computation of planes position. It is currently
only used to configure the planes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
---
 tests/kms-test-crc.py | 45 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/tests/kms-test-crc.py b/tests/kms-test-crc.py
index e3e31b34e2d4..8876c88506c1 100755
--- a/tests/kms-test-crc.py
+++ b/tests/kms-test-crc.py
@@ -2,9 +2,43 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # SPDX-FileCopyrightText: 2017-2019 Renesas Electronics Corporation
 
+import copy
 import kmstest
 import pykms
 
+
+class Composer(object):
+    # Manage the composition of planes on the screen by computing the source
+    # and destination rectangles of each plane.
+    #
+    # Stack the plane, starting at START_POINT, with a fixed INCREMENT.
+    #
+
+    START_POINT = kmstest.Point(0, 0)
+    INCREMENT = kmstest.Dist(50, 50)
+
+    def __init__(self, crtc, planes, fb):
+        self.__fb_size = kmstest.Size(fb.width, fb.height)
+        self.__planes_positions = {}
+
+        position = copy.copy(Composer.START_POINT)
+        for plane in planes:
+            self.__planes_positions[plane] = copy.copy(position)
+            position.move(Composer.INCREMENT)
+
+    def source(self, plane):
+        pos = self.__planes_positions[plane]
+        return kmstest.Rect(0, 0,
+                            max(0, self.__fb_size.width - pos.x),
+                            max(0, self.__fb_size.height - pos.y))
+
+    def destination(self, plane):
+        pos = self.__planes_positions[plane]
+        return kmstest.Rect(pos.x, pos.y,
+                            max(0, self.__fb_size.width - pos.x),
+                            max(0, self.__fb_size.height - pos.y))
+
+
 class CRCTest(kmstest.KMSTest):
     """Test CRC calculation on pipeline output."""
 
@@ -48,10 +82,13 @@ class CRCTest(kmstest.KMSTest):
             self.logger.log("Testing connector %s, CRTC %u, mode %s with %u planes" % \
                   (connector.fullname, crtc.id, mode.name, len(planes)))
 
-            # Create a frame buffer
+            # Create a frame buffer and draw a test pattern.
             fb = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, "XR24")
             pykms.draw_test_pattern(fb)
 
+            # Create a composer.
+            composer = Composer(crtc, planes, fb)
+
             # Set the mode and add all planes
             ret = self.atomic_crtc_mode_set(crtc, connector, mode, sync=True)
             if ret < 0:
@@ -60,10 +97,9 @@ class CRCTest(kmstest.KMSTest):
 
             req = kmstest.AtomicRequest(self)
 
-            offset = 100
             for plane in planes:
-                source = kmstest.Rect(0, 0, fb.width, fb.height)
-                destination = kmstest.Rect(offset, offset, fb.width, fb.height)
+                source = composer.source(plane)
+                destination = composer.destination(plane)
                 req.add(plane, {
                         'FB_ID': fb.id,
                         'CRTC_ID': crtc.id,
@@ -76,7 +112,6 @@ class CRCTest(kmstest.KMSTest):
                         'CRTC_W': destination.width,
                         'CRTC_H': destination.height,
                 })
-                offset += 50
 
             ret = req.commit(0)
             if ret < 0:
-- 
Regards,

Laurent Pinchart




[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