summaryrefslogtreecommitdiff
path: root/sys/d3dvideosink/directx/directx_d3d.h
blob: 54e0c08dd4381d425f3c61c339e4a555d2bf2802 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* GStreamer
 * Copyright (C) 2011 David Hoyt <dhoyt@hoytsoft.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __DIRECTX_D3D_H__
#define __DIRECTX_D3D_H__

#include <glib.h>

#include "dx.h"

G_BEGIN_DECLS

#define WM_DIRECTX_D3D_INIT_DEVICE      WM_DIRECTX + 1
#define WM_DIRECTX_D3D_INIT_DEVICELOST  WM_DIRECTX + 2
#define WM_DIRECTX_D3D_DEVICELOST       WM_DIRECTX + 3
#define WM_DIRECTX_D3D_END_DEVICELOST   WM_DIRECTX + 4
#define WM_DIRECTX_D3D_RESIZE           WM_DIRECTX + 5

#define DIRECTX_D3D_API(version, dispatch_table, init_function, create_function, resize_function, device_lost_function, notify_device_reset_function, release_function) \
  static gpointer G_GNUC_UNUSED DIRECTX_API_COMPONENT_D3D_ ## version ## _DISPATCH_TABLE = &dispatch_table;                                                                           \
  static DirectXAPIComponentD3D G_GNUC_UNUSED DIRECTX_API_COMPONENT_D3D_ ## version ## _INIT = {                                                                                      \
      create_function               /*create_function*/                                                                                                                 \
    , resize_function               /*resize_function*/                                                                                                                 \
    , device_lost_function          /*device_lost_function*/                                                                                                            \
    , notify_device_reset_function  /*notify_device_reset_function*/                                                                                                    \
    , release_function              /*release_function*/                                                                                                                \
    , NULL                          /*private_data*/                                                                                                                    \
  };                                                                                                                                                                    \
  static void G_GNUC_UNUSED init_directx_api_component_d3d_ ## version ## _(const DirectXAPI* api) {                                                                                  \
    gpointer private_data = &DIRECTX_API_COMPONENT_D3D_ ## version ## _INIT;                                                                                            \
    gpointer vtable = DIRECTX_API_COMPONENT_D3D_ ## version ## _DISPATCH_TABLE;                                                                                         \
    DIRECTX_SET_COMPONENT_INIT(DIRECTX_D3D(api), init_function);                                                                                                        \
    DIRECTX_SET_COMPONENT_DATA(DIRECTX_D3D(api), private_data);                                                                                                         \
    DIRECTX_SET_COMPONENT_DISPATCH_TABLE(DIRECTX_D3D(api), vtable);                                                                                                     \
  }

#define INITIALIZE_DIRECTX_D3D_API(version, api)                                                                                                                        \
  init_directx_api_component_d3d_ ## version ## _(api);

#define DIRECTX_D3D_FUNCTIONS(d3d)                          ((DirectXAPIComponentD3D*)d3d->d3d_component)
#define DIRECTX_D3D_API_FUNCTIONS(api)                      ((DirectXAPIComponentD3D*)DIRECTX_D3D_COMPONENT_DATA(api))
#define DIRECTX_D3D_CALL_FUNCTION(d3d, func_name, ...)      (DIRECTX_D3D_FUNCTIONS(d3d)->func_name(__VA_ARGS__))
#define DIRECTX_D3D_CALL_API_FUNCTION(api, func_name, ...)  (DIRECTX_D3D_API_FUNCTIONS(api)->func_name(__VA_ARGS__))

typedef struct _DirectXD3D DirectXD3D;
typedef struct _DirectXAPIComponentD3D DirectXAPIComponentD3D;

/* Function pointers */
typedef DirectXD3D* (*DirectXD3DCreateFunction)             (const DirectXAPI* api);
typedef gboolean    (*DirectXD3DResizeFunction)             (const DirectXD3D* d3d);
typedef gboolean    (*DirectXD3DDeviceLostFunction)         (const DirectXD3D* d3d);
typedef gboolean    (*DirectXD3DNotifyDeviceResetFunction)  (const DirectXD3D* d3d);
typedef gboolean    (*DirectXD3DReleaseFunction)            (const DirectXD3D* d3d);

struct _DirectXAPIComponentD3D 
{
  DirectXD3DCreateFunction              create;
  DirectXD3DResizeFunction              resize;
  DirectXD3DDeviceLostFunction          device_lost;
  DirectXD3DNotifyDeviceResetFunction   notify_device_reset;
  DirectXD3DReleaseFunction             release;

  gpointer                              private_data;
};

struct _DirectXD3D 
{
  DirectXAPI*               api;
  DirectXAPIComponent*      api_component;
  DirectXAPIComponentD3D*   d3d_component;

  gpointer                  private_data;
};

const DirectXD3D* directx_d3d_create(const DirectXAPI* api);
gboolean directx_d3d_resize(const DirectXD3D* d3d);
gboolean directx_d3d_device_lost(const DirectXD3D* d3d);
gboolean directx_d3d_notify_device_reset(const DirectXD3D* d3d);
gboolean directx_d3d_release(const DirectXD3D* d3d);

G_END_DECLS

#endif /* __DIRECTX_D3D_H__ */