OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 19 matching lines...) Expand all Loading... |
30 */ | 30 */ |
31 | 31 |
32 | 32 |
33 #ifndef O3D_COMMAND_BUFFER_SERVICE_WIN_D3D9_RENDER_SURFACE_D3D9_H_ | 33 #ifndef O3D_COMMAND_BUFFER_SERVICE_WIN_D3D9_RENDER_SURFACE_D3D9_H_ |
34 #define O3D_COMMAND_BUFFER_SERVICE_WIN_D3D9_RENDER_SURFACE_D3D9_H_ | 34 #define O3D_COMMAND_BUFFER_SERVICE_WIN_D3D9_RENDER_SURFACE_D3D9_H_ |
35 | 35 |
36 // This file contains the definition of the D3D9 versions of | 36 // This file contains the definition of the D3D9 versions of |
37 // render surface-related resource classes. | 37 // render surface-related resource classes. |
38 | 38 |
39 #include <d3d9.h> | 39 #include <d3d9.h> |
| 40 #include "base/scoped_ptr.h" |
40 #include "command_buffer/common/cross/gapi_interface.h" | 41 #include "command_buffer/common/cross/gapi_interface.h" |
| 42 #include "command_buffer/service/cross/resource.h" |
41 #include "command_buffer/service/win/d3d9/d3d9_utils.h" | 43 #include "command_buffer/service/win/d3d9/d3d9_utils.h" |
42 #include "command_buffer/service/cross/resource.h" | 44 #include "command_buffer/service/win/d3d9/texture_d3d9.h" |
43 | 45 |
44 namespace o3d { | 46 namespace o3d { |
45 namespace command_buffer { | 47 namespace command_buffer { |
46 | 48 |
47 class GAPID3D9; | 49 class GAPID3D9; |
48 | 50 |
| 51 // The RenderSurfaceD3D class represents a render surface resource in the d3d |
| 52 // backend of the command buffer server. |
49 class RenderSurfaceD3D9 : public RenderSurface { | 53 class RenderSurfaceD3D9 : public RenderSurface { |
50 public: | 54 public: |
| 55 |
| 56 // Creates a render surface resource based on D3D. |
| 57 // Parameters: |
| 58 // width - width of the surface to be created. Must match width of texture |
| 59 // at mip_level. |
| 60 // height - height of the surface to be created. Must match width of |
| 61 // texture at mip_level. |
| 62 // mip_level - mip level of the texture to which the render surface maps. |
| 63 // side - side of a cube if texture is a cube texture. Does not apply to |
| 64 // texture 2d's. |
| 65 // texture - the texture to which this render surface maps. Not owned by |
| 66 // the RenderSurfaceD3D9. |
| 67 // direct3d_surface - a surface to be used as this render surface's |
| 68 // rendering surface. The new RenderSurfaceD3D9 will own the |
| 69 // direct3d_surface. |
51 RenderSurfaceD3D9(int width, | 70 RenderSurfaceD3D9(int width, |
52 int height, | 71 int height, |
53 int mip_level, | 72 int mip_level, |
54 int side, | 73 int side, |
55 TextureD3D9 *texture, | 74 TextureD3D9 *texture, |
56 IDirect3DSurface9* direct3d_surface); | 75 IDirect3DSurface9 *direct3d_surface); |
| 76 |
| 77 // Destructor for the render surface. |
57 virtual ~RenderSurfaceD3D9() {} | 78 virtual ~RenderSurfaceD3D9() {} |
58 | 79 |
| 80 // Performs the setup necessary to create a render surface resource based on |
| 81 // D3D and returns a new one if possibe. |
| 82 // Parameters: |
| 83 // gapi - the gapi interface to D3D. |
| 84 // width - width of the surface to be created. Must match width of texture |
| 85 // at mip_level. |
| 86 // height - height of the surface to be created. Must match width of |
| 87 // texture at mip_level. |
| 88 // mip_level - mip level of the texture to which the render surface maps. |
| 89 // side - side of a cube if texture is a cube texture. Does not apply to |
| 90 // texture 2d's. |
| 91 // texture - the texture to which this render surface maps. |
| 92 // Returns: |
| 93 // a new RenderSurfaceD3D9 or NULL on failure |
59 static RenderSurfaceD3D9* Create(GAPID3D9 *gapi, | 94 static RenderSurfaceD3D9* Create(GAPID3D9 *gapi, |
60 int width, | 95 int width, |
61 int height, | 96 int height, |
62 int mip_level, | 97 int mip_level, |
63 int side, | 98 int side, |
64 TextureD3D9 *texture); | 99 TextureD3D9 *texture); |
65 IDirect3DSurface9* GetSurfaceHandle() const { | 100 |
| 101 // Returns a reference to the actual direct3d surface that is rendered to. |
| 102 IDirect3DSurface9* direct3d_surface() const { |
66 return direct3d_surface_; | 103 return direct3d_surface_; |
67 } | 104 } |
68 private: | 105 private: |
69 CComPtr<IDirect3DSurface9> direct3d_surface_; | 106 CComPtr<IDirect3DSurface9> direct3d_surface_; |
70 unsigned int width_; | 107 int width_; |
71 unsigned int height_; | 108 int height_; |
72 unsigned int mip_level_; | 109 int mip_level_; |
73 TextureD3D9* texture_; | 110 TextureD3D9 *texture_; |
74 DISALLOW_COPY_AND_ASSIGN(RenderSurfaceD3D9); | 111 DISALLOW_COPY_AND_ASSIGN(RenderSurfaceD3D9); |
75 }; | 112 }; |
76 | 113 |
| 114 // The RenderDepthStencilSurfaceD3D class represents a depth stencil surface |
| 115 // resource in the d3d backend of the command buffer server. |
77 class RenderDepthStencilSurfaceD3D9 : public RenderDepthStencilSurface { | 116 class RenderDepthStencilSurfaceD3D9 : public RenderDepthStencilSurface { |
78 public: | 117 public: |
| 118 |
| 119 // Creates a depth stencil surface resource based on D3D. |
| 120 // Parameters: |
| 121 // width - width of the surface to be created. |
| 122 // height - height of the surface to be created. |
| 123 // direct3d_surface - a surface to be used as this depth stencil surface's |
| 124 // rendering rendering surface. The new RenderDepthStencilSurfaceD3D9 |
| 125 // will own the direct3d_surface. |
79 RenderDepthStencilSurfaceD3D9(int width, | 126 RenderDepthStencilSurfaceD3D9(int width, |
80 int height, | 127 int height, |
81 IDirect3DSurface9* direct3d_surface); | 128 IDirect3DSurface9 *direct3d_surface); |
| 129 |
| 130 // Destructor for the depth stencil surface. |
82 virtual ~RenderDepthStencilSurfaceD3D9() {} | 131 virtual ~RenderDepthStencilSurfaceD3D9() {} |
83 | 132 |
84 static RenderDepthStencilSurfaceD3D9* Create( | 133 |
85 GAPID3D9 *gapi, | 134 // Performs the setup necessary to create a depth stencil surface resource |
86 int width, | 135 // based on D3D and returns a new one if possibe. |
87 int height); | 136 // Parameters: |
88 IDirect3DSurface9* GetSurfaceHandle() const { | 137 // gapi - the gapi interface to D3D. |
| 138 // width - width of the surface to be created. |
| 139 // height - height of the surface to be created. |
| 140 // Returns: |
| 141 // a new RenderDepthStencilSurfaceD3D9 or NULL on failure. |
| 142 static RenderDepthStencilSurfaceD3D9* Create(GAPID3D9 *gapi, |
| 143 int width, |
| 144 int height); |
| 145 |
| 146 // Returns a reference to the actual direct3d surface that is rendered to. |
| 147 IDirect3DSurface9* direct3d_surface() const { |
89 return direct3d_surface_; | 148 return direct3d_surface_; |
90 } | 149 } |
91 private: | 150 private: |
92 CComPtr<IDirect3DSurface9> direct3d_surface_; | 151 CComPtr<IDirect3DSurface9> direct3d_surface_; |
93 unsigned int width_; | 152 int width_; |
94 unsigned int height_; | 153 int height_; |
95 DISALLOW_COPY_AND_ASSIGN(RenderDepthStencilSurfaceD3D9); | 154 DISALLOW_COPY_AND_ASSIGN(RenderDepthStencilSurfaceD3D9); |
96 }; | 155 }; |
97 | 156 |
98 } // namespace command_buffer | 157 } // namespace command_buffer |
99 } // namespace o3d | 158 } // namespace o3d |
100 | 159 |
101 #endif // O3D_COMMAND_BUFFER_SERVICE_WIN_D3D9_RENDER_SURFACE_D3D9_H_ | 160 #endif // O3D_COMMAND_BUFFER_SERVICE_WIN_D3D9_RENDER_SURFACE_D3D9_H_ |
102 | 161 |
OLD | NEW |