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

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

Issue 2402273002: DrawingBuffer: Clean up GL state restoration (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 std::move(drawingBuffer()->transferToStaticBitmapImage()), 707 std::move(drawingBuffer()->transferToStaticBitmapImage()),
708 drawingBuffer()->contextProvider()->isSoftwareRendering()); 708 drawingBuffer()->contextProvider()->isSoftwareRendering());
709 } 709 }
710 710
711 PassRefPtr<Image> WebGLRenderingContextBase::getImage( 711 PassRefPtr<Image> WebGLRenderingContextBase::getImage(
712 AccelerationHint hint, 712 AccelerationHint hint,
713 SnapshotReason reason) const { 713 SnapshotReason reason) const {
714 if (!drawingBuffer()) 714 if (!drawingBuffer())
715 return nullptr; 715 return nullptr;
716 716
717 drawingBuffer()->commit(); 717 drawingBuffer()->resolveAndBindForReadAndDraw();
718 IntSize size = clampedCanvasSize(); 718 IntSize size = clampedCanvasSize();
719 OpacityMode opacityMode = 719 OpacityMode opacityMode =
720 creationAttributes().hasAlpha() ? NonOpaque : Opaque; 720 creationAttributes().hasAlpha() ? NonOpaque : Opaque;
721 std::unique_ptr<AcceleratedImageBufferSurface> surface = 721 std::unique_ptr<AcceleratedImageBufferSurface> surface =
722 wrapUnique(new AcceleratedImageBufferSurface(size, opacityMode)); 722 wrapUnique(new AcceleratedImageBufferSurface(size, opacityMode));
723 if (!surface->isValid()) 723 if (!surface->isValid())
724 return nullptr; 724 return nullptr;
725 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface)); 725 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface));
726 if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), 726 if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(),
727 BackBuffer)) { 727 BackBuffer)) {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 : DrawingBuffer::Discard; 1046 : DrawingBuffer::Discard;
1047 DrawingBuffer::WebGLVersion webGLVersion = DrawingBuffer::WebGL1; 1047 DrawingBuffer::WebGLVersion webGLVersion = DrawingBuffer::WebGL1;
1048 if (version() == 1) { 1048 if (version() == 1) {
1049 webGLVersion = DrawingBuffer::WebGL1; 1049 webGLVersion = DrawingBuffer::WebGL1;
1050 } else if (version() == 2) { 1050 } else if (version() == 2) {
1051 webGLVersion = DrawingBuffer::WebGL2; 1051 webGLVersion = DrawingBuffer::WebGL2;
1052 } else { 1052 } else {
1053 NOTREACHED(); 1053 NOTREACHED();
1054 } 1054 }
1055 return DrawingBuffer::create( 1055 return DrawingBuffer::create(
1056 std::move(contextProvider), clampedCanvasSize(), premultipliedAlpha, 1056 std::move(contextProvider), this, clampedCanvasSize(), premultipliedAlpha,
1057 wantAlphaChannel, wantDepthBuffer, wantStencilBuffer, wantAntialiasing, 1057 wantAlphaChannel, wantDepthBuffer, wantStencilBuffer, wantAntialiasing,
1058 preserve, webGLVersion, chromiumImageUsage); 1058 preserve, webGLVersion, chromiumImageUsage);
1059 } 1059 }
1060 1060
1061 void WebGLRenderingContextBase::initializeNewContext() { 1061 void WebGLRenderingContextBase::initializeNewContext() {
1062 ASSERT(!isContextLost()); 1062 ASSERT(!isContextLost());
1063 ASSERT(drawingBuffer()); 1063 ASSERT(drawingBuffer());
1064 1064
1065 m_markedCanvasDirty = false; 1065 m_markedCanvasDirty = false;
1066 m_activeTextureUnit = 0; 1066 m_activeTextureUnit = 0;
(...skipping 10 matching lines...) Expand all
1077 m_stencilEnabled = false; 1077 m_stencilEnabled = false;
1078 m_stencilMask = 0xFFFFFFFF; 1078 m_stencilMask = 0xFFFFFFFF;
1079 m_stencilMaskBack = 0xFFFFFFFF; 1079 m_stencilMaskBack = 0xFFFFFFFF;
1080 m_stencilFuncRef = 0; 1080 m_stencilFuncRef = 0;
1081 m_stencilFuncRefBack = 0; 1081 m_stencilFuncRefBack = 0;
1082 m_stencilFuncMask = 0xFFFFFFFF; 1082 m_stencilFuncMask = 0xFFFFFFFF;
1083 m_stencilFuncMaskBack = 0xFFFFFFFF; 1083 m_stencilFuncMaskBack = 0xFFFFFFFF;
1084 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; 1084 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole;
1085 1085
1086 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; 1086 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0;
1087 drawingBuffer()->setClearColor(m_clearColor);
1088 m_scissorEnabled = false; 1087 m_scissorEnabled = false;
1089 m_clearDepth = 1; 1088 m_clearDepth = 1;
1090 m_clearStencil = 0; 1089 m_clearStencil = 0;
1091 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; 1090 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true;
1092 drawingBuffer()->setColorMask(m_colorMask);
1093 1091
1094 GLint numCombinedTextureImageUnits = 0; 1092 GLint numCombinedTextureImageUnits = 0;
1095 contextGL()->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 1093 contextGL()->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
1096 &numCombinedTextureImageUnits); 1094 &numCombinedTextureImageUnits);
1097 m_textureUnits.clear(); 1095 m_textureUnits.clear();
1098 m_textureUnits.resize(numCombinedTextureImageUnits); 1096 m_textureUnits.resize(numCombinedTextureImageUnits);
1099 1097
1100 GLint numVertexAttribs = 0; 1098 GLint numVertexAttribs = 0;
1101 contextGL()->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); 1099 contextGL()->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs);
1102 m_maxVertexAttribs = numVertexAttribs; 1100 m_maxVertexAttribs = numVertexAttribs;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 else 1366 else
1369 contextGL()->ClearStencil(0); 1367 contextGL()->ClearStencil(0);
1370 clearMask |= GL_STENCIL_BUFFER_BIT; 1368 clearMask |= GL_STENCIL_BUFFER_BIT;
1371 contextGL()->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); 1369 contextGL()->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF);
1372 } 1370 }
1373 1371
1374 contextGL()->ColorMask( 1372 contextGL()->ColorMask(
1375 true, true, true, 1373 true, true, true,
1376 !drawingBuffer()->defaultBufferRequiresAlphaChannelToBePreserved()); 1374 !drawingBuffer()->defaultBufferRequiresAlphaChannelToBePreserved());
1377 drawingBuffer()->clearFramebuffers(clearMask); 1375 drawingBuffer()->clearFramebuffers(clearMask);
1378
1379 restoreStateAfterClear();
1380 drawingBuffer()->restoreFramebufferBindings();
1381 drawingBuffer()->setBufferClearNeeded(false); 1376 drawingBuffer()->setBufferClearNeeded(false);
1382 1377
1383 return combinedClear ? CombinedClear : JustClear; 1378 return combinedClear ? CombinedClear : JustClear;
1384 } 1379 }
1385 1380
1386 void WebGLRenderingContextBase::restoreScissorEnabled() { 1381 void WebGLRenderingContextBase::restoreScissorEnabled() {
1387 if (isContextLost()) 1382 if (isContextLost())
1388 return; 1383 return;
1389 1384
1390 if (m_scissorEnabled) { 1385 if (m_scissorEnabled) {
(...skipping 12 matching lines...) Expand all
1403 } 1398 }
1404 1399
1405 void WebGLRenderingContextBase::restoreClearColor() { 1400 void WebGLRenderingContextBase::restoreClearColor() {
1406 if (isContextLost()) 1401 if (isContextLost())
1407 return; 1402 return;
1408 1403
1409 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], 1404 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2],
1410 m_clearColor[3]); 1405 m_clearColor[3]);
1411 } 1406 }
1412 1407
1413 void WebGLRenderingContextBase::restoreClearDepthf() {
1414 if (isContextLost())
1415 return;
1416
1417 contextGL()->ClearDepthf(m_clearDepth);
1418 }
1419
1420 void WebGLRenderingContextBase::restoreClearStencil() {
1421 if (isContextLost())
1422 return;
1423
1424 contextGL()->ClearStencil(m_clearStencil);
1425 }
1426
1427 void WebGLRenderingContextBase::restoreStencilMaskSeparate() {
1428 if (isContextLost())
1429 return;
1430
1431 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask);
1432 }
1433
1434 void WebGLRenderingContextBase::restoreColorMask() { 1408 void WebGLRenderingContextBase::restoreColorMask() {
1435 if (isContextLost()) 1409 if (isContextLost())
1436 return; 1410 return;
1437 1411
1438 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], 1412 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2],
1439 m_colorMask[3]); 1413 m_colorMask[3]);
1440 } 1414 }
1441 1415
1442 void WebGLRenderingContextBase::restoreDepthMask() {
1443 if (isContextLost())
1444 return;
1445
1446 contextGL()->DepthMask(m_depthMask);
1447 }
1448
1449 void WebGLRenderingContextBase::restoreStateAfterClear() {
1450 // Restore clear-related state items back to what the context had set.
1451 restoreScissorEnabled();
1452 restoreClearColor();
1453 restoreColorMask();
1454 restoreClearDepthf();
1455 restoreClearStencil();
1456 restoreStencilMaskSeparate();
1457 restoreDepthMask();
1458 }
1459
1460 void WebGLRenderingContextBase::markLayerComposited() { 1416 void WebGLRenderingContextBase::markLayerComposited() {
1461 if (!isContextLost()) 1417 if (!isContextLost())
1462 drawingBuffer()->setBufferClearNeeded(true); 1418 drawingBuffer()->setBufferClearNeeded(true);
1463 } 1419 }
1464 1420
1465 void WebGLRenderingContextBase::setIsHidden(bool hidden) { 1421 void WebGLRenderingContextBase::setIsHidden(bool hidden) {
1466 m_isHidden = hidden; 1422 m_isHidden = hidden;
1467 if (drawingBuffer()) 1423 if (drawingBuffer())
1468 drawingBuffer()->setIsHidden(hidden); 1424 drawingBuffer()->setIsHidden(hidden);
1469 1425
(...skipping 15 matching lines...) Expand all
1485 1441
1486 canvas()->clearCopiedImage(); 1442 canvas()->clearCopiedImage();
1487 m_markedCanvasDirty = false; 1443 m_markedCanvasDirty = false;
1488 1444
1489 if (!canvas()->buffer()) 1445 if (!canvas()->buffer())
1490 return false; 1446 return false;
1491 1447
1492 ScopedTexture2DRestorer restorer(this); 1448 ScopedTexture2DRestorer restorer(this);
1493 ScopedFramebufferRestorer fboRestorer(this); 1449 ScopedFramebufferRestorer fboRestorer(this);
1494 1450
1495 drawingBuffer()->commit(); 1451 drawingBuffer()->resolveAndBindForReadAndDraw();
1496 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer( 1452 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(
1497 drawingBuffer(), sourceBuffer)) { 1453 drawingBuffer(), sourceBuffer)) {
1498 // Currently, copyRenderingResultsFromDrawingBuffer is expected to always 1454 // Currently, copyRenderingResultsFromDrawingBuffer is expected to always
1499 // succeed because cases where canvas()-buffer() is not accelerated are 1455 // succeed because cases where canvas()-buffer() is not accelerated are
1500 // handle before reaching this point. If that assumption ever stops holding 1456 // handle before reaching this point. If that assumption ever stops holding
1501 // true, we may need to implement a fallback right here. 1457 // true, we may need to implement a fallback right here.
1502 ASSERT_NOT_REACHED(); 1458 ASSERT_NOT_REACHED();
1503 return false; 1459 return false;
1504 } 1460 }
1505 1461
1506 return true; 1462 return true;
1507 } 1463 }
1508 1464
1509 ImageData* WebGLRenderingContextBase::paintRenderingResultsToImageData( 1465 ImageData* WebGLRenderingContextBase::paintRenderingResultsToImageData(
1510 SourceDrawingBuffer sourceBuffer) { 1466 SourceDrawingBuffer sourceBuffer) {
1511 if (isContextLost()) 1467 if (isContextLost())
1512 return nullptr; 1468 return nullptr;
1513 if (creationAttributes().premultipliedAlpha()) 1469 if (creationAttributes().premultipliedAlpha())
1514 return nullptr; 1470 return nullptr;
1515 1471
1516 clearIfComposited(); 1472 clearIfComposited();
1517 drawingBuffer()->commit(); 1473 drawingBuffer()->resolveAndBindForReadAndDraw();
1518 ScopedFramebufferRestorer restorer(this); 1474 ScopedFramebufferRestorer restorer(this);
1519 int width, height; 1475 int width, height;
1520 WTF::ArrayBufferContents contents; 1476 WTF::ArrayBufferContents contents;
1521 if (!drawingBuffer()->paintRenderingResultsToImageData( 1477 if (!drawingBuffer()->paintRenderingResultsToImageData(
1522 width, height, sourceBuffer, contents)) 1478 width, height, sourceBuffer, contents))
1523 return nullptr; 1479 return nullptr;
1524 DOMArrayBuffer* imageDataPixels = DOMArrayBuffer::create(contents); 1480 DOMArrayBuffer* imageDataPixels = DOMArrayBuffer::create(contents);
1525 1481
1526 return ImageData::create( 1482 return ImageData::create(
1527 IntSize(width, height), 1483 IntSize(width, height),
(...skipping 27 matching lines...) Expand all
1555 // If we've exceeded the area limit scale the buffer down, preserving 1511 // If we've exceeded the area limit scale the buffer down, preserving
1556 // ascpect ratio, until it fits. 1512 // ascpect ratio, until it fits.
1557 float scaleFactor = 1513 float scaleFactor =
1558 sqrtf(static_cast<float>(maxArea) / static_cast<float>(currentArea)); 1514 sqrtf(static_cast<float>(maxArea) / static_cast<float>(currentArea));
1559 width = std::max(1, static_cast<int>(width * scaleFactor)); 1515 width = std::max(1, static_cast<int>(width * scaleFactor));
1560 height = std::max(1, static_cast<int>(height * scaleFactor)); 1516 height = std::max(1, static_cast<int>(height * scaleFactor));
1561 } 1517 }
1562 1518
1563 // We don't have to mark the canvas as dirty, since the newly created image 1519 // We don't have to mark the canvas as dirty, since the newly created image
1564 // buffer will also start off clear (and this matches what reshape will do). 1520 // buffer will also start off clear (and this matches what reshape will do).
1565 drawingBuffer()->reset(IntSize(width, height)); 1521 drawingBuffer()->resize(IntSize(width, height));
ccameron 2016/10/09 21:10:53 This callsite has the most sin of all of them...
1566 restoreStateAfterClear();
1567
1568 contextGL()->BindTexture(
ccameron 2016/10/09 21:10:53 Note that we already have the helper function WebG
1569 GL_TEXTURE_2D,
1570 objectOrZero(
1571 m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get()));
1572 contextGL()->BindRenderbuffer(GL_RENDERBUFFER,
ccameron 2016/10/09 21:10:54 This line is also precious, because we track the c
1573 objectOrZero(m_renderbufferBinding.get()));
1574 drawingBuffer()->restoreFramebufferBindings();
ccameron 2016/10/09 21:10:53 We already have a method WebGLRenderingContextBase
1575 drawingBuffer()->restorePixelUnpackBufferBindings();
1576 } 1522 }
1577 1523
1578 int WebGLRenderingContextBase::drawingBufferWidth() const { 1524 int WebGLRenderingContextBase::drawingBufferWidth() const {
1579 return isContextLost() ? 0 : drawingBuffer()->size().width(); 1525 return isContextLost() ? 0 : drawingBuffer()->size().width();
1580 } 1526 }
1581 1527
1582 int WebGLRenderingContextBase::drawingBufferHeight() const { 1528 int WebGLRenderingContextBase::drawingBufferHeight() const {
1583 return isContextLost() ? 0 : drawingBuffer()->size().height(); 1529 return isContextLost() ? 0 : drawingBuffer()->size().height();
1584 } 1530 }
1585 1531
1586 void WebGLRenderingContextBase::activeTexture(GLenum texture) { 1532 void WebGLRenderingContextBase::activeTexture(GLenum texture) {
1587 if (isContextLost()) 1533 if (isContextLost())
1588 return; 1534 return;
1589 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { 1535 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) {
1590 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", 1536 synthesizeGLError(GL_INVALID_ENUM, "activeTexture",
1591 "texture unit out of range"); 1537 "texture unit out of range");
1592 return; 1538 return;
1593 } 1539 }
1594 m_activeTextureUnit = texture - GL_TEXTURE0; 1540 m_activeTextureUnit = texture - GL_TEXTURE0;
1595 contextGL()->ActiveTexture(texture); 1541 contextGL()->ActiveTexture(texture);
1596
1597 drawingBuffer()->setActiveTextureUnit(texture);
1598 } 1542 }
1599 1543
1600 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, 1544 void WebGLRenderingContextBase::attachShader(WebGLProgram* program,
1601 WebGLShader* shader) { 1545 WebGLShader* shader) {
1602 if (isContextLost() || !validateWebGLObject("attachShader", program) || 1546 if (isContextLost() || !validateWebGLObject("attachShader", program) ||
1603 !validateWebGLObject("attachShader", shader)) 1547 !validateWebGLObject("attachShader", shader))
1604 return; 1548 return;
1605 if (!program->attachShader(shader)) { 1549 if (!program->attachShader(shader)) {
1606 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", 1550 synthesizeGLError(GL_INVALID_OPERATION, "attachShader",
1607 "shader attachment already has shader"); 1551 "shader attachment already has shader");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 bool deleted; 1623 bool deleted;
1680 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) 1624 if (!checkObjectToBeBound("bindBuffer", buffer, deleted))
1681 return; 1625 return;
1682 if (deleted) { 1626 if (deleted) {
1683 synthesizeGLError(GL_INVALID_OPERATION, "bindBuffer", 1627 synthesizeGLError(GL_INVALID_OPERATION, "bindBuffer",
1684 "attempt to bind a deleted buffer"); 1628 "attempt to bind a deleted buffer");
1685 return; 1629 return;
1686 } 1630 }
1687 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) 1631 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer))
1688 return; 1632 return;
1689
1690 if (target == GL_PIXEL_UNPACK_BUFFER) {
1691 drawingBuffer()->setPixelUnpackBufferBinding(objectOrZero(buffer));
1692 }
1693 contextGL()->BindBuffer(target, objectOrZero(buffer)); 1633 contextGL()->BindBuffer(target, objectOrZero(buffer));
1694 } 1634 }
1695 1635
1696 void WebGLRenderingContextBase::bindFramebuffer(GLenum target, 1636 void WebGLRenderingContextBase::bindFramebuffer(GLenum target,
1697 WebGLFramebuffer* buffer) { 1637 WebGLFramebuffer* buffer) {
1698 bool deleted; 1638 bool deleted;
1699 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) 1639 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted))
1700 return; 1640 return;
1701 if (deleted) { 1641 if (deleted) {
1702 synthesizeGLError(GL_INVALID_OPERATION, "bindFramebuffer", 1642 synthesizeGLError(GL_INVALID_OPERATION, "bindFramebuffer",
(...skipping 19 matching lines...) Expand all
1722 synthesizeGLError(GL_INVALID_OPERATION, "bindRenderbuffer", 1662 synthesizeGLError(GL_INVALID_OPERATION, "bindRenderbuffer",
1723 "attempt to bind a deleted renderbuffer"); 1663 "attempt to bind a deleted renderbuffer");
1724 return; 1664 return;
1725 } 1665 }
1726 if (target != GL_RENDERBUFFER) { 1666 if (target != GL_RENDERBUFFER) {
1727 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target"); 1667 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target");
1728 return; 1668 return;
1729 } 1669 }
1730 m_renderbufferBinding = renderBuffer; 1670 m_renderbufferBinding = renderBuffer;
1731 contextGL()->BindRenderbuffer(target, objectOrZero(renderBuffer)); 1671 contextGL()->BindRenderbuffer(target, objectOrZero(renderBuffer));
1732
1733 drawingBuffer()->setRenderbufferBinding(objectOrZero(renderBuffer));
1734
1735 if (renderBuffer) 1672 if (renderBuffer)
1736 renderBuffer->setHasEverBeenBound(); 1673 renderBuffer->setHasEverBeenBound();
1737 } 1674 }
1738 1675
1739 void WebGLRenderingContextBase::bindTexture(GLenum target, 1676 void WebGLRenderingContextBase::bindTexture(GLenum target,
1740 WebGLTexture* texture) { 1677 WebGLTexture* texture) {
1741 bool deleted; 1678 bool deleted;
1742 if (!checkObjectToBeBound("bindTexture", texture, deleted)) 1679 if (!checkObjectToBeBound("bindTexture", texture, deleted))
1743 return; 1680 return;
1744 if (deleted) { 1681 if (deleted) {
1745 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", 1682 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture",
1746 "attempt to bind a deleted texture"); 1683 "attempt to bind a deleted texture");
1747 return; 1684 return;
1748 } 1685 }
1749 if (texture && texture->getTarget() && texture->getTarget() != target) { 1686 if (texture && texture->getTarget() && texture->getTarget() != target) {
1750 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", 1687 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture",
1751 "textures can not be used with multiple targets"); 1688 "textures can not be used with multiple targets");
1752 return; 1689 return;
1753 } 1690 }
1754 1691
1755 if (target == GL_TEXTURE_2D) { 1692 if (target == GL_TEXTURE_2D) {
1756 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; 1693 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture;
1757
1758 if (!m_activeTextureUnit)
1759 drawingBuffer()->setTexture2DBinding(objectOrZero(texture));
1760 } else if (target == GL_TEXTURE_CUBE_MAP) { 1694 } else if (target == GL_TEXTURE_CUBE_MAP) {
1761 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; 1695 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture;
1762 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { 1696 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) {
1763 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; 1697 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture;
1764 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { 1698 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) {
1765 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; 1699 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture;
1766 } else { 1700 } else {
1767 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); 1701 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target");
1768 return; 1702 return;
1769 } 1703 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 if (std::isnan(g)) 1945 if (std::isnan(g))
2012 g = 0; 1946 g = 0;
2013 if (std::isnan(b)) 1947 if (std::isnan(b))
2014 b = 0; 1948 b = 0;
2015 if (std::isnan(a)) 1949 if (std::isnan(a))
2016 a = 1; 1950 a = 1;
2017 m_clearColor[0] = r; 1951 m_clearColor[0] = r;
2018 m_clearColor[1] = g; 1952 m_clearColor[1] = g;
2019 m_clearColor[2] = b; 1953 m_clearColor[2] = b;
2020 m_clearColor[3] = a; 1954 m_clearColor[3] = a;
2021 drawingBuffer()->setClearColor(m_clearColor);
2022 contextGL()->ClearColor(r, g, b, a); 1955 contextGL()->ClearColor(r, g, b, a);
2023 } 1956 }
2024 1957
2025 void WebGLRenderingContextBase::clearDepth(GLfloat depth) { 1958 void WebGLRenderingContextBase::clearDepth(GLfloat depth) {
2026 if (isContextLost()) 1959 if (isContextLost())
2027 return; 1960 return;
2028 m_clearDepth = depth; 1961 m_clearDepth = depth;
2029 contextGL()->ClearDepthf(depth); 1962 contextGL()->ClearDepthf(depth);
2030 } 1963 }
2031 1964
2032 void WebGLRenderingContextBase::clearStencil(GLint s) { 1965 void WebGLRenderingContextBase::clearStencil(GLint s) {
2033 if (isContextLost()) 1966 if (isContextLost())
2034 return; 1967 return;
2035 m_clearStencil = s; 1968 m_clearStencil = s;
2036 contextGL()->ClearStencil(s); 1969 contextGL()->ClearStencil(s);
2037 } 1970 }
2038 1971
2039 void WebGLRenderingContextBase::colorMask(GLboolean red, 1972 void WebGLRenderingContextBase::colorMask(GLboolean red,
2040 GLboolean green, 1973 GLboolean green,
2041 GLboolean blue, 1974 GLboolean blue,
2042 GLboolean alpha) { 1975 GLboolean alpha) {
2043 if (isContextLost()) 1976 if (isContextLost())
2044 return; 1977 return;
2045 m_colorMask[0] = red; 1978 m_colorMask[0] = red;
2046 m_colorMask[1] = green; 1979 m_colorMask[1] = green;
2047 m_colorMask[2] = blue; 1980 m_colorMask[2] = blue;
2048 m_colorMask[3] = alpha; 1981 m_colorMask[3] = alpha;
2049 drawingBuffer()->setColorMask(m_colorMask);
2050 contextGL()->ColorMask(red, green, blue, alpha); 1982 contextGL()->ColorMask(red, green, blue, alpha);
2051 } 1983 }
2052 1984
2053 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) { 1985 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) {
2054 if (isContextLost() || !validateWebGLObject("compileShader", shader)) 1986 if (isContextLost() || !validateWebGLObject("compileShader", shader))
2055 return; 1987 return;
2056 contextGL()->CompileShader(objectOrZero(shader)); 1988 contextGL()->CompileShader(objectOrZero(shader));
2057 } 1989 }
2058 1990
2059 void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, 1991 void WebGLRenderingContextBase::compressedTexImage2D(GLenum target,
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 } 2182 }
2251 if (object->hasObject()) { 2183 if (object->hasObject()) {
2252 // We need to pass in context here because we want 2184 // We need to pass in context here because we want
2253 // things in this context unbound. 2185 // things in this context unbound.
2254 object->deleteObject(contextGL()); 2186 object->deleteObject(contextGL());
2255 } 2187 }
2256 return true; 2188 return true;
2257 } 2189 }
2258 2190
2259 void WebGLRenderingContextBase::deleteBuffer(WebGLBuffer* buffer) { 2191 void WebGLRenderingContextBase::deleteBuffer(WebGLBuffer* buffer) {
2260 GLuint bufferName = objectOrZero(buffer);
2261 if (!deleteObject(buffer)) 2192 if (!deleteObject(buffer))
2262 return; 2193 return;
2263 drawingBuffer()->notifyBufferDeleted(bufferName);
2264 removeBoundBuffer(buffer); 2194 removeBoundBuffer(buffer);
2265 } 2195 }
2266 2196
2267 void WebGLRenderingContextBase::deleteFramebuffer( 2197 void WebGLRenderingContextBase::deleteFramebuffer(
2268 WebGLFramebuffer* framebuffer) { 2198 WebGLFramebuffer* framebuffer) {
2269 if (!deleteObject(framebuffer)) 2199 if (!deleteObject(framebuffer))
2270 return; 2200 return;
2271 if (framebuffer == m_framebufferBinding) { 2201 if (framebuffer == m_framebufferBinding) {
2272 m_framebufferBinding = nullptr; 2202 m_framebufferBinding = nullptr;
2273 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0);
2274 // Have to call drawingBuffer()->bind() here to bind back to internal fbo. 2203 // Have to call drawingBuffer()->bind() here to bind back to internal fbo.
2275 drawingBuffer()->bind(GL_FRAMEBUFFER); 2204 drawingBuffer()->bind(GL_FRAMEBUFFER);
2276 } 2205 }
2277 } 2206 }
2278 2207
2279 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) { 2208 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) {
2280 deleteObject(program); 2209 deleteObject(program);
2281 // We don't reset m_currentProgram to 0 here because the deletion of the 2210 // We don't reset m_currentProgram to 0 here because the deletion of the
2282 // current program is delayed. 2211 // current program is delayed.
2283 } 2212 }
2284 2213
2285 void WebGLRenderingContextBase::deleteRenderbuffer( 2214 void WebGLRenderingContextBase::deleteRenderbuffer(
2286 WebGLRenderbuffer* renderbuffer) { 2215 WebGLRenderbuffer* renderbuffer) {
2287 if (!deleteObject(renderbuffer)) 2216 if (!deleteObject(renderbuffer))
2288 return; 2217 return;
2289 if (renderbuffer == m_renderbufferBinding) { 2218 if (renderbuffer == m_renderbufferBinding) {
2290 m_renderbufferBinding = nullptr; 2219 m_renderbufferBinding = nullptr;
2291 drawingBuffer()->setRenderbufferBinding(0);
2292 } 2220 }
2293 if (m_framebufferBinding) 2221 if (m_framebufferBinding)
2294 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFER, 2222 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFER,
2295 renderbuffer); 2223 renderbuffer);
2296 if (getFramebufferBinding(GL_READ_FRAMEBUFFER)) 2224 if (getFramebufferBinding(GL_READ_FRAMEBUFFER))
2297 getFramebufferBinding(GL_READ_FRAMEBUFFER) 2225 getFramebufferBinding(GL_READ_FRAMEBUFFER)
2298 ->removeAttachmentFromBoundFramebuffer(GL_READ_FRAMEBUFFER, 2226 ->removeAttachmentFromBoundFramebuffer(GL_READ_FRAMEBUFFER,
2299 renderbuffer); 2227 renderbuffer);
2300 } 2228 }
2301 2229
2302 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) { 2230 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) {
2303 deleteObject(shader); 2231 deleteObject(shader);
2304 } 2232 }
2305 2233
2306 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) { 2234 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) {
2307 if (!deleteObject(texture)) 2235 if (!deleteObject(texture))
2308 return; 2236 return;
2309 2237
2310 int maxBoundTextureIndex = -1; 2238 int maxBoundTextureIndex = -1;
2311 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) { 2239 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) {
2312 if (texture == m_textureUnits[i].m_texture2DBinding) { 2240 if (texture == m_textureUnits[i].m_texture2DBinding) {
2313 m_textureUnits[i].m_texture2DBinding = nullptr; 2241 m_textureUnits[i].m_texture2DBinding = nullptr;
2314 maxBoundTextureIndex = i; 2242 maxBoundTextureIndex = i;
2315 if (!i)
2316 drawingBuffer()->setTexture2DBinding(0);
2317 } 2243 }
2318 if (texture == m_textureUnits[i].m_textureCubeMapBinding) { 2244 if (texture == m_textureUnits[i].m_textureCubeMapBinding) {
2319 m_textureUnits[i].m_textureCubeMapBinding = nullptr; 2245 m_textureUnits[i].m_textureCubeMapBinding = nullptr;
2320 maxBoundTextureIndex = i; 2246 maxBoundTextureIndex = i;
2321 } 2247 }
2322 if (isWebGL2OrHigher()) { 2248 if (isWebGL2OrHigher()) {
2323 if (texture == m_textureUnits[i].m_texture3DBinding) { 2249 if (texture == m_textureUnits[i].m_texture3DBinding) {
2324 m_textureUnits[i].m_texture3DBinding = nullptr; 2250 m_textureUnits[i].m_texture3DBinding = nullptr;
2325 maxBoundTextureIndex = i; 2251 maxBoundTextureIndex = i;
2326 } 2252 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 } 2310 }
2385 2311
2386 void WebGLRenderingContextBase::disable(GLenum cap) { 2312 void WebGLRenderingContextBase::disable(GLenum cap) {
2387 if (isContextLost() || !validateCapability("disable", cap)) 2313 if (isContextLost() || !validateCapability("disable", cap))
2388 return; 2314 return;
2389 if (cap == GL_STENCIL_TEST) { 2315 if (cap == GL_STENCIL_TEST) {
2390 m_stencilEnabled = false; 2316 m_stencilEnabled = false;
2391 applyStencilTest(); 2317 applyStencilTest();
2392 return; 2318 return;
2393 } 2319 }
2394 if (cap == GL_SCISSOR_TEST) { 2320 if (cap == GL_SCISSOR_TEST)
2395 m_scissorEnabled = false; 2321 m_scissorEnabled = false;
2396 drawingBuffer()->setScissorEnabled(m_scissorEnabled);
2397 }
2398 contextGL()->Disable(cap); 2322 contextGL()->Disable(cap);
2399 } 2323 }
2400 2324
2401 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) { 2325 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) {
2402 if (isContextLost()) 2326 if (isContextLost())
2403 return; 2327 return;
2404 if (index >= m_maxVertexAttribs) { 2328 if (index >= m_maxVertexAttribs) {
2405 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", 2329 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray",
2406 "index out of range"); 2330 "index out of range");
2407 return; 2331 return;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 } 2447 }
2524 2448
2525 void WebGLRenderingContextBase::enable(GLenum cap) { 2449 void WebGLRenderingContextBase::enable(GLenum cap) {
2526 if (isContextLost() || !validateCapability("enable", cap)) 2450 if (isContextLost() || !validateCapability("enable", cap))
2527 return; 2451 return;
2528 if (cap == GL_STENCIL_TEST) { 2452 if (cap == GL_STENCIL_TEST) {
2529 m_stencilEnabled = true; 2453 m_stencilEnabled = true;
2530 applyStencilTest(); 2454 applyStencilTest();
2531 return; 2455 return;
2532 } 2456 }
2533 if (cap == GL_SCISSOR_TEST) { 2457 if (cap == GL_SCISSOR_TEST)
2534 m_scissorEnabled = true; 2458 m_scissorEnabled = true;
2535 drawingBuffer()->setScissorEnabled(m_scissorEnabled);
2536 }
2537 contextGL()->Enable(cap); 2459 contextGL()->Enable(cap);
2538 } 2460 }
2539 2461
2540 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) { 2462 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) {
2541 if (isContextLost()) 2463 if (isContextLost())
2542 return; 2464 return;
2543 if (index >= m_maxVertexAttribs) { 2465 if (index >= m_maxVertexAttribs) {
2544 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", 2466 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray",
2545 "index out of range"); 2467 "index out of range");
2546 return; 2468 return;
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3927 GL_INVALID_VALUE, "pixelStorei", 3849 GL_INVALID_VALUE, "pixelStorei",
3928 "invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL"); 3850 "invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL");
3929 return; 3851 return;
3930 } 3852 }
3931 break; 3853 break;
3932 case GL_PACK_ALIGNMENT: 3854 case GL_PACK_ALIGNMENT:
3933 case GL_UNPACK_ALIGNMENT: 3855 case GL_UNPACK_ALIGNMENT:
3934 if (param == 1 || param == 2 || param == 4 || param == 8) { 3856 if (param == 1 || param == 2 || param == 4 || param == 8) {
3935 if (pname == GL_PACK_ALIGNMENT) { 3857 if (pname == GL_PACK_ALIGNMENT) {
3936 m_packAlignment = param; 3858 m_packAlignment = param;
3937 drawingBuffer()->setPackAlignment(param);
3938 } else { // GL_UNPACK_ALIGNMENT: 3859 } else { // GL_UNPACK_ALIGNMENT:
3939 m_unpackAlignment = param; 3860 m_unpackAlignment = param;
3940 } 3861 }
3941 contextGL()->PixelStorei(pname, param); 3862 contextGL()->PixelStorei(pname, param);
3942 } else { 3863 } else {
3943 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", 3864 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei",
3944 "invalid parameter for alignment"); 3865 "invalid parameter for alignment");
3945 return; 3866 return;
3946 } 3867 }
3947 break; 3868 break;
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after
5946 void WebGLRenderingContextBase::loseContextImpl( 5867 void WebGLRenderingContextBase::loseContextImpl(
5947 WebGLRenderingContextBase::LostContextMode mode, 5868 WebGLRenderingContextBase::LostContextMode mode,
5948 AutoRecoveryMethod autoRecoveryMethod) { 5869 AutoRecoveryMethod autoRecoveryMethod) {
5949 if (isContextLost()) 5870 if (isContextLost())
5950 return; 5871 return;
5951 5872
5952 m_contextLostMode = mode; 5873 m_contextLostMode = mode;
5953 ASSERT(m_contextLostMode != NotLostContext); 5874 ASSERT(m_contextLostMode != NotLostContext);
5954 m_autoRecoveryMethod = autoRecoveryMethod; 5875 m_autoRecoveryMethod = autoRecoveryMethod;
5955 5876
5956 // Make absolutely sure we do not refer to an already-deleted texture or
5957 // framebuffer.
5958 drawingBuffer()->setTexture2DBinding(0);
5959 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0);
5960 drawingBuffer()->setRenderbufferBinding(0);
5961
5962 detachAndRemoveAllObjects(); 5877 detachAndRemoveAllObjects();
5963 5878
5964 // Lose all the extensions. 5879 // Lose all the extensions.
5965 for (size_t i = 0; i < m_extensions.size(); ++i) { 5880 for (size_t i = 0; i < m_extensions.size(); ++i) {
5966 ExtensionTracker* tracker = m_extensions[i]; 5881 ExtensionTracker* tracker = m_extensions[i];
5967 tracker->loseExtension(false); 5882 tracker->loseExtension(false);
5968 } 5883 }
5969 5884
5970 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) 5885 for (size_t i = 0; i < WebGLExtensionNameCount; ++i)
5971 m_extensionEnabled[i] = false; 5886 m_extensionEnabled[i] = false;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
6108 } 6023 }
6109 } 6024 }
6110 6025
6111 void WebGLRenderingContextBase::stop() { 6026 void WebGLRenderingContextBase::stop() {
6112 if (!isContextLost()) { 6027 if (!isContextLost()) {
6113 // Never attempt to restore the context because the page is being torn down. 6028 // Never attempt to restore the context because the page is being torn down.
6114 forceLostContext(SyntheticLostContext, Manual); 6029 forceLostContext(SyntheticLostContext, Manual);
6115 } 6030 }
6116 } 6031 }
6117 6032
6033 bool WebGLRenderingContextBase::DrawingBufferClientIsBoundForDraw() {
6034 return !m_framebufferBinding;
6035 }
6036
6037 void WebGLRenderingContextBase::DrawingBufferClientRestoreScissorTest() {
6038 if (m_scissorEnabled)
6039 contextGL()->Enable(GL_SCISSOR_TEST);
6040 else
6041 contextGL()->Disable(GL_SCISSOR_TEST);
6042 }
6043
6044 void WebGLRenderingContextBase::DrawingBufferClientRestoreMaskAndClearValues() {
6045 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2],
6046 m_colorMask[3]);
6047 contextGL()->DepthMask(m_depthMask);
6048 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask);
6049
6050 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2],
6051 m_clearColor[3]);
6052 contextGL()->ClearDepthf(m_clearDepth);
6053 contextGL()->ClearStencil(m_clearStencil);
6054 }
6055
6056 void WebGLRenderingContextBase::DrawingBufferClientRestorePixelPackAlignment() {
6057 contextGL()->PixelStorei(GL_PACK_ALIGNMENT, m_packAlignment);
6058 }
6059
6060 void WebGLRenderingContextBase::DrawingBufferClientRestoreTexture2DBinding() {
6061 if (m_activeTextureUnit < m_textureUnits.size()) {
6062 contextGL()->BindTexture(
6063 GL_TEXTURE_2D,
6064 objectOrZero(
6065 m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get()));
6066 }
6067 }
6068
6069 void WebGLRenderingContextBase::
6070 DrawingBufferClientRestoreRenderbufferBinding() {
6071 contextGL()->BindRenderbuffer(GL_RENDERBUFFER,
6072 objectOrZero(m_renderbufferBinding.get()));
6073 }
6074
6075 void WebGLRenderingContextBase::DrawingBufferClientRestoreFramebufferBinding() {
6076 contextGL()->BindFramebuffer(GL_FRAMEBUFFER,
6077 objectOrZero(m_framebufferBinding.get()));
6078 }
6079
6080 void WebGLRenderingContextBase::
6081 DrawingBufferClientRestorePixelUnpackBufferBinding() {}
6082
6118 ScriptValue WebGLRenderingContextBase::getBooleanParameter( 6083 ScriptValue WebGLRenderingContextBase::getBooleanParameter(
6119 ScriptState* scriptState, 6084 ScriptState* scriptState,
6120 GLenum pname) { 6085 GLenum pname) {
6121 GLboolean value = 0; 6086 GLboolean value = 0;
6122 if (!isContextLost()) 6087 if (!isContextLost())
6123 contextGL()->GetBooleanv(pname, &value); 6088 contextGL()->GetBooleanv(pname, &value);
6124 return WebGLAny(scriptState, static_cast<bool>(value)); 6089 return WebGLAny(scriptState, static_cast<bool>(value));
6125 } 6090 }
6126 6091
6127 ScriptValue WebGLRenderingContextBase::getBooleanArrayParameter( 6092 ScriptValue WebGLRenderingContextBase::getBooleanArrayParameter(
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
7401 7366
7402 void WebGLRenderingContextBase::setFramebuffer(GLenum target, 7367 void WebGLRenderingContextBase::setFramebuffer(GLenum target,
7403 WebGLFramebuffer* buffer) { 7368 WebGLFramebuffer* buffer) {
7404 if (buffer) 7369 if (buffer)
7405 buffer->setHasEverBeenBound(); 7370 buffer->setHasEverBeenBound();
7406 7371
7407 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { 7372 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) {
7408 m_framebufferBinding = buffer; 7373 m_framebufferBinding = buffer;
7409 applyStencilTest(); 7374 applyStencilTest();
7410 } 7375 }
7411 drawingBuffer()->setFramebufferBinding(
7412 target, objectOrZero(getFramebufferBinding(target)));
7413
7414 if (!buffer) { 7376 if (!buffer) {
7415 // Instead of binding fb 0, bind the drawing buffer. 7377 // Instead of binding fb 0, bind the drawing buffer.
7416 drawingBuffer()->bind(target); 7378 drawingBuffer()->bind(target);
7417 } else { 7379 } else {
7418 contextGL()->BindFramebuffer(target, buffer->object()); 7380 contextGL()->BindFramebuffer(target, buffer->object());
7419 } 7381 }
7420 } 7382 }
7421 7383
7422 void WebGLRenderingContextBase::restoreCurrentFramebuffer() { 7384 void WebGLRenderingContextBase::restoreCurrentFramebuffer() {
7423 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); 7385 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
7529 7491
7530 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7492 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7531 HTMLCanvasElementOrOffscreenCanvas& result) const { 7493 HTMLCanvasElementOrOffscreenCanvas& result) const {
7532 if (canvas()) 7494 if (canvas())
7533 result.setHTMLCanvasElement(canvas()); 7495 result.setHTMLCanvasElement(canvas());
7534 else 7496 else
7535 result.setOffscreenCanvas(getOffscreenCanvas()); 7497 result.setOffscreenCanvas(getOffscreenCanvas());
7536 } 7498 }
7537 7499
7538 } // namespace blink 7500 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698