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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContext.cpp

Issue 93873009: Moved GL enums from GraphicsContext3D to a more generic location. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Changed over to use the standard GL headers and enums. Also fixed some minor style issues. Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 , m_onePlusMaxEnabledAttribIndex(0) 554 , m_onePlusMaxEnabledAttribIndex(0)
555 , m_onePlusMaxNonDefaultTextureUnit(0) 555 , m_onePlusMaxNonDefaultTextureUnit(0)
556 { 556 {
557 ASSERT(m_context); 557 ASSERT(m_context);
558 ScriptWrappable::init(this); 558 ScriptWrappable::init(this);
559 559
560 m_contextGroup = WebGLContextGroup::create(); 560 m_contextGroup = WebGLContextGroup::create();
561 m_contextGroup->addContext(this); 561 m_contextGroup->addContext(this);
562 562
563 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; 563 m_maxViewportDims[0] = m_maxViewportDims[1] = 0;
564 m_context->getIntegerv(GraphicsContext3D::MAX_VIEWPORT_DIMS, m_maxViewportDi ms); 564 m_context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims);
565 565
566 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager()); 566 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager());
567 567
568 // Create the DrawingBuffer and initialize the platform layer. 568 // Create the DrawingBuffer and initialize the platform layer.
569 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; 569 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard;
570 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize() , preserve, contextEvictionManager.release()); 570 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize() , preserve, contextEvictionManager.release());
571 571
572 if (!m_drawingBuffer->isZeroSized()) { 572 if (!m_drawingBuffer->isZeroSized()) {
573 m_drawingBuffer->bind(); 573 m_drawingBuffer->bind();
574 setupFlags(); 574 setupFlags();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 void WebGLRenderingContext::initializeNewContext() 606 void WebGLRenderingContext::initializeNewContext()
607 { 607 {
608 ASSERT(!isContextLost()); 608 ASSERT(!isContextLost());
609 m_needsUpdate = true; 609 m_needsUpdate = true;
610 m_markedCanvasDirty = false; 610 m_markedCanvasDirty = false;
611 m_activeTextureUnit = 0; 611 m_activeTextureUnit = 0;
612 m_packAlignment = 4; 612 m_packAlignment = 4;
613 m_unpackAlignment = 4; 613 m_unpackAlignment = 4;
614 m_unpackFlipY = false; 614 m_unpackFlipY = false;
615 m_unpackPremultiplyAlpha = false; 615 m_unpackPremultiplyAlpha = false;
616 m_unpackColorspaceConversion = GraphicsContext3D::BROWSER_DEFAULT_WEBGL; 616 m_unpackColorspaceConversion = GC3D_BROWSER_DEFAULT_WEBGL;
617 m_boundArrayBuffer = 0; 617 m_boundArrayBuffer = 0;
618 m_currentProgram = 0; 618 m_currentProgram = 0;
619 m_framebufferBinding = 0; 619 m_framebufferBinding = 0;
620 m_renderbufferBinding = 0; 620 m_renderbufferBinding = 0;
621 m_depthMask = true; 621 m_depthMask = true;
622 m_stencilEnabled = false; 622 m_stencilEnabled = false;
623 m_stencilMask = 0xFFFFFFFF; 623 m_stencilMask = 0xFFFFFFFF;
624 m_stencilMaskBack = 0xFFFFFFFF; 624 m_stencilMaskBack = 0xFFFFFFFF;
625 m_stencilFuncRef = 0; 625 m_stencilFuncRef = 0;
626 m_stencilFuncRefBack = 0; 626 m_stencilFuncRefBack = 0;
627 m_stencilFuncMask = 0xFFFFFFFF; 627 m_stencilFuncMask = 0xFFFFFFFF;
628 m_stencilFuncMaskBack = 0xFFFFFFFF; 628 m_stencilFuncMaskBack = 0xFFFFFFFF;
629 m_layerCleared = false; 629 m_layerCleared = false;
630 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; 630 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole;
631 631
632 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; 632 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0;
633 m_scissorEnabled = false; 633 m_scissorEnabled = false;
634 m_clearDepth = 1; 634 m_clearDepth = 1;
635 m_clearStencil = 0; 635 m_clearStencil = 0;
636 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; 636 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true;
637 637
638 GC3Dint numCombinedTextureImageUnits = 0; 638 GC3Dint numCombinedTextureImageUnits = 0;
639 m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTextureImageUnits); 639 m_context->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedText ureImageUnits);
640 m_textureUnits.clear(); 640 m_textureUnits.clear();
641 m_textureUnits.resize(numCombinedTextureImageUnits); 641 m_textureUnits.resize(numCombinedTextureImageUnits);
642 642
643 GC3Dint numVertexAttribs = 0; 643 GC3Dint numVertexAttribs = 0;
644 m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &numVertexAttr ibs); 644 m_context->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs);
645 m_maxVertexAttribs = numVertexAttribs; 645 m_maxVertexAttribs = numVertexAttribs;
646 646
647 m_maxTextureSize = 0; 647 m_maxTextureSize = 0;
648 m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_maxTextureSiz e); 648 m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize);
649 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT extureSize); 649 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT extureSize);
650 m_maxCubeMapTextureSize = 0; 650 m_maxCubeMapTextureSize = 0;
651 m_context->getIntegerv(GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxC ubeMapTextureSize); 651 m_context->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSiz e);
652 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu reSize, m_maxCubeMapTextureSize); 652 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu reSize, m_maxCubeMapTextureSize);
653 m_maxRenderbufferSize = 0; 653 m_maxRenderbufferSize = 0;
654 m_context->getIntegerv(GraphicsContext3D::MAX_RENDERBUFFER_SIZE, &m_maxRende rbufferSize); 654 m_context->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize);
655 655
656 // These two values from EXT_draw_buffers are lazily queried. 656 // These two values from EXT_draw_buffers are lazily queried.
657 m_maxDrawBuffers = 0; 657 m_maxDrawBuffers = 0;
658 m_maxColorAttachments = 0; 658 m_maxColorAttachments = 0;
659 659
660 m_backDrawBuffer = GraphicsContext3D::BACK; 660 m_backDrawBuffer = GL_BACK;
661 661
662 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe rtexArrayObjectOES::VaoTypeDefault); 662 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe rtexArrayObjectOES::VaoTypeDefault);
663 addContextObject(m_defaultVertexArrayObject.get()); 663 addContextObject(m_defaultVertexArrayObject.get());
664 m_boundVertexArrayObject = m_defaultVertexArrayObject; 664 m_boundVertexArrayObject = m_defaultVertexArrayObject;
665 665
666 m_vertexAttribValue.resize(m_maxVertexAttribs); 666 m_vertexAttribValue.resize(m_maxVertexAttribs);
667 667
668 createFallbackBlackTextures1x1(); 668 createFallbackBlackTextures1x1();
669 669
670 IntSize canvasSize = clampedCanvasSize(); 670 IntSize canvasSize = clampedCanvasSize();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 810
811 if (!m_context->layerComposited() || m_layerCleared 811 if (!m_context->layerComposited() || m_layerCleared
812 || m_attributes.preserveDrawingBuffer || (mask && m_framebufferBinding)) 812 || m_attributes.preserveDrawingBuffer || (mask && m_framebufferBinding))
813 return false; 813 return false;
814 814
815 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes(); 815 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes();
816 816
817 // Determine if it's possible to combine the clear the user asked for and th is clear. 817 // Determine if it's possible to combine the clear the user asked for and th is clear.
818 bool combinedClear = mask && !m_scissorEnabled; 818 bool combinedClear = mask && !m_scissorEnabled;
819 819
820 m_context->disable(GraphicsContext3D::SCISSOR_TEST); 820 m_context->disable(GL_SCISSOR_TEST);
821 if (combinedClear && (mask & GraphicsContext3D::COLOR_BUFFER_BIT)) 821 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT))
822 m_context->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, 822 m_context->clearColor(m_colorMask[0] ? m_clearColor[0] : 0,
823 m_colorMask[1] ? m_clearColor[1] : 0, 823 m_colorMask[1] ? m_clearColor[1] : 0,
824 m_colorMask[2] ? m_clearColor[2] : 0, 824 m_colorMask[2] ? m_clearColor[2] : 0,
825 m_colorMask[3] ? m_clearColor[3] : 0); 825 m_colorMask[3] ? m_clearColor[3] : 0);
826 else 826 else
827 m_context->clearColor(0, 0, 0, 0); 827 m_context->clearColor(0, 0, 0, 0);
828 m_context->colorMask(true, true, true, true); 828 m_context->colorMask(true, true, true, true);
829 GC3Dbitfield clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; 829 GC3Dbitfield clearMask = GL_COLOR_BUFFER_BIT;
830 if (contextAttributes->depth()) { 830 if (contextAttributes->depth()) {
831 if (!combinedClear || !m_depthMask || !(mask & GraphicsContext3D::DEPTH_ BUFFER_BIT)) 831 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT))
832 m_context->clearDepth(1.0f); 832 m_context->clearDepth(1.0f);
833 clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; 833 clearMask |= GL_DEPTH_BUFFER_BIT;
834 m_context->depthMask(true); 834 m_context->depthMask(true);
835 } 835 }
836 if (contextAttributes->stencil()) { 836 if (contextAttributes->stencil()) {
837 if (combinedClear && (mask & GraphicsContext3D::STENCIL_BUFFER_BIT)) 837 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT))
838 m_context->clearStencil(m_clearStencil & m_stencilMask); 838 m_context->clearStencil(m_clearStencil & m_stencilMask);
839 else 839 else
840 m_context->clearStencil(0); 840 m_context->clearStencil(0);
841 clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; 841 clearMask |= GL_STENCIL_BUFFER_BIT;
842 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xFFFFFFFF); 842 m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF);
843 } 843 }
844 844
845 m_drawingBuffer->clearFramebuffers(clearMask); 845 m_drawingBuffer->clearFramebuffers(clearMask);
846 846
847 restoreStateAfterClear(); 847 restoreStateAfterClear();
848 if (m_framebufferBinding) 848 if (m_framebufferBinding)
849 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); 849 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin ding.get()));
850 m_layerCleared = true; 850 m_layerCleared = true;
851 851
852 return combinedClear; 852 return combinedClear;
853 } 853 }
854 854
855 void WebGLRenderingContext::restoreStateAfterClear() 855 void WebGLRenderingContext::restoreStateAfterClear()
856 { 856 {
857 if (isContextLost()) 857 if (isContextLost())
858 return; 858 return;
859 859
860 // Restore the state that the context set. 860 // Restore the state that the context set.
861 if (m_scissorEnabled) 861 if (m_scissorEnabled)
862 m_context->enable(GraphicsContext3D::SCISSOR_TEST); 862 m_context->enable(GL_SCISSOR_TEST);
863 m_context->clearColor(m_clearColor[0], m_clearColor[1], 863 m_context->clearColor(m_clearColor[0], m_clearColor[1],
864 m_clearColor[2], m_clearColor[3]); 864 m_clearColor[2], m_clearColor[3]);
865 m_context->colorMask(m_colorMask[0], m_colorMask[1], 865 m_context->colorMask(m_colorMask[0], m_colorMask[1],
866 m_colorMask[2], m_colorMask[3]); 866 m_colorMask[2], m_colorMask[3]);
867 m_context->clearDepth(m_clearDepth); 867 m_context->clearDepth(m_clearDepth);
868 m_context->clearStencil(m_clearStencil); 868 m_context->clearStencil(m_clearStencil);
869 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, m_stencilMask); 869 m_context->stencilMaskSeparate(GL_FRONT, m_stencilMask);
870 m_context->depthMask(m_depthMask); 870 m_context->depthMask(m_depthMask);
871 } 871 }
872 872
873 void WebGLRenderingContext::markLayerComposited() 873 void WebGLRenderingContext::markLayerComposited()
874 { 874 {
875 if (!isContextLost()) 875 if (!isContextLost())
876 m_context->markLayerComposited(); 876 m_context->markLayerComposited();
877 } 877 }
878 878
879 void WebGLRenderingContext::paintRenderingResultsToCanvas() 879 void WebGLRenderingContext::paintRenderingResultsToCanvas()
(...skipping 20 matching lines...) Expand all
900 return; 900 return;
901 901
902 canvas()->clearCopiedImage(); 902 canvas()->clearCopiedImage();
903 m_markedCanvasDirty = false; 903 m_markedCanvasDirty = false;
904 904
905 m_drawingBuffer->commit(); 905 m_drawingBuffer->commit();
906 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu ffer.get())) 906 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu ffer.get()))
907 m_context->paintRenderingResultsToCanvas(canvas()->buffer(), m_drawingBu ffer.get()); 907 m_context->paintRenderingResultsToCanvas(canvas()->buffer(), m_drawingBu ffer.get());
908 908
909 if (m_framebufferBinding) 909 if (m_framebufferBinding)
910 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); 910 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin ding.get()));
911 else 911 else
912 m_drawingBuffer->bind(); 912 m_drawingBuffer->bind();
913 } 913 }
914 914
915 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData() 915 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData()
916 { 916 {
917 if (isContextLost()) 917 if (isContextLost())
918 return 0; 918 return 0;
919 919
920 clearIfComposited(); 920 clearIfComposited();
921 m_drawingBuffer->commit(); 921 m_drawingBuffer->commit();
922 int width, height; 922 int width, height;
923 RefPtr<Uint8ClampedArray> imageDataPixels = m_context->paintRenderingResults ToImageData(m_drawingBuffer.get(), width, height); 923 RefPtr<Uint8ClampedArray> imageDataPixels = m_context->paintRenderingResults ToImageData(m_drawingBuffer.get(), width, height);
924 if (!imageDataPixels) 924 if (!imageDataPixels)
925 return 0; 925 return 0;
926 926
927 if (m_framebufferBinding) 927 if (m_framebufferBinding)
928 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero( m_framebufferBinding.get())); 928 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin ding.get()));
929 else 929 else
930 m_drawingBuffer->bind(); 930 m_drawingBuffer->bind();
931 931
932 return ImageData::create(IntSize(width, height), imageDataPixels); 932 return ImageData::create(IntSize(width, height), imageDataPixels);
933 } 933 }
934 934
935 void WebGLRenderingContext::reshape(int width, int height) 935 void WebGLRenderingContext::reshape(int width, int height)
936 { 936 {
937 if (isContextLost()) 937 if (isContextLost())
938 return; 938 return;
(...skipping 14 matching lines...) Expand all
953 if (renderBox && renderBox->hasAcceleratedCompositing()) 953 if (renderBox && renderBox->hasAcceleratedCompositing())
954 renderBox->contentChanged(CanvasChanged); 954 renderBox->contentChanged(CanvasChanged);
955 m_needsUpdate = false; 955 m_needsUpdate = false;
956 } 956 }
957 957
958 // We don't have to mark the canvas as dirty, since the newly created image buffer will also start off 958 // We don't have to mark the canvas as dirty, since the newly created image buffer will also start off
959 // clear (and this matches what reshape will do). 959 // clear (and this matches what reshape will do).
960 m_drawingBuffer->reset(IntSize(width, height)); 960 m_drawingBuffer->reset(IntSize(width, height));
961 restoreStateAfterClear(); 961 restoreStateAfterClear();
962 962
963 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(m_texture Units[m_activeTextureUnit].m_texture2DBinding.get())); 963 m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTe xtureUnit].m_texture2DBinding.get()));
964 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, objectOrZero(m_ renderbufferBinding.get())); 964 m_context->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBind ing.get()));
965 if (m_framebufferBinding) 965 if (m_framebufferBinding)
966 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero(m_ framebufferBinding.get())); 966 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin ding.get()));
967 } 967 }
968 968
969 int WebGLRenderingContext::drawingBufferWidth() const 969 int WebGLRenderingContext::drawingBufferWidth() const
970 { 970 {
971 return m_drawingBuffer->size().width(); 971 return m_drawingBuffer->size().width();
972 } 972 }
973 973
974 int WebGLRenderingContext::drawingBufferHeight() const 974 int WebGLRenderingContext::drawingBufferHeight() const
975 { 975 {
976 return m_drawingBuffer->size().height(); 976 return m_drawingBuffer->size().height();
977 } 977 }
978 978
979 unsigned int WebGLRenderingContext::sizeInBytes(GC3Denum type) 979 unsigned int WebGLRenderingContext::sizeInBytes(GC3Denum type)
980 { 980 {
981 switch (type) { 981 switch (type) {
982 case GraphicsContext3D::BYTE: 982 case GL_BYTE:
983 return sizeof(GC3Dbyte); 983 return sizeof(GC3Dbyte);
984 case GraphicsContext3D::UNSIGNED_BYTE: 984 case GL_UNSIGNED_BYTE:
985 return sizeof(GC3Dubyte); 985 return sizeof(GC3Dubyte);
986 case GraphicsContext3D::SHORT: 986 case GL_SHORT:
987 return sizeof(GC3Dshort); 987 return sizeof(GC3Dshort);
988 case GraphicsContext3D::UNSIGNED_SHORT: 988 case GL_UNSIGNED_SHORT:
989 return sizeof(GC3Dushort); 989 return sizeof(GC3Dushort);
990 case GraphicsContext3D::INT: 990 case GL_INT:
991 return sizeof(GC3Dint); 991 return sizeof(GC3Dint);
992 case GraphicsContext3D::UNSIGNED_INT: 992 case GL_UNSIGNED_INT:
993 return sizeof(GC3Duint); 993 return sizeof(GC3Duint);
994 case GraphicsContext3D::FLOAT: 994 case GL_FLOAT:
995 return sizeof(GC3Dfloat); 995 return sizeof(GC3Dfloat);
996 } 996 }
997 ASSERT_NOT_REACHED(); 997 ASSERT_NOT_REACHED();
998 return 0; 998 return 0;
999 } 999 }
1000 1000
1001 void WebGLRenderingContext::activeTexture(GC3Denum texture) 1001 void WebGLRenderingContext::activeTexture(GC3Denum texture)
1002 { 1002 {
1003 if (isContextLost()) 1003 if (isContextLost())
1004 return; 1004 return;
1005 if (texture - GraphicsContext3D::TEXTURE0 >= m_textureUnits.size()) { 1005 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) {
1006 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "activeTexture", "tex ture unit out of range"); 1006 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of range");
1007 return; 1007 return;
1008 } 1008 }
1009 m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0; 1009 m_activeTextureUnit = texture - GL_TEXTURE0;
1010 m_context->activeTexture(texture); 1010 m_context->activeTexture(texture);
1011 1011
1012 m_drawingBuffer->setActiveTextureUnit(texture); 1012 m_drawingBuffer->setActiveTextureUnit(texture);
1013 1013
1014 } 1014 }
1015 1015
1016 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha der) 1016 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha der)
1017 { 1017 {
1018 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader)) 1018 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader))
1019 return; 1019 return;
1020 if (!program->attachShader(shader)) { 1020 if (!program->attachShader(shader)) {
1021 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader", "shader attachment already has shader"); 1021 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme nt already has shader");
1022 return; 1022 return;
1023 } 1023 }
1024 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); 1024 m_context->attachShader(objectOrZero(program), objectOrZero(shader));
1025 shader->onAttached(); 1025 shader->onAttached();
1026 } 1026 }
1027 1027
1028 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i ndex, const String& name) 1028 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i ndex, const String& name)
1029 { 1029 {
1030 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) 1030 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program))
1031 return; 1031 return;
1032 if (!validateLocationLength("bindAttribLocation", name)) 1032 if (!validateLocationLength("bindAttribLocation", name))
1033 return; 1033 return;
1034 if (!validateString("bindAttribLocation", name)) 1034 if (!validateString("bindAttribLocation", name))
1035 return; 1035 return;
1036 if (isPrefixReserved(name)) { 1036 if (isPrefixReserved(name)) {
1037 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindAttribLocat ion", "reserved prefix"); 1037 synthesizeGLError(GL_INVALID_OPERATION, "bindAttribLocation", "reserved prefix");
1038 return; 1038 return;
1039 } 1039 }
1040 if (index >= m_maxVertexAttribs) { 1040 if (index >= m_maxVertexAttribs) {
1041 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bindAttribLocation" , "index out of range"); 1041 synthesizeGLError(GL_INVALID_VALUE, "bindAttribLocation", "index out of range");
1042 return; 1042 return;
1043 } 1043 }
1044 m_context->bindAttribLocation(objectOrZero(program), index, name); 1044 m_context->bindAttribLocation(objectOrZero(program), index, name);
1045 } 1045 }
1046 1046
1047 bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGL Object* object, bool& deleted) 1047 bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGL Object* object, bool& deleted)
1048 { 1048 {
1049 deleted = false; 1049 deleted = false;
1050 if (isContextLost()) 1050 if (isContextLost())
1051 return false; 1051 return false;
1052 if (object) { 1052 if (object) {
1053 if (!object->validate(contextGroup(), this)) { 1053 if (!object->validate(contextGroup(), this)) {
1054 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "object not from this context"); 1054 synthesizeGLError(GL_INVALID_OPERATION, functionName, "object not fr om this context");
1055 return false; 1055 return false;
1056 } 1056 }
1057 deleted = !object->object(); 1057 deleted = !object->object();
1058 } 1058 }
1059 return true; 1059 return true;
1060 } 1060 }
1061 1061
1062 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer) 1062 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer)
1063 { 1063 {
1064 bool deleted; 1064 bool deleted;
1065 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) 1065 if (!checkObjectToBeBound("bindBuffer", buffer, deleted))
1066 return; 1066 return;
1067 if (deleted) 1067 if (deleted)
1068 buffer = 0; 1068 buffer = 0;
1069 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { 1069 if (buffer && buffer->getTarget() && buffer->getTarget() != target) {
1070 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "b uffers can not be used with multiple targets"); 1070 synthesizeGLError(GL_INVALID_OPERATION, "bindBuffer", "buffers can not b e used with multiple targets");
1071 return; 1071 return;
1072 } 1072 }
1073 if (target == GraphicsContext3D::ARRAY_BUFFER) 1073 if (target == GL_ARRAY_BUFFER)
1074 m_boundArrayBuffer = buffer; 1074 m_boundArrayBuffer = buffer;
1075 else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER) 1075 else if (target == GL_ELEMENT_ARRAY_BUFFER)
1076 m_boundVertexArrayObject->setElementArrayBuffer(buffer); 1076 m_boundVertexArrayObject->setElementArrayBuffer(buffer);
1077 else { 1077 else {
1078 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invali d target"); 1078 synthesizeGLError(GL_INVALID_ENUM, "bindBuffer", "invalid target");
1079 return; 1079 return;
1080 } 1080 }
1081 1081
1082 m_context->bindBuffer(target, objectOrZero(buffer)); 1082 m_context->bindBuffer(target, objectOrZero(buffer));
1083 if (buffer) 1083 if (buffer)
1084 buffer->setTarget(target); 1084 buffer->setTarget(target);
1085 } 1085 }
1086 1086
1087 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b uffer) 1087 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b uffer)
1088 { 1088 {
1089 bool deleted; 1089 bool deleted;
1090 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) 1090 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted))
1091 return; 1091 return;
1092 if (deleted) 1092 if (deleted)
1093 buffer = 0; 1093 buffer = 0;
1094 if (target != GraphicsContext3D::FRAMEBUFFER) { 1094 if (target != GL_FRAMEBUFFER) {
1095 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "i nvalid target"); 1095 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target");
1096 return; 1096 return;
1097 } 1097 }
1098 m_framebufferBinding = buffer; 1098 m_framebufferBinding = buffer;
1099 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ())); 1099 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ()));
1100 if (!m_framebufferBinding) { 1100 if (!m_framebufferBinding) {
1101 // Instead of binding fb 0, bind the drawing buffer. 1101 // Instead of binding fb 0, bind the drawing buffer.
1102 m_drawingBuffer->bind(); 1102 m_drawingBuffer->bind();
1103 } else 1103 } else
1104 m_context->bindFramebuffer(target, objectOrZero(buffer)); 1104 m_context->bindFramebuffer(target, objectOrZero(buffer));
1105 if (buffer) 1105 if (buffer)
1106 buffer->setHasEverBeenBound(); 1106 buffer->setHasEverBeenBound();
1107 applyStencilTest(); 1107 applyStencilTest();
1108 } 1108 }
1109 1109
1110 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer* renderBuffer) 1110 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer* renderBuffer)
1111 { 1111 {
1112 bool deleted; 1112 bool deleted;
1113 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) 1113 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted))
1114 return; 1114 return;
1115 if (deleted) 1115 if (deleted)
1116 renderBuffer = 0; 1116 renderBuffer = 0;
1117 if (target != GraphicsContext3D::RENDERBUFFER) { 1117 if (target != GL_RENDERBUFFER) {
1118 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", " invalid target"); 1118 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ;
1119 return; 1119 return;
1120 } 1120 }
1121 m_renderbufferBinding = renderBuffer; 1121 m_renderbufferBinding = renderBuffer;
1122 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); 1122 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer));
1123 if (renderBuffer) 1123 if (renderBuffer)
1124 renderBuffer->setHasEverBeenBound(); 1124 renderBuffer->setHasEverBeenBound();
1125 } 1125 }
1126 1126
1127 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture) 1127 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture)
1128 { 1128 {
1129 bool deleted; 1129 bool deleted;
1130 if (!checkObjectToBeBound("bindTexture", texture, deleted)) 1130 if (!checkObjectToBeBound("bindTexture", texture, deleted))
1131 return; 1131 return;
1132 if (deleted) 1132 if (deleted)
1133 texture = 0; 1133 texture = 0;
1134 if (texture && texture->getTarget() && texture->getTarget() != target) { 1134 if (texture && texture->getTarget() && texture->getTarget() != target) {
1135 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", " textures can not be used with multiple targets"); 1135 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not be used with multiple targets");
1136 return; 1136 return;
1137 } 1137 }
1138 GC3Dint maxLevel = 0; 1138 GC3Dint maxLevel = 0;
1139 if (target == GraphicsContext3D::TEXTURE_2D) { 1139 if (target == GL_TEXTURE_2D) {
1140 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; 1140 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture;
1141 maxLevel = m_maxTextureLevel; 1141 maxLevel = m_maxTextureLevel;
1142 1142
1143 if (!m_activeTextureUnit) 1143 if (!m_activeTextureUnit)
1144 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); 1144 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture));
1145 1145
1146 } else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) { 1146 } else if (target == GL_TEXTURE_CUBE_MAP) {
1147 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; 1147 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture;
1148 maxLevel = m_maxCubeMapTextureLevel; 1148 maxLevel = m_maxCubeMapTextureLevel;
1149 } else { 1149 } else {
1150 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindTexture", "inval id target"); 1150 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target");
1151 return; 1151 return;
1152 } 1152 }
1153 1153
1154 m_context->bindTexture(target, objectOrZero(texture)); 1154 m_context->bindTexture(target, objectOrZero(texture));
1155 if (texture) { 1155 if (texture) {
1156 texture->setTarget(target, maxLevel); 1156 texture->setTarget(target, maxLevel);
1157 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl usMaxNonDefaultTextureUnit); 1157 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl usMaxNonDefaultTextureUnit);
1158 } else { 1158 } else {
1159 // If the disabled index is the current maximum, trace backwards to find the new max enabled texture index 1159 // If the disabled index is the current maximum, trace backwards to find the new max enabled texture index
1160 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { 1160 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 } 1211 }
1212 1212
1213 void WebGLRenderingContext::bufferData(GC3Denum target, long long size, GC3Denum usage) 1213 void WebGLRenderingContext::bufferData(GC3Denum target, long long size, GC3Denum usage)
1214 { 1214 {
1215 if (isContextLost()) 1215 if (isContextLost())
1216 return; 1216 return;
1217 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); 1217 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge);
1218 if (!buffer) 1218 if (!buffer)
1219 return; 1219 return;
1220 if (size < 0) { 1220 if (size < 0) {
1221 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size < 0"); 1221 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "size < 0");
1222 return; 1222 return;
1223 } 1223 }
1224 if (!size) { 1224 if (!size) {
1225 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size == 0"); 1225 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "size == 0");
1226 return; 1226 return;
1227 } 1227 }
1228 1228
1229 m_context->bufferData(target, static_cast<GC3Dsizeiptr>(size), usage); 1229 m_context->bufferData(target, static_cast<GC3Dsizeiptr>(size), usage);
1230 } 1230 }
1231 1231
1232 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBuffer* data, GC3De num usage) 1232 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBuffer* data, GC3De num usage)
1233 { 1233 {
1234 if (isContextLost()) 1234 if (isContextLost())
1235 return; 1235 return;
1236 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); 1236 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge);
1237 if (!buffer) 1237 if (!buffer)
1238 return; 1238 return;
1239 if (!data) { 1239 if (!data) {
1240 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no da ta"); 1240 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data");
1241 return; 1241 return;
1242 } 1242 }
1243 m_context->bufferData(target, data->byteLength(), data->data(), usage); 1243 m_context->bufferData(target, data->byteLength(), data->data(), usage);
1244 } 1244 }
1245 1245
1246 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBufferView* data, G C3Denum usage) 1246 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBufferView* data, G C3Denum usage)
1247 { 1247 {
1248 if (isContextLost()) 1248 if (isContextLost())
1249 return; 1249 return;
1250 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge); 1250 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa ge);
1251 if (!buffer) 1251 if (!buffer)
1252 return; 1252 return;
1253 if (!data) { 1253 if (!data) {
1254 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no da ta"); 1254 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data");
1255 return; 1255 return;
1256 } 1256 }
1257 1257
1258 m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage ); 1258 m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage );
1259 } 1259 }
1260 1260
1261 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr ayBuffer* data) 1261 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr ayBuffer* data)
1262 { 1262 {
1263 if (isContextLost()) 1263 if (isContextLost())
1264 return; 1264 return;
1265 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW); 1265 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GL_STATIC_DRAW);
1266 if (!buffer) 1266 if (!buffer)
1267 return; 1267 return;
1268 if (offset < 0) { 1268 if (offset < 0) {
1269 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "of fset < 0"); 1269 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "offset < 0");
1270 return; 1270 return;
1271 } 1271 }
1272 if (!data) 1272 if (!data)
1273 return; 1273 return;
1274 1274
1275 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->data()); 1275 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->data());
1276 } 1276 }
1277 1277
1278 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr ayBufferView* data) 1278 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr ayBufferView* data)
1279 { 1279 {
1280 if (isContextLost()) 1280 if (isContextLost())
1281 return; 1281 return;
1282 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GraphicsContext3D::STATIC_DRAW); 1282 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target, GL_STATIC_DRAW);
1283 if (!buffer) 1283 if (!buffer)
1284 return; 1284 return;
1285 if (offset < 0) { 1285 if (offset < 0) {
1286 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "of fset < 0"); 1286 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "offset < 0");
1287 return; 1287 return;
1288 } 1288 }
1289 if (!data) 1289 if (!data)
1290 return; 1290 return;
1291 1291
1292 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->baseAddress()); 1292 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte Length(), data->baseAddress());
1293 } 1293 }
1294 1294
1295 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target) 1295 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target)
1296 { 1296 {
1297 if (isContextLost()) 1297 if (isContextLost())
1298 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; 1298 return GL_FRAMEBUFFER_UNSUPPORTED;
1299 if (target != GraphicsContext3D::FRAMEBUFFER) { 1299 if (target != GL_FRAMEBUFFER) {
1300 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStat us", "invalid target"); 1300 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta rget");
1301 return 0; 1301 return 0;
1302 } 1302 }
1303 if (!m_framebufferBinding || !m_framebufferBinding->object()) 1303 if (!m_framebufferBinding || !m_framebufferBinding->object())
1304 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; 1304 return GL_FRAMEBUFFER_COMPLETE;
1305 const char* reason = "framebuffer incomplete"; 1305 const char* reason = "framebuffer incomplete";
1306 GC3Denum result = m_framebufferBinding->checkStatus(&reason); 1306 GC3Denum result = m_framebufferBinding->checkStatus(&reason);
1307 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { 1307 if (result != GL_FRAMEBUFFER_COMPLETE) {
1308 emitGLWarning("checkFramebufferStatus", reason); 1308 emitGLWarning("checkFramebufferStatus", reason);
1309 return result; 1309 return result;
1310 } 1310 }
1311 result = m_context->checkFramebufferStatus(target); 1311 result = m_context->checkFramebufferStatus(target);
1312 return result; 1312 return result;
1313 } 1313 }
1314 1314
1315 void WebGLRenderingContext::clear(GC3Dbitfield mask) 1315 void WebGLRenderingContext::clear(GC3Dbitfield mask)
1316 { 1316 {
1317 if (isContextLost()) 1317 if (isContextLost())
1318 return; 1318 return;
1319 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_ BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { 1319 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B IT)) {
1320 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid ma sk"); 1320 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask");
1321 return; 1321 return;
1322 } 1322 }
1323 const char* reason = "framebuffer incomplete"; 1323 const char* reason = "framebuffer incomplete";
1324 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 1324 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) {
1325 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cle ar", reason); 1325 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason);
1326 return; 1326 return;
1327 } 1327 }
1328 if (!clearIfComposited(mask)) 1328 if (!clearIfComposited(mask))
1329 m_context->clear(mask); 1329 m_context->clear(mask);
1330 markContextChanged(); 1330 markContextChanged();
1331 } 1331 }
1332 1332
1333 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC 3Dfloat a) 1333 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC 3Dfloat a)
1334 { 1334 {
1335 if (isContextLost()) 1335 if (isContextLost())
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 1385
1386 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, 1386 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
1387 GC3Dsizei height, GC3Dint borde r, ArrayBufferView* data) 1387 GC3Dsizei height, GC3Dint borde r, ArrayBufferView* data)
1388 { 1388 {
1389 if (isContextLost()) 1389 if (isContextLost())
1390 return; 1390 return;
1391 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) 1391 if (!validateTexFuncLevel("compressedTexImage2D", target, level))
1392 return; 1392 return;
1393 1393
1394 if (!validateCompressedTexFormat(internalformat)) { 1394 if (!validateCompressedTexFormat(internalformat)) {
1395 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D ", "invalid internalformat"); 1395 synthesizeGLError(GL_INVALID_ENUM, "compressedTexImage2D", "invalid inte rnalformat");
1396 return; 1396 return;
1397 } 1397 }
1398 if (border) { 1398 if (border) {
1399 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2 D", "border not 0"); 1399 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "border not 0");
1400 return; 1400 return;
1401 } 1401 }
1402 if (!validateCompressedTexDimensions("compressedTexImage2D", NotTexSubImage2 D, target, level, width, height, internalformat)) 1402 if (!validateCompressedTexDimensions("compressedTexImage2D", NotTexSubImage2 D, target, level, width, height, internalformat))
1403 return; 1403 return;
1404 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in ternalformat, data)) 1404 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in ternalformat, data))
1405 return; 1405 return;
1406 1406
1407 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t rue); 1407 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t rue);
1408 if (!tex) 1408 if (!tex)
1409 return; 1409 return;
1410 if (!isGLES2NPOTStrict()) { 1410 if (!isGLES2NPOTStrict()) {
1411 if (level && WebGLTexture::isNPOT(width, height)) { 1411 if (level && WebGLTexture::isNPOT(width, height)) {
1412 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexIm age2D", "level > 0 not power of 2"); 1412 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "level > 0 not power of 2");
1413 return; 1413 return;
1414 } 1414 }
1415 } 1415 }
1416 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid th, height, 1416 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid th, height,
1417 border, data->byteLength(), data-> baseAddress()); 1417 border, data->byteLength(), data-> baseAddress());
1418 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE); 1418 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_ BYTE);
1419 } 1419 }
1420 1420
1421 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev el, GC3Dint xoffset, GC3Dint yoffset, 1421 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev el, GC3Dint xoffset, GC3Dint yoffset,
1422 GC3Dsizei width, GC3Dsizei h eight, GC3Denum format, ArrayBufferView* data) 1422 GC3Dsizei width, GC3Dsizei h eight, GC3Denum format, ArrayBufferView* data)
1423 { 1423 {
1424 if (isContextLost()) 1424 if (isContextLost())
1425 return; 1425 return;
1426 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) 1426 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level))
1427 return; 1427 return;
1428 if (!validateCompressedTexFormat(format)) { 1428 if (!validateCompressedTexFormat(format)) {
1429 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImag e2D", "invalid format"); 1429 synthesizeGLError(GL_INVALID_ENUM, "compressedTexSubImage2D", "invalid f ormat");
1430 return; 1430 return;
1431 } 1431 }
1432 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data)) 1432 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height, format, data))
1433 return; 1433 return;
1434 1434
1435 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target , true); 1435 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target , true);
1436 if (!tex) 1436 if (!tex)
1437 return; 1437 return;
1438 1438
1439 if (format != tex->getInternalFormat(target, level)) { 1439 if (format != tex->getInternalFormat(target, level)) {
1440 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSu bImage2D", "format does not match texture format"); 1440 synthesizeGLError(GL_INVALID_OPERATION, "compressedTexSubImage2D", "form at does not match texture format");
1441 return; 1441 return;
1442 } 1442 }
1443 1443
1444 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l evel, xoffset, yoffset, width, height, format, tex)) 1444 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l evel, xoffset, yoffset, width, height, format, tex))
1445 return; 1445 return;
1446 1446
1447 graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset , 1447 graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset ,
1448 width, height, format, data->by teLength(), data->baseAddress()); 1448 width, height, format, data->by teLength(), data->baseAddress());
1449 } 1449 }
1450 1450
1451 bool WebGLRenderingContext::validateSettableTexFormat(const char* functionName, GC3Denum format) 1451 bool WebGLRenderingContext::validateSettableTexFormat(const char* functionName, GC3Denum format)
1452 { 1452 {
1453 if (GraphicsContext3D::getClearBitsByFormat(format) & (GraphicsContext3D::DE PTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { 1453 if (GraphicsContext3D::getClearBitsByFormat(format) & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) {
1454 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ormat can not be set, only rendered to"); 1454 synthesizeGLError(GL_INVALID_OPERATION, functionName, "format can not be set, only rendered to");
1455 return false; 1455 return false;
1456 } 1456 }
1457 return true; 1457 return true;
1458 } 1458 }
1459 1459
1460 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3 Dint border) 1460 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3 Dint border)
1461 { 1461 {
1462 if (isContextLost()) 1462 if (isContextLost())
1463 return; 1463 return;
1464 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l evel, internalformat, width, height, border, internalformat, GraphicsContext3D:: UNSIGNED_BYTE)) 1464 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l evel, internalformat, width, height, border, internalformat, GL_UNSIGNED_BYTE))
1465 return; 1465 return;
1466 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) 1466 if (!validateSettableTexFormat("copyTexImage2D", internalformat))
1467 return; 1467 return;
1468 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); 1468 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true);
1469 if (!tex) 1469 if (!tex)
1470 return; 1470 return;
1471 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) { 1471 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) {
1472 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D" , "framebuffer is incompatible format"); 1472 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i s incompatible format");
1473 return; 1473 return;
1474 } 1474 }
1475 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { 1475 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) {
1476 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexImage2D", "l evel > 0 not power of 2"); 1476 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow er of 2");
1477 return; 1477 return;
1478 } 1478 }
1479 const char* reason = "framebuffer incomplete"; 1479 const char* reason = "framebuffer incomplete";
1480 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 1480 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) {
1481 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexImage2D", reason); 1481 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re ason);
1482 return; 1482 return;
1483 } 1483 }
1484 clearIfComposited(); 1484 clearIfComposited();
1485 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); 1485 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get());
1486 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height , border); 1486 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height , border);
1487 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted. 1487 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted.
1488 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont ext3D::UNSIGNED_BYTE); 1488 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_ BYTE);
1489 } 1489 }
1490 1490
1491 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) 1491 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
1492 { 1492 {
1493 if (isContextLost()) 1493 if (isContextLost())
1494 return; 1494 return;
1495 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) 1495 if (!validateTexFuncLevel("copyTexSubImage2D", target, level))
1496 return; 1496 return;
1497 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true ); 1497 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true );
1498 if (!tex) 1498 if (!tex)
1499 return; 1499 return;
1500 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c opyTexSubImage2D", width, height)) 1500 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c opyTexSubImage2D", width, height))
1501 return; 1501 return;
1502 // Before checking if it is in the range, check if overflow happens first. 1502 // Before checking if it is in the range, check if overflow happens first.
1503 if (xoffset + width < 0 || yoffset + height < 0) { 1503 if (xoffset + width < 0 || yoffset + height < 0) {
1504 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "bad dimensions"); 1504 synthesizeGLError(GL_INVALID_VALUE, "copyTexSubImage2D", "bad dimensions ");
1505 return; 1505 return;
1506 } 1506 }
1507 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex ->getHeight(target, level)) { 1507 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex ->getHeight(target, level)) {
1508 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D", "rectangle out of range"); 1508 synthesizeGLError(GL_INVALID_VALUE, "copyTexSubImage2D", "rectangle out of range");
1509 return; 1509 return;
1510 } 1510 }
1511 GC3Denum internalformat = tex->getInternalFormat(target, level); 1511 GC3Denum internalformat = tex->getInternalFormat(target, level);
1512 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) 1512 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat))
1513 return; 1513 return;
1514 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) { 1514 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) {
1515 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexSubImage 2D", "framebuffer is incompatible format"); 1515 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe r is incompatible format");
1516 return; 1516 return;
1517 } 1517 }
1518 const char* reason = "framebuffer incomplete"; 1518 const char* reason = "framebuffer incomplete";
1519 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 1519 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) {
1520 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop yTexSubImage2D", reason); 1520 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason);
1521 return; 1521 return;
1522 } 1522 }
1523 clearIfComposited(); 1523 clearIfComposited();
1524 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get()); 1524 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding .get());
1525 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h eight); 1525 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h eight);
1526 } 1526 }
1527 1527
1528 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() 1528 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer()
1529 { 1529 {
1530 if (isContextLost()) 1530 if (isContextLost())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS tencilBuffer())); 1579 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS tencilBuffer()));
1580 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g et())); 1580 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g et()));
1581 } 1581 }
1582 return renderbuffer->emulatedStencilBuffer(); 1582 return renderbuffer->emulatedStencilBuffer();
1583 } 1583 }
1584 1584
1585 PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(GC3Denum type) 1585 PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(GC3Denum type)
1586 { 1586 {
1587 if (isContextLost()) 1587 if (isContextLost())
1588 return 0; 1588 return 0;
1589 if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::F RAGMENT_SHADER) { 1589 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) {
1590 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "createShader", "inva lid shader type"); 1590 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" );
1591 return 0; 1591 return 0;
1592 } 1592 }
1593 1593
1594 RefPtr<WebGLShader> o = WebGLShader::create(this, type); 1594 RefPtr<WebGLShader> o = WebGLShader::create(this, type);
1595 addSharedObject(o.get()); 1595 addSharedObject(o.get());
1596 return o; 1596 return o;
1597 } 1597 }
1598 1598
1599 void WebGLRenderingContext::cullFace(GC3Denum mode) 1599 void WebGLRenderingContext::cullFace(GC3Denum mode)
1600 { 1600 {
1601 if (isContextLost()) 1601 if (isContextLost())
1602 return; 1602 return;
1603 switch (mode) { 1603 switch (mode) {
1604 case GraphicsContext3D::FRONT_AND_BACK: 1604 case GL_FRONT_AND_BACK:
1605 case GraphicsContext3D::FRONT: 1605 case GL_FRONT:
1606 case GraphicsContext3D::BACK: 1606 case GL_BACK:
1607 break; 1607 break;
1608 default: 1608 default:
1609 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "cullFace", "invalid mode"); 1609 synthesizeGLError(GL_INVALID_ENUM, "cullFace", "invalid mode");
1610 return; 1610 return;
1611 } 1611 }
1612 m_context->cullFace(mode); 1612 m_context->cullFace(mode);
1613 } 1613 }
1614 1614
1615 bool WebGLRenderingContext::deleteObject(WebGLObject* object) 1615 bool WebGLRenderingContext::deleteObject(WebGLObject* object)
1616 { 1616 {
1617 if (isContextLost() || !object) 1617 if (isContextLost() || !object)
1618 return false; 1618 return false;
1619 if (!object->validate(contextGroup(), this)) { 1619 if (!object->validate(contextGroup(), this)) {
1620 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "delete", "objec t does not belong to this context"); 1620 synthesizeGLError(GL_INVALID_OPERATION, "delete", "object does not belon g to this context");
1621 return false; 1621 return false;
1622 } 1622 }
1623 if (object->object()) 1623 if (object->object())
1624 // We need to pass in context here because we want 1624 // We need to pass in context here because we want
1625 // things in this context unbound. 1625 // things in this context unbound.
1626 object->deleteObject(graphicsContext3D()); 1626 object->deleteObject(graphicsContext3D());
1627 return true; 1627 return true;
1628 } 1628 }
1629 1629
1630 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) 1630 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 return; 1713 return;
1714 m_depthMask = flag; 1714 m_depthMask = flag;
1715 m_context->depthMask(flag); 1715 m_context->depthMask(flag);
1716 } 1716 }
1717 1717
1718 void WebGLRenderingContext::depthRange(GC3Dfloat zNear, GC3Dfloat zFar) 1718 void WebGLRenderingContext::depthRange(GC3Dfloat zNear, GC3Dfloat zFar)
1719 { 1719 {
1720 if (isContextLost()) 1720 if (isContextLost())
1721 return; 1721 return;
1722 if (zNear > zFar) { 1722 if (zNear > zFar) {
1723 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "z Near > zFar"); 1723 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar");
1724 return; 1724 return;
1725 } 1725 }
1726 m_context->depthRange(zNear, zFar); 1726 m_context->depthRange(zNear, zFar);
1727 } 1727 }
1728 1728
1729 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha der) 1729 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha der)
1730 { 1730 {
1731 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) 1731 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader))
1732 return; 1732 return;
1733 if (!program->detachShader(shader)) { 1733 if (!program->detachShader(shader)) {
1734 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader", "shader not attached"); 1734 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched");
1735 return; 1735 return;
1736 } 1736 }
1737 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); 1737 m_context->detachShader(objectOrZero(program), objectOrZero(shader));
1738 shader->onDetached(graphicsContext3D()); 1738 shader->onDetached(graphicsContext3D());
1739 } 1739 }
1740 1740
1741 void WebGLRenderingContext::disable(GC3Denum cap) 1741 void WebGLRenderingContext::disable(GC3Denum cap)
1742 { 1742 {
1743 if (isContextLost() || !validateCapability("disable", cap)) 1743 if (isContextLost() || !validateCapability("disable", cap))
1744 return; 1744 return;
1745 if (cap == GraphicsContext3D::STENCIL_TEST) { 1745 if (cap == GL_STENCIL_TEST) {
1746 m_stencilEnabled = false; 1746 m_stencilEnabled = false;
1747 applyStencilTest(); 1747 applyStencilTest();
1748 return; 1748 return;
1749 } 1749 }
1750 if (cap == GraphicsContext3D::SCISSOR_TEST) { 1750 if (cap == GL_SCISSOR_TEST) {
1751 m_scissorEnabled = false; 1751 m_scissorEnabled = false;
1752 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); 1752 m_drawingBuffer->setScissorEnabled(m_scissorEnabled);
1753 } 1753 }
1754 m_context->disable(cap); 1754 m_context->disable(cap);
1755 } 1755 }
1756 1756
1757 void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index) 1757 void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index)
1758 { 1758 {
1759 if (isContextLost()) 1759 if (isContextLost())
1760 return; 1760 return;
1761 if (index >= m_maxVertexAttribs) { 1761 if (index >= m_maxVertexAttribs) {
1762 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "disableVertexAttrib Array", "index out of range"); 1762 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o ut of range");
1763 return; 1763 return;
1764 } 1764 }
1765 1765
1766 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index); 1766 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index);
1767 state.enabled = false; 1767 state.enabled = false;
1768 1768
1769 // If the disabled index is the current maximum, trace backwards to find the new max enabled attrib index 1769 // If the disabled index is the current maximum, trace backwards to find the new max enabled attrib index
1770 if (m_onePlusMaxEnabledAttribIndex == index + 1) { 1770 if (m_onePlusMaxEnabledAttribIndex == index + 1) {
1771 findNewMaxEnabledAttribIndex(); 1771 findNewMaxEnabledAttribIndex();
1772 } 1772 }
(...skipping 13 matching lines...) Expand all
1786 && (!state.bufferBinding || !state.bufferBinding->object())) 1786 && (!state.bufferBinding || !state.bufferBinding->object()))
1787 return false; 1787 return false;
1788 } 1788 }
1789 1789
1790 return true; 1790 return true;
1791 } 1791 }
1792 1792
1793 bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLO bject* object) 1793 bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLO bject* object)
1794 { 1794 {
1795 if (!object || !object->object()) { 1795 if (!object || !object->object()) {
1796 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ob ject or object deleted"); 1796 synthesizeGLError(GL_INVALID_VALUE, functionName, "no object or object d eleted");
1797 return false; 1797 return false;
1798 } 1798 }
1799 if (!object->validate(contextGroup(), this)) { 1799 if (!object->validate(contextGroup(), this)) {
1800 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "o bject does not belong to this context"); 1800 synthesizeGLError(GL_INVALID_OPERATION, functionName, "object does not b elong to this context");
1801 return false; 1801 return false;
1802 } 1802 }
1803 return true; 1803 return true;
1804 } 1804 }
1805 1805
1806 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c ount) 1806 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c ount)
1807 { 1807 {
1808 if (!validateDrawArrays("drawArrays", mode, first, count)) 1808 if (!validateDrawArrays("drawArrays", mode, first, count))
1809 return; 1809 return;
1810 1810
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 handleTextureCompleteness("drawElementsInstancedANGLE", true); 1858 handleTextureCompleteness("drawElementsInstancedANGLE", true);
1859 m_context->extensions()->drawElementsInstancedANGLE(mode, count, type, stati c_cast<GC3Dintptr>(offset), primcount); 1859 m_context->extensions()->drawElementsInstancedANGLE(mode, count, type, stati c_cast<GC3Dintptr>(offset), primcount);
1860 handleTextureCompleteness("drawElementsInstancedANGLE", false); 1860 handleTextureCompleteness("drawElementsInstancedANGLE", false);
1861 markContextChanged(); 1861 markContextChanged();
1862 } 1862 }
1863 1863
1864 void WebGLRenderingContext::enable(GC3Denum cap) 1864 void WebGLRenderingContext::enable(GC3Denum cap)
1865 { 1865 {
1866 if (isContextLost() || !validateCapability("enable", cap)) 1866 if (isContextLost() || !validateCapability("enable", cap))
1867 return; 1867 return;
1868 if (cap == GraphicsContext3D::STENCIL_TEST) { 1868 if (cap == GL_STENCIL_TEST) {
1869 m_stencilEnabled = true; 1869 m_stencilEnabled = true;
1870 applyStencilTest(); 1870 applyStencilTest();
1871 return; 1871 return;
1872 } 1872 }
1873 if (cap == GraphicsContext3D::SCISSOR_TEST) { 1873 if (cap == GL_SCISSOR_TEST) {
1874 m_scissorEnabled = true; 1874 m_scissorEnabled = true;
1875 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); 1875 m_drawingBuffer->setScissorEnabled(m_scissorEnabled);
1876 } 1876 }
1877 m_context->enable(cap); 1877 m_context->enable(cap);
1878 } 1878 }
1879 1879
1880 void WebGLRenderingContext::enableVertexAttribArray(GC3Duint index) 1880 void WebGLRenderingContext::enableVertexAttribArray(GC3Duint index)
1881 { 1881 {
1882 if (isContextLost()) 1882 if (isContextLost())
1883 return; 1883 return;
1884 if (index >= m_maxVertexAttribs) { 1884 if (index >= m_maxVertexAttribs) {
1885 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "enableVertexAttribA rray", "index out of range"); 1885 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou t of range");
1886 return; 1886 return;
1887 } 1887 }
1888 1888
1889 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index); 1889 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje ct->getVertexAttribState(index);
1890 state.enabled = true; 1890 state.enabled = true;
1891 1891
1892 m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribInd ex); 1892 m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribInd ex);
1893 1893
1894 m_context->enableVertexAttribArray(index); 1894 m_context->enableVertexAttribArray(index);
1895 } 1895 }
1896 1896
1897 void WebGLRenderingContext::finish() 1897 void WebGLRenderingContext::finish()
1898 { 1898 {
1899 if (isContextLost()) 1899 if (isContextLost())
1900 return; 1900 return;
1901 m_context->flush(); // Intentionally a flush, not a finish. 1901 m_context->flush(); // Intentionally a flush, not a finish.
1902 } 1902 }
1903 1903
1904 void WebGLRenderingContext::flush() 1904 void WebGLRenderingContext::flush()
1905 { 1905 {
1906 if (isContextLost()) 1906 if (isContextLost())
1907 return; 1907 return;
1908 m_context->flush(); 1908 m_context->flush();
1909 } 1909 }
1910 1910
1911 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer) 1911 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer)
1912 { 1912 {
1913 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) 1913 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment))
1914 return; 1914 return;
1915 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { 1915 if (renderbuffertarget != GL_RENDERBUFFER) {
1916 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuf fer", "invalid target"); 1916 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget");
1917 return; 1917 return;
1918 } 1918 }
1919 if (buffer && !buffer->validate(contextGroup(), this)) { 1919 if (buffer && !buffer->validate(contextGroup(), this)) {
1920 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no buffer or buffer not from this context"); 1920 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context");
1921 return; 1921 return;
1922 } 1922 }
1923 // Don't allow the default framebuffer to be mutated; all current 1923 // Don't allow the default framebuffer to be mutated; all current
1924 // implementations use an FBO internally in place of the default 1924 // implementations use an FBO internally in place of the default
1925 // FBO. 1925 // FBO.
1926 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 1926 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
1927 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no framebuffer bound"); 1927 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f ramebuffer bound");
1928 return; 1928 return;
1929 } 1929 }
1930 Platform3DObject bufferObject = objectOrZero(buffer); 1930 Platform3DObject bufferObject = objectOrZero(buffer);
1931 switch (attachment) { 1931 switch (attachment) {
1932 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: 1932 case GC3D_DEPTH_STENCIL_ATTACHMENT:
1933 if (isDepthStencilSupported() || !buffer) { 1933 if (isDepthStencilSupported() || !buffer) {
1934 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_ ATTACHMENT, renderbuffertarget, bufferObject); 1934 m_context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, rend erbuffertarget, bufferObject);
1935 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI L_ATTACHMENT, renderbuffertarget, bufferObject); 1935 m_context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, re nderbuffertarget, bufferObject);
1936 } else { 1936 } else {
1937 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(renderbuffertarget, buffer); 1937 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(renderbuffertarget, buffer);
1938 if (!emulatedStencilBuffer) { 1938 if (!emulatedStencilBuffer) {
1939 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "framebuffer Renderbuffer", "out of memory"); 1939 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", " out of memory");
1940 return; 1940 return;
1941 } 1941 }
1942 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_ ATTACHMENT, renderbuffertarget, bufferObject); 1942 m_context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, rend erbuffertarget, bufferObject);
1943 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI L_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); 1943 m_context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, re nderbuffertarget, objectOrZero(emulatedStencilBuffer));
1944 } 1944 }
1945 break; 1945 break;
1946 default: 1946 default:
1947 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject); 1947 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject);
1948 } 1948 }
1949 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); 1949 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer);
1950 applyStencilTest(); 1950 applyStencilTest();
1951 } 1951 }
1952 1952
1953 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level) 1953 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level)
1954 { 1954 {
1955 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) 1955 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment))
1956 return; 1956 return;
1957 if (level) { 1957 if (level) {
1958 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2 D", "level not 0"); 1958 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 ");
1959 return; 1959 return;
1960 } 1960 }
1961 if (texture && !texture->validate(contextGroup(), this)) { 1961 if (texture && !texture->validate(contextGroup(), this)) {
1962 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no texture or texture not from this context"); 1962 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text ure or texture not from this context");
1963 return; 1963 return;
1964 } 1964 }
1965 // Don't allow the default framebuffer to be mutated; all current 1965 // Don't allow the default framebuffer to be mutated; all current
1966 // implementations use an FBO internally in place of the default 1966 // implementations use an FBO internally in place of the default
1967 // FBO. 1967 // FBO.
1968 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 1968 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
1969 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no framebuffer bound"); 1969 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram ebuffer bound");
1970 return; 1970 return;
1971 } 1971 }
1972 Platform3DObject textureObject = objectOrZero(texture); 1972 Platform3DObject textureObject = objectOrZero(texture);
1973 switch (attachment) { 1973 switch (attachment) {
1974 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: 1974 case GC3D_DEPTH_STENCIL_ATTACHMENT:
1975 m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHM ENT, textarget, textureObject, level); 1975 m_context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget, textureObject, level);
1976 m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTAC HMENT, textarget, textureObject, level); 1976 m_context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarget , textureObject, level);
1977 break; 1977 break;
1978 case GraphicsContext3D::DEPTH_ATTACHMENT: 1978 case GL_DEPTH_ATTACHMENT:
1979 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 1979 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
1980 break; 1980 break;
1981 case GraphicsContext3D::STENCIL_ATTACHMENT: 1981 case GL_STENCIL_ATTACHMENT:
1982 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 1982 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
1983 break; 1983 break;
1984 default: 1984 default:
1985 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 1985 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
1986 } 1986 }
1987 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level); 1987 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level);
1988 applyStencilTest(); 1988 applyStencilTest();
1989 } 1989 }
1990 1990
1991 void WebGLRenderingContext::frontFace(GC3Denum mode) 1991 void WebGLRenderingContext::frontFace(GC3Denum mode)
1992 { 1992 {
1993 if (isContextLost()) 1993 if (isContextLost())
1994 return; 1994 return;
1995 switch (mode) { 1995 switch (mode) {
1996 case GraphicsContext3D::CW: 1996 case GL_CW:
1997 case GraphicsContext3D::CCW: 1997 case GL_CCW:
1998 break; 1998 break;
1999 default: 1999 default:
2000 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "frontFace", "invalid mode"); 2000 synthesizeGLError(GL_INVALID_ENUM, "frontFace", "invalid mode");
2001 return; 2001 return;
2002 } 2002 }
2003 m_context->frontFace(mode); 2003 m_context->frontFace(mode);
2004 } 2004 }
2005 2005
2006 void WebGLRenderingContext::generateMipmap(GC3Denum target) 2006 void WebGLRenderingContext::generateMipmap(GC3Denum target)
2007 { 2007 {
2008 if (isContextLost()) 2008 if (isContextLost())
2009 return; 2009 return;
2010 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); 2010 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false);
2011 if (!tex) 2011 if (!tex)
2012 return; 2012 return;
2013 if (!tex->canGenerateMipmaps()) { 2013 if (!tex->canGenerateMipmaps()) {
2014 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap" , "level 0 not power of 2 or not all the same size"); 2014 synthesizeGLError(GL_INVALID_OPERATION, "generateMipmap", "level 0 not p ower of 2 or not all the same size");
2015 return; 2015 return;
2016 } 2016 }
2017 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ et, 0))) 2017 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ et, 0)))
2018 return; 2018 return;
2019 2019
2020 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN EAR 2020 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN EAR
2021 // on Mac. Remove the hack once this driver bug is fixed. 2021 // on Mac. Remove the hack once this driver bug is fixed.
2022 #if OS(MACOSX) 2022 #if OS(MACOSX)
2023 bool needToResetMinFilter = false; 2023 bool needToResetMinFilter = false;
2024 if (tex->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_LINEAR) { 2024 if (tex->getMinFilter() != GL_NEAREST_MIPMAP_LINEAR) {
2025 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::NEAREST_MIPMAP_LINEAR); 2025 m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMA P_LINEAR);
2026 needToResetMinFilter = true; 2026 needToResetMinFilter = true;
2027 } 2027 }
2028 #endif 2028 #endif
2029 m_context->generateMipmap(target); 2029 m_context->generateMipmap(target);
2030 #if OS(MACOSX) 2030 #if OS(MACOSX)
2031 if (needToResetMinFilter) 2031 if (needToResetMinFilter)
2032 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER, tex->getMinFilter()); 2032 m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFilte r());
2033 #endif 2033 #endif
2034 tex->generateMipmapLevelInfo(); 2034 tex->generateMipmapLevelInfo();
2035 } 2035 }
2036 2036
2037 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram* program, GC3Duint index) 2037 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram* program, GC3Duint index)
2038 { 2038 {
2039 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) 2039 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program))
2040 return 0; 2040 return 0;
2041 ActiveInfo info; 2041 ActiveInfo info;
2042 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) 2042 if (!m_context->getActiveAttrib(objectOrZero(program), index, info))
(...skipping 11 matching lines...) Expand all
2054 return WebGLActiveInfo::create(info.name, info.type, info.size); 2054 return WebGLActiveInfo::create(info.name, info.type, info.size);
2055 } 2055 }
2056 2056
2057 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref Ptr<WebGLShader> >& shaderObjects) 2057 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref Ptr<WebGLShader> >& shaderObjects)
2058 { 2058 {
2059 shaderObjects.clear(); 2059 shaderObjects.clear();
2060 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) 2060 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program))
2061 return false; 2061 return false;
2062 2062
2063 const GC3Denum shaderType[] = { 2063 const GC3Denum shaderType[] = {
2064 GraphicsContext3D::VERTEX_SHADER, 2064 GL_VERTEX_SHADER,
2065 GraphicsContext3D::FRAGMENT_SHADER 2065 GL_FRAGMENT_SHADER
2066 }; 2066 };
2067 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) { 2067 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) {
2068 WebGLShader* shader = program->getAttachedShader(shaderType[i]); 2068 WebGLShader* shader = program->getAttachedShader(shaderType[i]);
2069 if (shader) 2069 if (shader)
2070 shaderObjects.append(shader); 2070 shaderObjects.append(shader);
2071 } 2071 }
2072 return true; 2072 return true;
2073 } 2073 }
2074 2074
2075 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St ring& name) 2075 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St ring& name)
2076 { 2076 {
2077 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) 2077 if (isContextLost() || !validateWebGLObject("getAttribLocation", program))
2078 return -1; 2078 return -1;
2079 if (!validateLocationLength("getAttribLocation", name)) 2079 if (!validateLocationLength("getAttribLocation", name))
2080 return -1; 2080 return -1;
2081 if (!validateString("getAttribLocation", name)) 2081 if (!validateString("getAttribLocation", name))
2082 return -1; 2082 return -1;
2083 if (isPrefixReserved(name)) 2083 if (isPrefixReserved(name))
2084 return -1; 2084 return -1;
2085 if (!program->linkStatus()) { 2085 if (!program->linkStatus()) {
2086 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getAttribLocati on", "program not linked"); 2086 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no t linked");
2087 return 0; 2087 return 0;
2088 } 2088 }
2089 return m_context->getAttribLocation(objectOrZero(program), name); 2089 return m_context->getAttribLocation(objectOrZero(program), name);
2090 } 2090 }
2091 2091
2092 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum pname) 2092 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum pname)
2093 { 2093 {
2094 if (isContextLost()) 2094 if (isContextLost())
2095 return WebGLGetInfo(); 2095 return WebGLGetInfo();
2096 if (target != GraphicsContext3D::ARRAY_BUFFER && target != GraphicsContext3D ::ELEMENT_ARRAY_BUFFER) { 2096 if (target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) {
2097 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid target"); 2097 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid target ");
2098 return WebGLGetInfo(); 2098 return WebGLGetInfo();
2099 } 2099 }
2100 2100
2101 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::B UFFER_USAGE) { 2101 if (pname != GL_BUFFER_SIZE && pname != GL_BUFFER_USAGE) {
2102 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter", "invalid parameter name"); 2102 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid parame ter name");
2103 return WebGLGetInfo(); 2103 return WebGLGetInfo();
2104 } 2104 }
2105 2105
2106 GC3Dint value = 0; 2106 GC3Dint value = 0;
2107 m_context->getBufferParameteriv(target, pname, &value); 2107 m_context->getBufferParameteriv(target, pname, &value);
2108 if (pname == GraphicsContext3D::BUFFER_SIZE) 2108 if (pname == GL_BUFFER_SIZE)
2109 return WebGLGetInfo(value); 2109 return WebGLGetInfo(value);
2110 return WebGLGetInfo(static_cast<unsigned int>(value)); 2110 return WebGLGetInfo(static_cast<unsigned int>(value));
2111 } 2111 }
2112 2112
2113 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() 2113 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes()
2114 { 2114 {
2115 if (isContextLost()) 2115 if (isContextLost())
2116 return 0; 2116 return 0;
2117 // We always need to return a new WebGLContextAttributes object to 2117 // We always need to return a new WebGLContextAttributes object to
2118 // prevent the user from mutating any cached version. 2118 // prevent the user from mutating any cached version.
(...skipping 14 matching lines...) Expand all
2133 2133
2134 GC3Denum WebGLRenderingContext::getError() 2134 GC3Denum WebGLRenderingContext::getError()
2135 { 2135 {
2136 if (lost_context_errors_.size()) { 2136 if (lost_context_errors_.size()) {
2137 GC3Denum err = lost_context_errors_.first(); 2137 GC3Denum err = lost_context_errors_.first();
2138 lost_context_errors_.remove(0); 2138 lost_context_errors_.remove(0);
2139 return err; 2139 return err;
2140 } 2140 }
2141 2141
2142 if (isContextLost()) 2142 if (isContextLost())
2143 return GraphicsContext3D::NO_ERROR; 2143 return GL_NO_ERROR;
2144 2144
2145 return m_context->getError(); 2145 return m_context->getError();
2146 } 2146 }
2147 2147
2148 bool WebGLRenderingContext::ExtensionTracker::matchesNameWithPrefixes(const Stri ng& name) const 2148 bool WebGLRenderingContext::ExtensionTracker::matchesNameWithPrefixes(const Stri ng& name) const
2149 { 2149 {
2150 static const char* const unprefixed[] = { "", 0, }; 2150 static const char* const unprefixed[] = { "", 0, };
2151 2151
2152 const char* const* prefixes = m_prefixes ? m_prefixes : unprefixed; 2152 const char* const* prefixes = m_prefixes ? m_prefixes : unprefixed;
2153 for (; *prefixes; ++prefixes) { 2153 for (; *prefixes; ++prefixes) {
(...skipping 27 matching lines...) Expand all
2181 2181
2182 return 0; 2182 return 0;
2183 } 2183 }
2184 2184
2185 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum t arget, GC3Denum attachment, GC3Denum pname) 2185 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum t arget, GC3Denum attachment, GC3Denum pname)
2186 { 2186 {
2187 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) 2187 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment))
2188 return WebGLGetInfo(); 2188 return WebGLGetInfo();
2189 2189
2190 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2190 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
2191 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getFramebufferA ttachmentParameter", "no framebuffer bound"); 2191 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound");
2192 return WebGLGetInfo(); 2192 return WebGLGetInfo();
2193 } 2193 }
2194 2194
2195 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment); 2195 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment);
2196 if (!object) { 2196 if (!object) {
2197 if (pname == GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) 2197 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)
2198 return WebGLGetInfo(GraphicsContext3D::NONE); 2198 return WebGLGetInfo(GL_NONE);
2199 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL 2199 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL
2200 // specifies INVALID_OPERATION. 2200 // specifies INVALID_OPERATION.
2201 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAttach mentParameter", "invalid parameter name"); 2201 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name");
2202 return WebGLGetInfo(); 2202 return WebGLGetInfo();
2203 } 2203 }
2204 2204
2205 ASSERT(object->isTexture() || object->isRenderbuffer()); 2205 ASSERT(object->isTexture() || object->isRenderbuffer());
2206 if (object->isTexture()) { 2206 if (object->isTexture()) {
2207 switch (pname) { 2207 switch (pname) {
2208 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2208 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2209 return WebGLGetInfo(GraphicsContext3D::TEXTURE); 2209 return WebGLGetInfo(GL_TEXTURE);
2210 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2210 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2211 return WebGLGetInfo(PassRefPtr<WebGLTexture>(static_cast<WebGLTextur e*>(object))); 2211 return WebGLGetInfo(PassRefPtr<WebGLTexture>(static_cast<WebGLTextur e*>(object)));
2212 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 2212 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2213 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 2213 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2214 { 2214 {
2215 GC3Dint value = 0; 2215 GC3Dint value = 0;
2216 m_context->getFramebufferAttachmentParameteriv(target, attachmen t, pname, &value); 2216 m_context->getFramebufferAttachmentParameteriv(target, attachmen t, pname, &value);
2217 return WebGLGetInfo(value); 2217 return WebGLGetInfo(value);
2218 } 2218 }
2219 default: 2219 default:
2220 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAt tachmentParameter", "invalid parameter name for texture attachment"); 2220 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment");
2221 return WebGLGetInfo(); 2221 return WebGLGetInfo();
2222 } 2222 }
2223 } else { 2223 } else {
2224 switch (pname) { 2224 switch (pname) {
2225 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2225 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2226 return WebGLGetInfo(GraphicsContext3D::RENDERBUFFER); 2226 return WebGLGetInfo(GL_RENDERBUFFER);
2227 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2227 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2228 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(static_cast<WebGLR enderbuffer*>(object))); 2228 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(static_cast<WebGLR enderbuffer*>(object)));
2229 default: 2229 default:
2230 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAt tachmentParameter", "invalid parameter name for renderbuffer attachment"); 2230 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2231 return WebGLGetInfo(); 2231 return WebGLGetInfo();
2232 } 2232 }
2233 } 2233 }
2234 } 2234 }
2235 2235
2236 WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname) 2236 WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname)
2237 { 2237 {
2238 if (isContextLost()) 2238 if (isContextLost())
2239 return WebGLGetInfo(); 2239 return WebGLGetInfo();
2240 const int intZero = 0; 2240 const int intZero = 0;
2241 switch (pname) { 2241 switch (pname) {
2242 case GraphicsContext3D::ACTIVE_TEXTURE: 2242 case GL_ACTIVE_TEXTURE:
2243 return getUnsignedIntParameter(pname); 2243 return getUnsignedIntParameter(pname);
2244 case GraphicsContext3D::ALIASED_LINE_WIDTH_RANGE: 2244 case GL_ALIASED_LINE_WIDTH_RANGE:
2245 return getWebGLFloatArrayParameter(pname); 2245 return getWebGLFloatArrayParameter(pname);
2246 case GraphicsContext3D::ALIASED_POINT_SIZE_RANGE: 2246 case GL_ALIASED_POINT_SIZE_RANGE:
2247 return getWebGLFloatArrayParameter(pname); 2247 return getWebGLFloatArrayParameter(pname);
2248 case GraphicsContext3D::ALPHA_BITS: 2248 case GL_ALPHA_BITS:
2249 return getIntParameter(pname); 2249 return getIntParameter(pname);
2250 case GraphicsContext3D::ARRAY_BUFFER_BINDING: 2250 case GL_ARRAY_BUFFER_BINDING:
2251 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundArrayBuffer)); 2251 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundArrayBuffer));
2252 case GraphicsContext3D::BLEND: 2252 case GL_BLEND:
2253 return getBooleanParameter(pname); 2253 return getBooleanParameter(pname);
2254 case GraphicsContext3D::BLEND_COLOR: 2254 case GL_BLEND_COLOR:
2255 return getWebGLFloatArrayParameter(pname); 2255 return getWebGLFloatArrayParameter(pname);
2256 case GraphicsContext3D::BLEND_DST_ALPHA: 2256 case GL_BLEND_DST_ALPHA:
2257 return getUnsignedIntParameter(pname); 2257 return getUnsignedIntParameter(pname);
2258 case GraphicsContext3D::BLEND_DST_RGB: 2258 case GL_BLEND_DST_RGB:
2259 return getUnsignedIntParameter(pname); 2259 return getUnsignedIntParameter(pname);
2260 case GraphicsContext3D::BLEND_EQUATION_ALPHA: 2260 case GL_BLEND_EQUATION_ALPHA:
2261 return getUnsignedIntParameter(pname); 2261 return getUnsignedIntParameter(pname);
2262 case GraphicsContext3D::BLEND_EQUATION_RGB: 2262 case GL_BLEND_EQUATION_RGB:
2263 return getUnsignedIntParameter(pname); 2263 return getUnsignedIntParameter(pname);
2264 case GraphicsContext3D::BLEND_SRC_ALPHA: 2264 case GL_BLEND_SRC_ALPHA:
2265 return getUnsignedIntParameter(pname); 2265 return getUnsignedIntParameter(pname);
2266 case GraphicsContext3D::BLEND_SRC_RGB: 2266 case GL_BLEND_SRC_RGB:
2267 return getUnsignedIntParameter(pname); 2267 return getUnsignedIntParameter(pname);
2268 case GraphicsContext3D::BLUE_BITS: 2268 case GL_BLUE_BITS:
2269 return getIntParameter(pname); 2269 return getIntParameter(pname);
2270 case GraphicsContext3D::COLOR_CLEAR_VALUE: 2270 case GL_COLOR_CLEAR_VALUE:
2271 return getWebGLFloatArrayParameter(pname); 2271 return getWebGLFloatArrayParameter(pname);
2272 case GraphicsContext3D::COLOR_WRITEMASK: 2272 case GL_COLOR_WRITEMASK:
2273 return getBooleanArrayParameter(pname); 2273 return getBooleanArrayParameter(pname);
2274 case GraphicsContext3D::COMPRESSED_TEXTURE_FORMATS: 2274 case GL_COMPRESSED_TEXTURE_FORMATS:
2275 return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data( ), m_compressedTextureFormats.size())); 2275 return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data( ), m_compressedTextureFormats.size()));
2276 case GraphicsContext3D::CULL_FACE: 2276 case GL_CULL_FACE:
2277 return getBooleanParameter(pname); 2277 return getBooleanParameter(pname);
2278 case GraphicsContext3D::CULL_FACE_MODE: 2278 case GL_CULL_FACE_MODE:
2279 return getUnsignedIntParameter(pname); 2279 return getUnsignedIntParameter(pname);
2280 case GraphicsContext3D::CURRENT_PROGRAM: 2280 case GL_CURRENT_PROGRAM:
2281 return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram)); 2281 return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram));
2282 case GraphicsContext3D::DEPTH_BITS: 2282 case GL_DEPTH_BITS:
2283 if (!m_framebufferBinding && !m_attributes.depth) 2283 if (!m_framebufferBinding && !m_attributes.depth)
2284 return WebGLGetInfo(intZero); 2284 return WebGLGetInfo(intZero);
2285 return getIntParameter(pname); 2285 return getIntParameter(pname);
2286 case GraphicsContext3D::DEPTH_CLEAR_VALUE: 2286 case GL_DEPTH_CLEAR_VALUE:
2287 return getFloatParameter(pname); 2287 return getFloatParameter(pname);
2288 case GraphicsContext3D::DEPTH_FUNC: 2288 case GL_DEPTH_FUNC:
2289 return getUnsignedIntParameter(pname); 2289 return getUnsignedIntParameter(pname);
2290 case GraphicsContext3D::DEPTH_RANGE: 2290 case GL_DEPTH_RANGE:
2291 return getWebGLFloatArrayParameter(pname); 2291 return getWebGLFloatArrayParameter(pname);
2292 case GraphicsContext3D::DEPTH_TEST: 2292 case GL_DEPTH_TEST:
2293 return getBooleanParameter(pname); 2293 return getBooleanParameter(pname);
2294 case GraphicsContext3D::DEPTH_WRITEMASK: 2294 case GL_DEPTH_WRITEMASK:
2295 return getBooleanParameter(pname); 2295 return getBooleanParameter(pname);
2296 case GraphicsContext3D::DITHER: 2296 case GL_DITHER:
2297 return getBooleanParameter(pname); 2297 return getBooleanParameter(pname);
2298 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER_BINDING: 2298 case GL_ELEMENT_ARRAY_BUFFER_BINDING:
2299 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundVertexArrayObject->bo undElementArrayBuffer())); 2299 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundVertexArrayObject->bo undElementArrayBuffer()));
2300 case GraphicsContext3D::FRAMEBUFFER_BINDING: 2300 case GL_FRAMEBUFFER_BINDING:
2301 return WebGLGetInfo(PassRefPtr<WebGLFramebuffer>(m_framebufferBinding)); 2301 return WebGLGetInfo(PassRefPtr<WebGLFramebuffer>(m_framebufferBinding));
2302 case GraphicsContext3D::FRONT_FACE: 2302 case GL_FRONT_FACE:
2303 return getUnsignedIntParameter(pname); 2303 return getUnsignedIntParameter(pname);
2304 case GraphicsContext3D::GENERATE_MIPMAP_HINT: 2304 case GL_GENERATE_MIPMAP_HINT:
2305 return getUnsignedIntParameter(pname); 2305 return getUnsignedIntParameter(pname);
2306 case GraphicsContext3D::GREEN_BITS: 2306 case GL_GREEN_BITS:
2307 return getIntParameter(pname); 2307 return getIntParameter(pname);
2308 case GraphicsContext3D::LINE_WIDTH: 2308 case GL_LINE_WIDTH:
2309 return getFloatParameter(pname); 2309 return getFloatParameter(pname);
2310 case GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS: 2310 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
2311 return getIntParameter(pname); 2311 return getIntParameter(pname);
2312 case GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE: 2312 case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
2313 return getIntParameter(pname); 2313 return getIntParameter(pname);
2314 case GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS: 2314 case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
2315 return getIntParameter(pname); 2315 return getIntParameter(pname);
2316 case GraphicsContext3D::MAX_RENDERBUFFER_SIZE: 2316 case GL_MAX_RENDERBUFFER_SIZE:
2317 return getIntParameter(pname); 2317 return getIntParameter(pname);
2318 case GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS: 2318 case GL_MAX_TEXTURE_IMAGE_UNITS:
2319 return getIntParameter(pname); 2319 return getIntParameter(pname);
2320 case GraphicsContext3D::MAX_TEXTURE_SIZE: 2320 case GL_MAX_TEXTURE_SIZE:
2321 return getIntParameter(pname); 2321 return getIntParameter(pname);
2322 case GraphicsContext3D::MAX_VARYING_VECTORS: 2322 case GL_MAX_VARYING_VECTORS:
2323 return getIntParameter(pname); 2323 return getIntParameter(pname);
2324 case GraphicsContext3D::MAX_VERTEX_ATTRIBS: 2324 case GL_MAX_VERTEX_ATTRIBS:
2325 return getIntParameter(pname); 2325 return getIntParameter(pname);
2326 case GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS: 2326 case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
2327 return getIntParameter(pname); 2327 return getIntParameter(pname);
2328 case GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS: 2328 case GL_MAX_VERTEX_UNIFORM_VECTORS:
2329 return getIntParameter(pname); 2329 return getIntParameter(pname);
2330 case GraphicsContext3D::MAX_VIEWPORT_DIMS: 2330 case GL_MAX_VIEWPORT_DIMS:
2331 return getWebGLIntArrayParameter(pname); 2331 return getWebGLIntArrayParameter(pname);
2332 case GraphicsContext3D::NUM_SHADER_BINARY_FORMATS: 2332 case GL_NUM_SHADER_BINARY_FORMATS:
2333 // FIXME: should we always return 0 for this? 2333 // FIXME: should we always return 0 for this?
2334 return getIntParameter(pname); 2334 return getIntParameter(pname);
2335 case GraphicsContext3D::PACK_ALIGNMENT: 2335 case GL_PACK_ALIGNMENT:
2336 return getIntParameter(pname); 2336 return getIntParameter(pname);
2337 case GraphicsContext3D::POLYGON_OFFSET_FACTOR: 2337 case GL_POLYGON_OFFSET_FACTOR:
2338 return getFloatParameter(pname); 2338 return getFloatParameter(pname);
2339 case GraphicsContext3D::POLYGON_OFFSET_FILL: 2339 case GL_POLYGON_OFFSET_FILL:
2340 return getBooleanParameter(pname); 2340 return getBooleanParameter(pname);
2341 case GraphicsContext3D::POLYGON_OFFSET_UNITS: 2341 case GL_POLYGON_OFFSET_UNITS:
2342 return getFloatParameter(pname); 2342 return getFloatParameter(pname);
2343 case GraphicsContext3D::RED_BITS: 2343 case GL_RED_BITS:
2344 return getIntParameter(pname); 2344 return getIntParameter(pname);
2345 case GraphicsContext3D::RENDERBUFFER_BINDING: 2345 case GL_RENDERBUFFER_BINDING:
2346 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(m_renderbufferBinding) ); 2346 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(m_renderbufferBinding) );
2347 case GraphicsContext3D::RENDERER: 2347 case GL_RENDERER:
2348 return WebGLGetInfo(String("WebKit WebGL")); 2348 return WebGLGetInfo(String("WebKit WebGL"));
2349 case GraphicsContext3D::SAMPLE_BUFFERS: 2349 case GL_SAMPLE_BUFFERS:
2350 return getIntParameter(pname); 2350 return getIntParameter(pname);
2351 case GraphicsContext3D::SAMPLE_COVERAGE_INVERT: 2351 case GL_SAMPLE_COVERAGE_INVERT:
2352 return getBooleanParameter(pname); 2352 return getBooleanParameter(pname);
2353 case GraphicsContext3D::SAMPLE_COVERAGE_VALUE: 2353 case GL_SAMPLE_COVERAGE_VALUE:
2354 return getFloatParameter(pname); 2354 return getFloatParameter(pname);
2355 case GraphicsContext3D::SAMPLES: 2355 case GL_SAMPLES:
2356 return getIntParameter(pname); 2356 return getIntParameter(pname);
2357 case GraphicsContext3D::SCISSOR_BOX: 2357 case GL_SCISSOR_BOX:
2358 return getWebGLIntArrayParameter(pname); 2358 return getWebGLIntArrayParameter(pname);
2359 case GraphicsContext3D::SCISSOR_TEST: 2359 case GL_SCISSOR_TEST:
2360 return getBooleanParameter(pname); 2360 return getBooleanParameter(pname);
2361 case GraphicsContext3D::SHADING_LANGUAGE_VERSION: 2361 case GL_SHADING_LANGUAGE_VERSION:
2362 return WebGLGetInfo("WebGL GLSL ES 1.0 (" + m_context->getString(Graphic sContext3D::SHADING_LANGUAGE_VERSION) + ")"); 2362 return WebGLGetInfo("WebGL GLSL ES 1.0 (" + m_context->getString(GL_SHAD ING_LANGUAGE_VERSION) + ")");
2363 case GraphicsContext3D::STENCIL_BACK_FAIL: 2363 case GL_STENCIL_BACK_FAIL:
2364 return getUnsignedIntParameter(pname); 2364 return getUnsignedIntParameter(pname);
2365 case GraphicsContext3D::STENCIL_BACK_FUNC: 2365 case GL_STENCIL_BACK_FUNC:
2366 return getUnsignedIntParameter(pname); 2366 return getUnsignedIntParameter(pname);
2367 case GraphicsContext3D::STENCIL_BACK_PASS_DEPTH_FAIL: 2367 case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
2368 return getUnsignedIntParameter(pname); 2368 return getUnsignedIntParameter(pname);
2369 case GraphicsContext3D::STENCIL_BACK_PASS_DEPTH_PASS: 2369 case GL_STENCIL_BACK_PASS_DEPTH_PASS:
2370 return getUnsignedIntParameter(pname); 2370 return getUnsignedIntParameter(pname);
2371 case GraphicsContext3D::STENCIL_BACK_REF: 2371 case GL_STENCIL_BACK_REF:
2372 return getIntParameter(pname); 2372 return getIntParameter(pname);
2373 case GraphicsContext3D::STENCIL_BACK_VALUE_MASK: 2373 case GL_STENCIL_BACK_VALUE_MASK:
2374 return getUnsignedIntParameter(pname); 2374 return getUnsignedIntParameter(pname);
2375 case GraphicsContext3D::STENCIL_BACK_WRITEMASK: 2375 case GL_STENCIL_BACK_WRITEMASK:
2376 return getUnsignedIntParameter(pname); 2376 return getUnsignedIntParameter(pname);
2377 case GraphicsContext3D::STENCIL_BITS: 2377 case GL_STENCIL_BITS:
2378 if (!m_framebufferBinding && !m_attributes.stencil) 2378 if (!m_framebufferBinding && !m_attributes.stencil)
2379 return WebGLGetInfo(intZero); 2379 return WebGLGetInfo(intZero);
2380 return getIntParameter(pname); 2380 return getIntParameter(pname);
2381 case GraphicsContext3D::STENCIL_CLEAR_VALUE: 2381 case GL_STENCIL_CLEAR_VALUE:
2382 return getIntParameter(pname); 2382 return getIntParameter(pname);
2383 case GraphicsContext3D::STENCIL_FAIL: 2383 case GL_STENCIL_FAIL:
2384 return getUnsignedIntParameter(pname); 2384 return getUnsignedIntParameter(pname);
2385 case GraphicsContext3D::STENCIL_FUNC: 2385 case GL_STENCIL_FUNC:
2386 return getUnsignedIntParameter(pname); 2386 return getUnsignedIntParameter(pname);
2387 case GraphicsContext3D::STENCIL_PASS_DEPTH_FAIL: 2387 case GL_STENCIL_PASS_DEPTH_FAIL:
2388 return getUnsignedIntParameter(pname); 2388 return getUnsignedIntParameter(pname);
2389 case GraphicsContext3D::STENCIL_PASS_DEPTH_PASS: 2389 case GL_STENCIL_PASS_DEPTH_PASS:
2390 return getUnsignedIntParameter(pname); 2390 return getUnsignedIntParameter(pname);
2391 case GraphicsContext3D::STENCIL_REF: 2391 case GL_STENCIL_REF:
2392 return getIntParameter(pname); 2392 return getIntParameter(pname);
2393 case GraphicsContext3D::STENCIL_TEST: 2393 case GL_STENCIL_TEST:
2394 return getBooleanParameter(pname); 2394 return getBooleanParameter(pname);
2395 case GraphicsContext3D::STENCIL_VALUE_MASK: 2395 case GL_STENCIL_VALUE_MASK:
2396 return getUnsignedIntParameter(pname); 2396 return getUnsignedIntParameter(pname);
2397 case GraphicsContext3D::STENCIL_WRITEMASK: 2397 case GL_STENCIL_WRITEMASK:
2398 return getUnsignedIntParameter(pname); 2398 return getUnsignedIntParameter(pname);
2399 case GraphicsContext3D::SUBPIXEL_BITS: 2399 case GL_SUBPIXEL_BITS:
2400 return getIntParameter(pname); 2400 return getIntParameter(pname);
2401 case GraphicsContext3D::TEXTURE_BINDING_2D: 2401 case GL_TEXTURE_BINDING_2D:
2402 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText ureUnit].m_texture2DBinding)); 2402 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText ureUnit].m_texture2DBinding));
2403 case GraphicsContext3D::TEXTURE_BINDING_CUBE_MAP: 2403 case GL_TEXTURE_BINDING_CUBE_MAP:
2404 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText ureUnit].m_textureCubeMapBinding)); 2404 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText ureUnit].m_textureCubeMapBinding));
2405 case GraphicsContext3D::UNPACK_ALIGNMENT: 2405 case GL_UNPACK_ALIGNMENT:
2406 return getIntParameter(pname); 2406 return getIntParameter(pname);
2407 case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL: 2407 case GC3D_UNPACK_FLIP_Y_WEBGL:
2408 return WebGLGetInfo(m_unpackFlipY); 2408 return WebGLGetInfo(m_unpackFlipY);
2409 case GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL: 2409 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL:
2410 return WebGLGetInfo(m_unpackPremultiplyAlpha); 2410 return WebGLGetInfo(m_unpackPremultiplyAlpha);
2411 case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: 2411 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL:
2412 return WebGLGetInfo(m_unpackColorspaceConversion); 2412 return WebGLGetInfo(m_unpackColorspaceConversion);
2413 case GraphicsContext3D::VENDOR: 2413 case GL_VENDOR:
2414 return WebGLGetInfo(String("WebKit")); 2414 return WebGLGetInfo(String("WebKit"));
2415 case GraphicsContext3D::VERSION: 2415 case GL_VERSION:
2416 return WebGLGetInfo("WebGL 1.0 (" + m_context->getString(GraphicsContext 3D::VERSION) + ")"); 2416 return WebGLGetInfo("WebGL 1.0 (" + m_context->getString(GL_VERSION) + " )");
2417 case GraphicsContext3D::VIEWPORT: 2417 case GL_VIEWPORT:
2418 return getWebGLIntArrayParameter(pname); 2418 return getWebGLIntArrayParameter(pname);
2419 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives 2419 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives
2420 if (m_oesStandardDerivatives) 2420 if (m_oesStandardDerivatives)
2421 return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVAT IVE_HINT_OES); 2421 return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVAT IVE_HINT_OES);
2422 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, OES_standard_derivatives not enabled"); 2422 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_standard_derivatives not enabled");
2423 return WebGLGetInfo(); 2423 return WebGLGetInfo();
2424 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: 2424 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL:
2425 if (m_webglDebugRendererInfo) 2425 if (m_webglDebugRendererInfo)
2426 return WebGLGetInfo(m_context->getString(GraphicsContext3D::RENDERER )); 2426 return WebGLGetInfo(m_context->getString(GL_RENDERER));
2427 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_debug_renderer_info not enabled"); 2427 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled");
2428 return WebGLGetInfo(); 2428 return WebGLGetInfo();
2429 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: 2429 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL:
2430 if (m_webglDebugRendererInfo) 2430 if (m_webglDebugRendererInfo)
2431 return WebGLGetInfo(m_context->getString(GraphicsContext3D::VENDOR)) ; 2431 return WebGLGetInfo(m_context->getString(GL_VENDOR));
2432 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_debug_renderer_info not enabled"); 2432 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled");
2433 return WebGLGetInfo(); 2433 return WebGLGetInfo();
2434 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object 2434 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object
2435 if (m_oesVertexArrayObject) { 2435 if (m_oesVertexArrayObject) {
2436 if (!m_boundVertexArrayObject->isDefaultObject()) 2436 if (!m_boundVertexArrayObject->isDefaultObject())
2437 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun dVertexArrayObject)); 2437 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun dVertexArrayObject));
2438 return WebGLGetInfo(); 2438 return WebGLGetInfo();
2439 } 2439 }
2440 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, OES_vertex_array_object not enabled"); 2440 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled");
2441 return WebGLGetInfo(); 2441 return WebGLGetInfo();
2442 case Extensions3D::MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_ani sotropic 2442 case Extensions3D::MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_ani sotropic
2443 if (m_extTextureFilterAnisotropic) 2443 if (m_extTextureFilterAnisotropic)
2444 return getUnsignedIntParameter(Extensions3D::MAX_TEXTURE_MAX_ANISOTR OPY_EXT); 2444 return getUnsignedIntParameter(Extensions3D::MAX_TEXTURE_MAX_ANISOTR OPY_EXT);
2445 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, EXT_texture_filter_anisotropic not enabled"); 2445 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled");
2446 return WebGLGetInfo(); 2446 return WebGLGetInfo();
2447 case Extensions3D::MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN 2447 case Extensions3D::MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN
2448 if (m_webglDrawBuffers) 2448 if (m_webglDrawBuffers)
2449 return WebGLGetInfo(maxColorAttachments()); 2449 return WebGLGetInfo(maxColorAttachments());
2450 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_draw_buffers not enabled"); 2450 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled");
2451 return WebGLGetInfo(); 2451 return WebGLGetInfo();
2452 case Extensions3D::MAX_DRAW_BUFFERS_EXT: 2452 case Extensions3D::MAX_DRAW_BUFFERS_EXT:
2453 if (m_webglDrawBuffers) 2453 if (m_webglDrawBuffers)
2454 return WebGLGetInfo(maxDrawBuffers()); 2454 return WebGLGetInfo(maxDrawBuffers());
2455 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name, WEBGL_draw_buffers not enabled"); 2455 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled");
2456 return WebGLGetInfo(); 2456 return WebGLGetInfo();
2457 default: 2457 default:
2458 if (m_webglDrawBuffers 2458 if (m_webglDrawBuffers
2459 && pname >= Extensions3D::DRAW_BUFFER0_EXT 2459 && pname >= Extensions3D::DRAW_BUFFER0_EXT
2460 && pname < static_cast<GC3Denum>(Extensions3D::DRAW_BUFFER0_EXT + ma xDrawBuffers())) { 2460 && pname < static_cast<GC3Denum>(Extensions3D::DRAW_BUFFER0_EXT + ma xDrawBuffers())) {
2461 GC3Dint value = GraphicsContext3D::NONE; 2461 GC3Dint value = GL_NONE;
2462 if (m_framebufferBinding) 2462 if (m_framebufferBinding)
2463 value = m_framebufferBinding->getDrawBuffer(pname); 2463 value = m_framebufferBinding->getDrawBuffer(pname);
2464 else // emulated backbuffer 2464 else // emulated backbuffer
2465 value = m_backDrawBuffer; 2465 value = m_backDrawBuffer;
2466 return WebGLGetInfo(value); 2466 return WebGLGetInfo(value);
2467 } 2467 }
2468 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva lid parameter name"); 2468 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me");
2469 return WebGLGetInfo(); 2469 return WebGLGetInfo();
2470 } 2470 }
2471 } 2471 }
2472 2472
2473 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G C3Denum pname) 2473 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G C3Denum pname)
2474 { 2474 {
2475 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) 2475 if (isContextLost() || !validateWebGLObject("getProgramParameter", program))
2476 return WebGLGetInfo(); 2476 return WebGLGetInfo();
2477 2477
2478 GC3Dint value = 0; 2478 GC3Dint value = 0;
2479 switch (pname) { 2479 switch (pname) {
2480 case GraphicsContext3D::DELETE_STATUS: 2480 case GL_DELETE_STATUS:
2481 return WebGLGetInfo(program->isDeleted()); 2481 return WebGLGetInfo(program->isDeleted());
2482 case GraphicsContext3D::VALIDATE_STATUS: 2482 case GL_VALIDATE_STATUS:
2483 m_context->getProgramiv(objectOrZero(program), pname, &value); 2483 m_context->getProgramiv(objectOrZero(program), pname, &value);
2484 return WebGLGetInfo(static_cast<bool>(value)); 2484 return WebGLGetInfo(static_cast<bool>(value));
2485 case GraphicsContext3D::LINK_STATUS: 2485 case GL_LINK_STATUS:
2486 return WebGLGetInfo(program->linkStatus()); 2486 return WebGLGetInfo(program->linkStatus());
2487 case GraphicsContext3D::ATTACHED_SHADERS: 2487 case GL_ATTACHED_SHADERS:
2488 case GraphicsContext3D::ACTIVE_ATTRIBUTES: 2488 case GL_ACTIVE_ATTRIBUTES:
2489 case GraphicsContext3D::ACTIVE_UNIFORMS: 2489 case GL_ACTIVE_UNIFORMS:
2490 m_context->getProgramiv(objectOrZero(program), pname, &value); 2490 m_context->getProgramiv(objectOrZero(program), pname, &value);
2491 return WebGLGetInfo(value); 2491 return WebGLGetInfo(value);
2492 default: 2492 default:
2493 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter" , "invalid parameter name"); 2493 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid param eter name");
2494 return WebGLGetInfo(); 2494 return WebGLGetInfo();
2495 } 2495 }
2496 } 2496 }
2497 2497
2498 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program) 2498 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program)
2499 { 2499 {
2500 if (isContextLost()) 2500 if (isContextLost())
2501 return String(); 2501 return String();
2502 if (!validateWebGLObject("getProgramInfoLog", program)) 2502 if (!validateWebGLObject("getProgramInfoLog", program))
2503 return ""; 2503 return "";
2504 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); 2504 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program)));
2505 } 2505 }
2506 2506
2507 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC 3Denum pname) 2507 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC 3Denum pname)
2508 { 2508 {
2509 if (isContextLost()) 2509 if (isContextLost())
2510 return WebGLGetInfo(); 2510 return WebGLGetInfo();
2511 if (target != GraphicsContext3D::RENDERBUFFER) { 2511 if (target != GL_RENDERBUFFER) {
2512 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid target"); 2512 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid target");
2513 return WebGLGetInfo(); 2513 return WebGLGetInfo();
2514 } 2514 }
2515 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { 2515 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) {
2516 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbuffer Parameter", "no renderbuffer bound"); 2516 synthesizeGLError(GL_INVALID_OPERATION, "getRenderbufferParameter", "no renderbuffer bound");
2517 return WebGLGetInfo(); 2517 return WebGLGetInfo();
2518 } 2518 }
2519 2519
2520 GC3Dint value = 0; 2520 GC3Dint value = 0;
2521 switch (pname) { 2521 switch (pname) {
2522 case GraphicsContext3D::RENDERBUFFER_WIDTH: 2522 case GL_RENDERBUFFER_WIDTH:
2523 case GraphicsContext3D::RENDERBUFFER_HEIGHT: 2523 case GL_RENDERBUFFER_HEIGHT:
2524 case GraphicsContext3D::RENDERBUFFER_RED_SIZE: 2524 case GL_RENDERBUFFER_RED_SIZE:
2525 case GraphicsContext3D::RENDERBUFFER_GREEN_SIZE: 2525 case GL_RENDERBUFFER_GREEN_SIZE:
2526 case GraphicsContext3D::RENDERBUFFER_BLUE_SIZE: 2526 case GL_RENDERBUFFER_BLUE_SIZE:
2527 case GraphicsContext3D::RENDERBUFFER_ALPHA_SIZE: 2527 case GL_RENDERBUFFER_ALPHA_SIZE:
2528 case GraphicsContext3D::RENDERBUFFER_DEPTH_SIZE: 2528 case GL_RENDERBUFFER_DEPTH_SIZE:
2529 m_context->getRenderbufferParameteriv(target, pname, &value); 2529 m_context->getRenderbufferParameteriv(target, pname, &value);
2530 return WebGLGetInfo(value); 2530 return WebGLGetInfo(value);
2531 case GraphicsContext3D::RENDERBUFFER_STENCIL_SIZE: 2531 case GL_RENDERBUFFER_STENCIL_SIZE:
2532 if (m_renderbufferBinding->emulatedStencilBuffer()) { 2532 if (m_renderbufferBinding->emulatedStencilBuffer()) {
2533 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi ng->emulatedStencilBuffer())); 2533 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi ng->emulatedStencilBuffer()));
2534 m_context->getRenderbufferParameteriv(target, pname, &value); 2534 m_context->getRenderbufferParameteriv(target, pname, &value);
2535 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi ng.get())); 2535 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi ng.get()));
2536 } else { 2536 } else {
2537 m_context->getRenderbufferParameteriv(target, pname, &value); 2537 m_context->getRenderbufferParameteriv(target, pname, &value);
2538 } 2538 }
2539 return WebGLGetInfo(value); 2539 return WebGLGetInfo(value);
2540 case GraphicsContext3D::RENDERBUFFER_INTERNAL_FORMAT: 2540 case GL_RENDERBUFFER_INTERNAL_FORMAT:
2541 return WebGLGetInfo(m_renderbufferBinding->internalFormat()); 2541 return WebGLGetInfo(m_renderbufferBinding->internalFormat());
2542 default: 2542 default:
2543 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam eter", "invalid parameter name"); 2543 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid parameter name");
2544 return WebGLGetInfo(); 2544 return WebGLGetInfo();
2545 } 2545 }
2546 } 2546 }
2547 2547
2548 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D enum pname) 2548 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D enum pname)
2549 { 2549 {
2550 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) 2550 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader))
2551 return WebGLGetInfo(); 2551 return WebGLGetInfo();
2552 GC3Dint value = 0; 2552 GC3Dint value = 0;
2553 switch (pname) { 2553 switch (pname) {
2554 case GraphicsContext3D::DELETE_STATUS: 2554 case GL_DELETE_STATUS:
2555 return WebGLGetInfo(shader->isDeleted()); 2555 return WebGLGetInfo(shader->isDeleted());
2556 case GraphicsContext3D::COMPILE_STATUS: 2556 case GL_COMPILE_STATUS:
2557 m_context->getShaderiv(objectOrZero(shader), pname, &value); 2557 m_context->getShaderiv(objectOrZero(shader), pname, &value);
2558 return WebGLGetInfo(static_cast<bool>(value)); 2558 return WebGLGetInfo(static_cast<bool>(value));
2559 case GraphicsContext3D::SHADER_TYPE: 2559 case GL_SHADER_TYPE:
2560 m_context->getShaderiv(objectOrZero(shader), pname, &value); 2560 m_context->getShaderiv(objectOrZero(shader), pname, &value);
2561 return WebGLGetInfo(static_cast<unsigned int>(value)); 2561 return WebGLGetInfo(static_cast<unsigned int>(value));
2562 default: 2562 default:
2563 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter", "invalid parameter name"); 2563 synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parame ter name");
2564 return WebGLGetInfo(); 2564 return WebGLGetInfo();
2565 } 2565 }
2566 } 2566 }
2567 2567
2568 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader) 2568 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader)
2569 { 2569 {
2570 if (isContextLost()) 2570 if (isContextLost())
2571 return String(); 2571 return String();
2572 if (!validateWebGLObject("getShaderInfoLog", shader)) 2572 if (!validateWebGLObject("getShaderInfoLog", shader))
2573 return ""; 2573 return "";
2574 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); 2574 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader)));
2575 } 2575 }
2576 2576
2577 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision Format(GC3Denum shaderType, GC3Denum precisionType) 2577 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision Format(GC3Denum shaderType, GC3Denum precisionType)
2578 { 2578 {
2579 if (isContextLost()) 2579 if (isContextLost())
2580 return 0; 2580 return 0;
2581 switch (shaderType) { 2581 switch (shaderType) {
2582 case GraphicsContext3D::VERTEX_SHADER: 2582 case GL_VERTEX_SHADER:
2583 case GraphicsContext3D::FRAGMENT_SHADER: 2583 case GL_FRAGMENT_SHADER:
2584 break; 2584 break;
2585 default: 2585 default:
2586 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFo rmat", "invalid shader type"); 2586 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid shader type");
2587 return 0; 2587 return 0;
2588 } 2588 }
2589 switch (precisionType) { 2589 switch (precisionType) {
2590 case GraphicsContext3D::LOW_FLOAT: 2590 case GL_LOW_FLOAT:
2591 case GraphicsContext3D::MEDIUM_FLOAT: 2591 case GL_MEDIUM_FLOAT:
2592 case GraphicsContext3D::HIGH_FLOAT: 2592 case GL_HIGH_FLOAT:
2593 case GraphicsContext3D::LOW_INT: 2593 case GL_LOW_INT:
2594 case GraphicsContext3D::MEDIUM_INT: 2594 case GL_MEDIUM_INT:
2595 case GraphicsContext3D::HIGH_INT: 2595 case GL_HIGH_INT:
2596 break; 2596 break;
2597 default: 2597 default:
2598 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFo rmat", "invalid precision type"); 2598 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid precision type");
2599 return 0; 2599 return 0;
2600 } 2600 }
2601 2601
2602 GC3Dint range[2] = {0, 0}; 2602 GC3Dint range[2] = {0, 0};
2603 GC3Dint precision = 0; 2603 GC3Dint precision = 0;
2604 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci sion); 2604 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci sion);
2605 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); 2605 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision);
2606 } 2606 }
2607 2607
2608 String WebGLRenderingContext::getShaderSource(WebGLShader* shader) 2608 String WebGLRenderingContext::getShaderSource(WebGLShader* shader)
(...skipping 28 matching lines...) Expand all
2637 2637
2638 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn ame) 2638 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn ame)
2639 { 2639 {
2640 if (isContextLost()) 2640 if (isContextLost())
2641 return WebGLGetInfo(); 2641 return WebGLGetInfo();
2642 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false) ; 2642 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false) ;
2643 if (!tex) 2643 if (!tex)
2644 return WebGLGetInfo(); 2644 return WebGLGetInfo();
2645 GC3Dint value = 0; 2645 GC3Dint value = 0;
2646 switch (pname) { 2646 switch (pname) {
2647 case GraphicsContext3D::TEXTURE_MAG_FILTER: 2647 case GL_TEXTURE_MAG_FILTER:
2648 case GraphicsContext3D::TEXTURE_MIN_FILTER: 2648 case GL_TEXTURE_MIN_FILTER:
2649 case GraphicsContext3D::TEXTURE_WRAP_S: 2649 case GL_TEXTURE_WRAP_S:
2650 case GraphicsContext3D::TEXTURE_WRAP_T: 2650 case GL_TEXTURE_WRAP_T:
2651 m_context->getTexParameteriv(target, pname, &value); 2651 m_context->getTexParameteriv(target, pname, &value);
2652 return WebGLGetInfo(static_cast<unsigned int>(value)); 2652 return WebGLGetInfo(static_cast<unsigned int>(value));
2653 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic 2653 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic
2654 if (m_extTextureFilterAnisotropic) { 2654 if (m_extTextureFilterAnisotropic) {
2655 m_context->getTexParameteriv(target, pname, &value); 2655 m_context->getTexParameteriv(target, pname, &value);
2656 return WebGLGetInfo(static_cast<unsigned int>(value)); 2656 return WebGLGetInfo(static_cast<unsigned int>(value));
2657 } 2657 }
2658 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name, EXT_texture_filter_anisotropic not enabled"); 2658 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name, EXT_texture_filter_anisotropic not enabled");
2659 return WebGLGetInfo(); 2659 return WebGLGetInfo();
2660 default: 2660 default:
2661 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i nvalid parameter name"); 2661 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name");
2662 return WebGLGetInfo(); 2662 return WebGLGetInfo();
2663 } 2663 }
2664 } 2664 }
2665 2665
2666 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG LUniformLocation* uniformLocation) 2666 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG LUniformLocation* uniformLocation)
2667 { 2667 {
2668 if (isContextLost() || !validateWebGLObject("getUniform", program)) 2668 if (isContextLost() || !validateWebGLObject("getUniform", program))
2669 return WebGLGetInfo(); 2669 return WebGLGetInfo();
2670 if (!uniformLocation || uniformLocation->program() != program) { 2670 if (!uniformLocation || uniformLocation->program() != program) {
2671 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "n o uniformlocation or not valid for this program"); 2671 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", "no uniformlocatio n or not valid for this program");
2672 return WebGLGetInfo(); 2672 return WebGLGetInfo();
2673 } 2673 }
2674 GC3Dint location = uniformLocation->location(); 2674 GC3Dint location = uniformLocation->location();
2675 2675
2676 // FIXME: make this more efficient using WebGLUniformLocation and caching ty pes in it 2676 // FIXME: make this more efficient using WebGLUniformLocation and caching ty pes in it
2677 GC3Dint activeUniforms = 0; 2677 GC3Dint activeUniforms = 0;
2678 m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNI FORMS, &activeUniforms); 2678 m_context->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activeUn iforms);
2679 for (GC3Dint i = 0; i < activeUniforms; i++) { 2679 for (GC3Dint i = 0; i < activeUniforms; i++) {
2680 ActiveInfo info; 2680 ActiveInfo info;
2681 if (!m_context->getActiveUniform(objectOrZero(program), i, info)) 2681 if (!m_context->getActiveUniform(objectOrZero(program), i, info))
2682 return WebGLGetInfo(); 2682 return WebGLGetInfo();
2683 // Strip "[0]" from the name if it's an array. 2683 // Strip "[0]" from the name if it's an array.
2684 if (info.size > 1 && info.name.endsWith("[0]")) 2684 if (info.size > 1 && info.name.endsWith("[0]"))
2685 info.name = info.name.left(info.name.length() - 3); 2685 info.name = info.name.left(info.name.length() - 3);
2686 // If it's an array, we need to iterate through each element, appending "[index]" to the name. 2686 // If it's an array, we need to iterate through each element, appending "[index]" to the name.
2687 for (GC3Dint index = 0; index < info.size; ++index) { 2687 for (GC3Dint index = 0; index < info.size; ++index) {
2688 String name = info.name; 2688 String name = info.name;
2689 if (info.size > 1 && index >= 1) { 2689 if (info.size > 1 && index >= 1) {
2690 name.append('['); 2690 name.append('[');
2691 name.append(String::number(index)); 2691 name.append(String::number(index));
2692 name.append(']'); 2692 name.append(']');
2693 } 2693 }
2694 // Now need to look this up by name again to find its location 2694 // Now need to look this up by name again to find its location
2695 GC3Dint loc = m_context->getUniformLocation(objectOrZero(program), n ame); 2695 GC3Dint loc = m_context->getUniformLocation(objectOrZero(program), n ame);
2696 if (loc == location) { 2696 if (loc == location) {
2697 // Found it. Use the type in the ActiveInfo to determine the ret urn type. 2697 // Found it. Use the type in the ActiveInfo to determine the ret urn type.
2698 GC3Denum baseType; 2698 GC3Denum baseType;
2699 unsigned int length; 2699 unsigned int length;
2700 switch (info.type) { 2700 switch (info.type) {
2701 case GraphicsContext3D::BOOL: 2701 case GL_BOOL:
2702 baseType = GraphicsContext3D::BOOL; 2702 baseType = GL_BOOL;
2703 length = 1; 2703 length = 1;
2704 break; 2704 break;
2705 case GraphicsContext3D::BOOL_VEC2: 2705 case GL_BOOL_VEC2:
2706 baseType = GraphicsContext3D::BOOL; 2706 baseType = GL_BOOL;
2707 length = 2; 2707 length = 2;
2708 break; 2708 break;
2709 case GraphicsContext3D::BOOL_VEC3: 2709 case GL_BOOL_VEC3:
2710 baseType = GraphicsContext3D::BOOL; 2710 baseType = GL_BOOL;
2711 length = 3; 2711 length = 3;
2712 break; 2712 break;
2713 case GraphicsContext3D::BOOL_VEC4: 2713 case GL_BOOL_VEC4:
2714 baseType = GraphicsContext3D::BOOL; 2714 baseType = GL_BOOL;
2715 length = 4; 2715 length = 4;
2716 break; 2716 break;
2717 case GraphicsContext3D::INT: 2717 case GL_INT:
2718 baseType = GraphicsContext3D::INT; 2718 baseType = GL_INT;
2719 length = 1; 2719 length = 1;
2720 break; 2720 break;
2721 case GraphicsContext3D::INT_VEC2: 2721 case GL_INT_VEC2:
2722 baseType = GraphicsContext3D::INT; 2722 baseType = GL_INT;
2723 length = 2; 2723 length = 2;
2724 break; 2724 break;
2725 case GraphicsContext3D::INT_VEC3: 2725 case GL_INT_VEC3:
2726 baseType = GraphicsContext3D::INT; 2726 baseType = GL_INT;
2727 length = 3; 2727 length = 3;
2728 break; 2728 break;
2729 case GraphicsContext3D::INT_VEC4: 2729 case GL_INT_VEC4:
2730 baseType = GraphicsContext3D::INT; 2730 baseType = GL_INT;
2731 length = 4; 2731 length = 4;
2732 break; 2732 break;
2733 case GraphicsContext3D::FLOAT: 2733 case GL_FLOAT:
2734 baseType = GraphicsContext3D::FLOAT; 2734 baseType = GL_FLOAT;
2735 length = 1; 2735 length = 1;
2736 break; 2736 break;
2737 case GraphicsContext3D::FLOAT_VEC2: 2737 case GL_FLOAT_VEC2:
2738 baseType = GraphicsContext3D::FLOAT; 2738 baseType = GL_FLOAT;
2739 length = 2; 2739 length = 2;
2740 break; 2740 break;
2741 case GraphicsContext3D::FLOAT_VEC3: 2741 case GL_FLOAT_VEC3:
2742 baseType = GraphicsContext3D::FLOAT; 2742 baseType = GL_FLOAT;
2743 length = 3; 2743 length = 3;
2744 break; 2744 break;
2745 case GraphicsContext3D::FLOAT_VEC4: 2745 case GL_FLOAT_VEC4:
2746 baseType = GraphicsContext3D::FLOAT; 2746 baseType = GL_FLOAT;
2747 length = 4; 2747 length = 4;
2748 break; 2748 break;
2749 case GraphicsContext3D::FLOAT_MAT2: 2749 case GL_FLOAT_MAT2:
2750 baseType = GraphicsContext3D::FLOAT; 2750 baseType = GL_FLOAT;
2751 length = 4; 2751 length = 4;
2752 break; 2752 break;
2753 case GraphicsContext3D::FLOAT_MAT3: 2753 case GL_FLOAT_MAT3:
2754 baseType = GraphicsContext3D::FLOAT; 2754 baseType = GL_FLOAT;
2755 length = 9; 2755 length = 9;
2756 break; 2756 break;
2757 case GraphicsContext3D::FLOAT_MAT4: 2757 case GL_FLOAT_MAT4:
2758 baseType = GraphicsContext3D::FLOAT; 2758 baseType = GL_FLOAT;
2759 length = 16; 2759 length = 16;
2760 break; 2760 break;
2761 case GraphicsContext3D::SAMPLER_2D: 2761 case GL_SAMPLER_2D:
2762 case GraphicsContext3D::SAMPLER_CUBE: 2762 case GL_SAMPLER_CUBE:
2763 baseType = GraphicsContext3D::INT; 2763 baseType = GL_INT;
2764 length = 1; 2764 length = 1;
2765 break; 2765 break;
2766 default: 2766 default:
2767 // Can't handle this type 2767 // Can't handle this type
2768 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUnif orm", "unhandled type"); 2768 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unhandled type");
2769 return WebGLGetInfo(); 2769 return WebGLGetInfo();
2770 } 2770 }
2771 switch (baseType) { 2771 switch (baseType) {
2772 case GraphicsContext3D::FLOAT: { 2772 case GL_FLOAT: {
2773 GC3Dfloat value[16] = {0}; 2773 GC3Dfloat value[16] = {0};
2774 m_context->getUniformfv(objectOrZero(program), location, val ue); 2774 m_context->getUniformfv(objectOrZero(program), location, val ue);
2775 if (length == 1) 2775 if (length == 1)
2776 return WebGLGetInfo(value[0]); 2776 return WebGLGetInfo(value[0]);
2777 return WebGLGetInfo(Float32Array::create(value, length)); 2777 return WebGLGetInfo(Float32Array::create(value, length));
2778 } 2778 }
2779 case GraphicsContext3D::INT: { 2779 case GL_INT: {
2780 GC3Dint value[4] = {0}; 2780 GC3Dint value[4] = {0};
2781 m_context->getUniformiv(objectOrZero(program), location, val ue); 2781 m_context->getUniformiv(objectOrZero(program), location, val ue);
2782 if (length == 1) 2782 if (length == 1)
2783 return WebGLGetInfo(value[0]); 2783 return WebGLGetInfo(value[0]);
2784 return WebGLGetInfo(Int32Array::create(value, length)); 2784 return WebGLGetInfo(Int32Array::create(value, length));
2785 } 2785 }
2786 case GraphicsContext3D::BOOL: { 2786 case GL_BOOL: {
2787 GC3Dint value[4] = {0}; 2787 GC3Dint value[4] = {0};
2788 m_context->getUniformiv(objectOrZero(program), location, val ue); 2788 m_context->getUniformiv(objectOrZero(program), location, val ue);
2789 if (length > 1) { 2789 if (length > 1) {
2790 bool boolValue[16] = {0}; 2790 bool boolValue[16] = {0};
2791 for (unsigned j = 0; j < length; j++) 2791 for (unsigned j = 0; j < length; j++)
2792 boolValue[j] = static_cast<bool>(value[j]); 2792 boolValue[j] = static_cast<bool>(value[j]);
2793 return WebGLGetInfo(boolValue, length); 2793 return WebGLGetInfo(boolValue, length);
2794 } 2794 }
2795 return WebGLGetInfo(static_cast<bool>(value[0])); 2795 return WebGLGetInfo(static_cast<bool>(value[0]));
2796 } 2796 }
2797 default: 2797 default:
2798 notImplemented(); 2798 notImplemented();
2799 } 2799 }
2800 } 2800 }
2801 } 2801 }
2802 } 2802 }
2803 // If we get here, something went wrong in our unfortunately complex logic a bove 2803 // If we get here, something went wrong in our unfortunately complex logic a bove
2804 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown e rror"); 2804 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error");
2805 return WebGLGetInfo(); 2805 return WebGLGetInfo();
2806 } 2806 }
2807 2807
2808 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL Program* program, const String& name) 2808 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL Program* program, const String& name)
2809 { 2809 {
2810 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) 2810 if (isContextLost() || !validateWebGLObject("getUniformLocation", program))
2811 return 0; 2811 return 0;
2812 if (!validateLocationLength("getUniformLocation", name)) 2812 if (!validateLocationLength("getUniformLocation", name))
2813 return 0; 2813 return 0;
2814 if (!validateString("getUniformLocation", name)) 2814 if (!validateString("getUniformLocation", name))
2815 return 0; 2815 return 0;
2816 if (isPrefixReserved(name)) 2816 if (isPrefixReserved(name))
2817 return 0; 2817 return 0;
2818 if (!program->linkStatus()) { 2818 if (!program->linkStatus()) {
2819 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniformLocat ion", "program not linked"); 2819 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n ot linked");
2820 return 0; 2820 return 0;
2821 } 2821 }
2822 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program ), name); 2822 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program ), name);
2823 if (uniformLocation == -1) 2823 if (uniformLocation == -1)
2824 return 0; 2824 return 0;
2825 return WebGLUniformLocation::create(program, uniformLocation); 2825 return WebGLUniformLocation::create(program, uniformLocation);
2826 } 2826 }
2827 2827
2828 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna me) 2828 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna me)
2829 { 2829 {
2830 if (isContextLost()) 2830 if (isContextLost())
2831 return WebGLGetInfo(); 2831 return WebGLGetInfo();
2832 if (index >= m_maxVertexAttribs) { 2832 if (index >= m_maxVertexAttribs) {
2833 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getVertexAttrib", " index out of range"); 2833 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran ge");
2834 return WebGLGetInfo(); 2834 return WebGLGetInfo();
2835 } 2835 }
2836 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index); 2836 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index);
2837 2837
2838 if (m_angleInstancedArrays && pname == Extensions3D::VERTEX_ATTRIB_ARRAY_DIV ISOR_ANGLE) 2838 if (m_angleInstancedArrays && pname == Extensions3D::VERTEX_ATTRIB_ARRAY_DIV ISOR_ANGLE)
2839 return WebGLGetInfo(state.divisor); 2839 return WebGLGetInfo(state.divisor);
2840 2840
2841 switch (pname) { 2841 switch (pname) {
2842 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 2842 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
2843 if (!state.bufferBinding || !state.bufferBinding->object()) 2843 if (!state.bufferBinding || !state.bufferBinding->object())
2844 return WebGLGetInfo(); 2844 return WebGLGetInfo();
2845 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding)); 2845 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding));
2846 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_ENABLED: 2846 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
2847 return WebGLGetInfo(state.enabled); 2847 return WebGLGetInfo(state.enabled);
2848 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_NORMALIZED: 2848 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
2849 return WebGLGetInfo(state.normalized); 2849 return WebGLGetInfo(state.normalized);
2850 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_SIZE: 2850 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
2851 return WebGLGetInfo(state.size); 2851 return WebGLGetInfo(state.size);
2852 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_STRIDE: 2852 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
2853 return WebGLGetInfo(state.originalStride); 2853 return WebGLGetInfo(state.originalStride);
2854 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_TYPE: 2854 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
2855 return WebGLGetInfo(state.type); 2855 return WebGLGetInfo(state.type);
2856 case GraphicsContext3D::CURRENT_VERTEX_ATTRIB: 2856 case GL_CURRENT_VERTEX_ATTRIB:
2857 return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].valu e, 4)); 2857 return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].valu e, 4));
2858 default: 2858 default:
2859 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttrib", "i nvalid parameter name"); 2859 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttrib", "invalid parameter name");
2860 return WebGLGetInfo(); 2860 return WebGLGetInfo();
2861 } 2861 }
2862 } 2862 }
2863 2863
2864 long long WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname) 2864 long long WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname)
2865 { 2865 {
2866 if (isContextLost()) 2866 if (isContextLost())
2867 return 0; 2867 return 0;
2868 if (pname != GraphicsContext3D::VERTEX_ATTRIB_ARRAY_POINTER) { 2868 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) {
2869 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttribOffse t", "invalid parameter name"); 2869 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttribOffset", "invalid par ameter name");
2870 return 0; 2870 return 0;
2871 } 2871 }
2872 GC3Dsizeiptr result = m_context->getVertexAttribOffset(index, pname); 2872 GC3Dsizeiptr result = m_context->getVertexAttribOffset(index, pname);
2873 return static_cast<long long>(result); 2873 return static_cast<long long>(result);
2874 } 2874 }
2875 2875
2876 void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode) 2876 void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode)
2877 { 2877 {
2878 if (isContextLost()) 2878 if (isContextLost())
2879 return; 2879 return;
2880 bool isValid = false; 2880 bool isValid = false;
2881 switch (target) { 2881 switch (target) {
2882 case GraphicsContext3D::GENERATE_MIPMAP_HINT: 2882 case GL_GENERATE_MIPMAP_HINT:
2883 isValid = true; 2883 isValid = true;
2884 break; 2884 break;
2885 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives 2885 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives
2886 if (m_oesStandardDerivatives) 2886 if (m_oesStandardDerivatives)
2887 isValid = true; 2887 isValid = true;
2888 break; 2888 break;
2889 } 2889 }
2890 if (!isValid) { 2890 if (!isValid) {
2891 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "hint", "invalid targ et"); 2891 synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target");
2892 return; 2892 return;
2893 } 2893 }
2894 m_context->hint(target, mode); 2894 m_context->hint(target, mode);
2895 } 2895 }
2896 2896
2897 GC3Dboolean WebGLRenderingContext::isBuffer(WebGLBuffer* buffer) 2897 GC3Dboolean WebGLRenderingContext::isBuffer(WebGLBuffer* buffer)
2898 { 2898 {
2899 if (!buffer || isContextLost()) 2899 if (!buffer || isContextLost())
2900 return 0; 2900 return 0;
2901 2901
2902 if (!buffer->hasEverBeenBound()) 2902 if (!buffer->hasEverBeenBound())
2903 return 0; 2903 return 0;
2904 2904
2905 return m_context->isBuffer(buffer->object()); 2905 return m_context->isBuffer(buffer->object());
2906 } 2906 }
2907 2907
2908 bool WebGLRenderingContext::isContextLost() 2908 bool WebGLRenderingContext::isContextLost()
2909 { 2909 {
2910 return m_contextLost; 2910 return m_contextLost;
2911 } 2911 }
2912 2912
2913 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) 2913 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap)
2914 { 2914 {
2915 if (isContextLost() || !validateCapability("isEnabled", cap)) 2915 if (isContextLost() || !validateCapability("isEnabled", cap))
2916 return 0; 2916 return 0;
2917 if (cap == GraphicsContext3D::STENCIL_TEST) 2917 if (cap == GL_STENCIL_TEST)
2918 return m_stencilEnabled; 2918 return m_stencilEnabled;
2919 return m_context->isEnabled(cap); 2919 return m_context->isEnabled(cap);
2920 } 2920 }
2921 2921
2922 GC3Dboolean WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer) 2922 GC3Dboolean WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer)
2923 { 2923 {
2924 if (!framebuffer || isContextLost()) 2924 if (!framebuffer || isContextLost())
2925 return 0; 2925 return 0;
2926 2926
2927 if (!framebuffer->hasEverBeenBound()) 2927 if (!framebuffer->hasEverBeenBound())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 2982
2983 m_context->linkProgram(objectOrZero(program)); 2983 m_context->linkProgram(objectOrZero(program));
2984 program->increaseLinkCount(); 2984 program->increaseLinkCount();
2985 } 2985 }
2986 2986
2987 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param) 2987 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param)
2988 { 2988 {
2989 if (isContextLost()) 2989 if (isContextLost())
2990 return; 2990 return;
2991 switch (pname) { 2991 switch (pname) {
2992 case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL: 2992 case GC3D_UNPACK_FLIP_Y_WEBGL:
2993 m_unpackFlipY = param; 2993 m_unpackFlipY = param;
2994 break; 2994 break;
2995 case GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL: 2995 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL:
2996 m_unpackPremultiplyAlpha = param; 2996 m_unpackPremultiplyAlpha = param;
2997 break; 2997 break;
2998 case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: 2998 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL:
2999 if (param == GraphicsContext3D::BROWSER_DEFAULT_WEBGL || param == Graphi csContext3D::NONE) 2999 if (param == GC3D_BROWSER_DEFAULT_WEBGL || param == GL_NONE)
3000 m_unpackColorspaceConversion = static_cast<GC3Denum>(param); 3000 m_unpackColorspaceConversion = static_cast<GC3Denum>(param);
3001 else { 3001 else {
3002 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", " invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL"); 3002 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete r for UNPACK_COLORSPACE_CONVERSION_WEBGL");
3003 return; 3003 return;
3004 } 3004 }
3005 break; 3005 break;
3006 case GraphicsContext3D::PACK_ALIGNMENT: 3006 case GL_PACK_ALIGNMENT:
3007 case GraphicsContext3D::UNPACK_ALIGNMENT: 3007 case GL_UNPACK_ALIGNMENT:
3008 if (param == 1 || param == 2 || param == 4 || param == 8) { 3008 if (param == 1 || param == 2 || param == 4 || param == 8) {
3009 if (pname == GraphicsContext3D::PACK_ALIGNMENT) 3009 if (pname == GL_PACK_ALIGNMENT)
3010 m_packAlignment = param; 3010 m_packAlignment = param;
3011 else // GraphicsContext3D::UNPACK_ALIGNMENT: 3011 else // GL_UNPACK_ALIGNMENT:
3012 m_unpackAlignment = param; 3012 m_unpackAlignment = param;
3013 m_context->pixelStorei(pname, param); 3013 m_context->pixelStorei(pname, param);
3014 } else { 3014 } else {
3015 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", " invalid parameter for alignment"); 3015 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete r for alignment");
3016 return; 3016 return;
3017 } 3017 }
3018 break; 3018 break;
3019 default: 3019 default:
3020 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "pixelStorei", "inval id parameter name"); 3020 synthesizeGLError(GL_INVALID_ENUM, "pixelStorei", "invalid parameter nam e");
3021 return; 3021 return;
3022 } 3022 }
3023 } 3023 }
3024 3024
3025 void WebGLRenderingContext::polygonOffset(GC3Dfloat factor, GC3Dfloat units) 3025 void WebGLRenderingContext::polygonOffset(GC3Dfloat factor, GC3Dfloat units)
3026 { 3026 {
3027 if (isContextLost()) 3027 if (isContextLost())
3028 return; 3028 return;
3029 m_context->polygonOffset(factor, units); 3029 m_context->polygonOffset(factor, units);
3030 } 3030 }
3031 3031
3032 void WebGLRenderingContext::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC 3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels) 3032 void WebGLRenderingContext::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC 3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels)
3033 { 3033 {
3034 if (isContextLost()) 3034 if (isContextLost())
3035 return; 3035 return;
3036 // Due to WebGL's same-origin restrictions, it is not possible to 3036 // Due to WebGL's same-origin restrictions, it is not possible to
3037 // taint the origin using the WebGL API. 3037 // taint the origin using the WebGL API.
3038 ASSERT(canvas()->originClean()); 3038 ASSERT(canvas()->originClean());
3039 // Validate input parameters. 3039 // Validate input parameters.
3040 if (!pixels) { 3040 if (!pixels) {
3041 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "readPixels", "no de stination ArrayBufferView"); 3041 synthesizeGLError(GL_INVALID_VALUE, "readPixels", "no destination ArrayB ufferView");
3042 return; 3042 return;
3043 } 3043 }
3044 switch (format) { 3044 switch (format) {
3045 case GraphicsContext3D::ALPHA: 3045 case GL_ALPHA:
3046 case GraphicsContext3D::RGB: 3046 case GL_RGB:
3047 case GraphicsContext3D::RGBA: 3047 case GL_RGBA:
3048 break; 3048 break;
3049 default: 3049 default:
3050 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "readPixels", "invali d format"); 3050 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid format");
3051 return; 3051 return;
3052 } 3052 }
3053 switch (type) { 3053 switch (type) {
3054 case GraphicsContext3D::UNSIGNED_BYTE: 3054 case GL_UNSIGNED_BYTE:
3055 case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: 3055 case GL_UNSIGNED_SHORT_5_6_5:
3056 case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: 3056 case GL_UNSIGNED_SHORT_4_4_4_4:
3057 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: 3057 case GL_UNSIGNED_SHORT_5_5_5_1:
3058 break; 3058 break;
3059 default: 3059 default:
3060 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "readPixels", "invali d type"); 3060 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid type");
3061 return; 3061 return;
3062 } 3062 }
3063 if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED _BYTE) { 3063 if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) {
3064 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "f ormat not RGBA or type not UNSIGNED_BYTE"); 3064 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format not RGBA o r type not UNSIGNED_BYTE");
3065 return; 3065 return;
3066 } 3066 }
3067 // Validate array type against pixel type. 3067 // Validate array type against pixel type.
3068 if (pixels->getType() != ArrayBufferView::TypeUint8) { 3068 if (pixels->getType() != ArrayBufferView::TypeUint8) {
3069 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A rrayBufferView not Uint8Array"); 3069 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n ot Uint8Array");
3070 return; 3070 return;
3071 } 3071 }
3072 const char* reason = "framebuffer incomplete"; 3072 const char* reason = "framebuffer incomplete";
3073 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 3073 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) {
3074 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "rea dPixels", reason); 3074 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason );
3075 return; 3075 return;
3076 } 3076 }
3077 // Calculate array size, taking into consideration of PACK_ALIGNMENT. 3077 // Calculate array size, taking into consideration of PACK_ALIGNMENT.
3078 unsigned int totalBytesRequired = 0; 3078 unsigned int totalBytesRequired = 0;
3079 unsigned int padding = 0; 3079 unsigned int padding = 0;
3080 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_packAlignment, &totalBytesRequired, &padding); 3080 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_packAlignment, &totalBytesRequired, &padding);
3081 if (error != GraphicsContext3D::NO_ERROR) { 3081 if (error != GL_NO_ERROR) {
3082 synthesizeGLError(error, "readPixels", "invalid dimensions"); 3082 synthesizeGLError(error, "readPixels", "invalid dimensions");
3083 return; 3083 return;
3084 } 3084 }
3085 if (pixels->byteLength() < totalBytesRequired) { 3085 if (pixels->byteLength() < totalBytesRequired) {
3086 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A rrayBufferView not large enough for dimensions"); 3086 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n ot large enough for dimensions");
3087 return; 3087 return;
3088 } 3088 }
3089 3089
3090 clearIfComposited(); 3090 clearIfComposited();
3091 void* data = pixels->baseAddress(); 3091 void* data = pixels->baseAddress();
3092 3092
3093 { 3093 {
3094 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBin ding.get()); 3094 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBin ding.get());
3095 m_context->readPixels(x, y, width, height, format, type, data); 3095 m_context->readPixels(x, y, width, height, format, type, data);
3096 } 3096 }
(...skipping 11 matching lines...) Expand all
3108 pixels += padding; 3108 pixels += padding;
3109 } 3109 }
3110 } 3110 }
3111 #endif 3111 #endif
3112 } 3112 }
3113 3113
3114 void WebGLRenderingContext::renderbufferStorage(GC3Denum target, GC3Denum intern alformat, GC3Dsizei width, GC3Dsizei height) 3114 void WebGLRenderingContext::renderbufferStorage(GC3Denum target, GC3Denum intern alformat, GC3Dsizei width, GC3Dsizei height)
3115 { 3115 {
3116 if (isContextLost()) 3116 if (isContextLost())
3117 return; 3117 return;
3118 if (target != GraphicsContext3D::RENDERBUFFER) { 3118 if (target != GL_RENDERBUFFER) {
3119 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage" , "invalid target"); 3119 synthesizeGLError(GL_INVALID_ENUM, "renderbufferStorage", "invalid targe t");
3120 return; 3120 return;
3121 } 3121 }
3122 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { 3122 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) {
3123 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferSto rage", "no bound renderbuffer"); 3123 synthesizeGLError(GL_INVALID_OPERATION, "renderbufferStorage", "no bound renderbuffer");
3124 return; 3124 return;
3125 } 3125 }
3126 if (!validateSize("renderbufferStorage", width, height)) 3126 if (!validateSize("renderbufferStorage", width, height))
3127 return; 3127 return;
3128 switch (internalformat) { 3128 switch (internalformat) {
3129 case GraphicsContext3D::DEPTH_COMPONENT16: 3129 case GL_DEPTH_COMPONENT16:
3130 case GraphicsContext3D::RGBA4: 3130 case GL_RGBA4:
3131 case GraphicsContext3D::RGB5_A1: 3131 case GL_RGB5_A1:
3132 case GraphicsContext3D::RGB565: 3132 case GL_RGB565:
3133 case GraphicsContext3D::STENCIL_INDEX8: 3133 case GL_STENCIL_INDEX8:
3134 m_context->renderbufferStorage(target, internalformat, width, height); 3134 m_context->renderbufferStorage(target, internalformat, width, height);
3135 m_renderbufferBinding->setInternalFormat(internalformat); 3135 m_renderbufferBinding->setInternalFormat(internalformat);
3136 m_renderbufferBinding->setSize(width, height); 3136 m_renderbufferBinding->setSize(width, height);
3137 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_context.get()); 3137 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_context.get());
3138 break; 3138 break;
3139 case GraphicsContext3D::DEPTH_STENCIL: 3139 case GL_DEPTH_STENCIL_OES:
3140 if (isDepthStencilSupported()) { 3140 if (isDepthStencilSupported()) {
3141 m_context->renderbufferStorage(target, Extensions3D::DEPTH24_STENCIL 8, width, height); 3141 m_context->renderbufferStorage(target, Extensions3D::DEPTH24_STENCIL 8, width, height);
3142 } else { 3142 } else {
3143 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(target, m_renderbufferBinding.get()); 3143 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(target, m_renderbufferBinding.get());
3144 if (!emulatedStencilBuffer) { 3144 if (!emulatedStencilBuffer) {
3145 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "renderbuffe rStorage", "out of memory"); 3145 synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out of memory");
3146 return; 3146 return;
3147 } 3147 }
3148 m_context->renderbufferStorage(target, GraphicsContext3D::DEPTH_COMP ONENT16, width, height); 3148 m_context->renderbufferStorage(target, GL_DEPTH_COMPONENT16, width, height);
3149 m_context->bindRenderbuffer(target, objectOrZero(emulatedStencilBuff er)); 3149 m_context->bindRenderbuffer(target, objectOrZero(emulatedStencilBuff er));
3150 m_context->renderbufferStorage(target, GraphicsContext3D::STENCIL_IN DEX8, width, height); 3150 m_context->renderbufferStorage(target, GL_STENCIL_INDEX8, width, hei ght);
3151 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi ng.get())); 3151 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi ng.get()));
3152 emulatedStencilBuffer->setSize(width, height); 3152 emulatedStencilBuffer->setSize(width, height);
3153 emulatedStencilBuffer->setInternalFormat(GraphicsContext3D::STENCIL_ INDEX8); 3153 emulatedStencilBuffer->setInternalFormat(GL_STENCIL_INDEX8);
3154 } 3154 }
3155 m_renderbufferBinding->setSize(width, height); 3155 m_renderbufferBinding->setSize(width, height);
3156 m_renderbufferBinding->setInternalFormat(internalformat); 3156 m_renderbufferBinding->setInternalFormat(internalformat);
3157 break; 3157 break;
3158 default: 3158 default:
3159 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage" , "invalid internalformat"); 3159 synthesizeGLError(GL_INVALID_ENUM, "renderbufferStorage", "invalid inter nalformat");
3160 return; 3160 return;
3161 } 3161 }
3162 applyStencilTest(); 3162 applyStencilTest();
3163 } 3163 }
3164 3164
3165 void WebGLRenderingContext::sampleCoverage(GC3Dfloat value, GC3Dboolean invert) 3165 void WebGLRenderingContext::sampleCoverage(GC3Dfloat value, GC3Dboolean invert)
3166 { 3166 {
3167 if (isContextLost()) 3167 if (isContextLost())
3168 return; 3168 return;
3169 m_context->sampleCoverage(value, invert); 3169 m_context->sampleCoverage(value, invert);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3202 m_context->stencilFunc(func, ref, mask); 3202 m_context->stencilFunc(func, ref, mask);
3203 } 3203 }
3204 3204
3205 void WebGLRenderingContext::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC 3Dint ref, GC3Duint mask) 3205 void WebGLRenderingContext::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC 3Dint ref, GC3Duint mask)
3206 { 3206 {
3207 if (isContextLost()) 3207 if (isContextLost())
3208 return; 3208 return;
3209 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) 3209 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func))
3210 return; 3210 return;
3211 switch (face) { 3211 switch (face) {
3212 case GraphicsContext3D::FRONT_AND_BACK: 3212 case GL_FRONT_AND_BACK:
3213 m_stencilFuncRef = ref; 3213 m_stencilFuncRef = ref;
3214 m_stencilFuncRefBack = ref; 3214 m_stencilFuncRefBack = ref;
3215 m_stencilFuncMask = mask; 3215 m_stencilFuncMask = mask;
3216 m_stencilFuncMaskBack = mask; 3216 m_stencilFuncMaskBack = mask;
3217 break; 3217 break;
3218 case GraphicsContext3D::FRONT: 3218 case GL_FRONT:
3219 m_stencilFuncRef = ref; 3219 m_stencilFuncRef = ref;
3220 m_stencilFuncMask = mask; 3220 m_stencilFuncMask = mask;
3221 break; 3221 break;
3222 case GraphicsContext3D::BACK: 3222 case GL_BACK:
3223 m_stencilFuncRefBack = ref; 3223 m_stencilFuncRefBack = ref;
3224 m_stencilFuncMaskBack = mask; 3224 m_stencilFuncMaskBack = mask;
3225 break; 3225 break;
3226 default: 3226 default:
3227 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilFuncSeparate" , "invalid face"); 3227 synthesizeGLError(GL_INVALID_ENUM, "stencilFuncSeparate", "invalid face" );
3228 return; 3228 return;
3229 } 3229 }
3230 m_context->stencilFuncSeparate(face, func, ref, mask); 3230 m_context->stencilFuncSeparate(face, func, ref, mask);
3231 } 3231 }
3232 3232
3233 void WebGLRenderingContext::stencilMask(GC3Duint mask) 3233 void WebGLRenderingContext::stencilMask(GC3Duint mask)
3234 { 3234 {
3235 if (isContextLost()) 3235 if (isContextLost())
3236 return; 3236 return;
3237 m_stencilMask = mask; 3237 m_stencilMask = mask;
3238 m_stencilMaskBack = mask; 3238 m_stencilMaskBack = mask;
3239 m_context->stencilMask(mask); 3239 m_context->stencilMask(mask);
3240 } 3240 }
3241 3241
3242 void WebGLRenderingContext::stencilMaskSeparate(GC3Denum face, GC3Duint mask) 3242 void WebGLRenderingContext::stencilMaskSeparate(GC3Denum face, GC3Duint mask)
3243 { 3243 {
3244 if (isContextLost()) 3244 if (isContextLost())
3245 return; 3245 return;
3246 switch (face) { 3246 switch (face) {
3247 case GraphicsContext3D::FRONT_AND_BACK: 3247 case GL_FRONT_AND_BACK:
3248 m_stencilMask = mask; 3248 m_stencilMask = mask;
3249 m_stencilMaskBack = mask; 3249 m_stencilMaskBack = mask;
3250 break; 3250 break;
3251 case GraphicsContext3D::FRONT: 3251 case GL_FRONT:
3252 m_stencilMask = mask; 3252 m_stencilMask = mask;
3253 break; 3253 break;
3254 case GraphicsContext3D::BACK: 3254 case GL_BACK:
3255 m_stencilMaskBack = mask; 3255 m_stencilMaskBack = mask;
3256 break; 3256 break;
3257 default: 3257 default:
3258 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilMaskSeparate" , "invalid face"); 3258 synthesizeGLError(GL_INVALID_ENUM, "stencilMaskSeparate", "invalid face" );
3259 return; 3259 return;
3260 } 3260 }
3261 m_context->stencilMaskSeparate(face, mask); 3261 m_context->stencilMaskSeparate(face, mask);
3262 } 3262 }
3263 3263
3264 void WebGLRenderingContext::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zp ass) 3264 void WebGLRenderingContext::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zp ass)
3265 { 3265 {
3266 if (isContextLost()) 3266 if (isContextLost())
3267 return; 3267 return;
3268 m_context->stencilOp(fail, zfail, zpass); 3268 m_context->stencilOp(fail, zfail, zpass);
(...skipping 17 matching lines...) Expand all
3286 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); 3286 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat));
3287 m_context->texImage2D(target, level, internalformat, width, height, 3287 m_context->texImage2D(target, level, internalformat, width, height,
3288 border, format, type, pixels); 3288 border, format, type, pixels);
3289 tex->setLevelInfo(target, level, internalformat, width, height, type); 3289 tex->setLevelInfo(target, level, internalformat, width, height, type);
3290 } 3290 }
3291 3291
3292 void WebGLRenderingContext::texImage2DImpl(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContex t3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionS tate& exceptionState) 3292 void WebGLRenderingContext::texImage2DImpl(GC3Denum target, GC3Dint level, GC3De num internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContex t3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionS tate& exceptionState)
3293 { 3293 {
3294 // All calling functions check isContextLost, so a duplicate check is not ne eded here. 3294 // All calling functions check isContextLost, so a duplicate check is not ne eded here.
3295 Vector<uint8_t> data; 3295 Vector<uint8_t> data;
3296 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip lyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); 3296 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip lyAlpha, m_unpackColorspaceConversion == GL_NONE);
3297 if (!imageExtractor.extractSucceeded()) { 3297 if (!imageExtractor.extractSucceeded()) {
3298 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad i mage data"); 3298 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data");
3299 return; 3299 return;
3300 } 3300 }
3301 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF ormat(); 3301 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF ormat();
3302 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); 3302 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp();
3303 const void* imagePixelData = imageExtractor.imagePixelData(); 3303 const void* imagePixelData = imageExtractor.imagePixelData();
3304 3304
3305 bool needConversion = true; 3305 bool needConversion = true;
3306 if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == Graphics Context3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == Gr aphicsContext3D::AlphaDoNothing && !flipY) 3306 if (type == GL_UNSIGNED_BYTE && sourceDataFormat == GraphicsContext3D::DataF ormatRGBA8 && format == GL_RGBA && alphaOp == GraphicsContext3D::AlphaDoNothing && !flipY)
3307 needConversion = false; 3307 needConversion = false;
3308 else { 3308 else {
3309 if (!m_context->packImageData(image, imagePixelData, format, type, flipY , alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe ight(), imageExtractor.imageSourceUnpackAlignment(), data)) { 3309 if (!m_context->packImageData(image, imagePixelData, format, type, flipY , alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe ight(), imageExtractor.imageSourceUnpackAlignment(), data)) {
3310 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "p ackImage error"); 3310 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "packImage error") ;
3311 return; 3311 return;
3312 } 3312 }
3313 } 3313 }
3314 3314
3315 if (m_unpackAlignment != 1) 3315 if (m_unpackAlignment != 1)
3316 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 3316 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
3317 texImage2DBase(target, level, internalformat, image->width(), image->height( ), 0, format, type, needConversion ? data.data() : imagePixelData, exceptionStat e); 3317 texImage2DBase(target, level, internalformat, image->width(), image->height( ), 0, format, type, needConversion ? data.data() : imagePixelData, exceptionStat e);
3318 if (m_unpackAlignment != 1) 3318 if (m_unpackAlignment != 1)
3319 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3319 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
3320 } 3320 }
3321 3321
3322 bool WebGLRenderingContext::validateTexFunc(const char* functionName, TexFuncVal idationFunctionType functionType, TexFuncValidationSourceType sourceType, GC3Den um target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei he ight, GC3Dint border, GC3Denum format, GC3Denum type, GC3Dint xoffset, GC3Dint y offset) 3322 bool WebGLRenderingContext::validateTexFunc(const char* functionName, TexFuncVal idationFunctionType functionType, TexFuncValidationSourceType sourceType, GC3Den um target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei he ight, GC3Dint border, GC3Denum format, GC3Denum type, GC3Dint xoffset, GC3Dint y offset)
3323 { 3323 {
3324 if (!validateTexFuncParameters(functionName, functionType, target, level, in ternalformat, width, height, border, format, type)) 3324 if (!validateTexFuncParameters(functionName, functionType, target, level, in ternalformat, width, height, border, format, type))
3325 return false; 3325 return false;
3326 3326
3327 WebGLTexture* texture = validateTextureBinding(functionName, target, true); 3327 WebGLTexture* texture = validateTextureBinding(functionName, target, true);
3328 if (!texture) 3328 if (!texture)
3329 return false; 3329 return false;
3330 3330
3331 if (functionType == NotTexSubImage2D) { 3331 if (functionType == NotTexSubImage2D) {
3332 if (level && WebGLTexture::isNPOT(width, height)) { 3332 if (level && WebGLTexture::isNPOT(width, height)) {
3333 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel > 0 not power of 2"); 3333 synthesizeGLError(GL_INVALID_VALUE, functionName, "level > 0 not pow er of 2");
3334 return false; 3334 return false;
3335 } 3335 }
3336 // For SourceArrayBufferView, function validateTexFuncData() would handl e whether to validate the SettableTexFormat 3336 // For SourceArrayBufferView, function validateTexFuncData() would handl e whether to validate the SettableTexFormat
3337 // by checking if the ArrayBufferView is null or not. 3337 // by checking if the ArrayBufferView is null or not.
3338 if (sourceType != SourceArrayBufferView) { 3338 if (sourceType != SourceArrayBufferView) {
3339 if (!validateSettableTexFormat(functionName, format)) 3339 if (!validateSettableTexFormat(functionName, format))
3340 return false; 3340 return false;
3341 } 3341 }
3342 } else { 3342 } else {
3343 if (!validateSettableTexFormat(functionName, format)) 3343 if (!validateSettableTexFormat(functionName, format))
3344 return false; 3344 return false;
3345 if (!validateSize(functionName, xoffset, yoffset)) 3345 if (!validateSize(functionName, xoffset, yoffset))
3346 return false; 3346 return false;
3347 // Before checking if it is in the range, check if overflow happens firs t. 3347 // Before checking if it is in the range, check if overflow happens firs t.
3348 if (xoffset + width < 0 || yoffset + height < 0) { 3348 if (xoffset + width < 0 || yoffset + height < 0) {
3349 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "b ad dimensions"); 3349 synthesizeGLError(GL_INVALID_VALUE, functionName, "bad dimensions");
3350 return false; 3350 return false;
3351 } 3351 }
3352 if (xoffset + width > texture->getWidth(target, level) || yoffset + heig ht > texture->getHeight(target, level)) { 3352 if (xoffset + width > texture->getWidth(target, level) || yoffset + heig ht > texture->getHeight(target, level)) {
3353 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "d imensions out of range"); 3353 synthesizeGLError(GL_INVALID_VALUE, functionName, "dimensions out of range");
3354 return false; 3354 return false;
3355 } 3355 }
3356 if (texture->getInternalFormat(target, level) != format || texture->getT ype(target, level) != type) { 3356 if (texture->getInternalFormat(target, level) != format || texture->getT ype(target, level) != type) {
3357 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type and format do not match texture"); 3357 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type and form at do not match texture");
3358 return false; 3358 return false;
3359 } 3359 }
3360 } 3360 }
3361 3361
3362 return true; 3362 return true;
3363 } 3363 }
3364 3364
3365 PassRefPtr<Image> WebGLRenderingContext::drawImageIntoBuffer(Image* image, int w idth, int height, int deviceScaleFactor) 3365 PassRefPtr<Image> WebGLRenderingContext::drawImageIntoBuffer(Image* image, int w idth, int height, int deviceScaleFactor)
3366 { 3366 {
3367 IntSize size(width, height); 3367 IntSize size(width, height);
3368 size.scale(deviceScaleFactor); 3368 size.scale(deviceScaleFactor);
3369 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); 3369 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
3370 if (!buf) { 3370 if (!buf) {
3371 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out o f memory"); 3371 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory");
3372 return 0; 3372 return 0;
3373 } 3373 }
3374 3374
3375 IntRect srcRect(IntPoint(), image->size()); 3375 IntRect srcRect(IntPoint(), image->size());
3376 IntRect destRect(0, 0, size.width(), size.height()); 3376 IntRect destRect(0, 0, size.width(), size.height());
3377 buf->context()->drawImage(image, destRect, srcRect); 3377 buf->context()->drawImage(image, destRect, srcRect);
3378 return buf->copyImage(ImageBuffer::fastCopyImageMode()); 3378 return buf->copyImage(ImageBuffer::fastCopyImageMode());
3379 } 3379 }
3380 3380
3381 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3381 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
(...skipping 10 matching lines...) Expand all
3392 if (!m_context->extractTextureData(width, height, format, type, 3392 if (!m_context->extractTextureData(width, height, format, type,
3393 m_unpackAlignment, 3393 m_unpackAlignment,
3394 m_unpackFlipY, m_unpackPremultiplyAlp ha, 3394 m_unpackFlipY, m_unpackPremultiplyAlp ha,
3395 data, 3395 data,
3396 tempData)) 3396 tempData))
3397 return; 3397 return;
3398 data = tempData.data(); 3398 data = tempData.data();
3399 changeUnpackAlignment = true; 3399 changeUnpackAlignment = true;
3400 } 3400 }
3401 if (changeUnpackAlignment) 3401 if (changeUnpackAlignment)
3402 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 3402 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
3403 texImage2DBase(target, level, internalformat, width, height, border, format, type, data, exceptionState); 3403 texImage2DBase(target, level, internalformat, width, height, border, format, type, data, exceptionState);
3404 if (changeUnpackAlignment) 3404 if (changeUnpackAlignment)
3405 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3405 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
3406 } 3406 }
3407 3407
3408 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3408 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
3409 GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionState& exception State) 3409 GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionState& exception State)
3410 { 3410 {
3411 if (isContextLost() || !pixels || !validateTexFunc("texImage2D", NotTexSubIm age2D, SourceImageData, target, level, internalformat, pixels->width(), pixels-> height(), 0, format, type, 0, 0)) 3411 if (isContextLost() || !pixels || !validateTexFunc("texImage2D", NotTexSubIm age2D, SourceImageData, target, level, internalformat, pixels->width(), pixels-> height(), 0, format, type, 0, 0))
3412 return; 3412 return;
3413 Vector<uint8_t> data; 3413 Vector<uint8_t> data;
3414 bool needConversion = true; 3414 bool needConversion = true;
3415 // The data from ImageData is always of format RGBA8. 3415 // The data from ImageData is always of format RGBA8.
3416 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required. 3416 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required.
3417 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GraphicsContext 3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE) 3417 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GL_RGBA && type == GL_UNSIGNED_BYTE)
3418 needConversion = false; 3418 needConversion = false;
3419 else { 3419 else {
3420 if (!m_context->extractImageData(pixels->data()->data(), pixels->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { 3420 if (!m_context->extractImageData(pixels->data()->data(), pixels->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
3421 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "b ad image data"); 3421 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data");
3422 return; 3422 return;
3423 } 3423 }
3424 } 3424 }
3425 if (m_unpackAlignment != 1) 3425 if (m_unpackAlignment != 1)
3426 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 3426 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
3427 texImage2DBase(target, level, internalformat, pixels->width(), pixels->heigh t(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), exc eptionState); 3427 texImage2DBase(target, level, internalformat, pixels->width(), pixels->heigh t(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), exc eptionState);
3428 if (m_unpackAlignment != 1) 3428 if (m_unpackAlignment != 1)
3429 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3429 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
3430 } 3430 }
3431 3431
3432 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3432 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
3433 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& exc eptionState) 3433 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& exc eptionState)
3434 { 3434 {
3435 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except ionState)) 3435 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except ionState))
3436 return; 3436 return;
3437 3437
3438 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image- >renderer()); 3438 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image- >renderer());
3439 if (imageForRender->isSVGImage()) 3439 if (imageForRender->isSVGImage())
3440 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width( ), image->height(), canvas()->deviceScaleFactor()); 3440 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width( ), image->height(), canvas()->deviceScaleFactor());
3441 3441
3442 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag eForRender->height(), 0, format, type, 0, 0)) 3442 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag eForRender->height(), 0, format, type, 0, 0))
3443 return; 3443 return;
3444 3444
3445 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g et(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, exceptionState); 3445 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g et(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha, exceptionState);
3446 } 3446 }
3447 3447
3448 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3448 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
3449 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e xceptionState) 3449 GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionState& e xceptionState)
3450 { 3450 {
3451 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)) 3451 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))
3452 return; 3452 return;
3453 3453
3454 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); 3454 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
3455 // If possible, copy from the canvas element directly to the texture 3455 // If possible, copy from the canvas element directly to the texture
3456 // via the GPU, without a read-back to system memory. 3456 // via the GPU, without a read-back to system memory.
3457 if (GraphicsContext3D::TEXTURE_2D == target && texture) { 3457 if (GL_TEXTURE_2D == target && texture) {
3458 if (!canvas->is3D()) { 3458 if (!canvas->is3D()) {
3459 ImageBuffer* buffer = canvas->buffer(); 3459 ImageBuffer* buffer = canvas->buffer();
3460 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), textur e->object(), internalformat, type, 3460 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), textur e->object(), internalformat, type,
3461 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3461 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3462 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type); 3462 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type);
3463 return; 3463 return;
3464 } 3464 }
3465 } else { 3465 } else {
3466 WebGLRenderingContext* gl = toWebGLRenderingContext(canvas->renderin gContext()); 3466 WebGLRenderingContext* gl = toWebGLRenderingContext(canvas->renderin gContext());
3467 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(*m_context.get( ), texture->object(), internalformat, type, 3467 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(*m_context.get( ), texture->object(), internalformat, type,
3468 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3468 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3469 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type); 3469 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type);
3470 return; 3470 return;
3471 } 3471 }
3472 } 3472 }
3473 } 3473 }
3474 3474
3475 RefPtr<ImageData> imageData = canvas->getImageData(); 3475 RefPtr<ImageData> imageData = canvas->getImageData();
3476 if (imageData) 3476 if (imageData)
3477 texImage2D(target, level, internalformat, format, type, imageData.get(), exceptionState); 3477 texImage2D(target, level, internalformat, format, type, imageData.get(), exceptionState);
3478 else 3478 else
3479 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyA lpha, exceptionState); 3479 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyA lpha, exceptionState);
3480 } 3480 }
3481 3481
3482 PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* vid eo, BackingStoreCopy backingStoreCopy) 3482 PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* vid eo, BackingStoreCopy backingStoreCopy)
3483 { 3483 {
3484 IntSize size(video->videoWidth(), video->videoHeight()); 3484 IntSize size(video->videoWidth(), video->videoHeight());
3485 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); 3485 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
3486 if (!buf) { 3486 if (!buf) {
3487 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out o f memory"); 3487 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory");
3488 return 0; 3488 return 0;
3489 } 3489 }
3490 IntRect destRect(0, 0, size.width(), size.height()); 3490 IntRect destRect(0, 0, size.width(), size.height());
3491 // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback. 3491 // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback.
3492 video->paintCurrentFrameInContext(buf->context(), destRect); 3492 video->paintCurrentFrameInContext(buf->context(), destRect);
3493 return buf->copyImage(backingStoreCopy); 3493 return buf->copyImage(backingStoreCopy);
3494 } 3494 }
3495 3495
3496 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, 3496 void WebGLRenderingContext::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat,
3497 GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionState& exc eptionState) 3497 GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionState& exc eptionState)
3498 { 3498 {
3499 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except ionState) 3499 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except ionState)
3500 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0)) 3500 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0))
3501 return; 3501 return;
3502 3502
3503 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible. 3503 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible.
3504 // Otherwise, it will fall back to the normal SW path. 3504 // Otherwise, it will fall back to the normal SW path.
3505 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); 3505 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
3506 if (GraphicsContext3D::TEXTURE_2D == target && texture) { 3506 if (GL_TEXTURE_2D == target && texture) {
3507 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3507 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3508 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type); 3508 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type);
3509 return; 3509 return;
3510 } 3510 }
3511 } 3511 }
3512 3512
3513 // Normal pure SW path. 3513 // Normal pure SW path.
3514 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e()); 3514 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e());
3515 if (!image) 3515 if (!image)
3516 return; 3516 return;
3517 texImage2DImpl(target, level, internalformat, format, type, image.get(), Gra phicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, exception State); 3517 texImage2DImpl(target, level, internalformat, format, type, image.get(), Gra phicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, exception State);
3518 } 3518 }
3519 3519
3520 void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfl oat paramf, GC3Dint parami, bool isFloat) 3520 void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfl oat paramf, GC3Dint parami, bool isFloat)
3521 { 3521 {
3522 if (isContextLost()) 3522 if (isContextLost())
3523 return; 3523 return;
3524 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); 3524 WebGLTexture* tex = validateTextureBinding("texParameter", target, false);
3525 if (!tex) 3525 if (!tex)
3526 return; 3526 return;
3527 switch (pname) { 3527 switch (pname) {
3528 case GraphicsContext3D::TEXTURE_MIN_FILTER: 3528 case GL_TEXTURE_MIN_FILTER:
3529 case GraphicsContext3D::TEXTURE_MAG_FILTER: 3529 case GL_TEXTURE_MAG_FILTER:
3530 break; 3530 break;
3531 case GraphicsContext3D::TEXTURE_WRAP_S: 3531 case GL_TEXTURE_WRAP_S:
3532 case GraphicsContext3D::TEXTURE_WRAP_T: 3532 case GL_TEXTURE_WRAP_T:
3533 if ((isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT) 3533 if ((isFloat && paramf != GL_CLAMP_TO_EDGE && paramf != GL_MIRRORED_REPE AT && paramf != GL_REPEAT)
3534 || (!isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT)) { 3534 || (!isFloat && parami != GL_CLAMP_TO_EDGE && parami != GL_MIRRORED_ REPEAT && parami != GL_REPEAT)) {
3535 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", " invalid parameter"); 3535 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid paramete r");
3536 return; 3536 return;
3537 } 3537 }
3538 break; 3538 break;
3539 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic 3539 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic
3540 if (!m_extTextureFilterAnisotropic) { 3540 if (!m_extTextureFilterAnisotropic) {
3541 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", " invalid parameter, EXT_texture_filter_anisotropic not enabled"); 3541 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid paramete r, EXT_texture_filter_anisotropic not enabled");
3542 return; 3542 return;
3543 } 3543 }
3544 break; 3544 break;
3545 default: 3545 default:
3546 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "texParameter", "inva lid parameter name"); 3546 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid parameter na me");
3547 return; 3547 return;
3548 } 3548 }
3549 if (isFloat) { 3549 if (isFloat) {
3550 tex->setParameterf(pname, paramf); 3550 tex->setParameterf(pname, paramf);
3551 m_context->texParameterf(target, pname, paramf); 3551 m_context->texParameterf(target, pname, paramf);
3552 } else { 3552 } else {
3553 tex->setParameteri(pname, parami); 3553 tex->setParameteri(pname, parami);
3554 m_context->texParameteri(target, pname, parami); 3554 m_context->texParameteri(target, pname, parami);
3555 } 3555 }
3556 } 3556 }
(...skipping 26 matching lines...) Expand all
3583 ASSERT(tex->getHeight(target, level) >= (yoffset + height)); 3583 ASSERT(tex->getHeight(target, level) >= (yoffset + height));
3584 ASSERT(tex->getInternalFormat(target, level) == format); 3584 ASSERT(tex->getInternalFormat(target, level) == format);
3585 ASSERT(tex->getType(target, level) == type); 3585 ASSERT(tex->getType(target, level) == type);
3586 m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, for mat, type, pixels); 3586 m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, for mat, type, pixels);
3587 } 3587 }
3588 3588
3589 void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, Gr aphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha , ExceptionState& exceptionState) 3589 void WebGLRenderingContext::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC 3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, Gr aphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha , ExceptionState& exceptionState)
3590 { 3590 {
3591 // All calling functions check isContextLost, so a duplicate check is not ne eded here. 3591 // All calling functions check isContextLost, so a duplicate check is not ne eded here.
3592 Vector<uint8_t> data; 3592 Vector<uint8_t> data;
3593 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip lyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); 3593 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip lyAlpha, m_unpackColorspaceConversion == GL_NONE);
3594 if (!imageExtractor.extractSucceeded()) { 3594 if (!imageExtractor.extractSucceeded()) {
3595 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "ba d image"); 3595 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "bad image");
3596 return; 3596 return;
3597 } 3597 }
3598 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF ormat(); 3598 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF ormat();
3599 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); 3599 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp();
3600 const void* imagePixelData = imageExtractor.imagePixelData(); 3600 const void* imagePixelData = imageExtractor.imagePixelData();
3601 3601
3602 bool needConversion = true; 3602 bool needConversion = true;
3603 if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == Graphics Context3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == Gr aphicsContext3D::AlphaDoNothing && !flipY) 3603 if (type == GL_UNSIGNED_BYTE && sourceDataFormat == GraphicsContext3D::DataF ormatRGBA8 && format == GL_RGBA && alphaOp == GraphicsContext3D::AlphaDoNothing && !flipY)
3604 needConversion = false; 3604 needConversion = false;
3605 else { 3605 else {
3606 if (!m_context->packImageData(image, imagePixelData, format, type, flipY , alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe ight(), imageExtractor.imageSourceUnpackAlignment(), data)) { 3606 if (!m_context->packImageData(image, imagePixelData, format, type, flipY , alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe ight(), imageExtractor.imageSourceUnpackAlignment(), data)) {
3607 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "b ad image data"); 3607 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data");
3608 return; 3608 return;
3609 } 3609 }
3610 } 3610 }
3611 3611
3612 if (m_unpackAlignment != 1) 3612 if (m_unpackAlignment != 1)
3613 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 3613 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
3614 texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->he ight(), format, type, needConversion ? data.data() : imagePixelData, exceptionS tate); 3614 texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->he ight(), format, type, needConversion ? data.data() : imagePixelData, exceptionS tate);
3615 if (m_unpackAlignment != 1) 3615 if (m_unpackAlignment != 1)
3616 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3616 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
3617 } 3617 }
3618 3618
3619 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, 3619 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset,
3620 GC3Dsizei width, GC3Dsizei height, 3620 GC3Dsizei width, GC3Dsizei height,
3621 GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionState& exc eptionState) 3621 GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionState& exc eptionState)
3622 { 3622 {
3623 if (isContextLost() || !validateTexFuncData("texSubImage2D", level, width, h eight, format, type, pixels, NullNotAllowed) 3623 if (isContextLost() || !validateTexFuncData("texSubImage2D", level, width, h eight, format, type, pixels, NullNotAllowed)
3624 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferVie w, target, level, format, width, height, 0, format, type, xoffset, yoffset)) 3624 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferVie w, target, level, format, width, height, 0, format, type, xoffset, yoffset))
3625 return; 3625 return;
3626 void* data = pixels->baseAddress(); 3626 void* data = pixels->baseAddress();
3627 Vector<uint8_t> tempData; 3627 Vector<uint8_t> tempData;
3628 bool changeUnpackAlignment = false; 3628 bool changeUnpackAlignment = false;
3629 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { 3629 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
3630 if (!m_context->extractTextureData(width, height, format, type, 3630 if (!m_context->extractTextureData(width, height, format, type,
3631 m_unpackAlignment, 3631 m_unpackAlignment,
3632 m_unpackFlipY, m_unpackPremultiplyAlp ha, 3632 m_unpackFlipY, m_unpackPremultiplyAlp ha,
3633 data, 3633 data,
3634 tempData)) 3634 tempData))
3635 return; 3635 return;
3636 data = tempData.data(); 3636 data = tempData.data();
3637 changeUnpackAlignment = true; 3637 changeUnpackAlignment = true;
3638 } 3638 }
3639 if (changeUnpackAlignment) 3639 if (changeUnpackAlignment)
3640 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 3640 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
3641 texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, ty pe, data, exceptionState); 3641 texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, ty pe, data, exceptionState);
3642 if (changeUnpackAlignment) 3642 if (changeUnpackAlignment)
3643 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3643 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
3644 } 3644 }
3645 3645
3646 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, 3646 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset,
3647 GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionState& exception State) 3647 GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionState& exception State)
3648 { 3648 {
3649 if (isContextLost() || !pixels || !validateTexFunc("texSubImage2D", TexSubIm age2D, SourceImageData, target, level, format, pixels->width(), pixels->height( ), 0, format, type, xoffset, yoffset)) 3649 if (isContextLost() || !pixels || !validateTexFunc("texSubImage2D", TexSubIm age2D, SourceImageData, target, level, format, pixels->width(), pixels->height( ), 0, format, type, xoffset, yoffset))
3650 return; 3650 return;
3651 3651
3652 Vector<uint8_t> data; 3652 Vector<uint8_t> data;
3653 bool needConversion = true; 3653 bool needConversion = true;
3654 // The data from ImageData is always of format RGBA8. 3654 // The data from ImageData is always of format RGBA8.
3655 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required. 3655 // No conversion is needed if destination format is RGBA and type is USIGNED _BYTE and no Flip or Premultiply operation is required.
3656 if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED _BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha) 3656 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !m_unpackFlipY && !m_un packPremultiplyAlpha)
3657 needConversion = false; 3657 needConversion = false;
3658 else { 3658 else {
3659 if (!m_context->extractImageData(pixels->data()->data(), pixels->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { 3659 if (!m_context->extractImageData(pixels->data()->data(), pixels->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
3660 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data"); 3660 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "bad image data ");
3661 return; 3661 return;
3662 } 3662 }
3663 } 3663 }
3664 if (m_unpackAlignment != 1) 3664 if (m_unpackAlignment != 1)
3665 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); 3665 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
3666 texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels-> height(), format, type, needConversion ? data.data() : pixels->data()->data(), e xceptionState); 3666 texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels-> height(), format, type, needConversion ? data.data() : pixels->data()->data(), e xceptionState);
3667 if (m_unpackAlignment != 1) 3667 if (m_unpackAlignment != 1)
3668 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig nment); 3668 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
3669 } 3669 }
3670 3670
3671 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset, 3671 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Din t xoffset, GC3Dint yoffset,
3672 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& exc eptionState) 3672 GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionState& exc eptionState)
3673 { 3673 {
3674 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc eptionState)) 3674 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc eptionState))
3675 return; 3675 return;
3676 3676
3677 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image- >renderer()); 3677 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image- >renderer());
3678 if (imageForRender->isSVGImage()) 3678 if (imageForRender->isSVGImage())
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3710 return; 3710 return;
3711 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, exce ptionState); 3711 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, exce ptionState);
3712 } 3712 }
3713 3713
3714 void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, GC3D float x) 3714 void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, GC3D float x)
3715 { 3715 {
3716 if (isContextLost() || !location) 3716 if (isContextLost() || !location)
3717 return; 3717 return;
3718 3718
3719 if (location->program() != m_currentProgram) { 3719 if (location->program() != m_currentProgram) {
3720 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1f", "lo cation not for current program"); 3720 synthesizeGLError(GL_INVALID_OPERATION, "uniform1f", "location not for c urrent program");
3721 return; 3721 return;
3722 } 3722 }
3723 3723
3724 m_context->uniform1f(location->location(), x); 3724 m_context->uniform1f(location->location(), x);
3725 } 3725 }
3726 3726
3727 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Flo at32Array* v) 3727 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Flo at32Array* v)
3728 { 3728 {
3729 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, 1)) 3729 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, 1))
3730 return; 3730 return;
3731 3731
3732 m_context->uniform1fv(location->location(), v->length(), v->data()); 3732 m_context->uniform1fv(location->location(), v->length(), v->data());
3733 } 3733 }
3734 3734
3735 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size) 3735 void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size)
3736 { 3736 {
3737 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, size, 1)) 3737 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v, size, 1))
3738 return; 3738 return;
3739 3739
3740 m_context->uniform1fv(location->location(), size, v); 3740 m_context->uniform1fv(location->location(), size, v);
3741 } 3741 }
3742 3742
3743 void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, GC3D int x) 3743 void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, GC3D int x)
3744 { 3744 {
3745 if (isContextLost() || !location) 3745 if (isContextLost() || !location)
3746 return; 3746 return;
3747 3747
3748 if (location->program() != m_currentProgram) { 3748 if (location->program() != m_currentProgram) {
3749 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform1i", "lo cation not for current program"); 3749 synthesizeGLError(GL_INVALID_OPERATION, "uniform1i", "location not for c urrent program");
3750 return; 3750 return;
3751 } 3751 }
3752 3752
3753 m_context->uniform1i(location->location(), x); 3753 m_context->uniform1i(location->location(), x);
3754 } 3754 }
3755 3755
3756 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int 32Array* v) 3756 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int 32Array* v)
3757 { 3757 {
3758 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, 1)) 3758 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, 1))
3759 return; 3759 return;
3760 3760
3761 m_context->uniform1iv(location->location(), v->length(), v->data()); 3761 m_context->uniform1iv(location->location(), v->length(), v->data());
3762 } 3762 }
3763 3763
3764 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size) 3764 void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size)
3765 { 3765 {
3766 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, size, 1)) 3766 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v, size, 1))
3767 return; 3767 return;
3768 3768
3769 m_context->uniform1iv(location->location(), size, v); 3769 m_context->uniform1iv(location->location(), size, v);
3770 } 3770 }
3771 3771
3772 void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y) 3772 void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y)
3773 { 3773 {
3774 if (isContextLost() || !location) 3774 if (isContextLost() || !location)
3775 return; 3775 return;
3776 3776
3777 if (location->program() != m_currentProgram) { 3777 if (location->program() != m_currentProgram) {
3778 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2f", "lo cation not for current program"); 3778 synthesizeGLError(GL_INVALID_OPERATION, "uniform2f", "location not for c urrent program");
3779 return; 3779 return;
3780 } 3780 }
3781 3781
3782 m_context->uniform2f(location->location(), x, y); 3782 m_context->uniform2f(location->location(), x, y);
3783 } 3783 }
3784 3784
3785 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Flo at32Array* v) 3785 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Flo at32Array* v)
3786 { 3786 {
3787 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, 2)) 3787 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, 2))
3788 return; 3788 return;
3789 3789
3790 m_context->uniform2fv(location->location(), v->length() / 2, v->data()); 3790 m_context->uniform2fv(location->location(), v->length() / 2, v->data());
3791 } 3791 }
3792 3792
3793 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size) 3793 void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size)
3794 { 3794 {
3795 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, size, 2)) 3795 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v, size, 2))
3796 return; 3796 return;
3797 3797
3798 m_context->uniform2fv(location->location(), size / 2, v); 3798 m_context->uniform2fv(location->location(), size / 2, v);
3799 } 3799 }
3800 3800
3801 void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y) 3801 void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y)
3802 { 3802 {
3803 if (isContextLost() || !location) 3803 if (isContextLost() || !location)
3804 return; 3804 return;
3805 3805
3806 if (location->program() != m_currentProgram) { 3806 if (location->program() != m_currentProgram) {
3807 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform2i", "lo cation not for current program"); 3807 synthesizeGLError(GL_INVALID_OPERATION, "uniform2i", "location not for c urrent program");
3808 return; 3808 return;
3809 } 3809 }
3810 3810
3811 m_context->uniform2i(location->location(), x, y); 3811 m_context->uniform2i(location->location(), x, y);
3812 } 3812 }
3813 3813
3814 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int 32Array* v) 3814 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int 32Array* v)
3815 { 3815 {
3816 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, 2)) 3816 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, 2))
3817 return; 3817 return;
3818 3818
3819 m_context->uniform2iv(location->location(), v->length() / 2, v->data()); 3819 m_context->uniform2iv(location->location(), v->length() / 2, v->data());
3820 } 3820 }
3821 3821
3822 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size) 3822 void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size)
3823 { 3823 {
3824 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, size, 2)) 3824 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v, size, 2))
3825 return; 3825 return;
3826 3826
3827 m_context->uniform2iv(location->location(), size / 2, v); 3827 m_context->uniform2iv(location->location(), size / 2, v);
3828 } 3828 }
3829 3829
3830 void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z) 3830 void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z)
3831 { 3831 {
3832 if (isContextLost() || !location) 3832 if (isContextLost() || !location)
3833 return; 3833 return;
3834 3834
3835 if (location->program() != m_currentProgram) { 3835 if (location->program() != m_currentProgram) {
3836 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3f", "lo cation not for current program"); 3836 synthesizeGLError(GL_INVALID_OPERATION, "uniform3f", "location not for c urrent program");
3837 return; 3837 return;
3838 } 3838 }
3839 3839
3840 m_context->uniform3f(location->location(), x, y, z); 3840 m_context->uniform3f(location->location(), x, y, z);
3841 } 3841 }
3842 3842
3843 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Flo at32Array* v) 3843 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Flo at32Array* v)
3844 { 3844 {
3845 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, 3)) 3845 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, 3))
3846 return; 3846 return;
3847 3847
3848 m_context->uniform3fv(location->location(), v->length() / 3, v->data()); 3848 m_context->uniform3fv(location->location(), v->length() / 3, v->data());
3849 } 3849 }
3850 3850
3851 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size) 3851 void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size)
3852 { 3852 {
3853 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, size, 3)) 3853 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v, size, 3))
3854 return; 3854 return;
3855 3855
3856 m_context->uniform3fv(location->location(), size / 3, v); 3856 m_context->uniform3fv(location->location(), size / 3, v);
3857 } 3857 }
3858 3858
3859 void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z) 3859 void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z)
3860 { 3860 {
3861 if (isContextLost() || !location) 3861 if (isContextLost() || !location)
3862 return; 3862 return;
3863 3863
3864 if (location->program() != m_currentProgram) { 3864 if (location->program() != m_currentProgram) {
3865 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform3i", "lo cation not for current program"); 3865 synthesizeGLError(GL_INVALID_OPERATION, "uniform3i", "location not for c urrent program");
3866 return; 3866 return;
3867 } 3867 }
3868 3868
3869 m_context->uniform3i(location->location(), x, y, z); 3869 m_context->uniform3i(location->location(), x, y, z);
3870 } 3870 }
3871 3871
3872 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int 32Array* v) 3872 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int 32Array* v)
3873 { 3873 {
3874 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, 3)) 3874 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, 3))
3875 return; 3875 return;
3876 3876
3877 m_context->uniform3iv(location->location(), v->length() / 3, v->data()); 3877 m_context->uniform3iv(location->location(), v->length() / 3, v->data());
3878 } 3878 }
3879 3879
3880 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size) 3880 void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, GC3 Dint* v, GC3Dsizei size)
3881 { 3881 {
3882 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, size, 3)) 3882 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v, size, 3))
3883 return; 3883 return;
3884 3884
3885 m_context->uniform3iv(location->location(), size / 3, v); 3885 m_context->uniform3iv(location->location(), size / 3, v);
3886 } 3886 }
3887 3887
3888 void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) 3888 void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, GC3D float x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w)
3889 { 3889 {
3890 if (isContextLost() || !location) 3890 if (isContextLost() || !location)
3891 return; 3891 return;
3892 3892
3893 if (location->program() != m_currentProgram) { 3893 if (location->program() != m_currentProgram) {
3894 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4f", "lo cation not for current program"); 3894 synthesizeGLError(GL_INVALID_OPERATION, "uniform4f", "location not for c urrent program");
3895 return; 3895 return;
3896 } 3896 }
3897 3897
3898 m_context->uniform4f(location->location(), x, y, z, w); 3898 m_context->uniform4f(location->location(), x, y, z, w);
3899 } 3899 }
3900 3900
3901 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Flo at32Array* v) 3901 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Flo at32Array* v)
3902 { 3902 {
3903 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, 4)) 3903 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, 4))
3904 return; 3904 return;
3905 3905
3906 m_context->uniform4fv(location->location(), v->length() / 4, v->data()); 3906 m_context->uniform4fv(location->location(), v->length() / 4, v->data());
3907 } 3907 }
3908 3908
3909 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size) 3909 void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, GC3 Dfloat* v, GC3Dsizei size)
3910 { 3910 {
3911 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, size, 4)) 3911 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v, size, 4))
3912 return; 3912 return;
3913 3913
3914 m_context->uniform4fv(location->location(), size / 4, v); 3914 m_context->uniform4fv(location->location(), size / 4, v);
3915 } 3915 }
3916 3916
3917 void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z, GC3Dint w) 3917 void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, GC3D int x, GC3Dint y, GC3Dint z, GC3Dint w)
3918 { 3918 {
3919 if (isContextLost() || !location) 3919 if (isContextLost() || !location)
3920 return; 3920 return;
3921 3921
3922 if (location->program() != m_currentProgram) { 3922 if (location->program() != m_currentProgram) {
3923 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "uniform4i", "lo cation not for current program"); 3923 synthesizeGLError(GL_INVALID_OPERATION, "uniform4i", "location not for c urrent program");
3924 return; 3924 return;
3925 } 3925 }
3926 3926
3927 m_context->uniform4i(location->location(), x, y, z, w); 3927 m_context->uniform4i(location->location(), x, y, z, w);
3928 } 3928 }
3929 3929
3930 void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int 32Array* v) 3930 void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int 32Array* v)
3931 { 3931 {
3932 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, 4)) 3932 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v, 4))
3933 return; 3933 return;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3986 } 3986 }
3987 3987
3988 void WebGLRenderingContext::useProgram(WebGLProgram* program) 3988 void WebGLRenderingContext::useProgram(WebGLProgram* program)
3989 { 3989 {
3990 bool deleted; 3990 bool deleted;
3991 if (!checkObjectToBeBound("useProgram", program, deleted)) 3991 if (!checkObjectToBeBound("useProgram", program, deleted))
3992 return; 3992 return;
3993 if (deleted) 3993 if (deleted)
3994 program = 0; 3994 program = 0;
3995 if (program && !program->linkStatus()) { 3995 if (program && !program->linkStatus()) {
3996 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "useProgram", "p rogram not valid"); 3996 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid ");
3997 return; 3997 return;
3998 } 3998 }
3999 if (m_currentProgram != program) { 3999 if (m_currentProgram != program) {
4000 if (m_currentProgram) 4000 if (m_currentProgram)
4001 m_currentProgram->onDetached(graphicsContext3D()); 4001 m_currentProgram->onDetached(graphicsContext3D());
4002 m_currentProgram = program; 4002 m_currentProgram = program;
4003 m_context->useProgram(objectOrZero(program)); 4003 m_context->useProgram(objectOrZero(program));
4004 if (program) 4004 if (program)
4005 program->onAttached(); 4005 program->onAttached();
4006 } 4006 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
4071 void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, GC3Dfloat* v, GC3Dsi zei size) 4071 void WebGLRenderingContext::vertexAttrib4fv(GC3Duint index, GC3Dfloat* v, GC3Dsi zei size)
4072 { 4072 {
4073 vertexAttribfvImpl("vertexAttrib4fv", index, v, size, 4); 4073 vertexAttribfvImpl("vertexAttrib4fv", index, v, size, 4);
4074 } 4074 }
4075 4075
4076 void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC 3Denum type, GC3Dboolean normalized, GC3Dsizei stride, long long offset) 4076 void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC 3Denum type, GC3Dboolean normalized, GC3Dsizei stride, long long offset)
4077 { 4077 {
4078 if (isContextLost()) 4078 if (isContextLost())
4079 return; 4079 return;
4080 switch (type) { 4080 switch (type) {
4081 case GraphicsContext3D::BYTE: 4081 case GL_BYTE:
4082 case GraphicsContext3D::UNSIGNED_BYTE: 4082 case GL_UNSIGNED_BYTE:
4083 case GraphicsContext3D::SHORT: 4083 case GL_SHORT:
4084 case GraphicsContext3D::UNSIGNED_SHORT: 4084 case GL_UNSIGNED_SHORT:
4085 case GraphicsContext3D::FLOAT: 4085 case GL_FLOAT:
4086 break; 4086 break;
4087 default: 4087 default:
4088 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer" , "invalid type"); 4088 synthesizeGLError(GL_INVALID_ENUM, "vertexAttribPointer", "invalid type" );
4089 return; 4089 return;
4090 } 4090 }
4091 if (index >= m_maxVertexAttribs) { 4091 if (index >= m_maxVertexAttribs) {
4092 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer ", "index out of range"); 4092 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribPointer", "index out of range");
4093 return; 4093 return;
4094 } 4094 }
4095 if (size < 1 || size > 4 || stride < 0 || stride > 255 || offset < 0) { 4095 if (size < 1 || size > 4 || stride < 0 || stride > 255 || offset < 0) {
4096 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribPointer ", "bad size, stride or offset"); 4096 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribPointer", "bad size, st ride or offset");
4097 return; 4097 return;
4098 } 4098 }
4099 if (!m_boundArrayBuffer) { 4099 if (!m_boundArrayBuffer) {
4100 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi nter", "no bound ARRAY_BUFFER"); 4100 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "no bound ARRAY_BUFFER");
4101 return; 4101 return;
4102 } 4102 }
4103 // Determine the number of elements the bound buffer can hold, given the off set, size, type and stride 4103 // Determine the number of elements the bound buffer can hold, given the off set, size, type and stride
4104 unsigned int typeSize = sizeInBytes(type); 4104 unsigned int typeSize = sizeInBytes(type);
4105 if (!typeSize) { 4105 if (!typeSize) {
4106 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "vertexAttribPointer" , "invalid type"); 4106 synthesizeGLError(GL_INVALID_ENUM, "vertexAttribPointer", "invalid type" );
4107 return; 4107 return;
4108 } 4108 }
4109 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) { 4109 if ((stride % typeSize) || (static_cast<GC3Dintptr>(offset) % typeSize)) {
4110 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "vertexAttribPoi nter", "stride or offset not valid for type"); 4110 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type");
4111 return; 4111 return;
4112 } 4112 }
4113 GC3Dsizei bytesPerElement = size * typeSize; 4113 GC3Dsizei bytesPerElement = size * typeSize;
4114 4114
4115 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer); 4115 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GC3Dintptr>(offset), m_boundArrayBuffer);
4116 m_context->vertexAttribPointer(index, size, type, normalized, stride, static _cast<GC3Dintptr>(offset)); 4116 m_context->vertexAttribPointer(index, size, type, normalized, stride, static _cast<GC3Dintptr>(offset));
4117 } 4117 }
4118 4118
4119 void WebGLRenderingContext::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint di visor) 4119 void WebGLRenderingContext::vertexAttribDivisorANGLE(GC3Duint index, GC3Duint di visor)
4120 { 4120 {
4121 if (isContextLost()) 4121 if (isContextLost())
4122 return; 4122 return;
4123 4123
4124 if (index >= m_maxVertexAttribs) { 4124 if (index >= m_maxVertexAttribs) {
4125 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribDivisor ANGLE", "index out of range"); 4125 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range");
4126 return; 4126 return;
4127 } 4127 }
4128 4128
4129 m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor); 4129 m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor);
4130 m_context->extensions()->vertexAttribDivisorANGLE(index, divisor); 4130 m_context->extensions()->vertexAttribDivisorANGLE(index, divisor);
4131 } 4131 }
4132 4132
4133 void WebGLRenderingContext::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3D sizei height) 4133 void WebGLRenderingContext::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3D sizei height)
4134 { 4134 {
4135 if (isContextLost()) 4135 if (isContextLost())
4136 return; 4136 return;
4137 if (!validateSize("viewport", width, height)) 4137 if (!validateSize("viewport", width, height))
4138 return; 4138 return;
4139 m_context->viewport(x, y, width, height); 4139 m_context->viewport(x, y, width, height);
4140 } 4140 }
4141 4141
4142 void WebGLRenderingContext::forceLostContext(WebGLRenderingContext::LostContextM ode mode) 4142 void WebGLRenderingContext::forceLostContext(WebGLRenderingContext::LostContextM ode mode)
4143 { 4143 {
4144 if (isContextLost()) { 4144 if (isContextLost()) {
4145 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "loseContext", " context already lost"); 4145 synthesizeGLError(GL_INVALID_OPERATION, "loseContext", "context already lost");
4146 return; 4146 return;
4147 } 4147 }
4148 4148
4149 m_contextGroup->loseContextGroup(mode); 4149 m_contextGroup->loseContextGroup(mode);
4150 } 4150 }
4151 4151
4152 void WebGLRenderingContext::loseContextImpl(WebGLRenderingContext::LostContextMo de mode) 4152 void WebGLRenderingContext::loseContextImpl(WebGLRenderingContext::LostContextMo de mode)
4153 { 4153 {
4154 if (isContextLost()) 4154 if (isContextLost())
4155 return; 4155 return;
(...skipping 19 matching lines...) Expand all
4175 ExtensionTracker* tracker = m_extensions[i]; 4175 ExtensionTracker* tracker = m_extensions[i];
4176 tracker->loseExtension(); 4176 tracker->loseExtension();
4177 } 4177 }
4178 4178
4179 removeAllCompressedTextureFormats(); 4179 removeAllCompressedTextureFormats();
4180 4180
4181 if (mode != RealLostContext) 4181 if (mode != RealLostContext)
4182 destroyGraphicsContext3D(); 4182 destroyGraphicsContext3D();
4183 4183
4184 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons ole: DontDisplayInConsole; 4184 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons ole: DontDisplayInConsole;
4185 synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL, "loseContext", "con text lost", display); 4185 synthesizeGLError(GC3D_CONTEXT_LOST_WEBGL, "loseContext", "context lost", di splay);
4186 4186
4187 // Don't allow restoration unless the context lost event has both been 4187 // Don't allow restoration unless the context lost event has both been
4188 // dispatched and its default behavior prevented. 4188 // dispatched and its default behavior prevented.
4189 m_restoreAllowed = false; 4189 m_restoreAllowed = false;
4190 4190
4191 // Always defer the dispatch of the context lost event, to implement 4191 // Always defer the dispatch of the context lost event, to implement
4192 // the spec behavior of queueing a task. 4192 // the spec behavior of queueing a task.
4193 m_dispatchContextLostEventTimer.startOneShot(0); 4193 m_dispatchContextLostEventTimer.startOneShot(0);
4194 } 4194 }
4195 4195
4196 void WebGLRenderingContext::forceRestoreContext() 4196 void WebGLRenderingContext::forceRestoreContext()
4197 { 4197 {
4198 if (!isContextLost()) { 4198 if (!isContextLost()) {
4199 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreContext" , "context not lost"); 4199 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context not l ost");
4200 return; 4200 return;
4201 } 4201 }
4202 4202
4203 if (!m_restoreAllowed) { 4203 if (!m_restoreAllowed) {
4204 if (m_contextLostMode == SyntheticLostContext) 4204 if (m_contextLostMode == SyntheticLostContext)
4205 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "restoreCont ext", "context restoration not allowed"); 4205 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r estoration not allowed");
4206 return; 4206 return;
4207 } 4207 }
4208 4208
4209 if (!m_restoreTimer.isActive()) 4209 if (!m_restoreTimer.isActive())
4210 m_restoreTimer.startOneShot(0); 4210 m_restoreTimer.startOneShot(0);
4211 } 4211 }
4212 4212
4213 blink::WebLayer* WebGLRenderingContext::platformLayer() const 4213 blink::WebLayer* WebGLRenderingContext::platformLayer() const
4214 { 4214 {
4215 return m_drawingBuffer->platformLayer(); 4215 return m_drawingBuffer->platformLayer();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4261 WebGLGetInfo WebGLRenderingContext::getBooleanParameter(GC3Denum pname) 4261 WebGLGetInfo WebGLRenderingContext::getBooleanParameter(GC3Denum pname)
4262 { 4262 {
4263 GC3Dboolean value = 0; 4263 GC3Dboolean value = 0;
4264 if (!isContextLost()) 4264 if (!isContextLost())
4265 m_context->getBooleanv(pname, &value); 4265 m_context->getBooleanv(pname, &value);
4266 return WebGLGetInfo(static_cast<bool>(value)); 4266 return WebGLGetInfo(static_cast<bool>(value));
4267 } 4267 }
4268 4268
4269 WebGLGetInfo WebGLRenderingContext::getBooleanArrayParameter(GC3Denum pname) 4269 WebGLGetInfo WebGLRenderingContext::getBooleanArrayParameter(GC3Denum pname)
4270 { 4270 {
4271 if (pname != GraphicsContext3D::COLOR_WRITEMASK) { 4271 if (pname != GL_COLOR_WRITEMASK) {
4272 notImplemented(); 4272 notImplemented();
4273 return WebGLGetInfo(0, 0); 4273 return WebGLGetInfo(0, 0);
4274 } 4274 }
4275 GC3Dboolean value[4] = {0}; 4275 GC3Dboolean value[4] = {0};
4276 if (!isContextLost()) 4276 if (!isContextLost())
4277 m_context->getBooleanv(pname, value); 4277 m_context->getBooleanv(pname, value);
4278 bool boolValue[4]; 4278 bool boolValue[4];
4279 for (int ii = 0; ii < 4; ++ii) 4279 for (int ii = 0; ii < 4; ++ii)
4280 boolValue[ii] = static_cast<bool>(value[ii]); 4280 boolValue[ii] = static_cast<bool>(value[ii]);
4281 return WebGLGetInfo(boolValue, 4); 4281 return WebGLGetInfo(boolValue, 4);
(...skipping 23 matching lines...) Expand all
4305 return WebGLGetInfo(static_cast<unsigned int>(value)); 4305 return WebGLGetInfo(static_cast<unsigned int>(value));
4306 } 4306 }
4307 4307
4308 WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(GC3Denum pname) 4308 WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(GC3Denum pname)
4309 { 4309 {
4310 GC3Dfloat value[4] = {0}; 4310 GC3Dfloat value[4] = {0};
4311 if (!isContextLost()) 4311 if (!isContextLost())
4312 m_context->getFloatv(pname, value); 4312 m_context->getFloatv(pname, value);
4313 unsigned length = 0; 4313 unsigned length = 0;
4314 switch (pname) { 4314 switch (pname) {
4315 case GraphicsContext3D::ALIASED_POINT_SIZE_RANGE: 4315 case GL_ALIASED_POINT_SIZE_RANGE:
4316 case GraphicsContext3D::ALIASED_LINE_WIDTH_RANGE: 4316 case GL_ALIASED_LINE_WIDTH_RANGE:
4317 case GraphicsContext3D::DEPTH_RANGE: 4317 case GL_DEPTH_RANGE:
4318 length = 2; 4318 length = 2;
4319 break; 4319 break;
4320 case GraphicsContext3D::BLEND_COLOR: 4320 case GL_BLEND_COLOR:
4321 case GraphicsContext3D::COLOR_CLEAR_VALUE: 4321 case GL_COLOR_CLEAR_VALUE:
4322 length = 4; 4322 length = 4;
4323 break; 4323 break;
4324 default: 4324 default:
4325 notImplemented(); 4325 notImplemented();
4326 } 4326 }
4327 return WebGLGetInfo(Float32Array::create(value, length)); 4327 return WebGLGetInfo(Float32Array::create(value, length));
4328 } 4328 }
4329 4329
4330 WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(GC3Denum pname) 4330 WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(GC3Denum pname)
4331 { 4331 {
4332 GC3Dint value[4] = {0}; 4332 GC3Dint value[4] = {0};
4333 if (!isContextLost()) 4333 if (!isContextLost())
4334 m_context->getIntegerv(pname, value); 4334 m_context->getIntegerv(pname, value);
4335 unsigned length = 0; 4335 unsigned length = 0;
4336 switch (pname) { 4336 switch (pname) {
4337 case GraphicsContext3D::MAX_VIEWPORT_DIMS: 4337 case GL_MAX_VIEWPORT_DIMS:
4338 length = 2; 4338 length = 2;
4339 break; 4339 break;
4340 case GraphicsContext3D::SCISSOR_BOX: 4340 case GL_SCISSOR_BOX:
4341 case GraphicsContext3D::VIEWPORT: 4341 case GL_VIEWPORT:
4342 length = 4; 4342 length = 4;
4343 break; 4343 break;
4344 default: 4344 default:
4345 notImplemented(); 4345 notImplemented();
4346 } 4346 }
4347 return WebGLGetInfo(Int32Array::create(value, length)); 4347 return WebGLGetInfo(Int32Array::create(value, length));
4348 } 4348 }
4349 4349
4350 void WebGLRenderingContext::handleTextureCompleteness(const char* functionName, bool prepareToDraw) 4350 void WebGLRenderingContext::handleTextureCompleteness(const char* functionName, bool prepareToDraw)
4351 { 4351 {
(...skipping 18 matching lines...) Expand all
4370 + " is not renderable. It maybe non-power-of-2 and have inco mpatible texture filtering or is not 'texture complete'." 4370 + " is not renderable. It maybe non-power-of-2 and have inco mpatible texture filtering or is not 'texture complete'."
4371 + " 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."); 4371 + " 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.");
4372 emitGLWarning(functionName, msg.utf8().data()); 4372 emitGLWarning(functionName, msg.utf8().data());
4373 tex2D = m_blackTexture2D.get(); 4373 tex2D = m_blackTexture2D.get();
4374 texCubeMap = m_blackTextureCubeMap.get(); 4374 texCubeMap = m_blackTextureCubeMap.get();
4375 } else { 4375 } else {
4376 tex2D = m_textureUnits[ii].m_texture2DBinding.get(); 4376 tex2D = m_textureUnits[ii].m_texture2DBinding.get();
4377 texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); 4377 texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get();
4378 } 4378 }
4379 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_te xture2DBinding->needToUseBlackTexture(flag)) 4379 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_te xture2DBinding->needToUseBlackTexture(flag))
4380 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZe ro(tex2D)); 4380 m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D));
4381 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii] .m_textureCubeMapBinding->needToUseBlackTexture(flag)) 4381 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii] .m_textureCubeMapBinding->needToUseBlackTexture(flag))
4382 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, obje ctOrZero(texCubeMap)); 4382 m_context->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texCube Map));
4383 } 4383 }
4384 } 4384 }
4385 if (resetActiveUnit) 4385 if (resetActiveUnit)
4386 m_context->activeTexture(m_activeTextureUnit); 4386 m_context->activeTexture(m_activeTextureUnit);
4387 } 4387 }
4388 4388
4389 void WebGLRenderingContext::createFallbackBlackTextures1x1() 4389 void WebGLRenderingContext::createFallbackBlackTextures1x1()
4390 { 4390 {
4391 // All calling functions check isContextLost, so a duplicate check is not ne eded here. 4391 // All calling functions check isContextLost, so a duplicate check is not ne eded here.
4392 unsigned char black[] = {0, 0, 0, 255}; 4392 unsigned char black[] = {0, 0, 0, 255};
4393 m_blackTexture2D = createTexture(); 4393 m_blackTexture2D = createTexture();
4394 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_blackTexture2D->obje ct()); 4394 m_context->bindTexture(GL_TEXTURE_2D, m_blackTexture2D->object());
4395 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::R GBA, 1, 1, 4395 m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1,
4396 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); 4396 0, GL_RGBA, GL_UNSIGNED_BYTE, black);
4397 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); 4397 m_context->bindTexture(GL_TEXTURE_2D, 0);
4398 m_blackTextureCubeMap = createTexture(); 4398 m_blackTextureCubeMap = createTexture();
4399 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, m_blackTextureCu beMap->object()); 4399 m_context->bindTexture(GL_TEXTURE_CUBE_MAP, m_blackTextureCubeMap->object()) ;
4400 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X, 0, Gra phicsContext3D::RGBA, 1, 1, 4400 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 1, 1,
4401 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); 4401 0, GL_RGBA, GL_UNSIGNED_BYTE, black);
4402 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X, 0, Gra phicsContext3D::RGBA, 1, 1, 4402 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 1, 1,
4403 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); 4403 0, GL_RGBA, GL_UNSIGNED_BYTE, black);
4404 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y, 0, Gra phicsContext3D::RGBA, 1, 1, 4404 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 1, 1,
4405 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); 4405 0, GL_RGBA, GL_UNSIGNED_BYTE, black);
4406 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, Gra phicsContext3D::RGBA, 1, 1, 4406 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 1, 1,
4407 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); 4407 0, GL_RGBA, GL_UNSIGNED_BYTE, black);
4408 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z, 0, Gra phicsContext3D::RGBA, 1, 1, 4408 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 1, 1,
4409 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); 4409 0, GL_RGBA, GL_UNSIGNED_BYTE, black);
4410 m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, Gra phicsContext3D::RGBA, 1, 1, 4410 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 1, 1,
4411 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNE D_BYTE, black); 4411 0, GL_RGBA, GL_UNSIGNED_BYTE, black);
4412 m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, 0); 4412 m_context->bindTexture(GL_TEXTURE_CUBE_MAP, 0);
4413 } 4413 }
4414 4414
4415 bool WebGLRenderingContext::isTexInternalFormatColorBufferCombinationValid(GC3De num texInternalFormat, 4415 bool WebGLRenderingContext::isTexInternalFormatColorBufferCombinationValid(GC3De num texInternalFormat,
4416 GC3De num colorBufferFormat) 4416 GC3De num colorBufferFormat)
4417 { 4417 {
4418 unsigned need = GraphicsContext3D::getChannelBitsByFormat(texInternalFormat) ; 4418 unsigned need = GraphicsContext3D::getChannelBitsByFormat(texInternalFormat) ;
4419 unsigned have = GraphicsContext3D::getChannelBitsByFormat(colorBufferFormat) ; 4419 unsigned have = GraphicsContext3D::getChannelBitsByFormat(colorBufferFormat) ;
4420 return (need & have) == need; 4420 return (need & have) == need;
4421 } 4421 }
4422 4422
4423 GC3Denum WebGLRenderingContext::boundFramebufferColorFormat() 4423 GC3Denum WebGLRenderingContext::boundFramebufferColorFormat()
4424 { 4424 {
4425 if (m_framebufferBinding && m_framebufferBinding->object()) 4425 if (m_framebufferBinding && m_framebufferBinding->object())
4426 return m_framebufferBinding->colorBufferFormat(); 4426 return m_framebufferBinding->colorBufferFormat();
4427 if (m_attributes.alpha) 4427 if (m_attributes.alpha)
4428 return GraphicsContext3D::RGBA; 4428 return GL_RGBA;
4429 return GraphicsContext3D::RGB; 4429 return GL_RGB;
4430 } 4430 }
4431 4431
4432 int WebGLRenderingContext::boundFramebufferWidth() 4432 int WebGLRenderingContext::boundFramebufferWidth()
4433 { 4433 {
4434 if (m_framebufferBinding && m_framebufferBinding->object()) 4434 if (m_framebufferBinding && m_framebufferBinding->object())
4435 return m_framebufferBinding->colorBufferWidth(); 4435 return m_framebufferBinding->colorBufferWidth();
4436 return m_drawingBuffer->size().width(); 4436 return m_drawingBuffer->size().width();
4437 } 4437 }
4438 4438
4439 int WebGLRenderingContext::boundFramebufferHeight() 4439 int WebGLRenderingContext::boundFramebufferHeight()
4440 { 4440 {
4441 if (m_framebufferBinding && m_framebufferBinding->object()) 4441 if (m_framebufferBinding && m_framebufferBinding->object())
4442 return m_framebufferBinding->colorBufferHeight(); 4442 return m_framebufferBinding->colorBufferHeight();
4443 return m_drawingBuffer->size().height(); 4443 return m_drawingBuffer->size().height();
4444 } 4444 }
4445 4445
4446 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* function Name, GC3Denum target, bool useSixEnumsForCubeMap) 4446 WebGLTexture* WebGLRenderingContext::validateTextureBinding(const char* function Name, GC3Denum target, bool useSixEnumsForCubeMap)
4447 { 4447 {
4448 WebGLTexture* tex = 0; 4448 WebGLTexture* tex = 0;
4449 switch (target) { 4449 switch (target) {
4450 case GraphicsContext3D::TEXTURE_2D: 4450 case GL_TEXTURE_2D:
4451 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); 4451 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get();
4452 break; 4452 break;
4453 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: 4453 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4454 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: 4454 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4455 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: 4455 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4456 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: 4456 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4457 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z: 4457 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4458 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: 4458 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4459 if (!useSixEnumsForCubeMap) { 4459 if (!useSixEnumsForCubeMap) {
4460 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "in valid texture target"); 4460 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture ta rget");
4461 return 0; 4461 return 0;
4462 } 4462 }
4463 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); 4463 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get();
4464 break; 4464 break;
4465 case GraphicsContext3D::TEXTURE_CUBE_MAP: 4465 case GL_TEXTURE_CUBE_MAP:
4466 if (useSixEnumsForCubeMap) { 4466 if (useSixEnumsForCubeMap) {
4467 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "in valid texture target"); 4467 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture ta rget");
4468 return 0; 4468 return 0;
4469 } 4469 }
4470 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get(); 4470 tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding.get();
4471 break; 4471 break;
4472 default: 4472 default:
4473 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture target"); 4473 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture target ");
4474 return 0; 4474 return 0;
4475 } 4475 }
4476 if (!tex) 4476 if (!tex)
4477 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o texture"); 4477 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no texture");
4478 return tex; 4478 return tex;
4479 } 4479 }
4480 4480
4481 bool WebGLRenderingContext::validateLocationLength(const char* functionName, con st String& string) 4481 bool WebGLRenderingContext::validateLocationLength(const char* functionName, con st String& string)
4482 { 4482 {
4483 const unsigned maxWebGLLocationLength = 256; 4483 const unsigned maxWebGLLocationLength = 256;
4484 if (string.length() > maxWebGLLocationLength) { 4484 if (string.length() > maxWebGLLocationLength) {
4485 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "locat ion length > 256"); 4485 synthesizeGLError(GL_INVALID_VALUE, functionName, "location length > 256 ");
4486 return false; 4486 return false;
4487 } 4487 }
4488 return true; 4488 return true;
4489 } 4489 }
4490 4490
4491 bool WebGLRenderingContext::validateSize(const char* functionName, GC3Dint x, GC 3Dint y) 4491 bool WebGLRenderingContext::validateSize(const char* functionName, GC3Dint x, GC 3Dint y)
4492 { 4492 {
4493 if (x < 0 || y < 0) { 4493 if (x < 0 || y < 0) {
4494 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "size < 0"); 4494 synthesizeGLError(GL_INVALID_VALUE, functionName, "size < 0");
4495 return false; 4495 return false;
4496 } 4496 }
4497 return true; 4497 return true;
4498 } 4498 }
4499 4499
4500 bool WebGLRenderingContext::validateString(const char* functionName, const Strin g& string) 4500 bool WebGLRenderingContext::validateString(const char* functionName, const Strin g& string)
4501 { 4501 {
4502 for (size_t i = 0; i < string.length(); ++i) { 4502 for (size_t i = 0; i < string.length(); ++i) {
4503 if (!validateCharacter(string[i])) { 4503 if (!validateCharacter(string[i])) {
4504 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "s tring not ASCII"); 4504 synthesizeGLError(GL_INVALID_VALUE, functionName, "string not ASCII" );
4505 return false; 4505 return false;
4506 } 4506 }
4507 } 4507 }
4508 return true; 4508 return true;
4509 } 4509 }
4510 4510
4511 bool WebGLRenderingContext::validateTexFuncFormatAndType(const char* functionNam e, GC3Denum format, GC3Denum type, GC3Dint level) 4511 bool WebGLRenderingContext::validateTexFuncFormatAndType(const char* functionNam e, GC3Denum format, GC3Denum type, GC3Dint level)
4512 { 4512 {
4513 switch (format) { 4513 switch (format) {
4514 case GraphicsContext3D::ALPHA: 4514 case GL_ALPHA:
4515 case GraphicsContext3D::LUMINANCE: 4515 case GL_LUMINANCE:
4516 case GraphicsContext3D::LUMINANCE_ALPHA: 4516 case GL_LUMINANCE_ALPHA:
4517 case GraphicsContext3D::RGB: 4517 case GL_RGB:
4518 case GraphicsContext3D::RGBA: 4518 case GL_RGBA:
4519 break; 4519 break;
4520 case GraphicsContext3D::DEPTH_STENCIL: 4520 case GL_DEPTH_STENCIL_OES:
4521 case GraphicsContext3D::DEPTH_COMPONENT: 4521 case GL_DEPTH_COMPONENT:
4522 if (m_webglDepthTexture) 4522 if (m_webglDepthTexture)
4523 break; 4523 break;
4524 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "depth texture formats not enabled"); 4524 synthesizeGLError(GL_INVALID_ENUM, functionName, "depth texture formats not enabled");
4525 return false; 4525 return false;
4526 default: 4526 default:
4527 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture format"); 4527 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture format ");
4528 return false; 4528 return false;
4529 } 4529 }
4530 4530
4531 switch (type) { 4531 switch (type) {
4532 case GraphicsContext3D::UNSIGNED_BYTE: 4532 case GL_UNSIGNED_BYTE:
4533 case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: 4533 case GL_UNSIGNED_SHORT_5_6_5:
4534 case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: 4534 case GL_UNSIGNED_SHORT_4_4_4_4:
4535 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: 4535 case GL_UNSIGNED_SHORT_5_5_5_1:
4536 break; 4536 break;
4537 case GraphicsContext3D::FLOAT: 4537 case GL_FLOAT:
4538 if (m_oesTextureFloat) 4538 if (m_oesTextureFloat)
4539 break; 4539 break;
4540 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); 4540 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture type") ;
4541 return false; 4541 return false;
4542 case GraphicsContext3D::HALF_FLOAT_OES: 4542 case GL_HALF_FLOAT_OES:
4543 if (m_oesTextureHalfFloat) 4543 if (m_oesTextureHalfFloat)
4544 break; 4544 break;
4545 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); 4545 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture type") ;
4546 return false; 4546 return false;
4547 case GraphicsContext3D::UNSIGNED_INT: 4547 case GL_UNSIGNED_INT:
4548 case GraphicsContext3D::UNSIGNED_INT_24_8: 4548 case GL_UNSIGNED_INT_24_8_OES:
4549 case GraphicsContext3D::UNSIGNED_SHORT: 4549 case GL_UNSIGNED_SHORT:
4550 if (m_webglDepthTexture) 4550 if (m_webglDepthTexture)
4551 break; 4551 break;
4552 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); 4552 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture type") ;
4553 return false; 4553 return false;
4554 default: 4554 default:
4555 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d texture type"); 4555 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid texture type") ;
4556 return false; 4556 return false;
4557 } 4557 }
4558 4558
4559 // Verify that the combination of format and type is supported. 4559 // Verify that the combination of format and type is supported.
4560 switch (format) { 4560 switch (format) {
4561 case GraphicsContext3D::ALPHA: 4561 case GL_ALPHA:
4562 case GraphicsContext3D::LUMINANCE: 4562 case GL_LUMINANCE:
4563 case GraphicsContext3D::LUMINANCE_ALPHA: 4563 case GL_LUMINANCE_ALPHA:
4564 if (type != GraphicsContext3D::UNSIGNED_BYTE 4564 if (type != GL_UNSIGNED_BYTE
4565 && type != GraphicsContext3D::FLOAT 4565 && type != GL_FLOAT
4566 && type != GraphicsContext3D::HALF_FLOAT_OES) { 4566 && type != GL_HALF_FLOAT_OES) {
4567 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for format"); 4567 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid type for format");
4568 return false; 4568 return false;
4569 } 4569 }
4570 break; 4570 break;
4571 case GraphicsContext3D::RGB: 4571 case GL_RGB:
4572 if (type != GraphicsContext3D::UNSIGNED_BYTE 4572 if (type != GL_UNSIGNED_BYTE
4573 && type != GraphicsContext3D::UNSIGNED_SHORT_5_6_5 4573 && type != GL_UNSIGNED_SHORT_5_6_5
4574 && type != GraphicsContext3D::FLOAT 4574 && type != GL_FLOAT
4575 && type != GraphicsContext3D::HALF_FLOAT_OES) { 4575 && type != GL_HALF_FLOAT_OES) {
4576 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for RGB format"); 4576 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid type for RGB format");
4577 return false; 4577 return false;
4578 } 4578 }
4579 break; 4579 break;
4580 case GraphicsContext3D::RGBA: 4580 case GL_RGBA:
4581 if (type != GraphicsContext3D::UNSIGNED_BYTE 4581 if (type != GL_UNSIGNED_BYTE
4582 && type != GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4 4582 && type != GL_UNSIGNED_SHORT_4_4_4_4
4583 && type != GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1 4583 && type != GL_UNSIGNED_SHORT_5_5_5_1
4584 && type != GraphicsContext3D::FLOAT 4584 && type != GL_FLOAT
4585 && type != GraphicsContext3D::HALF_FLOAT_OES) { 4585 && type != GL_HALF_FLOAT_OES) {
4586 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for RGBA format"); 4586 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid type for RGBA format");
4587 return false; 4587 return false;
4588 } 4588 }
4589 break; 4589 break;
4590 case GraphicsContext3D::DEPTH_COMPONENT: 4590 case GL_DEPTH_COMPONENT:
4591 if (!m_webglDepthTexture) { 4591 if (!m_webglDepthTexture) {
4592 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "in valid format. DEPTH_COMPONENT not enabled"); 4592 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid format. DE PTH_COMPONENT not enabled");
4593 return false; 4593 return false;
4594 } 4594 }
4595 if (type != GraphicsContext3D::UNSIGNED_SHORT 4595 if (type != GL_UNSIGNED_SHORT
4596 && type != GraphicsContext3D::UNSIGNED_INT) { 4596 && type != GL_UNSIGNED_INT) {
4597 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for DEPTH_COMPONENT format"); 4597 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid type for DEPTH_COMPONENT format");
4598 return false; 4598 return false;
4599 } 4599 }
4600 if (level > 0) { 4600 if (level > 0) {
4601 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "level must be 0 for DEPTH_COMPONENT format"); 4601 synthesizeGLError(GL_INVALID_OPERATION, functionName, "level must be 0 for DEPTH_COMPONENT format");
4602 return false; 4602 return false;
4603 } 4603 }
4604 break; 4604 break;
4605 case GraphicsContext3D::DEPTH_STENCIL: 4605 case GL_DEPTH_STENCIL_OES:
4606 if (!m_webglDepthTexture) { 4606 if (!m_webglDepthTexture) {
4607 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "in valid format. DEPTH_STENCIL not enabled"); 4607 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid format. DE PTH_STENCIL not enabled");
4608 return false; 4608 return false;
4609 } 4609 }
4610 if (type != GraphicsContext3D::UNSIGNED_INT_24_8) { 4610 if (type != GL_UNSIGNED_INT_24_8_OES) {
4611 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "invalid type for DEPTH_STENCIL format"); 4611 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid type for DEPTH_STENCIL format");
4612 return false; 4612 return false;
4613 } 4613 }
4614 if (level > 0) { 4614 if (level > 0) {
4615 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "level must be 0 for DEPTH_STENCIL format"); 4615 synthesizeGLError(GL_INVALID_OPERATION, functionName, "level must be 0 for DEPTH_STENCIL format");
4616 return false; 4616 return false;
4617 } 4617 }
4618 break; 4618 break;
4619 default: 4619 default:
4620 ASSERT_NOT_REACHED(); 4620 ASSERT_NOT_REACHED();
4621 } 4621 }
4622 4622
4623 return true; 4623 return true;
4624 } 4624 }
4625 4625
4626 bool WebGLRenderingContext::validateTexFuncLevel(const char* functionName, GC3De num target, GC3Dint level) 4626 bool WebGLRenderingContext::validateTexFuncLevel(const char* functionName, GC3De num target, GC3Dint level)
4627 { 4627 {
4628 if (level < 0) { 4628 if (level < 0) {
4629 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "level < 0"); 4629 synthesizeGLError(GL_INVALID_VALUE, functionName, "level < 0");
4630 return false; 4630 return false;
4631 } 4631 }
4632 switch (target) { 4632 switch (target) {
4633 case GraphicsContext3D::TEXTURE_2D: 4633 case GL_TEXTURE_2D:
4634 if (level >= m_maxTextureLevel) { 4634 if (level >= m_maxTextureLevel) {
4635 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel out of range"); 4635 synthesizeGLError(GL_INVALID_VALUE, functionName, "level out of rang e");
4636 return false; 4636 return false;
4637 } 4637 }
4638 break; 4638 break;
4639 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: 4639 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4640 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: 4640 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4641 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: 4641 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4642 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: 4642 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4643 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z: 4643 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4644 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: 4644 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4645 if (level >= m_maxCubeMapTextureLevel) { 4645 if (level >= m_maxCubeMapTextureLevel) {
4646 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l evel out of range"); 4646 synthesizeGLError(GL_INVALID_VALUE, functionName, "level out of rang e");
4647 return false; 4647 return false;
4648 } 4648 }
4649 break; 4649 break;
4650 } 4650 }
4651 // This function only checks if level is legal, so we return true and don't 4651 // This function only checks if level is legal, so we return true and don't
4652 // generate INVALID_ENUM if target is illegal. 4652 // generate INVALID_ENUM if target is illegal.
4653 return true; 4653 return true;
4654 } 4654 }
4655 4655
4656 bool WebGLRenderingContext::validateTexFuncDimensions(const char* functionName, TexFuncValidationFunctionType functionType, 4656 bool WebGLRenderingContext::validateTexFuncDimensions(const char* functionName, TexFuncValidationFunctionType functionType,
4657 GC3Denum target, GC3Dint level, GC3Dsizei width, GC3Dsizei height) 4657 GC3Denum target, GC3Dint level, GC3Dsizei width, GC3Dsizei height)
4658 { 4658 {
4659 if (width < 0 || height < 0) { 4659 if (width < 0 || height < 0) {
4660 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0"); 4660 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height < 0") ;
4661 return false; 4661 return false;
4662 } 4662 }
4663 4663
4664 switch (target) { 4664 switch (target) {
4665 case GraphicsContext3D::TEXTURE_2D: 4665 case GL_TEXTURE_2D:
4666 if (width > (m_maxTextureSize >> level) || height > (m_maxTextureSize >> level)) { 4666 if (width > (m_maxTextureSize >> level) || height > (m_maxTextureSize >> level)) {
4667 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "w idth or height out of range"); 4667 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height o ut of range");
4668 return false; 4668 return false;
4669 } 4669 }
4670 break; 4670 break;
4671 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X: 4671 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4672 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X: 4672 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4673 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y: 4673 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4674 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y: 4674 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4675 case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z: 4675 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4676 case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z: 4676 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4677 if (functionType != TexSubImage2D && width != height) { 4677 if (functionType != TexSubImage2D && width != height) {
4678 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "wid th != height for cube map"); 4678 synthesizeGLError(GL_INVALID_VALUE, functionName, "width != height f or cube map");
4679 return false; 4679 return false;
4680 } 4680 }
4681 // No need to check height here. For texImage width == height. 4681 // No need to check height here. For texImage width == height.
4682 // For texSubImage that will be checked when checking yoffset + height i s in range. 4682 // For texSubImage that will be checked when checking yoffset + height i s in range.
4683 if (width > (m_maxCubeMapTextureSize >> level)) { 4683 if (width > (m_maxCubeMapTextureSize >> level)) {
4684 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "w idth or height out of range for cube map"); 4684 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height o ut of range for cube map");
4685 return false; 4685 return false;
4686 } 4686 }
4687 break; 4687 break;
4688 default: 4688 default:
4689 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); 4689 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target");
4690 return false; 4690 return false;
4691 } 4691 }
4692 return true; 4692 return true;
4693 } 4693 }
4694 4694
4695 bool WebGLRenderingContext::validateTexFuncParameters(const char* functionName, TexFuncValidationFunctionType functionType, GC3Denum target, 4695 bool WebGLRenderingContext::validateTexFuncParameters(const char* functionName, TexFuncValidationFunctionType functionType, GC3Denum target,
4696 GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, G C3Dint border, GC3Denum format, GC3Denum type) 4696 GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, G C3Dint border, GC3Denum format, GC3Denum type)
4697 { 4697 {
4698 // We absolutely have to validate the format and type combination. 4698 // We absolutely have to validate the format and type combination.
4699 // The texImage2D entry points taking HTMLImage, etc. will produce 4699 // The texImage2D entry points taking HTMLImage, etc. will produce
4700 // temporary data based on this combination, so it must be legal. 4700 // temporary data based on this combination, so it must be legal.
4701 if (!validateTexFuncFormatAndType(functionName, format, type, level) || !val idateTexFuncLevel(functionName, target, level)) 4701 if (!validateTexFuncFormatAndType(functionName, format, type, level) || !val idateTexFuncLevel(functionName, target, level))
4702 return false; 4702 return false;
4703 4703
4704 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) 4704 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height))
4705 return false; 4705 return false;
4706 4706
4707 if (format != internalformat) { 4707 if (format != internalformat) {
4708 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ormat != internalformat"); 4708 synthesizeGLError(GL_INVALID_OPERATION, functionName, "format != interna lformat");
4709 return false; 4709 return false;
4710 } 4710 }
4711 4711
4712 if (border) { 4712 if (border) {
4713 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "borde r != 0"); 4713 synthesizeGLError(GL_INVALID_VALUE, functionName, "border != 0");
4714 return false; 4714 return false;
4715 } 4715 }
4716 4716
4717 return true; 4717 return true;
4718 } 4718 }
4719 4719
4720 bool WebGLRenderingContext::validateTexFuncData(const char* functionName, GC3Din t level, 4720 bool WebGLRenderingContext::validateTexFuncData(const char* functionName, GC3Din t level,
4721 GC3Dsizei width, GC3Dsizei heigh t, 4721 GC3Dsizei width, GC3Dsizei heigh t,
4722 GC3Denum format, GC3Denum type, 4722 GC3Denum format, GC3Denum type,
4723 ArrayBufferView* pixels, 4723 ArrayBufferView* pixels,
4724 NullDisposition disposition) 4724 NullDisposition disposition)
4725 { 4725 {
4726 // All calling functions check isContextLost, so a duplicate check is not ne eded here. 4726 // All calling functions check isContextLost, so a duplicate check is not ne eded here.
4727 if (!pixels) { 4727 if (!pixels) {
4728 if (disposition == NullAllowed) 4728 if (disposition == NullAllowed)
4729 return true; 4729 return true;
4730 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pi xels"); 4730 synthesizeGLError(GL_INVALID_VALUE, functionName, "no pixels");
4731 return false; 4731 return false;
4732 } 4732 }
4733 4733
4734 if (!validateTexFuncFormatAndType(functionName, format, type, level)) 4734 if (!validateTexFuncFormatAndType(functionName, format, type, level))
4735 return false; 4735 return false;
4736 if (!validateSettableTexFormat(functionName, format)) 4736 if (!validateSettableTexFormat(functionName, format))
4737 return false; 4737 return false;
4738 4738
4739 switch (type) { 4739 switch (type) {
4740 case GraphicsContext3D::UNSIGNED_BYTE: 4740 case GL_UNSIGNED_BYTE:
4741 if (pixels->getType() != ArrayBufferView::TypeUint8) { 4741 if (pixels->getType() != ArrayBufferView::TypeUint8) {
4742 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type UNSIGNED_BYTE but ArrayBufferView not Uint8Array"); 4742 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type UNSIGNED _BYTE but ArrayBufferView not Uint8Array");
4743 return false; 4743 return false;
4744 } 4744 }
4745 break; 4745 break;
4746 case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: 4746 case GL_UNSIGNED_SHORT_5_6_5:
4747 case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: 4747 case GL_UNSIGNED_SHORT_4_4_4_4:
4748 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: 4748 case GL_UNSIGNED_SHORT_5_5_5_1:
4749 if (pixels->getType() != ArrayBufferView::TypeUint16) { 4749 if (pixels->getType() != ArrayBufferView::TypeUint16) {
4750 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type UNSIGNED_SHORT but ArrayBufferView not Uint16Array"); 4750 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type UNSIGNED _SHORT but ArrayBufferView not Uint16Array");
4751 return false; 4751 return false;
4752 } 4752 }
4753 break; 4753 break;
4754 case GraphicsContext3D::FLOAT: // OES_texture_float 4754 case GL_FLOAT: // OES_texture_float
4755 if (pixels->getType() != ArrayBufferView::TypeFloat32) { 4755 if (pixels->getType() != ArrayBufferView::TypeFloat32) {
4756 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type FLOAT but ArrayBufferView not Float32Array"); 4756 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type FLOAT bu t ArrayBufferView not Float32Array");
4757 return false; 4757 return false;
4758 } 4758 }
4759 break; 4759 break;
4760 case GraphicsContext3D::HALF_FLOAT_OES: // OES_texture_half_float 4760 case GL_HALF_FLOAT_OES: // OES_texture_half_float
4761 // As per the specification, ArrayBufferView should be null when 4761 // As per the specification, ArrayBufferView should be null when
4762 // OES_texture_half_float is enabled. 4762 // OES_texture_half_float is enabled.
4763 if (pixels) { 4763 if (pixels) {
4764 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "type HALF_FLOAT_OES but ArrayBufferView is not NULL"); 4764 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type HALF_FLO AT_OES but ArrayBufferView is not NULL");
4765 return false; 4765 return false;
4766 } 4766 }
4767 break; 4767 break;
4768 default: 4768 default:
4769 ASSERT_NOT_REACHED(); 4769 ASSERT_NOT_REACHED();
4770 } 4770 }
4771 4771
4772 unsigned int totalBytesRequired; 4772 unsigned int totalBytesRequired;
4773 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_unpackAlignment, &totalBytesRequired, 0); 4773 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei ght, m_unpackAlignment, &totalBytesRequired, 0);
4774 if (error != GraphicsContext3D::NO_ERROR) { 4774 if (error != GL_NO_ERROR) {
4775 synthesizeGLError(error, functionName, "invalid texture dimensions"); 4775 synthesizeGLError(error, functionName, "invalid texture dimensions");
4776 return false; 4776 return false;
4777 } 4777 }
4778 if (pixels->byteLength() < totalBytesRequired) { 4778 if (pixels->byteLength() < totalBytesRequired) {
4779 if (m_unpackAlignment != 1) { 4779 if (m_unpackAlignment != 1) {
4780 error = m_context->computeImageSizeInBytes(format, type, width, height , 1, &totalBytesRequired, 0); 4780 error = m_context->computeImageSizeInBytes(format, type, width, height , 1, &totalBytesRequired, 0);
4781 if (pixels->byteLength() == totalBytesRequired) { 4781 if (pixels->byteLength() == totalBytesRequired) {
4782 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "ArrayBufferView not big enough for request with UNPACK_ALIGNMENT > 1"); 4782 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBufferVi ew not big enough for request with UNPACK_ALIGNMENT > 1");
4783 return false; 4783 return false;
4784 } 4784 }
4785 } 4785 }
4786 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "A rrayBufferView not big enough for request"); 4786 synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBufferView n ot big enough for request");
4787 return false; 4787 return false;
4788 } 4788 }
4789 return true; 4789 return true;
4790 } 4790 }
4791 4791
4792 bool WebGLRenderingContext::validateCompressedTexFormat(GC3Denum format) 4792 bool WebGLRenderingContext::validateCompressedTexFormat(GC3Denum format)
4793 { 4793 {
4794 return m_compressedTextureFormats.contains(format); 4794 return m_compressedTextureFormats.contains(format);
4795 } 4795 }
4796 4796
4797 bool WebGLRenderingContext::validateCompressedTexFuncData(const char* functionNa me, 4797 bool WebGLRenderingContext::validateCompressedTexFuncData(const char* functionNa me,
4798 GC3Dsizei width, GC3Ds izei height, 4798 GC3Dsizei width, GC3Ds izei height,
4799 GC3Denum format, Array BufferView* pixels) 4799 GC3Denum format, Array BufferView* pixels)
4800 { 4800 {
4801 if (!pixels) { 4801 if (!pixels) {
4802 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no pi xels"); 4802 synthesizeGLError(GL_INVALID_VALUE, functionName, "no pixels");
4803 return false; 4803 return false;
4804 } 4804 }
4805 if (width < 0 || height < 0) { 4805 if (width < 0 || height < 0) {
4806 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "width or height < 0"); 4806 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height < 0") ;
4807 return false; 4807 return false;
4808 } 4808 }
4809 4809
4810 unsigned int bytesRequired = 0; 4810 unsigned int bytesRequired = 0;
4811 4811
4812 switch (format) { 4812 switch (format) {
4813 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: 4813 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
4814 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: 4814 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
4815 { 4815 {
4816 const int kBlockWidth = 4; 4816 const int kBlockWidth = 4;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4850 bytesRequired = max(width, 8) * max(height, 8) / 2; 4850 bytesRequired = max(width, 8) * max(height, 8) / 2;
4851 } 4851 }
4852 break; 4852 break;
4853 case Extensions3D::COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 4853 case Extensions3D::COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
4854 case Extensions3D::COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 4854 case Extensions3D::COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
4855 { 4855 {
4856 bytesRequired = max(width, 8) * max(height, 8) / 4; 4856 bytesRequired = max(width, 8) * max(height, 8) / 4;
4857 } 4857 }
4858 break; 4858 break;
4859 default: 4859 default:
4860 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d format"); 4860 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid format");
4861 return false; 4861 return false;
4862 } 4862 }
4863 4863
4864 if (pixels->byteLength() != bytesRequired) { 4864 if (pixels->byteLength() != bytesRequired) {
4865 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "lengt h of ArrayBufferView is not correct for dimensions"); 4865 synthesizeGLError(GL_INVALID_VALUE, functionName, "length of ArrayBuffer View is not correct for dimensions");
4866 return false; 4866 return false;
4867 } 4867 }
4868 4868
4869 return true; 4869 return true;
4870 } 4870 }
4871 4871
4872 bool WebGLRenderingContext::validateCompressedTexDimensions(const char* function Name, TexFuncValidationFunctionType functionType, GC3Denum target, GC3Dint level , GC3Dsizei width, GC3Dsizei height, GC3Denum format) 4872 bool WebGLRenderingContext::validateCompressedTexDimensions(const char* function Name, TexFuncValidationFunctionType functionType, GC3Denum target, GC3Dint level , GC3Dsizei width, GC3Dsizei height, GC3Denum format)
4873 { 4873 {
4874 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) 4874 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height))
4875 return false; 4875 return false;
4876 4876
4877 switch (format) { 4877 switch (format) {
4878 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: 4878 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
4879 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: 4879 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
4880 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: 4880 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
4881 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: { 4881 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: {
4882 const int kBlockWidth = 4; 4882 const int kBlockWidth = 4;
4883 const int kBlockHeight = 4; 4883 const int kBlockHeight = 4;
4884 bool widthValid = (level && width == 1) || (level && width == 2) || !(wi dth % kBlockWidth); 4884 bool widthValid = (level && width == 1) || (level && width == 2) || !(wi dth % kBlockWidth);
4885 bool heightValid = (level && height == 1) || (level && height == 2) || ! (height % kBlockHeight); 4885 bool heightValid = (level && height == 1) || (level && height == 2) || ! (height % kBlockHeight);
4886 if (!widthValid || !heightValid) { 4886 if (!widthValid || !heightValid) {
4887 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "width or height invalid for level"); 4887 synthesizeGLError(GL_INVALID_OPERATION, functionName, "width or heig ht invalid for level");
4888 return false; 4888 return false;
4889 } 4889 }
4890 return true; 4890 return true;
4891 } 4891 }
4892 default: 4892 default:
4893 return false; 4893 return false;
4894 } 4894 }
4895 } 4895 }
4896 4896
4897 bool WebGLRenderingContext::validateCompressedTexSubDimensions(const char* funct ionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, 4897 bool WebGLRenderingContext::validateCompressedTexSubDimensions(const char* funct ionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
4898 GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture* tex) 4898 GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture* tex)
4899 { 4899 {
4900 if (xoffset < 0 || yoffset < 0) { 4900 if (xoffset < 0 || yoffset < 0) {
4901 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "xoffset or yoffset < 0"); 4901 synthesizeGLError(GL_INVALID_VALUE, functionName, "xoffset or yoffset < 0");
4902 return false; 4902 return false;
4903 } 4903 }
4904 4904
4905 switch (format) { 4905 switch (format) {
4906 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: 4906 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
4907 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: 4907 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
4908 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: 4908 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
4909 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: { 4909 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: {
4910 const int kBlockWidth = 4; 4910 const int kBlockWidth = 4;
4911 const int kBlockHeight = 4; 4911 const int kBlockHeight = 4;
4912 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { 4912 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) {
4913 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "xoffset or yoffset not multiple of 4"); 4913 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo ffset not multiple of 4");
4914 return false; 4914 return false;
4915 } 4915 }
4916 if (width - xoffset > tex->getWidth(target, level) 4916 if (width - xoffset > tex->getWidth(target, level)
4917 || height - yoffset > tex->getHeight(target, level)) { 4917 || height - yoffset > tex->getHeight(target, level)) {
4918 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName , "dimensions out of range"); 4918 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions ou t of range");
4919 return false; 4919 return false;
4920 } 4920 }
4921 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format); 4921 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format);
4922 } 4922 }
4923 default: 4923 default:
4924 return false; 4924 return false;
4925 } 4925 }
4926 } 4926 }
4927 4927
4928 bool WebGLRenderingContext::validateDrawMode(const char* functionName, GC3Denum mode) 4928 bool WebGLRenderingContext::validateDrawMode(const char* functionName, GC3Denum mode)
4929 { 4929 {
4930 switch (mode) { 4930 switch (mode) {
4931 case GraphicsContext3D::POINTS: 4931 case GL_POINTS:
4932 case GraphicsContext3D::LINE_STRIP: 4932 case GL_LINE_STRIP:
4933 case GraphicsContext3D::LINE_LOOP: 4933 case GL_LINE_LOOP:
4934 case GraphicsContext3D::LINES: 4934 case GL_LINES:
4935 case GraphicsContext3D::TRIANGLE_STRIP: 4935 case GL_TRIANGLE_STRIP:
4936 case GraphicsContext3D::TRIANGLE_FAN: 4936 case GL_TRIANGLE_FAN:
4937 case GraphicsContext3D::TRIANGLES: 4937 case GL_TRIANGLES:
4938 return true; 4938 return true;
4939 default: 4939 default:
4940 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d draw mode"); 4940 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid draw mode");
4941 return false; 4941 return false;
4942 } 4942 }
4943 } 4943 }
4944 4944
4945 bool WebGLRenderingContext::validateStencilSettings(const char* functionName) 4945 bool WebGLRenderingContext::validateStencilSettings(const char* functionName)
4946 { 4946 {
4947 if (m_stencilMask != m_stencilMaskBack || m_stencilFuncRef != m_stencilFuncR efBack || m_stencilFuncMask != m_stencilFuncMaskBack) { 4947 if (m_stencilMask != m_stencilMaskBack || m_stencilFuncRef != m_stencilFuncR efBack || m_stencilFuncMask != m_stencilFuncMaskBack) {
4948 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f ront and back stencils settings do not match"); 4948 synthesizeGLError(GL_INVALID_OPERATION, functionName, "front and back st encils settings do not match");
4949 return false; 4949 return false;
4950 } 4950 }
4951 return true; 4951 return true;
4952 } 4952 }
4953 4953
4954 bool WebGLRenderingContext::validateStencilOrDepthFunc(const char* functionName, GC3Denum func) 4954 bool WebGLRenderingContext::validateStencilOrDepthFunc(const char* functionName, GC3Denum func)
4955 { 4955 {
4956 switch (func) { 4956 switch (func) {
4957 case GraphicsContext3D::NEVER: 4957 case GL_NEVER:
4958 case GraphicsContext3D::LESS: 4958 case GL_LESS:
4959 case GraphicsContext3D::LEQUAL: 4959 case GL_LEQUAL:
4960 case GraphicsContext3D::GREATER: 4960 case GL_GREATER:
4961 case GraphicsContext3D::GEQUAL: 4961 case GL_GEQUAL:
4962 case GraphicsContext3D::EQUAL: 4962 case GL_EQUAL:
4963 case GraphicsContext3D::NOTEQUAL: 4963 case GL_NOTEQUAL:
4964 case GraphicsContext3D::ALWAYS: 4964 case GL_ALWAYS:
4965 return true; 4965 return true;
4966 default: 4966 default:
4967 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d function"); 4967 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid function");
4968 return false; 4968 return false;
4969 } 4969 }
4970 } 4970 }
4971 4971
4972 void WebGLRenderingContext::printGLErrorToConsole(const String& message) 4972 void WebGLRenderingContext::printGLErrorToConsole(const String& message)
4973 { 4973 {
4974 if (!m_numGLErrorsToConsoleAllowed) 4974 if (!m_numGLErrorsToConsoleAllowed)
4975 return; 4975 return;
4976 4976
4977 --m_numGLErrorsToConsoleAllowed; 4977 --m_numGLErrorsToConsoleAllowed;
4978 printWarningToConsole(message); 4978 printWarningToConsole(message);
4979 4979
4980 if (!m_numGLErrorsToConsoleAllowed) 4980 if (!m_numGLErrorsToConsoleAllowed)
4981 printWarningToConsole("WebGL: too many errors, no more errors will be re ported to the console for this context."); 4981 printWarningToConsole("WebGL: too many errors, no more errors will be re ported to the console for this context.");
4982 4982
4983 return; 4983 return;
4984 } 4984 }
4985 4985
4986 void WebGLRenderingContext::printWarningToConsole(const String& message) 4986 void WebGLRenderingContext::printWarningToConsole(const String& message)
4987 { 4987 {
4988 if (!canvas()) 4988 if (!canvas())
4989 return; 4989 return;
4990 canvas()->document().addConsoleMessage(RenderingMessageSource, WarningMessag eLevel, message); 4990 canvas()->document().addConsoleMessage(RenderingMessageSource, WarningMessag eLevel, message);
4991 } 4991 }
4992 4992
4993 bool WebGLRenderingContext::validateFramebufferFuncParameters(const char* functi onName, GC3Denum target, GC3Denum attachment) 4993 bool WebGLRenderingContext::validateFramebufferFuncParameters(const char* functi onName, GC3Denum target, GC3Denum attachment)
4994 { 4994 {
4995 if (target != GraphicsContext3D::FRAMEBUFFER) { 4995 if (target != GL_FRAMEBUFFER) {
4996 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); 4996 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target");
4997 return false; 4997 return false;
4998 } 4998 }
4999 switch (attachment) { 4999 switch (attachment) {
5000 case GraphicsContext3D::COLOR_ATTACHMENT0: 5000 case GL_COLOR_ATTACHMENT0:
5001 case GraphicsContext3D::DEPTH_ATTACHMENT: 5001 case GL_DEPTH_ATTACHMENT:
5002 case GraphicsContext3D::STENCIL_ATTACHMENT: 5002 case GL_STENCIL_ATTACHMENT:
5003 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: 5003 case GC3D_DEPTH_STENCIL_ATTACHMENT:
5004 break; 5004 break;
5005 default: 5005 default:
5006 if (m_webglDrawBuffers 5006 if (m_webglDrawBuffers
5007 && attachment > GraphicsContext3D::COLOR_ATTACHMENT0 5007 && attachment > GL_COLOR_ATTACHMENT0
5008 && attachment < static_cast<GC3Denum>(GraphicsContext3D::COLOR_ATTAC HMENT0 + maxColorAttachments())) 5008 && attachment < static_cast<GC3Denum>(GL_COLOR_ATTACHMENT0 + maxColo rAttachments()))
5009 break; 5009 break;
5010 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d attachment"); 5010 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid attachment");
5011 return false; 5011 return false;
5012 } 5012 }
5013 return true; 5013 return true;
5014 } 5014 }
5015 5015
5016 bool WebGLRenderingContext::validateBlendEquation(const char* functionName, GC3D enum mode) 5016 bool WebGLRenderingContext::validateBlendEquation(const char* functionName, GC3D enum mode)
5017 { 5017 {
5018 switch (mode) { 5018 switch (mode) {
5019 case GraphicsContext3D::FUNC_ADD: 5019 case GL_FUNC_ADD:
5020 case GraphicsContext3D::FUNC_SUBTRACT: 5020 case GL_FUNC_SUBTRACT:
5021 case GraphicsContext3D::FUNC_REVERSE_SUBTRACT: 5021 case GL_FUNC_REVERSE_SUBTRACT:
5022 return true; 5022 return true;
5023 default: 5023 default:
5024 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d mode"); 5024 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid mode");
5025 return false; 5025 return false;
5026 } 5026 }
5027 } 5027 }
5028 5028
5029 bool WebGLRenderingContext::validateBlendFuncFactors(const char* functionName, G C3Denum src, GC3Denum dst) 5029 bool WebGLRenderingContext::validateBlendFuncFactors(const char* functionName, G C3Denum src, GC3Denum dst)
5030 { 5030 {
5031 if (((src == GraphicsContext3D::CONSTANT_COLOR || src == GraphicsContext3D:: ONE_MINUS_CONSTANT_COLOR) 5031 if (((src == GL_CONSTANT_COLOR || src == GL_ONE_MINUS_CONSTANT_COLOR)
5032 && (dst == GraphicsContext3D::CONSTANT_ALPHA || dst == GraphicsContext3 D::ONE_MINUS_CONSTANT_ALPHA)) 5032 && (dst == GL_CONSTANT_ALPHA || dst == GL_ONE_MINUS_CONSTANT_ALPHA))
5033 || ((dst == GraphicsContext3D::CONSTANT_COLOR || dst == GraphicsContext3 D::ONE_MINUS_CONSTANT_COLOR) 5033 || ((dst == GL_CONSTANT_COLOR || dst == GL_ONE_MINUS_CONSTANT_COLOR)
5034 && (src == GraphicsContext3D::CONSTANT_ALPHA || src == GraphicsConte xt3D::ONE_MINUS_CONSTANT_ALPHA))) { 5034 && (src == GL_CONSTANT_ALPHA || src == GL_ONE_MINUS_CONSTANT_ALPHA))) {
5035 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "i ncompatible src and dst"); 5035 synthesizeGLError(GL_INVALID_OPERATION, functionName, "incompatible src and dst");
5036 return false; 5036 return false;
5037 } 5037 }
5038 return true; 5038 return true;
5039 } 5039 }
5040 5040
5041 bool WebGLRenderingContext::validateCapability(const char* functionName, GC3Denu m cap) 5041 bool WebGLRenderingContext::validateCapability(const char* functionName, GC3Denu m cap)
5042 { 5042 {
5043 switch (cap) { 5043 switch (cap) {
5044 case GraphicsContext3D::BLEND: 5044 case GL_BLEND:
5045 case GraphicsContext3D::CULL_FACE: 5045 case GL_CULL_FACE:
5046 case GraphicsContext3D::DEPTH_TEST: 5046 case GL_DEPTH_TEST:
5047 case GraphicsContext3D::DITHER: 5047 case GL_DITHER:
5048 case GraphicsContext3D::POLYGON_OFFSET_FILL: 5048 case GL_POLYGON_OFFSET_FILL:
5049 case GraphicsContext3D::SAMPLE_ALPHA_TO_COVERAGE: 5049 case GL_SAMPLE_ALPHA_TO_COVERAGE:
5050 case GraphicsContext3D::SAMPLE_COVERAGE: 5050 case GL_SAMPLE_COVERAGE:
5051 case GraphicsContext3D::SCISSOR_TEST: 5051 case GL_SCISSOR_TEST:
5052 case GraphicsContext3D::STENCIL_TEST: 5052 case GL_STENCIL_TEST:
5053 return true; 5053 return true;
5054 default: 5054 default:
5055 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d capability"); 5055 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid capability");
5056 return false; 5056 return false;
5057 } 5057 }
5058 } 5058 }
5059 5059
5060 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize ) 5060 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Float32Array* v, GC3Dsizei requiredMinSize )
5061 { 5061 {
5062 if (!v) { 5062 if (!v) {
5063 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5063 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
5064 return false; 5064 return false;
5065 } 5065 }
5066 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize); 5066 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize);
5067 } 5067 }
5068 5068
5069 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize) 5069 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, Int32Array* v, GC3Dsizei requiredMinSize)
5070 { 5070 {
5071 if (!v) { 5071 if (!v) {
5072 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5072 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
5073 return false; 5073 return false;
5074 } 5074 }
5075 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize); 5075 return validateUniformMatrixParameters(functionName, location, false, v->dat a(), v->length(), requiredMinSize);
5076 } 5076 }
5077 5077
5078 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei require dMinSize) 5078 bool WebGLRenderingContext::validateUniformParameters(const char* functionName, const WebGLUniformLocation* location, void* v, GC3Dsizei size, GC3Dsizei require dMinSize)
5079 { 5079 {
5080 return validateUniformMatrixParameters(functionName, location, false, v, siz e, requiredMinSize); 5080 return validateUniformMatrixParameters(functionName, location, false, v, siz e, requiredMinSize);
5081 } 5081 }
5082 5082
5083 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize) 5083 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, GC3Dsizei requiredMinSize)
5084 { 5084 {
5085 if (!v) { 5085 if (!v) {
5086 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5086 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
5087 return false; 5087 return false;
5088 } 5088 }
5089 return validateUniformMatrixParameters(functionName, location, transpose, v- >data(), v->length(), requiredMinSize); 5089 return validateUniformMatrixParameters(functionName, location, transpose, v- >data(), v->length(), requiredMinSize);
5090 } 5090 }
5091 5091
5092 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3D sizei size, GC3Dsizei requiredMinSize) 5092 bool WebGLRenderingContext::validateUniformMatrixParameters(const char* function Name, const WebGLUniformLocation* location, GC3Dboolean transpose, void* v, GC3D sizei size, GC3Dsizei requiredMinSize)
5093 { 5093 {
5094 if (!location) 5094 if (!location)
5095 return false; 5095 return false;
5096 if (location->program() != m_currentProgram) { 5096 if (location->program() != m_currentProgram) {
5097 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "l ocation is not from current program"); 5097 synthesizeGLError(GL_INVALID_OPERATION, functionName, "location is not f rom current program");
5098 return false; 5098 return false;
5099 } 5099 }
5100 if (!v) { 5100 if (!v) {
5101 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5101 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
5102 return false; 5102 return false;
5103 } 5103 }
5104 if (transpose) { 5104 if (transpose) {
5105 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "trans pose not FALSE"); 5105 synthesizeGLError(GL_INVALID_VALUE, functionName, "transpose not FALSE") ;
5106 return false; 5106 return false;
5107 } 5107 }
5108 if (size < requiredMinSize || (size % requiredMinSize)) { 5108 if (size < requiredMinSize || (size % requiredMinSize)) {
5109 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id size"); 5109 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size");
5110 return false; 5110 return false;
5111 } 5111 }
5112 return true; 5112 return true;
5113 } 5113 }
5114 5114
5115 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* fun ctionName, GC3Denum target, GC3Denum usage) 5115 WebGLBuffer* WebGLRenderingContext::validateBufferDataParameters(const char* fun ctionName, GC3Denum target, GC3Denum usage)
5116 { 5116 {
5117 WebGLBuffer* buffer = 0; 5117 WebGLBuffer* buffer = 0;
5118 switch (target) { 5118 switch (target) {
5119 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER: 5119 case GL_ELEMENT_ARRAY_BUFFER:
5120 buffer = m_boundVertexArrayObject->boundElementArrayBuffer().get(); 5120 buffer = m_boundVertexArrayObject->boundElementArrayBuffer().get();
5121 break; 5121 break;
5122 case GraphicsContext3D::ARRAY_BUFFER: 5122 case GL_ARRAY_BUFFER:
5123 buffer = m_boundArrayBuffer.get(); 5123 buffer = m_boundArrayBuffer.get();
5124 break; 5124 break;
5125 default: 5125 default:
5126 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d target"); 5126 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target");
5127 return 0; 5127 return 0;
5128 } 5128 }
5129 if (!buffer) { 5129 if (!buffer) {
5130 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o buffer"); 5130 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no buffer");
5131 return 0; 5131 return 0;
5132 } 5132 }
5133 switch (usage) { 5133 switch (usage) {
5134 case GraphicsContext3D::STREAM_DRAW: 5134 case GL_STREAM_DRAW:
5135 case GraphicsContext3D::STATIC_DRAW: 5135 case GL_STATIC_DRAW:
5136 case GraphicsContext3D::DYNAMIC_DRAW: 5136 case GL_DYNAMIC_DRAW:
5137 return buffer; 5137 return buffer;
5138 } 5138 }
5139 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid us age"); 5139 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid usage");
5140 return 0; 5140 return 0;
5141 } 5141 }
5142 5142
5143 bool WebGLRenderingContext::validateHTMLImageElement(const char* functionName, H TMLImageElement* image, ExceptionState& exceptionState) 5143 bool WebGLRenderingContext::validateHTMLImageElement(const char* functionName, H TMLImageElement* image, ExceptionState& exceptionState)
5144 { 5144 {
5145 if (!image || !image->cachedImage()) { 5145 if (!image || !image->cachedImage()) {
5146 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no im age"); 5146 synthesizeGLError(GL_INVALID_VALUE, functionName, "no image");
5147 return false; 5147 return false;
5148 } 5148 }
5149 const KURL& url = image->cachedImage()->response().url(); 5149 const KURL& url = image->cachedImage()->response().url();
5150 if (url.isNull() || url.isEmpty() || !url.isValid()) { 5150 if (url.isNull() || url.isEmpty() || !url.isValid()) {
5151 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id image"); 5151 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid image");
5152 return false; 5152 return false;
5153 } 5153 }
5154 if (wouldTaintOrigin(image)) { 5154 if (wouldTaintOrigin(image)) {
5155 exceptionState.throwSecurityError("The cross-origin image at " + url.eli dedString() + " may not be loaded."); 5155 exceptionState.throwSecurityError("The cross-origin image at " + url.eli dedString() + " may not be loaded.");
5156 return false; 5156 return false;
5157 } 5157 }
5158 return true; 5158 return true;
5159 } 5159 }
5160 5160
5161 bool WebGLRenderingContext::validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement* canvas, ExceptionState& exceptionState) 5161 bool WebGLRenderingContext::validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement* canvas, ExceptionState& exceptionState)
5162 { 5162 {
5163 if (!canvas || !canvas->buffer()) { 5163 if (!canvas || !canvas->buffer()) {
5164 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ca nvas"); 5164 synthesizeGLError(GL_INVALID_VALUE, functionName, "no canvas");
5165 return false; 5165 return false;
5166 } 5166 }
5167 if (wouldTaintOrigin(canvas)) { 5167 if (wouldTaintOrigin(canvas)) {
5168 exceptionState.throwSecurityError("Tainted canvases may not be loaded.") ; 5168 exceptionState.throwSecurityError("Tainted canvases may not be loaded.") ;
5169 return false; 5169 return false;
5170 } 5170 }
5171 return true; 5171 return true;
5172 } 5172 }
5173 5173
5174 bool WebGLRenderingContext::validateHTMLVideoElement(const char* functionName, H TMLVideoElement* video, ExceptionState& exceptionState) 5174 bool WebGLRenderingContext::validateHTMLVideoElement(const char* functionName, H TMLVideoElement* video, ExceptionState& exceptionState)
5175 { 5175 {
5176 if (!video || !video->videoWidth() || !video->videoHeight()) { 5176 if (!video || !video->videoWidth() || !video->videoHeight()) {
5177 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no vi deo"); 5177 synthesizeGLError(GL_INVALID_VALUE, functionName, "no video");
5178 return false; 5178 return false;
5179 } 5179 }
5180 if (wouldTaintOrigin(video)) { 5180 if (wouldTaintOrigin(video)) {
5181 exceptionState.throwSecurityError("The video element contains cross-orig in data, and may not be loaded."); 5181 exceptionState.throwSecurityError("The video element contains cross-orig in data, and may not be loaded.");
5182 return false; 5182 return false;
5183 } 5183 }
5184 return true; 5184 return true;
5185 } 5185 }
5186 5186
5187 bool WebGLRenderingContext::validateDrawArrays(const char* functionName, GC3Denu m mode, GC3Dint first, GC3Dsizei count) 5187 bool WebGLRenderingContext::validateDrawArrays(const char* functionName, GC3Denu m mode, GC3Dint first, GC3Dsizei count)
5188 { 5188 {
5189 if (isContextLost() || !validateDrawMode(functionName, mode)) 5189 if (isContextLost() || !validateDrawMode(functionName, mode))
5190 return false; 5190 return false;
5191 5191
5192 if (!validateStencilSettings(functionName)) 5192 if (!validateStencilSettings(functionName))
5193 return false; 5193 return false;
5194 5194
5195 if (first < 0 || count < 0) { 5195 if (first < 0 || count < 0) {
5196 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "first or count < 0"); 5196 synthesizeGLError(GL_INVALID_VALUE, functionName, "first or count < 0");
5197 return false; 5197 return false;
5198 } 5198 }
5199 5199
5200 if (!count) { 5200 if (!count) {
5201 markContextChanged(); 5201 markContextChanged();
5202 return false; 5202 return false;
5203 } 5203 }
5204 5204
5205 if (!validateRenderingState()) { 5205 if (!validateRenderingState()) {
5206 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "a ttribs not setup correctly"); 5206 synthesizeGLError(GL_INVALID_OPERATION, functionName, "attribs not setup correctly");
5207 return false; 5207 return false;
5208 } 5208 }
5209 5209
5210 const char* reason = "framebuffer incomplete"; 5210 const char* reason = "framebuffer incomplete";
5211 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 5211 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) {
5212 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason); 5212 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason );
5213 return false; 5213 return false;
5214 } 5214 }
5215 5215
5216 return true; 5216 return true;
5217 } 5217 }
5218 5218
5219 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3De num mode, GC3Dsizei count, GC3Denum type, long long offset) 5219 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3De num mode, GC3Dsizei count, GC3Denum type, long long offset)
5220 { 5220 {
5221 if (isContextLost() || !validateDrawMode(functionName, mode)) 5221 if (isContextLost() || !validateDrawMode(functionName, mode))
5222 return false; 5222 return false;
5223 5223
5224 if (!validateStencilSettings(functionName)) 5224 if (!validateStencilSettings(functionName))
5225 return false; 5225 return false;
5226 5226
5227 switch (type) { 5227 switch (type) {
5228 case GraphicsContext3D::UNSIGNED_BYTE: 5228 case GL_UNSIGNED_BYTE:
5229 case GraphicsContext3D::UNSIGNED_SHORT: 5229 case GL_UNSIGNED_SHORT:
5230 break; 5230 break;
5231 case GraphicsContext3D::UNSIGNED_INT: 5231 case GL_UNSIGNED_INT:
5232 if (m_oesElementIndexUint) 5232 if (m_oesElementIndexUint)
5233 break; 5233 break;
5234 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d type"); 5234 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid type");
5235 return false; 5235 return false;
5236 default: 5236 default:
5237 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invali d type"); 5237 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid type");
5238 return false; 5238 return false;
5239 } 5239 }
5240 5240
5241 if (count < 0 || offset < 0) { 5241 if (count < 0 || offset < 0) {
5242 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "count or offset < 0"); 5242 synthesizeGLError(GL_INVALID_VALUE, functionName, "count or offset < 0") ;
5243 return false; 5243 return false;
5244 } 5244 }
5245 5245
5246 if (!count) { 5246 if (!count) {
5247 markContextChanged(); 5247 markContextChanged();
5248 return false; 5248 return false;
5249 } 5249 }
5250 5250
5251 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { 5251 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) {
5252 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "n o ELEMENT_ARRAY_BUFFER bound"); 5252 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_ BUFFER bound");
5253 return false; 5253 return false;
5254 } 5254 }
5255 5255
5256 if (!validateRenderingState()) { 5256 if (!validateRenderingState()) {
5257 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "a ttribs not setup correctly"); 5257 synthesizeGLError(GL_INVALID_OPERATION, functionName, "attribs not setup correctly");
5258 return false; 5258 return false;
5259 } 5259 }
5260 5260
5261 const char* reason = "framebuffer incomplete"; 5261 const char* reason = "framebuffer incomplete";
5262 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) { 5262 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3 D(), &reason)) {
5263 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, func tionName, reason); 5263 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason );
5264 return false; 5264 return false;
5265 } 5265 }
5266 5266
5267 return true; 5267 return true;
5268 } 5268 }
5269 5269
5270 // Helper function to validate draw*Instanced calls 5270 // Helper function to validate draw*Instanced calls
5271 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GC3D sizei primcount) 5271 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GC3D sizei primcount)
5272 { 5272 {
5273 if (primcount < 0) { 5273 if (primcount < 0) {
5274 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "primc ount < 0"); 5274 synthesizeGLError(GL_INVALID_VALUE, functionName, "primcount < 0");
5275 return false; 5275 return false;
5276 } 5276 }
5277 5277
5278 // Ensure at least one enabled vertex attrib has a divisor of 0. 5278 // Ensure at least one enabled vertex attrib has a divisor of 0.
5279 for (unsigned i = 0; i < m_onePlusMaxEnabledAttribIndex; ++i) { 5279 for (unsigned i = 0; i < m_onePlusMaxEnabledAttribIndex; ++i) {
5280 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte xArrayObject->getVertexAttribState(i); 5280 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVerte xArrayObject->getVertexAttribState(i);
5281 if (state.enabled && !state.divisor) 5281 if (state.enabled && !state.divisor)
5282 return true; 5282 return true;
5283 } 5283 }
5284 5284
5285 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "at le ast one enabled attribute must have a divisor of 0"); 5285 synthesizeGLError(GL_INVALID_OPERATION, functionName, "at least one enabled attribute must have a divisor of 0");
5286 return false; 5286 return false;
5287 } 5287 }
5288 5288
5289 void WebGLRenderingContext::vertexAttribfImpl(const char* functionName, GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfl oat v3) 5289 void WebGLRenderingContext::vertexAttribfImpl(const char* functionName, GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfl oat v3)
5290 { 5290 {
5291 if (isContextLost()) 5291 if (isContextLost())
5292 return; 5292 return;
5293 if (index >= m_maxVertexAttribs) { 5293 if (index >= m_maxVertexAttribs) {
5294 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "index out of range"); 5294 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range");
5295 return; 5295 return;
5296 } 5296 }
5297 // In GL, we skip setting vertexAttrib0 values. 5297 // In GL, we skip setting vertexAttrib0 values.
5298 switch (expectedSize) { 5298 switch (expectedSize) {
5299 case 1: 5299 case 1:
5300 m_context->vertexAttrib1f(index, v0); 5300 m_context->vertexAttrib1f(index, v0);
5301 break; 5301 break;
5302 case 2: 5302 case 2:
5303 m_context->vertexAttrib2f(index, v0, v1); 5303 m_context->vertexAttrib2f(index, v0, v1);
5304 break; 5304 break;
5305 case 3: 5305 case 3:
5306 m_context->vertexAttrib3f(index, v0, v1, v2); 5306 m_context->vertexAttrib3f(index, v0, v1, v2);
5307 break; 5307 break;
5308 case 4: 5308 case 4:
5309 m_context->vertexAttrib4f(index, v0, v1, v2, v3); 5309 m_context->vertexAttrib4f(index, v0, v1, v2, v3);
5310 break; 5310 break;
5311 } 5311 }
5312 VertexAttribValue& attribValue = m_vertexAttribValue[index]; 5312 VertexAttribValue& attribValue = m_vertexAttribValue[index];
5313 attribValue.value[0] = v0; 5313 attribValue.value[0] = v0;
5314 attribValue.value[1] = v1; 5314 attribValue.value[1] = v1;
5315 attribValue.value[2] = v2; 5315 attribValue.value[2] = v2;
5316 attribValue.value[3] = v3; 5316 attribValue.value[3] = v3;
5317 } 5317 }
5318 5318
5319 void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duin t index, Float32Array* v, GC3Dsizei expectedSize) 5319 void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duin t index, Float32Array* v, GC3Dsizei expectedSize)
5320 { 5320 {
5321 if (isContextLost()) 5321 if (isContextLost())
5322 return; 5322 return;
5323 if (!v) { 5323 if (!v) {
5324 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5324 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
5325 return; 5325 return;
5326 } 5326 }
5327 vertexAttribfvImpl(functionName, index, v->data(), v->length(), expectedSize ); 5327 vertexAttribfvImpl(functionName, index, v->data(), v->length(), expectedSize );
5328 } 5328 }
5329 5329
5330 void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duin t index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize) 5330 void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duin t index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize)
5331 { 5331 {
5332 if (isContextLost()) 5332 if (isContextLost())
5333 return; 5333 return;
5334 if (!v) { 5334 if (!v) {
5335 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ar ray"); 5335 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array");
5336 return; 5336 return;
5337 } 5337 }
5338 if (size < expectedSize) { 5338 if (size < expectedSize) {
5339 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "inval id size"); 5339 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size");
5340 return; 5340 return;
5341 } 5341 }
5342 if (index >= m_maxVertexAttribs) { 5342 if (index >= m_maxVertexAttribs) {
5343 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "index out of range"); 5343 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range");
5344 return; 5344 return;
5345 } 5345 }
5346 // In GL, we skip setting vertexAttrib0 values. 5346 // In GL, we skip setting vertexAttrib0 values.
5347 switch (expectedSize) { 5347 switch (expectedSize) {
5348 case 1: 5348 case 1:
5349 m_context->vertexAttrib1fv(index, v); 5349 m_context->vertexAttrib1fv(index, v);
5350 break; 5350 break;
5351 case 2: 5351 case 2:
5352 m_context->vertexAttrib2fv(index, v); 5352 m_context->vertexAttrib2fv(index, v);
5353 break; 5353 break;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5395 5395
5396 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) 5396 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ()))
5397 return; 5397 return;
5398 5398
5399 // Reset the context attributes back to the requested attributes and re-appl y restrictions 5399 // Reset the context attributes back to the requested attributes and re-appl y restrictions
5400 m_attributes = adjustAttributes(m_requestedAttributes, settings); 5400 m_attributes = adjustAttributes(m_requestedAttributes, settings);
5401 5401
5402 RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(m_attributes)); 5402 RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(m_attributes));
5403 5403
5404 if (!context) { 5404 if (!context) {
5405 if (m_contextLostMode == RealLostContext) 5405 if (m_contextLostMode == RealLostContext) {
5406 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); 5406 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts);
5407 else 5407 } else {
5408 // This likely shouldn't happen but is the best way to report it to the WebGL app. 5408 // This likely shouldn't happen but is the best way to report it to the WebGL app.
5409 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "", "error r estoring context"); 5409 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context ");
5410 }
5410 return; 5411 return;
5411 } 5412 }
5412 5413
5413 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager()); 5414 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager());
5414 5415
5415 // Construct a new drawing buffer with the new GraphicsContext3D. 5416 // Construct a new drawing buffer with the new GraphicsContext3D.
5416 m_drawingBuffer->releaseResources(); 5417 m_drawingBuffer->releaseResources();
5417 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; 5418 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard;
5418 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release()); 5419 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release());
5419 5420
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
5473 { 5474 {
5474 for (int i = idx; i > 0; --i) 5475 for (int i = idx; i > 0; --i)
5475 m_buffers[i].swap(m_buffers[i-1]); 5476 m_buffers[i].swap(m_buffers[i-1]);
5476 } 5477 }
5477 5478
5478 namespace { 5479 namespace {
5479 5480
5480 String GetErrorString(GC3Denum error) 5481 String GetErrorString(GC3Denum error)
5481 { 5482 {
5482 switch (error) { 5483 switch (error) {
5483 case GraphicsContext3D::INVALID_ENUM: 5484 case GL_INVALID_ENUM:
5484 return "INVALID_ENUM"; 5485 return "INVALID_ENUM";
5485 case GraphicsContext3D::INVALID_VALUE: 5486 case GL_INVALID_VALUE:
5486 return "INVALID_VALUE"; 5487 return "INVALID_VALUE";
5487 case GraphicsContext3D::INVALID_OPERATION: 5488 case GL_INVALID_OPERATION:
5488 return "INVALID_OPERATION"; 5489 return "INVALID_OPERATION";
5489 case GraphicsContext3D::OUT_OF_MEMORY: 5490 case GL_OUT_OF_MEMORY:
5490 return "OUT_OF_MEMORY"; 5491 return "OUT_OF_MEMORY";
5491 case GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION: 5492 case GL_INVALID_FRAMEBUFFER_OPERATION:
5492 return "INVALID_FRAMEBUFFER_OPERATION"; 5493 return "INVALID_FRAMEBUFFER_OPERATION";
5493 case GraphicsContext3D::CONTEXT_LOST_WEBGL: 5494 case GC3D_CONTEXT_LOST_WEBGL:
5494 return "CONTEXT_LOST_WEBGL"; 5495 return "CONTEXT_LOST_WEBGL";
5495 default: 5496 default:
5496 return String::format("WebGL ERROR(0x%04X)", error); 5497 return String::format("WebGL ERROR(0x%04X)", error);
5497 } 5498 }
5498 } 5499 }
5499 5500
5500 } // namespace anonymous 5501 } // namespace anonymous
5501 5502
5502 void WebGLRenderingContext::synthesizeGLError(GC3Denum error, const char* functi onName, const char* description, ConsoleDisplayPreference display) 5503 void WebGLRenderingContext::synthesizeGLError(GC3Denum error, const char* functi onName, const char* description, ConsoleDisplayPreference display)
5503 { 5504 {
(...skipping 23 matching lines...) Expand all
5527 void WebGLRenderingContext::applyStencilTest() 5528 void WebGLRenderingContext::applyStencilTest()
5528 { 5529 {
5529 bool haveStencilBuffer = false; 5530 bool haveStencilBuffer = false;
5530 5531
5531 if (m_framebufferBinding) 5532 if (m_framebufferBinding)
5532 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); 5533 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer();
5533 else { 5534 else {
5534 RefPtr<WebGLContextAttributes> attributes = getContextAttributes(); 5535 RefPtr<WebGLContextAttributes> attributes = getContextAttributes();
5535 haveStencilBuffer = attributes->stencil(); 5536 haveStencilBuffer = attributes->stencil();
5536 } 5537 }
5537 enableOrDisable(GraphicsContext3D::STENCIL_TEST, 5538 enableOrDisable(GL_STENCIL_TEST,
5538 m_stencilEnabled && haveStencilBuffer); 5539 m_stencilEnabled && haveStencilBuffer);
5539 } 5540 }
5540 5541
5541 void WebGLRenderingContext::enableOrDisable(GC3Denum capability, bool enable) 5542 void WebGLRenderingContext::enableOrDisable(GC3Denum capability, bool enable)
5542 { 5543 {
5543 if (isContextLost()) 5544 if (isContextLost())
5544 return; 5545 return;
5545 if (enable) 5546 if (enable)
5546 m_context->enable(capability); 5547 m_context->enable(capability);
5547 else 5548 else
(...skipping 27 matching lines...) Expand all
5575 return m_maxColorAttachments; 5576 return m_maxColorAttachments;
5576 } 5577 }
5577 5578
5578 void WebGLRenderingContext::setBackDrawBuffer(GC3Denum buf) 5579 void WebGLRenderingContext::setBackDrawBuffer(GC3Denum buf)
5579 { 5580 {
5580 m_backDrawBuffer = buf; 5581 m_backDrawBuffer = buf;
5581 } 5582 }
5582 5583
5583 void WebGLRenderingContext::restoreCurrentFramebuffer() 5584 void WebGLRenderingContext::restoreCurrentFramebuffer()
5584 { 5585 {
5585 bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_framebufferBinding.get()); 5586 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get());
5586 } 5587 }
5587 5588
5588 void WebGLRenderingContext::restoreCurrentTexture2D() 5589 void WebGLRenderingContext::restoreCurrentTexture2D()
5589 { 5590 {
5590 bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureUnits[m_activeTextureUni t].m_texture2DBinding.get()); 5591 bindTexture(GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_texture2DBi nding.get());
5591 } 5592 }
5592 5593
5593 void WebGLRenderingContext::multisamplingChanged(bool enabled) 5594 void WebGLRenderingContext::multisamplingChanged(bool enabled)
5594 { 5595 {
5595 if (m_multisamplingAllowed != enabled) { 5596 if (m_multisamplingAllowed != enabled) {
5596 m_multisamplingAllowed = enabled; 5597 m_multisamplingAllowed = enabled;
5597 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext) ; 5598 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext) ;
5598 } 5599 }
5599 } 5600 }
5600 5601
(...skipping 18 matching lines...) Expand all
5619 if (m_textureUnits[i].m_texture2DBinding 5620 if (m_textureUnits[i].m_texture2DBinding
5620 || m_textureUnits[i].m_textureCubeMapBinding) { 5621 || m_textureUnits[i].m_textureCubeMapBinding) {
5621 m_onePlusMaxNonDefaultTextureUnit = i + 1; 5622 m_onePlusMaxNonDefaultTextureUnit = i + 1;
5622 return; 5623 return;
5623 } 5624 }
5624 } 5625 }
5625 m_onePlusMaxNonDefaultTextureUnit = 0; 5626 m_onePlusMaxNonDefaultTextureUnit = 0;
5626 } 5627 }
5627 5628
5628 } // namespace WebCore 5629 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698