ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ddraw_private.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006 Stefan Dösinger
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00017  */
00018 
00019 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
00020 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
00021 
00022 #include <assert.h>
00023 #define COBJMACROS
00024 #define NONAMELESSSTRUCT
00025 #define NONAMELESSUNION
00026 #include "wine/debug.h"
00027 
00028 #include "winbase.h"
00029 #include "wingdi.h"
00030 #include "winuser.h"
00031 
00032 #include "d3d.h"
00033 #include "ddraw.h"
00034 #ifdef DDRAW_INIT_GUID
00035 #include "initguid.h"
00036 #endif
00037 #include "wine/list.h"
00038 #include "wine/wined3d.h"
00039 #include "legacy.h"
00040 
00041 extern const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops DECLSPEC_HIDDEN;
00042 extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN;
00043 
00044 /* Typdef the interfaces */
00045 typedef struct IDirectDrawImpl            IDirectDrawImpl;
00046 typedef struct IDirectDrawSurfaceImpl     IDirectDrawSurfaceImpl;
00047 typedef struct IDirectDrawPaletteImpl     IDirectDrawPaletteImpl;
00048 typedef struct IDirect3DDeviceImpl        IDirect3DDeviceImpl;
00049 typedef struct IDirect3DLightImpl         IDirect3DLightImpl;
00050 typedef struct IDirect3DViewportImpl      IDirect3DViewportImpl;
00051 typedef struct IDirect3DMaterialImpl      IDirect3DMaterialImpl;
00052 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
00053 typedef struct IDirect3DVertexBufferImpl  IDirect3DVertexBufferImpl;
00054 
00055 extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
00056 
00057 /*****************************************************************************
00058  * IDirectDraw implementation structure
00059  *****************************************************************************/
00060 struct FvfToDecl
00061 {
00062     DWORD fvf;
00063     struct wined3d_vertex_declaration *decl;
00064 };
00065 
00066 struct IDirectDrawImpl
00067 {
00068     /* Interfaces */
00069     IDirectDraw7 IDirectDraw7_iface;
00070     IDirectDraw4 IDirectDraw4_iface;
00071     IDirectDraw2 IDirectDraw2_iface;
00072     IDirectDraw IDirectDraw_iface;
00073     IDirect3D7 IDirect3D7_iface;
00074     IDirect3D3 IDirect3D3_iface;
00075     IDirect3D2 IDirect3D2_iface;
00076     IDirect3D IDirect3D_iface;
00077     struct wined3d_device_parent device_parent;
00078 
00079     /* See comment in IDirectDraw::AddRef */
00080     LONG                    ref7, ref4, ref2, ref3, ref1, numIfaces;
00081     BOOL initialized;
00082 
00083     struct wined3d *wined3d;
00084     struct wined3d_device *wined3d_device;
00085     BOOL                    d3d_initialized;
00086 
00087     IDirectDrawSurfaceImpl *primary;
00088     RECT primary_lock;
00089     struct wined3d_surface *wined3d_frontbuffer;
00090     struct wined3d_swapchain *wined3d_swapchain;
00091     HWND swapchain_window;
00092 
00093     /* DirectDraw things, which are not handled by WineD3D */
00094     DWORD                   cooperative_level;
00095 
00096     DWORD                   orig_width, orig_height;
00097     DWORD                   orig_bpp;
00098 
00099     /* D3D things */
00100     HWND                    d3d_window;
00101     IDirect3DDeviceImpl     *d3ddevice;
00102     int                     d3dversion;
00103 
00104     /* Various HWNDs */
00105     HWND                    focuswindow;
00106     HWND                    devicewindow;
00107     HWND                    dest_window;
00108 
00109     /* Helpers for surface creation */
00110     IDirectDrawSurfaceImpl *tex_root;
00111 
00112     /* For the dll unload cleanup code */
00113     struct list ddraw_list_entry;
00114     /* The surface list - can't relay this to WineD3D
00115      * because of IParent
00116      */
00117     struct list surface_list;
00118 
00119     /* FVF management */
00120     struct FvfToDecl       *decls;
00121     UINT                    numConvertedDecls, declArraySize;
00122 };
00123 
00124 #define DDRAW_WINDOW_CLASS_NAME "DirectDrawDeviceWnd"
00125 
00126 HRESULT ddraw_init(IDirectDrawImpl *ddraw, enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
00127 void ddraw_destroy_swapchain(IDirectDrawImpl *ddraw) DECLSPEC_HIDDEN;
00128 
00129 static inline void ddraw_set_swapchain_window(struct IDirectDrawImpl *ddraw, HWND window)
00130 {
00131     if (window == GetDesktopWindow())
00132         window = NULL;
00133     ddraw->swapchain_window = window;
00134 }
00135 
00136 /* Utility functions */
00137 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS *pIn, DDSCAPS2 *pOut) DECLSPEC_HIDDEN;
00138 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2 *pIn, DDDEVICEIDENTIFIER *pOut) DECLSPEC_HIDDEN;
00139 struct wined3d_vertex_declaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf) DECLSPEC_HIDDEN;
00140 
00141 /* The default surface type */
00142 extern WINED3DSURFTYPE DefaultSurfaceType DECLSPEC_HIDDEN;
00143 
00144 /*****************************************************************************
00145  * IDirectDrawSurface implementation structure
00146  *****************************************************************************/
00147 
00148 struct IDirectDrawSurfaceImpl
00149 {
00150     /* IUnknown fields */
00151     IDirectDrawSurface7 IDirectDrawSurface7_iface;
00152     IDirectDrawSurface4 IDirectDrawSurface4_iface;
00153     IDirectDrawSurface3 IDirectDrawSurface3_iface;
00154     IDirectDrawSurface2 IDirectDrawSurface2_iface;
00155     IDirectDrawSurface IDirectDrawSurface_iface;
00156     IDirectDrawGammaControl IDirectDrawGammaControl_iface;
00157     IDirect3DTexture2 IDirect3DTexture2_iface;
00158     IDirect3DTexture IDirect3DTexture_iface;
00159 
00160     LONG                     ref7, ref4, ref3, ref2, ref1, iface_count, gamma_count;
00161     IUnknown                *ifaceToRelease;
00162 
00163     int                     version;
00164 
00165     /* Connections to other Objects */
00166     IDirectDrawImpl         *ddraw;
00167     struct wined3d_surface *wined3d_surface;
00168     struct wined3d_texture *wined3d_texture;
00169 
00170     /* This implementation handles attaching surfaces to other surfaces */
00171     IDirectDrawSurfaceImpl  *next_attached;
00172     IDirectDrawSurfaceImpl  *first_attached;
00173     IUnknown                *attached_iface;
00174 
00175     /* Complex surfaces are organized in a tree, although the tree is degenerated to a list in most cases.
00176      * In mipmap and primary surfaces each level has only one attachment, which is the next surface level.
00177      * Only the cube texture root has 6 surfaces attached, which then have a normal mipmap chain attached
00178      * to them. So hardcode the array to 6, a dynamic array or a list would be an overkill.
00179      */
00180 #define MAX_COMPLEX_ATTACHED 6
00181     IDirectDrawSurfaceImpl  *complex_array[MAX_COMPLEX_ATTACHED];
00182     /* You can't traverse the tree upwards. Only a flag for Surface::Release because its needed there,
00183      * but no pointer to prevent temptations to traverse it in the wrong direction.
00184      */
00185     BOOL                    is_complex_root;
00186 
00187     /* Surface description, for GetAttachedSurface */
00188     DDSURFACEDESC2          surface_desc;
00189 
00190     /* Misc things */
00191     DWORD                   uniqueness_value;
00192     UINT                    mipmap_level;
00193 
00194     /* Clipper objects */
00195     struct ddraw_clipper *clipper;
00196 
00197     /* For the ddraw surface list */
00198     struct list             surface_list_entry;
00199 
00200     DWORD                   Handle;
00201 };
00202 
00203 HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface) DECLSPEC_HIDDEN;
00204 HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddraw,
00205         DDSURFACEDESC2 *desc, UINT mip_level, UINT version) DECLSPEC_HIDDEN;
00206 ULONG ddraw_surface_release_iface(IDirectDrawSurfaceImpl *This) DECLSPEC_HIDDEN;
00207 
00208 static inline IDirectDrawSurfaceImpl *impl_from_IDirect3DTexture(IDirect3DTexture *iface)
00209 {
00210     return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirect3DTexture_iface);
00211 }
00212 
00213 static inline IDirectDrawSurfaceImpl *impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface)
00214 {
00215     return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirect3DTexture2_iface);
00216 }
00217 
00218 static inline IDirectDrawSurfaceImpl *impl_from_IDirectDrawSurface(IDirectDrawSurface *iface)
00219 {
00220     return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface_iface);
00221 }
00222 
00223 static inline IDirectDrawSurfaceImpl *impl_from_IDirectDrawSurface2(IDirectDrawSurface2 *iface)
00224 {
00225     return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface2_iface);
00226 }
00227 
00228 static inline IDirectDrawSurfaceImpl *impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface)
00229 {
00230     return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface3_iface);
00231 }
00232 
00233 static inline IDirectDrawSurfaceImpl *impl_from_IDirectDrawSurface4(IDirectDrawSurface4 *iface)
00234 {
00235     return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface4_iface);
00236 }
00237 
00238 static inline IDirectDrawSurfaceImpl *impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface)
00239 {
00240     return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface7_iface);
00241 }
00242 
00243 IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface(IDirectDrawSurface *iface) DECLSPEC_HIDDEN;
00244 IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface4(IDirectDrawSurface4 *iface) DECLSPEC_HIDDEN;
00245 IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface) DECLSPEC_HIDDEN;
00246 
00247 IDirectDrawSurfaceImpl *unsafe_impl_from_IDirect3DTexture(IDirect3DTexture *iface) DECLSPEC_HIDDEN;
00248 IDirectDrawSurfaceImpl *unsafe_impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface) DECLSPEC_HIDDEN;
00249 
00250 #define DDRAW_INVALID_HANDLE ~0U
00251 
00252 enum ddraw_handle_type
00253 {
00254     DDRAW_HANDLE_FREE,
00255     DDRAW_HANDLE_MATERIAL,
00256     DDRAW_HANDLE_MATRIX,
00257     DDRAW_HANDLE_STATEBLOCK,
00258     DDRAW_HANDLE_SURFACE,
00259 };
00260 
00261 struct ddraw_handle_entry
00262 {
00263     void *object;
00264     enum ddraw_handle_type type;
00265 };
00266 
00267 struct ddraw_handle_table
00268 {
00269     struct ddraw_handle_entry *entries;
00270     struct ddraw_handle_entry *free_entries;
00271     UINT table_size;
00272     UINT entry_count;
00273 };
00274 
00275 BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size) DECLSPEC_HIDDEN;
00276 void ddraw_handle_table_destroy(struct ddraw_handle_table *t) DECLSPEC_HIDDEN;
00277 DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
00278 void *ddraw_free_handle(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
00279 void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
00280 
00281 struct IDirect3DDeviceImpl
00282 {
00283     /* IUnknown */
00284     IDirect3DDevice7 IDirect3DDevice7_iface;
00285     IDirect3DDevice3 IDirect3DDevice3_iface;
00286     IDirect3DDevice2 IDirect3DDevice2_iface;
00287     IDirect3DDevice IDirect3DDevice_iface;
00288     LONG                    ref;
00289 
00290     /* Other object connections */
00291     struct wined3d_device *wined3d_device;
00292     IDirectDrawImpl         *ddraw;
00293     struct wined3d_buffer *indexbuffer;
00294     IDirectDrawSurfaceImpl  *target;
00295 
00296     /* Viewport management */
00297     struct list viewport_list;
00298     IDirect3DViewportImpl *current_viewport;
00299     D3DVIEWPORT7 active_viewport;
00300 
00301     /* Required to keep track which of two available texture blending modes in d3ddevice3 is used */
00302     BOOL legacyTextureBlending;
00303     BOOL from_surface;
00304 
00305     D3DMATRIX legacy_projection;
00306     D3DMATRIX legacy_clipspace;
00307 
00308     /* Light state */
00309     DWORD material;
00310 
00311     /* Rendering functions to wrap D3D(1-3) to D3D7 */
00312     D3DPRIMITIVETYPE primitive_type;
00313     DWORD vertex_type;
00314     DWORD render_flags;
00315     DWORD nb_vertices;
00316     LPBYTE vertex_buffer;
00317     DWORD vertex_size;
00318     DWORD buffer_size;
00319 
00320     /* Handle management */
00321     struct ddraw_handle_table handle_table;
00322     D3DMATRIXHANDLE          world, proj, view;
00323 };
00324 
00325 HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw,
00326         IDirectDrawSurfaceImpl *target) DECLSPEC_HIDDEN;
00327 
00328 /* The IID */
00329 extern const GUID IID_D3DDEVICE_WineD3D DECLSPEC_HIDDEN;
00330 
00331 /* Helper functions */
00332 HRESULT IDirect3DImpl_GetCaps(const struct wined3d *wined3d,
00333         D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7) DECLSPEC_HIDDEN;
00334 enum wined3d_depth_buffer_type IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *device) DECLSPEC_HIDDEN;
00335 
00336 static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice(IDirect3DDevice *iface)
00337 {
00338     return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice_iface);
00339 }
00340 
00341 static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
00342 {
00343     return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice2_iface);
00344 }
00345 
00346 static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface)
00347 {
00348     return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice3_iface);
00349 }
00350 
00351 static inline IDirect3DDeviceImpl *impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface)
00352 {
00353     return CONTAINING_RECORD(iface, IDirect3DDeviceImpl, IDirect3DDevice7_iface);
00354 }
00355 
00356 IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice(IDirect3DDevice *iface) DECLSPEC_HIDDEN;
00357 IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface) DECLSPEC_HIDDEN;
00358 IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface) DECLSPEC_HIDDEN;
00359 IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface) DECLSPEC_HIDDEN;
00360 
00361 struct ddraw_clipper
00362 {
00363     IDirectDrawClipper IDirectDrawClipper_iface;
00364     LONG ref;
00365     HWND window;
00366     HRGN region;
00367     BOOL initialized;
00368 };
00369 
00370 HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper) DECLSPEC_HIDDEN;
00371 struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) DECLSPEC_HIDDEN;
00372 
00373 /*****************************************************************************
00374  * IDirectDrawPalette implementation structure
00375  *****************************************************************************/
00376 struct IDirectDrawPaletteImpl
00377 {
00378     /* IUnknown fields */
00379     IDirectDrawPalette IDirectDrawPalette_iface;
00380     LONG ref;
00381 
00382     struct wined3d_palette *wineD3DPalette;
00383 
00384     /* IDirectDrawPalette fields */
00385     IUnknown                  *ifaceToRelease;
00386 };
00387 
00388 static inline IDirectDrawPaletteImpl *impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
00389 {
00390     return CONTAINING_RECORD(iface, IDirectDrawPaletteImpl, IDirectDrawPalette_iface);
00391 }
00392 
00393 IDirectDrawPaletteImpl *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface) DECLSPEC_HIDDEN;
00394 
00395 HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
00396         IDirectDrawImpl *ddraw, DWORD flags, PALETTEENTRY *entries) DECLSPEC_HIDDEN;
00397 
00398 /* Helper structures */
00399 struct object_creation_info
00400 {
00401     const CLSID *clsid;
00402     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
00403                                  void **ppObj);
00404 };
00405 
00406 /******************************************************************************
00407  * IDirect3DLight implementation structure - Wraps to D3D7
00408  ******************************************************************************/
00409 struct IDirect3DLightImpl
00410 {
00411     IDirect3DLight IDirect3DLight_iface;
00412     LONG ref;
00413 
00414     /* IDirect3DLight fields */
00415     IDirectDrawImpl           *ddraw;
00416 
00417     /* If this light is active for one viewport, put the viewport here */
00418     IDirect3DViewportImpl     *active_viewport;
00419 
00420     D3DLIGHT2 light;
00421     D3DLIGHT7 light7;
00422 
00423     DWORD dwLightIndex;
00424 
00425     struct list entry;
00426 };
00427 
00428 /* Helper functions */
00429 void light_activate(IDirect3DLightImpl *light) DECLSPEC_HIDDEN;
00430 void light_deactivate(IDirect3DLightImpl *light) DECLSPEC_HIDDEN;
00431 void d3d_light_init(IDirect3DLightImpl *light, IDirectDrawImpl *ddraw) DECLSPEC_HIDDEN;
00432 IDirect3DLightImpl *unsafe_impl_from_IDirect3DLight(IDirect3DLight *iface) DECLSPEC_HIDDEN;
00433 
00434 /******************************************************************************
00435  * IDirect3DMaterial implementation structure - Wraps to D3D7
00436  ******************************************************************************/
00437 struct IDirect3DMaterialImpl
00438 {
00439     IDirect3DMaterial3 IDirect3DMaterial3_iface;
00440     IDirect3DMaterial2 IDirect3DMaterial2_iface;
00441     IDirect3DMaterial IDirect3DMaterial_iface;
00442     LONG  ref;
00443 
00444     /* IDirect3DMaterial2 fields */
00445     IDirectDrawImpl               *ddraw;
00446     IDirect3DDeviceImpl           *active_device;
00447 
00448     D3DMATERIAL mat;
00449     DWORD Handle;
00450 };
00451 
00452 /* Helper functions */
00453 void material_activate(IDirect3DMaterialImpl* This) DECLSPEC_HIDDEN;
00454 IDirect3DMaterialImpl *d3d_material_create(IDirectDrawImpl *ddraw) DECLSPEC_HIDDEN;
00455 
00456 /*****************************************************************************
00457  * IDirect3DViewport - Wraps to D3D7
00458  *****************************************************************************/
00459 struct IDirect3DViewportImpl
00460 {
00461     IDirect3DViewport3 IDirect3DViewport3_iface;
00462     LONG ref;
00463 
00464     /* IDirect3DViewport fields */
00465     IDirectDrawImpl           *ddraw;
00466 
00467     /* If this viewport is active for one device, put the device here */
00468     IDirect3DDeviceImpl       *active_device;
00469 
00470     DWORD                     num_lights;
00471     DWORD                     map_lights;
00472 
00473     int                       use_vp2;
00474 
00475     union
00476     {
00477         D3DVIEWPORT vp1;
00478         D3DVIEWPORT2 vp2;
00479     } viewports;
00480 
00481     struct list entry;
00482     struct list light_list;
00483 
00484     /* Background material */
00485     IDirect3DMaterialImpl     *background;
00486 };
00487 
00488 IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport3(IDirect3DViewport3 *iface) DECLSPEC_HIDDEN;
00489 IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport2(IDirect3DViewport2 *iface) DECLSPEC_HIDDEN;
00490 IDirect3DViewportImpl *unsafe_impl_from_IDirect3DViewport(IDirect3DViewport *iface) DECLSPEC_HIDDEN;
00491 
00492 /* Helper functions */
00493 void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights) DECLSPEC_HIDDEN;
00494 void d3d_viewport_init(IDirect3DViewportImpl *viewport, IDirectDrawImpl *ddraw) DECLSPEC_HIDDEN;
00495 
00496 /*****************************************************************************
00497  * IDirect3DExecuteBuffer - Wraps to D3D7
00498  *****************************************************************************/
00499 struct IDirect3DExecuteBufferImpl
00500 {
00501     IDirect3DExecuteBuffer IDirect3DExecuteBuffer_iface;
00502     LONG ref;
00503     /* IDirect3DExecuteBuffer fields */
00504     IDirectDrawImpl      *ddraw;
00505     IDirect3DDeviceImpl  *d3ddev;
00506 
00507     D3DEXECUTEBUFFERDESC desc;
00508     D3DEXECUTEDATA       data;
00509 
00510     /* This buffer will store the transformed vertices */
00511     void                 *vertex_data;
00512     WORD                 *indices;
00513     int                  nb_indices;
00514 
00515     /* This flags is set to TRUE if we allocated ourselves the
00516      * data buffer
00517      */
00518     BOOL                 need_free;
00519 };
00520 
00521 HRESULT d3d_execute_buffer_init(IDirect3DExecuteBufferImpl *execute_buffer,
00522         IDirect3DDeviceImpl *device, D3DEXECUTEBUFFERDESC *desc) DECLSPEC_HIDDEN;
00523 IDirect3DExecuteBufferImpl *unsafe_impl_from_IDirect3DExecuteBuffer(IDirect3DExecuteBuffer *iface) DECLSPEC_HIDDEN;
00524 
00525 /* The execute function */
00526 HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *execute_buffer,
00527         IDirect3DDeviceImpl *device, IDirect3DViewportImpl *viewport) DECLSPEC_HIDDEN;
00528 
00529 /*****************************************************************************
00530  * IDirect3DVertexBuffer
00531  *****************************************************************************/
00532 struct IDirect3DVertexBufferImpl
00533 {
00534     IDirect3DVertexBuffer7 IDirect3DVertexBuffer7_iface;
00535     IDirect3DVertexBuffer IDirect3DVertexBuffer_iface;
00536     LONG ref;
00537 
00538     /*** WineD3D and ddraw links ***/
00539     struct wined3d_buffer *wineD3DVertexBuffer;
00540     struct wined3d_vertex_declaration *wineD3DVertexDeclaration;
00541     IDirectDrawImpl *ddraw;
00542 
00543     /*** Storage for D3D7 specific things ***/
00544     DWORD                Caps;
00545     DWORD                fvf;
00546 };
00547 
00548 HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirectDrawImpl *ddraw,
00549         D3DVERTEXBUFFERDESC *desc) DECLSPEC_HIDDEN;
00550 IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer *iface) DECLSPEC_HIDDEN;
00551 IDirect3DVertexBufferImpl *unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7 *iface) DECLSPEC_HIDDEN;
00552 
00553 /*****************************************************************************
00554  * Helper functions from utils.c
00555  *****************************************************************************/
00556 
00557 #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
00558     (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
00559 
00560 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
00561     (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
00562 
00563 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, enum wined3d_format_id WineD3DFormat) DECLSPEC_HIDDEN;
00564 enum wined3d_format_id PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat) DECLSPEC_HIDDEN;
00565 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd) DECLSPEC_HIDDEN;
00566 void dump_D3DMATRIX(const D3DMATRIX *mat) DECLSPEC_HIDDEN;
00567 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) DECLSPEC_HIDDEN;
00568 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
00569 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in) DECLSPEC_HIDDEN;
00570 void DDRAW_dump_cooperativelevel(DWORD cooplevel) DECLSPEC_HIDDEN;
00571 void DDSD_to_DDSD2(const DDSURFACEDESC *in, DDSURFACEDESC2 *out) DECLSPEC_HIDDEN;
00572 void DDSD2_to_DDSD(const DDSURFACEDESC2 *in, DDSURFACEDESC *out) DECLSPEC_HIDDEN;
00573 
00574 /* This only needs to be here as long the processvertices functionality of
00575  * IDirect3DExecuteBuffer isn't in WineD3D */
00576 void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2) DECLSPEC_HIDDEN;
00577 
00578 /* Used for generic dumping */
00579 typedef struct
00580 {
00581     DWORD val;
00582     const char* name;
00583 } flag_info;
00584 
00585 #define FE(x) { x, #x }
00586 
00587 typedef struct
00588 {
00589     DWORD val;
00590     const char* name;
00591     void (*func)(const void *);
00592     ptrdiff_t offset;
00593 } member_info;
00594 
00595 /* Structure copy */
00596 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
00597 
00598 #define DD_STRUCT_COPY_BYSIZE_(to,from,from_size)                 \
00599     do {                                                          \
00600         DWORD __size = (to)->dwSize;                              \
00601         DWORD __resetsize = min(__size, sizeof(*to));             \
00602         DWORD __copysize = min(__resetsize, from_size);           \
00603         assert(to != from);                                       \
00604         memcpy(to, from, __copysize);                             \
00605         memset((char*)(to) + __copysize, 0, __resetsize - __copysize); \
00606         (to)->dwSize = __size; /* restore size */                 \
00607     } while (0)
00608 
00609 #define DD_STRUCT_COPY_BYSIZE(to,from) DD_STRUCT_COPY_BYSIZE_(to,from,(from)->dwSize)
00610 
00611 #define SIZEOF_END_PADDING(type, last_field) \
00612     (sizeof(type) - offsetof(type, last_field) - sizeof(((type *)0)->last_field))
00613 
00614 static inline void copy_to_surfacedesc2(DDSURFACEDESC2 *to, DDSURFACEDESC2 *from)
00615 {
00616     DWORD from_size = from->dwSize;
00617     if (from_size == sizeof(DDSURFACEDESC))
00618         from_size -= SIZEOF_END_PADDING(DDSURFACEDESC, ddsCaps);
00619     to->dwSize = sizeof(DDSURFACEDESC2); /* for struct copy */
00620     DD_STRUCT_COPY_BYSIZE_(to, from, from_size);
00621 }
00622 
00623 HRESULT hr_ddraw_from_wined3d(HRESULT hr) DECLSPEC_HIDDEN;
00624 
00625 #endif

Generated on Sun May 27 2012 04:22:15 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.