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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 { GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT }, | 857 { GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT }, |
858 { GL_RGBA32I, GL_RGBA_INTEGER, GL_INT }, | 858 { GL_RGBA32I, GL_RGBA_INTEGER, GL_INT }, |
859 { GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT }, | 859 { GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT }, |
860 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT }, | 860 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT }, |
861 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, | 861 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, |
862 { GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, | 862 { GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, |
863 { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT }, | 863 { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT }, |
864 { GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 }, | 864 { GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 }, |
865 }; | 865 }; |
866 | 866 |
867 bool isUnsignedIntegerFormat(GLenum internalformat) | |
868 { | |
869 switch (internalformat) { | |
870 case GL_R8UI: | |
871 case GL_R16UI: | |
872 case GL_R32UI: | |
873 case GL_RG8UI: | |
874 case GL_RG16UI: | |
875 case GL_RG32UI: | |
876 case GL_RGB8UI: | |
877 case GL_RGB16UI: | |
878 case GL_RGB32UI: | |
879 case GL_RGBA8UI: | |
880 case GL_RGB10_A2UI: | |
881 case GL_RGBA16UI: | |
882 case GL_RGBA32UI: | |
883 return true; | |
884 default: | |
885 return false; | |
886 } | |
887 } | |
888 | |
889 bool isSignedIntegerFormat(GLenum internalformat) | |
890 { | |
891 switch (internalformat) { | |
892 case GL_R8I: | |
893 case GL_R16I: | |
894 case GL_R32I: | |
895 case GL_RG8I: | |
896 case GL_RG16I: | |
897 case GL_RG32I: | |
898 case GL_RGB8I: | |
899 case GL_RGB16I: | |
900 case GL_RGB32I: | |
901 case GL_RGBA8I: | |
902 case GL_RGBA16I: | |
903 case GL_RGBA32I: | |
904 return true; | |
905 default: | |
906 return false; | |
907 } | |
908 } | |
909 | |
910 bool isIntegerFormat(GLenum internalformat) | |
911 { | |
912 return (isUnsignedIntegerFormat(internalformat) || isSignedIntegerFormat(int ernalformat)); | |
913 } | |
914 | |
915 bool isFloatType(GLenum type) | |
916 { | |
917 switch (type) { | |
918 case GL_FLOAT: | |
919 case GL_HALF_FLOAT: | |
920 case GL_HALF_FLOAT_OES: | |
921 case GL_UNSIGNED_INT_10F_11F_11F_REV: | |
922 return true; | |
923 default: | |
924 return false; | |
925 } | |
926 } | |
927 | |
928 bool isSRGBFormat(GLenum internalformat) | |
929 { | |
930 switch (internalformat) { | |
931 case GL_SRGB_EXT: | |
932 case GL_SRGB_ALPHA_EXT: | |
933 case GL_SRGB8: | |
934 case GL_SRGB8_ALPHA8: | |
935 return true; | |
936 default: | |
937 return false; | |
938 } | |
939 } | |
940 | |
867 } // namespace anonymous | 941 } // namespace anonymous |
868 | 942 |
869 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& re questedAttributes) | 943 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& re questedAttributes) |
870 : CanvasRenderingContext(passedCanvas) | 944 : CanvasRenderingContext(passedCanvas) |
871 , m_contextLostMode(NotLostContext) | 945 , m_contextLostMode(NotLostContext) |
872 , m_autoRecoveryMethod(Manual) | 946 , m_autoRecoveryMethod(Manual) |
873 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) | 947 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) |
874 , m_restoreAllowed(false) | 948 , m_restoreAllowed(false) |
875 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) | 949 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
876 , m_preservedDefaultVAOObjectWrapper(false) | 950 , m_preservedDefaultVAOObjectWrapper(false) |
(...skipping 3469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4346 | 4420 |
4347 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, | 4421 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, |
4348 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) | 4422 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) |
4349 { | 4423 { |
4350 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, exce ptionState) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvas Element, target, level, internalformat, canvas->width(), canvas->height(), 0, fo rmat, type, 0, 0)) | 4424 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, exce ptionState) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvas Element, target, level, internalformat, canvas->width(), canvas->height(), 0, fo rmat, type, 0, 0)) |
4351 return; | 4425 return; |
4352 | 4426 |
4353 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 4427 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
4354 ASSERT(texture); | 4428 ASSERT(texture); |
4355 | 4429 |
4356 // texImage2DCanvasByGPU relies on copyTextureCHROMIUM which doesn't support float type. | 4430 // texImage2DCanvasByGPU relies on copyTextureCHROMIUM which doesn't support float/integer/sRGB internal format. |
Zhenyao Mo
2015/10/16 18:52:16
I am actually working on upgrading copyTextureCHRO
Ken Russell (switch to Gerrit)
2015/10/16 22:09:44
Could you also add the same FIXME below? Also, it
qiankun
2015/10/17 08:10:40
Done.
qiankun
2015/10/17 08:10:40
Done.
| |
4357 bool isFloatType = type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_H ALF_FLOAT_OES; | 4431 if (!canvas->renderingContext() || !canvas->renderingContext()->isAccelerate d() || isFloatType(type) || isIntegerFormat(internalformat) || isSRGBFormat(inte rnalformat)) { |
4358 if (!canvas->renderingContext() || !canvas->renderingContext()->isAccelerate d() || isFloatType) { | |
4359 // 2D canvas has only FrontBuffer. | 4432 // 2D canvas has only FrontBuffer. |
4360 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(FrontBuffer, PreferAcceleration).get(), | 4433 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(FrontBuffer, PreferAcceleration).get(), |
4361 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremulti plyAlpha); | 4434 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremulti plyAlpha); |
4362 return; | 4435 return; |
4363 } | 4436 } |
4364 | 4437 |
4365 texImage2DCanvasByGPU(NotTexSubImage2D, texture, target, level, internalform at, type, 0, 0, canvas); | 4438 texImage2DCanvasByGPU(NotTexSubImage2D, texture, target, level, internalform at, type, 0, 0, canvas); |
4366 texture->setLevelInfo(target, level, internalformat, canvas->width(), canvas ->height(), 1, type); | 4439 texture->setLevelInfo(target, level, internalformat, canvas->width(), canvas ->height(), 1, type); |
4367 } | 4440 } |
4368 | 4441 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4604 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 4677 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
4605 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) | 4678 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) |
4606 { | 4679 { |
4607 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e xceptionState) | 4680 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e xceptionState) |
4608 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem ent, target, level, 0, canvas->width(), canvas->height(), 0, format, type, xoffs et, yoffset)) | 4681 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem ent, target, level, 0, canvas->width(), canvas->height(), 0, format, type, xoffs et, yoffset)) |
4609 return; | 4682 return; |
4610 | 4683 |
4611 WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true ); | 4684 WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true ); |
4612 ASSERT(texture); | 4685 ASSERT(texture); |
4613 | 4686 |
4614 bool isFloatType = type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_H ALF_FLOAT_OES; | 4687 GLenum internalformat = texture->getInternalFormat(target, level); |
4615 if (!canvas->renderingContext() || !canvas->renderingContext()->isAccelerate d() || isFloatType) { | 4688 if (!canvas->renderingContext() || !canvas->renderingContext()->isAccelerate d() || isFloatType(type) || isIntegerFormat(internalformat) || isSRGBFormat(inte rnalformat)) { |
4616 // 2D canvas has only FrontBuffer. | 4689 // 2D canvas has only FrontBuffer. |
4617 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas- >copiedImage(FrontBuffer, PreferAcceleration).get(), | 4690 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas- >copiedImage(FrontBuffer, PreferAcceleration).get(), |
4618 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremulti plyAlpha); | 4691 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremulti plyAlpha); |
4619 return; | 4692 return; |
4620 } | 4693 } |
4621 | 4694 |
4622 texImage2DCanvasByGPU(TexSubImage2D, texture, target, level, GL_RGBA, type, xoffset, yoffset, canvas); | 4695 texImage2DCanvasByGPU(TexSubImage2D, texture, target, level, GL_RGBA, type, xoffset, yoffset, canvas); |
4623 } | 4696 } |
4624 | 4697 |
4625 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, | 4698 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, |
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6832 | 6905 |
6833 return totalBytesPerPixel; | 6906 return totalBytesPerPixel; |
6834 } | 6907 } |
6835 | 6908 |
6836 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6909 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
6837 { | 6910 { |
6838 return m_drawingBuffer.get(); | 6911 return m_drawingBuffer.get(); |
6839 } | 6912 } |
6840 | 6913 |
6841 } // namespace blink | 6914 } // namespace blink |
OLD | NEW |