michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef WEBGLRENDERBUFFER_H_ michael@0: #define WEBGLRENDERBUFFER_H_ michael@0: michael@0: #include "WebGLObjectModel.h" michael@0: #include "WebGLFramebufferAttachable.h" michael@0: michael@0: #include "nsWrapperCache.h" michael@0: michael@0: #include "mozilla/LinkedList.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class WebGLRenderbuffer MOZ_FINAL michael@0: : public nsWrapperCache michael@0: , public WebGLRefCountedObject michael@0: , public LinkedListElement michael@0: , public WebGLRectangleObject michael@0: , public WebGLContextBoundObject michael@0: , public WebGLFramebufferAttachable michael@0: { michael@0: public: michael@0: WebGLRenderbuffer(WebGLContext *context); michael@0: michael@0: ~WebGLRenderbuffer() { michael@0: DeleteOnce(); michael@0: } michael@0: michael@0: void Delete(); michael@0: michael@0: bool HasEverBeenBound() { return mHasEverBeenBound; } michael@0: void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; } michael@0: michael@0: bool HasUninitializedImageData() const { return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData; } michael@0: void SetImageDataStatus(WebGLImageDataStatus x) { michael@0: // there is no way to go from having image data to not having any michael@0: MOZ_ASSERT(x != WebGLImageDataStatus::NoImageData || michael@0: mImageDataStatus == WebGLImageDataStatus::NoImageData); michael@0: mImageDataStatus = x; michael@0: } michael@0: michael@0: GLenum InternalFormat() const { return mInternalFormat; } michael@0: void SetInternalFormat(GLenum aInternalFormat) { mInternalFormat = aInternalFormat; } michael@0: michael@0: GLenum InternalFormatForGL() const { return mInternalFormatForGL; } michael@0: void SetInternalFormatForGL(GLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; } michael@0: michael@0: int64_t MemoryUsage() const; michael@0: michael@0: WebGLContext *GetParentObject() const { michael@0: return Context(); michael@0: } michael@0: michael@0: void BindRenderbuffer() const; michael@0: void RenderbufferStorage(GLenum internalFormat, GLsizei width, GLsizei height) const; michael@0: void FramebufferRenderbuffer(GLenum attachment) const; michael@0: // Only handles a subset of `pname`s. michael@0: GLint GetRenderbufferParameter(GLenum target, GLenum pname) const; michael@0: michael@0: virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; michael@0: michael@0: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer) michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer) michael@0: michael@0: protected: michael@0: GLuint mPrimaryRB; michael@0: GLuint mSecondaryRB; michael@0: GLenum mInternalFormat; michael@0: GLenum mInternalFormatForGL; michael@0: bool mHasEverBeenBound; michael@0: WebGLImageDataStatus mImageDataStatus; michael@0: michael@0: friend class WebGLFramebuffer; michael@0: }; michael@0: } // namespace mozilla michael@0: michael@0: #endif