[coreboot-gerrit] Change in libgfxinit[master]: [WIP] gfx_test: Draw a cursor
Nico Huber (Code Review)
gerrit at coreboot.org
Fri Jan 12 14:22:56 CET 2018
Nico Huber has uploaded this change for review. ( https://review.coreboot.org/23242
Change subject: [WIP] gfx_test: Draw a cursor
......................................................................
[WIP] gfx_test: Draw a cursor
Change-Id: I58cd859f3294f30dfd91b87834699d62b1d0b025
Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
M gfxtest/hw-gfx-gma-gfx_test.adb
1 file changed, 56 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/42/23242/1
diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb
index 145230b..9bbb72a 100644
--- a/gfxtest/hw-gfx-gma-gfx_test.adb
+++ b/gfxtest/hw-gfx-gma-gfx_test.adb
@@ -21,6 +21,7 @@
Start_X : constant := 0;
Start_Y : constant := 0;
+ Cursor_Width : constant := 64;
package Dev is new PCI.Dev (PCI.Address'(0, 2, 0));
@@ -83,7 +84,7 @@
Max_H : constant := 2160;
FB_Align : constant := 16#0004_0000#;
subtype Screen_Index is Natural range
- 0 .. 3 * (Max_W * Max_H + FB_Align / 4) - 1;
+ 0 .. 3 * (Max_W * Max_H + FB_Align / 4 + Cursor_Width * Cursor_Width) - 1;
type Screen_Type is array (Screen_Index) of Word32;
function Screen_Offset (FB : Framebuffer_Type) return Natural is
@@ -214,6 +215,31 @@
end loop;
end Test_Screen;
+ function Donut (X, Y, Max : Cursor_Pos) return Pixel_Type
+ is
+ --Z : constant Int32 := (Max * 14_142_136) / 10_000_000;
+ ZZ : constant Int32 := Max * Max * 2;
+ Dist_Center : constant Int32 := ((X * X + Y * Y) * 510) / ZZ;
+ Dist_Circle : constant Int32 := Dist_Center - 255;
+ begin
+ return (0, 0, 0, Byte (255 - (Dist_Circle * Dist_Circle) / 255));
+ end Donut;
+
+ procedure Draw_Cursor (Cursor : Cursor_Type)
+ is
+ Screen_Offset : Natural := Natural (Cursor.GTT_Offset / 4);
+ begin
+ for X in Cursor_Pos range -Cursor_Width / 2 .. Cursor_Width / 2 - 1 loop
+ for Y in Cursor_Pos range -Cursor_Width / 2 .. Cursor_Width / 2 - 1
+ loop
+ Screen.Write
+ (Index => Screen_Offset,
+ Value => Pixel_To_Word (Donut (X, Y, Cursor_Width / 2)));
+ Screen_Offset := Screen_Offset + 1;
+ end loop;
+ end loop;
+ end Draw_Cursor;
+
procedure Calc_Framebuffer
(FB : out Framebuffer_Type;
Mode : in Mode_Type;
@@ -252,6 +278,31 @@
Offset := Offset + Word32 (FB_Size (FB));
end Calc_Framebuffer;
+ procedure Prepare_Cursor
+ (Cursor : out Cursor_Type;
+ Offset : in out Word32)
+ is
+ begin
+ Offset := (Offset + FB_Align - 1) and not (FB_Align - 1);
+ Cursor :=
+ (Mode => ARGB_Cursor,
+ Size => Cursor_64x64,
+ Center_X => Cursor_Width / 2,
+ Center_Y => Cursor_Width / 2,
+ GTT_Offset => Offset);
+ declare
+ GTT_End : constant Word32 := Offset + Cursor_Width * Cursor_Width * 4;
+ begin
+ while Offset < GTT_End loop
+ GMA.Write_GTT
+ (GTT_Page => GTT_Range (Offset / GTT_Page_Size),
+ Device_Address => GTT_Address_Type (Offset),
+ Valid => True);
+ Offset := Offset + GTT_Page_Size;
+ end loop;
+ end;
+ end Prepare_Cursor;
+
Pipes : GMA.Pipe_Configs;
procedure Prepare_Configs (Rotation : Rotation_Type)
@@ -277,6 +328,9 @@
if not Success then
Pipes (Pipe).Port := GMA.Disabled;
end if;
+ Prepare_Cursor
+ (Cursor => Pipes (Pipe).Cursor,
+ Offset => Offset);
end if;
end loop;
@@ -371,6 +425,7 @@
Test_Screen
(Framebuffer => Pipes (Pipe).Framebuffer,
Pipe => Pipe);
+ Draw_Cursor (Pipes (Pipe).Cursor);
end if;
end loop;
--
To view, visit https://review.coreboot.org/23242
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I58cd859f3294f30dfd91b87834699d62b1d0b025
Gerrit-Change-Number: 23242
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180112/d00636de/attachment-0001.html>
More information about the coreboot-gerrit
mailing list