зеркало из https://github.com/mozilla/gecko-dev.git
Bug 779611 - part 8 - port WebGLShader and WebGLProgram to WebIDL bindings - r=bz
This commit is contained in:
Родитель
19d4659685
Коммит
d0d8da9931
|
@ -60,7 +60,9 @@ CPPSRCS += \
|
|||
WebGLExtensionTextureFilterAnisotropic.cpp \
|
||||
WebGLExtensionTextureFloat.cpp \
|
||||
WebGLFramebuffer.cpp \
|
||||
WebGLProgram.cpp \
|
||||
WebGLRenderbuffer.cpp \
|
||||
WebGLShader.cpp \
|
||||
WebGLTexelConversions.cpp \
|
||||
WebGLTexture.cpp \
|
||||
$(NULL)
|
||||
|
|
|
@ -1390,30 +1390,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLContext)
|
|||
nsICanvasRenderingContextInternal)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
// WebGLProgram
|
||||
|
||||
NS_IMPL_ADDREF(WebGLProgram)
|
||||
NS_IMPL_RELEASE(WebGLProgram)
|
||||
|
||||
DOMCI_DATA(WebGLProgram, WebGLProgram)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(WebGLProgram)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebGLProgram)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WebGLProgram)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(WebGLShader)
|
||||
NS_IMPL_RELEASE(WebGLShader)
|
||||
|
||||
DOMCI_DATA(WebGLShader, WebGLShader)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(WebGLShader)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebGLShader)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WebGLShader)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
// WebGLUniformLocation
|
||||
|
||||
NS_IMPL_ADDREF(WebGLUniformLocation)
|
||||
|
@ -1457,15 +1433,6 @@ NS_INTERFACE_MAP_BEGIN(WebGLActiveInfo)
|
|||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WebGLActiveInfo)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
#define NAME_NOT_SUPPORTED(base) \
|
||||
NS_IMETHODIMP base::GetName(WebGLuint *aName) \
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; } \
|
||||
NS_IMETHODIMP base::SetName(WebGLuint aName) \
|
||||
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
NAME_NOT_SUPPORTED(WebGLProgram)
|
||||
NAME_NOT_SUPPORTED(WebGLShader)
|
||||
|
||||
/* readonly attribute WebGLint size; */
|
||||
NS_IMETHODIMP
|
||||
WebGLActiveInfo::GetSize(WebGLint *aSize)
|
||||
|
|
|
@ -2099,10 +2099,11 @@ struct WebGLUniformInfo {
|
|||
};
|
||||
|
||||
class WebGLShader MOZ_FINAL
|
||||
: public nsIWebGLShader
|
||||
: public nsISupports
|
||||
, public WebGLRefCountedObject<WebGLShader>
|
||||
, public LinkedListElement<WebGLShader>
|
||||
, public WebGLContextBoundObject
|
||||
, public nsWrapperCache
|
||||
{
|
||||
friend class WebGLContext;
|
||||
friend class WebGLProgram;
|
||||
|
@ -2115,6 +2116,7 @@ public:
|
|||
, mAttribMaxNameLength(0)
|
||||
, mCompileStatus(false)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
mContext->MakeContextCurrent();
|
||||
mGLName = mContext->gl->fCreateShader(mType);
|
||||
mContext->mShaders.insertBack(this);
|
||||
|
@ -2170,8 +2172,14 @@ public:
|
|||
|
||||
const nsCString& TranslationLog() const { return mTranslationLog; }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBGLSHADER
|
||||
WebGLContext *GetParentObject() const {
|
||||
return Context();
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLShader)
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -2223,13 +2231,12 @@ static bool SplitLastSquareBracket(nsACString& string, nsCString& bracketPart)
|
|||
typedef nsDataHashtable<nsCStringHashKey, nsCString> CStringMap;
|
||||
typedef nsDataHashtable<nsCStringHashKey, WebGLUniformInfo> CStringToUniformInfoMap;
|
||||
|
||||
// NOTE: When this class is switched to new DOM bindings, update the
|
||||
// (then-slow) WrapObject call in GetParameter.
|
||||
class WebGLProgram MOZ_FINAL
|
||||
: public nsIWebGLProgram
|
||||
: public nsISupports
|
||||
, public WebGLRefCountedObject<WebGLProgram>
|
||||
, public LinkedListElement<WebGLProgram>
|
||||
, public WebGLContextBoundObject
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
WebGLProgram(WebGLContext *context)
|
||||
|
@ -2238,6 +2245,7 @@ public:
|
|||
, mGeneration(0)
|
||||
, mAttribMaxNameLength(0)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
mContext->MakeContextCurrent();
|
||||
mGLName = mContext->gl->fCreateProgram();
|
||||
mContext->mPrograms.insertBack(this);
|
||||
|
@ -2481,8 +2489,14 @@ public:
|
|||
return info;
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBGLPROGRAM
|
||||
WebGLContext *GetParentObject() const {
|
||||
return Context();
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLProgram)
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -2157,12 +2157,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
|
|||
|
||||
case LOCAL_GL_CURRENT_PROGRAM:
|
||||
{
|
||||
JS::Value v;
|
||||
if (!dom::WrapObject(cx, GetWrapper(), mCurrentProgram.get(), &v)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
return JS::NullValue();
|
||||
}
|
||||
return v;
|
||||
return WebGLObjectAsJSValue(cx, mCurrentProgram.get(), rv);
|
||||
}
|
||||
|
||||
case LOCAL_GL_TEXTURE_BINDING_2D:
|
||||
|
|
|
@ -10,6 +10,4 @@
|
|||
|
||||
DUMMY(NS_NewCanvasRenderingContextWebGL, nsIDOMWebGLRenderingContext)
|
||||
|
||||
DOMCI_DATA(WebGLProgram, void)
|
||||
DOMCI_DATA(WebGLShader, void)
|
||||
DOMCI_DATA(WebGLActiveInfo, void)
|
|
@ -0,0 +1,24 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
JSObject*
|
||||
WebGLProgram::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap) {
|
||||
return dom::WebGLProgramBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLProgram)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLProgram)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLProgram)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLProgram)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
|
@ -0,0 +1,24 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WebGLContext.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
JSObject*
|
||||
WebGLShader::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap) {
|
||||
return dom::WebGLShaderBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLShader)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLShader)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLShader)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLShader)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
|
@ -1559,10 +1559,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(MathMLElement, Element, nsElementSH,
|
||||
ELEMENT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(WebGLProgram, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(WebGLShader, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(WebGLActiveInfo, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
|
@ -4208,14 +4204,6 @@ nsDOMClassInfo::Init()
|
|||
nsDOMTouchEvent::PrefEnabled())
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(WebGLProgram, nsIWebGLProgram)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIWebGLProgram)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(WebGLShader, nsIWebGLShader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIWebGLShader)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(WebGLActiveInfo, nsIWebGLActiveInfo)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIWebGLActiveInfo)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
|
|
@ -447,8 +447,6 @@ DOMCI_CLASS(SimpleGestureEvent)
|
|||
DOMCI_CLASS(MathMLElement)
|
||||
|
||||
// WebGL
|
||||
DOMCI_CLASS(WebGLProgram)
|
||||
DOMCI_CLASS(WebGLShader)
|
||||
DOMCI_CLASS(WebGLActiveInfo)
|
||||
|
||||
DOMCI_CLASS(PaintRequest)
|
||||
|
|
|
@ -392,6 +392,11 @@ DOMInterfaces = {
|
|||
'headerFile': 'WebGLContext.h'
|
||||
},
|
||||
|
||||
'WebGLProgram': {
|
||||
'nativeType': 'mozilla::WebGLProgram',
|
||||
'headerFile': 'WebGLContext.h'
|
||||
},
|
||||
|
||||
'WebGLRenderbuffer': {
|
||||
'nativeType': 'mozilla::WebGLRenderbuffer',
|
||||
'headerFile': 'WebGLContext.h'
|
||||
|
@ -405,6 +410,11 @@ DOMInterfaces = {
|
|||
'implicitJSContext': [ 'texImage2D', 'texSubImage2D' ],
|
||||
},
|
||||
|
||||
'WebGLShader': {
|
||||
'nativeType': 'mozilla::WebGLShader',
|
||||
'headerFile': 'WebGLContext.h'
|
||||
},
|
||||
|
||||
'WebGLShaderPrecisionFormat': {
|
||||
'nativeType': 'mozilla::WebGLShaderPrecisionFormat',
|
||||
'headerFile': 'WebGLContext.h',
|
||||
|
@ -604,9 +614,5 @@ addExternalIface('WebGLActiveInfo', nativeType='mozilla::WebGLActiveInfo',
|
|||
headerFile='WebGLContext.h')
|
||||
addExternalIface('WebGLContextAttributes', nativeType='JSObject',
|
||||
headerFile='jsapi.h')
|
||||
addExternalIface('WebGLProgram', nativeType='mozilla::WebGLProgram',
|
||||
headerFile='WebGLContext.h')
|
||||
addExternalIface('WebGLShader', nativeType='mozilla::WebGLShader',
|
||||
headerFile='WebGLContext.h')
|
||||
addExternalIface('Window')
|
||||
addExternalIface('XULElement')
|
||||
|
|
|
@ -44,25 +44,6 @@ class Element;
|
|||
// OpenGL object wrappers
|
||||
//
|
||||
|
||||
[scriptable, builtinclass, uuid(a6a19e74-8305-11de-9ce9-000c29206271)]
|
||||
interface nsIWebGLProgram : nsISupports
|
||||
{
|
||||
[noscript] attribute WebGLuint name;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(ac7440a4-8305-11de-807b-000c29206271)]
|
||||
interface nsIWebGLShader : nsISupports
|
||||
{
|
||||
[noscript] attribute WebGLuint name;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(beea4b38-3094-4e8d-b6e6-8b21d07e8994)]
|
||||
interface nsIWebGLShaderArray : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long length;
|
||||
nsIWebGLShader item(in unsigned long index);
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(a85d4fd0-5b9f-4cb8-aeee-5a2c5c5bad76)]
|
||||
interface nsIWebGLActiveInfo : nsISupports
|
||||
{
|
||||
|
|
|
@ -55,12 +55,14 @@ interface WebGLBuffer {
|
|||
interface WebGLFramebuffer {
|
||||
};
|
||||
|
||||
interface WebGLProgram;
|
||||
interface WebGLProgram {
|
||||
};
|
||||
|
||||
interface WebGLRenderbuffer {
|
||||
};
|
||||
|
||||
interface WebGLShader;
|
||||
interface WebGLShader {
|
||||
};
|
||||
|
||||
interface WebGLTexture {
|
||||
};
|
||||
|
|
|
@ -461,9 +461,6 @@ irregularFilenames = {
|
|||
|
||||
'nsIDOMBlob': 'nsIDOMFile',
|
||||
|
||||
'nsIWebGLProgram': 'nsIDOMWebGLRenderingContext',
|
||||
'nsIWebGLShader': 'nsIDOMWebGLRenderingContext',
|
||||
'nsIWebGLShaderArray': 'nsIDOMWebGLRenderingContext',
|
||||
'nsIWebGLActiveInfo': 'nsIDOMWebGLRenderingContext',
|
||||
|
||||
'nsIIndexedDatabaseUsageCallback': 'nsIIndexedDatabaseManager',
|
||||
|
|
Загрузка…
Ссылка в новой задаче