2013-06-27 14:07:21 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
#ifndef WEBGL_VERTEX_ARRAY_H_
|
|
|
|
#define WEBGL_VERTEX_ARRAY_H_
|
2013-06-27 14:07:21 -07:00
|
|
|
|
2015-07-14 17:37:28 -07:00
|
|
|
#include "nsTArray.h"
|
2014-11-13 20:03:50 -08:00
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2015-07-14 17:37:28 -07:00
|
|
|
|
2013-07-17 09:13:38 -07:00
|
|
|
#include "WebGLBuffer.h"
|
2014-11-13 20:03:50 -08:00
|
|
|
#include "WebGLObjectModel.h"
|
2014-09-26 13:11:51 -07:00
|
|
|
#include "WebGLStrongTypes.h"
|
2014-11-13 20:03:50 -08:00
|
|
|
#include "WebGLVertexAttribData.h"
|
2013-06-27 14:07:21 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-06-10 17:23:50 -07:00
|
|
|
class WebGLVertexArrayFake;
|
|
|
|
|
2014-06-05 16:38:27 -07:00
|
|
|
class WebGLVertexArray
|
2013-09-04 05:14:48 -07:00
|
|
|
: public nsWrapperCache
|
2013-06-27 14:07:21 -07:00
|
|
|
, public WebGLRefCountedObject<WebGLVertexArray>
|
|
|
|
, public LinkedListElement<WebGLVertexArray>
|
|
|
|
, public WebGLContextBoundObject
|
|
|
|
{
|
|
|
|
public:
|
2014-11-13 20:03:50 -08:00
|
|
|
static WebGLVertexArray* Create(WebGLContext* webgl);
|
2013-08-06 17:05:51 -07:00
|
|
|
|
2014-06-05 16:38:27 -07:00
|
|
|
void BindVertexArray() {
|
2014-11-13 20:03:50 -08:00
|
|
|
// Bind to dummy value to signal that this vertex array has ever been
|
|
|
|
// bound.
|
2014-06-05 16:38:27 -07:00
|
|
|
BindVertexArrayImpl();
|
2013-06-27 14:07:21 -07:00
|
|
|
};
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
void EnsureAttrib(GLuint index);
|
|
|
|
bool HasAttrib(GLuint index) const {
|
|
|
|
return index < mAttribs.Length();
|
|
|
|
}
|
|
|
|
bool IsAttribArrayEnabled(GLuint index) const {
|
|
|
|
return HasAttrib(index) && mAttribs[index].enabled;
|
|
|
|
}
|
2013-08-06 17:05:51 -07:00
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
// Implement parent classes:
|
2013-08-06 17:05:51 -07:00
|
|
|
void Delete();
|
2015-05-20 16:58:36 -07:00
|
|
|
bool IsVertexArray();
|
2013-06-27 14:07:21 -07:00
|
|
|
|
|
|
|
WebGLContext* GetParentObject() const {
|
2015-11-24 20:15:29 -08:00
|
|
|
return mContext;
|
2013-06-27 14:07:21 -07:00
|
|
|
}
|
|
|
|
|
2015-07-14 17:37:28 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
2013-06-27 14:07:21 -07:00
|
|
|
|
2013-09-04 05:14:48 -07:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray)
|
2013-06-27 14:07:21 -07:00
|
|
|
|
2014-11-16 18:21:04 -08:00
|
|
|
GLuint GLName() const { return mGLName; }
|
|
|
|
|
2014-06-05 16:38:27 -07:00
|
|
|
protected:
|
2014-11-13 20:03:50 -08:00
|
|
|
explicit WebGLVertexArray(WebGLContext* webgl);
|
2014-06-05 16:38:27 -07:00
|
|
|
|
|
|
|
virtual ~WebGLVertexArray() {
|
|
|
|
MOZ_ASSERT(IsDeleted());
|
2014-11-13 20:03:50 -08:00
|
|
|
}
|
2013-08-06 17:05:51 -07:00
|
|
|
|
2015-05-20 16:58:36 -07:00
|
|
|
virtual void GenVertexArray() = 0;
|
|
|
|
virtual void BindVertexArrayImpl() = 0;
|
|
|
|
virtual void DeleteImpl() = 0;
|
|
|
|
virtual bool IsVertexArrayImpl() = 0;
|
|
|
|
|
2014-11-16 18:21:04 -08:00
|
|
|
GLuint mGLName;
|
2013-10-11 06:16:44 -07:00
|
|
|
nsTArray<WebGLVertexAttribData> mAttribs;
|
2014-06-05 16:38:27 -07:00
|
|
|
WebGLRefPtr<WebGLBuffer> mElementArrayBuffer;
|
2013-08-06 17:05:51 -07:00
|
|
|
|
2013-06-27 14:07:21 -07:00
|
|
|
friend class WebGLContext;
|
2014-11-13 20:03:50 -08:00
|
|
|
friend class WebGLVertexArrayFake;
|
2014-06-23 17:56:21 -07:00
|
|
|
friend class WebGL2Context;
|
2013-06-27 14:07:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
#endif // WEBGL_VERTEX_ARRAY_H_
|