2012-03-16 13:50:00 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +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/. */
|
2009-09-03 04:47:49 +04:00
|
|
|
|
|
|
|
#ifndef WEBGLCONTEXT_H_
|
|
|
|
#define WEBGLCONTEXT_H_
|
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "GLDefs.h"
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-01-06 19:49:03 +04:00
|
|
|
#include "mozilla/CheckedInt.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "mozilla/dom/HTMLCanvasElement.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2014-01-06 19:49:03 +04:00
|
|
|
#include "mozilla/EnumeratedArray.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-01-06 19:49:03 +04:00
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
#include "mozilla/UniquePtr.h"
|
2014-08-22 20:55:00 +04:00
|
|
|
#include "mozilla/WeakPtr.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "nsCycleCollectionNoteChild.h"
|
|
|
|
#include "nsICanvasRenderingContextInternal.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2014-01-06 19:49:03 +04:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include "ForceDiscreteGPUHelperCGL.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Local
|
2014-10-27 02:40:37 +03:00
|
|
|
#include "WebGLContextUnchecked.h"
|
2015-07-11 02:34:45 +03:00
|
|
|
#include "WebGLFormats.h"
|
2012-11-21 01:38:20 +04:00
|
|
|
#include "WebGLObjectModel.h"
|
2014-09-19 03:14:22 +04:00
|
|
|
#include "WebGLStrongTypes.h"
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
// Generated
|
|
|
|
#include "nsIDOMEventListener.h"
|
2010-11-17 07:33:04 +03:00
|
|
|
#include "nsIDOMWebGLRenderingContext.h"
|
2012-04-22 00:48:22 +04:00
|
|
|
#include "nsIObserver.h"
|
2010-01-23 05:29:49 +03:00
|
|
|
|
2013-08-22 10:34:54 +04:00
|
|
|
|
|
|
|
class nsIDocShell;
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-01-23 07:59:33 +04:00
|
|
|
/*
|
2011-10-13 16:09:22 +04:00
|
|
|
* Minimum value constants defined in 6.2 State Tables of OpenGL ES - 2.0.25
|
|
|
|
* https://bugzilla.mozilla.org/show_bug.cgi?id=686732
|
2014-01-23 07:59:33 +04:00
|
|
|
*
|
2011-10-13 16:09:22 +04:00
|
|
|
* Exceptions: some of the following values are set to higher values than in the spec because
|
|
|
|
* the values in the spec are ridiculously low. They are explicitly marked below
|
2014-06-24 04:56:21 +04:00
|
|
|
*/
|
2011-10-13 16:09:22 +04:00
|
|
|
#define MINVALUE_GL_MAX_TEXTURE_SIZE 1024 // Different from the spec, which sets it to 64 on page 162
|
|
|
|
#define MINVALUE_GL_MAX_CUBE_MAP_TEXTURE_SIZE 512 // Different from the spec, which sets it to 16 on page 162
|
|
|
|
#define MINVALUE_GL_MAX_VERTEX_ATTRIBS 8 // Page 164
|
|
|
|
#define MINVALUE_GL_MAX_FRAGMENT_UNIFORM_VECTORS 16 // Page 164
|
|
|
|
#define MINVALUE_GL_MAX_VERTEX_UNIFORM_VECTORS 128 // Page 164
|
|
|
|
#define MINVALUE_GL_MAX_VARYING_VECTORS 8 // Page 164
|
|
|
|
#define MINVALUE_GL_MAX_TEXTURE_IMAGE_UNITS 8 // Page 164
|
|
|
|
#define MINVALUE_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0 // Page 164
|
|
|
|
#define MINVALUE_GL_MAX_RENDERBUFFER_SIZE 1024 // Different from the spec, which sets it to 1 on page 164
|
|
|
|
#define MINVALUE_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 8 // Page 164
|
|
|
|
|
2015-06-10 08:13:02 +03:00
|
|
|
/*
|
|
|
|
* WebGL-only GLenums
|
|
|
|
*/
|
|
|
|
#define LOCAL_GL_BROWSER_DEFAULT_WEBGL 0x9244
|
|
|
|
#define LOCAL_GL_CONTEXT_LOST_WEBGL 0x9242
|
|
|
|
#define LOCAL_GL_MAX_CLIENT_WAIT_TIMEOUT_WEBGL 0x9247
|
|
|
|
#define LOCAL_GL_UNPACK_COLORSPACE_CONVERSION_WEBGL 0x9243
|
|
|
|
#define LOCAL_GL_UNPACK_FLIP_Y_WEBGL 0x9240
|
|
|
|
#define LOCAL_GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL 0x9241
|
|
|
|
|
2009-09-03 04:47:49 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
class WebGLActiveInfo;
|
2014-11-14 07:03:50 +03:00
|
|
|
class WebGLContextLossHandler;
|
2013-06-11 00:00:35 +04:00
|
|
|
class WebGLBuffer;
|
2014-11-14 07:03:50 +03:00
|
|
|
class WebGLExtensionBase;
|
|
|
|
class WebGLFramebuffer;
|
|
|
|
class WebGLObserver;
|
2013-06-11 00:00:35 +04:00
|
|
|
class WebGLProgram;
|
2013-08-07 01:23:46 +04:00
|
|
|
class WebGLQuery;
|
2013-06-11 00:00:35 +04:00
|
|
|
class WebGLRenderbuffer;
|
2014-10-27 02:40:37 +03:00
|
|
|
class WebGLSampler;
|
2014-11-14 07:03:50 +03:00
|
|
|
class WebGLShader;
|
2013-06-11 00:00:35 +04:00
|
|
|
class WebGLShaderPrecisionFormat;
|
|
|
|
class WebGLTexture;
|
2014-11-26 05:00:06 +03:00
|
|
|
class WebGLTransformFeedback;
|
2014-11-14 07:03:50 +03:00
|
|
|
class WebGLUniformLocation;
|
2013-06-28 01:07:21 +04:00
|
|
|
class WebGLVertexArray;
|
2014-10-27 02:40:37 +03:00
|
|
|
|
2012-10-22 21:08:52 +04:00
|
|
|
namespace dom {
|
2014-07-08 22:52:00 +04:00
|
|
|
class Element;
|
2014-11-14 07:03:50 +03:00
|
|
|
class ImageData;
|
2012-10-22 21:08:52 +04:00
|
|
|
struct WebGLContextAttributes;
|
2013-09-09 13:43:52 +04:00
|
|
|
template<typename> struct Nullable;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2012-10-22 21:08:52 +04:00
|
|
|
|
2013-10-02 01:01:19 +04:00
|
|
|
namespace gfx {
|
|
|
|
class SourceSurface;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
2013-10-02 01:01:19 +04:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
namespace webgl {
|
|
|
|
struct LinkedProgramInfo;
|
2015-07-15 03:37:28 +03:00
|
|
|
class ShaderValidator;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace webgl
|
2015-01-16 02:40:39 +03:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
WebGLTexelFormat GetWebGLTexelFormat(TexInternalFormat format);
|
2010-10-16 01:50:15 +04:00
|
|
|
|
2014-05-22 06:03:09 +04:00
|
|
|
void AssertUintParamCorrect(gl::GLContext* gl, GLenum pname, GLuint shadow);
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
struct WebGLContextOptions
|
|
|
|
{
|
2010-11-17 07:33:03 +03:00
|
|
|
// these are defaults
|
2012-08-01 22:58:44 +04:00
|
|
|
WebGLContextOptions();
|
2010-11-17 07:33:03 +03:00
|
|
|
|
|
|
|
bool operator==(const WebGLContextOptions& other) const {
|
|
|
|
return
|
|
|
|
alpha == other.alpha &&
|
|
|
|
depth == other.depth &&
|
|
|
|
stencil == other.stencil &&
|
|
|
|
premultipliedAlpha == other.premultipliedAlpha &&
|
2011-05-20 23:53:53 +04:00
|
|
|
antialias == other.antialias &&
|
|
|
|
preserveDrawingBuffer == other.preserveDrawingBuffer;
|
2010-11-17 07:33:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const WebGLContextOptions& other) const {
|
2011-05-20 23:53:53 +04:00
|
|
|
return !operator==(other);
|
2010-11-17 07:33:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool alpha;
|
|
|
|
bool depth;
|
|
|
|
bool stencil;
|
|
|
|
bool premultipliedAlpha;
|
2011-05-20 23:53:53 +04:00
|
|
|
bool antialias;
|
|
|
|
bool preserveDrawingBuffer;
|
2015-05-21 18:51:49 +03:00
|
|
|
bool failIfMajorPerformanceCaveat;
|
2010-11-17 07:33:03 +03:00
|
|
|
};
|
|
|
|
|
2014-09-03 23:17:18 +04:00
|
|
|
// From WebGLContextUtils
|
2014-09-19 03:14:22 +04:00
|
|
|
TexTarget TexImageTargetToTexTarget(TexImageTarget texImageTarget);
|
2014-05-22 06:03:09 +04:00
|
|
|
|
2014-10-27 02:40:37 +03:00
|
|
|
class WebGLIntOrFloat {
|
|
|
|
enum {
|
|
|
|
Int,
|
2014-06-24 04:56:21 +04:00
|
|
|
Float,
|
|
|
|
Uint
|
2014-10-27 02:40:37 +03:00
|
|
|
} mType;
|
|
|
|
union {
|
|
|
|
GLint i;
|
|
|
|
GLfloat f;
|
2014-06-24 04:56:21 +04:00
|
|
|
GLuint u;
|
2014-10-27 02:40:37 +03:00
|
|
|
} mValue;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit WebGLIntOrFloat(GLint i) : mType(Int) { mValue.i = i; }
|
|
|
|
explicit WebGLIntOrFloat(GLfloat f) : mType(Float) { mValue.f = f; }
|
|
|
|
|
|
|
|
GLint AsInt() const { return (mType == Int) ? mValue.i : NS_lroundf(mValue.f); }
|
|
|
|
GLfloat AsFloat() const { return (mType == Float) ? mValue.f : GLfloat(mValue.i); }
|
|
|
|
};
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
class WebGLContext
|
|
|
|
: public nsIDOMWebGLRenderingContext
|
|
|
|
, public nsICanvasRenderingContextInternal
|
|
|
|
, public nsSupportsWeakReference
|
|
|
|
, public WebGLContextUnchecked
|
|
|
|
, public WebGLRectangleObject
|
|
|
|
, public nsWrapperCache
|
|
|
|
, public SupportsWeakPtr<WebGLContext>
|
2009-09-03 04:47:49 +04:00
|
|
|
{
|
2014-06-24 04:56:21 +04:00
|
|
|
friend class WebGL2Context;
|
2012-09-25 16:49:28 +04:00
|
|
|
friend class WebGLContextUserData;
|
2012-09-25 16:49:28 +04:00
|
|
|
friend class WebGLExtensionCompressedTextureATC;
|
2014-03-11 02:42:58 +04:00
|
|
|
friend class WebGLExtensionCompressedTextureETC1;
|
2012-09-25 16:49:28 +04:00
|
|
|
friend class WebGLExtensionCompressedTexturePVRTC;
|
2014-03-11 02:42:58 +04:00
|
|
|
friend class WebGLExtensionCompressedTextureS3TC;
|
2012-08-14 05:17:55 +04:00
|
|
|
friend class WebGLExtensionDepthTexture;
|
2015-05-27 14:12:00 +03:00
|
|
|
friend class WebGLExtensionDisjointTimerQuery;
|
2013-06-22 03:44:17 +04:00
|
|
|
friend class WebGLExtensionDrawBuffers;
|
2014-03-11 02:42:58 +04:00
|
|
|
friend class WebGLExtensionLoseContext;
|
2013-06-28 01:07:21 +04:00
|
|
|
friend class WebGLExtensionVertexArray;
|
2014-03-11 02:42:58 +04:00
|
|
|
friend class WebGLMemoryTracker;
|
2014-11-14 07:03:50 +03:00
|
|
|
friend class WebGLObserver;
|
2011-07-08 04:01:12 +04:00
|
|
|
|
2012-09-20 11:55:36 +04:00
|
|
|
enum {
|
|
|
|
UNPACK_FLIP_Y_WEBGL = 0x9240,
|
|
|
|
UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241,
|
|
|
|
CONTEXT_LOST_WEBGL = 0x9242,
|
|
|
|
UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243,
|
2012-10-17 23:11:51 +04:00
|
|
|
BROWSER_DEFAULT_WEBGL = 0x9244,
|
|
|
|
UNMASKED_VENDOR_WEBGL = 0x9245,
|
|
|
|
UNMASKED_RENDERER_WEBGL = 0x9246
|
2012-09-20 11:55:36 +04:00
|
|
|
};
|
|
|
|
|
2009-09-03 04:47:49 +04:00
|
|
|
public:
|
|
|
|
WebGLContext();
|
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
protected:
|
|
|
|
virtual ~WebGLContext();
|
|
|
|
|
|
|
|
public:
|
2015-04-24 19:43:01 +03:00
|
|
|
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLContext)
|
2014-08-22 20:55:00 +04:00
|
|
|
|
2010-06-16 01:38:05 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
2012-05-04 20:36:40 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WebGLContext,
|
|
|
|
nsIDOMWebGLRenderingContext)
|
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override = 0;
|
2012-05-31 22:16:48 +04:00
|
|
|
|
2010-11-17 07:33:04 +03:00
|
|
|
NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT
|
2009-09-03 04:47:49 +04:00
|
|
|
|
|
|
|
// nsICanvasRenderingContextInternal
|
2013-10-01 01:02:40 +04:00
|
|
|
#ifdef DEBUG
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual int32_t GetWidth() const override;
|
|
|
|
virtual int32_t GetHeight() const override;
|
2013-10-01 01:02:40 +04:00
|
|
|
#endif
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetDimensions(int32_t width, int32_t height) override;
|
2014-11-14 07:03:50 +03:00
|
|
|
NS_IMETHOD InitializeWithSurface(nsIDocShell*, gfxASurface*, int32_t,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t) override
|
2014-11-14 07:03:50 +03:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Reset() override {
|
2014-11-14 07:03:50 +03:00
|
|
|
/* (InitializeWithSurface) */
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void GetImageBuffer(uint8_t** out_imageBuffer,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t* out_format) override;
|
2014-11-14 07:03:50 +03:00
|
|
|
NS_IMETHOD GetInputStream(const char* mimeType,
|
|
|
|
const char16_t* encoderOptions,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIInputStream** out_stream) override;
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<mozilla::gfx::SourceSurface>
|
2015-03-21 19:28:04 +03:00
|
|
|
GetSurfaceSnapshot(bool* out_premultAlpha) override;
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetIsOpaque(bool) override { return NS_OK; };
|
|
|
|
bool GetIsOpaque() override { return false; }
|
2014-11-14 07:03:50 +03:00
|
|
|
NS_IMETHOD SetContextOptions(JSContext* cx,
|
2015-03-21 19:28:04 +03:00
|
|
|
JS::Handle<JS::Value> options) override;
|
2010-11-17 07:33:03 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetIsIPC(bool) override {
|
2014-11-14 07:03:50 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2014-09-10 05:40:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An abstract base class to be implemented by callers wanting to be notified
|
|
|
|
* that a refresh has occurred. Callers must ensure an observer is removed
|
|
|
|
* before it is destroyed.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DidRefresh() override;
|
2014-09-10 05:40:51 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Redraw(const gfxRect&) override {
|
2014-11-14 07:03:50 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
void SynthesizeGLError(GLenum err);
|
2014-11-14 07:03:50 +03:00
|
|
|
void SynthesizeGLError(GLenum err, const char* fmt, ...);
|
2010-05-15 17:55:45 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void ErrorInvalidEnum(const char* fmt = 0, ...);
|
|
|
|
void ErrorInvalidOperation(const char* fmt = 0, ...);
|
|
|
|
void ErrorInvalidValue(const char* fmt = 0, ...);
|
|
|
|
void ErrorInvalidFramebufferOperation(const char* fmt = 0, ...);
|
2015-02-19 03:57:05 +03:00
|
|
|
void ErrorInvalidEnumInfo(const char* info, GLenum enumValue);
|
|
|
|
void ErrorInvalidEnumInfo(const char* info, const char* funcName,
|
|
|
|
GLenum enumValue);
|
2014-11-14 07:03:50 +03:00
|
|
|
void ErrorOutOfMemory(const char* fmt = 0, ...);
|
2012-01-25 01:12:31 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
const char* ErrorName(GLenum error);
|
2014-06-03 00:30:00 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return displayable name for GLenum.
|
|
|
|
* This version is like gl::GLenumToStr but with out the GL_ prefix to
|
|
|
|
* keep consistency with how errors are reported from WebGL.
|
|
|
|
*/
|
2014-10-27 02:35:02 +03:00
|
|
|
// Returns nullptr if glenum is unknown.
|
|
|
|
static const char* EnumName(GLenum glenum);
|
|
|
|
// Returns hex formatted version of glenum if glenum is unknown.
|
|
|
|
static void EnumName(GLenum glenum, nsACString* out_name);
|
2014-06-03 00:30:00 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void DummyFramebufferOperation(const char* funcName);
|
2012-01-25 01:12:31 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLTexture* ActiveBoundTextureForTarget(const TexTarget texTarget) const {
|
2014-10-14 03:42:20 +04:00
|
|
|
switch (texTarget.get()) {
|
2014-11-14 07:03:50 +03:00
|
|
|
case LOCAL_GL_TEXTURE_2D:
|
|
|
|
return mBound2DTextures[mActiveTexture];
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP:
|
|
|
|
return mBoundCubeMapTextures[mActiveTexture];
|
|
|
|
case LOCAL_GL_TEXTURE_3D:
|
|
|
|
return mBound3DTextures[mActiveTexture];
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("bad target");
|
2014-10-14 03:42:20 +04:00
|
|
|
}
|
2014-09-03 23:17:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Use this function when you have the texture image target, for example:
|
|
|
|
* GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP_[POSITIVE|NEGATIVE]_[X|Y|Z], and
|
|
|
|
* not the actual texture binding target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
|
|
|
|
*/
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLTexture*
|
|
|
|
ActiveBoundTextureForTexImageTarget(const TexImageTarget texImgTarget) const
|
|
|
|
{
|
2014-09-19 03:14:22 +04:00
|
|
|
const TexTarget texTarget = TexImageTargetToTexTarget(texImgTarget);
|
2014-11-14 07:03:50 +03:00
|
|
|
return ActiveBoundTextureForTarget(texTarget);
|
2010-08-24 01:03:35 +04:00
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
already_AddRefed<CanvasLayer>
|
|
|
|
GetCanvasLayer(nsDisplayListBuilder* builder, CanvasLayer* oldLayer,
|
2015-03-21 19:28:04 +03:00
|
|
|
LayerManager* manager) override;
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
// Note that 'clean' here refers to its invalidation state, not the
|
|
|
|
// contents of the buffer.
|
2015-03-21 19:28:04 +03:00
|
|
|
void MarkContextClean() override { mInvalidated = false; }
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2013-09-04 16:14:50 +04:00
|
|
|
gl::GLContext* GL() const { return gl; }
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2013-09-04 16:14:50 +04:00
|
|
|
bool IsPremultAlpha() const { return mOptions.premultipliedAlpha; }
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2015-05-13 09:04:41 +03:00
|
|
|
bool IsPreservingDrawingBuffer() const { return mOptions.preserveDrawingBuffer; }
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
bool PresentScreenBuffer();
|
|
|
|
|
2010-06-04 23:03:37 +04:00
|
|
|
// a number that increments every time we have an event that causes
|
|
|
|
// all context resources to be lost.
|
2012-05-23 20:07:01 +04:00
|
|
|
uint32_t Generation() { return mGeneration.value(); }
|
2010-08-24 01:03:53 +04:00
|
|
|
|
2014-01-23 07:59:34 +04:00
|
|
|
// Returns null if the current bound FB is not likely complete.
|
2015-01-13 02:05:21 +03:00
|
|
|
const WebGLRectangleObject* CurValidDrawFBRectObject() const;
|
|
|
|
const WebGLRectangleObject* CurValidReadFBRectObject() const;
|
2012-01-25 01:12:31 +04:00
|
|
|
|
2014-05-01 01:30:23 +04:00
|
|
|
static const size_t kMaxColorAttachments = 16;
|
2013-06-22 03:44:17 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
// This is similar to GLContext::ClearSafely, but tries to minimize the
|
|
|
|
// amount of work it does.
|
|
|
|
// It only clears the buffers we specify, and can reset its state without
|
|
|
|
// first having to query anything, as WebGL knows its state at all times.
|
2015-05-01 03:30:26 +03:00
|
|
|
void ForceClearFramebufferWithDefaultValues(bool fakeNoAlpha, GLbitfield mask,
|
2014-11-14 07:03:50 +03:00
|
|
|
const bool colorAttachmentsMask[kMaxColorAttachments]);
|
2011-05-20 23:53:53 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
// Calls ForceClearFramebufferWithDefaultValues() for the Context's 'screen'.
|
|
|
|
void ClearScreen();
|
2014-04-18 00:15:41 +04:00
|
|
|
void ClearBackbufferIfNeeded();
|
2011-05-20 23:53:53 +04:00
|
|
|
|
2013-09-04 16:14:50 +04:00
|
|
|
bool MinCapabilityMode() const { return mMinCapability; }
|
2012-10-23 20:21:23 +04:00
|
|
|
|
2014-08-22 20:55:00 +04:00
|
|
|
void RunContextLossTimer();
|
2014-06-03 01:40:15 +04:00
|
|
|
void UpdateContextLossStatus();
|
|
|
|
void EnqueueUpdateContextLossStatus();
|
2011-10-27 00:00:44 +04:00
|
|
|
|
2014-06-03 01:40:15 +04:00
|
|
|
bool TryToRestoreContext();
|
|
|
|
|
2014-05-22 06:03:09 +04:00
|
|
|
void AssertCachedBindings();
|
|
|
|
void AssertCachedState();
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
// WebIDL WebGLRenderingContext API
|
2013-09-04 16:14:50 +04:00
|
|
|
dom::HTMLCanvasElement* GetCanvas() const { return mCanvasElement; }
|
|
|
|
GLsizei DrawingBufferWidth() const { return IsContextLost() ? 0 : mWidth; }
|
2014-11-14 07:03:50 +03:00
|
|
|
GLsizei DrawingBufferHeight() const {
|
|
|
|
return IsContextLost() ? 0 : mHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetContextAttributes(dom::Nullable<dom::WebGLContextAttributes>& retval);
|
2013-09-04 16:14:44 +04:00
|
|
|
|
|
|
|
bool IsContextLost() const { return mContextStatus != ContextNotLost; }
|
2014-11-14 07:03:50 +03:00
|
|
|
void GetSupportedExtensions(JSContext* cx,
|
|
|
|
dom::Nullable< nsTArray<nsString> >& retval);
|
|
|
|
void GetExtension(JSContext* cx, const nsAString& name,
|
|
|
|
JS::MutableHandle<JSObject*> retval, ErrorResult& rv);
|
|
|
|
void AttachShader(WebGLProgram* prog, WebGLShader* shader);
|
|
|
|
void BindAttribLocation(WebGLProgram* prog, GLuint location,
|
2012-05-04 20:38:44 +04:00
|
|
|
const nsAString& name);
|
2014-11-14 07:03:50 +03:00
|
|
|
void BindFramebuffer(GLenum target, WebGLFramebuffer* fb);
|
|
|
|
void BindRenderbuffer(GLenum target, WebGLRenderbuffer* fb);
|
|
|
|
void BindVertexArray(WebGLVertexArray* vao);
|
2013-09-04 16:14:50 +04:00
|
|
|
void BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a);
|
2013-09-04 16:14:43 +04:00
|
|
|
void BlendEquation(GLenum mode);
|
|
|
|
void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
|
|
|
|
void BlendFunc(GLenum sfactor, GLenum dfactor);
|
|
|
|
void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
|
|
|
|
GLenum srcAlpha, GLenum dstAlpha);
|
|
|
|
GLenum CheckFramebufferStatus(GLenum target);
|
|
|
|
void Clear(GLbitfield mask);
|
|
|
|
void ClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a);
|
|
|
|
void ClearDepth(GLclampf v);
|
|
|
|
void ClearStencil(GLint v);
|
2012-05-04 20:38:44 +04:00
|
|
|
void ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboolean a);
|
2014-11-03 08:35:04 +03:00
|
|
|
void CompileShader(WebGLShader* shader);
|
2015-01-16 02:40:39 +03:00
|
|
|
void CompileShaderANGLE(WebGLShader* shader);
|
|
|
|
void CompileShaderBypass(WebGLShader* shader, const nsCString& shaderSource);
|
2012-05-04 20:38:44 +04:00
|
|
|
already_AddRefed<WebGLFramebuffer> CreateFramebuffer();
|
|
|
|
already_AddRefed<WebGLProgram> CreateProgram();
|
|
|
|
already_AddRefed<WebGLRenderbuffer> CreateRenderbuffer();
|
2013-09-04 16:14:43 +04:00
|
|
|
already_AddRefed<WebGLShader> CreateShader(GLenum type);
|
2013-06-28 01:07:21 +04:00
|
|
|
already_AddRefed<WebGLVertexArray> CreateVertexArray();
|
2013-09-04 16:14:43 +04:00
|
|
|
void CullFace(GLenum face);
|
2014-11-14 07:03:50 +03:00
|
|
|
void DeleteFramebuffer(WebGLFramebuffer* fb);
|
|
|
|
void DeleteProgram(WebGLProgram* prog);
|
|
|
|
void DeleteRenderbuffer(WebGLRenderbuffer* rb);
|
|
|
|
void DeleteShader(WebGLShader* shader);
|
|
|
|
void DeleteVertexArray(WebGLVertexArray* vao);
|
2013-09-04 16:14:43 +04:00
|
|
|
void DepthFunc(GLenum func);
|
2012-05-04 20:38:44 +04:00
|
|
|
void DepthMask(WebGLboolean b);
|
2013-09-04 16:14:43 +04:00
|
|
|
void DepthRange(GLclampf zNear, GLclampf zFar);
|
2014-11-14 07:03:50 +03:00
|
|
|
void DetachShader(WebGLProgram* prog, WebGLShader* shader);
|
2013-07-17 20:13:38 +04:00
|
|
|
void DrawBuffers(const dom::Sequence<GLenum>& buffers);
|
2013-09-04 16:14:50 +04:00
|
|
|
void Flush();
|
|
|
|
void Finish();
|
2013-09-04 16:14:43 +04:00
|
|
|
void FramebufferRenderbuffer(GLenum target, GLenum attachment,
|
2014-11-14 07:03:50 +03:00
|
|
|
GLenum rbTarget, WebGLRenderbuffer* rb);
|
2013-09-04 16:14:43 +04:00
|
|
|
void FramebufferTexture2D(GLenum target, GLenum attachment,
|
2014-11-14 07:03:50 +03:00
|
|
|
GLenum texImageTarget, WebGLTexture* tex,
|
2013-09-04 16:14:43 +04:00
|
|
|
GLint level);
|
2014-09-25 19:21:33 +04:00
|
|
|
|
|
|
|
// Framebuffer validation
|
2015-01-13 02:05:21 +03:00
|
|
|
bool ValidateFramebufferAttachment(const WebGLFramebuffer* fb,
|
|
|
|
GLenum attachment, const char* funcName);
|
2014-09-25 19:21:33 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
void FrontFace(GLenum mode);
|
2014-11-14 07:03:50 +03:00
|
|
|
already_AddRefed<WebGLActiveInfo> GetActiveAttrib(WebGLProgram* prog,
|
2013-09-04 16:14:43 +04:00
|
|
|
GLuint index);
|
2014-11-14 07:03:50 +03:00
|
|
|
already_AddRefed<WebGLActiveInfo> GetActiveUniform(WebGLProgram* prog,
|
2013-09-04 16:14:43 +04:00
|
|
|
GLuint index);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
GetAttachedShaders(WebGLProgram* prog,
|
|
|
|
dom::Nullable<nsTArray<nsRefPtr<WebGLShader>>>& retval);
|
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLint GetAttribLocation(WebGLProgram* prog, const nsAString& name);
|
|
|
|
JS::Value GetBufferParameter(GLenum target, GLenum pname);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
void GetBufferParameter(JSContext*, GLenum target, GLenum pname,
|
|
|
|
JS::MutableHandle<JS::Value> retval)
|
|
|
|
{
|
2014-06-12 00:26:52 +04:00
|
|
|
retval.set(GetBufferParameter(target, pname));
|
2012-05-31 22:16:48 +04:00
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum GetError();
|
2014-11-14 07:03:50 +03:00
|
|
|
JS::Value GetFramebufferAttachmentParameter(JSContext* cx, GLenum target,
|
|
|
|
GLenum attachment, GLenum pname,
|
2012-05-06 05:15:11 +04:00
|
|
|
ErrorResult& rv);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
void GetFramebufferAttachmentParameter(JSContext* cx, GLenum target,
|
|
|
|
GLenum attachment, GLenum pname,
|
2014-06-12 00:26:52 +04:00
|
|
|
JS::MutableHandle<JS::Value> retval,
|
2014-11-14 07:03:50 +03:00
|
|
|
ErrorResult& rv)
|
|
|
|
{
|
2014-06-12 00:26:52 +04:00
|
|
|
retval.set(GetFramebufferAttachmentParameter(cx, target, attachment,
|
|
|
|
pname, rv));
|
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
JS::Value GetProgramParameter(WebGLProgram* prog, GLenum pname);
|
|
|
|
|
|
|
|
void GetProgramParameter(JSContext*, WebGLProgram* prog, GLenum pname,
|
|
|
|
JS::MutableHandle<JS::Value> retval)
|
|
|
|
{
|
2014-06-12 00:26:52 +04:00
|
|
|
retval.set(GetProgramParameter(prog, pname));
|
2012-05-31 22:16:48 +04:00
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
void GetProgramInfoLog(WebGLProgram* prog, nsACString& retval);
|
|
|
|
void GetProgramInfoLog(WebGLProgram* prog, nsAString& retval);
|
2013-09-04 16:14:43 +04:00
|
|
|
JS::Value GetRenderbufferParameter(GLenum target, GLenum pname);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
void GetRenderbufferParameter(JSContext*, GLenum target, GLenum pname,
|
|
|
|
JS::MutableHandle<JS::Value> retval)
|
|
|
|
{
|
2014-06-12 00:26:52 +04:00
|
|
|
retval.set(GetRenderbufferParameter(target, pname));
|
2012-05-31 22:16:48 +04:00
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
JS::Value GetShaderParameter(WebGLShader* shader, GLenum pname);
|
|
|
|
|
|
|
|
void GetShaderParameter(JSContext*, WebGLShader* shader, GLenum pname,
|
|
|
|
JS::MutableHandle<JS::Value> retval)
|
|
|
|
{
|
2014-06-12 00:26:52 +04:00
|
|
|
retval.set(GetShaderParameter(shader, pname));
|
2012-05-31 22:16:48 +04:00
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
already_AddRefed<WebGLShaderPrecisionFormat>
|
2014-11-14 07:03:50 +03:00
|
|
|
GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
|
|
|
|
|
|
|
|
void GetShaderInfoLog(WebGLShader* shader, nsACString& retval);
|
|
|
|
void GetShaderInfoLog(WebGLShader* shader, nsAString& retval);
|
|
|
|
void GetShaderSource(WebGLShader* shader, nsAString& retval);
|
|
|
|
void GetShaderTranslatedSource(WebGLShader* shader, nsAString& retval);
|
|
|
|
|
|
|
|
JS::Value GetUniform(JSContext* cx, WebGLProgram* prog,
|
|
|
|
WebGLUniformLocation* loc);
|
|
|
|
|
|
|
|
void GetUniform(JSContext* cx, WebGLProgram* prog,
|
|
|
|
WebGLUniformLocation* loc,
|
|
|
|
JS::MutableHandle<JS::Value> retval)
|
|
|
|
{
|
|
|
|
retval.set(GetUniform(cx, prog, loc));
|
2014-06-12 00:26:52 +04:00
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
already_AddRefed<WebGLUniformLocation>
|
2014-11-14 07:03:50 +03:00
|
|
|
GetUniformLocation(WebGLProgram* prog, const nsAString& name);
|
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
void Hint(GLenum target, GLenum mode);
|
2014-11-14 07:03:50 +03:00
|
|
|
bool IsFramebuffer(WebGLFramebuffer* fb);
|
|
|
|
bool IsProgram(WebGLProgram* prog);
|
|
|
|
bool IsRenderbuffer(WebGLRenderbuffer* rb);
|
|
|
|
bool IsShader(WebGLShader* shader);
|
|
|
|
bool IsVertexArray(WebGLVertexArray* vao);
|
2013-09-04 16:14:50 +04:00
|
|
|
void LineWidth(GLfloat width);
|
2014-11-14 07:03:50 +03:00
|
|
|
void LinkProgram(WebGLProgram* prog);
|
2013-09-04 16:14:43 +04:00
|
|
|
void PixelStorei(GLenum pname, GLint param);
|
2013-09-04 16:14:50 +04:00
|
|
|
void PolygonOffset(GLfloat factor, GLfloat units);
|
2013-09-04 16:14:43 +04:00
|
|
|
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
|
|
|
|
GLenum format, GLenum type,
|
2015-07-15 03:37:28 +03:00
|
|
|
const dom::Nullable<dom::ArrayBufferView>& pixels,
|
2013-08-05 21:40:01 +04:00
|
|
|
ErrorResult& rv);
|
2014-11-14 07:03:50 +03:00
|
|
|
void RenderbufferStorage(GLenum target, GLenum internalFormat,
|
2013-09-04 16:14:43 +04:00
|
|
|
GLsizei width, GLsizei height);
|
2015-02-19 03:57:05 +03:00
|
|
|
protected:
|
|
|
|
void RenderbufferStorage_base(const char* funcName, GLenum target,
|
|
|
|
GLsizei samples, GLenum internalformat,
|
|
|
|
GLsizei width, GLsizei height);
|
|
|
|
public:
|
2013-09-04 16:14:50 +04:00
|
|
|
void SampleCoverage(GLclampf value, WebGLboolean invert);
|
2013-09-04 16:14:43 +04:00
|
|
|
void Scissor(GLint x, GLint y, GLsizei width, GLsizei height);
|
2014-11-14 07:03:50 +03:00
|
|
|
void ShaderSource(WebGLShader* shader, const nsAString& source);
|
2013-09-04 16:14:43 +04:00
|
|
|
void StencilFunc(GLenum func, GLint ref, GLuint mask);
|
2014-11-14 07:03:50 +03:00
|
|
|
void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
|
2013-09-04 16:14:43 +04:00
|
|
|
void StencilMask(GLuint mask);
|
|
|
|
void StencilMaskSeparate(GLenum face, GLuint mask);
|
|
|
|
void StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
|
|
|
void StencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail,
|
|
|
|
GLenum dppass);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform1i(WebGLUniformLocation* loc, GLint x);
|
|
|
|
void Uniform2i(WebGLUniformLocation* loc, GLint x, GLint y);
|
|
|
|
void Uniform3i(WebGLUniformLocation* loc, GLint x, GLint y, GLint z);
|
|
|
|
void Uniform4i(WebGLUniformLocation* loc, GLint x, GLint y, GLint z,
|
|
|
|
GLint w);
|
|
|
|
|
|
|
|
void Uniform1f(WebGLUniformLocation* loc, GLfloat x);
|
|
|
|
void Uniform2f(WebGLUniformLocation* loc, GLfloat x, GLfloat y);
|
|
|
|
void Uniform3f(WebGLUniformLocation* loc, GLfloat x, GLfloat y, GLfloat z);
|
|
|
|
void Uniform4f(WebGLUniformLocation* loc, GLfloat x, GLfloat y, GLfloat z,
|
|
|
|
GLfloat w);
|
|
|
|
|
|
|
|
// Int array
|
|
|
|
void Uniform1iv(WebGLUniformLocation* loc, const dom::Int32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
Uniform1iv_base(loc, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform1iv(WebGLUniformLocation* loc,
|
|
|
|
const dom::Sequence<GLint>& arr)
|
|
|
|
{
|
|
|
|
Uniform1iv_base(loc, arr.Length(), arr.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform1iv_base(WebGLUniformLocation* loc, size_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLint* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform2iv(WebGLUniformLocation* loc, const dom::Int32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
Uniform2iv_base(loc, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform2iv(WebGLUniformLocation* loc,
|
|
|
|
const dom::Sequence<GLint>& arr)
|
|
|
|
{
|
|
|
|
Uniform2iv_base(loc, arr.Length(), arr.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform2iv_base(WebGLUniformLocation* loc, size_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLint* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform3iv(WebGLUniformLocation* loc, const dom::Int32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
Uniform3iv_base(loc, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform3iv(WebGLUniformLocation* loc,
|
|
|
|
const dom::Sequence<GLint>& arr)
|
|
|
|
{
|
|
|
|
Uniform3iv_base(loc, arr.Length(), arr.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform3iv_base(WebGLUniformLocation* loc, size_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLint* data);
|
2014-01-23 07:59:33 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform4iv(WebGLUniformLocation* loc, const dom::Int32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
Uniform4iv_base(loc, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform4iv(WebGLUniformLocation* loc,
|
|
|
|
const dom::Sequence<GLint>& arr)
|
|
|
|
{
|
|
|
|
Uniform4iv_base(loc, arr.Length(), arr.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform4iv_base(WebGLUniformLocation* loc, size_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLint* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
// Float array
|
|
|
|
void Uniform1fv(WebGLUniformLocation* loc, const dom::Float32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
Uniform1fv_base(loc, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform1fv(WebGLUniformLocation* loc,
|
|
|
|
const dom::Sequence<GLfloat>& arr)
|
|
|
|
{
|
|
|
|
Uniform1fv_base(loc, arr.Length(), arr.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform1fv_base(WebGLUniformLocation* loc, size_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLfloat* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform2fv(WebGLUniformLocation* loc, const dom::Float32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
Uniform2fv_base(loc, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform2fv(WebGLUniformLocation* loc,
|
|
|
|
const dom::Sequence<GLfloat>& arr)
|
|
|
|
{
|
|
|
|
Uniform2fv_base(loc, arr.Length(), arr.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform2fv_base(WebGLUniformLocation* loc, size_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLfloat* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform3fv(WebGLUniformLocation* loc, const dom::Float32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
Uniform3fv_base(loc, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform3fv(WebGLUniformLocation* loc,
|
|
|
|
const dom::Sequence<GLfloat>& arr)
|
|
|
|
{
|
|
|
|
Uniform3fv_base(loc, arr.Length(), arr.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform3fv_base(WebGLUniformLocation* loc, size_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLfloat* data);
|
2014-01-23 07:59:33 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform4fv(WebGLUniformLocation* loc, const dom::Float32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
Uniform4fv_base(loc, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform4fv(WebGLUniformLocation* loc,
|
|
|
|
const dom::Sequence<GLfloat>& arr)
|
|
|
|
{
|
|
|
|
Uniform4fv_base(loc, arr.Length(), arr.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void Uniform4fv_base(WebGLUniformLocation* loc, size_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLfloat* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
// Matrix
|
|
|
|
void UniformMatrix2fv(WebGLUniformLocation* loc, WebGLboolean transpose,
|
|
|
|
const dom::Float32Array& value)
|
|
|
|
{
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
value.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
UniformMatrix2fv_base(loc, transpose, value.Length(), value.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void UniformMatrix2fv(WebGLUniformLocation* loc, WebGLboolean transpose,
|
|
|
|
const dom::Sequence<float>& value)
|
|
|
|
{
|
|
|
|
UniformMatrix2fv_base(loc, transpose, value.Length(),
|
2012-05-04 20:38:44 +04:00
|
|
|
value.Elements());
|
|
|
|
}
|
2015-03-23 04:29:32 +03:00
|
|
|
void UniformMatrix2fv_base(WebGLUniformLocation* loc, bool transpose,
|
|
|
|
size_t arrayLength, const float* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void UniformMatrix3fv(WebGLUniformLocation* loc, WebGLboolean transpose,
|
|
|
|
const dom::Float32Array& value)
|
|
|
|
{
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
value.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
UniformMatrix3fv_base(loc, transpose, value.Length(), value.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2014-10-24 02:10:57 +04:00
|
|
|
void UniformMatrix3fv(WebGLUniformLocation* loc, WebGLboolean transpose,
|
|
|
|
const dom::Sequence<float>& value)
|
|
|
|
{
|
|
|
|
UniformMatrix3fv_base(loc, transpose, value.Length(), value.Elements());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2015-03-23 04:29:32 +03:00
|
|
|
void UniformMatrix3fv_base(WebGLUniformLocation* loc, bool transpose,
|
|
|
|
size_t arrayLength, const float* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
void UniformMatrix4fv(WebGLUniformLocation* loc, WebGLboolean transpose,
|
|
|
|
const dom::Float32Array& value)
|
|
|
|
{
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
value.ComputeLengthAndData();
|
2014-10-24 02:10:57 +04:00
|
|
|
UniformMatrix4fv_base(loc, transpose, value.Length(), value.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2015-03-23 04:29:32 +03:00
|
|
|
void UniformMatrix4fv(WebGLUniformLocation* loc, bool transpose,
|
2014-10-24 02:10:57 +04:00
|
|
|
const dom::Sequence<float>& value)
|
|
|
|
{
|
|
|
|
UniformMatrix4fv_base(loc, transpose, value.Length(),
|
2012-05-04 20:38:44 +04:00
|
|
|
value.Elements());
|
|
|
|
}
|
2015-03-23 04:29:32 +03:00
|
|
|
void UniformMatrix4fv_base(WebGLUniformLocation* loc, bool transpose,
|
|
|
|
size_t arrayLength, const float* data);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void UseProgram(WebGLProgram* prog);
|
2015-01-16 02:40:39 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateAttribArraySetter(const char* name, uint32_t count,
|
|
|
|
uint32_t arrayLength);
|
2015-01-16 02:40:39 +03:00
|
|
|
bool ValidateUniformLocation(WebGLUniformLocation* loc, const char* funcName);
|
2014-10-24 02:10:57 +04:00
|
|
|
bool ValidateUniformSetter(WebGLUniformLocation* loc, uint8_t setterSize,
|
|
|
|
GLenum setterType, const char* info,
|
|
|
|
GLuint* out_rawLoc);
|
|
|
|
bool ValidateUniformArraySetter(WebGLUniformLocation* loc,
|
|
|
|
uint8_t setterElemSize, GLenum setterType,
|
|
|
|
size_t setterArraySize, const char* info,
|
|
|
|
GLuint* out_rawLoc,
|
|
|
|
GLsizei* out_numElementsToUpload);
|
|
|
|
bool ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
2015-03-23 04:29:32 +03:00
|
|
|
uint8_t setterCols,
|
|
|
|
uint8_t setterRows,
|
|
|
|
GLenum setterType,
|
2014-10-24 02:10:57 +04:00
|
|
|
size_t setterArraySize,
|
|
|
|
bool setterTranspose,
|
2015-03-23 04:29:32 +03:00
|
|
|
const char* info,
|
|
|
|
GLuint* out_rawLoc,
|
2014-10-24 02:10:57 +04:00
|
|
|
GLsizei* out_numElementsToUpload);
|
2014-11-14 07:03:50 +03:00
|
|
|
void ValidateProgram(WebGLProgram* prog);
|
|
|
|
bool ValidateUniformLocation(const char* info, WebGLUniformLocation* loc);
|
2013-03-05 04:44:31 +04:00
|
|
|
bool ValidateSamplerUniformSetter(const char* info,
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLUniformLocation* loc, GLint value);
|
2013-09-04 16:14:43 +04:00
|
|
|
void Viewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
2014-06-03 01:40:15 +04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// WEBGL_lose_context
|
|
|
|
public:
|
|
|
|
void LoseContext();
|
|
|
|
void RestoreContext();
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2013-08-20 19:36:19 +04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Buffer Objects (WebGLContextBuffers.cpp)
|
2014-12-05 10:04:55 +03:00
|
|
|
private:
|
|
|
|
void UpdateBoundBuffer(GLenum target, WebGLBuffer* buffer);
|
|
|
|
void UpdateBoundBufferIndexed(GLenum target, GLuint index, WebGLBuffer* buffer);
|
|
|
|
|
2013-08-20 19:36:19 +04:00
|
|
|
public:
|
2014-12-05 10:04:55 +03:00
|
|
|
void BindBuffer(GLenum target, WebGLBuffer* buffer);
|
2014-11-14 07:03:50 +03:00
|
|
|
void BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buf);
|
|
|
|
void BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buf,
|
2013-08-20 19:36:20 +04:00
|
|
|
WebGLintptr offset, WebGLsizeiptr size);
|
2014-12-05 10:04:55 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
void BufferDataUnchecked(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
|
|
|
|
void BufferData(GLenum target, WebGLsizeiptr size, void* data, GLenum usage);
|
|
|
|
|
|
|
|
public:
|
2013-09-04 16:14:43 +04:00
|
|
|
void BufferData(GLenum target, WebGLsizeiptr size, GLenum usage);
|
2014-11-14 07:03:50 +03:00
|
|
|
void BufferData(GLenum target, const dom::ArrayBufferView& data,
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum usage);
|
2015-07-15 03:37:28 +03:00
|
|
|
void BufferData(GLenum target, const dom::Nullable<dom::ArrayBuffer>& maybeData,
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum usage);
|
2014-12-05 10:04:55 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
void BufferSubDataUnchecked(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
|
|
|
|
void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
|
|
|
|
|
|
|
|
public:
|
2013-09-04 16:14:43 +04:00
|
|
|
void BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
|
2014-11-14 07:03:50 +03:00
|
|
|
const dom::ArrayBufferView& data);
|
2013-09-04 16:14:43 +04:00
|
|
|
void BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
|
2015-07-15 03:37:28 +03:00
|
|
|
const dom::Nullable<dom::ArrayBuffer>& maybeData);
|
2013-08-20 19:36:19 +04:00
|
|
|
already_AddRefed<WebGLBuffer> CreateBuffer();
|
2014-11-14 07:03:50 +03:00
|
|
|
void DeleteBuffer(WebGLBuffer* buf);
|
|
|
|
bool IsBuffer(WebGLBuffer* buf);
|
2013-08-20 19:36:19 +04:00
|
|
|
|
2014-11-26 05:00:06 +03:00
|
|
|
protected:
|
|
|
|
// bound buffer state
|
2013-08-20 19:36:19 +04:00
|
|
|
WebGLRefPtr<WebGLBuffer> mBoundArrayBuffer;
|
2014-12-05 10:04:55 +03:00
|
|
|
WebGLRefPtr<WebGLBuffer> mBoundCopyReadBuffer;
|
|
|
|
WebGLRefPtr<WebGLBuffer> mBoundCopyWriteBuffer;
|
|
|
|
WebGLRefPtr<WebGLBuffer> mBoundPixelPackBuffer;
|
|
|
|
WebGLRefPtr<WebGLBuffer> mBoundPixelUnpackBuffer;
|
2013-08-20 19:36:20 +04:00
|
|
|
WebGLRefPtr<WebGLBuffer> mBoundTransformFeedbackBuffer;
|
2014-12-05 10:04:55 +03:00
|
|
|
WebGLRefPtr<WebGLBuffer> mBoundUniformBuffer;
|
2013-08-20 19:36:20 +04:00
|
|
|
|
2015-02-08 17:13:00 +03:00
|
|
|
nsTArray<WebGLRefPtr<WebGLBuffer>> mBoundUniformBuffers;
|
|
|
|
nsTArray<WebGLRefPtr<WebGLBuffer>> mBoundTransformFeedbackBuffers;
|
2014-11-26 05:00:06 +03:00
|
|
|
|
2014-12-05 10:04:55 +03:00
|
|
|
WebGLRefPtr<WebGLBuffer>& GetBufferSlotByTarget(GLenum target);
|
|
|
|
WebGLRefPtr<WebGLBuffer>& GetBufferSlotByTargetIndexed(GLenum target,
|
2014-11-26 05:00:06 +03:00
|
|
|
GLuint index);
|
2013-08-20 19:36:19 +04:00
|
|
|
|
2015-05-21 02:59:14 +03:00
|
|
|
GLenum GetCurrentBinding(WebGLBuffer* buffer) const;
|
|
|
|
|
2014-11-03 08:35:04 +03:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Queries (WebGL2ContextQueries.cpp)
|
|
|
|
protected:
|
2015-04-17 04:17:07 +03:00
|
|
|
WebGLRefPtr<WebGLQuery>& GetQuerySlotByTarget(GLenum target);
|
2014-11-03 08:35:04 +03:00
|
|
|
|
2014-11-26 06:46:49 +03:00
|
|
|
WebGLRefPtr<WebGLQuery> mActiveOcclusionQuery;
|
|
|
|
WebGLRefPtr<WebGLQuery> mActiveTransformFeedbackQuery;
|
2014-11-03 08:35:04 +03:00
|
|
|
|
2013-08-16 04:43:47 +04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// State and State Requests (WebGLContextState.cpp)
|
|
|
|
public:
|
2013-09-04 16:14:43 +04:00
|
|
|
void Disable(GLenum cap);
|
|
|
|
void Enable(GLenum cap);
|
2014-09-27 02:06:38 +04:00
|
|
|
bool GetStencilBits(GLint* out_stencilBits);
|
2015-06-05 06:26:34 +03:00
|
|
|
virtual JS::Value GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
void GetParameter(JSContext* cx, GLenum pname,
|
2014-11-14 07:03:50 +03:00
|
|
|
JS::MutableHandle<JS::Value> retval, ErrorResult& rv)
|
|
|
|
{
|
2014-06-12 00:26:52 +04:00
|
|
|
retval.set(GetParameter(cx, pname, rv));
|
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
void GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index,
|
|
|
|
JS::MutableHandle<JS::Value> retval);
|
2013-09-04 16:14:43 +04:00
|
|
|
bool IsEnabled(GLenum cap);
|
2013-08-16 04:43:47 +04:00
|
|
|
|
|
|
|
private:
|
2013-08-23 04:11:27 +04:00
|
|
|
// State tracking slots
|
|
|
|
realGLboolean mDitherEnabled;
|
2013-08-23 04:11:40 +04:00
|
|
|
realGLboolean mRasterizerDiscardEnabled;
|
2013-08-23 04:11:27 +04:00
|
|
|
realGLboolean mScissorTestEnabled;
|
2015-03-12 04:23:56 +03:00
|
|
|
realGLboolean mStencilTestEnabled;
|
2013-08-23 04:11:27 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
bool ValidateCapabilityEnum(GLenum cap, const char* info);
|
|
|
|
realGLboolean* GetStateTrackingSlot(GLenum cap);
|
2013-08-16 04:43:47 +04:00
|
|
|
|
2015-08-04 00:34:46 +03:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Texture funcions (WebGLContextTextures.cpp)
|
|
|
|
public:
|
|
|
|
void ActiveTexture(GLenum texUnit);
|
|
|
|
void BindTexture(GLenum texTarget, WebGLTexture* tex);
|
|
|
|
already_AddRefed<WebGLTexture> CreateTexture();
|
|
|
|
void DeleteTexture(WebGLTexture* tex);
|
|
|
|
void GenerateMipmap(GLenum texTarget);
|
|
|
|
|
|
|
|
void GetTexParameter(JSContext*, GLenum texTarget, GLenum pname,
|
|
|
|
JS::MutableHandle<JS::Value> retval)
|
|
|
|
{
|
|
|
|
retval.set(GetTexParameter(texTarget, pname));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsTexture(WebGLTexture* tex);
|
|
|
|
|
|
|
|
void TexParameterf(GLenum texTarget, GLenum pname, GLfloat param) {
|
|
|
|
TexParameter_base(texTarget, pname, nullptr, ¶m);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TexParameteri(GLenum texTarget, GLenum pname, GLint param) {
|
|
|
|
TexParameter_base(texTarget, pname, ¶m, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
JS::Value GetTexParameter(GLenum texTarget, GLenum pname);
|
|
|
|
void TexParameter_base(GLenum texTarget, GLenum pname, GLint* maybeIntParam,
|
|
|
|
GLfloat* maybeFloatParam);
|
|
|
|
|
|
|
|
virtual bool IsTexParamValid(GLenum pname) const;
|
|
|
|
|
|
|
|
// Upload funcs
|
|
|
|
public:
|
|
|
|
void CompressedTexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
|
|
|
|
GLsizei width, GLsizei height, GLint border,
|
|
|
|
const dom::ArrayBufferView& view);
|
|
|
|
void CompressedTexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset,
|
|
|
|
GLint yOffset, GLsizei width, GLsizei height,
|
|
|
|
GLenum unpackFormat, const dom::ArrayBufferView& view);
|
|
|
|
|
|
|
|
void CopyTexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
|
|
|
|
GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
|
|
|
|
void CopyTexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset,
|
|
|
|
GLint yOffset, GLint x, GLint y, GLsizei width,
|
|
|
|
GLsizei height);
|
|
|
|
|
|
|
|
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
|
|
|
|
GLsizei width, GLsizei height, GLint border, GLenum unpackFormat,
|
|
|
|
GLenum unpackType,
|
|
|
|
const dom::Nullable<dom::ArrayBufferView>& maybeView,
|
|
|
|
ErrorResult& out_rv);
|
|
|
|
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
|
|
|
|
GLenum unpackFormat, GLenum unpackType, dom::ImageData* imageData,
|
|
|
|
ErrorResult& out_rv);
|
|
|
|
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
|
|
|
|
GLenum unpackFormat, GLenum unpackType, dom::Element* elem,
|
|
|
|
ErrorResult* const out_rv);
|
|
|
|
|
|
|
|
|
|
|
|
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
|
|
|
|
GLsizei width, GLsizei height, GLenum unpackFormat,
|
|
|
|
GLenum unpackType,
|
|
|
|
const dom::Nullable<dom::ArrayBufferView>& maybeView,
|
|
|
|
ErrorResult& out_rv);
|
|
|
|
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
|
|
|
|
GLenum unpackFormat, GLenum unpackType, dom::ImageData* imageData,
|
|
|
|
ErrorResult& out_rv);
|
|
|
|
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
|
|
|
|
GLenum unpackFormat, GLenum unpackType, dom::Element* elem,
|
|
|
|
ErrorResult* const out_rv);
|
|
|
|
|
|
|
|
// Allow whatever element unpackTypes the bindings are willing to pass
|
|
|
|
// us in Tex(Sub)Image2D
|
|
|
|
template<typename ElementT>
|
|
|
|
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
|
|
|
|
GLenum unpackFormat, GLenum unpackType, ElementT& elem,
|
|
|
|
ErrorResult& out_rv)
|
|
|
|
{
|
|
|
|
TexImage2D(texImageTarget, level, internalFormat, unpackFormat, unpackType, &elem,
|
|
|
|
&out_rv);
|
|
|
|
}
|
|
|
|
template<typename ElementT>
|
|
|
|
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xOffset, GLint yOffset,
|
|
|
|
GLenum unpackFormat, GLenum unpackType, ElementT& elem,
|
|
|
|
ErrorResult& out_rv)
|
|
|
|
{
|
|
|
|
TexSubImage2D(texImageTarget, level, xOffset, yOffset, unpackFormat, unpackType,
|
|
|
|
&elem, &out_rv);
|
|
|
|
}
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Vertices Feature (WebGLContextVertices.cpp)
|
|
|
|
public:
|
2013-09-04 16:14:43 +04:00
|
|
|
void DrawArrays(GLenum mode, GLint first, GLsizei count);
|
2014-11-14 07:03:50 +03:00
|
|
|
void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
|
|
|
|
GLsizei primcount);
|
|
|
|
void DrawElements(GLenum mode, GLsizei count, GLenum type,
|
|
|
|
WebGLintptr byteOffset);
|
2013-09-04 16:14:43 +04:00
|
|
|
void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
|
|
|
|
WebGLintptr byteOffset, GLsizei primcount);
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
void EnableVertexAttribArray(GLuint index);
|
|
|
|
void DisableVertexAttribArray(GLuint index);
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
JS::Value GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
|
2013-08-07 04:05:51 +04:00
|
|
|
ErrorResult& rv);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
void GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
|
2014-11-14 07:03:50 +03:00
|
|
|
JS::MutableHandle<JS::Value> retval, ErrorResult& rv)
|
|
|
|
{
|
2014-06-12 00:26:52 +04:00
|
|
|
retval.set(GetVertexAttrib(cx, index, pname, rv));
|
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLsizeiptr GetVertexAttribOffset(GLuint index, GLenum pname);
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
void VertexAttrib1f(GLuint index, GLfloat x0);
|
|
|
|
void VertexAttrib2f(GLuint index, GLfloat x0, GLfloat x1);
|
2014-11-14 07:03:50 +03:00
|
|
|
void VertexAttrib3f(GLuint index, GLfloat x0, GLfloat x1, GLfloat x2);
|
|
|
|
void VertexAttrib4f(GLuint index, GLfloat x0, GLfloat x1, GLfloat x2,
|
|
|
|
GLfloat x3);
|
2012-05-04 20:38:44 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void VertexAttrib1fv(GLuint idx, const dom::Float32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2012-08-01 07:45:20 +04:00
|
|
|
VertexAttrib1fv_base(idx, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2013-09-04 16:14:43 +04:00
|
|
|
void VertexAttrib1fv(GLuint idx, const dom::Sequence<GLfloat>& arr) {
|
2012-05-04 20:38:44 +04:00
|
|
|
VertexAttrib1fv_base(idx, arr.Length(), arr.Elements());
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void VertexAttrib2fv(GLuint idx, const dom::Float32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2012-08-01 07:45:20 +04:00
|
|
|
VertexAttrib2fv_base(idx, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2013-09-04 16:14:43 +04:00
|
|
|
void VertexAttrib2fv(GLuint idx, const dom::Sequence<GLfloat>& arr) {
|
2012-05-04 20:38:44 +04:00
|
|
|
VertexAttrib2fv_base(idx, arr.Length(), arr.Elements());
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void VertexAttrib3fv(GLuint idx, const dom::Float32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2012-08-01 07:45:20 +04:00
|
|
|
VertexAttrib3fv_base(idx, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2013-09-04 16:14:43 +04:00
|
|
|
void VertexAttrib3fv(GLuint idx, const dom::Sequence<GLfloat>& arr) {
|
2012-05-04 20:38:44 +04:00
|
|
|
VertexAttrib3fv_base(idx, arr.Length(), arr.Elements());
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void VertexAttrib4fv(GLuint idx, const dom::Float32Array& arr) {
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
arr.ComputeLengthAndData();
|
2012-08-01 07:45:20 +04:00
|
|
|
VertexAttrib4fv_base(idx, arr.Length(), arr.Data());
|
2012-05-04 20:38:44 +04:00
|
|
|
}
|
2013-09-04 16:14:43 +04:00
|
|
|
void VertexAttrib4fv(GLuint idx, const dom::Sequence<GLfloat>& arr) {
|
2012-05-04 20:38:44 +04:00
|
|
|
VertexAttrib4fv_base(idx, arr.Length(), arr.Elements());
|
|
|
|
}
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
void VertexAttribPointer(GLuint index, GLint size, GLenum type,
|
|
|
|
WebGLboolean normalized, GLsizei stride,
|
2012-05-04 20:38:44 +04:00
|
|
|
WebGLintptr byteOffset);
|
2013-09-04 16:14:43 +04:00
|
|
|
void VertexAttribDivisor(GLuint index, GLuint divisor);
|
2013-07-26 04:38:58 +04:00
|
|
|
|
|
|
|
private:
|
2013-08-14 02:11:01 +04:00
|
|
|
// Cache the max number of vertices and instances that can be read from
|
|
|
|
// bound VBOs (result of ValidateBuffers).
|
|
|
|
bool mBufferFetchingIsVerified;
|
|
|
|
bool mBufferFetchingHasPerVertex;
|
|
|
|
uint32_t mMaxFetchedVertices;
|
|
|
|
uint32_t mMaxFetchedInstances;
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool DrawArrays_check(GLint first, GLsizei count, GLsizei primcount,
|
|
|
|
const char* info);
|
2013-09-04 16:14:43 +04:00
|
|
|
bool DrawElements_check(GLsizei count, GLenum type, WebGLintptr byteOffset,
|
2014-03-17 18:52:56 +04:00
|
|
|
GLsizei primcount, const char* info,
|
2014-07-22 16:53:24 +04:00
|
|
|
GLuint* out_upperBound);
|
2013-09-20 02:30:19 +04:00
|
|
|
bool DrawInstanced_check(const char* info);
|
2013-07-26 04:38:58 +04:00
|
|
|
void Draw_cleanup();
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void VertexAttrib1fv_base(GLuint index, uint32_t arrayLength,
|
|
|
|
const GLfloat* ptr);
|
|
|
|
void VertexAttrib2fv_base(GLuint index, uint32_t arrayLength,
|
|
|
|
const GLfloat* ptr);
|
|
|
|
void VertexAttrib3fv_base(GLuint index, uint32_t arrayLength,
|
|
|
|
const GLfloat* ptr);
|
|
|
|
void VertexAttrib4fv_base(GLuint index, uint32_t arrayLength,
|
|
|
|
const GLfloat* ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateBufferFetching(const char* info);
|
|
|
|
bool BindArrayAttribToLocation0(WebGLProgram* prog);
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2013-07-26 04:38:58 +04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// PROTECTED
|
2011-02-25 01:17:34 +03:00
|
|
|
protected:
|
2013-10-11 17:16:43 +04:00
|
|
|
void SetFakeBlackStatus(WebGLContextFakeBlackStatus x) {
|
|
|
|
mFakeBlackStatus = x;
|
2010-08-24 01:03:53 +04:00
|
|
|
}
|
2013-10-11 17:16:43 +04:00
|
|
|
// Returns the current fake-black-status, except if it was Unknown,
|
|
|
|
// in which case this function resolves it first, so it never returns Unknown.
|
|
|
|
WebGLContextFakeBlackStatus ResolvedFakeBlackStatus();
|
2010-08-24 01:03:53 +04:00
|
|
|
|
|
|
|
void BindFakeBlackTextures();
|
|
|
|
void UnbindFakeBlackTextures();
|
|
|
|
|
2013-10-11 17:16:43 +04:00
|
|
|
WebGLVertexAttrib0Status WhatDoesVertexAttrib0Need();
|
2013-09-04 16:14:43 +04:00
|
|
|
bool DoFakeVertexAttrib0(GLuint vertexCount);
|
2010-09-02 18:34:08 +04:00
|
|
|
void UndoFakeVertexAttrib0();
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
static CheckedUint32 GetImageSize(GLsizei height, GLsizei width,
|
|
|
|
GLsizei depth, uint32_t pixelSize,
|
2012-05-23 20:07:01 +04:00
|
|
|
uint32_t alignment);
|
2011-09-01 23:28:34 +04:00
|
|
|
|
2014-12-05 10:04:55 +03:00
|
|
|
inline void InvalidateBufferFetching()
|
|
|
|
{
|
|
|
|
mBufferFetchingIsVerified = false;
|
|
|
|
mBufferFetchingHasPerVertex = false;
|
|
|
|
mMaxFetchedVertices = 0;
|
|
|
|
mMaxFetchedInstances = 0;
|
|
|
|
}
|
|
|
|
|
2010-07-04 02:32:19 +04:00
|
|
|
CheckedUint32 mGeneration;
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2010-11-17 07:33:03 +03:00
|
|
|
WebGLContextOptions mOptions;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInvalidated;
|
|
|
|
bool mResetLayer;
|
|
|
|
bool mOptionsFrozen;
|
2011-10-13 16:09:22 +04:00
|
|
|
bool mMinCapability;
|
|
|
|
bool mDisableExtensions;
|
2012-08-10 06:30:17 +04:00
|
|
|
bool mIsMesa;
|
2014-06-23 03:16:00 +04:00
|
|
|
bool mLoseContextOnMemoryPressure;
|
2013-01-04 03:39:25 +04:00
|
|
|
bool mCanLoseContextInForeground;
|
2014-06-23 03:16:00 +04:00
|
|
|
bool mRestoreWhenVisible;
|
2013-02-14 03:26:24 +04:00
|
|
|
bool mShouldPresent;
|
2014-04-18 00:15:41 +04:00
|
|
|
bool mBackbufferNeedsClear;
|
2013-05-16 01:50:52 +04:00
|
|
|
bool mDisableFragHighP;
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2011-12-04 23:15:43 +04:00
|
|
|
template<typename WebGLObjectType>
|
|
|
|
void DeleteWebGLObjectsArray(nsTArray<WebGLObjectType>& array);
|
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
GLuint mActiveTexture;
|
2014-03-08 01:16:34 +04:00
|
|
|
|
|
|
|
// glGetError sources:
|
|
|
|
bool mEmitContextLostErrorOnce;
|
2013-09-04 16:14:43 +04:00
|
|
|
GLenum mWebGLError;
|
2014-03-08 01:16:34 +04:00
|
|
|
GLenum mUnderlyingGLError;
|
|
|
|
GLenum GetAndFlushUnderlyingGLErrors();
|
2010-05-15 17:55:45 +04:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
bool mBypassShaderValidation;
|
|
|
|
|
|
|
|
webgl::ShaderValidator* CreateShaderValidator(GLenum shaderType) const;
|
2010-07-15 07:52:34 +04:00
|
|
|
|
|
|
|
// some GL constants
|
2012-05-23 20:07:01 +04:00
|
|
|
int32_t mGLMaxVertexAttribs;
|
|
|
|
int32_t mGLMaxTextureUnits;
|
|
|
|
int32_t mGLMaxTextureSize;
|
2014-09-03 23:17:18 +04:00
|
|
|
int32_t mGLMaxTextureSizeLog2;
|
2012-05-23 20:07:01 +04:00
|
|
|
int32_t mGLMaxCubeMapTextureSize;
|
2014-09-03 23:17:18 +04:00
|
|
|
int32_t mGLMaxCubeMapTextureSizeLog2;
|
2012-12-12 01:57:30 +04:00
|
|
|
int32_t mGLMaxRenderbufferSize;
|
2012-05-23 20:07:01 +04:00
|
|
|
int32_t mGLMaxTextureImageUnits;
|
|
|
|
int32_t mGLMaxVertexTextureImageUnits;
|
|
|
|
int32_t mGLMaxVaryingVectors;
|
|
|
|
int32_t mGLMaxFragmentUniformVectors;
|
|
|
|
int32_t mGLMaxVertexUniformVectors;
|
2013-06-22 03:44:17 +04:00
|
|
|
int32_t mGLMaxColorAttachments;
|
|
|
|
int32_t mGLMaxDrawBuffers;
|
2015-02-19 03:57:05 +03:00
|
|
|
uint32_t mGLMaxTransformFeedbackSeparateAttribs;
|
2014-12-05 10:04:55 +03:00
|
|
|
GLuint mGLMaxUniformBufferBindings;
|
2015-02-19 03:57:05 +03:00
|
|
|
GLsizei mGLMaxSamples;
|
2015-07-03 04:55:43 +03:00
|
|
|
GLuint mGLMax3DTextureSize;
|
|
|
|
GLuint mGLMaxArrayTextureLayers;
|
2010-07-15 07:52:34 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
public:
|
|
|
|
GLuint MaxVertexAttribs() const {
|
|
|
|
return mGLMaxVertexAttribs;
|
|
|
|
}
|
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
GLuint GLMaxTextureUnits() const {
|
|
|
|
return mGLMaxTextureUnits;
|
|
|
|
}
|
|
|
|
|
2014-11-22 02:04:08 +03:00
|
|
|
|
|
|
|
bool IsFormatValidForFB(GLenum sizedFormat) const;
|
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
protected:
|
2013-09-04 16:14:44 +04:00
|
|
|
// Represents current status of the context with respect to context loss.
|
|
|
|
// That is, whether the context is lost, and what part of the context loss
|
|
|
|
// process we currently are at.
|
2012-01-05 01:12:03 +04:00
|
|
|
// This is used to support the WebGL spec's asyncronous nature in handling
|
|
|
|
// context loss.
|
|
|
|
enum ContextStatus {
|
|
|
|
// The context is stable; there either are none or we don't know of any.
|
2013-09-04 16:14:44 +04:00
|
|
|
ContextNotLost,
|
2012-01-05 01:12:03 +04:00
|
|
|
// The context has been lost, but we have not yet sent an event to the
|
|
|
|
// script informing it of this.
|
|
|
|
ContextLostAwaitingEvent,
|
|
|
|
// The context has been lost, and we have sent the script an event
|
|
|
|
// informing it of this.
|
|
|
|
ContextLost,
|
|
|
|
// The context is lost, an event has been sent to the script, and the
|
|
|
|
// script correctly handled the event. We are waiting for the context to
|
|
|
|
// be restored.
|
|
|
|
ContextLostAwaitingRestore
|
|
|
|
};
|
|
|
|
|
2013-08-27 01:12:53 +04:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// WebGL extensions (implemented in WebGLContextExtensions.cpp)
|
2014-11-14 07:03:50 +03:00
|
|
|
typedef EnumeratedArray<WebGLExtensionID, WebGLExtensionID::Max,
|
2014-04-26 06:34:07 +04:00
|
|
|
nsRefPtr<WebGLExtensionBase>> ExtensionsArrayType;
|
|
|
|
|
|
|
|
ExtensionsArrayType mExtensions;
|
2012-06-16 09:12:30 +04:00
|
|
|
|
2013-07-17 20:13:38 +04:00
|
|
|
// enable an extension. the extension should not be enabled before.
|
|
|
|
void EnableExtension(WebGLExtensionID ext);
|
|
|
|
|
2014-11-22 02:04:08 +03:00
|
|
|
// Enable an extension if it's supported. Return the extension on success.
|
|
|
|
WebGLExtensionBase* EnableSupportedExtension(JSContext* js,
|
|
|
|
WebGLExtensionID ext);
|
|
|
|
|
2012-06-16 09:12:30 +04:00
|
|
|
// returns true if the extension has been enabled by calling getExtension.
|
2012-10-04 01:13:05 +04:00
|
|
|
bool IsExtensionEnabled(WebGLExtensionID ext) const;
|
2012-06-16 09:12:30 +04:00
|
|
|
|
2012-10-17 23:11:51 +04:00
|
|
|
// returns true if the extension is supported for this JSContext (this decides what getSupportedExtensions exposes)
|
2014-11-14 07:03:50 +03:00
|
|
|
bool IsExtensionSupported(JSContext* cx, WebGLExtensionID ext) const;
|
2013-07-17 20:13:38 +04:00
|
|
|
bool IsExtensionSupported(WebGLExtensionID ext) const;
|
2011-05-20 23:53:53 +04:00
|
|
|
|
2013-08-27 01:12:53 +04:00
|
|
|
static const char* GetExtensionString(WebGLExtensionID ext);
|
|
|
|
|
2013-09-04 16:14:43 +04:00
|
|
|
nsTArray<GLenum> mCompressedTextureFormats;
|
2012-05-08 21:29:31 +04:00
|
|
|
|
2013-08-27 01:12:54 +04:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// WebGL 2 specifics (implemented in WebGL2Context.cpp)
|
2015-02-13 06:00:41 +03:00
|
|
|
public:
|
2013-08-27 01:12:54 +04:00
|
|
|
virtual bool IsWebGL2() const = 0;
|
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
protected:
|
2013-08-27 01:12:54 +04:00
|
|
|
bool InitWebGL2();
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Validation functions (implemented in WebGLContextValidate.cpp)
|
2014-08-28 03:16:22 +04:00
|
|
|
bool CreateOffscreenGL(bool forceEnabled);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool InitAndValidateGL();
|
2014-08-28 03:16:22 +04:00
|
|
|
bool ResizeBackbuffer(uint32_t width, uint32_t height);
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateBlendEquationEnum(GLenum cap, const char* info);
|
|
|
|
bool ValidateBlendFuncDstEnum(GLenum mode, const char* info);
|
|
|
|
bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info);
|
|
|
|
bool ValidateBlendFuncEnumsCompatibility(GLenum sfactor, GLenum dfactor,
|
|
|
|
const char* info);
|
2014-12-05 10:04:55 +03:00
|
|
|
bool ValidateDataOffsetSize(WebGLintptr offset, WebGLsizeiptr size, WebGLsizeiptr bufferSize, const char* info);
|
|
|
|
bool ValidateDataRanges(WebGLintptr readOffset, WebGLintptr writeOffset, WebGLsizeiptr size, const char* info);
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateTextureTargetEnum(GLenum target, const char* info);
|
|
|
|
bool ValidateComparisonEnum(GLenum target, const char* info);
|
|
|
|
bool ValidateStencilOpEnum(GLenum action, const char* info);
|
|
|
|
bool ValidateFaceEnum(GLenum face, const char* info);
|
|
|
|
bool ValidateTexInputData(GLenum type, js::Scalar::Type jsArrayType,
|
|
|
|
WebGLTexImageFunc func, WebGLTexDimensions dims);
|
|
|
|
bool ValidateDrawModeEnum(GLenum mode, const char* info);
|
2014-06-24 04:56:21 +04:00
|
|
|
bool ValidateAttribIndex(GLuint index, const char* info);
|
|
|
|
bool ValidateAttribPointer(bool integerMode, GLuint index, GLint size, GLenum type,
|
|
|
|
WebGLboolean normalized, GLsizei stride,
|
|
|
|
WebGLintptr byteOffset, const char* info);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ValidateStencilParamsForDrawCall();
|
2014-01-23 07:59:33 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateCopyTexImage(GLenum internalFormat, WebGLTexImageFunc func,
|
2014-10-14 03:42:15 +04:00
|
|
|
WebGLTexDimensions dims);
|
2014-10-27 02:40:37 +03:00
|
|
|
|
|
|
|
bool ValidateSamplerParameterName(GLenum pname, const char* info);
|
|
|
|
bool ValidateSamplerParameterParams(GLenum pname, const WebGLIntOrFloat& param, const char* info);
|
|
|
|
|
2014-10-14 03:42:15 +04:00
|
|
|
bool ValidateTexImage(TexImageTarget texImageTarget,
|
2014-09-23 21:48:27 +04:00
|
|
|
GLint level, GLenum internalFormat,
|
2014-02-21 05:20:28 +04:00
|
|
|
GLint xoffset, GLint yoffset, GLint zoffset,
|
|
|
|
GLint width, GLint height, GLint depth,
|
|
|
|
GLint border, GLenum format, GLenum type,
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLTexImageFunc func, WebGLTexDimensions dims);
|
|
|
|
bool ValidateTexImageFormat(GLenum internalFormat, WebGLTexImageFunc func,
|
2014-10-14 03:42:15 +04:00
|
|
|
WebGLTexDimensions dims);
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateTexImageType(GLenum type, WebGLTexImageFunc func,
|
2014-10-14 03:42:15 +04:00
|
|
|
WebGLTexDimensions dims);
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateTexImageFormatAndType(GLenum format, GLenum type,
|
2014-10-14 03:42:15 +04:00
|
|
|
WebGLTexImageFunc func,
|
|
|
|
WebGLTexDimensions dims);
|
2014-10-05 06:24:24 +04:00
|
|
|
bool ValidateCompTexImageInternalFormat(GLenum format,
|
2014-10-14 03:42:15 +04:00
|
|
|
WebGLTexImageFunc func,
|
|
|
|
WebGLTexDimensions dims);
|
2014-10-05 06:24:24 +04:00
|
|
|
bool ValidateCopyTexImageInternalFormat(GLenum format,
|
2014-10-14 03:42:15 +04:00
|
|
|
WebGLTexImageFunc func,
|
|
|
|
WebGLTexDimensions dims);
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateTexImageSize(TexImageTarget texImageTarget, GLint level,
|
2014-02-21 05:20:28 +04:00
|
|
|
GLint width, GLint height, GLint depth,
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLTexImageFunc func, WebGLTexDimensions dims);
|
|
|
|
bool ValidateTexSubImageSize(GLint x, GLint y, GLint z, GLsizei width,
|
|
|
|
GLsizei height, GLsizei depth,
|
|
|
|
GLsizei baseWidth, GLsizei baseHeight,
|
|
|
|
GLsizei baseDepth, WebGLTexImageFunc func,
|
2014-10-14 03:42:15 +04:00
|
|
|
WebGLTexDimensions dims);
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateCompTexImageSize(GLint level, GLenum internalFormat,
|
|
|
|
GLint xoffset, GLint yoffset, GLsizei width,
|
|
|
|
GLsizei height, GLsizei levelWidth,
|
|
|
|
GLsizei levelHeight, WebGLTexImageFunc func,
|
2014-10-14 03:42:15 +04:00
|
|
|
WebGLTexDimensions dims);
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateCompTexImageDataSize(GLint level, GLenum internalFormat,
|
2014-02-21 05:20:28 +04:00
|
|
|
GLsizei width, GLsizei height,
|
2014-10-14 03:42:15 +04:00
|
|
|
uint32_t byteLength,
|
|
|
|
WebGLTexImageFunc func,
|
|
|
|
WebGLTexDimensions dims);
|
2014-02-21 05:20:28 +04:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
bool ValidateUniformLocationForProgram(WebGLUniformLocation* location,
|
|
|
|
WebGLProgram* program,
|
|
|
|
const char* funcName);
|
|
|
|
|
2009-09-03 04:47:49 +04:00
|
|
|
void Invalidate();
|
2010-07-19 09:01:14 +04:00
|
|
|
void DestroyResourcesAndContext();
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
void MakeContextCurrent() const;
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2010-01-23 00:34:25 +03:00
|
|
|
// helpers
|
2014-10-14 03:42:11 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ConvertImage(size_t width, size_t height, size_t srcStride,
|
|
|
|
size_t dstStride, const uint8_t* src, uint8_t* dst,
|
2012-05-07 21:05:32 +04:00
|
|
|
WebGLTexelFormat srcFormat, bool srcPremultiplied,
|
|
|
|
WebGLTexelFormat dstFormat, bool dstPremultiplied,
|
2010-10-16 01:50:15 +04:00
|
|
|
size_t dstTexelSize);
|
|
|
|
|
2012-05-31 22:16:48 +04:00
|
|
|
template<class ElementType>
|
2014-11-14 07:03:50 +03:00
|
|
|
nsLayoutUtils::SurfaceFromElementResult
|
|
|
|
SurfaceFromElement(ElementType* element) {
|
|
|
|
MOZ_ASSERT(element);
|
2012-05-31 22:16:48 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
uint32_t flags = nsLayoutUtils::SFE_WANT_IMAGE_SURFACE;
|
2012-05-31 22:16:48 +04:00
|
|
|
if (mPixelStoreColorspaceConversion == LOCAL_GL_NONE)
|
|
|
|
flags |= nsLayoutUtils::SFE_NO_COLORSPACE_CONVERSION;
|
|
|
|
if (!mPixelStorePremultiplyAlpha)
|
2014-04-17 09:29:52 +04:00
|
|
|
flags |= nsLayoutUtils::SFE_PREFER_NO_PREMULTIPLY_ALPHA;
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
return nsLayoutUtils::SurfaceFromElement(element, flags);
|
2012-05-31 22:16:48 +04:00
|
|
|
}
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2012-12-31 22:48:55 +04:00
|
|
|
template<class ElementType>
|
2014-11-14 07:03:50 +03:00
|
|
|
nsLayoutUtils::SurfaceFromElementResult
|
|
|
|
SurfaceFromElement(ElementType& element) {
|
|
|
|
return SurfaceFromElement(&element);
|
2012-12-31 22:48:55 +04:00
|
|
|
}
|
2012-05-31 22:16:48 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
nsresult
|
|
|
|
SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromElementResult& res,
|
|
|
|
RefPtr<gfx::DataSourceSurface>& imageOut,
|
|
|
|
WebGLTexelFormat* format);
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
// Returns false if `object` is null or not valid.
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateObject(const char* info, ObjectType* object);
|
|
|
|
|
|
|
|
// Returns false if `object` is not valid. Considers null to be valid.
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateObjectAllowNull(const char* info, ObjectType* object);
|
|
|
|
|
|
|
|
// Returns false if `object` is not valid, but considers deleted objects and
|
|
|
|
// null objects valid.
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateObjectAllowDeletedOrNull(const char* info, ObjectType* object);
|
|
|
|
|
|
|
|
// Returns false if `object` is null or not valid, but considers deleted
|
2012-05-04 20:38:44 +04:00
|
|
|
// objects valid.
|
|
|
|
template<class ObjectType>
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateObjectAllowDeleted(const char* info, ObjectType* object);
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
private:
|
2014-11-14 07:03:50 +03:00
|
|
|
// Like ValidateObject, but only for cases when `object` is known to not be
|
|
|
|
// null already.
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
2014-11-14 07:03:50 +03:00
|
|
|
bool ValidateObjectAssumeNonNull(const char* info, ObjectType* object);
|
2010-06-04 23:03:37 +04:00
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
private:
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Context customization points
|
2015-06-01 09:49:47 +03:00
|
|
|
virtual WebGLVertexArray* CreateVertexArrayImpl();
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
virtual bool ValidateAttribPointerType(bool integerMode, GLenum type, GLsizei* alignment, const char* info) = 0;
|
2014-11-26 05:00:06 +03:00
|
|
|
virtual bool ValidateBufferTarget(GLenum target, const char* info) = 0;
|
|
|
|
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) = 0;
|
2015-05-21 02:59:14 +03:00
|
|
|
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info);
|
2015-02-03 05:06:20 +03:00
|
|
|
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) = 0;
|
2015-04-17 04:17:07 +03:00
|
|
|
virtual bool ValidateQueryTarget(GLenum usage, const char* info) = 0;
|
2015-03-23 04:29:32 +03:00
|
|
|
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) = 0;
|
2014-06-24 04:56:21 +04:00
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
protected:
|
2014-09-19 03:14:22 +04:00
|
|
|
int32_t MaxTextureSizeForTarget(TexTarget target) const {
|
2014-11-14 07:03:50 +03:00
|
|
|
return (target == LOCAL_GL_TEXTURE_2D) ? mGLMaxTextureSize
|
|
|
|
: mGLMaxCubeMapTextureSize;
|
2011-02-25 01:17:34 +03:00
|
|
|
}
|
2014-01-23 07:59:33 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
int32_t
|
|
|
|
MaxTextureLevelForTexImageTarget(TexImageTarget texImageTarget) const {
|
2014-09-19 03:14:22 +04:00
|
|
|
const TexTarget target = TexImageTargetToTexTarget(texImageTarget);
|
2014-11-14 07:03:50 +03:00
|
|
|
return (target == LOCAL_GL_TEXTURE_2D) ? mGLMaxTextureSizeLog2
|
|
|
|
: mGLMaxCubeMapTextureSizeLog2;
|
2014-09-03 23:17:18 +04:00
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
/** Like glBufferData, but if the call may change the buffer size, checks
|
|
|
|
* any GL error generated by this glBufferData call and returns it.
|
|
|
|
*/
|
|
|
|
GLenum CheckedBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
|
2011-07-08 04:01:16 +04:00
|
|
|
GLenum usage);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
void ForceLoseContext(bool simulateLoss = false);
|
2011-10-27 00:00:44 +04:00
|
|
|
void ForceRestoreContext();
|
|
|
|
|
2011-12-04 23:15:42 +04:00
|
|
|
nsTArray<WebGLRefPtr<WebGLTexture> > mBound2DTextures;
|
|
|
|
nsTArray<WebGLRefPtr<WebGLTexture> > mBoundCubeMapTextures;
|
2014-10-14 03:42:20 +04:00
|
|
|
nsTArray<WebGLRefPtr<WebGLTexture> > mBound3DTextures;
|
2015-06-09 03:18:19 +03:00
|
|
|
nsTArray<WebGLRefPtr<WebGLSampler> > mBoundSamplers;
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2015-04-07 05:05:11 +03:00
|
|
|
void ResolveTexturesForDraw() const;
|
|
|
|
|
2011-12-04 23:15:42 +04:00
|
|
|
WebGLRefPtr<WebGLProgram> mCurrentProgram;
|
2015-01-16 02:40:39 +03:00
|
|
|
RefPtr<const webgl::LinkedProgramInfo> mActiveProgramLinkInfo;
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2015-02-19 03:57:05 +03:00
|
|
|
GLenum LastColorAttachment() const {
|
2015-07-17 03:14:12 +03:00
|
|
|
return LOCAL_GL_COLOR_ATTACHMENT0 + mGLMaxColorAttachments - 1;
|
2015-02-19 03:57:05 +03:00
|
|
|
}
|
|
|
|
|
2015-01-13 02:05:21 +03:00
|
|
|
bool ValidateFramebufferTarget(GLenum target, const char* const info);
|
|
|
|
|
|
|
|
WebGLRefPtr<WebGLFramebuffer> mBoundDrawFramebuffer;
|
|
|
|
WebGLRefPtr<WebGLFramebuffer> mBoundReadFramebuffer;
|
2011-12-04 23:15:42 +04:00
|
|
|
WebGLRefPtr<WebGLRenderbuffer> mBoundRenderbuffer;
|
2014-11-26 05:00:06 +03:00
|
|
|
WebGLRefPtr<WebGLTransformFeedback> mBoundTransformFeedback;
|
2013-06-28 01:07:21 +04:00
|
|
|
WebGLRefPtr<WebGLVertexArray> mBoundVertexArray;
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2012-05-29 22:44:31 +04:00
|
|
|
LinkedList<WebGLTexture> mTextures;
|
|
|
|
LinkedList<WebGLBuffer> mBuffers;
|
|
|
|
LinkedList<WebGLProgram> mPrograms;
|
2013-08-07 01:23:46 +04:00
|
|
|
LinkedList<WebGLQuery> mQueries;
|
2012-05-29 22:44:31 +04:00
|
|
|
LinkedList<WebGLShader> mShaders;
|
|
|
|
LinkedList<WebGLRenderbuffer> mRenderbuffers;
|
|
|
|
LinkedList<WebGLFramebuffer> mFramebuffers;
|
2013-06-28 01:07:21 +04:00
|
|
|
LinkedList<WebGLVertexArray> mVertexArrays;
|
|
|
|
|
2014-10-27 02:40:37 +03:00
|
|
|
// TODO(djg): Does this need a rethink? Should it be WebGL2Context?
|
|
|
|
LinkedList<WebGLSampler> mSamplers;
|
2014-11-26 05:00:06 +03:00
|
|
|
LinkedList<WebGLTransformFeedback> mTransformFeedbacks;
|
2014-10-27 02:40:37 +03:00
|
|
|
|
2014-11-26 05:00:06 +03:00
|
|
|
WebGLRefPtr<WebGLTransformFeedback> mDefaultTransformFeedback;
|
2014-12-05 10:04:55 +03:00
|
|
|
WebGLRefPtr<WebGLVertexArray> mDefaultVertexArray;
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2010-10-16 01:50:15 +04:00
|
|
|
// PixelStore parameters
|
2014-11-14 07:03:50 +03:00
|
|
|
uint32_t mPixelStorePackAlignment;
|
|
|
|
uint32_t mPixelStoreUnpackAlignment;
|
|
|
|
uint32_t mPixelStoreColorspaceConversion;
|
|
|
|
bool mPixelStoreFlipY;
|
|
|
|
bool mPixelStorePremultiplyAlpha;
|
2010-06-15 19:59:39 +04:00
|
|
|
|
2013-10-11 17:16:43 +04:00
|
|
|
WebGLContextFakeBlackStatus mFakeBlackStatus;
|
2010-08-24 01:03:53 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
class FakeBlackTexture {
|
|
|
|
gl::GLContext* const mGL;
|
2013-10-11 17:16:43 +04:00
|
|
|
GLuint mGLName;
|
|
|
|
|
|
|
|
public:
|
2014-09-27 00:11:51 +04:00
|
|
|
FakeBlackTexture(gl::GLContext* gl, TexTarget target, GLenum format);
|
2013-10-11 17:16:43 +04:00
|
|
|
~FakeBlackTexture();
|
|
|
|
GLuint GLName() const { return mGLName; }
|
|
|
|
};
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
UniquePtr<FakeBlackTexture> mBlackOpaqueTexture2D;
|
|
|
|
UniquePtr<FakeBlackTexture> mBlackOpaqueTextureCubeMap;
|
|
|
|
UniquePtr<FakeBlackTexture> mBlackTransparentTexture2D;
|
|
|
|
UniquePtr<FakeBlackTexture> mBlackTransparentTextureCubeMap;
|
2013-10-11 17:16:43 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
void
|
|
|
|
BindFakeBlackTexturesHelper(GLenum target,
|
|
|
|
const nsTArray<WebGLRefPtr<WebGLTexture> >& boundTexturesArray,
|
|
|
|
UniquePtr<FakeBlackTexture>& opaqueTextureScopedPtr,
|
|
|
|
UniquePtr<FakeBlackTexture>& transparentTextureScopedPtr);
|
2010-08-24 01:03:53 +04:00
|
|
|
|
2015-07-20 10:56:17 +03:00
|
|
|
// Generic Vertex Attributes
|
|
|
|
UniquePtr<GLenum[]> mVertexAttribType;
|
2013-09-04 16:14:43 +04:00
|
|
|
GLfloat mVertexAttrib0Vector[4];
|
|
|
|
GLfloat mFakeVertexAttrib0BufferObjectVector[4];
|
2011-02-25 01:17:34 +03:00
|
|
|
size_t mFakeVertexAttrib0BufferObjectSize;
|
|
|
|
GLuint mFakeVertexAttrib0BufferObject;
|
2013-10-11 17:16:43 +04:00
|
|
|
WebGLVertexAttrib0Status mFakeVertexAttrib0BufferStatus;
|
2010-09-02 18:34:08 +04:00
|
|
|
|
2015-07-20 10:56:17 +03:00
|
|
|
void GetVertexAttribFloat(GLuint index, GLfloat* out_result);
|
|
|
|
void GetVertexAttribInt(GLuint index, GLint* out_result);
|
|
|
|
void GetVertexAttribUint(GLuint index, GLuint* out_result);
|
|
|
|
JSObject* GetVertexAttribFloat32Array(JSContext* cx, GLuint index);
|
|
|
|
JSObject* GetVertexAttribInt32Array(JSContext* cx, GLuint index);
|
|
|
|
JSObject* GetVertexAttribUint32Array(JSContext* cx, GLuint index);
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
GLint mStencilRefFront;
|
|
|
|
GLint mStencilRefBack;
|
|
|
|
GLuint mStencilValueMaskFront;
|
|
|
|
GLuint mStencilValueMaskBack;
|
|
|
|
GLuint mStencilWriteMaskFront;
|
|
|
|
GLuint mStencilWriteMaskBack;
|
2011-05-20 23:53:53 +04:00
|
|
|
realGLboolean mColorWriteMask[4];
|
|
|
|
realGLboolean mDepthWriteMask;
|
2013-09-04 16:14:43 +04:00
|
|
|
GLfloat mColorClearValue[4];
|
|
|
|
GLint mStencilClearValue;
|
|
|
|
GLfloat mDepthClearValue;
|
2010-12-06 14:34:35 +03:00
|
|
|
|
2014-01-10 17:41:04 +04:00
|
|
|
GLint mViewportX;
|
|
|
|
GLint mViewportY;
|
|
|
|
GLsizei mViewportWidth;
|
|
|
|
GLsizei mViewportHeight;
|
|
|
|
bool mAlreadyWarnedAboutViewportLargerThanDest;
|
|
|
|
|
2014-08-22 20:55:00 +04:00
|
|
|
RefPtr<WebGLContextLossHandler> mContextLossHandler;
|
2014-06-03 01:40:15 +04:00
|
|
|
bool mAllowContextRestore;
|
|
|
|
bool mLastLossWasSimulated;
|
2012-01-05 01:12:03 +04:00
|
|
|
ContextStatus mContextStatus;
|
|
|
|
bool mContextLostErrorSet;
|
2012-03-01 00:49:55 +04:00
|
|
|
|
2013-05-22 11:05:38 +04:00
|
|
|
// Used for some hardware (particularly Tegra 2 and 4) that likes to
|
|
|
|
// be Flushed while doing hundreds of draw calls.
|
|
|
|
int mDrawCallsSinceLastFlush;
|
|
|
|
|
2012-05-29 22:44:31 +04:00
|
|
|
int mAlreadyGeneratedWarnings;
|
2013-06-04 23:44:08 +04:00
|
|
|
int mMaxWarnings;
|
2012-07-25 20:13:45 +04:00
|
|
|
bool mAlreadyWarnedAboutFakeVertexAttrib0;
|
2012-05-29 22:44:31 +04:00
|
|
|
|
2013-09-04 16:14:50 +04:00
|
|
|
bool ShouldGenerateWarnings() const;
|
2012-05-23 20:07:10 +04:00
|
|
|
|
2012-08-03 01:28:02 +04:00
|
|
|
uint64_t mLastUseIndex;
|
|
|
|
|
2014-10-02 04:05:34 +04:00
|
|
|
bool mNeedsFakeNoAlpha;
|
2015-03-12 04:23:56 +03:00
|
|
|
bool mNeedsFakeNoStencil;
|
2014-10-02 04:05:34 +04:00
|
|
|
|
|
|
|
struct ScopedMaskWorkaround {
|
|
|
|
WebGLContext& mWebGL;
|
2015-03-12 04:23:56 +03:00
|
|
|
const bool mFakeNoAlpha;
|
|
|
|
const bool mFakeNoStencil;
|
2014-10-02 04:05:34 +04:00
|
|
|
|
2015-03-12 04:23:56 +03:00
|
|
|
static bool ShouldFakeNoAlpha(WebGLContext& webgl) {
|
2015-01-27 05:27:24 +03:00
|
|
|
// We should only be doing this if we're about to draw to the backbuffer, but
|
|
|
|
// the backbuffer needs to have this fake-no-alpha workaround.
|
|
|
|
return !webgl.mBoundDrawFramebuffer &&
|
|
|
|
webgl.mNeedsFakeNoAlpha &&
|
2014-10-02 04:05:34 +04:00
|
|
|
webgl.mColorWriteMask[3] != false;
|
|
|
|
}
|
|
|
|
|
2015-03-12 04:23:56 +03:00
|
|
|
static bool ShouldFakeNoStencil(WebGLContext& webgl) {
|
|
|
|
// We should only be doing this if we're about to draw to the backbuffer.
|
|
|
|
return !webgl.mBoundDrawFramebuffer &&
|
|
|
|
webgl.mNeedsFakeNoStencil &&
|
|
|
|
webgl.mStencilTestEnabled;
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
explicit ScopedMaskWorkaround(WebGLContext& webgl);
|
2014-10-02 04:05:34 +04:00
|
|
|
|
|
|
|
~ScopedMaskWorkaround();
|
|
|
|
};
|
|
|
|
|
2012-08-03 01:28:02 +04:00
|
|
|
void LoseOldestWebGLContextIfLimitExceeded();
|
|
|
|
void UpdateLastUseIndex();
|
|
|
|
|
2012-10-05 00:35:54 +04:00
|
|
|
template <typename WebGLObjectType>
|
2014-11-14 07:03:50 +03:00
|
|
|
JS::Value WebGLObjectAsJSValue(JSContext* cx, const WebGLObjectType*,
|
|
|
|
ErrorResult& rv) const;
|
2012-10-05 00:35:54 +04:00
|
|
|
template <typename WebGLObjectType>
|
2014-11-14 07:03:50 +03:00
|
|
|
JSObject* WebGLObjectAsJSObject(JSContext* cx, const WebGLObjectType*,
|
|
|
|
ErrorResult& rv) const;
|
2012-10-05 00:35:54 +04:00
|
|
|
|
2012-03-01 00:49:55 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// see bug 713305. This RAII helper guarantees that we're on the discrete GPU, during its lifetime
|
|
|
|
// Debouncing note: we don't want to switch GPUs too frequently, so try to not create and destroy
|
|
|
|
// these objects at high frequency. Having WebGLContext's hold one such object seems fine,
|
|
|
|
// because WebGLContext objects only go away during GC, which shouldn't happen too frequently.
|
|
|
|
// If in the future GC becomes much more frequent, we may have to revisit then (maybe use a timer).
|
|
|
|
ForceDiscreteGPUHelperCGL mForceDiscreteGPUHelper;
|
|
|
|
#endif
|
|
|
|
|
2014-06-23 03:16:00 +04:00
|
|
|
nsRefPtr<WebGLObserver> mContextObserver;
|
2011-10-27 00:00:44 +04:00
|
|
|
|
2010-05-20 00:46:08 +04:00
|
|
|
public:
|
2009-09-03 04:47:49 +04:00
|
|
|
// console logging helpers
|
2014-11-14 07:03:50 +03:00
|
|
|
void GenerateWarning(const char* fmt, ...);
|
|
|
|
void GenerateWarning(const char* fmt, va_list ap);
|
2010-08-24 01:03:53 +04:00
|
|
|
|
2015-08-04 06:39:47 +03:00
|
|
|
public:
|
2015-07-11 02:34:45 +03:00
|
|
|
UniquePtr<webgl::FormatUsageAuthority> mFormatUsage;
|
2015-08-04 06:39:47 +03:00
|
|
|
virtual UniquePtr<webgl::FormatUsageAuthority> CreateFormatUsage() const = 0;
|
2015-07-11 02:34:45 +03:00
|
|
|
|
|
|
|
// Friend list
|
2010-08-24 01:03:53 +04:00
|
|
|
friend class WebGLTexture;
|
2010-11-05 22:57:58 +03:00
|
|
|
friend class WebGLFramebuffer;
|
2011-12-04 23:15:42 +04:00
|
|
|
friend class WebGLRenderbuffer;
|
2011-11-03 18:50:40 +04:00
|
|
|
friend class WebGLProgram;
|
2013-08-07 01:23:46 +04:00
|
|
|
friend class WebGLQuery;
|
2011-12-04 23:15:42 +04:00
|
|
|
friend class WebGLBuffer;
|
2014-10-27 02:40:37 +03:00
|
|
|
friend class WebGLSampler;
|
2011-12-04 23:15:42 +04:00
|
|
|
friend class WebGLShader;
|
2014-06-18 08:25:53 +04:00
|
|
|
friend class WebGLSync;
|
2015-05-27 14:12:00 +03:00
|
|
|
friend class WebGLTimerQuery;
|
2014-11-26 05:00:06 +03:00
|
|
|
friend class WebGLTransformFeedback;
|
2011-12-04 23:15:43 +04:00
|
|
|
friend class WebGLUniformLocation;
|
2013-06-28 01:07:21 +04:00
|
|
|
friend class WebGLVertexArray;
|
2014-06-06 03:38:27 +04:00
|
|
|
friend class WebGLVertexArrayFake;
|
|
|
|
friend class WebGLVertexArrayGL;
|
2009-09-03 04:47:49 +04:00
|
|
|
};
|
|
|
|
|
2012-10-04 01:13:05 +04:00
|
|
|
// used by DOM bindings in conjunction with GetParentObject
|
|
|
|
inline nsISupports*
|
2014-11-14 07:03:50 +03:00
|
|
|
ToSupports(WebGLContext* webgl)
|
2012-10-04 01:13:05 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
return static_cast<nsIDOMWebGLRenderingContext*>(webgl);
|
2012-10-04 01:13:05 +04:00
|
|
|
}
|
|
|
|
|
2010-06-04 23:03:37 +04:00
|
|
|
/**
|
|
|
|
** Template implementations
|
|
|
|
**/
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
2011-09-29 10:19:26 +04:00
|
|
|
inline bool
|
2012-05-04 20:38:44 +04:00
|
|
|
WebGLContext::ValidateObjectAllowDeletedOrNull(const char* info,
|
2014-11-14 07:03:50 +03:00
|
|
|
ObjectType* object)
|
2010-06-04 23:03:37 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
if (object && !object->IsCompatibleWithContext(this)) {
|
2012-05-04 20:38:44 +04:00
|
|
|
ErrorInvalidOperation("%s: object from different WebGL context "
|
|
|
|
"(or older generation of this one) "
|
|
|
|
"passed as argument", info);
|
|
|
|
return false;
|
2010-06-04 23:03:37 +04:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-04 23:03:37 +04:00
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
|
|
|
inline bool
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ValidateObjectAssumeNonNull(const char* info, ObjectType* object)
|
2012-05-04 20:38:44 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
MOZ_ASSERT(object);
|
2010-06-04 23:03:37 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
if (!ValidateObjectAllowDeletedOrNull(info, object))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-06-04 23:03:37 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
if (object->IsDeleted()) {
|
2015-01-16 02:40:39 +03:00
|
|
|
ErrorInvalidValue("%s: Deleted object passed as argument.", info);
|
2012-05-04 20:38:44 +04:00
|
|
|
return false;
|
2010-06-04 23:03:37 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-06-04 23:03:37 +04:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
2011-09-29 10:19:26 +04:00
|
|
|
inline bool
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ValidateObjectAllowNull(const char* info, ObjectType* object)
|
2010-06-04 23:03:37 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
if (!object)
|
2012-05-04 20:38:44 +04:00
|
|
|
return true;
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
return ValidateObjectAssumeNonNull(info, object);
|
2010-06-04 23:03:37 +04:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
2011-09-29 10:19:26 +04:00
|
|
|
inline bool
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ValidateObjectAllowDeleted(const char* info, ObjectType* object)
|
2010-06-04 23:03:37 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
if (!object) {
|
2012-05-04 20:38:44 +04:00
|
|
|
ErrorInvalidValue("%s: null object passed as argument", info);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
return ValidateObjectAllowDeletedOrNull(info, object);
|
2010-06-04 23:03:37 +04:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
template<class ObjectType>
|
2011-09-29 10:19:26 +04:00
|
|
|
inline bool
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ValidateObject(const char* info, ObjectType* object)
|
2010-06-04 23:03:37 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
if (!object) {
|
2012-05-04 20:38:44 +04:00
|
|
|
ErrorInvalidValue("%s: null object passed as argument", info);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
return ValidateObjectAssumeNonNull(info, object);
|
2010-06-04 23:03:37 +04:00
|
|
|
}
|
|
|
|
|
2014-06-23 03:16:00 +04:00
|
|
|
// Listen visibilitychange and memory-pressure event for context lose/restore
|
2015-03-21 19:28:04 +03:00
|
|
|
class WebGLObserver final
|
2012-04-22 00:48:22 +04:00
|
|
|
: public nsIObserver
|
2014-06-23 03:16:00 +04:00
|
|
|
, public nsIDOMEventListener
|
2012-04-22 00:48:22 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-06-23 03:16:00 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2012-04-22 00:48:22 +04:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
explicit WebGLObserver(WebGLContext* webgl);
|
2014-06-23 03:16:00 +04:00
|
|
|
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
void RegisterVisibilityChangeEvent();
|
|
|
|
void UnregisterVisibilityChangeEvent();
|
|
|
|
|
|
|
|
void RegisterMemoryPressureEvent();
|
|
|
|
void UnregisterMemoryPressureEvent();
|
2012-04-22 00:48:22 +04:00
|
|
|
|
|
|
|
private:
|
2014-07-06 00:35:35 +04:00
|
|
|
~WebGLObserver();
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext* mWebGL;
|
2012-04-22 00:48:22 +04:00
|
|
|
};
|
|
|
|
|
2015-02-25 01:09:09 +03:00
|
|
|
size_t RoundUpToMultipleOf(size_t value, size_t multiple);
|
|
|
|
|
2015-08-04 00:34:46 +03:00
|
|
|
bool
|
|
|
|
ValidateTexTarget(WebGLContext* webgl, GLenum rawTexTarget, const char* funcName,
|
|
|
|
TexTarget* const out_texTarget, WebGLTexture** const out_tex);
|
|
|
|
bool
|
|
|
|
ValidateTexImageTarget(WebGLContext* webgl, GLenum rawTexImageTarget,
|
|
|
|
const char* funcName, TexImageTarget* const out_texImageTarget,
|
|
|
|
WebGLTexture** const out_tex);
|
|
|
|
|
|
|
|
// Returns x rounded to the next highest multiple of y.
|
|
|
|
CheckedUint32 RoundedToNextMultipleOf(CheckedUint32 x, CheckedUint32 y);
|
|
|
|
|
2012-11-15 11:32:39 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-09-03 04:47:49 +04:00
|
|
|
#endif
|