Hello Arthur Heymans, Matt DeVillier, Thomas Heijligen,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/libgfxinit/+/35721
to review the following change.
Change subject: [WIP] gfx_test: Factor main animation loop out to handle HP events ......................................................................
[WIP] gfx_test: Factor main animation loop out to handle HP events
Change-Id: Ib3bfc462e5be9a7a08fec5a8ead77c8631674bcf --- M gfxtest/hw-gfx-gma-gfx_test.adb 1 file changed, 92 insertions(+), 74 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/21/35721/1
diff --git a/gfxtest/hw-gfx-gma-gfx_test.adb b/gfxtest/hw-gfx-gma-gfx_test.adb index fc1868f..665f119 100644 --- a/gfxtest/hw-gfx-gma-gfx_test.adb +++ b/gfxtest/hw-gfx-gma-gfx_test.adb @@ -509,6 +509,96 @@ end loop; end Move_Cursors;
+ procedure Run_The_Show + (Delay_MS : in out Natural; + Rotation : in Rotation_Type := No_Rotation; + Gen : in Rand_P.Generator) + is + Hotplug_List : GMA.Display_Probing.Port_List; + begin + Prepare_Configs (Rotation, Gen); + + GMA.Update_Outputs (Pipes); + + for Pipe in GMA.Pipe_Index loop + if Pipes (Pipe).Port /= GMA.Disabled then + Backup_Screen (Pipes (Pipe).Framebuffer); + Test_Screen + (Framebuffer => Pipes (Pipe).Framebuffer, + Pipe => Pipe); + end if; + for Size in Cursor_Size loop + Draw_Cursor (Pipe, Cursors (Pipe) (Size)); + end loop; + end loop; + + Cursor_Infos := + (others => + (Color => Pipe_Index'Val (Rand (Gen) mod 3), + Size => Cursor_Size'Val (Rand (Gen) mod 3), + X_Velo => 3 * Cursor_Rand (Gen), + Y_Velo => 3 * Cursor_Rand (Gen), + others => Cursor_Rand (Gen))); + + if Delay_MS < Primary_Delay_MS + Secondary_Delay_MS then + Script_Cursors (Pipes, Delay_MS); + Delay_MS := 0; + else -- getting bored? + Script_Cursors (Pipes, Primary_Delay_MS); + Delay_MS := Delay_MS - Primary_Delay_MS; + declare + New_Pipes : GMA.Pipe_Configs := Pipes; + + function Rand_Div (Num : Position_Type) return Position_Type is + (case Rand (Gen) mod 4 is + when 3 => Rand (Gen) mod Num / 3, + when 2 => Rand (Gen) mod Num / 2, + when 1 => Rand (Gen) mod Num, + when others => 0); + begin + Rand_P.Reset (Gen, Seed); + while Delay_MS >= Secondary_Delay_MS loop + New_Pipes := Pipes; + for Pipe in GMA.Pipe_Index loop + exit when Pipes (Pipe).Port = Disabled; + declare + New_FB : Framebuffer_Type renames + New_Pipes (Pipe).Framebuffer; + Cursor : Cursor_Type renames New_Pipes (Pipe).Cursor; + Width : constant Width_Type := + Pipes (Pipe).Framebuffer.Width; + Height : constant Height_Type := + Pipes (Pipe).Framebuffer.Height; + begin + New_FB.Start_X := Position_Type'Min + (Width - 320, Rand_Div (Width)); + New_FB.Start_Y := Position_Type'Min + (Height - 320, Rand_Div (Height)); + New_FB.Width := Width_Type'Max + (320, Width - New_FB.Start_X - Rand_Div (Width)); + New_FB.Height := Height_Type'Max + (320, Height - New_FB.Start_Y - Rand_Div (Height)); + + Cursor.Center_X := Rotated_Width (New_FB) / 2; + Cursor.Center_Y := Rotated_Height (New_FB) / 2; + GMA.Update_Cursor (Pipe, Cursor); + end; + end loop; + GMA.Display_Probing.Hotplug_Events (Hotplug_List); + if Hotplug_List (Hotplug_List'First) /= Disabled then + return; + end if; + GMA.Dump_Configs (New_Pipes); + GMA.Update_Outputs (New_Pipes); + Move_Cursors (New_Pipes, Secondary_Delay_MS, Gen); + Delay_MS := Delay_MS - Secondary_Delay_MS; + end loop; + Move_Cursors (New_Pipes, Delay_MS, Gen); + Delay_MS := 0; + end; + end if; + end Run_The_Show; + procedure Print_Usage is begin @@ -582,82 +672,10 @@ if Initialized then Backup_GTT;
- Prepare_Configs (Rotation, Gen); - - GMA.Update_Outputs (Pipes); - - for Pipe in GMA.Pipe_Index loop - if Pipes (Pipe).Port /= GMA.Disabled then - Backup_Screen (Pipes (Pipe).Framebuffer); - Test_Screen - (Framebuffer => Pipes (Pipe).Framebuffer, - Pipe => Pipe); - end if; - for Size in Cursor_Size loop - Draw_Cursor (Pipe, Cursors (Pipe) (Size)); - end loop; + while Delay_MS > 0 loop + Run_The_Show (Delay_MS, Rotation, Gen); end loop;
- Cursor_Infos := - (others => - (Color => Pipe_Index'Val (Rand (Gen) mod 3), - Size => Cursor_Size'Val (Rand (Gen) mod 3), - X_Velo => 3 * Cursor_Rand (Gen), - Y_Velo => 3 * Cursor_Rand (Gen), - others => Cursor_Rand (Gen))); - - if Delay_MS < Primary_Delay_MS + Secondary_Delay_MS then - Script_Cursors (Pipes, Delay_MS); - else -- getting bored? - Script_Cursors (Pipes, Primary_Delay_MS); - Delay_MS := Delay_MS - Primary_Delay_MS; - declare - New_Pipes : GMA.Pipe_Configs := Pipes; - - function Rand_Div (Num : Position_Type) return Position_Type is - (case Rand (Gen) mod 4 is - when 3 => Rand (Gen) mod Num / 3, - when 2 => Rand (Gen) mod Num / 2, - when 1 => Rand (Gen) mod Num, - when others => 0); - begin - Rand_P.Reset (Gen, Seed); - while Delay_MS >= Secondary_Delay_MS loop - New_Pipes := Pipes; - for Pipe in GMA.Pipe_Index loop - exit when Pipes (Pipe).Port = Disabled; - declare - New_FB : Framebuffer_Type renames - New_Pipes (Pipe).Framebuffer; - Cursor : Cursor_Type renames New_Pipes (Pipe).Cursor; - Width : constant Width_Type := - Pipes (Pipe).Framebuffer.Width; - Height : constant Height_Type := - Pipes (Pipe).Framebuffer.Height; - begin - New_FB.Start_X := Position_Type'Min - (Width - 320, Rand_Div (Width)); - New_FB.Start_Y := Position_Type'Min - (Height - 320, Rand_Div (Height)); - New_FB.Width := Width_Type'Max - (320, Width - New_FB.Start_X - Rand_Div (Width)); - New_FB.Height := Height_Type'Max - (320, Height - New_FB.Start_Y - Rand_Div (Height)); - - Cursor.Center_X := Rotated_Width (New_FB) / 2; - Cursor.Center_Y := Rotated_Height (New_FB) / 2; - GMA.Update_Cursor (Pipe, Cursor); - end; - end loop; - GMA.Dump_Configs (New_Pipes); - GMA.Update_Outputs (New_Pipes); - Move_Cursors (New_Pipes, Secondary_Delay_MS, Gen); - Delay_MS := Delay_MS - Secondary_Delay_MS; - end loop; - Move_Cursors (New_Pipes, Delay_MS, Gen); - end; - end if; - for Pipe in GMA.Pipe_Index loop if Pipes (Pipe).Port /= GMA.Disabled then Restore_Screen (Pipes (Pipe).Framebuffer);