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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 | 930 |
931 // Wrapper for TexStorage2DEXT. | 931 // Wrapper for TexStorage2DEXT. |
932 void DoTexStorage2DEXT( | 932 void DoTexStorage2DEXT( |
933 GLenum target, | 933 GLenum target, |
934 GLint levels, | 934 GLint levels, |
935 GLenum internal_format, | 935 GLenum internal_format, |
936 GLsizei width, | 936 GLsizei width, |
937 GLsizei height); | 937 GLsizei height); |
938 | 938 |
939 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 939 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
| 940 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, |
| 941 const GLbyte* key); |
| 942 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, |
| 943 GLenum target, const GLbyte* data); |
| 944 |
940 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); | 945 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
| 946 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, |
| 947 GLuint client_id); |
941 | 948 |
942 void DoBindTexImage2DCHROMIUM( | 949 void DoBindTexImage2DCHROMIUM( |
943 GLenum target, | 950 GLenum target, |
944 GLint image_id); | 951 GLint image_id); |
945 void DoReleaseTexImage2DCHROMIUM( | 952 void DoReleaseTexImage2DCHROMIUM( |
946 GLenum target, | 953 GLenum target, |
947 GLint image_id); | 954 GLint image_id); |
948 | 955 |
949 void DoTraceEndCHROMIUM(void); | 956 void DoTraceEndCHROMIUM(void); |
950 | 957 |
(...skipping 9239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10190 uint32 immediate_data_size, const cmds::GenMailboxCHROMIUM& c) { | 10197 uint32 immediate_data_size, const cmds::GenMailboxCHROMIUM& c) { |
10191 return error::kUnknownCommand; | 10198 return error::kUnknownCommand; |
10192 } | 10199 } |
10193 | 10200 |
10194 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, | 10201 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, |
10195 const GLbyte* data) { | 10202 const GLbyte* data) { |
10196 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM", | 10203 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM", |
10197 "context", logger_.GetLogPrefix(), | 10204 "context", logger_.GetLogPrefix(), |
10198 "mailbox[0]", static_cast<unsigned char>(data[0])); | 10205 "mailbox[0]", static_cast<unsigned char>(data[0])); |
10199 | 10206 |
| 10207 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( |
| 10208 &state_, target); |
| 10209 ProduceTextureRef("glProduceTextureCHROMIUM", texture_ref, target, data); |
| 10210 } |
| 10211 |
| 10212 void GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM(GLuint client_id, |
| 10213 GLenum target, const GLbyte* data) { |
| 10214 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM", |
| 10215 "context", logger_.GetLogPrefix(), |
| 10216 "mailbox[0]", static_cast<unsigned char>(data[0])); |
| 10217 |
| 10218 ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id), |
| 10219 target, data); |
| 10220 } |
| 10221 |
| 10222 void GLES2DecoderImpl::ProduceTextureRef(std::string func_name, |
| 10223 TextureRef* texture_ref, GLenum target, const GLbyte* data) { |
10200 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 10224 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
10201 DLOG_IF(ERROR, !mailbox.Verify()) << "ProduceTextureCHROMIUM was passed a " | 10225 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " |
10202 "mailbox that was not generated by " | 10226 "mailbox that was not generated by " |
10203 "GenMailboxCHROMIUM."; | 10227 "GenMailboxCHROMIUM."; |
10204 | 10228 |
10205 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | |
10206 &state_, target); | |
10207 if (!texture_ref) { | 10229 if (!texture_ref) { |
10208 LOCAL_SET_GL_ERROR( | 10230 LOCAL_SET_GL_ERROR( |
10209 GL_INVALID_OPERATION, | 10231 GL_INVALID_OPERATION, func_name.c_str(), "unknown texture for target"); |
10210 "glProduceTextureCHROMIUM", "unknown texture for target"); | |
10211 return; | 10232 return; |
10212 } | 10233 } |
10213 | 10234 |
10214 Texture* produced = texture_manager()->Produce(texture_ref); | 10235 Texture* produced = texture_manager()->Produce(texture_ref); |
10215 if (!produced) { | 10236 if (!produced) { |
10216 LOCAL_SET_GL_ERROR( | 10237 LOCAL_SET_GL_ERROR( |
10217 GL_INVALID_OPERATION, | 10238 GL_INVALID_OPERATION, func_name.c_str(), "invalid texture"); |
10218 "glProduceTextureCHROMIUM", "invalid texture"); | |
10219 return; | 10239 return; |
10220 } | 10240 } |
10221 | 10241 |
| 10242 if (produced->target() != target) { |
| 10243 LOCAL_SET_GL_ERROR( |
| 10244 GL_INVALID_OPERATION, func_name.c_str(), "invalid target"); |
| 10245 return; |
| 10246 } |
| 10247 |
10222 group_->mailbox_manager()->ProduceTexture(target, mailbox, produced); | 10248 group_->mailbox_manager()->ProduceTexture(target, mailbox, produced); |
10223 } | 10249 } |
10224 | 10250 |
10225 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, | 10251 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
10226 const GLbyte* data) { | 10252 const GLbyte* data) { |
10227 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", | 10253 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", |
10228 "context", logger_.GetLogPrefix(), | 10254 "context", logger_.GetLogPrefix(), |
10229 "mailbox[0]", static_cast<unsigned char>(data[0])); | 10255 "mailbox[0]", static_cast<unsigned char>(data[0])); |
10230 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 10256 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
10231 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a " | 10257 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a " |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10279 break; | 10305 break; |
10280 case GL_TEXTURE_RECTANGLE_ARB: | 10306 case GL_TEXTURE_RECTANGLE_ARB: |
10281 unit.bound_texture_rectangle_arb = texture_ref; | 10307 unit.bound_texture_rectangle_arb = texture_ref; |
10282 break; | 10308 break; |
10283 default: | 10309 default: |
10284 NOTREACHED(); // Validation should prevent us getting here. | 10310 NOTREACHED(); // Validation should prevent us getting here. |
10285 break; | 10311 break; |
10286 } | 10312 } |
10287 } | 10313 } |
10288 | 10314 |
| 10315 error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( |
| 10316 uint32_t immediate_data_size, |
| 10317 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c) { |
| 10318 GLenum target = static_cast<GLenum>(c.target); |
| 10319 uint32_t data_size; |
| 10320 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { |
| 10321 return error::kOutOfBounds; |
| 10322 } |
| 10323 if (data_size > immediate_data_size) { |
| 10324 return error::kOutOfBounds; |
| 10325 } |
| 10326 const GLbyte* mailbox = |
| 10327 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); |
| 10328 if (!validators_->texture_bind_target.IsValid(target)) { |
| 10329 LOCAL_SET_GL_ERROR_INVALID_ENUM( |
| 10330 "glCreateAndConsumeTextureCHROMIUM", target, "target"); |
| 10331 return error::kNoError; |
| 10332 } |
| 10333 if (mailbox == NULL) { |
| 10334 return error::kOutOfBounds; |
| 10335 } |
| 10336 uint32_t client_id = c.client_id; |
| 10337 DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id); |
| 10338 return error::kNoError; |
| 10339 } |
| 10340 |
| 10341 void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target, |
| 10342 const GLbyte* data, GLuint client_id) { |
| 10343 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM", |
| 10344 "context", logger_.GetLogPrefix(), |
| 10345 "mailbox[0]", static_cast<unsigned char>(data[0])); |
| 10346 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
| 10347 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " |
| 10348 "passed a mailbox that was not " |
| 10349 "generated by GenMailboxCHROMIUM."; |
| 10350 |
| 10351 TextureRef* texture_ref = GetTexture(client_id); |
| 10352 if (texture_ref) { |
| 10353 LOCAL_SET_GL_ERROR( |
| 10354 GL_INVALID_OPERATION, |
| 10355 "glCreateAndConsumeTextureCHROMIUM", "client id already in use"); |
| 10356 return; |
| 10357 } |
| 10358 Texture* texture = group_->mailbox_manager()->ConsumeTexture(target, mailbox); |
| 10359 if (!texture) { |
| 10360 LOCAL_SET_GL_ERROR( |
| 10361 GL_INVALID_OPERATION, |
| 10362 "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); |
| 10363 return; |
| 10364 } |
| 10365 if (texture->target() != target) { |
| 10366 LOCAL_SET_GL_ERROR( |
| 10367 GL_INVALID_OPERATION, |
| 10368 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); |
| 10369 return; |
| 10370 } |
| 10371 |
| 10372 IdAllocatorInterface* id_allocator = |
| 10373 group_->GetIdAllocator(id_namespaces::kTextures); |
| 10374 id_allocator->MarkAsUsed(client_id); |
| 10375 |
| 10376 texture_ref = texture_manager()->Consume(client_id, texture); |
| 10377 } |
| 10378 |
10289 void GLES2DecoderImpl::DoInsertEventMarkerEXT( | 10379 void GLES2DecoderImpl::DoInsertEventMarkerEXT( |
10290 GLsizei length, const GLchar* marker) { | 10380 GLsizei length, const GLchar* marker) { |
10291 if (!marker) { | 10381 if (!marker) { |
10292 marker = ""; | 10382 marker = ""; |
10293 } | 10383 } |
10294 debug_marker_manager_.SetMarker( | 10384 debug_marker_manager_.SetMarker( |
10295 length ? std::string(marker, length) : std::string(marker)); | 10385 length ? std::string(marker, length) : std::string(marker)); |
10296 } | 10386 } |
10297 | 10387 |
10298 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 10388 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10786 } | 10876 } |
10787 } | 10877 } |
10788 | 10878 |
10789 // Include the auto-generated part of this file. We split this because it means | 10879 // Include the auto-generated part of this file. We split this because it means |
10790 // we can easily edit the non-auto generated parts right here in this file | 10880 // we can easily edit the non-auto generated parts right here in this file |
10791 // instead of having to edit some template or the code generator. | 10881 // instead of having to edit some template or the code generator. |
10792 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10882 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10793 | 10883 |
10794 } // namespace gles2 | 10884 } // namespace gles2 |
10795 } // namespace gpu | 10885 } // namespace gpu |
OLD | NEW |