Since the library consumes the GOP mode structure which is provided by
library caller, library caller doesn't need to ask the library about
the screen resolution, instead, it can directly get from the GOP mode
structure.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Laszlo Ersek <ler...@redhat.com>
Cc: Jordan Justen <jordan.l.jus...@intel.com>
---
 .../Application/BltLibSample/BltLibSample.c        | 64 ++++++++++------------
 OptionRomPkg/Include/Library/BltLib.h              | 20 +------
 .../Library/FrameBufferBltLib/FrameBufferBltLib.c  | 27 ---------
 OptionRomPkg/Library/GopBltLib/GopBltLib.c         | 32 +----------
 4 files changed, 32 insertions(+), 111 deletions(-)

diff --git a/OptionRomPkg/Application/BltLibSample/BltLibSample.c 
b/OptionRomPkg/Application/BltLibSample/BltLibSample.c
index 09fea62..3409b2c 100644
--- a/OptionRomPkg/Application/BltLibSample/BltLibSample.c
+++ b/OptionRomPkg/Application/BltLibSample/BltLibSample.c
@@ -68,7 +68,8 @@ Rand32 (
 
 VOID
 TestFills (
-  VOID
+  UINT32                         HorizontalResolution,
+  UINT32                         VerticalResolution
   )
 {
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Color;
@@ -77,20 +78,17 @@ TestFills (
   UINTN                          Y;
   UINTN                          W;
   UINTN                          H;
-  UINTN                          Width;
-  UINTN                          Height;
 
-  BltLibGetSizes (&Width, &Height);
   for (Loop = 0; Loop < 10000; Loop++) {
-    W = Width - (Rand32 () % Width);
-    H = Height - (Rand32 () % Height);
-    if (W != Width) {
-      X = Rand32 () % (Width - W);
+    W = HorizontalResolution - (Rand32 () % HorizontalResolution);
+    H = VerticalResolution - (Rand32 () % VerticalResolution);
+    if (W != HorizontalResolution) {
+      X = Rand32 () % (HorizontalResolution - W);
     } else {
       X = 0;
     }
-    if (H != Height) {
-      Y = Rand32 () % (Height - H);
+    if (H != VerticalResolution) {
+      Y = Rand32 () % (VerticalResolution - H);
     } else {
       Y = 0;
     }
@@ -102,23 +100,21 @@ TestFills (
 
 VOID
 TestColor1 (
-  VOID
+  UINT32                         HorizontalResolution,
+  UINT32                         VerticalResolution
   )
 {
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Color;
   UINTN                          X;
   UINTN                          Y;
-  UINTN                          Width;
-  UINTN                          Height;
 
-  BltLibGetSizes (&Width, &Height);
   *(UINT32*) (&Color) = 0;
 
-  for (Y = 0; Y < Height; Y++) {
-    for (X = 0; X < Width; X++) {
-      Color.Red =   (UINT8) ((X * 0x100) / Width);
-      Color.Green = (UINT8) ((Y * 0x100) / Height);
-      Color.Blue =  (UINT8) ((Y * 0x100) / Height);
+  for (Y = 0; Y < VerticalResolution; Y++) {
+    for (X = 0; X < HorizontalResolution; X++) {
+      Color.Red =   (UINT8) ((X * 0x100) / HorizontalResolution);
+      Color.Green = (UINT8) ((Y * 0x100) / VerticalResolution);
+      Color.Blue =  (UINT8) ((Y * 0x100) / VerticalResolution);
       BltLibVideoFill (&Color, X, Y, 1, 1);
     }
   }
@@ -180,43 +176,43 @@ GetTriColor (
 
 VOID
 TestColor (
-  VOID
+  UINT32                         HorizontalResolution,
+  UINT32                         VerticalResolution
   )
 {
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Color;
   UINTN                          X, Y;
   UINTN                          X1, X2, X3;
   UINTN                          Y1, Y2;
-  UINTN                          LineWidth, TriWidth, ScreenWidth;
-  UINTN                          TriHeight, ScreenHeight;
+  UINTN                          LineWidth, TriWidth;
+  UINTN                          TriHeight;
   UINT32                         ColorDist;
 
-  BltLibGetSizes (&ScreenWidth, &ScreenHeight);
   *(UINT32*) (&Color) = 0;
-  BltLibVideoFill (&Color, 0, 0, ScreenWidth, ScreenHeight);
+  BltLibVideoFill (&Color, 0, 0, HorizontalResolution, VerticalResolution);
 
   TriWidth = (UINTN) DivU64x32 (
-                       MultU64x32 (11547005, (UINT32) ScreenHeight),
+                       MultU64x32 (11547005, (UINT32) VerticalResolution),
                        10000000
                        );
   TriHeight = (UINTN) DivU64x32 (
-                        MultU64x32 (8660254, (UINT32) ScreenWidth),
+                        MultU64x32 (8660254, (UINT32) HorizontalResolution),
                         10000000
                         );
-  if (TriWidth > ScreenWidth) {
+  if (TriWidth > HorizontalResolution) {
     DEBUG ((EFI_D_INFO, "TriWidth at %d was too big\n", TriWidth));
-    TriWidth = ScreenWidth;
-  } else if (TriHeight > ScreenHeight) {
+    TriWidth = HorizontalResolution;
+  } else if (TriHeight > VerticalResolution) {
     DEBUG ((EFI_D_INFO, "TriHeight at %d was too big\n", TriHeight));
-    TriHeight = ScreenHeight;
+    TriHeight = VerticalResolution;
   }
 
   DEBUG ((EFI_D_INFO, "Triangle Width: %d; Height: %d\n", TriWidth, 
TriHeight));
 
-  X1 = (ScreenWidth - TriWidth) / 2;
+  X1 = (HorizontalResolution - TriWidth) / 2;
   X3 = X1 + TriWidth - 1;
   X2 = (X1 + X3) / 2;
-  Y2 = (ScreenHeight - TriHeight) / 2;
+  Y2 = (VerticalResolution - TriHeight) / 2;
   Y1 = Y2 + TriHeight - 1;
 
   for (Y = Y2; Y <= Y1; Y++) {
@@ -310,9 +306,9 @@ UefiMain (
     return Status;
   }
 
-  TestFills ();
+  TestFills (Gop->Mode->Info->HorizontalResolution, 
Gop->Mode->Info->VerticalResolution);
 
-  TestColor ();
+  TestColor (Gop->Mode->Info->HorizontalResolution, 
Gop->Mode->Info->VerticalResolution);
 
   TestMove1 (Gop->Mode->Info->HorizontalResolution, 
Gop->Mode->Info->VerticalResolution);
 
diff --git a/OptionRomPkg/Include/Library/BltLib.h 
b/OptionRomPkg/Include/Library/BltLib.h
index 98d49e5..8bc5d91 100644
--- a/OptionRomPkg/Include/Library/BltLib.h
+++ b/OptionRomPkg/Include/Library/BltLib.h
@@ -1,7 +1,7 @@
 /** @file
   Library for performing video blt operations
 
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -237,23 +237,5 @@ BltLibVideoToVideo (
   IN  UINTN                                 Height
   );
 
-
-/**
-  Returns the sizes related to the video device
-
-  @param[out]  Width   Width (in pixels)
-  @param[out]  Height  Height (in pixels)
-
-  @retval  EFI_INVALID_PARAMETER - Invalid parameter passed in
-  @retval  EFI_SUCCESS - The sizes were returned
-
-**/
-EFI_STATUS
-EFIAPI
-BltLibGetSizes (
-  OUT UINTN                                 *Width,  OPTIONAL
-  OUT UINTN                                 *Height  OPTIONAL
-  );
-
 #endif
 
diff --git a/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c 
b/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
index 49ef568..7066e76 100644
--- a/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
+++ b/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
@@ -711,30 +711,3 @@ BltLibVideoToVideo (
 
   return EFI_SUCCESS;
 }
-
-/**
-  Returns the sizes related to the video device
-
-  @param[out]  Width   Width (in pixels)
-  @param[out]  Height  Height (in pixels)
-
-  @retval  EFI_INVALID_PARAMETER - Invalid parameter passed in
-  @retval  EFI_SUCCESS - The sizes were returned
-
-**/
-EFI_STATUS
-EFIAPI
-BltLibGetSizes (
-  OUT UINTN                                 *Width,  OPTIONAL
-  OUT UINTN                                 *Height  OPTIONAL
-  )
-{
-  if (Width != NULL) {
-    *Width = mBltLibWidthInPixels;
-  }
-  if (Height != NULL) {
-    *Height = mBltLibHeight;
-  }
-
-  return EFI_SUCCESS;
-}
diff --git a/OptionRomPkg/Library/GopBltLib/GopBltLib.c 
b/OptionRomPkg/Library/GopBltLib/GopBltLib.c
index 1fb34fa..70377db 100644
--- a/OptionRomPkg/Library/GopBltLib/GopBltLib.c
+++ b/OptionRomPkg/Library/GopBltLib/GopBltLib.c
@@ -1,7 +1,7 @@
 /** @file
   GopBltLib - Library to perform blt using the UEFI Graphics Output Protocol.
 
-  Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -423,33 +423,3 @@ BltLibVideoToVideo (
            0
            );
 }
-
-/**
-  Returns the sizes related to the video device
-
-  @param[out]  Width   Width (in pixels)
-  @param[out]  Height  Height (in pixels)
-
-  @retval  EFI_INVALID_PARAMETER - Invalid parameter passed in
-  @retval  EFI_SUCCESS - The sizes were returned
-
-**/
-EFI_STATUS
-EFIAPI
-BltLibGetSizes (
-  OUT UINTN                                 *Width,  OPTIONAL
-  OUT UINTN                                 *Height  OPTIONAL
-  )
-{
-  ASSERT (mGop != NULL);
-
-  if (Width != NULL) {
-    *Width = mGop->Mode->Info->HorizontalResolution;
-  }
-  if (Height != NULL) {
-    *Height = mGop->Mode->Info->VerticalResolution;
-  }
-
-  return EFI_SUCCESS;
-}
-
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to