Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1408803003: Enforce queries' new availability semantics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webgl/WebGLQuery.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 void WebGL2RenderingContextBase::endQuery(GLenum target) 1484 void WebGL2RenderingContextBase::endQuery(GLenum target)
1485 { 1485 {
1486 if (isContextLost()) 1486 if (isContextLost())
1487 return; 1487 return;
1488 1488
1489 switch (target) { 1489 switch (target) {
1490 case GL_ANY_SAMPLES_PASSED: 1490 case GL_ANY_SAMPLES_PASSED:
1491 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: 1491 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
1492 { 1492 {
1493 if (m_currentBooleanOcclusionQuery && m_currentBooleanOcclusionQuery ->getTarget() == target) { 1493 if (m_currentBooleanOcclusionQuery && m_currentBooleanOcclusionQuery ->getTarget() == target) {
1494 m_currentBooleanOcclusionQuery->resetCachedResult();
1494 m_currentBooleanOcclusionQuery = nullptr; 1495 m_currentBooleanOcclusionQuery = nullptr;
1495 } else { 1496 } else {
1496 synthesizeGLError(GL_INVALID_OPERATION, "endQuery", "target quer y is not active"); 1497 synthesizeGLError(GL_INVALID_OPERATION, "endQuery", "target quer y is not active");
1497 return; 1498 return;
1498 } 1499 }
1499 } 1500 }
1500 break; 1501 break;
1501 case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: 1502 case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
1502 { 1503 {
1503 if (m_currentTransformFeedbackPrimitivesWrittenQuery) { 1504 if (m_currentTransformFeedbackPrimitivesWrittenQuery) {
1505 m_currentTransformFeedbackPrimitivesWrittenQuery->resetCachedRes ult();
1504 m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr; 1506 m_currentTransformFeedbackPrimitivesWrittenQuery = nullptr;
1505 } else { 1507 } else {
1506 synthesizeGLError(GL_INVALID_OPERATION, "endQuery", "target quer y is not active"); 1508 synthesizeGLError(GL_INVALID_OPERATION, "endQuery", "target quer y is not active");
1507 return; 1509 return;
1508 } 1510 }
1509 } 1511 }
1510 break; 1512 break;
1511 default: 1513 default:
1512 synthesizeGLError(GL_INVALID_ENUM, "endQuery", "invalid target"); 1514 synthesizeGLError(GL_INVALID_ENUM, "endQuery", "invalid target");
1513 return; 1515 return;
(...skipping 25 matching lines...) Expand all
1539 return nullptr; 1541 return nullptr;
1540 } 1542 }
1541 return nullptr; 1543 return nullptr;
1542 } 1544 }
1543 1545
1544 ScriptValue WebGL2RenderingContextBase::getQueryParameter(ScriptState* scriptSta te, WebGLQuery* query, GLenum pname) 1546 ScriptValue WebGL2RenderingContextBase::getQueryParameter(ScriptState* scriptSta te, WebGLQuery* query, GLenum pname)
1545 { 1547 {
1546 if (isContextLost() || !validateWebGLObject("getQueryParameter", query)) 1548 if (isContextLost() || !validateWebGLObject("getQueryParameter", query))
1547 return ScriptValue::createNull(scriptState); 1549 return ScriptValue::createNull(scriptState);
1548 1550
1551 // Query is non-null at this point.
1552 if (query == m_currentBooleanOcclusionQuery || query == m_currentTransformFe edbackPrimitivesWrittenQuery) {
1553 synthesizeGLError(GL_INVALID_OPERATION, "getQueryParameter", "query is c urrently active");
1554 return ScriptValue::createNull(scriptState);
1555 }
1556
1549 switch (pname) { 1557 switch (pname) {
1550 case GL_QUERY_RESULT: 1558 case GL_QUERY_RESULT:
1551 { 1559 {
1552 GLuint value; 1560 query->updateCachedResult(webContext());
1553 webContext()->getQueryObjectuivEXT(objectOrZero(query), pname, &valu e); 1561 return WebGLAny(scriptState, query->getQueryResult());
1554 return WebGLAny(scriptState, value);
1555 } 1562 }
1556 case GL_QUERY_RESULT_AVAILABLE: 1563 case GL_QUERY_RESULT_AVAILABLE:
1557 { 1564 {
1558 GLuint value; 1565 query->updateCachedResult(webContext());
1559 webContext()->getQueryObjectuivEXT(objectOrZero(query), pname, &valu e); 1566 return WebGLAny(scriptState, query->isQueryResultAvailable());
1560 return WebGLAny(scriptState, value == GL_TRUE);
1561 } 1567 }
1562 default: 1568 default:
1563 synthesizeGLError(GL_INVALID_ENUM, "getQueryParameter", "invalid paramet er name"); 1569 synthesizeGLError(GL_INVALID_ENUM, "getQueryParameter", "invalid paramet er name");
1564 return ScriptValue::createNull(scriptState); 1570 return ScriptValue::createNull(scriptState);
1565 } 1571 }
1566 } 1572 }
1567 1573
1568 WebGLSampler* WebGL2RenderingContextBase::createSampler() 1574 WebGLSampler* WebGL2RenderingContextBase::createSampler()
1569 { 1575 {
1570 if (isContextLost()) 1576 if (isContextLost())
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2956 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() 2962 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
2957 { 2963 {
2958 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) 2964 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
2959 return m_readFramebufferBinding->colorBufferFormat(); 2965 return m_readFramebufferBinding->colorBufferFormat();
2960 if (m_requestedAttributes.alpha()) 2966 if (m_requestedAttributes.alpha())
2961 return GL_RGBA; 2967 return GL_RGBA;
2962 return GL_RGB; 2968 return GL_RGB;
2963 } 2969 }
2964 2970
2965 } // namespace blink 2971 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webgl/WebGLQuery.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698