Chromium Code Reviews| 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 386bb3746753dc6d29f93c024b5de2dfb5822d63..b3f6d40dbd771e697d527760f361403cd3676efc 100644 |
| --- a/Source/core/html/canvas/WebGLRenderingContext.h |
| +++ b/Source/core/html/canvas/WebGLRenderingContextBase.h |
| @@ -23,8 +23,8 @@ |
| * 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" |
| @@ -85,14 +85,15 @@ class WebGLTexture; |
| class WebGLUniformLocation; |
| class WebGLVertexArrayObjectOES; |
| -class WebGLRenderingContext : 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 { return true; } |
| virtual bool isAccelerated() const { return true; } |
| + virtual void registerContextExtensions() = 0; |
| + |
| int drawingBufferWidth() const; |
| int drawingBufferHeight() const; |
| @@ -124,9 +125,9 @@ public: |
| void compileShader(WebGLShader*); |
| void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, |
| - GC3Dsizei height, GC3Dint border, ArrayBufferView* data); |
| + GC3Dsizei height, GC3Dint border, ArrayBufferView* data); |
|
bajones
2013/09/20 19:24:25
Apologies for the clutter, but cl upload decided t
|
| void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, |
| - GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data); |
| + GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data); |
| void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border); |
| void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height); |
| @@ -332,7 +333,7 @@ public: |
| virtual bool hasPendingActivity() const; |
| virtual void stop(); |
| - private: |
| +protected: |
| friend class WebGLDrawBuffers; |
| friend class WebGLFramebuffer; |
| friend class WebGLObject; |
| @@ -344,7 +345,7 @@ public: |
| friend class WebGLRenderingContextErrorMessageCallback; |
| friend class WebGLVertexArrayObjectOES; |
| - WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes, GraphicsContext3D::Attributes); |
| + WebGLRenderingContextBase(const String&, HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>, GraphicsContext3D::Attributes, GraphicsContext3D::Attributes); |
| void initializeNewContext(); |
| void setupFlags(); |
| @@ -362,7 +363,7 @@ public: |
| // Helper to return the size in bytes of OpenGL data types |
| // like GL_FLOAT, GL_INT, etc. |
| - unsigned int sizeInBytes(GC3Denum type); |
| + unsigned sizeInBytes(GC3Denum type); |
| // Check if each enabled vertex attribute is bound to a buffer. |
| bool validateRenderingState(); |
| @@ -377,6 +378,7 @@ public: |
| WebGLRenderbuffer* ensureEmulatedStencilBuffer(GC3Denum target, WebGLRenderbuffer*); |
| + const String m_contextName; |
|
Zhenyao Mo
2013/09/20 23:04:45
I still feel like we should have a unsigned int m_
bajones
2013/09/20 23:08:49
If we want to branch functionality based on WebGL
|
| RefPtr<GraphicsContext3D> m_context; |
| RefPtr<WebGLContextGroup> m_contextGroup; |
| @@ -389,9 +391,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; |
| @@ -456,7 +458,7 @@ public: |
| public: |
| LRUImageBufferCache(int capacity); |
| // The pointer returned is owned by the image buffer map. |
| - ImageBuffer* imageBuffer(const IntSize& size); |
| + ImageBuffer* imageBuffer(const IntSize&); |
| private: |
| void bubbleToFront(int idx); |
| OwnArrayPtr<OwnPtr<ImageBuffer> > m_buffers; |
| @@ -516,21 +518,21 @@ public: |
| RefPtr<ANGLEInstancedArrays> m_angleInstancedArrays; |
| RefPtr<EXTFragDepth> m_extFragDepth; |
| RefPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic; |
| + RefPtr<OESElementIndexUint> m_oesElementIndexUint; |
| + RefPtr<OESStandardDerivatives> m_oesStandardDerivatives; |
| 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<WebGLDebugRendererInfo> m_webglDebugRendererInfo; |
| + RefPtr<WebGLDebugShaders> m_webglDebugShaders; |
| RefPtr<WebGLDepthTexture> m_webglDepthTexture; |
| + RefPtr<WebGLDrawBuffers> m_webglDrawBuffers; |
| + RefPtr<WebGLLoseContext> m_webglLoseContext; |
| enum ExtensionFlags { |
| ApprovedExtension = 0x00, |
| @@ -570,8 +572,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*) const = 0; |
| + virtual bool supported(WebGLRenderingContextBase*) const = 0; |
| virtual const char* getExtensionName() const = 0; |
| virtual void loseExtension() = 0; |
| @@ -599,7 +601,7 @@ public: |
| } |
| } |
| - virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContext* context) const |
| + virtual PassRefPtr<WebGLExtension> getExtension(WebGLRenderingContextBase* context) const |
| { |
| if (!m_extensionField) |
| m_extensionField = T::create(context); |
| @@ -607,7 +609,7 @@ public: |
| return m_extensionField; |
| } |
| - virtual bool supported(WebGLRenderingContext* context) const |
| + virtual bool supported(WebGLRenderingContextBase* context) const |
| { |
| return T::supported(context); |
| } |
| @@ -639,7 +641,7 @@ public: |
| } |
| // Errors raised by synthesizeGLError() while the context is lost. |
| - Vector<GC3Denum> lost_context_errors_; |
| + Vector<GC3Denum> m_lostContextErrors; |
| // Helpers for getParameter and others |
| WebGLGetInfo getBooleanParameter(GC3Denum); |
| @@ -669,8 +671,7 @@ public: |
| // Helper function for copyTex{Sub}Image, check whether the internalformat |
| // and the color buffer format of the current bound framebuffer combination |
| // is valid. |
| - bool isTexInternalFormatColorBufferCombinationValid(GC3Denum texInternalFormat, |
| - GC3Denum colorBufferFormat); |
| + bool isTexInternalFormatColorBufferCombinationValid(GC3Denum texInternalFormat, GC3Denum colorBufferFormat); |
| // Helper function to get the bound framebuffer's color buffer format. |
| GC3Denum getBoundFramebufferColorFormat(); |
| @@ -694,7 +695,7 @@ public: |
| // Helper function to check target and texture bound to the target. |
| // Generate GL errors and return 0 if target is invalid or texture bound is |
| - // null. Otherwise, return the texture bound to the target. |
| + // null. Otherwise, return the texture bound to the target. |
| WebGLTexture* validateTextureBinding(const char* functionName, GC3Denum target, bool useSixEnumsForCubeMap); |
| // Helper function to check input format/type for functions {copy}Tex{Sub}Image. |
| @@ -731,11 +732,11 @@ public: |
| // Helper function to check input parameters for functions {copy}Tex{Sub}Image. |
| // Generates GL error and returns false if parameters are invalid. |
| bool validateTexFuncParameters(const char* functionName, |
| - TexFuncValidationFunctionType, |
| - GC3Denum target, GC3Dint level, |
| - GC3Denum internalformat, |
| - GC3Dsizei width, GC3Dsizei height, GC3Dint border, |
| - GC3Denum format, GC3Denum type); |
| + TexFuncValidationFunctionType, |
| + GC3Denum target, GC3Dint level, |
| + GC3Denum internalformat, |
| + GC3Dsizei width, GC3Dsizei height, GC3Dint border, |
| + GC3Denum format, GC3Denum type); |
| enum NullDisposition { |
| NullAllowed, |
| @@ -746,10 +747,10 @@ public: |
| // is of the correct type and contains enough data for the texImage call. |
| // Generates GL error and returns false if parameters are invalid. |
| bool validateTexFuncData(const char* functionName, GC3Dint level, |
| - GC3Dsizei width, GC3Dsizei height, |
| - GC3Denum format, GC3Denum type, |
| - ArrayBufferView* pixels, |
| - NullDisposition); |
| + GC3Dsizei width, GC3Dsizei height, |
| + GC3Denum format, GC3Denum type, |
| + ArrayBufferView* pixels, |
| + NullDisposition); |
| // Helper function to validate a given texture format is settable as in |
| // you can supply data to texImage2D, or call texImage2D, copyTexImage2D and |
| @@ -760,8 +761,8 @@ public: |
| // Helper function to validate compressed texture data is correct size |
| // for the given format and dimensions. |
| bool validateCompressedTexFuncData(const char* functionName, |
| - GC3Dsizei width, GC3Dsizei height, |
| - GC3Denum format, ArrayBufferView* pixels); |
| + GC3Dsizei width, GC3Dsizei height, |
| + GC3Denum format, ArrayBufferView* pixels); |
| // Helper function for validating compressed texture formats. |
| bool validateCompressedTexFormat(GC3Denum format); |
| @@ -773,7 +774,7 @@ public: |
| // Helper function to validate compressed texture dimensions are valid for |
| // the given format. |
| bool validateCompressedTexSubDimensions(const char* functionName, GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, |
| - GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture*); |
| + GC3Dsizei width, GC3Dsizei height, GC3Denum format, WebGLTexture*); |
| // Helper function to validate mode for draw{Arrays/Elements}. |
| bool validateDrawMode(const char* functionName, GC3Denum); |
| @@ -850,9 +851,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. |
| @@ -898,14 +899,16 @@ 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); |
| static IntSize oldestContextSize(); |
| + |
| + static GraphicsContext3D::Attributes adjustAttributes(const GraphicsContext3D::Attributes&, Settings*); |
| }; |
| } // namespace WebCore |