| 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 return nullptr; | 520 return nullptr; |
| 521 } | 521 } |
| 522 | 522 |
| 523 return renderingContext.release(); | 523 return renderingContext.release(); |
| 524 } | 524 } |
| 525 | 525 |
| 526 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* requested
Attributes) | 526 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* requested
Attributes) |
| 527 : CanvasRenderingContext(passedCanvas) | 527 : CanvasRenderingContext(passedCanvas) |
| 528 , ActiveDOMObject(&passedCanvas->document()) | 528 , ActiveDOMObject(&passedCanvas->document()) |
| 529 , m_context(context) | 529 , m_context(context) |
| 530 , m_drawingBuffer(0) | 530 , m_drawingBuffer(nullptr) |
| 531 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContext::dispatchCont
extLostEvent) | 531 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContext::dispatchCont
extLostEvent) |
| 532 , m_restoreAllowed(false) | 532 , m_restoreAllowed(false) |
| 533 , m_restoreTimer(this, &WebGLRenderingContext::maybeRestoreContext) | 533 , m_restoreTimer(this, &WebGLRenderingContext::maybeRestoreContext) |
| 534 , m_generatedImageCache(4) | 534 , m_generatedImageCache(4) |
| 535 , m_contextLost(false) | 535 , m_contextLost(false) |
| 536 , m_contextLostMode(SyntheticLostContext) | 536 , m_contextLostMode(SyntheticLostContext) |
| 537 , m_requestedAttributes(requestedAttributes->clone()) | 537 , m_requestedAttributes(requestedAttributes->clone()) |
| 538 , m_synthesizedErrorsToConsole(true) | 538 , m_synthesizedErrorsToConsole(true) |
| 539 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 539 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
| 540 , m_multisamplingAllowed(false) | 540 , m_multisamplingAllowed(false) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 { | 595 { |
| 596 ASSERT(!isContextLost()); | 596 ASSERT(!isContextLost()); |
| 597 m_needsUpdate = true; | 597 m_needsUpdate = true; |
| 598 m_markedCanvasDirty = false; | 598 m_markedCanvasDirty = false; |
| 599 m_activeTextureUnit = 0; | 599 m_activeTextureUnit = 0; |
| 600 m_packAlignment = 4; | 600 m_packAlignment = 4; |
| 601 m_unpackAlignment = 4; | 601 m_unpackAlignment = 4; |
| 602 m_unpackFlipY = false; | 602 m_unpackFlipY = false; |
| 603 m_unpackPremultiplyAlpha = false; | 603 m_unpackPremultiplyAlpha = false; |
| 604 m_unpackColorspaceConversion = GC3D_BROWSER_DEFAULT_WEBGL; | 604 m_unpackColorspaceConversion = GC3D_BROWSER_DEFAULT_WEBGL; |
| 605 m_boundArrayBuffer = 0; | 605 m_boundArrayBuffer = nullptr; |
| 606 m_currentProgram = 0; | 606 m_currentProgram = nullptr; |
| 607 m_framebufferBinding = 0; | 607 m_framebufferBinding = nullptr; |
| 608 m_renderbufferBinding = 0; | 608 m_renderbufferBinding = nullptr; |
| 609 m_depthMask = true; | 609 m_depthMask = true; |
| 610 m_stencilEnabled = false; | 610 m_stencilEnabled = false; |
| 611 m_stencilMask = 0xFFFFFFFF; | 611 m_stencilMask = 0xFFFFFFFF; |
| 612 m_stencilMaskBack = 0xFFFFFFFF; | 612 m_stencilMaskBack = 0xFFFFFFFF; |
| 613 m_stencilFuncRef = 0; | 613 m_stencilFuncRef = 0; |
| 614 m_stencilFuncRefBack = 0; | 614 m_stencilFuncRefBack = 0; |
| 615 m_stencilFuncMask = 0xFFFFFFFF; | 615 m_stencilFuncMask = 0xFFFFFFFF; |
| 616 m_stencilFuncMaskBack = 0xFFFFFFFF; | 616 m_stencilFuncMaskBack = 0xFFFFFFFF; |
| 617 m_layerCleared = false; | 617 m_layerCleared = false; |
| 618 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; | 618 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 | 709 |
| 710 void WebGLRenderingContext::removeAllCompressedTextureFormats() | 710 void WebGLRenderingContext::removeAllCompressedTextureFormats() |
| 711 { | 711 { |
| 712 m_compressedTextureFormats.clear(); | 712 m_compressedTextureFormats.clear(); |
| 713 } | 713 } |
| 714 | 714 |
| 715 WebGLRenderingContext::~WebGLRenderingContext() | 715 WebGLRenderingContext::~WebGLRenderingContext() |
| 716 { | 716 { |
| 717 // Remove all references to WebGLObjects so if they are the last reference | 717 // Remove all references to WebGLObjects so if they are the last reference |
| 718 // they will be freed before the last context is removed from the context gr
oup. | 718 // they will be freed before the last context is removed from the context gr
oup. |
| 719 m_boundArrayBuffer = 0; | 719 m_boundArrayBuffer = nullptr; |
| 720 m_defaultVertexArrayObject = 0; | 720 m_defaultVertexArrayObject = nullptr; |
| 721 m_boundVertexArrayObject = 0; | 721 m_boundVertexArrayObject = nullptr; |
| 722 m_vertexAttrib0Buffer = 0; | 722 m_vertexAttrib0Buffer = nullptr; |
| 723 m_currentProgram = 0; | 723 m_currentProgram = nullptr; |
| 724 m_framebufferBinding = 0; | 724 m_framebufferBinding = nullptr; |
| 725 m_renderbufferBinding = 0; | 725 m_renderbufferBinding = nullptr; |
| 726 | 726 |
| 727 for (size_t i = 0; i < m_textureUnits.size(); ++i) { | 727 for (size_t i = 0; i < m_textureUnits.size(); ++i) { |
| 728 m_textureUnits[i].m_texture2DBinding = 0; | 728 m_textureUnits[i].m_texture2DBinding = nullptr; |
| 729 m_textureUnits[i].m_textureCubeMapBinding = 0; | 729 m_textureUnits[i].m_textureCubeMapBinding = nullptr; |
| 730 } | 730 } |
| 731 | 731 |
| 732 m_blackTexture2D = 0; | 732 m_blackTexture2D = nullptr; |
| 733 m_blackTextureCubeMap = 0; | 733 m_blackTextureCubeMap = nullptr; |
| 734 | 734 |
| 735 detachAndRemoveAllObjects(); | 735 detachAndRemoveAllObjects(); |
| 736 | 736 |
| 737 // release all extensions | 737 // release all extensions |
| 738 for (size_t i = 0; i < m_extensions.size(); ++i) | 738 for (size_t i = 0; i < m_extensions.size(); ++i) |
| 739 delete m_extensions[i]; | 739 delete m_extensions[i]; |
| 740 | 740 |
| 741 // Context must be removed from the group prior to the destruction of the | 741 // Context must be removed from the group prior to the destruction of the |
| 742 // WebGraphicsContext3D, otherwise shared objects may not be properly delete
d. | 742 // WebGraphicsContext3D, otherwise shared objects may not be properly delete
d. |
| 743 m_contextGroup->removeContext(this); | 743 m_contextGroup->removeContext(this); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 | 899 |
| 900 if (m_framebufferBinding) | 900 if (m_framebufferBinding) |
| 901 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); | 901 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); |
| 902 else | 902 else |
| 903 m_drawingBuffer->bind(); | 903 m_drawingBuffer->bind(); |
| 904 } | 904 } |
| 905 | 905 |
| 906 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData() | 906 PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData() |
| 907 { | 907 { |
| 908 if (isContextLost()) | 908 if (isContextLost()) |
| 909 return 0; | 909 return nullptr; |
| 910 | 910 |
| 911 clearIfComposited(); | 911 clearIfComposited(); |
| 912 m_drawingBuffer->commit(); | 912 m_drawingBuffer->commit(); |
| 913 int width, height; | 913 int width, height; |
| 914 RefPtr<Uint8ClampedArray> imageDataPixels = m_drawingBuffer->paintRenderingR
esultsToImageData(width, height); | 914 RefPtr<Uint8ClampedArray> imageDataPixels = m_drawingBuffer->paintRenderingR
esultsToImageData(width, height); |
| 915 if (!imageDataPixels) | 915 if (!imageDataPixels) |
| 916 return 0; | 916 return nullptr; |
| 917 | 917 |
| 918 if (m_framebufferBinding) | 918 if (m_framebufferBinding) |
| 919 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); | 919 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); |
| 920 else | 920 else |
| 921 m_drawingBuffer->bind(); | 921 m_drawingBuffer->bind(); |
| 922 | 922 |
| 923 return ImageData::create(IntSize(width, height), imageDataPixels); | 923 return ImageData::create(IntSize(width, height), imageDataPixels); |
| 924 } | 924 } |
| 925 | 925 |
| 926 void WebGLRenderingContext::reshape(int width, int height) | 926 void WebGLRenderingContext::reshape(int width, int height) |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 return; | 1514 return; |
| 1515 } | 1515 } |
| 1516 clearIfComposited(); | 1516 clearIfComposited(); |
| 1517 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1517 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
| 1518 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); | 1518 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); |
| 1519 } | 1519 } |
| 1520 | 1520 |
| 1521 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() | 1521 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() |
| 1522 { | 1522 { |
| 1523 if (isContextLost()) | 1523 if (isContextLost()) |
| 1524 return 0; | 1524 return nullptr; |
| 1525 RefPtr<WebGLBuffer> o = WebGLBuffer::create(this); | 1525 RefPtr<WebGLBuffer> o = WebGLBuffer::create(this); |
| 1526 addSharedObject(o.get()); | 1526 addSharedObject(o.get()); |
| 1527 return o; | 1527 return o; |
| 1528 } | 1528 } |
| 1529 | 1529 |
| 1530 PassRefPtr<WebGLFramebuffer> WebGLRenderingContext::createFramebuffer() | 1530 PassRefPtr<WebGLFramebuffer> WebGLRenderingContext::createFramebuffer() |
| 1531 { | 1531 { |
| 1532 if (isContextLost()) | 1532 if (isContextLost()) |
| 1533 return 0; | 1533 return nullptr; |
| 1534 RefPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this); | 1534 RefPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this); |
| 1535 addContextObject(o.get()); | 1535 addContextObject(o.get()); |
| 1536 return o; | 1536 return o; |
| 1537 } | 1537 } |
| 1538 | 1538 |
| 1539 PassRefPtr<WebGLTexture> WebGLRenderingContext::createTexture() | 1539 PassRefPtr<WebGLTexture> WebGLRenderingContext::createTexture() |
| 1540 { | 1540 { |
| 1541 if (isContextLost()) | 1541 if (isContextLost()) |
| 1542 return 0; | 1542 return nullptr; |
| 1543 RefPtr<WebGLTexture> o = WebGLTexture::create(this); | 1543 RefPtr<WebGLTexture> o = WebGLTexture::create(this); |
| 1544 addSharedObject(o.get()); | 1544 addSharedObject(o.get()); |
| 1545 return o; | 1545 return o; |
| 1546 } | 1546 } |
| 1547 | 1547 |
| 1548 PassRefPtr<WebGLProgram> WebGLRenderingContext::createProgram() | 1548 PassRefPtr<WebGLProgram> WebGLRenderingContext::createProgram() |
| 1549 { | 1549 { |
| 1550 if (isContextLost()) | 1550 if (isContextLost()) |
| 1551 return 0; | 1551 return nullptr; |
| 1552 RefPtr<WebGLProgram> o = WebGLProgram::create(this); | 1552 RefPtr<WebGLProgram> o = WebGLProgram::create(this); |
| 1553 addSharedObject(o.get()); | 1553 addSharedObject(o.get()); |
| 1554 return o; | 1554 return o; |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 PassRefPtr<WebGLRenderbuffer> WebGLRenderingContext::createRenderbuffer() | 1557 PassRefPtr<WebGLRenderbuffer> WebGLRenderingContext::createRenderbuffer() |
| 1558 { | 1558 { |
| 1559 if (isContextLost()) | 1559 if (isContextLost()) |
| 1560 return 0; | 1560 return nullptr; |
| 1561 RefPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); | 1561 RefPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); |
| 1562 addSharedObject(o.get()); | 1562 addSharedObject(o.get()); |
| 1563 return o; | 1563 return o; |
| 1564 } | 1564 } |
| 1565 | 1565 |
| 1566 WebGLRenderbuffer* WebGLRenderingContext::ensureEmulatedStencilBuffer(GLenum tar
get, WebGLRenderbuffer* renderbuffer) | 1566 WebGLRenderbuffer* WebGLRenderingContext::ensureEmulatedStencilBuffer(GLenum tar
get, WebGLRenderbuffer* renderbuffer) |
| 1567 { | 1567 { |
| 1568 if (isContextLost()) | 1568 if (isContextLost()) |
| 1569 return 0; | 1569 return 0; |
| 1570 if (!renderbuffer->emulatedStencilBuffer()) { | 1570 if (!renderbuffer->emulatedStencilBuffer()) { |
| 1571 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1571 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
| 1572 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS
tencilBuffer())); | 1572 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS
tencilBuffer())); |
| 1573 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g
et())); | 1573 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g
et())); |
| 1574 } | 1574 } |
| 1575 return renderbuffer->emulatedStencilBuffer(); | 1575 return renderbuffer->emulatedStencilBuffer(); |
| 1576 } | 1576 } |
| 1577 | 1577 |
| 1578 PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(GLenum type) | 1578 PassRefPtr<WebGLShader> WebGLRenderingContext::createShader(GLenum type) |
| 1579 { | 1579 { |
| 1580 if (isContextLost()) | 1580 if (isContextLost()) |
| 1581 return 0; | 1581 return nullptr; |
| 1582 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { | 1582 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { |
| 1583 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type"
); | 1583 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type"
); |
| 1584 return 0; | 1584 return nullptr; |
| 1585 } | 1585 } |
| 1586 | 1586 |
| 1587 RefPtr<WebGLShader> o = WebGLShader::create(this, type); | 1587 RefPtr<WebGLShader> o = WebGLShader::create(this, type); |
| 1588 addSharedObject(o.get()); | 1588 addSharedObject(o.get()); |
| 1589 return o; | 1589 return o; |
| 1590 } | 1590 } |
| 1591 | 1591 |
| 1592 void WebGLRenderingContext::cullFace(GLenum mode) | 1592 void WebGLRenderingContext::cullFace(GLenum mode) |
| 1593 { | 1593 { |
| 1594 if (isContextLost()) | 1594 if (isContextLost()) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1619 object->deleteObject(m_context.get()); | 1619 object->deleteObject(m_context.get()); |
| 1620 } | 1620 } |
| 1621 return true; | 1621 return true; |
| 1622 } | 1622 } |
| 1623 | 1623 |
| 1624 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) | 1624 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) |
| 1625 { | 1625 { |
| 1626 if (!deleteObject(buffer)) | 1626 if (!deleteObject(buffer)) |
| 1627 return; | 1627 return; |
| 1628 if (m_boundArrayBuffer == buffer) | 1628 if (m_boundArrayBuffer == buffer) |
| 1629 m_boundArrayBuffer = 0; | 1629 m_boundArrayBuffer = nullptr; |
| 1630 | 1630 |
| 1631 m_boundVertexArrayObject->unbindBuffer(buffer); | 1631 m_boundVertexArrayObject->unbindBuffer(buffer); |
| 1632 } | 1632 } |
| 1633 | 1633 |
| 1634 void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer) | 1634 void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer) |
| 1635 { | 1635 { |
| 1636 if (!deleteObject(framebuffer)) | 1636 if (!deleteObject(framebuffer)) |
| 1637 return; | 1637 return; |
| 1638 if (framebuffer == m_framebufferBinding) { | 1638 if (framebuffer == m_framebufferBinding) { |
| 1639 m_framebufferBinding = 0; | 1639 m_framebufferBinding = nullptr; |
| 1640 m_drawingBuffer->setFramebufferBinding(0); | 1640 m_drawingBuffer->setFramebufferBinding(0); |
| 1641 // Have to call bindFramebuffer here to bind back to internal fbo. | 1641 // Have to call bindFramebuffer here to bind back to internal fbo. |
| 1642 m_drawingBuffer->bind(); | 1642 m_drawingBuffer->bind(); |
| 1643 } | 1643 } |
| 1644 } | 1644 } |
| 1645 | 1645 |
| 1646 void WebGLRenderingContext::deleteProgram(WebGLProgram* program) | 1646 void WebGLRenderingContext::deleteProgram(WebGLProgram* program) |
| 1647 { | 1647 { |
| 1648 deleteObject(program); | 1648 deleteObject(program); |
| 1649 // We don't reset m_currentProgram to 0 here because the deletion of the | 1649 // We don't reset m_currentProgram to 0 here because the deletion of the |
| 1650 // current program is delayed. | 1650 // current program is delayed. |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 void WebGLRenderingContext::deleteRenderbuffer(WebGLRenderbuffer* renderbuffer) | 1653 void WebGLRenderingContext::deleteRenderbuffer(WebGLRenderbuffer* renderbuffer) |
| 1654 { | 1654 { |
| 1655 if (!deleteObject(renderbuffer)) | 1655 if (!deleteObject(renderbuffer)) |
| 1656 return; | 1656 return; |
| 1657 if (renderbuffer == m_renderbufferBinding) | 1657 if (renderbuffer == m_renderbufferBinding) |
| 1658 m_renderbufferBinding = 0; | 1658 m_renderbufferBinding = nullptr; |
| 1659 if (m_framebufferBinding) | 1659 if (m_framebufferBinding) |
| 1660 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer)
; | 1660 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer)
; |
| 1661 } | 1661 } |
| 1662 | 1662 |
| 1663 void WebGLRenderingContext::deleteShader(WebGLShader* shader) | 1663 void WebGLRenderingContext::deleteShader(WebGLShader* shader) |
| 1664 { | 1664 { |
| 1665 deleteObject(shader); | 1665 deleteObject(shader); |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 void WebGLRenderingContext::deleteTexture(WebGLTexture* texture) | 1668 void WebGLRenderingContext::deleteTexture(WebGLTexture* texture) |
| 1669 { | 1669 { |
| 1670 if (!deleteObject(texture)) | 1670 if (!deleteObject(texture)) |
| 1671 return; | 1671 return; |
| 1672 | 1672 |
| 1673 int maxBoundTextureIndex = -1; | 1673 int maxBoundTextureIndex = -1; |
| 1674 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) { | 1674 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) { |
| 1675 if (texture == m_textureUnits[i].m_texture2DBinding) { | 1675 if (texture == m_textureUnits[i].m_texture2DBinding) { |
| 1676 m_textureUnits[i].m_texture2DBinding = 0; | 1676 m_textureUnits[i].m_texture2DBinding = nullptr; |
| 1677 maxBoundTextureIndex = i; | 1677 maxBoundTextureIndex = i; |
| 1678 if (!i) | 1678 if (!i) |
| 1679 m_drawingBuffer->setTexture2DBinding(0); | 1679 m_drawingBuffer->setTexture2DBinding(0); |
| 1680 } | 1680 } |
| 1681 if (texture == m_textureUnits[i].m_textureCubeMapBinding) { | 1681 if (texture == m_textureUnits[i].m_textureCubeMapBinding) { |
| 1682 m_textureUnits[i].m_textureCubeMapBinding = 0; | 1682 m_textureUnits[i].m_textureCubeMapBinding = nullptr; |
| 1683 maxBoundTextureIndex = i; | 1683 maxBoundTextureIndex = i; |
| 1684 } | 1684 } |
| 1685 } | 1685 } |
| 1686 if (m_framebufferBinding) | 1686 if (m_framebufferBinding) |
| 1687 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); | 1687 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); |
| 1688 | 1688 |
| 1689 // If the deleted was bound to the the current maximum index, trace backward
s to find the new max texture index | 1689 // If the deleted was bound to the the current maximum index, trace backward
s to find the new max texture index |
| 1690 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound
TextureIndex + 1)) { | 1690 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound
TextureIndex + 1)) { |
| 1691 findNewMaxNonDefaultTextureUnit(); | 1691 findNewMaxNonDefaultTextureUnit(); |
| 1692 } | 1692 } |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 #if OS(MACOSX) | 2028 #if OS(MACOSX) |
| 2029 if (needToResetMinFilter) | 2029 if (needToResetMinFilter) |
| 2030 m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFilte
r()); | 2030 m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFilte
r()); |
| 2031 #endif | 2031 #endif |
| 2032 tex->generateMipmapLevelInfo(); | 2032 tex->generateMipmapLevelInfo(); |
| 2033 } | 2033 } |
| 2034 | 2034 |
| 2035 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram*
program, GLuint index) | 2035 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram*
program, GLuint index) |
| 2036 { | 2036 { |
| 2037 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 2037 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) |
| 2038 return 0; | 2038 return nullptr; |
| 2039 blink::WebGraphicsContext3D::ActiveInfo info; | 2039 blink::WebGraphicsContext3D::ActiveInfo info; |
| 2040 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) | 2040 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) |
| 2041 return 0; | 2041 return nullptr; |
| 2042 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2042 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2043 } | 2043 } |
| 2044 | 2044 |
| 2045 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram
* program, GLuint index) | 2045 PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram
* program, GLuint index) |
| 2046 { | 2046 { |
| 2047 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) | 2047 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) |
| 2048 return 0; | 2048 return nullptr; |
| 2049 blink::WebGraphicsContext3D::ActiveInfo info; | 2049 blink::WebGraphicsContext3D::ActiveInfo info; |
| 2050 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) | 2050 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) |
| 2051 return 0; | 2051 return nullptr; |
| 2052 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2052 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref
Ptr<WebGLShader> >& shaderObjects) | 2055 bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Ref
Ptr<WebGLShader> >& shaderObjects) |
| 2056 { | 2056 { |
| 2057 shaderObjects.clear(); | 2057 shaderObjects.clear(); |
| 2058 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) | 2058 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) |
| 2059 return false; | 2059 return false; |
| 2060 | 2060 |
| 2061 const GLenum shaderType[] = { | 2061 const GLenum shaderType[] = { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 GLint value = 0; | 2104 GLint value = 0; |
| 2105 m_context->getBufferParameteriv(target, pname, &value); | 2105 m_context->getBufferParameteriv(target, pname, &value); |
| 2106 if (pname == GL_BUFFER_SIZE) | 2106 if (pname == GL_BUFFER_SIZE) |
| 2107 return WebGLGetInfo(value); | 2107 return WebGLGetInfo(value); |
| 2108 return WebGLGetInfo(static_cast<unsigned>(value)); | 2108 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2109 } | 2109 } |
| 2110 | 2110 |
| 2111 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() | 2111 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() |
| 2112 { | 2112 { |
| 2113 if (isContextLost()) | 2113 if (isContextLost()) |
| 2114 return 0; | 2114 return nullptr; |
| 2115 // We always need to return a new WebGLContextAttributes object to | 2115 // We always need to return a new WebGLContextAttributes object to |
| 2116 // prevent the user from mutating any cached version. | 2116 // prevent the user from mutating any cached version. |
| 2117 blink::WebGraphicsContext3D::Attributes attrs = m_context->getContextAttribu
tes(); | 2117 blink::WebGraphicsContext3D::Attributes attrs = m_context->getContextAttribu
tes(); |
| 2118 RefPtr<WebGLContextAttributes> attributes = m_requestedAttributes->clone(); | 2118 RefPtr<WebGLContextAttributes> attributes = m_requestedAttributes->clone(); |
| 2119 // Some requested attributes may not be honored, so we need to query the und
erlying | 2119 // Some requested attributes may not be honored, so we need to query the und
erlying |
| 2120 // context/drawing buffer and adjust accordingly. | 2120 // context/drawing buffer and adjust accordingly. |
| 2121 if (m_requestedAttributes->depth() && !attrs.depth) | 2121 if (m_requestedAttributes->depth() && !attrs.depth) |
| 2122 attributes->setDepth(false); | 2122 attributes->setDepth(false); |
| 2123 if (m_requestedAttributes->stencil() && !attrs.stencil) | 2123 if (m_requestedAttributes->stencil() && !attrs.stencil) |
| 2124 attributes->setStencil(false); | 2124 attributes->setStencil(false); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2150 if (equalIgnoringCase(prefixedName, name)) { | 2150 if (equalIgnoringCase(prefixedName, name)) { |
| 2151 return true; | 2151 return true; |
| 2152 } | 2152 } |
| 2153 } | 2153 } |
| 2154 return false; | 2154 return false; |
| 2155 } | 2155 } |
| 2156 | 2156 |
| 2157 PassRefPtr<WebGLExtension> WebGLRenderingContext::getExtension(const String& nam
e) | 2157 PassRefPtr<WebGLExtension> WebGLRenderingContext::getExtension(const String& nam
e) |
| 2158 { | 2158 { |
| 2159 if (isContextLost()) | 2159 if (isContextLost()) |
| 2160 return 0; | 2160 return nullptr; |
| 2161 | 2161 |
| 2162 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2162 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 2163 ExtensionTracker* tracker = m_extensions[i]; | 2163 ExtensionTracker* tracker = m_extensions[i]; |
| 2164 if (tracker->matchesNameWithPrefixes(name)) { | 2164 if (tracker->matchesNameWithPrefixes(name)) { |
| 2165 if (tracker->webglDebugRendererInfo() && !allowWebGLDebugRendererInf
o()) | 2165 if (tracker->webglDebugRendererInfo() && !allowWebGLDebugRendererInf
o()) |
| 2166 return 0; | 2166 return nullptr; |
| 2167 if (tracker->privileged() && !allowPrivilegedExtensions()) | 2167 if (tracker->privileged() && !allowPrivilegedExtensions()) |
| 2168 return 0; | 2168 return nullptr; |
| 2169 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtension
sEnabled()) | 2169 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtension
sEnabled()) |
| 2170 return 0; | 2170 return nullptr; |
| 2171 if (!tracker->supported(this)) | 2171 if (!tracker->supported(this)) |
| 2172 return 0; | 2172 return nullptr; |
| 2173 return tracker->getExtension(this); | 2173 return tracker->getExtension(this); |
| 2174 } | 2174 } |
| 2175 } | 2175 } |
| 2176 | 2176 |
| 2177 return 0; | 2177 return nullptr; |
| 2178 } | 2178 } |
| 2179 | 2179 |
| 2180 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GLenum tar
get, GLenum attachment, GLenum pname) | 2180 WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GLenum tar
get, GLenum attachment, GLenum pname) |
| 2181 { | 2181 { |
| 2182 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt
achmentParameter", target, attachment)) | 2182 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt
achmentParameter", target, attachment)) |
| 2183 return WebGLGetInfo(); | 2183 return WebGLGetInfo(); |
| 2184 | 2184 |
| 2185 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2185 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 2186 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet
er", "no framebuffer bound"); | 2186 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet
er", "no framebuffer bound"); |
| 2187 return WebGLGetInfo(); | 2187 return WebGLGetInfo(); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2565 if (isContextLost()) | 2565 if (isContextLost()) |
| 2566 return String(); | 2566 return String(); |
| 2567 if (!validateWebGLObject("getShaderInfoLog", shader)) | 2567 if (!validateWebGLObject("getShaderInfoLog", shader)) |
| 2568 return ""; | 2568 return ""; |
| 2569 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); | 2569 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); |
| 2570 } | 2570 } |
| 2571 | 2571 |
| 2572 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision
Format(GLenum shaderType, GLenum precisionType) | 2572 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecision
Format(GLenum shaderType, GLenum precisionType) |
| 2573 { | 2573 { |
| 2574 if (isContextLost()) | 2574 if (isContextLost()) |
| 2575 return 0; | 2575 return nullptr; |
| 2576 switch (shaderType) { | 2576 switch (shaderType) { |
| 2577 case GL_VERTEX_SHADER: | 2577 case GL_VERTEX_SHADER: |
| 2578 case GL_FRAGMENT_SHADER: | 2578 case GL_FRAGMENT_SHADER: |
| 2579 break; | 2579 break; |
| 2580 default: | 2580 default: |
| 2581 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
shader type"); | 2581 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
shader type"); |
| 2582 return 0; | 2582 return nullptr; |
| 2583 } | 2583 } |
| 2584 switch (precisionType) { | 2584 switch (precisionType) { |
| 2585 case GL_LOW_FLOAT: | 2585 case GL_LOW_FLOAT: |
| 2586 case GL_MEDIUM_FLOAT: | 2586 case GL_MEDIUM_FLOAT: |
| 2587 case GL_HIGH_FLOAT: | 2587 case GL_HIGH_FLOAT: |
| 2588 case GL_LOW_INT: | 2588 case GL_LOW_INT: |
| 2589 case GL_MEDIUM_INT: | 2589 case GL_MEDIUM_INT: |
| 2590 case GL_HIGH_INT: | 2590 case GL_HIGH_INT: |
| 2591 break; | 2591 break; |
| 2592 default: | 2592 default: |
| 2593 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
precision type"); | 2593 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
precision type"); |
| 2594 return 0; | 2594 return nullptr; |
| 2595 } | 2595 } |
| 2596 | 2596 |
| 2597 GLint range[2] = {0, 0}; | 2597 GLint range[2] = {0, 0}; |
| 2598 GLint precision = 0; | 2598 GLint precision = 0; |
| 2599 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci
sion); | 2599 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci
sion); |
| 2600 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); | 2600 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); |
| 2601 } | 2601 } |
| 2602 | 2602 |
| 2603 String WebGLRenderingContext::getShaderSource(WebGLShader* shader) | 2603 String WebGLRenderingContext::getShaderSource(WebGLShader* shader) |
| 2604 { | 2604 { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 } | 2799 } |
| 2800 } | 2800 } |
| 2801 // If we get here, something went wrong in our unfortunately complex logic a
bove | 2801 // If we get here, something went wrong in our unfortunately complex logic a
bove |
| 2802 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error"); | 2802 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error"); |
| 2803 return WebGLGetInfo(); | 2803 return WebGLGetInfo(); |
| 2804 } | 2804 } |
| 2805 | 2805 |
| 2806 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL
Program* program, const String& name) | 2806 PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL
Program* program, const String& name) |
| 2807 { | 2807 { |
| 2808 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) | 2808 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) |
| 2809 return 0; | 2809 return nullptr; |
| 2810 if (!validateLocationLength("getUniformLocation", name)) | 2810 if (!validateLocationLength("getUniformLocation", name)) |
| 2811 return 0; | 2811 return nullptr; |
| 2812 if (!validateString("getUniformLocation", name)) | 2812 if (!validateString("getUniformLocation", name)) |
| 2813 return 0; | 2813 return nullptr; |
| 2814 if (isPrefixReserved(name)) | 2814 if (isPrefixReserved(name)) |
| 2815 return 0; | 2815 return nullptr; |
| 2816 if (!program->linkStatus()) { | 2816 if (!program->linkStatus()) { |
| 2817 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); | 2817 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); |
| 2818 return 0; | 2818 return nullptr; |
| 2819 } | 2819 } |
| 2820 GLint uniformLocation = m_context->getUniformLocation(objectOrZero(program),
name.utf8().data()); | 2820 GLint uniformLocation = m_context->getUniformLocation(objectOrZero(program),
name.utf8().data()); |
| 2821 if (uniformLocation == -1) | 2821 if (uniformLocation == -1) |
| 2822 return 0; | 2822 return nullptr; |
| 2823 return WebGLUniformLocation::create(program, uniformLocation); | 2823 return WebGLUniformLocation::create(program, uniformLocation); |
| 2824 } | 2824 } |
| 2825 | 2825 |
| 2826 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GLuint index, GLenum pname) | 2826 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GLuint index, GLenum pname) |
| 2827 { | 2827 { |
| 2828 if (isContextLost()) | 2828 if (isContextLost()) |
| 2829 return WebGLGetInfo(); | 2829 return WebGLGetInfo(); |
| 2830 if (index >= m_maxVertexAttribs) { | 2830 if (index >= m_maxVertexAttribs) { |
| 2831 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran
ge"); | 2831 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran
ge"); |
| 2832 return WebGLGetInfo(); | 2832 return WebGLGetInfo(); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3372 | 3372 |
| 3373 return true; | 3373 return true; |
| 3374 } | 3374 } |
| 3375 | 3375 |
| 3376 PassRefPtr<Image> WebGLRenderingContext::drawImageIntoBuffer(Image* image, int w
idth, int height) | 3376 PassRefPtr<Image> WebGLRenderingContext::drawImageIntoBuffer(Image* image, int w
idth, int height) |
| 3377 { | 3377 { |
| 3378 IntSize size(width, height); | 3378 IntSize size(width, height); |
| 3379 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); | 3379 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); |
| 3380 if (!buf) { | 3380 if (!buf) { |
| 3381 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); | 3381 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); |
| 3382 return 0; | 3382 return nullptr; |
| 3383 } | 3383 } |
| 3384 | 3384 |
| 3385 IntRect srcRect(IntPoint(), image->size()); | 3385 IntRect srcRect(IntPoint(), image->size()); |
| 3386 IntRect destRect(0, 0, size.width(), size.height()); | 3386 IntRect destRect(0, 0, size.width(), size.height()); |
| 3387 buf->context()->drawImage(image, destRect, srcRect); | 3387 buf->context()->drawImage(image, destRect, srcRect); |
| 3388 return buf->copyImage(ImageBuffer::fastCopyImageMode()); | 3388 return buf->copyImage(ImageBuffer::fastCopyImageMode()); |
| 3389 } | 3389 } |
| 3390 | 3390 |
| 3391 void WebGLRenderingContext::texImage2D(GLenum target, GLint level, GLenum intern
alformat, | 3391 void WebGLRenderingContext::texImage2D(GLenum target, GLint level, GLenum intern
alformat, |
| 3392 GLsizei width, GLsizei height, GLint border, | 3392 GLsizei width, GLsizei height, GLint border, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3484 else | 3484 else |
| 3485 texImage2DImpl(target, level, internalformat, format, type, canvas->copi
edImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultip
lyAlpha, exceptionState); | 3485 texImage2DImpl(target, level, internalformat, format, type, canvas->copi
edImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultip
lyAlpha, exceptionState); |
| 3486 } | 3486 } |
| 3487 | 3487 |
| 3488 PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* vid
eo, BackingStoreCopy backingStoreCopy) | 3488 PassRefPtr<Image> WebGLRenderingContext::videoFrameToImage(HTMLVideoElement* vid
eo, BackingStoreCopy backingStoreCopy) |
| 3489 { | 3489 { |
| 3490 IntSize size(video->videoWidth(), video->videoHeight()); | 3490 IntSize size(video->videoWidth(), video->videoHeight()); |
| 3491 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); | 3491 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); |
| 3492 if (!buf) { | 3492 if (!buf) { |
| 3493 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); | 3493 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); |
| 3494 return 0; | 3494 return nullptr; |
| 3495 } | 3495 } |
| 3496 IntRect destRect(0, 0, size.width(), size.height()); | 3496 IntRect destRect(0, 0, size.width(), size.height()); |
| 3497 // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback. | 3497 // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback. |
| 3498 video->paintCurrentFrameInContext(buf->context(), destRect); | 3498 video->paintCurrentFrameInContext(buf->context(), destRect); |
| 3499 return buf->copyImage(backingStoreCopy); | 3499 return buf->copyImage(backingStoreCopy); |
| 3500 } | 3500 } |
| 3501 | 3501 |
| 3502 void WebGLRenderingContext::texImage2D(GLenum target, GLint level, GLenum intern
alformat, | 3502 void WebGLRenderingContext::texImage2D(GLenum target, GLint level, GLenum intern
alformat, |
| 3503 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 3503 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
| 3504 { | 3504 { |
| (...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5607 if (m_textureUnits[i].m_texture2DBinding | 5607 if (m_textureUnits[i].m_texture2DBinding |
| 5608 || m_textureUnits[i].m_textureCubeMapBinding) { | 5608 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 5609 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5609 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 5610 return; | 5610 return; |
| 5611 } | 5611 } |
| 5612 } | 5612 } |
| 5613 m_onePlusMaxNonDefaultTextureUnit = 0; | 5613 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 5614 } | 5614 } |
| 5615 | 5615 |
| 5616 } // namespace WebCore | 5616 } // namespace WebCore |
| OLD | NEW |