| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 // glBindTexture | 559 // glBindTexture |
| 560 TextureManager::TextureInfo::Ref bound_texture_external_oes; | 560 TextureManager::TextureInfo::Ref bound_texture_external_oes; |
| 561 | 561 |
| 562 TextureManager::TextureInfo::Ref GetInfoForSamplerType(GLenum type) { | 562 TextureManager::TextureInfo::Ref GetInfoForSamplerType(GLenum type) { |
| 563 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || | 563 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || |
| 564 type == GL_SAMPLER_EXTERNAL_OES); | 564 type == GL_SAMPLER_EXTERNAL_OES); |
| 565 return type == GL_SAMPLER_2D ? bound_texture_2d : | 565 return type == GL_SAMPLER_2D ? bound_texture_2d : |
| 566 (type == GL_SAMPLER_EXTERNAL_OES ? bound_texture_external_oes : | 566 (type == GL_SAMPLER_EXTERNAL_OES ? bound_texture_external_oes : |
| 567 bound_texture_cube_map); | 567 bound_texture_cube_map); |
| 568 } | 568 } |
| 569 |
| 570 void Unbind(TextureManager::TextureInfo* texture) { |
| 571 if (bound_texture_2d == texture) { |
| 572 bound_texture_2d = NULL; |
| 573 } |
| 574 if (bound_texture_cube_map == texture) { |
| 575 bound_texture_cube_map = NULL; |
| 576 } |
| 577 if (bound_texture_external_oes == texture) { |
| 578 bound_texture_external_oes = NULL; |
| 579 } |
| 580 } |
| 569 }; | 581 }; |
| 570 | 582 |
| 571 // Initialize or re-initialize the shader translator. | 583 // Initialize or re-initialize the shader translator. |
| 572 bool InitializeShaderTranslator(); | 584 bool InitializeShaderTranslator(); |
| 573 | 585 |
| 574 void UpdateCapabilities(); | 586 void UpdateCapabilities(); |
| 575 | 587 |
| 576 // Helpers for the glGen and glDelete functions. | 588 // Helpers for the glGen and glDelete functions. |
| 577 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); | 589 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); |
| 578 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); | 590 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 TextureManager::TextureInfo* CreateTextureInfo( | 628 TextureManager::TextureInfo* CreateTextureInfo( |
| 617 GLuint client_id, GLuint service_id) { | 629 GLuint client_id, GLuint service_id) { |
| 618 return texture_manager()->CreateTextureInfo( | 630 return texture_manager()->CreateTextureInfo( |
| 619 feature_info_, client_id, service_id); | 631 feature_info_, client_id, service_id); |
| 620 } | 632 } |
| 621 | 633 |
| 622 // Gets the texture info for the given texture. Returns NULL if none exists. | 634 // Gets the texture info for the given texture. Returns NULL if none exists. |
| 623 TextureManager::TextureInfo* GetTextureInfo(GLuint client_id) { | 635 TextureManager::TextureInfo* GetTextureInfo(GLuint client_id) { |
| 624 TextureManager::TextureInfo* info = | 636 TextureManager::TextureInfo* info = |
| 625 texture_manager()->GetTextureInfo(client_id); | 637 texture_manager()->GetTextureInfo(client_id); |
| 626 return (info && !info->IsDeleted()) ? info : NULL; | 638 return info; |
| 627 } | 639 } |
| 628 | 640 |
| 629 // Deletes the texture info for the given texture. | 641 // Deletes the texture info for the given texture. |
| 630 void RemoveTextureInfo(GLuint client_id) { | 642 void RemoveTextureInfo(GLuint client_id) { |
| 631 texture_manager()->RemoveTextureInfo(feature_info_, client_id); | 643 texture_manager()->RemoveTextureInfo(feature_info_, client_id); |
| 632 } | 644 } |
| 633 | 645 |
| 634 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 646 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
| 635 // or regular back buffer). | 647 // or regular back buffer). |
| 636 gfx::Size GetBoundReadFrameBufferSize(); | 648 gfx::Size GetBoundReadFrameBufferSize(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 | 787 |
| 776 // Creates a buffer info for the given buffer. | 788 // Creates a buffer info for the given buffer. |
| 777 void CreateBufferInfo(GLuint client_id, GLuint service_id) { | 789 void CreateBufferInfo(GLuint client_id, GLuint service_id) { |
| 778 return buffer_manager()->CreateBufferInfo(client_id, service_id); | 790 return buffer_manager()->CreateBufferInfo(client_id, service_id); |
| 779 } | 791 } |
| 780 | 792 |
| 781 // Gets the buffer info for the given buffer. | 793 // Gets the buffer info for the given buffer. |
| 782 BufferManager::BufferInfo* GetBufferInfo(GLuint client_id) { | 794 BufferManager::BufferInfo* GetBufferInfo(GLuint client_id) { |
| 783 BufferManager::BufferInfo* info = | 795 BufferManager::BufferInfo* info = |
| 784 buffer_manager()->GetBufferInfo(client_id); | 796 buffer_manager()->GetBufferInfo(client_id); |
| 785 return (info && !info->IsDeleted()) ? info : NULL; | 797 return info; |
| 786 } | 798 } |
| 787 | 799 |
| 788 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used | 800 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used |
| 789 // on glDeleteBuffers so we can make sure the user does not try to render | 801 // on glDeleteBuffers so we can make sure the user does not try to render |
| 790 // with deleted buffers. | 802 // with deleted buffers. |
| 791 void RemoveBufferInfo(GLuint client_id); | 803 void RemoveBufferInfo(GLuint client_id); |
| 792 | 804 |
| 793 // Creates a framebuffer info for the given framebuffer. | 805 // Creates a framebuffer info for the given framebuffer. |
| 794 void CreateFramebufferInfo(GLuint client_id, GLuint service_id) { | 806 void CreateFramebufferInfo(GLuint client_id, GLuint service_id) { |
| 795 return framebuffer_manager()->CreateFramebufferInfo(client_id, service_id); | 807 return framebuffer_manager()->CreateFramebufferInfo(client_id, service_id); |
| 796 } | 808 } |
| 797 | 809 |
| 798 // Gets the framebuffer info for the given framebuffer. | 810 // Gets the framebuffer info for the given framebuffer. |
| 799 FramebufferManager::FramebufferInfo* GetFramebufferInfo( | 811 FramebufferManager::FramebufferInfo* GetFramebufferInfo( |
| 800 GLuint client_id) { | 812 GLuint client_id) { |
| 801 FramebufferManager::FramebufferInfo* info = | 813 FramebufferManager::FramebufferInfo* info = |
| 802 framebuffer_manager()->GetFramebufferInfo(client_id); | 814 framebuffer_manager()->GetFramebufferInfo(client_id); |
| 803 return (info && !info->IsDeleted()) ? info : NULL; | 815 return info; |
| 804 } | 816 } |
| 805 | 817 |
| 806 // Removes the framebuffer info for the given framebuffer. | 818 // Removes the framebuffer info for the given framebuffer. |
| 807 void RemoveFramebufferInfo(GLuint client_id) { | 819 void RemoveFramebufferInfo(GLuint client_id) { |
| 808 framebuffer_manager()->RemoveFramebufferInfo(client_id); | 820 framebuffer_manager()->RemoveFramebufferInfo(client_id); |
| 809 } | 821 } |
| 810 | 822 |
| 811 // Creates a renderbuffer info for the given renderbuffer. | 823 // Creates a renderbuffer info for the given renderbuffer. |
| 812 void CreateRenderbufferInfo(GLuint client_id, GLuint service_id) { | 824 void CreateRenderbufferInfo(GLuint client_id, GLuint service_id) { |
| 813 return renderbuffer_manager()->CreateRenderbufferInfo( | 825 return renderbuffer_manager()->CreateRenderbufferInfo( |
| 814 client_id, service_id); | 826 client_id, service_id); |
| 815 } | 827 } |
| 816 | 828 |
| 817 // Gets the renderbuffer info for the given renderbuffer. | 829 // Gets the renderbuffer info for the given renderbuffer. |
| 818 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfo( | 830 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfo( |
| 819 GLuint client_id) { | 831 GLuint client_id) { |
| 820 RenderbufferManager::RenderbufferInfo* info = | 832 RenderbufferManager::RenderbufferInfo* info = |
| 821 renderbuffer_manager()->GetRenderbufferInfo(client_id); | 833 renderbuffer_manager()->GetRenderbufferInfo(client_id); |
| 822 return (info && !info->IsDeleted()) ? info : NULL; | 834 return info; |
| 823 } | 835 } |
| 824 | 836 |
| 825 // Removes the renderbuffer info for the given renderbuffer. | 837 // Removes the renderbuffer info for the given renderbuffer. |
| 826 void RemoveRenderbufferInfo(GLuint client_id) { | 838 void RemoveRenderbufferInfo(GLuint client_id) { |
| 827 renderbuffer_manager()->RemoveRenderbufferInfo(client_id); | 839 renderbuffer_manager()->RemoveRenderbufferInfo(client_id); |
| 828 } | 840 } |
| 829 | 841 |
| 830 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); | 842 void DoBindAttribLocation(GLuint client_id, GLuint index, const char* name); |
| 831 | 843 |
| 832 error::Error GetAttribLocationHelper( | 844 error::Error GetAttribLocationHelper( |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 | 1150 |
| 1139 // Returns true if GL_FIXED attribs were simulated. | 1151 // Returns true if GL_FIXED attribs were simulated. |
| 1140 bool SimulateFixedAttribs(GLuint max_vertex_accessed, bool* simulated); | 1152 bool SimulateFixedAttribs(GLuint max_vertex_accessed, bool* simulated); |
| 1141 void RestoreStateForSimulatedFixedAttribs(); | 1153 void RestoreStateForSimulatedFixedAttribs(); |
| 1142 | 1154 |
| 1143 // Gets the buffer id for a given target. | 1155 // Gets the buffer id for a given target. |
| 1144 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) { | 1156 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) { |
| 1145 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); | 1157 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); |
| 1146 BufferManager::BufferInfo* info = target == GL_ARRAY_BUFFER ? | 1158 BufferManager::BufferInfo* info = target == GL_ARRAY_BUFFER ? |
| 1147 bound_array_buffer_ : bound_element_array_buffer_; | 1159 bound_array_buffer_ : bound_element_array_buffer_; |
| 1148 return (info && !info->IsDeleted()) ? info : NULL; | 1160 return info; |
| 1149 } | 1161 } |
| 1150 | 1162 |
| 1151 // Gets the texture id for a given target. | 1163 // Gets the texture id for a given target. |
| 1152 TextureManager::TextureInfo* GetTextureInfoForTarget(GLenum target) { | 1164 TextureManager::TextureInfo* GetTextureInfoForTarget(GLenum target) { |
| 1153 TextureUnit& unit = texture_units_[active_texture_unit_]; | 1165 TextureUnit& unit = texture_units_[active_texture_unit_]; |
| 1154 TextureManager::TextureInfo* info = NULL; | 1166 TextureManager::TextureInfo* info = NULL; |
| 1155 switch (target) { | 1167 switch (target) { |
| 1156 case GL_TEXTURE_2D: | 1168 case GL_TEXTURE_2D: |
| 1157 info = unit.bound_texture_2d; | 1169 info = unit.bound_texture_2d; |
| 1158 break; | 1170 break; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1169 info = unit.bound_texture_external_oes; | 1181 info = unit.bound_texture_external_oes; |
| 1170 break; | 1182 break; |
| 1171 // Note: If we ever support TEXTURE_RECTANGLE as a target, be sure to | 1183 // Note: If we ever support TEXTURE_RECTANGLE as a target, be sure to |
| 1172 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture, | 1184 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture, |
| 1173 // because |texture_| is used by the FBO rendering mechanism for readback | 1185 // because |texture_| is used by the FBO rendering mechanism for readback |
| 1174 // to the bits that get sent to the browser. | 1186 // to the bits that get sent to the browser. |
| 1175 default: | 1187 default: |
| 1176 NOTREACHED(); | 1188 NOTREACHED(); |
| 1177 return NULL; | 1189 return NULL; |
| 1178 } | 1190 } |
| 1179 return (info && !info->IsDeleted()) ? info : NULL; | 1191 return info; |
| 1180 } | 1192 } |
| 1181 | 1193 |
| 1182 GLenum GetBindTargetForSamplerType(GLenum type) { | 1194 GLenum GetBindTargetForSamplerType(GLenum type) { |
| 1183 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || | 1195 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || |
| 1184 type == GL_SAMPLER_EXTERNAL_OES); | 1196 type == GL_SAMPLER_EXTERNAL_OES); |
| 1185 return type == GL_SAMPLER_2D ? GL_TEXTURE_2D : | 1197 return type == GL_SAMPLER_2D ? GL_TEXTURE_2D : |
| 1186 (type == GL_SAMPLER_EXTERNAL_OES ? GL_TEXTURE_EXTERNAL_OES : | 1198 (type == GL_SAMPLER_EXTERNAL_OES ? GL_TEXTURE_EXTERNAL_OES : |
| 1187 GL_TEXTURE_CUBE_MAP); | 1199 GL_TEXTURE_CUBE_MAP); |
| 1188 } | 1200 } |
| 1189 | 1201 |
| 1190 // Gets the framebuffer info for a particular target. | 1202 // Gets the framebuffer info for a particular target. |
| 1191 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( | 1203 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( |
| 1192 GLenum target) { | 1204 GLenum target) { |
| 1193 FramebufferManager::FramebufferInfo* info = NULL; | 1205 FramebufferManager::FramebufferInfo* info = NULL; |
| 1194 switch (target) { | 1206 switch (target) { |
| 1195 case GL_FRAMEBUFFER: | 1207 case GL_FRAMEBUFFER: |
| 1196 case GL_DRAW_FRAMEBUFFER: | 1208 case GL_DRAW_FRAMEBUFFER: |
| 1197 info = bound_draw_framebuffer_; | 1209 info = bound_draw_framebuffer_; |
| 1198 break; | 1210 break; |
| 1199 case GL_READ_FRAMEBUFFER: | 1211 case GL_READ_FRAMEBUFFER: |
| 1200 info = bound_read_framebuffer_; | 1212 info = bound_read_framebuffer_; |
| 1201 break; | 1213 break; |
| 1202 default: | 1214 default: |
| 1203 NOTREACHED(); | 1215 NOTREACHED(); |
| 1204 break; | 1216 break; |
| 1205 } | 1217 } |
| 1206 return (info && !info->IsDeleted()) ? info : NULL; | 1218 return info; |
| 1207 } | 1219 } |
| 1208 | 1220 |
| 1209 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfoForTarget( | 1221 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfoForTarget( |
| 1210 GLenum target) { | 1222 GLenum target) { |
| 1211 RenderbufferManager::RenderbufferInfo* info = NULL; | 1223 RenderbufferManager::RenderbufferInfo* info = NULL; |
| 1212 switch (target) { | 1224 switch (target) { |
| 1213 case GL_RENDERBUFFER: | 1225 case GL_RENDERBUFFER: |
| 1214 info = bound_renderbuffer_; | 1226 info = bound_renderbuffer_; |
| 1215 break; | 1227 break; |
| 1216 default: | 1228 default: |
| 1217 NOTREACHED(); | 1229 NOTREACHED(); |
| 1218 break; | 1230 break; |
| 1219 } | 1231 } |
| 1220 return (info && !info->IsDeleted()) ? info : NULL; | 1232 return info; |
| 1221 } | 1233 } |
| 1222 | 1234 |
| 1223 // Validates the program and location for a glGetUniform call and returns | 1235 // Validates the program and location for a glGetUniform call and returns |
| 1224 // a SizeResult setup to receive the result. Returns true if glGetUniform | 1236 // a SizeResult setup to receive the result. Returns true if glGetUniform |
| 1225 // should be called. | 1237 // should be called. |
| 1226 bool GetUniformSetup( | 1238 bool GetUniformSetup( |
| 1227 GLuint program, GLint location, | 1239 GLuint program, GLint location, |
| 1228 uint32 shm_id, uint32 shm_offset, | 1240 uint32 shm_id, uint32 shm_offset, |
| 1229 error::Error* error, GLuint* service_id, void** result, | 1241 error::Error* error, GLuint* service_id, void** result, |
| 1230 GLenum* result_type); | 1242 GLenum* result_type); |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 glGenTextures(n, service_ids.get()); | 2191 glGenTextures(n, service_ids.get()); |
| 2180 for (GLsizei ii = 0; ii < n; ++ii) { | 2192 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2181 CreateTextureInfo(client_ids[ii], service_ids[ii]); | 2193 CreateTextureInfo(client_ids[ii], service_ids[ii]); |
| 2182 } | 2194 } |
| 2183 return true; | 2195 return true; |
| 2184 } | 2196 } |
| 2185 | 2197 |
| 2186 void GLES2DecoderImpl::DeleteBuffersHelper( | 2198 void GLES2DecoderImpl::DeleteBuffersHelper( |
| 2187 GLsizei n, const GLuint* client_ids) { | 2199 GLsizei n, const GLuint* client_ids) { |
| 2188 for (GLsizei ii = 0; ii < n; ++ii) { | 2200 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2189 BufferManager::BufferInfo* info = GetBufferInfo(client_ids[ii]); | 2201 BufferManager::BufferInfo* buffer = GetBufferInfo(client_ids[ii]); |
| 2190 if (info) { | 2202 if (buffer && !buffer->IsDeleted()) { |
| 2191 GLuint service_id = info->service_id(); | 2203 vertex_attrib_manager_.Unbind(buffer); |
| 2204 if (bound_array_buffer_ == buffer) { |
| 2205 bound_array_buffer_ = NULL; |
| 2206 } |
| 2207 if (bound_element_array_buffer_ == buffer) { |
| 2208 bound_element_array_buffer_ = NULL; |
| 2209 } |
| 2210 GLuint service_id = buffer->service_id(); |
| 2192 glDeleteBuffersARB(1, &service_id); | 2211 glDeleteBuffersARB(1, &service_id); |
| 2193 RemoveBufferInfo(client_ids[ii]); | 2212 RemoveBufferInfo(client_ids[ii]); |
| 2194 } | 2213 } |
| 2195 } | 2214 } |
| 2196 } | 2215 } |
| 2197 | 2216 |
| 2198 void GLES2DecoderImpl::DeleteFramebuffersHelper( | 2217 void GLES2DecoderImpl::DeleteFramebuffersHelper( |
| 2199 GLsizei n, const GLuint* client_ids) { | 2218 GLsizei n, const GLuint* client_ids) { |
| 2200 bool supports_seperate_framebuffer_binds = | 2219 bool supports_seperate_framebuffer_binds = |
| 2201 feature_info_->feature_flags().chromium_framebuffer_multisample; | 2220 feature_info_->feature_flags().chromium_framebuffer_multisample; |
| 2202 | 2221 |
| 2203 for (GLsizei ii = 0; ii < n; ++ii) { | 2222 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2204 FramebufferManager::FramebufferInfo* info = | 2223 FramebufferManager::FramebufferInfo* framebuffer = |
| 2205 GetFramebufferInfo(client_ids[ii]); | 2224 GetFramebufferInfo(client_ids[ii]); |
| 2206 if (info) { | 2225 if (framebuffer && !framebuffer->IsDeleted()) { |
| 2207 if (info == bound_draw_framebuffer_) { | 2226 if (framebuffer == bound_draw_framebuffer_) { |
| 2208 bound_draw_framebuffer_ = NULL; | 2227 bound_draw_framebuffer_ = NULL; |
| 2209 state_dirty_ = true; | 2228 state_dirty_ = true; |
| 2210 GLenum target = supports_seperate_framebuffer_binds ? | 2229 GLenum target = supports_seperate_framebuffer_binds ? |
| 2211 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | 2230 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 2212 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 2231 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
| 2213 } | 2232 } |
| 2214 if (info == bound_read_framebuffer_) { | 2233 if (framebuffer == bound_read_framebuffer_) { |
| 2215 bound_read_framebuffer_ = NULL; | 2234 bound_read_framebuffer_ = NULL; |
| 2216 GLenum target = supports_seperate_framebuffer_binds ? | 2235 GLenum target = supports_seperate_framebuffer_binds ? |
| 2217 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | 2236 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 2218 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 2237 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
| 2219 } | 2238 } |
| 2220 GLuint service_id = info->service_id(); | 2239 GLuint service_id = framebuffer->service_id(); |
| 2221 glDeleteFramebuffersEXT(1, &service_id); | 2240 glDeleteFramebuffersEXT(1, &service_id); |
| 2222 RemoveFramebufferInfo(client_ids[ii]); | 2241 RemoveFramebufferInfo(client_ids[ii]); |
| 2223 } | 2242 } |
| 2224 } | 2243 } |
| 2225 } | 2244 } |
| 2226 | 2245 |
| 2227 void GLES2DecoderImpl::DeleteRenderbuffersHelper( | 2246 void GLES2DecoderImpl::DeleteRenderbuffersHelper( |
| 2228 GLsizei n, const GLuint* client_ids) { | 2247 GLsizei n, const GLuint* client_ids) { |
| 2248 bool supports_seperate_framebuffer_binds = |
| 2249 feature_info_->feature_flags().chromium_framebuffer_multisample; |
| 2229 for (GLsizei ii = 0; ii < n; ++ii) { | 2250 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2230 RenderbufferManager::RenderbufferInfo* info = | 2251 RenderbufferManager::RenderbufferInfo* renderbuffer = |
| 2231 GetRenderbufferInfo(client_ids[ii]); | 2252 GetRenderbufferInfo(client_ids[ii]); |
| 2232 if (info) { | 2253 if (renderbuffer && !renderbuffer->IsDeleted()) { |
| 2254 if (bound_renderbuffer_ == renderbuffer) { |
| 2255 bound_renderbuffer_ = NULL; |
| 2256 } |
| 2257 // Unbind from current framebuffers. |
| 2258 if (supports_seperate_framebuffer_binds) { |
| 2259 if (bound_read_framebuffer_) { |
| 2260 bound_read_framebuffer_->UnbindRenderbuffer( |
| 2261 GL_READ_FRAMEBUFFER, renderbuffer); |
| 2262 } |
| 2263 if (bound_draw_framebuffer_) { |
| 2264 bound_draw_framebuffer_->UnbindRenderbuffer( |
| 2265 GL_DRAW_FRAMEBUFFER, renderbuffer); |
| 2266 } |
| 2267 } else { |
| 2268 if (bound_draw_framebuffer_) { |
| 2269 bound_draw_framebuffer_->UnbindRenderbuffer( |
| 2270 GL_FRAMEBUFFER, renderbuffer); |
| 2271 } |
| 2272 } |
| 2233 state_dirty_ = true; | 2273 state_dirty_ = true; |
| 2234 GLuint service_id = info->service_id(); | 2274 GLuint service_id = renderbuffer->service_id(); |
| 2235 glDeleteRenderbuffersEXT(1, &service_id); | 2275 glDeleteRenderbuffersEXT(1, &service_id); |
| 2236 RemoveRenderbufferInfo(client_ids[ii]); | 2276 RemoveRenderbufferInfo(client_ids[ii]); |
| 2237 } | 2277 } |
| 2238 } | 2278 } |
| 2239 } | 2279 } |
| 2240 | 2280 |
| 2241 void GLES2DecoderImpl::DeleteTexturesHelper( | 2281 void GLES2DecoderImpl::DeleteTexturesHelper( |
| 2242 GLsizei n, const GLuint* client_ids) { | 2282 GLsizei n, const GLuint* client_ids) { |
| 2283 bool supports_seperate_framebuffer_binds = |
| 2284 feature_info_->feature_flags().chromium_framebuffer_multisample; |
| 2243 for (GLsizei ii = 0; ii < n; ++ii) { | 2285 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2244 TextureManager::TextureInfo* info = GetTextureInfo(client_ids[ii]); | 2286 TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]); |
| 2245 if (info) { | 2287 if (texture && !texture->IsDeleted()) { |
| 2246 if (info->IsAttachedToFramebuffer()) { | 2288 if (texture->IsAttachedToFramebuffer()) { |
| 2247 state_dirty_ = true; | 2289 state_dirty_ = true; |
| 2248 } | 2290 } |
| 2249 GLuint service_id = info->service_id(); | 2291 // Unbind texture from texture units. |
| 2250 if (info->IsStreamTexture() && stream_texture_manager_) { | 2292 for (size_t jj = 0; jj < group_->max_texture_units(); ++jj) { |
| 2293 texture_units_[ii].Unbind(texture); |
| 2294 } |
| 2295 // Unbind from current framebuffers. |
| 2296 if (supports_seperate_framebuffer_binds) { |
| 2297 if (bound_read_framebuffer_) { |
| 2298 bound_read_framebuffer_->UnbindTexture(GL_READ_FRAMEBUFFER, texture); |
| 2299 } |
| 2300 if (bound_draw_framebuffer_) { |
| 2301 bound_draw_framebuffer_->UnbindTexture(GL_DRAW_FRAMEBUFFER, texture); |
| 2302 } |
| 2303 } else { |
| 2304 if (bound_draw_framebuffer_) { |
| 2305 bound_draw_framebuffer_->UnbindTexture(GL_FRAMEBUFFER, texture); |
| 2306 } |
| 2307 } |
| 2308 GLuint service_id = texture->service_id(); |
| 2309 if (texture->IsStreamTexture() && stream_texture_manager_) { |
| 2251 stream_texture_manager_->DestroyStreamTexture(service_id); | 2310 stream_texture_manager_->DestroyStreamTexture(service_id); |
| 2252 } | 2311 } |
| 2253 glDeleteTextures(1, &service_id); | 2312 glDeleteTextures(1, &service_id); |
| 2254 RemoveTextureInfo(client_ids[ii]); | 2313 RemoveTextureInfo(client_ids[ii]); |
| 2255 } | 2314 } |
| 2256 } | 2315 } |
| 2257 } | 2316 } |
| 2258 | 2317 |
| 2259 // } // anonymous namespace | 2318 // } // anonymous namespace |
| 2260 | 2319 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2322 last_id = 0; | 2381 last_id = 0; |
| 2323 } | 2382 } |
| 2324 | 2383 |
| 2325 glBindTexture(GL_TEXTURE_2D, last_id); | 2384 glBindTexture(GL_TEXTURE_2D, last_id); |
| 2326 glActiveTexture(GL_TEXTURE0 + active_texture_unit_); | 2385 glActiveTexture(GL_TEXTURE0 + active_texture_unit_); |
| 2327 } | 2386 } |
| 2328 | 2387 |
| 2329 bool GLES2DecoderImpl::CheckFramebufferValid( | 2388 bool GLES2DecoderImpl::CheckFramebufferValid( |
| 2330 FramebufferManager::FramebufferInfo* framebuffer, | 2389 FramebufferManager::FramebufferInfo* framebuffer, |
| 2331 GLenum target, const char* func_name) { | 2390 GLenum target, const char* func_name) { |
| 2332 if (!framebuffer || framebuffer->IsDeleted()) { | 2391 if (!framebuffer) { |
| 2333 return true; | 2392 return true; |
| 2334 } | 2393 } |
| 2335 | 2394 |
| 2336 GLenum completeness = framebuffer->IsPossiblyComplete(); | 2395 GLenum completeness = framebuffer->IsPossiblyComplete(); |
| 2337 if (completeness != GL_FRAMEBUFFER_COMPLETE) { | 2396 if (completeness != GL_FRAMEBUFFER_COMPLETE) { |
| 2338 SetGLError( | 2397 SetGLError( |
| 2339 GL_INVALID_FRAMEBUFFER_OPERATION, | 2398 GL_INVALID_FRAMEBUFFER_OPERATION, |
| 2340 (std::string(func_name) + " framebuffer incomplete").c_str()); | 2399 (std::string(func_name) + " framebuffer incomplete").c_str()); |
| 2341 return false; | 2400 return false; |
| 2342 } | 2401 } |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3791 } | 3850 } |
| 3792 if (face == GL_BACK || face == GL_FRONT_AND_BACK) { | 3851 if (face == GL_BACK || face == GL_FRONT_AND_BACK) { |
| 3793 mask_stencil_back_ = mask; | 3852 mask_stencil_back_ = mask; |
| 3794 } | 3853 } |
| 3795 state_dirty_ = true; | 3854 state_dirty_ = true; |
| 3796 } | 3855 } |
| 3797 | 3856 |
| 3798 // Assumes framebuffer is complete. | 3857 // Assumes framebuffer is complete. |
| 3799 void GLES2DecoderImpl::ClearUnclearedAttachments( | 3858 void GLES2DecoderImpl::ClearUnclearedAttachments( |
| 3800 GLenum target, FramebufferManager::FramebufferInfo* info) { | 3859 GLenum target, FramebufferManager::FramebufferInfo* info) { |
| 3801 DCHECK(!info->IsDeleted()); | |
| 3802 if (target == GL_READ_FRAMEBUFFER_EXT) { | 3860 if (target == GL_READ_FRAMEBUFFER_EXT) { |
| 3803 // bind this to the DRAW point, clear then bind back to READ | 3861 // bind this to the DRAW point, clear then bind back to READ |
| 3804 // TODO(gman): I don't think there is any guarantee that an FBO that | 3862 // TODO(gman): I don't think there is any guarantee that an FBO that |
| 3805 // is complete on the READ attachment will be complete as a DRAW | 3863 // is complete on the READ attachment will be complete as a DRAW |
| 3806 // attachment. | 3864 // attachment. |
| 3807 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); | 3865 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); |
| 3808 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, info->service_id()); | 3866 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, info->service_id()); |
| 3809 } | 3867 } |
| 3810 GLbitfield clear_bits = 0; | 3868 GLbitfield clear_bits = 0; |
| 3811 if (info->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { | 3869 if (info->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4557 current_program_->GetAttribInfoByLocation(info->index()); | 4615 current_program_->GetAttribInfoByLocation(info->index()); |
| 4558 if (attrib_info) { | 4616 if (attrib_info) { |
| 4559 // This attrib is used in the current program. | 4617 // This attrib is used in the current program. |
| 4560 if (!info->CanAccess(max_vertex_accessed)) { | 4618 if (!info->CanAccess(max_vertex_accessed)) { |
| 4561 SetGLError(GL_INVALID_OPERATION, | 4619 SetGLError(GL_INVALID_OPERATION, |
| 4562 "glDrawXXX: attempt to access out of range vertices"); | 4620 "glDrawXXX: attempt to access out of range vertices"); |
| 4563 return false; | 4621 return false; |
| 4564 } | 4622 } |
| 4565 } else { | 4623 } else { |
| 4566 // This attrib is not used in the current program. | 4624 // This attrib is not used in the current program. |
| 4567 if (!info->buffer() || info->buffer()->IsDeleted()) { | 4625 if (!info->buffer()) { |
| 4568 SetGLError( | 4626 SetGLError( |
| 4569 GL_INVALID_OPERATION, | 4627 GL_INVALID_OPERATION, |
| 4570 "glDrawXXX: attempt to render with no buffer attached to enabled " | 4628 "glDrawXXX: attempt to render with no buffer attached to enabled " |
| 4571 "attrib"); | 4629 "attrib"); |
| 4572 return false; | 4630 return false; |
| 4573 } | 4631 } |
| 4574 } | 4632 } |
| 4575 } | 4633 } |
| 4576 return true; | 4634 return true; |
| 4577 } | 4635 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4810 if (WasContextLost()) { | 4868 if (WasContextLost()) { |
| 4811 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawArrays."; | 4869 LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawArrays."; |
| 4812 return error::kLostContext; | 4870 return error::kLostContext; |
| 4813 } | 4871 } |
| 4814 } | 4872 } |
| 4815 return error::kNoError; | 4873 return error::kNoError; |
| 4816 } | 4874 } |
| 4817 | 4875 |
| 4818 error::Error GLES2DecoderImpl::HandleDrawElements( | 4876 error::Error GLES2DecoderImpl::HandleDrawElements( |
| 4819 uint32 immediate_data_size, const gles2::DrawElements& c) { | 4877 uint32 immediate_data_size, const gles2::DrawElements& c) { |
| 4820 if (!bound_element_array_buffer_ || | 4878 if (!bound_element_array_buffer_) { |
| 4821 bound_element_array_buffer_->IsDeleted()) { | |
| 4822 SetGLError(GL_INVALID_OPERATION, | 4879 SetGLError(GL_INVALID_OPERATION, |
| 4823 "glDrawElements: No element array buffer bound"); | 4880 "glDrawElements: No element array buffer bound"); |
| 4824 return error::kNoError; | 4881 return error::kNoError; |
| 4825 } | 4882 } |
| 4826 | 4883 |
| 4827 GLenum mode = c.mode; | 4884 GLenum mode = c.mode; |
| 4828 GLsizei count = c.count; | 4885 GLsizei count = c.count; |
| 4829 GLenum type = c.type; | 4886 GLenum type = c.type; |
| 4830 int32 offset = c.index_offset; | 4887 int32 offset = c.index_offset; |
| 4831 if (count < 0) { | 4888 if (count < 0) { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5110 shader, "glGetShaderInfoLog"); | 5167 shader, "glGetShaderInfoLog"); |
| 5111 if (!info || !info->log_info()) { | 5168 if (!info || !info->log_info()) { |
| 5112 bucket->SetFromString(""); | 5169 bucket->SetFromString(""); |
| 5113 return error::kNoError; | 5170 return error::kNoError; |
| 5114 } | 5171 } |
| 5115 bucket->SetFromString(info->log_info()->c_str()); | 5172 bucket->SetFromString(info->log_info()->c_str()); |
| 5116 return error::kNoError; | 5173 return error::kNoError; |
| 5117 } | 5174 } |
| 5118 | 5175 |
| 5119 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) { | 5176 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) { |
| 5120 const BufferManager::BufferInfo* info = GetBufferInfo(client_id); | 5177 const BufferManager::BufferInfo* buffer = GetBufferInfo(client_id); |
| 5121 return info && info->IsValid(); | 5178 return buffer && buffer->IsValid() && !buffer->IsDeleted(); |
| 5122 } | 5179 } |
| 5123 | 5180 |
| 5124 bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) { | 5181 bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) { |
| 5125 const FramebufferManager::FramebufferInfo* info = | 5182 const FramebufferManager::FramebufferInfo* framebuffer = |
| 5126 GetFramebufferInfo(client_id); | 5183 GetFramebufferInfo(client_id); |
| 5127 return info && info->IsValid(); | 5184 return framebuffer && framebuffer->IsValid() && !framebuffer->IsDeleted(); |
| 5128 } | 5185 } |
| 5129 | 5186 |
| 5130 bool GLES2DecoderImpl::DoIsProgram(GLuint client_id) { | 5187 bool GLES2DecoderImpl::DoIsProgram(GLuint client_id) { |
| 5131 // IsProgram is true for programs as soon as they are created, until they are | 5188 // IsProgram is true for programs as soon as they are created, until they are |
| 5132 // deleted and no longer in use. | 5189 // deleted and no longer in use. |
| 5133 return GetProgramInfo(client_id) != NULL; | 5190 const ProgramManager::ProgramInfo* program = GetProgramInfo(client_id); |
| 5191 return program != NULL && !program->IsDeleted(); |
| 5134 } | 5192 } |
| 5135 | 5193 |
| 5136 bool GLES2DecoderImpl::DoIsRenderbuffer(GLuint client_id) { | 5194 bool GLES2DecoderImpl::DoIsRenderbuffer(GLuint client_id) { |
| 5137 const RenderbufferManager::RenderbufferInfo* info = | 5195 const RenderbufferManager::RenderbufferInfo* renderbuffer = |
| 5138 GetRenderbufferInfo(client_id); | 5196 GetRenderbufferInfo(client_id); |
| 5139 return info && info->IsValid(); | 5197 return renderbuffer && renderbuffer->IsValid() && !renderbuffer->IsDeleted(); |
| 5140 } | 5198 } |
| 5141 | 5199 |
| 5142 bool GLES2DecoderImpl::DoIsShader(GLuint client_id) { | 5200 bool GLES2DecoderImpl::DoIsShader(GLuint client_id) { |
| 5143 // IsShader is true for shaders as soon as they are created, until they | 5201 // IsShader is true for shaders as soon as they are created, until they |
| 5144 // are deleted and not attached to any programs. | 5202 // are deleted and not attached to any programs. |
| 5145 return GetShaderInfo(client_id) != NULL; | 5203 const ShaderManager::ShaderInfo* shader = GetShaderInfo(client_id); |
| 5204 return shader != NULL && !shader->IsDeleted(); |
| 5146 } | 5205 } |
| 5147 | 5206 |
| 5148 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { | 5207 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { |
| 5149 const TextureManager::TextureInfo* info = GetTextureInfo(client_id); | 5208 const TextureManager::TextureInfo* texture = GetTextureInfo(client_id); |
| 5150 return info && info->IsValid(); | 5209 return texture && texture->IsValid() && !texture->IsDeleted(); |
| 5151 } | 5210 } |
| 5152 | 5211 |
| 5153 void GLES2DecoderImpl::DoAttachShader( | 5212 void GLES2DecoderImpl::DoAttachShader( |
| 5154 GLuint program_client_id, GLint shader_client_id) { | 5213 GLuint program_client_id, GLint shader_client_id) { |
| 5155 ProgramManager::ProgramInfo* program_info = GetProgramInfoNotShader( | 5214 ProgramManager::ProgramInfo* program_info = GetProgramInfoNotShader( |
| 5156 program_client_id, "glAttachShader"); | 5215 program_client_id, "glAttachShader"); |
| 5157 if (!program_info) { | 5216 if (!program_info) { |
| 5158 return; | 5217 return; |
| 5159 } | 5218 } |
| 5160 ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram( | 5219 ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram( |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5522 return error::kNoError; | 5581 return error::kNoError; |
| 5523 } | 5582 } |
| 5524 if (!validators_->pixel_type.IsValid(type)) { | 5583 if (!validators_->pixel_type.IsValid(type)) { |
| 5525 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM"); | 5584 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM"); |
| 5526 return error::kNoError; | 5585 return error::kNoError; |
| 5527 } | 5586 } |
| 5528 if (width == 0 || height == 0) { | 5587 if (width == 0 || height == 0) { |
| 5529 return error::kNoError; | 5588 return error::kNoError; |
| 5530 } | 5589 } |
| 5531 | 5590 |
| 5532 CopyRealGLErrorsToWrapper(); | |
| 5533 | |
| 5534 ScopedResolvedFrameBufferBinder binder(this, false, true); | |
| 5535 | |
| 5536 // Get the size of the current fbo or backbuffer. | 5591 // Get the size of the current fbo or backbuffer. |
| 5537 gfx::Size max_size = GetBoundReadFrameBufferSize(); | 5592 gfx::Size max_size = GetBoundReadFrameBufferSize(); |
| 5538 | 5593 |
| 5539 GLint max_x; | 5594 GLint max_x; |
| 5540 GLint max_y; | 5595 GLint max_y; |
| 5541 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) { | 5596 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) { |
| 5542 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); | 5597 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); |
| 5543 return error::kNoError; | 5598 return error::kNoError; |
| 5544 } | 5599 } |
| 5545 | 5600 |
| 5546 if (!CheckBoundFramebuffersValid("glReadPixels")) { | 5601 if (!CheckBoundFramebuffersValid("glReadPixels")) { |
| 5547 return error::kNoError; | 5602 return error::kNoError; |
| 5548 } | 5603 } |
| 5549 | 5604 |
| 5605 CopyRealGLErrorsToWrapper(); |
| 5606 |
| 5607 ScopedResolvedFrameBufferBinder binder(this, false, true); |
| 5608 |
| 5550 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { | 5609 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { |
| 5551 // The user requested an out of range area. Get the results 1 line | 5610 // The user requested an out of range area. Get the results 1 line |
| 5552 // at a time. | 5611 // at a time. |
| 5553 uint32 temp_size; | 5612 uint32 temp_size; |
| 5554 if (!GLES2Util::ComputeImageDataSize( | 5613 if (!GLES2Util::ComputeImageDataSize( |
| 5555 width, 1, format, type, pack_alignment_, &temp_size)) { | 5614 width, 1, format, type, pack_alignment_, &temp_size)) { |
| 5556 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); | 5615 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions out of range"); |
| 5557 return error::kNoError; | 5616 return error::kNoError; |
| 5558 } | 5617 } |
| 5559 GLsizei unpadded_row_size = temp_size; | 5618 GLsizei unpadded_row_size = temp_size; |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6380 // Check we have compatible formats. | 6439 // Check we have compatible formats. |
| 6381 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 6440 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
| 6382 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 6441 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
| 6383 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); | 6442 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); |
| 6384 | 6443 |
| 6385 if ((channels_needed & channels_exist) != channels_needed) { | 6444 if ((channels_needed & channels_exist) != channels_needed) { |
| 6386 SetGLError(GL_INVALID_OPERATION, "glCopyTexImage2D: incompatible format"); | 6445 SetGLError(GL_INVALID_OPERATION, "glCopyTexImage2D: incompatible format"); |
| 6387 return; | 6446 return; |
| 6388 } | 6447 } |
| 6389 | 6448 |
| 6449 if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) { |
| 6450 return; |
| 6451 } |
| 6452 |
| 6390 CopyRealGLErrorsToWrapper(); | 6453 CopyRealGLErrorsToWrapper(); |
| 6391 ScopedResolvedFrameBufferBinder binder(this, false, true); | 6454 ScopedResolvedFrameBufferBinder binder(this, false, true); |
| 6392 gfx::Size size = GetBoundReadFrameBufferSize(); | 6455 gfx::Size size = GetBoundReadFrameBufferSize(); |
| 6393 | 6456 |
| 6394 if (info->IsAttachedToFramebuffer()) { | 6457 if (info->IsAttachedToFramebuffer()) { |
| 6395 state_dirty_ = true; | 6458 state_dirty_ = true; |
| 6396 } | 6459 } |
| 6397 | 6460 |
| 6398 // Clip to size to source dimensions | 6461 // Clip to size to source dimensions |
| 6399 GLint copyX = 0; | 6462 GLint copyX = 0; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6464 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 6527 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
| 6465 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 6528 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
| 6466 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format); | 6529 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format); |
| 6467 | 6530 |
| 6468 if ((channels_needed & channels_exist) != channels_needed) { | 6531 if ((channels_needed & channels_exist) != channels_needed) { |
| 6469 SetGLError( | 6532 SetGLError( |
| 6470 GL_INVALID_OPERATION, "glCopyTexSubImage2D: incompatible format"); | 6533 GL_INVALID_OPERATION, "glCopyTexSubImage2D: incompatible format"); |
| 6471 return; | 6534 return; |
| 6472 } | 6535 } |
| 6473 | 6536 |
| 6537 if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) { |
| 6538 return; |
| 6539 } |
| 6540 |
| 6474 ScopedResolvedFrameBufferBinder binder(this, false, true); | 6541 ScopedResolvedFrameBufferBinder binder(this, false, true); |
| 6475 gfx::Size size = GetBoundReadFrameBufferSize(); | 6542 gfx::Size size = GetBoundReadFrameBufferSize(); |
| 6476 GLint copyX = 0; | 6543 GLint copyX = 0; |
| 6477 GLint copyY = 0; | 6544 GLint copyY = 0; |
| 6478 GLint copyWidth = 0; | 6545 GLint copyWidth = 0; |
| 6479 GLint copyHeight = 0; | 6546 GLint copyHeight = 0; |
| 6480 Clip(x, width, size.width(), ©X, ©Width); | 6547 Clip(x, width, size.width(), ©X, ©Width); |
| 6481 Clip(y, height, size.height(), ©Y, ©Height); | 6548 Clip(y, height, size.height(), ©Y, ©Height); |
| 6482 | 6549 |
| 6483 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) { | 6550 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) { |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7404 return error::kNoError; | 7471 return error::kNoError; |
| 7405 } | 7472 } |
| 7406 | 7473 |
| 7407 // Include the auto-generated part of this file. We split this because it means | 7474 // Include the auto-generated part of this file. We split this because it means |
| 7408 // we can easily edit the non-auto generated parts right here in this file | 7475 // we can easily edit the non-auto generated parts right here in this file |
| 7409 // instead of having to edit some template or the code generator. | 7476 // instead of having to edit some template or the code generator. |
| 7410 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 7477 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 7411 | 7478 |
| 7412 } // namespace gles2 | 7479 } // namespace gles2 |
| 7413 } // namespace gpu | 7480 } // namespace gpu |
| OLD | NEW |