OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 virtual Error DoCommand(unsigned int command, | 663 virtual Error DoCommand(unsigned int command, |
664 unsigned int arg_count, | 664 unsigned int arg_count, |
665 const void* args); | 665 const void* args); |
666 | 666 |
667 // Overridden from AsyncAPIInterface. | 667 // Overridden from AsyncAPIInterface. |
668 virtual const char* GetCommandName(unsigned int command_id) const; | 668 virtual const char* GetCommandName(unsigned int command_id) const; |
669 | 669 |
670 // Overridden from GLES2Decoder. | 670 // Overridden from GLES2Decoder. |
671 virtual bool Initialize(gfx::GLContext* context, | 671 virtual bool Initialize(gfx::GLContext* context, |
672 const gfx::Size& size, | 672 const gfx::Size& size, |
| 673 const DisallowedExtensions& disallowed_extensions, |
673 const char* allowed_extensions, | 674 const char* allowed_extensions, |
674 const std::vector<int32>& attribs, | 675 const std::vector<int32>& attribs, |
675 GLES2Decoder* parent, | 676 GLES2Decoder* parent, |
676 uint32 parent_client_texture_id); | 677 uint32 parent_client_texture_id); |
677 virtual void Destroy(); | 678 virtual void Destroy(); |
678 virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size); | 679 virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size); |
679 virtual bool UpdateOffscreenFrameBufferSize(); | 680 virtual bool UpdateOffscreenFrameBufferSize(); |
680 virtual bool MakeCurrent(); | 681 virtual bool MakeCurrent(); |
681 virtual GLES2Util* GetGLES2Util() { return &util_; } | 682 virtual GLES2Util* GetGLES2Util() { return &util_; } |
682 virtual gfx::GLContext* GetGLContext() { return context_.get(); } | 683 virtual gfx::GLContext* GetGLContext() { return context_.get(); } |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 // The last error message set. | 1436 // The last error message set. |
1436 std::string last_error_; | 1437 std::string last_error_; |
1437 | 1438 |
1438 // The current decoder error. | 1439 // The current decoder error. |
1439 error::Error current_decoder_error_; | 1440 error::Error current_decoder_error_; |
1440 | 1441 |
1441 bool use_shader_translator_; | 1442 bool use_shader_translator_; |
1442 scoped_ptr<ShaderTranslator> vertex_translator_; | 1443 scoped_ptr<ShaderTranslator> vertex_translator_; |
1443 scoped_ptr<ShaderTranslator> fragment_translator_; | 1444 scoped_ptr<ShaderTranslator> fragment_translator_; |
1444 | 1445 |
| 1446 DisallowedExtensions disallowed_extensions_; |
| 1447 |
1445 // Cached from ContextGroup | 1448 // Cached from ContextGroup |
1446 const Validators* validators_; | 1449 const Validators* validators_; |
1447 FeatureInfo* feature_info_; | 1450 FeatureInfo* feature_info_; |
1448 | 1451 |
1449 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1452 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
1450 }; | 1453 }; |
1451 | 1454 |
1452 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1455 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
1453 : decoder_(decoder) { | 1456 : decoder_(decoder) { |
1454 decoder_->CopyRealGLErrorsToWrapper(); | 1457 decoder_->CopyRealGLErrorsToWrapper(); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the | 1783 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the |
1781 // empty string to CompileShader and this is not a valid shader. | 1784 // empty string to CompileShader and this is not a valid shader. |
1782 // TODO(apatrick): fix this test. | 1785 // TODO(apatrick): fix this test. |
1783 if ((gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && | 1786 if ((gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && |
1784 !feature_info_->feature_flags().chromium_webglsl) || | 1787 !feature_info_->feature_flags().chromium_webglsl) || |
1785 gfx::GetGLImplementation() == gfx::kGLImplementationMockGL) { | 1788 gfx::GetGLImplementation() == gfx::kGLImplementationMockGL) { |
1786 use_shader_translator_ = false; | 1789 use_shader_translator_ = false; |
1787 } | 1790 } |
1788 } | 1791 } |
1789 | 1792 |
1790 bool GLES2DecoderImpl::Initialize(gfx::GLContext* context, | 1793 bool GLES2DecoderImpl::Initialize( |
1791 const gfx::Size& size, | 1794 gfx::GLContext* context, |
1792 const char* allowed_extensions, | 1795 const gfx::Size& size, |
1793 const std::vector<int32>& attribs, | 1796 const DisallowedExtensions& disallowed_extensions, |
1794 GLES2Decoder* parent, | 1797 const char* allowed_extensions, |
1795 uint32 parent_client_texture_id) { | 1798 const std::vector<int32>& attribs, |
| 1799 GLES2Decoder* parent, |
| 1800 uint32 parent_client_texture_id) { |
1796 DCHECK(context); | 1801 DCHECK(context); |
1797 DCHECK(!context_.get()); | 1802 DCHECK(!context_.get()); |
1798 | 1803 |
1799 // Take ownership of the GLContext. | 1804 // Take ownership of the GLContext. |
1800 context_.reset(context); | 1805 context_.reset(context); |
1801 | 1806 |
1802 // Keep only a weak pointer to the parent so we don't unmap its client | 1807 // Keep only a weak pointer to the parent so we don't unmap its client |
1803 // frame buffer after it has been destroyed. | 1808 // frame buffer after it has been destroyed. |
1804 if (parent) | 1809 if (parent) |
1805 parent_ = static_cast<GLES2DecoderImpl*>(parent)->AsWeakPtr(); | 1810 parent_ = static_cast<GLES2DecoderImpl*>(parent)->AsWeakPtr(); |
1806 | 1811 |
1807 if (!MakeCurrent()) { | 1812 if (!MakeCurrent()) { |
1808 LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because " | 1813 LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because " |
1809 << "MakeCurrent failed."; | 1814 << "MakeCurrent failed."; |
1810 Destroy(); | 1815 Destroy(); |
1811 return false; | 1816 return false; |
1812 } | 1817 } |
1813 | 1818 |
1814 if (!group_->Initialize(allowed_extensions)) { | 1819 if (!group_->Initialize(disallowed_extensions, allowed_extensions)) { |
1815 LOG(ERROR) << "GPUProcessor::InitializeCommon failed because group " | 1820 LOG(ERROR) << "GPUProcessor::InitializeCommon failed because group " |
1816 << "failed to initialize."; | 1821 << "failed to initialize."; |
1817 Destroy(); | 1822 Destroy(); |
1818 return false; | 1823 return false; |
1819 } | 1824 } |
1820 | 1825 |
1821 CHECK_GL_ERROR(); | 1826 CHECK_GL_ERROR(); |
| 1827 disallowed_extensions_ = disallowed_extensions; |
1822 | 1828 |
1823 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); | 1829 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); |
1824 | 1830 |
1825 GLint v = 0; | 1831 GLint v = 0; |
1826 glGetIntegerv(GL_ALPHA_BITS, &v); | 1832 glGetIntegerv(GL_ALPHA_BITS, &v); |
1827 back_buffer_color_format_ = v ? GL_RGBA : GL_RGB; | 1833 back_buffer_color_format_ = v ? GL_RGBA : GL_RGB; |
1828 | 1834 |
1829 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 1835 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
1830 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 1836 // We have to enable vertex array 0 on OpenGL or it won't render. Note that |
1831 // OpenGL ES 2.0 does not have this issue. | 1837 // OpenGL ES 2.0 does not have this issue. |
(...skipping 4329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6161 | 6167 |
6162 *result = 1; // true. | 6168 *result = 1; // true. |
6163 return error::kNoError; | 6169 return error::kNoError; |
6164 } | 6170 } |
6165 | 6171 |
6166 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( | 6172 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( |
6167 uint32 immediate_data_size, | 6173 uint32 immediate_data_size, |
6168 const gles2::GetRequestableExtensionsCHROMIUM& c) { | 6174 const gles2::GetRequestableExtensionsCHROMIUM& c) { |
6169 Bucket* bucket = CreateBucket(c.bucket_id); | 6175 Bucket* bucket = CreateBucket(c.bucket_id); |
6170 scoped_ptr<FeatureInfo> info(new FeatureInfo()); | 6176 scoped_ptr<FeatureInfo> info(new FeatureInfo()); |
6171 info->Initialize(NULL); | 6177 info->Initialize(disallowed_extensions_, NULL); |
6172 bucket->SetFromString(info->extensions().c_str()); | 6178 bucket->SetFromString(info->extensions().c_str()); |
6173 return error::kNoError; | 6179 return error::kNoError; |
6174 } | 6180 } |
6175 | 6181 |
6176 error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( | 6182 error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( |
6177 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { | 6183 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { |
6178 Bucket* bucket = GetBucket(c.bucket_id); | 6184 Bucket* bucket = GetBucket(c.bucket_id); |
6179 std::string feature_str; | 6185 std::string feature_str; |
6180 if (!bucket->GetAsString(&feature_str)) { | 6186 if (!bucket->GetAsString(&feature_str)) { |
6181 return error::kInvalidArguments; | 6187 return error::kInvalidArguments; |
(...skipping 18 matching lines...) Expand all Loading... |
6200 return error::kNoError; | 6206 return error::kNoError; |
6201 } | 6207 } |
6202 | 6208 |
6203 // Include the auto-generated part of this file. We split this because it means | 6209 // Include the auto-generated part of this file. We split this because it means |
6204 // we can easily edit the non-auto generated parts right here in this file | 6210 // we can easily edit the non-auto generated parts right here in this file |
6205 // instead of having to edit some template or the code generator. | 6211 // instead of having to edit some template or the code generator. |
6206 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6212 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
6207 | 6213 |
6208 } // namespace gles2 | 6214 } // namespace gles2 |
6209 } // namespace gpu | 6215 } // namespace gpu |
OLD | NEW |