1
#ifndef __SQ_DRAW_SURFACE_H
2
#define __SQ_DRAW_SURFACE_H
4
#define SQ_SURFACE_MAJOR 1
5
#define SQ_SURFACE_MINOR 0
7
/* Plugins creating their own surfaces must register these using
8
the following set of functions. The typedefs are for easier casts. */
9
typedef int (*fn_getSurfaceFormat)(int surfaceHandle, int* width, int* height, int* depth, int* isMSB);
10
typedef int (*fn_lockSurface)(int surfaceHandle, int *pitch, int x, int y, int w, int h);
11
typedef int (*fn_unlockSurface)(int surfaceHandle, int x, int y, int w, int h);
12
typedef int (*fn_showSurface)(int surfaceHandle, int x, int y, int w, int h);
14
typedef struct sqSurfaceDispatch {
15
/* Version information. Must be provided by the client
16
so the surface manager can check if certain operations
22
fn_getSurfaceFormat getSurfaceFormat;
23
fn_lockSurface lockSurface;
24
fn_unlockSurface unlockSurface;
25
fn_showSurface showSurface;
28
/* The functions for sqSurfaceDispatch are:
30
int getSurfaceFormat(int handle, int* width, int* height, int* depth, int* isMSB);
31
Return general information about the OS drawing surface.
32
Return true if successful, false otherwise.
34
The returned values describe the basic properties such as
35
width, height, depth and LSB vs. MSB pixels.
37
int lockSurface(int handle, int *pitch, int x, int y, int w, int h);
38
Lock the bits of the surface.
39
Return a pointer to the actual surface bits, or NULL on failure.
40
If successful, store the pitch of the surface (e.g., the bytes
43
For equal source/dest handles only one locking operation is performed.
44
This is to prevent locking of overlapping areas which does not work with
45
certain APIs (e.g., DirectDraw prevents locking of overlapping areas).
46
A special case for non-overlapping but equal source/dest handle would
47
be possible but we would have to transfer this information over to
48
unlockSurfaces somehow (currently, only one unlock operation is
49
performed for equal source and dest handles). Also, this would require
50
a change in the notion of ioLockSurface() which is right now interpreted
51
as a hint and not as a requirement to lock only the specific portion of
54
The arguments in ioLockSurface() provide the implementation with
55
an explicit hint what area is affected. It can be very useful to
56
know the max. affected area beforehand if getting the bits requires expensive
57
copy operations (e.g., like a roundtrip to the X server or a glReadPixel op).
58
However, the returned pointer *MUST* point to the virtual origin of the surface
59
and not to the beginning of the rectangle. The promise made by BitBlt
60
is to never access data outside the given rectangle (aligned to 4byte boundaries!)
61
so it is okay to return a pointer to the virtual origin that is actually outside
62
the valid memory area.
64
The area provided in ioLockSurface() is already clipped (e.g., it will always
65
be inside the source and dest boundingBox) but it is not aligned to word boundaries
66
yet. It is up to the support code to compute accurate alignment if necessary.
68
int unlockSurface(int handle, int x, int y, int w, int h);
69
Unlock the bits of a (possibly modified) surface after BitBlt completed.
70
The return value is ignored.
72
The arguments provided specify the dirty region of the surface. If the
73
surface is unmodified all arguments are set to zero.
75
int showSurface(int handle, int x, int y, int w, int h);
76
Display the contents of the surface on the actual screen.
78
If ioShowSurface() is called the surface in question represents
79
a Squeak DisplayScreen.
81
FXBlt uses a variant of the above functions which are exported from
84
int ioGetSurfaceFormat(int surfaceID, int* width, int* height, int* depth, int* isMSB);
85
int ioLockSurface(int surfaceID, int *pitch, int x, int y, int w, int h);
86
int ioUnlockSurface(int surfaceID, int x, int y, int w, int h);
88
These functions are looked up in the registered surfaces and invoked
89
as appropriate. The meaning of all values is exactly the same as for
90
the functions specified in sqSurfaceDispatch with the exception that
91
the surfaceID represents the 'bits' handle of the Form that is used
94
Interpreter itself uses a separate entry point for updating the display
96
int ioShowSurface(int surfaceID, int x, int y, int w, int h);
98
since the management of deferred updates is currently an intrinsic
99
property of the VM (which is bad - deferred updates should be a
100
property of the DisplayScreen in question and not of the VM but
101
that's the way it is...).
105
/* The following are the entry points for the surface manager:
107
int ioRegisterSurface(int surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID);
108
Register a new surface with the given handle and
109
the set of surface functions. The new ID is returned
110
in surfaceID. Returns true if successful, false
113
int ioUnregisterSurface(int surfaceID);
114
Unregister the surface with the given handle.
115
Returns true if successful, false otherwise.
117
int ioFindSurface(int surfaceID, sqSurfaceDispatch *fn, int *surfaceHandle);
118
Find the surface with the given ID, and, optionally,
119
the given set of surface functions. The registered handle
120
is returned in surfaceHandle. Return true if successful
121
(e.g., the surface has been found), false otherwise.
123
The above entry points can be looked up through the interpreter, e.g., using
124
interpreterProxy->ioLoadFunctionFrom("ioRegisterSurface","SurfacePlugin");
125
The typedefs below are for easier casts.
127
typedef int (*fn_ioRegisterSurface)(int surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID);
128
typedef int (*fn_ioUnregisterSurface)(int surfaceID);
129
typedef int (*fn_ioFindSurface)(int surfaceID, sqSurfaceDispatch *fn, int *surfaceHandle);
131
#endif /* __SQ_DRAW_SURFACE_H */