| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 | 8 |
| 9 namespace gpu { | 9 namespace gpu { |
| 10 namespace gles2 { | 10 namespace gles2 { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 ClientServiceMap<GLuint, GLuint>* id_map, | 129 ClientServiceMap<GLuint, GLuint>* id_map, |
| 130 bool create_if_missing) { | 130 bool create_if_missing) { |
| 131 return GetServiceID(client_id, id_map, create_if_missing, []() { | 131 return GetServiceID(client_id, id_map, create_if_missing, []() { |
| 132 GLuint service_id = 0; | 132 GLuint service_id = 0; |
| 133 glGenFramebuffersEXT(1, &service_id); | 133 glGenFramebuffersEXT(1, &service_id); |
| 134 return service_id; | 134 return service_id; |
| 135 }); | 135 }); |
| 136 } | 136 } |
| 137 | 137 |
| 138 GLuint GetTransformFeedbackServiceID(GLuint client_id, | 138 GLuint GetTransformFeedbackServiceID(GLuint client_id, |
| 139 ClientServiceMap<GLuint, GLuint>* id_map, | 139 ClientServiceMap<GLuint, GLuint>* id_map) { |
| 140 bool create_if_missing) { | 140 return id_map->GetServiceIDOrInvalid(client_id); |
| 141 return GetServiceID(client_id, id_map, create_if_missing, []() { | |
| 142 GLuint service_id = 0; | |
| 143 glGenTransformFeedbacks(1, &service_id); | |
| 144 return service_id; | |
| 145 }); | |
| 146 } | 141 } |
| 147 | 142 |
| 148 GLuint GetVertexArrayServiceID(GLuint client_id, | 143 GLuint GetVertexArrayServiceID(GLuint client_id, |
| 149 ClientServiceMap<GLuint, GLuint>* id_map, | 144 ClientServiceMap<GLuint, GLuint>* id_map) { |
| 150 bool create_if_missing) { | 145 return id_map->GetServiceIDOrInvalid(client_id); |
| 151 return GetServiceID(client_id, id_map, create_if_missing, []() { | |
| 152 GLuint service_id = 0; | |
| 153 glGenVertexArraysOES(1, &service_id); | |
| 154 return service_id; | |
| 155 }); | |
| 156 } | 146 } |
| 157 | 147 |
| 158 GLuint GetProgramServiceID(GLuint client_id, PassthroughResources* resources) { | 148 GLuint GetProgramServiceID(GLuint client_id, PassthroughResources* resources) { |
| 159 return resources->program_id_map.GetServiceIDOrInvalid(client_id); | 149 return resources->program_id_map.GetServiceIDOrInvalid(client_id); |
| 160 } | 150 } |
| 161 | 151 |
| 162 GLuint GetShaderServiceID(GLuint client_id, PassthroughResources* resources) { | 152 GLuint GetShaderServiceID(GLuint client_id, PassthroughResources* resources) { |
| 163 return resources->shader_id_map.GetServiceIDOrInvalid(client_id); | 153 return resources->shader_id_map.GetServiceIDOrInvalid(client_id); |
| 164 } | 154 } |
| 165 | 155 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 bound_textures_[active_texture_unit_] = texture; | 273 bound_textures_[active_texture_unit_] = texture; |
| 284 } | 274 } |
| 285 return error::kNoError; | 275 return error::kNoError; |
| 286 } | 276 } |
| 287 | 277 |
| 288 error::Error GLES2DecoderPassthroughImpl::DoBindTransformFeedback( | 278 error::Error GLES2DecoderPassthroughImpl::DoBindTransformFeedback( |
| 289 GLenum target, | 279 GLenum target, |
| 290 GLuint transformfeedback) { | 280 GLuint transformfeedback) { |
| 291 glBindTransformFeedback( | 281 glBindTransformFeedback( |
| 292 target, GetTransformFeedbackServiceID(transformfeedback, | 282 target, GetTransformFeedbackServiceID(transformfeedback, |
| 293 &transform_feedback_id_map_, | 283 &transform_feedback_id_map_)); |
| 294 bind_generates_resource_)); | |
| 295 return error::kNoError; | 284 return error::kNoError; |
| 296 } | 285 } |
| 297 | 286 |
| 298 error::Error GLES2DecoderPassthroughImpl::DoBlendColor(GLclampf red, | 287 error::Error GLES2DecoderPassthroughImpl::DoBlendColor(GLclampf red, |
| 299 GLclampf green, | 288 GLclampf green, |
| 300 GLclampf blue, | 289 GLclampf blue, |
| 301 GLclampf alpha) { | 290 GLclampf alpha) { |
| 302 glBlendColor(red, green, blue, alpha); | 291 glBlendColor(red, green, blue, alpha); |
| 303 return error::kNoError; | 292 return error::kNoError; |
| 304 } | 293 } |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 GLintptr offset, | 705 GLintptr offset, |
| 717 GLsizeiptr size) { | 706 GLsizeiptr size) { |
| 718 return error::kNoError; | 707 return error::kNoError; |
| 719 } | 708 } |
| 720 | 709 |
| 721 error::Error GLES2DecoderPassthroughImpl::DoFramebufferRenderbuffer( | 710 error::Error GLES2DecoderPassthroughImpl::DoFramebufferRenderbuffer( |
| 722 GLenum target, | 711 GLenum target, |
| 723 GLenum attachment, | 712 GLenum attachment, |
| 724 GLenum renderbuffertarget, | 713 GLenum renderbuffertarget, |
| 725 GLuint renderbuffer) { | 714 GLuint renderbuffer) { |
| 726 // TODO(geofflang): Handle this case in ANGLE by adding a WebGL validation | 715 glFramebufferRenderbufferEXT( |
| 727 // mode. | 716 target, attachment, renderbuffertarget, |
| 728 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 717 GetRenderbufferServiceID(renderbuffer, resources_, false)); |
| 729 glFramebufferRenderbufferEXT( | |
| 730 target, GL_DEPTH_ATTACHMENT, renderbuffertarget, | |
| 731 GetRenderbufferServiceID(renderbuffer, resources_, false)); | |
| 732 glFramebufferRenderbufferEXT( | |
| 733 target, GL_STENCIL_ATTACHMENT, renderbuffertarget, | |
| 734 GetRenderbufferServiceID(renderbuffer, resources_, false)); | |
| 735 } else { | |
| 736 glFramebufferRenderbufferEXT( | |
| 737 target, attachment, renderbuffertarget, | |
| 738 GetRenderbufferServiceID(renderbuffer, resources_, false)); | |
| 739 } | |
| 740 return error::kNoError; | 718 return error::kNoError; |
| 741 } | 719 } |
| 742 | 720 |
| 743 error::Error GLES2DecoderPassthroughImpl::DoFramebufferTexture2D( | 721 error::Error GLES2DecoderPassthroughImpl::DoFramebufferTexture2D( |
| 744 GLenum target, | 722 GLenum target, |
| 745 GLenum attachment, | 723 GLenum attachment, |
| 746 GLenum textarget, | 724 GLenum textarget, |
| 747 GLuint texture, | 725 GLuint texture, |
| 748 GLint level) { | 726 GLint level) { |
| 749 glFramebufferTexture2DEXT(target, attachment, textarget, | 727 glFramebufferTexture2DEXT(target, attachment, textarget, |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 error::Error GLES2DecoderPassthroughImpl::DoIsTexture(GLuint texture, | 1315 error::Error GLES2DecoderPassthroughImpl::DoIsTexture(GLuint texture, |
| 1338 uint32_t* result) { | 1316 uint32_t* result) { |
| 1339 *result = glIsTexture(GetTextureServiceID(texture, resources_, false)); | 1317 *result = glIsTexture(GetTextureServiceID(texture, resources_, false)); |
| 1340 return error::kNoError; | 1318 return error::kNoError; |
| 1341 } | 1319 } |
| 1342 | 1320 |
| 1343 error::Error GLES2DecoderPassthroughImpl::DoIsTransformFeedback( | 1321 error::Error GLES2DecoderPassthroughImpl::DoIsTransformFeedback( |
| 1344 GLuint transformfeedback, | 1322 GLuint transformfeedback, |
| 1345 uint32_t* result) { | 1323 uint32_t* result) { |
| 1346 *result = glIsTransformFeedback(GetTransformFeedbackServiceID( | 1324 *result = glIsTransformFeedback(GetTransformFeedbackServiceID( |
| 1347 transformfeedback, &transform_feedback_id_map_, false)); | 1325 transformfeedback, &transform_feedback_id_map_)); |
| 1348 return error::kNoError; | 1326 return error::kNoError; |
| 1349 } | 1327 } |
| 1350 | 1328 |
| 1351 error::Error GLES2DecoderPassthroughImpl::DoLineWidth(GLfloat width) { | 1329 error::Error GLES2DecoderPassthroughImpl::DoLineWidth(GLfloat width) { |
| 1352 glLineWidth(width); | 1330 glLineWidth(width); |
| 1353 return error::kNoError; | 1331 return error::kNoError; |
| 1354 } | 1332 } |
| 1355 | 1333 |
| 1356 error::Error GLES2DecoderPassthroughImpl::DoLinkProgram(GLuint program) { | 1334 error::Error GLES2DecoderPassthroughImpl::DoLinkProgram(GLuint program) { |
| 1357 glLinkProgram(GetProgramServiceID(program, resources_)); | 1335 glLinkProgram(GetProgramServiceID(program, resources_)); |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2202 error::Error GLES2DecoderPassthroughImpl::DoDeleteVertexArraysOES( | 2180 error::Error GLES2DecoderPassthroughImpl::DoDeleteVertexArraysOES( |
| 2203 GLsizei n, | 2181 GLsizei n, |
| 2204 const volatile GLuint* arrays) { | 2182 const volatile GLuint* arrays) { |
| 2205 return DeleteHelper( | 2183 return DeleteHelper( |
| 2206 n, arrays, &vertex_array_id_map_, | 2184 n, arrays, &vertex_array_id_map_, |
| 2207 [](GLsizei n, GLuint* arrays) { glDeleteVertexArraysOES(n, arrays); }); | 2185 [](GLsizei n, GLuint* arrays) { glDeleteVertexArraysOES(n, arrays); }); |
| 2208 } | 2186 } |
| 2209 | 2187 |
| 2210 error::Error GLES2DecoderPassthroughImpl::DoIsVertexArrayOES(GLuint array, | 2188 error::Error GLES2DecoderPassthroughImpl::DoIsVertexArrayOES(GLuint array, |
| 2211 uint32_t* result) { | 2189 uint32_t* result) { |
| 2212 *result = glIsVertexArrayOES( | 2190 *result = |
| 2213 GetVertexArrayServiceID(array, &vertex_array_id_map_, false)); | 2191 glIsVertexArrayOES(GetVertexArrayServiceID(array, &vertex_array_id_map_)); |
| 2214 return error::kNoError; | 2192 return error::kNoError; |
| 2215 } | 2193 } |
| 2216 | 2194 |
| 2217 error::Error GLES2DecoderPassthroughImpl::DoBindVertexArrayOES(GLuint array) { | 2195 error::Error GLES2DecoderPassthroughImpl::DoBindVertexArrayOES(GLuint array) { |
| 2218 glBindVertexArrayOES(GetVertexArrayServiceID(array, &vertex_array_id_map_, | 2196 glBindVertexArrayOES(GetVertexArrayServiceID(array, &vertex_array_id_map_)); |
| 2219 bind_generates_resource_)); | |
| 2220 return error::kNoError; | 2197 return error::kNoError; |
| 2221 } | 2198 } |
| 2222 | 2199 |
| 2223 error::Error GLES2DecoderPassthroughImpl::DoSwapBuffers() { | 2200 error::Error GLES2DecoderPassthroughImpl::DoSwapBuffers() { |
| 2224 gfx::SwapResult result = surface_->SwapBuffers(); | 2201 gfx::SwapResult result = surface_->SwapBuffers(); |
| 2225 if (result == gfx::SwapResult::SWAP_FAILED) { | 2202 if (result == gfx::SwapResult::SWAP_FAILED) { |
| 2226 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 2203 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
| 2227 } | 2204 } |
| 2228 // TODO(geofflang): force the context loss? | 2205 // TODO(geofflang): force the context loss? |
| 2229 return error::kNoError; | 2206 return error::kNoError; |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3023 GLES2DecoderPassthroughImpl::DoUniformMatrix4fvStreamTextureMatrixCHROMIUM( | 3000 GLES2DecoderPassthroughImpl::DoUniformMatrix4fvStreamTextureMatrixCHROMIUM( |
| 3024 GLint location, | 3001 GLint location, |
| 3025 GLboolean transpose, | 3002 GLboolean transpose, |
| 3026 const volatile GLfloat* defaultValue) { | 3003 const volatile GLfloat* defaultValue) { |
| 3027 NOTIMPLEMENTED(); | 3004 NOTIMPLEMENTED(); |
| 3028 return error::kNoError; | 3005 return error::kNoError; |
| 3029 } | 3006 } |
| 3030 | 3007 |
| 3031 } // namespace gles2 | 3008 } // namespace gles2 |
| 3032 } // namespace gpu | 3009 } // namespace gpu |
| OLD | NEW |