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"
|
2015-07-15 03:37:28 +03:00
|
|
|
|
2014-03-04 11:14:35 +04:00
|
|
|
#include "WebGLFramebufferAttachable.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLObjectModel.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "WebGLStrongTypes.h"
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2015-11-25 07:15:29 +03:00
|
|
|
namespace webgl {
|
|
|
|
struct FormatUsageInfo;
|
|
|
|
}
|
2012-12-03 22:27:25 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class WebGLRenderbuffer final
|
2013-08-29 19:39:17 +04:00
|
|
|
: public nsWrapperCache
|
2012-12-03 22:27:25 +04:00
|
|
|
, public WebGLRefCountedObject<WebGLRenderbuffer>
|
|
|
|
, public LinkedListElement<WebGLRenderbuffer>
|
|
|
|
, public WebGLRectangleObject
|
2014-03-04 11:14:35 +04:00
|
|
|
, public WebGLFramebufferAttachable
|
2012-12-03 22:27:25 +04:00
|
|
|
{
|
2016-02-13 06:31:58 +03:00
|
|
|
friend class WebGLContext;
|
|
|
|
friend class WebGLFramebuffer;
|
|
|
|
friend class WebGLFBAttachPoint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const GLuint mPrimaryRB;
|
|
|
|
protected:
|
|
|
|
const bool mEmulatePackedDepthStencil;
|
|
|
|
GLuint mSecondaryRB;
|
|
|
|
const webgl::FormatUsageInfo* mFormat;
|
|
|
|
GLsizei mSamples;
|
|
|
|
|
|
|
|
WebGLImageDataStatus mImageDataStatus;
|
|
|
|
|
|
|
|
bool mHasBeenBound;
|
|
|
|
|
2012-12-03 22:27:25 +04:00
|
|
|
public:
|
2016-02-13 06:31:58 +03:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer)
|
|
|
|
|
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 {
|
2015-11-25 07:15:29 +03:00
|
|
|
MOZ_ASSERT(mImageDataStatus != WebGLImageDataStatus::NoImageData);
|
2014-11-14 07:03:50 +03:00
|
|
|
return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData;
|
|
|
|
}
|
2015-11-25 07:15:29 +03:00
|
|
|
|
|
|
|
bool IsDefined() const {
|
|
|
|
if (!mFormat) {
|
|
|
|
MOZ_ASSERT(!mWidth && !mHeight);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-10-11 17:16:43 +04:00
|
|
|
}
|
2012-12-03 22:27:25 +04:00
|
|
|
|
2015-02-19 03:57:05 +03:00
|
|
|
GLsizei Samples() const { return mSamples; }
|
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
const webgl::FormatUsageInfo* Format() const { return mFormat; }
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
int64_t MemoryUsage() const;
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext* GetParentObject() const {
|
2015-11-25 07:15:29 +03:00
|
|
|
return mContext;
|
2012-12-03 22:27:25 +04:00
|
|
|
}
|
|
|
|
|
2018-08-09 04:58:04 +03:00
|
|
|
void RenderbufferStorage(const char* funcName, uint32_t samples,
|
|
|
|
GLenum internalFormat, uint32_t width, uint32_t height);
|
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
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
2012-12-03 22:27:25 +04:00
|
|
|
|
|
|
|
protected:
|
2014-06-26 17:30:49 +04:00
|
|
|
~WebGLRenderbuffer() {
|
|
|
|
DeleteOnce();
|
|
|
|
}
|
|
|
|
|
2016-07-18 10:15:54 +03:00
|
|
|
void DoFramebufferRenderbuffer(FBTarget target, GLenum attachment) const;
|
2016-02-13 06:31:58 +03:00
|
|
|
GLenum DoRenderbufferStorage(uint32_t samples, const webgl::FormatUsageInfo* format,
|
|
|
|
uint32_t width, uint32_t height);
|
2012-12-03 22:27:25 +04:00
|
|
|
};
|
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_
|