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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp

Issue 1490043002: Implementing Blink-side validation for WebGL 2 Samplers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed zmo@'s new feedback Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLTexture.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp b/third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp
index 80d5bd122550a8930eb8e6535f6b55be582539e1..3b4977663e221ea0fcd0ba6ef1119a9e83063c99 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp
@@ -39,11 +39,6 @@ WebGLTexture* WebGLTexture::create(WebGLRenderingContextBase* ctx)
WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx)
: WebGLSharedPlatform3DObject(ctx)
, m_target(0)
- , m_minFilter(GL_NEAREST_MIPMAP_LINEAR)
- , m_magFilter(GL_LINEAR)
- , m_wrapR(GL_REPEAT)
- , m_wrapS(GL_REPEAT)
- , m_wrapT(GL_REPEAT)
, m_isNPOT(false)
, m_isCubeComplete(false)
, m_isComplete(false)
@@ -101,7 +96,7 @@ void WebGLTexture::setParameteri(GLenum pname, GLint param)
case GL_LINEAR_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
- m_minFilter = param;
+ m_samplerState.minFilter = param;
break;
}
break;
@@ -109,7 +104,7 @@ void WebGLTexture::setParameteri(GLenum pname, GLint param)
switch (param) {
case GL_NEAREST:
case GL_LINEAR:
- m_magFilter = param;
+ m_samplerState.magFilter = param;
break;
}
break;
@@ -118,7 +113,7 @@ void WebGLTexture::setParameteri(GLenum pname, GLint param)
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
case GL_REPEAT:
- m_wrapR = param;
+ m_samplerState.wrapR = param;
break;
}
break;
@@ -127,7 +122,7 @@ void WebGLTexture::setParameteri(GLenum pname, GLint param)
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
case GL_REPEAT:
- m_wrapS = param;
+ m_samplerState.wrapS = param;
break;
}
break;
@@ -136,7 +131,7 @@ void WebGLTexture::setParameteri(GLenum pname, GLint param)
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
case GL_REPEAT:
- m_wrapT = param;
+ m_samplerState.wrapT = param;
break;
}
break;
@@ -303,14 +298,15 @@ bool WebGLTexture::isNPOT() const
return m_isNPOT;
}
-bool WebGLTexture::needToUseBlackTexture(TextureExtensionFlag flag) const
+bool WebGLTexture::needToUseBlackTexture(TextureExtensionFlag flag, const WebGLSamplerState* samplerState) const
{
+ ASSERT(samplerState);
if (!object())
return false;
if (m_needToUseBlackTexture)
return true;
if ((m_isFloatType && !(flag & TextureFloatLinearExtensionEnabled)) || (m_isHalfFloatType && !(flag && TextureHalfFloatLinearExtensionEnabled))) {
- if (m_magFilter != GL_NEAREST || (m_minFilter != GL_NEAREST && m_minFilter != GL_NEAREST_MIPMAP_NEAREST))
+ if (samplerState->magFilter != GL_NEAREST || (samplerState->minFilter != GL_NEAREST && samplerState->minFilter != GL_NEAREST_MIPMAP_NEAREST))
return true;
}
return false;
@@ -445,16 +441,19 @@ void WebGLTexture::update()
m_isHalfFloatType = m_info[0][0].type == GL_HALF_FLOAT_OES;
m_needToUseBlackTexture = false;
- // NPOT
- if (!m_isWebGL2OrHigher && m_isNPOT && ((m_minFilter != GL_NEAREST && m_minFilter != GL_LINEAR)
- || m_wrapS != GL_CLAMP_TO_EDGE || m_wrapT != GL_CLAMP_TO_EDGE || (m_target == GL_TEXTURE_3D && m_wrapR != GL_CLAMP_TO_EDGE)))
- m_needToUseBlackTexture = true;
// If it is a Cube texture, check Cube Completeness first
if (m_info.size() > 1 && !m_isCubeComplete)
m_needToUseBlackTexture = true;
- // Completeness
- if (!m_isComplete && m_minFilter != GL_NEAREST && m_minFilter != GL_LINEAR)
- m_needToUseBlackTexture = true;
+ if (!m_isWebGL2OrHigher) {
+ // We can do these checks up front in WebGL 1 because there's no separate samplers.
+ // NPOT
+ if (m_isNPOT && ((m_samplerState.minFilter != GL_NEAREST && m_samplerState.minFilter != GL_LINEAR)
+ || m_samplerState.wrapS != GL_CLAMP_TO_EDGE || m_samplerState.wrapT != GL_CLAMP_TO_EDGE))
+ m_needToUseBlackTexture = true;
+ // Completeness
+ if (!m_isComplete && m_samplerState.minFilter != GL_NEAREST && m_samplerState.minFilter != GL_LINEAR)
+ m_needToUseBlackTexture = true;
+ }
}
const WebGLTexture::LevelInfo* WebGLTexture::getLevelInfo(GLenum target, GLint level) const
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLTexture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698