OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 void EnsureTextureForClientId(GLenum target, GLuint client_id); | 1034 void EnsureTextureForClientId(GLenum target, GLuint client_id); |
1035 void DoConsumeTextureCHROMIUM(GLenum target, const volatile GLbyte* key); | 1035 void DoConsumeTextureCHROMIUM(GLenum target, const volatile GLbyte* key); |
1036 void DoCreateAndConsumeTextureINTERNAL(GLenum target, | 1036 void DoCreateAndConsumeTextureINTERNAL(GLenum target, |
1037 GLuint client_id, | 1037 GLuint client_id, |
1038 const volatile GLbyte* key); | 1038 const volatile GLbyte* key); |
1039 void DoApplyScreenSpaceAntialiasingCHROMIUM(); | 1039 void DoApplyScreenSpaceAntialiasingCHROMIUM(); |
1040 | 1040 |
1041 void DoBindTexImage2DCHROMIUM( | 1041 void DoBindTexImage2DCHROMIUM( |
1042 GLenum target, | 1042 GLenum target, |
1043 GLint image_id); | 1043 GLint image_id); |
1044 void DoBindTexImage2DWithInternalformatCHROMIUM(GLenum target, | |
1045 GLenum internalformat, | |
1046 GLint image_id); | |
1047 // Common implementation of DoBindTexImage2DCHROMIUM entry points. | |
1048 void BindTexImage2DCHROMIUMImpl(const char* function_name, | |
1049 GLenum target, | |
1050 GLenum internalformat, | |
1051 GLint image_id); | |
1052 void DoReleaseTexImage2DCHROMIUM( | 1044 void DoReleaseTexImage2DCHROMIUM( |
1053 GLenum target, | 1045 GLenum target, |
1054 GLint image_id); | 1046 GLint image_id); |
1055 | 1047 |
1056 void DoTraceEndCHROMIUM(void); | 1048 void DoTraceEndCHROMIUM(void); |
1057 | 1049 |
1058 void DoDrawBuffersEXT(GLsizei count, const volatile GLenum* bufs); | 1050 void DoDrawBuffersEXT(GLsizei count, const volatile GLenum* bufs); |
1059 | 1051 |
1060 void DoLoseContextCHROMIUM(GLenum current, GLenum other); | 1052 void DoLoseContextCHROMIUM(GLenum current, GLenum other); |
1061 | 1053 |
(...skipping 16702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17764 GLsizei /*length*/, const GLchar* /*marker*/) { | 17756 GLsizei /*length*/, const GLchar* /*marker*/) { |
17765 } | 17757 } |
17766 | 17758 |
17767 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { | 17759 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { |
17768 } | 17760 } |
17769 | 17761 |
17770 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( | 17762 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( |
17771 GLenum target, GLint image_id) { | 17763 GLenum target, GLint image_id) { |
17772 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); | 17764 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); |
17773 | 17765 |
17774 BindTexImage2DCHROMIUMImpl("glBindTexImage2DCHROMIUM", target, 0, image_id); | |
17775 } | |
17776 | |
17777 void GLES2DecoderImpl::DoBindTexImage2DWithInternalformatCHROMIUM( | |
17778 GLenum target, | |
17779 GLenum internalformat, | |
17780 GLint image_id) { | |
17781 TRACE_EVENT0("gpu", | |
17782 "GLES2DecoderImpl::DoBindTexImage2DWithInternalformatCHROMIUM"); | |
17783 | |
17784 BindTexImage2DCHROMIUMImpl("glBindTexImage2DWithInternalformatCHROMIUM", | |
17785 target, internalformat, image_id); | |
17786 } | |
17787 | |
17788 void GLES2DecoderImpl::BindTexImage2DCHROMIUMImpl(const char* function_name, | |
17789 GLenum target, | |
17790 GLenum internalformat, | |
17791 GLint image_id) { | |
17792 if (target == GL_TEXTURE_CUBE_MAP) { | 17766 if (target == GL_TEXTURE_CUBE_MAP) { |
17793 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, function_name, "invalid target"); | 17767 LOCAL_SET_GL_ERROR( |
| 17768 GL_INVALID_ENUM, |
| 17769 "glBindTexImage2DCHROMIUM", "invalid target"); |
17794 return; | 17770 return; |
17795 } | 17771 } |
17796 | 17772 |
17797 // Default target might be conceptually valid, but disallow it to avoid | 17773 // Default target might be conceptually valid, but disallow it to avoid |
17798 // accidents. | 17774 // accidents. |
17799 TextureRef* texture_ref = | 17775 TextureRef* texture_ref = |
17800 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 17776 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
17801 if (!texture_ref) { | 17777 if (!texture_ref) { |
17802 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, "no texture bound"); | 17778 LOCAL_SET_GL_ERROR( |
| 17779 GL_INVALID_OPERATION, |
| 17780 "glBindTexImage2DCHROMIUM", "no texture bound"); |
17803 return; | 17781 return; |
17804 } | 17782 } |
17805 | 17783 |
17806 gl::GLImage* image = image_manager()->LookupImage(image_id); | 17784 gl::GLImage* image = image_manager()->LookupImage(image_id); |
17807 if (!image) { | 17785 if (!image) { |
17808 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 17786 LOCAL_SET_GL_ERROR( |
17809 "no image found with the given ID"); | 17787 GL_INVALID_OPERATION, |
| 17788 "glBindTexImage2DCHROMIUM", "no image found with the given ID"); |
17810 return; | 17789 return; |
17811 } | 17790 } |
17812 | 17791 |
17813 Texture::ImageState image_state = Texture::UNBOUND; | 17792 Texture::ImageState image_state = Texture::UNBOUND; |
17814 | 17793 |
17815 { | 17794 { |
17816 ScopedGLErrorSuppressor suppressor( | 17795 ScopedGLErrorSuppressor suppressor( |
17817 "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM", GetErrorState()); | 17796 "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM", GetErrorState()); |
17818 | 17797 |
17819 // Note: We fallback to using CopyTexImage() before the texture is used | 17798 // Note: We fallback to using CopyTexImage() before the texture is used |
17820 // when BindTexImage() fails. | 17799 // when BindTexImage() fails. |
17821 if (internalformat) { | 17800 if (image->BindTexImage(target)) |
17822 if (image->BindTexImageWithInternalformat(target, internalformat)) | 17801 image_state = Texture::BOUND; |
17823 image_state = Texture::BOUND; | |
17824 } else { | |
17825 if (image->BindTexImage(target)) | |
17826 image_state = Texture::BOUND; | |
17827 } | |
17828 } | 17802 } |
17829 | 17803 |
17830 gfx::Size size = image->GetSize(); | 17804 gfx::Size size = image->GetSize(); |
17831 GLenum texture_internalformat = | 17805 GLenum internalformat = image->GetInternalFormat(); |
17832 internalformat ? internalformat : image->GetInternalFormat(); | 17806 texture_manager()->SetLevelInfo( |
17833 texture_manager()->SetLevelInfo(texture_ref, target, 0, | 17807 texture_ref, target, 0, internalformat, size.width(), size.height(), 1, 0, |
17834 texture_internalformat, size.width(), | 17808 internalformat, GL_UNSIGNED_BYTE, gfx::Rect(size)); |
17835 size.height(), 1, 0, texture_internalformat, | |
17836 GL_UNSIGNED_BYTE, gfx::Rect(size)); | |
17837 texture_manager()->SetLevelImage(texture_ref, target, 0, image, image_state); | 17809 texture_manager()->SetLevelImage(texture_ref, target, 0, image, image_state); |
17838 } | 17810 } |
17839 | 17811 |
17840 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( | 17812 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( |
17841 GLenum target, GLint image_id) { | 17813 GLenum target, GLint image_id) { |
17842 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); | 17814 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM"); |
17843 | 17815 |
17844 // Default target might be conceptually valid, but disallow it to avoid | 17816 // Default target might be conceptually valid, but disallow it to avoid |
17845 // accidents. | 17817 // accidents. |
17846 TextureRef* texture_ref = | 17818 TextureRef* texture_ref = |
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19632 } | 19604 } |
19633 | 19605 |
19634 // Include the auto-generated part of this file. We split this because it means | 19606 // Include the auto-generated part of this file. We split this because it means |
19635 // we can easily edit the non-auto generated parts right here in this file | 19607 // we can easily edit the non-auto generated parts right here in this file |
19636 // instead of having to edit some template or the code generator. | 19608 // instead of having to edit some template or the code generator. |
19637 #include "base/macros.h" | 19609 #include "base/macros.h" |
19638 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19610 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
19639 | 19611 |
19640 } // namespace gles2 | 19612 } // namespace gles2 |
19641 } // namespace gpu | 19613 } // namespace gpu |
OLD | NEW |