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

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

Issue 15876011: Make WebGL extensions get lost when context is lost. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 return p->settings()->privilegedWebGLExtensionsEnabled(); 704 return p->settings()->privilegedWebGLExtensionsEnabled();
705 return false; 705 return false;
706 } 706 }
707 707
708 void WebGLRenderingContext::addCompressedTextureFormat(GC3Denum format) 708 void WebGLRenderingContext::addCompressedTextureFormat(GC3Denum format)
709 { 709 {
710 if (!m_compressedTextureFormats.contains(format)) 710 if (!m_compressedTextureFormats.contains(format))
711 m_compressedTextureFormats.append(format); 711 m_compressedTextureFormats.append(format);
712 } 712 }
713 713
714 void WebGLRenderingContext::removeAllCompressedTextureFormats()
715 {
716 m_compressedTextureFormats.clear();
717 }
718
714 WebGLRenderingContext::~WebGLRenderingContext() 719 WebGLRenderingContext::~WebGLRenderingContext()
715 { 720 {
716 // Remove all references to WebGLObjects so if they are the last reference 721 // Remove all references to WebGLObjects so if they are the last reference
717 // they will be freed before the last context is removed from the context gr oup. 722 // they will be freed before the last context is removed from the context gr oup.
718 m_boundArrayBuffer = 0; 723 m_boundArrayBuffer = 0;
719 m_defaultVertexArrayObject = 0; 724 m_defaultVertexArrayObject = 0;
720 m_boundVertexArrayObject = 0; 725 m_boundVertexArrayObject = 0;
721 m_vertexAttrib0Buffer = 0; 726 m_vertexAttrib0Buffer = 0;
722 m_currentProgram = 0; 727 m_currentProgram = 0;
723 m_framebufferBinding = 0; 728 m_framebufferBinding = 0;
724 m_renderbufferBinding = 0; 729 m_renderbufferBinding = 0;
725 730
726 for (size_t i = 0; i < m_textureUnits.size(); ++i) { 731 for (size_t i = 0; i < m_textureUnits.size(); ++i) {
727 m_textureUnits[i].m_texture2DBinding = 0; 732 m_textureUnits[i].m_texture2DBinding = 0;
728 m_textureUnits[i].m_textureCubeMapBinding = 0; 733 m_textureUnits[i].m_textureCubeMapBinding = 0;
729 } 734 }
730 735
731 m_blackTexture2D = 0; 736 m_blackTexture2D = 0;
732 m_blackTextureCubeMap = 0; 737 m_blackTextureCubeMap = 0;
733 738
734 detachAndRemoveAllObjects(); 739 detachAndRemoveAllObjects();
740
741 // release all extensions
742 for (size_t i = 0; i < m_extensions.size(); ++i)
743 delete m_extensions[i];
744
735 destroyGraphicsContext3D(); 745 destroyGraphicsContext3D();
736 m_contextGroup->removeContext(this); 746 m_contextGroup->removeContext(this);
737 747
738 if (m_multisamplingObserverRegistered) { 748 if (m_multisamplingObserverRegistered) {
739 Page* page = canvas()->document()->page(); 749 Page* page = canvas()->document()->page();
740 if (page) 750 if (page)
741 page->removeMultisamplingChangedObserver(this); 751 page->removeMultisamplingChangedObserver(this);
742 } 752 }
743 753
744 willDestroyContext(this); 754 willDestroyContext(this);
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 const char** prefixes = m_prefixes; 2147 const char** prefixes = m_prefixes;
2138 for (; *prefixes; ++prefixes) { 2148 for (; *prefixes; ++prefixes) {
2139 String prefixedName = String(*prefixes) + getExtensionName(); 2149 String prefixedName = String(*prefixes) + getExtensionName();
2140 if (equalIgnoringCase(prefixedName, name)) { 2150 if (equalIgnoringCase(prefixedName, name)) {
2141 return true; 2151 return true;
2142 } 2152 }
2143 } 2153 }
2144 return false; 2154 return false;
2145 } 2155 }
2146 2156
2147 WebGLExtension* WebGLRenderingContext::getExtension(const String& name) 2157 PassRefPtr<WebGLExtension> WebGLRenderingContext::getExtension(const String& nam e)
2148 { 2158 {
2149 if (isContextLost()) 2159 if (isContextLost())
2150 return 0; 2160 return 0;
2151 2161
2152 for (size_t i = 0; i < m_extensions.size(); ++i) { 2162 for (size_t i = 0; i < m_extensions.size(); ++i) {
2153 ExtensionTracker* tracker = m_extensions[i]; 2163 ExtensionTracker* tracker = m_extensions[i];
2154 if (tracker->matchesNameWithPrefixes(name)) { 2164 if (tracker->matchesNameWithPrefixes(name)) {
2155 if (tracker->getPrivileged() && !allowPrivilegedExtensions()) 2165 if (tracker->getPrivileged() && !allowPrivilegedExtensions())
2156 return 0; 2166 return 0;
2157 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtens ionsEnabled()) 2167 if (tracker->getDraft() && !RuntimeEnabledFeatures::webGLDraftExtens ionsEnabled())
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after
4167 frame->loader()->client()->didLoseWebGLContext(m_context->getExt ensions()->getGraphicsResetStatusARB()); 4177 frame->loader()->client()->didLoseWebGLContext(m_context->getExt ensions()->getGraphicsResetStatusARB());
4168 } 4178 }
4169 } 4179 }
4170 4180
4171 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. 4181 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer.
4172 m_drawingBuffer->setTexture2DBinding(0); 4182 m_drawingBuffer->setTexture2DBinding(0);
4173 m_drawingBuffer->setFramebufferBinding(0); 4183 m_drawingBuffer->setFramebufferBinding(0);
4174 4184
4175 detachAndRemoveAllObjects(); 4185 detachAndRemoveAllObjects();
4176 4186
4187 // Lose all the extensions.
4188 for (size_t i = 0; i < m_extensions.size(); ++i) {
4189 ExtensionTracker* tracker = m_extensions[i];
4190 tracker->loseExtension();
4191 }
4192
4193 removeAllCompressedTextureFormats();
4194
4177 if (mode != RealLostContext) 4195 if (mode != RealLostContext)
4178 destroyGraphicsContext3D(); 4196 destroyGraphicsContext3D();
4179 4197
4180 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons ole: DontDisplayInConsole; 4198 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons ole: DontDisplayInConsole;
4181 synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL, "loseContext", "con text lost", display); 4199 synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL, "loseContext", "con text lost", display);
4182 4200
4183 // Don't allow restoration unless the context lost event has both been 4201 // Don't allow restoration unless the context lost event has both been
4184 // dispatched and its default behavior prevented. 4202 // dispatched and its default behavior prevented.
4185 m_restoreAllowed = false; 4203 m_restoreAllowed = false;
4186 4204
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
5488 5506
5489 void WebGLRenderingContext::multisamplingChanged(bool enabled) 5507 void WebGLRenderingContext::multisamplingChanged(bool enabled)
5490 { 5508 {
5491 if (m_multisamplingAllowed != enabled) { 5509 if (m_multisamplingAllowed != enabled) {
5492 m_multisamplingAllowed = enabled; 5510 m_multisamplingAllowed = enabled;
5493 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext) ; 5511 forceLostContext(WebGLRenderingContext::AutoRecoverSyntheticLostContext) ;
5494 } 5512 }
5495 } 5513 }
5496 5514
5497 } // namespace WebCore 5515 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698