content/canvas/src/WebGLRenderbuffer.h

branch
TOR_BUG_9701
changeset 11
deefc01c0e14
equal deleted inserted replaced
-1:000000000000 0:171ac86730d6
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 WEBGLRENDERBUFFER_H_
7 #define WEBGLRENDERBUFFER_H_
8
9 #include "WebGLObjectModel.h"
10 #include "WebGLFramebufferAttachable.h"
11
12 #include "nsWrapperCache.h"
13
14 #include "mozilla/LinkedList.h"
15
16 namespace mozilla {
17
18 class WebGLRenderbuffer MOZ_FINAL
19 : public nsWrapperCache
20 , public WebGLRefCountedObject<WebGLRenderbuffer>
21 , public LinkedListElement<WebGLRenderbuffer>
22 , public WebGLRectangleObject
23 , public WebGLContextBoundObject
24 , public WebGLFramebufferAttachable
25 {
26 public:
27 WebGLRenderbuffer(WebGLContext *context);
28
29 ~WebGLRenderbuffer() {
30 DeleteOnce();
31 }
32
33 void Delete();
34
35 bool HasEverBeenBound() { return mHasEverBeenBound; }
36 void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
37
38 bool HasUninitializedImageData() const { return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData; }
39 void SetImageDataStatus(WebGLImageDataStatus x) {
40 // there is no way to go from having image data to not having any
41 MOZ_ASSERT(x != WebGLImageDataStatus::NoImageData ||
42 mImageDataStatus == WebGLImageDataStatus::NoImageData);
43 mImageDataStatus = x;
44 }
45
46 GLenum InternalFormat() const { return mInternalFormat; }
47 void SetInternalFormat(GLenum aInternalFormat) { mInternalFormat = aInternalFormat; }
48
49 GLenum InternalFormatForGL() const { return mInternalFormatForGL; }
50 void SetInternalFormatForGL(GLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; }
51
52 int64_t MemoryUsage() const;
53
54 WebGLContext *GetParentObject() const {
55 return Context();
56 }
57
58 void BindRenderbuffer() const;
59 void RenderbufferStorage(GLenum internalFormat, GLsizei width, GLsizei height) const;
60 void FramebufferRenderbuffer(GLenum attachment) const;
61 // Only handles a subset of `pname`s.
62 GLint GetRenderbufferParameter(GLenum target, GLenum pname) const;
63
64 virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
65
66 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer)
67 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer)
68
69 protected:
70 GLuint mPrimaryRB;
71 GLuint mSecondaryRB;
72 GLenum mInternalFormat;
73 GLenum mInternalFormatForGL;
74 bool mHasEverBeenBound;
75 WebGLImageDataStatus mImageDataStatus;
76
77 friend class WebGLFramebuffer;
78 };
79 } // namespace mozilla
80
81 #endif

mercurial