OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
BlitVideoToBuffer.c
Go to the documentation of this file.
1
10#include "BlitInternal.h"
11
12#include <Library/BaseLib.h>
13#include <Library/BaseMemoryLib.h>
14#include <Library/DebugLib.h>
15
16RETURN_STATUS
18 IN OC_BLIT_CONFIGURE *Configure,
19 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
20 IN UINTN SourceX,
21 IN UINTN SourceY,
22 IN UINTN DestinationX,
23 IN UINTN DestinationY,
24 IN UINTN Width,
25 IN UINTN Height,
26 IN UINTN DeltaPixels
27 )
28{
29 UINT32 *Source;
30 UINT32 *Destination;
31 UINT32 *SourceWalker;
32 UINT32 *DestinationWalker;
33 UINTN IndexX;
34 UINTN WidthInBytes;
35 UINTN PixelsPerScanLine;
36 UINT32 Uint32;
37
38 WidthInBytes = Width * BYTES_PER_PIXEL;
39 PixelsPerScanLine = Configure->PixelsPerScanLine;
40
41 Destination = (UINT32 *)BltBuffer
42 + DestinationY * DeltaPixels + DestinationX;
43 Source = (UINT32 *)Configure->FrameBuffer
44 + SourceY * PixelsPerScanLine + SourceX;
45 if (Configure->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
46 while (Height > 0) {
47 CopyMem (Destination, Source, WidthInBytes);
48 Source += PixelsPerScanLine;
49 Destination += DeltaPixels;
50 Height--;
51 }
52 } else {
53 while (Height > 0) {
54 DestinationWalker = (UINT32 *)Configure->LineBuffer;
55 SourceWalker = (UINT32 *)Source;
56 for (IndexX = 0; IndexX < Width; IndexX++) {
57 Uint32 = *SourceWalker++;
58 *DestinationWalker++ =
59 (UINT32)(
60 (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
61 Configure->PixelMasks.RedMask) |
62 (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
63 Configure->PixelMasks.GreenMask) |
64 (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
65 Configure->PixelMasks.BlueMask)
66 );
67 }
68
69 CopyMem (Destination, Configure->LineBuffer, WidthInBytes);
70 Source += PixelsPerScanLine;
71 Destination += DeltaPixels;
72 Height--;
73 }
74 }
75
76 return EFI_SUCCESS;
77}
78
79RETURN_STATUS
81 IN OC_BLIT_CONFIGURE *Configure,
82 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
83 IN UINTN SourceX,
84 IN UINTN SourceY,
85 IN UINTN DestinationX,
86 IN UINTN DestinationY,
87 IN UINTN Width,
88 IN UINTN Height,
89 IN UINTN DeltaPixels
90 )
91{
92 UINT32 *Source;
93 UINT32 *Destination;
94 UINT32 *SourceWalker;
95 UINT32 *DestinationWalker;
96 UINTN IndexX;
97 UINTN PixelsPerScanLine;
98 UINT32 Uint32;
99
100 PixelsPerScanLine = Configure->PixelsPerScanLine;
101
102 Destination = (UINT32 *)BltBuffer
103 + DestinationY * DeltaPixels + DestinationX;
104 Source = (UINT32 *)Configure->FrameBuffer
105 + (Configure->Width - SourceY - 1);
106
107 if (Configure->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
108 while (Height > 0) {
109 DestinationWalker = Destination;
110 SourceWalker = Source;
111 for (IndexX = SourceX; IndexX < SourceX + Width; IndexX++) {
112 *DestinationWalker++ = SourceWalker[IndexX * PixelsPerScanLine];
113 }
114
115 Source--;
116 Destination += DeltaPixels;
117 Height--;
118 }
119 } else {
120 while (Height > 0) {
121 DestinationWalker = Destination;
122 SourceWalker = Source;
123 for (IndexX = SourceX; IndexX < SourceX + Width; IndexX++) {
124 Uint32 = SourceWalker[IndexX * PixelsPerScanLine];
125 *DestinationWalker++ =
126 (UINT32)(
127 (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
128 Configure->PixelMasks.RedMask) |
129 (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
130 Configure->PixelMasks.GreenMask) |
131 (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
132 Configure->PixelMasks.BlueMask)
133 );
134 }
135
136 Source--;
137 Destination += DeltaPixels;
138 Height--;
139 }
140 }
141
142 return EFI_SUCCESS;
143}
144
145RETURN_STATUS
147 IN OC_BLIT_CONFIGURE *Configure,
148 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
149 IN UINTN SourceX,
150 IN UINTN SourceY,
151 IN UINTN DestinationX,
152 IN UINTN DestinationY,
153 IN UINTN Width,
154 IN UINTN Height,
155 IN UINTN DeltaPixels
156 )
157{
158 UINT32 *Source;
159 UINT32 *Destination;
160 UINT32 *SourceWalker;
161 UINT32 *DestinationWalker;
162 UINTN IndexX;
163 UINTN PixelsPerScanLine;
164 UINT32 Uint32;
165
166 PixelsPerScanLine = Configure->PixelsPerScanLine;
167
168 SourceX = Configure->Width - SourceX - Width;
169 SourceY = Configure->Height - SourceY - Height;
170
171 Destination = (UINT32 *)BltBuffer
172 + DestinationY * DeltaPixels + DestinationX;
173 Source = (UINT32 *)Configure->FrameBuffer
174 + (SourceY + (Height - 1)) * PixelsPerScanLine + SourceX;
175
176 if (Configure->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
177 while (Height > 0) {
178 DestinationWalker = Destination;
179 SourceWalker = Source + (Width - 1);
180 for (IndexX = 0; IndexX < Width; IndexX++) {
181 *DestinationWalker++ = *SourceWalker--;
182 }
183
184 Source -= PixelsPerScanLine;
185 Destination += DeltaPixels;
186 Height--;
187 }
188 } else {
189 while (Height > 0) {
190 DestinationWalker = Destination;
191 SourceWalker = Source + (Width - 1);
192 for (IndexX = 0; IndexX < Width; IndexX++) {
193 Uint32 = *SourceWalker--;
194 *DestinationWalker++ =
195 (UINT32)(
196 (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
197 Configure->PixelMasks.RedMask) |
198 (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
199 Configure->PixelMasks.GreenMask) |
200 (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
201 Configure->PixelMasks.BlueMask)
202 );
203 }
204
205 Source -= PixelsPerScanLine;
206 Destination += DeltaPixels;
207 Height--;
208 }
209 }
210
211 return EFI_SUCCESS;
212}
213
214RETURN_STATUS
216 IN OC_BLIT_CONFIGURE *Configure,
217 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
218 IN UINTN SourceX,
219 IN UINTN SourceY,
220 IN UINTN DestinationX,
221 IN UINTN DestinationY,
222 IN UINTN Width,
223 IN UINTN Height,
224 IN UINTN DeltaPixels
225 )
226{
227 UINT32 *Source;
228 UINT32 *Destination;
229 UINT32 *SourceWalker;
230 UINT32 *DestinationWalker;
231 UINTN IndexX;
232 UINTN LastX;
233 UINTN PixelsPerScanLine;
234 UINT32 Uint32;
235
236 PixelsPerScanLine = Configure->PixelsPerScanLine;
237
238 Destination = (UINT32 *)BltBuffer
239 + DestinationY * DeltaPixels + DestinationX;
240 Source = (UINT32 *)Configure->FrameBuffer
241 + SourceY;
242
243 if (Configure->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
244 while (Height > 0) {
245 DestinationWalker = Destination;
246 SourceWalker = Source;
247 LastX = Configure->Height - SourceX - 1;
248 for (IndexX = 0; IndexX < Width; IndexX++) {
249 *DestinationWalker++ = SourceWalker[(LastX - IndexX) * PixelsPerScanLine];
250 }
251
252 Source++;
253 Destination += DeltaPixels;
254 Height--;
255 }
256 } else {
257 while (Height > 0) {
258 DestinationWalker = Destination;
259 SourceWalker = Source;
260 LastX = Configure->Height - SourceX - 1;
261 for (IndexX = 0; IndexX < Width; IndexX++) {
262 Uint32 = SourceWalker[(LastX - IndexX) * PixelsPerScanLine];
263 *DestinationWalker++ =
264 (UINT32)(
265 (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
266 Configure->PixelMasks.RedMask) |
267 (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
268 Configure->PixelMasks.GreenMask) |
269 (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
270 Configure->PixelMasks.BlueMask)
271 );
272 }
273
274 Source++;
275 Destination += DeltaPixels;
276 Height--;
277 }
278 }
279
280 return EFI_SUCCESS;
281}
RETURN_STATUS BlitLibVideoToBuffer90(IN OC_BLIT_CONFIGURE *Configure, OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN DeltaPixels)
RETURN_STATUS BlitLibVideoToBuffer270(IN OC_BLIT_CONFIGURE *Configure, OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN DeltaPixels)
RETURN_STATUS BlitLibVideoToBuffer0(IN OC_BLIT_CONFIGURE *Configure, OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN DeltaPixels)
RETURN_STATUS BlitLibVideoToBuffer180(IN OC_BLIT_CONFIGURE *Configure, OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN DeltaPixels)
#define BYTES_PER_PIXEL
Definition OcBlitLib.h:20
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)