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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 1120953002: WebGL 2: add read/write framebuffer binding points to related APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed zmo@'s feedback: WebGLFramebuffer::isBound need to be updated Created 5 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 /* 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (!desiredSize.isEmpty()) { 214 if (!desiredSize.isEmpty()) {
215 forciblyEvictedContexts().remove(0); 215 forciblyEvictedContexts().remove(0);
216 evictedContext->forceRestoreContext(); 216 evictedContext->forceRestoreContext();
217 } 217 }
218 break; 218 break;
219 } 219 }
220 } 220 }
221 221
222 namespace { 222 namespace {
223 223
224 // ScopedDrawingBufferBinder is used for ReadPixels/CopyTexImage2D/CopySubIm age2D to read from
225 // a multisampled DrawingBuffer. In this situation, we need to blit to a sin gle sampled buffer
226 // for reading, during which the bindings could be changed and need to be re covered.
224 class ScopedDrawingBufferBinder { 227 class ScopedDrawingBufferBinder {
225 STACK_ALLOCATED(); 228 STACK_ALLOCATED();
226 public: 229 public:
227 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding) 230 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding)
228 : m_drawingBuffer(drawingBuffer) 231 : m_drawingBuffer(drawingBuffer)
229 , m_framebufferBinding(framebufferBinding) 232 , m_readFramebufferBinding(framebufferBinding)
230 { 233 {
231 // Commit DrawingBuffer if needed (e.g., for multisampling) 234 // Commit DrawingBuffer if needed (e.g., for multisampling)
232 if (!m_framebufferBinding && m_drawingBuffer) 235 if (!m_readFramebufferBinding && m_drawingBuffer)
233 m_drawingBuffer->commit(); 236 m_drawingBuffer->commit();
234 } 237 }
235 238
236 ~ScopedDrawingBufferBinder() 239 ~ScopedDrawingBufferBinder()
237 { 240 {
238 // Restore DrawingBuffer if needed 241 // Restore DrawingBuffer if needed
239 if (!m_framebufferBinding && m_drawingBuffer) 242 if (!m_readFramebufferBinding && m_drawingBuffer)
240 m_drawingBuffer->bind(); 243 m_drawingBuffer->restoreFramebufferBindings();
241 } 244 }
242 245
243 private: 246 private:
244 DrawingBuffer* m_drawingBuffer; 247 DrawingBuffer* m_drawingBuffer;
245 RawPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding; 248 RawPtrWillBeMember<WebGLFramebuffer> m_readFramebufferBinding;
246 }; 249 };
247 250
248 GLint clamp(GLint value, GLint min, GLint max) 251 GLint clamp(GLint value, GLint min, GLint max)
249 { 252 {
250 if (value < min) 253 if (value < min)
251 value = min; 254 value = min;
252 if (value > max) 255 if (value > max)
253 value = max; 256 value = max;
254 return value; 257 return value;
255 } 258 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); 647 context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims);
645 648
646 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); 649 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context);
647 if (!buffer) { 650 if (!buffer) {
648 m_contextLostMode = SyntheticLostContext; 651 m_contextLostMode = SyntheticLostContext;
649 return; 652 return;
650 } 653 }
651 654
652 m_drawingBuffer = buffer.release(); 655 m_drawingBuffer = buffer.release();
653 656
654 drawingBuffer()->bind(); 657 drawingBuffer()->bind(GL_FRAMEBUFFER);
655 setupFlags(); 658 setupFlags();
656 } 659 }
657 660
658 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn Ptr<WebGraphicsContext3D> context) 661 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn Ptr<WebGraphicsContext3D> context)
659 { 662 {
660 WebGraphicsContext3D::Attributes attrs; 663 WebGraphicsContext3D::Attributes attrs;
661 attrs.alpha = m_requestedAttributes.alpha(); 664 attrs.alpha = m_requestedAttributes.alpha();
662 attrs.depth = m_requestedAttributes.depth(); 665 attrs.depth = m_requestedAttributes.depth();
663 attrs.stencil = m_requestedAttributes.stencil(); 666 attrs.stencil = m_requestedAttributes.stencil();
664 attrs.antialias = m_requestedAttributes.antialias(); 667 attrs.antialias = m_requestedAttributes.antialias();
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 webContext()->clearStencil(m_clearStencil & m_stencilMask); 908 webContext()->clearStencil(m_clearStencil & m_stencilMask);
906 else 909 else
907 webContext()->clearStencil(0); 910 webContext()->clearStencil(0);
908 clearMask |= GL_STENCIL_BUFFER_BIT; 911 clearMask |= GL_STENCIL_BUFFER_BIT;
909 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); 912 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF);
910 } 913 }
911 914
912 drawingBuffer()->clearFramebuffers(clearMask); 915 drawingBuffer()->clearFramebuffers(clearMask);
913 916
914 restoreStateAfterClear(); 917 restoreStateAfterClear();
915 if (m_framebufferBinding) 918 drawingBuffer()->restoreFramebufferBindings();
916 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer Binding.get()));
917 drawingBuffer()->setBufferClearNeeded(false); 919 drawingBuffer()->setBufferClearNeeded(false);
918 920
919 return combinedClear ? CombinedClear : JustClear; 921 return combinedClear ? CombinedClear : JustClear;
920 } 922 }
921 923
922 void WebGLRenderingContextBase::restoreStateAfterClear() 924 void WebGLRenderingContextBase::restoreStateAfterClear()
923 { 925 {
924 if (isContextLost()) 926 if (isContextLost())
925 return; 927 return;
926 928
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 width = clamp(width, 1, maxWidth); 1013 width = clamp(width, 1, maxWidth);
1012 height = clamp(height, 1, maxHeight); 1014 height = clamp(height, 1, maxHeight);
1013 1015
1014 // We don't have to mark the canvas as dirty, since the newly created image buffer will also start off 1016 // We don't have to mark the canvas as dirty, since the newly created image buffer will also start off
1015 // clear (and this matches what reshape will do). 1017 // clear (and this matches what reshape will do).
1016 drawingBuffer()->reset(IntSize(width, height)); 1018 drawingBuffer()->reset(IntSize(width, height));
1017 restoreStateAfterClear(); 1019 restoreStateAfterClear();
1018 1020
1019 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ eTextureUnit].m_texture2DBinding.get())); 1021 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ eTextureUnit].m_texture2DBinding.get()));
1020 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB inding.get())); 1022 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB inding.get()));
1021 if (m_framebufferBinding) 1023 drawingBuffer()->restoreFramebufferBindings();
1022 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer Binding.get()));
1023 } 1024 }
1024 1025
1025 int WebGLRenderingContextBase::drawingBufferWidth() const 1026 int WebGLRenderingContextBase::drawingBufferWidth() const
1026 { 1027 {
1027 return isContextLost() ? 0 : drawingBuffer()->size().width(); 1028 return isContextLost() ? 0 : drawingBuffer()->size().width();
1028 } 1029 }
1029 1030
1030 int WebGLRenderingContextBase::drawingBufferHeight() const 1031 int WebGLRenderingContextBase::drawingBufferHeight() const
1031 { 1032 {
1032 return isContextLost() ? 0 : drawingBuffer()->size().height(); 1033 return isContextLost() ? 0 : drawingBuffer()->size().height();
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1364
1364 bool WebGLRenderingContextBase::validateFramebufferTarget(GLenum target) 1365 bool WebGLRenderingContextBase::validateFramebufferTarget(GLenum target)
1365 { 1366 {
1366 if (target == GL_FRAMEBUFFER) 1367 if (target == GL_FRAMEBUFFER)
1367 return true; 1368 return true;
1368 return false; 1369 return false;
1369 } 1370 }
1370 1371
1371 WebGLFramebuffer* WebGLRenderingContextBase::getFramebufferBinding(GLenum target ) 1372 WebGLFramebuffer* WebGLRenderingContextBase::getFramebufferBinding(GLenum target )
1372 { 1373 {
1373 return m_framebufferBinding.get(); 1374 if (target == GL_FRAMEBUFFER)
1375 return m_framebufferBinding.get();
1376 return nullptr;
1374 } 1377 }
1375 1378
1376 GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) 1379 GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target)
1377 { 1380 {
1378 if (isContextLost()) 1381 if (isContextLost())
1379 return GL_FRAMEBUFFER_UNSUPPORTED; 1382 return GL_FRAMEBUFFER_UNSUPPORTED;
1380 if (!validateFramebufferTarget(target)) { 1383 if (!validateFramebufferTarget(target)) {
1381 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta rget"); 1384 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta rget");
1382 return 0; 1385 return 0;
1383 } 1386 }
1384 if (!getFramebufferBinding(target) || !getFramebufferBinding(target)->object ()) 1387 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
1388 if (!framebufferBinding || !framebufferBinding->object())
1385 return GL_FRAMEBUFFER_COMPLETE; 1389 return GL_FRAMEBUFFER_COMPLETE;
1386 const char* reason = "framebuffer incomplete"; 1390 const char* reason = "framebuffer incomplete";
1387 GLenum result = m_framebufferBinding->checkStatus(&reason); 1391 GLenum result = framebufferBinding->checkStatus(&reason);
1388 if (result != GL_FRAMEBUFFER_COMPLETE) { 1392 if (result != GL_FRAMEBUFFER_COMPLETE) {
1389 emitGLWarning("checkFramebufferStatus", reason); 1393 emitGLWarning("checkFramebufferStatus", reason);
1390 return result; 1394 return result;
1391 } 1395 }
1392 result = webContext()->checkFramebufferStatus(target); 1396 result = webContext()->checkFramebufferStatus(target);
1393 return result; 1397 return result;
1394 } 1398 }
1395 1399
1396 void WebGLRenderingContextBase::clear(GLbitfield mask) 1400 void WebGLRenderingContextBase::clear(GLbitfield mask)
1397 { 1401 {
1398 if (isContextLost()) 1402 if (isContextLost())
1399 return; 1403 return;
1400 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B IT)) { 1404 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B IT)) {
1401 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); 1405 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask");
1402 return; 1406 return;
1403 } 1407 }
1404 const char* reason = "framebuffer incomplete"; 1408 const char* reason = "framebuffer incomplete";
1405 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { 1409 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL _FRAMEBUFFER, &reason)) {
1406 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); 1410 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason);
1407 return; 1411 return;
1408 } 1412 }
1409 if (clearIfComposited(mask) != CombinedClear) 1413 if (clearIfComposited(mask) != CombinedClear)
1410 webContext()->clear(mask); 1414 webContext()->clear(mask);
1411 markContextChanged(CanvasChanged); 1415 markContextChanged(CanvasChanged);
1412 } 1416 }
1413 1417
1414 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl oat a) 1418 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl oat a)
1415 { 1419 {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 } 1560 }
1557 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) { 1561 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) {
1558 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i s incompatible format"); 1562 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i s incompatible format");
1559 return; 1563 return;
1560 } 1564 }
1561 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { 1565 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) {
1562 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow er of 2"); 1566 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow er of 2");
1563 return; 1567 return;
1564 } 1568 }
1565 const char* reason = "framebuffer incomplete"; 1569 const char* reason = "framebuffer incomplete";
1566 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { 1570 if ((m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), G L_FRAMEBUFFER, &reason))
1571 || (getFramebufferBinding(GL_READ_FRAMEBUFFER) && !getFramebufferBinding (GL_READ_FRAMEBUFFER)->onAccess(webContext(), GL_READ_FRAMEBUFFER, &reason))) {
Ken Russell (switch to Gerrit) 2015/06/20 00:08:42 I think more checks may be needed regarding the cu
yunchao 2015/06/23 08:54:26 I checked this in ES 3.0 spec. This indeed should
1567 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re ason); 1572 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re ason);
1568 return; 1573 return;
1569 } 1574 }
1570 clearIfComposited(); 1575 clearIfComposited();
1571 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get() ); 1576 GLenum framebufferTarget = isWebGL2OrHigher() ? GL_READ_FRAMEBUFFER : GL_FRA MEBUFFER;
1577 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(framebuffer Target);
1578 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding);
1572 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei ght, border); 1579 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei ght, border);
1573 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted. 1580 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted.
1574 tex->setLevelInfo(target, level, internalformat, width, height, 1, GL_UNSIGN ED_BYTE); 1581 tex->setLevelInfo(target, level, internalformat, width, height, 1, GL_UNSIGN ED_BYTE);
1575 } 1582 }
1576 1583
1577 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) 1584 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1578 { 1585 {
1579 if (isContextLost()) 1586 if (isContextLost())
1580 return; 1587 return;
1581 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) 1588 if (!validateTexFuncLevel("copyTexSubImage2D", target, level))
(...skipping 17 matching lines...) Expand all
1599 return; 1606 return;
1600 } 1607 }
1601 GLenum internalformat = tex->getInternalFormat(target, level); 1608 GLenum internalformat = tex->getInternalFormat(target, level);
1602 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) 1609 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat))
1603 return; 1610 return;
1604 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) { 1611 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) {
1605 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe r is incompatible format"); 1612 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe r is incompatible format");
1606 return; 1613 return;
1607 } 1614 }
1608 const char* reason = "framebuffer incomplete"; 1615 const char* reason = "framebuffer incomplete";
1609 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { 1616 if ((m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), G L_FRAMEBUFFER, &reason))
1617 || (getFramebufferBinding(GL_READ_FRAMEBUFFER) && !getFramebufferBinding (GL_READ_FRAMEBUFFER)->onAccess(webContext(), GL_READ_FRAMEBUFFER, &reason))) {
1610 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason); 1618 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason);
1611 return; 1619 return;
1612 } 1620 }
1613 clearIfComposited(); 1621 clearIfComposited();
1614 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get() ); 1622 GLenum framebufferTarget = isWebGL2OrHigher() ? GL_READ_FRAMEBUFFER : GL_FRA MEBUFFER;
1623 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(framebuffer Target);
1624 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding);
1615 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width , height); 1625 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width , height);
1616 } 1626 }
1617 1627
1618 PassRefPtrWillBeRawPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() 1628 PassRefPtrWillBeRawPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer()
1619 { 1629 {
1620 if (isContextLost()) 1630 if (isContextLost())
1621 return nullptr; 1631 return nullptr;
1622 RefPtrWillBeRawPtr<WebGLBuffer> o = WebGLBuffer::create(this); 1632 RefPtrWillBeRawPtr<WebGLBuffer> o = WebGLBuffer::create(this);
1623 addSharedObject(o.get()); 1633 addSharedObject(o.get());
1624 return o.release(); 1634 return o.release();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 return; 1734 return;
1725 removeBoundBuffer(buffer); 1735 removeBoundBuffer(buffer);
1726 } 1736 }
1727 1737
1728 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) 1738 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer)
1729 { 1739 {
1730 if (!deleteObject(framebuffer)) 1740 if (!deleteObject(framebuffer))
1731 return; 1741 return;
1732 if (framebuffer == m_framebufferBinding) { 1742 if (framebuffer == m_framebufferBinding) {
1733 m_framebufferBinding = nullptr; 1743 m_framebufferBinding = nullptr;
1734 drawingBuffer()->setFramebufferBinding(0); 1744 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0);
1735 // Have to call bindFramebuffer here to bind back to internal fbo. 1745 // Have to call drawingBuffer()->bind() here to bind back to internal fb o.
1736 drawingBuffer()->bind(); 1746 drawingBuffer()->bind(GL_FRAMEBUFFER);
1737 } 1747 }
1738 } 1748 }
1739 1749
1740 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) 1750 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program)
1741 { 1751 {
1742 deleteObject(program); 1752 deleteObject(program);
1743 // We don't reset m_currentProgram to 0 here because the deletion of the 1753 // We don't reset m_currentProgram to 0 here because the deletion of the
1744 // current program is delayed. 1754 // current program is delayed.
1745 } 1755 }
1746 1756
1747 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff er) 1757 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff er)
1748 { 1758 {
1749 if (!deleteObject(renderbuffer)) 1759 if (!deleteObject(renderbuffer))
1750 return; 1760 return;
1751 if (renderbuffer == m_renderbufferBinding) 1761 if (renderbuffer == m_renderbufferBinding)
1752 m_renderbufferBinding = nullptr; 1762 m_renderbufferBinding = nullptr;
1753 if (m_framebufferBinding) 1763 if (m_framebufferBinding)
1754 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer) ; 1764 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFE R, renderbuffer);
1765 if (getFramebufferBinding(GL_READ_FRAMEBUFFER))
1766 getFramebufferBinding(GL_READ_FRAMEBUFFER)->removeAttachmentFromBoundFra mebuffer(GL_READ_FRAMEBUFFER, renderbuffer);
1755 } 1767 }
1756 1768
1757 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) 1769 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader)
1758 { 1770 {
1759 deleteObject(shader); 1771 deleteObject(shader);
1760 } 1772 }
1761 1773
1762 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) 1774 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture)
1763 { 1775 {
1764 if (!deleteObject(texture)) 1776 if (!deleteObject(texture))
(...skipping 16 matching lines...) Expand all
1781 m_textureUnits[i].m_texture3DBinding = nullptr; 1793 m_textureUnits[i].m_texture3DBinding = nullptr;
1782 maxBoundTextureIndex = i; 1794 maxBoundTextureIndex = i;
1783 } 1795 }
1784 if (texture == m_textureUnits[i].m_texture2DArrayBinding) { 1796 if (texture == m_textureUnits[i].m_texture2DArrayBinding) {
1785 m_textureUnits[i].m_texture2DArrayBinding = nullptr; 1797 m_textureUnits[i].m_texture2DArrayBinding = nullptr;
1786 maxBoundTextureIndex = i; 1798 maxBoundTextureIndex = i;
1787 } 1799 }
1788 } 1800 }
1789 } 1801 }
1790 if (m_framebufferBinding) 1802 if (m_framebufferBinding)
1791 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); 1803 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFE R, texture);
1804 if (getFramebufferBinding(GL_READ_FRAMEBUFFER))
1805 getFramebufferBinding(GL_READ_FRAMEBUFFER)->removeAttachmentFromBoundFra mebuffer(GL_READ_FRAMEBUFFER, texture);
1792 1806
1793 // If the deleted was bound to the the current maximum index, trace backward s to find the new max texture index 1807 // If the deleted was bound to the the current maximum index, trace backward s to find the new max texture index
1794 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound TextureIndex + 1)) { 1808 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound TextureIndex + 1)) {
1795 findNewMaxNonDefaultTextureUnit(); 1809 findNewMaxNonDefaultTextureUnit();
1796 } 1810 }
1797 } 1811 }
1798 1812
1799 void WebGLRenderingContextBase::depthFunc(GLenum func) 1813 void WebGLRenderingContextBase::depthFunc(GLenum func)
1800 { 1814 {
1801 if (isContextLost()) 1815 if (isContextLost())
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); 2015 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget");
2002 return; 2016 return;
2003 } 2017 }
2004 if (buffer && !buffer->validate(contextGroup(), this)) { 2018 if (buffer && !buffer->validate(contextGroup(), this)) {
2005 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); 2019 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context");
2006 return; 2020 return;
2007 } 2021 }
2008 // Don't allow the default framebuffer to be mutated; all current 2022 // Don't allow the default framebuffer to be mutated; all current
2009 // implementations use an FBO internally in place of the default 2023 // implementations use an FBO internally in place of the default
2010 // FBO. 2024 // FBO.
2011 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2025 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
2026 if (!framebufferBinding || !framebufferBinding->object()) {
2012 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f ramebuffer bound"); 2027 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f ramebuffer bound");
2013 return; 2028 return;
2014 } 2029 }
2015 Platform3DObject bufferObject = objectOrZero(buffer); 2030 Platform3DObject bufferObject = objectOrZero(buffer);
2016 switch (attachment) { 2031 switch (attachment) {
2017 case GL_DEPTH_STENCIL_ATTACHMENT: 2032 case GL_DEPTH_STENCIL_ATTACHMENT:
2018 if (isDepthStencilSupported() || !buffer) { 2033 if (isDepthStencilSupported() || !buffer) {
2019 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r enderbuffertarget, bufferObject); 2034 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r enderbuffertarget, bufferObject);
2020 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, bufferObject); 2035 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, bufferObject);
2021 } else { 2036 } else {
2022 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(renderbuffertarget, buffer); 2037 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(renderbuffertarget, buffer);
2023 if (!emulatedStencilBuffer) { 2038 if (!emulatedStencilBuffer) {
2024 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", " out of memory"); 2039 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", " out of memory");
2025 return; 2040 return;
2026 } 2041 }
2027 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r enderbuffertarget, bufferObject); 2042 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r enderbuffertarget, bufferObject);
2028 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); 2043 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer));
2029 } 2044 }
2030 break; 2045 break;
2031 default: 2046 default:
2032 webContext()->framebufferRenderbuffer(target, attachment, renderbufferta rget, bufferObject); 2047 webContext()->framebufferRenderbuffer(target, attachment, renderbufferta rget, bufferObject);
2033 } 2048 }
2034 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); 2049 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buf fer);
2035 applyStencilTest(); 2050 applyStencilTest();
2036 } 2051 }
2037 2052
2038 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level) 2053 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level)
2039 { 2054 {
2040 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) 2055 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment))
2041 return; 2056 return;
2042 if (level) { 2057 if (level) {
2043 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); 2058 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 ");
2044 return; 2059 return;
2045 } 2060 }
2046 if (texture && !texture->validate(contextGroup(), this)) { 2061 if (texture && !texture->validate(contextGroup(), this)) {
2047 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text ure or texture not from this context"); 2062 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text ure or texture not from this context");
2048 return; 2063 return;
2049 } 2064 }
2050 // Don't allow the default framebuffer to be mutated; all current 2065 // Don't allow the default framebuffer to be mutated; all current
2051 // implementations use an FBO internally in place of the default 2066 // implementations use an FBO internally in place of the default
2052 // FBO. 2067 // FBO.
2053 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2068 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
2069 if (!framebufferBinding || !framebufferBinding->object()) {
2054 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram ebuffer bound"); 2070 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram ebuffer bound");
2055 return; 2071 return;
2056 } 2072 }
2057 Platform3DObject textureObject = objectOrZero(texture); 2073 Platform3DObject textureObject = objectOrZero(texture);
2058 switch (attachment) { 2074 switch (attachment) {
2059 case GL_DEPTH_STENCIL_ATTACHMENT: 2075 case GL_DEPTH_STENCIL_ATTACHMENT:
2060 webContext()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarge t, textureObject, level); 2076 webContext()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarge t, textureObject, level);
2061 webContext()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textar get, textureObject, level); 2077 webContext()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textar get, textureObject, level);
2062 break; 2078 break;
2063 case GL_DEPTH_ATTACHMENT: 2079 case GL_DEPTH_ATTACHMENT:
2064 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); 2080 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level);
2065 break; 2081 break;
2066 case GL_STENCIL_ATTACHMENT: 2082 case GL_STENCIL_ATTACHMENT:
2067 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); 2083 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level);
2068 break; 2084 break;
2069 default: 2085 default:
2070 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); 2086 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level);
2071 } 2087 }
2072 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level); 2088 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level);
2073 applyStencilTest(); 2089 applyStencilTest();
2074 } 2090 }
2075 2091
2076 void WebGLRenderingContextBase::frontFace(GLenum mode) 2092 void WebGLRenderingContextBase::frontFace(GLenum mode)
2077 { 2093 {
2078 if (isContextLost()) 2094 if (isContextLost())
2079 return; 2095 return;
2080 switch (mode) { 2096 switch (mode) {
2081 case GL_CW: 2097 case GL_CW:
2082 case GL_CCW: 2098 case GL_CCW:
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format/type n ot RGBA/UNSIGNED_BYTE or implementation-defined values"); 3332 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format/type n ot RGBA/UNSIGNED_BYTE or implementation-defined values");
3317 return; 3333 return;
3318 } 3334 }
3319 } 3335 }
3320 // Validate array type against pixel type. 3336 // Validate array type against pixel type.
3321 if (pixels->type() != expectedViewType) { 3337 if (pixels->type() != expectedViewType) {
3322 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView w as the wrong type for the pixel format"); 3338 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView w as the wrong type for the pixel format");
3323 return; 3339 return;
3324 } 3340 }
3325 const char* reason = "framebuffer incomplete"; 3341 const char* reason = "framebuffer incomplete";
3326 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { 3342 GLenum target = isWebGL2OrHigher() ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
3343 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(target);
3344 if (readFramebufferBinding && !readFramebufferBinding->onAccess(webContext() , target, &reason)) {
3327 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason ); 3345 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason );
3328 return; 3346 return;
3329 } 3347 }
3330 // Calculate array size, taking into consideration of PACK_ALIGNMENT. 3348 // Calculate array size, taking into consideration of PACK_ALIGNMENT.
3331 unsigned totalBytesRequired = 0; 3349 unsigned totalBytesRequired = 0;
3332 unsigned padding = 0; 3350 unsigned padding = 0;
3333 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w idth, height, m_packAlignment, &totalBytesRequired, &padding); 3351 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w idth, height, m_packAlignment, &totalBytesRequired, &padding);
3334 if (error != GL_NO_ERROR) { 3352 if (error != GL_NO_ERROR) {
3335 synthesizeGLError(error, "readPixels", "invalid dimensions"); 3353 synthesizeGLError(error, "readPixels", "invalid dimensions");
3336 return; 3354 return;
3337 } 3355 }
3338 if (pixels->byteLength() < totalBytesRequired) { 3356 if (pixels->byteLength() < totalBytesRequired) {
3339 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n ot large enough for dimensions"); 3357 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n ot large enough for dimensions");
3340 return; 3358 return;
3341 } 3359 }
3342 3360
3343 clearIfComposited(); 3361 clearIfComposited();
3344 void* data = pixels->baseAddress(); 3362 void* data = pixels->baseAddress();
3345 3363
3346 { 3364 {
3347 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.g et()); 3365 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding );
3348 webContext()->readPixels(x, y, width, height, format, type, data); 3366 webContext()->readPixels(x, y, width, height, format, type, data);
3349 } 3367 }
3350 3368
3351 #if OS(MACOSX) 3369 #if OS(MACOSX)
3352 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., 3370 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e.,
3353 // when alpha is off, readPixels should set alpha to 255 instead of 0. 3371 // when alpha is off, readPixels should set alpha to 255 instead of 0.
3354 if (!m_framebufferBinding && !drawingBuffer()->getActualAttributes().alpha) { 3372 if (!readFramebufferBinding && !drawingBuffer()->getActualAttributes().alpha ) {
3355 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); 3373 unsigned char* pixels = reinterpret_cast<unsigned char*>(data);
3356 for (GLsizei iy = 0; iy < height; ++iy) { 3374 for (GLsizei iy = 0; iy < height; ++iy) {
3357 for (GLsizei ix = 0; ix < width; ++ix) { 3375 for (GLsizei ix = 0; ix < width; ++ix) {
3358 pixels[3] = 255; 3376 pixels[3] = 255;
3359 pixels += 4; 3377 pixels += 4;
3360 } 3378 }
3361 pixels += padding; 3379 pixels += padding;
3362 } 3380 }
3363 } 3381 }
3364 #endif 3382 #endif
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
4623 4641
4624 if (mode == RealLostContext) { 4642 if (mode == RealLostContext) {
4625 // Inform the embedder that a lost context was received. In response, th e embedder might 4643 // Inform the embedder that a lost context was received. In response, th e embedder might
4626 // decide to take action such as asking the user for permission to use W ebGL again. 4644 // decide to take action such as asking the user for permission to use W ebGL again.
4627 if (LocalFrame* frame = canvas()->document().frame()) 4645 if (LocalFrame* frame = canvas()->document().frame())
4628 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph icsResetStatusARB()); 4646 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph icsResetStatusARB());
4629 } 4647 }
4630 4648
4631 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. 4649 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer.
4632 drawingBuffer()->setTexture2DBinding(0); 4650 drawingBuffer()->setTexture2DBinding(0);
4633 drawingBuffer()->setFramebufferBinding(0); 4651 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0);
4634 4652
4635 detachAndRemoveAllObjects(); 4653 detachAndRemoveAllObjects();
4636 4654
4637 // Lose all the extensions. 4655 // Lose all the extensions.
4638 for (size_t i = 0; i < m_extensions.size(); ++i) { 4656 for (size_t i = 0; i < m_extensions.size(); ++i) {
4639 ExtensionTracker* tracker = m_extensions[i].get(); 4657 ExtensionTracker* tracker = m_extensions[i].get();
4640 tracker->loseExtension(); 4658 tracker->loseExtension();
4641 } 4659 }
4642 4660
4643 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) 4661 for (size_t i = 0; i < WebGLExtensionNameCount; ++i)
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
5726 if (!count) { 5744 if (!count) {
5727 markContextChanged(CanvasChanged); 5745 markContextChanged(CanvasChanged);
5728 return false; 5746 return false;
5729 } 5747 }
5730 5748
5731 if (!validateRenderingState(functionName)) { 5749 if (!validateRenderingState(functionName)) {
5732 return false; 5750 return false;
5733 } 5751 }
5734 5752
5735 const char* reason = "framebuffer incomplete"; 5753 const char* reason = "framebuffer incomplete";
5736 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { 5754 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL _FRAMEBUFFER, &reason)) {
5737 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason ); 5755 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason );
5738 return false; 5756 return false;
5739 } 5757 }
5740 5758
5741 return true; 5759 return true;
5742 } 5760 }
5743 5761
5744 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)
5745 { 5763 {
5746 if (isContextLost() || !validateDrawMode(functionName, mode)) 5764 if (isContextLost() || !validateDrawMode(functionName, mode))
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5778 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { 5796 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) {
5779 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_ BUFFER bound"); 5797 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_ BUFFER bound");
5780 return false; 5798 return false;
5781 } 5799 }
5782 5800
5783 if (!validateRenderingState(functionName)) { 5801 if (!validateRenderingState(functionName)) {
5784 return false; 5802 return false;
5785 } 5803 }
5786 5804
5787 const char* reason = "framebuffer incomplete"; 5805 const char* reason = "framebuffer incomplete";
5788 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { 5806 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL _FRAMEBUFFER, &reason)) {
5789 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason ); 5807 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason );
5790 return false; 5808 return false;
5791 } 5809 }
5792 5810
5793 return true; 5811 return true;
5794 } 5812 }
5795 5813
5796 // Helper function to validate draw*Instanced calls 5814 // Helper function to validate draw*Instanced calls
5797 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName, GLsizei primcount) 5815 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName, GLsizei primcount)
5798 { 5816 {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
5936 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE ); 5954 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE );
5937 } else { 5955 } else {
5938 // This likely shouldn't happen but is the best way to report it to the WebGL app. 5956 // This likely shouldn't happen but is the best way to report it to the WebGL app.
5939 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); 5957 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context ");
5940 } 5958 }
5941 return; 5959 return;
5942 } 5960 }
5943 5961
5944 m_drawingBuffer = buffer.release(); 5962 m_drawingBuffer = buffer.release();
5945 5963
5946 drawingBuffer()->bind(); 5964 drawingBuffer()->bind(GL_FRAMEBUFFER);
5947 m_lostContextErrors.clear(); 5965 m_lostContextErrors.clear();
5948 m_contextLostMode = NotLostContext; 5966 m_contextLostMode = NotLostContext;
5949 m_autoRecoveryMethod = Manual; 5967 m_autoRecoveryMethod = Manual;
5950 m_restoreAllowed = false; 5968 m_restoreAllowed = false;
5951 removeFromEvictedList(this); 5969 removeFromEvictedList(this);
5952 5970
5953 setupFlags(); 5971 setupFlags();
5954 initializeNewContext(); 5972 initializeNewContext();
5955 markContextChanged(CanvasContextChanged); 5973 markContextChanged(CanvasContextChanged);
5956 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, "")); 5974 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, ""));
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
6107 6125
6108 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* buffer) 6126 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* buffer)
6109 { 6127 {
6110 if (buffer) 6128 if (buffer)
6111 buffer->setHasEverBeenBound(); 6129 buffer->setHasEverBeenBound();
6112 6130
6113 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { 6131 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) {
6114 m_framebufferBinding = buffer; 6132 m_framebufferBinding = buffer;
6115 applyStencilTest(); 6133 applyStencilTest();
6116 } 6134 }
6117 drawingBuffer()->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ())); 6135 drawingBuffer()->setFramebufferBinding(target, objectOrZero(getFramebufferBi nding(target)));
6118 6136
6119 if (!buffer) { 6137 if (!buffer) {
6120 // Instead of binding fb 0, bind the drawing buffer. 6138 // Instead of binding fb 0, bind the drawing buffer.
6121 drawingBuffer()->bind(target); 6139 drawingBuffer()->bind(target);
6122 } else { 6140 } else {
6123 webContext()->bindFramebuffer(target, buffer->object()); 6141 webContext()->bindFramebuffer(target, buffer->object());
6124 } 6142 }
6125 } 6143 }
6126 6144
6127 void WebGLRenderingContextBase::restoreCurrentFramebuffer() 6145 void WebGLRenderingContextBase::restoreCurrentFramebuffer()
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
6212 6230
6213 return totalBytesPerPixel; 6231 return totalBytesPerPixel;
6214 } 6232 }
6215 6233
6216 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6234 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6217 { 6235 {
6218 return m_drawingBuffer.get(); 6236 return m_drawingBuffer.get();
6219 } 6237 }
6220 6238
6221 } // namespace blink 6239 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698