ReactOS 0.4.17-dev-1343-g8fe3cee
common.c File Reference
#include "precomp.h"
Include dependency graph for common.c:

Go to the source code of this file.

Functions

static VOID BitBlt (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
 
static VOID RleBitBlt (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ PUCHAR Buffer)
 
VOID NTAPI VidBufferToScreenBlt (_In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ ULONG Stride)
 
VOID NTAPI VidBitBlt (_In_ PUCHAR Buffer, _In_ ULONG Left, _In_ ULONG Top)
 

Variables

const RGBQUAD VidpDefaultPalette [BV_MAX_COLORS]
 

Function Documentation

◆ BitBlt()

static VOID BitBlt ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Width,
_In_ ULONG  Height,
_In_reads_bytes_(Height *Stride) PUCHAR  Buffer,
_In_ ULONG  BitsPerPixel,
_In_ ULONG  Stride 
)
static

Definition at line 42 of file common.c.

50{
51 ULONG X, Y;
53 const ULONG Bottom = Top + Height;
54 const ULONG Right = Left + Width;
55
56 if ((Width == 0) || (Height == 0))
57 return;
58
59 if (BitsPerPixel != 4)
60 {
61 /* FIXME: TODO */
62#if DBG
63 DbgPrint("Unhandled BitBlt\n"
64 "%lux%lu @ (%lu|%lu)\n"
65 "Bits Per Pixel %lu\n"
66 "Buffer: %p. Stride: %lu\n",
67 Width,
68 Height,
69 Left,
70 Top,
71 BitsPerPixel,
72 Buffer,
73 Stride);
74#endif
75 return;
76 }
77
79
80 /* 4bpp blitting */
81 for (Y = Top; Y < Bottom; ++Y)
82 {
83 ULONG PxlToggle = 0;
84 UCHAR Colors = 0, Color;
85
87
88 for (X = Left; X < Right; ++X)
89 {
90 if ((PxlToggle ^= 1))
91 {
92 /* Extract colors at every two pixels */
94 Color = Colors >> 4;
95 }
96 else
97 {
98 Color = Colors & 0x0F;
99 }
100 SetPixel(X, Y, Color);
101 }
102
103 Buffer += Stride;
104 }
105}
Colors
Definition: ansiprsr.h:4
VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: bootvid.c:52
#define PrepareForSetPixel()
Definition: arm.h:21
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53
Definition: bufpool.h:45
_Check_return_ _In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS _Out_ UINT _Out_ UINT * Height
Definition: dispmprt.h:1445
_Check_return_ _In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS _Out_ UINT * Width
Definition: dispmprt.h:1444
#define Y(I)
#define DbgPrint
Definition: hal.h:12
#define X(b, s)
unsigned char UCHAR
Definition: typedefs.h:53
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

