OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 5506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5517 break; | 5517 break; |
5518 default: | 5518 default: |
5519 notImplemented(); | 5519 notImplemented(); |
5520 } | 5520 } |
5521 return WebGLAny(scriptState, DOMInt32Array::create(value, length)); | 5521 return WebGLAny(scriptState, DOMInt32Array::create(value, length)); |
5522 } | 5522 } |
5523 | 5523 |
5524 void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa
me, bool prepareToDraw) | 5524 void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa
me, bool prepareToDraw) |
5525 { | 5525 { |
5526 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 5526 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
| 5527 // We only handle the situation with float/half_float textures here. Other s
ituations are handled in command buffer. |
5527 bool resetActiveUnit = false; | 5528 bool resetActiveUnit = false; |
5528 WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureE
xtensionFlag>((extensionEnabled(OESTextureFloatLinearName) ? WebGLTexture::Textu
reFloatLinearExtensionEnabled : 0) | 5529 WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureE
xtensionFlag>((extensionEnabled(OESTextureFloatLinearName) ? WebGLTexture::Textu
reFloatLinearExtensionEnabled : 0) |
5529 | ((extensionEnabled(OESTextureHalfFloatLinearName) || isWebGL2OrHigher(
)) ? WebGLTexture::TextureHalfFloatLinearExtensionEnabled : 0)); | 5530 | ((extensionEnabled(OESTextureHalfFloatLinearName) || isWebGL2OrHigher(
)) ? WebGLTexture::TextureHalfFloatLinearExtensionEnabled : 0)); |
5530 for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) { | 5531 for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) { |
5531 const WebGLSamplerState* samplerState2D = getTextureUnitSamplerState(GL_
TEXTURE_2D, ii); | 5532 const WebGLSamplerState* samplerState2D = getTextureUnitSamplerState(GL_
TEXTURE_2D, ii); |
5532 const WebGLSamplerState* samplerStateCubeMap = getTextureUnitSamplerStat
e(GL_TEXTURE_CUBE_MAP, ii); | 5533 const WebGLSamplerState* samplerStateCubeMap = getTextureUnitSamplerStat
e(GL_TEXTURE_CUBE_MAP, ii); |
5533 if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m
_texture2DBinding->needToUseBlackTexture(flag, samplerState2D)) | 5534 bool needToUseBlackTex2D = (m_textureUnits[ii].m_texture2DBinding.get()
&& m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag, samplerSta
te2D)); |
5534 || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUni
ts[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag, samplerStateCubeMap)
)) { | 5535 bool needToUseBlackTexCubeMap = (m_textureUnits[ii].m_textureCubeMapBind
ing.get() && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(f
lag, samplerStateCubeMap)); |
| 5536 if (needToUseBlackTex2D || needToUseBlackTexCubeMap) { |
5535 if (ii != m_activeTextureUnit) { | 5537 if (ii != m_activeTextureUnit) { |
5536 webContext()->activeTexture(GL_TEXTURE0 + ii); | 5538 webContext()->activeTexture(GL_TEXTURE0 + ii); |
5537 resetActiveUnit = true; | 5539 resetActiveUnit = true; |
5538 } else if (resetActiveUnit) { | 5540 } else if (resetActiveUnit) { |
5539 webContext()->activeTexture(GL_TEXTURE0 + ii); | 5541 webContext()->activeTexture(GL_TEXTURE0 + ii); |
5540 resetActiveUnit = false; | 5542 resetActiveUnit = false; |
5541 } | 5543 } |
5542 WebGLTexture* tex2D; | 5544 WebGLTexture* tex2D; |
5543 WebGLTexture* texCubeMap; | 5545 WebGLTexture* texCubeMap; |
5544 if (prepareToDraw) { | 5546 if (prepareToDraw) { |
5545 String msg(String("texture bound to texture unit ") + String::nu
mber(ii) | 5547 String msg(String("texture bound to texture unit ") + String::nu
mber(ii) |
5546 + " is not renderable. It maybe non-power-of-2 and have inco
mpatible texture filtering or is not 'texture complete'." | 5548 + " is not renderable. Texture is Float or Half Float type w
ith linear filtering while OES_float_linear or OES_half_float_linear extension i
s not enabled."); |
5547 + " Or the texture is Float or Half Float type with linear f
iltering while OES_float_linear or OES_half_float_linear extension is not enable
d."); | |
5548 emitGLWarning(functionName, msg.utf8().data()); | 5549 emitGLWarning(functionName, msg.utf8().data()); |
5549 tex2D = m_blackTexture2D.get(); | 5550 tex2D = m_blackTexture2D.get(); |
5550 texCubeMap = m_blackTextureCubeMap.get(); | 5551 texCubeMap = m_blackTextureCubeMap.get(); |
5551 } else { | 5552 } else { |
5552 tex2D = m_textureUnits[ii].m_texture2DBinding.get(); | 5553 tex2D = m_textureUnits[ii].m_texture2DBinding.get(); |
5553 texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); | 5554 texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); |
5554 } | 5555 } |
5555 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_te
xture2DBinding->needToUseBlackTexture(flag, samplerState2D)) | 5556 if (needToUseBlackTex2D) |
5556 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D)); | 5557 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D)); |
5557 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii]
.m_textureCubeMapBinding->needToUseBlackTexture(flag, samplerStateCubeMap)) | 5558 if (needToUseBlackTexCubeMap) |
5558 webContext()->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texC
ubeMap)); | 5559 webContext()->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texC
ubeMap)); |
5559 } | 5560 } |
5560 } | 5561 } |
5561 if (resetActiveUnit) | 5562 if (resetActiveUnit) |
5562 webContext()->activeTexture(GL_TEXTURE0 + m_activeTextureUnit); | 5563 webContext()->activeTexture(GL_TEXTURE0 + m_activeTextureUnit); |
5563 } | 5564 } |
5564 | 5565 |
5565 void WebGLRenderingContextBase::createFallbackBlackTextures1x1() | 5566 void WebGLRenderingContextBase::createFallbackBlackTextures1x1() |
5566 { | 5567 { |
5567 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 5568 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7000 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 7001 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
7001 } | 7002 } |
7002 | 7003 |
7003 void WebGLRenderingContextBase::restoreUnpackParameters() | 7004 void WebGLRenderingContextBase::restoreUnpackParameters() |
7004 { | 7005 { |
7005 if (m_unpackAlignment != 1) | 7006 if (m_unpackAlignment != 1) |
7006 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 7007 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
7007 } | 7008 } |
7008 | 7009 |
7009 } // namespace blink | 7010 } // namespace blink |
OLD | NEW |