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 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1454 // FIXME: Some of these ES3 buffer targets may require additional state tracking. | 1454 // FIXME: Some of these ES3 buffer targets may require additional state tracking. |
| 1455 break; | 1455 break; |
| 1456 default: | 1456 default: |
| 1457 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | 1457 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); |
| 1458 return false; | 1458 return false; |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 return true; | 1461 return true; |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 bool WebGL2RenderingContextBase::validateGetFramebufferAttachmentParameterFunc(c onst char* functionName, GLenum target, GLenum attachment) | |
| 1465 { | |
| 1466 if (target != GL_FRAMEBUFFER && target != GL_READ_FRAMEBUFFER && target != G L_DRAW_FRAMEBUFFER) { | |
|
Ken Russell (switch to Gerrit)
2015/04/28 05:43:23
Please make sure that this code eventually uses th
yunchao
2015/04/29 11:13:11
Done.
| |
| 1467 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | |
| 1468 return false; | |
| 1469 } | |
| 1470 ASSERT(m_framebufferBinding || drawingBuffer()); | |
| 1471 if (!m_framebufferBinding) { | |
| 1472 // for the default framebuffer | |
| 1473 switch (attachment) { | |
| 1474 case GL_BACK: | |
| 1475 case GL_DEPTH: | |
| 1476 case GL_STENCIL: | |
| 1477 break; | |
| 1478 default: | |
| 1479 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid attachment "); | |
| 1480 return false; | |
| 1481 } | |
| 1482 } else { | |
| 1483 // for the FBO | |
| 1484 switch (attachment) { | |
| 1485 case GL_COLOR_ATTACHMENT0: | |
| 1486 case GL_DEPTH_ATTACHMENT: | |
| 1487 case GL_STENCIL_ATTACHMENT: | |
| 1488 break; | |
| 1489 case GL_DEPTH_STENCIL_ATTACHMENT: | |
| 1490 if (m_framebufferBinding->getAttachmentObject(GL_DEPTH_STENCIL_ATTAC HMENT) || (m_framebufferBinding->getAttachmentObject(GL_DEPTH_ATTACHMENT) == m_f ramebufferBinding->getAttachmentObject(GL_STENCIL_ATTACHMENT))) | |
| 1491 break; | |
| 1492 default: | |
| 1493 if (attachment > GL_COLOR_ATTACHMENT0 | |
| 1494 && attachment < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + maxCo lorAttachments())) | |
| 1495 break; | |
| 1496 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid attachment "); | |
| 1497 return false; | |
| 1498 } | |
| 1499 } | |
| 1500 return true; | |
| 1501 } | |
| 1502 | |
| 1503 ScriptValue WebGL2RenderingContextBase::getFramebufferAttachmentParameter(Script State* scriptState, GLenum target, GLenum attachment, GLenum pname) | |
| 1504 { | |
| 1505 if (isContextLost() || !validateGetFramebufferAttachmentParameterFunc("getFr amebufferAttachmentParameter", target, attachment)) | |
| 1506 return ScriptValue::createNull(scriptState); | |
| 1507 | |
| 1508 ASSERT(!m_framebufferBinding || m_framebufferBinding->object()); | |
|
Ken Russell (switch to Gerrit)
2015/04/28 05:43:23
target can be either GL_READ_FRAMEBUFFER or GL_DRA
yunchao
2015/04/29 11:13:11
Done.
| |
| 1509 | |
| 1510 WebGLSharedObject* attachmentObject = m_framebufferBinding ? m_framebufferBi nding->getAttachmentObject(attachment) : 0; | |
| 1511 if (m_framebufferBinding && !attachmentObject) { | |
| 1512 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) | |
| 1513 return WebGLAny(scriptState, GL_NONE); | |
| 1514 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) | |
| 1515 return WebGLAny(scriptState, 0); | |
| 1516 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "invalid parameter name"); | |
| 1517 return ScriptValue::createNull(scriptState); | |
| 1518 } | |
| 1519 | |
| 1520 switch (pname) { | |
| 1521 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | |
| 1522 if (!attachmentObject) { | |
| 1523 ASSERT(!m_framebufferBinding); | |
| 1524 return WebGLAny(scriptState, GL_FRAMEBUFFER_DEFAULT); | |
| 1525 } | |
| 1526 ASSERT(attachmentObject->isTexture() || attachmentObject->isRenderbuffer ()); | |
| 1527 if (attachmentObject->isTexture()) | |
| 1528 return WebGLAny(scriptState, GL_TEXTURE); | |
| 1529 if (attachmentObject->isRenderbuffer()) | |
| 1530 return WebGLAny(scriptState, GL_RENDERBUFFER); | |
| 1531 break; | |
| 1532 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | |
| 1533 if (!attachmentObject) | |
| 1534 break; | |
| 1535 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(attachm entObject)); | |
| 1536 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | |
| 1537 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: | |
| 1538 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: | |
| 1539 if (!attachmentObject || !attachmentObject->isTexture()) | |
| 1540 break; | |
| 1541 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: | |
| 1542 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: | |
| 1543 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: | |
| 1544 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: | |
| 1545 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: | |
| 1546 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: | |
| 1547 { | |
| 1548 GLint value = 0; | |
| 1549 webContext()->getFramebufferAttachmentParameteriv(target, attachment , pname, &value); | |
|
Ken Russell (switch to Gerrit)
2015/04/28 05:43:23
This will return an incorrect answer if the Drawin
yunchao
2015/04/29 11:13:11
Agreed. The latest patch set has updated bindFrame
| |
| 1550 return WebGLAny(scriptState, value); | |
| 1551 } | |
| 1552 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: | |
| 1553 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: | |
| 1554 { | |
| 1555 GLint value = 0; | |
| 1556 webContext()->getFramebufferAttachmentParameteriv(target, attachment , pname, &value); | |
| 1557 return WebGLAny(scriptState, static_cast<unsigned>(value)); | |
| 1558 } | |
| 1559 default: | |
| 1560 break; | |
| 1561 } | |
| 1562 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "inv alid parameter name"); | |
| 1563 return ScriptValue::createNull(scriptState); | |
| 1564 } | |
| 1565 | |
| 1464 DEFINE_TRACE(WebGL2RenderingContextBase) | 1566 DEFINE_TRACE(WebGL2RenderingContextBase) |
| 1465 { | 1567 { |
| 1466 visitor->trace(m_readFramebufferBinding); | 1568 visitor->trace(m_readFramebufferBinding); |
| 1467 WebGLRenderingContextBase::trace(visitor); | 1569 WebGLRenderingContextBase::trace(visitor); |
| 1468 } | 1570 } |
| 1469 | 1571 |
| 1470 WebGLTexture* WebGL2RenderingContextBase::validateTextureBinding(const char* fun ctionName, GLenum target, bool useSixEnumsForCubeMap) | 1572 WebGLTexture* WebGL2RenderingContextBase::validateTextureBinding(const char* fun ctionName, GLenum target, bool useSixEnumsForCubeMap) |
| 1471 { | 1573 { |
| 1472 switch (target) { | 1574 switch (target) { |
| 1473 // FIXME: add 2D Array texture binding point and 3D texture binding point. | 1575 // FIXME: add 2D Array texture binding point and 3D texture binding point. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1516 GLfloat value = 0.f; | 1618 GLfloat value = 0.f; |
| 1517 webContext()->getTexParameterfv(target, pname, &value); | 1619 webContext()->getTexParameterfv(target, pname, &value); |
| 1518 return WebGLAny(scriptState, value); | 1620 return WebGLAny(scriptState, value); |
| 1519 } | 1621 } |
| 1520 default: | 1622 default: |
| 1521 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p name); | 1623 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p name); |
| 1522 } | 1624 } |
| 1523 } | 1625 } |
| 1524 | 1626 |
| 1525 } // namespace blink | 1627 } // namespace blink |
| OLD | NEW |