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

Side by Side Diff: Source/core/html/canvas/WebGLVertexArrayObjectOES.h

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Complete VectorTraits<> specialization for VertexAttribState Created 6 years, 5 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 unified diff | Download patch
OLDNEW
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
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 namespace WTF {
108 template<>
109 struct VectorTraits<WebCore::WebGLVertexArrayObjectOES::VertexAttribState> : Sim pleClassVectorTraits<WebCore::WebGLVertexArrayObjectOES::VertexAttribState> {
110 // Specialization needed as the VertexAttribState's struct fields
111 // aren't handled as desired by the IsPod() trait.
112 static const bool needsDestruction = false;
113 // Must use the constructor.
114 static const bool canInitializeWithMemset = false;
115 static const bool canCopyWithMemcpy = true;
haraken 2014/07/02 07:47:39 Is it to safe to move the memory with memcpy even
sof 2014/07/02 11:43:53 I don't think it is relied upon, but what's your c
116 };
117 }
118
100 #endif // WebGLVertexArrayObjectOES_h 119 #endif // WebGLVertexArrayObjectOES_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698