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

Unified Diff: Source/core/html/canvas/WebGL2RenderingContextBase.cpp

Issue 974203002: update getTexParameter for WebGL 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed zmo@'s feedback Created 5 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 side-by-side diff with in-line comments
Download patch
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..0a42d4c07df96becaf4e33cfcb578c352a90ef9f 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);
+ // return m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding.get();
+ case GL_TEXTURE_3D:
+ ASSERT(false);
+ // 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:
+ {
+ GLfloat value = 0.f;
Zhenyao Mo 2015/03/06 18:39:46 This should be GLint, the function being getTexPar
yunchao 2015/03/09 02:25:25 Thanks for your review, @zmo. Accroding to OpenGL
Zhenyao Mo 2015/03/09 17:18:44 Yes, it seems there are some discrepancies in the
+ webContext()->getTexParameterfv(target, pname, &value);
+ return WebGLAny(scriptState, static_cast<int>(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
+ 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");
+ return ScriptValue::createNull(scriptState);
+ default:
+ synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name");
+ return ScriptValue::createNull(scriptState);
+ }
+}
+
} // namespace blink
« no previous file with comments | « Source/core/html/canvas/WebGL2RenderingContextBase.h ('k') | Source/core/html/canvas/WebGLRenderingContextBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698