| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Copies the data from a texture resource. | 129 // Copies the data from a texture resource. |
| 130 BufferSyncInterface::ParseError GAPID3D9::CreateRenderSurface( | 130 BufferSyncInterface::ParseError GAPID3D9::CreateRenderSurface( |
| 131 ResourceID id, | 131 ResourceID id, |
| 132 unsigned int width, | 132 unsigned int width, |
| 133 unsigned int height, | 133 unsigned int height, |
| 134 unsigned int mip_level, | 134 unsigned int mip_level, |
| 135 unsigned int side, | 135 unsigned int side, |
| 136 ResourceID texture_id) { | 136 ResourceID texture_id) { |
| 137 if (id == current_surface_id_) { | 137 if (id == current_surface_id_) { |
| 138 // This will delete the current surface which would be bad. | 138 // This will delete the current surface which would be bad. |
| 139 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 139 return BufferSyncInterface::kParseInvalidArguments; |
| 140 } | 140 } |
| 141 TextureD3D9 *texture = textures_.Get(texture_id); | 141 TextureD3D9 *texture = textures_.Get(texture_id); |
| 142 if (!texture->render_surfaces_enabled()) { | 142 if (!texture->render_surfaces_enabled()) { |
| 143 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 143 return BufferSyncInterface::kParseInvalidArguments; |
| 144 } else { | 144 } else { |
| 145 RenderSurfaceD3D9 *render_surface = RenderSurfaceD3D9::Create(this, | 145 RenderSurfaceD3D9 *render_surface = RenderSurfaceD3D9::Create(this, |
| 146 width, | 146 width, |
| 147 height, | 147 height, |
| 148 mip_level, | 148 mip_level, |
| 149 side, | 149 side, |
| 150 texture); | 150 texture); |
| 151 if (render_surface == NULL) { | 151 if (render_surface == NULL) { |
| 152 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 152 return BufferSyncInterface::kParseInvalidArguments; |
| 153 } | 153 } |
| 154 render_surfaces_.Assign(id, render_surface); | 154 render_surfaces_.Assign(id, render_surface); |
| 155 } | 155 } |
| 156 return BufferSyncInterface::PARSE_NO_ERROR; | 156 return BufferSyncInterface::kParseNoError; |
| 157 } | 157 } |
| 158 | 158 |
| 159 BufferSyncInterface::ParseError GAPID3D9::DestroyRenderSurface(ResourceID id) { | 159 BufferSyncInterface::ParseError GAPID3D9::DestroyRenderSurface(ResourceID id) { |
| 160 if (id == current_surface_id_) { | 160 if (id == current_surface_id_) { |
| 161 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 161 return BufferSyncInterface::kParseInvalidArguments; |
| 162 } | 162 } |
| 163 return render_surfaces_.Destroy(id) ? | 163 return render_surfaces_.Destroy(id) ? |
| 164 BufferSyncInterface::PARSE_NO_ERROR : | 164 BufferSyncInterface::kParseNoError : |
| 165 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 165 BufferSyncInterface::kParseInvalidArguments; |
| 166 } | 166 } |
| 167 | 167 |
| 168 BufferSyncInterface::ParseError GAPID3D9::CreateDepthSurface( | 168 BufferSyncInterface::ParseError GAPID3D9::CreateDepthSurface( |
| 169 ResourceID id, | 169 ResourceID id, |
| 170 unsigned int width, | 170 unsigned int width, |
| 171 unsigned int height) { | 171 unsigned int height) { |
| 172 if (id == current_depth_surface_id_) { | 172 if (id == current_depth_surface_id_) { |
| 173 // This will delete the current surface which would be bad. | 173 // This will delete the current surface which would be bad. |
| 174 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 174 return BufferSyncInterface::kParseInvalidArguments; |
| 175 } | 175 } |
| 176 RenderDepthStencilSurfaceD3D9 *depth_surface = | 176 RenderDepthStencilSurfaceD3D9 *depth_surface = |
| 177 RenderDepthStencilSurfaceD3D9::Create(this, width, height); | 177 RenderDepthStencilSurfaceD3D9::Create(this, width, height); |
| 178 if (depth_surface == NULL) { | 178 if (depth_surface == NULL) { |
| 179 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 179 return BufferSyncInterface::kParseInvalidArguments; |
| 180 } | 180 } |
| 181 depth_surfaces_.Assign(id, depth_surface); | 181 depth_surfaces_.Assign(id, depth_surface); |
| 182 return BufferSyncInterface::PARSE_NO_ERROR; | 182 return BufferSyncInterface::kParseNoError; |
| 183 } | 183 } |
| 184 | 184 |
| 185 BufferSyncInterface::ParseError GAPID3D9::DestroyDepthSurface(ResourceID id) { | 185 BufferSyncInterface::ParseError GAPID3D9::DestroyDepthSurface(ResourceID id) { |
| 186 if (id == current_depth_surface_id_) { | 186 if (id == current_depth_surface_id_) { |
| 187 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 187 return BufferSyncInterface::kParseInvalidArguments; |
| 188 } | 188 } |
| 189 return depth_surfaces_.Destroy(id) ? | 189 return depth_surfaces_.Destroy(id) ? |
| 190 BufferSyncInterface::PARSE_NO_ERROR : | 190 BufferSyncInterface::kParseNoError : |
| 191 BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 191 BufferSyncInterface::kParseInvalidArguments; |
| 192 } | 192 } |
| 193 | 193 |
| 194 BufferSyncInterface::ParseError GAPID3D9::SetRenderSurface( | 194 BufferSyncInterface::ParseError GAPID3D9::SetRenderSurface( |
| 195 ResourceID render_surface_id, | 195 ResourceID render_surface_id, |
| 196 ResourceID depth_stencil_id) { | 196 ResourceID depth_stencil_id) { |
| 197 RenderSurfaceD3D9 *d3d_render_surface = | 197 RenderSurfaceD3D9 *d3d_render_surface = |
| 198 render_surfaces_.Get(render_surface_id); | 198 render_surfaces_.Get(render_surface_id); |
| 199 RenderDepthStencilSurfaceD3D9 *d3d_render_depth_surface = | 199 RenderDepthStencilSurfaceD3D9 *d3d_render_depth_surface = |
| 200 depth_surfaces_.Get(depth_stencil_id); | 200 depth_surfaces_.Get(depth_stencil_id); |
| 201 | 201 |
| 202 if (d3d_render_surface == NULL && d3d_render_depth_surface == NULL) { | 202 if (d3d_render_surface == NULL && d3d_render_depth_surface == NULL) { |
| 203 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 203 return BufferSyncInterface::kParseInvalidArguments; |
| 204 } | 204 } |
| 205 | 205 |
| 206 IDirect3DSurface9 *d3d_surface = | 206 IDirect3DSurface9 *d3d_surface = |
| 207 d3d_render_surface ? d3d_render_surface->direct3d_surface() : NULL; | 207 d3d_render_surface ? d3d_render_surface->direct3d_surface() : NULL; |
| 208 IDirect3DSurface9 *d3d_depth_surface = d3d_render_depth_surface ? | 208 IDirect3DSurface9 *d3d_depth_surface = d3d_render_depth_surface ? |
| 209 d3d_render_depth_surface->direct3d_surface() : NULL; | 209 d3d_render_depth_surface->direct3d_surface() : NULL; |
| 210 | 210 |
| 211 // Get the device and set the render target and the depth stencil surface. | 211 // Get the device and set the render target and the depth stencil surface. |
| 212 IDirect3DDevice9 *device = this->d3d_device(); | 212 IDirect3DDevice9 *device = this->d3d_device(); |
| 213 | 213 |
| 214 HR(device->SetRenderTarget(0, d3d_surface)); | 214 HR(device->SetRenderTarget(0, d3d_surface)); |
| 215 HR(device->SetDepthStencilSurface(d3d_depth_surface)); | 215 HR(device->SetDepthStencilSurface(d3d_depth_surface)); |
| 216 current_surface_id_ = render_surface_id; | 216 current_surface_id_ = render_surface_id; |
| 217 current_depth_surface_id_ = depth_stencil_id; | 217 current_depth_surface_id_ = depth_stencil_id; |
| 218 return BufferSyncInterface::PARSE_NO_ERROR; | 218 return BufferSyncInterface::kParseNoError; |
| 219 } | 219 } |
| 220 | 220 |
| 221 void GAPID3D9::SetBackSurfaces() { | 221 void GAPID3D9::SetBackSurfaces() { |
| 222 // Get the device and set the render target and the depth stencil surface. | 222 // Get the device and set the render target and the depth stencil surface. |
| 223 IDirect3DDevice9 *device = this->d3d_device(); | 223 IDirect3DDevice9 *device = this->d3d_device(); |
| 224 HR(d3d_device()->SetRenderTarget(0, back_buffer_surface_)); | 224 HR(d3d_device()->SetRenderTarget(0, back_buffer_surface_)); |
| 225 HR(d3d_device()->SetDepthStencilSurface(back_buffer_depth_surface_)); | 225 HR(d3d_device()->SetDepthStencilSurface(back_buffer_depth_surface_)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace command_buffer | 228 } // namespace command_buffer |
| 229 } // namespace o3d | 229 } // namespace o3d |
| 230 | 230 |
| OLD | NEW |