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/. */
|
|
|
|
|
|
|
|
#ifndef WEBGLRENDERBUFFER_H_
|
|
|
|
#define WEBGLRENDERBUFFER_H_
|
|
|
|
|
2014-05-06 20:11:18 -07:00
|
|
|
#include "WebGLBindableName.h"
|
2012-12-03 10:27:25 -08:00
|
|
|
#include "WebGLObjectModel.h"
|
2014-03-03 23:14:35 -08:00
|
|
|
#include "WebGLFramebufferAttachable.h"
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class WebGLRenderbuffer MOZ_FINAL
|
2013-08-29 08:39:17 -07:00
|
|
|
: public nsWrapperCache
|
2014-05-06 20:11:18 -07:00
|
|
|
, public WebGLBindableName
|
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-09-01 17:49:25 -07:00
|
|
|
explicit WebGLRenderbuffer(WebGLContext* context);
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
void Delete();
|
|
|
|
|
2013-10-11 06:16:43 -07:00
|
|
|
bool HasUninitializedImageData() const { return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData; }
|
|
|
|
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; }
|
|
|
|
void SetInternalFormat(GLenum aInternalFormat) { mInternalFormat = aInternalFormat; }
|
2012-12-03 10:27:25 -08:00
|
|
|
|
2013-09-04 05:14:43 -07:00
|
|
|
GLenum InternalFormatForGL() const { return mInternalFormatForGL; }
|
|
|
|
void SetInternalFormatForGL(GLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; }
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
int64_t MemoryUsage() const;
|
|
|
|
|
|
|
|
WebGLContext *GetParentObject() const {
|
|
|
|
return Context();
|
|
|
|
}
|
|
|
|
|
2013-10-01 17:31:09 -07:00
|
|
|
void BindRenderbuffer() const;
|
|
|
|
void RenderbufferStorage(GLenum internalFormat, GLsizei width, GLsizei height) const;
|
|
|
|
void FramebufferRenderbuffer(GLenum attachment) const;
|
|
|
|
// Only handles a subset of `pname`s.
|
|
|
|
GLint GetRenderbufferParameter(GLenum target, GLenum pname) const;
|
|
|
|
|
2014-04-08 15:27:18 -07: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;
|
|
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|