ReactOS  0.4.14-dev-390-g34947ad
offscreen.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS VGA display driver
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: win32ss/drivers/displays/vga/objects/offscreen.c
5  * PURPOSE: Manages off-screen video memory
6  * PROGRAMMERS: Copyright (C) 1998-2001 ReactOS Team
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <vgaddi.h>
12 
13 /* GLOBALS *******************************************************************/
14 
16 
17 /* FUNCTIONS *****************************************************************/
18 
19 VOID
21  IN ULONG DestX,
22  IN ULONG DestY,
24  IN ULONG SizeX,
25  IN ULONG SizeY)
26 {
27  PUCHAR DestOffset;
28  PUCHAR SrcOffset;
29  ULONG i, j;
30 
31  /* Select write mode 1. */
34 
35  SrcOffset = (PUCHAR)vidmem + Src->Offset;
36  for (i = 0; i < SizeY; i++)
37  {
38  DestOffset = (PUCHAR)vidmem + (i + DestY) * 80 + (DestX >> 3);
39  //FIXME: in the loop below we should treat the case when SizeX is not divisible by 8, i.e. partial bytes
40  for (j = 0; j < SizeX>>3; j++, SrcOffset++, DestOffset++)
41  {
42  (VOID)READ_REGISTER_UCHAR(SrcOffset);
43  WRITE_REGISTER_UCHAR(DestOffset, 0);
44  }
45  }
46 
47  /* Select write mode 2. */
50 }
51 
52 VOID
55  IN ULONG SourceX,
56  IN ULONG SourceY,
57  IN ULONG SizeX,
58  IN ULONG SizeY)
59 {
60  PUCHAR DestOffset;
61  PUCHAR SrcOffset;
62  ULONG i, j;
63 
64  /* Select write mode 1. */
67 
68  DestOffset = (PUCHAR)vidmem + Dest->Offset;
69 
70  for (i = 0; i < SizeY; i++)
71  {
72  SrcOffset = (PUCHAR)vidmem + (SourceY + i) * 80 + (SourceX >> 3);
73  //FIXME: in the loop below we should treat the case when SizeX is not divisible by 8, i.e. partial bytes
74  for (j = 0; j < SizeX>>3; j++, SrcOffset++, DestOffset++)
75  {
76  (VOID)READ_REGISTER_UCHAR(SrcOffset);
77  WRITE_REGISTER_UCHAR(DestOffset, 0);
78  }
79  }
80 
81  /* Select write mode 2. */
84 }
85 
86 VOID
88 {
89  SavedBits->Free = TRUE;
90 
91  if (SavedBits->ListEntry.Blink != &SavedBitsList)
92  {
93  PSAVED_SCREEN_BITS Previous;
94 
95  Previous = CONTAINING_RECORD(SavedBits->ListEntry.Blink,
96  SAVED_SCREEN_BITS, ListEntry);
97  if (Previous->Free)
98  {
99  Previous->Size += SavedBits->Size;
100  RemoveEntryList(&SavedBits->ListEntry);
101  EngFreeMem(SavedBits);
102  SavedBits = Previous;
103  }
104  }
105  if (SavedBits->ListEntry.Flink != &SavedBitsList)
106  {
107  PSAVED_SCREEN_BITS Next;
108 
110  ListEntry);
111  if (Next->Free)
112  {
113  SavedBits->Size += Next->Size;
114  RemoveEntryList(&SavedBits->ListEntry);
115  EngFreeMem(SavedBits);
116  }
117  }
118 }
119 
122 {
123  PSAVED_SCREEN_BITS Current;
124  PLIST_ENTRY CurrentEntry;
125  PSAVED_SCREEN_BITS Best;
127 
128  Best = NULL;
129  CurrentEntry = SavedBitsList.Flink;
130  while (CurrentEntry != &SavedBitsList)
131  {
132  Current = CONTAINING_RECORD(CurrentEntry, SAVED_SCREEN_BITS, ListEntry);
133 
134  if (Current->Free && Current->Size >= Size &&
135  (Best == NULL || (Current->Size - Size) < (Best->Size - Size)))
136  {
137  Best = Current;
138  }
139 
140  CurrentEntry = CurrentEntry->Flink;
141  }
142 
143  if (!Best)
144  return NULL;
145 
146  if (Best->Size == Size)
147  {
148  Best->Free = FALSE;
149  return Best;
150  }
151  else
152  {
154  New->Free = FALSE;
155  New->Offset = Best->Offset + Size;
156  New->Size = Size;
157  Best->Size -= Size;
158  InsertHeadList(&Best->ListEntry, &New->ListEntry);
159  return New;
160  }
161 }
162 
163 VOID
165  IN ULONG Start,
166  IN ULONG Length)
167 {
168  PSAVED_SCREEN_BITS FreeBits;
169 
171 
172  FreeBits = EngAllocMem(0, sizeof(SAVED_SCREEN_BITS), ALLOC_TAG);
173  FreeBits->Free = TRUE;
174  FreeBits->Offset = Start;
175  FreeBits->Size = Length;
176  InsertHeadList(&SavedBitsList, &FreeBits->ListEntry);
177 }
#define IN
Definition: typedefs.h:38
PBYTE vidmem
Definition: vgavideo.c:18
#define TRUE
Definition: types.h:120
VOID VGADDI_FreeSavedScreenBits(PSAVED_SCREEN_BITS SavedBits)
Definition: offscreen.c:87
#define EngFreeMem
Definition: polytest.cpp:56
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
unsigned char * PUCHAR
Definition: retypes.h:3
#define GRA_I
Definition: vgavideo.h:59
#define New(t)
Definition: rtf.h:1086
static ULONG SizeX
Definition: display.c:138
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define ALLOC_TAG
Definition: btrfs_drv.h:91
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
smooth NULL
Definition: ftsmooth.c:416
VOID VGADDI_BltToSavedScreenBits(IN PSAVED_SCREEN_BITS Dest, IN ULONG SourceX, IN ULONG SourceY, IN ULONG SizeX, IN ULONG SizeY)
Definition: offscreen.c:53
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define for
Definition: utility.h:88
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Definition: partlist.h:33
VOID VGADDI_InitializeOffScreenMem(IN ULONG Start, IN ULONG Length)
Definition: offscreen.c:164
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
VOID VGADDI_BltFromSavedScreenBits(IN ULONG DestX, IN ULONG DestY, IN PSAVED_SCREEN_BITS Src, IN ULONG SizeX, IN ULONG SizeY)
Definition: offscreen.c:20
#define VOID
Definition: acefi.h:82
Definition: typedefs.h:117
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY ListEntry
Definition: vgaddi.h:94
#define GRA_D
Definition: vgavideo.h:60
static LIST_ENTRY SavedBitsList
Definition: offscreen.c:15
unsigned int ULONG
Definition: retypes.h:1
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:532
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
static ULONG SizeY
Definition: display.c:139
PSAVED_SCREEN_BITS VGADDI_AllocSavedScreenBits(ULONG Size)
Definition: offscreen.c:121