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 "modules/webgl/WebGL2RenderingContextBase.h" | 6 #include "modules/webgl/WebGL2RenderingContextBase.h" |
7 | 7 |
8 #include "bindings/modules/v8/WebGLAny.h" | 8 #include "bindings/modules/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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1586 { | 1586 { |
1587 if (isContextLost()) | 1587 if (isContextLost()) |
1588 return nullptr; | 1588 return nullptr; |
1589 WebGLQuery* o = WebGLQuery::create(this); | 1589 WebGLQuery* o = WebGLQuery::create(this); |
1590 addSharedObject(o); | 1590 addSharedObject(o); |
1591 return o; | 1591 return o; |
1592 } | 1592 } |
1593 | 1593 |
1594 void WebGL2RenderingContextBase::deleteQuery(WebGLQuery* query) | 1594 void WebGL2RenderingContextBase::deleteQuery(WebGLQuery* query) |
1595 { | 1595 { |
1596 if (!query) | |
Zhenyao Mo
2015/11/30 18:16:48
You should also check for isContextLost() here.
| |
1597 return; | |
1598 | |
1596 if (m_currentBooleanOcclusionQuery == query) { | 1599 if (m_currentBooleanOcclusionQuery == query) { |
1597 webContext()->endQueryEXT(m_currentBooleanOcclusionQuery->getTarget()); | 1600 webContext()->endQueryEXT(m_currentBooleanOcclusionQuery->getTarget()); |
1598 m_currentBooleanOcclusionQuery = nullptr; | 1601 m_currentBooleanOcclusionQuery = nullptr; |
1599 } | 1602 } |
1600 | 1603 |
1601 if (m_currentTransformFeedbackPrimitivesWrittenQuery == query) { | 1604 if (m_currentTransformFeedbackPrimitivesWrittenQuery == query) { |
1602 webContext()->endQueryEXT(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); | 1605 webContext()->endQueryEXT(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); |
1603 m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr; | 1606 m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr; |
1604 } | 1607 } |
1605 | 1608 |
1606 deleteObject(query); | 1609 deleteObject(query); |
1607 } | 1610 } |
1608 | 1611 |
1609 GLboolean WebGL2RenderingContextBase::isQuery(WebGLQuery* query) | 1612 GLboolean WebGL2RenderingContextBase::isQuery(WebGLQuery* query) |
1610 { | 1613 { |
1611 if (isContextLost() || !query) | 1614 if (isContextLost() || !query) |
1612 return 0; | 1615 return 0; |
1613 | 1616 |
1614 return webContext()->isQueryEXT(query->object()); | 1617 return webContext()->isQueryEXT(query->object()); |
1615 } | 1618 } |
1616 | 1619 |
1617 void WebGL2RenderingContextBase::beginQuery(GLenum target, WebGLQuery* query) | 1620 void WebGL2RenderingContextBase::beginQuery(GLenum target, WebGLQuery* query) |
1618 { | 1621 { |
1619 bool deleted; | 1622 bool deleted; |
1623 if (!query) { | |
1624 synthesizeGLError(GL_INVALID_OPERATION, "beginQuery", "query object is n ull"); | |
1625 return; | |
1626 } | |
1627 | |
1620 if (!checkObjectToBeBound("beginQuery", query, deleted)) | 1628 if (!checkObjectToBeBound("beginQuery", query, deleted)) |
1621 return; | 1629 return; |
1622 if (deleted) { | 1630 if (deleted) { |
1623 synthesizeGLError(GL_INVALID_OPERATION, "beginQuery", "attempted to begi n a deleted query object"); | 1631 synthesizeGLError(GL_INVALID_OPERATION, "beginQuery", "attempted to begi n a deleted query object"); |
1624 return; | 1632 return; |
1625 } | 1633 } |
1626 | 1634 |
1627 if (query->getTarget() && query->getTarget() != target) { | 1635 if (query->getTarget() && query->getTarget() != target) { |
1628 synthesizeGLError(GL_INVALID_OPERATION, "beginQuery", "query type does n ot match target"); | 1636 synthesizeGLError(GL_INVALID_OPERATION, "beginQuery", "query type does n ot match target"); |
1629 return; | 1637 return; |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3211 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 3219 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
3212 { | 3220 { |
3213 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 3221 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
3214 return m_readFramebufferBinding->colorBufferFormat(); | 3222 return m_readFramebufferBinding->colorBufferFormat(); |
3215 if (m_requestedAttributes.alpha()) | 3223 if (m_requestedAttributes.alpha()) |
3216 return GL_RGBA; | 3224 return GL_RGBA; |
3217 return GL_RGB; | 3225 return GL_RGB; |
3218 } | 3226 } |
3219 | 3227 |
3220 } // namespace blink | 3228 } // namespace blink |
OLD | NEW |