Angel Pons has uploaded this change for review.

View Change

gfxtest: Fix out-of-order components, permanently

The `Pixel_Type` record uses a different order for its components, as
the hardware expects the data bytes in BGRA order but most people are
used to RGBA order for color components. However, this approach makes
the compiler complain:

warning: component clause out of order with respect to declaration [-gnatw_r]

This prevents building gfxtest since the warning gets promoted to an
error. While the issue is easy to work around (use BGRA order in the
declaration), *having* to work around this problem is most certainly
not ideal.

Introduce the `From_RGB` function, which maps 3 or 4 RGB(A) bytes to
a `Pixel_Type` record. Alpha is optional for convenience, as most of
the pixel handling uses fully opaque colors anyway.

Use this new function to replace positional aggregate initialization
to preserve colors (red is red, blue is blue). Omitting `255` alphas
makes up for the (slightly) increased verbosity of the code.

TEST=Run this and make sure all builds pass:

for f in configs/*
do
make distclean
make DEBUG=1 cnf=$f gfx_test -j$(nproc)
done

Change-Id: I77dbdcd6c235e411585585779c31777adcef57d0
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
---
M gfxtest/hw-gfx-gma-gfx_test.adb
1 file changed, 13 insertions(+), 10 deletions(-)

git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/54/81854/1
diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb
index a7579a0..a70721b 100644
--- a/gfxtest/hw-gfx-gma-gfx_test.adb
+++ b/gfxtest/hw-gfx-gma-gfx_test.adb
@@ -51,9 +51,9 @@
end Restore_GTT;

type Pixel_Type is record
- Red : Byte;
- Green : Byte;
Blue : Byte;
+ Green : Byte;
+ Red : Byte;
Alpha : Byte;
end record;

@@ -64,11 +64,14 @@
Alpha at 3 range 0 .. 7;
end record;

- White : constant Pixel_Type := (255, 255, 255, 255);
- Black : constant Pixel_Type := ( 0, 0, 0, 255);
- Red : constant Pixel_Type := (255, 0, 0, 255);
- Green : constant Pixel_Type := ( 0, 255, 0, 255);
- Blue : constant Pixel_Type := ( 0, 0, 255, 255);
+ function From_RGB (R, G, B : Byte; A : Byte := 255) return Pixel_Type is
+ (Red => R, Green => G, Blue => B, Alpha => A);
+
+ White : constant Pixel_Type := From_RGB (255, 255, 255);
+ Black : constant Pixel_Type := From_RGB ( 0, 0, 0);
+ Red : constant Pixel_Type := From_RGB (255, 0, 0);
+ Green : constant Pixel_Type := From_RGB ( 0, 255, 0);
+ Blue : constant Pixel_Type := From_RGB ( 0, 0, 255);

function Pixel_To_Word (P : Pixel_Type) return Word32
with
@@ -168,9 +171,9 @@
begin
return
(case Pipe is
- when GMA.Primary => (Map (Xn, Yn), Map (Xp, Yn), Map (Xp, Yp), 255),
- when GMA.Secondary => (Map (Xn, Yp), Map (Xn, Yn), Map (Xp, Yn), 255),
- when GMA.Tertiary => (Map (Xp, Yp), Map (Xn, Yp), Map (Xn, Yn), 255));
+ when GMA.Primary => From_RGB (Map (Xn, Yn), Map (Xp, Yn), Map (Xp, Yp)),
+ when GMA.Secondary => From_RGB (Map (Xn, Yp), Map (Xn, Yn), Map (Xp, Yn)),
+ when GMA.Tertiary => From_RGB (Map (Xp, Yp), Map (Xn, Yp), Map (Xn, Yn)));
end Fill;

procedure Test_Screen

To view, visit change 81854. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libgfxinit
Gerrit-Branch: main
Gerrit-Change-Id: I77dbdcd6c235e411585585779c31777adcef57d0
Gerrit-Change-Number: 81854
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-MessageType: newchange