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

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

Issue 1856933002: WebGL GL_RGB emulation to support IOSurfaces on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from kbr. Created 4 years, 7 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 #include "platform/graphics/gpu/DrawingBuffer.h" 92 #include "platform/graphics/gpu/DrawingBuffer.h"
93 #include "public/platform/Platform.h" 93 #include "public/platform/Platform.h"
94 #include "public/platform/WebGraphicsContext3DProvider.h" 94 #include "public/platform/WebGraphicsContext3DProvider.h"
95 #include "public/platform/functional/WebFunction.h" 95 #include "public/platform/functional/WebFunction.h"
96 #include "wtf/Functional.h" 96 #include "wtf/Functional.h"
97 #include "wtf/PassOwnPtr.h" 97 #include "wtf/PassOwnPtr.h"
98 #include "wtf/text/StringBuilder.h" 98 #include "wtf/text/StringBuilder.h"
99 #include "wtf/text/StringUTF8Adaptor.h" 99 #include "wtf/text/StringUTF8Adaptor.h"
100 #include "wtf/typed_arrays/ArrayBufferContents.h" 100 #include "wtf/typed_arrays/ArrayBufferContents.h"
101 101
102 #include <memory>
103
102 namespace blink { 104 namespace blink {
103 105
104 namespace { 106 namespace {
105 107
106 const double secondsBetweenRestoreAttempts = 1.0; 108 const double secondsBetweenRestoreAttempts = 1.0;
107 const int maxGLErrorsAllowedToConsole = 256; 109 const int maxGLErrorsAllowedToConsole = 256;
108 const unsigned maxGLActiveContexts = 16; 110 const unsigned maxGLActiveContexts = 16;
109 111
110 using WebGLRenderingContextBaseSet = PersistentHeapHashSet<WeakMember<WebGLRende ringContextBase>>; 112 using WebGLRenderingContextBaseSet = PersistentHeapHashSet<WeakMember<WebGLRende ringContextBase>>;
111 WebGLRenderingContextBaseSet& activeContexts() 113 WebGLRenderingContextBaseSet& activeContexts()
112 { 114 {
113 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseSet, activeContexts, ()); 115 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseSet, activeContexts, ());
114 return activeContexts; 116 return activeContexts;
115 } 117 }
116 118
117 using WebGLRenderingContextBaseMap = PersistentHeapHashMap<WeakMember<WebGLRende ringContextBase>, int>; 119 using WebGLRenderingContextBaseMap = PersistentHeapHashMap<WeakMember<WebGLRende ringContextBase>, int>;
118 WebGLRenderingContextBaseMap& forciblyEvictedContexts() 120 WebGLRenderingContextBaseMap& forciblyEvictedContexts()
119 { 121 {
120 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseMap, forciblyEvictedContexts, ( )); 122 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseMap, forciblyEvictedContexts, ( ));
121 return forciblyEvictedContexts; 123 return forciblyEvictedContexts;
122 } 124 }
123 125
124 } // namespace 126 } // namespace
125 127
128 ScopedRGBEmulationColorMask::ScopedRGBEmulationColorMask(gpu::gles2::GLES2Interf ace* contextGL, GLboolean* colorMask, DrawingBuffer* drawingBuffer)
129 : m_contextGL(contextGL)
130 , m_requiresEmulation(drawingBuffer->requiresRGBEmulation())
131 {
132 if (m_requiresEmulation) {
133 memcpy(m_colorMask, colorMask, 4 * sizeof(GLboolean));
134 m_contextGL->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], f alse);
135 }
136 }
137
138 ScopedRGBEmulationColorMask::~ScopedRGBEmulationColorMask()
139 {
140 if (m_requiresEmulation)
141 m_contextGL->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], m _colorMask[3]);
142 }
143
126 void WebGLRenderingContextBase::forciblyLoseOldestContext(const String& reason) 144 void WebGLRenderingContextBase::forciblyLoseOldestContext(const String& reason)
127 { 145 {
128 WebGLRenderingContextBase* candidate = oldestContext(); 146 WebGLRenderingContextBase* candidate = oldestContext();
129 if (!candidate) 147 if (!candidate)
130 return; 148 return;
131 149
132 candidate->printWarningToConsole(reason); 150 candidate->printWarningToConsole(reason);
133 InspectorInstrumentation::didFireWebGLWarning(candidate->canvas()); 151 InspectorInstrumentation::didFireWebGLWarning(candidate->canvas());
134 152
135 // This will call deactivateContext once the context has actually been lost. 153 // This will call deactivateContext once the context has actually been lost.
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 m_stencilEnabled = false; 913 m_stencilEnabled = false;
896 m_stencilMask = 0xFFFFFFFF; 914 m_stencilMask = 0xFFFFFFFF;
897 m_stencilMaskBack = 0xFFFFFFFF; 915 m_stencilMaskBack = 0xFFFFFFFF;
898 m_stencilFuncRef = 0; 916 m_stencilFuncRef = 0;
899 m_stencilFuncRefBack = 0; 917 m_stencilFuncRefBack = 0;
900 m_stencilFuncMask = 0xFFFFFFFF; 918 m_stencilFuncMask = 0xFFFFFFFF;
901 m_stencilFuncMaskBack = 0xFFFFFFFF; 919 m_stencilFuncMaskBack = 0xFFFFFFFF;
902 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; 920 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole;
903 921
904 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; 922 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0;
923 drawingBuffer()->setClearColor(m_clearColor);
905 m_scissorEnabled = false; 924 m_scissorEnabled = false;
906 m_clearDepth = 1; 925 m_clearDepth = 1;
907 m_clearStencil = 0; 926 m_clearStencil = 0;
908 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; 927 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true;
928 drawingBuffer()->setColorMask(m_colorMask);
909 929
910 GLint numCombinedTextureImageUnits = 0; 930 GLint numCombinedTextureImageUnits = 0;
911 contextGL()->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTe xtureImageUnits); 931 contextGL()->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTe xtureImageUnits);
912 m_textureUnits.clear(); 932 m_textureUnits.clear();
913 m_textureUnits.resize(numCombinedTextureImageUnits); 933 m_textureUnits.resize(numCombinedTextureImageUnits);
914 934
915 GLint numVertexAttribs = 0; 935 GLint numVertexAttribs = 0;
916 contextGL()->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); 936 contextGL()->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs);
917 m_maxVertexAttribs = numVertexAttribs; 937 m_maxVertexAttribs = numVertexAttribs;
918 938
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1157
1138 contextGL()->Disable(GL_SCISSOR_TEST); 1158 contextGL()->Disable(GL_SCISSOR_TEST);
1139 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { 1159 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) {
1140 contextGL()->ClearColor(m_colorMask[0] ? m_clearColor[0] : 0, 1160 contextGL()->ClearColor(m_colorMask[0] ? m_clearColor[0] : 0,
1141 m_colorMask[1] ? m_clearColor[1] : 0, 1161 m_colorMask[1] ? m_clearColor[1] : 0,
1142 m_colorMask[2] ? m_clearColor[2] : 0, 1162 m_colorMask[2] ? m_clearColor[2] : 0,
1143 m_colorMask[3] ? m_clearColor[3] : 0); 1163 m_colorMask[3] ? m_clearColor[3] : 0);
1144 } else { 1164 } else {
1145 contextGL()->ClearColor(0, 0, 0, 0); 1165 contextGL()->ClearColor(0, 0, 0, 0);
1146 } 1166 }
1147 contextGL()->ColorMask(true, true, true, true); 1167 contextGL()->ColorMask(true, true, true, !drawingBuffer()->requiresRGBEmulat ion());
1148 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; 1168 GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
1149 if (contextAttributes.get().depth()) { 1169 if (contextAttributes.get().depth()) {
1150 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) 1170 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT))
1151 contextGL()->ClearDepthf(1.0f); 1171 contextGL()->ClearDepthf(1.0f);
1152 clearMask |= GL_DEPTH_BUFFER_BIT; 1172 clearMask |= GL_DEPTH_BUFFER_BIT;
1153 contextGL()->DepthMask(true); 1173 contextGL()->DepthMask(true);
1154 } 1174 }
1155 if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencil Buffer()) { 1175 if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencil Buffer()) {
1156 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) 1176 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT))
1157 contextGL()->ClearStencil(m_clearStencil & m_stencilMask); 1177 contextGL()->ClearStencil(m_clearStencil & m_stencilMask);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 return; 1449 return;
1430 if (deleted) 1450 if (deleted)
1431 renderBuffer = 0; 1451 renderBuffer = 0;
1432 if (target != GL_RENDERBUFFER) { 1452 if (target != GL_RENDERBUFFER) {
1433 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ; 1453 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ;
1434 return; 1454 return;
1435 } 1455 }
1436 m_renderbufferBinding = renderBuffer; 1456 m_renderbufferBinding = renderBuffer;
1437 contextGL()->BindRenderbuffer(target, objectOrZero(renderBuffer)); 1457 contextGL()->BindRenderbuffer(target, objectOrZero(renderBuffer));
1438 preserveObjectWrapper(scriptState, this, "renderbuffer", 0, renderBuffer); 1458 preserveObjectWrapper(scriptState, this, "renderbuffer", 0, renderBuffer);
1459
1460 drawingBuffer()->setRenderbufferBinding(objectOrZero(renderBuffer));
1461
1439 if (renderBuffer) 1462 if (renderBuffer)
1440 renderBuffer->setHasEverBeenBound(); 1463 renderBuffer->setHasEverBeenBound();
1441 } 1464 }
1442 1465
1443 void WebGLRenderingContextBase::bindTexture(ScriptState* scriptState, GLenum tar get, WebGLTexture* texture) 1466 void WebGLRenderingContextBase::bindTexture(ScriptState* scriptState, GLenum tar get, WebGLTexture* texture)
1444 { 1467 {
1445 bool deleted; 1468 bool deleted;
1446 if (!checkObjectToBeBound("bindTexture", texture, deleted)) 1469 if (!checkObjectToBeBound("bindTexture", texture, deleted))
1447 return; 1470 return;
1448 if (deleted) 1471 if (deleted)
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 return; 1690 return;
1668 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B IT)) { 1691 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B IT)) {
1669 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); 1692 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask");
1670 return; 1693 return;
1671 } 1694 }
1672 const char* reason = "framebuffer incomplete"; 1695 const char* reason = "framebuffer incomplete";
1673 if (m_framebufferBinding && m_framebufferBinding->checkDepthStencilStatus(&r eason) != GL_FRAMEBUFFER_COMPLETE) { 1696 if (m_framebufferBinding && m_framebufferBinding->checkDepthStencilStatus(&r eason) != GL_FRAMEBUFFER_COMPLETE) {
1674 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); 1697 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason);
1675 return; 1698 return;
1676 } 1699 }
1700
1701 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get());
1702
1677 if (clearIfComposited(mask) != CombinedClear) { 1703 if (clearIfComposited(mask) != CombinedClear) {
1678 // If clearing the default back buffer's depth buffer, also clear the st encil buffer, if one 1704 // If clearing the default back buffer's depth buffer, also clear the st encil buffer, if one
1679 // was allocated implicitly. This avoids performance problems on some GP Us. 1705 // was allocated implicitly. This avoids performance problems on some GP Us.
1680 if (!m_framebufferBinding && drawingBuffer()->hasImplicitStencilBuffer() && (mask & GL_DEPTH_BUFFER_BIT)) { 1706 if (!m_framebufferBinding && drawingBuffer()->hasImplicitStencilBuffer() && (mask & GL_DEPTH_BUFFER_BIT)) {
1681 // It shouldn't matter what value it's cleared to, since in other qu eries in the API, we 1707 // It shouldn't matter what value it's cleared to, since in other qu eries in the API, we
1682 // claim that the stencil buffer doesn't exist. 1708 // claim that the stencil buffer doesn't exist.
1683 mask |= GL_STENCIL_BUFFER_BIT; 1709 mask |= GL_STENCIL_BUFFER_BIT;
1684 } 1710 }
1685 contextGL()->Clear(mask); 1711 contextGL()->Clear(mask);
1686 } 1712 }
1687 markContextChanged(CanvasChanged); 1713 markContextChanged(CanvasChanged);
1688 } 1714 }
1689 1715
1690 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl oat a) 1716 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl oat a)
1691 { 1717 {
1692 if (isContextLost()) 1718 if (isContextLost())
1693 return; 1719 return;
1694 if (std::isnan(r)) 1720 if (std::isnan(r))
1695 r = 0; 1721 r = 0;
1696 if (std::isnan(g)) 1722 if (std::isnan(g))
1697 g = 0; 1723 g = 0;
1698 if (std::isnan(b)) 1724 if (std::isnan(b))
1699 b = 0; 1725 b = 0;
1700 if (std::isnan(a)) 1726 if (std::isnan(a))
1701 a = 1; 1727 a = 1;
1702 m_clearColor[0] = r; 1728 m_clearColor[0] = r;
1703 m_clearColor[1] = g; 1729 m_clearColor[1] = g;
1704 m_clearColor[2] = b; 1730 m_clearColor[2] = b;
1705 m_clearColor[3] = a; 1731 m_clearColor[3] = a;
1732 drawingBuffer()->setClearColor(m_clearColor);
1706 contextGL()->ClearColor(r, g, b, a); 1733 contextGL()->ClearColor(r, g, b, a);
1707 } 1734 }
1708 1735
1709 void WebGLRenderingContextBase::clearDepth(GLfloat depth) 1736 void WebGLRenderingContextBase::clearDepth(GLfloat depth)
1710 { 1737 {
1711 if (isContextLost()) 1738 if (isContextLost())
1712 return; 1739 return;
1713 m_clearDepth = depth; 1740 m_clearDepth = depth;
1714 contextGL()->ClearDepthf(depth); 1741 contextGL()->ClearDepthf(depth);
1715 } 1742 }
1716 1743
1717 void WebGLRenderingContextBase::clearStencil(GLint s) 1744 void WebGLRenderingContextBase::clearStencil(GLint s)
1718 { 1745 {
1719 if (isContextLost()) 1746 if (isContextLost())
1720 return; 1747 return;
1721 m_clearStencil = s; 1748 m_clearStencil = s;
1722 contextGL()->ClearStencil(s); 1749 contextGL()->ClearStencil(s);
1723 } 1750 }
1724 1751
1725 void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLbool ean blue, GLboolean alpha) 1752 void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLbool ean blue, GLboolean alpha)
1726 { 1753 {
1727 if (isContextLost()) 1754 if (isContextLost())
1728 return; 1755 return;
1729 m_colorMask[0] = red; 1756 m_colorMask[0] = red;
1730 m_colorMask[1] = green; 1757 m_colorMask[1] = green;
1731 m_colorMask[2] = blue; 1758 m_colorMask[2] = blue;
1732 m_colorMask[3] = alpha; 1759 m_colorMask[3] = alpha;
1760 drawingBuffer()->setColorMask(m_colorMask);
1733 contextGL()->ColorMask(red, green, blue, alpha); 1761 contextGL()->ColorMask(red, green, blue, alpha);
1734 } 1762 }
1735 1763
1736 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) 1764 void WebGLRenderingContextBase::compileShader(WebGLShader* shader)
1737 { 1765 {
1738 if (isContextLost() || !validateWebGLObject("compileShader", shader)) 1766 if (isContextLost() || !validateWebGLObject("compileShader", shader))
1739 return; 1767 return;
1740 contextGL()->CompileShader(objectOrZero(shader)); 1768 contextGL()->CompileShader(objectOrZero(shader));
1741 } 1769 }
1742 1770
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 { 1966 {
1939 deleteObject(program); 1967 deleteObject(program);
1940 // We don't reset m_currentProgram to 0 here because the deletion of the 1968 // We don't reset m_currentProgram to 0 here because the deletion of the
1941 // current program is delayed. 1969 // current program is delayed.
1942 } 1970 }
1943 1971
1944 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff er) 1972 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff er)
1945 { 1973 {
1946 if (!deleteObject(renderbuffer)) 1974 if (!deleteObject(renderbuffer))
1947 return; 1975 return;
1948 if (renderbuffer == m_renderbufferBinding) 1976 if (renderbuffer == m_renderbufferBinding) {
1949 m_renderbufferBinding = nullptr; 1977 m_renderbufferBinding = nullptr;
1978 drawingBuffer()->setRenderbufferBinding(0);
1979 }
1950 if (m_framebufferBinding) 1980 if (m_framebufferBinding)
1951 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFE R, renderbuffer); 1981 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFE R, renderbuffer);
1952 if (getFramebufferBinding(GL_READ_FRAMEBUFFER)) 1982 if (getFramebufferBinding(GL_READ_FRAMEBUFFER))
1953 getFramebufferBinding(GL_READ_FRAMEBUFFER)->removeAttachmentFromBoundFra mebuffer(GL_READ_FRAMEBUFFER, renderbuffer); 1983 getFramebufferBinding(GL_READ_FRAMEBUFFER)->removeAttachmentFromBoundFra mebuffer(GL_READ_FRAMEBUFFER, renderbuffer);
1954 } 1984 }
1955 1985
1956 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) 1986 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader)
1957 { 1987 {
1958 deleteObject(shader); 1988 deleteObject(shader);
1959 } 1989 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 return false; 2117 return false;
2088 } 2118 }
2089 return true; 2119 return true;
2090 } 2120 }
2091 2121
2092 void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou nt) 2122 void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou nt)
2093 { 2123 {
2094 if (!validateDrawArrays("drawArrays")) 2124 if (!validateDrawArrays("drawArrays"))
2095 return; 2125 return;
2096 2126
2127 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get());
2097 clearIfComposited(); 2128 clearIfComposited();
2098 contextGL()->DrawArrays(mode, first, count); 2129 contextGL()->DrawArrays(mode, first, count);
2099 markContextChanged(CanvasChanged); 2130 markContextChanged(CanvasChanged);
2100 } 2131 }
2101 2132
2102 void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum type, long long offset) 2133 void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum type, long long offset)
2103 { 2134 {
2104 if (!validateDrawElements("drawElements", type, offset)) 2135 if (!validateDrawElements("drawElements", type, offset))
2105 return; 2136 return;
2106 2137
2107 if (transformFeedbackActive() && !transformFeedbackPaused()) { 2138 if (transformFeedbackActive() && !transformFeedbackPaused()) {
2108 synthesizeGLError(GL_INVALID_OPERATION, "drawElements", "transform feedb ack is active and not paused"); 2139 synthesizeGLError(GL_INVALID_OPERATION, "drawElements", "transform feedb ack is active and not paused");
2109 return; 2140 return;
2110 } 2141 }
2111 2142
2143 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get());
2112 clearIfComposited(); 2144 clearIfComposited();
2113 contextGL()->DrawElements(mode, count, type, reinterpret_cast<void*>(static_ cast<intptr_t>(offset))); 2145 contextGL()->DrawElements(mode, count, type, reinterpret_cast<void*>(static_ cast<intptr_t>(offset)));
2114 markContextChanged(CanvasChanged); 2146 markContextChanged(CanvasChanged);
2115 } 2147 }
2116 2148
2117 void WebGLRenderingContextBase::drawArraysInstancedANGLE(GLenum mode, GLint firs t, GLsizei count, GLsizei primcount) 2149 void WebGLRenderingContextBase::drawArraysInstancedANGLE(GLenum mode, GLint firs t, GLsizei count, GLsizei primcount)
2118 { 2150 {
2119 if (!validateDrawArrays("drawArraysInstancedANGLE")) 2151 if (!validateDrawArrays("drawArraysInstancedANGLE"))
2120 return; 2152 return;
2121 2153
2154 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get());
2122 clearIfComposited(); 2155 clearIfComposited();
2123 contextGL()->DrawArraysInstancedANGLE(mode, first, count, primcount); 2156 contextGL()->DrawArraysInstancedANGLE(mode, first, count, primcount);
2124 markContextChanged(CanvasChanged); 2157 markContextChanged(CanvasChanged);
2125 } 2158 }
2126 2159
2127 void WebGLRenderingContextBase::drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, long long offset, GLsizei primcount) 2160 void WebGLRenderingContextBase::drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, long long offset, GLsizei primcount)
2128 { 2161 {
2129 if (!validateDrawElements("drawElementsInstancedANGLE", type, offset)) 2162 if (!validateDrawElements("drawElementsInstancedANGLE", type, offset))
2130 return; 2163 return;
2131 2164
2165 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d rawingBuffer.get());
2132 clearIfComposited(); 2166 clearIfComposited();
2133 contextGL()->DrawElementsInstancedANGLE(mode, count, type, reinterpret_cast< void*>(static_cast<intptr_t>(offset)), primcount); 2167 contextGL()->DrawElementsInstancedANGLE(mode, count, type, reinterpret_cast< void*>(static_cast<intptr_t>(offset)), primcount);
2134 markContextChanged(CanvasChanged); 2168 markContextChanged(CanvasChanged);
2135 } 2169 }
2136 2170
2137 void WebGLRenderingContextBase::enable(GLenum cap) 2171 void WebGLRenderingContextBase::enable(GLenum cap)
2138 { 2172 {
2139 if (isContextLost() || !validateCapability("enable", cap)) 2173 if (isContextLost() || !validateCapability("enable", cap))
2140 return; 2174 return;
2141 if (cap == GL_STENCIL_TEST) { 2175 if (cap == GL_STENCIL_TEST) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 return ScriptValue::createNull(scriptState); 2587 return ScriptValue::createNull(scriptState);
2554 const int intZero = 0; 2588 const int intZero = 0;
2555 switch (pname) { 2589 switch (pname) {
2556 case GL_ACTIVE_TEXTURE: 2590 case GL_ACTIVE_TEXTURE:
2557 return getUnsignedIntParameter(scriptState, pname); 2591 return getUnsignedIntParameter(scriptState, pname);
2558 case GL_ALIASED_LINE_WIDTH_RANGE: 2592 case GL_ALIASED_LINE_WIDTH_RANGE:
2559 return getWebGLFloatArrayParameter(scriptState, pname); 2593 return getWebGLFloatArrayParameter(scriptState, pname);
2560 case GL_ALIASED_POINT_SIZE_RANGE: 2594 case GL_ALIASED_POINT_SIZE_RANGE:
2561 return getWebGLFloatArrayParameter(scriptState, pname); 2595 return getWebGLFloatArrayParameter(scriptState, pname);
2562 case GL_ALPHA_BITS: 2596 case GL_ALPHA_BITS:
2597 if (m_drawingBuffer->requiresRGBEmulation())
2598 return WebGLAny(scriptState, 0);
2563 return getIntParameter(scriptState, pname); 2599 return getIntParameter(scriptState, pname);
2564 case GL_ARRAY_BUFFER_BINDING: 2600 case GL_ARRAY_BUFFER_BINDING:
2565 return WebGLAny(scriptState, m_boundArrayBuffer.get()); 2601 return WebGLAny(scriptState, m_boundArrayBuffer.get());
2566 case GL_BLEND: 2602 case GL_BLEND:
2567 return getBooleanParameter(scriptState, pname); 2603 return getBooleanParameter(scriptState, pname);
2568 case GL_BLEND_COLOR: 2604 case GL_BLEND_COLOR:
2569 return getWebGLFloatArrayParameter(scriptState, pname); 2605 return getWebGLFloatArrayParameter(scriptState, pname);
2570 case GL_BLEND_DST_ALPHA: 2606 case GL_BLEND_DST_ALPHA:
2571 return getUnsignedIntParameter(scriptState, pname); 2607 return getUnsignedIntParameter(scriptState, pname);
2572 case GL_BLEND_DST_RGB: 2608 case GL_BLEND_DST_RGB:
(...skipping 2401 matching lines...) Expand 10 before | Expand all | Expand 10 after
4974 if (isContextLost()) 5010 if (isContextLost())
4975 return; 5011 return;
4976 5012
4977 m_contextLostMode = mode; 5013 m_contextLostMode = mode;
4978 ASSERT(m_contextLostMode != NotLostContext); 5014 ASSERT(m_contextLostMode != NotLostContext);
4979 m_autoRecoveryMethod = autoRecoveryMethod; 5015 m_autoRecoveryMethod = autoRecoveryMethod;
4980 5016
4981 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. 5017 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer.
4982 drawingBuffer()->setTexture2DBinding(0); 5018 drawingBuffer()->setTexture2DBinding(0);
4983 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0); 5019 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0);
5020 drawingBuffer()->setRenderbufferBinding(0);
4984 5021
4985 detachAndRemoveAllObjects(); 5022 detachAndRemoveAllObjects();
4986 5023
4987 // Lose all the extensions. 5024 // Lose all the extensions.
4988 for (size_t i = 0; i < m_extensions.size(); ++i) { 5025 for (size_t i = 0; i < m_extensions.size(); ++i) {
4989 ExtensionTracker* tracker = m_extensions[i]; 5026 ExtensionTracker* tracker = m_extensions[i];
4990 tracker->loseExtension(false); 5027 tracker->loseExtension(false);
4991 } 5028 }
4992 5029
4993 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) 5030 for (size_t i = 0; i < WebGLExtensionNameCount; ++i)
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
6270 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6307 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6271 } 6308 }
6272 6309
6273 void WebGLRenderingContextBase::restoreUnpackParameters() 6310 void WebGLRenderingContextBase::restoreUnpackParameters()
6274 { 6311 {
6275 if (m_unpackAlignment != 1) 6312 if (m_unpackAlignment != 1)
6276 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6313 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6277 } 6314 }
6278 6315
6279 } // namespace blink 6316 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698