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