| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 int width, | 103 int width, |
| 104 int height) { | 104 int height) { |
| 105 DCHECK_GT(width, 0); | 105 DCHECK_GT(width, 0); |
| 106 DCHECK_GT(height, 0); | 106 DCHECK_GT(height, 0); |
| 107 | 107 |
| 108 return new RenderDepthStencilSurfaceGL(height, width); | 108 return new RenderDepthStencilSurfaceGL(height, width); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Copies the data from a texture resource. | 111 // Copies the data from a texture resource. |
| 112 BufferSyncInterface::ParseError GAPIGL::CreateRenderSurface( | 112 BufferSyncInterface::ParseError GAPIGL::CreateRenderSurface( |
| 113 ResourceID id, | 113 ResourceId id, |
| 114 unsigned int width, | 114 unsigned int width, |
| 115 unsigned int height, | 115 unsigned int height, |
| 116 unsigned int mip_level, | 116 unsigned int mip_level, |
| 117 unsigned int side, | 117 unsigned int side, |
| 118 ResourceID texture_id) { | 118 ResourceId texture_id) { |
| 119 if (id == current_surface_id_) { | 119 if (id == current_surface_id_) { |
| 120 // This will delete the current surface which would be bad. | 120 // This will delete the current surface which would be bad. |
| 121 return BufferSyncInterface::kParseInvalidArguments; | 121 return BufferSyncInterface::kParseInvalidArguments; |
| 122 } | 122 } |
| 123 TextureGL *texture = textures_.Get(texture_id); | 123 TextureGL *texture = textures_.Get(texture_id); |
| 124 if (!texture->render_surfaces_enabled()) { | 124 if (!texture->render_surfaces_enabled()) { |
| 125 return BufferSyncInterface::kParseInvalidArguments; | 125 return BufferSyncInterface::kParseInvalidArguments; |
| 126 } else { | 126 } else { |
| 127 RenderSurfaceGL* render_surface = RenderSurfaceGL::Create(width, | 127 RenderSurfaceGL* render_surface = RenderSurfaceGL::Create(width, |
| 128 height, | 128 height, |
| 129 mip_level, | 129 mip_level, |
| 130 side, | 130 side, |
| 131 texture); | 131 texture); |
| 132 if (render_surface == NULL) { | 132 if (render_surface == NULL) { |
| 133 return BufferSyncInterface::kParseInvalidArguments; | 133 return BufferSyncInterface::kParseInvalidArguments; |
| 134 } | 134 } |
| 135 render_surfaces_.Assign(id, render_surface); | 135 render_surfaces_.Assign(id, render_surface); |
| 136 } | 136 } |
| 137 return BufferSyncInterface::kParseNoError; | 137 return BufferSyncInterface::kParseNoError; |
| 138 } | 138 } |
| 139 | 139 |
| 140 BufferSyncInterface::ParseError GAPIGL::DestroyRenderSurface(ResourceID id) { | 140 BufferSyncInterface::ParseError GAPIGL::DestroyRenderSurface(ResourceId id) { |
| 141 if (id == current_surface_id_) { | 141 if (id == current_surface_id_) { |
| 142 return BufferSyncInterface::kParseInvalidArguments; | 142 return BufferSyncInterface::kParseInvalidArguments; |
| 143 } | 143 } |
| 144 return render_surfaces_.Destroy(id) ? | 144 return render_surfaces_.Destroy(id) ? |
| 145 BufferSyncInterface::kParseNoError : | 145 BufferSyncInterface::kParseNoError : |
| 146 BufferSyncInterface::kParseInvalidArguments; | 146 BufferSyncInterface::kParseInvalidArguments; |
| 147 } | 147 } |
| 148 | 148 |
| 149 BufferSyncInterface::ParseError GAPIGL::CreateDepthSurface( | 149 BufferSyncInterface::ParseError GAPIGL::CreateDepthSurface( |
| 150 ResourceID id, | 150 ResourceId id, |
| 151 unsigned int width, | 151 unsigned int width, |
| 152 unsigned int height) { | 152 unsigned int height) { |
| 153 if (id == current_depth_surface_id_) { | 153 if (id == current_depth_surface_id_) { |
| 154 // This will delete the current surface which would be bad. | 154 // This will delete the current surface which would be bad. |
| 155 return BufferSyncInterface::kParseInvalidArguments; | 155 return BufferSyncInterface::kParseInvalidArguments; |
| 156 } | 156 } |
| 157 RenderDepthStencilSurfaceGL* depth_surface = | 157 RenderDepthStencilSurfaceGL* depth_surface = |
| 158 RenderDepthStencilSurfaceGL::Create(width, height); | 158 RenderDepthStencilSurfaceGL::Create(width, height); |
| 159 if (depth_surface == NULL) { | 159 if (depth_surface == NULL) { |
| 160 return BufferSyncInterface::kParseInvalidArguments; | 160 return BufferSyncInterface::kParseInvalidArguments; |
| 161 } | 161 } |
| 162 depth_surfaces_.Assign(id, depth_surface); | 162 depth_surfaces_.Assign(id, depth_surface); |
| 163 return BufferSyncInterface::kParseNoError; | 163 return BufferSyncInterface::kParseNoError; |
| 164 } | 164 } |
| 165 | 165 |
| 166 BufferSyncInterface::ParseError GAPIGL::DestroyDepthSurface(ResourceID id) { | 166 BufferSyncInterface::ParseError GAPIGL::DestroyDepthSurface(ResourceId id) { |
| 167 if (id == current_depth_surface_id_) { | 167 if (id == current_depth_surface_id_) { |
| 168 return BufferSyncInterface::kParseInvalidArguments; | 168 return BufferSyncInterface::kParseInvalidArguments; |
| 169 } | 169 } |
| 170 return depth_surfaces_.Destroy(id) ? | 170 return depth_surfaces_.Destroy(id) ? |
| 171 BufferSyncInterface::kParseNoError : | 171 BufferSyncInterface::kParseNoError : |
| 172 BufferSyncInterface::kParseInvalidArguments; | 172 BufferSyncInterface::kParseInvalidArguments; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void ResetBoundAttachments() { | 175 void ResetBoundAttachments() { |
| 176 #ifdef _DEBUG | 176 #ifdef _DEBUG |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 GLenum framebuffer_status = ::glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); | 213 GLenum framebuffer_status = ::glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); |
| 214 if (GL_FRAMEBUFFER_COMPLETE_EXT != framebuffer_status) { | 214 if (GL_FRAMEBUFFER_COMPLETE_EXT != framebuffer_status) { |
| 215 return false; | 215 return false; |
| 216 } | 216 } |
| 217 | 217 |
| 218 CHECK_GL_ERROR(); | 218 CHECK_GL_ERROR(); |
| 219 return true; | 219 return true; |
| 220 } | 220 } |
| 221 | 221 |
| 222 BufferSyncInterface::ParseError GAPIGL::SetRenderSurface( | 222 BufferSyncInterface::ParseError GAPIGL::SetRenderSurface( |
| 223 ResourceID render_surface_id, | 223 ResourceId render_surface_id, |
| 224 ResourceID depth_stencil_id) { | 224 ResourceId depth_stencil_id) { |
| 225 if (render_surfaces_.Get(render_surface_id) == NULL && | 225 if (render_surfaces_.Get(render_surface_id) == NULL && |
| 226 depth_surfaces_.Get(depth_stencil_id) == NULL) { | 226 depth_surfaces_.Get(depth_stencil_id) == NULL) { |
| 227 return BufferSyncInterface::kParseInvalidArguments; | 227 return BufferSyncInterface::kParseInvalidArguments; |
| 228 } | 228 } |
| 229 | 229 |
| 230 ::glBindFramebufferEXT(GL_FRAMEBUFFER, render_surface_framebuffer_); | 230 ::glBindFramebufferEXT(GL_FRAMEBUFFER, render_surface_framebuffer_); |
| 231 ResetBoundAttachments(); | 231 ResetBoundAttachments(); |
| 232 | 232 |
| 233 RenderSurfaceGL* render_surface = render_surfaces_.Get(render_surface_id); | 233 RenderSurfaceGL* render_surface = render_surfaces_.Get(render_surface_id); |
| 234 RenderDepthStencilSurfaceGL* depth_surface = | 234 RenderDepthStencilSurfaceGL* depth_surface = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 252 | 252 |
| 253 void GAPIGL::SetBackSurfaces() { | 253 void GAPIGL::SetBackSurfaces() { |
| 254 // Bind the default context, and restore the default front-face winding. | 254 // Bind the default context, and restore the default front-face winding. |
| 255 ::glBindFramebufferEXT(GL_FRAMEBUFFER, 0); | 255 ::glBindFramebufferEXT(GL_FRAMEBUFFER, 0); |
| 256 glFrontFace(GL_CCW); | 256 glFrontFace(GL_CCW); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace command_buffer | 259 } // namespace command_buffer |
| 260 } // namespace o3d | 260 } // namespace o3d |
| 261 | 261 |
| OLD | NEW |