| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 , m_onePlusMaxEnabledAttribIndex(0) | 555 , m_onePlusMaxEnabledAttribIndex(0) |
| 556 , m_onePlusMaxNonDefaultTextureUnit(0) | 556 , m_onePlusMaxNonDefaultTextureUnit(0) |
| 557 { | 557 { |
| 558 ASSERT(m_context); | 558 ASSERT(m_context); |
| 559 ScriptWrappable::init(this); | 559 ScriptWrappable::init(this); |
| 560 | 560 |
| 561 m_contextGroup = WebGLContextGroup::create(); | 561 m_contextGroup = WebGLContextGroup::create(); |
| 562 m_contextGroup->addContext(this); | 562 m_contextGroup->addContext(this); |
| 563 | 563 |
| 564 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; | 564 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; |
| 565 m_context->getIntegerv(GraphicsContext3D::MAX_VIEWPORT_DIMS, m_maxViewportDi
ms); | 565 m_context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); |
| 566 | 566 |
| 567 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | 567 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); |
| 568 | 568 |
| 569 // Create the DrawingBuffer and initialize the platform layer. | 569 // Create the DrawingBuffer and initialize the platform layer. |
| 570 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing
Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 570 DrawingBuffer::PreserveDrawingBuffer preserve = m_attributes.preserveDrawing
Buffer ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| 571 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize()
, preserve, contextEvictionManager.release()); | 571 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize()
, preserve, contextEvictionManager.release()); |
| 572 | 572 |
| 573 if (!m_drawingBuffer->isZeroSized()) { | 573 if (!m_drawingBuffer->isZeroSized()) { |
| 574 m_drawingBuffer->bind(); | 574 m_drawingBuffer->bind(); |
| 575 setupFlags(); | 575 setupFlags(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 void WebGLRenderingContext::initializeNewContext() | 607 void WebGLRenderingContext::initializeNewContext() |
| 608 { | 608 { |
| 609 ASSERT(!isContextLost()); | 609 ASSERT(!isContextLost()); |
| 610 m_needsUpdate = true; | 610 m_needsUpdate = true; |
| 611 m_markedCanvasDirty = false; | 611 m_markedCanvasDirty = false; |
| 612 m_activeTextureUnit = 0; | 612 m_activeTextureUnit = 0; |
| 613 m_packAlignment = 4; | 613 m_packAlignment = 4; |
| 614 m_unpackAlignment = 4; | 614 m_unpackAlignment = 4; |
| 615 m_unpackFlipY = false; | 615 m_unpackFlipY = false; |
| 616 m_unpackPremultiplyAlpha = false; | 616 m_unpackPremultiplyAlpha = false; |
| 617 m_unpackColorspaceConversion = GraphicsContext3D::BROWSER_DEFAULT_WEBGL; | 617 m_unpackColorspaceConversion = GC3D_BROWSER_DEFAULT_WEBGL; |
| 618 m_boundArrayBuffer = 0; | 618 m_boundArrayBuffer = 0; |
| 619 m_currentProgram = 0; | 619 m_currentProgram = 0; |
| 620 m_framebufferBinding = 0; | 620 m_framebufferBinding = 0; |
| 621 m_renderbufferBinding = 0; | 621 m_renderbufferBinding = 0; |
| 622 m_depthMask = true; | 622 m_depthMask = true; |
| 623 m_stencilEnabled = false; | 623 m_stencilEnabled = false; |
| 624 m_stencilMask = 0xFFFFFFFF; | 624 m_stencilMask = 0xFFFFFFFF; |
| 625 m_stencilMaskBack = 0xFFFFFFFF; | 625 m_stencilMaskBack = 0xFFFFFFFF; |
| 626 m_stencilFuncRef = 0; | 626 m_stencilFuncRef = 0; |
| 627 m_stencilFuncRefBack = 0; | 627 m_stencilFuncRefBack = 0; |
| 628 m_stencilFuncMask = 0xFFFFFFFF; | 628 m_stencilFuncMask = 0xFFFFFFFF; |
| 629 m_stencilFuncMaskBack = 0xFFFFFFFF; | 629 m_stencilFuncMaskBack = 0xFFFFFFFF; |
| 630 m_layerCleared = false; | 630 m_layerCleared = false; |
| 631 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; | 631 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; |
| 632 | 632 |
| 633 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; | 633 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; |
| 634 m_scissorEnabled = false; | 634 m_scissorEnabled = false; |
| 635 m_clearDepth = 1; | 635 m_clearDepth = 1; |
| 636 m_clearStencil = 0; | 636 m_clearStencil = 0; |
| 637 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; | 637 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; |
| 638 | 638 |
| 639 GC3Dint numCombinedTextureImageUnits = 0; | 639 GC3Dint numCombinedTextureImageUnits = 0; |
| 640 m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS,
&numCombinedTextureImageUnits); | 640 m_context->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedText
ureImageUnits); |
| 641 m_textureUnits.clear(); | 641 m_textureUnits.clear(); |
| 642 m_textureUnits.resize(numCombinedTextureImageUnits); | 642 m_textureUnits.resize(numCombinedTextureImageUnits); |
| 643 | 643 |
| 644 GC3Dint numVertexAttribs = 0; | 644 GC3Dint numVertexAttribs = 0; |
| 645 m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &numVertexAttr
ibs); | 645 m_context->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); |
| 646 m_maxVertexAttribs = numVertexAttribs; | 646 m_maxVertexAttribs = numVertexAttribs; |
| 647 | 647 |
| 648 m_maxTextureSize = 0; | 648 m_maxTextureSize = 0; |
| 649 m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_maxTextureSiz
e); | 649 m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); |
| 650 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT
extureSize); | 650 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT
extureSize); |
| 651 m_maxCubeMapTextureSize = 0; | 651 m_maxCubeMapTextureSize = 0; |
| 652 m_context->getIntegerv(GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxC
ubeMapTextureSize); | 652 m_context->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSiz
e); |
| 653 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu
reSize, m_maxCubeMapTextureSize); | 653 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu
reSize, m_maxCubeMapTextureSize); |
| 654 m_maxRenderbufferSize = 0; | 654 m_maxRenderbufferSize = 0; |
| 655 m_context->getIntegerv(GraphicsContext3D::MAX_RENDERBUFFER_SIZE, &m_maxRende
rbufferSize); | 655 m_context->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); |
| 656 | 656 |
| 657 // These two values from EXT_draw_buffers are lazily queried. | 657 // These two values from EXT_draw_buffers are lazily queried. |
| 658 m_maxDrawBuffers = 0; | 658 m_maxDrawBuffers = 0; |
| 659 m_maxColorAttachments = 0; | 659 m_maxColorAttachments = 0; |
| 660 | 660 |
| 661 m_backDrawBuffer = GraphicsContext3D::BACK; | 661 m_backDrawBuffer = GL_BACK; |
| 662 | 662 |
| 663 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe
rtexArrayObjectOES::VaoTypeDefault); | 663 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe
rtexArrayObjectOES::VaoTypeDefault); |
| 664 addContextObject(m_defaultVertexArrayObject.get()); | 664 addContextObject(m_defaultVertexArrayObject.get()); |
| 665 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 665 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 666 | 666 |
| 667 m_vertexAttribValue.resize(m_maxVertexAttribs); | 667 m_vertexAttribValue.resize(m_maxVertexAttribs); |
| 668 | 668 |
| 669 createFallbackBlackTextures1x1(); | 669 createFallbackBlackTextures1x1(); |
| 670 | 670 |
| 671 IntSize canvasSize = clampedCanvasSize(); | 671 IntSize canvasSize = clampedCanvasSize(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 | 811 |
| 812 if (!m_context->layerComposited() || m_layerCleared | 812 if (!m_context->layerComposited() || m_layerCleared |
| 813 || m_attributes.preserveDrawingBuffer || (mask && m_framebufferBinding)) | 813 || m_attributes.preserveDrawingBuffer || (mask && m_framebufferBinding)) |
| 814 return false; | 814 return false; |
| 815 | 815 |
| 816 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes(); | 816 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes(); |
| 817 | 817 |
| 818 // Determine if it's possible to combine the clear the user asked for and th
is clear. | 818 // Determine if it's possible to combine the clear the user asked for and th
is clear. |
| 819 bool combinedClear = mask && !m_scissorEnabled; | 819 bool combinedClear = mask && !m_scissorEnabled; |
| 820 | 820 |
| 821 m_context->disable(GraphicsContext3D::SCISSOR_TEST); | 821 m_context->disable(GL_SCISSOR_TEST); |
| 822 if (combinedClear && (mask & GraphicsContext3D::COLOR_BUFFER_BIT)) | 822 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) |
| 823 m_context->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 823 m_context->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, |
| 824 m_colorMask[1] ? m_clearColor[1] : 0, | 824 m_colorMask[1] ? m_clearColor[1] : 0, |
| 825 m_colorMask[2] ? m_clearColor[2] : 0, | 825 m_colorMask[2] ? m_clearColor[2] : 0, |
| 826 m_colorMask[3] ? m_clearColor[3] : 0); | 826 m_colorMask[3] ? m_clearColor[3] : 0); |
| 827 else | 827 else |
| 828 m_context->clearColor(0, 0, 0, 0); | 828 m_context->clearColor(0, 0, 0, 0); |
| 829 m_context->colorMask(true, true, true, true); | 829 m_context->colorMask(true, true, true, true); |
| 830 GC3Dbitfield clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; | 830 GC3Dbitfield clearMask = GL_COLOR_BUFFER_BIT; |
| 831 if (contextAttributes->depth()) { | 831 if (contextAttributes->depth()) { |
| 832 if (!combinedClear || !m_depthMask || !(mask & GraphicsContext3D::DEPTH_
BUFFER_BIT)) | 832 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) |
| 833 m_context->clearDepth(1.0f); | 833 m_context->clearDepth(1.0f); |
| 834 clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; | 834 clearMask |= GL_DEPTH_BUFFER_BIT; |
| 835 m_context->depthMask(true); | 835 m_context->depthMask(true); |
| 836 } | 836 } |
| 837 if (contextAttributes->stencil()) { | 837 if (contextAttributes->stencil()) { |
| 838 if (combinedClear && (mask & GraphicsContext3D::STENCIL_BUFFER_BIT)) | 838 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) |
| 839 m_context->clearStencil(m_clearStencil & m_stencilMask); | 839 m_context->clearStencil(m_clearStencil & m_stencilMask); |
| 840 else | 840 else |
| 841 m_context->clearStencil(0); | 841 m_context->clearStencil(0); |
| 842 clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; | 842 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 843 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xFFFFFFFF); | 843 m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 844 } | 844 } |
| 845 | 845 |
| 846 m_drawingBuffer->clearFramebuffers(clearMask); | 846 m_drawingBuffer->clearFramebuffers(clearMask); |
| 847 | 847 |
| 848 restoreStateAfterClear(); | 848 restoreStateAfterClear(); |
| 849 if (m_framebufferBinding) | 849 if (m_framebufferBinding) |
| 850 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero(
m_framebufferBinding.get())); | 850 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); |
| 851 m_layerCleared = true; | 851 m_layerCleared = true; |
| 852 | 852 |
| 853 return combinedClear; | 853 return combinedClear; |
| 854 } | 854 } |
| 855 | 855 |
| 856 void WebGLRenderingContext::restoreStateAfterClear() | 856 void WebGLRenderingContext::restoreStateAfterClear() |
| 857 { | 857 { |
| 858 if (isContextLost()) | 858 if (isContextLost()) |
| 859 return; | 859 return; |
| 860 | 860 |
| 861 // Restore the state that the context set. | 861 // Restore the state that the context set. |
| 862 if (m_scissorEnabled) | 862 if (m_scissorEnabled) |
| 863 m_context->enable(GraphicsContext3D::SCISSOR_TEST); | 863 m_context->enable(GL_SCISSOR_TEST); |
| 864 m_context->clearColor(m_clearColor[0], m_clearColor[1], | 864 m_context->clearColor(m_clearColor[0], m_clearColor[1], |
| 865 m_clearColor[2], m_clearColor[3]); | 865 m_clearColor[2], m_clearColor[3]); |
| 866 m_context->colorMask(m_colorMask[0], m_colorMask[1], | 866 m_context->colorMask(m_colorMask[0], m_colorMask[1], |
| 867 m_colorMask[2], m_colorMask[3]); | 867 m_colorMask[2], m_colorMask[3]); |
| 868 m_context->clearDepth(m_clearDepth); | 868 m_context->clearDepth(m_clearDepth); |
| 869 m_context->clearStencil(m_clearStencil); | 869 m_context->clearStencil(m_clearStencil); |
| 870 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, m_stencilMask); | 870 m_context->stencilMaskSeparate(GL_FRONT, m_stencilMask); |
| 871 m_context->depthMask(m_depthMask); | 871 m_context->depthMask(m_depthMask); |
| 872 } | 872 } |
| 873 | 873 |
| 874 void WebGLRenderingContext::markLayerComposited() | 874 void WebGLRenderingContext::markLayerComposited() |
| 875 { | 875 { |
| 876 if (!isContextLost()) | 876 if (!isContextLost()) |
| 877 m_context->markLayerComposited(); | 877 m_context->markLayerComposited(); |
| 878 } | 878 } |
| 879 | 879 |
| 880 void WebGLRenderingContext::paintRenderingResultsToCanvas() | 880 void WebGLRenderingContext::paintRenderingResultsToCanvas() |
| (...skipping 20 matching lines...) Expand all Loading... |
| 901 return; | 901 return; |
| 902 | 902 |
| 903 canvas()->clearCopiedImage(); | 903 canvas()->clearCopiedImage(); |
| 904 m_markedCanvasDirty = false; | 904 m_markedCanvasDirty = false; |
| 905 | 905 |
| 906 m_drawingBuffer->commit(); | 906 m_drawingBuffer->commit(); |
| 907 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu
ffer.get())) | 907 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu
ffer.get())) |
| 908 m_context->paintRenderingResultsToCanvas(canvas()->buffer(), m_drawingBu
ffer.get()); | 908 m_context->paintRenderingResultsToCanvas(canvas()->buffer(), m_drawingBu
ffer.get()); |
| 909 | 909 |
| 910 if (m_framebufferBinding) | 910 if (m_framebufferBinding) |
| 911 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero(
m_framebufferBinding.get())); | 911 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); |
| 912 else | 912 else |
| 913 m_drawingBuffer->bind(); | 913 m_drawingBuffer->bind(); |
| 914 } | 914 } |
| 915 | 915 |
| 916 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData() | 916 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData() |
| 917 { | 917 { |
| 918 if (isContextLost()) | 918 if (isContextLost()) |
| 919 return 0; | 919 return 0; |
| 920 | 920 |
| 921 clearIfComposited(); | 921 clearIfComposited(); |
| 922 m_drawingBuffer->commit(); | 922 m_drawingBuffer->commit(); |
| 923 int width, height; | 923 int width, height; |
| 924 RefPtr<Uint8ClampedArray> imageDataPixels = m_context->paintRenderingResults
ToImageData(m_drawingBuffer.get(), width, height); | 924 RefPtr<Uint8ClampedArray> imageDataPixels = m_context->paintRenderingResults
ToImageData(m_drawingBuffer.get(), width, height); |
| 925 if (!imageDataPixels) | 925 if (!imageDataPixels) |
| 926 return 0; | 926 return 0; |
| 927 | 927 |
| 928 if (m_framebufferBinding) | 928 if (m_framebufferBinding) |
| 929 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero(
m_framebufferBinding.get())); | 929 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); |
| 930 else | 930 else |
| 931 m_drawingBuffer->bind(); | 931 m_drawingBuffer->bind(); |
| 932 | 932 |
| 933 return ImageData::create(IntSize(width, height), imageDataPixels); | 933 return ImageData::create(IntSize(width, height), imageDataPixels); |
| 934 } | 934 } |
| 935 | 935 |
| 936 void WebGLRenderingContext::reshape(int width, int height) | 936 void WebGLRenderingContext::reshape(int width, int height) |
| 937 { | 937 { |
| 938 if (isContextLost()) | 938 if (isContextLost()) |
| 939 return; | 939 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 954 if (renderBox && renderBox->hasAcceleratedCompositing()) | 954 if (renderBox && renderBox->hasAcceleratedCompositing()) |
| 955 renderBox->contentChanged(CanvasChanged); | 955 renderBox->contentChanged(CanvasChanged); |
| 956 m_needsUpdate = false; | 956 m_needsUpdate = false; |
| 957 } | 957 } |
| 958 | 958 |
| 959 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off | 959 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off |
| 960 // clear (and this matches what reshape will do). | 960 // clear (and this matches what reshape will do). |
| 961 m_drawingBuffer->reset(IntSize(width, height)); | 961 m_drawingBuffer->reset(IntSize(width, height)); |
| 962 restoreStateAfterClear(); | 962 restoreStateAfterClear(); |
| 963 | 963 |
| 964 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(m_texture
Units[m_activeTextureUnit].m_texture2DBinding.get())); | 964 m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTe
xtureUnit].m_texture2DBinding.get())); |
| 965 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, objectOrZero(m_
renderbufferBinding.get())); | 965 m_context->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBind
ing.get())); |
| 966 if (m_framebufferBinding) | 966 if (m_framebufferBinding) |
| 967 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, objectOrZero(m_
framebufferBinding.get())); | 967 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); |
| 968 } | 968 } |
| 969 | 969 |
| 970 int WebGLRenderingContext::drawingBufferWidth() const | 970 int WebGLRenderingContext::drawingBufferWidth() const |
| 971 { | 971 { |
| 972 return m_drawingBuffer->size().width(); | 972 return m_drawingBuffer->size().width(); |
| 973 } | 973 } |
| 974 | 974 |
| 975 int WebGLRenderingContext::drawingBufferHeight() const | 975 int WebGLRenderingContext::drawingBufferHeight() const |
| 976 { | 976 { |
| 977 return m_drawingBuffer->size().height(); | 977 return m_drawingBuffer->size().height(); |
| 978 } | 978 } |
| 979 | 979 |
| 980 unsigned int WebGLRenderingContext::sizeInBytes(GC3Denum type) | 980 unsigned int WebGLRenderingContext::sizeInBytes(GC3Denum type) |
| 981 { | 981 { |
| 982 switch (type) { | 982 switch (type) { |
| 983 case GraphicsContext3D::BYTE: | 983 case GL_BYTE: |
| 984 return sizeof(GC3Dbyte); | 984 return sizeof(GC3Dbyte); |
| 985 case GraphicsContext3D::UNSIGNED_BYTE: | 985 case GL_UNSIGNED_BYTE: |
| 986 return sizeof(GC3Dubyte); | 986 return sizeof(GC3Dubyte); |
| 987 case GraphicsContext3D::SHORT: | 987 case GL_SHORT: |
| 988 return sizeof(GC3Dshort); | 988 return sizeof(GC3Dshort); |
| 989 case GraphicsContext3D::UNSIGNED_SHORT: | 989 case GL_UNSIGNED_SHORT: |
| 990 return sizeof(GC3Dushort); | 990 return sizeof(GC3Dushort); |
| 991 case GraphicsContext3D::INT: | 991 case GL_INT: |
| 992 return sizeof(GC3Dint); | 992 return sizeof(GC3Dint); |
| 993 case GraphicsContext3D::UNSIGNED_INT: | 993 case GL_UNSIGNED_INT: |
| 994 return sizeof(GC3Duint); | 994 return sizeof(GC3Duint); |
| 995 case GraphicsContext3D::FLOAT: | 995 case GL_FLOAT: |
| 996 return sizeof(GC3Dfloat); | 996 return sizeof(GC3Dfloat); |
| 997 } | 997 } |
| 998 ASSERT_NOT_REACHED(); | 998 ASSERT_NOT_REACHED(); |
| 999 return 0; | 999 return 0; |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 void WebGLRenderingContext::activeTexture(GC3Denum texture) | 1002 void WebGLRenderingContext::activeTexture(GC3Denum texture) |
| 1003 { | 1003 { |
| 1004 if (isContextLost()) | 1004 if (isContextLost()) |
| 1005 return; | 1005 return; |
| 1006 if (texture - GraphicsContext3D::TEXTURE0 >= m_textureUnits.size()) { | 1006 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { |
| 1007 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "activeTexture", "tex
ture unit out of range"); | 1007 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); |
| 1008 return; | 1008 return; |
| 1009 } | 1009 } |
| 1010 m_activeTextureUnit = texture - GraphicsContext3D::TEXTURE0; | 1010 m_activeTextureUnit = texture - GL_TEXTURE0; |
| 1011 m_context->activeTexture(texture); | 1011 m_context->activeTexture(texture); |
| 1012 | 1012 |
| 1013 m_drawingBuffer->setActiveTextureUnit(texture); | 1013 m_drawingBuffer->setActiveTextureUnit(texture); |
| 1014 | 1014 |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha
der) | 1017 void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha
der) |
| 1018 { | 1018 { |
| 1019 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) | 1019 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) |
| 1020 return; | 1020 return; |
| 1021 if (!program->attachShader(shader)) { | 1021 if (!program->attachShader(shader)) { |
| 1022 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "attachShader",
"shader attachment already has shader"); | 1022 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme
nt already has shader"); |
| 1023 return; | 1023 return; |
| 1024 } | 1024 } |
| 1025 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); | 1025 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); |
| 1026 shader->onAttached(); | 1026 shader->onAttached(); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i
ndex, const String& name) | 1029 void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint i
ndex, const String& name) |
| 1030 { | 1030 { |
| 1031 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) | 1031 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) |
| 1032 return; | 1032 return; |
| 1033 if (!validateLocationLength("bindAttribLocation", name)) | 1033 if (!validateLocationLength("bindAttribLocation", name)) |
| 1034 return; | 1034 return; |
| 1035 if (!validateString("bindAttribLocation", name)) | 1035 if (!validateString("bindAttribLocation", name)) |
| 1036 return; | 1036 return; |
| 1037 if (isPrefixReserved(name)) { | 1037 if (isPrefixReserved(name)) { |
| 1038 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindAttribLocat
ion", "reserved prefix"); | 1038 synthesizeGLError(GL_INVALID_OPERATION, "bindAttribLocation", "reserved
prefix"); |
| 1039 return; | 1039 return; |
| 1040 } | 1040 } |
| 1041 if (index >= m_maxVertexAttribs) { | 1041 if (index >= m_maxVertexAttribs) { |
| 1042 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bindAttribLocation"
, "index out of range"); | 1042 synthesizeGLError(GL_INVALID_VALUE, "bindAttribLocation", "index out of
range"); |
| 1043 return; | 1043 return; |
| 1044 } | 1044 } |
| 1045 m_context->bindAttribLocation(objectOrZero(program), index, name); | 1045 m_context->bindAttribLocation(objectOrZero(program), index, name); |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGL
Object* object, bool& deleted) | 1048 bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGL
Object* object, bool& deleted) |
| 1049 { | 1049 { |
| 1050 deleted = false; | 1050 deleted = false; |
| 1051 if (isContextLost()) | 1051 if (isContextLost()) |
| 1052 return false; | 1052 return false; |
| 1053 if (object) { | 1053 if (object) { |
| 1054 if (!object->validate(contextGroup(), this)) { | 1054 if (!object->validate(contextGroup(), this)) { |
| 1055 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName
, "object not from this context"); | 1055 synthesizeGLError(GL_INVALID_OPERATION, functionName, "object not fr
om this context"); |
| 1056 return false; | 1056 return false; |
| 1057 } | 1057 } |
| 1058 deleted = !object->object(); | 1058 deleted = !object->object(); |
| 1059 } | 1059 } |
| 1060 return true; | 1060 return true; |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer) | 1063 void WebGLRenderingContext::bindBuffer(GC3Denum target, WebGLBuffer* buffer) |
| 1064 { | 1064 { |
| 1065 bool deleted; | 1065 bool deleted; |
| 1066 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) | 1066 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) |
| 1067 return; | 1067 return; |
| 1068 if (deleted) | 1068 if (deleted) |
| 1069 buffer = 0; | 1069 buffer = 0; |
| 1070 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { | 1070 if (buffer && buffer->getTarget() && buffer->getTarget() != target) { |
| 1071 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindBuffer", "b
uffers can not be used with multiple targets"); | 1071 synthesizeGLError(GL_INVALID_OPERATION, "bindBuffer", "buffers can not b
e used with multiple targets"); |
| 1072 return; | 1072 return; |
| 1073 } | 1073 } |
| 1074 if (target == GraphicsContext3D::ARRAY_BUFFER) | 1074 if (target == GL_ARRAY_BUFFER) |
| 1075 m_boundArrayBuffer = buffer; | 1075 m_boundArrayBuffer = buffer; |
| 1076 else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER) | 1076 else if (target == GL_ELEMENT_ARRAY_BUFFER) |
| 1077 m_boundVertexArrayObject->setElementArrayBuffer(buffer); | 1077 m_boundVertexArrayObject->setElementArrayBuffer(buffer); |
| 1078 else { | 1078 else { |
| 1079 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindBuffer", "invali
d target"); | 1079 synthesizeGLError(GL_INVALID_ENUM, "bindBuffer", "invalid target"); |
| 1080 return; | 1080 return; |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 m_context->bindBuffer(target, objectOrZero(buffer)); | 1083 m_context->bindBuffer(target, objectOrZero(buffer)); |
| 1084 if (buffer) | 1084 if (buffer) |
| 1085 buffer->setTarget(target); | 1085 buffer->setTarget(target); |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b
uffer) | 1088 void WebGLRenderingContext::bindFramebuffer(GC3Denum target, WebGLFramebuffer* b
uffer) |
| 1089 { | 1089 { |
| 1090 bool deleted; | 1090 bool deleted; |
| 1091 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1091 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
| 1092 return; | 1092 return; |
| 1093 if (deleted) | 1093 if (deleted) |
| 1094 buffer = 0; | 1094 buffer = 0; |
| 1095 if (target != GraphicsContext3D::FRAMEBUFFER) { | 1095 if (target != GL_FRAMEBUFFER) { |
| 1096 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindFramebuffer", "i
nvalid target"); | 1096 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
| 1097 return; | 1097 return; |
| 1098 } | 1098 } |
| 1099 m_framebufferBinding = buffer; | 1099 m_framebufferBinding = buffer; |
| 1100 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); | 1100 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); |
| 1101 if (!m_framebufferBinding) { | 1101 if (!m_framebufferBinding) { |
| 1102 // Instead of binding fb 0, bind the drawing buffer. | 1102 // Instead of binding fb 0, bind the drawing buffer. |
| 1103 m_drawingBuffer->bind(); | 1103 m_drawingBuffer->bind(); |
| 1104 } else | 1104 } else |
| 1105 m_context->bindFramebuffer(target, objectOrZero(buffer)); | 1105 m_context->bindFramebuffer(target, objectOrZero(buffer)); |
| 1106 if (buffer) | 1106 if (buffer) |
| 1107 buffer->setHasEverBeenBound(); | 1107 buffer->setHasEverBeenBound(); |
| 1108 applyStencilTest(); | 1108 applyStencilTest(); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer*
renderBuffer) | 1111 void WebGLRenderingContext::bindRenderbuffer(GC3Denum target, WebGLRenderbuffer*
renderBuffer) |
| 1112 { | 1112 { |
| 1113 bool deleted; | 1113 bool deleted; |
| 1114 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) | 1114 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) |
| 1115 return; | 1115 return; |
| 1116 if (deleted) | 1116 if (deleted) |
| 1117 renderBuffer = 0; | 1117 renderBuffer = 0; |
| 1118 if (target != GraphicsContext3D::RENDERBUFFER) { | 1118 if (target != GL_RENDERBUFFER) { |
| 1119 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindRenderbuffer", "
invalid target"); | 1119 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target")
; |
| 1120 return; | 1120 return; |
| 1121 } | 1121 } |
| 1122 m_renderbufferBinding = renderBuffer; | 1122 m_renderbufferBinding = renderBuffer; |
| 1123 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 1123 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); |
| 1124 if (renderBuffer) | 1124 if (renderBuffer) |
| 1125 renderBuffer->setHasEverBeenBound(); | 1125 renderBuffer->setHasEverBeenBound(); |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture) | 1128 void WebGLRenderingContext::bindTexture(GC3Denum target, WebGLTexture* texture) |
| 1129 { | 1129 { |
| 1130 bool deleted; | 1130 bool deleted; |
| 1131 if (!checkObjectToBeBound("bindTexture", texture, deleted)) | 1131 if (!checkObjectToBeBound("bindTexture", texture, deleted)) |
| 1132 return; | 1132 return; |
| 1133 if (deleted) | 1133 if (deleted) |
| 1134 texture = 0; | 1134 texture = 0; |
| 1135 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1135 if (texture && texture->getTarget() && texture->getTarget() != target) { |
| 1136 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "bindTexture", "
textures can not be used with multiple targets"); | 1136 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not
be used with multiple targets"); |
| 1137 return; | 1137 return; |
| 1138 } | 1138 } |
| 1139 GC3Dint maxLevel = 0; | 1139 GC3Dint maxLevel = 0; |
| 1140 if (target == GraphicsContext3D::TEXTURE_2D) { | 1140 if (target == GL_TEXTURE_2D) { |
| 1141 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; | 1141 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; |
| 1142 maxLevel = m_maxTextureLevel; | 1142 maxLevel = m_maxTextureLevel; |
| 1143 | 1143 |
| 1144 if (!m_activeTextureUnit) | 1144 if (!m_activeTextureUnit) |
| 1145 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); | 1145 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); |
| 1146 | 1146 |
| 1147 } else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) { | 1147 } else if (target == GL_TEXTURE_CUBE_MAP) { |
| 1148 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; | 1148 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; |
| 1149 maxLevel = m_maxCubeMapTextureLevel; | 1149 maxLevel = m_maxCubeMapTextureLevel; |
| 1150 } else { | 1150 } else { |
| 1151 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "bindTexture", "inval
id target"); | 1151 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); |
| 1152 return; | 1152 return; |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 m_context->bindTexture(target, objectOrZero(texture)); | 1155 m_context->bindTexture(target, objectOrZero(texture)); |
| 1156 if (texture) { | 1156 if (texture) { |
| 1157 texture->setTarget(target, maxLevel); | 1157 texture->setTarget(target, maxLevel); |
| 1158 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl
usMaxNonDefaultTextureUnit); | 1158 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl
usMaxNonDefaultTextureUnit); |
| 1159 } else { | 1159 } else { |
| 1160 // If the disabled index is the current maximum, trace backwards to find
the new max enabled texture index | 1160 // If the disabled index is the current maximum, trace backwards to find
the new max enabled texture index |
| 1161 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { | 1161 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 void WebGLRenderingContext::bufferData(GC3Denum target, long long size, GC3Denum
usage) | 1214 void WebGLRenderingContext::bufferData(GC3Denum target, long long size, GC3Denum
usage) |
| 1215 { | 1215 { |
| 1216 if (isContextLost()) | 1216 if (isContextLost()) |
| 1217 return; | 1217 return; |
| 1218 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); | 1218 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); |
| 1219 if (!buffer) | 1219 if (!buffer) |
| 1220 return; | 1220 return; |
| 1221 if (size < 0) { | 1221 if (size < 0) { |
| 1222 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size
< 0"); | 1222 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "size < 0"); |
| 1223 return; | 1223 return; |
| 1224 } | 1224 } |
| 1225 if (!size) { | 1225 if (!size) { |
| 1226 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "size
== 0"); | 1226 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "size == 0"); |
| 1227 return; | 1227 return; |
| 1228 } | 1228 } |
| 1229 | 1229 |
| 1230 m_context->bufferData(target, static_cast<GC3Dsizeiptr>(size), usage); | 1230 m_context->bufferData(target, static_cast<GC3Dsizeiptr>(size), usage); |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBuffer* data, GC3De
num usage) | 1233 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBuffer* data, GC3De
num usage) |
| 1234 { | 1234 { |
| 1235 if (isContextLost()) | 1235 if (isContextLost()) |
| 1236 return; | 1236 return; |
| 1237 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); | 1237 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); |
| 1238 if (!buffer) | 1238 if (!buffer) |
| 1239 return; | 1239 return; |
| 1240 if (!data) { | 1240 if (!data) { |
| 1241 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no da
ta"); | 1241 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); |
| 1242 return; | 1242 return; |
| 1243 } | 1243 } |
| 1244 m_context->bufferData(target, data->byteLength(), data->data(), usage); | 1244 m_context->bufferData(target, data->byteLength(), data->data(), usage); |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBufferView* data, G
C3Denum usage) | 1247 void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBufferView* data, G
C3Denum usage) |
| 1248 { | 1248 { |
| 1249 if (isContextLost()) | 1249 if (isContextLost()) |
| 1250 return; | 1250 return; |
| 1251 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); | 1251 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); |
| 1252 if (!buffer) | 1252 if (!buffer) |
| 1253 return; | 1253 return; |
| 1254 if (!data) { | 1254 if (!data) { |
| 1255 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferData", "no da
ta"); | 1255 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); |
| 1256 return; | 1256 return; |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage
); | 1259 m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage
); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr
ayBuffer* data) | 1262 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr
ayBuffer* data) |
| 1263 { | 1263 { |
| 1264 if (isContextLost()) | 1264 if (isContextLost()) |
| 1265 return; | 1265 return; |
| 1266 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target,
GraphicsContext3D::STATIC_DRAW); | 1266 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target,
GL_STATIC_DRAW); |
| 1267 if (!buffer) | 1267 if (!buffer) |
| 1268 return; | 1268 return; |
| 1269 if (offset < 0) { | 1269 if (offset < 0) { |
| 1270 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "of
fset < 0"); | 1270 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "offset < 0"); |
| 1271 return; | 1271 return; |
| 1272 } | 1272 } |
| 1273 if (!data) | 1273 if (!data) |
| 1274 return; | 1274 return; |
| 1275 | 1275 |
| 1276 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte
Length(), data->data()); | 1276 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte
Length(), data->data()); |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr
ayBufferView* data) | 1279 void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, Arr
ayBufferView* data) |
| 1280 { | 1280 { |
| 1281 if (isContextLost()) | 1281 if (isContextLost()) |
| 1282 return; | 1282 return; |
| 1283 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target,
GraphicsContext3D::STATIC_DRAW); | 1283 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target,
GL_STATIC_DRAW); |
| 1284 if (!buffer) | 1284 if (!buffer) |
| 1285 return; | 1285 return; |
| 1286 if (offset < 0) { | 1286 if (offset < 0) { |
| 1287 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "bufferSubData", "of
fset < 0"); | 1287 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "offset < 0"); |
| 1288 return; | 1288 return; |
| 1289 } | 1289 } |
| 1290 if (!data) | 1290 if (!data) |
| 1291 return; | 1291 return; |
| 1292 | 1292 |
| 1293 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte
Length(), data->baseAddress()); | 1293 m_context->bufferSubData(target, static_cast<GC3Dintptr>(offset), data->byte
Length(), data->baseAddress()); |
| 1294 } | 1294 } |
| 1295 | 1295 |
| 1296 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target) | 1296 GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target) |
| 1297 { | 1297 { |
| 1298 if (isContextLost()) | 1298 if (isContextLost()) |
| 1299 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; | 1299 return GL_FRAMEBUFFER_UNSUPPORTED; |
| 1300 if (target != GraphicsContext3D::FRAMEBUFFER) { | 1300 if (target != GL_FRAMEBUFFER) { |
| 1301 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "checkFramebufferStat
us", "invalid target"); | 1301 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta
rget"); |
| 1302 return 0; | 1302 return 0; |
| 1303 } | 1303 } |
| 1304 if (!m_framebufferBinding || !m_framebufferBinding->object()) | 1304 if (!m_framebufferBinding || !m_framebufferBinding->object()) |
| 1305 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; | 1305 return GL_FRAMEBUFFER_COMPLETE; |
| 1306 const char* reason = "framebuffer incomplete"; | 1306 const char* reason = "framebuffer incomplete"; |
| 1307 GC3Denum result = m_framebufferBinding->checkStatus(&reason); | 1307 GC3Denum result = m_framebufferBinding->checkStatus(&reason); |
| 1308 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { | 1308 if (result != GL_FRAMEBUFFER_COMPLETE) { |
| 1309 emitGLWarning("checkFramebufferStatus", reason); | 1309 emitGLWarning("checkFramebufferStatus", reason); |
| 1310 return result; | 1310 return result; |
| 1311 } | 1311 } |
| 1312 result = m_context->checkFramebufferStatus(target); | 1312 result = m_context->checkFramebufferStatus(target); |
| 1313 return result; | 1313 return result; |
| 1314 } | 1314 } |
| 1315 | 1315 |
| 1316 void WebGLRenderingContext::clear(GC3Dbitfield mask) | 1316 void WebGLRenderingContext::clear(GC3Dbitfield mask) |
| 1317 { | 1317 { |
| 1318 if (isContextLost()) | 1318 if (isContextLost()) |
| 1319 return; | 1319 return; |
| 1320 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_
BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { | 1320 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { |
| 1321 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "clear", "invalid ma
sk"); | 1321 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); |
| 1322 return; | 1322 return; |
| 1323 } | 1323 } |
| 1324 const char* reason = "framebuffer incomplete"; | 1324 const char* reason = "framebuffer incomplete"; |
| 1325 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 1325 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { |
| 1326 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cle
ar", reason); | 1326 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); |
| 1327 return; | 1327 return; |
| 1328 } | 1328 } |
| 1329 if (!clearIfComposited(mask)) | 1329 if (!clearIfComposited(mask)) |
| 1330 m_context->clear(mask); | 1330 m_context->clear(mask); |
| 1331 markContextChanged(); | 1331 markContextChanged(); |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC
3Dfloat a) | 1334 void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC
3Dfloat a) |
| 1335 { | 1335 { |
| 1336 if (isContextLost()) | 1336 if (isContextLost()) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 | 1386 |
| 1387 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level,
GC3Denum internalformat, GC3Dsizei width, | 1387 void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level,
GC3Denum internalformat, GC3Dsizei width, |
| 1388 GC3Dsizei height, GC3Dint borde
r, ArrayBufferView* data) | 1388 GC3Dsizei height, GC3Dint borde
r, ArrayBufferView* data) |
| 1389 { | 1389 { |
| 1390 if (isContextLost()) | 1390 if (isContextLost()) |
| 1391 return; | 1391 return; |
| 1392 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) | 1392 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) |
| 1393 return; | 1393 return; |
| 1394 | 1394 |
| 1395 if (!validateCompressedTexFormat(internalformat)) { | 1395 if (!validateCompressedTexFormat(internalformat)) { |
| 1396 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexImage2D
", "invalid internalformat"); | 1396 synthesizeGLError(GL_INVALID_ENUM, "compressedTexImage2D", "invalid inte
rnalformat"); |
| 1397 return; | 1397 return; |
| 1398 } | 1398 } |
| 1399 if (border) { | 1399 if (border) { |
| 1400 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexImage2
D", "border not 0"); | 1400 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "border not
0"); |
| 1401 return; | 1401 return; |
| 1402 } | 1402 } |
| 1403 if (!validateCompressedTexDimensions("compressedTexImage2D", NotTexSubImage2
D, target, level, width, height, internalformat)) | 1403 if (!validateCompressedTexDimensions("compressedTexImage2D", NotTexSubImage2
D, target, level, width, height, internalformat)) |
| 1404 return; | 1404 return; |
| 1405 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in
ternalformat, data)) | 1405 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, in
ternalformat, data)) |
| 1406 return; | 1406 return; |
| 1407 | 1407 |
| 1408 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t
rue); | 1408 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t
rue); |
| 1409 if (!tex) | 1409 if (!tex) |
| 1410 return; | 1410 return; |
| 1411 if (!isGLES2NPOTStrict()) { | 1411 if (!isGLES2NPOTStrict()) { |
| 1412 if (level && WebGLTexture::isNPOT(width, height)) { | 1412 if (level && WebGLTexture::isNPOT(width, height)) { |
| 1413 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "compressedTexIm
age2D", "level > 0 not power of 2"); | 1413 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "level >
0 not power of 2"); |
| 1414 return; | 1414 return; |
| 1415 } | 1415 } |
| 1416 } | 1416 } |
| 1417 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid
th, height, | 1417 graphicsContext3D()->compressedTexImage2D(target, level, internalformat, wid
th, height, |
| 1418 border, data->byteLength(), data->
baseAddress()); | 1418 border, data->byteLength(), data->
baseAddress()); |
| 1419 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont
ext3D::UNSIGNED_BYTE); | 1419 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev
el, GC3Dint xoffset, GC3Dint yoffset, | 1422 void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint lev
el, GC3Dint xoffset, GC3Dint yoffset, |
| 1423 GC3Dsizei width, GC3Dsizei h
eight, GC3Denum format, ArrayBufferView* data) | 1423 GC3Dsizei width, GC3Dsizei h
eight, GC3Denum format, ArrayBufferView* data) |
| 1424 { | 1424 { |
| 1425 if (isContextLost()) | 1425 if (isContextLost()) |
| 1426 return; | 1426 return; |
| 1427 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) | 1427 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) |
| 1428 return; | 1428 return; |
| 1429 if (!validateCompressedTexFormat(format)) { | 1429 if (!validateCompressedTexFormat(format)) { |
| 1430 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "compressedTexSubImag
e2D", "invalid format"); | 1430 synthesizeGLError(GL_INVALID_ENUM, "compressedTexSubImage2D", "invalid f
ormat"); |
| 1431 return; | 1431 return; |
| 1432 } | 1432 } |
| 1433 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height,
format, data)) | 1433 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height,
format, data)) |
| 1434 return; | 1434 return; |
| 1435 | 1435 |
| 1436 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target
, true); | 1436 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target
, true); |
| 1437 if (!tex) | 1437 if (!tex) |
| 1438 return; | 1438 return; |
| 1439 | 1439 |
| 1440 if (format != tex->getInternalFormat(target, level)) { | 1440 if (format != tex->getInternalFormat(target, level)) { |
| 1441 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "compressedTexSu
bImage2D", "format does not match texture format"); | 1441 synthesizeGLError(GL_INVALID_OPERATION, "compressedTexSubImage2D", "form
at does not match texture format"); |
| 1442 return; | 1442 return; |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l
evel, xoffset, yoffset, width, height, format, tex)) | 1445 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l
evel, xoffset, yoffset, width, height, format, tex)) |
| 1446 return; | 1446 return; |
| 1447 | 1447 |
| 1448 graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset
, | 1448 graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset
, |
| 1449 width, height, format, data->by
teLength(), data->baseAddress()); | 1449 width, height, format, data->by
teLength(), data->baseAddress()); |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 bool WebGLRenderingContext::validateSettableTexFormat(const char* functionName,
GC3Denum format) | 1452 bool WebGLRenderingContext::validateSettableTexFormat(const char* functionName,
GC3Denum format) |
| 1453 { | 1453 { |
| 1454 if (GraphicsContext3D::getClearBitsByFormat(format) & (GraphicsContext3D::DE
PTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { | 1454 if (GraphicsContext3D::getClearBitsByFormat(format) & (GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT)) { |
| 1455 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "f
ormat can not be set, only rendered to"); | 1455 synthesizeGLError(GL_INVALID_OPERATION, functionName, "format can not be
set, only rendered to"); |
| 1456 return false; | 1456 return false; |
| 1457 } | 1457 } |
| 1458 return true; | 1458 return true; |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De
num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3
Dint border) | 1461 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3De
num internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3
Dint border) |
| 1462 { | 1462 { |
| 1463 if (isContextLost()) | 1463 if (isContextLost()) |
| 1464 return; | 1464 return; |
| 1465 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l
evel, internalformat, width, height, border, internalformat, GraphicsContext3D::
UNSIGNED_BYTE)) | 1465 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l
evel, internalformat, width, height, border, internalformat, GL_UNSIGNED_BYTE)) |
| 1466 return; | 1466 return; |
| 1467 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) | 1467 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) |
| 1468 return; | 1468 return; |
| 1469 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); | 1469 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); |
| 1470 if (!tex) | 1470 if (!tex) |
| 1471 return; | 1471 return; |
| 1472 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1472 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
| 1473 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexImage2D"
, "framebuffer is incompatible format"); | 1473 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i
s incompatible format"); |
| 1474 return; | 1474 return; |
| 1475 } | 1475 } |
| 1476 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 1476 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
| 1477 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexImage2D", "l
evel > 0 not power of 2"); | 1477 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); |
| 1478 return; | 1478 return; |
| 1479 } | 1479 } |
| 1480 const char* reason = "framebuffer incomplete"; | 1480 const char* reason = "framebuffer incomplete"; |
| 1481 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 1481 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { |
| 1482 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop
yTexImage2D", reason); | 1482 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); |
| 1483 return; | 1483 return; |
| 1484 } | 1484 } |
| 1485 clearIfComposited(); | 1485 clearIfComposited(); |
| 1486 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1486 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
| 1487 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height
, border); | 1487 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height
, border); |
| 1488 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. | 1488 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. |
| 1489 tex->setLevelInfo(target, level, internalformat, width, height, GraphicsCont
ext3D::UNSIGNED_BYTE); | 1489 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); |
| 1490 } | 1490 } |
| 1491 | 1491 |
| 1492 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC
3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei
height) | 1492 void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC
3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei
height) |
| 1493 { | 1493 { |
| 1494 if (isContextLost()) | 1494 if (isContextLost()) |
| 1495 return; | 1495 return; |
| 1496 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) | 1496 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) |
| 1497 return; | 1497 return; |
| 1498 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true
); | 1498 WebGLTexture* tex = validateTextureBinding("copyTexSubImage2D", target, true
); |
| 1499 if (!tex) | 1499 if (!tex) |
| 1500 return; | 1500 return; |
| 1501 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c
opyTexSubImage2D", width, height)) | 1501 if (!validateSize("copyTexSubImage2D", xoffset, yoffset) || !validateSize("c
opyTexSubImage2D", width, height)) |
| 1502 return; | 1502 return; |
| 1503 // Before checking if it is in the range, check if overflow happens first. | 1503 // Before checking if it is in the range, check if overflow happens first. |
| 1504 if (xoffset + width < 0 || yoffset + height < 0) { | 1504 if (xoffset + width < 0 || yoffset + height < 0) { |
| 1505 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D",
"bad dimensions"); | 1505 synthesizeGLError(GL_INVALID_VALUE, "copyTexSubImage2D", "bad dimensions
"); |
| 1506 return; | 1506 return; |
| 1507 } | 1507 } |
| 1508 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex
->getHeight(target, level)) { | 1508 if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex
->getHeight(target, level)) { |
| 1509 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "copyTexSubImage2D",
"rectangle out of range"); | 1509 synthesizeGLError(GL_INVALID_VALUE, "copyTexSubImage2D", "rectangle out
of range"); |
| 1510 return; | 1510 return; |
| 1511 } | 1511 } |
| 1512 GC3Denum internalformat = tex->getInternalFormat(target, level); | 1512 GC3Denum internalformat = tex->getInternalFormat(target, level); |
| 1513 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) | 1513 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) |
| 1514 return; | 1514 return; |
| 1515 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1515 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
| 1516 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "copyTexSubImage
2D", "framebuffer is incompatible format"); | 1516 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); |
| 1517 return; | 1517 return; |
| 1518 } | 1518 } |
| 1519 const char* reason = "framebuffer incomplete"; | 1519 const char* reason = "framebuffer incomplete"; |
| 1520 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 1520 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { |
| 1521 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "cop
yTexSubImage2D", reason); | 1521 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D",
reason); |
| 1522 return; | 1522 return; |
| 1523 } | 1523 } |
| 1524 clearIfComposited(); | 1524 clearIfComposited(); |
| 1525 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1525 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
| 1526 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); | 1526 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() | 1529 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() |
| 1530 { | 1530 { |
| 1531 if (isContextLost()) | 1531 if (isContextLost()) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS
tencilBuffer())); | 1580 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS
tencilBuffer())); |
| 1581 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g
et())); | 1581 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g
et())); |
| 1582 } | 1582 } |
| 1583 return renderbuffer->emulatedStencilBuffer(); | 1583 return renderbuffer->emulatedStencilBuffer(); |
| 1584 } | 1584 } |
| 1585 | 1585 |
| 1586 PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(GC3Denum type) | 1586 PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(GC3Denum type) |
| 1587 { | 1587 { |
| 1588 if (isContextLost()) | 1588 if (isContextLost()) |
| 1589 return 0; | 1589 return 0; |
| 1590 if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::F
RAGMENT_SHADER) { | 1590 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { |
| 1591 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "createShader", "inva
lid shader type"); | 1591 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type"
); |
| 1592 return 0; | 1592 return 0; |
| 1593 } | 1593 } |
| 1594 | 1594 |
| 1595 RefPtr<WebGLShader> o = WebGLShader::create(this, type); | 1595 RefPtr<WebGLShader> o = WebGLShader::create(this, type); |
| 1596 addSharedObject(o.get()); | 1596 addSharedObject(o.get()); |
| 1597 return o; | 1597 return o; |
| 1598 } | 1598 } |
| 1599 | 1599 |
| 1600 void WebGLRenderingContext::cullFace(GC3Denum mode) | 1600 void WebGLRenderingContext::cullFace(GC3Denum mode) |
| 1601 { | 1601 { |
| 1602 if (isContextLost()) | 1602 if (isContextLost()) |
| 1603 return; | 1603 return; |
| 1604 switch (mode) { | 1604 switch (mode) { |
| 1605 case GraphicsContext3D::FRONT_AND_BACK: | 1605 case GL_FRONT_AND_BACK: |
| 1606 case GraphicsContext3D::FRONT: | 1606 case GL_FRONT: |
| 1607 case GraphicsContext3D::BACK: | 1607 case GL_BACK: |
| 1608 break; | 1608 break; |
| 1609 default: | 1609 default: |
| 1610 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "cullFace", "invalid
mode"); | 1610 synthesizeGLError(GL_INVALID_ENUM, "cullFace", "invalid mode"); |
| 1611 return; | 1611 return; |
| 1612 } | 1612 } |
| 1613 m_context->cullFace(mode); | 1613 m_context->cullFace(mode); |
| 1614 } | 1614 } |
| 1615 | 1615 |
| 1616 bool WebGLRenderingContext::deleteObject(WebGLObject* object) | 1616 bool WebGLRenderingContext::deleteObject(WebGLObject* object) |
| 1617 { | 1617 { |
| 1618 if (isContextLost() || !object) | 1618 if (isContextLost() || !object) |
| 1619 return false; | 1619 return false; |
| 1620 if (!object->validate(contextGroup(), this)) { | 1620 if (!object->validate(contextGroup(), this)) { |
| 1621 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "delete", "objec
t does not belong to this context"); | 1621 synthesizeGLError(GL_INVALID_OPERATION, "delete", "object does not belon
g to this context"); |
| 1622 return false; | 1622 return false; |
| 1623 } | 1623 } |
| 1624 if (object->object()) | 1624 if (object->object()) |
| 1625 // We need to pass in context here because we want | 1625 // We need to pass in context here because we want |
| 1626 // things in this context unbound. | 1626 // things in this context unbound. |
| 1627 object->deleteObject(graphicsContext3D()); | 1627 object->deleteObject(graphicsContext3D()); |
| 1628 return true; | 1628 return true; |
| 1629 } | 1629 } |
| 1630 | 1630 |
| 1631 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) | 1631 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 return; | 1714 return; |
| 1715 m_depthMask = flag; | 1715 m_depthMask = flag; |
| 1716 m_context->depthMask(flag); | 1716 m_context->depthMask(flag); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 void WebGLRenderingContext::depthRange(GC3Dfloat zNear, GC3Dfloat zFar) | 1719 void WebGLRenderingContext::depthRange(GC3Dfloat zNear, GC3Dfloat zFar) |
| 1720 { | 1720 { |
| 1721 if (isContextLost()) | 1721 if (isContextLost()) |
| 1722 return; | 1722 return; |
| 1723 if (zNear > zFar) { | 1723 if (zNear > zFar) { |
| 1724 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "depthRange", "z
Near > zFar"); | 1724 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); |
| 1725 return; | 1725 return; |
| 1726 } | 1726 } |
| 1727 m_context->depthRange(zNear, zFar); | 1727 m_context->depthRange(zNear, zFar); |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
der) | 1730 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
der) |
| 1731 { | 1731 { |
| 1732 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) | 1732 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) |
| 1733 return; | 1733 return; |
| 1734 if (!program->detachShader(shader)) { | 1734 if (!program->detachShader(shader)) { |
| 1735 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "detachShader",
"shader not attached"); | 1735 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta
ched"); |
| 1736 return; | 1736 return; |
| 1737 } | 1737 } |
| 1738 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); | 1738 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); |
| 1739 shader->onDetached(graphicsContext3D()); | 1739 shader->onDetached(graphicsContext3D()); |
| 1740 } | 1740 } |
| 1741 | 1741 |
| 1742 void WebGLRenderingContext::disable(GC3Denum cap) | 1742 void WebGLRenderingContext::disable(GC3Denum cap) |
| 1743 { | 1743 { |
| 1744 if (isContextLost() || !validateCapability("disable", cap)) | 1744 if (isContextLost() || !validateCapability("disable", cap)) |
| 1745 return; | 1745 return; |
| 1746 if (cap == GraphicsContext3D::STENCIL_TEST) { | 1746 if (cap == GL_STENCIL_TEST) { |
| 1747 m_stencilEnabled = false; | 1747 m_stencilEnabled = false; |
| 1748 applyStencilTest(); | 1748 applyStencilTest(); |
| 1749 return; | 1749 return; |
| 1750 } | 1750 } |
| 1751 if (cap == GraphicsContext3D::SCISSOR_TEST) { | 1751 if (cap == GL_SCISSOR_TEST) { |
| 1752 m_scissorEnabled = false; | 1752 m_scissorEnabled = false; |
| 1753 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 1753 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); |
| 1754 } | 1754 } |
| 1755 m_context->disable(cap); | 1755 m_context->disable(cap); |
| 1756 } | 1756 } |
| 1757 | 1757 |
| 1758 void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index) | 1758 void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index) |
| 1759 { | 1759 { |
| 1760 if (isContextLost()) | 1760 if (isContextLost()) |
| 1761 return; | 1761 return; |
| 1762 if (index >= m_maxVertexAttribs) { | 1762 if (index >= m_maxVertexAttribs) { |
| 1763 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "disableVertexAttrib
Array", "index out of range"); | 1763 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); |
| 1764 return; | 1764 return; |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje
ct->getVertexAttribState(index); | 1767 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje
ct->getVertexAttribState(index); |
| 1768 state.enabled = false; | 1768 state.enabled = false; |
| 1769 | 1769 |
| 1770 // If the disabled index is the current maximum, trace backwards to find the
new max enabled attrib index | 1770 // If the disabled index is the current maximum, trace backwards to find the
new max enabled attrib index |
| 1771 if (m_onePlusMaxEnabledAttribIndex == index + 1) { | 1771 if (m_onePlusMaxEnabledAttribIndex == index + 1) { |
| 1772 findNewMaxEnabledAttribIndex(); | 1772 findNewMaxEnabledAttribIndex(); |
| 1773 } | 1773 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1787 && (!state.bufferBinding || !state.bufferBinding->object())) | 1787 && (!state.bufferBinding || !state.bufferBinding->object())) |
| 1788 return false; | 1788 return false; |
| 1789 } | 1789 } |
| 1790 | 1790 |
| 1791 return true; | 1791 return true; |
| 1792 } | 1792 } |
| 1793 | 1793 |
| 1794 bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLO
bject* object) | 1794 bool WebGLRenderingContext::validateWebGLObject(const char* functionName, WebGLO
bject* object) |
| 1795 { | 1795 { |
| 1796 if (!object || !object->object()) { | 1796 if (!object || !object->object()) { |
| 1797 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "no ob
ject or object deleted"); | 1797 synthesizeGLError(GL_INVALID_VALUE, functionName, "no object or object d
eleted"); |
| 1798 return false; | 1798 return false; |
| 1799 } | 1799 } |
| 1800 if (!object->validate(contextGroup(), this)) { | 1800 if (!object->validate(contextGroup(), this)) { |
| 1801 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "o
bject does not belong to this context"); | 1801 synthesizeGLError(GL_INVALID_OPERATION, functionName, "object does not b
elong to this context"); |
| 1802 return false; | 1802 return false; |
| 1803 } | 1803 } |
| 1804 return true; | 1804 return true; |
| 1805 } | 1805 } |
| 1806 | 1806 |
| 1807 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c
ount) | 1807 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei c
ount) |
| 1808 { | 1808 { |
| 1809 if (!validateDrawArrays("drawArrays", mode, first, count)) | 1809 if (!validateDrawArrays("drawArrays", mode, first, count)) |
| 1810 return; | 1810 return; |
| 1811 | 1811 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 handleTextureCompleteness("drawElementsInstancedANGLE", true); | 1859 handleTextureCompleteness("drawElementsInstancedANGLE", true); |
| 1860 m_context->extensions()->drawElementsInstancedANGLE(mode, count, type, stati
c_cast<GC3Dintptr>(offset), primcount); | 1860 m_context->extensions()->drawElementsInstancedANGLE(mode, count, type, stati
c_cast<GC3Dintptr>(offset), primcount); |
| 1861 handleTextureCompleteness("drawElementsInstancedANGLE", false); | 1861 handleTextureCompleteness("drawElementsInstancedANGLE", false); |
| 1862 markContextChanged(); | 1862 markContextChanged(); |
| 1863 } | 1863 } |
| 1864 | 1864 |
| 1865 void WebGLRenderingContext::enable(GC3Denum cap) | 1865 void WebGLRenderingContext::enable(GC3Denum cap) |
| 1866 { | 1866 { |
| 1867 if (isContextLost() || !validateCapability("enable", cap)) | 1867 if (isContextLost() || !validateCapability("enable", cap)) |
| 1868 return; | 1868 return; |
| 1869 if (cap == GraphicsContext3D::STENCIL_TEST) { | 1869 if (cap == GL_STENCIL_TEST) { |
| 1870 m_stencilEnabled = true; | 1870 m_stencilEnabled = true; |
| 1871 applyStencilTest(); | 1871 applyStencilTest(); |
| 1872 return; | 1872 return; |
| 1873 } | 1873 } |
| 1874 if (cap == GraphicsContext3D::SCISSOR_TEST) { | 1874 if (cap == GL_SCISSOR_TEST) { |
| 1875 m_scissorEnabled = true; | 1875 m_scissorEnabled = true; |
| 1876 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 1876 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); |
| 1877 } | 1877 } |
| 1878 m_context->enable(cap); | 1878 m_context->enable(cap); |
| 1879 } | 1879 } |
| 1880 | 1880 |
| 1881 void WebGLRenderingContext::enableVertexAttribArray(GC3Duint index) | 1881 void WebGLRenderingContext::enableVertexAttribArray(GC3Duint index) |
| 1882 { | 1882 { |
| 1883 if (isContextLost()) | 1883 if (isContextLost()) |
| 1884 return; | 1884 return; |
| 1885 if (index >= m_maxVertexAttribs) { | 1885 if (index >= m_maxVertexAttribs) { |
| 1886 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "enableVertexAttribA
rray", "index out of range"); | 1886 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); |
| 1887 return; | 1887 return; |
| 1888 } | 1888 } |
| 1889 | 1889 |
| 1890 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje
ct->getVertexAttribState(index); | 1890 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje
ct->getVertexAttribState(index); |
| 1891 state.enabled = true; | 1891 state.enabled = true; |
| 1892 | 1892 |
| 1893 m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribInd
ex); | 1893 m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribInd
ex); |
| 1894 | 1894 |
| 1895 m_context->enableVertexAttribArray(index); | 1895 m_context->enableVertexAttribArray(index); |
| 1896 } | 1896 } |
| 1897 | 1897 |
| 1898 void WebGLRenderingContext::finish() | 1898 void WebGLRenderingContext::finish() |
| 1899 { | 1899 { |
| 1900 if (isContextLost()) | 1900 if (isContextLost()) |
| 1901 return; | 1901 return; |
| 1902 m_context->flush(); // Intentionally a flush, not a finish. | 1902 m_context->flush(); // Intentionally a flush, not a finish. |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 void WebGLRenderingContext::flush() | 1905 void WebGLRenderingContext::flush() |
| 1906 { | 1906 { |
| 1907 if (isContextLost()) | 1907 if (isContextLost()) |
| 1908 return; | 1908 return; |
| 1909 m_context->flush(); | 1909 m_context->flush(); |
| 1910 } | 1910 } |
| 1911 | 1911 |
| 1912 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at
tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer) | 1912 void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum at
tachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer) |
| 1913 { | 1913 { |
| 1914 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender
buffer", target, attachment)) | 1914 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender
buffer", target, attachment)) |
| 1915 return; | 1915 return; |
| 1916 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { | 1916 if (renderbuffertarget != GL_RENDERBUFFER) { |
| 1917 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "framebufferRenderbuf
fer", "invalid target"); | 1917 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t
arget"); |
| 1918 return; | 1918 return; |
| 1919 } | 1919 } |
| 1920 if (buffer && !buffer->validate(contextGroup(), this)) { | 1920 if (buffer && !buffer->validate(contextGroup(), this)) { |
| 1921 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend
erbuffer", "no buffer or buffer not from this context"); | 1921 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b
uffer or buffer not from this context"); |
| 1922 return; | 1922 return; |
| 1923 } | 1923 } |
| 1924 // Don't allow the default framebuffer to be mutated; all current | 1924 // Don't allow the default framebuffer to be mutated; all current |
| 1925 // implementations use an FBO internally in place of the default | 1925 // implementations use an FBO internally in place of the default |
| 1926 // FBO. | 1926 // FBO. |
| 1927 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 1927 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 1928 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend
erbuffer", "no framebuffer bound"); | 1928 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f
ramebuffer bound"); |
| 1929 return; | 1929 return; |
| 1930 } | 1930 } |
| 1931 Platform3DObject bufferObject = objectOrZero(buffer); | 1931 Platform3DObject bufferObject = objectOrZero(buffer); |
| 1932 switch (attachment) { | 1932 switch (attachment) { |
| 1933 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: | 1933 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
| 1934 if (isDepthStencilSupported() || !buffer) { | 1934 if (isDepthStencilSupported() || !buffer) { |
| 1935 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_
ATTACHMENT, renderbuffertarget, bufferObject); | 1935 m_context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, rend
erbuffertarget, bufferObject); |
| 1936 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI
L_ATTACHMENT, renderbuffertarget, bufferObject); | 1936 m_context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, re
nderbuffertarget, bufferObject); |
| 1937 } else { | 1937 } else { |
| 1938 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(renderbuffertarget, buffer); | 1938 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(renderbuffertarget, buffer); |
| 1939 if (!emulatedStencilBuffer) { | 1939 if (!emulatedStencilBuffer) { |
| 1940 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "framebuffer
Renderbuffer", "out of memory"); | 1940 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", "
out of memory"); |
| 1941 return; | 1941 return; |
| 1942 } | 1942 } |
| 1943 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_
ATTACHMENT, renderbuffertarget, bufferObject); | 1943 m_context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, rend
erbuffertarget, bufferObject); |
| 1944 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCI
L_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); | 1944 m_context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, re
nderbuffertarget, objectOrZero(emulatedStencilBuffer)); |
| 1945 } | 1945 } |
| 1946 break; | 1946 break; |
| 1947 default: | 1947 default: |
| 1948 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge
t, bufferObject); | 1948 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge
t, bufferObject); |
| 1949 } | 1949 } |
| 1950 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); | 1950 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); |
| 1951 applyStencilTest(); | 1951 applyStencilTest(); |
| 1952 } | 1952 } |
| 1953 | 1953 |
| 1954 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac
hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level) | 1954 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac
hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level) |
| 1955 { | 1955 { |
| 1956 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) | 1956 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) |
| 1957 return; | 1957 return; |
| 1958 if (level) { | 1958 if (level) { |
| 1959 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2
D", "level not 0"); | 1959 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0
"); |
| 1960 return; | 1960 return; |
| 1961 } | 1961 } |
| 1962 if (texture && !texture->validate(contextGroup(), this)) { | 1962 if (texture && !texture->validate(contextGroup(), this)) { |
| 1963 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText
ure2D", "no texture or texture not from this context"); | 1963 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text
ure or texture not from this context"); |
| 1964 return; | 1964 return; |
| 1965 } | 1965 } |
| 1966 // Don't allow the default framebuffer to be mutated; all current | 1966 // Don't allow the default framebuffer to be mutated; all current |
| 1967 // implementations use an FBO internally in place of the default | 1967 // implementations use an FBO internally in place of the default |
| 1968 // FBO. | 1968 // FBO. |
| 1969 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 1969 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 1970 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText
ure2D", "no framebuffer bound"); | 1970 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram
ebuffer bound"); |
| 1971 return; | 1971 return; |
| 1972 } | 1972 } |
| 1973 Platform3DObject textureObject = objectOrZero(texture); | 1973 Platform3DObject textureObject = objectOrZero(texture); |
| 1974 switch (attachment) { | 1974 switch (attachment) { |
| 1975 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: | 1975 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
| 1976 m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHM
ENT, textarget, textureObject, level); | 1976 m_context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget,
textureObject, level); |
| 1977 m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTAC
HMENT, textarget, textureObject, level); | 1977 m_context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarget
, textureObject, level); |
| 1978 break; | 1978 break; |
| 1979 case GraphicsContext3D::DEPTH_ATTACHMENT: | 1979 case GL_DEPTH_ATTACHMENT: |
| 1980 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 1980 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); |
| 1981 break; | 1981 break; |
| 1982 case GraphicsContext3D::STENCIL_ATTACHMENT: | 1982 case GL_STENCIL_ATTACHMENT: |
| 1983 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 1983 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); |
| 1984 break; | 1984 break; |
| 1985 default: | 1985 default: |
| 1986 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 1986 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); |
| 1987 } | 1987 } |
| 1988 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget
, texture, level); | 1988 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget
, texture, level); |
| 1989 applyStencilTest(); | 1989 applyStencilTest(); |
| 1990 } | 1990 } |
| 1991 | 1991 |
| 1992 void WebGLRenderingContext::frontFace(GC3Denum mode) | 1992 void WebGLRenderingContext::frontFace(GC3Denum mode) |
| 1993 { | 1993 { |
| 1994 if (isContextLost()) | 1994 if (isContextLost()) |
| 1995 return; | 1995 return; |
| 1996 switch (mode) { | 1996 switch (mode) { |
| 1997 case GraphicsContext3D::CW: | 1997 case GL_CW: |
| 1998 case GraphicsContext3D::CCW: | 1998 case GL_CCW: |
| 1999 break; | 1999 break; |
| 2000 default: | 2000 default: |
| 2001 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "frontFace", "invalid
mode"); | 2001 synthesizeGLError(GL_INVALID_ENUM, "frontFace", "invalid mode"); |
| 2002 return; | 2002 return; |
| 2003 } | 2003 } |
| 2004 m_context->frontFace(mode); | 2004 m_context->frontFace(mode); |
| 2005 } | 2005 } |
| 2006 | 2006 |
| 2007 void WebGLRenderingContext::generateMipmap(GC3Denum target) | 2007 void WebGLRenderingContext::generateMipmap(GC3Denum target) |
| 2008 { | 2008 { |
| 2009 if (isContextLost()) | 2009 if (isContextLost()) |
| 2010 return; | 2010 return; |
| 2011 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); | 2011 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); |
| 2012 if (!tex) | 2012 if (!tex) |
| 2013 return; | 2013 return; |
| 2014 if (!tex->canGenerateMipmaps()) { | 2014 if (!tex->canGenerateMipmaps()) { |
| 2015 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap"
, "level 0 not power of 2 or not all the same size"); | 2015 synthesizeGLError(GL_INVALID_OPERATION, "generateMipmap", "level 0 not p
ower of 2 or not all the same size"); |
| 2016 return; | 2016 return; |
| 2017 } | 2017 } |
| 2018 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ
et, 0))) | 2018 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ
et, 0))) |
| 2019 return; | 2019 return; |
| 2020 | 2020 |
| 2021 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN
EAR | 2021 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN
EAR |
| 2022 // on Mac. Remove the hack once this driver bug is fixed. | 2022 // on Mac. Remove the hack once this driver bug is fixed. |
| 2023 #if OS(MACOSX) | 2023 #if OS(MACOSX) |
| 2024 bool needToResetMinFilter = false; | 2024 bool needToResetMinFilter = false; |
| 2025 if (tex->getMinFilter() != GraphicsContext3D::NEAREST_MIPMAP_LINEAR) { | 2025 if (tex->getMinFilter() != GL_NEAREST_MIPMAP_LINEAR) { |
| 2026 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER,
GraphicsContext3D::NEAREST_MIPMAP_LINEAR); | 2026 m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMA
P_LINEAR); |
| 2027 needToResetMinFilter = true; | 2027 needToResetMinFilter = true; |
| 2028 } | 2028 } |
| 2029 #endif | 2029 #endif |
| 2030 m_context->generateMipmap(target); | 2030 m_context->generateMipmap(target); |
| 2031 #if OS(MACOSX) | 2031 #if OS(MACOSX) |
| 2032 if (needToResetMinFilter) | 2032 if (needToResetMinFilter) |
| 2033 m_context->texParameteri(target, GraphicsContext3D::TEXTURE_MIN_FILTER,
tex->getMinFilter()); | 2033 m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFilte
r()); |
| 2034 #endif | 2034 #endif |
| 2035 tex->generateMipmapLevelInfo(); | 2035 tex->generateMipmapLevelInfo(); |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram*
program, GC3Duint index) | 2038 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram*
program, GC3Duint index) |
| 2039 { | 2039 { |
| 2040 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 2040 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) |
| 2041 return 0; | 2041 return 0; |
| 2042 ActiveInfo info; | 2042 ActiveInfo info; |
| 2043 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) | 2043 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2055 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2055 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2056 } | 2056 } |
| 2057 | 2057 |
| 2058 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref
Ptr<WebGLShader> >& shaderObjects) | 2058 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref
Ptr<WebGLShader> >& shaderObjects) |
| 2059 { | 2059 { |
| 2060 shaderObjects.clear(); | 2060 shaderObjects.clear(); |
| 2061 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) | 2061 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) |
| 2062 return false; | 2062 return false; |
| 2063 | 2063 |
| 2064 const GC3Denum shaderType[] = { | 2064 const GC3Denum shaderType[] = { |
| 2065 GraphicsContext3D::VERTEX_SHADER, | 2065 GL_VERTEX_SHADER, |
| 2066 GraphicsContext3D::FRAGMENT_SHADER | 2066 GL_FRAGMENT_SHADER |
| 2067 }; | 2067 }; |
| 2068 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) { | 2068 for (unsigned i = 0; i < sizeof(shaderType) / sizeof(GC3Denum); ++i) { |
| 2069 WebGLShader* shader = program->getAttachedShader(shaderType[i]); | 2069 WebGLShader* shader = program->getAttachedShader(shaderType[i]); |
| 2070 if (shader) | 2070 if (shader) |
| 2071 shaderObjects.append(shader); | 2071 shaderObjects.append(shader); |
| 2072 } | 2072 } |
| 2073 return true; | 2073 return true; |
| 2074 } | 2074 } |
| 2075 | 2075 |
| 2076 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St
ring& name) | 2076 GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const St
ring& name) |
| 2077 { | 2077 { |
| 2078 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) | 2078 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) |
| 2079 return -1; | 2079 return -1; |
| 2080 if (!validateLocationLength("getAttribLocation", name)) | 2080 if (!validateLocationLength("getAttribLocation", name)) |
| 2081 return -1; | 2081 return -1; |
| 2082 if (!validateString("getAttribLocation", name)) | 2082 if (!validateString("getAttribLocation", name)) |
| 2083 return -1; | 2083 return -1; |
| 2084 if (isPrefixReserved(name)) | 2084 if (isPrefixReserved(name)) |
| 2085 return -1; | 2085 return -1; |
| 2086 if (!program->linkStatus()) { | 2086 if (!program->linkStatus()) { |
| 2087 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getAttribLocati
on", "program not linked"); | 2087 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no
t linked"); |
| 2088 return 0; | 2088 return 0; |
| 2089 } | 2089 } |
| 2090 return m_context->getAttribLocation(objectOrZero(program), name); | 2090 return m_context->getAttribLocation(objectOrZero(program), name); |
| 2091 } | 2091 } |
| 2092 | 2092 |
| 2093 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum
pname) | 2093 WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum
pname) |
| 2094 { | 2094 { |
| 2095 if (isContextLost()) | 2095 if (isContextLost()) |
| 2096 return WebGLGetInfo(); | 2096 return WebGLGetInfo(); |
| 2097 if (target != GraphicsContext3D::ARRAY_BUFFER && target != GraphicsContext3D
::ELEMENT_ARRAY_BUFFER) { | 2097 if (target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) { |
| 2098 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter",
"invalid target"); | 2098 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid target
"); |
| 2099 return WebGLGetInfo(); | 2099 return WebGLGetInfo(); |
| 2100 } | 2100 } |
| 2101 | 2101 |
| 2102 if (pname != GraphicsContext3D::BUFFER_SIZE && pname != GraphicsContext3D::B
UFFER_USAGE) { | 2102 if (pname != GL_BUFFER_SIZE && pname != GL_BUFFER_USAGE) { |
| 2103 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getBufferParameter",
"invalid parameter name"); | 2103 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid parame
ter name"); |
| 2104 return WebGLGetInfo(); | 2104 return WebGLGetInfo(); |
| 2105 } | 2105 } |
| 2106 | 2106 |
| 2107 GC3Dint value = 0; | 2107 GC3Dint value = 0; |
| 2108 m_context->getBufferParameteriv(target, pname, &value); | 2108 m_context->getBufferParameteriv(target, pname, &value); |
| 2109 if (pname == GraphicsContext3D::BUFFER_SIZE) | 2109 if (pname == GL_BUFFER_SIZE) |
| 2110 return WebGLGetInfo(value); | 2110 return WebGLGetInfo(value); |
| 2111 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2111 return WebGLGetInfo(static_cast<unsigned int>(value)); |
| 2112 } | 2112 } |
| 2113 | 2113 |
| 2114 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() | 2114 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() |
| 2115 { | 2115 { |
| 2116 if (isContextLost()) | 2116 if (isContextLost()) |
| 2117 return 0; | 2117 return 0; |
| 2118 // We always need to return a new WebGLContextAttributes object to | 2118 // We always need to return a new WebGLContextAttributes object to |
| 2119 // prevent the user from mutating any cached version. | 2119 // prevent the user from mutating any cached version. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2134 | 2134 |
| 2135 GC3Denum WebGLRenderingContext::getError() | 2135 GC3Denum WebGLRenderingContext::getError() |
| 2136 { | 2136 { |
| 2137 if (lost_context_errors_.size()) { | 2137 if (lost_context_errors_.size()) { |
| 2138 GC3Denum err = lost_context_errors_.first(); | 2138 GC3Denum err = lost_context_errors_.first(); |
| 2139 lost_context_errors_.remove(0); | 2139 lost_context_errors_.remove(0); |
| 2140 return err; | 2140 return err; |
| 2141 } | 2141 } |
| 2142 | 2142 |
| 2143 if (isContextLost()) | 2143 if (isContextLost()) |
| 2144 return GraphicsContext3D::NO_ERROR; | 2144 return GL_NO_ERROR; |
| 2145 | 2145 |
| 2146 return m_context->getError(); | 2146 return m_context->getError(); |
| 2147 } | 2147 } |
| 2148 | 2148 |
| 2149 bool WebGLRenderingContext::ExtensionTracker::matchesNameWithPrefixes(const Stri
ng& name) const | 2149 bool WebGLRenderingContext::ExtensionTracker::matchesNameWithPrefixes(const Stri
ng& name) const |
| 2150 { | 2150 { |
| 2151 static const char* const unprefixed[] = { "", 0, }; | 2151 static const char* const unprefixed[] = { "", 0, }; |
| 2152 | 2152 |
| 2153 const char* const* prefixes = m_prefixes ? m_prefixes : unprefixed; | 2153 const char* const* prefixes = m_prefixes ? m_prefixes : unprefixed; |
| 2154 for (; *prefixes; ++prefixes) { | 2154 for (; *prefixes; ++prefixes) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2182 | 2182 |
| 2183 return 0; | 2183 return 0; |
| 2184 } | 2184 } |
| 2185 | 2185 |
| 2186 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum t
arget, GC3Denum attachment, GC3Denum pname) | 2186 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum t
arget, GC3Denum attachment, GC3Denum pname) |
| 2187 { | 2187 { |
| 2188 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt
achmentParameter", target, attachment)) | 2188 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt
achmentParameter", target, attachment)) |
| 2189 return WebGLGetInfo(); | 2189 return WebGLGetInfo(); |
| 2190 | 2190 |
| 2191 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2191 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 2192 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getFramebufferA
ttachmentParameter", "no framebuffer bound"); | 2192 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet
er", "no framebuffer bound"); |
| 2193 return WebGLGetInfo(); | 2193 return WebGLGetInfo(); |
| 2194 } | 2194 } |
| 2195 | 2195 |
| 2196 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach
ment); | 2196 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach
ment); |
| 2197 if (!object) { | 2197 if (!object) { |
| 2198 if (pname == GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) | 2198 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) |
| 2199 return WebGLGetInfo(GraphicsContext3D::NONE); | 2199 return WebGLGetInfo(GL_NONE); |
| 2200 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL | 2200 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL |
| 2201 // specifies INVALID_OPERATION. | 2201 // specifies INVALID_OPERATION. |
| 2202 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAttach
mentParameter", "invalid parameter name"); | 2202 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter",
"invalid parameter name"); |
| 2203 return WebGLGetInfo(); | 2203 return WebGLGetInfo(); |
| 2204 } | 2204 } |
| 2205 | 2205 |
| 2206 ASSERT(object->isTexture() || object->isRenderbuffer()); | 2206 ASSERT(object->isTexture() || object->isRenderbuffer()); |
| 2207 if (object->isTexture()) { | 2207 if (object->isTexture()) { |
| 2208 switch (pname) { | 2208 switch (pname) { |
| 2209 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 2209 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2210 return WebGLGetInfo(GraphicsContext3D::TEXTURE); | 2210 return WebGLGetInfo(GL_TEXTURE); |
| 2211 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 2211 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2212 return WebGLGetInfo(PassRefPtr<WebGLTexture>(static_cast<WebGLTextur
e*>(object))); | 2212 return WebGLGetInfo(PassRefPtr<WebGLTexture>(static_cast<WebGLTextur
e*>(object))); |
| 2213 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: | 2213 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2214 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | 2214 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2215 { | 2215 { |
| 2216 GC3Dint value = 0; | 2216 GC3Dint value = 0; |
| 2217 m_context->getFramebufferAttachmentParameteriv(target, attachmen
t, pname, &value); | 2217 m_context->getFramebufferAttachmentParameteriv(target, attachmen
t, pname, &value); |
| 2218 return WebGLGetInfo(value); | 2218 return WebGLGetInfo(value); |
| 2219 } | 2219 } |
| 2220 default: | 2220 default: |
| 2221 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAt
tachmentParameter", "invalid parameter name for texture attachment"); | 2221 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for texture attachment"); |
| 2222 return WebGLGetInfo(); | 2222 return WebGLGetInfo(); |
| 2223 } | 2223 } |
| 2224 } else { | 2224 } else { |
| 2225 switch (pname) { | 2225 switch (pname) { |
| 2226 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 2226 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2227 return WebGLGetInfo(GraphicsContext3D::RENDERBUFFER); | 2227 return WebGLGetInfo(GL_RENDERBUFFER); |
| 2228 case GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 2228 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2229 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(static_cast<WebGLR
enderbuffer*>(object))); | 2229 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(static_cast<WebGLR
enderbuffer*>(object))); |
| 2230 default: | 2230 default: |
| 2231 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getFramebufferAt
tachmentParameter", "invalid parameter name for renderbuffer attachment"); | 2231 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for renderbuffer attachment"); |
| 2232 return WebGLGetInfo(); | 2232 return WebGLGetInfo(); |
| 2233 } | 2233 } |
| 2234 } | 2234 } |
| 2235 } | 2235 } |
| 2236 | 2236 |
| 2237 WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname) | 2237 WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname) |
| 2238 { | 2238 { |
| 2239 if (isContextLost()) | 2239 if (isContextLost()) |
| 2240 return WebGLGetInfo(); | 2240 return WebGLGetInfo(); |
| 2241 const int intZero = 0; | 2241 const int intZero = 0; |
| 2242 switch (pname) { | 2242 switch (pname) { |
| 2243 case GraphicsContext3D::ACTIVE_TEXTURE: | 2243 case GL_ACTIVE_TEXTURE: |
| 2244 return getUnsignedIntParameter(pname); | 2244 return getUnsignedIntParameter(pname); |
| 2245 case GraphicsContext3D::ALIASED_LINE_WIDTH_RANGE: | 2245 case GL_ALIASED_LINE_WIDTH_RANGE: |
| 2246 return getWebGLFloatArrayParameter(pname); | 2246 return getWebGLFloatArrayParameter(pname); |
| 2247 case GraphicsContext3D::ALIASED_POINT_SIZE_RANGE: | 2247 case GL_ALIASED_POINT_SIZE_RANGE: |
| 2248 return getWebGLFloatArrayParameter(pname); | 2248 return getWebGLFloatArrayParameter(pname); |
| 2249 case GraphicsContext3D::ALPHA_BITS: | 2249 case GL_ALPHA_BITS: |
| 2250 return getIntParameter(pname); | 2250 return getIntParameter(pname); |
| 2251 case GraphicsContext3D::ARRAY_BUFFER_BINDING: | 2251 case GL_ARRAY_BUFFER_BINDING: |
| 2252 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundArrayBuffer)); | 2252 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundArrayBuffer)); |
| 2253 case GraphicsContext3D::BLEND: | 2253 case GL_BLEND: |
| 2254 return getBooleanParameter(pname); | 2254 return getBooleanParameter(pname); |
| 2255 case GraphicsContext3D::BLEND_COLOR: | 2255 case GL_BLEND_COLOR: |
| 2256 return getWebGLFloatArrayParameter(pname); | 2256 return getWebGLFloatArrayParameter(pname); |
| 2257 case GraphicsContext3D::BLEND_DST_ALPHA: | 2257 case GL_BLEND_DST_ALPHA: |
| 2258 return getUnsignedIntParameter(pname); | 2258 return getUnsignedIntParameter(pname); |
| 2259 case GraphicsContext3D::BLEND_DST_RGB: | 2259 case GL_BLEND_DST_RGB: |
| 2260 return getUnsignedIntParameter(pname); | 2260 return getUnsignedIntParameter(pname); |
| 2261 case GraphicsContext3D::BLEND_EQUATION_ALPHA: | 2261 case GL_BLEND_EQUATION_ALPHA: |
| 2262 return getUnsignedIntParameter(pname); | 2262 return getUnsignedIntParameter(pname); |
| 2263 case GraphicsContext3D::BLEND_EQUATION_RGB: | 2263 case GL_BLEND_EQUATION_RGB: |
| 2264 return getUnsignedIntParameter(pname); | 2264 return getUnsignedIntParameter(pname); |
| 2265 case GraphicsContext3D::BLEND_SRC_ALPHA: | 2265 case GL_BLEND_SRC_ALPHA: |
| 2266 return getUnsignedIntParameter(pname); | 2266 return getUnsignedIntParameter(pname); |
| 2267 case GraphicsContext3D::BLEND_SRC_RGB: | 2267 case GL_BLEND_SRC_RGB: |
| 2268 return getUnsignedIntParameter(pname); | 2268 return getUnsignedIntParameter(pname); |
| 2269 case GraphicsContext3D::BLUE_BITS: | 2269 case GL_BLUE_BITS: |
| 2270 return getIntParameter(pname); | 2270 return getIntParameter(pname); |
| 2271 case GraphicsContext3D::COLOR_CLEAR_VALUE: | 2271 case GL_COLOR_CLEAR_VALUE: |
| 2272 return getWebGLFloatArrayParameter(pname); | 2272 return getWebGLFloatArrayParameter(pname); |
| 2273 case GraphicsContext3D::COLOR_WRITEMASK: | 2273 case GL_COLOR_WRITEMASK: |
| 2274 return getBooleanArrayParameter(pname); | 2274 return getBooleanArrayParameter(pname); |
| 2275 case GraphicsContext3D::COMPRESSED_TEXTURE_FORMATS: | 2275 case GL_COMPRESSED_TEXTURE_FORMATS: |
| 2276 return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data(
), m_compressedTextureFormats.size())); | 2276 return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data(
), m_compressedTextureFormats.size())); |
| 2277 case GraphicsContext3D::CULL_FACE: | 2277 case GL_CULL_FACE: |
| 2278 return getBooleanParameter(pname); | 2278 return getBooleanParameter(pname); |
| 2279 case GraphicsContext3D::CULL_FACE_MODE: | 2279 case GL_CULL_FACE_MODE: |
| 2280 return getUnsignedIntParameter(pname); | 2280 return getUnsignedIntParameter(pname); |
| 2281 case GraphicsContext3D::CURRENT_PROGRAM: | 2281 case GL_CURRENT_PROGRAM: |
| 2282 return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram)); | 2282 return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram)); |
| 2283 case GraphicsContext3D::DEPTH_BITS: | 2283 case GL_DEPTH_BITS: |
| 2284 if (!m_framebufferBinding && !m_attributes.depth) | 2284 if (!m_framebufferBinding && !m_attributes.depth) |
| 2285 return WebGLGetInfo(intZero); | 2285 return WebGLGetInfo(intZero); |
| 2286 return getIntParameter(pname); | 2286 return getIntParameter(pname); |
| 2287 case GraphicsContext3D::DEPTH_CLEAR_VALUE: | 2287 case GL_DEPTH_CLEAR_VALUE: |
| 2288 return getFloatParameter(pname); | 2288 return getFloatParameter(pname); |
| 2289 case GraphicsContext3D::DEPTH_FUNC: | 2289 case GL_DEPTH_FUNC: |
| 2290 return getUnsignedIntParameter(pname); | 2290 return getUnsignedIntParameter(pname); |
| 2291 case GraphicsContext3D::DEPTH_RANGE: | 2291 case GL_DEPTH_RANGE: |
| 2292 return getWebGLFloatArrayParameter(pname); | 2292 return getWebGLFloatArrayParameter(pname); |
| 2293 case GraphicsContext3D::DEPTH_TEST: | 2293 case GL_DEPTH_TEST: |
| 2294 return getBooleanParameter(pname); | 2294 return getBooleanParameter(pname); |
| 2295 case GraphicsContext3D::DEPTH_WRITEMASK: | 2295 case GL_DEPTH_WRITEMASK: |
| 2296 return getBooleanParameter(pname); | 2296 return getBooleanParameter(pname); |
| 2297 case GraphicsContext3D::DITHER: | 2297 case GL_DITHER: |
| 2298 return getBooleanParameter(pname); | 2298 return getBooleanParameter(pname); |
| 2299 case GraphicsContext3D::ELEMENT_ARRAY_BUFFER_BINDING: | 2299 case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 2300 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundVertexArrayObject->bo
undElementArrayBuffer())); | 2300 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(m_boundVertexArrayObject->bo
undElementArrayBuffer())); |
| 2301 case GraphicsContext3D::FRAMEBUFFER_BINDING: | 2301 case GL_FRAMEBUFFER_BINDING: |
| 2302 return WebGLGetInfo(PassRefPtr<WebGLFramebuffer>(m_framebufferBinding)); | 2302 return WebGLGetInfo(PassRefPtr<WebGLFramebuffer>(m_framebufferBinding)); |
| 2303 case GraphicsContext3D::FRONT_FACE: | 2303 case GL_FRONT_FACE: |
| 2304 return getUnsignedIntParameter(pname); | 2304 return getUnsignedIntParameter(pname); |
| 2305 case GraphicsContext3D::GENERATE_MIPMAP_HINT: | 2305 case GL_GENERATE_MIPMAP_HINT: |
| 2306 return getUnsignedIntParameter(pname); | 2306 return getUnsignedIntParameter(pname); |
| 2307 case GraphicsContext3D::GREEN_BITS: | 2307 case GL_GREEN_BITS: |
| 2308 return getIntParameter(pname); | 2308 return getIntParameter(pname); |
| 2309 case GraphicsContext3D::LINE_WIDTH: | 2309 case GL_LINE_WIDTH: |
| 2310 return getFloatParameter(pname); | 2310 return getFloatParameter(pname); |
| 2311 case GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS: | 2311 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 2312 return getIntParameter(pname); | 2312 return getIntParameter(pname); |
| 2313 case GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE: | 2313 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 2314 return getIntParameter(pname); | 2314 return getIntParameter(pname); |
| 2315 case GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS: | 2315 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 2316 return getIntParameter(pname); | 2316 return getIntParameter(pname); |
| 2317 case GraphicsContext3D::MAX_RENDERBUFFER_SIZE: | 2317 case GL_MAX_RENDERBUFFER_SIZE: |
| 2318 return getIntParameter(pname); | 2318 return getIntParameter(pname); |
| 2319 case GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS: | 2319 case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 2320 return getIntParameter(pname); | 2320 return getIntParameter(pname); |
| 2321 case GraphicsContext3D::MAX_TEXTURE_SIZE: | 2321 case GL_MAX_TEXTURE_SIZE: |
| 2322 return getIntParameter(pname); | 2322 return getIntParameter(pname); |
| 2323 case GraphicsContext3D::MAX_VARYING_VECTORS: | 2323 case GL_MAX_VARYING_VECTORS: |
| 2324 return getIntParameter(pname); | 2324 return getIntParameter(pname); |
| 2325 case GraphicsContext3D::MAX_VERTEX_ATTRIBS: | 2325 case GL_MAX_VERTEX_ATTRIBS: |
| 2326 return getIntParameter(pname); | 2326 return getIntParameter(pname); |
| 2327 case GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS: | 2327 case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 2328 return getIntParameter(pname); | 2328 return getIntParameter(pname); |
| 2329 case GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS: | 2329 case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 2330 return getIntParameter(pname); | 2330 return getIntParameter(pname); |
| 2331 case GraphicsContext3D::MAX_VIEWPORT_DIMS: | 2331 case GL_MAX_VIEWPORT_DIMS: |
| 2332 return getWebGLIntArrayParameter(pname); | 2332 return getWebGLIntArrayParameter(pname); |
| 2333 case GraphicsContext3D::NUM_SHADER_BINARY_FORMATS: | 2333 case GL_NUM_SHADER_BINARY_FORMATS: |
| 2334 // FIXME: should we always return 0 for this? | 2334 // FIXME: should we always return 0 for this? |
| 2335 return getIntParameter(pname); | 2335 return getIntParameter(pname); |
| 2336 case GraphicsContext3D::PACK_ALIGNMENT: | 2336 case GL_PACK_ALIGNMENT: |
| 2337 return getIntParameter(pname); | 2337 return getIntParameter(pname); |
| 2338 case GraphicsContext3D::POLYGON_OFFSET_FACTOR: | 2338 case GL_POLYGON_OFFSET_FACTOR: |
| 2339 return getFloatParameter(pname); | 2339 return getFloatParameter(pname); |
| 2340 case GraphicsContext3D::POLYGON_OFFSET_FILL: | 2340 case GL_POLYGON_OFFSET_FILL: |
| 2341 return getBooleanParameter(pname); | 2341 return getBooleanParameter(pname); |
| 2342 case GraphicsContext3D::POLYGON_OFFSET_UNITS: | 2342 case GL_POLYGON_OFFSET_UNITS: |
| 2343 return getFloatParameter(pname); | 2343 return getFloatParameter(pname); |
| 2344 case GraphicsContext3D::RED_BITS: | 2344 case GL_RED_BITS: |
| 2345 return getIntParameter(pname); | 2345 return getIntParameter(pname); |
| 2346 case GraphicsContext3D::RENDERBUFFER_BINDING: | 2346 case GL_RENDERBUFFER_BINDING: |
| 2347 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(m_renderbufferBinding)
); | 2347 return WebGLGetInfo(PassRefPtr<WebGLRenderbuffer>(m_renderbufferBinding)
); |
| 2348 case GraphicsContext3D::RENDERER: | 2348 case GL_RENDERER: |
| 2349 return WebGLGetInfo(String("WebKit WebGL")); | 2349 return WebGLGetInfo(String("WebKit WebGL")); |
| 2350 case GraphicsContext3D::SAMPLE_BUFFERS: | 2350 case GL_SAMPLE_BUFFERS: |
| 2351 return getIntParameter(pname); | 2351 return getIntParameter(pname); |
| 2352 case GraphicsContext3D::SAMPLE_COVERAGE_INVERT: | 2352 case GL_SAMPLE_COVERAGE_INVERT: |
| 2353 return getBooleanParameter(pname); | 2353 return getBooleanParameter(pname); |
| 2354 case GraphicsContext3D::SAMPLE_COVERAGE_VALUE: | 2354 case GL_SAMPLE_COVERAGE_VALUE: |
| 2355 return getFloatParameter(pname); | 2355 return getFloatParameter(pname); |
| 2356 case GraphicsContext3D::SAMPLES: | 2356 case GL_SAMPLES: |
| 2357 return getIntParameter(pname); | 2357 return getIntParameter(pname); |
| 2358 case GraphicsContext3D::SCISSOR_BOX: | 2358 case GL_SCISSOR_BOX: |
| 2359 return getWebGLIntArrayParameter(pname); | 2359 return getWebGLIntArrayParameter(pname); |
| 2360 case GraphicsContext3D::SCISSOR_TEST: | 2360 case GL_SCISSOR_TEST: |
| 2361 return getBooleanParameter(pname); | 2361 return getBooleanParameter(pname); |
| 2362 case GraphicsContext3D::SHADING_LANGUAGE_VERSION: | 2362 case GL_SHADING_LANGUAGE_VERSION: |
| 2363 return WebGLGetInfo("WebGL GLSL ES 1.0 (" + m_context->getString(Graphic
sContext3D::SHADING_LANGUAGE_VERSION) + ")"); | 2363 return WebGLGetInfo("WebGL GLSL ES 1.0 (" + m_context->getString(GL_SHAD
ING_LANGUAGE_VERSION) + ")"); |
| 2364 case GraphicsContext3D::STENCIL_BACK_FAIL: | 2364 case GL_STENCIL_BACK_FAIL: |
| 2365 return getUnsignedIntParameter(pname); | 2365 return getUnsignedIntParameter(pname); |
| 2366 case GraphicsContext3D::STENCIL_BACK_FUNC: | 2366 case GL_STENCIL_BACK_FUNC: |
| 2367 return getUnsignedIntParameter(pname); | 2367 return getUnsignedIntParameter(pname); |
| 2368 case GraphicsContext3D::STENCIL_BACK_PASS_DEPTH_FAIL: | 2368 case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 2369 return getUnsignedIntParameter(pname); | 2369 return getUnsignedIntParameter(pname); |
| 2370 case GraphicsContext3D::STENCIL_BACK_PASS_DEPTH_PASS: | 2370 case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 2371 return getUnsignedIntParameter(pname); | 2371 return getUnsignedIntParameter(pname); |
| 2372 case GraphicsContext3D::STENCIL_BACK_REF: | 2372 case GL_STENCIL_BACK_REF: |
| 2373 return getIntParameter(pname); | 2373 return getIntParameter(pname); |
| 2374 case GraphicsContext3D::STENCIL_BACK_VALUE_MASK: | 2374 case GL_STENCIL_BACK_VALUE_MASK: |
| 2375 return getUnsignedIntParameter(pname); | 2375 return getUnsignedIntParameter(pname); |
| 2376 case GraphicsContext3D::STENCIL_BACK_WRITEMASK: | 2376 case GL_STENCIL_BACK_WRITEMASK: |
| 2377 return getUnsignedIntParameter(pname); | 2377 return getUnsignedIntParameter(pname); |
| 2378 case GraphicsContext3D::STENCIL_BITS: | 2378 case GL_STENCIL_BITS: |
| 2379 if (!m_framebufferBinding && !m_attributes.stencil) | 2379 if (!m_framebufferBinding && !m_attributes.stencil) |
| 2380 return WebGLGetInfo(intZero); | 2380 return WebGLGetInfo(intZero); |
| 2381 return getIntParameter(pname); | 2381 return getIntParameter(pname); |
| 2382 case GraphicsContext3D::STENCIL_CLEAR_VALUE: | 2382 case GL_STENCIL_CLEAR_VALUE: |
| 2383 return getIntParameter(pname); | 2383 return getIntParameter(pname); |
| 2384 case GraphicsContext3D::STENCIL_FAIL: | 2384 case GL_STENCIL_FAIL: |
| 2385 return getUnsignedIntParameter(pname); | 2385 return getUnsignedIntParameter(pname); |
| 2386 case GraphicsContext3D::STENCIL_FUNC: | 2386 case GL_STENCIL_FUNC: |
| 2387 return getUnsignedIntParameter(pname); | 2387 return getUnsignedIntParameter(pname); |
| 2388 case GraphicsContext3D::STENCIL_PASS_DEPTH_FAIL: | 2388 case GL_STENCIL_PASS_DEPTH_FAIL: |
| 2389 return getUnsignedIntParameter(pname); | 2389 return getUnsignedIntParameter(pname); |
| 2390 case GraphicsContext3D::STENCIL_PASS_DEPTH_PASS: | 2390 case GL_STENCIL_PASS_DEPTH_PASS: |
| 2391 return getUnsignedIntParameter(pname); | 2391 return getUnsignedIntParameter(pname); |
| 2392 case GraphicsContext3D::STENCIL_REF: | 2392 case GL_STENCIL_REF: |
| 2393 return getIntParameter(pname); | 2393 return getIntParameter(pname); |
| 2394 case GraphicsContext3D::STENCIL_TEST: | 2394 case GL_STENCIL_TEST: |
| 2395 return getBooleanParameter(pname); | 2395 return getBooleanParameter(pname); |
| 2396 case GraphicsContext3D::STENCIL_VALUE_MASK: | 2396 case GL_STENCIL_VALUE_MASK: |
| 2397 return getUnsignedIntParameter(pname); | 2397 return getUnsignedIntParameter(pname); |
| 2398 case GraphicsContext3D::STENCIL_WRITEMASK: | 2398 case GL_STENCIL_WRITEMASK: |
| 2399 return getUnsignedIntParameter(pname); | 2399 return getUnsignedIntParameter(pname); |
| 2400 case GraphicsContext3D::SUBPIXEL_BITS: | 2400 case GL_SUBPIXEL_BITS: |
| 2401 return getIntParameter(pname); | 2401 return getIntParameter(pname); |
| 2402 case GraphicsContext3D::TEXTURE_BINDING_2D: | 2402 case GL_TEXTURE_BINDING_2D: |
| 2403 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText
ureUnit].m_texture2DBinding)); | 2403 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText
ureUnit].m_texture2DBinding)); |
| 2404 case GraphicsContext3D::TEXTURE_BINDING_CUBE_MAP: | 2404 case GL_TEXTURE_BINDING_CUBE_MAP: |
| 2405 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText
ureUnit].m_textureCubeMapBinding)); | 2405 return WebGLGetInfo(PassRefPtr<WebGLTexture>(m_textureUnits[m_activeText
ureUnit].m_textureCubeMapBinding)); |
| 2406 case GraphicsContext3D::UNPACK_ALIGNMENT: | 2406 case GL_UNPACK_ALIGNMENT: |
| 2407 return getIntParameter(pname); | 2407 return getIntParameter(pname); |
| 2408 case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL: | 2408 case GC3D_UNPACK_FLIP_Y_WEBGL: |
| 2409 return WebGLGetInfo(m_unpackFlipY); | 2409 return WebGLGetInfo(m_unpackFlipY); |
| 2410 case GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL: | 2410 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL: |
| 2411 return WebGLGetInfo(m_unpackPremultiplyAlpha); | 2411 return WebGLGetInfo(m_unpackPremultiplyAlpha); |
| 2412 case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: | 2412 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL: |
| 2413 return WebGLGetInfo(m_unpackColorspaceConversion); | 2413 return WebGLGetInfo(m_unpackColorspaceConversion); |
| 2414 case GraphicsContext3D::VENDOR: | 2414 case GL_VENDOR: |
| 2415 return WebGLGetInfo(String("WebKit")); | 2415 return WebGLGetInfo(String("WebKit")); |
| 2416 case GraphicsContext3D::VERSION: | 2416 case GL_VERSION: |
| 2417 return WebGLGetInfo("WebGL 1.0 (" + m_context->getString(GraphicsContext
3D::VERSION) + ")"); | 2417 return WebGLGetInfo("WebGL 1.0 (" + m_context->getString(GL_VERSION) + "
)"); |
| 2418 case GraphicsContext3D::VIEWPORT: | 2418 case GL_VIEWPORT: |
| 2419 return getWebGLIntArrayParameter(pname); | 2419 return getWebGLIntArrayParameter(pname); |
| 2420 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri
vatives | 2420 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri
vatives |
| 2421 if (m_oesStandardDerivatives) | 2421 if (m_oesStandardDerivatives) |
| 2422 return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVAT
IVE_HINT_OES); | 2422 return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVAT
IVE_HINT_OES); |
| 2423 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name, OES_standard_derivatives not enabled"); | 2423 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, OES_standard_derivatives not enabled"); |
| 2424 return WebGLGetInfo(); | 2424 return WebGLGetInfo(); |
| 2425 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: | 2425 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: |
| 2426 if (m_webglDebugRendererInfo) | 2426 if (m_webglDebugRendererInfo) |
| 2427 return WebGLGetInfo(m_context->getString(GraphicsContext3D::RENDERER
)); | 2427 return WebGLGetInfo(m_context->getString(GL_RENDERER)); |
| 2428 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name, WEBGL_debug_renderer_info not enabled"); | 2428 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, WEBGL_debug_renderer_info not enabled"); |
| 2429 return WebGLGetInfo(); | 2429 return WebGLGetInfo(); |
| 2430 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: | 2430 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: |
| 2431 if (m_webglDebugRendererInfo) | 2431 if (m_webglDebugRendererInfo) |
| 2432 return WebGLGetInfo(m_context->getString(GraphicsContext3D::VENDOR))
; | 2432 return WebGLGetInfo(m_context->getString(GL_VENDOR)); |
| 2433 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name, WEBGL_debug_renderer_info not enabled"); | 2433 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, WEBGL_debug_renderer_info not enabled"); |
| 2434 return WebGLGetInfo(); | 2434 return WebGLGetInfo(); |
| 2435 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object | 2435 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object |
| 2436 if (m_oesVertexArrayObject) { | 2436 if (m_oesVertexArrayObject) { |
| 2437 if (!m_boundVertexArrayObject->isDefaultObject()) | 2437 if (!m_boundVertexArrayObject->isDefaultObject()) |
| 2438 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun
dVertexArrayObject)); | 2438 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun
dVertexArrayObject)); |
| 2439 return WebGLGetInfo(); | 2439 return WebGLGetInfo(); |
| 2440 } | 2440 } |
| 2441 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name, OES_vertex_array_object not enabled"); | 2441 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, OES_vertex_array_object not enabled"); |
| 2442 return WebGLGetInfo(); | 2442 return WebGLGetInfo(); |
| 2443 case Extensions3D::MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_ani
sotropic | 2443 case Extensions3D::MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_ani
sotropic |
| 2444 if (m_extTextureFilterAnisotropic) | 2444 if (m_extTextureFilterAnisotropic) |
| 2445 return getUnsignedIntParameter(Extensions3D::MAX_TEXTURE_MAX_ANISOTR
OPY_EXT); | 2445 return getUnsignedIntParameter(Extensions3D::MAX_TEXTURE_MAX_ANISOTR
OPY_EXT); |
| 2446 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name, EXT_texture_filter_anisotropic not enabled"); | 2446 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, EXT_texture_filter_anisotropic not enabled"); |
| 2447 return WebGLGetInfo(); | 2447 return WebGLGetInfo(); |
| 2448 case Extensions3D::MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN | 2448 case Extensions3D::MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN |
| 2449 if (m_webglDrawBuffers) | 2449 if (m_webglDrawBuffers) |
| 2450 return WebGLGetInfo(maxColorAttachments()); | 2450 return WebGLGetInfo(maxColorAttachments()); |
| 2451 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name, WEBGL_draw_buffers not enabled"); | 2451 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, WEBGL_draw_buffers not enabled"); |
| 2452 return WebGLGetInfo(); | 2452 return WebGLGetInfo(); |
| 2453 case Extensions3D::MAX_DRAW_BUFFERS_EXT: | 2453 case Extensions3D::MAX_DRAW_BUFFERS_EXT: |
| 2454 if (m_webglDrawBuffers) | 2454 if (m_webglDrawBuffers) |
| 2455 return WebGLGetInfo(maxDrawBuffers()); | 2455 return WebGLGetInfo(maxDrawBuffers()); |
| 2456 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name, WEBGL_draw_buffers not enabled"); | 2456 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, WEBGL_draw_buffers not enabled"); |
| 2457 return WebGLGetInfo(); | 2457 return WebGLGetInfo(); |
| 2458 default: | 2458 default: |
| 2459 if (m_webglDrawBuffers | 2459 if (m_webglDrawBuffers |
| 2460 && pname >= Extensions3D::DRAW_BUFFER0_EXT | 2460 && pname >= Extensions3D::DRAW_BUFFER0_EXT |
| 2461 && pname < static_cast<GC3Denum>(Extensions3D::DRAW_BUFFER0_EXT + ma
xDrawBuffers())) { | 2461 && pname < static_cast<GC3Denum>(Extensions3D::DRAW_BUFFER0_EXT + ma
xDrawBuffers())) { |
| 2462 GC3Dint value = GraphicsContext3D::NONE; | 2462 GC3Dint value = GL_NONE; |
| 2463 if (m_framebufferBinding) | 2463 if (m_framebufferBinding) |
| 2464 value = m_framebufferBinding->getDrawBuffer(pname); | 2464 value = m_framebufferBinding->getDrawBuffer(pname); |
| 2465 else // emulated backbuffer | 2465 else // emulated backbuffer |
| 2466 value = m_backDrawBuffer; | 2466 value = m_backDrawBuffer; |
| 2467 return WebGLGetInfo(value); | 2467 return WebGLGetInfo(value); |
| 2468 } | 2468 } |
| 2469 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "inva
lid parameter name"); | 2469 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me"); |
| 2470 return WebGLGetInfo(); | 2470 return WebGLGetInfo(); |
| 2471 } | 2471 } |
| 2472 } | 2472 } |
| 2473 | 2473 |
| 2474 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G
C3Denum pname) | 2474 WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, G
C3Denum pname) |
| 2475 { | 2475 { |
| 2476 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) | 2476 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) |
| 2477 return WebGLGetInfo(); | 2477 return WebGLGetInfo(); |
| 2478 | 2478 |
| 2479 GC3Dint value = 0; | 2479 GC3Dint value = 0; |
| 2480 switch (pname) { | 2480 switch (pname) { |
| 2481 case GraphicsContext3D::DELETE_STATUS: | 2481 case GL_DELETE_STATUS: |
| 2482 return WebGLGetInfo(program->isDeleted()); | 2482 return WebGLGetInfo(program->isDeleted()); |
| 2483 case GraphicsContext3D::VALIDATE_STATUS: | 2483 case GL_VALIDATE_STATUS: |
| 2484 m_context->getProgramiv(objectOrZero(program), pname, &value); | 2484 m_context->getProgramiv(objectOrZero(program), pname, &value); |
| 2485 return WebGLGetInfo(static_cast<bool>(value)); | 2485 return WebGLGetInfo(static_cast<bool>(value)); |
| 2486 case GraphicsContext3D::LINK_STATUS: | 2486 case GL_LINK_STATUS: |
| 2487 return WebGLGetInfo(program->linkStatus()); | 2487 return WebGLGetInfo(program->linkStatus()); |
| 2488 case GraphicsContext3D::ATTACHED_SHADERS: | 2488 case GL_ATTACHED_SHADERS: |
| 2489 case GraphicsContext3D::ACTIVE_ATTRIBUTES: | 2489 case GL_ACTIVE_ATTRIBUTES: |
| 2490 case GraphicsContext3D::ACTIVE_UNIFORMS: | 2490 case GL_ACTIVE_UNIFORMS: |
| 2491 m_context->getProgramiv(objectOrZero(program), pname, &value); | 2491 m_context->getProgramiv(objectOrZero(program), pname, &value); |
| 2492 return WebGLGetInfo(value); | 2492 return WebGLGetInfo(value); |
| 2493 default: | 2493 default: |
| 2494 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter"
, "invalid parameter name"); | 2494 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid param
eter name"); |
| 2495 return WebGLGetInfo(); | 2495 return WebGLGetInfo(); |
| 2496 } | 2496 } |
| 2497 } | 2497 } |
| 2498 | 2498 |
| 2499 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program) | 2499 String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program) |
| 2500 { | 2500 { |
| 2501 if (isContextLost()) | 2501 if (isContextLost()) |
| 2502 return String(); | 2502 return String(); |
| 2503 if (!validateWebGLObject("getProgramInfoLog", program)) | 2503 if (!validateWebGLObject("getProgramInfoLog", program)) |
| 2504 return ""; | 2504 return ""; |
| 2505 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); | 2505 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); |
| 2506 } | 2506 } |
| 2507 | 2507 |
| 2508 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC
3Denum pname) | 2508 WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC
3Denum pname) |
| 2509 { | 2509 { |
| 2510 if (isContextLost()) | 2510 if (isContextLost()) |
| 2511 return WebGLGetInfo(); | 2511 return WebGLGetInfo(); |
| 2512 if (target != GraphicsContext3D::RENDERBUFFER) { | 2512 if (target != GL_RENDERBUFFER) { |
| 2513 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam
eter", "invalid target"); | 2513 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid
target"); |
| 2514 return WebGLGetInfo(); | 2514 return WebGLGetInfo(); |
| 2515 } | 2515 } |
| 2516 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { | 2516 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { |
| 2517 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getRenderbuffer
Parameter", "no renderbuffer bound"); | 2517 synthesizeGLError(GL_INVALID_OPERATION, "getRenderbufferParameter", "no
renderbuffer bound"); |
| 2518 return WebGLGetInfo(); | 2518 return WebGLGetInfo(); |
| 2519 } | 2519 } |
| 2520 | 2520 |
| 2521 GC3Dint value = 0; | 2521 GC3Dint value = 0; |
| 2522 switch (pname) { | 2522 switch (pname) { |
| 2523 case GraphicsContext3D::RENDERBUFFER_WIDTH: | 2523 case GL_RENDERBUFFER_WIDTH: |
| 2524 case GraphicsContext3D::RENDERBUFFER_HEIGHT: | 2524 case GL_RENDERBUFFER_HEIGHT: |
| 2525 case GraphicsContext3D::RENDERBUFFER_RED_SIZE: | 2525 case GL_RENDERBUFFER_RED_SIZE: |
| 2526 case GraphicsContext3D::RENDERBUFFER_GREEN_SIZE: | 2526 case GL_RENDERBUFFER_GREEN_SIZE: |
| 2527 case GraphicsContext3D::RENDERBUFFER_BLUE_SIZE: | 2527 case GL_RENDERBUFFER_BLUE_SIZE: |
| 2528 case GraphicsContext3D::RENDERBUFFER_ALPHA_SIZE: | 2528 case GL_RENDERBUFFER_ALPHA_SIZE: |
| 2529 case GraphicsContext3D::RENDERBUFFER_DEPTH_SIZE: | 2529 case GL_RENDERBUFFER_DEPTH_SIZE: |
| 2530 m_context->getRenderbufferParameteriv(target, pname, &value); | 2530 m_context->getRenderbufferParameteriv(target, pname, &value); |
| 2531 return WebGLGetInfo(value); | 2531 return WebGLGetInfo(value); |
| 2532 case GraphicsContext3D::RENDERBUFFER_STENCIL_SIZE: | 2532 case GL_RENDERBUFFER_STENCIL_SIZE: |
| 2533 if (m_renderbufferBinding->emulatedStencilBuffer()) { | 2533 if (m_renderbufferBinding->emulatedStencilBuffer()) { |
| 2534 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng->emulatedStencilBuffer())); | 2534 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng->emulatedStencilBuffer())); |
| 2535 m_context->getRenderbufferParameteriv(target, pname, &value); | 2535 m_context->getRenderbufferParameteriv(target, pname, &value); |
| 2536 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng.get())); | 2536 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng.get())); |
| 2537 } else { | 2537 } else { |
| 2538 m_context->getRenderbufferParameteriv(target, pname, &value); | 2538 m_context->getRenderbufferParameteriv(target, pname, &value); |
| 2539 } | 2539 } |
| 2540 return WebGLGetInfo(value); | 2540 return WebGLGetInfo(value); |
| 2541 case GraphicsContext3D::RENDERBUFFER_INTERNAL_FORMAT: | 2541 case GL_RENDERBUFFER_INTERNAL_FORMAT: |
| 2542 return WebGLGetInfo(m_renderbufferBinding->internalFormat()); | 2542 return WebGLGetInfo(m_renderbufferBinding->internalFormat()); |
| 2543 default: | 2543 default: |
| 2544 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getRenderbufferParam
eter", "invalid parameter name"); | 2544 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid
parameter name"); |
| 2545 return WebGLGetInfo(); | 2545 return WebGLGetInfo(); |
| 2546 } | 2546 } |
| 2547 } | 2547 } |
| 2548 | 2548 |
| 2549 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D
enum pname) | 2549 WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D
enum pname) |
| 2550 { | 2550 { |
| 2551 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) | 2551 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) |
| 2552 return WebGLGetInfo(); | 2552 return WebGLGetInfo(); |
| 2553 GC3Dint value = 0; | 2553 GC3Dint value = 0; |
| 2554 switch (pname) { | 2554 switch (pname) { |
| 2555 case GraphicsContext3D::DELETE_STATUS: | 2555 case GL_DELETE_STATUS: |
| 2556 return WebGLGetInfo(shader->isDeleted()); | 2556 return WebGLGetInfo(shader->isDeleted()); |
| 2557 case GraphicsContext3D::COMPILE_STATUS: | 2557 case GL_COMPILE_STATUS: |
| 2558 m_context->getShaderiv(objectOrZero(shader), pname, &value); | 2558 m_context->getShaderiv(objectOrZero(shader), pname, &value); |
| 2559 return WebGLGetInfo(static_cast<bool>(value)); | 2559 return WebGLGetInfo(static_cast<bool>(value)); |
| 2560 case GraphicsContext3D::SHADER_TYPE: | 2560 case GL_SHADER_TYPE: |
| 2561 m_context->getShaderiv(objectOrZero(shader), pname, &value); | 2561 m_context->getShaderiv(objectOrZero(shader), pname, &value); |
| 2562 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2562 return WebGLGetInfo(static_cast<unsigned int>(value)); |
| 2563 default: | 2563 default: |
| 2564 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderParameter",
"invalid parameter name"); | 2564 synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parame
ter name"); |
| 2565 return WebGLGetInfo(); | 2565 return WebGLGetInfo(); |
| 2566 } | 2566 } |
| 2567 } | 2567 } |
| 2568 | 2568 |
| 2569 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader) | 2569 String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader) |
| 2570 { | 2570 { |
| 2571 if (isContextLost()) | 2571 if (isContextLost()) |
| 2572 return String(); | 2572 return String(); |
| 2573 if (!validateWebGLObject("getShaderInfoLog", shader)) | 2573 if (!validateWebGLObject("getShaderInfoLog", shader)) |
| 2574 return ""; | 2574 return ""; |
| 2575 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); | 2575 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); |
| 2576 } | 2576 } |
| 2577 | 2577 |
| 2578 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision
Format(GC3Denum shaderType, GC3Denum precisionType) | 2578 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision
Format(GC3Denum shaderType, GC3Denum precisionType) |
| 2579 { | 2579 { |
| 2580 if (isContextLost()) | 2580 if (isContextLost()) |
| 2581 return 0; | 2581 return 0; |
| 2582 switch (shaderType) { | 2582 switch (shaderType) { |
| 2583 case GraphicsContext3D::VERTEX_SHADER: | 2583 case GL_VERTEX_SHADER: |
| 2584 case GraphicsContext3D::FRAGMENT_SHADER: | 2584 case GL_FRAGMENT_SHADER: |
| 2585 break; | 2585 break; |
| 2586 default: | 2586 default: |
| 2587 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFo
rmat", "invalid shader type"); | 2587 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
shader type"); |
| 2588 return 0; | 2588 return 0; |
| 2589 } | 2589 } |
| 2590 switch (precisionType) { | 2590 switch (precisionType) { |
| 2591 case GraphicsContext3D::LOW_FLOAT: | 2591 case GL_LOW_FLOAT: |
| 2592 case GraphicsContext3D::MEDIUM_FLOAT: | 2592 case GL_MEDIUM_FLOAT: |
| 2593 case GraphicsContext3D::HIGH_FLOAT: | 2593 case GL_HIGH_FLOAT: |
| 2594 case GraphicsContext3D::LOW_INT: | 2594 case GL_LOW_INT: |
| 2595 case GraphicsContext3D::MEDIUM_INT: | 2595 case GL_MEDIUM_INT: |
| 2596 case GraphicsContext3D::HIGH_INT: | 2596 case GL_HIGH_INT: |
| 2597 break; | 2597 break; |
| 2598 default: | 2598 default: |
| 2599 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFo
rmat", "invalid precision type"); | 2599 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
precision type"); |
| 2600 return 0; | 2600 return 0; |
| 2601 } | 2601 } |
| 2602 | 2602 |
| 2603 GC3Dint range[2] = {0, 0}; | 2603 GC3Dint range[2] = {0, 0}; |
| 2604 GC3Dint precision = 0; | 2604 GC3Dint precision = 0; |
| 2605 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci
sion); | 2605 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci
sion); |
| 2606 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); | 2606 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); |
| 2607 } | 2607 } |
| 2608 | 2608 |
| 2609 String WebGLRenderingContext::getShaderSource(WebGLShader* shader) | 2609 String WebGLRenderingContext::getShaderSource(WebGLShader* shader) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2638 | 2638 |
| 2639 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn
ame) | 2639 WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pn
ame) |
| 2640 { | 2640 { |
| 2641 if (isContextLost()) | 2641 if (isContextLost()) |
| 2642 return WebGLGetInfo(); | 2642 return WebGLGetInfo(); |
| 2643 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false)
; | 2643 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false)
; |
| 2644 if (!tex) | 2644 if (!tex) |
| 2645 return WebGLGetInfo(); | 2645 return WebGLGetInfo(); |
| 2646 GC3Dint value = 0; | 2646 GC3Dint value = 0; |
| 2647 switch (pname) { | 2647 switch (pname) { |
| 2648 case GraphicsContext3D::TEXTURE_MAG_FILTER: | 2648 case GL_TEXTURE_MAG_FILTER: |
| 2649 case GraphicsContext3D::TEXTURE_MIN_FILTER: | 2649 case GL_TEXTURE_MIN_FILTER: |
| 2650 case GraphicsContext3D::TEXTURE_WRAP_S: | 2650 case GL_TEXTURE_WRAP_S: |
| 2651 case GraphicsContext3D::TEXTURE_WRAP_T: | 2651 case GL_TEXTURE_WRAP_T: |
| 2652 m_context->getTexParameteriv(target, pname, &value); | 2652 m_context->getTexParameteriv(target, pname, &value); |
| 2653 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2653 return WebGLGetInfo(static_cast<unsigned int>(value)); |
| 2654 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr
opic | 2654 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr
opic |
| 2655 if (m_extTextureFilterAnisotropic) { | 2655 if (m_extTextureFilterAnisotropic) { |
| 2656 m_context->getTexParameteriv(target, pname, &value); | 2656 m_context->getTexParameteriv(target, pname, &value); |
| 2657 return WebGLGetInfo(static_cast<unsigned int>(value)); | 2657 return WebGLGetInfo(static_cast<unsigned int>(value)); |
| 2658 } | 2658 } |
| 2659 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i
nvalid parameter name, EXT_texture_filter_anisotropic not enabled"); | 2659 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name, EXT_texture_filter_anisotropic not enabled"); |
| 2660 return WebGLGetInfo(); | 2660 return WebGLGetInfo(); |
| 2661 default: | 2661 default: |
| 2662 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getTexParameter", "i
nvalid parameter name"); | 2662 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name"); |
| 2663 return WebGLGetInfo(); | 2663 return WebGLGetInfo(); |
| 2664 } | 2664 } |
| 2665 } | 2665 } |
| 2666 | 2666 |
| 2667 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
LUniformLocation* uniformLocation) | 2667 WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
LUniformLocation* uniformLocation) |
| 2668 { | 2668 { |
| 2669 if (isContextLost() || !validateWebGLObject("getUniform", program)) | 2669 if (isContextLost() || !validateWebGLObject("getUniform", program)) |
| 2670 return WebGLGetInfo(); | 2670 return WebGLGetInfo(); |
| 2671 if (!uniformLocation || uniformLocation->program() != program) { | 2671 if (!uniformLocation || uniformLocation->program() != program) { |
| 2672 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniform", "n
o uniformlocation or not valid for this program"); | 2672 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", "no uniformlocatio
n or not valid for this program"); |
| 2673 return WebGLGetInfo(); | 2673 return WebGLGetInfo(); |
| 2674 } | 2674 } |
| 2675 GC3Dint location = uniformLocation->location(); | 2675 GC3Dint location = uniformLocation->location(); |
| 2676 | 2676 |
| 2677 // FIXME: make this more efficient using WebGLUniformLocation and caching ty
pes in it | 2677 // FIXME: make this more efficient using WebGLUniformLocation and caching ty
pes in it |
| 2678 GC3Dint activeUniforms = 0; | 2678 GC3Dint activeUniforms = 0; |
| 2679 m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNI
FORMS, &activeUniforms); | 2679 m_context->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activeUn
iforms); |
| 2680 for (GC3Dint i = 0; i < activeUniforms; i++) { | 2680 for (GC3Dint i = 0; i < activeUniforms; i++) { |
| 2681 ActiveInfo info; | 2681 ActiveInfo info; |
| 2682 if (!m_context->getActiveUniform(objectOrZero(program), i, info)) | 2682 if (!m_context->getActiveUniform(objectOrZero(program), i, info)) |
| 2683 return WebGLGetInfo(); | 2683 return WebGLGetInfo(); |
| 2684 // Strip "[0]" from the name if it's an array. | 2684 // Strip "[0]" from the name if it's an array. |
| 2685 if (info.size > 1 && info.name.endsWith("[0]")) | 2685 if (info.size > 1 && info.name.endsWith("[0]")) |
| 2686 info.name = info.name.left(info.name.length() - 3); | 2686 info.name = info.name.left(info.name.length() - 3); |
| 2687 // If it's an array, we need to iterate through each element, appending
"[index]" to the name. | 2687 // If it's an array, we need to iterate through each element, appending
"[index]" to the name. |
| 2688 for (GC3Dint index = 0; index < info.size; ++index) { | 2688 for (GC3Dint index = 0; index < info.size; ++index) { |
| 2689 String name = info.name; | 2689 String name = info.name; |
| 2690 if (info.size > 1 && index >= 1) { | 2690 if (info.size > 1 && index >= 1) { |
| 2691 name.append('['); | 2691 name.append('['); |
| 2692 name.append(String::number(index)); | 2692 name.append(String::number(index)); |
| 2693 name.append(']'); | 2693 name.append(']'); |
| 2694 } | 2694 } |
| 2695 // Now need to look this up by name again to find its location | 2695 // Now need to look this up by name again to find its location |
| 2696 GC3Dint loc = m_context->getUniformLocation(objectOrZero(program), n
ame); | 2696 GC3Dint loc = m_context->getUniformLocation(objectOrZero(program), n
ame); |
| 2697 if (loc == location) { | 2697 if (loc == location) { |
| 2698 // Found it. Use the type in the ActiveInfo to determine the ret
urn type. | 2698 // Found it. Use the type in the ActiveInfo to determine the ret
urn type. |
| 2699 GC3Denum baseType; | 2699 GC3Denum baseType; |
| 2700 unsigned int length; | 2700 unsigned int length; |
| 2701 switch (info.type) { | 2701 switch (info.type) { |
| 2702 case GraphicsContext3D::BOOL: | 2702 case GL_BOOL: |
| 2703 baseType = GraphicsContext3D::BOOL; | 2703 baseType = GL_BOOL; |
| 2704 length = 1; | 2704 length = 1; |
| 2705 break; | 2705 break; |
| 2706 case GraphicsContext3D::BOOL_VEC2: | 2706 case GL_BOOL_VEC2: |
| 2707 baseType = GraphicsContext3D::BOOL; | 2707 baseType = GL_BOOL; |
| 2708 length = 2; | 2708 length = 2; |
| 2709 break; | 2709 break; |
| 2710 case GraphicsContext3D::BOOL_VEC3: | 2710 case GL_BOOL_VEC3: |
| 2711 baseType = GraphicsContext3D::BOOL; | 2711 baseType = GL_BOOL; |
| 2712 length = 3; | 2712 length = 3; |
| 2713 break; | 2713 break; |
| 2714 case GraphicsContext3D::BOOL_VEC4: | 2714 case GL_BOOL_VEC4: |
| 2715 baseType = GraphicsContext3D::BOOL; | 2715 baseType = GL_BOOL; |
| 2716 length = 4; | 2716 length = 4; |
| 2717 break; | 2717 break; |
| 2718 case GraphicsContext3D::INT: | 2718 case GL_INT: |
| 2719 baseType = GraphicsContext3D::INT; | 2719 baseType = GL_INT; |
| 2720 length = 1; | 2720 length = 1; |
| 2721 break; | 2721 break; |
| 2722 case GraphicsContext3D::INT_VEC2: | 2722 case GL_INT_VEC2: |
| 2723 baseType = GraphicsContext3D::INT; | 2723 baseType = GL_INT; |
| 2724 length = 2; | 2724 length = 2; |
| 2725 break; | 2725 break; |
| 2726 case GraphicsContext3D::INT_VEC3: | 2726 case GL_INT_VEC3: |
| 2727 baseType = GraphicsContext3D::INT; | 2727 baseType = GL_INT; |
| 2728 length = 3; | 2728 length = 3; |
| 2729 break; | 2729 break; |
| 2730 case GraphicsContext3D::INT_VEC4: | 2730 case GL_INT_VEC4: |
| 2731 baseType = GraphicsContext3D::INT; | 2731 baseType = GL_INT; |
| 2732 length = 4; | 2732 length = 4; |
| 2733 break; | 2733 break; |
| 2734 case GraphicsContext3D::FLOAT: | 2734 case GL_FLOAT: |
| 2735 baseType = GraphicsContext3D::FLOAT; | 2735 baseType = GL_FLOAT; |
| 2736 length = 1; | 2736 length = 1; |
| 2737 break; | 2737 break; |
| 2738 case GraphicsContext3D::FLOAT_VEC2: | 2738 case GL_FLOAT_VEC2: |
| 2739 baseType = GraphicsContext3D::FLOAT; | 2739 baseType = GL_FLOAT; |
| 2740 length = 2; | 2740 length = 2; |
| 2741 break; | 2741 break; |
| 2742 case GraphicsContext3D::FLOAT_VEC3: | 2742 case GL_FLOAT_VEC3: |
| 2743 baseType = GraphicsContext3D::FLOAT; | 2743 baseType = GL_FLOAT; |
| 2744 length = 3; | 2744 length = 3; |
| 2745 break; | 2745 break; |
| 2746 case GraphicsContext3D::FLOAT_VEC4: | 2746 case GL_FLOAT_VEC4: |
| 2747 baseType = GraphicsContext3D::FLOAT; | 2747 baseType = GL_FLOAT; |
| 2748 length = 4; | 2748 length = 4; |
| 2749 break; | 2749 break; |
| 2750 case GraphicsContext3D::FLOAT_MAT2: | 2750 case GL_FLOAT_MAT2: |
| 2751 baseType = GraphicsContext3D::FLOAT; | 2751 baseType = GL_FLOAT; |
| 2752 length = 4; | 2752 length = 4; |
| 2753 break; | 2753 break; |
| 2754 case GraphicsContext3D::FLOAT_MAT3: | 2754 case GL_FLOAT_MAT3: |
| 2755 baseType = GraphicsContext3D::FLOAT; | 2755 baseType = GL_FLOAT; |
| 2756 length = 9; | 2756 length = 9; |
| 2757 break; | 2757 break; |
| 2758 case GraphicsContext3D::FLOAT_MAT4: | 2758 case GL_FLOAT_MAT4: |
| 2759 baseType = GraphicsContext3D::FLOAT; | 2759 baseType = GL_FLOAT; |
| 2760 length = 16; | 2760 length = 16; |
| 2761 break; | 2761 break; |
| 2762 case GraphicsContext3D::SAMPLER_2D: | 2762 case GL_SAMPLER_2D: |
| 2763 case GraphicsContext3D::SAMPLER_CUBE: | 2763 case GL_SAMPLER_CUBE: |
| 2764 baseType = GraphicsContext3D::INT; | 2764 baseType = GL_INT; |
| 2765 length = 1; | 2765 length = 1; |
| 2766 break; | 2766 break; |
| 2767 default: | 2767 default: |
| 2768 // Can't handle this type | 2768 // Can't handle this type |
| 2769 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUnif
orm", "unhandled type"); | 2769 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unhandled
type"); |
| 2770 return WebGLGetInfo(); | 2770 return WebGLGetInfo(); |
| 2771 } | 2771 } |
| 2772 switch (baseType) { | 2772 switch (baseType) { |
| 2773 case GraphicsContext3D::FLOAT: { | 2773 case GL_FLOAT: { |
| 2774 GC3Dfloat value[16] = {0}; | 2774 GC3Dfloat value[16] = {0}; |
| 2775 m_context->getUniformfv(objectOrZero(program), location, val
ue); | 2775 m_context->getUniformfv(objectOrZero(program), location, val
ue); |
| 2776 if (length == 1) | 2776 if (length == 1) |
| 2777 return WebGLGetInfo(value[0]); | 2777 return WebGLGetInfo(value[0]); |
| 2778 return WebGLGetInfo(Float32Array::create(value, length)); | 2778 return WebGLGetInfo(Float32Array::create(value, length)); |
| 2779 } | 2779 } |
| 2780 case GraphicsContext3D::INT: { | 2780 case GL_INT: { |
| 2781 GC3Dint value[4] = {0}; | 2781 GC3Dint value[4] = {0}; |
| 2782 m_context->getUniformiv(objectOrZero(program), location, val
ue); | 2782 m_context->getUniformiv(objectOrZero(program), location, val
ue); |
| 2783 if (length == 1) | 2783 if (length == 1) |
| 2784 return WebGLGetInfo(value[0]); | 2784 return WebGLGetInfo(value[0]); |
| 2785 return WebGLGetInfo(Int32Array::create(value, length)); | 2785 return WebGLGetInfo(Int32Array::create(value, length)); |
| 2786 } | 2786 } |
| 2787 case GraphicsContext3D::BOOL: { | 2787 case GL_BOOL: { |
| 2788 GC3Dint value[4] = {0}; | 2788 GC3Dint value[4] = {0}; |
| 2789 m_context->getUniformiv(objectOrZero(program), location, val
ue); | 2789 m_context->getUniformiv(objectOrZero(program), location, val
ue); |
| 2790 if (length > 1) { | 2790 if (length > 1) { |
| 2791 bool boolValue[16] = {0}; | 2791 bool boolValue[16] = {0}; |
| 2792 for (unsigned j = 0; j < length; j++) | 2792 for (unsigned j = 0; j < length; j++) |
| 2793 boolValue[j] = static_cast<bool>(value[j]); | 2793 boolValue[j] = static_cast<bool>(value[j]); |
| 2794 return WebGLGetInfo(boolValue, length); | 2794 return WebGLGetInfo(boolValue, length); |
| 2795 } | 2795 } |
| 2796 return WebGLGetInfo(static_cast<bool>(value[0])); | 2796 return WebGLGetInfo(static_cast<bool>(value[0])); |
| 2797 } | 2797 } |
| 2798 default: | 2798 default: |
| 2799 notImplemented(); | 2799 notImplemented(); |
| 2800 } | 2800 } |
| 2801 } | 2801 } |
| 2802 } | 2802 } |
| 2803 } | 2803 } |
| 2804 // If we get here, something went wrong in our unfortunately complex logic a
bove | 2804 // If we get here, something went wrong in our unfortunately complex logic a
bove |
| 2805 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getUniform", "unknown e
rror"); | 2805 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error"); |
| 2806 return WebGLGetInfo(); | 2806 return WebGLGetInfo(); |
| 2807 } | 2807 } |
| 2808 | 2808 |
| 2809 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL
Program* program, const String& name) | 2809 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL
Program* program, const String& name) |
| 2810 { | 2810 { |
| 2811 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) | 2811 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) |
| 2812 return 0; | 2812 return 0; |
| 2813 if (!validateLocationLength("getUniformLocation", name)) | 2813 if (!validateLocationLength("getUniformLocation", name)) |
| 2814 return 0; | 2814 return 0; |
| 2815 if (!validateString("getUniformLocation", name)) | 2815 if (!validateString("getUniformLocation", name)) |
| 2816 return 0; | 2816 return 0; |
| 2817 if (isPrefixReserved(name)) | 2817 if (isPrefixReserved(name)) |
| 2818 return 0; | 2818 return 0; |
| 2819 if (!program->linkStatus()) { | 2819 if (!program->linkStatus()) { |
| 2820 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "getUniformLocat
ion", "program not linked"); | 2820 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); |
| 2821 return 0; | 2821 return 0; |
| 2822 } | 2822 } |
| 2823 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program
), name); | 2823 GC3Dint uniformLocation = m_context->getUniformLocation(objectOrZero(program
), name); |
| 2824 if (uniformLocation == -1) | 2824 if (uniformLocation == -1) |
| 2825 return 0; | 2825 return 0; |
| 2826 return WebGLUniformLocation::create(program, uniformLocation); | 2826 return WebGLUniformLocation::create(program, uniformLocation); |
| 2827 } | 2827 } |
| 2828 | 2828 |
| 2829 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna
me) | 2829 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pna
me) |
| 2830 { | 2830 { |
| 2831 if (isContextLost()) | 2831 if (isContextLost()) |
| 2832 return WebGLGetInfo(); | 2832 return WebGLGetInfo(); |
| 2833 if (index >= m_maxVertexAttribs) { | 2833 if (index >= m_maxVertexAttribs) { |
| 2834 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getVertexAttrib", "
index out of range"); | 2834 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran
ge"); |
| 2835 return WebGLGetInfo(); | 2835 return WebGLGetInfo(); |
| 2836 } | 2836 } |
| 2837 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr
ayObject->getVertexAttribState(index); | 2837 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr
ayObject->getVertexAttribState(index); |
| 2838 | 2838 |
| 2839 if (m_angleInstancedArrays && pname == Extensions3D::VERTEX_ATTRIB_ARRAY_DIV
ISOR_ANGLE) | 2839 if (m_angleInstancedArrays && pname == Extensions3D::VERTEX_ATTRIB_ARRAY_DIV
ISOR_ANGLE) |
| 2840 return WebGLGetInfo(state.divisor); | 2840 return WebGLGetInfo(state.divisor); |
| 2841 | 2841 |
| 2842 switch (pname) { | 2842 switch (pname) { |
| 2843 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: | 2843 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
| 2844 if (!state.bufferBinding || !state.bufferBinding->object()) | 2844 if (!state.bufferBinding || !state.bufferBinding->object()) |
| 2845 return WebGLGetInfo(); | 2845 return WebGLGetInfo(); |
| 2846 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding)); | 2846 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding)); |
| 2847 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_ENABLED: | 2847 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
| 2848 return WebGLGetInfo(state.enabled); | 2848 return WebGLGetInfo(state.enabled); |
| 2849 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_NORMALIZED: | 2849 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 2850 return WebGLGetInfo(state.normalized); | 2850 return WebGLGetInfo(state.normalized); |
| 2851 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_SIZE: | 2851 case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
| 2852 return WebGLGetInfo(state.size); | 2852 return WebGLGetInfo(state.size); |
| 2853 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_STRIDE: | 2853 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
| 2854 return WebGLGetInfo(state.originalStride); | 2854 return WebGLGetInfo(state.originalStride); |
| 2855 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_TYPE: | 2855 case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 2856 return WebGLGetInfo(state.type); | 2856 return WebGLGetInfo(state.type); |
| 2857 case GraphicsContext3D::CURRENT_VERTEX_ATTRIB: | 2857 case GL_CURRENT_VERTEX_ATTRIB: |
| 2858 return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].valu
e, 4)); | 2858 return WebGLGetInfo(Float32Array::create(m_vertexAttribValue[index].valu
e, 4)); |
| 2859 default: | 2859 default: |
| 2860 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttrib", "i
nvalid parameter name"); | 2860 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttrib", "invalid parameter
name"); |
| 2861 return WebGLGetInfo(); | 2861 return WebGLGetInfo(); |
| 2862 } | 2862 } |
| 2863 } | 2863 } |
| 2864 | 2864 |
| 2865 long long WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum
pname) | 2865 long long WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum
pname) |
| 2866 { | 2866 { |
| 2867 if (isContextLost()) | 2867 if (isContextLost()) |
| 2868 return 0; | 2868 return 0; |
| 2869 if (pname != GraphicsContext3D::VERTEX_ATTRIB_ARRAY_POINTER) { | 2869 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) { |
| 2870 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getVertexAttribOffse
t", "invalid parameter name"); | 2870 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttribOffset", "invalid par
ameter name"); |
| 2871 return 0; | 2871 return 0; |
| 2872 } | 2872 } |
| 2873 GC3Dsizeiptr result = m_context->getVertexAttribOffset(index, pname); | 2873 GC3Dsizeiptr result = m_context->getVertexAttribOffset(index, pname); |
| 2874 return static_cast<long long>(result); | 2874 return static_cast<long long>(result); |
| 2875 } | 2875 } |
| 2876 | 2876 |
| 2877 void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode) | 2877 void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode) |
| 2878 { | 2878 { |
| 2879 if (isContextLost()) | 2879 if (isContextLost()) |
| 2880 return; | 2880 return; |
| 2881 bool isValid = false; | 2881 bool isValid = false; |
| 2882 switch (target) { | 2882 switch (target) { |
| 2883 case GraphicsContext3D::GENERATE_MIPMAP_HINT: | 2883 case GL_GENERATE_MIPMAP_HINT: |
| 2884 isValid = true; | 2884 isValid = true; |
| 2885 break; | 2885 break; |
| 2886 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri
vatives | 2886 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri
vatives |
| 2887 if (m_oesStandardDerivatives) | 2887 if (m_oesStandardDerivatives) |
| 2888 isValid = true; | 2888 isValid = true; |
| 2889 break; | 2889 break; |
| 2890 } | 2890 } |
| 2891 if (!isValid) { | 2891 if (!isValid) { |
| 2892 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "hint", "invalid targ
et"); | 2892 synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target"); |
| 2893 return; | 2893 return; |
| 2894 } | 2894 } |
| 2895 m_context->hint(target, mode); | 2895 m_context->hint(target, mode); |
| 2896 } | 2896 } |
| 2897 | 2897 |
| 2898 GC3Dboolean WebGLRenderingContext::isBuffer(WebGLBuffer* buffer) | 2898 GC3Dboolean WebGLRenderingContext::isBuffer(WebGLBuffer* buffer) |
| 2899 { | 2899 { |
| 2900 if (!buffer || isContextLost()) | 2900 if (!buffer || isContextLost()) |
| 2901 return 0; | 2901 return 0; |
| 2902 | 2902 |
| 2903 if (!buffer->hasEverBeenBound()) | 2903 if (!buffer->hasEverBeenBound()) |
| 2904 return 0; | 2904 return 0; |
| 2905 | 2905 |
| 2906 return m_context->isBuffer(buffer->object()); | 2906 return m_context->isBuffer(buffer->object()); |
| 2907 } | 2907 } |
| 2908 | 2908 |
| 2909 bool WebGLRenderingContext::isContextLost() | 2909 bool WebGLRenderingContext::isContextLost() |
| 2910 { | 2910 { |
| 2911 return m_contextLost; | 2911 return m_contextLost; |
| 2912 } | 2912 } |
| 2913 | 2913 |
| 2914 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) | 2914 GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap) |
| 2915 { | 2915 { |
| 2916 if (isContextLost() || !validateCapability("isEnabled", cap)) | 2916 if (isContextLost() || !validateCapability("isEnabled", cap)) |
| 2917 return 0; | 2917 return 0; |
| 2918 if (cap == GraphicsContext3D::STENCIL_TEST) | 2918 if (cap == GL_STENCIL_TEST) |
| 2919 return m_stencilEnabled; | 2919 return m_stencilEnabled; |
| 2920 return m_context->isEnabled(cap); | 2920 return m_context->isEnabled(cap); |
| 2921 } | 2921 } |
| 2922 | 2922 |
| 2923 GC3Dboolean WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer) | 2923 GC3Dboolean WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer) |
| 2924 { | 2924 { |
| 2925 if (!framebuffer || isContextLost()) | 2925 if (!framebuffer || isContextLost()) |
| 2926 return 0; | 2926 return 0; |
| 2927 | 2927 |
| 2928 if (!framebuffer->hasEverBeenBound()) | 2928 if (!framebuffer->hasEverBeenBound()) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2983 | 2983 |
| 2984 m_context->linkProgram(objectOrZero(program)); | 2984 m_context->linkProgram(objectOrZero(program)); |
| 2985 program->increaseLinkCount(); | 2985 program->increaseLinkCount(); |
| 2986 } | 2986 } |
| 2987 | 2987 |
| 2988 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param) | 2988 void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param) |
| 2989 { | 2989 { |
| 2990 if (isContextLost()) | 2990 if (isContextLost()) |
| 2991 return; | 2991 return; |
| 2992 switch (pname) { | 2992 switch (pname) { |
| 2993 case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL: | 2993 case GC3D_UNPACK_FLIP_Y_WEBGL: |
| 2994 m_unpackFlipY = param; | 2994 m_unpackFlipY = param; |
| 2995 break; | 2995 break; |
| 2996 case GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL: | 2996 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL: |
| 2997 m_unpackPremultiplyAlpha = param; | 2997 m_unpackPremultiplyAlpha = param; |
| 2998 break; | 2998 break; |
| 2999 case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL: | 2999 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL: |
| 3000 if (param == GraphicsContext3D::BROWSER_DEFAULT_WEBGL || param == Graphi
csContext3D::NONE) | 3000 if (static_cast<GC3Denum>(param) == GC3D_BROWSER_DEFAULT_WEBGL || param
== GL_NONE) |
| 3001 m_unpackColorspaceConversion = static_cast<GC3Denum>(param); | 3001 m_unpackColorspaceConversion = static_cast<GC3Denum>(param); |
| 3002 else { | 3002 else { |
| 3003 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", "
invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL"); | 3003 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for UNPACK_COLORSPACE_CONVERSION_WEBGL"); |
| 3004 return; | 3004 return; |
| 3005 } | 3005 } |
| 3006 break; | 3006 break; |
| 3007 case GraphicsContext3D::PACK_ALIGNMENT: | 3007 case GL_PACK_ALIGNMENT: |
| 3008 case GraphicsContext3D::UNPACK_ALIGNMENT: | 3008 case GL_UNPACK_ALIGNMENT: |
| 3009 if (param == 1 || param == 2 || param == 4 || param == 8) { | 3009 if (param == 1 || param == 2 || param == 4 || param == 8) { |
| 3010 if (pname == GraphicsContext3D::PACK_ALIGNMENT) | 3010 if (pname == GL_PACK_ALIGNMENT) |
| 3011 m_packAlignment = param; | 3011 m_packAlignment = param; |
| 3012 else // GraphicsContext3D::UNPACK_ALIGNMENT: | 3012 else // GL_UNPACK_ALIGNMENT: |
| 3013 m_unpackAlignment = param; | 3013 m_unpackAlignment = param; |
| 3014 m_context->pixelStorei(pname, param); | 3014 m_context->pixelStorei(pname, param); |
| 3015 } else { | 3015 } else { |
| 3016 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "pixelStorei", "
invalid parameter for alignment"); | 3016 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for alignment"); |
| 3017 return; | 3017 return; |
| 3018 } | 3018 } |
| 3019 break; | 3019 break; |
| 3020 default: | 3020 default: |
| 3021 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "pixelStorei", "inval
id parameter name"); | 3021 synthesizeGLError(GL_INVALID_ENUM, "pixelStorei", "invalid parameter nam
e"); |
| 3022 return; | 3022 return; |
| 3023 } | 3023 } |
| 3024 } | 3024 } |
| 3025 | 3025 |
| 3026 void WebGLRenderingContext::polygonOffset(GC3Dfloat factor, GC3Dfloat units) | 3026 void WebGLRenderingContext::polygonOffset(GC3Dfloat factor, GC3Dfloat units) |
| 3027 { | 3027 { |
| 3028 if (isContextLost()) | 3028 if (isContextLost()) |
| 3029 return; | 3029 return; |
| 3030 m_context->polygonOffset(factor, units); | 3030 m_context->polygonOffset(factor, units); |
| 3031 } | 3031 } |
| 3032 | 3032 |
| 3033 void WebGLRenderingContext::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC
3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels) | 3033 void WebGLRenderingContext::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC
3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels) |
| 3034 { | 3034 { |
| 3035 if (isContextLost()) | 3035 if (isContextLost()) |
| 3036 return; | 3036 return; |
| 3037 // Due to WebGL's same-origin restrictions, it is not possible to | 3037 // Due to WebGL's same-origin restrictions, it is not possible to |
| 3038 // taint the origin using the WebGL API. | 3038 // taint the origin using the WebGL API. |
| 3039 ASSERT(canvas()->originClean()); | 3039 ASSERT(canvas()->originClean()); |
| 3040 // Validate input parameters. | 3040 // Validate input parameters. |
| 3041 if (!pixels) { | 3041 if (!pixels) { |
| 3042 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "readPixels", "no de
stination ArrayBufferView"); | 3042 synthesizeGLError(GL_INVALID_VALUE, "readPixels", "no destination ArrayB
ufferView"); |
| 3043 return; | 3043 return; |
| 3044 } | 3044 } |
| 3045 switch (format) { | 3045 switch (format) { |
| 3046 case GraphicsContext3D::ALPHA: | 3046 case GL_ALPHA: |
| 3047 case GraphicsContext3D::RGB: | 3047 case GL_RGB: |
| 3048 case GraphicsContext3D::RGBA: | 3048 case GL_RGBA: |
| 3049 break; | 3049 break; |
| 3050 default: | 3050 default: |
| 3051 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "readPixels", "invali
d format"); | 3051 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid format"); |
| 3052 return; | 3052 return; |
| 3053 } | 3053 } |
| 3054 switch (type) { | 3054 switch (type) { |
| 3055 case GraphicsContext3D::UNSIGNED_BYTE: | 3055 case GL_UNSIGNED_BYTE: |
| 3056 case GraphicsContext3D::UNSIGNED_SHORT_5_6_5: | 3056 case GL_UNSIGNED_SHORT_5_6_5: |
| 3057 case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4: | 3057 case GL_UNSIGNED_SHORT_4_4_4_4: |
| 3058 case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1: | 3058 case GL_UNSIGNED_SHORT_5_5_5_1: |
| 3059 break; | 3059 break; |
| 3060 default: | 3060 default: |
| 3061 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "readPixels", "invali
d type"); | 3061 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid type"); |
| 3062 return; | 3062 return; |
| 3063 } | 3063 } |
| 3064 if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED
_BYTE) { | 3064 if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) { |
| 3065 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "f
ormat not RGBA or type not UNSIGNED_BYTE"); | 3065 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format not RGBA o
r type not UNSIGNED_BYTE"); |
| 3066 return; | 3066 return; |
| 3067 } | 3067 } |
| 3068 // Validate array type against pixel type. | 3068 // Validate array type against pixel type. |
| 3069 if (pixels->getType() != ArrayBufferView::TypeUint8) { | 3069 if (pixels->getType() != ArrayBufferView::TypeUint8) { |
| 3070 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A
rrayBufferView not Uint8Array"); | 3070 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot Uint8Array"); |
| 3071 return; | 3071 return; |
| 3072 } | 3072 } |
| 3073 const char* reason = "framebuffer incomplete"; | 3073 const char* reason = "framebuffer incomplete"; |
| 3074 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { | 3074 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3
D(), &reason)) { |
| 3075 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "rea
dPixels", reason); | 3075 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason
); |
| 3076 return; | 3076 return; |
| 3077 } | 3077 } |
| 3078 // Calculate array size, taking into consideration of PACK_ALIGNMENT. | 3078 // Calculate array size, taking into consideration of PACK_ALIGNMENT. |
| 3079 unsigned int totalBytesRequired = 0; | 3079 unsigned int totalBytesRequired = 0; |
| 3080 unsigned int padding = 0; | 3080 unsigned int padding = 0; |
| 3081 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei
ght, m_packAlignment, &totalBytesRequired, &padding); | 3081 GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, hei
ght, m_packAlignment, &totalBytesRequired, &padding); |
| 3082 if (error != GraphicsContext3D::NO_ERROR) { | 3082 if (error != GL_NO_ERROR) { |
| 3083 synthesizeGLError(error, "readPixels", "invalid dimensions"); | 3083 synthesizeGLError(error, "readPixels", "invalid dimensions"); |
| 3084 return; | 3084 return; |
| 3085 } | 3085 } |
| 3086 if (pixels->byteLength() < totalBytesRequired) { | 3086 if (pixels->byteLength() < totalBytesRequired) { |
| 3087 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "A
rrayBufferView not large enough for dimensions"); | 3087 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot large enough for dimensions"); |
| 3088 return; | 3088 return; |
| 3089 } | 3089 } |
| 3090 | 3090 |
| 3091 clearIfComposited(); | 3091 clearIfComposited(); |
| 3092 void* data = pixels->baseAddress(); | 3092 void* data = pixels->baseAddress(); |
| 3093 | 3093 |
| 3094 { | 3094 { |
| 3095 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBin
ding.get()); | 3095 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBin
ding.get()); |
| 3096 m_context->readPixels(x, y, width, height, format, type, data); | 3096 m_context->readPixels(x, y, width, height, format, type, data); |
| 3097 } | 3097 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3109 pixels += padding; | 3109 pixels += padding; |
| 3110 } | 3110 } |
| 3111 } | 3111 } |
| 3112 #endif | 3112 #endif |
| 3113 } | 3113 } |
| 3114 | 3114 |
| 3115 void WebGLRenderingContext::renderbufferStorage(GC3Denum target, GC3Denum intern
alformat, GC3Dsizei width, GC3Dsizei height) | 3115 void WebGLRenderingContext::renderbufferStorage(GC3Denum target, GC3Denum intern
alformat, GC3Dsizei width, GC3Dsizei height) |
| 3116 { | 3116 { |
| 3117 if (isContextLost()) | 3117 if (isContextLost()) |
| 3118 return; | 3118 return; |
| 3119 if (target != GraphicsContext3D::RENDERBUFFER) { | 3119 if (target != GL_RENDERBUFFER) { |
| 3120 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage"
, "invalid target"); | 3120 synthesizeGLError(GL_INVALID_ENUM, "renderbufferStorage", "invalid targe
t"); |
| 3121 return; | 3121 return; |
| 3122 } | 3122 } |
| 3123 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { | 3123 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { |
| 3124 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "renderbufferSto
rage", "no bound renderbuffer"); | 3124 synthesizeGLError(GL_INVALID_OPERATION, "renderbufferStorage", "no bound
renderbuffer"); |
| 3125 return; | 3125 return; |
| 3126 } | 3126 } |
| 3127 if (!validateSize("renderbufferStorage", width, height)) | 3127 if (!validateSize("renderbufferStorage", width, height)) |
| 3128 return; | 3128 return; |
| 3129 switch (internalformat) { | 3129 switch (internalformat) { |
| 3130 case GraphicsContext3D::DEPTH_COMPONENT16: | 3130 case GL_DEPTH_COMPONENT16: |
| 3131 case GraphicsContext3D::RGBA4: | 3131 case GL_RGBA4: |
| 3132 case GraphicsContext3D::RGB5_A1: | 3132 case GL_RGB5_A1: |
| 3133 case GraphicsContext3D::RGB565: | 3133 case GL_RGB565: |
| 3134 case GraphicsContext3D::STENCIL_INDEX8: | 3134 case GL_STENCIL_INDEX8: |
| 3135 m_context->renderbufferStorage(target, internalformat, width, height); | 3135 m_context->renderbufferStorage(target, internalformat, width, height); |
| 3136 m_renderbufferBinding->setInternalFormat(internalformat); | 3136 m_renderbufferBinding->setInternalFormat(internalformat); |
| 3137 m_renderbufferBinding->setSize(width, height); | 3137 m_renderbufferBinding->setSize(width, height); |
| 3138 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_context.get()); | 3138 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_context.get()); |
| 3139 break; | 3139 break; |
| 3140 case GraphicsContext3D::DEPTH_STENCIL: | 3140 case GL_DEPTH_STENCIL_OES: |
| 3141 if (isDepthStencilSupported()) { | 3141 if (isDepthStencilSupported()) { |
| 3142 m_context->renderbufferStorage(target, Extensions3D::DEPTH24_STENCIL
8, width, height); | 3142 m_context->renderbufferStorage(target, Extensions3D::DEPTH24_STENCIL
8, width, height); |
| 3143 } else { | 3143 } else { |
| 3144 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(target, m_renderbufferBinding.get()); | 3144 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(target, m_renderbufferBinding.get()); |
| 3145 if (!emulatedStencilBuffer) { | 3145 if (!emulatedStencilBuffer) { |
| 3146 synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "renderbuffe
rStorage", "out of memory"); | 3146 synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out
of memory"); |
| 3147 return; | 3147 return; |
| 3148 } | 3148 } |
| 3149 m_context->renderbufferStorage(target, GraphicsContext3D::DEPTH_COMP
ONENT16, width, height); | 3149 m_context->renderbufferStorage(target, GL_DEPTH_COMPONENT16, width,
height); |
| 3150 m_context->bindRenderbuffer(target, objectOrZero(emulatedStencilBuff
er)); | 3150 m_context->bindRenderbuffer(target, objectOrZero(emulatedStencilBuff
er)); |
| 3151 m_context->renderbufferStorage(target, GraphicsContext3D::STENCIL_IN
DEX8, width, height); | 3151 m_context->renderbufferStorage(target, GL_STENCIL_INDEX8, width, hei
ght); |
| 3152 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng.get())); | 3152 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng.get())); |
| 3153 emulatedStencilBuffer->setSize(width, height); | 3153 emulatedStencilBuffer->setSize(width, height); |
| 3154 emulatedStencilBuffer->setInternalFormat(GraphicsContext3D::STENCIL_
INDEX8); | 3154 emulatedStencilBuffer->setInternalFormat(GL_STENCIL_INDEX8); |
| 3155 } | 3155 } |
| 3156 m_renderbufferBinding->setSize(width, height); | 3156 m_renderbufferBinding->setSize(width, height); |
| 3157 m_renderbufferBinding->setInternalFormat(internalformat); | 3157 m_renderbufferBinding->setInternalFormat(internalformat); |
| 3158 break; | 3158 break; |
| 3159 default: | 3159 default: |
| 3160 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "renderbufferStorage"
, "invalid internalformat"); | 3160 synthesizeGLError(GL_INVALID_ENUM, "renderbufferStorage", "invalid inter
nalformat"); |
| 3161 return; | 3161 return; |
| 3162 } | 3162 } |
| 3163 applyStencilTest(); | 3163 applyStencilTest(); |
| 3164 } | 3164 } |
| 3165 | 3165 |
| 3166 void WebGLRenderingContext::sampleCoverage(GC3Dfloat value, GC3Dboolean invert) | 3166 void WebGLRenderingContext::sampleCoverage(GC3Dfloat value, GC3Dboolean invert) |
| 3167 { | 3167 { |
| 3168 if (isContextLost()) | 3168 if (isContextLost()) |
| 3169 return; | 3169 return; |
| 3170 m_context->sampleCoverage(value, invert); | 3170 m_context->sampleCoverage(value, invert); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3203 m_context->stencilFunc(func, ref, mask); | 3203 m_context->stencilFunc(func, ref, mask); |
| 3204 } | 3204 } |
| 3205 | 3205 |
| 3206 void WebGLRenderingContext::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC
3Dint ref, GC3Duint mask) | 3206 void WebGLRenderingContext::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC
3Dint ref, GC3Duint mask) |
| 3207 { | 3207 { |
| 3208 if (isContextLost()) | 3208 if (isContextLost()) |
| 3209 return; | 3209 return; |
| 3210 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) | 3210 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) |
| 3211 return; | 3211 return; |
| 3212 switch (face) { | 3212 switch (face) { |
| 3213 case GraphicsContext3D::FRONT_AND_BACK: | 3213 case GL_FRONT_AND_BACK: |
| 3214 m_stencilFuncRef = ref; | 3214 m_stencilFuncRef = ref; |
| 3215 m_stencilFuncRefBack = ref; | 3215 m_stencilFuncRefBack = ref; |
| 3216 m_stencilFuncMask = mask; | 3216 m_stencilFuncMask = mask; |
| 3217 m_stencilFuncMaskBack = mask; | 3217 m_stencilFuncMaskBack = mask; |
| 3218 break; | 3218 break; |
| 3219 case GraphicsContext3D::FRONT: | 3219 case GL_FRONT: |
| 3220 m_stencilFuncRef = ref; | 3220 m_stencilFuncRef = ref; |
| 3221 m_stencilFuncMask = mask; | 3221 m_stencilFuncMask = mask; |
| 3222 break; | 3222 break; |
| 3223 case GraphicsContext3D::BACK: | 3223 case GL_BACK: |
| 3224 m_stencilFuncRefBack = ref; | 3224 m_stencilFuncRefBack = ref; |
| 3225 m_stencilFuncMaskBack = mask; | 3225 m_stencilFuncMaskBack = mask; |
| 3226 break; | 3226 break; |
| 3227 default: | 3227 default: |
| 3228 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilFuncSeparate"
, "invalid face"); | 3228 synthesizeGLError(GL_INVALID_ENUM, "stencilFuncSeparate", "invalid face"
); |
| 3229 return; | 3229 return; |
| 3230 } | 3230 } |
| 3231 m_context->stencilFuncSeparate(face, func, ref, mask); | 3231 m_context->stencilFuncSeparate(face, func, ref, mask); |
| 3232 } | 3232 } |
| 3233 | 3233 |
| 3234 void WebGLRenderingContext::stencilMask(GC3Duint mask) | 3234 void WebGLRenderingContext::stencilMask(GC3Duint mask) |
| 3235 { | 3235 { |
| 3236 if (isContextLost()) | 3236 if (isContextLost()) |
| 3237 return; | 3237 return; |
| 3238 m_stencilMask = mask; | 3238 m_stencilMask = mask; |
| 3239 m_stencilMaskBack = mask; | 3239 m_stencilMaskBack = mask; |
| 3240 m_context->stencilMask(mask); | 3240 m_context->stencilMask(mask); |
| 3241 } | 3241 } |
| 3242 | 3242 |
| 3243 void WebGLRenderingContext::stencilMaskSeparate(GC3Denum face, GC3Duint mask) | 3243 void WebGLRenderingContext::stencilMaskSeparate(GC3Denum face, GC3Duint mask) |
| 3244 { | 3244 { |
| 3245 if (isContextLost()) | 3245 if (isContextLost()) |
| 3246 return; | 3246 return; |
| 3247 switch (face) { | 3247 switch (face) { |
| 3248 case GraphicsContext3D::FRONT_AND_BACK: | 3248 case GL_FRONT_AND_BACK: |
| 3249 m_stencilMask = mask; | 3249 m_stencilMask = mask; |
| 3250 m_stencilMaskBack = mask; | 3250 m_stencilMaskBack = mask; |
| 3251 break; | 3251 break; |
| 3252 case GraphicsContext3D::FRONT: | 3252 case GL_FRONT: |
| 3253 m_stencilMask = mask; | 3253 m_stencilMask = mask; |
| 3254 break; | 3254 break; |
| 3255 case GraphicsContext3D::BACK: | 3255 case GL_BACK: |
| 3256 m_stencilMaskBack = mask; | 3256 m_stencilMaskBack = mask; |
| 3257 break; | 3257 break; |
| 3258 default: | 3258 default: |
| 3259 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "stencilMaskSeparate"
, "invalid face"); | 3259 synthesizeGLError(GL_INVALID_ENUM, "stencilMaskSeparate", "invalid face"
); |
| 3260 return; | 3260 return; |
| 3261 } | 3261 } |
| 3262 m_context->stencilMaskSeparate(face, mask); | 3262 m_context->stencilMaskSeparate(face, mask); |
| 3263 } | 3263 } |
| 3264 | 3264 |
| 3265 void WebGLRenderingContext::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zp
ass) | 3265 void WebGLRenderingContext::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zp
ass) |
| 3266 { | 3266 { |
| 3267 if (isContextLost()) | 3267 if (isContextLost()) |
| 3268 return; | 3268 return; |
| 3269 m_context->stencilOp(fail, zfail, zpass); | 3269 m_context->stencilOp(fail, zfail, zpass); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3287 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); | 3287 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); |
| 3288 m_context->texImage2D(target, level, internalformat, width, height, | 3288 m_context->texImage2D(target, level, internalformat, width, height, |
| 3289 border, format, type, pixels); | 3289 border, format, type, pixels); |
| 3290 tex->setLevelInfo(target, level, internalformat, width, height, type); | 3290 tex->setLevelInfo(target, level, internalformat, width, height, type); |
| 3291 } | 3291 } |
| 3292 | 3292 |
| 3293 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 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) |
| 3294 { | 3294 { |
| 3295 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 3295 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
| 3296 Vector<uint8_t> data; | 3296 Vector<uint8_t> data; |
| 3297 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip
lyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE); | 3297 GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultip
lyAlpha, m_unpackColorspaceConversion == GL_NONE); |
| 3298 if (!imageExtractor.extractSucceeded()) { | 3298 if (!imageExtractor.extractSucceeded()) { |
| 3299 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad i
mage data"); | 3299 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data"); |
| 3300 return; | 3300 return; |
| 3301 } | 3301 } |
| 3302 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF
ormat(); | 3302 GraphicsContext3D::DataFormat sourceDataFormat = imageExtractor.imageSourceF
ormat(); |
| 3303 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); | 3303 GraphicsContext3D::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); |
| 3304 const void* imagePixelData = imageExtractor.imagePixelData(); | 3304 const void* imagePixelData = imageExtractor.imagePixelData(); |
| 3305 | 3305 |
| 3306 bool needConversion = true; | 3306 bool needConversion = true; |
| 3307 if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == Graphics
Context3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == Gr
aphicsContext3D::AlphaDoNothing && !flipY) | 3307 if (type == GL_UNSIGNED_BYTE && sourceDataFormat == GraphicsContext3D::DataF
ormatRGBA8 && format == GL_RGBA && alphaOp == GraphicsContext3D::AlphaDoNothing
&& !flipY) |
| 3308 needConversion = false; | 3308 needConversion = false; |
| 3309 else { | 3309 else { |
| 3310 if (!m_context->packImageData(image, imagePixelData, format, type, flipY
, alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe
ight(), imageExtractor.imageSourceUnpackAlignment(), data)) { | 3310 if (!m_context->packImageData(image, imagePixelData, format, type, flipY
, alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHe
ight(), imageExtractor.imageSourceUnpackAlignment(), data)) { |
| 3311 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "p
ackImage error"); | 3311 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "packImage error")
; |
| 3312 return; | 3312 return; |
| 3313 } | 3313 } |
| 3314 } | 3314 } |
| 3315 | 3315 |
| 3316 if (m_unpackAlignment != 1) | 3316 if (m_unpackAlignment != 1) |
| 3317 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1); | 3317 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 3318 texImage2DBase(target, level, internalformat, image->width(), image->height(
), 0, format, type, needConversion ? data.data() : imagePixelData, exceptionStat
e); | 3318 texImage2DBase(target, level, internalformat, image->width(), image->height(
), 0, format, type, needConversion ? data.data() : imagePixelData, exceptionStat
e); |
| 3319 if (m_unpackAlignment != 1) | 3319 if (m_unpackAlignment != 1) |
| 3320 m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlig
nment); | 3320 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 3321 } | 3321 } |
| 3322 | 3322 |
| 3323 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 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) |
| 3324 { | 3324 { |
| 3325 if (!validateTexFuncParameters(functionName, functionType, target, level, in
ternalformat, width, height, border, format, type)) | 3325 if (!validateTexFuncParameters(functionName, functionType, target, level, in
ternalformat, width, height, border, format, type)) |
| 3326 return false; | 3326 return false; |
| 3327 | 3327 |
| 3328 WebGLTexture* texture = validateTextureBinding(functionName, target, true); | 3328 WebGLTexture* texture = validateTextureBinding(functionName, target, true); |
| 3329 if (!texture) | 3329 if (!texture) |
| 3330 return false; | 3330 return false; |
| 3331 | 3331 |
| 3332 if (functionType == NotTexSubImage2D) { | 3332 if (functionType == NotTexSubImage2D) { |
| 3333 if (level && WebGLTexture::isNPOT(width, height)) { | 3333 if (level && WebGLTexture::isNPOT(width, height)) { |
| 3334 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "l
evel > 0 not power of 2"); | 3334 synthesizeGLError(GL_INVALID_VALUE, functionName, "level > 0 not pow
er of 2"); |
| 3335 return false; | 3335 return false; |
| 3336 } | 3336 } |
| 3337 // For SourceArrayBufferView, function validateTexFuncData() would handl
e whether to validate the SettableTexFormat | 3337 // For SourceArrayBufferView, function validateTexFuncData() would handl
e whether to validate the SettableTexFormat |
| 3338 // by checking if the ArrayBufferView is null or not. | 3338 // by checking if the ArrayBufferView is null or not. |
| 3339 if (sourceType != SourceArrayBufferView) { | 3339 if (sourceType != SourceArrayBufferView) { |
| 3340 if (!validateSettableTexFormat(functionName, format)) | 3340 if (!validateSettableTexFormat(functionName, format)) |
| 3341 return false; | 3341 return false; |
| 3342 } | 3342 } |
| 3343 } else { | 3343 } else { |
| 3344 if (!validateSettableTexFormat(functionName, format)) | 3344 if (!validateSettableTexFormat(functionName, format)) |
| 3345 return false; | 3345 return false; |
| 3346 if (!validateSize(functionName, xoffset, yoffset)) | 3346 if (!validateSize(functionName, xoffset, yoffset)) |
| 3347 return false; | 3347 return false; |
| 3348 // Before checking if it is in the range, check if overflow happens firs
t. | 3348 // Before checking if it is in the range, check if overflow happens firs
t. |
| 3349 if (xoffset + width < 0 || yoffset + height < 0) { | 3349 if (xoffset + width < 0 || yoffset + height < 0) { |
| 3350 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "b
ad dimensions"); | 3350 synthesizeGLError(GL_INVALID_VALUE, functionName, "bad dimensions"); |
| 3351 return false; | 3351 return false; |
| 3352 } | 3352 } |
| 3353 if (xoffset + width > texture->getWidth(target, level) || yoffset + heig
ht > texture->getHeight(target, level)) { | 3353 if (xoffset + width > texture->getWidth(target, level) || yoffset + heig
ht > texture->getHeight(target, level)) { |
| 3354 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "d
imensions out of range"); | 3354 synthesizeGLError(GL_INVALID_VALUE, functionName, "dimensions out of
range"); |
| 3355 return false; | 3355 return false; |
| 3356 } | 3356 } |
| 3357 if (texture->getInternalFormat(target, level) != format || texture->getT
ype(target, level) != type) { | 3357 if (texture->getInternalFormat(target, level) != format || texture->getT
ype(target, level) != type) { |
| 3358 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName
, "type and format do not match texture"); | 3358 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type and form
at do not match texture"); |
| 3359 return false; | 3359 return false; |
| 3360 } | 3360 } |
| 3361 } | 3361 } |
| 3362 | 3362 |
| 3363 return true; | 3363 return true; |
| 3364 } | 3364 } |
| 3365 | 3365 |
| 3366 PassRefPtr<Image> WebGLRenderingContext::drawImageIntoBuffer(Image* image, int w
idth, int height) | 3366 PassRefPtr<Image> WebGLRenderingContext::drawImageIntoBuffer(Image* image, int w
idth, int height) |
| 3367 { | 3367 { |
| 3368 IntSize size(width, height); | 3368 IntSize size(width, height); |
| 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 Loading... |
| 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()); | 3440 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width(
), image->height()); |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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_WEBGL: |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |