| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright (C) 2011 Google Inc. All rights reserved. |    2  * Copyright (C) 2011 Google 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 11 matching lines...) Expand all  Loading... | 
|   22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |   22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
|   23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |   23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
|   24  */ |   24  */ | 
|   25  |   25  | 
|   26 #ifndef WebGLVertexArrayObjectOES_h |   26 #ifndef WebGLVertexArrayObjectOES_h | 
|   27 #define WebGLVertexArrayObjectOES_h |   27 #define WebGLVertexArrayObjectOES_h | 
|   28  |   28  | 
|   29 #include "bindings/core/v8/ScriptWrappable.h" |   29 #include "bindings/core/v8/ScriptWrappable.h" | 
|   30 #include "core/html/canvas/WebGLBuffer.h" |   30 #include "core/html/canvas/WebGLBuffer.h" | 
|   31 #include "core/html/canvas/WebGLContextObject.h" |   31 #include "core/html/canvas/WebGLContextObject.h" | 
 |   32 #include "platform/heap/Handle.h" | 
|   32 #include "wtf/PassRefPtr.h" |   33 #include "wtf/PassRefPtr.h" | 
|   33  |   34  | 
|   34 namespace WebCore { |   35 namespace WebCore { | 
|   35  |   36  | 
|   36 class WebGLVertexArrayObjectOES FINAL : public WebGLContextObject, public Script
     Wrappable { |   37 class WebGLVertexArrayObjectOES FINAL : public WebGLContextObject, public Script
     Wrappable { | 
|   37 public: |   38 public: | 
|   38     enum VaoType { |   39     enum VaoType { | 
|   39         VaoTypeDefault, |   40         VaoTypeDefault, | 
|   40         VaoTypeUser, |   41         VaoTypeUser, | 
|   41     }; |   42     }; | 
|   42  |   43  | 
|   43     virtual ~WebGLVertexArrayObjectOES(); |   44     virtual ~WebGLVertexArrayObjectOES(); | 
|   44  |   45  | 
|   45     static PassRefPtr<WebGLVertexArrayObjectOES> create(WebGLRenderingContextBas
     e*, VaoType); |   46     static PassRefPtrWillBeRawPtr<WebGLVertexArrayObjectOES> create(WebGLRenderi
     ngContextBase*, VaoType); | 
|   46  |   47  | 
|   47     // Cached values for vertex attrib range checks |   48     // Cached values for vertex attrib range checks | 
|   48     struct VertexAttribState { |   49     class VertexAttribState FINAL { | 
 |   50         ALLOW_ONLY_INLINE_ALLOCATION(); | 
 |   51     public: | 
|   49         VertexAttribState() |   52         VertexAttribState() | 
|   50             : enabled(false) |   53             : enabled(false) | 
|   51             , bytesPerElement(0) |   54             , bytesPerElement(0) | 
|   52             , size(4) |   55             , size(4) | 
|   53             , type(GL_FLOAT) |   56             , type(GL_FLOAT) | 
|   54             , normalized(false) |   57             , normalized(false) | 
|   55             , stride(16) |   58             , stride(16) | 
|   56             , originalStride(0) |   59             , originalStride(0) | 
|   57             , offset(0) |   60             , offset(0) | 
|   58             , divisor(0) |   61             , divisor(0) | 
|   59         { |   62         { | 
|   60         } |   63         } | 
|   61  |   64  | 
 |   65         void trace(Visitor*); | 
 |   66  | 
|   62         bool enabled; |   67         bool enabled; | 
|   63         RefPtr<WebGLBuffer> bufferBinding; |   68         RefPtrWillBeMember<WebGLBuffer> bufferBinding; | 
|   64         GLsizei bytesPerElement; |   69         GLsizei bytesPerElement; | 
|   65         GLint size; |   70         GLint size; | 
|   66         GLenum type; |   71         GLenum type; | 
|   67         bool normalized; |   72         bool normalized; | 
|   68         GLsizei stride; |   73         GLsizei stride; | 
|   69         GLsizei originalStride; |   74         GLsizei originalStride; | 
|   70         GLintptr offset; |   75         GLintptr offset; | 
|   71         GLuint divisor; |   76         GLuint divisor; | 
|   72     }; |   77     }; | 
|   73  |   78  | 
|   74     bool isDefaultObject() const { return m_type == VaoTypeDefault; } |   79     bool isDefaultObject() const { return m_type == VaoTypeDefault; } | 
|   75  |   80  | 
|   76     bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; } |   81     bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; } | 
|   77     void setHasEverBeenBound() { m_hasEverBeenBound = true; } |   82     void setHasEverBeenBound() { m_hasEverBeenBound = true; } | 
|   78  |   83  | 
|   79     PassRefPtr<WebGLBuffer> boundElementArrayBuffer() const { return m_boundElem
     entArrayBuffer; } |   84     PassRefPtrWillBeRawPtr<WebGLBuffer> boundElementArrayBuffer() const { return
      m_boundElementArrayBuffer; } | 
|   80     void setElementArrayBuffer(PassRefPtr<WebGLBuffer>); |   85     void setElementArrayBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer>); | 
|   81  |   86  | 
|   82     VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribSt
     ate[index]; } |   87     VertexAttribState& getVertexAttribState(int index) { return m_vertexAttribSt
     ate[index]; } | 
|   83     void setVertexAttribState(GLuint, GLsizei, GLint, GLenum, GLboolean, GLsizei
     , GLintptr, PassRefPtr<WebGLBuffer>); |   88     void setVertexAttribState(GLuint, GLsizei, GLint, GLenum, GLboolean, GLsizei
     , GLintptr, PassRefPtrWillBeRawPtr<WebGLBuffer>); | 
|   84     void unbindBuffer(PassRefPtr<WebGLBuffer>); |   89     void unbindBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer>); | 
|   85     void setVertexAttribDivisor(GLuint index, GLuint divisor); |   90     void setVertexAttribDivisor(GLuint index, GLuint divisor); | 
|   86  |   91  | 
 |   92     virtual void trace(Visitor*) OVERRIDE; | 
 |   93  | 
|   87 private: |   94 private: | 
|   88     WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VaoType); |   95     WebGLVertexArrayObjectOES(WebGLRenderingContextBase*, VaoType); | 
|   89  |   96  | 
|   90     virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject
     ) OVERRIDE; |   97     virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject
     ) OVERRIDE; | 
|   91  |   98  | 
|   92     VaoType m_type; |   99     VaoType m_type; | 
|   93     bool m_hasEverBeenBound; |  100     bool m_hasEverBeenBound; | 
|   94     RefPtr<WebGLBuffer> m_boundElementArrayBuffer; |  101     RefPtrWillBeMember<WebGLBuffer> m_boundElementArrayBuffer; | 
|   95     Vector<VertexAttribState> m_vertexAttribState; |  102     WillBeHeapVector<VertexAttribState> m_vertexAttribState; | 
|   96 }; |  103 }; | 
|   97  |  104  | 
|   98 } // namespace WebCore |  105 } // namespace WebCore | 
|   99  |  106  | 
 |  107 #if ENABLE(OILPAN) | 
 |  108 namespace WTF { | 
 |  109 template<> | 
 |  110 struct VectorTraits<WebCore::WebGLVertexArrayObjectOES::VertexAttribState> : Sim
     pleClassVectorTraits<WebCore::WebGLVertexArrayObjectOES::VertexAttribState> { | 
 |  111     // The VertexAttribState's struct fields aren't handled as desired by the Is
     Pod() trait. | 
 |  112     // Override with the correct setting for the type. | 
 |  113     static const bool needsDestruction = false; | 
 |  114 }; | 
 |  115 } | 
 |  116 #endif | 
 |  117  | 
|  100 #endif // WebGLVertexArrayObjectOES_h |  118 #endif // WebGLVertexArrayObjectOES_h | 
| OLD | NEW |