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

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

Issue 24096029: Moved the majority of WebGL functionality into WebGLRenderingContextBase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed typo in gypi, was only causing issues on Windows (?!?) Created 6 years, 10 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/WebGLRenderingContextBase.h
diff --git a/Source/core/html/canvas/WebGLRenderingContext.h b/Source/core/html/canvas/WebGLRenderingContextBase.h
similarity index 93%
copy from Source/core/html/canvas/WebGLRenderingContext.h
copy to Source/core/html/canvas/WebGLRenderingContextBase.h
index f2c75ea0168474a65ad501e1d2f9159cf20aa946..c0ca96c1a8492a05cd07db547725006a9013fad4 100644
--- a/Source/core/html/canvas/WebGLRenderingContext.h
+++ b/Source/core/html/canvas/WebGLRenderingContextBase.h
@@ -23,11 +23,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebGLRenderingContext_h
-#define WebGLRenderingContext_h
+#ifndef WebGLRenderingContextBase_h
+#define WebGLRenderingContextBase_h
#include "core/dom/ActiveDOMObject.h"
#include "core/html/canvas/CanvasRenderingContext.h"
+#include "core/html/canvas/WebGLExtensionName.h"
#include "core/html/canvas/WebGLGetInfo.h"
#include "core/page/Page.h"
#include "platform/Timer.h"
@@ -92,13 +93,17 @@ class WebGLVertexArrayObjectOES;
class WebGLRenderingContextLostCallback;
class WebGLRenderingContextErrorMessageCallback;
-class WebGLRenderingContext FINAL : public CanvasRenderingContext, public ActiveDOMObject, private Page::MultisamplingChangedObserver {
+class WebGLRenderingContextBase : public CanvasRenderingContext, public ActiveDOMObject, private Page::MultisamplingChangedObserver {
public:
- static PassOwnPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLContextAttributes*);
- virtual ~WebGLRenderingContext();
+ virtual ~WebGLRenderingContextBase();
virtual bool is3d() const OVERRIDE { return true; }
virtual bool isAccelerated() const OVERRIDE { return true; }
+ virtual unsigned version() const = 0;
+ virtual String contextName() const = 0;
+ virtual void registerContextExtensions() = 0;
+
+ static unsigned getWebGLVersion(const CanvasRenderingContext*);
int drawingBufferWidth() const;
int drawingBufferHeight() const;
@@ -338,7 +343,7 @@ public:
virtual bool hasPendingActivity() const OVERRIDE;
virtual void stop() OVERRIDE;
- private:
+protected:
friend class WebGLDrawBuffers;
friend class WebGLFramebuffer;
friend class WebGLObject;
@@ -350,7 +355,7 @@ public:
friend class WebGLRenderingContextErrorMessageCallback;
friend class WebGLVertexArrayObjectOES;
- WebGLRenderingContext(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsContext3D>, WebGLContextAttributes*);
+ WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsContext3D>, WebGLContextAttributes*);
void initializeNewContext();
void setupFlags();
@@ -397,9 +402,9 @@ public:
// likely that there's no JavaScript on the stack, but that might be dependent
// on how exactly the platform discovers that the context was lost. For better
// portability we always defer the dispatch of the event.
- Timer<WebGLRenderingContext> m_dispatchContextLostEventTimer;
+ Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
bool m_restoreAllowed;
- Timer<WebGLRenderingContext> m_restoreTimer;
+ Timer<WebGLRenderingContextBase> m_restoreTimer;
bool m_needsUpdate;
bool m_markedCanvasDirty;
@@ -524,26 +529,6 @@ public:
OwnPtr<Extensions3DUtil> m_extensionsUtil;
- // Enabled extension objects.
- RefPtr<ANGLEInstancedArrays> m_angleInstancedArrays;
- RefPtr<EXTFragDepth> m_extFragDepth;
- RefPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic;
- RefPtr<OESTextureFloat> m_oesTextureFloat;
- RefPtr<OESTextureFloatLinear> m_oesTextureFloatLinear;
- RefPtr<OESTextureHalfFloat> m_oesTextureHalfFloat;
- RefPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear;
- RefPtr<OESStandardDerivatives> m_oesStandardDerivatives;
- RefPtr<OESVertexArrayObject> m_oesVertexArrayObject;
- RefPtr<OESElementIndexUint> m_oesElementIndexUint;
- RefPtr<WebGLLoseContext> m_webglLoseContext;
- RefPtr<WebGLDebugRendererInfo> m_webglDebugRendererInfo;
- RefPtr<WebGLDebugShaders> m_webglDebugShaders;
- RefPtr<WebGLDrawBuffers> m_webglDrawBuffers;
- RefPtr<WebGLCompressedTextureATC> m_webglCompressedTextureATC;
- RefPtr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC;
- RefPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC;
- RefPtr<WebGLDepthTexture> m_webglDepthTexture;
-
enum ExtensionFlags {
ApprovedExtension = 0x00,
DraftExtension = 0x01,
@@ -589,8 +574,8 @@ public:
bool matchesNameWithPrefixes(const String&) const;
- virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext*) const = 0;
- virtual bool supported(WebGLRenderingContext*) const = 0;
+ virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBase*) = 0;
+ virtual bool supported(WebGLRenderingContextBase*) const = 0;
virtual const char* extensionName() const = 0;
virtual void loseExtension() = 0;
@@ -608,26 +593,29 @@ public:
TypedExtensionTracker(RefPtr<T>& extensionField, ExtensionFlags flags, const char* const* prefixes)
: ExtensionTracker(flags, prefixes)
, m_extensionField(extensionField)
+ , m_extension(nullptr)
{
}
virtual ~TypedExtensionTracker()
{
- if (m_extensionField) {
- m_extensionField->lose(true);
- m_extensionField = nullptr;
+ if (m_extension) {
+ m_extension->lose(true);
+ m_extension = nullptr;
}
}
- virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext* context) const OVERRIDE
+ virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBase* context) OVERRIDE
{
- if (!m_extensionField)
- m_extensionField = T::create(context);
+ if (!m_extension) {
+ m_extension = T::create(context);
+ m_extensionField = m_extension;
+ }
- return m_extensionField;
+ return m_extension;
}
- virtual bool supported(WebGLRenderingContext* context) const OVERRIDE
+ virtual bool supported(WebGLRenderingContextBase* context) const OVERRIDE
{
return T::supported(context);
}
@@ -639,17 +627,21 @@ public:
virtual void loseExtension() OVERRIDE
{
- if (m_extensionField) {
- m_extensionField->lose(false);
- if (m_extensionField->isLost())
- m_extensionField = nullptr;
+ if (m_extension) {
+ m_extension->lose(false);
+ if (m_extension->isLost())
+ m_extension = nullptr;
}
}
private:
RefPtr<T>& m_extensionField;
+ // ExtensionTracker holds it's own reference to the extension to ensure
+ // that it is not deleted before this object's destructor is called
+ RefPtr<T> m_extension;
};
+ bool m_extensionEnabled[WebGLExtensionNameCount];
Vector<ExtensionTracker*> m_extensions;
template <typename T>
@@ -658,6 +650,11 @@ public:
m_extensions.append(new TypedExtensionTracker<T>(extensionPtr, flags, prefixes));
}
+ inline bool extensionEnabled(WebGLExtensionName name)
+ {
+ return m_extensionEnabled[name];
+ }
+
// Errors raised by synthesizeGLError() while the context is lost.
Vector<GLenum> m_lostContextErrors;
@@ -853,9 +850,9 @@ public:
// Return false if caller should return without further processing.
bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& deleted);
- void dispatchContextLostEvent(Timer<WebGLRenderingContext>*);
+ void dispatchContextLostEvent(Timer<WebGLRenderingContextBase>*);
// Helper for restoration after context lost.
- void maybeRestoreContext(Timer<WebGLRenderingContext>*);
+ void maybeRestoreContext(Timer<WebGLRenderingContextBase>*);
// Determine if we are running privileged code in the browser, for example,
// a Safari or Chrome extension.
@@ -906,12 +903,12 @@ public:
friend class WebGLStateRestorer;
friend class WebGLRenderingContextEvictionManager;
- static Vector<WebGLRenderingContext*>& activeContexts();
- static Vector<WebGLRenderingContext*>& forciblyEvictedContexts();
+ static Vector<WebGLRenderingContextBase*>& activeContexts();
+ static Vector<WebGLRenderingContextBase*>& forciblyEvictedContexts();
- static void activateContext(WebGLRenderingContext*);
- static void deactivateContext(WebGLRenderingContext*, bool addToInactiveList);
- static void willDestroyContext(WebGLRenderingContext*);
+ static void activateContext(WebGLRenderingContextBase*);
+ static void deactivateContext(WebGLRenderingContextBase*, bool addToInactiveList);
+ static void willDestroyContext(WebGLRenderingContextBase*);
static void forciblyLoseOldestContext(const String& reason);
// Return the least recently used context's position in the active context vector.
// If the vector is empty, return the maximum allowed active context number.
@@ -919,8 +916,8 @@ public:
static IntSize oldestContextSize();
};
-DEFINE_TYPE_CASTS(WebGLRenderingContext, CanvasRenderingContext, context, context->is3d(), context.is3d());
+DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, context->is3d(), context.is3d());
} // namespace WebCore
-#endif
+#endif // WebGLRenderingContextBase_h

Powered by Google App Engine
This is Rietveld 408576698