Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / canvas / WebGLVertexArrayObjectOES.h
index 2d7fe01..0b6ed25 100644 (file)
 #ifndef WebGLVertexArrayObjectOES_h
 #define WebGLVertexArrayObjectOES_h
 
-#include "bindings/v8/ScriptWrappable.h"
+#include "bindings/core/v8/ScriptWrappable.h"
 #include "core/html/canvas/WebGLBuffer.h"
 #include "core/html/canvas/WebGLContextObject.h"
+#include "platform/heap/Handle.h"
 #include "wtf/PassRefPtr.h"
 
-namespace WebCore {
+namespace blink {
 
-class WebGLVertexArrayObjectOES : public WebGLContextObject, public ScriptWrappable {
+class WebGLVertexArrayObjectOES final : public WebGLContextObject, public ScriptWrappable {
+    DEFINE_WRAPPERTYPEINFO();
 public:
     enum VaoType {
         VaoTypeDefault,
@@ -42,15 +44,17 @@ public:
 
     virtual ~WebGLVertexArrayObjectOES();
 
-    static PassRefPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContext*, VaoType);
+    static PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContextBase*, VaoType);
 
     // Cached values for vertex attrib range checks
-    struct VertexAttribState {
+    class VertexAttribState final {
+        ALLOW_ONLY_INLINE_ALLOCATION();
+    public:
         VertexAttribState()
             : enabled(false)
             , bytesPerElement(0)
             , size(4)
-            , type(GraphicsContext3D::FLOAT)
+            , type(GL_FLOAT)
             , normalized(false)
             , stride(16)
             , originalStride(0)
@@ -59,16 +63,18 @@ public:
         {
         }
 
+        void trace(Visitor*);
+
         bool enabled;
-        RefPtr<WebGLBuffer> bufferBinding;
-        GC3Dsizei bytesPerElement;
-        GC3Dint size;
-        GC3Denum type;
+        RefPtrWillBeMember<WebGLBuffer> bufferBinding;
+        GLsizei bytesPerElement;
+        GLint size;
+        GLenum type;
         bool normalized;
-        GC3Dsizei stride;
-        GC3Dsizei originalStride;
-        GC3Dintptr offset;
-        GC3Duint divisor;
+        GLsizei stride;
+        GLsizei originalStride;
+        GLintptr offset;
+        GLuint divisor;
     };
 
     bool isDefaultObject() const { return m_type == VaoTypeDefault; }
@@ -76,27 +82,42 @@ public:
     bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; }
     void setHasEverBeenBound() { m_hasEverBeenBound = true; }
 
-    PassRefPtr<WebGLBuffer> boundElementArrayBuffer() const { return m_boundElementArrayBuffer; }
-    void setElementArrayBuffer(PassRefPtr<WebGLBuffer>);
+    PassRefPtrWillBeRawPtr<WebGLBuffer> boundElementArrayBuffer() const { return m_boundElementArrayBuffer; }
+    void setElementArrayBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer>);
 
     VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribState[index]; }
-    void setVertexAttribState(GC3Duint, GC3Dsizei, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr, PassRefPtr<WebGLBuffer>);
-    void unbindBuffer(PassRefPtr<WebGLBuffer>);
-    void setVertexAttribDivisor(GC3Duint index, GC3Duint divisor);
+    void setVertexAttribState(GLuint, GLsizei, GLint, GLenum, GLboolean, GLsizei, GLintptr, PassRefPtrWillBeRawPtr<WebGLBuffer>);
+    void unbindBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer>);
+    void setVertexAttribDivisor(GLuint index, GLuint divisor);
 
-private:
-    WebGLVertexArrayObjectOES(WebGLRenderingContext*, VaoType);
+    virtual void trace(Visitor*) override;
 
-    virtual void deleteObjectImpl(GraphicsContext3D*, Platform3DObject);
+private:
+    WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VaoType);
 
-    virtual bool isVertexArray() const { return true; }
+    void dispatchDetached(blink::WebGraphicsContext3D*);
+    virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject) override;
 
     VaoType m_type;
     bool m_hasEverBeenBound;
-    RefPtr<WebGLBuffer> m_boundElementArrayBuffer;
-    Vector<VertexAttribState> m_vertexAttribState;
+#if ENABLE(OILPAN)
+    bool m_destructionInProgress;
+#endif
+    RefPtrWillBeMember<WebGLBuffer> m_boundElementArrayBuffer;
+    WillBeHeapVector<VertexAttribState> m_vertexAttribState;
+};
+
+} // namespace blink
+
+namespace WTF {
+
+template<>
+struct VectorTraits<blink::WebGLVertexArrayObjectOES::VertexAttribState> : SimpleClassVectorTraits<blink::WebGLVertexArrayObjectOES::VertexAttribState> {
+    // Must use the constructor.
+    static const bool canInitializeWithMemset = false;
+    static const bool canCopyWithMemcpy = true;
 };
 
-} // namespace WebCore
+} // namespace WTF
 
 #endif // WebGLVertexArrayObjectOES_h