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/. */
|
|
|
|
|
|
|
|
#ifndef WEBGLRENDERBUFFER_H_
|
|
|
|
#define WEBGLRENDERBUFFER_H_
|
|
|
|
|
2014-05-07 07:11:18 +04:00
|
|
|
#include "WebGLBindableName.h"
|
2012-12-03 22:27:25 +04:00
|
|
|
#include "WebGLObjectModel.h"
|
2014-03-04 11:14:35 +04:00
|
|
|
#include "WebGLFramebufferAttachable.h"
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class WebGLRenderbuffer MOZ_FINAL
|
2013-08-29 19:39:17 +04:00
|
|
|
: public nsWrapperCache
|
2014-09-25 19:21:33 +04:00
|
|
|
, public WebGLBindableName<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-09-02 04:49:25 +04:00
|
|
|
explicit WebGLRenderbuffer(WebGLContext* context);
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
void Delete();
|
|
|
|
|
2013-10-11 17:16:43 +04: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 22:27:25 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum InternalFormat() const { return mInternalFormat; }
|
|
|
|
void SetInternalFormat(GLenum aInternalFormat) { mInternalFormat = aInternalFormat; }
|
2012-12-03 22:27:25 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum InternalFormatForGL() const { return mInternalFormatForGL; }
|
|
|
|
void SetInternalFormatForGL(GLenum aInternalFormatForGL) { mInternalFormatForGL = aInternalFormatForGL; }
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
int64_t MemoryUsage() const;
|
|
|
|
|
|
|
|
WebGLContext *GetParentObject() const {
|
|
|
|
return Context();
|
|
|
|
}
|
|
|
|
|
2013-10-02 04:31:09 +04:00
|
|
|
void BindRenderbuffer() const;
|
|
|
|
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-04-09 02:27:18 +04: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;
|
|
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|