ReactOS  0.4.13-dev-257-gfabbd7c
graphics.c File Reference
#include <consrv.h>
#include <debug.h>
#include "guiterm.h"
Include dependency graph for graphics.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID GuiCopyFromGraphicsBuffer (PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
 
VOID GuiPasteToGraphicsBuffer (PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
 
VOID GuiPaintGraphicsBuffer (PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, PRECT rcView, PRECT rcFramebuffer)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file graphics.c.

Function Documentation

◆ GuiCopyFromGraphicsBuffer()

VOID GuiCopyFromGraphicsBuffer ( PGRAPHICS_SCREEN_BUFFER  Buffer,
PGUI_CONSOLE_DATA  GuiData 
)

Definition at line 21 of file graphics.c.

23 {
24  /*
25  * This function supposes that the system clipboard was opened.
26  */
27 
28  HDC hMemDC;
29  HBITMAP hBitmapTarget, hBitmapOld;
30  HPALETTE hPalette, hPaletteOld;
31  ULONG selWidth, selHeight;
32 
33  if (Buffer->BitMap == NULL) return;
34 
35  selWidth = GuiData->Selection.srSelection.Right - GuiData->Selection.srSelection.Left + 1;
36  selHeight = GuiData->Selection.srSelection.Bottom - GuiData->Selection.srSelection.Top + 1;
37  DPRINT("Selection is (%d|%d) to (%d|%d)\n",
38  GuiData->Selection.srSelection.Left,
39  GuiData->Selection.srSelection.Top,
40  GuiData->Selection.srSelection.Right,
41  GuiData->Selection.srSelection.Bottom);
42 
43  hMemDC = CreateCompatibleDC(GuiData->hMemDC);
44  if (hMemDC == NULL) return;
45 
46  /* Allocate a bitmap to be given to the clipboard, so it will not be freed here */
47  hBitmapTarget = CreateCompatibleBitmap(GuiData->hMemDC, selWidth, selHeight);
48  if (hBitmapTarget == NULL)
49  {
50  DeleteDC(hMemDC);
51  return;
52  }
53 
54  /* Select the new bitmap */
55  hBitmapOld = SelectObject(hMemDC, hBitmapTarget);
56 
57  /* Change the palette in hMemDC if the current palette does exist */
58  if (Buffer->PaletteHandle == NULL)
59  hPalette = GuiData->hSysPalette;
60  else
61  hPalette = Buffer->PaletteHandle;
62 
63  if (hPalette) hPaletteOld = SelectPalette(hMemDC, hPalette, FALSE);
64 
65  /* Grab the mutex */
67 
68  // The equivalent of a SetDIBitsToDevice call...
69  // It seems to be broken: it does not copy the tail of the bitmap.
70  // http://wiki.allegro.cc/index.php?title=StretchDIBits
71 #if 0
72  StretchDIBits(hMemDC,
73  0, 0,
74  selWidth, selHeight,
75  GuiData->Selection.srSelection.Left,
76  GuiData->Selection.srSelection.Top,
77  selWidth, selHeight,
78  Buffer->BitMap,
79  Buffer->BitMapInfo,
80  Buffer->BitMapUsage,
81  SRCCOPY);
82 #else
83  SetDIBitsToDevice(hMemDC,
84  /* Coordinates / size of the repainted rectangle, in the framebuffer's frame */
85  0, 0,
86  selWidth, selHeight,
87  /* Coordinates / size of the corresponding image portion, in the graphics screen-buffer's frame */
88  GuiData->Selection.srSelection.Left,
89  GuiData->Selection.srSelection.Top,
90  0,
91  Buffer->ScreenBufferSize.Y, // == Buffer->BitMapInfo->bmiHeader.biHeight
92  Buffer->BitMap,
93  Buffer->BitMapInfo,
94  Buffer->BitMapUsage);
95 #endif
96 
97  /* Release the mutex */
98  NtReleaseMutant(Buffer->Mutex, NULL);
99 
100  /* Restore the palette and the old bitmap */
101  if (hPalette) SelectPalette(hMemDC, hPaletteOld, FALSE);
102  SelectObject(hMemDC, hBitmapOld);
103 
104  EmptyClipboard();
105  SetClipboardData(CF_BITMAP, hBitmapTarget);
106 
107  DeleteDC(hMemDC);
108 }
int WINAPI StretchDIBits(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ const VOID *, _In_ const BITMAPINFO *, _In_ UINT, _In_ DWORD)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
SMALL_RECT srSelection
Definition: wincon.h:195
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
#define CF_BITMAP
Definition: constants.h:397
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
SHORT Bottom
Definition: blue.h:28
SHORT Top
Definition: blue.h:26
int WINAPI SetDIBitsToDevice(_In_ HDC, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ int, _In_ int, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
BOOL WINAPI DeleteDC(_In_ HDC)
HPALETTE hSysPalette
Definition: conwnd.h:64
unsigned int ULONG
Definition: retypes.h:1
static HBITMAP
Definition: button.c:44
SHORT Right
Definition: blue.h:27
NTSTATUS NTAPI NtReleaseMutant(IN HANDLE MutantHandle, IN PLONG PreviousCount OPTIONAL)
Definition: mutant.c:299
#define SRCCOPY
Definition: wingdi.h:332
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by Copy().

◆ GuiPaintGraphicsBuffer()

VOID GuiPaintGraphicsBuffer ( PGRAPHICS_SCREEN_BUFFER  Buffer,
PGUI_CONSOLE_DATA  GuiData,
PRECT  rcView,
PRECT  rcFramebuffer 
)

Definition at line 124 of file graphics.c.

128 {
129  PCONSRV_CONSOLE Console = Buffer->Header.Console;
130  // ASSERT(Console == GuiData->Console);
131 
132  SetRectEmpty(rcFramebuffer);
133 
134  if (Buffer->BitMap == NULL) return;
135 
137 
138  rcFramebuffer->left = Buffer->ViewOrigin.X * 1 + rcView->left;
139  rcFramebuffer->top = Buffer->ViewOrigin.Y * 1 + rcView->top;
140  rcFramebuffer->right = Buffer->ViewOrigin.X * 1 + rcView->right;
141  rcFramebuffer->bottom = Buffer->ViewOrigin.Y * 1 + rcView->bottom;
142 
143  /* Grab the mutex */
145 
146  /*
147  * The seventh parameter (YSrc) of SetDIBitsToDevice always designates
148  * the Y-coordinate of the "lower-left corner" of the image, be the DIB
149  * in bottom-up or top-down mode.
150  */
151  SetDIBitsToDevice(GuiData->hMemDC,
152  /* Coordinates / size of the repainted rectangle, in the framebuffer's frame */
153  rcFramebuffer->left,
154  rcFramebuffer->top,
155  rcFramebuffer->right - rcFramebuffer->left,
156  rcFramebuffer->bottom - rcFramebuffer->top,
157  /* Coordinates / size of the corresponding image portion, in the graphics screen-buffer's frame */
158  rcFramebuffer->left,
159  rcFramebuffer->top,
160  0,
161  Buffer->ScreenBufferSize.Y, // == Buffer->BitMapInfo->bmiHeader.biHeight
162  Buffer->BitMap,
163  Buffer->BitMapInfo,
164  Buffer->BitMapUsage);
165 
166  /* Release the mutex */
167  NtReleaseMutant(Buffer->Mutex, NULL);
168 
170 }
#define TRUE
Definition: types.h:120
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
#define PCONSRV_CONSOLE
Definition: conio.h:27
LONG right
Definition: windef.h:293
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
int WINAPI SetDIBitsToDevice(_In_ HDC, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ int, _In_ int, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
CConsole Console
LONG bottom
Definition: windef.h:294
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
NTSTATUS NTAPI NtReleaseMutant(IN HANDLE MutantHandle, IN PLONG PreviousCount OPTIONAL)
Definition: mutant.c:299
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by OnPaint().

◆ GuiPasteToGraphicsBuffer()

VOID GuiPasteToGraphicsBuffer ( PGRAPHICS_SCREEN_BUFFER  Buffer,
PGUI_CONSOLE_DATA  GuiData 
)

Definition at line 111 of file graphics.c.

113 {
114  /*
115  * This function supposes that the system clipboard was opened.
116  */
117 
118  // PCONSRV_CONSOLE Console = Buffer->Header.Console;
119 
121 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by Paste().