1*f439973dSWarner Losh /** @file 2*f439973dSWarner Losh The file provides services to access to images in the images database. 3*f439973dSWarner Losh 4*f439973dSWarner Losh Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 5*f439973dSWarner Losh SPDX-License-Identifier: BSD-2-Clause-Patent 6*f439973dSWarner Losh 7*f439973dSWarner Losh @par Revision Reference: 8*f439973dSWarner Losh This Protocol was introduced in UEFI Specification 2.1. 9*f439973dSWarner Losh 10*f439973dSWarner Losh **/ 11*f439973dSWarner Losh 12*f439973dSWarner Losh #ifndef __HII_IMAGE_H__ 13*f439973dSWarner Losh #define __HII_IMAGE_H__ 14*f439973dSWarner Losh 15*f439973dSWarner Losh #include <Protocol/GraphicsOutput.h> 16*f439973dSWarner Losh 17*f439973dSWarner Losh #define EFI_HII_IMAGE_PROTOCOL_GUID \ 18*f439973dSWarner Losh { 0x31a6406a, 0x6bdf, 0x4e46, { 0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x9, 0x20 } } 19*f439973dSWarner Losh 20*f439973dSWarner Losh typedef struct _EFI_HII_IMAGE_PROTOCOL EFI_HII_IMAGE_PROTOCOL; 21*f439973dSWarner Losh 22*f439973dSWarner Losh /// 23*f439973dSWarner Losh /// Flags in EFI_IMAGE_INPUT 24*f439973dSWarner Losh /// 25*f439973dSWarner Losh #define EFI_IMAGE_TRANSPARENT 0x00000001 26*f439973dSWarner Losh 27*f439973dSWarner Losh /** 28*f439973dSWarner Losh 29*f439973dSWarner Losh Definition of EFI_IMAGE_INPUT. 30*f439973dSWarner Losh 31*f439973dSWarner Losh @param Flags Describe image characteristics. If 32*f439973dSWarner Losh EFI_IMAGE_TRANSPARENT is set, then the image was 33*f439973dSWarner Losh designed for transparent display. 34*f439973dSWarner Losh 35*f439973dSWarner Losh @param Width Image width, in pixels. 36*f439973dSWarner Losh 37*f439973dSWarner Losh @param Height Image height, in pixels. 38*f439973dSWarner Losh 39*f439973dSWarner Losh @param Bitmap A pointer to the actual bitmap, organized left-to-right, 40*f439973dSWarner Losh top-to-bottom. The size of the bitmap is 41*f439973dSWarner Losh Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL). 42*f439973dSWarner Losh 43*f439973dSWarner Losh 44*f439973dSWarner Losh **/ 45*f439973dSWarner Losh typedef struct _EFI_IMAGE_INPUT { 46*f439973dSWarner Losh UINT32 Flags; 47*f439973dSWarner Losh UINT16 Width; 48*f439973dSWarner Losh UINT16 Height; 49*f439973dSWarner Losh EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Bitmap; 50*f439973dSWarner Losh } EFI_IMAGE_INPUT; 51*f439973dSWarner Losh 52*f439973dSWarner Losh /** 53*f439973dSWarner Losh 54*f439973dSWarner Losh This function adds the image Image to the group of images 55*f439973dSWarner Losh owned by PackageList, and returns a new image identifier 56*f439973dSWarner Losh (ImageId). 57*f439973dSWarner Losh 58*f439973dSWarner Losh @param This A pointer to the EFI_HII_IMAGE_PROTOCOL instance. 59*f439973dSWarner Losh 60*f439973dSWarner Losh @param PackageList Handle of the package list where this image will be added. 61*f439973dSWarner Losh 62*f439973dSWarner Losh @param ImageId On return, contains the new image id, which is 63*f439973dSWarner Losh unique within PackageList. 64*f439973dSWarner Losh 65*f439973dSWarner Losh @param Image Points to the image. 66*f439973dSWarner Losh 67*f439973dSWarner Losh @retval EFI_SUCCESS The new image was added 68*f439973dSWarner Losh successfully 69*f439973dSWarner Losh 70*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Could not add the image. 71*f439973dSWarner Losh 72*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER Image is NULL or ImageId is 73*f439973dSWarner Losh NULL. 74*f439973dSWarner Losh 75*f439973dSWarner Losh 76*f439973dSWarner Losh **/ 77*f439973dSWarner Losh typedef 78*f439973dSWarner Losh EFI_STATUS 79*f439973dSWarner Losh (EFIAPI *EFI_HII_NEW_IMAGE)( 80*f439973dSWarner Losh IN CONST EFI_HII_IMAGE_PROTOCOL *This, 81*f439973dSWarner Losh IN EFI_HII_HANDLE PackageList, 82*f439973dSWarner Losh OUT EFI_IMAGE_ID *ImageId, 83*f439973dSWarner Losh IN CONST EFI_IMAGE_INPUT *Image 84*f439973dSWarner Losh ); 85*f439973dSWarner Losh 86*f439973dSWarner Losh /** 87*f439973dSWarner Losh 88*f439973dSWarner Losh This function retrieves the image specified by ImageId which 89*f439973dSWarner Losh is associated with the specified PackageList and copies it 90*f439973dSWarner Losh into the buffer specified by Image. If the image specified by 91*f439973dSWarner Losh ImageId is not present in the specified PackageList, then 92*f439973dSWarner Losh EFI_NOT_FOUND is returned. If the buffer specified by 93*f439973dSWarner Losh ImageSize is too small to hold the image, then 94*f439973dSWarner Losh EFI_BUFFER_TOO_SMALL will be returned. ImageSize will be 95*f439973dSWarner Losh updated to the size of buffer actually required to hold the 96*f439973dSWarner Losh image. 97*f439973dSWarner Losh 98*f439973dSWarner Losh @param This A pointer to the EFI_HII_IMAGE_PROTOCOL instance. 99*f439973dSWarner Losh 100*f439973dSWarner Losh @param PackageList The package list in the HII database to 101*f439973dSWarner Losh search for the specified image. 102*f439973dSWarner Losh 103*f439973dSWarner Losh @param ImageId The image's id, which is unique within 104*f439973dSWarner Losh PackageList. 105*f439973dSWarner Losh 106*f439973dSWarner Losh @param Image Points to the new image. 107*f439973dSWarner Losh 108*f439973dSWarner Losh @retval EFI_SUCCESS The image was returned successfully. 109*f439973dSWarner Losh 110*f439973dSWarner Losh @retval EFI_NOT_FOUND The image specified by ImageId is not 111*f439973dSWarner Losh available. Or The specified PackageList is not in the database. 112*f439973dSWarner Losh 113*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER The Image or Langugae was NULL. 114*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES The bitmap could not be retrieved because there was not 115*f439973dSWarner Losh enough memory. 116*f439973dSWarner Losh 117*f439973dSWarner Losh 118*f439973dSWarner Losh **/ 119*f439973dSWarner Losh typedef 120*f439973dSWarner Losh EFI_STATUS 121*f439973dSWarner Losh (EFIAPI *EFI_HII_GET_IMAGE)( 122*f439973dSWarner Losh IN CONST EFI_HII_IMAGE_PROTOCOL *This, 123*f439973dSWarner Losh IN EFI_HII_HANDLE PackageList, 124*f439973dSWarner Losh IN EFI_IMAGE_ID ImageId, 125*f439973dSWarner Losh OUT EFI_IMAGE_INPUT *Image 126*f439973dSWarner Losh ); 127*f439973dSWarner Losh 128*f439973dSWarner Losh /** 129*f439973dSWarner Losh 130*f439973dSWarner Losh This function updates the image specified by ImageId in the 131*f439973dSWarner Losh specified PackageListHandle to the image specified by Image. 132*f439973dSWarner Losh 133*f439973dSWarner Losh 134*f439973dSWarner Losh @param This A pointer to the EFI_HII_IMAGE_PROTOCOL instance. 135*f439973dSWarner Losh 136*f439973dSWarner Losh @param PackageList The package list containing the images. 137*f439973dSWarner Losh 138*f439973dSWarner Losh @param ImageId The image id, which is unique within PackageList. 139*f439973dSWarner Losh 140*f439973dSWarner Losh @param Image Points to the image. 141*f439973dSWarner Losh 142*f439973dSWarner Losh @retval EFI_SUCCESS The image was successfully updated. 143*f439973dSWarner Losh 144*f439973dSWarner Losh @retval EFI_NOT_FOUND The image specified by ImageId is not in the database. 145*f439973dSWarner Losh The specified PackageList is not in the database. 146*f439973dSWarner Losh 147*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER The Image or Language was NULL. 148*f439973dSWarner Losh 149*f439973dSWarner Losh **/ 150*f439973dSWarner Losh typedef 151*f439973dSWarner Losh EFI_STATUS 152*f439973dSWarner Losh (EFIAPI *EFI_HII_SET_IMAGE)( 153*f439973dSWarner Losh IN CONST EFI_HII_IMAGE_PROTOCOL *This, 154*f439973dSWarner Losh IN EFI_HII_HANDLE PackageList, 155*f439973dSWarner Losh IN EFI_IMAGE_ID ImageId, 156*f439973dSWarner Losh IN CONST EFI_IMAGE_INPUT *Image 157*f439973dSWarner Losh ); 158*f439973dSWarner Losh 159*f439973dSWarner Losh /// 160*f439973dSWarner Losh /// EFI_HII_DRAW_FLAGS describes how the image is to be drawn. 161*f439973dSWarner Losh /// These flags are defined as EFI_HII_DRAW_FLAG_*** 162*f439973dSWarner Losh /// 163*f439973dSWarner Losh typedef UINT32 EFI_HII_DRAW_FLAGS; 164*f439973dSWarner Losh 165*f439973dSWarner Losh #define EFI_HII_DRAW_FLAG_CLIP 0x00000001 166*f439973dSWarner Losh #define EFI_HII_DRAW_FLAG_TRANSPARENT 0x00000030 167*f439973dSWarner Losh #define EFI_HII_DRAW_FLAG_DEFAULT 0x00000000 168*f439973dSWarner Losh #define EFI_HII_DRAW_FLAG_FORCE_TRANS 0x00000010 169*f439973dSWarner Losh #define EFI_HII_DRAW_FLAG_FORCE_OPAQUE 0x00000020 170*f439973dSWarner Losh #define EFI_HII_DIRECT_TO_SCREEN 0x00000080 171*f439973dSWarner Losh 172*f439973dSWarner Losh /** 173*f439973dSWarner Losh 174*f439973dSWarner Losh Definition of EFI_IMAGE_OUTPUT. 175*f439973dSWarner Losh 176*f439973dSWarner Losh @param Width Width of the output image. 177*f439973dSWarner Losh 178*f439973dSWarner Losh @param Height Height of the output image. 179*f439973dSWarner Losh 180*f439973dSWarner Losh @param Bitmap Points to the output bitmap. 181*f439973dSWarner Losh 182*f439973dSWarner Losh @param Screen Points to the EFI_GRAPHICS_OUTPUT_PROTOCOL which 183*f439973dSWarner Losh describes the screen on which to draw the 184*f439973dSWarner Losh specified image. 185*f439973dSWarner Losh 186*f439973dSWarner Losh **/ 187*f439973dSWarner Losh typedef struct _EFI_IMAGE_OUTPUT { 188*f439973dSWarner Losh UINT16 Width; 189*f439973dSWarner Losh UINT16 Height; 190*f439973dSWarner Losh union { 191*f439973dSWarner Losh EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Bitmap; 192*f439973dSWarner Losh EFI_GRAPHICS_OUTPUT_PROTOCOL *Screen; 193*f439973dSWarner Losh } Image; 194*f439973dSWarner Losh } EFI_IMAGE_OUTPUT; 195*f439973dSWarner Losh 196*f439973dSWarner Losh /** 197*f439973dSWarner Losh 198*f439973dSWarner Losh This function renders an image to a bitmap or the screen using 199*f439973dSWarner Losh the specified color and options. It draws the image on an 200*f439973dSWarner Losh existing bitmap, allocates a new bitmap or uses the screen. The 201*f439973dSWarner Losh images can be clipped. If EFI_HII_DRAW_FLAG_CLIP is set, then 202*f439973dSWarner Losh all pixels drawn outside the bounding box specified by Width and 203*f439973dSWarner Losh Height are ignored. If EFI_HII_DRAW_FLAG_TRANSPARENT is set, 204*f439973dSWarner Losh then all 'off' pixels in the images drawn will use the 205*f439973dSWarner Losh pixel value from Blt. This flag cannot be used if Blt is NULL 206*f439973dSWarner Losh upon entry. If EFI_HII_DIRECT_TO_SCREEN is set, then the image 207*f439973dSWarner Losh will be written directly to the output device specified by 208*f439973dSWarner Losh Screen. Otherwise the image will be rendered to the bitmap 209*f439973dSWarner Losh specified by Bitmap. 210*f439973dSWarner Losh 211*f439973dSWarner Losh 212*f439973dSWarner Losh @param This A pointer to the EFI_HII_IMAGE_PROTOCOL instance. 213*f439973dSWarner Losh 214*f439973dSWarner Losh @param Flags Describes how the image is to be drawn. 215*f439973dSWarner Losh EFI_HII_DRAW_FLAGS is defined in Related 216*f439973dSWarner Losh Definitions, below. 217*f439973dSWarner Losh 218*f439973dSWarner Losh @param Image Points to the image to be displayed. 219*f439973dSWarner Losh 220*f439973dSWarner Losh @param Blt If this points to a non-NULL on entry, this points 221*f439973dSWarner Losh to the image, which is Width pixels wide and 222*f439973dSWarner Losh Height pixels high. The image will be drawn onto 223*f439973dSWarner Losh this image and EFI_HII_DRAW_FLAG_CLIP is implied. 224*f439973dSWarner Losh If this points to a NULL on entry, then a buffer 225*f439973dSWarner Losh will be allocated to hold the generated image and 226*f439973dSWarner Losh the pointer updated on exit. It is the caller's 227*f439973dSWarner Losh responsibility to free this buffer. 228*f439973dSWarner Losh 229*f439973dSWarner Losh @param BltX, BltY Specifies the offset from the left and top 230*f439973dSWarner Losh edge of the image of the first pixel in 231*f439973dSWarner Losh the image. 232*f439973dSWarner Losh 233*f439973dSWarner Losh @retval EFI_SUCCESS The image was successfully updated. 234*f439973dSWarner Losh 235*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Unable to allocate an output 236*f439973dSWarner Losh buffer for RowInfoArray or Blt. 237*f439973dSWarner Losh 238*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER The Image or Blt or Height or 239*f439973dSWarner Losh Width was NULL. 240*f439973dSWarner Losh 241*f439973dSWarner Losh 242*f439973dSWarner Losh **/ 243*f439973dSWarner Losh typedef 244*f439973dSWarner Losh EFI_STATUS 245*f439973dSWarner Losh (EFIAPI *EFI_HII_DRAW_IMAGE)( 246*f439973dSWarner Losh IN CONST EFI_HII_IMAGE_PROTOCOL *This, 247*f439973dSWarner Losh IN EFI_HII_DRAW_FLAGS Flags, 248*f439973dSWarner Losh IN CONST EFI_IMAGE_INPUT *Image, 249*f439973dSWarner Losh IN OUT EFI_IMAGE_OUTPUT **Blt, 250*f439973dSWarner Losh IN UINTN BltX, 251*f439973dSWarner Losh IN UINTN BltY 252*f439973dSWarner Losh ); 253*f439973dSWarner Losh 254*f439973dSWarner Losh /** 255*f439973dSWarner Losh 256*f439973dSWarner Losh This function renders an image as a bitmap or to the screen and 257*f439973dSWarner Losh can clip the image. The bitmap is either supplied by the caller 258*f439973dSWarner Losh or else is allocated by the function. The images can be drawn 259*f439973dSWarner Losh transparently or opaquely. If EFI_HII_DRAW_FLAG_CLIP is set, 260*f439973dSWarner Losh then all pixels drawn outside the bounding box specified by 261*f439973dSWarner Losh Width and Height are ignored. If EFI_HII_DRAW_FLAG_TRANSPARENT 262*f439973dSWarner Losh is set, then all "off" pixels in the character's glyph will 263*f439973dSWarner Losh use the pixel value from Blt. This flag cannot be used if Blt 264*f439973dSWarner Losh is NULL upon entry. If EFI_HII_DIRECT_TO_SCREEN is set, then 265*f439973dSWarner Losh the image will be written directly to the output device 266*f439973dSWarner Losh specified by Screen. Otherwise the image will be rendered to 267*f439973dSWarner Losh the bitmap specified by Bitmap. 268*f439973dSWarner Losh This function renders an image to a bitmap or the screen using 269*f439973dSWarner Losh the specified color and options. It draws the image on an 270*f439973dSWarner Losh existing bitmap, allocates a new bitmap or uses the screen. The 271*f439973dSWarner Losh images can be clipped. If EFI_HII_DRAW_FLAG_CLIP is set, then 272*f439973dSWarner Losh all pixels drawn outside the bounding box specified by Width and 273*f439973dSWarner Losh Height are ignored. The EFI_HII_DRAW_FLAG_TRANSPARENT flag 274*f439973dSWarner Losh determines whether the image will be drawn transparent or 275*f439973dSWarner Losh opaque. If EFI_HII_DRAW_FLAG_FORCE_TRANS is set, then the image 276*f439973dSWarner Losh will be drawn so that all 'off' pixels in the image will 277*f439973dSWarner Losh be drawn using the pixel value from Blt and all other pixels 278*f439973dSWarner Losh will be copied. If EFI_HII_DRAW_FLAG_FORCE_OPAQUE is set, then 279*f439973dSWarner Losh the image's pixels will be copied directly to the 280*f439973dSWarner Losh destination. If EFI_HII_DRAW_FLAG_DEFAULT is set, then the image 281*f439973dSWarner Losh will be drawn transparently or opaque, depending on the 282*f439973dSWarner Losh image's transparency setting (see EFI_IMAGE_TRANSPARENT). 283*f439973dSWarner Losh Images cannot be drawn transparently if Blt is NULL. If 284*f439973dSWarner Losh EFI_HII_DIRECT_TO_SCREEN is set, then the image will be written 285*f439973dSWarner Losh directly to the output device specified by Screen. Otherwise the 286*f439973dSWarner Losh image will be rendered to the bitmap specified by Bitmap. 287*f439973dSWarner Losh 288*f439973dSWarner Losh @param This A pointer to the EFI_HII_IMAGE_PROTOCOL instance. 289*f439973dSWarner Losh 290*f439973dSWarner Losh @param Flags Describes how the image is to be drawn. 291*f439973dSWarner Losh 292*f439973dSWarner Losh @param PackageList The package list in the HII database to 293*f439973dSWarner Losh search for the specified image. 294*f439973dSWarner Losh 295*f439973dSWarner Losh @param ImageId The image's id, which is unique within PackageList. 296*f439973dSWarner Losh 297*f439973dSWarner Losh @param Blt If this points to a non-NULL on entry, this points 298*f439973dSWarner Losh to the image, which is Width pixels wide and 299*f439973dSWarner Losh Height pixels high. The image will be drawn onto 300*f439973dSWarner Losh this image and EFI_HII_DRAW_FLAG_CLIP is implied. 301*f439973dSWarner Losh If this points to a NULL on entry, then a buffer 302*f439973dSWarner Losh will be allocated to hold the generated image and 303*f439973dSWarner Losh the pointer updated on exit. It is the caller's 304*f439973dSWarner Losh responsibility to free this buffer. 305*f439973dSWarner Losh 306*f439973dSWarner Losh @param BltX, BltY Specifies the offset from the left and top 307*f439973dSWarner Losh edge of the output image of the first 308*f439973dSWarner Losh pixel in the image. 309*f439973dSWarner Losh 310*f439973dSWarner Losh @retval EFI_SUCCESS The image was successfully updated. 311*f439973dSWarner Losh 312*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Unable to allocate an output 313*f439973dSWarner Losh buffer for RowInfoArray or Blt. 314*f439973dSWarner Losh 315*f439973dSWarner Losh @retval EFI_NOT_FOUND The image specified by ImageId is not in the database. 316*f439973dSWarner Losh Or The specified PackageList is not in the database. 317*f439973dSWarner Losh 318*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER The Blt was NULL. 319*f439973dSWarner Losh 320*f439973dSWarner Losh **/ 321*f439973dSWarner Losh typedef 322*f439973dSWarner Losh EFI_STATUS 323*f439973dSWarner Losh (EFIAPI *EFI_HII_DRAW_IMAGE_ID)( 324*f439973dSWarner Losh IN CONST EFI_HII_IMAGE_PROTOCOL *This, 325*f439973dSWarner Losh IN EFI_HII_DRAW_FLAGS Flags, 326*f439973dSWarner Losh IN EFI_HII_HANDLE PackageList, 327*f439973dSWarner Losh IN EFI_IMAGE_ID ImageId, 328*f439973dSWarner Losh IN OUT EFI_IMAGE_OUTPUT **Blt, 329*f439973dSWarner Losh IN UINTN BltX, 330*f439973dSWarner Losh IN UINTN BltY 331*f439973dSWarner Losh ); 332*f439973dSWarner Losh 333*f439973dSWarner Losh /// 334*f439973dSWarner Losh /// Services to access to images in the images database. 335*f439973dSWarner Losh /// 336*f439973dSWarner Losh struct _EFI_HII_IMAGE_PROTOCOL { 337*f439973dSWarner Losh EFI_HII_NEW_IMAGE NewImage; 338*f439973dSWarner Losh EFI_HII_GET_IMAGE GetImage; 339*f439973dSWarner Losh EFI_HII_SET_IMAGE SetImage; 340*f439973dSWarner Losh EFI_HII_DRAW_IMAGE DrawImage; 341*f439973dSWarner Losh EFI_HII_DRAW_IMAGE_ID DrawImageId; 342*f439973dSWarner Losh }; 343*f439973dSWarner Losh 344*f439973dSWarner Losh extern EFI_GUID gEfiHiiImageProtocolGuid; 345*f439973dSWarner Losh 346*f439973dSWarner Losh #endif 347