Index: Source/core/html/canvas/WebGL2RenderingContextBase.cpp |
diff --git a/Source/core/html/canvas/WebGL2RenderingContextBase.cpp b/Source/core/html/canvas/WebGL2RenderingContextBase.cpp |
index b6f57f87ac8c23137bcad0062f63a038e1dc62b6..289482c380421344c745ae8142fcdd90117bd7f4 100644 |
--- a/Source/core/html/canvas/WebGL2RenderingContextBase.cpp |
+++ b/Source/core/html/canvas/WebGL2RenderingContextBase.cpp |
@@ -1201,4 +1201,72 @@ DEFINE_TRACE(WebGL2RenderingContextBase) |
WebGLRenderingContextBase::trace(visitor); |
} |
+WebGLTexture* WebGL2RenderingContextBase::validateTextureBinding(const char* functionName, GLenum target, bool useSixEnumsForCubeMap) |
+{ |
+ switch (target) { |
+ case GL_TEXTURE_2D_ARRAY: |
+ // FIXME: add 2D Array texture binding point and 3D texture binding point. |
+ ASSERT(false); |
Zhenyao Mo
2015/03/11 17:31:40
Thinking more, maybe it's better to return nullptr
yunchao
2015/04/21 11:14:46
Done.
|
+ // return m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding.get(); |
+ case GL_TEXTURE_3D: |
+ ASSERT(false); |
Zhenyao Mo
2015/03/11 17:31:40
Same here.
yunchao
2015/04/21 11:14:46
Done.
|
+ // return m_textureUnits[m_activeTextureUnit].m_texture3DBinding.get(); |
+ default: |
+ return WebGLRenderingContextBase::validateTextureBinding(functionName, target, useSixEnumsForCubeMap); |
+ } |
+} |
+ |
+ScriptValue WebGL2RenderingContextBase::getTexParameter(ScriptState* scriptState, GLenum target, GLenum pname) |
+{ |
+ if (isContextLost() || !validateTextureBinding("getTexParameter", target, false)) |
+ return ScriptValue::createNull(scriptState); |
+ |
+ switch (pname) { |
+ case GL_TEXTURE_MAG_FILTER: |
+ case GL_TEXTURE_MIN_FILTER: |
+ case GL_TEXTURE_WRAP_S: |
+ case GL_TEXTURE_WRAP_T: |
+ case GL_TEXTURE_WRAP_R: |
+ case GL_TEXTURE_COMPARE_FUNC: |
+ case GL_TEXTURE_COMPARE_MODE: |
+ case GL_TEXTURE_IMMUTABLE_LEVELS: |
+ { |
+ GLint value = 0; |
+ webContext()->getTexParameteriv(target, pname, &value); |
+ return WebGLAny(scriptState, static_cast<unsigned>(value)); |
+ } |
+ case GL_TEXTURE_IMMUTABLE_FORMAT: |
+ { |
+ GLint value = 0; |
+ webContext()->getTexParameteriv(target, pname, &value); |
+ return WebGLAny(scriptState, static_cast<bool>(value)); |
+ } |
+ case GL_TEXTURE_BASE_LEVEL: |
+ case GL_TEXTURE_MAX_LEVEL: |
+ { |
+ GLint value = 0; |
+ webContext()->getTexParameteriv(target, pname, &value); |
+ return WebGLAny(scriptState, value); |
+ } |
+ case GL_TEXTURE_MAX_LOD: |
+ case GL_TEXTURE_MIN_LOD: |
+ { |
+ GLfloat value = 0.f; |
+ webContext()->getTexParameterfv(target, pname, &value); |
+ return WebGLAny(scriptState, value); |
+ } |
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic |
Zhenyao Mo
2015/03/11 17:31:40
Actually I am not sure about extension situation.
yunchao
2015/04/21 11:14:46
Done.
|
+ if (extensionEnabled(EXTTextureFilterAnisotropicName)) { |
+ GLfloat value = 0.f; |
+ webContext()->getTexParameterfv(target, pname, &value); |
+ return WebGLAny(scriptState, value); |
+ } |
+ synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name, EXT_texture_filter_anisotropic not enabled"); |
Zhenyao Mo
2015/03/11 17:31:40
This is not needed. It can just fall through to t
yunchao
2015/04/21 11:14:46
Acknowledged.
|
+ return ScriptValue::createNull(scriptState); |
+ default: |
+ synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name"); |
+ return ScriptValue::createNull(scriptState); |
+ } |
+} |
+ |
} // namespace blink |