|
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/. */ |
|
5 |
|
6 #ifndef WEBGLBUFFER_H_ |
|
7 #define WEBGLBUFFER_H_ |
|
8 |
|
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" |
|
15 |
|
16 namespace mozilla { |
|
17 |
|
18 class WebGLElementArrayCache; |
|
19 |
|
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); |
|
28 |
|
29 ~WebGLBuffer(); |
|
30 |
|
31 void Delete(); |
|
32 |
|
33 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
|
34 |
|
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; } |
|
40 |
|
41 void SetByteLength(WebGLsizeiptr byteLength) { mByteLength = byteLength; } |
|
42 |
|
43 void SetTarget(GLenum target); |
|
44 |
|
45 bool ElementArrayCacheBufferData(const void* ptr, size_t buffer_size_in_bytes); |
|
46 |
|
47 void ElementArrayCacheBufferSubData(size_t pos, const void* ptr, size_t update_size_in_bytes); |
|
48 |
|
49 bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count, |
|
50 uint32_t* out_upperBound); |
|
51 |
|
52 WebGLContext *GetParentObject() const { |
|
53 return Context(); |
|
54 } |
|
55 |
|
56 virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; |
|
57 |
|
58 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer) |
|
59 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer) |
|
60 |
|
61 protected: |
|
62 |
|
63 GLuint mGLName; |
|
64 bool mHasEverBeenBound; |
|
65 WebGLsizeiptr mByteLength; |
|
66 GLenum mTarget; |
|
67 |
|
68 nsAutoPtr<WebGLElementArrayCache> mCache; |
|
69 }; |
|
70 } |
|
71 #endif //WEBGLBUFFER_H_ |