2 <title>Outline of DirectDraw Architecture</title>
5 This is an outline of the architecture. Many details are
6 skipped, but hopefully this is useful.
9 <sect1 id="ddinheritance">
10 <title>DirectDraw inheritance tree</title>
19 Most of the DirectDraw functionality is implemented in a common base
20 class. Derived classes are responsible for providing display
21 mode functions (Enum, Set, Restore), GetCaps, GetDevice identifier
22 and internal functions called to create primary and backbuffer
26 User provides for DirectDraw capabilities based on drawing to a
27 Wine window. It uses the User DirectDrawSurface implementation
28 for primary and backbuffer surfaces.
31 XVidMode attempt to use the XFree86 VidMode extension to set the
32 display resolution to match the parameters to SetDisplayMode.
35 DGA2 attempt to use the XFree86 DGA 2.x extension to set the
36 display resolution and direct access to the framebuffer, if the
37 full-screen-exclusive cooperative level is used. If not, it just
38 uses the User implementation.
41 <sect1 id="ddsurfaceinheritance">
42 <title>DirectDrawSurface inheritance tree</title>
54 Main provides a very simple base class that does not implement any of
55 the image-related functions. Therefore it does not place any
56 constraints on how the surface data is stored.
59 DIB stores the surface data in a DIB section. It is used by the Main
60 DirectDraw driver to create off-screen surfaces.
63 User implements primary and backbuffer surfaces for the User DirectDraw
64 driver. If it is a primary surface, it will attempt to keep itself
65 synchronized to the window.
68 DGA2 surfaces claims an appropriate section of framebuffer space and
69 lets DIB build its DIB section on top of it.
72 Fake Z-Buffer surfaces are used by Direct3D to indicate that a primary
73 surface has an associated z-buffer. For a first implementation, it
74 doesn't need to store any image data since it is just a placeholder.
77 (Actually 3D programs will rarely use Lock or GetDC on primary
78 surfaces, backbuffers or z-buffers so we may want to arrange for
79 lazy allocation of the DIB sections.)
83 <sect1 id="interfacethunks">
84 <title>Interface Thunks</title>
86 Only the most recent version of an interface needs to be implemented.
87 Other versions are handled by having thunks convert their parameters
88 and call the root version.
91 Not all interface versions have thunks. Some versions could be combined
92 because their parameters were compatible. For example if a structure
93 changes but the structure has a dwSize field, methods using that structure
94 are compatible, as long as the implementation remembers to take the dwSize
98 Interface thunks for Direct3D are more complicated since the paradigm
99 changed between versions.
103 <sect1 id="logicalobjectlayout">
104 <title>Logical Object Layout</title>
106 The objects are split into the generic part (essentially the fields for
107 Main) and a private part. This is necessary because some objects
108 can be created with CoCreateInstance, then Initialized later. Only
109 at initialization time do we know which class to use. Each class
110 except Main declares a Part structure and adds that to its Impl.
113 For example, the DIBTexture DirectDrawSurface implementation looks
117 struct DIBTexture_DirectDrawSurfaceImpl_Part
119 union DIBTexture_data data; /*declared in the real header*/
124 struct DIB_DirectDrawSurfaceImpl_Part dib;
125 struct DIBTexture_DirectDrawSurfaceImpl_Part dibtexture;
126 } DIBTexture_DirectDrawSurfaceImpl;
129 So the DIBTexture surface class is derived from the DIB surface
130 class and it adds one piece of data, a union.
133 Main does not have a Part structure. Its fields are stored in
134 IDirectDrawImpl/IDirectDrawSurfaceImpl.
137 To access private data, one says
140 DIBTexture_DirectDrawSurfaceImpl* priv = This->private;
141 do_something_with(priv->dibtexture.data);
145 <sect1 id="creatingobject">
146 <title>Creating Objects</title>
148 Classes have two functions relevant to object creation, Create and
149 Construct. To create a new object, the class' Create function is
150 called. It allocates enough memory for IDirectDrawImpl or
151 IDirectDrawSurfaceImpl as well as the private data for derived
152 classes and then calls Construct.
155 Each class's Construct function calls the base class's Construct,
156 then does the necessary initialization.
159 For example, creating a primary surface with the user ddraw driver
160 calls User_DirectDrawSurface_Create which allocates memory for the
161 object and calls User_DirectDrawSurface_Construct to initialize it.
162 This calls DIB_DirectDrawSurface_Construct which calls
163 Main_DirectDrawSurface_Construct.
168 <!-- Keep this comment at the end of the file
171 sgml-parent-document:("wine-devel.sgml" "set" "book" "chapter" "")