FrameBufferBltLib.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/** @file
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe FrameBufferBltLib - Library to perform blt operations on a frame buffer.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe This program and the accompanying materials
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov are licensed and made available under the terms and conditions of the BSD License
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe which accompanies this distribution. The full text of the license may be found at
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe http://opensource.org/licenses/bsd-license.php
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include "PiDxe.h"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <Library/BaseLib.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <Library/BaseMemoryLib.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <Library/BltLib.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <Library/DebugLib.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#if 0
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#define VDEBUG DEBUG
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#else
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#define VDEBUG(x)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#endif
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#define MAX_LINE_BUFFER_SIZE (SIZE_4KB * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweUINTN mBltLibColorDepth;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweUINTN mBltLibWidthInBytes;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweUINTN mBltLibBytesPerPixel;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweUINTN mBltLibWidthInPixels;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweUINTN mBltLibHeight;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweUINT8 mBltLibLineBuffer[MAX_LINE_BUFFER_SIZE];
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweUINT8 *mBltLibFrameBuffer;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_GRAPHICS_PIXEL_FORMAT mPixelFormat;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_PIXEL_BITMASK mPixelBitMasks;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweINTN mPixelShl[4]; // R-G-B-Rsvd
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweINTN mPixelShr[4]; // R-G-B-Rsvd
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweVOID
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweConfigurePixelBitMaskFormat (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN EFI_PIXEL_BITMASK *BitMask
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN Loop;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINT32 *Masks;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINT32 MergedMasks;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe MergedMasks = 0;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Masks = (UINT32*) BitMask;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (Loop = 0; Loop < 3; Loop++) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ASSERT ((Loop == 3) || (Masks[Loop] != 0));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ASSERT ((MergedMasks & Masks[Loop]) == 0);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mPixelShl[Loop] = HighBitSet32 (Masks[Loop]) - 23 + (Loop * 8);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (mPixelShl[Loop] < 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mPixelShr[Loop] = -mPixelShl[Loop];
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mPixelShl[Loop] = 0;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe } else {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mPixelShr[Loop] = 0;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe MergedMasks = (UINT32) (MergedMasks | Masks[Loop]);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DEBUG ((EFI_D_INFO, "%d: shl:%d shr:%d mask:%x\n", Loop, mPixelShl[Loop], mPixelShr[Loop], Masks[Loop]));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe MergedMasks = (UINT32) (MergedMasks | Masks[3]);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ASSERT (MergedMasks != 0);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mBltLibBytesPerPixel = (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DEBUG ((EFI_D_INFO, "Bytes per pixel: %d\n", mBltLibBytesPerPixel));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe CopyMem (&mPixelBitMasks, BitMask, sizeof (*BitMask));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/**
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Configure the FrameBufferLib instance
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] FrameBuffer Pointer to the start of the frame buffer
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] FrameBufferInfo Describes the frame buffer characteristics
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_INVALID_PARAMETER - Invalid parameter
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_UNSUPPORTED - The BltLib does not support this configuration
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_SUCCESS - Blt operation success
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_STATUS
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFIAPI
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweBltLibConfigure (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN VOID *FrameBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe STATIC EFI_PIXEL_BITMASK RgbPixelMasks =
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe { 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe STATIC EFI_PIXEL_BITMASK BgrPixelMasks =
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe switch (FrameBufferInfo->PixelFormat) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe case PixelRedGreenBlueReserved8BitPerColor:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ConfigurePixelBitMaskFormat (&RgbPixelMasks);
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov break;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe case PixelBlueGreenRedReserved8BitPerColor:
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov ConfigurePixelBitMaskFormat (&BgrPixelMasks);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe break;
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov case PixelBitMask:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ConfigurePixelBitMaskFormat (&(FrameBufferInfo->PixelInformation));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe break;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe case PixelBltOnly:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ASSERT (FrameBufferInfo->PixelFormat != PixelBltOnly);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_UNSUPPORTED;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe default:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ASSERT (FALSE);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mPixelFormat = FrameBufferInfo->PixelFormat;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mBltLibFrameBuffer = (UINT8*) FrameBuffer;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mBltLibWidthInPixels = (UINTN) FrameBufferInfo->HorizontalResolution;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mBltLibHeight = (UINTN) FrameBufferInfo->VerticalResolution;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mBltLibWidthInBytes = mBltLibWidthInPixels * mBltLibBytesPerPixel;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ASSERT (mBltLibWidthInBytes < sizeof (mBltLibLineBuffer));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_SUCCESS;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/**
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Performs a UEFI Graphics Output Protocol Blt operation.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in,out] BltBuffer - The data to transfer to screen
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] BltOperation - The operation to perform
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceX - The X coordinate of the source for BltOperation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceY - The Y coordinate of the source for BltOperation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationX - The X coordinate of the destination for BltOperation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationY - The Y coordinate of the destination for BltOperation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Width - The width of a rectangle in the blt rectangle in pixels
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Height - The height of a rectangle in the blt rectangle in pixels
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe If a Delta of 0 is used, the entire BltBuffer will be operated on.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe If a subrectangle of the BltBuffer is used, then Delta represents
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe the number of bytes in a row of the BltBuffer.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_DEVICE_ERROR - A hardware error occured
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_SUCCESS - Blt operation success
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_STATUS
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFIAPI
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweBltLibGopBlt (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceX,
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov IN UINTN SourceY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Height,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Delta
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe switch (BltOperation) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe case EfiBltVideoToBltBuffer:
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov return BltLibVideoToBltBufferEx (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SourceX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SourceY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Height,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Delta
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe case EfiBltVideoToVideo:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return BltLibVideoToVideo (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SourceX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SourceY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe case EfiBltVideoFill:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return BltLibVideoFill (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe case EfiBltBufferToVideo:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return BltLibBufferToVideoEx (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SourceX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SourceY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Height,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Delta
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe default:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/**
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Performs a UEFI Graphics Output Protocol Blt Video Fill.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Color Color to fill the region with
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationX X location to start fill operation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationY Y location to start fill operation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Width Width (in pixels) to fill
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Height Height to fill
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_DEVICE_ERROR - A hardware error occured
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_SUCCESS - The sizes were returned
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_STATUS
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFIAPI
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweBltLibVideoFill (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN DstY;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VOID *BltMemSrc;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VOID *BltMemDst;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN X;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINT8 Uint8;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINT32 Uint32;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINT64 WideFill;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BOOLEAN UseWideFill;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BOOLEAN LineBufferReady;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN Offset;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN WidthInBytes;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN SizeInBytes;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // BltBuffer to Video: Source is BltBuffer, destination is Video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DestinationY + Height > mBltLibHeight) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DEBUG ((EFI_D_INFO, "VideoFill: Past screen (Y)\n"));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DestinationX + Width > mBltLibWidthInPixels) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DEBUG ((EFI_D_INFO, "VideoFill: Past screen (X)\n"));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (Width == 0 || Height == 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DEBUG ((EFI_D_INFO, "VideoFill: Width or Height is 0\n"));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe WidthInBytes = Width * mBltLibBytesPerPixel;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Uint32 = *(UINT32*) Color;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe WideFill =
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (UINT32) (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (((Uint32 << mPixelShl[0]) >> mPixelShr[0]) & mPixelBitMasks.RedMask) |
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (((Uint32 << mPixelShl[1]) >> mPixelShr[1]) & mPixelBitMasks.GreenMask) |
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (((Uint32 << mPixelShl[2]) >> mPixelShr[2]) & mPixelBitMasks.BlueMask)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VDEBUG ((EFI_D_INFO, "VideoFill: color=0x%x, wide-fill=0x%x\n", Uint32, WideFill));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // If the size of the pixel data evenly divides the sizeof
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // WideFill, then a wide fill operation can be used
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UseWideFill = TRUE;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if ((sizeof (WideFill) % mBltLibBytesPerPixel) == 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (X = mBltLibBytesPerPixel; X < sizeof (WideFill); X++) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ((UINT8*)&WideFill)[X] = ((UINT8*)&WideFill)[X % mBltLibBytesPerPixel];
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov } else {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // If all the bytes in the pixel are the same value, then use
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // a wide fill operation.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe X = 1, Uint8 = ((UINT8*)&WideFill)[0];
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe X < mBltLibBytesPerPixel;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe X++) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (Uint8 != ((UINT8*)&WideFill)[X]) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UseWideFill = FALSE;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe break;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (UseWideFill) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SetMem ((VOID*) &WideFill, sizeof (WideFill), Uint8);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (UseWideFill && (DestinationX == 0) && (Width == mBltLibWidthInPixels)) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VDEBUG ((EFI_D_INFO, "VideoFill (wide, one-shot)\n"));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Offset = DestinationY * mBltLibWidthInPixels;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Offset = mBltLibBytesPerPixel * Offset;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemDst = (VOID*) (mBltLibFrameBuffer + Offset);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SizeInBytes = WidthInBytes * Height;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (SizeInBytes >= 8) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SetMem32 (BltMemDst, SizeInBytes & ~3, (UINT32) WideFill);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SizeInBytes = SizeInBytes & 3;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (SizeInBytes > 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SetMem (BltMemDst, SizeInBytes, (UINT8)(UINTN) WideFill);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe } else {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe LineBufferReady = FALSE;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Offset = (DstY * mBltLibWidthInPixels) + DestinationX;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Offset = mBltLibBytesPerPixel * Offset;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemDst = (VOID*) (mBltLibFrameBuffer + Offset);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (UseWideFill && (((UINTN) BltMemDst & 7) == 0)) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VDEBUG ((EFI_D_INFO, "VideoFill (wide)\n"));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SizeInBytes = WidthInBytes;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (SizeInBytes >= 8) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SetMem64 (BltMemDst, SizeInBytes & ~7, WideFill);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SizeInBytes = SizeInBytes & 7;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (SizeInBytes > 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe CopyMem (BltMemDst, (VOID*) &WideFill, SizeInBytes);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe } else {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VDEBUG ((EFI_D_INFO, "VideoFill (not wide)\n"));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (!LineBufferReady) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe CopyMem (mBltLibLineBuffer, &WideFill, mBltLibBytesPerPixel);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (X = 1; X < Width; ) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe CopyMem(
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (mBltLibLineBuffer + (X * mBltLibBytesPerPixel)),
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe mBltLibLineBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe MIN (X, Width - X) * mBltLibBytesPerPixel
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe X = X + MIN (X, Width - X);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemSrc = (VOID *) mBltLibLineBuffer;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe LineBufferReady = TRUE;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe CopyMem (BltMemDst, mBltLibLineBuffer, WidthInBytes);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_SUCCESS;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/**
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[out] BltBuffer Output buffer for pixel color data
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceX X location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceY Y location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Width Width (in pixels)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Height Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_DEVICE_ERROR - A hardware error occured
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_SUCCESS - The sizes were returned
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_STATUS
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFIAPI
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweBltLibVideoToBltBuffer (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return BltLibVideoToBltBufferEx (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SourceX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe SourceY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe 0,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe 0,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Height,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe 0
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/**
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe with extended parameters.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[out] BltBuffer Output buffer for pixel color data
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceX X location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceY Y location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationX X location within BltBuffer
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationY Y location within BltBuffer
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Width Width (in pixels)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Height Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Delta Number of bytes in a row of BltBuffer
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov @retval EFI_DEVICE_ERROR - A hardware error occured
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_SUCCESS - The sizes were returned
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri PankovEFI_STATUS
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri PankovEFIAPI
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri PankovBltLibVideoToBltBufferEx (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Height,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Delta
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN DstY;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN SrcY;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VOID *BltMemSrc;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VOID *BltMemDst;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN X;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINT32 Uint32;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN Offset;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN WidthInBytes;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // Video to BltBuffer: Source is Video, destination is BltBuffer
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (SourceY + Height > mBltLibHeight) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (SourceX + Width > mBltLibWidthInPixels) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (Width == 0 || Height == 0) {
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // If Delta is zero, then the entire BltBuffer is being used, so Delta
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // the number of bytes in each row can be computed.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (Delta == 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe WidthInBytes = Width * mBltLibBytesPerPixel;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // Video to BltBuffer: Source is Video, destination is BltBuffer
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); SrcY++, DstY++) {
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Offset = (SrcY * mBltLibWidthInPixels) + SourceX;
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov Offset = mBltLibBytesPerPixel * Offset;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemSrc = (VOID *) (mBltLibFrameBuffer + Offset);
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (mPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemDst =
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (VOID *) (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (UINT8 *) BltBuffer +
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (DstY * Delta) +
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe } else {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemDst = (VOID *) mBltLibLineBuffer;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe CopyMem (BltMemDst, BltMemSrc, WidthInBytes);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (mPixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (X = 0; X < Width; X++) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX + X) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Uint32 = *(UINT32*) (mBltLibLineBuffer + (X * mBltLibBytesPerPixel));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *(UINT32*) Blt =
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (UINT32) (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (((Uint32 & mPixelBitMasks.RedMask) >> mPixelShl[0]) << mPixelShr[0]) |
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (((Uint32 & mPixelBitMasks.GreenMask) >> mPixelShl[1]) << mPixelShr[1]) |
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov (((Uint32 & mPixelBitMasks.BlueMask) >> mPixelShl[2]) << mPixelShr[2])
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov return EFI_SUCCESS;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/**
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] BltBuffer Output buffer for pixel color data
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationX X location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationY Y location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Width Width (in pixels)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Height Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_DEVICE_ERROR - A hardware error occured
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_SUCCESS - The sizes were returned
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_STATUS
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFIAPI
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweBltLibBufferToVideo (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return BltLibBufferToVideoEx (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe 0,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe 0,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Height,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe 0
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/**
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe with extended parameters.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] BltBuffer Output buffer for pixel color data
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceX X location within BltBuffer
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceY Y location within BltBuffer
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationX X location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationY Y location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Width Width (in pixels)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Height Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Delta Number of bytes in a row of BltBuffer
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_DEVICE_ERROR - A hardware error occured
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_SUCCESS - The sizes were returned
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_STATUS
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFIAPI
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweBltLibBufferToVideoEx (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceY,
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov IN UINTN DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationY,
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov IN UINTN Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Height,
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov IN UINTN Delta
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN DstY;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN SrcY;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VOID *BltMemSrc;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VOID *BltMemDst;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN X;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINT32 Uint32;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN Offset;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN WidthInBytes;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // BltBuffer to Video: Source is BltBuffer, destination is Video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DestinationY + Height > mBltLibHeight) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DestinationX + Width > mBltLibWidthInPixels) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (Width == 0 || Height == 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // If Delta is zero, then the entire BltBuffer is being used, so Delta
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe // the number of bytes in each row can be computed.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (Delta == 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe WidthInBytes = Width * mBltLibBytesPerPixel;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Offset = (DstY * mBltLibWidthInPixels) + DestinationX;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Offset = mBltLibBytesPerPixel * Offset;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemDst = (VOID*) (mBltLibFrameBuffer + Offset);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (mPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemSrc = (VOID *) ((UINT8 *) BltBuffer + (SrcY * Delta));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe } else {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (X = 0; X < Width; X++) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Blt =
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (UINT8 *) BltBuffer +
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (SrcY * Delta) +
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe ((SourceX + X) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Uint32 = *(UINT32*) Blt;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *(UINT32*) (mBltLibLineBuffer + (X * mBltLibBytesPerPixel)) =
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (UINT32) (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (((Uint32 << mPixelShl[0]) >> mPixelShr[0]) & mPixelBitMasks.RedMask) |
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (((Uint32 << mPixelShl[1]) >> mPixelShr[1]) & mPixelBitMasks.GreenMask) |
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (((Uint32 << mPixelShl[2]) >> mPixelShr[2]) & mPixelBitMasks.BlueMask)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe );
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe BltMemSrc = (VOID *) mBltLibLineBuffer;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe CopyMem (BltMemDst, BltMemSrc, WidthInBytes);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_SUCCESS;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/**
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe Performs a UEFI Graphics Output Protocol Blt Video to Video operation
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceX X location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] SourceY Y location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationX X location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] DestinationY Y location within video
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Width Width (in pixels)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @param[in] Height Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_DEVICE_ERROR - A hardware error occured
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe @retval EFI_SUCCESS - The sizes were returned
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe**/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFI_STATUS
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweEFIAPI
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweBltLibVideoToVideo (
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN SourceY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationX,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN DestinationY,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Width,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe IN UINTN Height
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe )
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VOID *BltMemSrc;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe VOID *BltMemDst;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN Offset;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe UINTN WidthInBytes;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe INTN LineStride;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe //
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov // Video to Video: Source is Video, destination is Video
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov //
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov if (SourceY + Height > mBltLibHeight) {
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (SourceX + Width > mBltLibWidthInPixels) {
ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2abYuri Pankov return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DestinationY + Height > mBltLibHeight) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (DestinationX + Width > mBltLibWidthInPixels) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (Width == 0 || Height == 0) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return EFI_INVALID_PARAMETER;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe }
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe WidthInBytes = Width * mBltLibBytesPerPixel;
Offset = (SourceY * mBltLibWidthInPixels) + SourceX;
Offset = mBltLibBytesPerPixel * Offset;
BltMemSrc = (VOID *) (mBltLibFrameBuffer + Offset);
Offset = (DestinationY * mBltLibWidthInPixels) + DestinationX;
Offset = mBltLibBytesPerPixel * Offset;
BltMemDst = (VOID *) (mBltLibFrameBuffer + Offset);
LineStride = mBltLibWidthInBytes;
if ((UINTN) BltMemDst > (UINTN) BltMemSrc) {
LineStride = -LineStride;
}
while (Height > 0) {
CopyMem (BltMemDst, BltMemSrc, WidthInBytes);
BltMemSrc = (VOID*) ((UINT8*) BltMemSrc + LineStride);
BltMemDst = (VOID*) ((UINT8*) BltMemDst + LineStride);
Height--;
}
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;
}