Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 10535073: Enforce compressed texture restrictions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); 490 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size);
491 void UpdateParentTextureInfo(); 491 void UpdateParentTextureInfo();
492 virtual bool MakeCurrent(); 492 virtual bool MakeCurrent();
493 virtual void ReleaseCurrent(); 493 virtual void ReleaseCurrent();
494 virtual GLES2Util* GetGLES2Util() { return &util_; } 494 virtual GLES2Util* GetGLES2Util() { return &util_; }
495 virtual gfx::GLContext* GetGLContext() { return context_.get(); } 495 virtual gfx::GLContext* GetGLContext() { return context_.get(); }
496 virtual ContextGroup* GetContextGroup() { return group_.get(); } 496 virtual ContextGroup* GetContextGroup() { return group_.get(); }
497 virtual QueryManager* GetQueryManager() { return query_manager_.get(); } 497 virtual QueryManager* GetQueryManager() { return query_manager_.get(); }
498 virtual bool ProcessPendingQueries(); 498 virtual bool ProcessPendingQueries();
499 499
500 virtual void SetGLError(GLenum error, const char* msg); 500 virtual void SetGLError(
501 GLenum error, const char* function_name, const char* msg);
501 virtual void SetResizeCallback( 502 virtual void SetResizeCallback(
502 const base::Callback<void(gfx::Size)>& callback); 503 const base::Callback<void(gfx::Size)>& callback);
503 504
504 virtual void SetMsgCallback(const MsgCallback& callback); 505 virtual void SetMsgCallback(const MsgCallback& callback);
505 506
506 virtual void SetStreamTextureManager(StreamTextureManager* manager); 507 virtual void SetStreamTextureManager(StreamTextureManager* manager);
507 virtual bool GetServiceTextureId(uint32 client_texture_id, 508 virtual bool GetServiceTextureId(uint32 client_texture_id,
508 uint32* service_texture_id); 509 uint32* service_texture_id);
509 510
510 // Restores the current state to the user's settings. 511 // Restores the current state to the user's settings.
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 return program_manager()->GetProgramInfo(client_id); 771 return program_manager()->GetProgramInfo(client_id);
771 } 772 }
772 773
773 // Gets the program info for the given program. If it's not a program 774 // Gets the program info for the given program. If it's not a program
774 // generates a GL error. Returns NULL if not program. 775 // generates a GL error. Returns NULL if not program.
775 ProgramManager::ProgramInfo* GetProgramInfoNotShader( 776 ProgramManager::ProgramInfo* GetProgramInfoNotShader(
776 GLuint client_id, const char* function_name) { 777 GLuint client_id, const char* function_name) {
777 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id); 778 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id);
778 if (!info) { 779 if (!info) {
779 if (GetShaderInfo(client_id)) { 780 if (GetShaderInfo(client_id)) {
780 SetGLError(GL_INVALID_OPERATION, 781 SetGLError(
781 (std::string(function_name) + 782 GL_INVALID_OPERATION, function_name, "shader passed for program");
782 ": shader passed for program").c_str());
783 } else { 783 } else {
784 SetGLError(GL_INVALID_VALUE, 784 SetGLError(GL_INVALID_VALUE, function_name, "unknown program");
785 (std::string(function_name) + ": unknown program").c_str());
786 } 785 }
787 } 786 }
788 return info; 787 return info;
789 } 788 }
790 789
791 790
792 // Creates a ShaderInfo for the given shader. 791 // Creates a ShaderInfo for the given shader.
793 ShaderManager::ShaderInfo* CreateShaderInfo( 792 ShaderManager::ShaderInfo* CreateShaderInfo(
794 GLuint client_id, 793 GLuint client_id,
795 GLuint service_id, 794 GLuint service_id,
796 GLenum shader_type) { 795 GLenum shader_type) {
797 return shader_manager()->CreateShaderInfo( 796 return shader_manager()->CreateShaderInfo(
798 client_id, service_id, shader_type); 797 client_id, service_id, shader_type);
799 } 798 }
800 799
801 // Gets the shader info for the given shader. Returns NULL if none exists. 800 // Gets the shader info for the given shader. Returns NULL if none exists.
802 ShaderManager::ShaderInfo* GetShaderInfo(GLuint client_id) { 801 ShaderManager::ShaderInfo* GetShaderInfo(GLuint client_id) {
803 return shader_manager()->GetShaderInfo(client_id); 802 return shader_manager()->GetShaderInfo(client_id);
804 } 803 }
805 804
806 // Gets the shader info for the given shader. If it's not a shader generates a 805 // Gets the shader info for the given shader. If it's not a shader generates a
807 // GL error. Returns NULL if not shader. 806 // GL error. Returns NULL if not shader.
808 ShaderManager::ShaderInfo* GetShaderInfoNotProgram( 807 ShaderManager::ShaderInfo* GetShaderInfoNotProgram(
809 GLuint client_id, const char* function_name) { 808 GLuint client_id, const char* function_name) {
810 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id); 809 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id);
811 if (!info) { 810 if (!info) {
812 if (GetProgramInfo(client_id)) { 811 if (GetProgramInfo(client_id)) {
813 SetGLError( 812 SetGLError(
814 GL_INVALID_OPERATION, 813 GL_INVALID_OPERATION, function_name, "program passed for shader");
815 (std::string(function_name) +
816 ": program passed for shader").c_str());
817 } else { 814 } else {
818 SetGLError(GL_INVALID_VALUE, 815 SetGLError(
819 (std::string(function_name) + ": unknown shader").c_str()); 816 GL_INVALID_VALUE, function_name, "unknown shader");
820 } 817 }
821 } 818 }
822 return info; 819 return info;
823 } 820 }
824 821
825 // Creates a buffer info for the given buffer. 822 // Creates a buffer info for the given buffer.
826 void CreateBufferInfo(GLuint client_id, GLuint service_id) { 823 void CreateBufferInfo(GLuint client_id, GLuint service_id) {
827 return buffer_manager()->CreateBufferInfo(client_id, service_id); 824 return buffer_manager()->CreateBufferInfo(client_id, service_id);
828 } 825 }
829 826
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 // make sure there are no native GL errors before calling some GL function 1179 // make sure there are no native GL errors before calling some GL function
1183 // so that on return we know any error generated was for that specific 1180 // so that on return we know any error generated was for that specific
1184 // command. 1181 // command.
1185 void CopyRealGLErrorsToWrapper(); 1182 void CopyRealGLErrorsToWrapper();
1186 1183
1187 // Clear all real GL errors. This is to prevent the client from seeing any 1184 // Clear all real GL errors. This is to prevent the client from seeing any
1188 // errors caused by GL calls that it was not responsible for issuing. 1185 // errors caused by GL calls that it was not responsible for issuing.
1189 void ClearRealGLErrors(); 1186 void ClearRealGLErrors();
1190 1187
1191 // Checks if the current program and vertex attributes are valid for drawing. 1188 // Checks if the current program and vertex attributes are valid for drawing.
1192 bool IsDrawValid(GLuint max_vertex_accessed, GLsizei primcount); 1189 bool IsDrawValid(
1190 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount);
1193 1191
1194 // Returns true if successful, simulated will be true if attrib0 was 1192 // Returns true if successful, simulated will be true if attrib0 was
1195 // simulated. 1193 // simulated.
1196 bool SimulateAttrib0( 1194 bool SimulateAttrib0(
1197 GLuint max_vertex_accessed, bool* simulated); 1195 const char* function_name, GLuint max_vertex_accessed, bool* simulated);
1198 void RestoreStateForAttrib(GLuint attrib); 1196 void RestoreStateForAttrib(GLuint attrib);
1199 1197
1200 // Returns true if textures were set. 1198 // Returns true if textures were set.
1201 bool SetBlackTextureForNonRenderableTextures(); 1199 bool SetBlackTextureForNonRenderableTextures();
1202 void RestoreStateForNonRenderableTextures(); 1200 void RestoreStateForNonRenderableTextures();
1203 1201
1204 // Returns true if GL_FIXED attribs were simulated. 1202 // Returns true if GL_FIXED attribs were simulated.
1205 bool SimulateFixedAttribs( 1203 bool SimulateFixedAttribs(
1204 const char* function_name,
1206 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); 1205 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount);
1207 void RestoreStateForSimulatedFixedAttribs(); 1206 void RestoreStateForSimulatedFixedAttribs();
1208 1207
1209 // Handle DrawArrays and DrawElements for both instanced and non-instanced 1208 // Handle DrawArrays and DrawElements for both instanced and non-instanced
1210 // cases (primcount is 0 for non-instanced). 1209 // cases (primcount is 0 for non-instanced).
1211 error::Error DoDrawArrays( 1210 error::Error DoDrawArrays(
1211 const char* function_name,
1212 bool instanced, GLenum mode, GLint first, GLsizei count, 1212 bool instanced, GLenum mode, GLint first, GLsizei count,
1213 GLsizei primcount); 1213 GLsizei primcount);
1214 error::Error DoDrawElements( 1214 error::Error DoDrawElements(
1215 const char* function_name,
1215 bool instanced, GLenum mode, GLsizei count, GLenum type, 1216 bool instanced, GLenum mode, GLsizei count, GLenum type,
1216 int32 offset, GLsizei primcount); 1217 int32 offset, GLsizei primcount);
1217 1218
1218 // Gets the buffer id for a given target. 1219 // Gets the buffer id for a given target.
1219 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) { 1220 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) {
1220 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); 1221 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER);
1221 BufferManager::BufferInfo* info = target == GL_ARRAY_BUFFER ? 1222 BufferManager::BufferInfo* info = target == GL_ARRAY_BUFFER ?
1222 bound_array_buffer_ : bound_element_array_buffer_; 1223 bound_array_buffer_ : bound_element_array_buffer_;
1223 return info; 1224 return info;
1224 } 1225 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 void ReleaseIOSurfaceForTexture(GLuint texture_id); 1325 void ReleaseIOSurfaceForTexture(GLuint texture_id);
1325 #endif 1326 #endif
1326 1327
1327 // Validates the combination of texture parameters. For example validates that 1328 // Validates the combination of texture parameters. For example validates that
1328 // for a given format the specific type, level and targets are valid. 1329 // for a given format the specific type, level and targets are valid.
1329 // Synthesizes the correct GL error if invalid. Returns true if valid. 1330 // Synthesizes the correct GL error if invalid. Returns true if valid.
1330 bool ValidateTextureParameters( 1331 bool ValidateTextureParameters(
1331 const char* function_name, 1332 const char* function_name,
1332 GLenum target, GLenum format, GLenum type, GLint level); 1333 GLenum target, GLenum format, GLenum type, GLint level);
1333 1334
1335 bool ValidateCompressedTexDimensions(
1336 const char* function_name,
1337 GLint level, GLsizei width, GLsizei height, GLenum format);
1338 bool ValidateCompressedTexFuncData(
1339 const char* function_name,
1340 GLsizei width, GLsizei height, GLenum format, size_t size);
1341 bool ValidateCompressedTexSubDimensions(
1342 const char* function_name,
1343 GLenum target, GLint level, GLint xoffset, GLint yoffset,
1344 GLsizei width, GLsizei height, GLenum format,
1345 TextureManager::TextureInfo* texture);
1346
1334 void LogMessage(const std::string& msg); 1347 void LogMessage(const std::string& msg);
1335 void RenderWarning(const std::string& msg); 1348 void RenderWarning(const std::string& msg);
1336 void PerformanceWarning(const std::string& msg); 1349 void PerformanceWarning(const std::string& msg);
1337 1350
1338 // Generate a member function prototype for each command in an automated and 1351 // Generate a member function prototype for each command in an automated and
1339 // typesafe way. 1352 // typesafe way.
1340 #define GLES2_CMD_OP(name) \ 1353 #define GLES2_CMD_OP(name) \
1341 Error Handle ## name( \ 1354 Error Handle ## name( \
1342 uint32 immediate_data_size, \ 1355 uint32 immediate_data_size, \
1343 const gles2::name& args); \ 1356 const gles2::name& args); \
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 return true; 2592 return true;
2580 } 2593 }
2581 2594
2582 if (framebuffer_manager()->IsComplete(framebuffer)) { 2595 if (framebuffer_manager()->IsComplete(framebuffer)) {
2583 return true; 2596 return true;
2584 } 2597 }
2585 2598
2586 GLenum completeness = framebuffer->IsPossiblyComplete(); 2599 GLenum completeness = framebuffer->IsPossiblyComplete();
2587 if (completeness != GL_FRAMEBUFFER_COMPLETE) { 2600 if (completeness != GL_FRAMEBUFFER_COMPLETE) {
2588 SetGLError( 2601 SetGLError(
2589 GL_INVALID_FRAMEBUFFER_OPERATION, 2602 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete");
2590 (std::string(func_name) + " framebuffer incomplete").c_str());
2591 return false; 2603 return false;
2592 } 2604 }
2593 2605
2594 // Are all the attachments cleared? 2606 // Are all the attachments cleared?
2595 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() || 2607 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() ||
2596 texture_manager()->HaveUnclearedMips()) { 2608 texture_manager()->HaveUnclearedMips()) {
2597 if (!framebuffer->IsCleared()) { 2609 if (!framebuffer->IsCleared()) {
2598 // Can we clear them? 2610 // Can we clear them?
2599 if (glCheckFramebufferStatusEXT(target) != GL_FRAMEBUFFER_COMPLETE) { 2611 if (glCheckFramebufferStatusEXT(target) != GL_FRAMEBUFFER_COMPLETE) {
2600 SetGLError( 2612 SetGLError(
2601 GL_INVALID_FRAMEBUFFER_OPERATION, 2613 GL_INVALID_FRAMEBUFFER_OPERATION, func_name,
2602 (std::string(func_name) + 2614 "framebuffer incomplete (clear)");
2603 " framebuffer incomplete (clear)").c_str());
2604 return false; 2615 return false;
2605 } 2616 }
2606 ClearUnclearedAttachments(target, framebuffer); 2617 ClearUnclearedAttachments(target, framebuffer);
2607 } 2618 }
2608 } 2619 }
2609 2620
2610 if (!framebuffer_manager()->IsComplete(framebuffer)) { 2621 if (!framebuffer_manager()->IsComplete(framebuffer)) {
2611 if (glCheckFramebufferStatusEXT(target) != GL_FRAMEBUFFER_COMPLETE) { 2622 if (glCheckFramebufferStatusEXT(target) != GL_FRAMEBUFFER_COMPLETE) {
2612 SetGLError( 2623 SetGLError(
2613 GL_INVALID_FRAMEBUFFER_OPERATION, 2624 GL_INVALID_FRAMEBUFFER_OPERATION, func_name,
2614 (std::string(func_name) + 2625 "framebuffer incomplete (check)");
2615 " framebuffer incomplete (check)").c_str());
2616 return false; 2626 return false;
2617 } 2627 }
2618 framebuffer_manager()->MarkAsComplete(framebuffer); 2628 framebuffer_manager()->MarkAsComplete(framebuffer);
2619 } 2629 }
2620 2630
2621 // NOTE: At this point we don't know if the framebuffer is complete but 2631 // NOTE: At this point we don't know if the framebuffer is complete but
2622 // we DO know that everything that needs to be cleared has been cleared. 2632 // we DO know that everything that needs to be cleared has been cleared.
2623 return true; 2633 return true;
2624 } 2634 }
2625 2635
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 3149
3140 GLES2_COMMAND_LIST(GLES2_CMD_OP) 3150 GLES2_COMMAND_LIST(GLES2_CMD_OP)
3141 #undef GLES2_CMD_OP 3151 #undef GLES2_CMD_OP
3142 } 3152 }
3143 if (debug()) { 3153 if (debug()) {
3144 GLenum error; 3154 GLenum error;
3145 while ((error = glGetError()) != GL_NO_ERROR) { 3155 while ((error = glGetError()) != GL_NO_ERROR) {
3146 LOG(ERROR) << "[" << this << "] " 3156 LOG(ERROR) << "[" << this << "] "
3147 << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : " 3157 << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : "
3148 << GetCommandName(command); 3158 << GetCommandName(command);
3149 SetGLError(error, "GL error from driver"); 3159 SetGLError(error, "DoCommand", "GL error from driver");
3150 } 3160 }
3151 } 3161 }
3152 } else { 3162 } else {
3153 result = error::kInvalidArguments; 3163 result = error::kInvalidArguments;
3154 } 3164 }
3155 } else { 3165 } else {
3156 result = DoCommonCommand(command, arg_count, cmd_data); 3166 result = DoCommonCommand(command, arg_count, cmd_data);
3157 } 3167 }
3158 if (result == error::kNoError && current_decoder_error_ != error::kNoError) { 3168 if (result == error::kNoError && current_decoder_error_ != error::kNoError) {
3159 result = current_decoder_error_; 3169 result = current_decoder_error_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3194 } 3204 }
3195 3205
3196 void GLES2DecoderImpl::DoFlush() { 3206 void GLES2DecoderImpl::DoFlush() {
3197 glFlush(); 3207 glFlush();
3198 ProcessPendingQueries(); 3208 ProcessPendingQueries();
3199 } 3209 }
3200 3210
3201 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { 3211 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) {
3202 GLuint texture_index = texture_unit - GL_TEXTURE0; 3212 GLuint texture_index = texture_unit - GL_TEXTURE0;
3203 if (texture_index >= group_->max_texture_units()) { 3213 if (texture_index >= group_->max_texture_units()) {
3204 SetGLError(GL_INVALID_ENUM, "glActiveTexture: texture_unit out of range."); 3214 SetGLError(
3215 GL_INVALID_ENUM, "glActiveTexture", "texture_unit out of range.");
3205 return; 3216 return;
3206 } 3217 }
3207 active_texture_unit_ = texture_index; 3218 active_texture_unit_ = texture_index;
3208 glActiveTexture(texture_unit); 3219 glActiveTexture(texture_unit);
3209 } 3220 }
3210 3221
3211 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { 3222 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) {
3212 BufferManager::BufferInfo* info = NULL; 3223 BufferManager::BufferInfo* info = NULL;
3213 GLuint service_id = 0; 3224 GLuint service_id = 0;
3214 if (client_id != 0) { 3225 if (client_id != 0) {
(...skipping 10 matching lines...) Expand all
3225 CreateBufferInfo(client_id, service_id); 3236 CreateBufferInfo(client_id, service_id);
3226 info = GetBufferInfo(client_id); 3237 info = GetBufferInfo(client_id);
3227 IdAllocatorInterface* id_allocator = 3238 IdAllocatorInterface* id_allocator =
3228 group_->GetIdAllocator(id_namespaces::kBuffers); 3239 group_->GetIdAllocator(id_namespaces::kBuffers);
3229 id_allocator->MarkAsUsed(client_id); 3240 id_allocator->MarkAsUsed(client_id);
3230 } 3241 }
3231 } 3242 }
3232 if (info) { 3243 if (info) {
3233 if (!buffer_manager()->SetTarget(info, target)) { 3244 if (!buffer_manager()->SetTarget(info, target)) {
3234 SetGLError(GL_INVALID_OPERATION, 3245 SetGLError(GL_INVALID_OPERATION,
3235 "glBindBuffer: buffer bound to more than 1 target"); 3246 "glBindBuffer", "buffer bound to more than 1 target");
3236 return; 3247 return;
3237 } 3248 }
3238 service_id = info->service_id(); 3249 service_id = info->service_id();
3239 } 3250 }
3240 switch (target) { 3251 switch (target) {
3241 case GL_ARRAY_BUFFER: 3252 case GL_ARRAY_BUFFER:
3242 bound_array_buffer_ = info; 3253 bound_array_buffer_ = info;
3243 break; 3254 break;
3244 case GL_ELEMENT_ARRAY_BUFFER: 3255 case GL_ELEMENT_ARRAY_BUFFER:
3245 bound_element_array_buffer_ = info; 3256 bound_element_array_buffer_ = info;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
3410 id_allocator->MarkAsUsed(client_id); 3421 id_allocator->MarkAsUsed(client_id);
3411 } 3422 }
3412 } else { 3423 } else {
3413 info = texture_manager()->GetDefaultTextureInfo(target); 3424 info = texture_manager()->GetDefaultTextureInfo(target);
3414 } 3425 }
3415 3426
3416 // Check the texture exists 3427 // Check the texture exists
3417 // Check that we are not trying to bind it to a different target. 3428 // Check that we are not trying to bind it to a different target.
3418 if (info->target() != 0 && info->target() != target) { 3429 if (info->target() != 0 && info->target() != target) {
3419 SetGLError(GL_INVALID_OPERATION, 3430 SetGLError(GL_INVALID_OPERATION,
3420 "glBindTexture: texture bound to more than 1 target."); 3431 "glBindTexture", "texture bound to more than 1 target.");
3421 return; 3432 return;
3422 } 3433 }
3423 if (info->IsStreamTexture() && target != GL_TEXTURE_EXTERNAL_OES) { 3434 if (info->IsStreamTexture() && target != GL_TEXTURE_EXTERNAL_OES) {
3424 SetGLError(GL_INVALID_OPERATION, 3435 SetGLError(GL_INVALID_OPERATION,
3425 "glBindTexture: illegal target for stream texture."); 3436 "glBindTexture", "illegal target for stream texture.");
3426 return; 3437 return;
3427 } 3438 }
3428 if (info->target() == 0) { 3439 if (info->target() == 0) {
3429 texture_manager()->SetInfoTarget(info, target); 3440 texture_manager()->SetInfoTarget(info, target);
3430 } 3441 }
3431 glBindTexture(target, info->service_id()); 3442 glBindTexture(target, info->service_id());
3432 TextureUnit& unit = texture_units_[active_texture_unit_]; 3443 TextureUnit& unit = texture_units_[active_texture_unit_];
3433 unit.bind_target = target; 3444 unit.bind_target = target;
3434 switch (target) { 3445 switch (target) {
3435 case GL_TEXTURE_2D: 3446 case GL_TEXTURE_2D:
(...skipping 22 matching lines...) Expand all
3458 } 3469 }
3459 3470
3460 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { 3471 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) {
3461 if (vertex_attrib_manager_->Enable(index, false)) { 3472 if (vertex_attrib_manager_->Enable(index, false)) {
3462 if (index != 0 || 3473 if (index != 0 ||
3463 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { 3474 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) {
3464 glDisableVertexAttribArray(index); 3475 glDisableVertexAttribArray(index);
3465 } 3476 }
3466 } else { 3477 } else {
3467 SetGLError(GL_INVALID_VALUE, 3478 SetGLError(GL_INVALID_VALUE,
3468 "glDisableVertexAttribArray: index out of range"); 3479 "glDisableVertexAttribArray", "index out of range");
3469 } 3480 }
3470 } 3481 }
3471 3482
3472 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { 3483 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) {
3473 if (vertex_attrib_manager_->Enable(index, true)) { 3484 if (vertex_attrib_manager_->Enable(index, true)) {
3474 glEnableVertexAttribArray(index); 3485 glEnableVertexAttribArray(index);
3475 } else { 3486 } else {
3476 SetGLError(GL_INVALID_VALUE, 3487 SetGLError(GL_INVALID_VALUE,
3477 "glEnableVertexAttribArray: index out of range"); 3488 "glEnableVertexAttribArray", "index out of range");
3478 } 3489 }
3479 } 3490 }
3480 3491
3481 void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) { 3492 void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {
3482 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 3493 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
3483 if (!info || 3494 if (!info ||
3484 !texture_manager()->CanGenerateMipmaps(info)) { 3495 !texture_manager()->CanGenerateMipmaps(info)) {
3485 SetGLError(GL_INVALID_OPERATION, 3496 SetGLError(GL_INVALID_OPERATION,
3486 "glGenerateMipmaps: Can not generate mips"); 3497 "glGenerateMipmaps", "Can not generate mips");
3487 return; 3498 return;
3488 } 3499 }
3489 3500
3490 if (!texture_manager()->ClearTextureLevel(this, info, target, 0)) { 3501 if (!texture_manager()->ClearTextureLevel(this, info, target, 0)) {
3491 SetGLError(GL_OUT_OF_MEMORY, "glGenerateMipmaps: dimensions too big"); 3502 SetGLError(GL_OUT_OF_MEMORY, "glGenerateMipmaps", "dimensions too big");
3492 return; 3503 return;
3493 } 3504 }
3494 3505
3495 CopyRealGLErrorsToWrapper(); 3506 CopyRealGLErrorsToWrapper();
3496 // Workaround for Mac driver bug. In the large scheme of things setting 3507 // Workaround for Mac driver bug. In the large scheme of things setting
3497 // glTexParamter twice for glGenerateMipmap is probably not a lage performance 3508 // glTexParamter twice for glGenerateMipmap is probably not a lage performance
3498 // hit so there's probably no need to make this conditional. The bug appears 3509 // hit so there's probably no need to make this conditional. The bug appears
3499 // to be that if the filtering mode is set to something that doesn't require 3510 // to be that if the filtering mode is set to something that doesn't require
3500 // mipmaps for rendering, or is never set to something other than the default, 3511 // mipmaps for rendering, or is never set to something other than the default,
3501 // then glGenerateMipmap misbehaves. 3512 // then glGenerateMipmap misbehaves.
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
3876 program_id, "glGetProgramiv"); 3887 program_id, "glGetProgramiv");
3877 if (!info) { 3888 if (!info) {
3878 return; 3889 return;
3879 } 3890 }
3880 info->GetProgramiv(pname, params); 3891 info->GetProgramiv(pname, params);
3881 } 3892 }
3882 3893
3883 void GLES2DecoderImpl::DoBindAttribLocation( 3894 void GLES2DecoderImpl::DoBindAttribLocation(
3884 GLuint program, GLuint index, const char* name) { 3895 GLuint program, GLuint index, const char* name) {
3885 if (!StringIsValidForGLES(name)) { 3896 if (!StringIsValidForGLES(name)) {
3886 SetGLError(GL_INVALID_VALUE, "glBindAttribLocation: Invalid character"); 3897 SetGLError(GL_INVALID_VALUE, "glBindAttribLocation", "Invalid character");
3887 return; 3898 return;
3888 } 3899 }
3889 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { 3900 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) {
3890 SetGLError(GL_INVALID_OPERATION, "glBindAttribLocation: reserved prefix"); 3901 SetGLError(GL_INVALID_OPERATION, "glBindAttribLocation", "reserved prefix");
3891 return; 3902 return;
3892 } 3903 }
3893 if (index >= group_->max_vertex_attribs()) { 3904 if (index >= group_->max_vertex_attribs()) {
3894 SetGLError(GL_INVALID_VALUE, "glBindAttribLocation: index out of range"); 3905 SetGLError(GL_INVALID_VALUE, "glBindAttribLocation", "index out of range");
3895 return; 3906 return;
3896 } 3907 }
3897 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 3908 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
3898 program, "glBindAttribLocation"); 3909 program, "glBindAttribLocation");
3899 if (!info) { 3910 if (!info) {
3900 return; 3911 return;
3901 } 3912 }
3902 info->SetAttribLocationBinding(name, static_cast<GLint>(index)); 3913 info->SetAttribLocationBinding(name, static_cast<GLint>(index));
3903 glBindAttribLocation(info->service_id(), index, name); 3914 glBindAttribLocation(info->service_id(), index, name);
3904 } 3915 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3953 uint32 immediate_data_size, const gles2::DeleteShader& c) { 3964 uint32 immediate_data_size, const gles2::DeleteShader& c) {
3954 GLuint client_id = c.shader; 3965 GLuint client_id = c.shader;
3955 if (client_id) { 3966 if (client_id) {
3956 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id); 3967 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id);
3957 if (info) { 3968 if (info) {
3958 if (!info->IsDeleted()) { 3969 if (!info->IsDeleted()) {
3959 glDeleteShader(info->service_id()); 3970 glDeleteShader(info->service_id());
3960 shader_manager()->MarkAsDeleted(info); 3971 shader_manager()->MarkAsDeleted(info);
3961 } 3972 }
3962 } else { 3973 } else {
3963 SetGLError(GL_INVALID_VALUE, "glDeleteShader: unknown shader"); 3974 SetGLError(GL_INVALID_VALUE, "glDeleteShader", "unknown shader");
3964 } 3975 }
3965 } 3976 }
3966 return error::kNoError; 3977 return error::kNoError;
3967 } 3978 }
3968 3979
3969 error::Error GLES2DecoderImpl::HandleDeleteProgram( 3980 error::Error GLES2DecoderImpl::HandleDeleteProgram(
3970 uint32 immediate_data_size, const gles2::DeleteProgram& c) { 3981 uint32 immediate_data_size, const gles2::DeleteProgram& c) {
3971 GLuint client_id = c.program; 3982 GLuint client_id = c.program;
3972 if (client_id) { 3983 if (client_id) {
3973 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id); 3984 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id);
3974 if (info) { 3985 if (info) {
3975 if (!info->IsDeleted()) { 3986 if (!info->IsDeleted()) {
3976 program_manager()->MarkAsDeleted(shader_manager(), info); 3987 program_manager()->MarkAsDeleted(shader_manager(), info);
3977 } 3988 }
3978 } else { 3989 } else {
3979 SetGLError(GL_INVALID_VALUE, "glDeleteProgram: unknown program"); 3990 SetGLError(GL_INVALID_VALUE, "glDeleteProgram", "unknown program");
3980 } 3991 }
3981 } 3992 }
3982 return error::kNoError; 3993 return error::kNoError;
3983 } 3994 }
3984 3995
3985 void GLES2DecoderImpl::DoDeleteSharedIdsCHROMIUM( 3996 void GLES2DecoderImpl::DoDeleteSharedIdsCHROMIUM(
3986 GLuint namespace_id, GLsizei n, const GLuint* ids) { 3997 GLuint namespace_id, GLsizei n, const GLuint* ids) {
3987 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id); 3998 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id);
3988 for (GLsizei ii = 0; ii < n; ++ii) { 3999 for (GLsizei ii = 0; ii < n; ++ii) {
3989 id_allocator->FreeID(ids[ii]); 4000 id_allocator->FreeID(ids[ii]);
3990 } 4001 }
3991 } 4002 }
3992 4003
3993 error::Error GLES2DecoderImpl::HandleDeleteSharedIdsCHROMIUM( 4004 error::Error GLES2DecoderImpl::HandleDeleteSharedIdsCHROMIUM(
3994 uint32 immediate_data_size, const gles2::DeleteSharedIdsCHROMIUM& c) { 4005 uint32 immediate_data_size, const gles2::DeleteSharedIdsCHROMIUM& c) {
3995 GLuint namespace_id = static_cast<GLuint>(c.namespace_id); 4006 GLuint namespace_id = static_cast<GLuint>(c.namespace_id);
3996 GLsizei n = static_cast<GLsizei>(c.n); 4007 GLsizei n = static_cast<GLsizei>(c.n);
3997 uint32 data_size; 4008 uint32 data_size;
3998 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 4009 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
3999 return error::kOutOfBounds; 4010 return error::kOutOfBounds;
4000 } 4011 }
4001 const GLuint* ids = GetSharedMemoryAs<const GLuint*>( 4012 const GLuint* ids = GetSharedMemoryAs<const GLuint*>(
4002 c.ids_shm_id, c.ids_shm_offset, data_size); 4013 c.ids_shm_id, c.ids_shm_offset, data_size);
4003 if (n < 0) { 4014 if (n < 0) {
4004 SetGLError(GL_INVALID_VALUE, "DeleteSharedIdsCHROMIUM: n < 0"); 4015 SetGLError(GL_INVALID_VALUE, "DeleteSharedIdsCHROMIUM", "n < 0");
4005 return error::kNoError; 4016 return error::kNoError;
4006 } 4017 }
4007 if (ids == NULL) { 4018 if (ids == NULL) {
4008 return error::kOutOfBounds; 4019 return error::kOutOfBounds;
4009 } 4020 }
4010 DoDeleteSharedIdsCHROMIUM(namespace_id, n, ids); 4021 DoDeleteSharedIdsCHROMIUM(namespace_id, n, ids);
4011 return error::kNoError; 4022 return error::kNoError;
4012 } 4023 }
4013 4024
4014 void GLES2DecoderImpl::DoGenSharedIdsCHROMIUM( 4025 void GLES2DecoderImpl::DoGenSharedIdsCHROMIUM(
(...skipping 16 matching lines...) Expand all
4031 GLuint namespace_id = static_cast<GLuint>(c.namespace_id); 4042 GLuint namespace_id = static_cast<GLuint>(c.namespace_id);
4032 GLuint id_offset = static_cast<GLuint>(c.id_offset); 4043 GLuint id_offset = static_cast<GLuint>(c.id_offset);
4033 GLsizei n = static_cast<GLsizei>(c.n); 4044 GLsizei n = static_cast<GLsizei>(c.n);
4034 uint32 data_size; 4045 uint32 data_size;
4035 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 4046 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4036 return error::kOutOfBounds; 4047 return error::kOutOfBounds;
4037 } 4048 }
4038 GLuint* ids = GetSharedMemoryAs<GLuint*>( 4049 GLuint* ids = GetSharedMemoryAs<GLuint*>(
4039 c.ids_shm_id, c.ids_shm_offset, data_size); 4050 c.ids_shm_id, c.ids_shm_offset, data_size);
4040 if (n < 0) { 4051 if (n < 0) {
4041 SetGLError(GL_INVALID_VALUE, "GenSharedIdsCHROMIUM: n < 0"); 4052 SetGLError(GL_INVALID_VALUE, "GenSharedIdsCHROMIUM", "n < 0");
4042 return error::kNoError; 4053 return error::kNoError;
4043 } 4054 }
4044 if (ids == NULL) { 4055 if (ids == NULL) {
4045 return error::kOutOfBounds; 4056 return error::kOutOfBounds;
4046 } 4057 }
4047 DoGenSharedIdsCHROMIUM(namespace_id, id_offset, n, ids); 4058 DoGenSharedIdsCHROMIUM(namespace_id, id_offset, n, ids);
4048 return error::kNoError; 4059 return error::kNoError;
4049 } 4060 }
4050 4061
4051 void GLES2DecoderImpl::DoRegisterSharedIdsCHROMIUM( 4062 void GLES2DecoderImpl::DoRegisterSharedIdsCHROMIUM(
4052 GLuint namespace_id, GLsizei n, const GLuint* ids) { 4063 GLuint namespace_id, GLsizei n, const GLuint* ids) {
4053 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id); 4064 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id);
4054 for (GLsizei ii = 0; ii < n; ++ii) { 4065 for (GLsizei ii = 0; ii < n; ++ii) {
4055 if (!id_allocator->MarkAsUsed(ids[ii])) { 4066 if (!id_allocator->MarkAsUsed(ids[ii])) {
4056 for (GLsizei jj = 0; jj < ii; ++jj) { 4067 for (GLsizei jj = 0; jj < ii; ++jj) {
4057 id_allocator->FreeID(ids[jj]); 4068 id_allocator->FreeID(ids[jj]);
4058 } 4069 }
4059 SetGLError( 4070 SetGLError(
4060 GL_INVALID_VALUE, 4071 GL_INVALID_VALUE, "RegisterSharedIdsCHROMIUM",
4061 "RegisterSharedIdsCHROMIUM: attempt to register " 4072 "attempt to register id that already exists");
4062 "id that already exists");
4063 return; 4073 return;
4064 } 4074 }
4065 } 4075 }
4066 } 4076 }
4067 4077
4068 error::Error GLES2DecoderImpl::HandleRegisterSharedIdsCHROMIUM( 4078 error::Error GLES2DecoderImpl::HandleRegisterSharedIdsCHROMIUM(
4069 uint32 immediate_data_size, const gles2::RegisterSharedIdsCHROMIUM& c) { 4079 uint32 immediate_data_size, const gles2::RegisterSharedIdsCHROMIUM& c) {
4070 GLuint namespace_id = static_cast<GLuint>(c.namespace_id); 4080 GLuint namespace_id = static_cast<GLuint>(c.namespace_id);
4071 GLsizei n = static_cast<GLsizei>(c.n); 4081 GLsizei n = static_cast<GLsizei>(c.n);
4072 uint32 data_size; 4082 uint32 data_size;
4073 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 4083 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4074 return error::kOutOfBounds; 4084 return error::kOutOfBounds;
4075 } 4085 }
4076 GLuint* ids = GetSharedMemoryAs<GLuint*>( 4086 GLuint* ids = GetSharedMemoryAs<GLuint*>(
4077 c.ids_shm_id, c.ids_shm_offset, data_size); 4087 c.ids_shm_id, c.ids_shm_offset, data_size);
4078 if (n < 0) { 4088 if (n < 0) {
4079 SetGLError(GL_INVALID_VALUE, "RegisterSharedIdsCHROMIUM: n < 0"); 4089 SetGLError(GL_INVALID_VALUE, "RegisterSharedIdsCHROMIUM", "n < 0");
4080 return error::kNoError; 4090 return error::kNoError;
4081 } 4091 }
4082 if (ids == NULL) { 4092 if (ids == NULL) {
4083 return error::kOutOfBounds; 4093 return error::kOutOfBounds;
4084 } 4094 }
4085 DoRegisterSharedIdsCHROMIUM(namespace_id, n, ids); 4095 DoRegisterSharedIdsCHROMIUM(namespace_id, n, ids);
4086 return error::kNoError; 4096 return error::kNoError;
4087 } 4097 }
4088 4098
4089 void GLES2DecoderImpl::DoClear(GLbitfield mask) { 4099 void GLES2DecoderImpl::DoClear(GLbitfield mask) {
4090 if (CheckBoundFramebuffersValid("glClear")) { 4100 if (CheckBoundFramebuffersValid("glClear")) {
4091 UNSHIPPED_TRACE_EVENT_INSTANT2("test_gpu", "DoClear", "red", clear_red_, 4101 UNSHIPPED_TRACE_EVENT_INSTANT2("test_gpu", "DoClear", "red", clear_red_,
4092 "green", clear_green_); 4102 "green", clear_green_);
4093 ApplyDirtyState(); 4103 ApplyDirtyState();
4094 glClear(mask); 4104 glClear(mask);
4095 } 4105 }
4096 } 4106 }
4097 4107
4098 void GLES2DecoderImpl::DoFramebufferRenderbuffer( 4108 void GLES2DecoderImpl::DoFramebufferRenderbuffer(
4099 GLenum target, GLenum attachment, GLenum renderbuffertarget, 4109 GLenum target, GLenum attachment, GLenum renderbuffertarget,
4100 GLuint client_renderbuffer_id) { 4110 GLuint client_renderbuffer_id) {
4101 FramebufferManager::FramebufferInfo* framebuffer_info = 4111 FramebufferManager::FramebufferInfo* framebuffer_info =
4102 GetFramebufferInfoForTarget(target); 4112 GetFramebufferInfoForTarget(target);
4103 if (!framebuffer_info) { 4113 if (!framebuffer_info) {
4104 SetGLError(GL_INVALID_OPERATION, 4114 SetGLError(GL_INVALID_OPERATION,
4105 "glFramebufferRenderbuffer: no framebuffer bound"); 4115 "glFramebufferRenderbuffer", "no framebuffer bound");
4106 return; 4116 return;
4107 } 4117 }
4108 GLuint service_id = 0; 4118 GLuint service_id = 0;
4109 RenderbufferManager::RenderbufferInfo* info = NULL; 4119 RenderbufferManager::RenderbufferInfo* info = NULL;
4110 if (client_renderbuffer_id) { 4120 if (client_renderbuffer_id) {
4111 info = GetRenderbufferInfo(client_renderbuffer_id); 4121 info = GetRenderbufferInfo(client_renderbuffer_id);
4112 if (!info) { 4122 if (!info) {
4113 SetGLError(GL_INVALID_OPERATION, 4123 SetGLError(GL_INVALID_OPERATION,
4114 "glFramebufferRenderbuffer: unknown renderbuffer"); 4124 "glFramebufferRenderbuffer", "unknown renderbuffer");
4115 return; 4125 return;
4116 } 4126 }
4117 service_id = info->service_id(); 4127 service_id = info->service_id();
4118 } 4128 }
4119 CopyRealGLErrorsToWrapper(); 4129 CopyRealGLErrorsToWrapper();
4120 glFramebufferRenderbufferEXT( 4130 glFramebufferRenderbufferEXT(
4121 target, attachment, renderbuffertarget, service_id); 4131 target, attachment, renderbuffertarget, service_id);
4122 GLenum error = PeekGLError(); 4132 GLenum error = PeekGLError();
4123 if (error == GL_NO_ERROR) { 4133 if (error == GL_NO_ERROR) {
4124 framebuffer_info->AttachRenderbuffer(attachment, info); 4134 framebuffer_info->AttachRenderbuffer(attachment, info);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4311 return glCheckFramebufferStatusEXT(target); 4321 return glCheckFramebufferStatusEXT(target);
4312 } 4322 }
4313 4323
4314 void GLES2DecoderImpl::DoFramebufferTexture2D( 4324 void GLES2DecoderImpl::DoFramebufferTexture2D(
4315 GLenum target, GLenum attachment, GLenum textarget, 4325 GLenum target, GLenum attachment, GLenum textarget,
4316 GLuint client_texture_id, GLint level) { 4326 GLuint client_texture_id, GLint level) {
4317 FramebufferManager::FramebufferInfo* framebuffer_info = 4327 FramebufferManager::FramebufferInfo* framebuffer_info =
4318 GetFramebufferInfoForTarget(target); 4328 GetFramebufferInfoForTarget(target);
4319 if (!framebuffer_info) { 4329 if (!framebuffer_info) {
4320 SetGLError(GL_INVALID_OPERATION, 4330 SetGLError(GL_INVALID_OPERATION,
4321 "glFramebufferTexture2D: no framebuffer bound."); 4331 "glFramebufferTexture2D", "no framebuffer bound.");
4322 return; 4332 return;
4323 } 4333 }
4324 GLuint service_id = 0; 4334 GLuint service_id = 0;
4325 TextureManager::TextureInfo* info = NULL; 4335 TextureManager::TextureInfo* info = NULL;
4326 if (client_texture_id) { 4336 if (client_texture_id) {
4327 info = GetTextureInfo(client_texture_id); 4337 info = GetTextureInfo(client_texture_id);
4328 if (!info) { 4338 if (!info) {
4329 SetGLError(GL_INVALID_OPERATION, 4339 SetGLError(GL_INVALID_OPERATION,
4330 "glFramebufferTexture2D: unknown texture"); 4340 "glFramebufferTexture2D", "unknown texture");
4331 return; 4341 return;
4332 } 4342 }
4333 service_id = info->service_id(); 4343 service_id = info->service_id();
4334 } 4344 }
4335 4345
4336 if (!texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { 4346 if (!texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) {
4337 SetGLError(GL_INVALID_VALUE, 4347 SetGLError(GL_INVALID_VALUE,
4338 "glFramebufferTexture2D: level out of range"); 4348 "glFramebufferTexture2D", "level out of range");
4339 return; 4349 return;
4340 } 4350 }
4341 4351
4342 CopyRealGLErrorsToWrapper(); 4352 CopyRealGLErrorsToWrapper();
4343 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); 4353 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level);
4344 GLenum error = PeekGLError(); 4354 GLenum error = PeekGLError();
4345 if (error == GL_NO_ERROR) { 4355 if (error == GL_NO_ERROR) {
4346 framebuffer_info->AttachTexture(attachment, info, textarget, level); 4356 framebuffer_info->AttachTexture(attachment, info, textarget, level);
4347 } 4357 }
4348 if (framebuffer_info == bound_draw_framebuffer_) { 4358 if (framebuffer_info == bound_draw_framebuffer_) {
4349 state_dirty_ = true; 4359 state_dirty_ = true;
4350 } 4360 }
4351 } 4361 }
4352 4362
4353 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( 4363 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv(
4354 GLenum target, GLenum attachment, GLenum pname, GLint* params) { 4364 GLenum target, GLenum attachment, GLenum pname, GLint* params) {
4355 FramebufferManager::FramebufferInfo* framebuffer_info = 4365 FramebufferManager::FramebufferInfo* framebuffer_info =
4356 GetFramebufferInfoForTarget(target); 4366 GetFramebufferInfoForTarget(target);
4357 if (!framebuffer_info) { 4367 if (!framebuffer_info) {
4358 SetGLError(GL_INVALID_OPERATION, 4368 SetGLError(GL_INVALID_OPERATION,
4359 "glFramebufferAttachmentParameteriv: no framebuffer bound"); 4369 "glFramebufferAttachmentParameteriv", "no framebuffer bound");
4360 return; 4370 return;
4361 } 4371 }
4362 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); 4372 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params);
4363 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { 4373 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) {
4364 GLint type = 0; 4374 GLint type = 0;
4365 GLuint client_id = 0; 4375 GLuint client_id = 0;
4366 glGetFramebufferAttachmentParameterivEXT( 4376 glGetFramebufferAttachmentParameterivEXT(
4367 target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); 4377 target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type);
4368 switch (type) { 4378 switch (type) {
4369 case GL_RENDERBUFFER: { 4379 case GL_RENDERBUFFER: {
(...skipping 10 matching lines...) Expand all
4380 *params = client_id; 4390 *params = client_id;
4381 } 4391 }
4382 } 4392 }
4383 4393
4384 void GLES2DecoderImpl::DoGetRenderbufferParameteriv( 4394 void GLES2DecoderImpl::DoGetRenderbufferParameteriv(
4385 GLenum target, GLenum pname, GLint* params) { 4395 GLenum target, GLenum pname, GLint* params) {
4386 RenderbufferManager::RenderbufferInfo* renderbuffer = 4396 RenderbufferManager::RenderbufferInfo* renderbuffer =
4387 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); 4397 GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
4388 if (!renderbuffer) { 4398 if (!renderbuffer) {
4389 SetGLError(GL_INVALID_OPERATION, 4399 SetGLError(GL_INVALID_OPERATION,
4390 "glGetRenderbufferParameteriv: no renderbuffer bound"); 4400 "glGetRenderbufferParameteriv", "no renderbuffer bound");
4391 return; 4401 return;
4392 } 4402 }
4393 switch (pname) { 4403 switch (pname) {
4394 case GL_RENDERBUFFER_INTERNAL_FORMAT: 4404 case GL_RENDERBUFFER_INTERNAL_FORMAT:
4395 *params = renderbuffer->internal_format(); 4405 *params = renderbuffer->internal_format();
4396 break; 4406 break;
4397 case GL_RENDERBUFFER_WIDTH: 4407 case GL_RENDERBUFFER_WIDTH:
4398 *params = renderbuffer->width(); 4408 *params = renderbuffer->width();
4399 break; 4409 break;
4400 case GL_RENDERBUFFER_HEIGHT: 4410 case GL_RENDERBUFFER_HEIGHT:
4401 *params = renderbuffer->height(); 4411 *params = renderbuffer->height();
4402 break; 4412 break;
4403 default: 4413 default:
4404 glGetRenderbufferParameterivEXT(target, pname, params); 4414 glGetRenderbufferParameterivEXT(target, pname, params);
4405 break; 4415 break;
4406 } 4416 }
4407 } 4417 }
4408 4418
4409 void GLES2DecoderImpl::DoBlitFramebufferEXT( 4419 void GLES2DecoderImpl::DoBlitFramebufferEXT(
4410 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 4420 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
4411 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, 4421 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
4412 GLbitfield mask, GLenum filter) { 4422 GLbitfield mask, GLenum filter) {
4413 if (!feature_info_->feature_flags().chromium_framebuffer_multisample) { 4423 if (!feature_info_->feature_flags().chromium_framebuffer_multisample) {
4414 SetGLError(GL_INVALID_OPERATION, 4424 SetGLError(GL_INVALID_OPERATION,
4415 "glBlitFramebufferEXT: function not available"); 4425 "glBlitFramebufferEXT", "function not available");
4416 } 4426 }
4417 if (IsAngle()) { 4427 if (IsAngle()) {
4418 glBlitFramebufferANGLE( 4428 glBlitFramebufferANGLE(
4419 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 4429 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
4420 } else { 4430 } else {
4421 glBlitFramebufferEXT( 4431 glBlitFramebufferEXT(
4422 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 4432 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
4423 } 4433 }
4424 UNSHIPPED_TRACE_EVENT_INSTANT1("test_gpu", "DoBlit", "width", srcX1 - srcX0); 4434 UNSHIPPED_TRACE_EVENT_INSTANT1("test_gpu", "DoBlit", "width", srcX1 - srcX0);
4425 } 4435 }
4426 4436
4427 void GLES2DecoderImpl::DoRenderbufferStorageMultisample( 4437 void GLES2DecoderImpl::DoRenderbufferStorageMultisample(
4428 GLenum target, GLsizei samples, GLenum internalformat, 4438 GLenum target, GLsizei samples, GLenum internalformat,
4429 GLsizei width, GLsizei height) { 4439 GLsizei width, GLsizei height) {
4430 if (!feature_info_->feature_flags().chromium_framebuffer_multisample) { 4440 if (!feature_info_->feature_flags().chromium_framebuffer_multisample) {
4431 SetGLError(GL_INVALID_OPERATION, 4441 SetGLError(GL_INVALID_OPERATION,
4432 "glRenderbufferStorageMultisampleEXT: function not available"); 4442 "glRenderbufferStorageMultisampleEXT", "function not available");
4433 return; 4443 return;
4434 } 4444 }
4435 4445
4436 RenderbufferManager::RenderbufferInfo* renderbuffer = 4446 RenderbufferManager::RenderbufferInfo* renderbuffer =
4437 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); 4447 GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
4438 if (!renderbuffer) { 4448 if (!renderbuffer) {
4439 SetGLError(GL_INVALID_OPERATION, 4449 SetGLError(GL_INVALID_OPERATION,
4440 "glGetRenderbufferStorageMultisample: no renderbuffer bound"); 4450 "glGetRenderbufferStorageMultisample", "no renderbuffer bound");
4441 return; 4451 return;
4442 } 4452 }
4443 4453
4444 if (samples > renderbuffer_manager()->max_samples()) { 4454 if (samples > renderbuffer_manager()->max_samples()) {
4445 SetGLError(GL_INVALID_VALUE, 4455 SetGLError(GL_INVALID_VALUE,
4446 "glGetRenderbufferStorageMultisample: samples too large"); 4456 "glGetRenderbufferStorageMultisample", "samples too large");
4447 return; 4457 return;
4448 } 4458 }
4449 4459
4450 if (width > renderbuffer_manager()->max_renderbuffer_size() || 4460 if (width > renderbuffer_manager()->max_renderbuffer_size() ||
4451 height > renderbuffer_manager()->max_renderbuffer_size()) { 4461 height > renderbuffer_manager()->max_renderbuffer_size()) {
4452 SetGLError(GL_INVALID_VALUE, 4462 SetGLError(GL_INVALID_VALUE,
4453 "glGetRenderbufferStorageMultisample: size too large"); 4463 "glGetRenderbufferStorageMultisample", "size too large");
4454 return; 4464 return;
4455 } 4465 }
4456 4466
4457 GLenum impl_format = internalformat; 4467 GLenum impl_format = internalformat;
4458 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 4468 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
4459 switch (impl_format) { 4469 switch (impl_format) {
4460 case GL_DEPTH_COMPONENT16: 4470 case GL_DEPTH_COMPONENT16:
4461 impl_format = GL_DEPTH_COMPONENT; 4471 impl_format = GL_DEPTH_COMPONENT;
4462 break; 4472 break;
4463 case GL_RGBA4: 4473 case GL_RGBA4:
(...skipping 23 matching lines...) Expand all
4487 renderbuffer, samples, internalformat, width, height); 4497 renderbuffer, samples, internalformat, width, height);
4488 } 4498 }
4489 } 4499 }
4490 4500
4491 void GLES2DecoderImpl::DoRenderbufferStorage( 4501 void GLES2DecoderImpl::DoRenderbufferStorage(
4492 GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { 4502 GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
4493 RenderbufferManager::RenderbufferInfo* renderbuffer = 4503 RenderbufferManager::RenderbufferInfo* renderbuffer =
4494 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); 4504 GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
4495 if (!renderbuffer) { 4505 if (!renderbuffer) {
4496 SetGLError(GL_INVALID_OPERATION, 4506 SetGLError(GL_INVALID_OPERATION,
4497 "glGetRenderbufferStorage: no renderbuffer bound"); 4507 "glGetRenderbufferStorage", "no renderbuffer bound");
4498 return; 4508 return;
4499 } 4509 }
4500 4510
4501 if (width > renderbuffer_manager()->max_renderbuffer_size() || 4511 if (width > renderbuffer_manager()->max_renderbuffer_size() ||
4502 height > renderbuffer_manager()->max_renderbuffer_size()) { 4512 height > renderbuffer_manager()->max_renderbuffer_size()) {
4503 SetGLError(GL_INVALID_VALUE, 4513 SetGLError(GL_INVALID_VALUE,
4504 "glGetRenderbufferStorage: size too large"); 4514 "glGetRenderbufferStorage", "size too large");
4505 return; 4515 return;
4506 } 4516 }
4507 4517
4508 GLenum impl_format = internalformat; 4518 GLenum impl_format = internalformat;
4509 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 4519 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
4510 switch (impl_format) { 4520 switch (impl_format) {
4511 case GL_DEPTH_COMPONENT16: 4521 case GL_DEPTH_COMPONENT16:
4512 impl_format = GL_DEPTH_COMPONENT; 4522 impl_format = GL_DEPTH_COMPONENT;
4513 break; 4523 break;
4514 case GL_RGBA4: 4524 case GL_RGBA4:
(...skipping 30 matching lines...) Expand all
4545 if (info == current_program_.get()) { 4555 if (info == current_program_.get()) {
4546 program_manager()->ClearUniforms(info); 4556 program_manager()->ClearUniforms(info);
4547 } 4557 }
4548 } 4558 }
4549 }; 4559 };
4550 4560
4551 void GLES2DecoderImpl::DoTexParameterf( 4561 void GLES2DecoderImpl::DoTexParameterf(
4552 GLenum target, GLenum pname, GLfloat param) { 4562 GLenum target, GLenum pname, GLfloat param) {
4553 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 4563 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
4554 if (!info) { 4564 if (!info) {
4555 SetGLError(GL_INVALID_VALUE, "glTexParameterf: unknown texture"); 4565 SetGLError(GL_INVALID_VALUE, "glTexParameterf", "unknown texture");
4556 return; 4566 return;
4557 } 4567 }
4558 4568
4559 if (!texture_manager()->SetParameter( 4569 if (!texture_manager()->SetParameter(
4560 info, pname, static_cast<GLint>(param))) { 4570 info, pname, static_cast<GLint>(param))) {
4561 SetGLError(GL_INVALID_ENUM, "glTexParameterf: param GL_INVALID_ENUM"); 4571 SetGLError(GL_INVALID_ENUM, "glTexParameterf", "param GL_INVALID_ENUM");
4562 return; 4572 return;
4563 } 4573 }
4564 glTexParameterf(target, pname, param); 4574 glTexParameterf(target, pname, param);
4565 } 4575 }
4566 4576
4567 void GLES2DecoderImpl::DoTexParameteri( 4577 void GLES2DecoderImpl::DoTexParameteri(
4568 GLenum target, GLenum pname, GLint param) { 4578 GLenum target, GLenum pname, GLint param) {
4569 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 4579 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
4570 if (!info) { 4580 if (!info) {
4571 SetGLError(GL_INVALID_VALUE, "glTexParameteri: unknown texture"); 4581 SetGLError(GL_INVALID_VALUE, "glTexParameteri", "unknown texture");
4572 return; 4582 return;
4573 } 4583 }
4574 4584
4575 if (!texture_manager()->SetParameter(info, pname, param)) { 4585 if (!texture_manager()->SetParameter(info, pname, param)) {
4576 SetGLError(GL_INVALID_ENUM, "glTexParameteri: param GL_INVALID_ENUM"); 4586 SetGLError(GL_INVALID_ENUM, "glTexParameteri", "param GL_INVALID_ENUM");
4577 return; 4587 return;
4578 } 4588 }
4579 glTexParameteri(target, pname, param); 4589 glTexParameteri(target, pname, param);
4580 } 4590 }
4581 4591
4582 void GLES2DecoderImpl::DoTexParameterfv( 4592 void GLES2DecoderImpl::DoTexParameterfv(
4583 GLenum target, GLenum pname, const GLfloat* params) { 4593 GLenum target, GLenum pname, const GLfloat* params) {
4584 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 4594 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
4585 if (!info) { 4595 if (!info) {
4586 SetGLError(GL_INVALID_VALUE, "glTexParameterfv: unknown texture"); 4596 SetGLError(GL_INVALID_VALUE, "glTexParameterfv", "unknown texture");
4587 return; 4597 return;
4588 } 4598 }
4589 4599
4590 if (!texture_manager()->SetParameter( 4600 if (!texture_manager()->SetParameter(
4591 info, pname, static_cast<GLint>(params[0]))) { 4601 info, pname, static_cast<GLint>(params[0]))) {
4592 SetGLError(GL_INVALID_ENUM, "glTexParameterfv: param GL_INVALID_ENUM"); 4602 SetGLError(GL_INVALID_ENUM, "glTexParameterfv", "param GL_INVALID_ENUM");
4593 return; 4603 return;
4594 } 4604 }
4595 glTexParameterfv(target, pname, params); 4605 glTexParameterfv(target, pname, params);
4596 } 4606 }
4597 4607
4598 void GLES2DecoderImpl::DoTexParameteriv( 4608 void GLES2DecoderImpl::DoTexParameteriv(
4599 GLenum target, GLenum pname, const GLint* params) { 4609 GLenum target, GLenum pname, const GLint* params) {
4600 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 4610 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
4601 if (!info) { 4611 if (!info) {
4602 SetGLError(GL_INVALID_VALUE, "glTexParameteriv: unknown texture"); 4612 SetGLError(GL_INVALID_VALUE, "glTexParameteriv", "unknown texture");
4603 return; 4613 return;
4604 } 4614 }
4605 4615
4606 if (!texture_manager()->SetParameter(info, pname, *params)) { 4616 if (!texture_manager()->SetParameter(info, pname, *params)) {
4607 SetGLError(GL_INVALID_ENUM, "glTexParameteriv: param GL_INVALID_ENUM"); 4617 SetGLError(GL_INVALID_ENUM, "glTexParameteriv", "param GL_INVALID_ENUM");
4608 return; 4618 return;
4609 } 4619 }
4610 glTexParameteriv(target, pname, params); 4620 glTexParameteriv(target, pname, params);
4611 } 4621 }
4612 4622
4613 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { 4623 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) {
4614 if (!current_program_) { 4624 if (!current_program_) {
4615 // The program does not exist. 4625 // The program does not exist.
4616 SetGLError(GL_INVALID_OPERATION, 4626 SetGLError(GL_INVALID_OPERATION, function_name, "no program in use");
4617 (std::string(function_name) + ": no program in use").c_str()); 4627 return false;
4618 return false;
4619 } 4628 }
4620 if (!current_program_->InUse()) { 4629 if (!current_program_->InUse()) {
4621 SetGLError(GL_INVALID_OPERATION, 4630 SetGLError(GL_INVALID_OPERATION, function_name, "program not linked");
4622 (std::string(function_name) + ": program not linked").c_str());
4623 return false; 4631 return false;
4624 } 4632 }
4625 return true; 4633 return true;
4626 } 4634 }
4627 4635
4628 bool GLES2DecoderImpl::CheckCurrentProgramForUniform( 4636 bool GLES2DecoderImpl::CheckCurrentProgramForUniform(
4629 GLint location, const char* function_name) { 4637 GLint location, const char* function_name) {
4630 if (!CheckCurrentProgram(function_name)) { 4638 if (!CheckCurrentProgram(function_name)) {
4631 return false; 4639 return false;
4632 } 4640 }
4633 return location != -1; 4641 return location != -1;
4634 } 4642 }
4635 4643
4636 bool GLES2DecoderImpl::PrepForSetUniformByLocation( 4644 bool GLES2DecoderImpl::PrepForSetUniformByLocation(
4637 GLint fake_location, const char* function_name, 4645 GLint fake_location, const char* function_name,
4638 GLint* real_location, GLenum* type, GLsizei* count) { 4646 GLint* real_location, GLenum* type, GLsizei* count) {
4639 DCHECK(type); 4647 DCHECK(type);
4640 DCHECK(count); 4648 DCHECK(count);
4641 DCHECK(real_location); 4649 DCHECK(real_location);
4642 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { 4650 if (!CheckCurrentProgramForUniform(fake_location, function_name)) {
4643 return false; 4651 return false;
4644 } 4652 }
4645 GLint array_index = -1; 4653 GLint array_index = -1;
4646 const ProgramManager::ProgramInfo::UniformInfo* info = 4654 const ProgramManager::ProgramInfo::UniformInfo* info =
4647 current_program_->GetUniformInfoByFakeLocation( 4655 current_program_->GetUniformInfoByFakeLocation(
4648 fake_location, real_location, &array_index); 4656 fake_location, real_location, &array_index);
4649 if (!info) { 4657 if (!info) {
4650 SetGLError(GL_INVALID_OPERATION, 4658 SetGLError(GL_INVALID_OPERATION, function_name, "unknown location");
4651 (std::string(function_name) + ": unknown location").c_str());
4652 return false; 4659 return false;
4653 } 4660 }
4654 if (*count > 1 && !info->is_array) { 4661 if (*count > 1 && !info->is_array) {
4655 SetGLError( 4662 SetGLError(
4656 GL_INVALID_OPERATION, 4663 GL_INVALID_OPERATION, function_name, "count > 1 for non-array");
4657 (std::string(function_name) + ": count > 1 for non-array").c_str());
4658 return false; 4664 return false;
4659 } 4665 }
4660 *count = std::min(info->size - array_index, *count); 4666 *count = std::min(info->size - array_index, *count);
4661 if (*count <= 0) { 4667 if (*count <= 0) {
4662 return false; 4668 return false;
4663 } 4669 }
4664 *type = info->type; 4670 *type = info->type;
4665 return true; 4671 return true;
4666 } 4672 }
4667 4673
4668 void GLES2DecoderImpl::DoUniform1i(GLint fake_location, GLint v0) { 4674 void GLES2DecoderImpl::DoUniform1i(GLint fake_location, GLint v0) {
4669 GLenum type = 0; 4675 GLenum type = 0;
4670 GLsizei count = 1; 4676 GLsizei count = 1;
4671 GLint real_location = -1; 4677 GLint real_location = -1;
4672 if (!PrepForSetUniformByLocation( 4678 if (!PrepForSetUniformByLocation(
4673 fake_location, "glUniform1iv", &real_location, &type, &count)) { 4679 fake_location, "glUniform1iv", &real_location, &type, &count)) {
4674 return; 4680 return;
4675 } 4681 }
4676 if (!current_program_->SetSamplers( 4682 if (!current_program_->SetSamplers(
4677 group_->max_texture_units(), fake_location, 1, &v0)) { 4683 group_->max_texture_units(), fake_location, 1, &v0)) {
4678 SetGLError(GL_INVALID_VALUE, "glUniform1i: texture unit out of range"); 4684 SetGLError(GL_INVALID_VALUE, "glUniform1i", "texture unit out of range");
4679 return; 4685 return;
4680 } 4686 }
4681 glUniform1i(real_location, v0); 4687 glUniform1i(real_location, v0);
4682 } 4688 }
4683 4689
4684 void GLES2DecoderImpl::DoUniform1iv( 4690 void GLES2DecoderImpl::DoUniform1iv(
4685 GLint fake_location, GLsizei count, const GLint *value) { 4691 GLint fake_location, GLsizei count, const GLint *value) {
4686 GLenum type = 0; 4692 GLenum type = 0;
4687 GLint real_location = -1; 4693 GLint real_location = -1;
4688 if (!PrepForSetUniformByLocation( 4694 if (!PrepForSetUniformByLocation(
4689 fake_location, "glUniform1iv", &real_location, &type, &count)) { 4695 fake_location, "glUniform1iv", &real_location, &type, &count)) {
4690 return; 4696 return;
4691 } 4697 }
4692 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || 4698 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ||
4693 type == GL_SAMPLER_EXTERNAL_OES) { 4699 type == GL_SAMPLER_EXTERNAL_OES) {
4694 if (!current_program_->SetSamplers( 4700 if (!current_program_->SetSamplers(
4695 group_->max_texture_units(), fake_location, count, value)) { 4701 group_->max_texture_units(), fake_location, count, value)) {
4696 SetGLError(GL_INVALID_VALUE, "glUniform1iv: texture unit out of range"); 4702 SetGLError(GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range");
4697 return; 4703 return;
4698 } 4704 }
4699 } 4705 }
4700 glUniform1iv(real_location, count, value); 4706 glUniform1iv(real_location, count, value);
4701 } 4707 }
4702 4708
4703 void GLES2DecoderImpl::DoUniform1fv( 4709 void GLES2DecoderImpl::DoUniform1fv(
4704 GLint fake_location, GLsizei count, const GLfloat* value) { 4710 GLint fake_location, GLsizei count, const GLfloat* value) {
4705 GLenum type = 0; 4711 GLenum type = 0;
4706 GLint real_location = -1; 4712 GLint real_location = -1;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4851 void GLES2DecoderImpl::DoUseProgram(GLuint program) { 4857 void GLES2DecoderImpl::DoUseProgram(GLuint program) {
4852 GLuint service_id = 0; 4858 GLuint service_id = 0;
4853 ProgramManager::ProgramInfo* info = NULL; 4859 ProgramManager::ProgramInfo* info = NULL;
4854 if (program) { 4860 if (program) {
4855 info = GetProgramInfoNotShader(program, "glUseProgram"); 4861 info = GetProgramInfoNotShader(program, "glUseProgram");
4856 if (!info) { 4862 if (!info) {
4857 return; 4863 return;
4858 } 4864 }
4859 if (!info->IsValid()) { 4865 if (!info->IsValid()) {
4860 // Program was not linked successfully. (ie, glLinkProgram) 4866 // Program was not linked successfully. (ie, glLinkProgram)
4861 SetGLError(GL_INVALID_OPERATION, "glUseProgram: program not linked"); 4867 SetGLError(GL_INVALID_OPERATION, "glUseProgram", "program not linked");
4862 return; 4868 return;
4863 } 4869 }
4864 service_id = info->service_id(); 4870 service_id = info->service_id();
4865 } 4871 }
4866 if (current_program_) { 4872 if (current_program_) {
4867 program_manager()->UnuseProgram(shader_manager(), current_program_); 4873 program_manager()->UnuseProgram(shader_manager(), current_program_);
4868 } 4874 }
4869 current_program_ = info; 4875 current_program_ = info;
4870 glUseProgram(service_id); 4876 glUseProgram(service_id);
4871 if (current_program_) { 4877 if (current_program_) {
(...skipping 16 matching lines...) Expand all
4888 if (error != GL_NO_ERROR) { 4894 if (error != GL_NO_ERROR) {
4889 // There was an error, clear the corresponding wrapped error. 4895 // There was an error, clear the corresponding wrapped error.
4890 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error); 4896 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error);
4891 } 4897 }
4892 return error; 4898 return error;
4893 } 4899 }
4894 4900
4895 GLenum GLES2DecoderImpl::PeekGLError() { 4901 GLenum GLES2DecoderImpl::PeekGLError() {
4896 GLenum error = glGetError(); 4902 GLenum error = glGetError();
4897 if (error != GL_NO_ERROR) { 4903 if (error != GL_NO_ERROR) {
4898 SetGLError(error, ""); 4904 SetGLError(error, "", "");
4899 } 4905 }
4900 return error; 4906 return error;
4901 } 4907 }
4902 4908
4903 void GLES2DecoderImpl::SetGLError(GLenum error, const char* msg) { 4909 void GLES2DecoderImpl::SetGLError(
4910 GLenum error, const char* function_name, const char* msg) {
4904 if (msg) { 4911 if (msg) {
4905 last_error_ = msg; 4912 last_error_ = msg;
4906 LogMessage(std::string("GL ERROR :") + 4913 LogMessage(std::string("GL ERROR :") +
4907 GLES2Util::GetStringEnum(error) + " : " + msg); 4914 GLES2Util::GetStringEnum(error) + " : " +
4915 function_name + ": " + msg);
4908 } 4916 }
4909 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); 4917 error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
4910 } 4918 }
4911 4919
4912 void GLES2DecoderImpl::LogMessage(const std::string& msg) { 4920 void GLES2DecoderImpl::LogMessage(const std::string& msg) {
4913 if (log_message_count_ < kMaxLogMessages || 4921 if (log_message_count_ < kMaxLogMessages ||
4914 CommandLine::ForCurrentProcess()->HasSwitch( 4922 CommandLine::ForCurrentProcess()->HasSwitch(
4915 switches::kDisableGLErrorLimit)) { 4923 switches::kDisableGLErrorLimit)) {
4916 ++log_message_count_; 4924 ++log_message_count_;
4917 // LOG this unless logging is turned off as any chromium code that 4925 // LOG this unless logging is turned off as any chromium code that
(...skipping 18 matching lines...) Expand all
4936 LogMessage(std::string("RENDER WARNING: ") + msg); 4944 LogMessage(std::string("RENDER WARNING: ") + msg);
4937 } 4945 }
4938 4946
4939 void GLES2DecoderImpl::PerformanceWarning(const std::string& msg) { 4947 void GLES2DecoderImpl::PerformanceWarning(const std::string& msg) {
4940 LogMessage(std::string("PERFORMANCE WARNING: ") + msg); 4948 LogMessage(std::string("PERFORMANCE WARNING: ") + msg);
4941 } 4949 }
4942 4950
4943 void GLES2DecoderImpl::CopyRealGLErrorsToWrapper() { 4951 void GLES2DecoderImpl::CopyRealGLErrorsToWrapper() {
4944 GLenum error; 4952 GLenum error;
4945 while ((error = glGetError()) != GL_NO_ERROR) { 4953 while ((error = glGetError()) != GL_NO_ERROR) {
4946 SetGLError(error, NULL); 4954 SetGLError(error, "", NULL);
4947 } 4955 }
4948 } 4956 }
4949 4957
4950 void GLES2DecoderImpl::ClearRealGLErrors() { 4958 void GLES2DecoderImpl::ClearRealGLErrors() {
4951 GLenum error; 4959 GLenum error;
4952 while ((error = glGetError()) != GL_NO_ERROR) { 4960 while ((error = glGetError()) != GL_NO_ERROR) {
4953 if (error != GL_OUT_OF_MEMORY) { 4961 if (error != GL_OUT_OF_MEMORY) {
4954 // GL_OUT_OF_MEMORY can legally happen on lost device. 4962 // GL_OUT_OF_MEMORY can legally happen on lost device.
4955 NOTREACHED() << "GL error " << error << " was unhandled."; 4963 NOTREACHED() << "GL error " << error << " was unhandled.";
4956 } 4964 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
5054 } 5062 }
5055 } 5063 }
5056 } 5064 }
5057 } 5065 }
5058 } 5066 }
5059 } 5067 }
5060 return true; 5068 return true;
5061 } 5069 }
5062 5070
5063 bool GLES2DecoderImpl::IsDrawValid( 5071 bool GLES2DecoderImpl::IsDrawValid(
5064 GLuint max_vertex_accessed, GLsizei primcount) { 5072 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount) {
5065 // NOTE: We specifically do not check current_program->IsValid() because 5073 // NOTE: We specifically do not check current_program->IsValid() because
5066 // it could never be invalid since glUseProgram would have failed. While 5074 // it could never be invalid since glUseProgram would have failed. While
5067 // glLinkProgram could later mark the program as invalid the previous 5075 // glLinkProgram could later mark the program as invalid the previous
5068 // valid program will still function if it is still the current program. 5076 // valid program will still function if it is still the current program.
5069 if (!current_program_) { 5077 if (!current_program_) {
5070 // The program does not exist. 5078 // The program does not exist.
5071 // But GL says no ERROR. 5079 // But GL says no ERROR.
5072 RenderWarning("Drawing with no current shader program."); 5080 RenderWarning("Drawing with no current shader program.");
5073 return false; 5081 return false;
5074 } 5082 }
(...skipping 10 matching lines...) Expand all
5085 infos.begin(); it != infos.end(); ++it) { 5093 infos.begin(); it != infos.end(); ++it) {
5086 const VertexAttribManager::VertexAttribInfo* info = *it; 5094 const VertexAttribManager::VertexAttribInfo* info = *it;
5087 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 5095 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info =
5088 current_program_->GetAttribInfoByLocation(info->index()); 5096 current_program_->GetAttribInfoByLocation(info->index());
5089 if (attrib_info) { 5097 if (attrib_info) {
5090 divisor0 |= (info->divisor() == 0); 5098 divisor0 |= (info->divisor() == 0);
5091 GLuint count = info->MaxVertexAccessed(primcount, max_vertex_accessed); 5099 GLuint count = info->MaxVertexAccessed(primcount, max_vertex_accessed);
5092 // This attrib is used in the current program. 5100 // This attrib is used in the current program.
5093 if (!info->CanAccess(count)) { 5101 if (!info->CanAccess(count)) {
5094 SetGLError( 5102 SetGLError(
5095 GL_INVALID_OPERATION, 5103 GL_INVALID_OPERATION, function_name,
5096 (std::string( 5104 (std::string(
5097 "glDrawXXX: attempt to access out of range vertices in " 5105 "attempt to access out of range vertices in attribute ") +
5098 "attribute ") + base::IntToString(info->index())).c_str()); 5106 base::IntToString(info->index())).c_str());
5099 return false; 5107 return false;
5100 } 5108 }
5101 } else { 5109 } else {
5102 // This attrib is not used in the current program. 5110 // This attrib is not used in the current program.
5103 if (!info->buffer()) { 5111 if (!info->buffer()) {
5104 SetGLError( 5112 SetGLError(
5105 GL_INVALID_OPERATION, 5113 GL_INVALID_OPERATION, function_name,
5106 (std::string( 5114 (std::string(
5107 "glDrawXXX: attempt to render with no buffer attached to " 5115 "attempt to render with no buffer attached to "
5108 "enabled attribute ") + 5116 "enabled attribute ") +
5109 base::IntToString(info->index())).c_str()); 5117 base::IntToString(info->index())).c_str());
5110 return false; 5118 return false;
5111 } 5119 }
5112 } 5120 }
5113 } 5121 }
5114 5122
5115 if (primcount && !divisor0) { 5123 if (primcount && !divisor0) {
5116 SetGLError( 5124 SetGLError(
5117 GL_INVALID_OPERATION, 5125 GL_INVALID_OPERATION, function_name,
5118 "glDrawXXX: attempt instanced render with all attributes having " 5126 "attempt instanced render with all attributes having "
5119 "non-zero divisors"); 5127 "non-zero divisors");
5120 return false; 5128 return false;
5121 } 5129 }
5122 5130
5123 return true; 5131 return true;
5124 } 5132 }
5125 5133
5126 bool GLES2DecoderImpl::SimulateAttrib0( 5134 bool GLES2DecoderImpl::SimulateAttrib0(
5127 GLuint max_vertex_accessed, bool* simulated) { 5135 const char* function_name, GLuint max_vertex_accessed, bool* simulated) {
5128 DCHECK(simulated); 5136 DCHECK(simulated);
5129 *simulated = false; 5137 *simulated = false;
5130 5138
5131 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) 5139 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
5132 return true; 5140 return true;
5133 5141
5134 const VertexAttribManager::VertexAttribInfo* info = 5142 const VertexAttribManager::VertexAttribInfo* info =
5135 vertex_attrib_manager_->GetVertexAttribInfo(0); 5143 vertex_attrib_manager_->GetVertexAttribInfo(0);
5136 // If it's enabled or it's not used then we don't need to do anything. 5144 // If it's enabled or it's not used then we don't need to do anything.
5137 bool attrib_0_used = current_program_->GetAttribInfoByLocation(0) != NULL; 5145 bool attrib_0_used = current_program_->GetAttribInfoByLocation(0) != NULL;
5138 if (info->enabled() && attrib_0_used) { 5146 if (info->enabled() && attrib_0_used) {
5139 return true; 5147 return true;
5140 } 5148 }
5141 5149
5142 // Make a buffer with a single repeated vec4 value enough to 5150 // Make a buffer with a single repeated vec4 value enough to
5143 // simulate the constant value that is supposed to be here. 5151 // simulate the constant value that is supposed to be here.
5144 // This is required to emulate GLES2 on GL. 5152 // This is required to emulate GLES2 on GL.
5145 typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4; 5153 typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4;
5146 5154
5147 GLuint num_vertices = max_vertex_accessed + 1; 5155 GLuint num_vertices = max_vertex_accessed + 1;
5148 GLuint size_needed = 0; 5156 GLuint size_needed = 0;
5149 5157
5150 if (num_vertices == 0 || 5158 if (num_vertices == 0 ||
5151 !SafeMultiply(num_vertices, static_cast<GLuint>(sizeof(Vec4)), 5159 !SafeMultiply(num_vertices, static_cast<GLuint>(sizeof(Vec4)),
5152 &size_needed) || 5160 &size_needed) ||
5153 size_needed > 0x7FFFFFFFU) { 5161 size_needed > 0x7FFFFFFFU) {
5154 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0"); 5162 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0");
5155 return false; 5163 return false;
5156 } 5164 }
5157 5165
5158 PerformanceWarning( 5166 PerformanceWarning(
5159 "Attribute 0 is disabled. This has signficant performance penalty"); 5167 "Attribute 0 is disabled. This has signficant performance penalty");
5160 5168
5161 CopyRealGLErrorsToWrapper(); 5169 CopyRealGLErrorsToWrapper();
5162 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); 5170 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_);
5163 5171
5164 bool new_buffer = static_cast<GLsizei>(size_needed) > attrib_0_size_; 5172 bool new_buffer = static_cast<GLsizei>(size_needed) > attrib_0_size_;
5165 if (new_buffer) { 5173 if (new_buffer) {
5166 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW); 5174 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW);
5167 GLenum error = glGetError(); 5175 GLenum error = glGetError();
5168 if (error != GL_NO_ERROR) { 5176 if (error != GL_NO_ERROR) {
5169 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0"); 5177 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0");
5170 return false; 5178 return false;
5171 } 5179 }
5172 } 5180 }
5173 if (new_buffer || 5181 if (new_buffer ||
5174 (attrib_0_used && 5182 (attrib_0_used &&
5175 (!attrib_0_buffer_matches_value_ || 5183 (!attrib_0_buffer_matches_value_ ||
5176 (info->value().v[0] != attrib_0_value_.v[0] || 5184 (info->value().v[0] != attrib_0_value_.v[0] ||
5177 info->value().v[1] != attrib_0_value_.v[1] || 5185 info->value().v[1] != attrib_0_value_.v[1] ||
5178 info->value().v[2] != attrib_0_value_.v[2] || 5186 info->value().v[2] != attrib_0_value_.v[2] ||
5179 info->value().v[3] != attrib_0_value_.v[3])))) { 5187 info->value().v[3] != attrib_0_value_.v[3])))) {
(...skipping 28 matching lines...) Expand all
5208 bound_array_buffer_ ? bound_array_buffer_->service_id() : 0); 5216 bound_array_buffer_ ? bound_array_buffer_->service_id() : 0);
5209 5217
5210 if (info->enabled()) { 5218 if (info->enabled()) {
5211 glEnableVertexAttribArray(attrib); 5219 glEnableVertexAttribArray(attrib);
5212 } else { 5220 } else {
5213 glDisableVertexAttribArray(attrib); 5221 glDisableVertexAttribArray(attrib);
5214 } 5222 }
5215 } 5223 }
5216 5224
5217 bool GLES2DecoderImpl::SimulateFixedAttribs( 5225 bool GLES2DecoderImpl::SimulateFixedAttribs(
5226 const char* function_name,
5218 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount) { 5227 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount) {
5219 DCHECK(simulated); 5228 DCHECK(simulated);
5220 *simulated = false; 5229 *simulated = false;
5221 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) 5230 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
5222 return true; 5231 return true;
5223 5232
5224 if (!vertex_attrib_manager_->HaveFixedAttribs()) { 5233 if (!vertex_attrib_manager_->HaveFixedAttribs()) {
5225 return true; 5234 return true;
5226 } 5235 }
5227 5236
(...skipping 11 matching lines...) Expand all
5239 vertex_attrib_manager_->GetEnabledVertexAttribInfos(); 5248 vertex_attrib_manager_->GetEnabledVertexAttribInfos();
5240 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = 5249 for (VertexAttribManager::VertexAttribInfoList::const_iterator it =
5241 infos.begin(); it != infos.end(); ++it) { 5250 infos.begin(); it != infos.end(); ++it) {
5242 const VertexAttribManager::VertexAttribInfo* info = *it; 5251 const VertexAttribManager::VertexAttribInfo* info = *it;
5243 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 5252 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info =
5244 current_program_->GetAttribInfoByLocation(info->index()); 5253 current_program_->GetAttribInfoByLocation(info->index());
5245 GLuint max_accessed = info->MaxVertexAccessed(primcount, 5254 GLuint max_accessed = info->MaxVertexAccessed(primcount,
5246 max_vertex_accessed); 5255 max_vertex_accessed);
5247 GLuint num_vertices = max_accessed + 1; 5256 GLuint num_vertices = max_accessed + 1;
5248 if (num_vertices == 0) { 5257 if (num_vertices == 0) {
5249 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0"); 5258 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0");
5250 return false; 5259 return false;
5251 } 5260 }
5252 if (attrib_info && 5261 if (attrib_info &&
5253 info->CanAccess(max_accessed) && 5262 info->CanAccess(max_accessed) &&
5254 info->type() == GL_FIXED) { 5263 info->type() == GL_FIXED) {
5255 GLuint elements_used = 0; 5264 GLuint elements_used = 0;
5256 if (!SafeMultiply(num_vertices, 5265 if (!SafeMultiply(num_vertices,
5257 static_cast<GLuint>(info->size()), &elements_used) || 5266 static_cast<GLuint>(info->size()), &elements_used) ||
5258 !SafeAdd(elements_needed, elements_used, &elements_needed)) { 5267 !SafeAdd(elements_needed, elements_used, &elements_needed)) {
5259 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: simulating GL_FIXED attribs"); 5268 SetGLError(
5269 GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs");
5260 return false; 5270 return false;
5261 } 5271 }
5262 } 5272 }
5263 } 5273 }
5264 5274
5265 const GLuint kSizeOfFloat = sizeof(float); // NOLINT 5275 const GLuint kSizeOfFloat = sizeof(float); // NOLINT
5266 GLuint size_needed = 0; 5276 GLuint size_needed = 0;
5267 if (!SafeMultiply(elements_needed, kSizeOfFloat, &size_needed) || 5277 if (!SafeMultiply(elements_needed, kSizeOfFloat, &size_needed) ||
5268 size_needed > 0x7FFFFFFFU) { 5278 size_needed > 0x7FFFFFFFU) {
5269 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: simulating GL_FIXED attribs"); 5279 SetGLError(GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs");
5270 return false; 5280 return false;
5271 } 5281 }
5272 5282
5273 CopyRealGLErrorsToWrapper(); 5283 CopyRealGLErrorsToWrapper();
5274 5284
5275 glBindBuffer(GL_ARRAY_BUFFER, fixed_attrib_buffer_id_); 5285 glBindBuffer(GL_ARRAY_BUFFER, fixed_attrib_buffer_id_);
5276 if (static_cast<GLsizei>(size_needed) > fixed_attrib_buffer_size_) { 5286 if (static_cast<GLsizei>(size_needed) > fixed_attrib_buffer_size_) {
5277 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW); 5287 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW);
5278 GLenum error = glGetError(); 5288 GLenum error = glGetError();
5279 if (error != GL_NO_ERROR) { 5289 if (error != GL_NO_ERROR) {
5280 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: simulating GL_FIXED attribs"); 5290 SetGLError(
5291 GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs");
5281 return false; 5292 return false;
5282 } 5293 }
5283 } 5294 }
5284 5295
5285 // Copy the elements and convert to float 5296 // Copy the elements and convert to float
5286 GLintptr offset = 0; 5297 GLintptr offset = 0;
5287 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = 5298 for (VertexAttribManager::VertexAttribInfoList::const_iterator it =
5288 infos.begin(); it != infos.end(); ++it) { 5299 infos.begin(); it != infos.end(); ++it) {
5289 const VertexAttribManager::VertexAttribInfo* info = *it; 5300 const VertexAttribManager::VertexAttribInfo* info = *it;
5290 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 5301 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info =
5291 current_program_->GetAttribInfoByLocation(info->index()); 5302 current_program_->GetAttribInfoByLocation(info->index());
5292 GLuint max_accessed = info->MaxVertexAccessed(primcount, 5303 GLuint max_accessed = info->MaxVertexAccessed(primcount,
5293 max_vertex_accessed); 5304 max_vertex_accessed);
5294 GLuint num_vertices = max_accessed + 1; 5305 GLuint num_vertices = max_accessed + 1;
5295 if (num_vertices == 0) { 5306 if (num_vertices == 0) {
5296 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0"); 5307 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0");
5297 return false; 5308 return false;
5298 } 5309 }
5299 if (attrib_info && 5310 if (attrib_info &&
5300 info->CanAccess(max_accessed) && 5311 info->CanAccess(max_accessed) &&
5301 info->type() == GL_FIXED) { 5312 info->type() == GL_FIXED) {
5302 int num_elements = info->size() * kSizeOfFloat; 5313 int num_elements = info->size() * kSizeOfFloat;
5303 int size = num_elements * num_vertices; 5314 int size = num_elements * num_vertices;
5304 scoped_array<float> data(new float[size]); 5315 scoped_array<float> data(new float[size]);
5305 const int32* src = reinterpret_cast<const int32 *>( 5316 const int32* src = reinterpret_cast<const int32 *>(
5306 info->buffer()->GetRange(info->offset(), size)); 5317 info->buffer()->GetRange(info->offset(), size));
(...skipping 13 matching lines...) Expand all
5320 return true; 5331 return true;
5321 } 5332 }
5322 5333
5323 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() { 5334 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() {
5324 // There's no need to call glVertexAttribPointer because we shadow all the 5335 // There's no need to call glVertexAttribPointer because we shadow all the
5325 // settings and passing GL_FIXED to it will not work. 5336 // settings and passing GL_FIXED to it will not work.
5326 glBindBuffer(GL_ARRAY_BUFFER, 5337 glBindBuffer(GL_ARRAY_BUFFER,
5327 bound_array_buffer_ ? bound_array_buffer_->service_id() : 0); 5338 bound_array_buffer_ ? bound_array_buffer_->service_id() : 0);
5328 } 5339 }
5329 5340
5330 error::Error GLES2DecoderImpl::DoDrawArrays(bool instanced, 5341 error::Error GLES2DecoderImpl::DoDrawArrays(
5331 GLenum mode, 5342 const char* function_name,
5332 GLint first, 5343 bool instanced,
5333 GLsizei count, 5344 GLenum mode,
5334 GLsizei primcount) { 5345 GLint first,
5346 GLsizei count,
5347 GLsizei primcount) {
5335 if (!validators_->draw_mode.IsValid(mode)) { 5348 if (!validators_->draw_mode.IsValid(mode)) {
5336 SetGLError(GL_INVALID_ENUM, "glDrawArrays: mode GL_INVALID_ENUM"); 5349 SetGLError(GL_INVALID_ENUM, function_name, "mode GL_INVALID_ENUM");
5337 return error::kNoError; 5350 return error::kNoError;
5338 } 5351 }
5339 if (count < 0) { 5352 if (count < 0) {
5340 SetGLError(GL_INVALID_VALUE, "glDrawArrays: count < 0"); 5353 SetGLError(GL_INVALID_VALUE, function_name, "count < 0");
5341 return error::kNoError; 5354 return error::kNoError;
5342 } 5355 }
5343 if (primcount < 0) { 5356 if (primcount < 0) {
5344 SetGLError(GL_INVALID_VALUE, "glDrawArrays: primcount < 0"); 5357 SetGLError(GL_INVALID_VALUE, function_name, "primcount < 0");
5345 return error::kNoError; 5358 return error::kNoError;
5346 } 5359 }
5347 if (!CheckBoundFramebuffersValid("glDrawArrays")) { 5360 if (!CheckBoundFramebuffersValid(function_name)) {
5348 return error::kNoError; 5361 return error::kNoError;
5349 } 5362 }
5350 // We have to check this here because the prototype for glDrawArrays 5363 // We have to check this here because the prototype for glDrawArrays
5351 // is GLint not GLsizei. 5364 // is GLint not GLsizei.
5352 if (first < 0) { 5365 if (first < 0) {
5353 SetGLError(GL_INVALID_VALUE, "glDrawArrays: first < 0"); 5366 SetGLError(GL_INVALID_VALUE, function_name, "first < 0");
5354 return error::kNoError; 5367 return error::kNoError;
5355 } 5368 }
5356 5369
5357 if (count == 0 || (instanced && primcount == 0)) { 5370 if (count == 0 || (instanced && primcount == 0)) {
5358 RenderWarning("Render count or primcount is 0."); 5371 RenderWarning("Render count or primcount is 0.");
5359 return error::kNoError; 5372 return error::kNoError;
5360 } 5373 }
5361 5374
5362 GLuint max_vertex_accessed = first + count - 1; 5375 GLuint max_vertex_accessed = first + count - 1;
5363 if (IsDrawValid(max_vertex_accessed, primcount)) { 5376 if (IsDrawValid(function_name, max_vertex_accessed, primcount)) {
5364 if (!ClearUnclearedTextures()) { 5377 if (!ClearUnclearedTextures()) {
5365 SetGLError(GL_INVALID_VALUE, "glDrawArrays: out of memory"); 5378 SetGLError(GL_INVALID_VALUE, function_name, "out of memory");
5366 return error::kNoError; 5379 return error::kNoError;
5367 } 5380 }
5368 bool simulated_attrib_0 = false; 5381 bool simulated_attrib_0 = false;
5369 if (!SimulateAttrib0(max_vertex_accessed, &simulated_attrib_0)) { 5382 if (!SimulateAttrib0(
5383 function_name, max_vertex_accessed, &simulated_attrib_0)) {
5370 return error::kNoError; 5384 return error::kNoError;
5371 } 5385 }
5372 bool simulated_fixed_attribs = false; 5386 bool simulated_fixed_attribs = false;
5373 if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs, 5387 if (SimulateFixedAttribs(
5374 primcount)) { 5388 function_name, max_vertex_accessed, &simulated_fixed_attribs,
5389 primcount)) {
5375 bool textures_set = SetBlackTextureForNonRenderableTextures(); 5390 bool textures_set = SetBlackTextureForNonRenderableTextures();
5376 ApplyDirtyState(); 5391 ApplyDirtyState();
5377 if (!instanced) { 5392 if (!instanced) {
5378 glDrawArrays(mode, first, count); 5393 glDrawArrays(mode, first, count);
5379 } else { 5394 } else {
5380 glDrawArraysInstancedANGLE(mode, first, count, primcount); 5395 glDrawArraysInstancedANGLE(mode, first, count, primcount);
5381 } 5396 }
5382 ProcessPendingQueries(); 5397 ProcessPendingQueries();
5383 if (textures_set) { 5398 if (textures_set) {
5384 RestoreStateForNonRenderableTextures(); 5399 RestoreStateForNonRenderableTextures();
5385 } 5400 }
5386 if (simulated_fixed_attribs) { 5401 if (simulated_fixed_attribs) {
5387 RestoreStateForSimulatedFixedAttribs(); 5402 RestoreStateForSimulatedFixedAttribs();
5388 } 5403 }
5389 } 5404 }
5390 if (simulated_attrib_0) { 5405 if (simulated_attrib_0) {
5391 RestoreStateForAttrib(0); 5406 RestoreStateForAttrib(0);
5392 } 5407 }
5393 if (WasContextLost()) { 5408 if (WasContextLost()) {
5394 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawArrays."; 5409 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawArrays.";
5395 return error::kLostContext; 5410 return error::kLostContext;
5396 } 5411 }
5397 } 5412 }
5398 return error::kNoError; 5413 return error::kNoError;
5399 } 5414 }
5400 5415
5401 error::Error GLES2DecoderImpl::HandleDrawArrays( 5416 error::Error GLES2DecoderImpl::HandleDrawArrays(
5402 uint32 immediate_data_size, const gles2::DrawArrays& c) { 5417 uint32 immediate_data_size, const gles2::DrawArrays& c) {
5403 return DoDrawArrays(false, 5418 return DoDrawArrays("glDrawArrays",
5419 false,
5404 static_cast<GLenum>(c.mode), 5420 static_cast<GLenum>(c.mode),
5405 static_cast<GLint>(c.first), 5421 static_cast<GLint>(c.first),
5406 static_cast<GLsizei>(c.count), 5422 static_cast<GLsizei>(c.count),
5407 0); 5423 0);
5408 } 5424 }
5409 5425
5410 error::Error GLES2DecoderImpl::HandleDrawArraysInstancedANGLE( 5426 error::Error GLES2DecoderImpl::HandleDrawArraysInstancedANGLE(
5411 uint32 immediate_data_size, const gles2::DrawArraysInstancedANGLE& c) { 5427 uint32 immediate_data_size, const gles2::DrawArraysInstancedANGLE& c) {
5412 if (!feature_info_->feature_flags().angle_instanced_arrays) { 5428 if (!feature_info_->feature_flags().angle_instanced_arrays) {
5413 SetGLError(GL_INVALID_OPERATION, 5429 SetGLError(GL_INVALID_OPERATION,
5414 "glDrawArraysInstancedANGLE: function not available"); 5430 "glDrawArraysInstancedANGLE", "function not available");
5415 return error::kNoError; 5431 return error::kNoError;
5416 } 5432 }
5417 return DoDrawArrays(true, 5433 return DoDrawArrays("glDrawArraysIntancedANGLE",
5434 true,
5418 static_cast<GLenum>(c.mode), 5435 static_cast<GLenum>(c.mode),
5419 static_cast<GLint>(c.first), 5436 static_cast<GLint>(c.first),
5420 static_cast<GLsizei>(c.count), 5437 static_cast<GLsizei>(c.count),
5421 static_cast<GLsizei>(c.primcount)); 5438 static_cast<GLsizei>(c.primcount));
5422 } 5439 }
5423 5440
5424 error::Error GLES2DecoderImpl::DoDrawElements(bool instanced, 5441 error::Error GLES2DecoderImpl::DoDrawElements(
5425 GLenum mode, 5442 const char* function_name,
5426 GLsizei count, 5443 bool instanced,
5427 GLenum type, 5444 GLenum mode,
5428 int32 offset, 5445 GLsizei count,
5429 GLsizei primcount) { 5446 GLenum type,
5447 int32 offset,
5448 GLsizei primcount) {
5430 if (!bound_element_array_buffer_) { 5449 if (!bound_element_array_buffer_) {
5431 SetGLError(GL_INVALID_OPERATION, 5450 SetGLError(GL_INVALID_OPERATION,
5432 "glDrawElements: No element array buffer bound"); 5451 function_name, "No element array buffer bound");
5433 return error::kNoError; 5452 return error::kNoError;
5434 } 5453 }
5435 5454
5436 if (count < 0) { 5455 if (count < 0) {
5437 SetGLError(GL_INVALID_VALUE, "glDrawElements: count < 0"); 5456 SetGLError(GL_INVALID_VALUE, function_name, "count < 0");
5438 return error::kNoError; 5457 return error::kNoError;
5439 } 5458 }
5440 if (offset < 0) { 5459 if (offset < 0) {
5441 SetGLError(GL_INVALID_VALUE, "glDrawElements: offset < 0"); 5460 SetGLError(GL_INVALID_VALUE, function_name, "offset < 0");
5442 return error::kNoError; 5461 return error::kNoError;
5443 } 5462 }
5444 if (!validators_->draw_mode.IsValid(mode)) { 5463 if (!validators_->draw_mode.IsValid(mode)) {
5445 SetGLError(GL_INVALID_ENUM, "glDrawElements: mode GL_INVALID_ENUM"); 5464 SetGLError(GL_INVALID_ENUM, function_name, "mode GL_INVALID_ENUM");
5446 return error::kNoError; 5465 return error::kNoError;
5447 } 5466 }
5448 if (!validators_->index_type.IsValid(type)) { 5467 if (!validators_->index_type.IsValid(type)) {
5449 SetGLError(GL_INVALID_ENUM, "glDrawElements: type GL_INVALID_ENUM"); 5468 SetGLError(GL_INVALID_ENUM, function_name, "type GL_INVALID_ENUM");
5450 return error::kNoError; 5469 return error::kNoError;
5451 } 5470 }
5452 if (primcount < 0) { 5471 if (primcount < 0) {
5453 SetGLError(GL_INVALID_VALUE, "glDrawElements: primcount < 0"); 5472 SetGLError(GL_INVALID_VALUE, function_name, "primcount < 0");
5454 return error::kNoError; 5473 return error::kNoError;
5455 } 5474 }
5456 5475
5457 if (!CheckBoundFramebuffersValid("glDrawElements")) { 5476 if (!CheckBoundFramebuffersValid(function_name)) {
5458 return error::kNoError; 5477 return error::kNoError;
5459 } 5478 }
5460 5479
5461 if (count == 0 || (instanced && primcount == 0)) { 5480 if (count == 0 || (instanced && primcount == 0)) {
5462 return error::kNoError; 5481 return error::kNoError;
5463 } 5482 }
5464 5483
5465 GLuint max_vertex_accessed; 5484 GLuint max_vertex_accessed;
5466 if (!bound_element_array_buffer_->GetMaxValueForRange( 5485 if (!bound_element_array_buffer_->GetMaxValueForRange(
5467 offset, count, type, &max_vertex_accessed)) { 5486 offset, count, type, &max_vertex_accessed)) {
5468 SetGLError(GL_INVALID_OPERATION, 5487 SetGLError(GL_INVALID_OPERATION,
5469 "glDrawElements: range out of bounds for buffer"); 5488 function_name, "range out of bounds for buffer");
5470 return error::kNoError; 5489 return error::kNoError;
5471 } 5490 }
5472 5491
5473 if (IsDrawValid(max_vertex_accessed, primcount)) { 5492 if (IsDrawValid(function_name, max_vertex_accessed, primcount)) {
5474 if (!ClearUnclearedTextures()) { 5493 if (!ClearUnclearedTextures()) {
5475 SetGLError(GL_INVALID_VALUE, "glDrawElements: out of memory"); 5494 SetGLError(GL_INVALID_VALUE, function_name, "out of memory");
5476 return error::kNoError; 5495 return error::kNoError;
5477 } 5496 }
5478 bool simulated_attrib_0 = false; 5497 bool simulated_attrib_0 = false;
5479 if (!SimulateAttrib0(max_vertex_accessed, &simulated_attrib_0)) { 5498 if (!SimulateAttrib0(
5499 function_name, max_vertex_accessed, &simulated_attrib_0)) {
5480 return error::kNoError; 5500 return error::kNoError;
5481 } 5501 }
5482 bool simulated_fixed_attribs = false; 5502 bool simulated_fixed_attribs = false;
5483 if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs, 5503 if (SimulateFixedAttribs(
5484 primcount)) { 5504 function_name, max_vertex_accessed, &simulated_fixed_attribs,
5505 primcount)) {
5485 bool textures_set = SetBlackTextureForNonRenderableTextures(); 5506 bool textures_set = SetBlackTextureForNonRenderableTextures();
5486 ApplyDirtyState(); 5507 ApplyDirtyState();
5487 const GLvoid* indices = reinterpret_cast<const GLvoid*>(offset); 5508 const GLvoid* indices = reinterpret_cast<const GLvoid*>(offset);
5488 if (!instanced) { 5509 if (!instanced) {
5489 glDrawElements(mode, count, type, indices); 5510 glDrawElements(mode, count, type, indices);
5490 } else { 5511 } else {
5491 glDrawElementsInstancedANGLE(mode, count, type, indices, primcount); 5512 glDrawElementsInstancedANGLE(mode, count, type, indices, primcount);
5492 } 5513 }
5493 ProcessPendingQueries(); 5514 ProcessPendingQueries();
5494 if (textures_set) { 5515 if (textures_set) {
5495 RestoreStateForNonRenderableTextures(); 5516 RestoreStateForNonRenderableTextures();
5496 } 5517 }
5497 if (simulated_fixed_attribs) { 5518 if (simulated_fixed_attribs) {
5498 RestoreStateForSimulatedFixedAttribs(); 5519 RestoreStateForSimulatedFixedAttribs();
5499 } 5520 }
5500 } 5521 }
5501 if (simulated_attrib_0) { 5522 if (simulated_attrib_0) {
5502 RestoreStateForAttrib(0); 5523 RestoreStateForAttrib(0);
5503 } 5524 }
5504 if (WasContextLost()) { 5525 if (WasContextLost()) {
5505 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawElements."; 5526 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawElements.";
5506 return error::kLostContext; 5527 return error::kLostContext;
5507 } 5528 }
5508 } 5529 }
5509 return error::kNoError; 5530 return error::kNoError;
5510 } 5531 }
5511 5532
5512 error::Error GLES2DecoderImpl::HandleDrawElements( 5533 error::Error GLES2DecoderImpl::HandleDrawElements(
5513 uint32 immediate_data_size, const gles2::DrawElements& c) { 5534 uint32 immediate_data_size, const gles2::DrawElements& c) {
5514 return DoDrawElements(false, 5535 return DoDrawElements("glDrawElements",
5536 false,
5515 static_cast<GLenum>(c.mode), 5537 static_cast<GLenum>(c.mode),
5516 static_cast<GLsizei>(c.count), 5538 static_cast<GLsizei>(c.count),
5517 static_cast<GLenum>(c.type), 5539 static_cast<GLenum>(c.type),
5518 static_cast<int32>(c.index_offset), 5540 static_cast<int32>(c.index_offset),
5519 0); 5541 0);
5520 } 5542 }
5521 5543
5522 error::Error GLES2DecoderImpl::HandleDrawElementsInstancedANGLE( 5544 error::Error GLES2DecoderImpl::HandleDrawElementsInstancedANGLE(
5523 uint32 immediate_data_size, const gles2::DrawElementsInstancedANGLE& c) { 5545 uint32 immediate_data_size, const gles2::DrawElementsInstancedANGLE& c) {
5524 if (!feature_info_->feature_flags().angle_instanced_arrays) { 5546 if (!feature_info_->feature_flags().angle_instanced_arrays) {
5525 SetGLError(GL_INVALID_OPERATION, 5547 SetGLError(GL_INVALID_OPERATION,
5526 "glDrawElementsInstancedANGLE: function not available"); 5548 "glDrawElementsInstancedANGLE", "function not available");
5527 return error::kNoError; 5549 return error::kNoError;
5528 } 5550 }
5529 return DoDrawElements(true, 5551 return DoDrawElements("glDrawElementsInstancedANGLE",
5552 true,
5530 static_cast<GLenum>(c.mode), 5553 static_cast<GLenum>(c.mode),
5531 static_cast<GLsizei>(c.count), 5554 static_cast<GLsizei>(c.count),
5532 static_cast<GLenum>(c.type), 5555 static_cast<GLenum>(c.type),
5533 static_cast<int32>(c.index_offset), 5556 static_cast<int32>(c.index_offset),
5534 static_cast<GLsizei>(c.primcount)); 5557 static_cast<GLsizei>(c.primcount));
5535 } 5558 }
5536 5559
5537 GLuint GLES2DecoderImpl::DoGetMaxValueInBufferCHROMIUM( 5560 GLuint GLES2DecoderImpl::DoGetMaxValueInBufferCHROMIUM(
5538 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) { 5561 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) {
5539 GLuint max_vertex_accessed = 0; 5562 GLuint max_vertex_accessed = 0;
5540 BufferManager::BufferInfo* info = GetBufferInfo(buffer_id); 5563 BufferManager::BufferInfo* info = GetBufferInfo(buffer_id);
5541 if (!info) { 5564 if (!info) {
5542 // TODO(gman): Should this be a GL error or a command buffer error? 5565 // TODO(gman): Should this be a GL error or a command buffer error?
5543 SetGLError(GL_INVALID_VALUE, 5566 SetGLError(GL_INVALID_VALUE,
5544 "GetMaxValueInBufferCHROMIUM: unknown buffer"); 5567 "GetMaxValueInBufferCHROMIUM", "unknown buffer");
5545 } else { 5568 } else {
5546 if (!info->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) { 5569 if (!info->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) {
5547 // TODO(gman): Should this be a GL error or a command buffer error? 5570 // TODO(gman): Should this be a GL error or a command buffer error?
5548 SetGLError( 5571 SetGLError(
5549 GL_INVALID_OPERATION, 5572 GL_INVALID_OPERATION,
5550 "GetMaxValueInBufferCHROMIUM: range out of bounds for buffer"); 5573 "GetMaxValueInBufferCHROMIUM", "range out of bounds for buffer");
5551 } 5574 }
5552 } 5575 }
5553 return max_vertex_accessed; 5576 return max_vertex_accessed;
5554 } 5577 }
5555 5578
5556 // Calls glShaderSource for the various versions of the ShaderSource command. 5579 // Calls glShaderSource for the various versions of the ShaderSource command.
5557 // Assumes that data / data_size points to a piece of memory that is in range 5580 // Assumes that data / data_size points to a piece of memory that is in range
5558 // of whatever context it came from (shared memory, immediate memory, bucket 5581 // of whatever context it came from (shared memory, immediate memory, bucket
5559 // memory.) 5582 // memory.)
5560 error::Error GLES2DecoderImpl::ShaderSourceHelper( 5583 error::Error GLES2DecoderImpl::ShaderSourceHelper(
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
5799 if (!program_info) { 5822 if (!program_info) {
5800 return; 5823 return;
5801 } 5824 }
5802 ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram( 5825 ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram(
5803 shader_client_id, "glAttachShader"); 5826 shader_client_id, "glAttachShader");
5804 if (!shader_info) { 5827 if (!shader_info) {
5805 return; 5828 return;
5806 } 5829 }
5807 if (!program_info->AttachShader(shader_manager(), shader_info)) { 5830 if (!program_info->AttachShader(shader_manager(), shader_info)) {
5808 SetGLError(GL_INVALID_OPERATION, 5831 SetGLError(GL_INVALID_OPERATION,
5809 "glAttachShader: can not attach more than" 5832 "glAttachShader", "can not attach more than"
5810 " one shader of the same type."); 5833 " one shader of the same type.");
5811 return; 5834 return;
5812 } 5835 }
5813 glAttachShader(program_info->service_id(), shader_info->service_id()); 5836 glAttachShader(program_info->service_id(), shader_info->service_id());
5814 } 5837 }
5815 5838
5816 void GLES2DecoderImpl::DoDetachShader( 5839 void GLES2DecoderImpl::DoDetachShader(
5817 GLuint program_client_id, GLint shader_client_id) { 5840 GLuint program_client_id, GLint shader_client_id) {
5818 ProgramManager::ProgramInfo* program_info = GetProgramInfoNotShader( 5841 ProgramManager::ProgramInfo* program_info = GetProgramInfoNotShader(
5819 program_client_id, "glDetachShader"); 5842 program_client_id, "glDetachShader");
5820 if (!program_info) { 5843 if (!program_info) {
5821 return; 5844 return;
5822 } 5845 }
5823 ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram( 5846 ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram(
5824 shader_client_id, "glDetachShader"); 5847 shader_client_id, "glDetachShader");
5825 if (!shader_info) { 5848 if (!shader_info) {
5826 return; 5849 return;
5827 } 5850 }
5828 if (!program_info->DetachShader(shader_manager(), shader_info)) { 5851 if (!program_info->DetachShader(shader_manager(), shader_info)) {
5829 SetGLError(GL_INVALID_OPERATION, 5852 SetGLError(GL_INVALID_OPERATION,
5830 "glDetachShader: shader not attached to program"); 5853 "glDetachShader", "shader not attached to program");
5831 return; 5854 return;
5832 } 5855 }
5833 glDetachShader(program_info->service_id(), shader_info->service_id()); 5856 glDetachShader(program_info->service_id(), shader_info->service_id());
5834 } 5857 }
5835 5858
5836 void GLES2DecoderImpl::DoValidateProgram(GLuint program_client_id) { 5859 void GLES2DecoderImpl::DoValidateProgram(GLuint program_client_id) {
5837 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 5860 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
5838 program_client_id, "glValidateProgram"); 5861 program_client_id, "glValidateProgram");
5839 if (!info) { 5862 if (!info) {
5840 return; 5863 return;
5841 } 5864 }
5842 info->Validate(); 5865 info->Validate();
5843 } 5866 }
5844 5867
5845 void GLES2DecoderImpl::DoGetVertexAttribfv( 5868 void GLES2DecoderImpl::DoGetVertexAttribfv(
5846 GLuint index, GLenum pname, GLfloat* params) { 5869 GLuint index, GLenum pname, GLfloat* params) {
5847 VertexAttribManager::VertexAttribInfo* info = 5870 VertexAttribManager::VertexAttribInfo* info =
5848 vertex_attrib_manager_->GetVertexAttribInfo(index); 5871 vertex_attrib_manager_->GetVertexAttribInfo(index);
5849 if (!info) { 5872 if (!info) {
5850 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribfv: index out of range"); 5873 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribfv", "index out of range");
5851 return; 5874 return;
5852 } 5875 }
5853 switch (pname) { 5876 switch (pname) {
5854 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { 5877 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: {
5855 BufferManager::BufferInfo* buffer = info->buffer(); 5878 BufferManager::BufferInfo* buffer = info->buffer();
5856 if (buffer && !buffer->IsDeleted()) { 5879 if (buffer && !buffer->IsDeleted()) {
5857 GLuint client_id; 5880 GLuint client_id;
5858 buffer_manager()->GetClientId(buffer->service_id(), &client_id); 5881 buffer_manager()->GetClientId(buffer->service_id(), &client_id);
5859 *params = static_cast<GLfloat>(client_id); 5882 *params = static_cast<GLfloat>(client_id);
5860 } 5883 }
(...skipping 27 matching lines...) Expand all
5888 NOTREACHED(); 5911 NOTREACHED();
5889 break; 5912 break;
5890 } 5913 }
5891 } 5914 }
5892 5915
5893 void GLES2DecoderImpl::DoGetVertexAttribiv( 5916 void GLES2DecoderImpl::DoGetVertexAttribiv(
5894 GLuint index, GLenum pname, GLint* params) { 5917 GLuint index, GLenum pname, GLint* params) {
5895 VertexAttribManager::VertexAttribInfo* info = 5918 VertexAttribManager::VertexAttribInfo* info =
5896 vertex_attrib_manager_->GetVertexAttribInfo(index); 5919 vertex_attrib_manager_->GetVertexAttribInfo(index);
5897 if (!info) { 5920 if (!info) {
5898 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribiv: index out of range"); 5921 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribiv", "index out of range");
5899 return; 5922 return;
5900 } 5923 }
5901 switch (pname) { 5924 switch (pname) {
5902 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { 5925 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: {
5903 BufferManager::BufferInfo* buffer = info->buffer(); 5926 BufferManager::BufferInfo* buffer = info->buffer();
5904 if (buffer && !buffer->IsDeleted()) { 5927 if (buffer && !buffer->IsDeleted()) {
5905 GLuint client_id; 5928 GLuint client_id;
5906 buffer_manager()->GetClientId(buffer->service_id(), &client_id); 5929 buffer_manager()->GetClientId(buffer->service_id(), &client_id);
5907 *params = client_id; 5930 *params = client_id;
5908 } 5931 }
(...skipping 26 matching lines...) Expand all
5935 default: 5958 default:
5936 NOTREACHED(); 5959 NOTREACHED();
5937 break; 5960 break;
5938 } 5961 }
5939 } 5962 }
5940 5963
5941 void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) { 5964 void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) {
5942 VertexAttribManager::VertexAttribInfo* info = 5965 VertexAttribManager::VertexAttribInfo* info =
5943 vertex_attrib_manager_->GetVertexAttribInfo(index); 5966 vertex_attrib_manager_->GetVertexAttribInfo(index);
5944 if (!info) { 5967 if (!info) {
5945 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1f: index out of range"); 5968 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1f", "index out of range");
5946 return; 5969 return;
5947 } 5970 }
5948 VertexAttribManager::VertexAttribInfo::Vec4 value; 5971 VertexAttribManager::VertexAttribInfo::Vec4 value;
5949 value.v[0] = v0; 5972 value.v[0] = v0;
5950 value.v[1] = 0.0f; 5973 value.v[1] = 0.0f;
5951 value.v[2] = 0.0f; 5974 value.v[2] = 0.0f;
5952 value.v[3] = 1.0f; 5975 value.v[3] = 1.0f;
5953 info->set_value(value); 5976 info->set_value(value);
5954 glVertexAttrib1f(index, v0); 5977 glVertexAttrib1f(index, v0);
5955 } 5978 }
5956 5979
5957 void GLES2DecoderImpl::DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) { 5980 void GLES2DecoderImpl::DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) {
5958 VertexAttribManager::VertexAttribInfo* info = 5981 VertexAttribManager::VertexAttribInfo* info =
5959 vertex_attrib_manager_->GetVertexAttribInfo(index); 5982 vertex_attrib_manager_->GetVertexAttribInfo(index);
5960 if (!info) { 5983 if (!info) {
5961 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2f: index out of range"); 5984 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2f", "index out of range");
5962 return; 5985 return;
5963 } 5986 }
5964 VertexAttribManager::VertexAttribInfo::Vec4 value; 5987 VertexAttribManager::VertexAttribInfo::Vec4 value;
5965 value.v[0] = v0; 5988 value.v[0] = v0;
5966 value.v[1] = v1; 5989 value.v[1] = v1;
5967 value.v[2] = 0.0f; 5990 value.v[2] = 0.0f;
5968 value.v[3] = 1.0f; 5991 value.v[3] = 1.0f;
5969 info->set_value(value); 5992 info->set_value(value);
5970 glVertexAttrib2f(index, v0, v1); 5993 glVertexAttrib2f(index, v0, v1);
5971 } 5994 }
5972 5995
5973 void GLES2DecoderImpl::DoVertexAttrib3f( 5996 void GLES2DecoderImpl::DoVertexAttrib3f(
5974 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) { 5997 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) {
5975 VertexAttribManager::VertexAttribInfo* info = 5998 VertexAttribManager::VertexAttribInfo* info =
5976 vertex_attrib_manager_->GetVertexAttribInfo(index); 5999 vertex_attrib_manager_->GetVertexAttribInfo(index);
5977 if (!info) { 6000 if (!info) {
5978 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3f: index out of range"); 6001 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3f", "index out of range");
5979 return; 6002 return;
5980 } 6003 }
5981 VertexAttribManager::VertexAttribInfo::Vec4 value; 6004 VertexAttribManager::VertexAttribInfo::Vec4 value;
5982 value.v[0] = v0; 6005 value.v[0] = v0;
5983 value.v[1] = v1; 6006 value.v[1] = v1;
5984 value.v[2] = v2; 6007 value.v[2] = v2;
5985 value.v[3] = 1.0f; 6008 value.v[3] = 1.0f;
5986 info->set_value(value); 6009 info->set_value(value);
5987 glVertexAttrib3f(index, v0, v1, v2); 6010 glVertexAttrib3f(index, v0, v1, v2);
5988 } 6011 }
5989 6012
5990 void GLES2DecoderImpl::DoVertexAttrib4f( 6013 void GLES2DecoderImpl::DoVertexAttrib4f(
5991 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { 6014 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
5992 VertexAttribManager::VertexAttribInfo* info = 6015 VertexAttribManager::VertexAttribInfo* info =
5993 vertex_attrib_manager_->GetVertexAttribInfo(index); 6016 vertex_attrib_manager_->GetVertexAttribInfo(index);
5994 if (!info) { 6017 if (!info) {
5995 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4f: index out of range"); 6018 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4f", "index out of range");
5996 return; 6019 return;
5997 } 6020 }
5998 VertexAttribManager::VertexAttribInfo::Vec4 value; 6021 VertexAttribManager::VertexAttribInfo::Vec4 value;
5999 value.v[0] = v0; 6022 value.v[0] = v0;
6000 value.v[1] = v1; 6023 value.v[1] = v1;
6001 value.v[2] = v2; 6024 value.v[2] = v2;
6002 value.v[3] = v3; 6025 value.v[3] = v3;
6003 info->set_value(value); 6026 info->set_value(value);
6004 glVertexAttrib4f(index, v0, v1, v2, v3); 6027 glVertexAttrib4f(index, v0, v1, v2, v3);
6005 } 6028 }
6006 6029
6007 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) { 6030 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) {
6008 VertexAttribManager::VertexAttribInfo* info = 6031 VertexAttribManager::VertexAttribInfo* info =
6009 vertex_attrib_manager_->GetVertexAttribInfo(index); 6032 vertex_attrib_manager_->GetVertexAttribInfo(index);
6010 if (!info) { 6033 if (!info) {
6011 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1fv: index out of range"); 6034 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1fv", "index out of range");
6012 return; 6035 return;
6013 } 6036 }
6014 VertexAttribManager::VertexAttribInfo::Vec4 value; 6037 VertexAttribManager::VertexAttribInfo::Vec4 value;
6015 value.v[0] = v[0]; 6038 value.v[0] = v[0];
6016 value.v[1] = 0.0f; 6039 value.v[1] = 0.0f;
6017 value.v[2] = 0.0f; 6040 value.v[2] = 0.0f;
6018 value.v[3] = 1.0f; 6041 value.v[3] = 1.0f;
6019 info->set_value(value); 6042 info->set_value(value);
6020 glVertexAttrib1fv(index, v); 6043 glVertexAttrib1fv(index, v);
6021 } 6044 }
6022 6045
6023 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) { 6046 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) {
6024 VertexAttribManager::VertexAttribInfo* info = 6047 VertexAttribManager::VertexAttribInfo* info =
6025 vertex_attrib_manager_->GetVertexAttribInfo(index); 6048 vertex_attrib_manager_->GetVertexAttribInfo(index);
6026 if (!info) { 6049 if (!info) {
6027 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2fv: index out of range"); 6050 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2fv", "index out of range");
6028 return; 6051 return;
6029 } 6052 }
6030 VertexAttribManager::VertexAttribInfo::Vec4 value; 6053 VertexAttribManager::VertexAttribInfo::Vec4 value;
6031 value.v[0] = v[0]; 6054 value.v[0] = v[0];
6032 value.v[1] = v[1]; 6055 value.v[1] = v[1];
6033 value.v[2] = 0.0f; 6056 value.v[2] = 0.0f;
6034 value.v[3] = 1.0f; 6057 value.v[3] = 1.0f;
6035 info->set_value(value); 6058 info->set_value(value);
6036 glVertexAttrib2fv(index, v); 6059 glVertexAttrib2fv(index, v);
6037 } 6060 }
6038 6061
6039 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) { 6062 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) {
6040 VertexAttribManager::VertexAttribInfo* info = 6063 VertexAttribManager::VertexAttribInfo* info =
6041 vertex_attrib_manager_->GetVertexAttribInfo(index); 6064 vertex_attrib_manager_->GetVertexAttribInfo(index);
6042 if (!info) { 6065 if (!info) {
6043 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3fv: index out of range"); 6066 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3fv", "index out of range");
6044 return; 6067 return;
6045 } 6068 }
6046 VertexAttribManager::VertexAttribInfo::Vec4 value; 6069 VertexAttribManager::VertexAttribInfo::Vec4 value;
6047 value.v[0] = v[0]; 6070 value.v[0] = v[0];
6048 value.v[1] = v[1]; 6071 value.v[1] = v[1];
6049 value.v[2] = v[2]; 6072 value.v[2] = v[2];
6050 value.v[3] = 1.0f; 6073 value.v[3] = 1.0f;
6051 info->set_value(value); 6074 info->set_value(value);
6052 glVertexAttrib3fv(index, v); 6075 glVertexAttrib3fv(index, v);
6053 } 6076 }
6054 6077
6055 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { 6078 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) {
6056 VertexAttribManager::VertexAttribInfo* info = 6079 VertexAttribManager::VertexAttribInfo* info =
6057 vertex_attrib_manager_->GetVertexAttribInfo(index); 6080 vertex_attrib_manager_->GetVertexAttribInfo(index);
6058 if (!info) { 6081 if (!info) {
6059 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4fv: index out of range"); 6082 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4fv", "index out of range");
6060 return; 6083 return;
6061 } 6084 }
6062 VertexAttribManager::VertexAttribInfo::Vec4 value; 6085 VertexAttribManager::VertexAttribInfo::Vec4 value;
6063 value.v[0] = v[0]; 6086 value.v[0] = v[0];
6064 value.v[1] = v[1]; 6087 value.v[1] = v[1];
6065 value.v[2] = v[2]; 6088 value.v[2] = v[2];
6066 value.v[3] = v[3]; 6089 value.v[3] = v[3];
6067 info->set_value(value); 6090 info->set_value(value);
6068 glVertexAttrib4fv(index, v); 6091 glVertexAttrib4fv(index, v);
6069 } 6092 }
6070 6093
6071 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( 6094 error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
6072 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { 6095 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) {
6073 if (!bound_array_buffer_ || bound_array_buffer_->IsDeleted()) { 6096 if (!bound_array_buffer_ || bound_array_buffer_->IsDeleted()) {
6074 SetGLError(GL_INVALID_VALUE, 6097 SetGLError(GL_INVALID_VALUE,
6075 "glVertexAttribPointer: no array buffer bound"); 6098 "glVertexAttribPointer", "no array buffer bound");
6076 return error::kNoError; 6099 return error::kNoError;
6077 } 6100 }
6078 6101
6079 GLuint indx = c.indx; 6102 GLuint indx = c.indx;
6080 GLint size = c.size; 6103 GLint size = c.size;
6081 GLenum type = c.type; 6104 GLenum type = c.type;
6082 GLboolean normalized = c.normalized; 6105 GLboolean normalized = c.normalized;
6083 GLsizei stride = c.stride; 6106 GLsizei stride = c.stride;
6084 GLsizei offset = c.offset; 6107 GLsizei offset = c.offset;
6085 const void* ptr = reinterpret_cast<const void*>(offset); 6108 const void* ptr = reinterpret_cast<const void*>(offset);
6086 if (!validators_->vertex_attrib_type.IsValid(type)) { 6109 if (!validators_->vertex_attrib_type.IsValid(type)) {
6087 SetGLError(GL_INVALID_ENUM, 6110 SetGLError(GL_INVALID_ENUM,
6088 "glVertexAttribPointer: type GL_INVALID_ENUM"); 6111 "glVertexAttribPointer", "type GL_INVALID_ENUM");
6089 return error::kNoError; 6112 return error::kNoError;
6090 } 6113 }
6091 if (!validators_->vertex_attrib_size.IsValid(size)) { 6114 if (!validators_->vertex_attrib_size.IsValid(size)) {
6092 SetGLError(GL_INVALID_VALUE, 6115 SetGLError(GL_INVALID_VALUE,
6093 "glVertexAttribPointer: size GL_INVALID_VALUE"); 6116 "glVertexAttribPointer", "size GL_INVALID_VALUE");
6094 return error::kNoError; 6117 return error::kNoError;
6095 } 6118 }
6096 if (indx >= group_->max_vertex_attribs()) { 6119 if (indx >= group_->max_vertex_attribs()) {
6097 SetGLError(GL_INVALID_VALUE, "glVertexAttribPointer: index out of range"); 6120 SetGLError(GL_INVALID_VALUE, "glVertexAttribPointer", "index out of range");
6098 return error::kNoError; 6121 return error::kNoError;
6099 } 6122 }
6100 if (stride < 0) { 6123 if (stride < 0) {
6101 SetGLError(GL_INVALID_VALUE, 6124 SetGLError(GL_INVALID_VALUE,
6102 "glVertexAttribPointer: stride < 0"); 6125 "glVertexAttribPointer", "stride < 0");
6103 return error::kNoError; 6126 return error::kNoError;
6104 } 6127 }
6105 if (stride > 255) { 6128 if (stride > 255) {
6106 SetGLError(GL_INVALID_VALUE, 6129 SetGLError(GL_INVALID_VALUE,
6107 "glVertexAttribPointer: stride > 255"); 6130 "glVertexAttribPointer", "stride > 255");
6108 return error::kNoError; 6131 return error::kNoError;
6109 } 6132 }
6110 if (offset < 0) { 6133 if (offset < 0) {
6111 SetGLError(GL_INVALID_VALUE, 6134 SetGLError(GL_INVALID_VALUE,
6112 "glVertexAttribPointer: offset < 0"); 6135 "glVertexAttribPointer", "offset < 0");
6113 return error::kNoError; 6136 return error::kNoError;
6114 } 6137 }
6115 GLsizei component_size = 6138 GLsizei component_size =
6116 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type); 6139 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type);
6117 if (offset % component_size > 0) { 6140 if (offset % component_size > 0) {
6118 SetGLError(GL_INVALID_OPERATION, 6141 SetGLError(GL_INVALID_OPERATION,
6119 "glVertexAttribPointer: offset not valid for type"); 6142 "glVertexAttribPointer", "offset not valid for type");
6120 return error::kNoError; 6143 return error::kNoError;
6121 } 6144 }
6122 if (stride % component_size > 0) { 6145 if (stride % component_size > 0) {
6123 SetGLError(GL_INVALID_OPERATION, 6146 SetGLError(GL_INVALID_OPERATION,
6124 "glVertexAttribPointer: stride not valid for type"); 6147 "glVertexAttribPointer", "stride not valid for type");
6125 return error::kNoError; 6148 return error::kNoError;
6126 } 6149 }
6127 vertex_attrib_manager_->SetAttribInfo( 6150 vertex_attrib_manager_->SetAttribInfo(
6128 indx, 6151 indx,
6129 bound_array_buffer_, 6152 bound_array_buffer_,
6130 size, 6153 size,
6131 type, 6154 type,
6132 normalized, 6155 normalized,
6133 stride, 6156 stride,
6134 stride != 0 ? stride : component_size * size, 6157 stride != 0 ? stride : component_size * size,
(...skipping 10 matching lines...) Expand all
6145 viewport_y_ = y; 6168 viewport_y_ = y;
6146 viewport_width_ = std::min(width, viewport_max_width_); 6169 viewport_width_ = std::min(width, viewport_max_width_);
6147 viewport_height_ = std::min(height, viewport_max_height_); 6170 viewport_height_ = std::min(height, viewport_max_height_);
6148 glViewport(x, y, width, height); 6171 glViewport(x, y, width, height);
6149 } 6172 }
6150 6173
6151 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( 6174 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE(
6152 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { 6175 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) {
6153 if (!feature_info_->feature_flags().angle_instanced_arrays) { 6176 if (!feature_info_->feature_flags().angle_instanced_arrays) {
6154 SetGLError(GL_INVALID_OPERATION, 6177 SetGLError(GL_INVALID_OPERATION,
6155 "glVertexAttribDivisorANGLE: function not available"); 6178 "glVertexAttribDivisorANGLE", "function not available");
6156 } 6179 }
6157 GLuint index = c.index; 6180 GLuint index = c.index;
6158 GLuint divisor = c.divisor; 6181 GLuint divisor = c.divisor;
6159 if (index >= group_->max_vertex_attribs()) { 6182 if (index >= group_->max_vertex_attribs()) {
6160 SetGLError(GL_INVALID_VALUE, 6183 SetGLError(GL_INVALID_VALUE,
6161 "glVertexAttribDivisorANGLE: index out of range"); 6184 "glVertexAttribDivisorANGLE", "index out of range");
6162 return error::kNoError; 6185 return error::kNoError;
6163 } 6186 }
6164 6187
6165 vertex_attrib_manager_->SetDivisor( 6188 vertex_attrib_manager_->SetDivisor(
6166 index, 6189 index,
6167 divisor); 6190 divisor);
6168 glVertexAttribDivisorANGLE(index, divisor); 6191 glVertexAttribDivisorANGLE(index, divisor);
6169 return error::kNoError; 6192 return error::kNoError;
6170 } 6193 }
6171 6194
6172 error::Error GLES2DecoderImpl::HandleReadPixels( 6195 error::Error GLES2DecoderImpl::HandleReadPixels(
6173 uint32 immediate_data_size, const gles2::ReadPixels& c) { 6196 uint32 immediate_data_size, const gles2::ReadPixels& c) {
6174 GLint x = c.x; 6197 GLint x = c.x;
6175 GLint y = c.y; 6198 GLint y = c.y;
6176 GLsizei width = c.width; 6199 GLsizei width = c.width;
6177 GLsizei height = c.height; 6200 GLsizei height = c.height;
6178 GLenum format = c.format; 6201 GLenum format = c.format;
6179 GLenum type = c.type; 6202 GLenum type = c.type;
6180 if (width < 0 || height < 0) { 6203 if (width < 0 || height < 0) {
6181 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0"); 6204 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0");
6182 return error::kNoError; 6205 return error::kNoError;
6183 } 6206 }
6184 typedef gles2::ReadPixels::Result Result; 6207 typedef gles2::ReadPixels::Result Result;
6185 uint32 pixels_size; 6208 uint32 pixels_size;
6186 if (!GLES2Util::ComputeImageDataSizes( 6209 if (!GLES2Util::ComputeImageDataSizes(
6187 width, height, format, type, pack_alignment_, &pixels_size, NULL, NULL)) { 6210 width, height, format, type, pack_alignment_, &pixels_size, NULL, NULL)) {
6188 return error::kOutOfBounds; 6211 return error::kOutOfBounds;
6189 } 6212 }
6190 void* pixels = GetSharedMemoryAs<void*>( 6213 void* pixels = GetSharedMemoryAs<void*>(
6191 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); 6214 c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
6192 Result* result = GetSharedMemoryAs<Result*>( 6215 Result* result = GetSharedMemoryAs<Result*>(
6193 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 6216 c.result_shm_id, c.result_shm_offset, sizeof(*result));
6194 if (!pixels || !result) { 6217 if (!pixels || !result) {
6195 return error::kOutOfBounds; 6218 return error::kOutOfBounds;
6196 } 6219 }
6197 6220
6198 if (!validators_->read_pixel_format.IsValid(format)) { 6221 if (!validators_->read_pixel_format.IsValid(format)) {
6199 SetGLError(GL_INVALID_ENUM, "glReadPixels: format GL_INVALID_ENUM"); 6222 SetGLError(GL_INVALID_ENUM, "glReadPixels", "format GL_INVALID_ENUM");
6200 return error::kNoError; 6223 return error::kNoError;
6201 } 6224 }
6202 if (!validators_->pixel_type.IsValid(type)) { 6225 if (!validators_->pixel_type.IsValid(type)) {
6203 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM"); 6226 SetGLError(GL_INVALID_ENUM, "glReadPixels", "type GL_INVALID_ENUM");
6204 return error::kNoError; 6227 return error::kNoError;
6205 } 6228 }
6206 if (width == 0 || height == 0) { 6229 if (width == 0 || height == 0) {
6207 return error::kNoError; 6230 return error::kNoError;
6208 } 6231 }
6209 6232
6210 // Get the size of the current fbo or backbuffer. 6233 // Get the size of the current fbo or backbuffer.
6211 gfx::Size max_size = GetBoundReadFrameBufferSize(); 6234 gfx::Size max_size = GetBoundReadFrameBufferSize();
6212 6235
6213 GLint max_x; 6236 GLint max_x;
6214 GLint max_y; 6237 GLint max_y;
6215 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) { 6238 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) {
6216 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); 6239 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
6217 return error::kNoError; 6240 return error::kNoError;
6218 } 6241 }
6219 6242
6220 if (!CheckBoundFramebuffersValid("glReadPixels")) { 6243 if (!CheckBoundFramebuffersValid("glReadPixels")) {
6221 return error::kNoError; 6244 return error::kNoError;
6222 } 6245 }
6223 6246
6224 CopyRealGLErrorsToWrapper(); 6247 CopyRealGLErrorsToWrapper();
6225 6248
6226 ScopedResolvedFrameBufferBinder binder(this, false, true); 6249 ScopedResolvedFrameBufferBinder binder(this, false, true);
6227 6250
6228 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { 6251 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) {
6229 // The user requested an out of range area. Get the results 1 line 6252 // The user requested an out of range area. Get the results 1 line
6230 // at a time. 6253 // at a time.
6231 uint32 temp_size; 6254 uint32 temp_size;
6232 uint32 unpadded_row_size; 6255 uint32 unpadded_row_size;
6233 uint32 padded_row_size; 6256 uint32 padded_row_size;
6234 if (!GLES2Util::ComputeImageDataSizes( 6257 if (!GLES2Util::ComputeImageDataSizes(
6235 width, 2, format, type, pack_alignment_, &temp_size, 6258 width, 2, format, type, pack_alignment_, &temp_size,
6236 &unpadded_row_size, &padded_row_size)) { 6259 &unpadded_row_size, &padded_row_size)) {
6237 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); 6260 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
6238 return error::kNoError; 6261 return error::kNoError;
6239 } 6262 }
6240 6263
6241 GLint dest_x_offset = std::max(-x, 0); 6264 GLint dest_x_offset = std::max(-x, 0);
6242 uint32 dest_row_offset; 6265 uint32 dest_row_offset;
6243 if (!GLES2Util::ComputeImageDataSizes( 6266 if (!GLES2Util::ComputeImageDataSizes(
6244 dest_x_offset, 1, format, type, pack_alignment_, &dest_row_offset, NULL, 6267 dest_x_offset, 1, format, type, pack_alignment_, &dest_row_offset, NULL,
6245 NULL)) { 6268 NULL)) {
6246 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); 6269 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
6247 return error::kNoError; 6270 return error::kNoError;
6248 } 6271 }
6249 6272
6250 // Copy each row into the larger dest rect. 6273 // Copy each row into the larger dest rect.
6251 int8* dst = static_cast<int8*>(pixels); 6274 int8* dst = static_cast<int8*>(pixels);
6252 GLint read_x = std::max(0, x); 6275 GLint read_x = std::max(0, x);
6253 GLint read_end_x = std::max(0, std::min(max_size.width(), max_x)); 6276 GLint read_end_x = std::max(0, std::min(max_size.width(), max_x));
6254 GLint read_width = read_end_x - read_x; 6277 GLint read_width = read_end_x - read_x;
6255 for (GLint yy = 0; yy < height; ++yy) { 6278 for (GLint yy = 0; yy < height; ++yy) {
6256 GLint ry = y + yy; 6279 GLint ry = y + yy;
(...skipping 19 matching lines...) Expand all
6276 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 6299 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
6277 if ((channels_exist & 0x0008) == 0 && !disable_workarounds_) { 6300 if ((channels_exist & 0x0008) == 0 && !disable_workarounds_) {
6278 // Set the alpha to 255 because some drivers are buggy in this regard. 6301 // Set the alpha to 255 because some drivers are buggy in this regard.
6279 uint32 temp_size; 6302 uint32 temp_size;
6280 6303
6281 uint32 unpadded_row_size; 6304 uint32 unpadded_row_size;
6282 uint32 padded_row_size; 6305 uint32 padded_row_size;
6283 if (!GLES2Util::ComputeImageDataSizes( 6306 if (!GLES2Util::ComputeImageDataSizes(
6284 width, 2, format, type, pack_alignment_, &temp_size, 6307 width, 2, format, type, pack_alignment_, &temp_size,
6285 &unpadded_row_size, &padded_row_size)) { 6308 &unpadded_row_size, &padded_row_size)) {
6286 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); 6309 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
6287 return error::kNoError; 6310 return error::kNoError;
6288 } 6311 }
6289 // NOTE: Assumes the type is GL_UNSIGNED_BYTE which was true at the time 6312 // NOTE: Assumes the type is GL_UNSIGNED_BYTE which was true at the time
6290 // of this implementation. 6313 // of this implementation.
6291 if (type != GL_UNSIGNED_BYTE) { 6314 if (type != GL_UNSIGNED_BYTE) {
6292 SetGLError(GL_INVALID_OPERATION, "unsupported readPixel format"); 6315 SetGLError(
6316 GL_INVALID_OPERATION, "glReadPixels",
6317 "unsupported readPixel format");
6293 return error::kNoError; 6318 return error::kNoError;
6294 } 6319 }
6295 switch (format) { 6320 switch (format) {
6296 case GL_RGBA: 6321 case GL_RGBA:
6297 case GL_BGRA_EXT: 6322 case GL_BGRA_EXT:
6298 case GL_ALPHA: { 6323 case GL_ALPHA: {
6299 int offset = (format == GL_ALPHA) ? 0 : 3; 6324 int offset = (format == GL_ALPHA) ? 0 : 3;
6300 int step = (format == GL_ALPHA) ? 1 : 4; 6325 int step = (format == GL_ALPHA) ? 1 : 4;
6301 uint8* dst = static_cast<uint8*>(pixels) + offset; 6326 uint8* dst = static_cast<uint8*>(pixels) + offset;
6302 for (GLint yy = 0; yy < height; ++yy) { 6327 for (GLint yy = 0; yy < height; ++yy) {
(...skipping 12 matching lines...) Expand all
6315 } 6340 }
6316 6341
6317 return error::kNoError; 6342 return error::kNoError;
6318 } 6343 }
6319 6344
6320 error::Error GLES2DecoderImpl::HandlePixelStorei( 6345 error::Error GLES2DecoderImpl::HandlePixelStorei(
6321 uint32 immediate_data_size, const gles2::PixelStorei& c) { 6346 uint32 immediate_data_size, const gles2::PixelStorei& c) {
6322 GLenum pname = c.pname; 6347 GLenum pname = c.pname;
6323 GLenum param = c.param; 6348 GLenum param = c.param;
6324 if (!validators_->pixel_store.IsValid(pname)) { 6349 if (!validators_->pixel_store.IsValid(pname)) {
6325 SetGLError(GL_INVALID_ENUM, "glPixelStorei: pname GL_INVALID_ENUM"); 6350 SetGLError(GL_INVALID_ENUM, "glPixelStorei", "pname GL_INVALID_ENUM");
6326 return error::kNoError; 6351 return error::kNoError;
6327 } 6352 }
6328 switch (pname) { 6353 switch (pname) {
6329 case GL_PACK_ALIGNMENT: 6354 case GL_PACK_ALIGNMENT:
6330 case GL_UNPACK_ALIGNMENT: 6355 case GL_UNPACK_ALIGNMENT:
6331 if (!validators_->pixel_store_alignment.IsValid(param)) { 6356 if (!validators_->pixel_store_alignment.IsValid(param)) {
6332 SetGLError(GL_INVALID_VALUE, 6357 SetGLError(GL_INVALID_VALUE,
6333 "glPixelSTore: param GL_INVALID_VALUE"); 6358 "glPixelStore", "param GL_INVALID_VALUE");
6334 return error::kNoError; 6359 return error::kNoError;
6335 } 6360 }
6336 break; 6361 break;
6337 case GL_UNPACK_FLIP_Y_CHROMIUM: 6362 case GL_UNPACK_FLIP_Y_CHROMIUM:
6338 unpack_flip_y_ = (param != 0); 6363 unpack_flip_y_ = (param != 0);
6339 return error::kNoError; 6364 return error::kNoError;
6340 case GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM: 6365 case GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM:
6341 unpack_premultiply_alpha_ = (param != 0); 6366 unpack_premultiply_alpha_ = (param != 0);
6342 return error::kNoError; 6367 return error::kNoError;
6343 default: 6368 default:
(...skipping 15 matching lines...) Expand all
6359 break; 6384 break;
6360 } 6385 }
6361 return error::kNoError; 6386 return error::kNoError;
6362 } 6387 }
6363 6388
6364 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( 6389 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM(
6365 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { 6390 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) {
6366 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); 6391 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM");
6367 if (!context_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { 6392 if (!context_->HasExtension("GL_CHROMIUM_post_sub_buffer")) {
6368 SetGLError(GL_INVALID_OPERATION, 6393 SetGLError(GL_INVALID_OPERATION,
6369 "glPostSubBufferCHROMIUM: command not supported by surface"); 6394 "glPostSubBufferCHROMIUM", "command not supported by surface");
6370 return error::kNoError; 6395 return error::kNoError;
6371 } 6396 }
6372 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { 6397 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) {
6373 return error::kNoError; 6398 return error::kNoError;
6374 } else { 6399 } else {
6375 LOG(ERROR) << "Context lost because PostSubBuffer failed."; 6400 LOG(ERROR) << "Context lost because PostSubBuffer failed.";
6376 return error::kLostContext; 6401 return error::kLostContext;
6377 } 6402 }
6378 } 6403 }
6379 6404
6380 error::Error GLES2DecoderImpl::GetAttribLocationHelper( 6405 error::Error GLES2DecoderImpl::GetAttribLocationHelper(
6381 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 6406 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
6382 const std::string& name_str) { 6407 const std::string& name_str) {
6383 if (!StringIsValidForGLES(name_str.c_str())) { 6408 if (!StringIsValidForGLES(name_str.c_str())) {
6384 SetGLError(GL_INVALID_VALUE, "glGetAttribLocation: Invalid character"); 6409 SetGLError(GL_INVALID_VALUE, "glGetAttribLocation", "Invalid character");
6385 return error::kNoError; 6410 return error::kNoError;
6386 } 6411 }
6387 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 6412 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
6388 client_id, "glGetAttribLocation"); 6413 client_id, "glGetAttribLocation");
6389 if (!info) { 6414 if (!info) {
6390 return error::kNoError; 6415 return error::kNoError;
6391 } 6416 }
6392 if (!info->IsValid()) { 6417 if (!info->IsValid()) {
6393 SetGLError(GL_INVALID_OPERATION, "glGetAttribLocation: program not linked"); 6418 SetGLError(
6419 GL_INVALID_OPERATION, "glGetAttribLocation", "program not linked");
6394 return error::kNoError; 6420 return error::kNoError;
6395 } 6421 }
6396 GLint* location = GetSharedMemoryAs<GLint*>( 6422 GLint* location = GetSharedMemoryAs<GLint*>(
6397 location_shm_id, location_shm_offset, sizeof(GLint)); 6423 location_shm_id, location_shm_offset, sizeof(GLint));
6398 if (!location) { 6424 if (!location) {
6399 return error::kOutOfBounds; 6425 return error::kOutOfBounds;
6400 } 6426 }
6401 // Require the client to init this incase the context is lost and we are no 6427 // Require the client to init this incase the context is lost and we are no
6402 // longer executing commands. 6428 // longer executing commands.
6403 if (*location != -1) { 6429 if (*location != -1) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6444 return error::kInvalidArguments; 6470 return error::kInvalidArguments;
6445 } 6471 }
6446 return GetAttribLocationHelper( 6472 return GetAttribLocationHelper(
6447 c.program, c.location_shm_id, c.location_shm_offset, name_str); 6473 c.program, c.location_shm_id, c.location_shm_offset, name_str);
6448 } 6474 }
6449 6475
6450 error::Error GLES2DecoderImpl::GetUniformLocationHelper( 6476 error::Error GLES2DecoderImpl::GetUniformLocationHelper(
6451 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 6477 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
6452 const std::string& name_str) { 6478 const std::string& name_str) {
6453 if (!StringIsValidForGLES(name_str.c_str())) { 6479 if (!StringIsValidForGLES(name_str.c_str())) {
6454 SetGLError(GL_INVALID_VALUE, "glGetUniformLocation: Invalid character"); 6480 SetGLError(GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character");
6455 return error::kNoError; 6481 return error::kNoError;
6456 } 6482 }
6457 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 6483 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
6458 client_id, "glUniformLocation"); 6484 client_id, "glUniformLocation");
6459 if (!info) { 6485 if (!info) {
6460 return error::kNoError; 6486 return error::kNoError;
6461 } 6487 }
6462 if (!info->IsValid()) { 6488 if (!info->IsValid()) {
6463 SetGLError(GL_INVALID_OPERATION, 6489 SetGLError(
6464 "glGetUniformLocation: program not linked"); 6490 GL_INVALID_OPERATION, "glGetUniformLocation", "program not linked");
6465 return error::kNoError; 6491 return error::kNoError;
6466 } 6492 }
6467 GLint* location = GetSharedMemoryAs<GLint*>( 6493 GLint* location = GetSharedMemoryAs<GLint*>(
6468 location_shm_id, location_shm_offset, sizeof(GLint)); 6494 location_shm_id, location_shm_offset, sizeof(GLint));
6469 if (!location) { 6495 if (!location) {
6470 return error::kOutOfBounds; 6496 return error::kOutOfBounds;
6471 } 6497 }
6472 // Require the client to init this incase the context is lost an we are no 6498 // Require the client to init this incase the context is lost an we are no
6473 // longer executing commands. 6499 // longer executing commands.
6474 if (*location != -1) { 6500 if (*location != -1) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6516 return error::kInvalidArguments; 6542 return error::kInvalidArguments;
6517 } 6543 }
6518 return GetUniformLocationHelper( 6544 return GetUniformLocationHelper(
6519 c.program, c.location_shm_id, c.location_shm_offset, name_str); 6545 c.program, c.location_shm_id, c.location_shm_offset, name_str);
6520 } 6546 }
6521 6547
6522 error::Error GLES2DecoderImpl::HandleGetString( 6548 error::Error GLES2DecoderImpl::HandleGetString(
6523 uint32 immediate_data_size, const gles2::GetString& c) { 6549 uint32 immediate_data_size, const gles2::GetString& c) {
6524 GLenum name = static_cast<GLenum>(c.name); 6550 GLenum name = static_cast<GLenum>(c.name);
6525 if (!validators_->string_type.IsValid(name)) { 6551 if (!validators_->string_type.IsValid(name)) {
6526 SetGLError(GL_INVALID_ENUM, "glGetString: name GL_INVALID_ENUM"); 6552 SetGLError(GL_INVALID_ENUM, "glGetString", "name GL_INVALID_ENUM");
6527 return error::kNoError; 6553 return error::kNoError;
6528 } 6554 }
6529 const char* gl_str = reinterpret_cast<const char*>(glGetString(name)); 6555 const char* gl_str = reinterpret_cast<const char*>(glGetString(name));
6530 const char* str = NULL; 6556 const char* str = NULL;
6531 std::string extensions; 6557 std::string extensions;
6532 switch (name) { 6558 switch (name) {
6533 case GL_VERSION: 6559 case GL_VERSION:
6534 str = "OpenGL ES 2.0 Chromium"; 6560 str = "OpenGL ES 2.0 Chromium";
6535 break; 6561 break;
6536 case GL_SHADING_LANGUAGE_VERSION: 6562 case GL_SHADING_LANGUAGE_VERSION:
(...skipping 29 matching lines...) Expand all
6566 break; 6592 break;
6567 } 6593 }
6568 Bucket* bucket = CreateBucket(c.bucket_id); 6594 Bucket* bucket = CreateBucket(c.bucket_id);
6569 bucket->SetFromString(str); 6595 bucket->SetFromString(str);
6570 return error::kNoError; 6596 return error::kNoError;
6571 } 6597 }
6572 6598
6573 void GLES2DecoderImpl::DoBufferData( 6599 void GLES2DecoderImpl::DoBufferData(
6574 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) { 6600 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) {
6575 if (!validators_->buffer_target.IsValid(target)) { 6601 if (!validators_->buffer_target.IsValid(target)) {
6576 SetGLError(GL_INVALID_ENUM, "glBufferData: target GL_INVALID_ENUM"); 6602 SetGLError(GL_INVALID_ENUM, "glBufferData", "target GL_INVALID_ENUM");
6577 return; 6603 return;
6578 } 6604 }
6579 if (!validators_->buffer_usage.IsValid(usage)) { 6605 if (!validators_->buffer_usage.IsValid(usage)) {
6580 SetGLError(GL_INVALID_ENUM, "glBufferData: usage GL_INVALID_ENUM"); 6606 SetGLError(GL_INVALID_ENUM, "glBufferData", "usage GL_INVALID_ENUM");
6581 return; 6607 return;
6582 } 6608 }
6583 if (size < 0) { 6609 if (size < 0) {
6584 SetGLError(GL_INVALID_VALUE, "glBufferData: size < 0"); 6610 SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0");
6585 return; 6611 return;
6586 } 6612 }
6587 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target); 6613 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target);
6588 if (!info) { 6614 if (!info) {
6589 SetGLError(GL_INVALID_VALUE, "glBufferData: unknown buffer"); 6615 SetGLError(GL_INVALID_VALUE, "glBufferData", "unknown buffer");
6590 return; 6616 return;
6591 } 6617 }
6592 // Clear the buffer to 0 if no initial data was passed in. 6618 // Clear the buffer to 0 if no initial data was passed in.
6593 scoped_array<int8> zero; 6619 scoped_array<int8> zero;
6594 if (!data) { 6620 if (!data) {
6595 zero.reset(new int8[size]); 6621 zero.reset(new int8[size]);
6596 memset(zero.get(), 0, size); 6622 memset(zero.get(), 0, size);
6597 data = zero.get(); 6623 data = zero.get();
6598 } 6624 }
6599 6625
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
6642 } 6668 }
6643 GLenum usage = static_cast<GLenum>(c.usage); 6669 GLenum usage = static_cast<GLenum>(c.usage);
6644 DoBufferData(target, size, data, usage); 6670 DoBufferData(target, size, data, usage);
6645 return error::kNoError; 6671 return error::kNoError;
6646 } 6672 }
6647 6673
6648 void GLES2DecoderImpl::DoBufferSubData( 6674 void GLES2DecoderImpl::DoBufferSubData(
6649 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) { 6675 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) {
6650 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target); 6676 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target);
6651 if (!info) { 6677 if (!info) {
6652 SetGLError(GL_INVALID_VALUE, "glBufferSubData: unknown buffer"); 6678 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer");
6653 return; 6679 return;
6654 } 6680 }
6655 if (!info->SetRange(offset, size, data)) { 6681 if (!info->SetRange(offset, size, data)) {
6656 SetGLError(GL_INVALID_VALUE, "glBufferSubData: out of range"); 6682 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "out of range");
6657 return; 6683 return;
6658 } 6684 }
6659 if (bufferdata_faster_than_buffersubdata_ && 6685 if (bufferdata_faster_than_buffersubdata_ &&
6660 offset == 0 && size == info->size()) { 6686 offset == 0 && size == info->size()) {
6661 glBufferData(target, size, data, info->usage()); 6687 glBufferData(target, size, data, info->usage());
6662 return; 6688 return;
6663 } 6689 }
6664 glBufferSubData(target, offset, size, data); 6690 glBufferSubData(target, offset, size, data);
6665 } 6691 }
6666 6692
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
6756 WrappedTexImage2D( 6782 WrappedTexImage2D(
6757 target, level, format, width, h, 0, format, type, zero.get()); 6783 target, level, format, width, h, 0, format, type, zero.get());
6758 } 6784 }
6759 y += tile_height; 6785 y += tile_height;
6760 } 6786 }
6761 TextureManager::TextureInfo* info = GetTextureInfoForTarget(bind_target); 6787 TextureManager::TextureInfo* info = GetTextureInfoForTarget(bind_target);
6762 glBindTexture(bind_target, info ? info->service_id() : 0); 6788 glBindTexture(bind_target, info ? info->service_id() : 0);
6763 return true; 6789 return true;
6764 } 6790 }
6765 6791
6792 bool GLES2DecoderImpl::ValidateCompressedTexFuncData(
6793 const char* function_name,
6794 GLsizei width, GLsizei height, GLenum format, size_t size) {
6795 unsigned int bytes_required = 0;
6796
6797 switch (format) {
6798 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
apatrick_chromium 2012/06/08 18:46:47 body of switch should be indented 2 spaces.
greggman 2012/06/08 20:01:13 Done.
6799 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
6800 {
6801 const int kBlockWidth = 4;
6802 const int kBlockHeight = 4;
6803 const int kBlockSize = 8;
6804 int num_blocks_across = (width + kBlockWidth - 1) / kBlockWidth;
6805 int num_blocks_down = (height + kBlockHeight - 1) / kBlockHeight;
6806 int num_blocks = num_blocks_across * num_blocks_down;
6807 bytes_required = num_blocks * kBlockSize;
6808 }
6809 break;
6810 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
6811 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
6812 {
6813 const int kBlockWidth = 4;
apatrick_chromium 2012/06/08 18:46:47 nit: single definition of kBlockWidth and kBlockHe
6814 const int kBlockHeight = 4;
6815 const int kBlockSize = 16;
6816 int num_blocks_across = (width + kBlockWidth - 1) / kBlockWidth;
6817 int num_blocks_down = (height + kBlockHeight - 1) / kBlockHeight;
6818 int num_blocks = num_blocks_across * num_blocks_down;
6819 bytes_required = num_blocks * kBlockSize;
6820 }
6821 break;
6822 default:
6823 SetGLError(GL_INVALID_ENUM, function_name, "invalid format");
6824 return false;
6825 }
6826
6827 if (size != bytes_required) {
6828 SetGLError(
6829 GL_INVALID_VALUE, function_name, "size is not correct for dimensions");
6830 return false;
6831 }
6832
6833 return true;
6834 }
6835
6836 bool GLES2DecoderImpl::ValidateCompressedTexDimensions(
6837 const char* function_name,
6838 GLint level, GLsizei width, GLsizei height, GLenum format) {
6839 switch (format) {
6840 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
6841 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
6842 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
6843 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: {
6844 const int kBlockWidth = 4;
apatrick_chromium 2012/06/08 18:46:47 In fact, why not just have a single constant for D
greggman 2012/06/08 20:01:13 Done.
6845 const int kBlockHeight = 4;
6846 bool width_valid = (level && width == 1) ||
6847 (level && width == 2) || !(width % kBlockWidth);
6848 bool height_valid = (level && height == 1) ||
6849 (level && height == 2) || !(height % kBlockHeight);
apatrick_chromium 2012/06/08 18:46:47 nit: up to you but you could have a function like
greggman 2012/06/08 20:01:13 Done.
6850 if (!width_valid || !height_valid) {
6851 SetGLError(
6852 GL_INVALID_OPERATION, function_name,
6853 "width or height invalid for level");
6854 return false;
6855 }
6856 return true;
6857 }
6858 default:
6859 return false;
6860 }
6861 }
6862
6863 bool GLES2DecoderImpl::ValidateCompressedTexSubDimensions(
6864 const char* function_name,
6865 GLenum target, GLint level, GLint xoffset, GLint yoffset,
6866 GLsizei width, GLsizei height, GLenum format,
6867 TextureManager::TextureInfo* texture) {
6868 if (xoffset < 0 || yoffset < 0) {
6869 SetGLError(
6870 GL_INVALID_VALUE, function_name, "xoffset or yoffset < 0");
6871 return false;
6872 }
6873
6874 switch (format) {
6875 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
apatrick_chromium 2012/06/08 18:46:47 indent body of switch.
greggman 2012/06/08 20:01:13 Done.
6876 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
6877 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
6878 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: {
6879 const int kBlockWidth = 4;
6880 const int kBlockHeight = 4;
6881 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) {
6882 SetGLError(
6883 GL_INVALID_OPERATION, function_name,
6884 "xoffset or yoffset not multiple of 4");
6885 return false;
6886 }
6887 GLsizei tex_width = 0;
6888 GLsizei tex_height = 0;
6889 if (!texture->GetLevelSize(target, level, &tex_width, &tex_height) ||
6890 width - xoffset > tex_width ||
6891 height - yoffset > tex_height) {
6892 SetGLError(
6893 GL_INVALID_OPERATION, function_name, "dimensions out of range");
6894 return false;
6895 }
6896 return ValidateCompressedTexDimensions(
6897 function_name, level, width, height, format);
6898 }
6899 default:
6900 return false;
6901 }
6902 }
6903
6766 error::Error GLES2DecoderImpl::DoCompressedTexImage2D( 6904 error::Error GLES2DecoderImpl::DoCompressedTexImage2D(
6767 GLenum target, 6905 GLenum target,
6768 GLint level, 6906 GLint level,
6769 GLenum internal_format, 6907 GLenum internal_format,
6770 GLsizei width, 6908 GLsizei width,
6771 GLsizei height, 6909 GLsizei height,
6772 GLint border, 6910 GLint border,
6773 GLsizei image_size, 6911 GLsizei image_size,
6774 const void* data) { 6912 const void* data) {
6775 // TODO(gman): Validate image_size is correct for width, height and format. 6913 // TODO(gman): Validate image_size is correct for width, height and format.
6776 if (!validators_->texture_target.IsValid(target)) { 6914 if (!validators_->texture_target.IsValid(target)) {
6777 SetGLError(GL_INVALID_ENUM, 6915 SetGLError(GL_INVALID_ENUM,
6778 "glCompressedTexImage2D: target GL_INVALID_ENUM"); 6916 "glCompressedTexImage2D", "target GL_INVALID_ENUM");
6779 return error::kNoError; 6917 return error::kNoError;
6780 } 6918 }
6781 if (!validators_->compressed_texture_format.IsValid( 6919 if (!validators_->compressed_texture_format.IsValid(
6782 internal_format)) { 6920 internal_format)) {
6783 SetGLError(GL_INVALID_ENUM, 6921 SetGLError(GL_INVALID_ENUM,
6784 "glCompressedTexImage2D: internal_format GL_INVALID_ENUM"); 6922 "glCompressedTexImage2D", "internal_format GL_INVALID_ENUM");
6785 return error::kNoError; 6923 return error::kNoError;
6786 } 6924 }
6787 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || 6925 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
6788 border != 0) { 6926 border != 0) {
6789 SetGLError(GL_INVALID_VALUE, 6927 SetGLError(GL_INVALID_VALUE,
6790 "glCompressedTexImage2D: dimensions out of range"); 6928 "glCompressedTexImage2D", "dimensions out of range");
6791 return error::kNoError; 6929 return error::kNoError;
6792 } 6930 }
6793 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 6931 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
6794 if (!info) { 6932 if (!info) {
6795 SetGLError(GL_INVALID_VALUE, 6933 SetGLError(GL_INVALID_VALUE,
6796 "glCompressedTexImage2D: unknown texture target"); 6934 "glCompressedTexImage2D", "unknown texture target");
6797 return error::kNoError; 6935 return error::kNoError;
6798 } 6936 }
6799 if (info->IsImmutable()) { 6937 if (info->IsImmutable()) {
6800 SetGLError(GL_INVALID_OPERATION, 6938 SetGLError(GL_INVALID_OPERATION,
6801 "glCompressedTexImage2D: texture is immutable"); 6939 "glCompressedTexImage2D", "texture is immutable");
6802 return error::kNoError; 6940 return error::kNoError;
6803 } 6941 }
6804 6942
6943 if (!ValidateCompressedTexDimensions(
6944 "glCompressedTexImage2D", level, width, height, internal_format) ||
6945 !ValidateCompressedTexFuncData(
6946 "glCompressedTexImage2D", width, height, internal_format, image_size)) {
6947 return error::kNoError;
6948 }
6949
6805 if (info->IsAttachedToFramebuffer()) { 6950 if (info->IsAttachedToFramebuffer()) {
6806 state_dirty_ = true; 6951 state_dirty_ = true;
6807 // TODO(gman): If textures tracked which framebuffers they were attached to 6952 // TODO(gman): If textures tracked which framebuffers they were attached to
6808 // we could just mark those framebuffers as not complete. 6953 // we could just mark those framebuffers as not complete.
6809 framebuffer_manager()->IncFramebufferStateChangeCount(); 6954 framebuffer_manager()->IncFramebufferStateChangeCount();
6810 } 6955 }
6811 6956
6812 scoped_array<int8> zero; 6957 scoped_array<int8> zero;
6813 if (!data) { 6958 if (!data) {
6814 zero.reset(new int8[image_size]); 6959 zero.reset(new int8[image_size]);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
6906 return error::kInvalidArguments; 7051 return error::kInvalidArguments;
6907 } 7052 }
6908 uint32 data_size = bucket->size(); 7053 uint32 data_size = bucket->size();
6909 GLsizei imageSize = data_size; 7054 GLsizei imageSize = data_size;
6910 const void* data = bucket->GetData(0, data_size); 7055 const void* data = bucket->GetData(0, data_size);
6911 if (!data) { 7056 if (!data) {
6912 return error::kInvalidArguments; 7057 return error::kInvalidArguments;
6913 } 7058 }
6914 if (!validators_->texture_target.IsValid(target)) { 7059 if (!validators_->texture_target.IsValid(target)) {
6915 SetGLError( 7060 SetGLError(
6916 GL_INVALID_ENUM, "glCompressedTexSubImage2D: target GL_INVALID_ENUM"); 7061 GL_INVALID_ENUM, "glCompressedTexSubImage2D", "target GL_INVALID_ENUM");
6917 return error::kNoError; 7062 return error::kNoError;
6918 } 7063 }
6919 if (!validators_->compressed_texture_format.IsValid(format)) { 7064 if (!validators_->compressed_texture_format.IsValid(format)) {
6920 SetGLError(GL_INVALID_ENUM, 7065 SetGLError(GL_INVALID_ENUM,
6921 "glCompressedTexSubImage2D: format GL_INVALID_ENUM"); 7066 "glCompressedTexSubImage2D", "format GL_INVALID_ENUM");
6922 return error::kNoError; 7067 return error::kNoError;
6923 } 7068 }
6924 if (width < 0) { 7069 if (width < 0) {
6925 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: width < 0"); 7070 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D", "width < 0");
6926 return error::kNoError; 7071 return error::kNoError;
6927 } 7072 }
6928 if (height < 0) { 7073 if (height < 0) {
6929 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: height < 0"); 7074 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D", "height < 0");
6930 return error::kNoError; 7075 return error::kNoError;
6931 } 7076 }
6932 if (imageSize < 0) { 7077 if (imageSize < 0) {
6933 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: imageSize < 0"); 7078 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D", "imageSize < 0");
6934 return error::kNoError; 7079 return error::kNoError;
6935 } 7080 }
6936 DoCompressedTexSubImage2D( 7081 DoCompressedTexSubImage2D(
6937 target, level, xoffset, yoffset, width, height, format, imageSize, data); 7082 target, level, xoffset, yoffset, width, height, format, imageSize, data);
6938 return error::kNoError; 7083 return error::kNoError;
6939 } 7084 }
6940 7085
6941 bool GLES2DecoderImpl::ValidateTextureParameters( 7086 bool GLES2DecoderImpl::ValidateTextureParameters(
6942 const char* function_name, 7087 const char* function_name,
6943 GLenum target, GLenum format, GLenum type, GLint level) { 7088 GLenum target, GLenum format, GLenum type, GLint level) {
6944 if (!feature_info_->GetTextureFormatValidator(format).IsValid(type)) { 7089 if (!feature_info_->GetTextureFormatValidator(format).IsValid(type)) {
6945 SetGLError(GL_INVALID_OPERATION, 7090 SetGLError(GL_INVALID_OPERATION, function_name,
6946 (std::string(function_name) + ": invalid type " + 7091 (std::string("invalid type ") +
6947 GLES2Util::GetStringEnum(type) + " for format " + 7092 GLES2Util::GetStringEnum(type) + " for format " +
6948 GLES2Util::GetStringEnum(format)).c_str()); 7093 GLES2Util::GetStringEnum(format)).c_str());
6949 return false; 7094 return false;
6950 } 7095 }
6951 7096
6952 uint32 channels = GLES2Util::GetChannelsForFormat(format); 7097 uint32 channels = GLES2Util::GetChannelsForFormat(format);
6953 if ((channels & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && level) { 7098 if ((channels & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && level) {
6954 SetGLError(GL_INVALID_OPERATION, 7099 SetGLError(GL_INVALID_OPERATION, function_name,
6955 (std::string(function_name) + ": invalid type " + 7100 (std::string("invalid type ") +
6956 GLES2Util::GetStringEnum(type) + " for format " + 7101 GLES2Util::GetStringEnum(type) + " for format " +
6957 GLES2Util::GetStringEnum(format)).c_str()); 7102 GLES2Util::GetStringEnum(format)).c_str());
6958 return false; 7103 return false;
6959 } 7104 }
6960 return true; 7105 return true;
6961 } 7106 }
6962 7107
6963 error::Error GLES2DecoderImpl::DoTexImage2D( 7108 error::Error GLES2DecoderImpl::DoTexImage2D(
6964 GLenum target, 7109 GLenum target,
6965 GLint level, 7110 GLint level,
6966 GLenum internal_format, 7111 GLenum internal_format,
6967 GLsizei width, 7112 GLsizei width,
6968 GLsizei height, 7113 GLsizei height,
6969 GLint border, 7114 GLint border,
6970 GLenum format, 7115 GLenum format,
6971 GLenum type, 7116 GLenum type,
6972 const void* pixels, 7117 const void* pixels,
6973 uint32 pixels_size) { 7118 uint32 pixels_size) {
6974 if (!validators_->texture_target.IsValid(target)) { 7119 if (!validators_->texture_target.IsValid(target)) {
6975 SetGLError(GL_INVALID_ENUM, "glTexImage2D: target GL_INVALID_ENUM"); 7120 SetGLError(GL_INVALID_ENUM, "glTexImage2D", "target GL_INVALID_ENUM");
6976 return error::kNoError; 7121 return error::kNoError;
6977 } 7122 }
6978 if (!validators_->texture_format.IsValid(internal_format)) { 7123 if (!validators_->texture_format.IsValid(internal_format)) {
6979 SetGLError(GL_INVALID_ENUM, 7124 SetGLError(GL_INVALID_ENUM,
6980 "glTexImage2D: internal_format GL_INVALID_ENUM"); 7125 "glTexImage2D", "internal_format GL_INVALID_ENUM");
6981 return error::kNoError; 7126 return error::kNoError;
6982 } 7127 }
6983 if (!validators_->texture_format.IsValid(format)) { 7128 if (!validators_->texture_format.IsValid(format)) {
6984 SetGLError(GL_INVALID_ENUM, "glTexImage2D: format GL_INVALID_ENUM"); 7129 SetGLError(GL_INVALID_ENUM, "glTexImage2D", "format GL_INVALID_ENUM");
6985 return error::kNoError; 7130 return error::kNoError;
6986 } 7131 }
6987 if (!validators_->pixel_type.IsValid(type)) { 7132 if (!validators_->pixel_type.IsValid(type)) {
6988 SetGLError(GL_INVALID_ENUM, "glTexImage2D: type GL_INVALID_ENUM"); 7133 SetGLError(GL_INVALID_ENUM, "glTexImage2D", "type GL_INVALID_ENUM");
6989 return error::kNoError; 7134 return error::kNoError;
6990 } 7135 }
6991 if (format != internal_format) { 7136 if (format != internal_format) {
6992 SetGLError(GL_INVALID_OPERATION, "glTexImage2D: format != internalFormat"); 7137 SetGLError(GL_INVALID_OPERATION,
7138 "glTexImage2D", "format != internalFormat");
6993 return error::kNoError; 7139 return error::kNoError;
6994 } 7140 }
6995 if (!ValidateTextureParameters("glTexImage2D", target, format, type, level)) { 7141 if (!ValidateTextureParameters("glTexImage2D", target, format, type, level)) {
6996 return error::kNoError; 7142 return error::kNoError;
6997 } 7143 }
6998 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || 7144 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
6999 border != 0) { 7145 border != 0) {
7000 SetGLError(GL_INVALID_VALUE, "glTexImage2D: dimensions out of range"); 7146 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimensions out of range");
7001 return error::kNoError; 7147 return error::kNoError;
7002 } 7148 }
7003 if ((GLES2Util::GetChannelsForFormat(format) & 7149 if ((GLES2Util::GetChannelsForFormat(format) &
7004 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && pixels) { 7150 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && pixels) {
7005 SetGLError( 7151 SetGLError(
7006 GL_INVALID_OPERATION, 7152 GL_INVALID_OPERATION,
7007 "glTexImage2D: can not supply data for depth or stencil textures"); 7153 "glTexImage2D", "can not supply data for depth or stencil textures");
7008 return error::kNoError; 7154 return error::kNoError;
7009 } 7155 }
7010 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7156 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
7011 if (!info) { 7157 if (!info) {
7012 SetGLError(GL_INVALID_OPERATION, 7158 SetGLError(GL_INVALID_OPERATION,
7013 "glTexImage2D: unknown texture for target"); 7159 "glTexImage2D", "unknown texture for target");
7014 return error::kNoError; 7160 return error::kNoError;
7015 } 7161 }
7016 7162
7017 if (info->IsImmutable()) { 7163 if (info->IsImmutable()) {
7018 SetGLError(GL_INVALID_OPERATION, 7164 SetGLError(GL_INVALID_OPERATION,
7019 "glTexImage2D: texture is immutable"); 7165 "glTexImage2D", "texture is immutable");
7020 return error::kNoError; 7166 return error::kNoError;
7021 } 7167 }
7022 7168
7023 GLsizei tex_width = 0; 7169 GLsizei tex_width = 0;
7024 GLsizei tex_height = 0; 7170 GLsizei tex_height = 0;
7025 GLenum tex_type = 0; 7171 GLenum tex_type = 0;
7026 GLenum tex_format = 0; 7172 GLenum tex_format = 0;
7027 bool level_is_same = 7173 bool level_is_same =
7028 info->GetLevelSize(target, level, &tex_width, &tex_height) && 7174 info->GetLevelSize(target, level, &tex_width, &tex_height) &&
7029 info->GetLevelType(target, level, &tex_type, &tex_format) && 7175 info->GetLevelType(target, level, &tex_type, &tex_format) &&
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
7134 GLint xoffset, 7280 GLint xoffset,
7135 GLint yoffset, 7281 GLint yoffset,
7136 GLsizei width, 7282 GLsizei width,
7137 GLsizei height, 7283 GLsizei height,
7138 GLenum format, 7284 GLenum format,
7139 GLsizei image_size, 7285 GLsizei image_size,
7140 const void * data) { 7286 const void * data) {
7141 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7287 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
7142 if (!info) { 7288 if (!info) {
7143 SetGLError(GL_INVALID_OPERATION, 7289 SetGLError(GL_INVALID_OPERATION,
7144 "glCompressedTexSubImage2D: unknown texture for target"); 7290 "glCompressedTexSubImage2D", "unknown texture for target");
7145 return; 7291 return;
7146 } 7292 }
7147 GLenum type = 0; 7293 GLenum type = 0;
7148 GLenum internal_format = 0; 7294 GLenum internal_format = 0;
7149 if (!info->GetLevelType(target, level, &type, &internal_format)) { 7295 if (!info->GetLevelType(target, level, &type, &internal_format)) {
7150 SetGLError( 7296 SetGLError(
7151 GL_INVALID_OPERATION, 7297 GL_INVALID_OPERATION,
7152 "glCompressedTexSubImage2D: level does not exist."); 7298 "glCompressedTexSubImage2D", "level does not exist.");
7153 return; 7299 return;
7154 } 7300 }
7155 if (internal_format != format) { 7301 if (internal_format != format) {
7156 SetGLError( 7302 SetGLError(
7157 GL_INVALID_OPERATION, 7303 GL_INVALID_OPERATION,
7158 "glCompressedTexSubImage2D: format does not match internal format."); 7304 "glCompressedTexSubImage2D", "format does not match internal format.");
7159 return; 7305 return;
7160 } 7306 }
7161 if (!info->ValidForTexture( 7307 if (!info->ValidForTexture(
7162 target, level, xoffset, yoffset, width, height, format, type)) { 7308 target, level, xoffset, yoffset, width, height, format, type)) {
7163 SetGLError(GL_INVALID_VALUE, 7309 SetGLError(GL_INVALID_VALUE,
7164 "glCompressedTexSubImage2D: bad dimensions."); 7310 "glCompressedTexSubImage2D", "bad dimensions.");
7165 return; 7311 return;
7166 } 7312 }
7313
7314 if (!ValidateCompressedTexFuncData(
7315 "glCompressedTexSubImage2D", width, height, format, image_size) ||
7316 !ValidateCompressedTexSubDimensions(
7317 "glCompressedTexSubImage2D",
7318 target, level, xoffset, yoffset, width, height, format, info)) {
7319 return;
7320 }
7321
7322
7167 // Note: There is no need to deal with texture cleared tracking here 7323 // Note: There is no need to deal with texture cleared tracking here
7168 // because the validation above means you can only get here if the level 7324 // because the validation above means you can only get here if the level
7169 // is already a matching compressed format and in that case 7325 // is already a matching compressed format and in that case
7170 // CompressedTexImage2D already cleared the texture. 7326 // CompressedTexImage2D already cleared the texture.
7171 glCompressedTexSubImage2D( 7327 glCompressedTexSubImage2D(
7172 target, level, xoffset, yoffset, width, height, format, image_size, data); 7328 target, level, xoffset, yoffset, width, height, format, image_size, data);
7173 } 7329 }
7174 7330
7175 static void Clip( 7331 static void Clip(
7176 GLint start, GLint range, GLint sourceRange, 7332 GLint start, GLint range, GLint sourceRange,
(...skipping 17 matching lines...) Expand all
7194 GLint level, 7350 GLint level,
7195 GLenum internal_format, 7351 GLenum internal_format,
7196 GLint x, 7352 GLint x,
7197 GLint y, 7353 GLint y,
7198 GLsizei width, 7354 GLsizei width,
7199 GLsizei height, 7355 GLsizei height,
7200 GLint border) { 7356 GLint border) {
7201 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7357 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
7202 if (!info) { 7358 if (!info) {
7203 SetGLError(GL_INVALID_OPERATION, 7359 SetGLError(GL_INVALID_OPERATION,
7204 "glCopyTexImage2D: unknown texture for target"); 7360 "glCopyTexImage2D", "unknown texture for target");
7205 return; 7361 return;
7206 } 7362 }
7207 if (info->IsImmutable()) { 7363 if (info->IsImmutable()) {
7208 SetGLError(GL_INVALID_OPERATION, 7364 SetGLError(GL_INVALID_OPERATION,
7209 "glCopyTexImage2D: texture is immutable"); 7365 "glCopyTexImage2D", "texture is immutable");
7210 } 7366 }
7211 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || 7367 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
7212 border != 0) { 7368 border != 0) {
7213 SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D: dimensions out of range"); 7369 SetGLError(GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range");
7214 return; 7370 return;
7215 } 7371 }
7216 if (!ValidateTextureParameters( 7372 if (!ValidateTextureParameters(
7217 "glCopyTexImage2D", target, internal_format, GL_UNSIGNED_BYTE, level)) { 7373 "glCopyTexImage2D", target, internal_format, GL_UNSIGNED_BYTE, level)) {
7218 return; 7374 return;
7219 } 7375 }
7220 7376
7221 // Check we have compatible formats. 7377 // Check we have compatible formats.
7222 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 7378 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
7223 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 7379 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
7224 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); 7380 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
7225 7381
7226 if ((channels_needed & channels_exist) != channels_needed) { 7382 if ((channels_needed & channels_exist) != channels_needed) {
7227 SetGLError(GL_INVALID_OPERATION, "glCopyTexImage2D: incompatible format"); 7383 SetGLError(GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format");
7228 return; 7384 return;
7229 } 7385 }
7230 7386
7231 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 7387 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
7232 SetGLError( 7388 SetGLError(
7233 GL_INVALID_OPERATION, 7389 GL_INVALID_OPERATION,
7234 "glCopyImage2D: can not be used with depth or stencil textures"); 7390 "glCopyImage2D", "can not be used with depth or stencil textures");
7235 return; 7391 return;
7236 } 7392 }
7237 7393
7238 if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) { 7394 if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) {
7239 return; 7395 return;
7240 } 7396 }
7241 7397
7242 CopyRealGLErrorsToWrapper(); 7398 CopyRealGLErrorsToWrapper();
7243 ScopedResolvedFrameBufferBinder binder(this, false, true); 7399 ScopedResolvedFrameBufferBinder binder(this, false, true);
7244 gfx::Size size = GetBoundReadFrameBufferSize(); 7400 gfx::Size size = GetBoundReadFrameBufferSize();
(...skipping 15 matching lines...) Expand all
7260 7416
7261 if (copyX != x || 7417 if (copyX != x ||
7262 copyY != y || 7418 copyY != y ||
7263 copyWidth != width || 7419 copyWidth != width ||
7264 copyHeight != height) { 7420 copyHeight != height) {
7265 // some part was clipped so clear the texture. 7421 // some part was clipped so clear the texture.
7266 if (!ClearLevel( 7422 if (!ClearLevel(
7267 info->service_id(), info->target(), 7423 info->service_id(), info->target(),
7268 target, level, internal_format, GL_UNSIGNED_BYTE, width, height, 7424 target, level, internal_format, GL_UNSIGNED_BYTE, width, height,
7269 info->IsImmutable())) { 7425 info->IsImmutable())) {
7270 SetGLError(GL_OUT_OF_MEMORY, "glCopyTexImage2D: dimensions too big"); 7426 SetGLError(GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too big");
7271 return; 7427 return;
7272 } 7428 }
7273 if (copyHeight > 0 && copyWidth > 0) { 7429 if (copyHeight > 0 && copyWidth > 0) {
7274 GLint dx = copyX - x; 7430 GLint dx = copyX - x;
7275 GLint dy = copyY - y; 7431 GLint dy = copyY - y;
7276 GLint destX = dx; 7432 GLint destX = dx;
7277 GLint destY = dy; 7433 GLint destY = dy;
7278 glCopyTexSubImage2D(target, level, 7434 glCopyTexSubImage2D(target, level,
7279 destX, destY, copyX, copyY, 7435 destX, destY, copyX, copyY,
7280 copyWidth, copyHeight); 7436 copyWidth, copyHeight);
(...skipping 15 matching lines...) Expand all
7296 GLint level, 7452 GLint level,
7297 GLint xoffset, 7453 GLint xoffset,
7298 GLint yoffset, 7454 GLint yoffset,
7299 GLint x, 7455 GLint x,
7300 GLint y, 7456 GLint y,
7301 GLsizei width, 7457 GLsizei width,
7302 GLsizei height) { 7458 GLsizei height) {
7303 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7459 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
7304 if (!info) { 7460 if (!info) {
7305 SetGLError(GL_INVALID_OPERATION, 7461 SetGLError(GL_INVALID_OPERATION,
7306 "glCopyTexSubImage2D: unknown texture for target"); 7462 "glCopyTexSubImage2D", "unknown texture for target");
7307 return; 7463 return;
7308 } 7464 }
7309 GLenum type = 0; 7465 GLenum type = 0;
7310 GLenum format = 0; 7466 GLenum format = 0;
7311 if (!info->GetLevelType(target, level, &type, &format) || 7467 if (!info->GetLevelType(target, level, &type, &format) ||
7312 !info->ValidForTexture( 7468 !info->ValidForTexture(
7313 target, level, xoffset, yoffset, width, height, format, type)) { 7469 target, level, xoffset, yoffset, width, height, format, type)) {
7314 SetGLError(GL_INVALID_VALUE, 7470 SetGLError(GL_INVALID_VALUE,
7315 "glCopyTexSubImage2D: bad dimensions."); 7471 "glCopyTexSubImage2D", "bad dimensions.");
7316 return; 7472 return;
7317 } 7473 }
7318 7474
7319 // Check we have compatible formats. 7475 // Check we have compatible formats.
7320 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 7476 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
7321 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 7477 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
7322 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format); 7478 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format);
7323 7479
7324 if ((channels_needed & channels_exist) != channels_needed) { 7480 if ((channels_needed & channels_exist) != channels_needed) {
7325 SetGLError( 7481 SetGLError(
7326 GL_INVALID_OPERATION, "glCopyTexSubImage2D: incompatible format"); 7482 GL_INVALID_OPERATION, "glCopyTexSubImage2D", "incompatible format");
7327 return; 7483 return;
7328 } 7484 }
7329 7485
7330 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 7486 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
7331 SetGLError( 7487 SetGLError(
7332 GL_INVALID_OPERATION, 7488 GL_INVALID_OPERATION,
7333 "glCopySubImage2D: can not be used with depth or stencil textures"); 7489 "glCopySubImage2D", "can not be used with depth or stencil textures");
7334 return; 7490 return;
7335 } 7491 }
7336 7492
7337 if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) { 7493 if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) {
7338 return; 7494 return;
7339 } 7495 }
7340 7496
7341 ScopedResolvedFrameBufferBinder binder(this, false, true); 7497 ScopedResolvedFrameBufferBinder binder(this, false, true);
7342 gfx::Size size = GetBoundReadFrameBufferSize(); 7498 gfx::Size size = GetBoundReadFrameBufferSize();
7343 GLint copyX = 0; 7499 GLint copyX = 0;
7344 GLint copyY = 0; 7500 GLint copyY = 0;
7345 GLint copyWidth = 0; 7501 GLint copyWidth = 0;
7346 GLint copyHeight = 0; 7502 GLint copyHeight = 0;
7347 Clip(x, width, size.width(), &copyX, &copyWidth); 7503 Clip(x, width, size.width(), &copyX, &copyWidth);
7348 Clip(y, height, size.height(), &copyY, &copyHeight); 7504 Clip(y, height, size.height(), &copyY, &copyHeight);
7349 7505
7350 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) { 7506 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) {
7351 SetGLError(GL_OUT_OF_MEMORY, "glCopyTexSubImage2D: dimensions too big"); 7507 SetGLError(GL_OUT_OF_MEMORY, "glCopyTexSubImage2D", "dimensions too big");
7352 return; 7508 return;
7353 } 7509 }
7354 7510
7355 if (copyX != x || 7511 if (copyX != x ||
7356 copyY != y || 7512 copyY != y ||
7357 copyWidth != width || 7513 copyWidth != width ||
7358 copyHeight != height) { 7514 copyHeight != height) {
7359 // some part was clipped so clear the sub rect. 7515 // some part was clipped so clear the sub rect.
7360 uint32 pixels_size = 0; 7516 uint32 pixels_size = 0;
7361 if (!GLES2Util::ComputeImageDataSizes( 7517 if (!GLES2Util::ComputeImageDataSizes(
7362 width, height, format, type, unpack_alignment_, &pixels_size, NULL, 7518 width, height, format, type, unpack_alignment_, &pixels_size, NULL,
7363 NULL)) { 7519 NULL)) {
7364 SetGLError(GL_INVALID_VALUE, "glCopyTexSubImage2D: dimensions too large"); 7520 SetGLError(
7521 GL_INVALID_VALUE, "glCopyTexSubImage2D", "dimensions too large");
7365 return; 7522 return;
7366 } 7523 }
7367 scoped_array<char> zero(new char[pixels_size]); 7524 scoped_array<char> zero(new char[pixels_size]);
7368 memset(zero.get(), 0, pixels_size); 7525 memset(zero.get(), 0, pixels_size);
7369 glTexSubImage2D( 7526 glTexSubImage2D(
7370 target, level, xoffset, yoffset, width, height, 7527 target, level, xoffset, yoffset, width, height,
7371 format, type, zero.get()); 7528 format, type, zero.get());
7372 } 7529 }
7373 7530
7374 if (copyHeight > 0 && copyWidth > 0) { 7531 if (copyHeight > 0 && copyWidth > 0) {
(...skipping 13 matching lines...) Expand all
7388 GLint xoffset, 7545 GLint xoffset,
7389 GLint yoffset, 7546 GLint yoffset,
7390 GLsizei width, 7547 GLsizei width,
7391 GLsizei height, 7548 GLsizei height,
7392 GLenum format, 7549 GLenum format,
7393 GLenum type, 7550 GLenum type,
7394 const void * data) { 7551 const void * data) {
7395 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7552 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
7396 if (!info) { 7553 if (!info) {
7397 SetGLError(GL_INVALID_OPERATION, 7554 SetGLError(GL_INVALID_OPERATION,
7398 "glTexSubImage2D: unknown texture for target"); 7555 "glTexSubImage2D", "unknown texture for target");
7399 return; 7556 return;
7400 } 7557 }
7401 GLenum current_type = 0; 7558 GLenum current_type = 0;
7402 GLenum internal_format = 0; 7559 GLenum internal_format = 0;
7403 if (!info->GetLevelType(target, level, &current_type, &internal_format)) { 7560 if (!info->GetLevelType(target, level, &current_type, &internal_format)) {
7404 SetGLError( 7561 SetGLError(
7405 GL_INVALID_OPERATION, 7562 GL_INVALID_OPERATION, "glTexSubImage2D", "level does not exist.");
7406 "glTexSubImage2D: level does not exist.");
7407 return; 7563 return;
7408 } 7564 }
7409 if (format != internal_format) { 7565 if (format != internal_format) {
7410 SetGLError(GL_INVALID_OPERATION, 7566 SetGLError(GL_INVALID_OPERATION,
7411 "glTexSubImage2D: format does not match internal format."); 7567 "glTexSubImage2D", "format does not match internal format.");
7412 return; 7568 return;
7413 } 7569 }
7414 if (type != current_type) { 7570 if (type != current_type) {
7415 SetGLError(GL_INVALID_OPERATION, 7571 SetGLError(GL_INVALID_OPERATION,
7416 "glTexSubImage2D: type does not match type of texture."); 7572 "glTexSubImage2D", "type does not match type of texture.");
7417 return; 7573 return;
7418 } 7574 }
7419 7575
7420 if (!info->ValidForTexture( 7576 if (!info->ValidForTexture(
7421 target, level, xoffset, yoffset, width, height, format, type)) { 7577 target, level, xoffset, yoffset, width, height, format, type)) {
7422 SetGLError(GL_INVALID_VALUE, 7578 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "bad dimensions.");
7423 "glTexSubImage2D: bad dimensions.");
7424 return; 7579 return;
7425 } 7580 }
7426 7581
7427 if ((GLES2Util::GetChannelsForFormat(format) & 7582 if ((GLES2Util::GetChannelsForFormat(format) &
7428 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 7583 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
7429 SetGLError( 7584 SetGLError(
7430 GL_INVALID_OPERATION, 7585 GL_INVALID_OPERATION,
7431 "glTexSubImage2D: can not supply data for depth or stencil textures"); 7586 "glTexSubImage2D", "can not supply data for depth or stencil textures");
7432 return; 7587 return;
7433 } 7588 }
7434 7589
7435 GLsizei tex_width = 0; 7590 GLsizei tex_width = 0;
7436 GLsizei tex_height = 0; 7591 GLsizei tex_height = 0;
7437 bool ok = info->GetLevelSize(target, level, &tex_width, &tex_height); 7592 bool ok = info->GetLevelSize(target, level, &tex_width, &tex_height);
7438 DCHECK(ok); 7593 DCHECK(ok);
7439 if (xoffset != 0 || yoffset != 0 || 7594 if (xoffset != 0 || yoffset != 0 ||
7440 width != tex_width || height != tex_height) { 7595 width != tex_width || height != tex_height) {
7441 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) { 7596 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) {
7442 SetGLError(GL_OUT_OF_MEMORY, "glTexSubImage2D: dimensions too big"); 7597 SetGLError(GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big");
7443 return; 7598 return;
7444 } 7599 }
7445 glTexSubImage2D( 7600 glTexSubImage2D(
7446 target, level, xoffset, yoffset, width, height, format, type, data); 7601 target, level, xoffset, yoffset, width, height, format, type, data);
7447 return; 7602 return;
7448 } 7603 }
7449 7604
7450 if (teximage2d_faster_than_texsubimage2d_ && !info->IsImmutable()) { 7605 if (teximage2d_faster_than_texsubimage2d_ && !info->IsImmutable()) {
7451 // NOTE: In OpenGL ES 2.0 border is always zero and format is always the 7606 // NOTE: In OpenGL ES 2.0 border is always zero and format is always the
7452 // same as internal_foramt. If that changes we'll need to look them up. 7607 // same as internal_foramt. If that changes we'll need to look them up.
(...skipping 22 matching lines...) Expand all
7475 GLenum format = static_cast<GLenum>(c.format); 7630 GLenum format = static_cast<GLenum>(c.format);
7476 GLenum type = static_cast<GLenum>(c.type); 7631 GLenum type = static_cast<GLenum>(c.type);
7477 uint32 data_size; 7632 uint32 data_size;
7478 if (!GLES2Util::ComputeImageDataSizes( 7633 if (!GLES2Util::ComputeImageDataSizes(
7479 width, height, format, type, unpack_alignment_, &data_size, NULL, NULL)) { 7634 width, height, format, type, unpack_alignment_, &data_size, NULL, NULL)) {
7480 return error::kOutOfBounds; 7635 return error::kOutOfBounds;
7481 } 7636 }
7482 const void* pixels = GetSharedMemoryAs<const void*>( 7637 const void* pixels = GetSharedMemoryAs<const void*>(
7483 c.pixels_shm_id, c.pixels_shm_offset, data_size); 7638 c.pixels_shm_id, c.pixels_shm_offset, data_size);
7484 if (!validators_->texture_target.IsValid(target)) { 7639 if (!validators_->texture_target.IsValid(target)) {
7485 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: target GL_INVALID_ENUM"); 7640 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D", "target GL_INVALID_ENUM");
7486 return error::kNoError; 7641 return error::kNoError;
7487 } 7642 }
7488 if (width < 0) { 7643 if (width < 0) {
7489 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: width < 0"); 7644 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "width < 0");
7490 return error::kNoError; 7645 return error::kNoError;
7491 } 7646 }
7492 if (height < 0) { 7647 if (height < 0) {
7493 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: height < 0"); 7648 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "height < 0");
7494 return error::kNoError; 7649 return error::kNoError;
7495 } 7650 }
7496 if (!validators_->texture_format.IsValid(format)) { 7651 if (!validators_->texture_format.IsValid(format)) {
7497 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: format GL_INVALID_ENUM"); 7652 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D", "format GL_INVALID_ENUM");
7498 return error::kNoError; 7653 return error::kNoError;
7499 } 7654 }
7500 if (!validators_->pixel_type.IsValid(type)) { 7655 if (!validators_->pixel_type.IsValid(type)) {
7501 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: type GL_INVALID_ENUM"); 7656 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D", "type GL_INVALID_ENUM");
7502 return error::kNoError; 7657 return error::kNoError;
7503 } 7658 }
7504 if (pixels == NULL) { 7659 if (pixels == NULL) {
7505 return error::kOutOfBounds; 7660 return error::kOutOfBounds;
7506 } 7661 }
7507 DoTexSubImage2D( 7662 DoTexSubImage2D(
7508 target, level, xoffset, yoffset, width, height, format, type, pixels); 7663 target, level, xoffset, yoffset, width, height, format, type, pixels);
7509 return error::kNoError; 7664 return error::kNoError;
7510 } 7665 }
7511 7666
(...skipping 12 matching lines...) Expand all
7524 GLenum format = static_cast<GLenum>(c.format); 7679 GLenum format = static_cast<GLenum>(c.format);
7525 GLenum type = static_cast<GLenum>(c.type); 7680 GLenum type = static_cast<GLenum>(c.type);
7526 uint32 data_size; 7681 uint32 data_size;
7527 if (!GLES2Util::ComputeImageDataSizes( 7682 if (!GLES2Util::ComputeImageDataSizes(
7528 width, height, format, type, unpack_alignment_, &data_size, NULL, NULL)) { 7683 width, height, format, type, unpack_alignment_, &data_size, NULL, NULL)) {
7529 return error::kOutOfBounds; 7684 return error::kOutOfBounds;
7530 } 7685 }
7531 const void* pixels = GetImmediateDataAs<const void*>( 7686 const void* pixels = GetImmediateDataAs<const void*>(
7532 c, data_size, immediate_data_size); 7687 c, data_size, immediate_data_size);
7533 if (!validators_->texture_target.IsValid(target)) { 7688 if (!validators_->texture_target.IsValid(target)) {
7534 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: target GL_INVALID_ENUM"); 7689 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D", "target GL_INVALID_ENUM");
7535 return error::kNoError; 7690 return error::kNoError;
7536 } 7691 }
7537 if (width < 0) { 7692 if (width < 0) {
7538 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: width < 0"); 7693 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "width < 0");
7539 return error::kNoError; 7694 return error::kNoError;
7540 } 7695 }
7541 if (height < 0) { 7696 if (height < 0) {
7542 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: height < 0"); 7697 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "height < 0");
7543 return error::kNoError; 7698 return error::kNoError;
7544 } 7699 }
7545 if (!validators_->texture_format.IsValid(format)) { 7700 if (!validators_->texture_format.IsValid(format)) {
7546 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: format GL_INVALID_ENUM"); 7701 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D", "format GL_INVALID_ENUM");
7547 return error::kNoError; 7702 return error::kNoError;
7548 } 7703 }
7549 if (!validators_->pixel_type.IsValid(type)) { 7704 if (!validators_->pixel_type.IsValid(type)) {
7550 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D: type GL_INVALID_ENUM"); 7705 SetGLError(GL_INVALID_ENUM, "glTexSubImage2D", "type GL_INVALID_ENUM");
7551 return error::kNoError; 7706 return error::kNoError;
7552 } 7707 }
7553 if (pixels == NULL) { 7708 if (pixels == NULL) {
7554 return error::kOutOfBounds; 7709 return error::kOutOfBounds;
7555 } 7710 }
7556 DoTexSubImage2D( 7711 DoTexSubImage2D(
7557 target, level, xoffset, yoffset, width, height, format, type, pixels); 7712 target, level, xoffset, yoffset, width, height, format, type, pixels);
7558 return error::kNoError; 7713 return error::kNoError;
7559 } 7714 }
7560 7715
7561 error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv( 7716 error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv(
7562 uint32 immediate_data_size, const gles2::GetVertexAttribPointerv& c) { 7717 uint32 immediate_data_size, const gles2::GetVertexAttribPointerv& c) {
7563 GLuint index = static_cast<GLuint>(c.index); 7718 GLuint index = static_cast<GLuint>(c.index);
7564 GLenum pname = static_cast<GLenum>(c.pname); 7719 GLenum pname = static_cast<GLenum>(c.pname);
7565 typedef gles2::GetVertexAttribPointerv::Result Result; 7720 typedef gles2::GetVertexAttribPointerv::Result Result;
7566 Result* result = GetSharedMemoryAs<Result*>( 7721 Result* result = GetSharedMemoryAs<Result*>(
7567 c.pointer_shm_id, c.pointer_shm_offset, Result::ComputeSize(1)); 7722 c.pointer_shm_id, c.pointer_shm_offset, Result::ComputeSize(1));
7568 if (!result) { 7723 if (!result) {
7569 return error::kOutOfBounds; 7724 return error::kOutOfBounds;
7570 } 7725 }
7571 // Check that the client initialized the result. 7726 // Check that the client initialized the result.
7572 if (result->size != 0) { 7727 if (result->size != 0) {
7573 return error::kInvalidArguments; 7728 return error::kInvalidArguments;
7574 } 7729 }
7575 if (!validators_->vertex_pointer.IsValid(pname)) { 7730 if (!validators_->vertex_pointer.IsValid(pname)) {
7576 SetGLError(GL_INVALID_ENUM, 7731 SetGLError(GL_INVALID_ENUM,
7577 "glGetVertexAttribPointerv: pname GL_INVALID_ENUM"); 7732 "glGetVertexAttribPointerv", "pname GL_INVALID_ENUM");
7578 return error::kNoError; 7733 return error::kNoError;
7579 } 7734 }
7580 if (index >= group_->max_vertex_attribs()) { 7735 if (index >= group_->max_vertex_attribs()) {
7581 SetGLError(GL_INVALID_VALUE, 7736 SetGLError(GL_INVALID_VALUE,
7582 "glGetVertexAttribPointerv: index out of range."); 7737 "glGetVertexAttribPointerv", "index out of range.");
7583 return error::kNoError; 7738 return error::kNoError;
7584 } 7739 }
7585 result->SetNumResults(1); 7740 result->SetNumResults(1);
7586 *result->GetData() = 7741 *result->GetData() =
7587 vertex_attrib_manager_->GetVertexAttribInfo(index)->offset(); 7742 vertex_attrib_manager_->GetVertexAttribInfo(index)->offset();
7588 return error::kNoError; 7743 return error::kNoError;
7589 } 7744 }
7590 7745
7591 bool GLES2DecoderImpl::GetUniformSetup( 7746 bool GLES2DecoderImpl::GetUniformSetup(
7592 GLuint program, GLint fake_location, 7747 GLuint program, GLint fake_location,
(...skipping 17 matching lines...) Expand all
7610 *result_pointer = result; 7765 *result_pointer = result;
7611 // Set the result size to 0 so the client does not have to check for success. 7766 // Set the result size to 0 so the client does not have to check for success.
7612 result->SetNumResults(0); 7767 result->SetNumResults(0);
7613 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 7768 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
7614 program, "glGetUniform"); 7769 program, "glGetUniform");
7615 if (!info) { 7770 if (!info) {
7616 return false; 7771 return false;
7617 } 7772 }
7618 if (!info->IsValid()) { 7773 if (!info->IsValid()) {
7619 // Program was not linked successfully. (ie, glLinkProgram) 7774 // Program was not linked successfully. (ie, glLinkProgram)
7620 SetGLError(GL_INVALID_OPERATION, "glGetUniform: program not linked"); 7775 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "program not linked");
7621 return false; 7776 return false;
7622 } 7777 }
7623 *service_id = info->service_id(); 7778 *service_id = info->service_id();
7624 GLint array_index = -1; 7779 GLint array_index = -1;
7625 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 7780 const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
7626 info->GetUniformInfoByFakeLocation( 7781 info->GetUniformInfoByFakeLocation(
7627 fake_location, real_location, &array_index); 7782 fake_location, real_location, &array_index);
7628 if (!uniform_info) { 7783 if (!uniform_info) {
7629 // No such location. 7784 // No such location.
7630 SetGLError(GL_INVALID_OPERATION, "glGetUniform: unknown location"); 7785 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "unknown location");
7631 return false; 7786 return false;
7632 } 7787 }
7633 GLenum type = uniform_info->type; 7788 GLenum type = uniform_info->type;
7634 GLsizei size = GLES2Util::GetGLDataTypeSizeForUniforms(type); 7789 GLsizei size = GLES2Util::GetGLDataTypeSizeForUniforms(type);
7635 if (size == 0) { 7790 if (size == 0) {
7636 SetGLError(GL_INVALID_OPERATION, "glGetUniform: unknown type"); 7791 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "unknown type");
7637 return false; 7792 return false;
7638 } 7793 }
7639 result = GetSharedMemoryAs<SizedResult<GLint>*>( 7794 result = GetSharedMemoryAs<SizedResult<GLint>*>(
7640 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size)); 7795 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size));
7641 if (!result) { 7796 if (!result) {
7642 *error = error::kOutOfBounds; 7797 *error = error::kOutOfBounds;
7643 return false; 7798 return false;
7644 } 7799 }
7645 result->size = size; 7800 result->size = size;
7646 *result_type = type; 7801 *result_type = type;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
7705 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 7860 c.result_shm_id, c.result_shm_offset, sizeof(*result));
7706 if (!result) { 7861 if (!result) {
7707 return error::kOutOfBounds; 7862 return error::kOutOfBounds;
7708 } 7863 }
7709 // Check that the client initialized the result. 7864 // Check that the client initialized the result.
7710 if (result->success != 0) { 7865 if (result->success != 0) {
7711 return error::kInvalidArguments; 7866 return error::kInvalidArguments;
7712 } 7867 }
7713 if (!validators_->shader_type.IsValid(shader_type)) { 7868 if (!validators_->shader_type.IsValid(shader_type)) {
7714 SetGLError(GL_INVALID_ENUM, 7869 SetGLError(GL_INVALID_ENUM,
7715 "glGetShaderPrecisionFormat: shader_type GL_INVALID_ENUM"); 7870 "glGetShaderPrecisionFormat", "shader_type GL_INVALID_ENUM");
7716 return error::kNoError; 7871 return error::kNoError;
7717 } 7872 }
7718 if (!validators_->shader_precision.IsValid(precision_type)) { 7873 if (!validators_->shader_precision.IsValid(precision_type)) {
7719 SetGLError(GL_INVALID_ENUM, 7874 SetGLError(GL_INVALID_ENUM,
7720 "glGetShaderPrecisionFormat: precision_type GL_INVALID_ENUM"); 7875 "glGetShaderPrecisionFormat", "precision_type GL_INVALID_ENUM");
7721 return error::kNoError; 7876 return error::kNoError;
7722 } 7877 }
7723 7878
7724 result->success = 1; // true 7879 result->success = 1; // true
7725 switch (precision_type) { 7880 switch (precision_type) {
7726 case GL_LOW_INT: 7881 case GL_LOW_INT:
7727 case GL_MEDIUM_INT: 7882 case GL_MEDIUM_INT:
7728 case GL_HIGH_INT: 7883 case GL_HIGH_INT:
7729 // These values are for a 32-bit twos-complement integer format. 7884 // These values are for a 32-bit twos-complement integer format.
7730 result->min_range = 31; 7885 result->min_range = 31;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
7796 return error::kInvalidArguments; 7951 return error::kInvalidArguments;
7797 } 7952 }
7798 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 7953 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
7799 program, "glGetActiveUniform"); 7954 program, "glGetActiveUniform");
7800 if (!info) { 7955 if (!info) {
7801 return error::kNoError; 7956 return error::kNoError;
7802 } 7957 }
7803 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 7958 const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
7804 info->GetUniformInfo(index); 7959 info->GetUniformInfo(index);
7805 if (!uniform_info) { 7960 if (!uniform_info) {
7806 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: index out of range"); 7961 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform", "index out of range");
7807 return error::kNoError; 7962 return error::kNoError;
7808 } 7963 }
7809 result->success = 1; // true. 7964 result->success = 1; // true.
7810 result->size = uniform_info->size; 7965 result->size = uniform_info->size;
7811 result->type = uniform_info->type; 7966 result->type = uniform_info->type;
7812 Bucket* bucket = CreateBucket(name_bucket_id); 7967 Bucket* bucket = CreateBucket(name_bucket_id);
7813 bucket->SetFromString(uniform_info->name.c_str()); 7968 bucket->SetFromString(uniform_info->name.c_str());
7814 return error::kNoError; 7969 return error::kNoError;
7815 } 7970 }
7816 7971
(...skipping 13 matching lines...) Expand all
7830 return error::kInvalidArguments; 7985 return error::kInvalidArguments;
7831 } 7986 }
7832 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 7987 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
7833 program, "glGetActiveAttrib"); 7988 program, "glGetActiveAttrib");
7834 if (!info) { 7989 if (!info) {
7835 return error::kNoError; 7990 return error::kNoError;
7836 } 7991 }
7837 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 7992 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info =
7838 info->GetAttribInfo(index); 7993 info->GetAttribInfo(index);
7839 if (!attrib_info) { 7994 if (!attrib_info) {
7840 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: index out of range"); 7995 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib", "index out of range");
7841 return error::kNoError; 7996 return error::kNoError;
7842 } 7997 }
7843 result->success = 1; // true. 7998 result->success = 1; // true.
7844 result->size = attrib_info->size; 7999 result->size = attrib_info->size;
7845 result->type = attrib_info->type; 8000 result->type = attrib_info->type;
7846 Bucket* bucket = CreateBucket(name_bucket_id); 8001 Bucket* bucket = CreateBucket(name_bucket_id);
7847 bucket->SetFromString(attrib_info->name.c_str()); 8002 bucket->SetFromString(attrib_info->name.c_str());
7848 return error::kNoError; 8003 return error::kNoError;
7849 } 8004 }
7850 8005
7851 error::Error GLES2DecoderImpl::HandleShaderBinary( 8006 error::Error GLES2DecoderImpl::HandleShaderBinary(
7852 uint32 immediate_data_size, const gles2::ShaderBinary& c) { 8007 uint32 immediate_data_size, const gles2::ShaderBinary& c) {
7853 #if 1 // No binary shader support. 8008 #if 1 // No binary shader support.
7854 SetGLError(GL_INVALID_OPERATION, "glShaderBinary: not supported"); 8009 SetGLError(GL_INVALID_OPERATION, "glShaderBinary", "not supported");
7855 return error::kNoError; 8010 return error::kNoError;
7856 #else 8011 #else
7857 GLsizei n = static_cast<GLsizei>(c.n); 8012 GLsizei n = static_cast<GLsizei>(c.n);
7858 if (n < 0) { 8013 if (n < 0) {
7859 SetGLError(GL_INVALID_VALUE, "glShaderBinary: n < 0"); 8014 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "n < 0");
7860 return error::kNoError; 8015 return error::kNoError;
7861 } 8016 }
7862 GLsizei length = static_cast<GLsizei>(c.length); 8017 GLsizei length = static_cast<GLsizei>(c.length);
7863 if (length < 0) { 8018 if (length < 0) {
7864 SetGLError(GL_INVALID_VALUE, "glShaderBinary: length < 0"); 8019 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "length < 0");
7865 return error::kNoError; 8020 return error::kNoError;
7866 } 8021 }
7867 uint32 data_size; 8022 uint32 data_size;
7868 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 8023 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
7869 return error::kOutOfBounds; 8024 return error::kOutOfBounds;
7870 } 8025 }
7871 const GLuint* shaders = GetSharedMemoryAs<const GLuint*>( 8026 const GLuint* shaders = GetSharedMemoryAs<const GLuint*>(
7872 c.shaders_shm_id, c.shaders_shm_offset, data_size); 8027 c.shaders_shm_id, c.shaders_shm_offset, data_size);
7873 GLenum binaryformat = static_cast<GLenum>(c.binaryformat); 8028 GLenum binaryformat = static_cast<GLenum>(c.binaryformat);
7874 const void* binary = GetSharedMemoryAs<const void*>( 8029 const void* binary = GetSharedMemoryAs<const void*>(
7875 c.binary_shm_id, c.binary_shm_offset, length); 8030 c.binary_shm_id, c.binary_shm_offset, length);
7876 if (shaders == NULL || binary == NULL) { 8031 if (shaders == NULL || binary == NULL) {
7877 return error::kOutOfBounds; 8032 return error::kOutOfBounds;
7878 } 8033 }
7879 scoped_array<GLuint> service_ids(new GLuint[n]); 8034 scoped_array<GLuint> service_ids(new GLuint[n]);
7880 for (GLsizei ii = 0; ii < n; ++ii) { 8035 for (GLsizei ii = 0; ii < n; ++ii) {
7881 ShaderManager::ShaderInfo* info = GetShaderInfo(shaders[ii]); 8036 ShaderManager::ShaderInfo* info = GetShaderInfo(shaders[ii]);
7882 if (!info) { 8037 if (!info) {
7883 SetGLError(GL_INVALID_VALUE, "glShaderBinary: unknown shader"); 8038 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "unknown shader");
7884 return error::kNoError; 8039 return error::kNoError;
7885 } 8040 }
7886 service_ids[ii] = info->service_id(); 8041 service_ids[ii] = info->service_id();
7887 } 8042 }
7888 // TODO(gman): call glShaderBinary 8043 // TODO(gman): call glShaderBinary
7889 return error::kNoError; 8044 return error::kNoError;
7890 #endif 8045 #endif
7891 } 8046 }
7892 8047
7893 error::Error GLES2DecoderImpl::HandleSwapBuffers( 8048 error::Error GLES2DecoderImpl::HandleSwapBuffers(
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
8105 // them. 8260 // them.
8106 scoped_array<GLenum> enums(new GLenum[count]); 8261 scoped_array<GLenum> enums(new GLenum[count]);
8107 memcpy(enums.get(), pnames, pnames_size); 8262 memcpy(enums.get(), pnames, pnames_size);
8108 8263
8109 // Count up the space needed for the result. 8264 // Count up the space needed for the result.
8110 uint32 num_results = 0; 8265 uint32 num_results = 0;
8111 for (GLuint ii = 0; ii < count; ++ii) { 8266 for (GLuint ii = 0; ii < count; ++ii) {
8112 uint32 num = util_.GLGetNumValuesReturned(enums[ii]); 8267 uint32 num = util_.GLGetNumValuesReturned(enums[ii]);
8113 if (num == 0) { 8268 if (num == 0) {
8114 SetGLError(GL_INVALID_ENUM, 8269 SetGLError(GL_INVALID_ENUM,
8115 "glGetMulitpleCHROMIUM: pname GL_INVALID_ENUM"); 8270 "glGetMulitpleCHROMIUM", "pname GL_INVALID_ENUM");
8116 return error::kNoError; 8271 return error::kNoError;
8117 } 8272 }
8118 // Num will never be more than 4. 8273 // Num will never be more than 4.
8119 DCHECK_LE(num, 4u); 8274 DCHECK_LE(num, 4u);
8120 if (!SafeAdd(num_results, num, &num_results)) { 8275 if (!SafeAdd(num_results, num, &num_results)) {
8121 return error::kOutOfBounds; 8276 return error::kOutOfBounds;
8122 } 8277 }
8123 } 8278 }
8124 8279
8125 uint32 result_size = 0; 8280 uint32 result_size = 0;
8126 if (!SafeMultiplyUint32(num_results, sizeof(GLint), &result_size)) { 8281 if (!SafeMultiplyUint32(num_results, sizeof(GLint), &result_size)) {
8127 return error::kOutOfBounds; 8282 return error::kOutOfBounds;
8128 } 8283 }
8129 8284
8130 if (result_size != static_cast<uint32>(c.size)) { 8285 if (result_size != static_cast<uint32>(c.size)) {
8131 SetGLError(GL_INVALID_VALUE, 8286 SetGLError(GL_INVALID_VALUE,
8132 "glGetMulitpleCHROMIUM: bad size GL_INVALID_VALUE"); 8287 "glGetMulitpleCHROMIUM", "bad size GL_INVALID_VALUE");
8133 return error::kNoError; 8288 return error::kNoError;
8134 } 8289 }
8135 8290
8136 GLint* results = GetSharedMemoryAs<GLint*>( 8291 GLint* results = GetSharedMemoryAs<GLint*>(
8137 c.results_shm_id, c.results_shm_offset, result_size); 8292 c.results_shm_id, c.results_shm_offset, result_size);
8138 if (results == NULL) { 8293 if (results == NULL) {
8139 return error::kOutOfBounds; 8294 return error::kOutOfBounds;
8140 } 8295 }
8141 8296
8142 // Check the results have been cleared in case the context was lost. 8297 // Check the results have been cleared in case the context was lost.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
8252 GLenum target = static_cast<GLenum>(c.target); 8407 GLenum target = static_cast<GLenum>(c.target);
8253 GLuint client_id = static_cast<GLuint>(c.id); 8408 GLuint client_id = static_cast<GLuint>(c.id);
8254 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id); 8409 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id);
8255 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); 8410 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset);
8256 8411
8257 switch (target) { 8412 switch (target) {
8258 case GL_COMMANDS_ISSUED_CHROMIUM: 8413 case GL_COMMANDS_ISSUED_CHROMIUM:
8259 break; 8414 break;
8260 default: 8415 default:
8261 if (!feature_info_->feature_flags().occlusion_query_boolean) { 8416 if (!feature_info_->feature_flags().occlusion_query_boolean) {
8262 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: not enabled"); 8417 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "not enabled");
8263 return error::kNoError; 8418 return error::kNoError;
8264 } 8419 }
8265 break; 8420 break;
8266 } 8421 }
8267 8422
8268 if (current_query_) { 8423 if (current_query_) {
8269 SetGLError( 8424 SetGLError(
8270 GL_INVALID_OPERATION, "glBeginQueryEXT: query already in progress"); 8425 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress");
8271 return error::kNoError; 8426 return error::kNoError;
8272 } 8427 }
8273 8428
8274 if (client_id == 0) { 8429 if (client_id == 0) {
8275 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: id is 0"); 8430 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0");
8276 return error::kNoError; 8431 return error::kNoError;
8277 } 8432 }
8278 8433
8279 QueryManager::Query* query = query_manager_->GetQuery(client_id); 8434 QueryManager::Query* query = query_manager_->GetQuery(client_id);
8280 if (!query) { 8435 if (!query) {
8281 // TODO(gman): Decide if we need this check. 8436 // TODO(gman): Decide if we need this check.
8282 // 8437 //
8283 // Checks id was made by glGenQueries 8438 // Checks id was made by glGenQueries
8284 // 8439 //
8285 // From the POV of OpenGL ES 2.0 you need to call glGenQueriesEXT 8440 // From the POV of OpenGL ES 2.0 you need to call glGenQueriesEXT
8286 // for all Query ids but from the POV of the command buffer service maybe 8441 // for all Query ids but from the POV of the command buffer service maybe
8287 // you don't. 8442 // you don't.
8288 // 8443 //
8289 // The client can enforce this. I don't think the service cares. 8444 // The client can enforce this. I don't think the service cares.
8290 // 8445 //
8291 // IdAllocatorInterface* id_allocator = 8446 // IdAllocatorInterface* id_allocator =
8292 // group_->GetIdAllocator(id_namespaces::kQueries); 8447 // group_->GetIdAllocator(id_namespaces::kQueries);
8293 // if (!id_allocator->InUse(client_id)) { 8448 // if (!id_allocator->InUse(client_id)) {
8294 // SetGLError(GL_INVALID_OPERATION, 8449 // SetGLError(GL_INVALID_OPERATION,
8295 // "glBeginQueryEXT: id not made by glGenQueriesEXT"); 8450 // "glBeginQueryEXT", "id not made by glGenQueriesEXT");
8296 // return error::kNoError; 8451 // return error::kNoError;
8297 // } 8452 // }
8298 query = query_manager_->CreateQuery( 8453 query = query_manager_->CreateQuery(
8299 target, client_id, sync_shm_id, sync_shm_offset); 8454 target, client_id, sync_shm_id, sync_shm_offset);
8300 } 8455 }
8301 8456
8302 if (query->target() != target) { 8457 if (query->target() != target) {
8303 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: target does not match"); 8458 SetGLError(
8459 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match");
8304 return error::kNoError; 8460 return error::kNoError;
8305 } else if (query->shm_id() != sync_shm_id || 8461 } else if (query->shm_id() != sync_shm_id ||
8306 query->shm_offset() != sync_shm_offset) { 8462 query->shm_offset() != sync_shm_offset) {
8307 DLOG(ERROR) << "Shared memory used by query not the same as before"; 8463 DLOG(ERROR) << "Shared memory used by query not the same as before";
8308 return error::kInvalidArguments; 8464 return error::kInvalidArguments;
8309 } 8465 }
8310 8466
8311 if (!query_manager_->BeginQuery(query)) { 8467 if (!query_manager_->BeginQuery(query)) {
8312 return error::kOutOfBounds; 8468 return error::kOutOfBounds;
8313 } 8469 }
8314 8470
8315 current_query_ = query; 8471 current_query_ = query;
8316 return error::kNoError; 8472 return error::kNoError;
8317 } 8473 }
8318 8474
8319 error::Error GLES2DecoderImpl::HandleEndQueryEXT( 8475 error::Error GLES2DecoderImpl::HandleEndQueryEXT(
8320 uint32 immediate_data_size, const gles2::EndQueryEXT& c) { 8476 uint32 immediate_data_size, const gles2::EndQueryEXT& c) {
8321 GLenum target = static_cast<GLenum>(c.target); 8477 GLenum target = static_cast<GLenum>(c.target);
8322 uint32 submit_count = static_cast<GLuint>(c.submit_count); 8478 uint32 submit_count = static_cast<GLuint>(c.submit_count);
8323 8479
8324 if (!current_query_) { 8480 if (!current_query_) {
8325 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT: No active query"); 8481 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "No active query");
8326 return error::kNoError; 8482 return error::kNoError;
8327 } 8483 }
8328 if (current_query_->target() != target) { 8484 if (current_query_->target() != target) {
8329 SetGLError(GL_INVALID_OPERATION, 8485 SetGLError(GL_INVALID_OPERATION,
8330 "glEndQueryEXT: target does not match active query"); 8486 "glEndQueryEXT", "target does not match active query");
8331 return error::kNoError; 8487 return error::kNoError;
8332 } 8488 }
8333 8489
8334 if (!query_manager_->EndQuery(current_query_, submit_count)) { 8490 if (!query_manager_->EndQuery(current_query_, submit_count)) {
8335 return error::kOutOfBounds; 8491 return error::kOutOfBounds;
8336 } 8492 }
8337 8493
8338 current_query_ = NULL; 8494 current_query_ = NULL;
8339 return error::kNoError; 8495 return error::kNoError;
8340 } 8496 }
8341 8497
8342 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM( 8498 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM(
8343 uint32 immediate_data_size, 8499 uint32 immediate_data_size,
8344 const gles2::CreateStreamTextureCHROMIUM& c) { 8500 const gles2::CreateStreamTextureCHROMIUM& c) {
8345 if (!feature_info_->feature_flags().chromium_stream_texture) { 8501 if (!feature_info_->feature_flags().chromium_stream_texture) {
8346 SetGLError(GL_INVALID_OPERATION, 8502 SetGLError(GL_INVALID_OPERATION,
8347 "glOpenStreamTextureCHROMIUM: " 8503 "glOpenStreamTextureCHROMIUM", ""
8348 "not supported."); 8504 "not supported.");
8349 return error::kNoError; 8505 return error::kNoError;
8350 } 8506 }
8351 8507
8352 uint32 client_id = c.client_id; 8508 uint32 client_id = c.client_id;
8353 typedef gles2::CreateStreamTextureCHROMIUM::Result Result; 8509 typedef gles2::CreateStreamTextureCHROMIUM::Result Result;
8354 Result* result = GetSharedMemoryAs<Result*>( 8510 Result* result = GetSharedMemoryAs<Result*>(
8355 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 8511 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8356 8512
8357 if (!result) 8513 if (!result)
8358 return error::kOutOfBounds; 8514 return error::kOutOfBounds;
8359 *result = GL_ZERO; 8515 *result = GL_ZERO;
8360 TextureManager::TextureInfo* info = 8516 TextureManager::TextureInfo* info =
8361 texture_manager()->GetTextureInfo(client_id); 8517 texture_manager()->GetTextureInfo(client_id);
8362 if (!info) { 8518 if (!info) {
8363 SetGLError(GL_INVALID_VALUE, 8519 SetGLError(GL_INVALID_VALUE,
8364 "glCreateStreamTextureCHROMIUM: " 8520 "glCreateStreamTextureCHROMIUM", ""
8365 "bad texture id."); 8521 "bad texture id.");
8366 return error::kNoError; 8522 return error::kNoError;
8367 } 8523 }
8368 8524
8369 if (info->IsStreamTexture()) { 8525 if (info->IsStreamTexture()) {
8370 SetGLError(GL_INVALID_OPERATION, 8526 SetGLError(GL_INVALID_OPERATION,
8371 "glCreateStreamTextureCHROMIUM: " 8527 "glCreateStreamTextureCHROMIUM", ""
8372 "is already a stream texture."); 8528 "is already a stream texture.");
8373 return error::kNoError; 8529 return error::kNoError;
8374 } 8530 }
8375 8531
8376 if (info->target() && info->target() != GL_TEXTURE_EXTERNAL_OES) { 8532 if (info->target() && info->target() != GL_TEXTURE_EXTERNAL_OES) {
8377 SetGLError(GL_INVALID_OPERATION, 8533 SetGLError(GL_INVALID_OPERATION,
8378 "glCreateStreamTextureCHROMIUM: " 8534 "glCreateStreamTextureCHROMIUM", ""
8379 "is already bound to incompatible target."); 8535 "is already bound to incompatible target.");
8380 return error::kNoError; 8536 return error::kNoError;
8381 } 8537 }
8382 8538
8383 if (!stream_texture_manager_) 8539 if (!stream_texture_manager_)
8384 return error::kInvalidArguments; 8540 return error::kInvalidArguments;
8385 8541
8386 GLuint object_id = stream_texture_manager_->CreateStreamTexture( 8542 GLuint object_id = stream_texture_manager_->CreateStreamTexture(
8387 info->service_id(), client_id); 8543 info->service_id(), client_id);
8388 8544
8389 if (object_id) { 8545 if (object_id) {
8390 info->SetStreamTexture(true); 8546 info->SetStreamTexture(true);
8391 } else { 8547 } else {
8392 SetGLError(GL_OUT_OF_MEMORY, 8548 SetGLError(GL_OUT_OF_MEMORY,
8393 "glCreateStreamTextureCHROMIUM: " 8549 "glCreateStreamTextureCHROMIUM", ""
8394 "failed to create platform texture."); 8550 "failed to create platform texture.");
8395 } 8551 }
8396 8552
8397 *result = object_id; 8553 *result = object_id;
8398 return error::kNoError; 8554 return error::kNoError;
8399 } 8555 }
8400 8556
8401 error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM( 8557 error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM(
8402 uint32 immediate_data_size, 8558 uint32 immediate_data_size,
8403 const gles2::DestroyStreamTextureCHROMIUM& c) { 8559 const gles2::DestroyStreamTextureCHROMIUM& c) {
8404 GLuint client_id = c.texture; 8560 GLuint client_id = c.texture;
8405 TextureManager::TextureInfo* info = 8561 TextureManager::TextureInfo* info =
8406 texture_manager()->GetTextureInfo(client_id); 8562 texture_manager()->GetTextureInfo(client_id);
8407 if (info && info->IsStreamTexture()) { 8563 if (info && info->IsStreamTexture()) {
8408 if (!stream_texture_manager_) 8564 if (!stream_texture_manager_)
8409 return error::kInvalidArguments; 8565 return error::kInvalidArguments;
8410 8566
8411 stream_texture_manager_->DestroyStreamTexture(info->service_id()); 8567 stream_texture_manager_->DestroyStreamTexture(info->service_id());
8412 info->SetStreamTexture(false); 8568 info->SetStreamTexture(false);
8413 texture_manager()->SetInfoTarget(info, 0); 8569 texture_manager()->SetInfoTarget(info, 0);
8414 } else { 8570 } else {
8415 SetGLError(GL_INVALID_VALUE, 8571 SetGLError(GL_INVALID_VALUE,
8416 "glDestroyStreamTextureCHROMIUM: bad texture id."); 8572 "glDestroyStreamTextureCHROMIUM", "bad texture id.");
8417 } 8573 }
8418 8574
8419 return error::kNoError; 8575 return error::kNoError;
8420 } 8576 }
8421 8577
8422 #if defined(OS_MACOSX) 8578 #if defined(OS_MACOSX)
8423 void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) { 8579 void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) {
8424 TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find( 8580 TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find(
8425 texture_id); 8581 texture_id);
8426 if (it != texture_to_io_surface_map_.end()) { 8582 if (it != texture_to_io_surface_map_.end()) {
8427 // Found a previous IOSurface bound to this texture; release it. 8583 // Found a previous IOSurface bound to this texture; release it.
8428 CFTypeRef surface = it->second; 8584 CFTypeRef surface = it->second;
8429 CFRelease(surface); 8585 CFRelease(surface);
8430 texture_to_io_surface_map_.erase(it); 8586 texture_to_io_surface_map_.erase(it);
8431 } 8587 }
8432 } 8588 }
8433 #endif 8589 #endif
8434 8590
8435 void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM( 8591 void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM(
8436 GLenum target, GLsizei width, GLsizei height, 8592 GLenum target, GLsizei width, GLsizei height,
8437 GLuint io_surface_id, GLuint plane) { 8593 GLuint io_surface_id, GLuint plane) {
8438 #if defined(OS_MACOSX) 8594 #if defined(OS_MACOSX)
8439 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) { 8595 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) {
8440 SetGLError(GL_INVALID_OPERATION, 8596 SetGLError(
8441 "glTexImageIOSurface2DCHROMIUM: only supported on desktop GL."); 8597 GL_INVALID_OPERATION,
8598 "glTexImageIOSurface2DCHROMIUM", "only supported on desktop GL.");
8442 return; 8599 return;
8443 } 8600 }
8444 8601
8445 IOSurfaceSupport* surface_support = IOSurfaceSupport::Initialize(); 8602 IOSurfaceSupport* surface_support = IOSurfaceSupport::Initialize();
8446 if (!surface_support) { 8603 if (!surface_support) {
8447 SetGLError(GL_INVALID_OPERATION, 8604 SetGLError(GL_INVALID_OPERATION,
8448 "glTexImageIOSurface2DCHROMIUM: only supported on 10.6."); 8605 "glTexImageIOSurface2DCHROMIUM", "only supported on 10.6.");
8449 return; 8606 return;
8450 } 8607 }
8451 8608
8452 if (target != GL_TEXTURE_RECTANGLE_ARB) { 8609 if (target != GL_TEXTURE_RECTANGLE_ARB) {
8453 // This might be supported in the future, and if we could require 8610 // This might be supported in the future, and if we could require
8454 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we 8611 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we
8455 // could delete a lot of code. For now, perform strict validation so we 8612 // could delete a lot of code. For now, perform strict validation so we
8456 // know what's going on. 8613 // know what's going on.
8457 SetGLError( 8614 SetGLError(
8458 GL_INVALID_OPERATION, 8615 GL_INVALID_OPERATION,
8459 "glTexImageIOSurface2DCHROMIUM: requires TEXTURE_RECTANGLE_ARB target"); 8616 "glTexImageIOSurface2DCHROMIUM",
8617 "requires TEXTURE_RECTANGLE_ARB target");
8460 return; 8618 return;
8461 } 8619 }
8462 8620
8463 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8621 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
8464 if (!info) { 8622 if (!info) {
8465 SetGLError(GL_INVALID_OPERATION, 8623 SetGLError(GL_INVALID_OPERATION,
8466 "glTexImageIOSurface2DCHROMIUM: no rectangle texture bound"); 8624 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound");
8467 return; 8625 return;
8468 } 8626 }
8469 if (info == texture_manager()->GetDefaultTextureInfo(target)) { 8627 if (info == texture_manager()->GetDefaultTextureInfo(target)) {
8470 // Maybe this is conceptually valid, but disallow it to avoid accidents. 8628 // Maybe this is conceptually valid, but disallow it to avoid accidents.
8471 SetGLError(GL_INVALID_OPERATION, 8629 SetGLError(GL_INVALID_OPERATION,
8472 "glTexImageIOSurface2DCHROMIUM: can't bind default texture"); 8630 "glTexImageIOSurface2DCHROMIUM", "can't bind default texture");
8473 return; 8631 return;
8474 } 8632 }
8475 8633
8476 // Look up the new IOSurface. Note that because of asynchrony 8634 // Look up the new IOSurface. Note that because of asynchrony
8477 // between processes this might fail; during live resizing the 8635 // between processes this might fail; during live resizing the
8478 // plugin process might allocate and release an IOSurface before 8636 // plugin process might allocate and release an IOSurface before
8479 // this process gets a chance to look it up. Hold on to any old 8637 // this process gets a chance to look it up. Hold on to any old
8480 // IOSurface in this case. 8638 // IOSurface in this case.
8481 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id); 8639 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id);
8482 if (!surface) { 8640 if (!surface) {
8483 SetGLError(GL_INVALID_OPERATION, 8641 SetGLError(
8484 "glTexImageIOSurface2DCHROMIUM: no IOSurface with the given ID"); 8642 GL_INVALID_OPERATION,
8643 "glTexImageIOSurface2DCHROMIUM", "no IOSurface with the given ID");
8485 return; 8644 return;
8486 } 8645 }
8487 8646
8488 // Release any IOSurface previously bound to this texture. 8647 // Release any IOSurface previously bound to this texture.
8489 ReleaseIOSurfaceForTexture(info->service_id()); 8648 ReleaseIOSurfaceForTexture(info->service_id());
8490 8649
8491 // Make sure we release the IOSurface even if CGLTexImageIOSurface2D fails. 8650 // Make sure we release the IOSurface even if CGLTexImageIOSurface2D fails.
8492 texture_to_io_surface_map_.insert( 8651 texture_to_io_surface_map_.insert(
8493 std::make_pair(info->service_id(), surface)); 8652 std::make_pair(info->service_id(), surface));
8494 8653
8495 CGLContextObj context = 8654 CGLContextObj context =
8496 static_cast<CGLContextObj>(context_->GetHandle()); 8655 static_cast<CGLContextObj>(context_->GetHandle());
8497 8656
8498 CGLError err = surface_support->CGLTexImageIOSurface2D( 8657 CGLError err = surface_support->CGLTexImageIOSurface2D(
8499 context, 8658 context,
8500 target, 8659 target,
8501 GL_RGBA, 8660 GL_RGBA,
8502 width, 8661 width,
8503 height, 8662 height,
8504 GL_BGRA, 8663 GL_BGRA,
8505 GL_UNSIGNED_INT_8_8_8_8_REV, 8664 GL_UNSIGNED_INT_8_8_8_8_REV,
8506 surface, 8665 surface,
8507 plane); 8666 plane);
8508 8667
8509 if (err != kCGLNoError) { 8668 if (err != kCGLNoError) {
8510 SetGLError( 8669 SetGLError(
8511 GL_INVALID_OPERATION, 8670 GL_INVALID_OPERATION,
8512 "glTexImageIOSurface2DCHROMIUM: error in CGLTexImageIOSurface2D"); 8671 "glTexImageIOSurface2DCHROMIUM", "error in CGLTexImageIOSurface2D");
8513 return; 8672 return;
8514 } 8673 }
8515 8674
8516 texture_manager()->SetLevelInfo( 8675 texture_manager()->SetLevelInfo(
8517 info, target, 0, GL_RGBA, width, height, 1, 0, 8676 info, target, 0, GL_RGBA, width, height, 1, 0,
8518 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true); 8677 GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true);
8519 8678
8520 #else 8679 #else
8521 SetGLError(GL_INVALID_OPERATION, 8680 SetGLError(GL_INVALID_OPERATION,
8522 "glTexImageIOSurface2DCHROMIUM: not supported."); 8681 "glTexImageIOSurface2DCHROMIUM", "not supported.");
8523 #endif 8682 #endif
8524 } 8683 }
8525 8684
8526 static GLenum ExtractFormatFromStorageFormat(GLenum internalformat) { 8685 static GLenum ExtractFormatFromStorageFormat(GLenum internalformat) {
8527 switch (internalformat) { 8686 switch (internalformat) {
8528 case GL_RGB565: 8687 case GL_RGB565:
8529 return GL_RGB; 8688 return GL_RGB;
8530 case GL_RGBA4: 8689 case GL_RGBA4:
8531 return GL_RGBA; 8690 return GL_RGBA;
8532 case GL_RGB5_A1: 8691 case GL_RGB5_A1:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
8568 } 8727 }
8569 } 8728 }
8570 8729
8571 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( 8730 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
8572 GLenum target, GLuint source_id, GLuint dest_id, GLint level, 8731 GLenum target, GLuint source_id, GLuint dest_id, GLint level,
8573 GLenum internal_format) { 8732 GLenum internal_format) {
8574 TextureManager::TextureInfo* dest_info = GetTextureInfo(dest_id); 8733 TextureManager::TextureInfo* dest_info = GetTextureInfo(dest_id);
8575 TextureManager::TextureInfo* source_info = GetTextureInfo(source_id); 8734 TextureManager::TextureInfo* source_info = GetTextureInfo(source_id);
8576 8735
8577 if (!source_info || !dest_info) { 8736 if (!source_info || !dest_info) {
8578 SetGLError(GL_INVALID_VALUE, "glCopyTextureCHROMIUM: unknown texture id"); 8737 SetGLError(GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id");
8579 return; 8738 return;
8580 } 8739 }
8581 8740
8582 if (GL_TEXTURE_2D != target) { 8741 if (GL_TEXTURE_2D != target) {
8583 SetGLError(GL_INVALID_VALUE, 8742 SetGLError(GL_INVALID_VALUE,
8584 "glCopyTextureCHROMIUM: invalid texture target"); 8743 "glCopyTextureCHROMIUM", "invalid texture target");
8585 return; 8744 return;
8586 } 8745 }
8587 8746
8588 if (dest_info->target() != GL_TEXTURE_2D || 8747 if (dest_info->target() != GL_TEXTURE_2D ||
8589 source_info->target() != GL_TEXTURE_2D) { 8748 source_info->target() != GL_TEXTURE_2D) {
8590 SetGLError(GL_INVALID_VALUE, 8749 SetGLError(GL_INVALID_VALUE,
8591 "glCopyTextureCHROMIUM: invalid texture target binding"); 8750 "glCopyTextureCHROMIUM", "invalid texture target binding");
8592 return; 8751 return;
8593 } 8752 }
8594 8753
8595 int source_width, source_height, dest_width, dest_height; 8754 int source_width, source_height, dest_width, dest_height;
8596 if (!source_info->GetLevelSize(GL_TEXTURE_2D, 0, &source_width, 8755 if (!source_info->GetLevelSize(GL_TEXTURE_2D, 0, &source_width,
8597 &source_height)) { 8756 &source_height)) {
8598 SetGLError(GL_INVALID_VALUE, 8757 SetGLError(GL_INVALID_VALUE,
8599 "glCopyTextureChromium: source texture has no level 0"); 8758 "glCopyTextureChromium", "source texture has no level 0");
8600 return; 8759 return;
8601 } 8760 }
8602 8761
8603 // Check that this type of texture is allowed. 8762 // Check that this type of texture is allowed.
8604 if (!texture_manager()->ValidForTarget(GL_TEXTURE_2D, level, source_width, 8763 if (!texture_manager()->ValidForTarget(GL_TEXTURE_2D, level, source_width,
8605 source_height, 1)) { 8764 source_height, 1)) {
8606 SetGLError(GL_INVALID_VALUE, 8765 SetGLError(GL_INVALID_VALUE,
8607 "glCopyTextureCHROMIUM: Bad dimensions"); 8766 "glCopyTextureCHROMIUM", "Bad dimensions");
8608 return; 8767 return;
8609 } 8768 }
8610 8769
8611 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 8770 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
8612 // needed because it takes 10s of milliseconds to initialize. 8771 // needed because it takes 10s of milliseconds to initialize.
8613 if (!copy_texture_CHROMIUM_.get()) { 8772 if (!copy_texture_CHROMIUM_.get()) {
8614 CopyRealGLErrorsToWrapper(); 8773 CopyRealGLErrorsToWrapper();
8615 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 8774 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
8616 copy_texture_CHROMIUM_->Initialize(); 8775 copy_texture_CHROMIUM_->Initialize();
8617 RestoreCurrentFramebufferBindings(); 8776 RestoreCurrentFramebufferBindings();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
8728 8887
8729 void GLES2DecoderImpl::DoTexStorage2DEXT( 8888 void GLES2DecoderImpl::DoTexStorage2DEXT(
8730 GLenum target, 8889 GLenum target,
8731 GLint levels, 8890 GLint levels,
8732 GLenum internal_format, 8891 GLenum internal_format,
8733 GLsizei width, 8892 GLsizei width,
8734 GLsizei height) { 8893 GLsizei height) {
8735 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT"); 8894 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT");
8736 if (!texture_manager()->ValidForTarget(target, 0, width, height, 1) || 8895 if (!texture_manager()->ValidForTarget(target, 0, width, height, 1) ||
8737 TextureManager::ComputeMipMapCount(width, height, 1) < levels) { 8896 TextureManager::ComputeMipMapCount(width, height, 1) < levels) {
8738 SetGLError(GL_INVALID_VALUE, "glTexStorage2DEXT: dimensions out of range"); 8897 SetGLError(
8898 GL_INVALID_VALUE, "glTexStorage2DEXT", "dimensions out of range");
8739 return; 8899 return;
8740 } 8900 }
8741 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8901 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
8742 if (!info) { 8902 if (!info) {
8743 SetGLError(GL_INVALID_OPERATION, 8903 SetGLError(GL_INVALID_OPERATION,
8744 "glTexStorage2DEXT: unknown texture for target"); 8904 "glTexStorage2DEXT", "unknown texture for target");
8745 return; 8905 return;
8746 } 8906 }
8747 if (info->IsAttachedToFramebuffer()) { 8907 if (info->IsAttachedToFramebuffer()) {
8748 state_dirty_ = true; 8908 state_dirty_ = true;
8749 } 8909 }
8750 if (info->IsImmutable()) { 8910 if (info->IsImmutable()) {
8751 SetGLError(GL_INVALID_OPERATION, 8911 SetGLError(GL_INVALID_OPERATION,
8752 "glTexStorage2DEXT: texture is immutable"); 8912 "glTexStorage2DEXT", "texture is immutable");
8753 return; 8913 return;
8754 } 8914 }
8755 CopyRealGLErrorsToWrapper(); 8915 CopyRealGLErrorsToWrapper();
8756 glTexStorage2DEXT(target, levels, GetTexInternalFormat(internal_format), 8916 glTexStorage2DEXT(target, levels, GetTexInternalFormat(internal_format),
8757 width, height); 8917 width, height);
8758 GLenum error = PeekGLError(); 8918 GLenum error = PeekGLError();
8759 if (error == GL_NO_ERROR) { 8919 if (error == GL_NO_ERROR) {
8760 GLenum format = ExtractFormatFromStorageFormat(internal_format); 8920 GLenum format = ExtractFormatFromStorageFormat(internal_format);
8761 GLenum type = ExtractTypeFromStorageFormat(internal_format); 8921 GLenum type = ExtractTypeFromStorageFormat(internal_format);
8762 GLsizei level_width = width; 8922 GLsizei level_width = width;
(...skipping 20 matching lines...) Expand all
8783 bucket->SetData(&name, 0, GL_MAILBOX_SIZE_CHROMIUM); 8943 bucket->SetData(&name, 0, GL_MAILBOX_SIZE_CHROMIUM);
8784 8944
8785 return error::kNoError; 8945 return error::kNoError;
8786 } 8946 }
8787 8947
8788 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, 8948 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target,
8789 const GLbyte* mailbox) { 8949 const GLbyte* mailbox) {
8790 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8950 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
8791 if (!info) { 8951 if (!info) {
8792 SetGLError(GL_INVALID_OPERATION, 8952 SetGLError(GL_INVALID_OPERATION,
8793 "glProduceTextureCHROMIUM: unknown texture for target"); 8953 "glProduceTextureCHROMIUM", "unknown texture for target");
8794 return; 8954 return;
8795 } 8955 }
8796 8956
8797 TextureDefinition* definition = texture_manager()->Save(info); 8957 TextureDefinition* definition = texture_manager()->Save(info);
8798 if (!definition) { 8958 if (!definition) {
8799 SetGLError(GL_INVALID_OPERATION, 8959 SetGLError(GL_INVALID_OPERATION,
8800 "glProduceTextureCHROMIUM: invalid texture"); 8960 "glProduceTextureCHROMIUM", "invalid texture");
8801 return; 8961 return;
8802 } 8962 }
8803 8963
8804 if (!group_->mailbox_manager()->ProduceTexture( 8964 if (!group_->mailbox_manager()->ProduceTexture(
8805 target, 8965 target,
8806 *reinterpret_cast<const MailboxName*>(mailbox), 8966 *reinterpret_cast<const MailboxName*>(mailbox),
8807 definition, 8967 definition,
8808 texture_manager())) { 8968 texture_manager())) {
8809 bool success = texture_manager()->Restore(info, definition); 8969 bool success = texture_manager()->Restore(info, definition);
8810 DCHECK(success); 8970 DCHECK(success);
8811 SetGLError(GL_INVALID_OPERATION, 8971 SetGLError(GL_INVALID_OPERATION,
8812 "glProduceTextureCHROMIUM: invalid mailbox name"); 8972 "glProduceTextureCHROMIUM", "invalid mailbox name");
8813 return; 8973 return;
8814 } 8974 }
8815 8975
8816 BindAndApplyTextureParameters(info); 8976 BindAndApplyTextureParameters(info);
8817 } 8977 }
8818 8978
8819 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, 8979 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target,
8820 const GLbyte* mailbox) { 8980 const GLbyte* mailbox) {
8821 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8981 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
8822 if (!info) { 8982 if (!info) {
8823 SetGLError(GL_INVALID_OPERATION, 8983 SetGLError(GL_INVALID_OPERATION,
8824 "glConsumeTextureCHROMIUM: unknown texture for target"); 8984 "glConsumeTextureCHROMIUM", "unknown texture for target");
8825 return; 8985 return;
8826 } 8986 }
8827 8987
8828 scoped_ptr<TextureDefinition> definition( 8988 scoped_ptr<TextureDefinition> definition(
8829 group_->mailbox_manager()->ConsumeTexture( 8989 group_->mailbox_manager()->ConsumeTexture(
8830 target, 8990 target,
8831 *reinterpret_cast<const MailboxName*>(mailbox))); 8991 *reinterpret_cast<const MailboxName*>(mailbox)));
8832 if (!definition.get()) { 8992 if (!definition.get()) {
8833 SetGLError(GL_INVALID_OPERATION, 8993 SetGLError(GL_INVALID_OPERATION,
8834 "glConsumeTextureCHROMIUM: invalid mailbox name"); 8994 "glConsumeTextureCHROMIUM", "invalid mailbox name");
8835 return; 8995 return;
8836 } 8996 }
8837 8997
8838 if (!texture_manager()->Restore(info, definition.release())) { 8998 if (!texture_manager()->Restore(info, definition.release())) {
8839 SetGLError(GL_INVALID_OPERATION, 8999 SetGLError(GL_INVALID_OPERATION,
8840 "glConsumeTextureCHROMIUM: invalid texture"); 9000 "glConsumeTextureCHROMIUM", "invalid texture");
8841 return; 9001 return;
8842 } 9002 }
8843 9003
8844 BindAndApplyTextureParameters(info); 9004 BindAndApplyTextureParameters(info);
8845 } 9005 }
8846 9006
8847 // Include the auto-generated part of this file. We split this because it means 9007 // Include the auto-generated part of this file. We split this because it means
8848 // we can easily edit the non-auto generated parts right here in this file 9008 // we can easily edit the non-auto generated parts right here in this file
8849 // instead of having to edit some template or the code generator. 9009 // instead of having to edit some template or the code generator.
8850 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9010 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
8851 9011
8852 } // namespace gles2 9012 } // namespace gles2
8853 } // namespace gpu 9013 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/common_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698