michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef WEBGLBUFFER_H_ michael@0: #define WEBGLBUFFER_H_ michael@0: michael@0: #include "GLDefs.h" michael@0: #include "mozilla/LinkedList.h" michael@0: #include "mozilla/MemoryReporting.h" michael@0: #include "nsWrapperCache.h" michael@0: #include "WebGLObjectModel.h" michael@0: #include "WebGLTypes.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class WebGLElementArrayCache; michael@0: michael@0: class WebGLBuffer MOZ_FINAL michael@0: : public nsWrapperCache michael@0: , public WebGLRefCountedObject michael@0: , public LinkedListElement michael@0: , public WebGLContextBoundObject michael@0: { michael@0: public: michael@0: WebGLBuffer(WebGLContext *context); michael@0: michael@0: ~WebGLBuffer(); michael@0: michael@0: void Delete(); michael@0: michael@0: size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; michael@0: michael@0: bool HasEverBeenBound() { return mHasEverBeenBound; } michael@0: void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; } michael@0: GLuint GLName() const { return mGLName; } michael@0: WebGLsizeiptr ByteLength() const { return mByteLength; } michael@0: GLenum Target() const { return mTarget; } michael@0: michael@0: void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; } michael@0: michael@0: void SetTarget(GLenum target); michael@0: michael@0: bool ElementArrayCacheBufferData(const void* ptr, size_t buffer_size_in_bytes); michael@0: michael@0: void ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t update_size_in_bytes); michael@0: michael@0: bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count, michael@0: uint32_t* out_upperBound); michael@0: michael@0: WebGLContext *GetParentObject() const { michael@0: return Context(); michael@0: } michael@0: michael@0: virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; michael@0: michael@0: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer) michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer) michael@0: michael@0: protected: michael@0: michael@0: GLuint mGLName; michael@0: bool mHasEverBeenBound; michael@0: WebGLsizeiptr mByteLength; michael@0: GLenum mTarget; michael@0: michael@0: nsAutoPtr mCache; michael@0: }; michael@0: } michael@0: #endif //WEBGLBUFFER_H_