2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-12-03 22:27:25 +04:00
|
|
|
/* 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
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
#include "CacheInvalidator.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "WebGLObjectModel.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "WebGLStrongTypes.h"
|
2018-10-17 07:18:15 +03:00
|
|
|
#include "WebGLTexture.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 : public nsWrapperCache,
|
2012-12-03 22:27:25 +04:00
|
|
|
public WebGLRefCountedObject<WebGLRenderbuffer>,
|
|
|
|
public LinkedListElement<WebGLRenderbuffer>,
|
|
|
|
public WebGLRectangleObject,
|
2018-10-17 07:18:15 +03:00
|
|
|
public CacheInvalidator {
|
2016-02-13 06:31:58 +03:00
|
|
|
friend class WebGLFramebuffer;
|
|
|
|
friend class WebGLFBAttachPoint;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-02-13 06:31:58 +03:00
|
|
|
public:
|
|
|
|
const GLuint mPrimaryRB;
|
2018-10-17 09:54:28 +03:00
|
|
|
bool mHasBeenBound = false;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-02-13 06:31:58 +03:00
|
|
|
protected:
|
|
|
|
const bool mEmulatePackedDepthStencil;
|
|
|
|
GLuint mSecondaryRB;
|
2018-10-17 07:18:15 +03:00
|
|
|
webgl::ImageInfo mImageInfo;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
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)
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
explicit WebGLRenderbuffer(WebGLContext* webgl);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-12-03 22:27:25 +04:00
|
|
|
void Delete();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
const auto& ImageInfo() const { return mImageInfo; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext* GetParentObject() const { return mContext; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
void RenderbufferStorage(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;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx,
|
|
|
|
JS::Handle<JSObject*> givenProto) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
auto MemoryUsage() const { return mImageInfo.MemoryUsage(); }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-12-03 22:27:25 +04:00
|
|
|
protected:
|
2014-06-26 17:30:49 +04:00
|
|
|
~WebGLRenderbuffer() { DeleteOnce(); }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-10-17 07:18:15 +03:00
|
|
|
void DoFramebufferRenderbuffer(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_
|