Referenced by CMenuDeskBar::_OnPaint(), AboutDlgProc(), add_ruler_units(), alpha_blend_image(), ANIMATE_PaintFrame(), ANIMATE_TransparentBlt(), BitBltFromClipboard(), CDimmedWindow::Blt(), BltCard(), C1_DrawLabel(), C1_InvertButton(), C1_OnDraw(), CDimmedWindow::Capture(), CaptureScreen(), CardBlt(), CC_PaintColorGraph(), CC_PaintCross(), check_BitBlt_pixel(), check_bits(), cicChangeBitmapColor(), cicConvertBlackBKGBitmap(), cicCreateDisabledBitmap(), cicCreateMaskBmp(), cicCreateShadowMaskBmp(), cicDrawMaskBmpOnDC(), cicMirrorBitmap(), ClippedBitBlt(), ClockWndProc(), ColorKeyedMaskBlt(), COMCTL32_EnsureBitmapSize(), ConvertBitmapTo32Bpp(), CCicLibMenuItem::CreateBitmap(), CreateMDIMenuBitmap(), CreateStarBitmap(), d2d_dc_render_target_present(), ddraw_surface_update_frontbuffer(), device_load_logo(), RdpClientUI::Display_DrawGlyph(), RdpClientUI::Display_MemBlt(), RdpClientUI::Display_ScreenBlt(), RdpClientUI::Display_TriBlt(), RdpClientUI::DisplayWindowProc(), DoBlt(), CCanvasWindow::DoDraw(), Draw(), draw_graphics(), DrawBrandingBitmap(), DrawCard(), DrawFace(), DrawGlyph(), DrawHorzCardStrip(), DrawIconOnOwnerDrawnButtons(), CUIFButton::DrawIconProc(), DrawLeds(), DrawMine(), DrawProc(), DrawScrollingBrandingBitmap(), DrawTileBitmap(), DrawVertCardStrip(), dup_bitmap(), EndBufferedPaint(), GeneralPageProc(), get_bitmap_info(), GetDiaogTextureBrush(), getSubImage(), Ghost_OnDraw(), GraphCtrl_AddPoint(), GraphCtrl_WndProc(), HEADER_DrawItem(), HelDdSurfBlt(), HelDdSurfLock(), HelDdSurfUnlock(), HEXEDIT_WM_PAINT(), HLPFILE_RtfAddTransparentBitmap(), ImageList_Add(), ImageList_AddMasked(), ImageList_BeginDrag(), ImageList_Copy(), imagelist_copy_images(), ImageList_DragMove(), ImageList_DragShowNolock(), ImageList_DrawIndirect(), ImageList_Duplicate(), ImageList_GetIcon(), IMAGELIST_InternalExpandBitmaps(), ImageList_Merge(), ImageList_Replace(), ImageList_ReplaceIcon(), Imm32DrawBitmap(), IntDrawState(), IntGetWindowBitmap(), IntGrayString(), LISTVIEW_Refresh(), LoadCardBitmapsFromLibrary(), MainWndProc(), mi_paint_rect(), CardRegion::MoveDragCardTo(), mstsc_WndProc(), NT5_DrawBaseBackground(), NT5_DrawLogoffIcon(), OLEPictureImpl_LoadWICSource(), CMainWindow::OnCommand(), OnDrawItem(), OnPaint(), CFullscreenWindow::OnPaint(), CMiniatureWindow::OnPaint(), CPaletteWindow::OnPaint(), CDownloaderProgress::OnPaint(), CBrandBand::OnPaint(), PaintBanner(), CardWindow::PaintCardRgn(), PaintCells(), PAINTING_DrawStateJam(), CAppScrnshotPreview::PaintOnDC(), PlayEnhMetaFileRecord(), PlayMetaFileRecord(), ProgressDlg::ProcessWindowMessage(), PROPSHEET_Paint(), putSubImage(), RosImageProc(), Run(), ScreenSaverProc(), serializeBMP(), show_image(), SIC_OverlayShortcutImage(), SkewDIB(), START_TEST(), StatusMessageWindowProc(), swapchain_gdi_frontbuffer_updated(), T1_DrawLabels(), T1_OnDraw(), test_32bit_ddb(), test_bitmap_colors(), test_clipping(), Test_CreateDIBitmap_CBM_CREATDIB(), test_D3DKMTCreateDCFromMemory(), test_dibsections(), test_emf_AlphaBlend(), test_emf_BitBlt(), test_emf_blit(), test_mf_blit(), test_printer_dc(), Test_Rectangle(), Test_SrcMono1(), ThemeEndBufferedPaint(), TOOLBAR_DrawMasked(), TRACKBAR_Refresh(), UXTHEME_SizedBlt(), VidBitBlt(), VidBufferToScreenBlt(), WinGBitBlt(), WndProc(), and ZoomWnd_OnDraw().

◆ RleBitBlt()

static VOID RleBitBlt ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Width,
_In_ ULONG  Height,
_In_ PUCHAR  Buffer 
)
static

Definition at line 108 of file common.c.

