Index: Source/core/html/canvas/WebGLRenderingContext.cpp |
diff --git a/Source/core/html/canvas/WebGLRenderingContext.cpp b/Source/core/html/canvas/WebGLRenderingContext.cpp |
index 65e1ccbc4eac2d21150bd4ac5671fba0919127ed..390e7794190a8f7c5be8522cc0910fd5241eef69 100644 |
--- a/Source/core/html/canvas/WebGLRenderingContext.cpp |
+++ b/Source/core/html/canvas/WebGLRenderingContext.cpp |
@@ -38,7 +38,9 @@ |
#include "core/html/canvas/OESElementIndexUint.h" |
#include "core/html/canvas/OESStandardDerivatives.h" |
#include "core/html/canvas/OESTextureFloat.h" |
+#include "core/html/canvas/OESTextureFloatLinear.h" |
#include "core/html/canvas/OESTextureHalfFloat.h" |
+#include "core/html/canvas/OESTextureHalfFloatLinear.h" |
#include "core/html/canvas/OESVertexArrayObject.h" |
#include "core/html/canvas/WebGLActiveInfo.h" |
#include "core/html/canvas/WebGLBuffer.h" |
@@ -625,8 +627,7 @@ void WebGLRenderingContext::initializeNewContext() |
m_vertexAttribValue.resize(m_maxVertexAttribs); |
- if (!isGLES2NPOTStrict()) |
- createFallbackBlackTextures1x1(); |
+ createFallbackBlackTextures1x1(); |
IntSize canvasSize = clampedCanvasSize(); |
m_drawingBuffer->reset(canvasSize); |
@@ -1728,12 +1729,9 @@ void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c |
clearIfComposited(); |
- bool vertexAttrib0Simulated = false; |
- if (!isGLES2NPOTStrict()) |
- handleNPOTTextures("drawArrays", true); |
+ handleTexturesCompleteness("drawArrays", true); |
m_context->drawArrays(mode, first, count); |
- if (!isGLES2NPOTStrict()) |
- handleNPOTTextures("drawArrays", false); |
+ handleTexturesCompleteness("drawArrays", false); |
markContextChanged(); |
} |
@@ -1789,11 +1787,9 @@ void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denu |
} |
clearIfComposited(); |
- if (!isGLES2NPOTStrict()) |
- handleNPOTTextures("drawElements", true); |
+ handleTexturesCompleteness("drawElements", true); |
m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offset)); |
- if (!isGLES2NPOTStrict()) |
- handleNPOTTextures("drawElements", false); |
+ handleTexturesCompleteness("drawElements", false); |
markContextChanged(); |
} |
@@ -2113,6 +2109,10 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name) |
return extension; |
if (getExtensionIfMatch<EXTDrawBuffers>(name, m_extDrawBuffers, unprefixed, extension)) |
return extension; |
+ if (getExtensionIfMatch<OESTextureFloatLinear>(name, m_oesTextureFloatLinear, unprefixed, extension)) |
+ return extension; |
+ if (getExtensionIfMatch<OESTextureHalfFloatLinear>(name, m_oesTextureHalfFloatLinear, unprefixed, extension)) |
+ return extension; |
if (allowPrivilegedExtensions()) { |
if (getExtensionIfMatch<WebGLDebugRendererInfo>(name, m_webglDebugRendererInfo, unprefixed, extension)) |
return extension; |
@@ -2599,6 +2599,9 @@ Vector<String> WebGLRenderingContext::getSupportedExtensions() |
appendIfSupported<OESElementIndexUint>(result, false); |
appendIfSupported<OESStandardDerivatives>(result, false); |
appendIfSupported<OESTextureFloat>(result, false); |
+ appendIfSupported<OESTextureFloatLinear>(result, false); |
+ appendIfSupported<OESTextureHalfFloat>(result, false); |
+ appendIfSupported<OESTextureHalfFloatLinear>(result, false); |
appendIfSupported<OESVertexArrayObject>(result, false); |
appendIfSupported<WebGLCompressedTextureATC>(result, true); |
appendIfSupported<WebGLCompressedTexturePVRTC>(result, true); |
@@ -4327,36 +4330,53 @@ WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(GC3Denum pname) |
return WebGLGetInfo(Int32Array::create(value, length)); |
} |
-void WebGLRenderingContext::handleNPOTTextures(const char* functionName, bool prepareToDraw) |
+void WebGLRenderingContext::handleTexturesCompleteness(const char* functionName, bool prepareToDraw) |
{ |
// All calling functions check isContextLost, so a duplicate check is not needed here. |
bool resetActiveUnit = false; |
+ String msgHint = String(); |
for (unsigned ii = 0; ii < m_textureUnits.size(); ++ii) { |
- if ((m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture()) |
- || (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture())) { |
- if (ii != m_activeTextureUnit) { |
- m_context->activeTexture(ii); |
- resetActiveUnit = true; |
- } else if (resetActiveUnit) { |
- m_context->activeTexture(ii); |
- resetActiveUnit = false; |
- } |
- WebGLTexture* tex2D; |
- WebGLTexture* texCubeMap; |
- if (prepareToDraw) { |
- String msg(String("texture bound to texture unit ") + String::number(ii) |
- + " is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'"); |
- printGLWarningToConsole(functionName, msg.utf8().data()); |
- tex2D = m_blackTexture2D.get(); |
- texCubeMap = m_blackTextureCubeMap.get(); |
- } else { |
- tex2D = m_textureUnits[ii].m_texture2DBinding.get(); |
- texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); |
+ GC3Denum target[7] = { GraphicsContext3D::TEXTURE_2D, |
Ken Russell (switch to Gerrit)
2013/05/13 20:00:35
Inlining this code here is inefficient and hard to
|
+ GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X, GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X, |
+ GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y, GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y, |
+ GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z, GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z }; |
+ for (unsigned i = 0; i < 7; i++) { |
+ WebGLTexture* textureBinding = |
+ (target[i] == GraphicsContext3D::TEXTURE_2D) ? (m_textureUnits[ii].m_texture2DBinding ? m_textureUnits[ii].m_texture2DBinding.get() : 0) |
Ken Russell (switch to Gerrit)
2013/05/13 20:00:35
The test here and below is unnecessary; you can ju
|
+ : (m_textureUnits[ii].m_textureCubeMapBinding ? m_textureUnits[ii].m_textureCubeMapBinding.get() : 0); |
+ if (textureBinding) { |
+ bool needToUseBlackTexture = false; |
+ if (textureBinding->needToUseBlackTexture()) { |
+ needToUseBlackTexture = true; |
+ msgHint.append("It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete"); |
+ } |
+ if ((textureBinding->getType(target[i], 0) == GraphicsContext3D::FLOAT && !m_oesTextureFloatLinear) |
+ || (textureBinding->getType(target[i], 0) == GraphicsContext3D::HALF_FLOAT_OES && !m_oesTextureHalfFloatLinear)) { |
+ if (textureBinding->getMagFilter() != GraphicsContext3D::NEAREST |
+ || (textureBinding->getMinFilter() != GraphicsContext3D::NEAREST && textureBinding->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_NEAREST)) { |
+ needToUseBlackTexture = true; |
+ msgHint.append("the texture is of Float type and requires a linear filtering but the linear filtering extension is disabled or not supported."); |
+ } |
+ } |
+ if (needToUseBlackTexture) { |
+ if (ii != m_activeTextureUnit) { |
+ m_context->activeTexture(ii); |
+ resetActiveUnit = true; |
+ } else if (resetActiveUnit) { |
+ m_context->activeTexture(ii); |
+ resetActiveUnit = false; |
+ } |
+ WebGLTexture* texTemp = 0; |
+ if (prepareToDraw) { |
+ String msg(String("texture bound to texture unit ") + String::number(ii) |
+ + " is not renderable: " + msgHint); |
+ printGLWarningToConsole(functionName, msg.utf8().data()); |
+ texTemp = (target[i] == GraphicsContext3D::TEXTURE_2D) ? m_blackTexture2D.get() : m_blackTextureCubeMap.get(); |
+ } else |
+ texTemp = (target[i] == GraphicsContext3D::TEXTURE_2D) ? m_textureUnits[ii].m_texture2DBinding.get() : m_textureUnits[ii].m_textureCubeMapBinding.get(); |
+ m_context->bindTexture((target[i] == GraphicsContext3D::TEXTURE_2D) ? GraphicsContext3D::TEXTURE_2D : GraphicsContext3D::TEXTURE_CUBE_MAP, objectOrZero(texTemp)); |
+ } |
} |
- if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture()) |
- m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(tex2D)); |
- if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture()) |
- m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, objectOrZero(texCubeMap)); |
} |
} |
if (resetActiveUnit) |