Chromium Code Reviews| 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& disalloowed, | |
|
zmo
2011/03/07 23:34:29
an extra o, also, it would be better to use disall
| |
| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(gfx::GLContext* context, |
| 1791 const gfx::Size& size, | 1794 const gfx::Size& size, |
| 1795 const DisallowedExtensions& disallowed, | |
| 1792 const char* allowed_extensions, | 1796 const char* allowed_extensions, |
| 1793 const std::vector<int32>& attribs, | 1797 const std::vector<int32>& attribs, |
| 1794 GLES2Decoder* parent, | 1798 GLES2Decoder* parent, |
| 1795 uint32 parent_client_texture_id) { | 1799 uint32 parent_client_texture_id) { |
| 1796 DCHECK(context); | 1800 DCHECK(context); |
| 1797 DCHECK(!context_.get()); | 1801 DCHECK(!context_.get()); |
| 1798 | 1802 |
| 1799 // Take ownership of the GLContext. | 1803 // Take ownership of the GLContext. |
| 1800 context_.reset(context); | 1804 context_.reset(context); |
| 1801 | 1805 |
| 1802 // Keep only a weak pointer to the parent so we don't unmap its client | 1806 // Keep only a weak pointer to the parent so we don't unmap its client |
| 1803 // frame buffer after it has been destroyed. | 1807 // frame buffer after it has been destroyed. |
| 1804 if (parent) | 1808 if (parent) |
| 1805 parent_ = static_cast<GLES2DecoderImpl*>(parent)->AsWeakPtr(); | 1809 parent_ = static_cast<GLES2DecoderImpl*>(parent)->AsWeakPtr(); |
| 1806 | 1810 |
| 1807 if (!MakeCurrent()) { | 1811 if (!MakeCurrent()) { |
| 1808 LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because " | 1812 LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because " |
| 1809 << "MakeCurrent failed."; | 1813 << "MakeCurrent failed."; |
| 1810 Destroy(); | 1814 Destroy(); |
| 1811 return false; | 1815 return false; |
| 1812 } | 1816 } |
| 1813 | 1817 |
| 1814 if (!group_->Initialize(allowed_extensions)) { | 1818 if (!group_->Initialize(disallowed, allowed_extensions)) { |
| 1815 LOG(ERROR) << "GPUProcessor::InitializeCommon failed because group " | 1819 LOG(ERROR) << "GPUProcessor::InitializeCommon failed because group " |
| 1816 << "failed to initialize."; | 1820 << "failed to initialize."; |
| 1817 Destroy(); | 1821 Destroy(); |
| 1818 return false; | 1822 return false; |
| 1819 } | 1823 } |
| 1820 | 1824 |
| 1821 CHECK_GL_ERROR(); | 1825 CHECK_GL_ERROR(); |
| 1826 disallowed_extensions_ = disallowed; | |
| 1822 | 1827 |
| 1823 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); | 1828 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); |
| 1824 | 1829 |
| 1825 GLint v = 0; | 1830 GLint v = 0; |
| 1826 glGetIntegerv(GL_ALPHA_BITS, &v); | 1831 glGetIntegerv(GL_ALPHA_BITS, &v); |
| 1827 back_buffer_color_format_ = v ? GL_RGBA : GL_RGB; | 1832 back_buffer_color_format_ = v ? GL_RGBA : GL_RGB; |
| 1828 | 1833 |
| 1829 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 1834 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 1830 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 1835 // 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. | 1836 // OpenGL ES 2.0 does not have this issue. |
| (...skipping 4281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6113 | 6118 |
| 6114 *result = 1; // true. | 6119 *result = 1; // true. |
| 6115 return error::kNoError; | 6120 return error::kNoError; |
| 6116 } | 6121 } |
| 6117 | 6122 |
| 6118 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( | 6123 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( |
| 6119 uint32 immediate_data_size, | 6124 uint32 immediate_data_size, |
| 6120 const gles2::GetRequestableExtensionsCHROMIUM& c) { | 6125 const gles2::GetRequestableExtensionsCHROMIUM& c) { |
| 6121 Bucket* bucket = CreateBucket(c.bucket_id); | 6126 Bucket* bucket = CreateBucket(c.bucket_id); |
| 6122 scoped_ptr<FeatureInfo> info(new FeatureInfo()); | 6127 scoped_ptr<FeatureInfo> info(new FeatureInfo()); |
| 6123 info->Initialize(NULL); | 6128 info->Initialize(disallowed_extensions_, NULL); |
| 6124 bucket->SetFromString(info->extensions().c_str()); | 6129 bucket->SetFromString(info->extensions().c_str()); |
| 6125 return error::kNoError; | 6130 return error::kNoError; |
| 6126 } | 6131 } |
| 6127 | 6132 |
| 6128 error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( | 6133 error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( |
| 6129 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { | 6134 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { |
| 6130 Bucket* bucket = GetBucket(c.bucket_id); | 6135 Bucket* bucket = GetBucket(c.bucket_id); |
| 6131 std::string feature_str; | 6136 std::string feature_str; |
| 6132 if (!bucket->GetAsString(&feature_str)) { | 6137 if (!bucket->GetAsString(&feature_str)) { |
| 6133 return error::kInvalidArguments; | 6138 return error::kInvalidArguments; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 6152 return error::kNoError; | 6157 return error::kNoError; |
| 6153 } | 6158 } |
| 6154 | 6159 |
| 6155 // Include the auto-generated part of this file. We split this because it means | 6160 // Include the auto-generated part of this file. We split this because it means |
| 6156 // we can easily edit the non-auto generated parts right here in this file | 6161 // we can easily edit the non-auto generated parts right here in this file |
| 6157 // instead of having to edit some template or the code generator. | 6162 // instead of having to edit some template or the code generator. |
| 6158 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6163 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 6159 | 6164 |
| 6160 } // namespace gles2 | 6165 } // namespace gles2 |
| 6161 } // namespace gpu | 6166 } // namespace gpu |
| OLD | NEW |