2012-12-03 22:27:25 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#ifndef WEBGL_RENDERBUFFER_H_
|
|
|
|
#define WEBGL_RENDERBUFFER_H_
|
2012-12-03 22:27:25 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2014-05-07 07:11:18 +04:00
|
|
|
#include "WebGLBindableName.h"
|
2014-03-04 11:14:35 +04:00
|
|
|
#include "WebGLFramebufferAttachable.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLObjectModel.h"
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class WebGLRenderbuffer MOZ_FINAL
|
2013-08-29 19:39:17 +04:00
|
|
|
: public nsWrapperCache
|
2014-11-17 05:21:04 +03:00
|
|
|
, public WebGLBindable<RBTarget>
|
2012-12-03 22:27:25 +04:00
|
|
|
, public WebGLRefCountedObject<WebGLRenderbuffer>
|
|
|
|
, public LinkedListElement<WebGLRenderbuffer>
|
|
|
|
, public WebGLRectangleObject
|
|
|
|
, public WebGLContextBoundObject
|
2014-03-04 11:14:35 +04:00
|
|
|
, public WebGLFramebufferAttachable
|
2012-12-03 22:27:25 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-11-14 07:03:50 +03:00
|
|
|
explicit WebGLRenderbuffer(WebGLContext* webgl);
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
void Delete();
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool HasUninitializedImageData() const {
|
|
|
|
return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData;
|
|
|
|
}
|
2013-10-11 17:16:43 +04:00
|
|
|
void SetImageDataStatus(WebGLImageDataStatus x) {
|
|
|
|
// there is no way to go from having image data to not having any
|
|
|
|
MOZ_ASSERT(x != WebGLImageDataStatus::NoImageData ||
|
|
|
|
mImageDataStatus == WebGLImageDataStatus::NoImageData);
|
|
|
|
mImageDataStatus = x;
|
|
|
|
}
|
2012-12-03 22:27:25 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum InternalFormat() const { return mInternalFormat; }
|
2014-11-14 07:03:50 +03:00
|
|
|
void SetInternalFormat(GLenum internalFormat) {
|
|
|
|
mInternalFormat = internalFormat;
|
|
|
|
}
|
2012-12-03 22:27:25 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum InternalFormatForGL() const { return mInternalFormatForGL; }
|
2014-11-14 07:03:50 +03:00
|
|
|
void SetInternalFormatForGL(GLenum internalFormatForGL) {
|
|
|
|
mInternalFormatForGL = internalFormatForGL;
|
|
|
|
}
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
int64_t MemoryUsage() const;
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext* GetParentObject() const {
|
2012-12-03 22:27:25 +04:00
|
|
|
return Context();
|
|
|
|
}
|
|
|
|
|
2013-10-02 04:31:09 +04:00
|
|
|
void BindRenderbuffer() const;
|
2014-11-14 07:03:50 +03:00
|
|
|
void RenderbufferStorage(GLenum internalFormat, GLsizei width,
|
|
|
|
GLsizei height) const;
|
2014-09-25 19:21:33 +04:00
|
|
|
void FramebufferRenderbuffer(FBAttachment attachment) const;
|
2013-10-02 04:31:09 +04:00
|
|
|
// Only handles a subset of `pname`s.
|
2014-09-25 19:21:33 +04:00
|
|
|
GLint GetRenderbufferParameter(RBTarget target, RBParam pname) const;
|
2013-10-02 04:31:09 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx) MOZ_OVERRIDE;
|
2012-12-03 22:27:25 +04:00
|
|
|
|
2013-08-29 19:39:17 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer)
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
protected:
|
2014-06-26 17:30:49 +04:00
|
|
|
~WebGLRenderbuffer() {
|
|
|
|
DeleteOnce();
|
|
|
|
}
|
|
|
|
|
2013-10-02 04:31:09 +04:00
|
|
|
GLuint mPrimaryRB;
|
|
|
|
GLuint mSecondaryRB;
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum mInternalFormat;
|
|
|
|
GLenum mInternalFormatForGL;
|
2013-10-11 17:16:43 +04:00
|
|
|
WebGLImageDataStatus mImageDataStatus;
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
friend class WebGLFramebuffer;
|
|
|
|
};
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2012-12-03 22:27:25 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
#endif // WEBGL_RENDERBUFFER_H_
|