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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 | 928 |
929 // Wrapper for TexStorage2DEXT. | 929 // Wrapper for TexStorage2DEXT. |
930 void DoTexStorage2DEXT( | 930 void DoTexStorage2DEXT( |
931 GLenum target, | 931 GLenum target, |
932 GLint levels, | 932 GLint levels, |
933 GLenum internal_format, | 933 GLenum internal_format, |
934 GLsizei width, | 934 GLsizei width, |
935 GLsizei height); | 935 GLsizei height); |
936 | 936 |
937 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 937 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
938 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, | |
939 const GLbyte* key); | |
940 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, | |
941 GLenum target, const GLbyte* data); | |
942 | |
938 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); | 943 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
944 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, | |
945 GLuint client_id); | |
939 | 946 |
940 void DoBindTexImage2DCHROMIUM( | 947 void DoBindTexImage2DCHROMIUM( |
941 GLenum target, | 948 GLenum target, |
942 GLint image_id); | 949 GLint image_id); |
943 void DoReleaseTexImage2DCHROMIUM( | 950 void DoReleaseTexImage2DCHROMIUM( |
944 GLenum target, | 951 GLenum target, |
945 GLint image_id); | 952 GLint image_id); |
946 | 953 |
947 void DoTraceEndCHROMIUM(void); | 954 void DoTraceEndCHROMIUM(void); |
948 | 955 |
(...skipping 9227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10176 uint32 immediate_data_size, const cmds::GenMailboxCHROMIUM& c) { | 10183 uint32 immediate_data_size, const cmds::GenMailboxCHROMIUM& c) { |
10177 return error::kUnknownCommand; | 10184 return error::kUnknownCommand; |
10178 } | 10185 } |
10179 | 10186 |
10180 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, | 10187 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, |
10181 const GLbyte* data) { | 10188 const GLbyte* data) { |
10182 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM", | 10189 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM", |
10183 "context", logger_.GetLogPrefix(), | 10190 "context", logger_.GetLogPrefix(), |
10184 "mailbox[0]", static_cast<unsigned char>(data[0])); | 10191 "mailbox[0]", static_cast<unsigned char>(data[0])); |
10185 | 10192 |
10193 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | |
10194 &state_, target); | |
10195 ProduceTextureRef("glProduceTextureCHROMIUM", texture_ref, target, data); | |
10196 } | |
10197 | |
10198 void GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM(GLuint client_id, | |
10199 GLenum target, const GLbyte* data) { | |
10200 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM", | |
10201 "context", logger_.GetLogPrefix(), | |
10202 "mailbox[0]", static_cast<unsigned char>(data[0])); | |
10203 | |
10204 ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id), | |
10205 target, data); | |
10206 } | |
10207 | |
10208 void GLES2DecoderImpl::ProduceTextureRef(std::string func_name, | |
10209 TextureRef* texture_ref, GLenum target, const GLbyte* data) { | |
10186 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 10210 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
10187 DLOG_IF(ERROR, !mailbox.Verify()) << "ProduceTextureCHROMIUM was passed a " | 10211 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " |
10188 "mailbox that was not generated by " | 10212 "mailbox that was not generated by " |
10189 "GenMailboxCHROMIUM."; | 10213 "GenMailboxCHROMIUM."; |
10190 | 10214 |
10191 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | |
10192 &state_, target); | |
10193 if (!texture_ref) { | 10215 if (!texture_ref) { |
10194 LOCAL_SET_GL_ERROR( | 10216 LOCAL_SET_GL_ERROR( |
10195 GL_INVALID_OPERATION, | 10217 GL_INVALID_OPERATION, func_name.c_str(), "unknown texture for target"); |
10196 "glProduceTextureCHROMIUM", "unknown texture for target"); | |
10197 return; | 10218 return; |
10198 } | 10219 } |
10199 | 10220 |
10200 Texture* produced = texture_manager()->Produce(texture_ref); | 10221 Texture* produced = texture_manager()->Produce(texture_ref); |
10201 if (!produced) { | 10222 if (!produced) { |
10202 LOCAL_SET_GL_ERROR( | 10223 LOCAL_SET_GL_ERROR( |
10203 GL_INVALID_OPERATION, | 10224 GL_INVALID_OPERATION, func_name.c_str(), "invalid texture"); |
10204 "glProduceTextureCHROMIUM", "invalid texture"); | |
10205 return; | 10225 return; |
10206 } | 10226 } |
10207 | 10227 |
10228 if (produced->target() != target) { | |
Ken Russell (switch to Gerrit)
2014/06/02 22:46:54
Is this new code path tested?
Do any other side-e
bajones
2014/06/02 23:31:23
Informally. I'll add a unit test in the next CL re
| |
10229 LOCAL_SET_GL_ERROR( | |
10230 GL_INVALID_OPERATION, func_name.c_str(), "invalid target"); | |
10231 return; | |
10232 } | |
10233 | |
10208 group_->mailbox_manager()->ProduceTexture(target, mailbox, produced); | 10234 group_->mailbox_manager()->ProduceTexture(target, mailbox, produced); |
10209 } | 10235 } |
10210 | 10236 |
10211 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, | 10237 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
10212 const GLbyte* data) { | 10238 const GLbyte* data) { |
10213 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", | 10239 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", |
10214 "context", logger_.GetLogPrefix(), | 10240 "context", logger_.GetLogPrefix(), |
10215 "mailbox[0]", static_cast<unsigned char>(data[0])); | 10241 "mailbox[0]", static_cast<unsigned char>(data[0])); |
10216 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 10242 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
10217 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a " | 10243 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a " |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10265 break; | 10291 break; |
10266 case GL_TEXTURE_RECTANGLE_ARB: | 10292 case GL_TEXTURE_RECTANGLE_ARB: |
10267 unit.bound_texture_rectangle_arb = texture_ref; | 10293 unit.bound_texture_rectangle_arb = texture_ref; |
10268 break; | 10294 break; |
10269 default: | 10295 default: |
10270 NOTREACHED(); // Validation should prevent us getting here. | 10296 NOTREACHED(); // Validation should prevent us getting here. |
10271 break; | 10297 break; |
10272 } | 10298 } |
10273 } | 10299 } |
10274 | 10300 |
10301 error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( | |
10302 uint32_t immediate_data_size, | |
10303 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c) { | |
10304 GLenum target = static_cast<GLenum>(c.target); | |
10305 uint32_t data_size; | |
10306 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { | |
10307 return error::kOutOfBounds; | |
10308 } | |
10309 if (data_size > immediate_data_size) { | |
10310 return error::kOutOfBounds; | |
10311 } | |
10312 const GLbyte* mailbox = | |
10313 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); | |
10314 if (!validators_->texture_bind_target.IsValid(target)) { | |
10315 LOCAL_SET_GL_ERROR_INVALID_ENUM( | |
10316 "glCreateAndConsumeTextureCHROMIUM", target, "target"); | |
10317 return error::kNoError; | |
10318 } | |
10319 if (mailbox == NULL) { | |
10320 return error::kOutOfBounds; | |
10321 } | |
10322 uint32_t client_id = c.client_id; | |
10323 DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id); | |
10324 return error::kNoError; | |
10325 } | |
10326 | |
10327 void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target, | |
10328 const GLbyte* data, GLuint client_id) { | |
10329 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM", | |
10330 "context", logger_.GetLogPrefix(), | |
10331 "mailbox[0]", static_cast<unsigned char>(data[0])); | |
10332 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | |
10333 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " | |
10334 "passed a mailbox that was not " | |
10335 "generated by GenMailboxCHROMIUM."; | |
10336 | |
10337 TextureRef* texture_ref = GetTexture(client_id); | |
10338 if (texture_ref) { | |
10339 LOCAL_SET_GL_ERROR( | |
10340 GL_INVALID_OPERATION, | |
10341 "glCreateAndConsumeTextureCHROMIUM", "client id already in use"); | |
10342 return; | |
10343 } | |
10344 Texture* texture = group_->mailbox_manager()->ConsumeTexture(target, mailbox); | |
10345 if (!texture) { | |
10346 LOCAL_SET_GL_ERROR( | |
10347 GL_INVALID_OPERATION, | |
10348 "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); | |
10349 return; | |
10350 } | |
10351 if (texture->target() != target) { | |
10352 LOCAL_SET_GL_ERROR( | |
10353 GL_INVALID_OPERATION, | |
10354 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); | |
10355 return; | |
10356 } | |
10357 | |
10358 texture_ref = texture_manager()->Consume(client_id, texture); | |
10359 } | |
10360 | |
10275 void GLES2DecoderImpl::DoInsertEventMarkerEXT( | 10361 void GLES2DecoderImpl::DoInsertEventMarkerEXT( |
10276 GLsizei length, const GLchar* marker) { | 10362 GLsizei length, const GLchar* marker) { |
10277 if (!marker) { | 10363 if (!marker) { |
10278 marker = ""; | 10364 marker = ""; |
10279 } | 10365 } |
10280 debug_marker_manager_.SetMarker( | 10366 debug_marker_manager_.SetMarker( |
10281 length ? std::string(marker, length) : std::string(marker)); | 10367 length ? std::string(marker, length) : std::string(marker)); |
10282 } | 10368 } |
10283 | 10369 |
10284 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 10370 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10772 } | 10858 } |
10773 } | 10859 } |
10774 | 10860 |
10775 // Include the auto-generated part of this file. We split this because it means | 10861 // Include the auto-generated part of this file. We split this because it means |
10776 // we can easily edit the non-auto generated parts right here in this file | 10862 // we can easily edit the non-auto generated parts right here in this file |
10777 // instead of having to edit some template or the code generator. | 10863 // instead of having to edit some template or the code generator. |
10778 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10864 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10779 | 10865 |
10780 } // namespace gles2 | 10866 } // namespace gles2 |
10781 } // namespace gpu | 10867 } // namespace gpu |
OLD | NEW |