| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 5628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5639 return; | 5639 return; |
| 5640 } | 5640 } |
| 5641 | 5641 |
| 5642 contextGL()->Uniform1f(location->location(), x); | 5642 contextGL()->Uniform1f(location->location(), x); |
| 5643 } | 5643 } |
| 5644 | 5644 |
| 5645 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, | 5645 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, |
| 5646 const FlexibleFloat32ArrayView& v) { | 5646 const FlexibleFloat32ArrayView& v) { |
| 5647 if (isContextLost() || | 5647 if (isContextLost() || |
| 5648 !validateUniformParameters<WTF::Float32Array>("uniform1fv", location, v, | 5648 !validateUniformParameters<WTF::Float32Array>("uniform1fv", location, v, |
| 5649 1)) | 5649 1, 0, v.length())) |
| 5650 return; | 5650 return; |
| 5651 | 5651 |
| 5652 contextGL()->Uniform1fv(location->location(), v.length(), | 5652 contextGL()->Uniform1fv(location->location(), v.length(), |
| 5653 v.dataMaybeOnStack()); | 5653 v.dataMaybeOnStack()); |
| 5654 } | 5654 } |
| 5655 | 5655 |
| 5656 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, | 5656 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, |
| 5657 Vector<GLfloat>& v) { | 5657 Vector<GLfloat>& v) { |
| 5658 if (isContextLost() || | 5658 if (isContextLost() || |
| 5659 !validateUniformParameters("uniform1fv", location, v.data(), v.size(), 1)) | 5659 !validateUniformParameters("uniform1fv", location, v.data(), v.size(), 1, |
| 5660 0, v.size())) |
| 5660 return; | 5661 return; |
| 5661 | 5662 |
| 5662 contextGL()->Uniform1fv(location->location(), v.size(), v.data()); | 5663 contextGL()->Uniform1fv(location->location(), v.size(), v.data()); |
| 5663 } | 5664 } |
| 5664 | 5665 |
| 5665 void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location, | 5666 void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location, |
| 5666 GLint x) { | 5667 GLint x) { |
| 5667 if (isContextLost() || !location) | 5668 if (isContextLost() || !location) |
| 5668 return; | 5669 return; |
| 5669 | 5670 |
| 5670 if (location->program() != m_currentProgram) { | 5671 if (location->program() != m_currentProgram) { |
| 5671 synthesizeGLError(GL_INVALID_OPERATION, "uniform1i", | 5672 synthesizeGLError(GL_INVALID_OPERATION, "uniform1i", |
| 5672 "location not for current program"); | 5673 "location not for current program"); |
| 5673 return; | 5674 return; |
| 5674 } | 5675 } |
| 5675 | 5676 |
| 5676 contextGL()->Uniform1i(location->location(), x); | 5677 contextGL()->Uniform1i(location->location(), x); |
| 5677 } | 5678 } |
| 5678 | 5679 |
| 5679 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, | 5680 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, |
| 5680 const FlexibleInt32ArrayView& v) { | 5681 const FlexibleInt32ArrayView& v) { |
| 5681 if (isContextLost() || | 5682 if (isContextLost() || |
| 5682 !validateUniformParameters<WTF::Int32Array>("uniform1iv", location, v, 1)) | 5683 !validateUniformParameters<WTF::Int32Array>("uniform1iv", location, v, 1, |
| 5684 0, v.length())) |
| 5683 return; | 5685 return; |
| 5684 | 5686 |
| 5685 contextGL()->Uniform1iv(location->location(), v.length(), | 5687 contextGL()->Uniform1iv(location->location(), v.length(), |
| 5686 v.dataMaybeOnStack()); | 5688 v.dataMaybeOnStack()); |
| 5687 } | 5689 } |
| 5688 | 5690 |
| 5689 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, | 5691 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, |
| 5690 Vector<GLint>& v) { | 5692 Vector<GLint>& v) { |
| 5691 if (isContextLost() || | 5693 if (isContextLost() || |
| 5692 !validateUniformParameters("uniform1iv", location, v.data(), v.size(), 1)) | 5694 !validateUniformParameters("uniform1iv", location, v.data(), v.size(), 1, |
| 5695 0, v.size())) |
| 5693 return; | 5696 return; |
| 5694 | 5697 |
| 5695 contextGL()->Uniform1iv(location->location(), v.size(), v.data()); | 5698 contextGL()->Uniform1iv(location->location(), v.size(), v.data()); |
| 5696 } | 5699 } |
| 5697 | 5700 |
| 5698 void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location, | 5701 void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location, |
| 5699 GLfloat x, | 5702 GLfloat x, |
| 5700 GLfloat y) { | 5703 GLfloat y) { |
| 5701 if (isContextLost() || !location) | 5704 if (isContextLost() || !location) |
| 5702 return; | 5705 return; |
| 5703 | 5706 |
| 5704 if (location->program() != m_currentProgram) { | 5707 if (location->program() != m_currentProgram) { |
| 5705 synthesizeGLError(GL_INVALID_OPERATION, "uniform2f", | 5708 synthesizeGLError(GL_INVALID_OPERATION, "uniform2f", |
| 5706 "location not for current program"); | 5709 "location not for current program"); |
| 5707 return; | 5710 return; |
| 5708 } | 5711 } |
| 5709 | 5712 |
| 5710 contextGL()->Uniform2f(location->location(), x, y); | 5713 contextGL()->Uniform2f(location->location(), x, y); |
| 5711 } | 5714 } |
| 5712 | 5715 |
| 5713 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, | 5716 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, |
| 5714 const FlexibleFloat32ArrayView& v) { | 5717 const FlexibleFloat32ArrayView& v) { |
| 5715 if (isContextLost() || | 5718 if (isContextLost() || |
| 5716 !validateUniformParameters<WTF::Float32Array>("uniform2fv", location, v, | 5719 !validateUniformParameters<WTF::Float32Array>("uniform2fv", location, v, |
| 5717 2)) | 5720 2, 0, v.length())) |
| 5718 return; | 5721 return; |
| 5719 | 5722 |
| 5720 contextGL()->Uniform2fv(location->location(), v.length() >> 1, | 5723 contextGL()->Uniform2fv(location->location(), v.length() >> 1, |
| 5721 v.dataMaybeOnStack()); | 5724 v.dataMaybeOnStack()); |
| 5722 } | 5725 } |
| 5723 | 5726 |
| 5724 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, | 5727 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, |
| 5725 Vector<GLfloat>& v) { | 5728 Vector<GLfloat>& v) { |
| 5726 if (isContextLost() || | 5729 if (isContextLost() || |
| 5727 !validateUniformParameters("uniform2fv", location, v.data(), v.size(), 2)) | 5730 !validateUniformParameters("uniform2fv", location, v.data(), v.size(), 2, |
| 5731 0, v.size())) |
| 5728 return; | 5732 return; |
| 5729 | 5733 |
| 5730 contextGL()->Uniform2fv(location->location(), v.size() >> 1, v.data()); | 5734 contextGL()->Uniform2fv(location->location(), v.size() >> 1, v.data()); |
| 5731 } | 5735 } |
| 5732 | 5736 |
| 5733 void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location, | 5737 void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location, |
| 5734 GLint x, | 5738 GLint x, |
| 5735 GLint y) { | 5739 GLint y) { |
| 5736 if (isContextLost() || !location) | 5740 if (isContextLost() || !location) |
| 5737 return; | 5741 return; |
| 5738 | 5742 |
| 5739 if (location->program() != m_currentProgram) { | 5743 if (location->program() != m_currentProgram) { |
| 5740 synthesizeGLError(GL_INVALID_OPERATION, "uniform2i", | 5744 synthesizeGLError(GL_INVALID_OPERATION, "uniform2i", |
| 5741 "location not for current program"); | 5745 "location not for current program"); |
| 5742 return; | 5746 return; |
| 5743 } | 5747 } |
| 5744 | 5748 |
| 5745 contextGL()->Uniform2i(location->location(), x, y); | 5749 contextGL()->Uniform2i(location->location(), x, y); |
| 5746 } | 5750 } |
| 5747 | 5751 |
| 5748 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, | 5752 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, |
| 5749 const FlexibleInt32ArrayView& v) { | 5753 const FlexibleInt32ArrayView& v) { |
| 5750 if (isContextLost() || | 5754 if (isContextLost() || |
| 5751 !validateUniformParameters<WTF::Int32Array>("uniform2iv", location, v, 2)) | 5755 !validateUniformParameters<WTF::Int32Array>("uniform2iv", location, v, 2, |
| 5756 0, v.length())) |
| 5752 return; | 5757 return; |
| 5753 | 5758 |
| 5754 contextGL()->Uniform2iv(location->location(), v.length() >> 1, | 5759 contextGL()->Uniform2iv(location->location(), v.length() >> 1, |
| 5755 v.dataMaybeOnStack()); | 5760 v.dataMaybeOnStack()); |
| 5756 } | 5761 } |
| 5757 | 5762 |
| 5758 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, | 5763 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, |
| 5759 Vector<GLint>& v) { | 5764 Vector<GLint>& v) { |
| 5760 if (isContextLost() || | 5765 if (isContextLost() || |
| 5761 !validateUniformParameters("uniform2iv", location, v.data(), v.size(), 2)) | 5766 !validateUniformParameters("uniform2iv", location, v.data(), v.size(), 2, |
| 5767 0, v.size())) |
| 5762 return; | 5768 return; |
| 5763 | 5769 |
| 5764 contextGL()->Uniform2iv(location->location(), v.size() >> 1, v.data()); | 5770 contextGL()->Uniform2iv(location->location(), v.size() >> 1, v.data()); |
| 5765 } | 5771 } |
| 5766 | 5772 |
| 5767 void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location, | 5773 void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location, |
| 5768 GLfloat x, | 5774 GLfloat x, |
| 5769 GLfloat y, | 5775 GLfloat y, |
| 5770 GLfloat z) { | 5776 GLfloat z) { |
| 5771 if (isContextLost() || !location) | 5777 if (isContextLost() || !location) |
| 5772 return; | 5778 return; |
| 5773 | 5779 |
| 5774 if (location->program() != m_currentProgram) { | 5780 if (location->program() != m_currentProgram) { |
| 5775 synthesizeGLError(GL_INVALID_OPERATION, "uniform3f", | 5781 synthesizeGLError(GL_INVALID_OPERATION, "uniform3f", |
| 5776 "location not for current program"); | 5782 "location not for current program"); |
| 5777 return; | 5783 return; |
| 5778 } | 5784 } |
| 5779 | 5785 |
| 5780 contextGL()->Uniform3f(location->location(), x, y, z); | 5786 contextGL()->Uniform3f(location->location(), x, y, z); |
| 5781 } | 5787 } |
| 5782 | 5788 |
| 5783 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, | 5789 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, |
| 5784 const FlexibleFloat32ArrayView& v) { | 5790 const FlexibleFloat32ArrayView& v) { |
| 5785 if (isContextLost() || | 5791 if (isContextLost() || |
| 5786 !validateUniformParameters<WTF::Float32Array>("uniform3fv", location, v, | 5792 !validateUniformParameters<WTF::Float32Array>("uniform3fv", location, v, |
| 5787 3)) | 5793 3, 0, v.length())) |
| 5788 return; | 5794 return; |
| 5789 | 5795 |
| 5790 contextGL()->Uniform3fv(location->location(), v.length() / 3, | 5796 contextGL()->Uniform3fv(location->location(), v.length() / 3, |
| 5791 v.dataMaybeOnStack()); | 5797 v.dataMaybeOnStack()); |
| 5792 } | 5798 } |
| 5793 | 5799 |
| 5794 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, | 5800 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, |
| 5795 Vector<GLfloat>& v) { | 5801 Vector<GLfloat>& v) { |
| 5796 if (isContextLost() || | 5802 if (isContextLost() || |
| 5797 !validateUniformParameters("uniform3fv", location, v.data(), v.size(), 3)) | 5803 !validateUniformParameters("uniform3fv", location, v.data(), v.size(), 3, |
| 5804 0, v.size())) |
| 5798 return; | 5805 return; |
| 5799 | 5806 |
| 5800 contextGL()->Uniform3fv(location->location(), v.size() / 3, v.data()); | 5807 contextGL()->Uniform3fv(location->location(), v.size() / 3, v.data()); |
| 5801 } | 5808 } |
| 5802 | 5809 |
| 5803 void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location, | 5810 void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location, |
| 5804 GLint x, | 5811 GLint x, |
| 5805 GLint y, | 5812 GLint y, |
| 5806 GLint z) { | 5813 GLint z) { |
| 5807 if (isContextLost() || !location) | 5814 if (isContextLost() || !location) |
| 5808 return; | 5815 return; |
| 5809 | 5816 |
| 5810 if (location->program() != m_currentProgram) { | 5817 if (location->program() != m_currentProgram) { |
| 5811 synthesizeGLError(GL_INVALID_OPERATION, "uniform3i", | 5818 synthesizeGLError(GL_INVALID_OPERATION, "uniform3i", |
| 5812 "location not for current program"); | 5819 "location not for current program"); |
| 5813 return; | 5820 return; |
| 5814 } | 5821 } |
| 5815 | 5822 |
| 5816 contextGL()->Uniform3i(location->location(), x, y, z); | 5823 contextGL()->Uniform3i(location->location(), x, y, z); |
| 5817 } | 5824 } |
| 5818 | 5825 |
| 5819 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, | 5826 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, |
| 5820 const FlexibleInt32ArrayView& v) { | 5827 const FlexibleInt32ArrayView& v) { |
| 5821 if (isContextLost() || | 5828 if (isContextLost() || |
| 5822 !validateUniformParameters<WTF::Int32Array>("uniform3iv", location, v, 3)) | 5829 !validateUniformParameters<WTF::Int32Array>("uniform3iv", location, v, 3, |
| 5830 0, v.length())) |
| 5823 return; | 5831 return; |
| 5824 | 5832 |
| 5825 contextGL()->Uniform3iv(location->location(), v.length() / 3, | 5833 contextGL()->Uniform3iv(location->location(), v.length() / 3, |
| 5826 v.dataMaybeOnStack()); | 5834 v.dataMaybeOnStack()); |
| 5827 } | 5835 } |
| 5828 | 5836 |
| 5829 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, | 5837 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, |
| 5830 Vector<GLint>& v) { | 5838 Vector<GLint>& v) { |
| 5831 if (isContextLost() || | 5839 if (isContextLost() || |
| 5832 !validateUniformParameters("uniform3iv", location, v.data(), v.size(), 3)) | 5840 !validateUniformParameters("uniform3iv", location, v.data(), v.size(), 3, |
| 5841 0, v.size())) |
| 5833 return; | 5842 return; |
| 5834 | 5843 |
| 5835 contextGL()->Uniform3iv(location->location(), v.size() / 3, v.data()); | 5844 contextGL()->Uniform3iv(location->location(), v.size() / 3, v.data()); |
| 5836 } | 5845 } |
| 5837 | 5846 |
| 5838 void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location, | 5847 void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location, |
| 5839 GLfloat x, | 5848 GLfloat x, |
| 5840 GLfloat y, | 5849 GLfloat y, |
| 5841 GLfloat z, | 5850 GLfloat z, |
| 5842 GLfloat w) { | 5851 GLfloat w) { |
| 5843 if (isContextLost() || !location) | 5852 if (isContextLost() || !location) |
| 5844 return; | 5853 return; |
| 5845 | 5854 |
| 5846 if (location->program() != m_currentProgram) { | 5855 if (location->program() != m_currentProgram) { |
| 5847 synthesizeGLError(GL_INVALID_OPERATION, "uniform4f", | 5856 synthesizeGLError(GL_INVALID_OPERATION, "uniform4f", |
| 5848 "location not for current program"); | 5857 "location not for current program"); |
| 5849 return; | 5858 return; |
| 5850 } | 5859 } |
| 5851 | 5860 |
| 5852 contextGL()->Uniform4f(location->location(), x, y, z, w); | 5861 contextGL()->Uniform4f(location->location(), x, y, z, w); |
| 5853 } | 5862 } |
| 5854 | 5863 |
| 5855 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, | 5864 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, |
| 5856 const FlexibleFloat32ArrayView& v) { | 5865 const FlexibleFloat32ArrayView& v) { |
| 5857 if (isContextLost() || | 5866 if (isContextLost() || |
| 5858 !validateUniformParameters<WTF::Float32Array>("uniform4fv", location, v, | 5867 !validateUniformParameters<WTF::Float32Array>("uniform4fv", location, v, |
| 5859 4)) | 5868 4, 0, v.length())) |
| 5860 return; | 5869 return; |
| 5861 | 5870 |
| 5862 contextGL()->Uniform4fv(location->location(), v.length() >> 2, | 5871 contextGL()->Uniform4fv(location->location(), v.length() >> 2, |
| 5863 v.dataMaybeOnStack()); | 5872 v.dataMaybeOnStack()); |
| 5864 } | 5873 } |
| 5865 | 5874 |
| 5866 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, | 5875 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, |
| 5867 Vector<GLfloat>& v) { | 5876 Vector<GLfloat>& v) { |
| 5868 if (isContextLost() || | 5877 if (isContextLost() || |
| 5869 !validateUniformParameters("uniform4fv", location, v.data(), v.size(), 4)) | 5878 !validateUniformParameters("uniform4fv", location, v.data(), v.size(), 4, |
| 5879 0, v.size())) |
| 5870 return; | 5880 return; |
| 5871 | 5881 |
| 5872 contextGL()->Uniform4fv(location->location(), v.size() >> 2, v.data()); | 5882 contextGL()->Uniform4fv(location->location(), v.size() >> 2, v.data()); |
| 5873 } | 5883 } |
| 5874 | 5884 |
| 5875 void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location, | 5885 void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location, |
| 5876 GLint x, | 5886 GLint x, |
| 5877 GLint y, | 5887 GLint y, |
| 5878 GLint z, | 5888 GLint z, |
| 5879 GLint w) { | 5889 GLint w) { |
| 5880 if (isContextLost() || !location) | 5890 if (isContextLost() || !location) |
| 5881 return; | 5891 return; |
| 5882 | 5892 |
| 5883 if (location->program() != m_currentProgram) { | 5893 if (location->program() != m_currentProgram) { |
| 5884 synthesizeGLError(GL_INVALID_OPERATION, "uniform4i", | 5894 synthesizeGLError(GL_INVALID_OPERATION, "uniform4i", |
| 5885 "location not for current program"); | 5895 "location not for current program"); |
| 5886 return; | 5896 return; |
| 5887 } | 5897 } |
| 5888 | 5898 |
| 5889 contextGL()->Uniform4i(location->location(), x, y, z, w); | 5899 contextGL()->Uniform4i(location->location(), x, y, z, w); |
| 5890 } | 5900 } |
| 5891 | 5901 |
| 5892 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, | 5902 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, |
| 5893 const FlexibleInt32ArrayView& v) { | 5903 const FlexibleInt32ArrayView& v) { |
| 5894 if (isContextLost() || | 5904 if (isContextLost() || |
| 5895 !validateUniformParameters<WTF::Int32Array>("uniform4iv", location, v, 4)) | 5905 !validateUniformParameters<WTF::Int32Array>("uniform4iv", location, v, 4, |
| 5906 0, v.length())) |
| 5896 return; | 5907 return; |
| 5897 | 5908 |
| 5898 contextGL()->Uniform4iv(location->location(), v.length() >> 2, | 5909 contextGL()->Uniform4iv(location->location(), v.length() >> 2, |
| 5899 v.dataMaybeOnStack()); | 5910 v.dataMaybeOnStack()); |
| 5900 } | 5911 } |
| 5901 | 5912 |
| 5902 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, | 5913 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, |
| 5903 Vector<GLint>& v) { | 5914 Vector<GLint>& v) { |
| 5904 if (isContextLost() || | 5915 if (isContextLost() || |
| 5905 !validateUniformParameters("uniform4iv", location, v.data(), v.size(), 4)) | 5916 !validateUniformParameters("uniform4iv", location, v.data(), v.size(), 4, |
| 5917 0, v.size())) |
| 5906 return; | 5918 return; |
| 5907 | 5919 |
| 5908 contextGL()->Uniform4iv(location->location(), v.size() >> 2, v.data()); | 5920 contextGL()->Uniform4iv(location->location(), v.size() >> 2, v.data()); |
| 5909 } | 5921 } |
| 5910 | 5922 |
| 5911 void WebGLRenderingContextBase::uniformMatrix2fv( | 5923 void WebGLRenderingContextBase::uniformMatrix2fv( |
| 5912 const WebGLUniformLocation* location, | 5924 const WebGLUniformLocation* location, |
| 5913 GLboolean transpose, | 5925 GLboolean transpose, |
| 5914 DOMFloat32Array* v) { | 5926 DOMFloat32Array* v) { |
| 5915 if (isContextLost() || | 5927 if (isContextLost() || |
| 5916 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, | 5928 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, |
| 5917 v, 4)) | 5929 v, 4, 0, v->length())) |
| 5918 return; | 5930 return; |
| 5919 contextGL()->UniformMatrix2fv(location->location(), v->length() >> 2, | 5931 contextGL()->UniformMatrix2fv(location->location(), v->length() >> 2, |
| 5920 transpose, v->data()); | 5932 transpose, v->data()); |
| 5921 } | 5933 } |
| 5922 | 5934 |
| 5923 void WebGLRenderingContextBase::uniformMatrix2fv( | 5935 void WebGLRenderingContextBase::uniformMatrix2fv( |
| 5924 const WebGLUniformLocation* location, | 5936 const WebGLUniformLocation* location, |
| 5925 GLboolean transpose, | 5937 GLboolean transpose, |
| 5926 Vector<GLfloat>& v) { | 5938 Vector<GLfloat>& v) { |
| 5927 if (isContextLost() || | 5939 if (isContextLost() || |
| 5928 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, | 5940 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, |
| 5929 v.data(), v.size(), 4)) | 5941 v.data(), v.size(), 4, 0, v.size())) |
| 5930 return; | 5942 return; |
| 5931 contextGL()->UniformMatrix2fv(location->location(), v.size() >> 2, transpose, | 5943 contextGL()->UniformMatrix2fv(location->location(), v.size() >> 2, transpose, |
| 5932 v.data()); | 5944 v.data()); |
| 5933 } | 5945 } |
| 5934 | 5946 |
| 5935 void WebGLRenderingContextBase::uniformMatrix3fv( | 5947 void WebGLRenderingContextBase::uniformMatrix3fv( |
| 5936 const WebGLUniformLocation* location, | 5948 const WebGLUniformLocation* location, |
| 5937 GLboolean transpose, | 5949 GLboolean transpose, |
| 5938 DOMFloat32Array* v) { | 5950 DOMFloat32Array* v) { |
| 5939 if (isContextLost() || | 5951 if (isContextLost() || |
| 5940 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, | 5952 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, |
| 5941 v, 9)) | 5953 v, 9, 0, v->length())) |
| 5942 return; | 5954 return; |
| 5943 contextGL()->UniformMatrix3fv(location->location(), v->length() / 9, | 5955 contextGL()->UniformMatrix3fv(location->location(), v->length() / 9, |
| 5944 transpose, v->data()); | 5956 transpose, v->data()); |
| 5945 } | 5957 } |
| 5946 | 5958 |
| 5947 void WebGLRenderingContextBase::uniformMatrix3fv( | 5959 void WebGLRenderingContextBase::uniformMatrix3fv( |
| 5948 const WebGLUniformLocation* location, | 5960 const WebGLUniformLocation* location, |
| 5949 GLboolean transpose, | 5961 GLboolean transpose, |
| 5950 Vector<GLfloat>& v) { | 5962 Vector<GLfloat>& v) { |
| 5951 if (isContextLost() || | 5963 if (isContextLost() || |
| 5952 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, | 5964 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, |
| 5953 v.data(), v.size(), 9)) | 5965 v.data(), v.size(), 9, 0, v.size())) |
| 5954 return; | 5966 return; |
| 5955 contextGL()->UniformMatrix3fv(location->location(), v.size() / 9, transpose, | 5967 contextGL()->UniformMatrix3fv(location->location(), v.size() / 9, transpose, |
| 5956 v.data()); | 5968 v.data()); |
| 5957 } | 5969 } |
| 5958 | 5970 |
| 5959 void WebGLRenderingContextBase::uniformMatrix4fv( | 5971 void WebGLRenderingContextBase::uniformMatrix4fv( |
| 5960 const WebGLUniformLocation* location, | 5972 const WebGLUniformLocation* location, |
| 5961 GLboolean transpose, | 5973 GLboolean transpose, |
| 5962 DOMFloat32Array* v) { | 5974 DOMFloat32Array* v) { |
| 5963 if (isContextLost() || | 5975 if (isContextLost() || |
| 5964 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, | 5976 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, |
| 5965 v, 16)) | 5977 v, 16, 0, v->length())) |
| 5966 return; | 5978 return; |
| 5967 contextGL()->UniformMatrix4fv(location->location(), v->length() >> 4, | 5979 contextGL()->UniformMatrix4fv(location->location(), v->length() >> 4, |
| 5968 transpose, v->data()); | 5980 transpose, v->data()); |
| 5969 } | 5981 } |
| 5970 | 5982 |
| 5971 void WebGLRenderingContextBase::uniformMatrix4fv( | 5983 void WebGLRenderingContextBase::uniformMatrix4fv( |
| 5972 const WebGLUniformLocation* location, | 5984 const WebGLUniformLocation* location, |
| 5973 GLboolean transpose, | 5985 GLboolean transpose, |
| 5974 Vector<GLfloat>& v) { | 5986 Vector<GLfloat>& v) { |
| 5975 if (isContextLost() || | 5987 if (isContextLost() || |
| 5976 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, | 5988 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, |
| 5977 v.data(), v.size(), 16)) | 5989 v.data(), v.size(), 16, 0, v.size())) |
| 5978 return; | 5990 return; |
| 5979 contextGL()->UniformMatrix4fv(location->location(), v.size() >> 4, transpose, | 5991 contextGL()->UniformMatrix4fv(location->location(), v.size() >> 4, transpose, |
| 5980 v.data()); | 5992 v.data()); |
| 5981 } | 5993 } |
| 5982 | 5994 |
| 5983 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) { | 5995 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) { |
| 5984 bool deleted; | 5996 bool deleted; |
| 5985 if (!checkObjectToBeBound("useProgram", program, deleted)) | 5997 if (!checkObjectToBeBound("useProgram", program, deleted)) |
| 5986 return; | 5998 return; |
| 5987 if (deleted) | 5999 if (deleted) |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7152 return true; | 7164 return true; |
| 7153 default: | 7165 default: |
| 7154 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid capability"); | 7166 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid capability"); |
| 7155 return false; | 7167 return false; |
| 7156 } | 7168 } |
| 7157 } | 7169 } |
| 7158 | 7170 |
| 7159 bool WebGLRenderingContextBase::validateUniformParameters( | 7171 bool WebGLRenderingContextBase::validateUniformParameters( |
| 7160 const char* functionName, | 7172 const char* functionName, |
| 7161 const WebGLUniformLocation* location, | 7173 const WebGLUniformLocation* location, |
| 7162 DOMFloat32Array* v, | |
| 7163 GLsizei requiredMinSize) { | |
| 7164 if (!v) { | |
| 7165 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); | |
| 7166 return false; | |
| 7167 } | |
| 7168 return validateUniformMatrixParameters( | |
| 7169 functionName, location, false, v->data(), v->length(), requiredMinSize); | |
| 7170 } | |
| 7171 | |
| 7172 bool WebGLRenderingContextBase::validateUniformParameters( | |
| 7173 const char* functionName, | |
| 7174 const WebGLUniformLocation* location, | |
| 7175 DOMInt32Array* v, | |
| 7176 GLsizei requiredMinSize) { | |
| 7177 if (!v) { | |
| 7178 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); | |
| 7179 return false; | |
| 7180 } | |
| 7181 return validateUniformMatrixParameters( | |
| 7182 functionName, location, false, v->data(), v->length(), requiredMinSize); | |
| 7183 } | |
| 7184 | |
| 7185 bool WebGLRenderingContextBase::validateUniformParameters( | |
| 7186 const char* functionName, | |
| 7187 const WebGLUniformLocation* location, | |
| 7188 void* v, | 7174 void* v, |
| 7189 GLsizei size, | 7175 GLsizei size, |
| 7190 GLsizei requiredMinSize) { | 7176 GLsizei requiredMinSize, |
| 7177 GLuint srcOffset, |
| 7178 GLuint srcLength) { |
| 7191 return validateUniformMatrixParameters(functionName, location, false, v, size, | 7179 return validateUniformMatrixParameters(functionName, location, false, v, size, |
| 7192 requiredMinSize); | 7180 requiredMinSize, srcOffset, srcLength); |
| 7193 } | 7181 } |
| 7194 | 7182 |
| 7195 bool WebGLRenderingContextBase::validateUniformMatrixParameters( | 7183 bool WebGLRenderingContextBase::validateUniformMatrixParameters( |
| 7196 const char* functionName, | 7184 const char* functionName, |
| 7197 const WebGLUniformLocation* location, | 7185 const WebGLUniformLocation* location, |
| 7198 GLboolean transpose, | 7186 GLboolean transpose, |
| 7199 DOMFloat32Array* v, | 7187 DOMFloat32Array* v, |
| 7200 GLsizei requiredMinSize) { | 7188 GLsizei requiredMinSize, |
| 7189 GLuint srcOffset, |
| 7190 GLuint srcLength) { |
| 7201 if (!v) { | 7191 if (!v) { |
| 7202 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); | 7192 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); |
| 7203 return false; | 7193 return false; |
| 7204 } | 7194 } |
| 7205 return validateUniformMatrixParameters(functionName, location, transpose, | 7195 return validateUniformMatrixParameters(functionName, location, transpose, |
| 7206 v->data(), v->length(), | 7196 v->data(), v->length(), |
| 7207 requiredMinSize); | 7197 requiredMinSize, srcOffset, srcLength); |
| 7208 } | 7198 } |
| 7209 | 7199 |
| 7210 bool WebGLRenderingContextBase::validateUniformMatrixParameters( | 7200 bool WebGLRenderingContextBase::validateUniformMatrixParameters( |
| 7211 const char* functionName, | 7201 const char* functionName, |
| 7212 const WebGLUniformLocation* location, | 7202 const WebGLUniformLocation* location, |
| 7213 GLboolean transpose, | 7203 GLboolean transpose, |
| 7214 void* v, | 7204 void* v, |
| 7215 GLsizei size, | 7205 GLsizei size, |
| 7216 GLsizei requiredMinSize) { | 7206 GLsizei requiredMinSize, |
| 7207 GLuint srcOffset, |
| 7208 GLuint srcLength) { |
| 7209 DCHECK(size >= 0 && requiredMinSize > 0); |
| 7217 if (!location) | 7210 if (!location) |
| 7218 return false; | 7211 return false; |
| 7219 if (location->program() != m_currentProgram) { | 7212 if (location->program() != m_currentProgram) { |
| 7220 synthesizeGLError(GL_INVALID_OPERATION, functionName, | 7213 synthesizeGLError(GL_INVALID_OPERATION, functionName, |
| 7221 "location is not from current program"); | 7214 "location is not from current program"); |
| 7222 return false; | 7215 return false; |
| 7223 } | 7216 } |
| 7224 if (!v) { | 7217 if (!v) { |
| 7225 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); | 7218 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); |
| 7226 return false; | 7219 return false; |
| 7227 } | 7220 } |
| 7228 if (transpose && !isWebGL2OrHigher()) { | 7221 if (transpose && !isWebGL2OrHigher()) { |
| 7229 synthesizeGLError(GL_INVALID_VALUE, functionName, "transpose not FALSE"); | 7222 synthesizeGLError(GL_INVALID_VALUE, functionName, "transpose not FALSE"); |
| 7230 return false; | 7223 return false; |
| 7231 } | 7224 } |
| 7232 if (size < requiredMinSize || (size % requiredMinSize)) { | 7225 if (srcOffset >= static_cast<GLuint>(size)) { |
| 7226 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid srcOffset"); |
| 7227 return false; |
| 7228 } |
| 7229 GLsizei actualSize = size - srcOffset; |
| 7230 if (srcLength > 0) { |
| 7231 if (srcLength > static_cast<GLuint>(actualSize)) { |
| 7232 synthesizeGLError(GL_INVALID_VALUE, functionName, |
| 7233 "invalid srcOffset + srcLength"); |
| 7234 return false; |
| 7235 } |
| 7236 actualSize = srcLength; |
| 7237 } |
| 7238 if (actualSize < requiredMinSize || (actualSize % requiredMinSize)) { |
| 7233 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size"); | 7239 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size"); |
| 7234 return false; | 7240 return false; |
| 7235 } | 7241 } |
| 7236 return true; | 7242 return true; |
| 7237 } | 7243 } |
| 7238 | 7244 |
| 7239 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataTarget( | 7245 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataTarget( |
| 7240 const char* functionName, | 7246 const char* functionName, |
| 7241 GLenum target) { | 7247 GLenum target) { |
| 7242 WebGLBuffer* buffer = nullptr; | 7248 WebGLBuffer* buffer = nullptr; |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7798 | 7804 |
| 7799 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7805 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7800 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7806 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7801 if (canvas()) | 7807 if (canvas()) |
| 7802 result.setHTMLCanvasElement(canvas()); | 7808 result.setHTMLCanvasElement(canvas()); |
| 7803 else | 7809 else |
| 7804 result.setOffscreenCanvas(offscreenCanvas()); | 7810 result.setOffscreenCanvas(offscreenCanvas()); |
| 7805 } | 7811 } |
| 7806 | 7812 |
| 7807 } // namespace blink | 7813 } // namespace blink |
| OLD | NEW |