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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp

Issue 2019513004: Validate bound buffer for draw calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: private function Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp
index 842546731cd6b336cd710b789745e3147d3fe49c..f5370cb50413efde620cf9409ffcbb5097405bac 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp
@@ -16,8 +16,13 @@ WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase(WebGLRenderingContextBase
, m_hasEverBeenBound(false)
, m_destructionInProgress(false)
, m_boundElementArrayBuffer(nullptr)
+ , m_isAllEnabledAttribBufferBound(true)
{
m_arrayBufferList.resize(ctx->maxVertexAttribs());
+ m_attribEnabled.resize(ctx->maxVertexAttribs());
+ for (size_t i = 0; i < m_attribEnabled.size(); ++i) {
+ m_attribEnabled[i] = false;
+ }
switch (m_type) {
case VaoTypeDefault:
@@ -80,7 +85,7 @@ void WebGLVertexArrayObjectBase::setElementArrayBuffer(WebGLBuffer* buffer)
WebGLBuffer* WebGLVertexArrayObjectBase::getArrayBufferForAttrib(size_t index)
{
- ASSERT(index < context()->maxVertexAttribs());
+ DCHECK(index < context()->maxVertexAttribs());
return m_arrayBufferList[index].get();
}
@@ -92,6 +97,31 @@ void WebGLVertexArrayObjectBase::setArrayBufferForAttrib(GLuint index, WebGLBuff
m_arrayBufferList[index]->onDetached(context()->contextGL());
m_arrayBufferList[index] = buffer;
+ updateAttribBufferBoundStatus();
+}
+
+void WebGLVertexArrayObjectBase::setAttribEnabled(GLuint index, bool enabled)
+{
+ DCHECK(index < context()->maxVertexAttribs());
+ m_attribEnabled[index] = enabled;
+ updateAttribBufferBoundStatus();
+}
+
+bool WebGLVertexArrayObjectBase::getAttribEnabled(GLuint index) const
+{
+ DCHECK(index < context()->maxVertexAttribs());
+ return m_attribEnabled[index];
+}
+
+void WebGLVertexArrayObjectBase::updateAttribBufferBoundStatus()
+{
+ m_isAllEnabledAttribBufferBound = true;
+ for (size_t i = 0; i < m_attribEnabled.size(); ++i) {
+ if (m_attribEnabled[i] && !m_arrayBufferList[i]) {
+ m_isAllEnabledAttribBufferBound = false;
+ return;
+ }
+ }
}
void WebGLVertexArrayObjectBase::unbindBuffer(WebGLBuffer* buffer)
@@ -107,6 +137,7 @@ void WebGLVertexArrayObjectBase::unbindBuffer(WebGLBuffer* buffer)
m_arrayBufferList[i] = nullptr;
}
}
+ updateAttribBufferBoundStatus();
}
ScopedPersistent<v8::Array>* WebGLVertexArrayObjectBase::getPersistentCache()
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698