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

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

Issue 2402273002: DrawingBuffer: Clean up GL state restoration (Closed)
Patch Set: Incorporate review feedback Created 4 years, 1 month 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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 commitStartTime, 710 commitStartTime,
711 drawingBuffer()->contextProvider()->isSoftwareRendering()); 711 drawingBuffer()->contextProvider()->isSoftwareRendering());
712 } 712 }
713 713
714 PassRefPtr<Image> WebGLRenderingContextBase::getImage( 714 PassRefPtr<Image> WebGLRenderingContextBase::getImage(
715 AccelerationHint hint, 715 AccelerationHint hint,
716 SnapshotReason reason) const { 716 SnapshotReason reason) const {
717 if (!drawingBuffer()) 717 if (!drawingBuffer())
718 return nullptr; 718 return nullptr;
719 719
720 drawingBuffer()->commit(); 720 drawingBuffer()->resolveAndBindForReadAndDraw();
721 IntSize size = clampedCanvasSize(); 721 IntSize size = clampedCanvasSize();
722 OpacityMode opacityMode = 722 OpacityMode opacityMode =
723 creationAttributes().hasAlpha() ? NonOpaque : Opaque; 723 creationAttributes().hasAlpha() ? NonOpaque : Opaque;
724 std::unique_ptr<AcceleratedImageBufferSurface> surface = 724 std::unique_ptr<AcceleratedImageBufferSurface> surface =
725 wrapUnique(new AcceleratedImageBufferSurface(size, opacityMode)); 725 wrapUnique(new AcceleratedImageBufferSurface(size, opacityMode));
726 if (!surface->isValid()) 726 if (!surface->isValid())
727 return nullptr; 727 return nullptr;
728 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface)); 728 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface));
729 if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), 729 if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(),
730 BackBuffer)) { 730 BackBuffer)) {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 : DrawingBuffer::Discard; 1054 : DrawingBuffer::Discard;
1055 DrawingBuffer::WebGLVersion webGLVersion = DrawingBuffer::WebGL1; 1055 DrawingBuffer::WebGLVersion webGLVersion = DrawingBuffer::WebGL1;
1056 if (version() == 1) { 1056 if (version() == 1) {
1057 webGLVersion = DrawingBuffer::WebGL1; 1057 webGLVersion = DrawingBuffer::WebGL1;
1058 } else if (version() == 2) { 1058 } else if (version() == 2) {
1059 webGLVersion = DrawingBuffer::WebGL2; 1059 webGLVersion = DrawingBuffer::WebGL2;
1060 } else { 1060 } else {
1061 NOTREACHED(); 1061 NOTREACHED();
1062 } 1062 }
1063 return DrawingBuffer::create( 1063 return DrawingBuffer::create(
1064 std::move(contextProvider), clampedCanvasSize(), premultipliedAlpha, 1064 std::move(contextProvider), this, clampedCanvasSize(), premultipliedAlpha,
1065 wantAlphaChannel, wantDepthBuffer, wantStencilBuffer, wantAntialiasing, 1065 wantAlphaChannel, wantDepthBuffer, wantStencilBuffer, wantAntialiasing,
1066 preserve, webGLVersion, chromiumImageUsage); 1066 preserve, webGLVersion, chromiumImageUsage);
1067 } 1067 }
1068 1068
1069 void WebGLRenderingContextBase::initializeNewContext() { 1069 void WebGLRenderingContextBase::initializeNewContext() {
1070 ASSERT(!isContextLost()); 1070 ASSERT(!isContextLost());
1071 ASSERT(drawingBuffer()); 1071 ASSERT(drawingBuffer());
1072 1072
1073 m_markedCanvasDirty = false; 1073 m_markedCanvasDirty = false;
1074 m_activeTextureUnit = 0; 1074 m_activeTextureUnit = 0;
(...skipping 10 matching lines...) Expand all
1085 m_stencilEnabled = false; 1085 m_stencilEnabled = false;
1086 m_stencilMask = 0xFFFFFFFF; 1086 m_stencilMask = 0xFFFFFFFF;
1087 m_stencilMaskBack = 0xFFFFFFFF; 1087 m_stencilMaskBack = 0xFFFFFFFF;
1088 m_stencilFuncRef = 0; 1088 m_stencilFuncRef = 0;
1089 m_stencilFuncRefBack = 0; 1089 m_stencilFuncRefBack = 0;
1090 m_stencilFuncMask = 0xFFFFFFFF; 1090 m_stencilFuncMask = 0xFFFFFFFF;
1091 m_stencilFuncMaskBack = 0xFFFFFFFF; 1091 m_stencilFuncMaskBack = 0xFFFFFFFF;
1092 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; 1092 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole;
1093 1093
1094 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; 1094 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0;
1095 drawingBuffer()->setClearColor(m_clearColor);
1096 m_scissorEnabled = false; 1095 m_scissorEnabled = false;
1097 m_clearDepth = 1; 1096 m_clearDepth = 1;
1098 m_clearStencil = 0; 1097 m_clearStencil = 0;
1099 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; 1098 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true;
1100 drawingBuffer()->setColorMask(m_colorMask);
1101 1099
1102 GLint numCombinedTextureImageUnits = 0; 1100 GLint numCombinedTextureImageUnits = 0;
1103 contextGL()->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 1101 contextGL()->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
1104 &numCombinedTextureImageUnits); 1102 &numCombinedTextureImageUnits);
1105 m_textureUnits.clear(); 1103 m_textureUnits.clear();
1106 m_textureUnits.resize(numCombinedTextureImageUnits); 1104 m_textureUnits.resize(numCombinedTextureImageUnits);
1107 1105
1108 GLint numVertexAttribs = 0; 1106 GLint numVertexAttribs = 0;
1109 contextGL()->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); 1107 contextGL()->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs);
1110 m_maxVertexAttribs = numVertexAttribs; 1108 m_maxVertexAttribs = numVertexAttribs;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 kSupportedFormatsES2); 1193 kSupportedFormatsES2);
1196 m_supportedFormats.clear(); 1194 m_supportedFormats.clear();
1197 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2); 1195 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2);
1198 m_supportedTexImageSourceFormats.clear(); 1196 m_supportedTexImageSourceFormats.clear();
1199 ADD_VALUES_TO_SET(m_supportedTexImageSourceFormats, kSupportedFormatsES2); 1197 ADD_VALUES_TO_SET(m_supportedTexImageSourceFormats, kSupportedFormatsES2);
1200 m_supportedTypes.clear(); 1198 m_supportedTypes.clear();
1201 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2); 1199 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2);
1202 m_supportedTexImageSourceTypes.clear(); 1200 m_supportedTexImageSourceTypes.clear();
1203 ADD_VALUES_TO_SET(m_supportedTexImageSourceTypes, kSupportedTypesES2); 1201 ADD_VALUES_TO_SET(m_supportedTexImageSourceTypes, kSupportedTypesES2);
1204 1202
1203 // The DrawingBuffer was unable to store the state that dirtied when it was
1204 // initialized. Restore it now.
1205 drawingBuffer()->restoreAllState();
1205 activateContext(this); 1206 activateContext(this);
1206 } 1207 }
1207 1208
1208 void WebGLRenderingContextBase::setupFlags() { 1209 void WebGLRenderingContextBase::setupFlags() {
1209 ASSERT(drawingBuffer()); 1210 ASSERT(drawingBuffer());
1210 if (canvas()) { 1211 if (canvas()) {
1211 if (Page* p = canvas()->document().page()) { 1212 if (Page* p = canvas()->document().page()) {
1212 m_synthesizedErrorsToConsole = 1213 m_synthesizedErrorsToConsole =
1213 p->settings().webGLErrorsToConsoleEnabled(); 1214 p->settings().webGLErrorsToConsoleEnabled();
1214 } 1215 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 contextGL()->ClearStencil(0); 1378 contextGL()->ClearStencil(0);
1378 clearMask |= GL_STENCIL_BUFFER_BIT; 1379 clearMask |= GL_STENCIL_BUFFER_BIT;
1379 contextGL()->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); 1380 contextGL()->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF);
1380 } 1381 }
1381 1382
1382 contextGL()->ColorMask( 1383 contextGL()->ColorMask(
1383 true, true, true, 1384 true, true, true,
1384 !drawingBuffer()->defaultBufferRequiresAlphaChannelToBePreserved()); 1385 !drawingBuffer()->defaultBufferRequiresAlphaChannelToBePreserved());
1385 drawingBuffer()->clearFramebuffers(clearMask); 1386 drawingBuffer()->clearFramebuffers(clearMask);
1386 1387
1387 restoreStateAfterClear(); 1388 // Call the DrawingBufferClient method to restore scissor test, mask, and
1388 drawingBuffer()->restoreFramebufferBindings(); 1389 // clear values, because we dirtied them above.
1390 DrawingBufferClientRestoreScissorTest();
1391 DrawingBufferClientRestoreMaskAndClearValues();
1392
1389 drawingBuffer()->setBufferClearNeeded(false); 1393 drawingBuffer()->setBufferClearNeeded(false);
1390 1394
1391 return combinedClear ? CombinedClear : JustClear; 1395 return combinedClear ? CombinedClear : JustClear;
1392 } 1396 }
1393 1397
1394 void WebGLRenderingContextBase::restoreScissorEnabled() { 1398 void WebGLRenderingContextBase::restoreScissorEnabled() {
1395 if (isContextLost()) 1399 if (isContextLost())
1396 return; 1400 return;
1397 1401
1398 if (m_scissorEnabled) { 1402 if (m_scissorEnabled) {
(...skipping 12 matching lines...) Expand all
1411 } 1415 }
1412 1416
1413 void WebGLRenderingContextBase::restoreClearColor() { 1417 void WebGLRenderingContextBase::restoreClearColor() {
1414 if (isContextLost()) 1418 if (isContextLost())
1415 return; 1419 return;
1416 1420
1417 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], 1421 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2],
1418 m_clearColor[3]); 1422 m_clearColor[3]);
1419 } 1423 }
1420 1424
1421 void WebGLRenderingContextBase::restoreClearDepthf() {
1422 if (isContextLost())
1423 return;
1424
1425 contextGL()->ClearDepthf(m_clearDepth);
1426 }
1427
1428 void WebGLRenderingContextBase::restoreClearStencil() {
1429 if (isContextLost())
1430 return;
1431
1432 contextGL()->ClearStencil(m_clearStencil);
1433 }
1434
1435 void WebGLRenderingContextBase::restoreStencilMaskSeparate() {
1436 if (isContextLost())
1437 return;
1438
1439 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask);
1440 }
1441
1442 void WebGLRenderingContextBase::restoreColorMask() { 1425 void WebGLRenderingContextBase::restoreColorMask() {
1443 if (isContextLost()) 1426 if (isContextLost())
1444 return; 1427 return;
1445 1428
1446 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], 1429 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2],
1447 m_colorMask[3]); 1430 m_colorMask[3]);
1448 } 1431 }
1449 1432
1450 void WebGLRenderingContextBase::restoreDepthMask() {
1451 if (isContextLost())
1452 return;
1453
1454 contextGL()->DepthMask(m_depthMask);
1455 }
1456
1457 void WebGLRenderingContextBase::restoreStateAfterClear() {
1458 // Restore clear-related state items back to what the context had set.
1459 restoreScissorEnabled();
1460 restoreClearColor();
1461 restoreColorMask();
1462 restoreClearDepthf();
1463 restoreClearStencil();
1464 restoreStencilMaskSeparate();
1465 restoreDepthMask();
1466 }
1467
1468 void WebGLRenderingContextBase::markLayerComposited() { 1433 void WebGLRenderingContextBase::markLayerComposited() {
1469 if (!isContextLost()) 1434 if (!isContextLost())
1470 drawingBuffer()->setBufferClearNeeded(true); 1435 drawingBuffer()->setBufferClearNeeded(true);
1471 } 1436 }
1472 1437
1473 void WebGLRenderingContextBase::setIsHidden(bool hidden) { 1438 void WebGLRenderingContextBase::setIsHidden(bool hidden) {
1474 m_isHidden = hidden; 1439 m_isHidden = hidden;
1475 if (drawingBuffer()) 1440 if (drawingBuffer())
1476 drawingBuffer()->setIsHidden(hidden); 1441 drawingBuffer()->setIsHidden(hidden);
1477 1442
(...skipping 15 matching lines...) Expand all
1493 1458
1494 canvas()->clearCopiedImage(); 1459 canvas()->clearCopiedImage();
1495 m_markedCanvasDirty = false; 1460 m_markedCanvasDirty = false;
1496 1461
1497 if (!canvas()->buffer()) 1462 if (!canvas()->buffer())
1498 return false; 1463 return false;
1499 1464
1500 ScopedTexture2DRestorer restorer(this); 1465 ScopedTexture2DRestorer restorer(this);
1501 ScopedFramebufferRestorer fboRestorer(this); 1466 ScopedFramebufferRestorer fboRestorer(this);
1502 1467
1503 drawingBuffer()->commit(); 1468 drawingBuffer()->resolveAndBindForReadAndDraw();
1504 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer( 1469 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(
1505 drawingBuffer(), sourceBuffer)) { 1470 drawingBuffer(), sourceBuffer)) {
1506 // Currently, copyRenderingResultsFromDrawingBuffer is expected to always 1471 // Currently, copyRenderingResultsFromDrawingBuffer is expected to always
1507 // succeed because cases where canvas()-buffer() is not accelerated are 1472 // succeed because cases where canvas()-buffer() is not accelerated are
1508 // handle before reaching this point. If that assumption ever stops holding 1473 // handle before reaching this point. If that assumption ever stops holding
1509 // true, we may need to implement a fallback right here. 1474 // true, we may need to implement a fallback right here.
1510 ASSERT_NOT_REACHED(); 1475 ASSERT_NOT_REACHED();
1511 return false; 1476 return false;
1512 } 1477 }
1513 1478
1514 return true; 1479 return true;
1515 } 1480 }
1516 1481
1517 ImageData* WebGLRenderingContextBase::paintRenderingResultsToImageData( 1482 ImageData* WebGLRenderingContextBase::paintRenderingResultsToImageData(
1518 SourceDrawingBuffer sourceBuffer) { 1483 SourceDrawingBuffer sourceBuffer) {
1519 if (isContextLost()) 1484 if (isContextLost())
1520 return nullptr; 1485 return nullptr;
1521 if (creationAttributes().premultipliedAlpha()) 1486 if (creationAttributes().premultipliedAlpha())
1522 return nullptr; 1487 return nullptr;
1523 1488
1524 clearIfComposited(); 1489 clearIfComposited();
1525 drawingBuffer()->commit(); 1490 drawingBuffer()->resolveAndBindForReadAndDraw();
1526 ScopedFramebufferRestorer restorer(this); 1491 ScopedFramebufferRestorer restorer(this);
1527 int width, height; 1492 int width, height;
1528 WTF::ArrayBufferContents contents; 1493 WTF::ArrayBufferContents contents;
1529 if (!drawingBuffer()->paintRenderingResultsToImageData( 1494 if (!drawingBuffer()->paintRenderingResultsToImageData(
1530 width, height, sourceBuffer, contents)) 1495 width, height, sourceBuffer, contents))
1531 return nullptr; 1496 return nullptr;
1532 DOMArrayBuffer* imageDataPixels = DOMArrayBuffer::create(contents); 1497 DOMArrayBuffer* imageDataPixels = DOMArrayBuffer::create(contents);
1533 1498
1534 return ImageData::create( 1499 return ImageData::create(
1535 IntSize(width, height), 1500 IntSize(width, height),
(...skipping 27 matching lines...) Expand all
1563 // If we've exceeded the area limit scale the buffer down, preserving 1528 // If we've exceeded the area limit scale the buffer down, preserving
1564 // ascpect ratio, until it fits. 1529 // ascpect ratio, until it fits.
1565 float scaleFactor = 1530 float scaleFactor =
1566 sqrtf(static_cast<float>(maxArea) / static_cast<float>(currentArea)); 1531 sqrtf(static_cast<float>(maxArea) / static_cast<float>(currentArea));
1567 width = std::max(1, static_cast<int>(width * scaleFactor)); 1532 width = std::max(1, static_cast<int>(width * scaleFactor));
1568 height = std::max(1, static_cast<int>(height * scaleFactor)); 1533 height = std::max(1, static_cast<int>(height * scaleFactor));
1569 } 1534 }
1570 1535
1571 // We don't have to mark the canvas as dirty, since the newly created image 1536 // We don't have to mark the canvas as dirty, since the newly created image
1572 // buffer will also start off clear (and this matches what reshape will do). 1537 // buffer will also start off clear (and this matches what reshape will do).
1573 drawingBuffer()->reset(IntSize(width, height)); 1538 drawingBuffer()->resize(IntSize(width, height));
1574 restoreStateAfterClear();
1575
1576 contextGL()->BindTexture(
1577 GL_TEXTURE_2D,
1578 objectOrZero(
1579 m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get()));
1580 contextGL()->BindRenderbuffer(GL_RENDERBUFFER,
1581 objectOrZero(m_renderbufferBinding.get()));
1582 drawingBuffer()->restoreFramebufferBindings();
1583 drawingBuffer()->restorePixelUnpackBufferBindings();
1584 } 1539 }
1585 1540
1586 int WebGLRenderingContextBase::drawingBufferWidth() const { 1541 int WebGLRenderingContextBase::drawingBufferWidth() const {
1587 return isContextLost() ? 0 : drawingBuffer()->size().width(); 1542 return isContextLost() ? 0 : drawingBuffer()->size().width();
1588 } 1543 }
1589 1544
1590 int WebGLRenderingContextBase::drawingBufferHeight() const { 1545 int WebGLRenderingContextBase::drawingBufferHeight() const {
1591 return isContextLost() ? 0 : drawingBuffer()->size().height(); 1546 return isContextLost() ? 0 : drawingBuffer()->size().height();
1592 } 1547 }
1593 1548
1594 void WebGLRenderingContextBase::activeTexture(GLenum texture) { 1549 void WebGLRenderingContextBase::activeTexture(GLenum texture) {
1595 if (isContextLost()) 1550 if (isContextLost())
1596 return; 1551 return;
1597 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { 1552 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) {
1598 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", 1553 synthesizeGLError(GL_INVALID_ENUM, "activeTexture",
1599 "texture unit out of range"); 1554 "texture unit out of range");
1600 return; 1555 return;
1601 } 1556 }
1602 m_activeTextureUnit = texture - GL_TEXTURE0; 1557 m_activeTextureUnit = texture - GL_TEXTURE0;
1603 contextGL()->ActiveTexture(texture); 1558 contextGL()->ActiveTexture(texture);
1604
1605 drawingBuffer()->setActiveTextureUnit(texture);
1606 } 1559 }
1607 1560
1608 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, 1561 void WebGLRenderingContextBase::attachShader(WebGLProgram* program,
1609 WebGLShader* shader) { 1562 WebGLShader* shader) {
1610 if (isContextLost() || !validateWebGLObject("attachShader", program) || 1563 if (isContextLost() || !validateWebGLObject("attachShader", program) ||
1611 !validateWebGLObject("attachShader", shader)) 1564 !validateWebGLObject("attachShader", shader))
1612 return; 1565 return;
1613 if (!program->attachShader(shader)) { 1566 if (!program->attachShader(shader)) {
1614 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", 1567 synthesizeGLError(GL_INVALID_OPERATION, "attachShader",
1615 "shader attachment already has shader"); 1568 "shader attachment already has shader");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 bool deleted; 1640 bool deleted;
1688 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) 1641 if (!checkObjectToBeBound("bindBuffer", buffer, deleted))
1689 return; 1642 return;
1690 if (deleted) { 1643 if (deleted) {
1691 synthesizeGLError(GL_INVALID_OPERATION, "bindBuffer", 1644 synthesizeGLError(GL_INVALID_OPERATION, "bindBuffer",
1692 "attempt to bind a deleted buffer"); 1645 "attempt to bind a deleted buffer");
1693 return; 1646 return;
1694 } 1647 }
1695 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) 1648 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer))
1696 return; 1649 return;
1697
1698 if (target == GL_PIXEL_UNPACK_BUFFER) {
1699 drawingBuffer()->setPixelUnpackBufferBinding(objectOrZero(buffer));
1700 }
1701 contextGL()->BindBuffer(target, objectOrZero(buffer)); 1650 contextGL()->BindBuffer(target, objectOrZero(buffer));
1702 } 1651 }
1703 1652
1704 void WebGLRenderingContextBase::bindFramebuffer(GLenum target, 1653 void WebGLRenderingContextBase::bindFramebuffer(GLenum target,
1705 WebGLFramebuffer* buffer) { 1654 WebGLFramebuffer* buffer) {
1706 bool deleted; 1655 bool deleted;
1707 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) 1656 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted))
1708 return; 1657 return;
1709 if (deleted) { 1658 if (deleted) {
1710 synthesizeGLError(GL_INVALID_OPERATION, "bindFramebuffer", 1659 synthesizeGLError(GL_INVALID_OPERATION, "bindFramebuffer",
(...skipping 19 matching lines...) Expand all
1730 synthesizeGLError(GL_INVALID_OPERATION, "bindRenderbuffer", 1679 synthesizeGLError(GL_INVALID_OPERATION, "bindRenderbuffer",
1731 "attempt to bind a deleted renderbuffer"); 1680 "attempt to bind a deleted renderbuffer");
1732 return; 1681 return;
1733 } 1682 }
1734 if (target != GL_RENDERBUFFER) { 1683 if (target != GL_RENDERBUFFER) {
1735 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target"); 1684 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target");
1736 return; 1685 return;
1737 } 1686 }
1738 m_renderbufferBinding = renderBuffer; 1687 m_renderbufferBinding = renderBuffer;
1739 contextGL()->BindRenderbuffer(target, objectOrZero(renderBuffer)); 1688 contextGL()->BindRenderbuffer(target, objectOrZero(renderBuffer));
1740
1741 drawingBuffer()->setRenderbufferBinding(objectOrZero(renderBuffer));
1742
1743 if (renderBuffer) 1689 if (renderBuffer)
1744 renderBuffer->setHasEverBeenBound(); 1690 renderBuffer->setHasEverBeenBound();
1745 } 1691 }
1746 1692
1747 void WebGLRenderingContextBase::bindTexture(GLenum target, 1693 void WebGLRenderingContextBase::bindTexture(GLenum target,
1748 WebGLTexture* texture) { 1694 WebGLTexture* texture) {
1749 bool deleted; 1695 bool deleted;
1750 if (!checkObjectToBeBound("bindTexture", texture, deleted)) 1696 if (!checkObjectToBeBound("bindTexture", texture, deleted))
1751 return; 1697 return;
1752 if (deleted) { 1698 if (deleted) {
1753 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", 1699 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture",
1754 "attempt to bind a deleted texture"); 1700 "attempt to bind a deleted texture");
1755 return; 1701 return;
1756 } 1702 }
1757 if (texture && texture->getTarget() && texture->getTarget() != target) { 1703 if (texture && texture->getTarget() && texture->getTarget() != target) {
1758 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", 1704 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture",
1759 "textures can not be used with multiple targets"); 1705 "textures can not be used with multiple targets");
1760 return; 1706 return;
1761 } 1707 }
1762 1708
1763 if (target == GL_TEXTURE_2D) { 1709 if (target == GL_TEXTURE_2D) {
1764 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = 1710 m_textureUnits[m_activeTextureUnit].m_texture2DBinding =
1765 TraceWrapperMember<WebGLTexture>(this, texture); 1711 TraceWrapperMember<WebGLTexture>(this, texture);
1766
1767 if (!m_activeTextureUnit)
1768 drawingBuffer()->setTexture2DBinding(objectOrZero(texture));
1769 } else if (target == GL_TEXTURE_CUBE_MAP) { 1712 } else if (target == GL_TEXTURE_CUBE_MAP) {
1770 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = 1713 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding =
1771 TraceWrapperMember<WebGLTexture>(this, texture); 1714 TraceWrapperMember<WebGLTexture>(this, texture);
1772 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { 1715 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) {
1773 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = 1716 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding =
1774 TraceWrapperMember<WebGLTexture>(this, texture); 1717 TraceWrapperMember<WebGLTexture>(this, texture);
1775 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { 1718 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) {
1776 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = 1719 m_textureUnits[m_activeTextureUnit].m_texture3DBinding =
1777 TraceWrapperMember<WebGLTexture>(this, texture); 1720 TraceWrapperMember<WebGLTexture>(this, texture);
1778 } else { 1721 } else {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 if (std::isnan(g)) 1966 if (std::isnan(g))
2024 g = 0; 1967 g = 0;
2025 if (std::isnan(b)) 1968 if (std::isnan(b))
2026 b = 0; 1969 b = 0;
2027 if (std::isnan(a)) 1970 if (std::isnan(a))
2028 a = 1; 1971 a = 1;
2029 m_clearColor[0] = r; 1972 m_clearColor[0] = r;
2030 m_clearColor[1] = g; 1973 m_clearColor[1] = g;
2031 m_clearColor[2] = b; 1974 m_clearColor[2] = b;
2032 m_clearColor[3] = a; 1975 m_clearColor[3] = a;
2033 drawingBuffer()->setClearColor(m_clearColor);
2034 contextGL()->ClearColor(r, g, b, a); 1976 contextGL()->ClearColor(r, g, b, a);
2035 } 1977 }
2036 1978
2037 void WebGLRenderingContextBase::clearDepth(GLfloat depth) { 1979 void WebGLRenderingContextBase::clearDepth(GLfloat depth) {
2038 if (isContextLost()) 1980 if (isContextLost())
2039 return; 1981 return;
2040 m_clearDepth = depth; 1982 m_clearDepth = depth;
2041 contextGL()->ClearDepthf(depth); 1983 contextGL()->ClearDepthf(depth);
2042 } 1984 }
2043 1985
2044 void WebGLRenderingContextBase::clearStencil(GLint s) { 1986 void WebGLRenderingContextBase::clearStencil(GLint s) {
2045 if (isContextLost()) 1987 if (isContextLost())
2046 return; 1988 return;
2047 m_clearStencil = s; 1989 m_clearStencil = s;
2048 contextGL()->ClearStencil(s); 1990 contextGL()->ClearStencil(s);
2049 } 1991 }
2050 1992
2051 void WebGLRenderingContextBase::colorMask(GLboolean red, 1993 void WebGLRenderingContextBase::colorMask(GLboolean red,
2052 GLboolean green, 1994 GLboolean green,
2053 GLboolean blue, 1995 GLboolean blue,
2054 GLboolean alpha) { 1996 GLboolean alpha) {
2055 if (isContextLost()) 1997 if (isContextLost())
2056 return; 1998 return;
2057 m_colorMask[0] = red; 1999 m_colorMask[0] = red;
2058 m_colorMask[1] = green; 2000 m_colorMask[1] = green;
2059 m_colorMask[2] = blue; 2001 m_colorMask[2] = blue;
2060 m_colorMask[3] = alpha; 2002 m_colorMask[3] = alpha;
2061 drawingBuffer()->setColorMask(m_colorMask);
2062 contextGL()->ColorMask(red, green, blue, alpha); 2003 contextGL()->ColorMask(red, green, blue, alpha);
2063 } 2004 }
2064 2005
2065 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) { 2006 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) {
2066 if (isContextLost() || !validateWebGLObject("compileShader", shader)) 2007 if (isContextLost() || !validateWebGLObject("compileShader", shader))
2067 return; 2008 return;
2068 contextGL()->CompileShader(objectOrZero(shader)); 2009 contextGL()->CompileShader(objectOrZero(shader));
2069 } 2010 }
2070 2011
2071 void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, 2012 void WebGLRenderingContextBase::compressedTexImage2D(GLenum target,
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 } 2203 }
2263 if (object->hasObject()) { 2204 if (object->hasObject()) {
2264 // We need to pass in context here because we want 2205 // We need to pass in context here because we want
2265 // things in this context unbound. 2206 // things in this context unbound.
2266 object->deleteObject(contextGL()); 2207 object->deleteObject(contextGL());
2267 } 2208 }
2268 return true; 2209 return true;
2269 } 2210 }
2270 2211
2271 void WebGLRenderingContextBase::deleteBuffer(WebGLBuffer* buffer) { 2212 void WebGLRenderingContextBase::deleteBuffer(WebGLBuffer* buffer) {
2272 GLuint bufferName = objectOrZero(buffer);
2273 if (!deleteObject(buffer)) 2213 if (!deleteObject(buffer))
2274 return; 2214 return;
2275 drawingBuffer()->notifyBufferDeleted(bufferName);
2276 removeBoundBuffer(buffer); 2215 removeBoundBuffer(buffer);
2277 } 2216 }
2278 2217
2279 void WebGLRenderingContextBase::deleteFramebuffer( 2218 void WebGLRenderingContextBase::deleteFramebuffer(
2280 WebGLFramebuffer* framebuffer) { 2219 WebGLFramebuffer* framebuffer) {
2281 if (!deleteObject(framebuffer)) 2220 if (!deleteObject(framebuffer))
2282 return; 2221 return;
2283 if (framebuffer == m_framebufferBinding) { 2222 if (framebuffer == m_framebufferBinding) {
2284 m_framebufferBinding = nullptr; 2223 m_framebufferBinding = nullptr;
2285 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0);
2286 // Have to call drawingBuffer()->bind() here to bind back to internal fbo. 2224 // Have to call drawingBuffer()->bind() here to bind back to internal fbo.
2287 drawingBuffer()->bind(GL_FRAMEBUFFER); 2225 drawingBuffer()->bind(GL_FRAMEBUFFER);
2288 } 2226 }
2289 } 2227 }
2290 2228
2291 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) { 2229 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) {
2292 deleteObject(program); 2230 deleteObject(program);
2293 // We don't reset m_currentProgram to 0 here because the deletion of the 2231 // We don't reset m_currentProgram to 0 here because the deletion of the
2294 // current program is delayed. 2232 // current program is delayed.
2295 } 2233 }
2296 2234
2297 void WebGLRenderingContextBase::deleteRenderbuffer( 2235 void WebGLRenderingContextBase::deleteRenderbuffer(
2298 WebGLRenderbuffer* renderbuffer) { 2236 WebGLRenderbuffer* renderbuffer) {
2299 if (!deleteObject(renderbuffer)) 2237 if (!deleteObject(renderbuffer))
2300 return; 2238 return;
2301 if (renderbuffer == m_renderbufferBinding) { 2239 if (renderbuffer == m_renderbufferBinding) {
2302 m_renderbufferBinding = nullptr; 2240 m_renderbufferBinding = nullptr;
2303 drawingBuffer()->setRenderbufferBinding(0);
2304 } 2241 }
2305 if (m_framebufferBinding) 2242 if (m_framebufferBinding)
2306 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFER, 2243 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFER,
2307 renderbuffer); 2244 renderbuffer);
2308 if (getFramebufferBinding(GL_READ_FRAMEBUFFER)) 2245 if (getFramebufferBinding(GL_READ_FRAMEBUFFER))
2309 getFramebufferBinding(GL_READ_FRAMEBUFFER) 2246 getFramebufferBinding(GL_READ_FRAMEBUFFER)
2310 ->removeAttachmentFromBoundFramebuffer(GL_READ_FRAMEBUFFER, 2247 ->removeAttachmentFromBoundFramebuffer(GL_READ_FRAMEBUFFER,
2311 renderbuffer); 2248 renderbuffer);
2312 } 2249 }
2313 2250
2314 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) { 2251 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) {
2315 deleteObject(shader); 2252 deleteObject(shader);
2316 } 2253 }
2317 2254
2318 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) { 2255 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) {
2319 if (!deleteObject(texture)) 2256 if (!deleteObject(texture))
2320 return; 2257 return;
2321 2258
2322 int maxBoundTextureIndex = -1; 2259 int maxBoundTextureIndex = -1;
2323 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) { 2260 for (size_t i = 0; i < m_onePlusMaxNonDefaultTextureUnit; ++i) {
2324 if (texture == m_textureUnits[i].m_texture2DBinding) { 2261 if (texture == m_textureUnits[i].m_texture2DBinding) {
2325 m_textureUnits[i].m_texture2DBinding = nullptr; 2262 m_textureUnits[i].m_texture2DBinding = nullptr;
2326 maxBoundTextureIndex = i; 2263 maxBoundTextureIndex = i;
2327 if (!i)
2328 drawingBuffer()->setTexture2DBinding(0);
2329 } 2264 }
2330 if (texture == m_textureUnits[i].m_textureCubeMapBinding) { 2265 if (texture == m_textureUnits[i].m_textureCubeMapBinding) {
2331 m_textureUnits[i].m_textureCubeMapBinding = nullptr; 2266 m_textureUnits[i].m_textureCubeMapBinding = nullptr;
2332 maxBoundTextureIndex = i; 2267 maxBoundTextureIndex = i;
2333 } 2268 }
2334 if (isWebGL2OrHigher()) { 2269 if (isWebGL2OrHigher()) {
2335 if (texture == m_textureUnits[i].m_texture3DBinding) { 2270 if (texture == m_textureUnits[i].m_texture3DBinding) {
2336 m_textureUnits[i].m_texture3DBinding = nullptr; 2271 m_textureUnits[i].m_texture3DBinding = nullptr;
2337 maxBoundTextureIndex = i; 2272 maxBoundTextureIndex = i;
2338 } 2273 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 } 2331 }
2397 2332
2398 void WebGLRenderingContextBase::disable(GLenum cap) { 2333 void WebGLRenderingContextBase::disable(GLenum cap) {
2399 if (isContextLost() || !validateCapability("disable", cap)) 2334 if (isContextLost() || !validateCapability("disable", cap))
2400 return; 2335 return;
2401 if (cap == GL_STENCIL_TEST) { 2336 if (cap == GL_STENCIL_TEST) {
2402 m_stencilEnabled = false; 2337 m_stencilEnabled = false;
2403 applyStencilTest(); 2338 applyStencilTest();
2404 return; 2339 return;
2405 } 2340 }
2406 if (cap == GL_SCISSOR_TEST) { 2341 if (cap == GL_SCISSOR_TEST)
2407 m_scissorEnabled = false; 2342 m_scissorEnabled = false;
2408 drawingBuffer()->setScissorEnabled(m_scissorEnabled);
2409 }
2410 contextGL()->Disable(cap); 2343 contextGL()->Disable(cap);
2411 } 2344 }
2412 2345
2413 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) { 2346 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) {
2414 if (isContextLost()) 2347 if (isContextLost())
2415 return; 2348 return;
2416 if (index >= m_maxVertexAttribs) { 2349 if (index >= m_maxVertexAttribs) {
2417 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", 2350 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray",
2418 "index out of range"); 2351 "index out of range");
2419 return; 2352 return;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 } 2468 }
2536 2469
2537 void WebGLRenderingContextBase::enable(GLenum cap) { 2470 void WebGLRenderingContextBase::enable(GLenum cap) {
2538 if (isContextLost() || !validateCapability("enable", cap)) 2471 if (isContextLost() || !validateCapability("enable", cap))
2539 return; 2472 return;
2540 if (cap == GL_STENCIL_TEST) { 2473 if (cap == GL_STENCIL_TEST) {
2541 m_stencilEnabled = true; 2474 m_stencilEnabled = true;
2542 applyStencilTest(); 2475 applyStencilTest();
2543 return; 2476 return;
2544 } 2477 }
2545 if (cap == GL_SCISSOR_TEST) { 2478 if (cap == GL_SCISSOR_TEST)
2546 m_scissorEnabled = true; 2479 m_scissorEnabled = true;
2547 drawingBuffer()->setScissorEnabled(m_scissorEnabled);
2548 }
2549 contextGL()->Enable(cap); 2480 contextGL()->Enable(cap);
2550 } 2481 }
2551 2482
2552 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) { 2483 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) {
2553 if (isContextLost()) 2484 if (isContextLost())
2554 return; 2485 return;
2555 if (index >= m_maxVertexAttribs) { 2486 if (index >= m_maxVertexAttribs) {
2556 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", 2487 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray",
2557 "index out of range"); 2488 "index out of range");
2558 return; 2489 return;
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 GL_INVALID_VALUE, "pixelStorei", 3870 GL_INVALID_VALUE, "pixelStorei",
3940 "invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL"); 3871 "invalid parameter for UNPACK_COLORSPACE_CONVERSION_WEBGL");
3941 return; 3872 return;
3942 } 3873 }
3943 break; 3874 break;
3944 case GL_PACK_ALIGNMENT: 3875 case GL_PACK_ALIGNMENT:
3945 case GL_UNPACK_ALIGNMENT: 3876 case GL_UNPACK_ALIGNMENT:
3946 if (param == 1 || param == 2 || param == 4 || param == 8) { 3877 if (param == 1 || param == 2 || param == 4 || param == 8) {
3947 if (pname == GL_PACK_ALIGNMENT) { 3878 if (pname == GL_PACK_ALIGNMENT) {
3948 m_packAlignment = param; 3879 m_packAlignment = param;
3949 drawingBuffer()->setPackAlignment(param);
3950 } else { // GL_UNPACK_ALIGNMENT: 3880 } else { // GL_UNPACK_ALIGNMENT:
3951 m_unpackAlignment = param; 3881 m_unpackAlignment = param;
3952 } 3882 }
3953 contextGL()->PixelStorei(pname, param); 3883 contextGL()->PixelStorei(pname, param);
3954 } else { 3884 } else {
3955 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", 3885 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei",
3956 "invalid parameter for alignment"); 3886 "invalid parameter for alignment");
3957 return; 3887 return;
3958 } 3888 }
3959 break; 3889 break;
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after
5958 void WebGLRenderingContextBase::loseContextImpl( 5888 void WebGLRenderingContextBase::loseContextImpl(
5959 WebGLRenderingContextBase::LostContextMode mode, 5889 WebGLRenderingContextBase::LostContextMode mode,
5960 AutoRecoveryMethod autoRecoveryMethod) { 5890 AutoRecoveryMethod autoRecoveryMethod) {
5961 if (isContextLost()) 5891 if (isContextLost())
5962 return; 5892 return;
5963 5893
5964 m_contextLostMode = mode; 5894 m_contextLostMode = mode;
5965 ASSERT(m_contextLostMode != NotLostContext); 5895 ASSERT(m_contextLostMode != NotLostContext);
5966 m_autoRecoveryMethod = autoRecoveryMethod; 5896 m_autoRecoveryMethod = autoRecoveryMethod;
5967 5897
5968 // Make absolutely sure we do not refer to an already-deleted texture or
5969 // framebuffer.
5970 drawingBuffer()->setTexture2DBinding(0);
5971 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0);
5972 drawingBuffer()->setRenderbufferBinding(0);
5973
5974 detachAndRemoveAllObjects(); 5898 detachAndRemoveAllObjects();
5975 5899
5976 // Lose all the extensions. 5900 // Lose all the extensions.
5977 for (size_t i = 0; i < m_extensions.size(); ++i) { 5901 for (size_t i = 0; i < m_extensions.size(); ++i) {
5978 ExtensionTracker* tracker = m_extensions[i]; 5902 ExtensionTracker* tracker = m_extensions[i];
5979 tracker->loseExtension(false); 5903 tracker->loseExtension(false);
5980 } 5904 }
5981 5905
5982 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) 5906 for (size_t i = 0; i < WebGLExtensionNameCount; ++i)
5983 m_extensionEnabled[i] = false; 5907 m_extensionEnabled[i] = false;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
6120 } 6044 }
6121 } 6045 }
6122 6046
6123 void WebGLRenderingContextBase::stop() { 6047 void WebGLRenderingContextBase::stop() {
6124 if (!isContextLost()) { 6048 if (!isContextLost()) {
6125 // Never attempt to restore the context because the page is being torn down. 6049 // Never attempt to restore the context because the page is being torn down.
6126 forceLostContext(SyntheticLostContext, Manual); 6050 forceLostContext(SyntheticLostContext, Manual);
6127 } 6051 }
6128 } 6052 }
6129 6053
6054 bool WebGLRenderingContextBase::DrawingBufferClientIsBoundForDraw() {
6055 return !m_framebufferBinding;
6056 }
6057
6058 void WebGLRenderingContextBase::DrawingBufferClientRestoreScissorTest() {
6059 if (!contextGL())
6060 return;
6061 if (m_scissorEnabled)
6062 contextGL()->Enable(GL_SCISSOR_TEST);
6063 else
6064 contextGL()->Disable(GL_SCISSOR_TEST);
6065 }
6066
6067 void WebGLRenderingContextBase::DrawingBufferClientRestoreMaskAndClearValues() {
6068 if (!contextGL())
6069 return;
6070 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2],
6071 m_colorMask[3]);
6072 contextGL()->DepthMask(m_depthMask);
6073 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask);
6074
6075 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2],
6076 m_clearColor[3]);
6077 contextGL()->ClearDepthf(m_clearDepth);
6078 contextGL()->ClearStencil(m_clearStencil);
6079 }
6080
6081 void WebGLRenderingContextBase::DrawingBufferClientRestorePixelPackAlignment() {
6082 if (!contextGL())
6083 return;
6084 contextGL()->PixelStorei(GL_PACK_ALIGNMENT, m_packAlignment);
6085 }
6086
6087 void WebGLRenderingContextBase::DrawingBufferClientRestoreTexture2DBinding() {
6088 if (!contextGL())
6089 return;
6090 restoreCurrentTexture2D();
6091 }
6092
6093 void WebGLRenderingContextBase::
6094 DrawingBufferClientRestoreRenderbufferBinding() {
6095 if (!contextGL())
6096 return;
6097 contextGL()->BindRenderbuffer(GL_RENDERBUFFER,
6098 objectOrZero(m_renderbufferBinding.get()));
6099 }
6100
6101 void WebGLRenderingContextBase::DrawingBufferClientRestoreFramebufferBinding() {
6102 if (!contextGL())
6103 return;
6104 restoreCurrentFramebuffer();
6105 }
6106
6107 void WebGLRenderingContextBase::
6108 DrawingBufferClientRestorePixelUnpackBufferBinding() {}
6109
6130 ScriptValue WebGLRenderingContextBase::getBooleanParameter( 6110 ScriptValue WebGLRenderingContextBase::getBooleanParameter(
6131 ScriptState* scriptState, 6111 ScriptState* scriptState,
6132 GLenum pname) { 6112 GLenum pname) {
6133 GLboolean value = 0; 6113 GLboolean value = 0;
6134 if (!isContextLost()) 6114 if (!isContextLost())
6135 contextGL()->GetBooleanv(pname, &value); 6115 contextGL()->GetBooleanv(pname, &value);
6136 return WebGLAny(scriptState, static_cast<bool>(value)); 6116 return WebGLAny(scriptState, static_cast<bool>(value));
6137 } 6117 }
6138 6118
6139 ScriptValue WebGLRenderingContextBase::getBooleanArrayParameter( 6119 ScriptValue WebGLRenderingContextBase::getBooleanArrayParameter(
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
7413 7393
7414 void WebGLRenderingContextBase::setFramebuffer(GLenum target, 7394 void WebGLRenderingContextBase::setFramebuffer(GLenum target,
7415 WebGLFramebuffer* buffer) { 7395 WebGLFramebuffer* buffer) {
7416 if (buffer) 7396 if (buffer)
7417 buffer->setHasEverBeenBound(); 7397 buffer->setHasEverBeenBound();
7418 7398
7419 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { 7399 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) {
7420 m_framebufferBinding = buffer; 7400 m_framebufferBinding = buffer;
7421 applyStencilTest(); 7401 applyStencilTest();
7422 } 7402 }
7423 drawingBuffer()->setFramebufferBinding(
7424 target, objectOrZero(getFramebufferBinding(target)));
7425
7426 if (!buffer) { 7403 if (!buffer) {
7427 // Instead of binding fb 0, bind the drawing buffer. 7404 // Instead of binding fb 0, bind the drawing buffer.
7428 drawingBuffer()->bind(target); 7405 drawingBuffer()->bind(target);
7429 } else { 7406 } else {
7430 contextGL()->BindFramebuffer(target, buffer->object()); 7407 contextGL()->BindFramebuffer(target, buffer->object());
7431 } 7408 }
7432 } 7409 }
7433 7410
7434 void WebGLRenderingContextBase::restoreCurrentFramebuffer() { 7411 void WebGLRenderingContextBase::restoreCurrentFramebuffer() {
7435 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); 7412 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
7545 7522
7546 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7523 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7547 HTMLCanvasElementOrOffscreenCanvas& result) const { 7524 HTMLCanvasElementOrOffscreenCanvas& result) const {
7548 if (canvas()) 7525 if (canvas())
7549 result.setHTMLCanvasElement(canvas()); 7526 result.setHTMLCanvasElement(canvas());
7550 else 7527 else
7551 result.setOffscreenCanvas(getOffscreenCanvas()); 7528 result.setOffscreenCanvas(getOffscreenCanvas());
7552 } 7529 }
7553 7530
7554 } // namespace blink 7531 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698