Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/html/canvas/WebGL2RenderingContextBase.h" | 6 #include "core/html/canvas/WebGL2RenderingContextBase.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/WebGLAny.h" | 8 #include "bindings/core/v8/WebGLAny.h" |
| 9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
| 10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1519 // FIXME: Some of these ES3 buffer targets may require additional state tracking. | 1519 // FIXME: Some of these ES3 buffer targets may require additional state tracking. |
| 1520 break; | 1520 break; |
| 1521 default: | 1521 default: |
| 1522 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | 1522 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); |
| 1523 return false; | 1523 return false; |
| 1524 } | 1524 } |
| 1525 | 1525 |
| 1526 return true; | 1526 return true; |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 bool WebGL2RenderingContextBase::validateGetFramebufferAttachmentParameterFunc(c onst char* functionName, GLenum target, GLenum attachment) | |
| 1530 { | |
| 1531 if (!validateFramebufferTarget(target) { | |
| 1532 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | |
| 1533 return false; | |
| 1534 } | |
| 1535 | |
| 1536 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); | |
| 1537 ASSERT(framebufferBinding || drawingBuffer()); | |
| 1538 if (!framebufferBinding) { | |
| 1539 // for the default framebuffer | |
| 1540 switch (attachment) { | |
| 1541 case GL_BACK: | |
| 1542 case GL_DEPTH: | |
| 1543 case GL_STENCIL: | |
| 1544 break; | |
| 1545 default: | |
| 1546 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid attachment "); | |
| 1547 return false; | |
| 1548 } | |
| 1549 } else { | |
| 1550 // for the FBO | |
| 1551 switch (attachment) { | |
| 1552 case GL_COLOR_ATTACHMENT0: | |
| 1553 case GL_DEPTH_ATTACHMENT: | |
| 1554 case GL_STENCIL_ATTACHMENT: | |
| 1555 break; | |
| 1556 case GL_DEPTH_STENCIL_ATTACHMENT: | |
| 1557 if (framebufferBinding->getAttachmentObject(GL_DEPTH_STENCIL_ATTACHM ENT) || (framebufferBinding->getAttachmentObject(GL_DEPTH_ATTACHMENT) == framebu fferBinding->getAttachmentObject(GL_STENCIL_ATTACHMENT))) | |
| 1558 break; | |
|
Ken Russell (switch to Gerrit)
2015/04/30 02:28:26
The scenario where different objects are bound to
| |
| 1559 default: | |
| 1560 if (attachment > GL_COLOR_ATTACHMENT0 | |
| 1561 && attachment < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + maxCo lorAttachments())) | |
| 1562 break; | |
| 1563 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid attachment "); | |
| 1564 return false; | |
| 1565 } | |
| 1566 } | |
| 1567 return true; | |
| 1568 } | |
| 1569 | |
| 1570 ScriptValue WebGL2RenderingContextBase::getFramebufferAttachmentParameter(Script State* scriptState, GLenum target, GLenum attachment, GLenum pname) | |
| 1571 { | |
| 1572 if (isContextLost() || !validateGetFramebufferAttachmentParameterFunc("getFr amebufferAttachmentParameter", target, attachment)) | |
| 1573 return ScriptValue::createNull(scriptState); | |
| 1574 | |
| 1575 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); | |
| 1576 ASSERT(!framebufferBinding || framebufferBinding->object()); | |
| 1577 | |
| 1578 WebGLSharedObject* attachmentObject = framebufferBinding ? framebufferBindin g->getAttachmentObject(attachment) : 0; | |
| 1579 if (framebufferBinding && !attachmentObject) { | |
| 1580 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) | |
| 1581 return WebGLAny(scriptState, GL_NONE); | |
| 1582 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) | |
| 1583 return WebGLAny(scriptState, 0); | |
| 1584 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "invalid parameter name"); | |
| 1585 return ScriptValue::createNull(scriptState); | |
| 1586 } | |
| 1587 | |
| 1588 switch (pname) { | |
| 1589 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | |
| 1590 if (!attachmentObject) { | |
| 1591 ASSERT(!framebufferBinding); | |
| 1592 return WebGLAny(scriptState, GL_FRAMEBUFFER_DEFAULT); | |
| 1593 } | |
| 1594 ASSERT(attachmentObject->isTexture() || attachmentObject->isRenderbuffer ()); | |
| 1595 if (attachmentObject->isTexture()) | |
| 1596 return WebGLAny(scriptState, GL_TEXTURE); | |
| 1597 if (attachmentObject->isRenderbuffer()) | |
| 1598 return WebGLAny(scriptState, GL_RENDERBUFFER); | |
| 1599 break; | |
| 1600 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | |
| 1601 if (!attachmentObject) | |
| 1602 break; | |
| 1603 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(attachm entObject)); | |
| 1604 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | |
| 1605 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: | |
| 1606 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: | |
| 1607 if (!attachmentObject || !attachmentObject->isTexture()) | |
| 1608 break; | |
| 1609 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: | |
| 1610 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: | |
| 1611 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: | |
| 1612 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: | |
| 1613 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: | |
| 1614 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: | |
| 1615 { | |
| 1616 GLint value = 0; | |
| 1617 webContext()->getFramebufferAttachmentParameteriv(target, attachment , pname, &value); | |
| 1618 return WebGLAny(scriptState, value); | |
| 1619 } | |
| 1620 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: | |
| 1621 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: | |
| 1622 { | |
| 1623 GLint value = 0; | |
| 1624 webContext()->getFramebufferAttachmentParameteriv(target, attachment , pname, &value); | |
| 1625 return WebGLAny(scriptState, static_cast<unsigned>(value)); | |
| 1626 } | |
| 1627 default: | |
| 1628 break; | |
| 1629 } | |
| 1630 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "inv alid parameter name"); | |
| 1631 return ScriptValue::createNull(scriptState); | |
| 1632 } | |
| 1633 | |
| 1529 DEFINE_TRACE(WebGL2RenderingContextBase) | 1634 DEFINE_TRACE(WebGL2RenderingContextBase) |
| 1530 { | 1635 { |
| 1531 visitor->trace(m_readFramebufferBinding); | 1636 visitor->trace(m_readFramebufferBinding); |
| 1532 WebGLRenderingContextBase::trace(visitor); | 1637 WebGLRenderingContextBase::trace(visitor); |
| 1533 } | 1638 } |
| 1534 | 1639 |
| 1535 WebGLTexture* WebGL2RenderingContextBase::validateTextureBinding(const char* fun ctionName, GLenum target, bool useSixEnumsForCubeMap) | 1640 WebGLTexture* WebGL2RenderingContextBase::validateTextureBinding(const char* fun ctionName, GLenum target, bool useSixEnumsForCubeMap) |
| 1536 { | 1641 { |
| 1537 switch (target) { | 1642 switch (target) { |
| 1538 // FIXME: add 2D Array texture binding point and 3D texture binding point. | 1643 // FIXME: add 2D Array texture binding point and 3D texture binding point. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1579 GLfloat value = 0.f; | 1684 GLfloat value = 0.f; |
| 1580 webContext()->getTexParameterfv(target, pname, &value); | 1685 webContext()->getTexParameterfv(target, pname, &value); |
| 1581 return WebGLAny(scriptState, value); | 1686 return WebGLAny(scriptState, value); |
| 1582 } | 1687 } |
| 1583 default: | 1688 default: |
| 1584 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p name); | 1689 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p name); |
| 1585 } | 1690 } |
| 1586 } | 1691 } |
| 1587 | 1692 |
| 1588 } // namespace blink | 1693 } // namespace blink |
| OLD | NEW |