114{
115 ULONG YDelta;
116 ULONG x;
117 ULONG RleValue, NewRleValue;
118 ULONG Color, Color2;
119 ULONG i, j;
120 ULONG Code;
121
122 if ((Width == 0) || (Height == 0))
123 return;
124
126
127 /* Set Y height and current X value and start loop */
128 YDelta = Top + Height - 1;
129 x = Left;
130 for (;;)
131 {
132 /* Get the current value and advance in the buffer */
133 RleValue = *Buffer;
134 Buffer++;
135 if (RleValue)
136 {
137 /* Check if we've gone past the edge */
138 if ((x + RleValue) > (Width + Left))
139 {
140 /* Fixup the pixel value */
141 RleValue = Left - x + Width;
142 }
143
144 /* Get the new value */
145 NewRleValue = *Buffer;
146
147 /* Get the two colors */
148 Color = NewRleValue >> 4;
149 Color2 = NewRleValue & 0xF;
150
151 /* Increase buffer position */
152 Buffer++;
153
154 /* Check if we need to do a fill */
155 if (Color == Color2)
156 {
157 /* Do a fill and continue the loop */
158 RleValue += x;
159 VidSolidColorFill(x, YDelta, RleValue - 1, YDelta, (UCHAR)Color);
160 x = RleValue;
161 continue;
162 }
163
164 /* Check if the pixel value is 1 or below */
165 if (RleValue > 1)
166 {
167 /* Set loop variables */
168 for (i = (RleValue - 2) / 2 + 1; i > 0; --i)
169 {
170 /* Set the pixels */
171 SetPixel(x, YDelta, (UCHAR)Color);
172 x++;
173 SetPixel(x, YDelta, (UCHAR)Color2);
174 x++;
175
176 /* Decrease pixel value */
177 RleValue -= 2;
178 }
179 }
180
181 /* Check if there is any value at all */
182 if (RleValue)
183 {
184 /* Set the pixel and increase position */
185 SetPixel(x, YDelta, (UCHAR)Color);
186 x++;
187 }
188
189 /* Start over */
190 continue;
191 }
192
193 /* Get the current pixel value */
194 RleValue = *Buffer;
195 Code = RleValue;
196 switch (Code)
197 {
198 /* Case 0 */
199 case 0:
200 {
201 /* Set new x value, decrease distance and restart */
202 x = Left;
203 YDelta--;
204 Buffer++;
205 continue;
206 }
207
208 /* Case 1 */
209 case 1:
210 {
211 /* Done */
212 return;
213 }
214
215 /* Case 2 */
216 case 2:
217 {
218 /* Set new x value, decrease distance and restart */
219 Buffer++;
220 x += *Buffer;
221 Buffer++;
222 YDelta -= *Buffer;
223 Buffer++;
224 continue;
225 }
226
227 /* Other values */
228 default:
229 {
230 Buffer++;
231 break;
232 }
233 }
234
235 /* Check if we've gone past the edge */
236 if ((x + RleValue) > (Width + Left))
237 {
238 /* Set fixed up loop count */
239 i = RleValue - Left - Width + x;
240
241 /* Fixup pixel value */
242 RleValue -= i;
243 }
244 else
245 {
246 /* Clear loop count */
247 i = 0;
248 }
249
250 /* Check the value now */
251 if (RleValue > 1)
252 {
253 /* Set loop variables */
254 for (j = (RleValue - 2) / 2 + 1; j > 0; --j)
255 {
256 /* Get the new value */
257 NewRleValue = *Buffer;
258
259 /* Get the two colors */
260 Color = NewRleValue >> 4;
261 Color2 = NewRleValue & 0xF;
262
263 /* Increase buffer position */
264 Buffer++;
265
266 /* Set the pixels */
267 SetPixel(x, YDelta, (UCHAR)Color);
268 x++;
269 SetPixel(x, YDelta, (UCHAR)Color2);
270 x++;
271
272 /* Decrease pixel value */
273 RleValue -= 2;
274 }
275 }
276
277 /* Check if there is any value at all */
278 if (RleValue)
279 {
280 /* Set the pixel and increase position */
281 Color = *Buffer >> 4;
282 Buffer++;
283 SetPixel(x, YDelta, (UCHAR)Color);
284 x++;
285 i--;
286 }
287
288 /* Check loop count now */
289 if ((LONG)i > 0)
290 {
291 /* Decrease it */
292 i--;
293
294 /* Set new position */
295 Buffer = Buffer + (i / 2) + 1;
296 }
297
298 /* Check if we need to increase the buffer */
299 if ((ULONG_PTR)Buffer & 1) Buffer++;
300 }
301}
VOID NTAPI VidSolidColorFill(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR Color)
Definition: bootvid.c:298
#define Code
Definition: deflate.h:80
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
long LONG
Definition: pedump.c:60
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1707

