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 "WebGLBindableName.h"
10 #include "WebGLObjectModel.h"
11 #include "WebGLFramebufferAttachable.h"
13 #include "nsWrapperCache.h"
15 #include "mozilla/LinkedList.h"
19 class WebGLRenderbuffer MOZ_FINAL
20 : public nsWrapperCache
21 , public WebGLBindableName
22 , public WebGLRefCountedObject
<WebGLRenderbuffer
>
23 , public LinkedListElement
<WebGLRenderbuffer
>
24 , public WebGLRectangleObject
25 , public WebGLContextBoundObject
26 , public WebGLFramebufferAttachable
29 explicit WebGLRenderbuffer(WebGLContext
* context
);
33 bool HasUninitializedImageData() const { return mImageDataStatus
== WebGLImageDataStatus::UninitializedImageData
; }
34 void SetImageDataStatus(WebGLImageDataStatus x
) {
35 // there is no way to go from having image data to not having any
36 MOZ_ASSERT(x
!= WebGLImageDataStatus::NoImageData
||
37 mImageDataStatus
== WebGLImageDataStatus::NoImageData
);
41 GLenum
InternalFormat() const { return mInternalFormat
; }
42 void SetInternalFormat(GLenum aInternalFormat
) { mInternalFormat
= aInternalFormat
; }
44 GLenum
InternalFormatForGL() const { return mInternalFormatForGL
; }
45 void SetInternalFormatForGL(GLenum aInternalFormatForGL
) { mInternalFormatForGL
= aInternalFormatForGL
; }
47 int64_t MemoryUsage() const;
49 WebGLContext
*GetParentObject() const {
53 void BindRenderbuffer() const;
54 void RenderbufferStorage(GLenum internalFormat
, GLsizei width
, GLsizei height
) const;
55 void FramebufferRenderbuffer(GLenum attachment
) const;
56 // Only handles a subset of `pname`s.
57 GLint
GetRenderbufferParameter(GLenum target
, GLenum pname
) const;
59 virtual JSObject
* WrapObject(JSContext
*cx
) MOZ_OVERRIDE
;
61 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer
)
62 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer
)
65 ~WebGLRenderbuffer() {
71 GLenum mInternalFormat
;
72 GLenum mInternalFormatForGL
;
73 WebGLImageDataStatus mImageDataStatus
;
75 friend class WebGLFramebuffer
;
77 } // namespace mozilla