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"
|
2015-07-14 17:37:28 -07:00
|
|
|
|
2014-03-03 23:14:35 -08:00
|
|
|
#include "WebGLFramebufferAttachable.h"
|
2014-11-13 20:03:50 -08:00
|
|
|
#include "WebGLObjectModel.h"
|
2015-07-14 17:37:28 -07:00
|
|
|
#include "WebGLStrongTypes.h"
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
2015-11-24 20:15:29 -08:00
|
|
|
namespace webgl {
|
|
|
|
struct FormatUsageInfo;
|
|
|
|
}
|
2012-12-03 10:27:25 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class WebGLRenderbuffer final
|
2013-08-29 08:39:17 -07:00
|
|
|
: public nsWrapperCache
|
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 {
|
2015-11-24 20:15:29 -08:00
|
|
|
MOZ_ASSERT(mImageDataStatus != WebGLImageDataStatus::NoImageData);
|
2014-11-13 20:03:50 -08:00
|
|
|
return mImageDataStatus == WebGLImageDataStatus::UninitializedImageData;
|
|
|
|
}
|
2015-11-24 20:15:29 -08:00
|
|
|
|
|
|
|
bool IsDefined() const {
|
|
|
|
if (!mFormat) {
|
|
|
|
MOZ_ASSERT(!mWidth && !mHeight);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2013-10-11 06:16:43 -07:00
|
|
|
}
|
2012-12-03 10:27:25 -08:00
|
|
|
|
2015-02-18 16:57:05 -08:00
|
|
|
GLsizei Samples() const { return mSamples; }
|
|
|
|
|
2015-05-20 16:53:02 -07:00
|
|
|
GLuint PrimaryGLName() const { return mPrimaryRB; }
|
|
|
|
|
2015-11-24 20:15:29 -08:00
|
|
|
const webgl::FormatUsageInfo* Format() const { return mFormat; }
|
2012-12-03 10:27:25 -08:00
|
|
|
|
|
|
|
int64_t MemoryUsage() const;
|
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
WebGLContext* GetParentObject() const {
|
2015-11-24 20:15:29 -08:00
|
|
|
return mContext;
|
2012-12-03 10:27:25 -08:00
|
|
|
}
|
|
|
|
|
2013-10-01 17:31:09 -07:00
|
|
|
void BindRenderbuffer() const;
|
2015-11-24 20:15:29 -08:00
|
|
|
void RenderbufferStorage(GLsizei samples, const webgl::FormatUsageInfo* format,
|
|
|
|
GLsizei width, GLsizei height);
|
|
|
|
void FramebufferRenderbuffer(GLenum 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
|
|
|
|
2015-07-14 17:37:28 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) 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;
|
2015-11-24 20:15:29 -08:00
|
|
|
const webgl::FormatUsageInfo* mFormat;
|
2013-10-11 06:16:43 -07:00
|
|
|
WebGLImageDataStatus mImageDataStatus;
|
2015-02-18 16:57:05 -08:00
|
|
|
GLsizei mSamples;
|
2015-11-24 20:15:29 -08:00
|
|
|
bool mIsUsingSecondary;
|
2015-05-20 16:53:02 -07:00
|
|
|
#ifdef ANDROID
|
|
|
|
// Bug 1140459: Some drivers (including our test slaves!) don't
|
|
|
|
// give reasonable answers for IsRenderbuffer, maybe others.
|
|
|
|
// This shows up on Android 2.3 emulator.
|
|
|
|
//
|
|
|
|
// So we track the `is a Renderbuffer` state ourselves.
|
|
|
|
bool mIsRB;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
friend class WebGLContext;
|
2012-12-03 10:27:25 -08:00
|
|
|
friend class WebGLFramebuffer;
|
2015-11-24 20:15:29 -08:00
|
|
|
friend class WebGLFBAttachPoint;
|
2012-12-03 10:27:25 -08:00
|
|
|
};
|
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_
|