2012-11-20 13:38:20 -08: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_BUFFER_H_
|
|
|
|
#define WEBGL_BUFFER_H_
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2013-06-10 13:00:35 -07:00
|
|
|
#include "GLDefs.h"
|
2012-11-20 13:38:20 -08:00
|
|
|
#include "mozilla/LinkedList.h"
|
2015-07-14 17:37:28 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2014-03-17 07:52:56 -07:00
|
|
|
#include "nsWrapperCache.h"
|
2015-07-14 17:37:28 -07:00
|
|
|
|
2014-03-17 07:52:56 -07:00
|
|
|
#include "WebGLObjectModel.h"
|
2014-11-13 20:03:50 -08:00
|
|
|
#include "WebGLTypes.h"
|
2012-11-20 13:38:20 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2013-06-10 13:00:35 -07:00
|
|
|
class WebGLElementArrayCache;
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class WebGLBuffer final
|
2013-08-29 08:39:17 -07:00
|
|
|
: public nsWrapperCache
|
2012-11-20 13:38:20 -08:00
|
|
|
, public WebGLRefCountedObject<WebGLBuffer>
|
|
|
|
, public LinkedListElement<WebGLBuffer>
|
|
|
|
, public WebGLContextBoundObject
|
|
|
|
{
|
|
|
|
public:
|
2015-05-20 16:59:14 -07:00
|
|
|
|
|
|
|
enum class Kind {
|
|
|
|
Undefined,
|
|
|
|
ElementArray,
|
|
|
|
OtherData
|
|
|
|
};
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
explicit WebGLBuffer(WebGLContext* webgl, GLuint buf);
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2015-05-20 16:59:14 -07:00
|
|
|
void BindTo(GLenum target);
|
|
|
|
Kind Content() const { return mContent; }
|
|
|
|
|
2012-11-20 13:38:20 -08:00
|
|
|
void Delete();
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2013-09-04 05:14:35 -07:00
|
|
|
WebGLsizeiptr ByteLength() const { return mByteLength; }
|
|
|
|
void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; }
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
bool ElementArrayCacheBufferData(const void* ptr, size_t bufferSizeInBytes);
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
void ElementArrayCacheBufferSubData(size_t pos, const void* ptr,
|
|
|
|
size_t updateSizeInBytes);
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2014-03-17 07:52:56 -07:00
|
|
|
bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count,
|
2014-11-13 20:03:50 -08:00
|
|
|
uint32_t* const out_upperBound);
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2014-06-02 13:30:00 -07:00
|
|
|
bool IsElementArrayUsedWithMultipleTypes() const;
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
WebGLContext* GetParentObject() const {
|
2012-11-20 13:38:20 -08:00
|
|
|
return Context();
|
2015-01-15 15:40:39 -08:00
|
|
|
}
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2015-07-14 17:37:28 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2015-05-21 22:49:30 -07:00
|
|
|
const GLenum mGLName;
|
|
|
|
|
2013-08-29 08:39:17 -07:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer)
|
2012-11-20 13:38:20 -08:00
|
|
|
|
|
|
|
protected:
|
2014-06-26 06:30:49 -07:00
|
|
|
~WebGLBuffer();
|
2012-11-20 13:38:20 -08:00
|
|
|
|
2015-05-20 16:59:14 -07:00
|
|
|
Kind mContent;
|
2013-09-04 05:14:35 -07:00
|
|
|
WebGLsizeiptr mByteLength;
|
2012-11-20 13:38:20 -08:00
|
|
|
nsAutoPtr<WebGLElementArrayCache> mCache;
|
|
|
|
};
|
2014-11-13 20:03:50 -08:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // WEBGL_BUFFER_H_
|