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

Unified Diff: Source/core/html/canvas/WebGLRenderingContext.h

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, 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/canvas/WebGLRenderingContext.h
diff --git a/Source/core/html/canvas/WebGLRenderingContext.h b/Source/core/html/canvas/WebGLRenderingContext.h
index 0797f1076e38f44530303760e26f7e3d15d6fd2b..58dd128f371013621b3509d33a1eea01fa311b58 100644
--- a/Source/core/html/canvas/WebGLRenderingContext.h
+++ b/Source/core/html/canvas/WebGLRenderingContext.h
@@ -364,6 +364,7 @@ public:
// Adds a compressed texture format.
void addCompressedTextureFormat(GC3Denum);
+ void removeAllCompressedTextureFormats();
PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy, ExceptionCode&);
@@ -498,22 +499,22 @@ public:
int m_numGLErrorsToConsoleAllowed;
// Enabled extension objects.
- OwnPtr<EXTDrawBuffers> m_extDrawBuffers;
- OwnPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic;
- OwnPtr<OESTextureFloat> m_oesTextureFloat;
- OwnPtr<OESTextureFloatLinear> m_oesTextureFloatLinear;
- OwnPtr<OESTextureHalfFloat> m_oesTextureHalfFloat;
- OwnPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear;
- OwnPtr<OESStandardDerivatives> m_oesStandardDerivatives;
- OwnPtr<OESVertexArrayObject> m_oesVertexArrayObject;
- OwnPtr<OESElementIndexUint> m_oesElementIndexUint;
- OwnPtr<WebGLLoseContext> m_webglLoseContext;
- OwnPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo;
- OwnPtr<WebGLDebugShaders> m_webglDebugShaders;
- OwnPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC;
- OwnPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC;
- OwnPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC;
- OwnPtr<WebGLDepthTexture> m_webglDepthTexture;
+ EXTDrawBuffers* m_extDrawBuffers;
+ EXTTextureFilterAnisotropic* m_extTextureFilterAnisotropic;
+ OESTextureFloat* m_oesTextureFloat;
+ OESTextureFloatLinear* m_oesTextureFloatLinear;
+ OESTextureHalfFloat* m_oesTextureHalfFloat;
+ OESTextureHalfFloatLinear* m_oesTextureHalfFloatLinear;
+ OESStandardDerivatives* m_oesStandardDerivatives;
+ OESVertexArrayObject* m_oesVertexArrayObject;
+ OESElementIndexUint* m_oesElementIndexUint;
+ WebGLLoseContext* m_webglLoseContext;
+ WebGLDebugRendererInfo* m_webglDebugRendererInfo;
+ WebGLDebugShaders* m_webglDebugShaders;
+ WebGLCompressedTextureATC* m_webglCompressedTextureATC;
+ WebGLCompressedTexturePVRTC* m_webglCompressedTexturePVRTC;
+ WebGLCompressedTextureS3TC* m_webglCompressedTextureS3TC;
+ WebGLDepthTexture* m_webglDepthTexture;
class ExtensionTracker {
public:
@@ -524,6 +525,10 @@ public:
{
}
+ virtual ~ExtensionTracker()
+ {
+ }
+
bool getPrefixed() const
{
return m_prefixed;
@@ -536,9 +541,10 @@ public:
bool matchesNameWithPrefixes(const String&) const;
- virtual WebGLExtension* getExtension(WebGLRenderingContext*) const = 0;
+ virtual WebGLExtension* getExtension(WebGLRenderingContext*) = 0;
virtual bool supported(WebGLRenderingContext*) const = 0;
virtual const char* getExtensionName() const = 0;
+ virtual void loseExtension() = 0;
private:
bool m_privileged;
@@ -546,21 +552,28 @@ public:
const char** m_prefixes;
};
+ // This class owns the extension and keeps a reference to the
+ // WebGLRenderingContext field the same extension.
template <typename T>
class TypedExtensionTracker : public ExtensionTracker {
public:
- TypedExtensionTracker(OwnPtr<T>& extensionField, bool privileged, bool prefixed, const char** prefixes)
+ TypedExtensionTracker(T*& extensionField, bool privileged, bool prefixed, const char** prefixes)
: ExtensionTracker(privileged, prefixed, prefixes)
, m_extensionField(extensionField)
{
+ m_extensionField = 0;
}
- virtual WebGLExtension* getExtension(WebGLRenderingContext* context) const
+ virtual WebGLExtension* getExtension(WebGLRenderingContext* context)
{
- if (!m_extensionField)
- m_extensionField = T::create(context);
+ if (!m_extension)
+ m_extension = T::create(context);
Ken Russell (switch to Gerrit) 2013/06/05 00:46:38 Should this also call m_extension->enable()? That
+
+ if (m_extension->isLost())
+ m_extension->restore();
- return m_extensionField.get();
+ m_extensionField = m_extension.get();
+ return m_extensionField;
}
virtual bool supported(WebGLRenderingContext* context) const
@@ -573,14 +586,22 @@ public:
return T::getExtensionName();
}
+ virtual void loseExtension()
+ {
+ m_extensionField = 0; // removes the extension's field from WebGLRenderingContext
+ if (m_extension)
+ m_extension->lose();
+ }
+
private:
- OwnPtr<T>& m_extensionField;
+ T*& m_extensionField; // reference to the typed field in WebGLRenderingContext
+ OwnPtr<T> m_extension;
};
Vector<ExtensionTracker*> m_extensions;
template <typename T>
- void registerExtension(OwnPtr<T>& extensionPtr, bool privileged, bool prefixed, const char** prefixes)
+ void registerExtension(T*& extensionPtr, bool privileged, bool prefixed, const char** prefixes)
{
m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, privileged, prefixed, prefixes));
}

Powered by Google App Engine
This is Rietveld 408576698