OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 GLuint client_id, GLint location, const char* name); | 1163 GLuint client_id, GLint location, const char* name); |
1164 | 1164 |
1165 error::Error GetAttribLocationHelper( | 1165 error::Error GetAttribLocationHelper( |
1166 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 1166 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
1167 const std::string& name_str); | 1167 const std::string& name_str); |
1168 | 1168 |
1169 error::Error GetUniformLocationHelper( | 1169 error::Error GetUniformLocationHelper( |
1170 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 1170 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
1171 const std::string& name_str); | 1171 const std::string& name_str); |
1172 | 1172 |
| 1173 error::Error GetFragDataLocationHelper( |
| 1174 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| 1175 const std::string& name_str); |
| 1176 |
1173 // Wrapper for glShaderSource. | 1177 // Wrapper for glShaderSource. |
1174 void DoShaderSource( | 1178 void DoShaderSource( |
1175 GLuint client_id, GLsizei count, const char** data, const GLint* length); | 1179 GLuint client_id, GLsizei count, const char** data, const GLint* length); |
1176 | 1180 |
1177 // Clear any textures used by the current program. | 1181 // Clear any textures used by the current program. |
1178 bool ClearUnclearedTextures(); | 1182 bool ClearUnclearedTextures(); |
1179 | 1183 |
1180 // Clears any uncleared attachments attached to the given frame buffer. | 1184 // Clears any uncleared attachments attached to the given frame buffer. |
1181 // Returns false if there was a generated GL error. | 1185 // Returns false if there was a generated GL error. |
1182 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); | 1186 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); |
(...skipping 6934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8117 return error::kInvalidArguments; | 8121 return error::kInvalidArguments; |
8118 } | 8122 } |
8119 std::string name_str; | 8123 std::string name_str; |
8120 if (!bucket->GetAsString(&name_str)) { | 8124 if (!bucket->GetAsString(&name_str)) { |
8121 return error::kInvalidArguments; | 8125 return error::kInvalidArguments; |
8122 } | 8126 } |
8123 return GetUniformLocationHelper( | 8127 return GetUniformLocationHelper( |
8124 c.program, c.location_shm_id, c.location_shm_offset, name_str); | 8128 c.program, c.location_shm_id, c.location_shm_offset, name_str); |
8125 } | 8129 } |
8126 | 8130 |
| 8131 error::Error GLES2DecoderImpl::GetFragDataLocationHelper( |
| 8132 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| 8133 const std::string& name_str) { |
| 8134 GLint* location = GetSharedMemoryAs<GLint*>( |
| 8135 location_shm_id, location_shm_offset, sizeof(GLint)); |
| 8136 if (!location) { |
| 8137 return error::kOutOfBounds; |
| 8138 } |
| 8139 // Require the client to init this incase the context is lost and we are no |
| 8140 // longer executing commands. |
| 8141 if (*location != -1) { |
| 8142 return error::kGenericError; |
| 8143 } |
| 8144 Program* program = GetProgramInfoNotShader( |
| 8145 client_id, "glGetFragDataLocation"); |
| 8146 if (!program) { |
| 8147 return error::kNoError; |
| 8148 } |
| 8149 *location = glGetFragDataLocation(program->service_id(), name_str.c_str()); |
| 8150 return error::kNoError; |
| 8151 } |
| 8152 |
| 8153 error::Error GLES2DecoderImpl::HandleGetFragDataLocation( |
| 8154 uint32 immediate_data_size, |
| 8155 const void* cmd_data) { |
| 8156 if (!unsafe_es3_apis_enabled()) |
| 8157 return error::kUnknownCommand; |
| 8158 const gles2::cmds::GetFragDataLocation& c = |
| 8159 *static_cast<const gles2::cmds::GetFragDataLocation*>(cmd_data); |
| 8160 Bucket* bucket = GetBucket(c.name_bucket_id); |
| 8161 if (!bucket) { |
| 8162 return error::kInvalidArguments; |
| 8163 } |
| 8164 std::string name_str; |
| 8165 if (!bucket->GetAsString(&name_str)) { |
| 8166 return error::kInvalidArguments; |
| 8167 } |
| 8168 return GetFragDataLocationHelper( |
| 8169 c.program, c.location_shm_id, c.location_shm_offset, name_str); |
| 8170 } |
| 8171 |
8127 error::Error GLES2DecoderImpl::HandleGetString(uint32 immediate_data_size, | 8172 error::Error GLES2DecoderImpl::HandleGetString(uint32 immediate_data_size, |
8128 const void* cmd_data) { | 8173 const void* cmd_data) { |
8129 const gles2::cmds::GetString& c = | 8174 const gles2::cmds::GetString& c = |
8130 *static_cast<const gles2::cmds::GetString*>(cmd_data); | 8175 *static_cast<const gles2::cmds::GetString*>(cmd_data); |
8131 GLenum name = static_cast<GLenum>(c.name); | 8176 GLenum name = static_cast<GLenum>(c.name); |
8132 if (!validators_->string_type.IsValid(name)) { | 8177 if (!validators_->string_type.IsValid(name)) { |
8133 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetString", name, "name"); | 8178 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetString", name, "name"); |
8134 return error::kNoError; | 8179 return error::kNoError; |
8135 } | 8180 } |
8136 const char* str = reinterpret_cast<const char*>(glGetString(name)); | 8181 const char* str = reinterpret_cast<const char*>(glGetString(name)); |
(...skipping 3469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11606 } | 11651 } |
11607 } | 11652 } |
11608 | 11653 |
11609 // Include the auto-generated part of this file. We split this because it means | 11654 // Include the auto-generated part of this file. We split this because it means |
11610 // we can easily edit the non-auto generated parts right here in this file | 11655 // we can easily edit the non-auto generated parts right here in this file |
11611 // instead of having to edit some template or the code generator. | 11656 // instead of having to edit some template or the code generator. |
11612 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11657 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11613 | 11658 |
11614 } // namespace gles2 | 11659 } // namespace gles2 |
11615 } // namespace gpu | 11660 } // namespace gpu |
OLD | NEW |