OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <vector> | 9 #include <vector> |
10 #include <string> | 10 #include <string> |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 bool CanAccess(GLuint index); | 406 bool CanAccess(GLuint index); |
407 | 407 |
408 void set_enabled(bool enabled) { | 408 void set_enabled(bool enabled) { |
409 enabled_ = enabled; | 409 enabled_ = enabled; |
410 } | 410 } |
411 | 411 |
412 GLuint buffer() const { | 412 GLuint buffer() const { |
413 return buffer_; | 413 return buffer_; |
414 } | 414 } |
415 | 415 |
| 416 GLsizei offset() const { |
| 417 return offset_; |
| 418 } |
| 419 |
416 void Clear() { | 420 void Clear() { |
417 buffer_ = 0; | 421 buffer_ = 0; |
418 SetBufferSize(0); | 422 SetBufferSize(0); |
419 } | 423 } |
420 | 424 |
421 void SetBufferSize(GLsizeiptr buffer_size) { | 425 void SetBufferSize(GLsizeiptr buffer_size) { |
422 buffer_size_ = buffer_size; | 426 buffer_size_ = buffer_size; |
423 if (offset_ > buffer_size || real_stride_ == 0) { | 427 if (offset_ > buffer_size || real_stride_ == 0) { |
424 num_elements_ = 0; | 428 num_elements_ = 0; |
425 } else { | 429 } else { |
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 const void* data = NULL; | 1723 const void* data = NULL; |
1720 if (data_shm_id != 0 || data_shm_offset != 0) { | 1724 if (data_shm_id != 0 || data_shm_offset != 0) { |
1721 data = GetSharedMemoryAs<const void*>( | 1725 data = GetSharedMemoryAs<const void*>( |
1722 data_shm_id, data_shm_offset, image_size); | 1726 data_shm_id, data_shm_offset, image_size); |
1723 if (!data) { | 1727 if (!data) { |
1724 return parse_error::kParseOutOfBounds; | 1728 return parse_error::kParseOutOfBounds; |
1725 } | 1729 } |
1726 } | 1730 } |
1727 // TODO(gman): Validate internal_format | 1731 // TODO(gman): Validate internal_format |
1728 if (!ValidateGLenumTextureTarget(target)) { | 1732 if (!ValidateGLenumTextureTarget(target)) { |
1729 SetGLError(GL_INVALID_VALUE); | 1733 SetGLError(GL_INVALID_ENUM); |
1730 return parse_error::kParseNoError; | 1734 return parse_error::kParseNoError; |
1731 } | 1735 } |
1732 scoped_array<int8> zero; | 1736 scoped_array<int8> zero; |
1733 if (!data) { | 1737 if (!data) { |
1734 zero.reset(new int8[image_size]); | 1738 zero.reset(new int8[image_size]); |
1735 memset(zero.get(), 0, image_size); | 1739 memset(zero.get(), 0, image_size); |
1736 data = zero.get(); | 1740 data = zero.get(); |
1737 } | 1741 } |
1738 glCompressedTexImage2D( | 1742 glCompressedTexImage2D( |
1739 target, level, internal_format, width, height, border, image_size, data); | 1743 target, level, internal_format, width, height, border, image_size, data); |
1740 return parse_error::kParseNoError; | 1744 return parse_error::kParseNoError; |
1741 } | 1745 } |
1742 | 1746 |
1743 parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexImage2DImmediate( | 1747 parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexImage2DImmediate( |
1744 uint32 immediate_data_size, const gles2::CompressedTexImage2DImmediate& c) { | 1748 uint32 immediate_data_size, const gles2::CompressedTexImage2DImmediate& c) { |
1745 GLenum target = static_cast<GLenum>(c.target); | 1749 GLenum target = static_cast<GLenum>(c.target); |
1746 GLint level = static_cast<GLint>(c.level); | 1750 GLint level = static_cast<GLint>(c.level); |
1747 GLenum internal_format = static_cast<GLenum>(c.internalformat); | 1751 GLenum internal_format = static_cast<GLenum>(c.internalformat); |
1748 GLsizei width = static_cast<GLsizei>(c.width); | 1752 GLsizei width = static_cast<GLsizei>(c.width); |
1749 GLsizei height = static_cast<GLsizei>(c.height); | 1753 GLsizei height = static_cast<GLsizei>(c.height); |
1750 GLint border = static_cast<GLint>(c.border); | 1754 GLint border = static_cast<GLint>(c.border); |
1751 GLsizei image_size = static_cast<GLsizei>(c.imageSize); | 1755 GLsizei image_size = static_cast<GLsizei>(c.imageSize); |
1752 const void* data = GetImmediateDataAs<const void*>( | 1756 const void* data = GetImmediateDataAs<const void*>( |
1753 c, image_size, immediate_data_size); | 1757 c, image_size, immediate_data_size); |
1754 if (!data) { | 1758 if (!data) { |
1755 return parse_error::kParseOutOfBounds; | 1759 return parse_error::kParseOutOfBounds; |
1756 } | 1760 } |
1757 // TODO(gman): Validate internal_format | 1761 // TODO(gman): Validate internal_format |
1758 if (!ValidateGLenumTextureTarget(target)) { | 1762 if (!ValidateGLenumTextureTarget(target)) { |
1759 SetGLError(GL_INVALID_VALUE); | 1763 SetGLError(GL_INVALID_ENUM); |
1760 return parse_error::kParseNoError; | 1764 return parse_error::kParseNoError; |
1761 } | 1765 } |
1762 glCompressedTexImage2D( | 1766 glCompressedTexImage2D( |
1763 target, level, internal_format, width, height, border, image_size, data); | 1767 target, level, internal_format, width, height, border, image_size, data); |
1764 return parse_error::kParseNoError; | 1768 return parse_error::kParseNoError; |
1765 } | 1769 } |
1766 | 1770 |
1767 parse_error::ParseError GLES2DecoderImpl::HandleTexImage2D( | 1771 parse_error::ParseError GLES2DecoderImpl::HandleTexImage2D( |
1768 uint32 immediate_data_size, const gles2::TexImage2D& c) { | 1772 uint32 immediate_data_size, const gles2::TexImage2D& c) { |
1769 GLenum target = static_cast<GLenum>(c.target); | 1773 GLenum target = static_cast<GLenum>(c.target); |
(...skipping 13 matching lines...) Expand all Loading... |
1783 pixels = GetSharedMemoryAs<const void*>( | 1787 pixels = GetSharedMemoryAs<const void*>( |
1784 pixels_shm_id, pixels_shm_offset, pixels_size); | 1788 pixels_shm_id, pixels_shm_offset, pixels_size); |
1785 if (!pixels) { | 1789 if (!pixels) { |
1786 return parse_error::kParseOutOfBounds; | 1790 return parse_error::kParseOutOfBounds; |
1787 } | 1791 } |
1788 } | 1792 } |
1789 if (!ValidateGLenumTextureTarget(target) || | 1793 if (!ValidateGLenumTextureTarget(target) || |
1790 !ValidateGLenumTextureFormat(internal_format) || | 1794 !ValidateGLenumTextureFormat(internal_format) || |
1791 !ValidateGLenumTextureFormat(format) || | 1795 !ValidateGLenumTextureFormat(format) || |
1792 !ValidateGLenumPixelType(type)) { | 1796 !ValidateGLenumPixelType(type)) { |
1793 SetGLError(GL_INVALID_VALUE); | 1797 SetGLError(GL_INVALID_ENUM); |
1794 return parse_error::kParseNoError; | 1798 return parse_error::kParseNoError; |
1795 } | 1799 } |
1796 scoped_array<int8> zero; | 1800 scoped_array<int8> zero; |
1797 if (!pixels) { | 1801 if (!pixels) { |
1798 zero.reset(new int8[pixels_size]); | 1802 zero.reset(new int8[pixels_size]); |
1799 memset(zero.get(), 0, pixels_size); | 1803 memset(zero.get(), 0, pixels_size); |
1800 pixels = zero.get(); | 1804 pixels = zero.get(); |
1801 } | 1805 } |
1802 glTexImage2D( | 1806 glTexImage2D( |
1803 target, level, internal_format, width, height, border, format, type, | 1807 target, level, internal_format, width, height, border, format, type, |
(...skipping 15 matching lines...) Expand all Loading... |
1819 width, height, format, type, unpack_alignment_); | 1823 width, height, format, type, unpack_alignment_); |
1820 const void* pixels = GetImmediateDataAs<const void*>( | 1824 const void* pixels = GetImmediateDataAs<const void*>( |
1821 c, size, immediate_data_size); | 1825 c, size, immediate_data_size); |
1822 if (!pixels) { | 1826 if (!pixels) { |
1823 return parse_error::kParseOutOfBounds; | 1827 return parse_error::kParseOutOfBounds; |
1824 } | 1828 } |
1825 if (!ValidateGLenumTextureTarget(target) || | 1829 if (!ValidateGLenumTextureTarget(target) || |
1826 !ValidateGLenumTextureFormat(internal_format) || | 1830 !ValidateGLenumTextureFormat(internal_format) || |
1827 !ValidateGLenumTextureFormat(format) || | 1831 !ValidateGLenumTextureFormat(format) || |
1828 !ValidateGLenumPixelType(type)) { | 1832 !ValidateGLenumPixelType(type)) { |
1829 SetGLError(GL_INVALID_VALUE); | 1833 SetGLError(GL_INVALID_ENUM); |
1830 return parse_error::kParseNoError; | 1834 return parse_error::kParseNoError; |
1831 } | 1835 } |
1832 glTexImage2D( | 1836 glTexImage2D( |
1833 target, level, internal_format, width, height, border, format, type, | 1837 target, level, internal_format, width, height, border, format, type, |
1834 pixels); | 1838 pixels); |
1835 return parse_error::kParseNoError; | 1839 return parse_error::kParseNoError; |
1836 } | 1840 } |
1837 | 1841 |
1838 parse_error::ParseError GLES2DecoderImpl::HandleGetVertexAttribPointerv( | 1842 parse_error::ParseError GLES2DecoderImpl::HandleGetVertexAttribPointerv( |
1839 uint32 immediate_data_size, const gles2::GetVertexAttribPointerv& c) { | 1843 uint32 immediate_data_size, const gles2::GetVertexAttribPointerv& c) { |
1840 // TODO(gman): Implement. | 1844 GLuint index = static_cast<GLuint>(c.index); |
| 1845 GLenum pname = static_cast<GLenum>(c.pname); |
| 1846 SizedResult* result = GetSharedMemoryAs<SizedResult*>( |
| 1847 c.pointer_shm_id, c.pointer_shm_offset, sizeof(SizedResult)); |
| 1848 if (!result) { |
| 1849 return parse_error::kParseOutOfBounds; |
| 1850 } |
| 1851 result->size = 0; |
| 1852 if (!ValidateGLenumVertexPointer(pname)) { |
| 1853 SetGLError(GL_INVALID_ENUM); |
| 1854 return parse_error::kParseNoError; |
| 1855 } |
| 1856 if (index >= max_vertex_attribs_) { |
| 1857 SetGLError(GL_INVALID_VALUE); |
| 1858 return parse_error::kParseNoError; |
| 1859 } |
| 1860 result->size = sizeof(GLuint); |
| 1861 *result->GetDataAs<GLuint*>() = vertex_attrib_infos_[index].offset(); |
1841 return parse_error::kParseNoError; | 1862 return parse_error::kParseNoError; |
1842 } | 1863 } |
1843 | 1864 |
1844 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformiv( | 1865 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformiv( |
1845 uint32 immediate_data_size, const gles2::GetUniformiv& c) { | 1866 uint32 immediate_data_size, const gles2::GetUniformiv& c) { |
1846 // TODO(gman): Implement. | 1867 // TODO(gman): Implement. |
| 1868 NOTREACHED(); |
1847 return parse_error::kParseNoError; | 1869 return parse_error::kParseNoError; |
1848 } | 1870 } |
1849 | 1871 |
1850 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformfv( | 1872 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformfv( |
1851 uint32 immediate_data_size, const gles2::GetUniformfv& c) { | 1873 uint32 immediate_data_size, const gles2::GetUniformfv& c) { |
1852 // TODO(gman): Implement. | 1874 // TODO(gman): Implement. |
| 1875 NOTREACHED(); |
1853 return parse_error::kParseNoError; | 1876 return parse_error::kParseNoError; |
1854 } | 1877 } |
1855 | 1878 |
1856 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderPrecisionFormat( | 1879 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderPrecisionFormat( |
1857 uint32 immediate_data_size, const gles2::GetShaderPrecisionFormat& c) { | 1880 uint32 immediate_data_size, const gles2::GetShaderPrecisionFormat& c) { |
1858 // TODO(gman): Implement. | 1881 // TODO(gman): Implement. |
| 1882 NOTREACHED(); |
1859 return parse_error::kParseNoError; | 1883 return parse_error::kParseNoError; |
1860 } | 1884 } |
1861 | 1885 |
1862 parse_error::ParseError GLES2DecoderImpl::HandleGetAttachedShaders( | 1886 parse_error::ParseError GLES2DecoderImpl::HandleGetAttachedShaders( |
1863 uint32 immediate_data_size, const gles2::GetAttachedShaders& c) { | 1887 uint32 immediate_data_size, const gles2::GetAttachedShaders& c) { |
1864 // TODO(gman): Implement. | 1888 // TODO(gman): Implement. |
| 1889 NOTREACHED(); |
1865 return parse_error::kParseNoError; | 1890 return parse_error::kParseNoError; |
1866 } | 1891 } |
1867 | 1892 |
1868 parse_error::ParseError GLES2DecoderImpl::HandleGetActiveUniform( | 1893 parse_error::ParseError GLES2DecoderImpl::HandleGetActiveUniform( |
1869 uint32 immediate_data_size, const gles2::GetActiveUniform& c) { | 1894 uint32 immediate_data_size, const gles2::GetActiveUniform& c) { |
1870 // TODO(gman): Implement. | 1895 // TODO(gman): Implement. |
| 1896 NOTREACHED(); |
1871 return parse_error::kParseNoError; | 1897 return parse_error::kParseNoError; |
1872 } | 1898 } |
1873 | 1899 |
1874 parse_error::ParseError GLES2DecoderImpl::HandleGetActiveAttrib( | 1900 parse_error::ParseError GLES2DecoderImpl::HandleGetActiveAttrib( |
1875 uint32 immediate_data_size, const gles2::GetActiveAttrib& c) { | 1901 uint32 immediate_data_size, const gles2::GetActiveAttrib& c) { |
1876 // TODO(gman): Implement. | 1902 // TODO(gman): Implement. |
| 1903 NOTREACHED(); |
1877 return parse_error::kParseNoError; | 1904 return parse_error::kParseNoError; |
1878 } | 1905 } |
1879 | 1906 |
1880 // Include the auto-generated part of this file. We split this because it means | 1907 // Include the auto-generated part of this file. We split this because it means |
1881 // we can easily edit the non-auto generated parts right here in this file | 1908 // we can easily edit the non-auto generated parts right here in this file |
1882 // instead of having to edit some template or the code generator. | 1909 // instead of having to edit some template or the code generator. |
1883 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 1910 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
1884 | 1911 |
1885 } // namespace gles2 | 1912 } // namespace gles2 |
1886 } // namespace gpu | 1913 } // namespace gpu |
OLD | NEW |