ReactOS 0.4.16-dev-122-g325d74c
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
19VOID
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
52VOID
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
86VOID
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 {
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;
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
163VOID
165 IN ULONG Start,
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;
177}
#define VOID
Definition: acefi.h:82
#define ALLOC_TAG
Definition: btrfs_drv.h:87
#define GRA_D
Definition: vgavideo.h:60
#define GRA_I
Definition: vgavideo.h:59
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertHeadList(ListHead, Entry)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
return pTarget Start()
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
#define for
Definition: utility.h:88
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
VOID VGADDI_BltFromSavedScreenBits(IN ULONG DestX, IN ULONG DestY, IN PSAVED_SCREEN_BITS Src, IN ULONG SizeX, IN ULONG SizeY)
Definition: offscreen.c:20
static LIST_ENTRY SavedBitsList
Definition: offscreen.c:15
PSAVED_SCREEN_BITS VGADDI_AllocSavedScreenBits(ULONG Size)
Definition: offscreen.c:121
VOID VGADDI_FreeSavedScreenBits(PSAVED_SCREEN_BITS SavedBits)
Definition: offscreen.c:87
VOID VGADDI_BltToSavedScreenBits(IN PSAVED_SCREEN_BITS Dest, IN ULONG SourceX, IN ULONG SourceY, IN ULONG SizeX, IN ULONG SizeY)
Definition: offscreen.c:53
VOID VGADDI_InitializeOffScreenMem(IN ULONG Start, IN ULONG Length)
Definition: offscreen.c:164
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define EngFreeMem
Definition: polytest.cpp:56
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define New(t)
Definition: rtf.h:1086
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY ListEntry
Definition: vgaddi.h:94
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
PBYTE vidmem
Definition: vgavideo.c:18
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)