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

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

Issue 2547813002: Remove WebGLObject maps from WebGLRenderingContextBase and WebGLContextGroup. (Closed)
Patch Set: Fixed WebGLContextObject::validate. Made WebGLExtension non-finalized. Created 4 years 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 WebGLRenderingContextBase* context) { 230 WebGLRenderingContextBase* context) {
231 static int generation = 0; 231 static int generation = 0;
232 forciblyEvictedContexts().set(context, generation++); 232 forciblyEvictedContexts().set(context, generation++);
233 } 233 }
234 234
235 void WebGLRenderingContextBase::removeFromEvictedList( 235 void WebGLRenderingContextBase::removeFromEvictedList(
236 WebGLRenderingContextBase* context) { 236 WebGLRenderingContextBase* context) {
237 forciblyEvictedContexts().remove(context); 237 forciblyEvictedContexts().remove(context);
238 } 238 }
239 239
240 void WebGLRenderingContextBase::willDestroyContext( 240 void WebGLRenderingContextBase::restoreEvictedContext(
241 WebGLRenderingContextBase* context) { 241 WebGLRenderingContextBase* context) {
242 // These two sets keep weak references to their contexts; 242 // These two sets keep weak references to their contexts;
243 // verify that the GC already removed the |context| entries. 243 // verify that the GC already removed the |context| entries.
244 ASSERT(!forciblyEvictedContexts().contains(context)); 244 ASSERT(!forciblyEvictedContexts().contains(context));
245 ASSERT(!activeContexts().contains(context)); 245 ASSERT(!activeContexts().contains(context));
246 246
247 unsigned maxGLContexts = currentMaxGLContexts(); 247 unsigned maxGLContexts = currentMaxGLContexts();
248 // Try to re-enable the oldest inactive contexts. 248 // Try to re-enable the oldest inactive contexts.
249 while (activeContexts().size() < maxGLContexts && 249 while (activeContexts().size() < maxGLContexts &&
250 forciblyEvictedContexts().size()) { 250 forciblyEvictedContexts().size()) {
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 991
992 WebGLRenderingContextBase::WebGLRenderingContextBase( 992 WebGLRenderingContextBase::WebGLRenderingContextBase(
993 HTMLCanvasElement* passedCanvas, 993 HTMLCanvasElement* passedCanvas,
994 OffscreenCanvas* passedOffscreenCanvas, 994 OffscreenCanvas* passedOffscreenCanvas,
995 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, 995 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider,
996 const CanvasContextCreationAttributes& requestedAttributes, 996 const CanvasContextCreationAttributes& requestedAttributes,
997 unsigned version) 997 unsigned version)
998 : CanvasRenderingContext(passedCanvas, 998 : CanvasRenderingContext(passedCanvas,
999 passedOffscreenCanvas, 999 passedOffscreenCanvas,
1000 requestedAttributes), 1000 requestedAttributes),
1001 m_contextGroup(this, new WebGLContextGroup()),
1001 m_isHidden(false), 1002 m_isHidden(false),
1002 m_contextLostMode(NotLostContext), 1003 m_contextLostMode(NotLostContext),
1003 m_autoRecoveryMethod(Manual), 1004 m_autoRecoveryMethod(Manual),
1004 m_dispatchContextLostEventTimer( 1005 m_dispatchContextLostEventTimer(
1005 this, 1006 this,
1006 &WebGLRenderingContextBase::dispatchContextLostEvent), 1007 &WebGLRenderingContextBase::dispatchContextLostEvent),
1007 m_restoreAllowed(false), 1008 m_restoreAllowed(false),
1008 m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext), 1009 m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext),
1009 m_boundArrayBuffer(this, nullptr), 1010 m_boundArrayBuffer(this, nullptr),
1010 m_boundVertexArrayObject(this, nullptr), 1011 m_boundVertexArrayObject(this, nullptr),
1011 m_currentProgram(this, nullptr), 1012 m_currentProgram(this, nullptr),
1012 m_framebufferBinding(this, nullptr), 1013 m_framebufferBinding(this, nullptr),
1013 m_renderbufferBinding(this, nullptr), 1014 m_renderbufferBinding(this, nullptr),
1014 m_generatedImageCache(4), 1015 m_generatedImageCache(4),
1015 m_synthesizedErrorsToConsole(true), 1016 m_synthesizedErrorsToConsole(true),
1016 m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole), 1017 m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole),
1017 m_onePlusMaxNonDefaultTextureUnit(0), 1018 m_onePlusMaxNonDefaultTextureUnit(0),
1018 m_isWebGL2FormatsTypesAdded(false), 1019 m_isWebGL2FormatsTypesAdded(false),
1019 m_isWebGL2TexImageSourceFormatsTypesAdded(false), 1020 m_isWebGL2TexImageSourceFormatsTypesAdded(false),
1020 m_isWebGL2InternalFormatsCopyTexImageAdded(false), 1021 m_isWebGL2InternalFormatsCopyTexImageAdded(false),
1021 m_isOESTextureFloatFormatsTypesAdded(false), 1022 m_isOESTextureFloatFormatsTypesAdded(false),
1022 m_isOESTextureHalfFloatFormatsTypesAdded(false), 1023 m_isOESTextureHalfFloatFormatsTypesAdded(false),
1023 m_isWebGLDepthTextureFormatsTypesAdded(false), 1024 m_isWebGLDepthTextureFormatsTypesAdded(false),
1024 m_isEXTsRGBFormatsTypesAdded(false), 1025 m_isEXTsRGBFormatsTypesAdded(false),
1025 m_version(version) { 1026 m_version(version) {
1026 ASSERT(contextProvider); 1027 ASSERT(contextProvider);
1027 1028
1028 m_contextGroup = WebGLContextGroup::create();
1029 m_contextGroup->addContext(this); 1029 m_contextGroup->addContext(this);
1030 1030
1031 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; 1031 m_maxViewportDims[0] = m_maxViewportDims[1] = 0;
1032 contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, 1032 contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS,
1033 m_maxViewportDims); 1033 m_maxViewportDims);
1034 1034
1035 RefPtr<DrawingBuffer> buffer; 1035 RefPtr<DrawingBuffer> buffer;
1036 // On Mac OS, DrawingBuffer is using an IOSurface as its backing storage, this 1036 // On Mac OS, DrawingBuffer is using an IOSurface as its backing storage, this
1037 // allows WebGL-rendered canvases to be composited by the OS rather than 1037 // allows WebGL-rendered canvases to be composited by the OS rather than
1038 // Chrome. 1038 // Chrome.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 // These two values from EXT_draw_buffers are lazily queried. 1166 // These two values from EXT_draw_buffers are lazily queried.
1167 m_maxDrawBuffers = 0; 1167 m_maxDrawBuffers = 0;
1168 m_maxColorAttachments = 0; 1168 m_maxColorAttachments = 0;
1169 1169
1170 m_backDrawBuffer = GL_BACK; 1170 m_backDrawBuffer = GL_BACK;
1171 1171
1172 m_readBufferOfDefaultFramebuffer = GL_BACK; 1172 m_readBufferOfDefaultFramebuffer = GL_BACK;
1173 1173
1174 m_defaultVertexArrayObject = WebGLVertexArrayObject::create( 1174 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(
1175 this, WebGLVertexArrayObjectBase::VaoTypeDefault); 1175 this, WebGLVertexArrayObjectBase::VaoTypeDefault);
1176 addContextObject(m_defaultVertexArrayObject.get());
1177 1176
1178 m_boundVertexArrayObject = m_defaultVertexArrayObject; 1177 m_boundVertexArrayObject = m_defaultVertexArrayObject;
1179 1178
1180 m_vertexAttribType.resize(m_maxVertexAttribs); 1179 m_vertexAttribType.resize(m_maxVertexAttribs);
1181 1180
1182 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); 1181 contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight());
1183 m_scissorBox[0] = m_scissorBox[1] = 0; 1182 m_scissorBox[0] = m_scissorBox[1] = 0;
1184 m_scissorBox[2] = drawingBufferWidth(); 1183 m_scissorBox[2] = drawingBufferWidth();
1185 m_scissorBox[3] = drawingBufferHeight(); 1184 m_scissorBox[3] = drawingBufferHeight();
1186 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2], 1185 contextGL()->Scissor(m_scissorBox[0], m_scissorBox[1], m_scissorBox[2],
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 // Helper function for V8 bindings to identify what version of WebGL a 1264 // Helper function for V8 bindings to identify what version of WebGL a
1266 // CanvasRenderingContext supports. 1265 // CanvasRenderingContext supports.
1267 unsigned WebGLRenderingContextBase::getWebGLVersion( 1266 unsigned WebGLRenderingContextBase::getWebGLVersion(
1268 const CanvasRenderingContext* context) { 1267 const CanvasRenderingContext* context) {
1269 if (!context->is3d()) 1268 if (!context->is3d())
1270 return 0; 1269 return 0;
1271 return static_cast<const WebGLRenderingContextBase*>(context)->version(); 1270 return static_cast<const WebGLRenderingContextBase*>(context)->version();
1272 } 1271 }
1273 1272
1274 WebGLRenderingContextBase::~WebGLRenderingContextBase() { 1273 WebGLRenderingContextBase::~WebGLRenderingContextBase() {
1275 // Remove all references to WebGLObjects so if they are the last reference 1274 // Now that the context and context group no longer hold on to the
1276 // they will be freed before the last context is removed from the context 1275 // objects they create, and now that the objects are eagerly finalized
1277 // group. 1276 // rather than the context, there is very little useful work that this
1278 m_boundArrayBuffer = nullptr; 1277 // destructor can do, since it's not allowed to touch other on-heap
1279 m_defaultVertexArrayObject = nullptr; 1278 // objects. All it can do is destroy its underlying context, which, if
1280 m_boundVertexArrayObject = nullptr; 1279 // there are no other contexts in the same share group, will cause all of
1281 m_currentProgram = nullptr; 1280 // the underlying graphics resources to be deleted. (Currently, it's
1282 m_framebufferBinding = nullptr; 1281 // always the case that there are no other contexts in the same share
1283 m_renderbufferBinding = nullptr; 1282 // group -- resource sharing between WebGL contexts is not yet
1284 1283 // implemented, and due to its complex semantics, it's doubtful that it
1285 // WebGLTexture shared objects will be detached and deleted 1284 // ever will be.)
1286 // m_contextGroup->removeContext(this), which will bring about deleteTexture()
1287 // calls. We null these out to avoid accessing those members in
1288 // deleteTexture().
1289 for (size_t i = 0; i < m_textureUnits.size(); ++i) {
1290 m_textureUnits[i].m_texture2DBinding = nullptr;
1291 m_textureUnits[i].m_textureCubeMapBinding = nullptr;
1292 m_textureUnits[i].m_texture3DBinding = nullptr;
1293 m_textureUnits[i].m_texture2DArrayBinding = nullptr;
1294 }
1295
1296 detachAndRemoveAllObjects();
1297
1298 // Release all extensions now.
1299 for (ExtensionTracker* tracker : m_extensions) {
1300 tracker->loseExtension(true);
1301 }
1302 m_extensions.clear();
1303
1304 // Context must be removed from the group prior to the destruction of the
1305 // GL context, otherwise shared objects may not be properly deleted.
1306 m_contextGroup->removeContext(this);
1307
1308 destroyContext(); 1285 destroyContext();
1309 1286
1310 willDestroyContext(this); 1287 // Now that this context is destroyed, see if there's a
1288 // previously-evicted one that should be restored.
1289 restoreEvictedContext(this);
1311 } 1290 }
1312 1291
1313 void WebGLRenderingContextBase::destroyContext() { 1292 void WebGLRenderingContextBase::destroyContext() {
1314 if (!drawingBuffer()) 1293 if (!drawingBuffer())
1315 return; 1294 return;
1316 1295
1317 m_extensionsUtil.reset(); 1296 m_extensionsUtil.reset();
1318 1297
1319 std::unique_ptr<WTF::Closure> nullClosure; 1298 std::unique_ptr<WTF::Closure> nullClosure;
1320 std::unique_ptr<WTF::Function<void(const char*, int32_t)>> nullFunction; 1299 std::unique_ptr<WTF::Function<void(const char*, int32_t)>> nullFunction;
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 return; 2128 return;
2150 clearIfComposited(); 2129 clearIfComposited();
2151 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding); 2130 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding);
2152 contextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, 2131 contextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width,
2153 height); 2132 height);
2154 } 2133 }
2155 2134
2156 WebGLBuffer* WebGLRenderingContextBase::createBuffer() { 2135 WebGLBuffer* WebGLRenderingContextBase::createBuffer() {
2157 if (isContextLost()) 2136 if (isContextLost())
2158 return nullptr; 2137 return nullptr;
2159 WebGLBuffer* o = WebGLBuffer::create(this); 2138 return WebGLBuffer::create(this);
2160 addSharedObject(o);
2161 return o;
2162 } 2139 }
2163 2140
2164 WebGLFramebuffer* WebGLRenderingContextBase::createFramebuffer() { 2141 WebGLFramebuffer* WebGLRenderingContextBase::createFramebuffer() {
2165 if (isContextLost()) 2142 if (isContextLost())
2166 return nullptr; 2143 return nullptr;
2167 WebGLFramebuffer* o = WebGLFramebuffer::create(this); 2144 return WebGLFramebuffer::create(this);
2168 addContextObject(o);
2169 return o;
2170 } 2145 }
2171 2146
2172 WebGLTexture* WebGLRenderingContextBase::createTexture() { 2147 WebGLTexture* WebGLRenderingContextBase::createTexture() {
2173 if (isContextLost()) 2148 if (isContextLost())
2174 return nullptr; 2149 return nullptr;
2175 WebGLTexture* o = WebGLTexture::create(this); 2150 return WebGLTexture::create(this);
2176 addSharedObject(o);
2177 return o;
2178 } 2151 }
2179 2152
2180 WebGLProgram* WebGLRenderingContextBase::createProgram() { 2153 WebGLProgram* WebGLRenderingContextBase::createProgram() {
2181 if (isContextLost()) 2154 if (isContextLost())
2182 return nullptr; 2155 return nullptr;
2183 WebGLProgram* o = WebGLProgram::create(this); 2156 return WebGLProgram::create(this);
2184 addSharedObject(o);
2185 return o;
2186 } 2157 }
2187 2158
2188 WebGLRenderbuffer* WebGLRenderingContextBase::createRenderbuffer() { 2159 WebGLRenderbuffer* WebGLRenderingContextBase::createRenderbuffer() {
2189 if (isContextLost()) 2160 if (isContextLost())
2190 return nullptr; 2161 return nullptr;
2191 WebGLRenderbuffer* o = WebGLRenderbuffer::create(this); 2162 return WebGLRenderbuffer::create(this);
2192 addSharedObject(o);
2193 return o;
2194 } 2163 }
2195 2164
2196 void WebGLRenderingContextBase::setBoundVertexArrayObject( 2165 void WebGLRenderingContextBase::setBoundVertexArrayObject(
2197 WebGLVertexArrayObjectBase* arrayObject) { 2166 WebGLVertexArrayObjectBase* arrayObject) {
2198 if (arrayObject) 2167 if (arrayObject)
2199 m_boundVertexArrayObject = arrayObject; 2168 m_boundVertexArrayObject = arrayObject;
2200 else 2169 else
2201 m_boundVertexArrayObject = m_defaultVertexArrayObject; 2170 m_boundVertexArrayObject = m_defaultVertexArrayObject;
2202 } 2171 }
2203 2172
2204 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) { 2173 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) {
2205 if (isContextLost()) 2174 if (isContextLost())
2206 return nullptr; 2175 return nullptr;
2207 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { 2176 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) {
2208 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type"); 2177 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type");
2209 return nullptr; 2178 return nullptr;
2210 } 2179 }
2211 2180
2212 WebGLShader* o = WebGLShader::create(this, type); 2181 return WebGLShader::create(this, type);
2213 addSharedObject(o);
2214 return o;
2215 } 2182 }
2216 2183
2217 void WebGLRenderingContextBase::cullFace(GLenum mode) { 2184 void WebGLRenderingContextBase::cullFace(GLenum mode) {
2218 if (isContextLost()) 2185 if (isContextLost())
2219 return; 2186 return;
2220 contextGL()->CullFace(mode); 2187 contextGL()->CullFace(mode);
2221 } 2188 }
2222 2189
2223 bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) { 2190 bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) {
2224 if (isContextLost() || !object) 2191 if (isContextLost() || !object)
(...skipping 3888 matching lines...) Expand 10 before | Expand all | Expand 10 after
6113 void WebGLRenderingContextBase::loseContextImpl( 6080 void WebGLRenderingContextBase::loseContextImpl(
6114 WebGLRenderingContextBase::LostContextMode mode, 6081 WebGLRenderingContextBase::LostContextMode mode,
6115 AutoRecoveryMethod autoRecoveryMethod) { 6082 AutoRecoveryMethod autoRecoveryMethod) {
6116 if (isContextLost()) 6083 if (isContextLost())
6117 return; 6084 return;
6118 6085
6119 m_contextLostMode = mode; 6086 m_contextLostMode = mode;
6120 ASSERT(m_contextLostMode != NotLostContext); 6087 ASSERT(m_contextLostMode != NotLostContext);
6121 m_autoRecoveryMethod = autoRecoveryMethod; 6088 m_autoRecoveryMethod = autoRecoveryMethod;
6122 6089
6123 detachAndRemoveAllObjects();
6124
6125 // Lose all the extensions. 6090 // Lose all the extensions.
6126 for (size_t i = 0; i < m_extensions.size(); ++i) { 6091 for (size_t i = 0; i < m_extensions.size(); ++i) {
6127 ExtensionTracker* tracker = m_extensions[i]; 6092 ExtensionTracker* tracker = m_extensions[i];
6128 tracker->loseExtension(false); 6093 tracker->loseExtension(false);
6129 } 6094 }
6130 6095
6131 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) 6096 for (size_t i = 0; i < WebGLExtensionNameCount; ++i)
6132 m_extensionEnabled[i] = false; 6097 m_extensionEnabled[i] = false;
6133 6098
6134 removeAllCompressedTextureFormats(); 6099 removeAllCompressedTextureFormats();
(...skipping 29 matching lines...) Expand all
6164 if (m_contextLostMode == WebGLLoseContextLostContext) 6129 if (m_contextLostMode == WebGLLoseContextLostContext)
6165 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", 6130 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext",
6166 "context restoration not allowed"); 6131 "context restoration not allowed");
6167 return; 6132 return;
6168 } 6133 }
6169 6134
6170 if (!m_restoreTimer.isActive()) 6135 if (!m_restoreTimer.isActive())
6171 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); 6136 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE);
6172 } 6137 }
6173 6138
6139 uint32_t WebGLRenderingContextBase::numberOfContextLosses() const {
6140 return m_contextGroup->numberOfContextLosses();
6141 }
6142
6174 WebLayer* WebGLRenderingContextBase::platformLayer() const { 6143 WebLayer* WebGLRenderingContextBase::platformLayer() const {
6175 return isContextLost() ? 0 : drawingBuffer()->platformLayer(); 6144 return isContextLost() ? 0 : drawingBuffer()->platformLayer();
6176 } 6145 }
6177 6146
6178 void WebGLRenderingContextBase::setFilterQuality( 6147 void WebGLRenderingContextBase::setFilterQuality(
6179 SkFilterQuality filterQuality) { 6148 SkFilterQuality filterQuality) {
6180 if (!isContextLost() && drawingBuffer()) { 6149 if (!isContextLost() && drawingBuffer()) {
6181 drawingBuffer()->setFilterQuality(filterQuality); 6150 drawingBuffer()->setFilterQuality(filterQuality);
6182 } 6151 }
6183 } 6152 }
6184 6153
6185 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() { 6154 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() {
6186 if (!m_extensionsUtil) { 6155 if (!m_extensionsUtil) {
6187 gpu::gles2::GLES2Interface* gl = contextGL(); 6156 gpu::gles2::GLES2Interface* gl = contextGL();
6188 m_extensionsUtil = Extensions3DUtil::create(gl); 6157 m_extensionsUtil = Extensions3DUtil::create(gl);
6189 // The only reason the ExtensionsUtil should be invalid is if the gl context 6158 // The only reason the ExtensionsUtil should be invalid is if the gl context
6190 // is lost. 6159 // is lost.
6191 ASSERT(m_extensionsUtil->isValid() || 6160 ASSERT(m_extensionsUtil->isValid() ||
6192 gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR); 6161 gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR);
6193 } 6162 }
6194 return m_extensionsUtil.get(); 6163 return m_extensionsUtil.get();
6195 } 6164 }
6196 6165
6197 void WebGLRenderingContextBase::removeSharedObject(WebGLSharedObject* object) {
6198 m_contextGroup->removeObject(object);
6199 }
6200
6201 void WebGLRenderingContextBase::addSharedObject(WebGLSharedObject* object) {
6202 ASSERT(!isContextLost());
6203 m_contextGroup->addObject(object);
6204 }
6205
6206 void WebGLRenderingContextBase::removeContextObject(
6207 WebGLContextObject* object) {
6208 m_contextObjects.remove(object);
6209 }
6210
6211 void WebGLRenderingContextBase::visitChildDOMWrappers( 6166 void WebGLRenderingContextBase::visitChildDOMWrappers(
6212 v8::Isolate* isolate, 6167 v8::Isolate* isolate,
6213 const v8::Persistent<v8::Object>& wrapper) { 6168 const v8::Persistent<v8::Object>& wrapper) {
6214 if (isContextLost()) { 6169 if (isContextLost()) {
6215 return; 6170 return;
6216 } 6171 }
6217 DOMWrapperWorld::setWrapperReferencesInAllWorlds(wrapper, m_boundArrayBuffer, 6172 DOMWrapperWorld::setWrapperReferencesInAllWorlds(wrapper, m_boundArrayBuffer,
6218 isolate); 6173 isolate);
6219 DOMWrapperWorld::setWrapperReferencesInAllWorlds( 6174 DOMWrapperWorld::setWrapperReferencesInAllWorlds(
6220 wrapper, m_renderbufferBinding, isolate); 6175 wrapper, m_renderbufferBinding, isolate);
(...skipping 27 matching lines...) Expand all
6248 m_boundVertexArrayObject->visitChildDOMWrappers(isolate, wrapper); 6203 m_boundVertexArrayObject->visitChildDOMWrappers(isolate, wrapper);
6249 } 6204 }
6250 6205
6251 for (ExtensionTracker* tracker : m_extensions) { 6206 for (ExtensionTracker* tracker : m_extensions) {
6252 WebGLExtension* extension = tracker->getExtensionObjectIfAlreadyEnabled(); 6207 WebGLExtension* extension = tracker->getExtensionObjectIfAlreadyEnabled();
6253 DOMWrapperWorld::setWrapperReferencesInAllWorlds(wrapper, extension, 6208 DOMWrapperWorld::setWrapperReferencesInAllWorlds(wrapper, extension,
6254 isolate); 6209 isolate);
6255 } 6210 }
6256 } 6211 }
6257 6212
6258 void WebGLRenderingContextBase::addContextObject(WebGLContextObject* object) {
6259 ASSERT(!isContextLost());
6260 m_contextObjects.add(object);
6261 }
6262
6263 void WebGLRenderingContextBase::detachAndRemoveAllObjects() {
6264 while (m_contextObjects.size() > 0) {
6265 // Following detachContext() will remove the iterated object from
6266 // |m_contextObjects|, and thus we need to look up begin() every time.
6267 auto it = m_contextObjects.begin();
6268 (*it)->detachContext();
6269 }
6270 }
6271
6272 void WebGLRenderingContextBase::stop() { 6213 void WebGLRenderingContextBase::stop() {
6273 if (!isContextLost()) { 6214 if (!isContextLost()) {
6274 // Never attempt to restore the context because the page is being torn down. 6215 // Never attempt to restore the context because the page is being torn down.
6275 forceLostContext(SyntheticLostContext, Manual); 6216 forceLostContext(SyntheticLostContext, Manual);
6276 } 6217 }
6277 } 6218 }
6278 6219
6279 bool WebGLRenderingContextBase::DrawingBufferClientIsBoundForDraw() { 6220 bool WebGLRenderingContextBase::DrawingBufferClientIsBoundForDraw() {
6280 return !m_framebufferBinding; 6221 return !m_framebufferBinding;
6281 } 6222 }
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
7679 } 7620 }
7680 7621
7681 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) { 7622 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) {
7682 visitor->trace(m_texture2DBinding); 7623 visitor->trace(m_texture2DBinding);
7683 visitor->trace(m_textureCubeMapBinding); 7624 visitor->trace(m_textureCubeMapBinding);
7684 visitor->trace(m_texture3DBinding); 7625 visitor->trace(m_texture3DBinding);
7685 visitor->trace(m_texture2DArrayBinding); 7626 visitor->trace(m_texture2DArrayBinding);
7686 } 7627 }
7687 7628
7688 DEFINE_TRACE(WebGLRenderingContextBase) { 7629 DEFINE_TRACE(WebGLRenderingContextBase) {
7689 visitor->trace(m_contextObjects); 7630 visitor->trace(m_contextGroup);
7690 visitor->trace(m_boundArrayBuffer); 7631 visitor->trace(m_boundArrayBuffer);
7691 visitor->trace(m_defaultVertexArrayObject); 7632 visitor->trace(m_defaultVertexArrayObject);
7692 visitor->trace(m_boundVertexArrayObject); 7633 visitor->trace(m_boundVertexArrayObject);
7693 visitor->trace(m_currentProgram); 7634 visitor->trace(m_currentProgram);
7694 visitor->trace(m_framebufferBinding); 7635 visitor->trace(m_framebufferBinding);
7695 visitor->trace(m_renderbufferBinding); 7636 visitor->trace(m_renderbufferBinding);
7696 visitor->trace(m_textureUnits); 7637 visitor->trace(m_textureUnits);
7697 visitor->trace(m_extensions); 7638 visitor->trace(m_extensions);
7698 CanvasRenderingContext::trace(visitor); 7639 CanvasRenderingContext::trace(visitor);
7699 } 7640 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
7767 7708
7768 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7709 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7769 HTMLCanvasElementOrOffscreenCanvas& result) const { 7710 HTMLCanvasElementOrOffscreenCanvas& result) const {
7770 if (canvas()) 7711 if (canvas())
7771 result.setHTMLCanvasElement(canvas()); 7712 result.setHTMLCanvasElement(canvas());
7772 else 7713 else
7773 result.setOffscreenCanvas(getOffscreenCanvas()); 7714 result.setOffscreenCanvas(getOffscreenCanvas());
7774 } 7715 }
7775 7716
7776 } // namespace blink 7717 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698