Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef WEBGLBUFFER_H_ |
michael@0 | 7 | #define WEBGLBUFFER_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "GLDefs.h" |
michael@0 | 10 | #include "mozilla/LinkedList.h" |
michael@0 | 11 | #include "mozilla/MemoryReporting.h" |
michael@0 | 12 | #include "nsWrapperCache.h" |
michael@0 | 13 | #include "WebGLObjectModel.h" |
michael@0 | 14 | #include "WebGLTypes.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | |
michael@0 | 18 | class WebGLElementArrayCache; |
michael@0 | 19 | |
michael@0 | 20 | class WebGLBuffer MOZ_FINAL |
michael@0 | 21 | : public nsWrapperCache |
michael@0 | 22 | , public WebGLRefCountedObject<WebGLBuffer> |
michael@0 | 23 | , public LinkedListElement<WebGLBuffer> |
michael@0 | 24 | , public WebGLContextBoundObject |
michael@0 | 25 | { |
michael@0 | 26 | public: |
michael@0 | 27 | WebGLBuffer(WebGLContext *context); |
michael@0 | 28 | |
michael@0 | 29 | ~WebGLBuffer(); |
michael@0 | 30 | |
michael@0 | 31 | void Delete(); |
michael@0 | 32 | |
michael@0 | 33 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 34 | |
michael@0 | 35 | bool HasEverBeenBound() { return mHasEverBeenBound; } |
michael@0 | 36 | void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; } |
michael@0 | 37 | GLuint GLName() const { return mGLName; } |
michael@0 | 38 | WebGLsizeiptr ByteLength() const { return mByteLength; } |
michael@0 | 39 | GLenum Target() const { return mTarget; } |
michael@0 | 40 | |
michael@0 | 41 | void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; } |
michael@0 | 42 | |
michael@0 | 43 | void SetTarget(GLenum target); |
michael@0 | 44 | |
michael@0 | 45 | bool ElementArrayCacheBufferData(const void* ptr, size_t buffer_size_in_bytes); |
michael@0 | 46 | |
michael@0 | 47 | void ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t update_size_in_bytes); |
michael@0 | 48 | |
michael@0 | 49 | bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count, |
michael@0 | 50 | uint32_t* out_upperBound); |
michael@0 | 51 | |
michael@0 | 52 | WebGLContext *GetParentObject() const { |
michael@0 | 53 | return Context(); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; |
michael@0 | 57 | |
michael@0 | 58 | NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer) |
michael@0 | 59 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer) |
michael@0 | 60 | |
michael@0 | 61 | protected: |
michael@0 | 62 | |
michael@0 | 63 | GLuint mGLName; |
michael@0 | 64 | bool mHasEverBeenBound; |
michael@0 | 65 | WebGLsizeiptr mByteLength; |
michael@0 | 66 | GLenum mTarget; |
michael@0 | 67 | |
michael@0 | 68 | nsAutoPtr<WebGLElementArrayCache> mCache; |
michael@0 | 69 | }; |
michael@0 | 70 | } |
michael@0 | 71 | #endif //WEBGLBUFFER_H_ |