2012-12-03 10:27:25 -08: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-13 20:03:50 -08:00
|
|
|
#ifndef WEBGL_RENDERBUFFER_H_
|
|
|
|
#define WEBGL_RENDERBUFFER_H_
|
2012-12-03 10:27:25 -08:00
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2014-05-06 20:11:18 -07:00
|
|
|
#include "WebGLBindableName.h"
|
2014-03-03 23:14:35 -08:00
|
|
|
#include "WebGLFramebufferAttachable.h"
|
2014-11-13 20:03:50 -08:00
|
|
|
#include "WebGLObjectModel.h"
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class WebGLRenderbuffer MOZ_FINAL
|
2013-08-29 08:39:17 -07:00
|
|
|
: public nsWrapperCache
|
2014-11-16 18:21:04 -08:00
|
|
|
, public WebGLBindable<RBTarget>
|
2012-12-03 10:27:25 -08:00
|
|
|
, public WebGLRefCountedObject<WebGLRenderbuffer>
|
|
|
|
, public LinkedListElement<WebGLRenderbuffer>
|
|
|
|
, public WebGLRectangleObject
|
|
|
|
, public WebGLContextBoundObject
|
2014-03-03 23:14:35 -08:00
|
|
|
, public WebGLFramebufferAttachable
|
2012-12-03 10:27:25 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-11-13 20:03:50 -08:00
|
|
|
explicit WebGLRenderbuffer(WebGLContext* webgl);
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
void Delete();
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
bool HasUninitializedImageData() const {
|
|
|
|
return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData;
|
|
|
|
}
|
2013-10-11 06:16:43 -07: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 10:27:25 -08:00
|
|
|
|
2013-09-04 05:14:43 -07:00
|
|
|
GLenum InternalFormat() const { return mInternalFormat; }
|
2014-11-13 20:03:50 -08:00
|
|
|
void SetInternalFormat(GLenum internalFormat) {
|
|
|
|
mInternalFormat = internalFormat;
|
|
|
|
}
|
2012-12-03 10:27:25 -08:00
|
|
|
|
2013-09-04 05:14:43 -07:00
|
|
|
GLenum InternalFormatForGL() const { return mInternalFormatForGL; }
|
2014-11-13 20:03:50 -08:00
|
|
|
void SetInternalFormatForGL(GLenum internalFormatForGL) {
|
|
|
|
mInternalFormatForGL = internalFormatForGL;
|
|
|
|
}
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
int64_t MemoryUsage() const;
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
WebGLContext* GetParentObject() const {
|
2012-12-03 10:27:25 -08:00
|
|
|
return Context();
|
|
|
|
}
|
|
|
|
|
2013-10-01 17:31:09 -07:00
|
|
|
void BindRenderbuffer() const;
|
2014-11-13 20:03:50 -08:00
|
|
|
void RenderbufferStorage(GLenum internalFormat, GLsizei width,
|
|
|
|
GLsizei height) const;
|
2014-09-25 08:21:33 -07:00
|
|
|
void FramebufferRenderbuffer(FBAttachment attachment) const;
|
2013-10-01 17:31:09 -07:00
|
|
|
// Only handles a subset of `pname`s.
|
2014-09-25 08:21:33 -07:00
|
|
|
GLint GetRenderbufferParameter(RBTarget target, RBParam pname) const;
|
2013-10-01 17:31:09 -07:00
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx) MOZ_OVERRIDE;
|
2012-12-03 10:27:25 -08:00
|
|
|
|
2013-08-29 08:39:17 -07:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer)
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
protected:
|
2014-06-26 06:30:49 -07:00
|
|
|
~WebGLRenderbuffer() {
|
|
|
|
DeleteOnce();
|
|
|
|
}
|
|
|
|
|
2013-10-01 17:31:09 -07:00
|
|
|
GLuint mPrimaryRB;
|
|
|
|
GLuint mSecondaryRB;
|
2013-09-04 05:14:43 -07:00
|
|
|
GLenum mInternalFormat;
|
|
|
|
GLenum mInternalFormatForGL;
|
2013-10-11 06:16:43 -07:00
|
|
|
WebGLImageDataStatus mImageDataStatus;
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
friend class WebGLFramebuffer;
|
|
|
|
};
|
2014-11-13 20:03:50 -08:00
|
|
|
|
2012-12-03 10:27:25 -08:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
#endif // WEBGL_RENDERBUFFER_H_
|