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.)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef WEBGLBUFFER_H_
7 #define WEBGLBUFFER_H_
9 #include "GLDefs.h"
10 #include "mozilla/LinkedList.h"
11 #include "mozilla/MemoryReporting.h"
12 #include "nsWrapperCache.h"
13 #include "WebGLObjectModel.h"
14 #include "WebGLTypes.h"
16 namespace mozilla {
18 class WebGLElementArrayCache;
20 class WebGLBuffer MOZ_FINAL
21 : public nsWrapperCache
22 , public WebGLRefCountedObject<WebGLBuffer>
23 , public LinkedListElement<WebGLBuffer>
24 , public WebGLContextBoundObject
25 {
26 public:
27 WebGLBuffer(WebGLContext *context);
29 ~WebGLBuffer();
31 void Delete();
33 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
35 bool HasEverBeenBound() { return mHasEverBeenBound; }
36 void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
37 GLuint GLName() const { return mGLName; }
38 WebGLsizeiptr ByteLength() const { return mByteLength; }
39 GLenum Target() const { return mTarget; }
41 void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; }
43 void SetTarget(GLenum target);
45 bool ElementArrayCacheBufferData(const void* ptr, size_t buffer_size_in_bytes);
47 void ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t update_size_in_bytes);
49 bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count,
50 uint32_t* out_upperBound);
52 WebGLContext *GetParentObject() const {
53 return Context();
54 }
56 virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
58 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer)
59 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer)
61 protected:
63 GLuint mGLName;
64 bool mHasEverBeenBound;
65 WebGLsizeiptr mByteLength;
66 GLenum mTarget;
68 nsAutoPtr<WebGLElementArrayCache> mCache;
69 };
70 }
71 #endif //WEBGLBUFFER_H_