Backed out changeset 58dbd2146e24 (bug 944961) for bustage.
[gecko.git] / content / canvas / src / WebGLRenderbuffer.h
blob4473253b7b3e320840a5e79b15af982e0794e21c
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 WEBGLRENDERBUFFER_H_
7 #define WEBGLRENDERBUFFER_H_
9 #include "WebGLObjectModel.h"
11 #include "nsWrapperCache.h"
13 #include "mozilla/LinkedList.h"
15 namespace mozilla {
17 class WebGLRenderbuffer MOZ_FINAL
18 : public nsWrapperCache
19 , public WebGLRefCountedObject<WebGLRenderbuffer>
20 , public LinkedListElement<WebGLRenderbuffer>
21 , public WebGLRectangleObject
22 , public WebGLContextBoundObject
24 public:
25 WebGLRenderbuffer(WebGLContext *context);
27 ~WebGLRenderbuffer() {
28 DeleteOnce();
31 void Delete();
33 bool HasEverBeenBound() { return mHasEverBeenBound; }
34 void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
36 bool HasUninitializedImageData() const { return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData; }
37 void SetImageDataStatus(WebGLImageDataStatus x) {
38 // there is no way to go from having image data to not having any
39 MOZ_ASSERT(x != WebGLImageDataStatus::NoImageData ||
40 mImageDataStatus == WebGLImageDataStatus::NoImageData);
41 mImageDataStatus = x;
44 GLenum InternalFormat() const { return mInternalFormat; }
45 void SetInternalFormat(GLenum aInternalFormat) { mInternalFormat = aInternalFormat; }
47 GLenum InternalFormatForGL() const { return mInternalFormatForGL; }
48 void SetInternalFormatForGL(GLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; }
50 int64_t MemoryUsage() const;
52 WebGLContext *GetParentObject() const {
53 return Context();
56 void BindRenderbuffer() const;
57 void RenderbufferStorage(GLenum internalFormat, GLsizei width, GLsizei height) const;
58 void FramebufferRenderbuffer(GLenum attachment) const;
59 // Only handles a subset of `pname`s.
60 GLint GetRenderbufferParameter(GLenum target, GLenum pname) const;
62 virtual JSObject* WrapObject(JSContext *cx,
63 JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
65 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer)
66 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer)
68 protected:
69 GLuint mPrimaryRB;
70 GLuint mSecondaryRB;
71 GLenum mInternalFormat;
72 GLenum mInternalFormatForGL;
73 bool mHasEverBeenBound;
74 WebGLImageDataStatus mImageDataStatus;
76 friend class WebGLFramebuffer;
78 } // namespace mozilla
80 #endif