| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/webgl/WebGL2RenderingContextBase.h" | 5 #include "modules/webgl/WebGL2RenderingContextBase.h" |
| 6 | 6 |
| 7 #include "bindings/modules/v8/WebGLAny.h" | 7 #include "bindings/modules/v8/WebGLAny.h" |
| 8 #include "core/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.h" |
| 9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
| 10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
| (...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 } | 1708 } |
| 1709 | 1709 |
| 1710 GLboolean WebGL2RenderingContextBase::isQuery(WebGLQuery* query) | 1710 GLboolean WebGL2RenderingContextBase::isQuery(WebGLQuery* query) |
| 1711 { | 1711 { |
| 1712 if (isContextLost() || !query) | 1712 if (isContextLost() || !query) |
| 1713 return 0; | 1713 return 0; |
| 1714 | 1714 |
| 1715 return contextGL()->IsQueryEXT(query->object()); | 1715 return contextGL()->IsQueryEXT(query->object()); |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 void WebGL2RenderingContextBase::beginQuery(GLenum target, WebGLQuery* query) | 1718 void WebGL2RenderingContextBase::beginQuery(ScriptState* scriptState, GLenum tar
get, WebGLQuery* query) |
| 1719 { | 1719 { |
| 1720 bool deleted; | 1720 bool deleted; |
| 1721 if (!query) { | 1721 if (!query) { |
| 1722 synthesizeGLError(GL_INVALID_OPERATION, "beginQuery", "query object is n
ull"); | 1722 synthesizeGLError(GL_INVALID_OPERATION, "beginQuery", "query object is n
ull"); |
| 1723 return; | 1723 return; |
| 1724 } | 1724 } |
| 1725 | 1725 |
| 1726 if (!checkObjectToBeBound("beginQuery", query, deleted)) | 1726 if (!checkObjectToBeBound("beginQuery", query, deleted)) |
| 1727 return; | 1727 return; |
| 1728 if (deleted) { | 1728 if (deleted) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1757 break; | 1757 break; |
| 1758 default: | 1758 default: |
| 1759 synthesizeGLError(GL_INVALID_ENUM, "beginQuery", "invalid target"); | 1759 synthesizeGLError(GL_INVALID_ENUM, "beginQuery", "invalid target"); |
| 1760 return; | 1760 return; |
| 1761 } | 1761 } |
| 1762 | 1762 |
| 1763 if (!query->getTarget()) | 1763 if (!query->getTarget()) |
| 1764 query->setTarget(target); | 1764 query->setTarget(target); |
| 1765 | 1765 |
| 1766 contextGL()->BeginQueryEXT(target, query->object()); | 1766 contextGL()->BeginQueryEXT(target, query->object()); |
| 1767 preserveObjectWrapper(scriptState, this, V8HiddenValue::webglQueries(scriptS
tate->isolate()), &m_queryWrappers, static_cast<uint32_t>(target), query); |
| 1767 } | 1768 } |
| 1768 | 1769 |
| 1769 void WebGL2RenderingContextBase::endQuery(GLenum target) | 1770 void WebGL2RenderingContextBase::endQuery(GLenum target) |
| 1770 { | 1771 { |
| 1771 if (isContextLost()) | 1772 if (isContextLost()) |
| 1772 return; | 1773 return; |
| 1773 | 1774 |
| 1774 switch (target) { | 1775 switch (target) { |
| 1775 case GL_ANY_SAMPLES_PASSED: | 1776 case GL_ANY_SAMPLES_PASSED: |
| 1776 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: | 1777 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 } | 1895 } |
| 1895 | 1896 |
| 1896 GLboolean WebGL2RenderingContextBase::isSampler(WebGLSampler* sampler) | 1897 GLboolean WebGL2RenderingContextBase::isSampler(WebGLSampler* sampler) |
| 1897 { | 1898 { |
| 1898 if (isContextLost() || !sampler) | 1899 if (isContextLost() || !sampler) |
| 1899 return 0; | 1900 return 0; |
| 1900 | 1901 |
| 1901 return contextGL()->IsSampler(sampler->object()); | 1902 return contextGL()->IsSampler(sampler->object()); |
| 1902 } | 1903 } |
| 1903 | 1904 |
| 1904 void WebGL2RenderingContextBase::bindSampler(GLuint unit, WebGLSampler* sampler) | 1905 void WebGL2RenderingContextBase::bindSampler(ScriptState* scriptState, GLuint un
it, WebGLSampler* sampler) |
| 1905 { | 1906 { |
| 1906 if (isContextLost()) | 1907 if (isContextLost()) |
| 1907 return; | 1908 return; |
| 1908 | 1909 |
| 1909 bool deleted; | 1910 bool deleted; |
| 1910 if (!checkObjectToBeBound("bindSampler", sampler, deleted)) | 1911 if (!checkObjectToBeBound("bindSampler", sampler, deleted)) |
| 1911 return; | 1912 return; |
| 1912 if (deleted) { | 1913 if (deleted) { |
| 1913 synthesizeGLError(GL_INVALID_OPERATION, "bindSampler", "attempted to bin
d a deleted sampler"); | 1914 synthesizeGLError(GL_INVALID_OPERATION, "bindSampler", "attempted to bin
d a deleted sampler"); |
| 1914 return; | 1915 return; |
| 1915 } | 1916 } |
| 1916 | 1917 |
| 1917 if (unit >= m_samplerUnits.size()) { | 1918 if (unit >= m_samplerUnits.size()) { |
| 1918 synthesizeGLError(GL_INVALID_VALUE, "bindSampler", "texture unit out of
range"); | 1919 synthesizeGLError(GL_INVALID_VALUE, "bindSampler", "texture unit out of
range"); |
| 1919 return; | 1920 return; |
| 1920 } | 1921 } |
| 1921 | 1922 |
| 1922 m_samplerUnits[unit] = sampler; | 1923 m_samplerUnits[unit] = sampler; |
| 1923 | 1924 |
| 1924 contextGL()->BindSampler(unit, objectOrZero(sampler)); | 1925 contextGL()->BindSampler(unit, objectOrZero(sampler)); |
| 1926 |
| 1927 preserveObjectWrapper(scriptState, this, V8HiddenValue::webglSamplers(script
State->isolate()), &m_samplerWrappers, static_cast<uint32_t>(unit), sampler); |
| 1925 } | 1928 } |
| 1926 | 1929 |
| 1927 void WebGL2RenderingContextBase::samplerParameter(WebGLSampler* sampler, GLenum
pname, GLfloat paramf, GLint parami, bool isFloat) | 1930 void WebGL2RenderingContextBase::samplerParameter(WebGLSampler* sampler, GLenum
pname, GLfloat paramf, GLint parami, bool isFloat) |
| 1928 { | 1931 { |
| 1929 if (isContextLost() || !validateWebGLObject("samplerParameter", sampler)) | 1932 if (isContextLost() || !validateWebGLObject("samplerParameter", sampler)) |
| 1930 return; | 1933 return; |
| 1931 | 1934 |
| 1932 GLint param = isFloat ? static_cast<GLint>(paramf) : parami; | 1935 GLint param = isFloat ? static_cast<GLint>(paramf) : parami; |
| 1933 switch (pname) { | 1936 switch (pname) { |
| 1934 case GL_TEXTURE_MAX_LOD: | 1937 case GL_TEXTURE_MAX_LOD: |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 { | 2151 { |
| 2149 if (isContextLost() || !feedback) | 2152 if (isContextLost() || !feedback) |
| 2150 return 0; | 2153 return 0; |
| 2151 | 2154 |
| 2152 if (!feedback->hasEverBeenBound()) | 2155 if (!feedback->hasEverBeenBound()) |
| 2153 return 0; | 2156 return 0; |
| 2154 | 2157 |
| 2155 return contextGL()->IsTransformFeedback(feedback->object()); | 2158 return contextGL()->IsTransformFeedback(feedback->object()); |
| 2156 } | 2159 } |
| 2157 | 2160 |
| 2158 void WebGL2RenderingContextBase::bindTransformFeedback(GLenum target, WebGLTrans
formFeedback* feedback) | 2161 void WebGL2RenderingContextBase::bindTransformFeedback(ScriptState* scriptState,
GLenum target, WebGLTransformFeedback* feedback) |
| 2159 { | 2162 { |
| 2160 bool deleted; | 2163 bool deleted; |
| 2161 if (!checkObjectToBeBound("bindTransformFeedback", feedback, deleted)) | 2164 if (!checkObjectToBeBound("bindTransformFeedback", feedback, deleted)) |
| 2162 return; | 2165 return; |
| 2163 if (deleted) { | 2166 if (deleted) { |
| 2164 synthesizeGLError(GL_INVALID_OPERATION, "bindTransformFeedback", "attemp
ted to bind a deleted transform feedback object"); | 2167 synthesizeGLError(GL_INVALID_OPERATION, "bindTransformFeedback", "attemp
ted to bind a deleted transform feedback object"); |
| 2165 return; | 2168 return; |
| 2166 } | 2169 } |
| 2167 | 2170 |
| 2168 if (target != GL_TRANSFORM_FEEDBACK) { | 2171 if (target != GL_TRANSFORM_FEEDBACK) { |
| 2169 synthesizeGLError(GL_INVALID_ENUM, "bindTransformFeedback", "target must
be TRANSFORM_FEEDBACK"); | 2172 synthesizeGLError(GL_INVALID_ENUM, "bindTransformFeedback", "target must
be TRANSFORM_FEEDBACK"); |
| 2170 return; | 2173 return; |
| 2171 } | 2174 } |
| 2172 | 2175 |
| 2173 if (transformFeedbackActive() && !transformFeedbackPaused()) { | 2176 if (transformFeedbackActive() && !transformFeedbackPaused()) { |
| 2174 synthesizeGLError(GL_INVALID_OPERATION, "bindTransformFeedback", "transf
orm feedback is active and not paused"); | 2177 synthesizeGLError(GL_INVALID_OPERATION, "bindTransformFeedback", "transf
orm feedback is active and not paused"); |
| 2175 return; | 2178 return; |
| 2176 } | 2179 } |
| 2177 | 2180 |
| 2178 m_transformFeedbackBinding = feedback; | 2181 m_transformFeedbackBinding = feedback; |
| 2179 | 2182 |
| 2180 contextGL()->BindTransformFeedback(target, objectOrZero(feedback)); | 2183 contextGL()->BindTransformFeedback(target, objectOrZero(feedback)); |
| 2181 if (feedback) | 2184 if (feedback) { |
| 2182 feedback->setTarget(target); | 2185 feedback->setTarget(target); |
| 2186 preserveObjectWrapper(scriptState, this, V8HiddenValue::webglMisc(script
State->isolate()), &m_miscWrappers, static_cast<uint32_t>(PreservedTransformFeed
back), feedback); |
| 2187 } |
| 2188 |
| 2183 } | 2189 } |
| 2184 | 2190 |
| 2185 void WebGL2RenderingContextBase::beginTransformFeedback(GLenum primitiveMode) | 2191 void WebGL2RenderingContextBase::beginTransformFeedback(GLenum primitiveMode) |
| 2186 { | 2192 { |
| 2187 if (isContextLost()) | 2193 if (isContextLost()) |
| 2188 return; | 2194 return; |
| 2189 if (!validateTransformFeedbackPrimitiveMode("beginTransformFeedback", primit
iveMode)) | 2195 if (!validateTransformFeedbackPrimitiveMode("beginTransformFeedback", primit
iveMode)) |
| 2190 return; | 2196 return; |
| 2191 | 2197 |
| 2192 if (transformFeedbackActive()) { | 2198 if (transformFeedbackActive()) { |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3583 params.skipPixels = m_unpackSkipPixels; | 3589 params.skipPixels = m_unpackSkipPixels; |
| 3584 params.skipRows = m_unpackSkipRows; | 3590 params.skipRows = m_unpackSkipRows; |
| 3585 if (dimension == Tex3D) { | 3591 if (dimension == Tex3D) { |
| 3586 params.imageHeight = m_unpackImageHeight; | 3592 params.imageHeight = m_unpackImageHeight; |
| 3587 params.skipImages = m_unpackSkipImages; | 3593 params.skipImages = m_unpackSkipImages; |
| 3588 } | 3594 } |
| 3589 return params; | 3595 return params; |
| 3590 } | 3596 } |
| 3591 | 3597 |
| 3592 } // namespace blink | 3598 } // namespace blink |
| OLD | NEW |