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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp

Issue 1555523002: WebGL: remove validation code for vertexAttribPointer and vertexAttribIPointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed feedbacks from Zhenyao and Ken Created 4 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/webgl/WebGLVertexArrayObjectBase.h" 5 #include "modules/webgl/WebGLVertexArrayObjectBase.h"
6 6
7 #include "modules/webgl/WebGLRenderingContextBase.h" 7 #include "modules/webgl/WebGLRenderingContextBase.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase(WebGLRenderingContextBase * ctx, VaoType type) 11 WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase(WebGLRenderingContextBase * ctx, VaoType type)
12 : WebGLContextObject(ctx) 12 : WebGLContextObject(ctx)
13 , m_object(0) 13 , m_object(0)
14 , m_type(type) 14 , m_type(type)
15 , m_hasEverBeenBound(false) 15 , m_hasEverBeenBound(false)
16 , m_destructionInProgress(false) 16 , m_destructionInProgress(false)
17 , m_boundElementArrayBuffer(nullptr) 17 , m_boundElementArrayBuffer(nullptr)
18 { 18 {
19 m_vertexAttribState.reserveCapacity(ctx->maxVertexAttribs()); 19 m_arrayBufferList.resize(ctx->maxVertexAttribs());
20 20
21 switch (m_type) { 21 switch (m_type) {
22 case VaoTypeDefault: 22 case VaoTypeDefault:
23 break; 23 break;
24 default: 24 default:
25 m_object = context()->webContext()->createVertexArrayOES(); 25 m_object = context()->webContext()->createVertexArrayOES();
26 break; 26 break;
27 } 27 }
28 } 28 }
29 29
30 WebGLVertexArrayObjectBase::~WebGLVertexArrayObjectBase() 30 WebGLVertexArrayObjectBase::~WebGLVertexArrayObjectBase()
31 { 31 {
32 m_destructionInProgress = true; 32 m_destructionInProgress = true;
33 33
34 // Delete the platform framebuffer resource, in case 34 // Delete the platform framebuffer resource, in case
35 // where this vertex array object isn't detached when it and 35 // where this vertex array object isn't detached when it and
36 // the WebGLRenderingContextBase object it is registered with 36 // the WebGLRenderingContextBase object it is registered with
37 // are both finalized. 37 // are both finalized.
38 detachAndDeleteObject(); 38 detachAndDeleteObject();
39 } 39 }
40 40
41 void WebGLVertexArrayObjectBase::dispatchDetached(WebGraphicsContext3D* context3 d) 41 void WebGLVertexArrayObjectBase::dispatchDetached(WebGraphicsContext3D* context3 d)
42 { 42 {
43 if (m_boundElementArrayBuffer) 43 if (m_boundElementArrayBuffer)
44 m_boundElementArrayBuffer->onDetached(context3d); 44 m_boundElementArrayBuffer->onDetached(context3d);
45 45
46 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { 46 for (size_t i = 0; i < m_arrayBufferList.size(); ++i) {
47 VertexAttribState* state = m_vertexAttribState[i].get(); 47 if (m_arrayBufferList[i])
48 if (state->bufferBinding) 48 m_arrayBufferList[i]->onDetached(context3d);
49 state->bufferBinding->onDetached(context3d);
50 } 49 }
51 } 50 }
52 51
53 void WebGLVertexArrayObjectBase::deleteObjectImpl(WebGraphicsContext3D* context3 d) 52 void WebGLVertexArrayObjectBase::deleteObjectImpl(WebGraphicsContext3D* context3 d)
54 { 53 {
55 switch (m_type) { 54 switch (m_type) {
56 case VaoTypeDefault: 55 case VaoTypeDefault:
57 break; 56 break;
58 default: 57 default:
59 context3d->deleteVertexArrayOES(m_object); 58 context3d->deleteVertexArrayOES(m_object);
(...skipping 11 matching lines...) Expand all
71 70
72 void WebGLVertexArrayObjectBase::setElementArrayBuffer(WebGLBuffer* buffer) 71 void WebGLVertexArrayObjectBase::setElementArrayBuffer(WebGLBuffer* buffer)
73 { 72 {
74 if (buffer) 73 if (buffer)
75 buffer->onAttached(); 74 buffer->onAttached();
76 if (m_boundElementArrayBuffer) 75 if (m_boundElementArrayBuffer)
77 m_boundElementArrayBuffer->onDetached(context()->webContext()); 76 m_boundElementArrayBuffer->onDetached(context()->webContext());
78 m_boundElementArrayBuffer = buffer; 77 m_boundElementArrayBuffer = buffer;
79 } 78 }
80 79
81 WebGLVertexArrayObjectBase::VertexAttribState* WebGLVertexArrayObjectBase::getVe rtexAttribState(size_t index) 80 WebGLBuffer* WebGLVertexArrayObjectBase::getArrayBufferForAttrib(size_t index)
82 { 81 {
83 ASSERT(index < context()->maxVertexAttribs()); 82 ASSERT(index < context()->maxVertexAttribs());
84 // Lazily create the vertex attribute states. 83 return m_arrayBufferList[index].get();
85 for (size_t i = m_vertexAttribState.size(); i <= index; i++)
86 m_vertexAttribState.append(new VertexAttribState);
87 return m_vertexAttribState[index].get();
88 } 84 }
89 85
90 void WebGLVertexArrayObjectBase::setVertexAttribState( 86 void WebGLVertexArrayObjectBase::setArrayBufferForAttrib(GLuint index, WebGLBuff er* buffer)
91 GLuint index, GLsizei bytesPerElement, GLint size, GLenum type, GLboolean no rmalized, GLsizei stride, GLintptr offset, WebGLBuffer* buffer)
92 { 87 {
93 GLsizei validatedStride = stride ? stride : bytesPerElement;
94 VertexAttribState* state = getVertexAttribState(index);
95
96 if (buffer) 88 if (buffer)
97 buffer->onAttached(); 89 buffer->onAttached();
98 if (state->bufferBinding) 90 if (m_arrayBufferList[index])
99 state->bufferBinding->onDetached(context()->webContext()); 91 m_arrayBufferList[index]->onDetached(context()->webContext());
100 92
101 state->bufferBinding = buffer; 93 m_arrayBufferList[index] = buffer;
102 state->bytesPerElement = bytesPerElement;
103 state->size = size;
104 state->type = type;
105 state->normalized = normalized;
106 state->stride = validatedStride;
107 state->originalStride = stride;
108 state->offset = offset;
109 } 94 }
110 95
111 void WebGLVertexArrayObjectBase::unbindBuffer(WebGLBuffer* buffer) 96 void WebGLVertexArrayObjectBase::unbindBuffer(WebGLBuffer* buffer)
112 { 97 {
113 if (m_boundElementArrayBuffer == buffer) { 98 if (m_boundElementArrayBuffer == buffer) {
114 m_boundElementArrayBuffer->onDetached(context()->webContext()); 99 m_boundElementArrayBuffer->onDetached(context()->webContext());
115 m_boundElementArrayBuffer = nullptr; 100 m_boundElementArrayBuffer = nullptr;
116 } 101 }
117 102
118 for (size_t i = 0; i < m_vertexAttribState.size(); ++i) { 103 for (size_t i = 0; i < m_arrayBufferList.size(); ++i) {
119 VertexAttribState* state = m_vertexAttribState[i]; 104 if (m_arrayBufferList[i] == buffer) {
120 if (state->bufferBinding == buffer) { 105 m_arrayBufferList[i]->onDetached(context()->webContext());
121 buffer->onDetached(context()->webContext()); 106 m_arrayBufferList[i] = nullptr;
122 state->bufferBinding = nullptr;
123 } 107 }
124 } 108 }
125 } 109 }
126 110
127 void WebGLVertexArrayObjectBase::setVertexAttribDivisor(GLuint index, GLuint div isor)
128 {
129 VertexAttribState* state = getVertexAttribState(index);
130 state->divisor = divisor;
131 }
132
133 DEFINE_TRACE(WebGLVertexArrayObjectBase::VertexAttribState)
134 {
135 visitor->trace(bufferBinding);
136 }
137
138 DEFINE_TRACE(WebGLVertexArrayObjectBase) 111 DEFINE_TRACE(WebGLVertexArrayObjectBase)
139 { 112 {
140 visitor->trace(m_boundElementArrayBuffer); 113 visitor->trace(m_boundElementArrayBuffer);
141 visitor->trace(m_vertexAttribState); 114 visitor->trace(m_arrayBufferList);
142 WebGLContextObject::trace(visitor); 115 WebGLContextObject::trace(visitor);
143 } 116 }
144 117
145 } // namespace blink 118 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698