Referenced by VidBitBlt().

◆ VidBitBlt()

VOID NTAPI VidBitBlt ( _In_ PUCHAR  Buffer,
_In_ ULONG  Left,
_In_ ULONG  Top 
)

Definition at line 321 of file common.c.

325{
327 LONG Stride;
328 PUCHAR BitmapOffset;
329 ULONG PaletteCount;
330
331 /* Get the Bitmap Header */
333
334 /* Initialize the palette */
335 PaletteCount = BitmapInfoHeader->biClrUsed ?
338 PaletteCount);
339
340 /* Make sure we can support this bitmap */
342
343 /*
344 * Calculate the stride and align it on 32-bytes, then calculate
345 * the actual start of the bitmap data.
346 */
348 Stride >>= 3;
349 Stride &= ~3;
350 BitmapOffset = Buffer + sizeof(BITMAPINFOHEADER) + PaletteCount * sizeof(ULONG);
351
352 /* Check the compression of the bitmap */
354 {
355 RleBitBlt(Left,
356 Top,
359 BitmapOffset);
360 }
361 else
362 {
363 if (BitmapInfoHeader->biHeight < 0)
364 {
365 /* Top-down DIB */
367 }
368 else
369 {
370 /* Bottom-up DIB */
371 BitmapOffset += ((BitmapInfoHeader->biHeight - 1) * Stride);
372 Stride *= -1;
373 }
374
375 BitBlt(Left,
376 Top,
379 BitmapOffset,
381 Stride);
382 }
383}
VOID InitPaletteWithTable(_In_reads_(Count) const ULONG *Table, _In_ ULONG Count)
Definition: bootvid.c:220
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
Definition: common.c:42
static VOID RleBitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ PUCHAR Buffer)
Definition: common.c:108
#define BI_RLE4
Definition: precomp.h:47
struct tagBITMAPINFOHEADER * PBITMAPINFOHEADER
#define ASSERT(a)
Definition: mode.c:44
#define BV_MAX_COLORS
Definition: display.h:32
DWORD biCompression
Definition: amvideo.idl:35
uint32_t * PULONG
Definition: typedefs.h:59

Referenced by BootLogoFadeIn(), and InbvBitBlt().

◆ VidBufferToScreenBlt()

VOID NTAPI VidBufferToScreenBlt ( _In_reads_bytes_(Height *Stride) PUCHAR  Buffer,
_In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Width,
_In_ ULONG  Height,
_In_ ULONG  Stride 
)

Definition at line 307 of file common.c.

314{
315 /* Invoke the helper function, expecting a 4bpp format buffer */
316 BitBlt(Left, Top, Width, Height, Buffer, 4, Stride);
317}

Referenced by InbvBufferToScreenBlt(), and InbvRotationThread().

Variable Documentation

◆ VidpDefaultPalette

const RGBQUAD VidpDefaultPalette[BV_MAX_COLORS]
Initial value:
=
{
RGB( 0, 0, 0),
RGB(128, 0, 0),
RGB( 0, 128, 0),
RGB(128, 128, 0),
RGB( 0, 0, 128),
RGB(128, 0, 128),
RGB( 0, 128, 128),
RGB(128, 128, 128),
RGB(192, 192, 192),
RGB(255, 0, 0),
RGB( 0, 255, 0),
RGB(255, 255, 0),
RGB( 0, 0, 255),
RGB(255, 0, 255),
RGB( 0, 255, 255),
RGB(255, 255, 255),
}
#define RGB(r, g, b)
Definition: precomp.h:88

Definition at line 19 of file common.c.

Referenced by InitializePalette(), and VidpBuildColor().