Skip to content

Commit de2f171

Browse files
committed
CHange CRLF to LF in ExampleSurfacePlugin code in advance of BitBlt fix
that affects surface functions.
1 parent cfa04b7 commit de2f171

File tree

2 files changed

+135
-135
lines changed

2 files changed

+135
-135
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/* example surface plugin header file */
2-
int memInitialize(void);
3-
int memCreateSurfaceWidthHeightDepth(int width, int height, int depth);
4-
int memDestroySurface(int id);
5-
int memGetSurfaceWidth(int id);
6-
int memGetSurfaceHeight(int id);
7-
int memGetSurfaceDepth(int id);
8-
1+
/* example surface plugin header file */
2+
int memInitialize(void);
3+
int memCreateSurfaceWidthHeightDepth(int width, int height, int depth);
4+
int memDestroySurface(int id);
5+
int memGetSurfaceWidth(int id);
6+
int memGetSurfaceHeight(int id);
7+
int memGetSurfaceDepth(int id);
8+
Lines changed: 127 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,127 @@
1-
/* sample memory surface plugin implementation */
2-
#include <malloc.h>
3-
#include "sqVirtualMachine.h"
4-
#include "ExampleSurfacePlugin.h"
5-
#include "../SurfacePlugin/SurfacePlugin.h"
6-
7-
typedef struct memSurface {
8-
int width, height, depth, stride;
9-
void *bits;
10-
} memSurface;
11-
12-
/* entry points for surface manager; looked up at startup */
13-
static fn_ioRegisterSurface registerSurface = 0;
14-
static fn_ioUnregisterSurface unregisterSurface = 0;
15-
static fn_ioFindSurface findSurface = 0;
16-
17-
extern struct VirtualMachine *interpreterProxy;
18-
19-
/******************* Surface manager entry points *******************/
20-
static int memGetSurfaceFormat(sqIntptr_t handle, int *w, int *h, int *d, int *msbFlag) {
21-
memSurface *ms = (memSurface *) handle;
22-
*w = ms->width;
23-
*h = ms->height;
24-
*d = ms->depth;
25-
*msbFlag = 0; /* should really depend on platform */
26-
return 1;
27-
}
28-
29-
static sqIntptr_t memLock(sqIntptr_t handle, int *stride, int x, int y, int w, int h){
30-
/* Locking can be safely ignored for memory surfaces but we need to fill in
31-
the stride and return the bits */
32-
memSurface *ms = (memSurface *) handle;
33-
*stride = ms->stride;
34-
return (sqIntptr_t)ms->bits;
35-
}
36-
37-
static int memUnlock(sqIntptr_t handle, int x, int y, int w, int h){
38-
return 1; /* ignored */
39-
}
40-
41-
static int memShow(sqIntptr_t handle, int x, int y, int w, int h) {
42-
/* unsupported */
43-
return 0;
44-
}
45-
46-
static sqSurfaceDispatch memSurfaceDispatch = {
47-
1,
48-
0,
49-
(fn_getSurfaceFormat) memGetSurfaceFormat,
50-
(fn_lockSurface) memLock,
51-
(fn_unlockSurface) memUnlock,
52-
(fn_showSurface) memShow
53-
};
54-
55-
/******************* primitive entry points *******************/
56-
57-
int memCreateSurfaceWidthHeightDepth(int w, int h, int d) {
58-
memSurface *ms;
59-
int id;
60-
/* since I'm lazy I'll only deal with d >= 8 */
61-
if(d < 8) return -1; /* indicates failure */
62-
/* create the memory surface */
63-
ms = calloc(1, sizeof(memSurface));
64-
ms->width = w;
65-
ms->height = h;
66-
ms->depth = d;
67-
ms->stride = w * (d >> 3);
68-
ms->bits = calloc(ms->stride, ms->height);
69-
/* register memory surface */
70-
if(!(*registerSurface)((sqIntptr_t)ms, &memSurfaceDispatch, &id)) {
71-
/* registration failed; bail */
72-
free(ms->bits);
73-
free(ms);
74-
return -1;
75-
}
76-
return id;
77-
}
78-
79-
int memDestroySurface(int id) {
80-
memSurface *ms;
81-
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
82-
(*unregisterSurface)(id);
83-
free(ms->bits);
84-
free(ms);
85-
return 1;
86-
}
87-
88-
int memGetSurfaceWidth(int id) {
89-
memSurface *ms;
90-
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
91-
return ms->width;
92-
}
93-
94-
int memGetSurfaceHeight(int id) {
95-
memSurface *ms;
96-
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
97-
return ms->height;
98-
}
99-
100-
int memGetSurfaceDepth(int id) {
101-
memSurface *ms;
102-
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
103-
return ms->depth;
104-
}
105-
106-
sqIntptr_t memGetSurfaceBits(int id) {
107-
memSurface *ms;
108-
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
109-
return (sqIntptr_t) ms->bits;
110-
}
111-
112-
int memInitialize(void) {
113-
/* look up the required entry points */
114-
registerSurface = (fn_ioRegisterSurface)
115-
interpreterProxy->ioLoadFunctionFrom("ioRegisterSurface","SurfacePlugin");
116-
unregisterSurface = (fn_ioUnregisterSurface)
117-
interpreterProxy->ioLoadFunctionFrom("ioUnregisterSurface","SurfacePlugin");
118-
findSurface = (fn_ioFindSurface)
119-
interpreterProxy->ioLoadFunctionFrom("ioFindSurface","SurfacePlugin");
120-
121-
/* if any of the above fail we won't load the plugin */
122-
if(!registerSurface) return 0;
123-
if(!unregisterSurface) return 0;
124-
if(!findSurface) return 0;
125-
return 1;
126-
}
127-
1+
/* sample memory surface plugin implementation */
2+
#include <malloc.h>
3+
#include "sqVirtualMachine.h"
4+
#include "ExampleSurfacePlugin.h"
5+
#include "../SurfacePlugin/SurfacePlugin.h"
6+
7+
typedef struct memSurface {
8+
int width, height, depth, stride;
9+
void *bits;
10+
} memSurface;
11+
12+
/* entry points for surface manager; looked up at startup */
13+
static fn_ioRegisterSurface registerSurface = 0;
14+
static fn_ioUnregisterSurface unregisterSurface = 0;
15+
static fn_ioFindSurface findSurface = 0;
16+
17+
extern struct VirtualMachine *interpreterProxy;
18+
19+
/******************* Surface manager entry points *******************/
20+
static int memGetSurfaceFormat(sqIntptr_t handle, int *w, int *h, int *d, int *msbFlag) {
21+
memSurface *ms = (memSurface *) handle;
22+
*w = ms->width;
23+
*h = ms->height;
24+
*d = ms->depth;
25+
*msbFlag = 0; /* should really depend on platform */
26+
return 1;
27+
}
28+
29+
static sqIntptr_t memLock(sqIntptr_t handle, int *stride, int x, int y, int w, int h){
30+
/* Locking can be safely ignored for memory surfaces but we need to fill in
31+
the stride and return the bits */
32+
memSurface *ms = (memSurface *) handle;
33+
*stride = ms->stride;
34+
return (sqIntptr_t)ms->bits;
35+
}
36+
37+
static int memUnlock(sqIntptr_t handle, int x, int y, int w, int h){
38+
return 1; /* ignored */
39+
}
40+
41+
static int memShow(sqIntptr_t handle, int x, int y, int w, int h) {
42+
/* unsupported */
43+
return 0;
44+
}
45+
46+
static sqSurfaceDispatch memSurfaceDispatch = {
47+
1,
48+
0,
49+
(fn_getSurfaceFormat) memGetSurfaceFormat,
50+
(fn_lockSurface) memLock,
51+
(fn_unlockSurface) memUnlock,
52+
(fn_showSurface) memShow
53+
};
54+
55+
/******************* primitive entry points *******************/
56+
57+
int memCreateSurfaceWidthHeightDepth(int w, int h, int d) {
58+
memSurface *ms;
59+
int id;
60+
/* since I'm lazy I'll only deal with d >= 8 */
61+
if(d < 8) return -1; /* indicates failure */
62+
/* create the memory surface */
63+
ms = calloc(1, sizeof(memSurface));
64+
ms->width = w;
65+
ms->height = h;
66+
ms->depth = d;
67+
ms->stride = w * (d >> 3);
68+
ms->bits = calloc(ms->stride, ms->height);
69+
/* register memory surface */
70+
if(!(*registerSurface)((sqIntptr_t)ms, &memSurfaceDispatch, &id)) {
71+
/* registration failed; bail */
72+
free(ms->bits);
73+
free(ms);
74+
return -1;
75+
}
76+
return id;
77+
}
78+
79+
int memDestroySurface(int id) {
80+
memSurface *ms;
81+
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
82+
(*unregisterSurface)(id);
83+
free(ms->bits);
84+
free(ms);
85+
return 1;
86+
}
87+
88+
int memGetSurfaceWidth(int id) {
89+
memSurface *ms;
90+
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
91+
return ms->width;
92+
}
93+
94+
int memGetSurfaceHeight(int id) {
95+
memSurface *ms;
96+
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
97+
return ms->height;
98+
}
99+
100+
int memGetSurfaceDepth(int id) {
101+
memSurface *ms;
102+
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
103+
return ms->depth;
104+
}
105+
106+
sqIntptr_t memGetSurfaceBits(int id) {
107+
memSurface *ms;
108+
if(!(*findSurface)(id, &memSurfaceDispatch, (sqIntptr_t*) &ms)) return 0;
109+
return (sqIntptr_t) ms->bits;
110+
}
111+
112+
int memInitialize(void) {
113+
/* look up the required entry points */
114+
registerSurface = (fn_ioRegisterSurface)
115+
interpreterProxy->ioLoadFunctionFrom("ioRegisterSurface","SurfacePlugin");
116+
unregisterSurface = (fn_ioUnregisterSurface)
117+
interpreterProxy->ioLoadFunctionFrom("ioUnregisterSurface","SurfacePlugin");
118+
findSurface = (fn_ioFindSurface)
119+
interpreterProxy->ioLoadFunctionFrom("ioFindSurface","SurfacePlugin");
120+
121+
/* if any of the above fail we won't load the plugin */
122+
if(!registerSurface) return 0;
123+
if(!unregisterSurface) return 0;
124+
if(!findSurface) return 0;
125+
return 1;
126+
}
127+

0 commit comments

Comments
 (0)