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

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

Issue 2019513004: Validate bound buffer for draw calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
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 "modules/webgl/WebGL2RenderingContextBase.h" 5 #include "modules/webgl/WebGL2RenderingContextBase.h"
6 6
7 #include "bindings/modules/v8/WebGLAny.h" 7 #include "bindings/modules/v8/WebGLAny.h"
8 #include "core/frame/ImageBitmap.h" 8 #include "core/frame/ImageBitmap.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 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 } 1506 }
1507 1507
1508 contextGL()->VertexAttribDivisorANGLE(index, divisor); 1508 contextGL()->VertexAttribDivisorANGLE(index, divisor);
1509 } 1509 }
1510 1510
1511 void WebGL2RenderingContextBase::drawArraysInstanced(GLenum mode, GLint first, G Lsizei count, GLsizei instanceCount) 1511 void WebGL2RenderingContextBase::drawArraysInstanced(GLenum mode, GLint first, G Lsizei count, GLsizei instanceCount)
1512 { 1512 {
1513 if (!validateDrawArrays("drawArraysInstanced")) 1513 if (!validateDrawArrays("drawArraysInstanced"))
1514 return; 1514 return;
1515 1515
1516 if (!m_boundVertexArrayObject->isAllEnabledAttribBufferBound()) {
1517 synthesizeGLError(GL_INVALID_OPERATION, "drawArraysInstanced", "no buffe r is bound to enabled attribute");
1518 return;
1519 }
1520
1516 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get()); 1521 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get());
1517 clearIfComposited(); 1522 clearIfComposited();
1518 contextGL()->DrawArraysInstancedANGLE(mode, first, count, instanceCount); 1523 contextGL()->DrawArraysInstancedANGLE(mode, first, count, instanceCount);
1519 markContextChanged(CanvasChanged); 1524 markContextChanged(CanvasChanged);
1520 } 1525 }
1521 1526
1522 void WebGL2RenderingContextBase::drawElementsInstanced(GLenum mode, GLsizei coun t, GLenum type, long long offset, GLsizei instanceCount) 1527 void WebGL2RenderingContextBase::drawElementsInstanced(GLenum mode, GLsizei coun t, GLenum type, long long offset, GLsizei instanceCount)
1523 { 1528 {
1524 if (!validateDrawElements("drawElementsInstanced", type, offset)) 1529 if (!validateDrawElements("drawElementsInstanced", type, offset))
1525 return; 1530 return;
1526 1531
1532 if (!m_boundVertexArrayObject->isAllEnabledAttribBufferBound()) {
1533 synthesizeGLError(GL_INVALID_OPERATION, "drawElementsInstanced", "no buf fer is bound to enabled attribute");
1534 return;
1535 }
1536
1527 if (transformFeedbackActive() && !transformFeedbackPaused()) { 1537 if (transformFeedbackActive() && !transformFeedbackPaused()) {
1528 synthesizeGLError(GL_INVALID_OPERATION, "drawElementsInstanced", "transf orm feedback is active and not paused"); 1538 synthesizeGLError(GL_INVALID_OPERATION, "drawElementsInstanced", "transf orm feedback is active and not paused");
1529 return; 1539 return;
1530 } 1540 }
1531 1541
1532 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get()); 1542 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get());
1533 clearIfComposited(); 1543 clearIfComposited();
1534 contextGL()->DrawElementsInstancedANGLE(mode, count, type, reinterpret_cast< void*>(static_cast<intptr_t>(offset)), instanceCount); 1544 contextGL()->DrawElementsInstancedANGLE(mode, count, type, reinterpret_cast< void*>(static_cast<intptr_t>(offset)), instanceCount);
1535 markContextChanged(CanvasChanged); 1545 markContextChanged(CanvasChanged);
1536 } 1546 }
1537 1547
1538 void WebGL2RenderingContextBase::drawRangeElements(GLenum mode, GLuint start, GL uint end, GLsizei count, GLenum type, long long offset) 1548 void WebGL2RenderingContextBase::drawRangeElements(GLenum mode, GLuint start, GL uint end, GLsizei count, GLenum type, long long offset)
1539 { 1549 {
1540 if (!validateDrawElements("drawRangeElements", type, offset)) 1550 if (!validateDrawElements("drawRangeElements", type, offset))
1541 return; 1551 return;
1542 1552
1553 if (!m_boundVertexArrayObject->isAllEnabledAttribBufferBound()) {
1554 synthesizeGLError(GL_INVALID_OPERATION, "drawRangeElements", "no buffer is bound to enabled attribute");
1555 return;
1556 }
1557
1543 if (transformFeedbackActive() && !transformFeedbackPaused()) { 1558 if (transformFeedbackActive() && !transformFeedbackPaused()) {
1544 synthesizeGLError(GL_INVALID_OPERATION, "drawRangeElements", "transform feedback is active and not paused"); 1559 synthesizeGLError(GL_INVALID_OPERATION, "drawRangeElements", "transform feedback is active and not paused");
1545 return; 1560 return;
1546 } 1561 }
1547 1562
1548 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get()); 1563 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get());
1549 clearIfComposited(); 1564 clearIfComposited();
1550 contextGL()->DrawRangeElements(mode, start, end, count, type, reinterpret_ca st<void*>(static_cast<intptr_t>(offset))); 1565 contextGL()->DrawRangeElements(mode, start, end, count, type, reinterpret_ca st<void*>(static_cast<intptr_t>(offset)));
1551 markContextChanged(CanvasChanged); 1566 markContextChanged(CanvasChanged);
1552 } 1567 }
(...skipping 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 params.skipPixels = m_unpackSkipPixels; 3604 params.skipPixels = m_unpackSkipPixels;
3590 params.skipRows = m_unpackSkipRows; 3605 params.skipRows = m_unpackSkipRows;
3591 if (dimension == Tex3D) { 3606 if (dimension == Tex3D) {
3592 params.imageHeight = m_unpackImageHeight; 3607 params.imageHeight = m_unpackImageHeight;
3593 params.skipImages = m_unpackSkipImages; 3608 params.skipImages = m_unpackSkipImages;
3594 } 3609 }
3595 return params; 3610 return params;
3596 } 3611 }
3597 3612
3598 } // namespace blink 3613 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698