Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2698863002: Implement WebGL2's uniform*() with sub source. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5621 matching lines...) Expand 10 before | Expand all | Expand 10 after
5632 return; 5632 return;
5633 } 5633 }
5634 5634
5635 contextGL()->Uniform1f(location->location(), x); 5635 contextGL()->Uniform1f(location->location(), x);
5636 } 5636 }
5637 5637
5638 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, 5638 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location,
5639 const FlexibleFloat32ArrayView& v) { 5639 const FlexibleFloat32ArrayView& v) {
5640 if (isContextLost() || 5640 if (isContextLost() ||
5641 !validateUniformParameters<WTF::Float32Array>("uniform1fv", location, v, 5641 !validateUniformParameters<WTF::Float32Array>("uniform1fv", location, v,
5642 1)) 5642 1, 0, v.length()))
5643 return; 5643 return;
5644 5644
5645 contextGL()->Uniform1fv(location->location(), v.length(), 5645 contextGL()->Uniform1fv(location->location(), v.length(),
5646 v.dataMaybeOnStack()); 5646 v.dataMaybeOnStack());
5647 } 5647 }
5648 5648
5649 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location, 5649 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location,
5650 Vector<GLfloat>& v) { 5650 Vector<GLfloat>& v) {
5651 if (isContextLost() || 5651 if (isContextLost() ||
5652 !validateUniformParameters("uniform1fv", location, v.data(), v.size(), 1)) 5652 !validateUniformParameters("uniform1fv", location, v.data(), v.size(), 1,
5653 0, v.size()))
5653 return; 5654 return;
5654 5655
5655 contextGL()->Uniform1fv(location->location(), v.size(), v.data()); 5656 contextGL()->Uniform1fv(location->location(), v.size(), v.data());
5656 } 5657 }
5657 5658
5658 void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location, 5659 void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location,
5659 GLint x) { 5660 GLint x) {
5660 if (isContextLost() || !location) 5661 if (isContextLost() || !location)
5661 return; 5662 return;
5662 5663
5663 if (location->program() != m_currentProgram) { 5664 if (location->program() != m_currentProgram) {
5664 synthesizeGLError(GL_INVALID_OPERATION, "uniform1i", 5665 synthesizeGLError(GL_INVALID_OPERATION, "uniform1i",
5665 "location not for current program"); 5666 "location not for current program");
5666 return; 5667 return;
5667 } 5668 }
5668 5669
5669 contextGL()->Uniform1i(location->location(), x); 5670 contextGL()->Uniform1i(location->location(), x);
5670 } 5671 }
5671 5672
5672 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, 5673 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location,
5673 const FlexibleInt32ArrayView& v) { 5674 const FlexibleInt32ArrayView& v) {
5674 if (isContextLost() || 5675 if (isContextLost() ||
5675 !validateUniformParameters<WTF::Int32Array>("uniform1iv", location, v, 1)) 5676 !validateUniformParameters<WTF::Int32Array>("uniform1iv", location, v, 1,
5677 0, v.length()))
5676 return; 5678 return;
5677 5679
5678 contextGL()->Uniform1iv(location->location(), v.length(), 5680 contextGL()->Uniform1iv(location->location(), v.length(),
5679 v.dataMaybeOnStack()); 5681 v.dataMaybeOnStack());
5680 } 5682 }
5681 5683
5682 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location, 5684 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location,
5683 Vector<GLint>& v) { 5685 Vector<GLint>& v) {
5684 if (isContextLost() || 5686 if (isContextLost() ||
5685 !validateUniformParameters("uniform1iv", location, v.data(), v.size(), 1)) 5687 !validateUniformParameters("uniform1iv", location, v.data(), v.size(), 1,
5688 0, v.size()))
5686 return; 5689 return;
5687 5690
5688 contextGL()->Uniform1iv(location->location(), v.size(), v.data()); 5691 contextGL()->Uniform1iv(location->location(), v.size(), v.data());
5689 } 5692 }
5690 5693
5691 void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location, 5694 void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location,
5692 GLfloat x, 5695 GLfloat x,
5693 GLfloat y) { 5696 GLfloat y) {
5694 if (isContextLost() || !location) 5697 if (isContextLost() || !location)
5695 return; 5698 return;
5696 5699
5697 if (location->program() != m_currentProgram) { 5700 if (location->program() != m_currentProgram) {
5698 synthesizeGLError(GL_INVALID_OPERATION, "uniform2f", 5701 synthesizeGLError(GL_INVALID_OPERATION, "uniform2f",
5699 "location not for current program"); 5702 "location not for current program");
5700 return; 5703 return;
5701 } 5704 }
5702 5705
5703 contextGL()->Uniform2f(location->location(), x, y); 5706 contextGL()->Uniform2f(location->location(), x, y);
5704 } 5707 }
5705 5708
5706 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, 5709 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location,
5707 const FlexibleFloat32ArrayView& v) { 5710 const FlexibleFloat32ArrayView& v) {
5708 if (isContextLost() || 5711 if (isContextLost() ||
5709 !validateUniformParameters<WTF::Float32Array>("uniform2fv", location, v, 5712 !validateUniformParameters<WTF::Float32Array>("uniform2fv", location, v,
5710 2)) 5713 2, 0, v.length()))
5711 return; 5714 return;
5712 5715
5713 contextGL()->Uniform2fv(location->location(), v.length() >> 1, 5716 contextGL()->Uniform2fv(location->location(), v.length() >> 1,
5714 v.dataMaybeOnStack()); 5717 v.dataMaybeOnStack());
5715 } 5718 }
5716 5719
5717 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location, 5720 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location,
5718 Vector<GLfloat>& v) { 5721 Vector<GLfloat>& v) {
5719 if (isContextLost() || 5722 if (isContextLost() ||
5720 !validateUniformParameters("uniform2fv", location, v.data(), v.size(), 2)) 5723 !validateUniformParameters("uniform2fv", location, v.data(), v.size(), 2,
5724 0, v.size()))
5721 return; 5725 return;
5722 5726
5723 contextGL()->Uniform2fv(location->location(), v.size() >> 1, v.data()); 5727 contextGL()->Uniform2fv(location->location(), v.size() >> 1, v.data());
5724 } 5728 }
5725 5729
5726 void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location, 5730 void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location,
5727 GLint x, 5731 GLint x,
5728 GLint y) { 5732 GLint y) {
5729 if (isContextLost() || !location) 5733 if (isContextLost() || !location)
5730 return; 5734 return;
5731 5735
5732 if (location->program() != m_currentProgram) { 5736 if (location->program() != m_currentProgram) {
5733 synthesizeGLError(GL_INVALID_OPERATION, "uniform2i", 5737 synthesizeGLError(GL_INVALID_OPERATION, "uniform2i",
5734 "location not for current program"); 5738 "location not for current program");
5735 return; 5739 return;
5736 } 5740 }
5737 5741
5738 contextGL()->Uniform2i(location->location(), x, y); 5742 contextGL()->Uniform2i(location->location(), x, y);
5739 } 5743 }
5740 5744
5741 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, 5745 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location,
5742 const FlexibleInt32ArrayView& v) { 5746 const FlexibleInt32ArrayView& v) {
5743 if (isContextLost() || 5747 if (isContextLost() ||
5744 !validateUniformParameters<WTF::Int32Array>("uniform2iv", location, v, 2)) 5748 !validateUniformParameters<WTF::Int32Array>("uniform2iv", location, v, 2,
5749 0, v.length()))
5745 return; 5750 return;
5746 5751
5747 contextGL()->Uniform2iv(location->location(), v.length() >> 1, 5752 contextGL()->Uniform2iv(location->location(), v.length() >> 1,
5748 v.dataMaybeOnStack()); 5753 v.dataMaybeOnStack());
5749 } 5754 }
5750 5755
5751 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location, 5756 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location,
5752 Vector<GLint>& v) { 5757 Vector<GLint>& v) {
5753 if (isContextLost() || 5758 if (isContextLost() ||
5754 !validateUniformParameters("uniform2iv", location, v.data(), v.size(), 2)) 5759 !validateUniformParameters("uniform2iv", location, v.data(), v.size(), 2,
5760 0, v.size()))
5755 return; 5761 return;
5756 5762
5757 contextGL()->Uniform2iv(location->location(), v.size() >> 1, v.data()); 5763 contextGL()->Uniform2iv(location->location(), v.size() >> 1, v.data());
5758 } 5764 }
5759 5765
5760 void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location, 5766 void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location,
5761 GLfloat x, 5767 GLfloat x,
5762 GLfloat y, 5768 GLfloat y,
5763 GLfloat z) { 5769 GLfloat z) {
5764 if (isContextLost() || !location) 5770 if (isContextLost() || !location)
5765 return; 5771 return;
5766 5772
5767 if (location->program() != m_currentProgram) { 5773 if (location->program() != m_currentProgram) {
5768 synthesizeGLError(GL_INVALID_OPERATION, "uniform3f", 5774 synthesizeGLError(GL_INVALID_OPERATION, "uniform3f",
5769 "location not for current program"); 5775 "location not for current program");
5770 return; 5776 return;
5771 } 5777 }
5772 5778
5773 contextGL()->Uniform3f(location->location(), x, y, z); 5779 contextGL()->Uniform3f(location->location(), x, y, z);
5774 } 5780 }
5775 5781
5776 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, 5782 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location,
5777 const FlexibleFloat32ArrayView& v) { 5783 const FlexibleFloat32ArrayView& v) {
5778 if (isContextLost() || 5784 if (isContextLost() ||
5779 !validateUniformParameters<WTF::Float32Array>("uniform3fv", location, v, 5785 !validateUniformParameters<WTF::Float32Array>("uniform3fv", location, v,
5780 3)) 5786 3, 0, v.length()))
5781 return; 5787 return;
5782 5788
5783 contextGL()->Uniform3fv(location->location(), v.length() / 3, 5789 contextGL()->Uniform3fv(location->location(), v.length() / 3,
5784 v.dataMaybeOnStack()); 5790 v.dataMaybeOnStack());
5785 } 5791 }
5786 5792
5787 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location, 5793 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location,
5788 Vector<GLfloat>& v) { 5794 Vector<GLfloat>& v) {
5789 if (isContextLost() || 5795 if (isContextLost() ||
5790 !validateUniformParameters("uniform3fv", location, v.data(), v.size(), 3)) 5796 !validateUniformParameters("uniform3fv", location, v.data(), v.size(), 3,
5797 0, v.size()))
5791 return; 5798 return;
5792 5799
5793 contextGL()->Uniform3fv(location->location(), v.size() / 3, v.data()); 5800 contextGL()->Uniform3fv(location->location(), v.size() / 3, v.data());
5794 } 5801 }
5795 5802
5796 void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location, 5803 void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location,
5797 GLint x, 5804 GLint x,
5798 GLint y, 5805 GLint y,
5799 GLint z) { 5806 GLint z) {
5800 if (isContextLost() || !location) 5807 if (isContextLost() || !location)
5801 return; 5808 return;
5802 5809
5803 if (location->program() != m_currentProgram) { 5810 if (location->program() != m_currentProgram) {
5804 synthesizeGLError(GL_INVALID_OPERATION, "uniform3i", 5811 synthesizeGLError(GL_INVALID_OPERATION, "uniform3i",
5805 "location not for current program"); 5812 "location not for current program");
5806 return; 5813 return;
5807 } 5814 }
5808 5815
5809 contextGL()->Uniform3i(location->location(), x, y, z); 5816 contextGL()->Uniform3i(location->location(), x, y, z);
5810 } 5817 }
5811 5818
5812 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, 5819 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location,
5813 const FlexibleInt32ArrayView& v) { 5820 const FlexibleInt32ArrayView& v) {
5814 if (isContextLost() || 5821 if (isContextLost() ||
5815 !validateUniformParameters<WTF::Int32Array>("uniform3iv", location, v, 3)) 5822 !validateUniformParameters<WTF::Int32Array>("uniform3iv", location, v, 3,
5823 0, v.length()))
5816 return; 5824 return;
5817 5825
5818 contextGL()->Uniform3iv(location->location(), v.length() / 3, 5826 contextGL()->Uniform3iv(location->location(), v.length() / 3,
5819 v.dataMaybeOnStack()); 5827 v.dataMaybeOnStack());
5820 } 5828 }
5821 5829
5822 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location, 5830 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location,
5823 Vector<GLint>& v) { 5831 Vector<GLint>& v) {
5824 if (isContextLost() || 5832 if (isContextLost() ||
5825 !validateUniformParameters("uniform3iv", location, v.data(), v.size(), 3)) 5833 !validateUniformParameters("uniform3iv", location, v.data(), v.size(), 3,
5834 0, v.size()))
5826 return; 5835 return;
5827 5836
5828 contextGL()->Uniform3iv(location->location(), v.size() / 3, v.data()); 5837 contextGL()->Uniform3iv(location->location(), v.size() / 3, v.data());
5829 } 5838 }
5830 5839
5831 void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location, 5840 void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location,
5832 GLfloat x, 5841 GLfloat x,
5833 GLfloat y, 5842 GLfloat y,
5834 GLfloat z, 5843 GLfloat z,
5835 GLfloat w) { 5844 GLfloat w) {
5836 if (isContextLost() || !location) 5845 if (isContextLost() || !location)
5837 return; 5846 return;
5838 5847
5839 if (location->program() != m_currentProgram) { 5848 if (location->program() != m_currentProgram) {
5840 synthesizeGLError(GL_INVALID_OPERATION, "uniform4f", 5849 synthesizeGLError(GL_INVALID_OPERATION, "uniform4f",
5841 "location not for current program"); 5850 "location not for current program");
5842 return; 5851 return;
5843 } 5852 }
5844 5853
5845 contextGL()->Uniform4f(location->location(), x, y, z, w); 5854 contextGL()->Uniform4f(location->location(), x, y, z, w);
5846 } 5855 }
5847 5856
5848 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, 5857 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location,
5849 const FlexibleFloat32ArrayView& v) { 5858 const FlexibleFloat32ArrayView& v) {
5850 if (isContextLost() || 5859 if (isContextLost() ||
5851 !validateUniformParameters<WTF::Float32Array>("uniform4fv", location, v, 5860 !validateUniformParameters<WTF::Float32Array>("uniform4fv", location, v,
5852 4)) 5861 4, 0, v.length()))
5853 return; 5862 return;
5854 5863
5855 contextGL()->Uniform4fv(location->location(), v.length() >> 2, 5864 contextGL()->Uniform4fv(location->location(), v.length() >> 2,
5856 v.dataMaybeOnStack()); 5865 v.dataMaybeOnStack());
5857 } 5866 }
5858 5867
5859 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location, 5868 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location,
5860 Vector<GLfloat>& v) { 5869 Vector<GLfloat>& v) {
5861 if (isContextLost() || 5870 if (isContextLost() ||
5862 !validateUniformParameters("uniform4fv", location, v.data(), v.size(), 4)) 5871 !validateUniformParameters("uniform4fv", location, v.data(), v.size(), 4,
5872 0, v.size()))
5863 return; 5873 return;
5864 5874
5865 contextGL()->Uniform4fv(location->location(), v.size() >> 2, v.data()); 5875 contextGL()->Uniform4fv(location->location(), v.size() >> 2, v.data());
5866 } 5876 }
5867 5877
5868 void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location, 5878 void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location,
5869 GLint x, 5879 GLint x,
5870 GLint y, 5880 GLint y,
5871 GLint z, 5881 GLint z,
5872 GLint w) { 5882 GLint w) {
5873 if (isContextLost() || !location) 5883 if (isContextLost() || !location)
5874 return; 5884 return;
5875 5885
5876 if (location->program() != m_currentProgram) { 5886 if (location->program() != m_currentProgram) {
5877 synthesizeGLError(GL_INVALID_OPERATION, "uniform4i", 5887 synthesizeGLError(GL_INVALID_OPERATION, "uniform4i",
5878 "location not for current program"); 5888 "location not for current program");
5879 return; 5889 return;
5880 } 5890 }
5881 5891
5882 contextGL()->Uniform4i(location->location(), x, y, z, w); 5892 contextGL()->Uniform4i(location->location(), x, y, z, w);
5883 } 5893 }
5884 5894
5885 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, 5895 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location,
5886 const FlexibleInt32ArrayView& v) { 5896 const FlexibleInt32ArrayView& v) {
5887 if (isContextLost() || 5897 if (isContextLost() ||
5888 !validateUniformParameters<WTF::Int32Array>("uniform4iv", location, v, 4)) 5898 !validateUniformParameters<WTF::Int32Array>("uniform4iv", location, v, 4,
5899 0, v.length()))
5889 return; 5900 return;
5890 5901
5891 contextGL()->Uniform4iv(location->location(), v.length() >> 2, 5902 contextGL()->Uniform4iv(location->location(), v.length() >> 2,
5892 v.dataMaybeOnStack()); 5903 v.dataMaybeOnStack());
5893 } 5904 }
5894 5905
5895 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location, 5906 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location,
5896 Vector<GLint>& v) { 5907 Vector<GLint>& v) {
5897 if (isContextLost() || 5908 if (isContextLost() ||
5898 !validateUniformParameters("uniform4iv", location, v.data(), v.size(), 4)) 5909 !validateUniformParameters("uniform4iv", location, v.data(), v.size(), 4,
5910 0, v.size()))
5899 return; 5911 return;
5900 5912
5901 contextGL()->Uniform4iv(location->location(), v.size() >> 2, v.data()); 5913 contextGL()->Uniform4iv(location->location(), v.size() >> 2, v.data());
5902 } 5914 }
5903 5915
5904 void WebGLRenderingContextBase::uniformMatrix2fv( 5916 void WebGLRenderingContextBase::uniformMatrix2fv(
5905 const WebGLUniformLocation* location, 5917 const WebGLUniformLocation* location,
5906 GLboolean transpose, 5918 GLboolean transpose,
5907 DOMFloat32Array* v) { 5919 DOMFloat32Array* v) {
5908 if (isContextLost() || 5920 if (isContextLost() ||
5909 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, 5921 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose,
5910 v, 4)) 5922 v, 4, 0, v->length()))
5911 return; 5923 return;
5912 contextGL()->UniformMatrix2fv(location->location(), v->length() >> 2, 5924 contextGL()->UniformMatrix2fv(location->location(), v->length() >> 2,
5913 transpose, v->data()); 5925 transpose, v->data());
5914 } 5926 }
5915 5927
5916 void WebGLRenderingContextBase::uniformMatrix2fv( 5928 void WebGLRenderingContextBase::uniformMatrix2fv(
5917 const WebGLUniformLocation* location, 5929 const WebGLUniformLocation* location,
5918 GLboolean transpose, 5930 GLboolean transpose,
5919 Vector<GLfloat>& v) { 5931 Vector<GLfloat>& v) {
5920 if (isContextLost() || 5932 if (isContextLost() ||
5921 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, 5933 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose,
5922 v.data(), v.size(), 4)) 5934 v.data(), v.size(), 4, 0, v.size()))
5923 return; 5935 return;
5924 contextGL()->UniformMatrix2fv(location->location(), v.size() >> 2, transpose, 5936 contextGL()->UniformMatrix2fv(location->location(), v.size() >> 2, transpose,
5925 v.data()); 5937 v.data());
5926 } 5938 }
5927 5939
5928 void WebGLRenderingContextBase::uniformMatrix3fv( 5940 void WebGLRenderingContextBase::uniformMatrix3fv(
5929 const WebGLUniformLocation* location, 5941 const WebGLUniformLocation* location,
5930 GLboolean transpose, 5942 GLboolean transpose,
5931 DOMFloat32Array* v) { 5943 DOMFloat32Array* v) {
5932 if (isContextLost() || 5944 if (isContextLost() ||
5933 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, 5945 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose,
5934 v, 9)) 5946 v, 9, 0, v->length()))
5935 return; 5947 return;
5936 contextGL()->UniformMatrix3fv(location->location(), v->length() / 9, 5948 contextGL()->UniformMatrix3fv(location->location(), v->length() / 9,
5937 transpose, v->data()); 5949 transpose, v->data());
5938 } 5950 }
5939 5951
5940 void WebGLRenderingContextBase::uniformMatrix3fv( 5952 void WebGLRenderingContextBase::uniformMatrix3fv(
5941 const WebGLUniformLocation* location, 5953 const WebGLUniformLocation* location,
5942 GLboolean transpose, 5954 GLboolean transpose,
5943 Vector<GLfloat>& v) { 5955 Vector<GLfloat>& v) {
5944 if (isContextLost() || 5956 if (isContextLost() ||
5945 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, 5957 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose,
5946 v.data(), v.size(), 9)) 5958 v.data(), v.size(), 9, 0, v.size()))
5947 return; 5959 return;
5948 contextGL()->UniformMatrix3fv(location->location(), v.size() / 9, transpose, 5960 contextGL()->UniformMatrix3fv(location->location(), v.size() / 9, transpose,
5949 v.data()); 5961 v.data());
5950 } 5962 }
5951 5963
5952 void WebGLRenderingContextBase::uniformMatrix4fv( 5964 void WebGLRenderingContextBase::uniformMatrix4fv(
5953 const WebGLUniformLocation* location, 5965 const WebGLUniformLocation* location,
5954 GLboolean transpose, 5966 GLboolean transpose,
5955 DOMFloat32Array* v) { 5967 DOMFloat32Array* v) {
5956 if (isContextLost() || 5968 if (isContextLost() ||
5957 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, 5969 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose,
5958 v, 16)) 5970 v, 16, 0, v->length()))
5959 return; 5971 return;
5960 contextGL()->UniformMatrix4fv(location->location(), v->length() >> 4, 5972 contextGL()->UniformMatrix4fv(location->location(), v->length() >> 4,
5961 transpose, v->data()); 5973 transpose, v->data());
5962 } 5974 }
5963 5975
5964 void WebGLRenderingContextBase::uniformMatrix4fv( 5976 void WebGLRenderingContextBase::uniformMatrix4fv(
5965 const WebGLUniformLocation* location, 5977 const WebGLUniformLocation* location,
5966 GLboolean transpose, 5978 GLboolean transpose,
5967 Vector<GLfloat>& v) { 5979 Vector<GLfloat>& v) {
5968 if (isContextLost() || 5980 if (isContextLost() ||
5969 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, 5981 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose,
5970 v.data(), v.size(), 16)) 5982 v.data(), v.size(), 16, 0, v.size()))
5971 return; 5983 return;
5972 contextGL()->UniformMatrix4fv(location->location(), v.size() >> 4, transpose, 5984 contextGL()->UniformMatrix4fv(location->location(), v.size() >> 4, transpose,
5973 v.data()); 5985 v.data());
5974 } 5986 }
5975 5987
5976 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) { 5988 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) {
5977 bool deleted; 5989 bool deleted;
5978 if (!checkObjectToBeBound("useProgram", program, deleted)) 5990 if (!checkObjectToBeBound("useProgram", program, deleted))
5979 return; 5991 return;
5980 if (deleted) 5992 if (deleted)
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
7192 return true; 7204 return true;
7193 default: 7205 default:
7194 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid capability"); 7206 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid capability");
7195 return false; 7207 return false;
7196 } 7208 }
7197 } 7209 }
7198 7210
7199 bool WebGLRenderingContextBase::validateUniformParameters( 7211 bool WebGLRenderingContextBase::validateUniformParameters(
7200 const char* functionName, 7212 const char* functionName,
7201 const WebGLUniformLocation* location, 7213 const WebGLUniformLocation* location,
7202 DOMFloat32Array* v,
7203 GLsizei requiredMinSize) {
7204 if (!v) {
7205 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
7206 return false;
7207 }
7208 return validateUniformMatrixParameters(
7209 functionName, location, false, v->data(), v->length(), requiredMinSize);
7210 }
7211
7212 bool WebGLRenderingContextBase::validateUniformParameters(
7213 const char* functionName,
7214 const WebGLUniformLocation* location,
7215 DOMInt32Array* v,
7216 GLsizei requiredMinSize) {
7217 if (!v) {
7218 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
7219 return false;
7220 }
7221 return validateUniformMatrixParameters(
7222 functionName, location, false, v->data(), v->length(), requiredMinSize);
7223 }
7224
7225 bool WebGLRenderingContextBase::validateUniformParameters(
7226 const char* functionName,
7227 const WebGLUniformLocation* location,
7228 void* v, 7214 void* v,
7229 GLsizei size, 7215 GLsizei size,
7230 GLsizei requiredMinSize) { 7216 GLsizei requiredMinSize,
7217 GLuint srcOffset,
7218 GLuint srcLength) {
7231 return validateUniformMatrixParameters(functionName, location, false, v, size, 7219 return validateUniformMatrixParameters(functionName, location, false, v, size,
7232 requiredMinSize); 7220 requiredMinSize, srcOffset, srcLength);
7233 } 7221 }
7234 7222
7235 bool WebGLRenderingContextBase::validateUniformMatrixParameters( 7223 bool WebGLRenderingContextBase::validateUniformMatrixParameters(
7236 const char* functionName, 7224 const char* functionName,
7237 const WebGLUniformLocation* location, 7225 const WebGLUniformLocation* location,
7238 GLboolean transpose, 7226 GLboolean transpose,
7239 DOMFloat32Array* v, 7227 DOMFloat32Array* v,
7240 GLsizei requiredMinSize) { 7228 GLsizei requiredMinSize,
7229 GLuint srcOffset,
7230 GLuint srcLength) {
7241 if (!v) { 7231 if (!v) {
7242 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); 7232 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
7243 return false; 7233 return false;
7244 } 7234 }
7245 return validateUniformMatrixParameters(functionName, location, transpose, 7235 return validateUniformMatrixParameters(functionName, location, transpose,
7246 v->data(), v->length(), 7236 v->data(), v->length(),
7247 requiredMinSize); 7237 requiredMinSize, srcOffset, srcLength);
7248 } 7238 }
7249 7239
7250 bool WebGLRenderingContextBase::validateUniformMatrixParameters( 7240 bool WebGLRenderingContextBase::validateUniformMatrixParameters(
7251 const char* functionName, 7241 const char* functionName,
7252 const WebGLUniformLocation* location, 7242 const WebGLUniformLocation* location,
7253 GLboolean transpose, 7243 GLboolean transpose,
7254 void* v, 7244 void* v,
7255 GLsizei size, 7245 GLsizei size,
7256 GLsizei requiredMinSize) { 7246 GLsizei requiredMinSize,
7247 GLuint srcOffset,
7248 GLuint srcLength) {
7249 DCHECK(size >= 0 && requiredMinSize > 0);
7257 if (!location) 7250 if (!location)
7258 return false; 7251 return false;
7259 if (location->program() != m_currentProgram) { 7252 if (location->program() != m_currentProgram) {
7260 synthesizeGLError(GL_INVALID_OPERATION, functionName, 7253 synthesizeGLError(GL_INVALID_OPERATION, functionName,
7261 "location is not from current program"); 7254 "location is not from current program");
7262 return false; 7255 return false;
7263 } 7256 }
7264 if (!v) { 7257 if (!v) {
7265 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); 7258 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
7266 return false; 7259 return false;
7267 } 7260 }
7268 if (transpose && !isWebGL2OrHigher()) { 7261 if (transpose && !isWebGL2OrHigher()) {
7269 synthesizeGLError(GL_INVALID_VALUE, functionName, "transpose not FALSE"); 7262 synthesizeGLError(GL_INVALID_VALUE, functionName, "transpose not FALSE");
7270 return false; 7263 return false;
7271 } 7264 }
7272 if (size < requiredMinSize || (size % requiredMinSize)) { 7265 if (srcOffset >= static_cast<GLuint>(size)) {
7266 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid srcOffset");
7267 return false;
7268 }
7269 GLsizei actualSize = size - srcOffset;
7270 if (srcLength > 0) {
7271 if (srcLength > static_cast<GLuint>(actualSize)) {
7272 synthesizeGLError(GL_INVALID_VALUE, functionName,
7273 "invalid srcOffset + srcLength");
7274 return false;
7275 }
7276 actualSize = srcLength;
7277 }
7278 if (actualSize < requiredMinSize || (actualSize % requiredMinSize)) {
7273 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size"); 7279 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size");
7274 return false; 7280 return false;
7275 } 7281 }
7276 return true; 7282 return true;
7277 } 7283 }
7278 7284
7279 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataTarget( 7285 WebGLBuffer* WebGLRenderingContextBase::validateBufferDataTarget(
7280 const char* functionName, 7286 const char* functionName,
7281 GLenum target) { 7287 GLenum target) {
7282 WebGLBuffer* buffer = nullptr; 7288 WebGLBuffer* buffer = nullptr;
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
7838 7844
7839 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7845 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7840 HTMLCanvasElementOrOffscreenCanvas& result) const { 7846 HTMLCanvasElementOrOffscreenCanvas& result) const {
7841 if (canvas()) 7847 if (canvas())
7842 result.setHTMLCanvasElement(canvas()); 7848 result.setHTMLCanvasElement(canvas());
7843 else 7849 else
7844 result.setOffscreenCanvas(offscreenCanvas()); 7850 result.setOffscreenCanvas(offscreenCanvas());
7845 } 7851 }
7846 7852
7847 } // namespace blink 7853 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698