| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 216 } |
| 217 break; | 217 break; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 namespace { | 221 namespace { |
| 222 | 222 |
| 223 class ScopedDrawingBufferBinder { | 223 class ScopedDrawingBufferBinder { |
| 224 STACK_ALLOCATED(); | 224 STACK_ALLOCATED(); |
| 225 public: | 225 public: |
| 226 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer
* framebufferBinding) | 226 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer
* framebufferBinding, GLenum target) |
| 227 : m_drawingBuffer(drawingBuffer) | 227 : m_drawingBuffer(drawingBuffer) |
| 228 , m_framebufferBinding(framebufferBinding) | 228 , m_framebufferBinding(framebufferBinding) |
| 229 , m_target(target) |
| 229 { | 230 { |
| 230 // Commit DrawingBuffer if needed (e.g., for multisampling) | 231 // Commit DrawingBuffer if needed (e.g., for multisampling) |
| 231 if (!m_framebufferBinding && m_drawingBuffer) | 232 if (!m_framebufferBinding && m_drawingBuffer) |
| 232 m_drawingBuffer->commit(); | 233 m_drawingBuffer->commit(m_target); |
| 233 } | 234 } |
| 234 | 235 |
| 235 ~ScopedDrawingBufferBinder() | 236 ~ScopedDrawingBufferBinder() |
| 236 { | 237 { |
| 237 // Restore DrawingBuffer if needed | 238 // Restore DrawingBuffer if needed |
| 238 if (!m_framebufferBinding && m_drawingBuffer) | 239 if (!m_framebufferBinding && m_drawingBuffer) |
| 239 m_drawingBuffer->bind(); | 240 m_drawingBuffer->bind(m_target); |
| 240 } | 241 } |
| 241 | 242 |
| 242 private: | 243 private: |
| 243 DrawingBuffer* m_drawingBuffer; | 244 DrawingBuffer* m_drawingBuffer; |
| 244 RawPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding; | 245 RawPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding; |
| 246 GLenum m_target; |
| 245 }; | 247 }; |
| 246 | 248 |
| 247 GLint clamp(GLint value, GLint min, GLint max) | 249 GLint clamp(GLint value, GLint min, GLint max) |
| 248 { | 250 { |
| 249 if (value < min) | 251 if (value < min) |
| 250 value = min; | 252 value = min; |
| 251 if (value > max) | 253 if (value > max) |
| 252 value = max; | 254 value = max; |
| 253 return value; | 255 return value; |
| 254 } | 256 } |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 canvas()->clearCopiedImage(); | 868 canvas()->clearCopiedImage(); |
| 867 layoutBox->contentChanged(changeType); | 869 layoutBox->contentChanged(changeType); |
| 868 } else { | 870 } else { |
| 869 if (!m_markedCanvasDirty) { | 871 if (!m_markedCanvasDirty) { |
| 870 m_markedCanvasDirty = true; | 872 m_markedCanvasDirty = true; |
| 871 canvas()->didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize())); | 873 canvas()->didDraw(FloatRect(FloatPoint(0, 0), clampedCanvasSize())); |
| 872 } | 874 } |
| 873 } | 875 } |
| 874 } | 876 } |
| 875 | 877 |
| 878 GLenum WebGLRenderingContextBase::getDrawFramebufferTarget() |
| 879 { |
| 880 return GL_FRAMEBUFFER; |
| 881 } |
| 882 |
| 876 WebGLRenderingContextBase::HowToClear WebGLRenderingContextBase::clearIfComposit
ed(GLbitfield mask) | 883 WebGLRenderingContextBase::HowToClear WebGLRenderingContextBase::clearIfComposit
ed(GLbitfield mask) |
| 877 { | 884 { |
| 878 if (isContextLost()) | 885 if (isContextLost()) |
| 879 return Skipped; | 886 return Skipped; |
| 880 | 887 |
| 881 if (!drawingBuffer()->bufferClearNeeded() || (mask && m_framebufferBinding)) | 888 if (!drawingBuffer()->bufferClearNeeded() || (mask && m_framebufferBinding)) |
| 882 return Skipped; | 889 return Skipped; |
| 883 | 890 |
| 884 Nullable<WebGLContextAttributes> contextAttributes; | 891 Nullable<WebGLContextAttributes> contextAttributes; |
| 885 getContextAttributes(contextAttributes); | 892 getContextAttributes(contextAttributes); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 910 } | 917 } |
| 911 if (contextAttributes.get().stencil()) { | 918 if (contextAttributes.get().stencil()) { |
| 912 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) | 919 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) |
| 913 webContext()->clearStencil(m_clearStencil & m_stencilMask); | 920 webContext()->clearStencil(m_clearStencil & m_stencilMask); |
| 914 else | 921 else |
| 915 webContext()->clearStencil(0); | 922 webContext()->clearStencil(0); |
| 916 clearMask |= GL_STENCIL_BUFFER_BIT; | 923 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 917 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 924 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 918 } | 925 } |
| 919 | 926 |
| 920 drawingBuffer()->clearFramebuffers(clearMask); | 927 GLenum target = getDrawFramebufferTarget(); |
| 928 drawingBuffer()->clearFramebuffers(target, clearMask); |
| 921 | 929 |
| 922 restoreStateAfterClear(); | 930 restoreStateAfterClear(); |
| 923 if (m_framebufferBinding) | 931 if (m_framebufferBinding) { |
| 924 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); | 932 webContext()->bindFramebuffer(target, objectOrZero(m_framebufferBinding.
get())); |
| 933 } |
| 925 drawingBuffer()->setBufferClearNeeded(false); | 934 drawingBuffer()->setBufferClearNeeded(false); |
| 926 | 935 |
| 927 return combinedClear ? CombinedClear : JustClear; | 936 return combinedClear ? CombinedClear : JustClear; |
| 928 } | 937 } |
| 929 | 938 |
| 930 void WebGLRenderingContextBase::restoreStateAfterClear() | 939 void WebGLRenderingContextBase::restoreStateAfterClear() |
| 931 { | 940 { |
| 932 if (isContextLost()) | 941 if (isContextLost()) |
| 933 return; | 942 return; |
| 934 | 943 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 width = clamp(width, 1, maxWidth); | 1028 width = clamp(width, 1, maxWidth); |
| 1020 height = clamp(height, 1, maxHeight); | 1029 height = clamp(height, 1, maxHeight); |
| 1021 | 1030 |
| 1022 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off | 1031 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off |
| 1023 // clear (and this matches what reshape will do). | 1032 // clear (and this matches what reshape will do). |
| 1024 drawingBuffer()->reset(IntSize(width, height)); | 1033 drawingBuffer()->reset(IntSize(width, height)); |
| 1025 restoreStateAfterClear(); | 1034 restoreStateAfterClear(); |
| 1026 | 1035 |
| 1027 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ
eTextureUnit].m_texture2DBinding.get())); | 1036 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ
eTextureUnit].m_texture2DBinding.get())); |
| 1028 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB
inding.get())); | 1037 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB
inding.get())); |
| 1029 if (m_framebufferBinding) | 1038 if (isWebGL2OrHigher()) { |
| 1039 // In GLES 3.0, bindFramebuffer(GL_FRAMEBUFFER, buffer1) = bindBuffer(GL_REA
D_FRAMEBUFFER, buffer1) + |
| 1040 // bindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer1) |
| 1041 if (m_framebufferBinding) |
| 1042 webContext()->bindFramebuffer(GL_DRAW_FRAMEBUFFER, objectOrZero(m_fr
amebufferBinding.get())); |
| 1043 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(GL_READ
_FRAMEBUFFER); |
| 1044 if (readFramebufferBinding) |
| 1045 webContext()->bindFramebuffer(GL_READ_FRAMEBUFFER, objectOrZero(read
FramebufferBinding)); |
| 1046 } else if (m_framebufferBinding) { |
| 1030 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); | 1047 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 1048 } |
| 1031 } | 1049 } |
| 1032 | 1050 |
| 1033 int WebGLRenderingContextBase::drawingBufferWidth() const | 1051 int WebGLRenderingContextBase::drawingBufferWidth() const |
| 1034 { | 1052 { |
| 1035 return isContextLost() ? 0 : drawingBuffer()->size().width(); | 1053 return isContextLost() ? 0 : drawingBuffer()->size().width(); |
| 1036 } | 1054 } |
| 1037 | 1055 |
| 1038 int WebGLRenderingContextBase::drawingBufferHeight() const | 1056 int WebGLRenderingContextBase::drawingBufferHeight() const |
| 1039 { | 1057 { |
| 1040 return isContextLost() ? 0 : drawingBuffer()->size().height(); | 1058 return isContextLost() ? 0 : drawingBuffer()->size().height(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 | 1386 |
| 1369 bool WebGLRenderingContextBase::validateFramebufferTarget(GLenum target) | 1387 bool WebGLRenderingContextBase::validateFramebufferTarget(GLenum target) |
| 1370 { | 1388 { |
| 1371 if (target == GL_FRAMEBUFFER) | 1389 if (target == GL_FRAMEBUFFER) |
| 1372 return true; | 1390 return true; |
| 1373 return false; | 1391 return false; |
| 1374 } | 1392 } |
| 1375 | 1393 |
| 1376 WebGLFramebuffer* WebGLRenderingContextBase::getFramebufferBinding(GLenum target
) | 1394 WebGLFramebuffer* WebGLRenderingContextBase::getFramebufferBinding(GLenum target
) |
| 1377 { | 1395 { |
| 1378 return m_framebufferBinding.get(); | 1396 if (target == GL_FRAMEBUFFER) |
| 1397 return m_framebufferBinding.get(); |
| 1398 return nullptr; |
| 1379 } | 1399 } |
| 1380 | 1400 |
| 1381 GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) | 1401 GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) |
| 1382 { | 1402 { |
| 1383 if (isContextLost()) | 1403 if (isContextLost()) |
| 1384 return GL_FRAMEBUFFER_UNSUPPORTED; | 1404 return GL_FRAMEBUFFER_UNSUPPORTED; |
| 1385 if (!validateFramebufferTarget(target)) { | 1405 if (!validateFramebufferTarget(target)) { |
| 1386 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta
rget"); | 1406 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta
rget"); |
| 1387 return 0; | 1407 return 0; |
| 1388 } | 1408 } |
| 1389 if (!getFramebufferBinding(target) || !getFramebufferBinding(target)->object
()) | 1409 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
| 1410 if (!framebufferBinding || !framebufferBinding->object()) |
| 1390 return GL_FRAMEBUFFER_COMPLETE; | 1411 return GL_FRAMEBUFFER_COMPLETE; |
| 1391 const char* reason = "framebuffer incomplete"; | 1412 const char* reason = "framebuffer incomplete"; |
| 1392 GLenum result = m_framebufferBinding->checkStatus(&reason); | 1413 GLenum result = framebufferBinding->checkStatus(&reason, target); |
| 1393 if (result != GL_FRAMEBUFFER_COMPLETE) { | 1414 if (result != GL_FRAMEBUFFER_COMPLETE) { |
| 1394 emitGLWarning("checkFramebufferStatus", reason); | 1415 emitGLWarning("checkFramebufferStatus", reason); |
| 1395 return result; | 1416 return result; |
| 1396 } | 1417 } |
| 1397 result = webContext()->checkFramebufferStatus(target); | 1418 result = webContext()->checkFramebufferStatus(target); |
| 1398 return result; | 1419 return result; |
| 1399 } | 1420 } |
| 1400 | 1421 |
| 1401 void WebGLRenderingContextBase::clear(GLbitfield mask) | 1422 void WebGLRenderingContextBase::clear(GLbitfield mask) |
| 1402 { | 1423 { |
| 1403 if (isContextLost()) | 1424 if (isContextLost()) |
| 1404 return; | 1425 return; |
| 1405 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { | 1426 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { |
| 1406 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); | 1427 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); |
| 1407 return; | 1428 return; |
| 1408 } | 1429 } |
| 1409 const char* reason = "framebuffer incomplete"; | 1430 const char* reason = "framebuffer incomplete"; |
| 1410 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { | 1431 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL
_FRAMEBUFFER, &reason)) { |
| 1411 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); | 1432 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); |
| 1412 return; | 1433 return; |
| 1413 } | 1434 } |
| 1414 if (clearIfComposited(mask) != CombinedClear) | 1435 if (clearIfComposited(mask) != CombinedClear) |
| 1415 webContext()->clear(mask); | 1436 webContext()->clear(mask); |
| 1416 markContextChanged(CanvasChanged); | 1437 markContextChanged(CanvasChanged); |
| 1417 } | 1438 } |
| 1418 | 1439 |
| 1419 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl
oat a) | 1440 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl
oat a) |
| 1420 { | 1441 { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 } | 1582 } |
| 1562 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1583 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
| 1563 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i
s incompatible format"); | 1584 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i
s incompatible format"); |
| 1564 return; | 1585 return; |
| 1565 } | 1586 } |
| 1566 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 1587 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
| 1567 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); | 1588 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); |
| 1568 return; | 1589 return; |
| 1569 } | 1590 } |
| 1570 const char* reason = "framebuffer incomplete"; | 1591 const char* reason = "framebuffer incomplete"; |
| 1571 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { | 1592 if ((m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), G
L_FRAMEBUFFER, &reason)) |
| 1593 || (getFramebufferBinding(GL_READ_FRAMEBUFFER) && !getFramebufferBinding
(GL_READ_FRAMEBUFFER)->onAccess(webContext(), GL_READ_FRAMEBUFFER, &reason))) { |
| 1572 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); | 1594 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); |
| 1573 return; | 1595 return; |
| 1574 } | 1596 } |
| 1575 clearIfComposited(); | 1597 clearIfComposited(); |
| 1576 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get()
); | 1598 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get()
, GL_FRAMEBUFFER); |
| 1599 if (isWebGL2OrHigher()) |
| 1600 ScopedDrawingBufferBinder readBinder(drawingBuffer(), getFramebufferBind
ing(GL_READ_FRAMEBUFFER), GL_READ_FRAMEBUFFER); |
| 1577 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei
ght, border); | 1601 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei
ght, border); |
| 1578 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. | 1602 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. |
| 1579 tex->setLevelInfo(target, level, internalformat, width, height, 1, GL_UNSIGN
ED_BYTE); | 1603 tex->setLevelInfo(target, level, internalformat, width, height, 1, GL_UNSIGN
ED_BYTE); |
| 1580 } | 1604 } |
| 1581 | 1605 |
| 1582 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) | 1606 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 1583 { | 1607 { |
| 1584 if (isContextLost()) | 1608 if (isContextLost()) |
| 1585 return; | 1609 return; |
| 1586 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) | 1610 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1604 return; | 1628 return; |
| 1605 } | 1629 } |
| 1606 GLenum internalformat = tex->getInternalFormat(target, level); | 1630 GLenum internalformat = tex->getInternalFormat(target, level); |
| 1607 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) | 1631 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) |
| 1608 return; | 1632 return; |
| 1609 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1633 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
| 1610 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); | 1634 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); |
| 1611 return; | 1635 return; |
| 1612 } | 1636 } |
| 1613 const char* reason = "framebuffer incomplete"; | 1637 const char* reason = "framebuffer incomplete"; |
| 1614 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { | 1638 if ((m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), G
L_FRAMEBUFFER, &reason)) |
| 1639 || (getFramebufferBinding(GL_READ_FRAMEBUFFER) && !getFramebufferBinding
(GL_READ_FRAMEBUFFER)->onAccess(webContext(), GL_READ_FRAMEBUFFER, &reason))) { |
| 1615 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D",
reason); | 1640 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D",
reason); |
| 1616 return; | 1641 return; |
| 1617 } | 1642 } |
| 1618 clearIfComposited(); | 1643 clearIfComposited(); |
| 1619 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get()
); | 1644 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get()
, GL_FRAMEBUFFER); |
| 1645 if (isWebGL2OrHigher()) |
| 1646 ScopedDrawingBufferBinder readBinder(drawingBuffer(), getFramebufferBind
ing(GL_READ_FRAMEBUFFER), GL_READ_FRAMEBUFFER); |
| 1620 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width
, height); | 1647 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width
, height); |
| 1621 } | 1648 } |
| 1622 | 1649 |
| 1623 PassRefPtrWillBeRawPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() | 1650 PassRefPtrWillBeRawPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() |
| 1624 { | 1651 { |
| 1625 if (isContextLost()) | 1652 if (isContextLost()) |
| 1626 return nullptr; | 1653 return nullptr; |
| 1627 RefPtrWillBeRawPtr<WebGLBuffer> o = WebGLBuffer::create(this); | 1654 RefPtrWillBeRawPtr<WebGLBuffer> o = WebGLBuffer::create(this); |
| 1628 addSharedObject(o.get()); | 1655 addSharedObject(o.get()); |
| 1629 return o.release(); | 1656 return o.release(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 | 1759 |
| 1733 m_boundVertexArrayObject->unbindBuffer(buffer); | 1760 m_boundVertexArrayObject->unbindBuffer(buffer); |
| 1734 } | 1761 } |
| 1735 | 1762 |
| 1736 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) | 1763 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) |
| 1737 { | 1764 { |
| 1738 if (!deleteObject(framebuffer)) | 1765 if (!deleteObject(framebuffer)) |
| 1739 return; | 1766 return; |
| 1740 if (framebuffer == m_framebufferBinding) { | 1767 if (framebuffer == m_framebufferBinding) { |
| 1741 m_framebufferBinding = nullptr; | 1768 m_framebufferBinding = nullptr; |
| 1742 drawingBuffer()->setFramebufferBinding(0); | 1769 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0); |
| 1743 // Have to call bindFramebuffer here to bind back to internal fbo. | 1770 // Have to call drawingBuffer()->bind() here to bind back to internal fb
o. |
| 1744 drawingBuffer()->bind(); | 1771 drawingBuffer()->bind(); |
| 1745 } | 1772 } |
| 1746 } | 1773 } |
| 1747 | 1774 |
| 1748 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) | 1775 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) |
| 1749 { | 1776 { |
| 1750 deleteObject(program); | 1777 deleteObject(program); |
| 1751 // We don't reset m_currentProgram to 0 here because the deletion of the | 1778 // We don't reset m_currentProgram to 0 here because the deletion of the |
| 1752 // current program is delayed. | 1779 // current program is delayed. |
| 1753 } | 1780 } |
| 1754 | 1781 |
| 1755 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff
er) | 1782 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff
er) |
| 1756 { | 1783 { |
| 1757 if (!deleteObject(renderbuffer)) | 1784 if (!deleteObject(renderbuffer)) |
| 1758 return; | 1785 return; |
| 1759 if (renderbuffer == m_renderbufferBinding) | 1786 if (renderbuffer == m_renderbufferBinding) |
| 1760 m_renderbufferBinding = nullptr; | 1787 m_renderbufferBinding = nullptr; |
| 1761 if (m_framebufferBinding) | 1788 if (m_framebufferBinding) |
| 1762 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer)
; | 1789 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer,
GL_FRAMEBUFFER); |
| 1790 if (getFramebufferBinding(GL_READ_FRAMEBUFFER)) |
| 1791 getFramebufferBinding(GL_READ_FRAMEBUFFER)->removeAttachmentFromBoundFra
mebuffer(renderbuffer, GL_READ_FRAMEBUFFER); |
| 1763 } | 1792 } |
| 1764 | 1793 |
| 1765 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) | 1794 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) |
| 1766 { | 1795 { |
| 1767 deleteObject(shader); | 1796 deleteObject(shader); |
| 1768 } | 1797 } |
| 1769 | 1798 |
| 1770 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) | 1799 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) |
| 1771 { | 1800 { |
| 1772 if (!deleteObject(texture)) | 1801 if (!deleteObject(texture)) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1789 m_textureUnits[i].m_texture3DBinding = nullptr; | 1818 m_textureUnits[i].m_texture3DBinding = nullptr; |
| 1790 maxBoundTextureIndex = i; | 1819 maxBoundTextureIndex = i; |
| 1791 } | 1820 } |
| 1792 if (texture == m_textureUnits[i].m_texture2DArrayBinding) { | 1821 if (texture == m_textureUnits[i].m_texture2DArrayBinding) { |
| 1793 m_textureUnits[i].m_texture2DArrayBinding = nullptr; | 1822 m_textureUnits[i].m_texture2DArrayBinding = nullptr; |
| 1794 maxBoundTextureIndex = i; | 1823 maxBoundTextureIndex = i; |
| 1795 } | 1824 } |
| 1796 } | 1825 } |
| 1797 } | 1826 } |
| 1798 if (m_framebufferBinding) | 1827 if (m_framebufferBinding) |
| 1799 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); | 1828 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture, GL_F
RAMEBUFFER); |
| 1829 if (getFramebufferBinding(GL_READ_FRAMEBUFFER)) |
| 1830 getFramebufferBinding(GL_READ_FRAMEBUFFER)->removeAttachmentFromBoundFra
mebuffer(texture, GL_READ_FRAMEBUFFER); |
| 1800 | 1831 |
| 1801 // If the deleted was bound to the the current maximum index, trace backward
s to find the new max texture index | 1832 // If the deleted was bound to the the current maximum index, trace backward
s to find the new max texture index |
| 1802 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound
TextureIndex + 1)) { | 1833 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound
TextureIndex + 1)) { |
| 1803 findNewMaxNonDefaultTextureUnit(); | 1834 findNewMaxNonDefaultTextureUnit(); |
| 1804 } | 1835 } |
| 1805 } | 1836 } |
| 1806 | 1837 |
| 1807 void WebGLRenderingContextBase::depthFunc(GLenum func) | 1838 void WebGLRenderingContextBase::depthFunc(GLenum func) |
| 1808 { | 1839 { |
| 1809 if (isContextLost()) | 1840 if (isContextLost()) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t
arget"); | 2040 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t
arget"); |
| 2010 return; | 2041 return; |
| 2011 } | 2042 } |
| 2012 if (buffer && !buffer->validate(contextGroup(), this)) { | 2043 if (buffer && !buffer->validate(contextGroup(), this)) { |
| 2013 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b
uffer or buffer not from this context"); | 2044 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b
uffer or buffer not from this context"); |
| 2014 return; | 2045 return; |
| 2015 } | 2046 } |
| 2016 // Don't allow the default framebuffer to be mutated; all current | 2047 // Don't allow the default framebuffer to be mutated; all current |
| 2017 // implementations use an FBO internally in place of the default | 2048 // implementations use an FBO internally in place of the default |
| 2018 // FBO. | 2049 // FBO. |
| 2019 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2050 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
| 2051 if (!framebufferBinding || !framebufferBinding->object()) { |
| 2020 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f
ramebuffer bound"); | 2052 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f
ramebuffer bound"); |
| 2021 return; | 2053 return; |
| 2022 } | 2054 } |
| 2023 Platform3DObject bufferObject = objectOrZero(buffer); | 2055 Platform3DObject bufferObject = objectOrZero(buffer); |
| 2024 switch (attachment) { | 2056 switch (attachment) { |
| 2025 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 2057 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
| 2026 if (isDepthStencilSupported() || !buffer) { | 2058 if (isDepthStencilSupported() || !buffer) { |
| 2027 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r
enderbuffertarget, bufferObject); | 2059 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r
enderbuffertarget, bufferObject); |
| 2028 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT,
renderbuffertarget, bufferObject); | 2060 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT,
renderbuffertarget, bufferObject); |
| 2029 } else { | 2061 } else { |
| 2030 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(renderbuffertarget, buffer); | 2062 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(renderbuffertarget, buffer); |
| 2031 if (!emulatedStencilBuffer) { | 2063 if (!emulatedStencilBuffer) { |
| 2032 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", "
out of memory"); | 2064 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", "
out of memory"); |
| 2033 return; | 2065 return; |
| 2034 } | 2066 } |
| 2035 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r
enderbuffertarget, bufferObject); | 2067 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r
enderbuffertarget, bufferObject); |
| 2036 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT,
renderbuffertarget, objectOrZero(emulatedStencilBuffer)); | 2068 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT,
renderbuffertarget, objectOrZero(emulatedStencilBuffer)); |
| 2037 } | 2069 } |
| 2038 break; | 2070 break; |
| 2039 default: | 2071 default: |
| 2040 webContext()->framebufferRenderbuffer(target, attachment, renderbufferta
rget, bufferObject); | 2072 webContext()->framebufferRenderbuffer(target, attachment, renderbufferta
rget, bufferObject); |
| 2041 } | 2073 } |
| 2042 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); | 2074 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buf
fer); |
| 2043 applyStencilTest(); | 2075 applyStencilTest(); |
| 2044 } | 2076 } |
| 2045 | 2077 |
| 2046 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac
hment, GLenum textarget, WebGLTexture* texture, GLint level) | 2078 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac
hment, GLenum textarget, WebGLTexture* texture, GLint level) |
| 2047 { | 2079 { |
| 2048 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) | 2080 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) |
| 2049 return; | 2081 return; |
| 2050 if (level) { | 2082 if (level) { |
| 2051 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0
"); | 2083 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0
"); |
| 2052 return; | 2084 return; |
| 2053 } | 2085 } |
| 2054 if (texture && !texture->validate(contextGroup(), this)) { | 2086 if (texture && !texture->validate(contextGroup(), this)) { |
| 2055 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text
ure or texture not from this context"); | 2087 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text
ure or texture not from this context"); |
| 2056 return; | 2088 return; |
| 2057 } | 2089 } |
| 2058 // Don't allow the default framebuffer to be mutated; all current | 2090 // Don't allow the default framebuffer to be mutated; all current |
| 2059 // implementations use an FBO internally in place of the default | 2091 // implementations use an FBO internally in place of the default |
| 2060 // FBO. | 2092 // FBO. |
| 2061 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2093 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
| 2094 if (!framebufferBinding || !framebufferBinding->object()) { |
| 2062 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram
ebuffer bound"); | 2095 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram
ebuffer bound"); |
| 2063 return; | 2096 return; |
| 2064 } | 2097 } |
| 2065 Platform3DObject textureObject = objectOrZero(texture); | 2098 Platform3DObject textureObject = objectOrZero(texture); |
| 2066 switch (attachment) { | 2099 switch (attachment) { |
| 2067 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 2100 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
| 2068 webContext()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarge
t, textureObject, level); | 2101 webContext()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarge
t, textureObject, level); |
| 2069 webContext()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textar
get, textureObject, level); | 2102 webContext()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textar
get, textureObject, level); |
| 2070 break; | 2103 break; |
| 2071 case GL_DEPTH_ATTACHMENT: | |
| 2072 webContext()->framebufferTexture2D(target, attachment, textarget, textur
eObject, level); | |
| 2073 break; | |
| 2074 case GL_STENCIL_ATTACHMENT: | |
| 2075 webContext()->framebufferTexture2D(target, attachment, textarget, textur
eObject, level); | |
| 2076 break; | |
| 2077 default: | 2104 default: |
| 2078 webContext()->framebufferTexture2D(target, attachment, textarget, textur
eObject, level); | 2105 webContext()->framebufferTexture2D(target, attachment, textarget, textur
eObject, level); |
| 2079 } | 2106 } |
| 2080 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget
, texture, level); | 2107 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex
target, texture, level); |
| 2081 applyStencilTest(); | 2108 applyStencilTest(); |
| 2082 } | 2109 } |
| 2083 | 2110 |
| 2084 void WebGLRenderingContextBase::frontFace(GLenum mode) | 2111 void WebGLRenderingContextBase::frontFace(GLenum mode) |
| 2085 { | 2112 { |
| 2086 if (isContextLost()) | 2113 if (isContextLost()) |
| 2087 return; | 2114 return; |
| 2088 switch (mode) { | 2115 switch (mode) { |
| 2089 case GL_CW: | 2116 case GL_CW: |
| 2090 case GL_CCW: | 2117 case GL_CCW: |
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3324 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format/type n
ot RGBA/UNSIGNED_BYTE or implementation-defined values"); | 3351 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format/type n
ot RGBA/UNSIGNED_BYTE or implementation-defined values"); |
| 3325 return; | 3352 return; |
| 3326 } | 3353 } |
| 3327 } | 3354 } |
| 3328 // Validate array type against pixel type. | 3355 // Validate array type against pixel type. |
| 3329 if (pixels->type() != expectedViewType) { | 3356 if (pixels->type() != expectedViewType) { |
| 3330 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView w
as the wrong type for the pixel format"); | 3357 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView w
as the wrong type for the pixel format"); |
| 3331 return; | 3358 return; |
| 3332 } | 3359 } |
| 3333 const char* reason = "framebuffer incomplete"; | 3360 const char* reason = "framebuffer incomplete"; |
| 3334 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { | 3361 GLenum target = isWebGL2OrHigher() ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 3362 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(target); |
| 3363 if (readFramebufferBinding && !readFramebufferBinding->onAccess(webContext()
, target, &reason)) { |
| 3335 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason
); | 3364 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason
); |
| 3336 return; | 3365 return; |
| 3337 } | 3366 } |
| 3338 // Calculate array size, taking into consideration of PACK_ALIGNMENT. | 3367 // Calculate array size, taking into consideration of PACK_ALIGNMENT. |
| 3339 unsigned totalBytesRequired = 0; | 3368 unsigned totalBytesRequired = 0; |
| 3340 unsigned padding = 0; | 3369 unsigned padding = 0; |
| 3341 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, m_packAlignment, &totalBytesRequired, &padding); | 3370 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, m_packAlignment, &totalBytesRequired, &padding); |
| 3342 if (error != GL_NO_ERROR) { | 3371 if (error != GL_NO_ERROR) { |
| 3343 synthesizeGLError(error, "readPixels", "invalid dimensions"); | 3372 synthesizeGLError(error, "readPixels", "invalid dimensions"); |
| 3344 return; | 3373 return; |
| 3345 } | 3374 } |
| 3346 if (pixels->byteLength() < totalBytesRequired) { | 3375 if (pixels->byteLength() < totalBytesRequired) { |
| 3347 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot large enough for dimensions"); | 3376 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot large enough for dimensions"); |
| 3348 return; | 3377 return; |
| 3349 } | 3378 } |
| 3350 | 3379 |
| 3351 clearIfComposited(); | 3380 clearIfComposited(); |
| 3352 void* data = pixels->baseAddress(); | 3381 void* data = pixels->baseAddress(); |
| 3353 | 3382 |
| 3354 { | 3383 { |
| 3355 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.g
et()); | 3384 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding
, target); |
| 3356 webContext()->readPixels(x, y, width, height, format, type, data); | 3385 webContext()->readPixels(x, y, width, height, format, type, data); |
| 3357 } | 3386 } |
| 3358 | 3387 |
| 3359 #if OS(MACOSX) | 3388 #if OS(MACOSX) |
| 3360 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., | 3389 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., |
| 3361 // when alpha is off, readPixels should set alpha to 255 instead of 0. | 3390 // when alpha is off, readPixels should set alpha to 255 instead of 0. |
| 3362 if (!m_framebufferBinding && !drawingBuffer()->getActualAttributes().alpha)
{ | 3391 if (!readFramebufferBinding && !drawingBuffer()->getActualAttributes().alpha
) { |
| 3363 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); | 3392 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); |
| 3364 for (GLsizei iy = 0; iy < height; ++iy) { | 3393 for (GLsizei iy = 0; iy < height; ++iy) { |
| 3365 for (GLsizei ix = 0; ix < width; ++ix) { | 3394 for (GLsizei ix = 0; ix < width; ++ix) { |
| 3366 pixels[3] = 255; | 3395 pixels[3] = 255; |
| 3367 pixels += 4; | 3396 pixels += 4; |
| 3368 } | 3397 } |
| 3369 pixels += padding; | 3398 pixels += padding; |
| 3370 } | 3399 } |
| 3371 } | 3400 } |
| 3372 #endif | 3401 #endif |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4620 | 4649 |
| 4621 if (mode == RealLostContext) { | 4650 if (mode == RealLostContext) { |
| 4622 // Inform the embedder that a lost context was received. In response, th
e embedder might | 4651 // Inform the embedder that a lost context was received. In response, th
e embedder might |
| 4623 // decide to take action such as asking the user for permission to use W
ebGL again. | 4652 // decide to take action such as asking the user for permission to use W
ebGL again. |
| 4624 if (LocalFrame* frame = canvas()->document().frame()) | 4653 if (LocalFrame* frame = canvas()->document().frame()) |
| 4625 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph
icsResetStatusARB()); | 4654 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph
icsResetStatusARB()); |
| 4626 } | 4655 } |
| 4627 | 4656 |
| 4628 // Make absolutely sure we do not refer to an already-deleted texture or fra
mebuffer. | 4657 // Make absolutely sure we do not refer to an already-deleted texture or fra
mebuffer. |
| 4629 drawingBuffer()->setTexture2DBinding(0); | 4658 drawingBuffer()->setTexture2DBinding(0); |
| 4630 drawingBuffer()->setFramebufferBinding(0); | 4659 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0); |
| 4631 | 4660 |
| 4632 detachAndRemoveAllObjects(); | 4661 detachAndRemoveAllObjects(); |
| 4633 | 4662 |
| 4634 // Lose all the extensions. | 4663 // Lose all the extensions. |
| 4635 for (size_t i = 0; i < m_extensions.size(); ++i) { | 4664 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 4636 ExtensionTracker* tracker = m_extensions[i].get(); | 4665 ExtensionTracker* tracker = m_extensions[i].get(); |
| 4637 tracker->loseExtension(); | 4666 tracker->loseExtension(); |
| 4638 } | 4667 } |
| 4639 | 4668 |
| 4640 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) | 4669 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5715 if (!count) { | 5744 if (!count) { |
| 5716 markContextChanged(CanvasChanged); | 5745 markContextChanged(CanvasChanged); |
| 5717 return false; | 5746 return false; |
| 5718 } | 5747 } |
| 5719 | 5748 |
| 5720 if (!validateRenderingState(functionName)) { | 5749 if (!validateRenderingState(functionName)) { |
| 5721 return false; | 5750 return false; |
| 5722 } | 5751 } |
| 5723 | 5752 |
| 5724 const char* reason = "framebuffer incomplete"; | 5753 const char* reason = "framebuffer incomplete"; |
| 5725 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { | 5754 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL
_FRAMEBUFFER, &reason)) { |
| 5726 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); | 5755 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); |
| 5727 return false; | 5756 return false; |
| 5728 } | 5757 } |
| 5729 | 5758 |
| 5730 return true; | 5759 return true; |
| 5731 } | 5760 } |
| 5732 | 5761 |
| 5733 bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G
Lenum mode, GLsizei count, GLenum type, long long offset) | 5762 bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G
Lenum mode, GLsizei count, GLenum type, long long offset) |
| 5734 { | 5763 { |
| 5735 if (isContextLost() || !validateDrawMode(functionName, mode)) | 5764 if (isContextLost() || !validateDrawMode(functionName, mode)) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5767 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { | 5796 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { |
| 5768 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_
BUFFER bound"); | 5797 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_
BUFFER bound"); |
| 5769 return false; | 5798 return false; |
| 5770 } | 5799 } |
| 5771 | 5800 |
| 5772 if (!validateRenderingState(functionName)) { | 5801 if (!validateRenderingState(functionName)) { |
| 5773 return false; | 5802 return false; |
| 5774 } | 5803 } |
| 5775 | 5804 |
| 5776 const char* reason = "framebuffer incomplete"; | 5805 const char* reason = "framebuffer incomplete"; |
| 5777 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { | 5806 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL
_FRAMEBUFFER, &reason)) { |
| 5778 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); | 5807 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); |
| 5779 return false; | 5808 return false; |
| 5780 } | 5809 } |
| 5781 | 5810 |
| 5782 return true; | 5811 return true; |
| 5783 } | 5812 } |
| 5784 | 5813 |
| 5785 // Helper function to validate draw*Instanced calls | 5814 // Helper function to validate draw*Instanced calls |
| 5786 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName,
GLsizei primcount) | 5815 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName,
GLsizei primcount) |
| 5787 { | 5816 { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6107 | 6136 |
| 6108 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer*
buffer) | 6137 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer*
buffer) |
| 6109 { | 6138 { |
| 6110 if (buffer) | 6139 if (buffer) |
| 6111 buffer->setHasEverBeenBound(); | 6140 buffer->setHasEverBeenBound(); |
| 6112 | 6141 |
| 6113 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { | 6142 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { |
| 6114 m_framebufferBinding = buffer; | 6143 m_framebufferBinding = buffer; |
| 6115 applyStencilTest(); | 6144 applyStencilTest(); |
| 6116 } | 6145 } |
| 6117 drawingBuffer()->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); | 6146 drawingBuffer()->setFramebufferBinding(target, objectOrZero(getFramebufferBi
nding(target))); |
| 6118 | 6147 |
| 6119 if (!buffer) { | 6148 if (!buffer) { |
| 6120 // Instead of binding fb 0, bind the drawing buffer. | 6149 // Instead of binding fb 0, bind the drawing buffer. |
| 6121 drawingBuffer()->bind(target); | 6150 drawingBuffer()->bind(target); |
| 6122 } else { | 6151 } else { |
| 6123 webContext()->bindFramebuffer(target, buffer->object()); | 6152 webContext()->bindFramebuffer(target, buffer->object()); |
| 6124 } | 6153 } |
| 6125 } | 6154 } |
| 6126 | 6155 |
| 6127 void WebGLRenderingContextBase::restoreCurrentFramebuffer() | 6156 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6224 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; | 6253 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; |
| 6225 } | 6254 } |
| 6226 #else | 6255 #else |
| 6227 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6256 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6228 { | 6257 { |
| 6229 return m_drawingBuffer.get(); | 6258 return m_drawingBuffer.get(); |
| 6230 } | 6259 } |
| 6231 #endif | 6260 #endif |
| 6232 | 6261 |
| 6233 } // namespace blink | 6262 } // namespace blink |
| OLD | NEW |