blob: 830eab15f3ceb19a606c9543ca5d21a4c34fbb80 [file] [log] [blame]
Alexandre Julliardd6c0f9f2001-01-04 22:44:55 +00001This is an outline of the architecture. Many details are
2skipped, but hopefully this is useful.
3
4By Andrew Lewycky <andrew@transgaming.com>
5(with updates by Ove Kåven <ovek@transgaming.com>)
6
7
8* DirectDraw inheritance tree
9
10 Main
11 |
12 User
13 |-----------\
14 XVidMode DGA2
15
16Most of the DirectDraw functionality is implemented in a common base
17class. Derived classes are responsible for providing display
18mode functions (Enum, Set, Restore), GetCaps, GetDevice identifier
19and internal functions called to create primary and backbuffer
20surfaces.
21
22User provides for DirectDraw capabilities based on drawing to a
23Wine window. It uses the User DirectDrawSurface implementation
24for primary and backbuffer surfaces.
25
26XVidMode attempt to use the XFree86 VidMode extension to set the
27display resolution to match the parameters to SetDisplayMode.
28
29DGA2 attempt to use the XFree86 DGA 2.x extension to set the
30display resolution and direct access to the framebuffer, if the
31full-screen-exclusive cooperative level is used. If not, it just
32uses the User implementation.
33
34
35* DirectDrawSurface inheritance tree
36
37 Main
38 |--------------\
39 | |
40 DIB Fake Z-Buffer
41 |
42 |------\---------\
43 | | |
44 User DGA2 DIBTexture
45
46Main provides a very simple base class that does not implement any of
47the image-related functions. Therefore it does not place any
48constraints on how the surface data is stored.
49
50DIB stores the surface data in a DIB section. It is used by the Main
51DirectDraw driver to create off-screen surfaces.
52
53User implements primary and backbuffer surfaces for the User DirectDraw
54driver. If it is a primary surface, it will attempt to keep itself
55synchronized to the window.
56
57DGA2 surfaces claims an appropriate section of framebuffer space and
58lets DIB build its DIB section on top of it.
59
60Fake Z-Buffer surfaces are used by Direct3D to indicate that a primary
61surface has an associated z-buffer. For a first implementation, it
62doesn't need to store any image data since it is just a placeholder.
63
64(Actually 3D programs will rarely use Lock or GetDC on primary
65surfaces, backbuffers or z-buffers so we may want to arrange for
66lazy allocation of the DIB sections.)
67
68
69* Interface Thunks
70
71Only the most recent version of an interface needs to be implemented.
72Other versions are handled by having thunks convert their parameters
73and call the root version.
74
75Not all interface versions have thunks. Some versions could be combined
76because their parameters were compatible. For example if a structure
77changes but the structure has a dwSize field, methods using that structure
78are compatible, as long as the implementation remembers to take the dwSize
79into account.
80
81Interface thunks for Direct3D are more complicated since the paradigm
82changed between versions.
83
84
85* Logical Object Layout
86
87The objects are split into the generic part (essentially the fields for
88Main) and a private part. This is necessary because some objects
89can be created with CoCreateInstance, then Initialized later. Only
90at initialisation time do we know which class to use. Each class
91except Main declares a Part structure and adds that to its Impl.
92
93For example, the DIBTexture DirectDrawSurface implementation looks
94like this:
95
96struct DIBTexture_DirectDrawSurfaceImpl_Part
97{
98 union DIBTexture_data data; /*declared in the real header*/
99};
100
101typedef struct
102{
103 struct DIB_DirectDrawSurfaceImpl_Part dib;
104 struct DIBTexture_DirectDrawSurfaceImpl_Part dibtexture;
105} DIBTexture_DirectDrawSurfaceImpl;
106
107So the DIBTexture surface class is derived from the DIB surface
108class and it adds one piece of data, a union.
109
110Main does not have a Part structure. Its fields are stored in
111IDirectDrawImpl/IDirectDrawSurfaceImpl.
112
113To access private data, one says
114
115DIBTexture_DirectDrawSurfaceImpl* priv = This->private;
116do_something_with(priv->dibtexture.data);
117
118
119* Creating Objects
120
121Classes have two functions relevant to object creation, Create and
122Construct. To create a new object, the class' Create function is
123called. It allocates enough memory for IDirectDrawImpl or
124IDirectDrawSurfaceImpl as well as the private data for derived
125classes and then calls Construct.
126
127Each class's Construct function calls the base class's Construct,
128then does the necessary initialization.
129
130For example, creating a primary surface with the user ddraw driver
131calls User_DirectDrawSurface_Create which allocates memory for the
132object and calls User_DirectDrawSurface_Construct to initialize it.
133This calls DIB_DirectDrawSurface_Construct which calls
134Main_DirectDrawSurface_Construct.