2013-06-28 01:07:21 +04: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-14 07:03:50 +03:00
|
|
|
#ifndef WEBGL_VERTEX_ARRAY_H_
|
|
|
|
#define WEBGL_VERTEX_ARRAY_H_
|
2013-06-28 01:07:21 +04:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "nsTArray.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLObjectModel.h"
|
2014-09-27 00:11:51 +04:00
|
|
|
#include "WebGLStrongTypes.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLVertexAttribData.h"
|
2013-06-28 01:07:21 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-06-11 04:23:50 +04:00
|
|
|
class WebGLVertexArrayFake;
|
|
|
|
|
2014-06-06 03:38:27 +04:00
|
|
|
class WebGLVertexArray
|
2013-09-04 16:14:48 +04:00
|
|
|
: public nsWrapperCache
|
2013-06-28 01:07:21 +04:00
|
|
|
, public WebGLRefCountedObject<WebGLVertexArray>
|
|
|
|
, public LinkedListElement<WebGLVertexArray>
|
|
|
|
{
|
|
|
|
public:
|
2014-11-14 07:03:50 +03:00
|
|
|
static WebGLVertexArray* Create(WebGLContext* webgl);
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2014-06-06 03:38:27 +04:00
|
|
|
void BindVertexArray() {
|
2014-11-14 07:03:50 +03:00
|
|
|
// Bind to dummy value to signal that this vertex array has ever been
|
|
|
|
// bound.
|
2014-06-06 03:38:27 +04:00
|
|
|
BindVertexArrayImpl();
|
2013-06-28 01:07:21 +04:00
|
|
|
};
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
// Implement parent classes:
|
2013-08-07 04:05:51 +04:00
|
|
|
void Delete();
|
2016-11-30 05:30:28 +03:00
|
|
|
bool IsVertexArray() const;
|
2013-06-28 01:07:21 +04:00
|
|
|
|
|
|
|
WebGLContext* GetParentObject() const {
|
2015-11-25 07:15:29 +03:00
|
|
|
return mContext;
|
2013-06-28 01:07:21 +04:00
|
|
|
}
|
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
2013-06-28 01:07:21 +04:00
|
|
|
|
2013-09-04 16:14:48 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray)
|
2013-06-28 01:07:21 +04:00
|
|
|
|
2014-11-17 05:21:04 +03:00
|
|
|
GLuint GLName() const { return mGLName; }
|
|
|
|
|
2016-12-29 11:08:39 +03:00
|
|
|
void AddBufferBindCounts(int8_t addVal) const;
|
|
|
|
|
2014-06-06 03:38:27 +04:00
|
|
|
protected:
|
2014-11-14 07:03:50 +03:00
|
|
|
explicit WebGLVertexArray(WebGLContext* webgl);
|
2016-12-29 11:08:39 +03:00
|
|
|
virtual ~WebGLVertexArray();
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2015-05-21 02:58:36 +03:00
|
|
|
virtual void GenVertexArray() = 0;
|
|
|
|
virtual void BindVertexArrayImpl() = 0;
|
|
|
|
virtual void DeleteImpl() = 0;
|
2016-11-30 05:30:28 +03:00
|
|
|
virtual bool IsVertexArrayImpl() const = 0;
|
2015-05-21 02:58:36 +03:00
|
|
|
|
2014-11-17 05:21:04 +03:00
|
|
|
GLuint mGLName;
|
2013-10-11 17:16:44 +04:00
|
|
|
nsTArray<WebGLVertexAttribData> mAttribs;
|
2014-06-06 03:38:27 +04:00
|
|
|
WebGLRefPtr<WebGLBuffer> mElementArrayBuffer;
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2016-12-22 06:42:07 +03:00
|
|
|
friend class ScopedDrawHelper;
|
2013-06-28 01:07:21 +04:00
|
|
|
friend class WebGLContext;
|
2014-11-14 07:03:50 +03:00
|
|
|
friend class WebGLVertexArrayFake;
|
2014-06-24 04:56:21 +04:00
|
|
|
friend class WebGL2Context;
|
2013-06-28 01:07:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_VERTEX_ARRAY_H_
|