[webgl] Reland earlier-backed out patches, b=520708, b=520920, b=522201; r=me/mwsteele
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#ifndef WEBGLARRAY_H_
|
#ifndef WEBGLARRAY_H_
|
||||||
#define WEBGLARRAY_H_
|
#define WEBGLARRAY_H_
|
||||||
|
|
||||||
|
nsresult NS_NewCanvasArrayBuffer(nsISupports **aNewObject);
|
||||||
nsresult NS_NewCanvasFloatArray(nsISupports **aNewObject);
|
nsresult NS_NewCanvasFloatArray(nsISupports **aNewObject);
|
||||||
nsresult NS_NewCanvasByteArray(nsISupports **aNewObject);
|
nsresult NS_NewCanvasByteArray(nsISupports **aNewObject);
|
||||||
nsresult NS_NewCanvasUnsignedByteArray(nsISupports **aNewObject);
|
nsresult NS_NewCanvasUnsignedByteArray(nsISupports **aNewObject);
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ CPPSRCS = \
|
|||||||
ifdef MOZ_WEBGL
|
ifdef MOZ_WEBGL
|
||||||
|
|
||||||
CPPSRCS += \
|
CPPSRCS += \
|
||||||
|
WebGLArrays.cpp \
|
||||||
WebGLContext.cpp \
|
WebGLContext.cpp \
|
||||||
WebGLContextGL.cpp \
|
WebGLContextGL.cpp \
|
||||||
WebGLContextUtils.cpp \
|
WebGLContextUtils.cpp \
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
if (type == LOCAL_GL_INT) return sizeof(int);
|
if (type == LOCAL_GL_INT) return sizeof(int);
|
||||||
if (type == LOCAL_GL_UNSIGNED_INT) return sizeof(unsigned int);
|
if (type == LOCAL_GL_UNSIGNED_INT) return sizeof(unsigned int);
|
||||||
if (type == LOCAL_GL_DOUBLE) return sizeof(double);
|
if (type == LOCAL_GL_DOUBLE) return sizeof(double);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear() {
|
void Clear() {
|
||||||
@@ -118,6 +118,10 @@ public:
|
|||||||
data = nsnull;
|
data = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Zero() {
|
||||||
|
memset(data, 0, capacity);
|
||||||
|
}
|
||||||
|
|
||||||
void EnsureCapacity(PRBool preserve, PRUint32 cap) {
|
void EnsureCapacity(PRBool preserve, PRUint32 cap) {
|
||||||
if (capacity >= cap)
|
if (capacity >= cap)
|
||||||
return;
|
return;
|
||||||
|
|||||||
1777
content/canvas/src/WebGLArrays.cpp
Normal file
1777
content/canvas/src/WebGLArrays.cpp
Normal file
File diff suppressed because it is too large
Load Diff
317
content/canvas/src/WebGLArrays.h
Normal file
317
content/canvas/src/WebGLArrays.h
Normal file
@@ -0,0 +1,317 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla Corporation.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Mark Steele <mwsteele@gmail.com>
|
||||||
|
* Vladimir Vukicevic <vladimir@pobox.com>
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#ifndef WEBGLARRAYS_H_
|
||||||
|
#define WEBGLARRAYS_H_
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include "nsTArray.h"
|
||||||
|
#include "nsDataHashtable.h"
|
||||||
|
#include "nsRefPtrHashtable.h"
|
||||||
|
#include "nsHashKeys.h"
|
||||||
|
|
||||||
|
#include "nsICanvasRenderingContextWebGL.h"
|
||||||
|
#include "nsICanvasRenderingContextInternal.h"
|
||||||
|
#include "nsIJSNativeInitializer.h"
|
||||||
|
|
||||||
|
#include "SimpleBuffer.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
|
||||||
|
//
|
||||||
|
// array wrapper classes
|
||||||
|
//
|
||||||
|
|
||||||
|
// XXX refactor buffer stuff
|
||||||
|
class WebGLArrayBuffer :
|
||||||
|
public nsICanvasArrayBuffer,
|
||||||
|
public nsIJSNativeInitializer,
|
||||||
|
public SimpleBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
WebGLArrayBuffer() { }
|
||||||
|
WebGLArrayBuffer(PRUint32 length);
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSICANVASARRAYBUFFER
|
||||||
|
|
||||||
|
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||||
|
JSContext* aCx,
|
||||||
|
JSObject* aObj,
|
||||||
|
PRUint32 aArgc,
|
||||||
|
jsval* aArgv);
|
||||||
|
};
|
||||||
|
|
||||||
|
class WebGLFloatArray :
|
||||||
|
public nsICanvasFloatArray,
|
||||||
|
public nsIJSNativeInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebGLFloatArray() :
|
||||||
|
mOffset(0), mLength(0) { }
|
||||||
|
|
||||||
|
WebGLFloatArray(PRUint32 length);
|
||||||
|
WebGLFloatArray(WebGLArrayBuffer *buffer, PRUint32 offset, PRUint32 length);
|
||||||
|
WebGLFloatArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSICANVASARRAY
|
||||||
|
NS_DECL_NSICANVASFLOATARRAY
|
||||||
|
|
||||||
|
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||||
|
JSContext* aCx,
|
||||||
|
JSObject* aObj,
|
||||||
|
PRUint32 aArgc,
|
||||||
|
jsval* aArgv);
|
||||||
|
|
||||||
|
void Set(PRUint32 index, float value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsRefPtr<WebGLArrayBuffer> mBuffer;
|
||||||
|
PRUint32 mOffset;
|
||||||
|
PRUint32 mLength;
|
||||||
|
PRUint32 mSize;
|
||||||
|
PRUint32 mElementSize;
|
||||||
|
PRUint32 mCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WebGLByteArray :
|
||||||
|
public nsICanvasByteArray,
|
||||||
|
public nsIJSNativeInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebGLByteArray() :
|
||||||
|
mOffset(0), mLength(0) { }
|
||||||
|
|
||||||
|
WebGLByteArray(PRUint32 length);
|
||||||
|
WebGLByteArray(WebGLArrayBuffer *buffer, PRUint32 offset, PRUint32 length);
|
||||||
|
WebGLByteArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSICANVASARRAY
|
||||||
|
NS_DECL_NSICANVASBYTEARRAY
|
||||||
|
|
||||||
|
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||||
|
JSContext* aCx,
|
||||||
|
JSObject* aObj,
|
||||||
|
PRUint32 aArgc,
|
||||||
|
jsval* aArgv);
|
||||||
|
|
||||||
|
void Set(PRUint32 index, char value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsRefPtr<WebGLArrayBuffer> mBuffer;
|
||||||
|
PRUint32 mOffset;
|
||||||
|
PRUint32 mLength;
|
||||||
|
PRUint32 mSize;
|
||||||
|
PRUint32 mElementSize;
|
||||||
|
PRUint32 mCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WebGLUnsignedByteArray :
|
||||||
|
public nsICanvasUnsignedByteArray,
|
||||||
|
public nsIJSNativeInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebGLUnsignedByteArray() :
|
||||||
|
mOffset(0), mLength(0) { }
|
||||||
|
|
||||||
|
WebGLUnsignedByteArray(PRUint32 length);
|
||||||
|
WebGLUnsignedByteArray(WebGLArrayBuffer *buffer, PRUint32 offset, PRUint32 length);
|
||||||
|
WebGLUnsignedByteArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSICANVASARRAY
|
||||||
|
NS_DECL_NSICANVASUNSIGNEDBYTEARRAY
|
||||||
|
|
||||||
|
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||||
|
JSContext* aCx,
|
||||||
|
JSObject* aObj,
|
||||||
|
PRUint32 aArgc,
|
||||||
|
jsval* aArgv);
|
||||||
|
|
||||||
|
void Set(PRUint32 index, unsigned char value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsRefPtr<WebGLArrayBuffer> mBuffer;
|
||||||
|
PRUint32 mOffset;
|
||||||
|
PRUint32 mLength;
|
||||||
|
PRUint32 mSize;
|
||||||
|
PRUint32 mElementSize;
|
||||||
|
PRUint32 mCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WebGLShortArray :
|
||||||
|
public nsICanvasShortArray,
|
||||||
|
public nsIJSNativeInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebGLShortArray() :
|
||||||
|
mOffset(0), mLength(0) { }
|
||||||
|
|
||||||
|
WebGLShortArray(PRUint32 length);
|
||||||
|
WebGLShortArray(WebGLArrayBuffer *buffer, PRUint32 offset, PRUint32 length);
|
||||||
|
WebGLShortArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSICANVASARRAY
|
||||||
|
NS_DECL_NSICANVASSHORTARRAY
|
||||||
|
|
||||||
|
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||||
|
JSContext* aCx,
|
||||||
|
JSObject* aObj,
|
||||||
|
PRUint32 aArgc,
|
||||||
|
jsval* aArgv);
|
||||||
|
|
||||||
|
void Set(PRUint32 index, short value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsRefPtr<WebGLArrayBuffer> mBuffer;
|
||||||
|
PRUint32 mOffset;
|
||||||
|
PRUint32 mLength;
|
||||||
|
PRUint32 mSize;
|
||||||
|
PRUint32 mElementSize;
|
||||||
|
PRUint32 mCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WebGLUnsignedShortArray :
|
||||||
|
public nsICanvasUnsignedShortArray,
|
||||||
|
public nsIJSNativeInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebGLUnsignedShortArray() :
|
||||||
|
mOffset(0), mLength(0) { }
|
||||||
|
|
||||||
|
WebGLUnsignedShortArray(PRUint32 length);
|
||||||
|
WebGLUnsignedShortArray(WebGLArrayBuffer *buffer, PRUint32 offset, PRUint32 length);
|
||||||
|
WebGLUnsignedShortArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSICANVASARRAY
|
||||||
|
NS_DECL_NSICANVASUNSIGNEDSHORTARRAY
|
||||||
|
|
||||||
|
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||||
|
JSContext* aCx,
|
||||||
|
JSObject* aObj,
|
||||||
|
PRUint32 aArgc,
|
||||||
|
jsval* aArgv);
|
||||||
|
|
||||||
|
void Set(PRUint32 index, unsigned short value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsRefPtr<WebGLArrayBuffer> mBuffer;
|
||||||
|
PRUint32 mOffset;
|
||||||
|
PRUint32 mLength;
|
||||||
|
PRUint32 mSize;
|
||||||
|
PRUint32 mElementSize;
|
||||||
|
PRUint32 mCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WebGLIntArray :
|
||||||
|
public nsICanvasIntArray,
|
||||||
|
public nsIJSNativeInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebGLIntArray() :
|
||||||
|
mOffset(0), mLength(0) { }
|
||||||
|
|
||||||
|
WebGLIntArray(PRUint32 length);
|
||||||
|
WebGLIntArray(WebGLArrayBuffer *buffer, PRUint32 offset, PRUint32 length);
|
||||||
|
WebGLIntArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSICANVASARRAY
|
||||||
|
NS_DECL_NSICANVASINTARRAY
|
||||||
|
|
||||||
|
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||||
|
JSContext* aCx,
|
||||||
|
JSObject* aObj,
|
||||||
|
PRUint32 aArgc,
|
||||||
|
jsval* aArgv);
|
||||||
|
|
||||||
|
void Set(PRUint32 index, int value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsRefPtr<WebGLArrayBuffer> mBuffer;
|
||||||
|
PRUint32 mOffset;
|
||||||
|
PRUint32 mLength;
|
||||||
|
PRUint32 mSize;
|
||||||
|
PRUint32 mElementSize;
|
||||||
|
PRUint32 mCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WebGLUnsignedIntArray :
|
||||||
|
public nsICanvasUnsignedIntArray,
|
||||||
|
public nsIJSNativeInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebGLUnsignedIntArray() :
|
||||||
|
mOffset(0), mLength(0) { }
|
||||||
|
|
||||||
|
WebGLUnsignedIntArray(PRUint32 length);
|
||||||
|
WebGLUnsignedIntArray(WebGLArrayBuffer *buffer, PRUint32 offset, PRUint32 length);
|
||||||
|
WebGLUnsignedIntArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
NS_DECL_NSICANVASARRAY
|
||||||
|
NS_DECL_NSICANVASUNSIGNEDINTARRAY
|
||||||
|
|
||||||
|
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||||
|
JSContext* aCx,
|
||||||
|
JSObject* aObj,
|
||||||
|
PRUint32 aArgc,
|
||||||
|
jsval* aArgv);
|
||||||
|
|
||||||
|
void Set(PRUint32 index, unsigned int value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
nsRefPtr<WebGLArrayBuffer> mBuffer;
|
||||||
|
PRUint32 mOffset;
|
||||||
|
PRUint32 mLength;
|
||||||
|
PRUint32 mSize;
|
||||||
|
PRUint32 mElementSize;
|
||||||
|
PRUint32 mCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace mozilla */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* WEBGLARRAYS_H_ */
|
||||||
@@ -6,11 +6,17 @@
|
|||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "nsIClassInfoImpl.h"
|
#include "nsIClassInfoImpl.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
#include "nsIXPConnect.h"
|
||||||
#include "nsDOMError.h"
|
#include "nsDOMError.h"
|
||||||
|
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
#include "gfxPattern.h"
|
#include "gfxPattern.h"
|
||||||
|
|
||||||
|
#include "CanvasUtils.h"
|
||||||
|
#include "NativeJSContext.h"
|
||||||
|
|
||||||
|
#include "WebGLArray.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
|
||||||
nsresult NS_NewCanvasRenderingContextWebGL(nsICanvasRenderingContextWebGL** aResult);
|
nsresult NS_NewCanvasRenderingContextWebGL(nsICanvasRenderingContextWebGL** aResult);
|
||||||
@@ -417,655 +423,6 @@ NS_INTERFACE_MAP_BEGIN(WebGLRenderbuffer)
|
|||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(WebGLRenderbuffer)
|
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(WebGLRenderbuffer)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
NS_IMPL_ADDREF(WebGLFloatArray)
|
|
||||||
NS_IMPL_RELEASE(WebGLFloatArray)
|
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(WebGLFloatArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasFloatArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasFloatArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CanvasFloatArray)
|
|
||||||
NS_INTERFACE_MAP_END
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(WebGLByteArray)
|
|
||||||
NS_IMPL_RELEASE(WebGLByteArray)
|
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(WebGLByteArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasByteArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasByteArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CanvasByteArray)
|
|
||||||
NS_INTERFACE_MAP_END
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(WebGLUnsignedByteArray)
|
|
||||||
NS_IMPL_RELEASE(WebGLUnsignedByteArray)
|
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(WebGLUnsignedByteArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasUnsignedByteArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasUnsignedByteArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CanvasUnsignedByteArray)
|
|
||||||
NS_INTERFACE_MAP_END
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(WebGLShortArray)
|
|
||||||
NS_IMPL_RELEASE(WebGLShortArray)
|
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(WebGLShortArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasShortArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasShortArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CanvasShortArray)
|
|
||||||
NS_INTERFACE_MAP_END
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(WebGLUnsignedShortArray)
|
|
||||||
NS_IMPL_RELEASE(WebGLUnsignedShortArray)
|
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(WebGLUnsignedShortArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasUnsignedShortArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasUnsignedShortArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CanvasUnsignedShortArray)
|
|
||||||
NS_INTERFACE_MAP_END
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(WebGLIntArray)
|
|
||||||
NS_IMPL_RELEASE(WebGLIntArray)
|
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(WebGLIntArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasIntArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasIntArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CanvasIntArray)
|
|
||||||
NS_INTERFACE_MAP_END
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(WebGLUnsignedIntArray)
|
|
||||||
NS_IMPL_RELEASE(WebGLUnsignedIntArray)
|
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(WebGLUnsignedIntArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsICanvasUnsignedIntArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICanvasUnsignedIntArray)
|
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CanvasUnsignedIntArray)
|
|
||||||
NS_INTERFACE_MAP_END
|
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
NS_NewCanvasFloatArray(nsISupports **aResult)
|
|
||||||
{
|
|
||||||
nsICanvasFloatArray *wgfa = new WebGLFloatArray();
|
|
||||||
if (!wgfa)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
NS_ADDREF(*aResult = wgfa);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebGLFloatArray::WebGLFloatArray()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
WebGLFloatArray::WebGLFloatArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen)
|
|
||||||
{
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_FLOAT, 1, cx, arrayObj, arrayLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WebGLFloatArray::Initialize(nsISupports *owner,
|
|
||||||
JSContext *cx,
|
|
||||||
JSObject *obj,
|
|
||||||
PRUint32 argc,
|
|
||||||
jsval *argv)
|
|
||||||
{
|
|
||||||
JSObject *arrayObj;
|
|
||||||
jsuint arrayLen;
|
|
||||||
|
|
||||||
if (!::JS_ConvertArguments(cx, argc, argv, "o", &arrayObj) ||
|
|
||||||
arrayObj == NULL ||
|
|
||||||
!::JS_IsArrayObject(cx, arrayObj) ||
|
|
||||||
!::JS_GetArrayLength(cx, arrayObj, &arrayLen))
|
|
||||||
{
|
|
||||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_FLOAT, 1, cx, arrayObj, arrayLen);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* attribute unsigned long length; */
|
|
||||||
NS_IMETHODIMP WebGLFloatArray::GetLength(PRUint32 *aLength)
|
|
||||||
{
|
|
||||||
*aLength = mBuffer.length;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
NS_IMETHODIMP WebGLFloatArray::SetLength(PRUint32 aLength)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLFloatArray::NativeType()
|
|
||||||
{
|
|
||||||
return mBuffer.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] voidPtr nativePointer (); */
|
|
||||||
NS_IMETHODIMP_(void *) WebGLFloatArray::NativePointer()
|
|
||||||
{
|
|
||||||
return mBuffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLFloatArray::NativeSize()
|
|
||||||
{
|
|
||||||
return mBuffer.capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeElementSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLFloatArray::NativeElementSize()
|
|
||||||
{
|
|
||||||
return mBuffer.ElementSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeCount (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLFloatArray::NativeCount()
|
|
||||||
{
|
|
||||||
return mBuffer.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
NS_NewCanvasByteArray(nsISupports **aResult)
|
|
||||||
{
|
|
||||||
nsICanvasByteArray *wgba = new WebGLByteArray();
|
|
||||||
if (!wgba)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
NS_ADDREF(*aResult = wgba);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebGLByteArray::WebGLByteArray() { }
|
|
||||||
|
|
||||||
WebGLByteArray::WebGLByteArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen)
|
|
||||||
{
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_BYTE, 1, cx, arrayObj, arrayLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WebGLByteArray::Initialize(nsISupports *owner,
|
|
||||||
JSContext *cx,
|
|
||||||
JSObject *obj,
|
|
||||||
PRUint32 argc,
|
|
||||||
jsval *argv)
|
|
||||||
{
|
|
||||||
JSObject *arrayObj;
|
|
||||||
jsuint arrayLen;
|
|
||||||
|
|
||||||
if (!::JS_ConvertArguments(cx, argc, argv, "o", &arrayObj) ||
|
|
||||||
arrayObj == NULL ||
|
|
||||||
!::JS_IsArrayObject(cx, arrayObj) ||
|
|
||||||
!::JS_GetArrayLength(cx, arrayObj, &arrayLen))
|
|
||||||
{
|
|
||||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_BYTE, 1, cx, arrayObj, arrayLen);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* attribute unsigned long length; */
|
|
||||||
NS_IMETHODIMP WebGLByteArray::GetLength(PRUint32 *aLength)
|
|
||||||
{
|
|
||||||
*aLength = mBuffer.length;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
NS_IMETHODIMP WebGLByteArray::SetLength(PRUint32 aLength)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLByteArray::NativeType()
|
|
||||||
{
|
|
||||||
return mBuffer.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] voidPtr nativePointer (); */
|
|
||||||
NS_IMETHODIMP_(void *) WebGLByteArray::NativePointer()
|
|
||||||
{
|
|
||||||
return mBuffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLByteArray::NativeSize()
|
|
||||||
{
|
|
||||||
return mBuffer.capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeElementSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLByteArray::NativeElementSize()
|
|
||||||
{
|
|
||||||
return mBuffer.ElementSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeCount (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLByteArray::NativeCount()
|
|
||||||
{
|
|
||||||
return mBuffer.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
NS_NewCanvasUnsignedByteArray(nsISupports **aResult)
|
|
||||||
{
|
|
||||||
nsICanvasUnsignedByteArray *wguba = new WebGLUnsignedByteArray();
|
|
||||||
if (!wguba)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
NS_ADDREF(*aResult = wguba);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebGLUnsignedByteArray::WebGLUnsignedByteArray() { }
|
|
||||||
|
|
||||||
WebGLUnsignedByteArray::WebGLUnsignedByteArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen)
|
|
||||||
{
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_UNSIGNED_BYTE, 1, cx, arrayObj, arrayLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WebGLUnsignedByteArray::Initialize(nsISupports *owner,
|
|
||||||
JSContext *cx,
|
|
||||||
JSObject *obj,
|
|
||||||
PRUint32 argc,
|
|
||||||
jsval *argv)
|
|
||||||
{
|
|
||||||
JSObject *arrayObj;
|
|
||||||
jsuint arrayLen;
|
|
||||||
|
|
||||||
if (!::JS_ConvertArguments(cx, argc, argv, "o", &arrayObj) ||
|
|
||||||
arrayObj == NULL ||
|
|
||||||
!::JS_IsArrayObject(cx, arrayObj) ||
|
|
||||||
!::JS_GetArrayLength(cx, arrayObj, &arrayLen))
|
|
||||||
{
|
|
||||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_UNSIGNED_BYTE, 1, cx, arrayObj, arrayLen);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* attribute unsigned long length; */
|
|
||||||
NS_IMETHODIMP WebGLUnsignedByteArray::GetLength(PRUint32 *aLength)
|
|
||||||
{
|
|
||||||
*aLength = mBuffer.length;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
NS_IMETHODIMP WebGLUnsignedByteArray::SetLength(PRUint32 aLength)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedByteArray::NativeType()
|
|
||||||
{
|
|
||||||
return mBuffer.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] voidPtr nativePointer (); */
|
|
||||||
NS_IMETHODIMP_(void *) WebGLUnsignedByteArray::NativePointer()
|
|
||||||
{
|
|
||||||
return mBuffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedByteArray::NativeSize()
|
|
||||||
{
|
|
||||||
return mBuffer.capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeElementSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedByteArray::NativeElementSize()
|
|
||||||
{
|
|
||||||
return mBuffer.ElementSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeCount (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedByteArray::NativeCount()
|
|
||||||
{
|
|
||||||
return mBuffer.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
NS_NewCanvasShortArray(nsISupports **aResult)
|
|
||||||
{
|
|
||||||
nsICanvasShortArray *wgsa = new WebGLShortArray();
|
|
||||||
if (!wgsa)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
NS_ADDREF(*aResult = wgsa);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebGLShortArray::WebGLShortArray() { }
|
|
||||||
|
|
||||||
WebGLShortArray::WebGLShortArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen)
|
|
||||||
{
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_SHORT, 1, cx, arrayObj, arrayLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WebGLShortArray::Initialize(nsISupports *owner,
|
|
||||||
JSContext *cx,
|
|
||||||
JSObject *obj,
|
|
||||||
PRUint32 argc,
|
|
||||||
jsval *argv)
|
|
||||||
{
|
|
||||||
JSObject *arrayObj;
|
|
||||||
jsuint arrayLen;
|
|
||||||
|
|
||||||
if (!::JS_ConvertArguments(cx, argc, argv, "o", &arrayObj) ||
|
|
||||||
arrayObj == NULL ||
|
|
||||||
!::JS_IsArrayObject(cx, arrayObj) ||
|
|
||||||
!::JS_GetArrayLength(cx, arrayObj, &arrayLen))
|
|
||||||
{
|
|
||||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_SHORT, 1, cx, arrayObj, arrayLen);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* attribute unsigned long length; */
|
|
||||||
NS_IMETHODIMP WebGLShortArray::GetLength(PRUint32 *aLength)
|
|
||||||
{
|
|
||||||
*aLength = mBuffer.length;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
NS_IMETHODIMP WebGLShortArray::SetLength(PRUint32 aLength)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLShortArray::NativeType()
|
|
||||||
{
|
|
||||||
return mBuffer.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] voidPtr nativePointer (); */
|
|
||||||
NS_IMETHODIMP_(void *) WebGLShortArray::NativePointer()
|
|
||||||
{
|
|
||||||
return mBuffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLShortArray::NativeSize()
|
|
||||||
{
|
|
||||||
return mBuffer.capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeElementSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLShortArray::NativeElementSize()
|
|
||||||
{
|
|
||||||
return mBuffer.ElementSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeCount (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLShortArray::NativeCount()
|
|
||||||
{
|
|
||||||
return mBuffer.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
NS_NewCanvasUnsignedShortArray(nsISupports **aResult)
|
|
||||||
{
|
|
||||||
nsICanvasUnsignedShortArray *wgusa = new WebGLUnsignedShortArray();
|
|
||||||
if (!wgusa)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
NS_ADDREF(*aResult = wgusa);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebGLUnsignedShortArray::WebGLUnsignedShortArray() { }
|
|
||||||
|
|
||||||
WebGLUnsignedShortArray::WebGLUnsignedShortArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen)
|
|
||||||
{
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_UNSIGNED_SHORT, 1, cx, arrayObj, arrayLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WebGLUnsignedShortArray::Initialize(nsISupports *owner,
|
|
||||||
JSContext *cx,
|
|
||||||
JSObject *obj,
|
|
||||||
PRUint32 argc,
|
|
||||||
jsval *argv)
|
|
||||||
{
|
|
||||||
JSObject *arrayObj;
|
|
||||||
jsuint arrayLen;
|
|
||||||
|
|
||||||
if (!::JS_ConvertArguments(cx, argc, argv, "o", &arrayObj) ||
|
|
||||||
arrayObj == NULL ||
|
|
||||||
!::JS_IsArrayObject(cx, arrayObj) ||
|
|
||||||
!::JS_GetArrayLength(cx, arrayObj, &arrayLen))
|
|
||||||
{
|
|
||||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_UNSIGNED_SHORT, 1, cx, arrayObj, arrayLen);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* attribute unsigned long length; */
|
|
||||||
NS_IMETHODIMP WebGLUnsignedShortArray::GetLength(PRUint32 *aLength)
|
|
||||||
{
|
|
||||||
*aLength = mBuffer.length;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
NS_IMETHODIMP WebGLUnsignedShortArray::SetLength(PRUint32 aLength)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedShortArray::NativeType()
|
|
||||||
{
|
|
||||||
return mBuffer.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] voidPtr nativePointer (); */
|
|
||||||
NS_IMETHODIMP_(void *) WebGLUnsignedShortArray::NativePointer()
|
|
||||||
{
|
|
||||||
return mBuffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedShortArray::NativeSize()
|
|
||||||
{
|
|
||||||
return mBuffer.capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeElementSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedShortArray::NativeElementSize()
|
|
||||||
{
|
|
||||||
return mBuffer.ElementSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeCount (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedShortArray::NativeCount()
|
|
||||||
{
|
|
||||||
return mBuffer.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
NS_NewCanvasIntArray(nsISupports **aResult)
|
|
||||||
{
|
|
||||||
nsICanvasIntArray *wgia = new WebGLIntArray();
|
|
||||||
if (!wgia)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
NS_ADDREF(*aResult = wgia);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebGLIntArray::WebGLIntArray() { }
|
|
||||||
|
|
||||||
WebGLIntArray::WebGLIntArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen)
|
|
||||||
{
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_INT, 1, cx, arrayObj, arrayLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WebGLIntArray::Initialize(nsISupports *owner,
|
|
||||||
JSContext *cx,
|
|
||||||
JSObject *obj,
|
|
||||||
PRUint32 argc,
|
|
||||||
jsval *argv)
|
|
||||||
{
|
|
||||||
JSObject *arrayObj;
|
|
||||||
jsuint arrayLen;
|
|
||||||
|
|
||||||
if (!::JS_ConvertArguments(cx, argc, argv, "o", &arrayObj) ||
|
|
||||||
arrayObj == NULL ||
|
|
||||||
!::JS_IsArrayObject(cx, arrayObj) ||
|
|
||||||
!::JS_GetArrayLength(cx, arrayObj, &arrayLen))
|
|
||||||
{
|
|
||||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_INT, 1, cx, arrayObj, arrayLen);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* attribute unsigned long length; */
|
|
||||||
NS_IMETHODIMP WebGLIntArray::GetLength(PRUint32 *aLength)
|
|
||||||
{
|
|
||||||
*aLength = mBuffer.length;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
NS_IMETHODIMP WebGLIntArray::SetLength(PRUint32 aLength)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLIntArray::NativeType()
|
|
||||||
{
|
|
||||||
return mBuffer.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] voidPtr nativePointer (); */
|
|
||||||
NS_IMETHODIMP_(void *) WebGLIntArray::NativePointer()
|
|
||||||
{
|
|
||||||
return mBuffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLIntArray::NativeSize()
|
|
||||||
{
|
|
||||||
return mBuffer.capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeElementSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLIntArray::NativeElementSize()
|
|
||||||
{
|
|
||||||
return mBuffer.ElementSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeCount (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLIntArray::NativeCount()
|
|
||||||
{
|
|
||||||
return mBuffer.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
NS_NewCanvasUnsignedIntArray(nsISupports **aResult)
|
|
||||||
{
|
|
||||||
nsICanvasUnsignedIntArray *wguia = new WebGLUnsignedIntArray();
|
|
||||||
if (!wguia)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
NS_ADDREF(*aResult = wguia);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebGLUnsignedIntArray::WebGLUnsignedIntArray() { }
|
|
||||||
|
|
||||||
WebGLUnsignedIntArray::WebGLUnsignedIntArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen)
|
|
||||||
{
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_UNSIGNED_INT, 1, cx, arrayObj, arrayLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
WebGLUnsignedIntArray::Initialize(nsISupports *owner,
|
|
||||||
JSContext *cx,
|
|
||||||
JSObject *obj,
|
|
||||||
PRUint32 argc,
|
|
||||||
jsval *argv)
|
|
||||||
{
|
|
||||||
JSObject *arrayObj;
|
|
||||||
jsuint arrayLen;
|
|
||||||
|
|
||||||
if (!::JS_ConvertArguments(cx, argc, argv, "o", &arrayObj) ||
|
|
||||||
arrayObj == NULL ||
|
|
||||||
!::JS_IsArrayObject(cx, arrayObj) ||
|
|
||||||
!::JS_GetArrayLength(cx, arrayObj, &arrayLen))
|
|
||||||
{
|
|
||||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBuffer.InitFromJSArray(LOCAL_GL_UNSIGNED_INT, 1, cx, arrayObj, arrayLen);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* attribute unsigned long length; */
|
|
||||||
NS_IMETHODIMP WebGLUnsignedIntArray::GetLength(PRUint32 *aLength)
|
|
||||||
{
|
|
||||||
*aLength = mBuffer.length;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
NS_IMETHODIMP WebGLUnsignedIntArray::SetLength(PRUint32 aLength)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedIntArray::NativeType()
|
|
||||||
{
|
|
||||||
return mBuffer.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] voidPtr nativePointer (); */
|
|
||||||
NS_IMETHODIMP_(void *) WebGLUnsignedIntArray::NativePointer()
|
|
||||||
{
|
|
||||||
return mBuffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedIntArray::NativeSize()
|
|
||||||
{
|
|
||||||
return mBuffer.capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeElementSize (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedIntArray::NativeElementSize()
|
|
||||||
{
|
|
||||||
return mBuffer.ElementSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript, notxpcom] unsigned long nativeCount (); */
|
|
||||||
NS_IMETHODIMP_(PRUint32) WebGLUnsignedIntArray::NativeCount()
|
|
||||||
{
|
|
||||||
return mBuffer.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* [noscript] attribute GLuint name; */
|
/* [noscript] attribute GLuint name; */
|
||||||
NS_IMETHODIMP WebGLTexture::GetName(GLuint *aName)
|
NS_IMETHODIMP WebGLTexture::GetName(GLuint *aName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,6 +58,8 @@
|
|||||||
#include "SimpleBuffer.h"
|
#include "SimpleBuffer.h"
|
||||||
#include "nsGLPbuffer.h"
|
#include "nsGLPbuffer.h"
|
||||||
|
|
||||||
|
#include "WebGLArrays.h"
|
||||||
|
|
||||||
class nsIDocShell;
|
class nsIDocShell;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
@@ -356,6 +358,10 @@ public:
|
|||||||
mCount = na->NativeCount();
|
mCount = na->NativeCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetCount(GLuint count) {
|
||||||
|
mCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
GLenum GLType() { return mGLType; }
|
GLenum GLType() { return mGLType; }
|
||||||
PRUint32 ByteCount() { return mElementSize * mCount; }
|
PRUint32 ByteCount() { return mElementSize * mCount; }
|
||||||
PRUint32 Count() { return mCount; }
|
PRUint32 Count() { return mCount; }
|
||||||
@@ -493,188 +499,6 @@ protected:
|
|||||||
PRBool mDeleted;
|
PRBool mDeleted;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
|
||||||
// array wrapper classes
|
|
||||||
//
|
|
||||||
|
|
||||||
class WebGLFloatArray :
|
|
||||||
public nsICanvasFloatArray,
|
|
||||||
public nsIJSNativeInitializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WebGLFloatArray();
|
|
||||||
WebGLFloatArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSICANVASARRAY
|
|
||||||
NS_DECL_NSICANVASFLOATARRAY
|
|
||||||
|
|
||||||
static nsresult NewCanvasFloatArray(nsISupports **aNewObject);
|
|
||||||
|
|
||||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
|
||||||
JSContext* aCx,
|
|
||||||
JSObject* aObj,
|
|
||||||
PRUint32 aArgc,
|
|
||||||
jsval* aArgv);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SimpleBuffer mBuffer;
|
|
||||||
PRUint32 mLength;
|
|
||||||
PRUint32 mSize;
|
|
||||||
PRUint32 mElementSize;
|
|
||||||
PRUint32 mCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WebGLByteArray :
|
|
||||||
public nsICanvasByteArray,
|
|
||||||
public nsIJSNativeInitializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WebGLByteArray();
|
|
||||||
WebGLByteArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSICANVASARRAY
|
|
||||||
NS_DECL_NSICANVASBYTEARRAY
|
|
||||||
|
|
||||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
|
||||||
JSContext* aCx,
|
|
||||||
JSObject* aObj,
|
|
||||||
PRUint32 aArgc,
|
|
||||||
jsval* aArgv);
|
|
||||||
protected:
|
|
||||||
SimpleBuffer mBuffer;
|
|
||||||
PRUint32 mLength;
|
|
||||||
PRUint32 mSize;
|
|
||||||
PRUint32 mElementSize;
|
|
||||||
PRUint32 mCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WebGLUnsignedByteArray :
|
|
||||||
public nsICanvasUnsignedByteArray,
|
|
||||||
public nsIJSNativeInitializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WebGLUnsignedByteArray();
|
|
||||||
WebGLUnsignedByteArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSICANVASARRAY
|
|
||||||
NS_DECL_NSICANVASUNSIGNEDBYTEARRAY
|
|
||||||
|
|
||||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
|
||||||
JSContext* aCx,
|
|
||||||
JSObject* aObj,
|
|
||||||
PRUint32 aArgc,
|
|
||||||
jsval* aArgv);
|
|
||||||
protected:
|
|
||||||
SimpleBuffer mBuffer;
|
|
||||||
PRUint32 mLength;
|
|
||||||
PRUint32 mSize;
|
|
||||||
PRUint32 mElementSize;
|
|
||||||
PRUint32 mCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WebGLShortArray :
|
|
||||||
public nsICanvasShortArray,
|
|
||||||
public nsIJSNativeInitializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WebGLShortArray();
|
|
||||||
WebGLShortArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSICANVASARRAY
|
|
||||||
NS_DECL_NSICANVASSHORTARRAY
|
|
||||||
|
|
||||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
|
||||||
JSContext* aCx,
|
|
||||||
JSObject* aObj,
|
|
||||||
PRUint32 aArgc,
|
|
||||||
jsval* aArgv);
|
|
||||||
protected:
|
|
||||||
SimpleBuffer mBuffer;
|
|
||||||
PRUint32 mLength;
|
|
||||||
PRUint32 mSize;
|
|
||||||
PRUint32 mElementSize;
|
|
||||||
PRUint32 mCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WebGLUnsignedShortArray :
|
|
||||||
public nsICanvasUnsignedShortArray,
|
|
||||||
public nsIJSNativeInitializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WebGLUnsignedShortArray();
|
|
||||||
WebGLUnsignedShortArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSICANVASARRAY
|
|
||||||
NS_DECL_NSICANVASUNSIGNEDSHORTARRAY
|
|
||||||
|
|
||||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
|
||||||
JSContext* aCx,
|
|
||||||
JSObject* aObj,
|
|
||||||
PRUint32 aArgc,
|
|
||||||
jsval* aArgv);
|
|
||||||
protected:
|
|
||||||
SimpleBuffer mBuffer;
|
|
||||||
PRUint32 mLength;
|
|
||||||
PRUint32 mSize;
|
|
||||||
PRUint32 mElementSize;
|
|
||||||
PRUint32 mCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WebGLIntArray :
|
|
||||||
public nsICanvasIntArray,
|
|
||||||
public nsIJSNativeInitializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WebGLIntArray();
|
|
||||||
WebGLIntArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSICANVASARRAY
|
|
||||||
NS_DECL_NSICANVASINTARRAY
|
|
||||||
|
|
||||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
|
||||||
JSContext* aCx,
|
|
||||||
JSObject* aObj,
|
|
||||||
PRUint32 aArgc,
|
|
||||||
jsval* aArgv);
|
|
||||||
protected:
|
|
||||||
SimpleBuffer mBuffer;
|
|
||||||
PRUint32 mLength;
|
|
||||||
PRUint32 mSize;
|
|
||||||
PRUint32 mElementSize;
|
|
||||||
PRUint32 mCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WebGLUnsignedIntArray :
|
|
||||||
public nsICanvasUnsignedIntArray,
|
|
||||||
public nsIJSNativeInitializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WebGLUnsignedIntArray();
|
|
||||||
WebGLUnsignedIntArray(JSContext *cx, JSObject *arrayObj, jsuint arrayLen);
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSICANVASARRAY
|
|
||||||
NS_DECL_NSICANVASUNSIGNEDINTARRAY
|
|
||||||
|
|
||||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
|
||||||
JSContext* aCx,
|
|
||||||
JSObject* aObj,
|
|
||||||
PRUint32 aArgc,
|
|
||||||
jsval* aArgv);
|
|
||||||
protected:
|
|
||||||
SimpleBuffer mBuffer;
|
|
||||||
PRUint32 mLength;
|
|
||||||
PRUint32 mSize;
|
|
||||||
PRUint32 mElementSize;
|
|
||||||
PRUint32 mCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -354,6 +354,20 @@ WebGLContext::Present()
|
|||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* long sizeInBytes (in GLenum type); */
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebGLContext::SizeInBytes(GLenum type, PRInt32 *retval)
|
||||||
|
{
|
||||||
|
if (type == LOCAL_GL_FLOAT) *retval = sizeof(float);
|
||||||
|
if (type == LOCAL_GL_SHORT) *retval = sizeof(short);
|
||||||
|
if (type == LOCAL_GL_UNSIGNED_SHORT) *retval = sizeof(unsigned short);
|
||||||
|
if (type == LOCAL_GL_BYTE) *retval = 1;
|
||||||
|
if (type == LOCAL_GL_UNSIGNED_BYTE) *retval = 1;
|
||||||
|
if (type == LOCAL_GL_INT) *retval = sizeof(int);
|
||||||
|
if (type == LOCAL_GL_UNSIGNED_INT) *retval = sizeof(unsigned int);
|
||||||
|
if (type == LOCAL_GL_DOUBLE) *retval = sizeof(double);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* void GlActiveTexture (in PRUint32 texture); */
|
/* void GlActiveTexture (in PRUint32 texture); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -442,7 +456,8 @@ WebGLContext::BindFramebuffer(GLenum target, nsIWebGLFramebuffer *fb)
|
|||||||
if (target >= LOCAL_GL_COLOR_ATTACHMENT0 &&
|
if (target >= LOCAL_GL_COLOR_ATTACHMENT0 &&
|
||||||
target < (LOCAL_GL_COLOR_ATTACHMENT0 + mBoundColorFramebuffers.Length()))
|
target < (LOCAL_GL_COLOR_ATTACHMENT0 + mBoundColorFramebuffers.Length()))
|
||||||
{
|
{
|
||||||
mBoundColorFramebuffers[target] = wfb;
|
int targetOffset = target - LOCAL_GL_COLOR_ATTACHMENT0;
|
||||||
|
mBoundColorFramebuffers[targetOffset] = wfb;
|
||||||
} else if (target == LOCAL_GL_DEPTH_ATTACHMENT) {
|
} else if (target == LOCAL_GL_DEPTH_ATTACHMENT) {
|
||||||
mBoundDepthFramebuffer = wfb;
|
mBoundDepthFramebuffer = wfb;
|
||||||
} else if (target == LOCAL_GL_STENCIL_ATTACHMENT) {
|
} else if (target == LOCAL_GL_STENCIL_ATTACHMENT) {
|
||||||
@@ -508,15 +523,28 @@ GL_SAME_METHOD_2(BlendFunc, BlendFunc, PRUint32, PRUint32)
|
|||||||
GL_SAME_METHOD_4(BlendFuncSeparate, BlendFuncSeparate, PRUint32, PRUint32, PRUint32, PRUint32)
|
GL_SAME_METHOD_4(BlendFuncSeparate, BlendFuncSeparate, PRUint32, PRUint32, PRUint32, PRUint32)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
WebGLContext::BufferData(GLenum target, nsICanvasArray *na, GLenum usage)
|
WebGLContext::BufferData(GLenum target)
|
||||||
{
|
{
|
||||||
|
// overloaded:
|
||||||
|
// void bufferData (in GLenum target, in GLsizei size, in GLenum usage);
|
||||||
|
// void bufferData (in GLenum target, in nsICanvasArray data, in GLenum usage);
|
||||||
|
// void bufferData (in GLenum target, in nsICanvasArrayBuffer data, in GLenum usage)
|
||||||
|
|
||||||
|
NativeJSContext js;
|
||||||
|
if (NS_FAILED(js.error))
|
||||||
|
return js.error;
|
||||||
|
|
||||||
|
if (js.argc != 3)
|
||||||
|
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||||
|
|
||||||
WebGLBuffer *boundBuffer = NULL;
|
WebGLBuffer *boundBuffer = NULL;
|
||||||
|
|
||||||
if (target == LOCAL_GL_ARRAY_BUFFER) {
|
if (target == LOCAL_GL_ARRAY_BUFFER) {
|
||||||
boundBuffer = mBoundArrayBuffer;
|
boundBuffer = mBoundArrayBuffer;
|
||||||
} else if (target == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
|
} else if (target == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
|
||||||
if (na->NativeType() != LOCAL_GL_UNSIGNED_SHORT)
|
// XXX fix type check
|
||||||
return ErrorMessage("glBufferData: %x - GL_ELEMENT_ARRAY_BUFFER target must be used with UnsignedShortBuffer", na->NativeType());
|
//if (na->NativeType() != LOCAL_GL_UNSIGNED_SHORT)
|
||||||
|
// return ErrorMessage("glBufferData: %x - GL_ELEMENT_ARRAY_BUFFER target must be used with UnsignedShortBuffer", na->NativeType());
|
||||||
|
|
||||||
boundBuffer = mBoundElementArrayBuffer;
|
boundBuffer = mBoundElementArrayBuffer;
|
||||||
} else {
|
} else {
|
||||||
@@ -527,18 +555,62 @@ WebGLContext::BufferData(GLenum target, nsICanvasArray *na, GLenum usage)
|
|||||||
return ErrorMessage("glBufferData: no buffer bound!");
|
return ErrorMessage("glBufferData: no buffer bound!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MakeContextCurrent();
|
MakeContextCurrent();
|
||||||
|
|
||||||
boundBuffer->Set(na);
|
uint32 usage;
|
||||||
|
|
||||||
gl->fBufferData(target, na->NativeSize(), na->NativePointer(), usage);
|
if (!::JS_ValueToECMAUint32(js.ctx, js.argv[2], &usage)) {
|
||||||
|
return ErrorMessage("bufferData: invalid usage parameter");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JSVAL_IS_NUMBER(js.argv[1])) {
|
||||||
|
int32 size;
|
||||||
|
if (!::JS_ValueToECMAInt32(js.ctx, js.argv[1], &size)) {
|
||||||
|
return ErrorMessage("bufferData: invalid size parameter");
|
||||||
|
}
|
||||||
|
boundBuffer->SetCount(size);
|
||||||
|
gl->fBufferData(target, size, 0, usage);
|
||||||
|
} else if (JSVAL_IS_OBJECT(js.argv[1])) {
|
||||||
|
nsCOMPtr<nsICanvasArray> canvasArrayObj;
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
rv = nsContentUtils::XPConnect()->WrapJS(js.ctx, JSVAL_TO_OBJECT(js.argv[1]),
|
||||||
|
NS_GET_IID(nsICanvasArray), getter_AddRefs(canvasArrayObj));
|
||||||
|
if (NS_FAILED(rv) || !canvasArrayObj) {
|
||||||
|
nsCOMPtr<nsICanvasArrayBuffer> arrayBuf;
|
||||||
|
rv = nsContentUtils::XPConnect()->WrapJS(js.ctx, JSVAL_TO_OBJECT(js.argv[1]),
|
||||||
|
NS_GET_IID(nsICanvasArrayBuffer), getter_AddRefs(arrayBuf));
|
||||||
|
if (NS_FAILED(rv) || !arrayBuf)
|
||||||
|
return ErrorMessage("bufferData: need CanvasArray or CanvasArrayBuffer");
|
||||||
|
|
||||||
|
boundBuffer->SetCount(arrayBuf->NativeSize());
|
||||||
|
gl->fBufferData(target, arrayBuf->NativeSize(), arrayBuf->NativePointer(), usage);
|
||||||
|
} else {
|
||||||
|
boundBuffer->Set(canvasArrayObj);
|
||||||
|
gl->fBufferData(target, canvasArrayObj->NativeSize(), canvasArrayObj->NativePointer(), usage);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ErrorMessage("bufferData: invalid data");
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
WebGLContext::BufferSubData(GLenum target, GLuint offset, nsICanvasArray *na)
|
WebGLContext::BufferSubData(GLenum target, GLsizeiptr offset)
|
||||||
{
|
{
|
||||||
|
// overloaded:
|
||||||
|
// void bufferSubData(in GLenum target, in GLsizeiptr offset, in CanvasArray data)
|
||||||
|
// void bufferSubData(in GLenum target, in GLsizeiptr offset, in CanvasArrayBuffer data)
|
||||||
|
|
||||||
|
NativeJSContext js;
|
||||||
|
if (NS_FAILED(js.error))
|
||||||
|
return js.error;
|
||||||
|
|
||||||
|
if (js.argc != 3)
|
||||||
|
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||||
|
|
||||||
WebGLBuffer *boundBuffer = NULL;
|
WebGLBuffer *boundBuffer = NULL;
|
||||||
|
|
||||||
if (target == LOCAL_GL_ARRAY_BUFFER) {
|
if (target == LOCAL_GL_ARRAY_BUFFER) {
|
||||||
@@ -553,23 +625,62 @@ WebGLContext::BufferSubData(GLenum target, GLuint offset, nsICanvasArray *na)
|
|||||||
return ErrorMessage("glBufferSubData: no buffer bound!");
|
return ErrorMessage("glBufferSubData: no buffer bound!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* XXX FIXME
|
||||||
// check type
|
// check type
|
||||||
if (na->NativeType() != boundBuffer->GLType()) {
|
if (na->NativeType() != boundBuffer->GLType()) {
|
||||||
return ErrorMessage("glBufferSubData: existing buffer has different base type (0x%04x) the sub data (0x%04x)!", boundBuffer->GLType(), na->NativeType());
|
return ErrorMessage("glBufferSubData: existing buffer has different base type (0x%04x) the sub data (0x%04x)!", boundBuffer->GLType(), na->NativeType());
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (JSVAL_IS_OBJECT(js.argv[2])) {
|
||||||
|
nsCOMPtr<nsICanvasArray> canvasArrayObj;
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
rv = nsContentUtils::XPConnect()->WrapJS(js.ctx, JSVAL_TO_OBJECT(js.argv[2]),
|
||||||
|
NS_GET_IID(nsICanvasArray), getter_AddRefs(canvasArrayObj));
|
||||||
|
if (NS_FAILED(rv) || !canvasArrayObj) {
|
||||||
|
nsCOMPtr<nsICanvasArrayBuffer> arrayBuf;
|
||||||
|
rv = nsContentUtils::XPConnect()->WrapJS(js.ctx, JSVAL_TO_OBJECT(js.argv[2]),
|
||||||
|
NS_GET_IID(nsICanvasArrayBuffer), getter_AddRefs(arrayBuf));
|
||||||
|
if (NS_FAILED(rv) || !arrayBuf)
|
||||||
|
return ErrorMessage("bufferData: need CanvasArray or CanvasArrayBuffer");
|
||||||
|
|
||||||
// check size
|
// check size
|
||||||
if ((offset + na->NativeCount()) > boundBuffer->Count()) {
|
// XXX should be bytes
|
||||||
return ErrorMessage("glBufferSubData: existing buffer is too small for additional data");
|
if ((offset + arrayBuf->NativeSize()) > boundBuffer->Count()) {
|
||||||
|
return ErrorMessage("glBufferSubData: existing buffer is too small (%d) for data at offset (%d+%d)",
|
||||||
|
boundBuffer->Count(), offset, arrayBuf->NativeSize());
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
LogMessage("bufferSubData: buffer (%d) for data at offset (%d+%d)", boundBuffer->Count(), offset, arrayBuf->NativeSize());
|
||||||
|
#endif
|
||||||
// all good
|
// all good
|
||||||
|
|
||||||
MakeContextCurrent();
|
MakeContextCurrent();
|
||||||
|
|
||||||
gl->fBufferSubData(target, offset * na->NativeElementSize(), na->NativeSize(), na->NativePointer());
|
gl->fBufferSubData(target, offset, arrayBuf->NativeSize(), arrayBuf->NativePointer());
|
||||||
|
} else {
|
||||||
|
// check size
|
||||||
|
// XXX should be bytes
|
||||||
|
if ((offset + canvasArrayObj->NativeCount()) > boundBuffer->Count()) {
|
||||||
|
return ErrorMessage("glBufferSubData: existing buffer is too small (%d) for data at offset (%d+%d)",
|
||||||
|
boundBuffer->Count(), offset, canvasArrayObj->NativeCount());
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
LogMessage("bufferSubData: buffer (%d) for data at offset (%d+%d)", boundBuffer->Count(), offset, canvasArrayObj->NativeSize());
|
||||||
|
#endif
|
||||||
|
// all good
|
||||||
|
|
||||||
|
MakeContextCurrent();
|
||||||
|
|
||||||
|
gl->fBufferSubData(target, offset, canvasArrayObj->NativeSize(), canvasArrayObj->NativePointer());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ErrorMessage("bufferData: invalid data");
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -583,7 +694,15 @@ WebGLContext::CheckFramebufferStatus(GLenum target, GLenum *retval)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_SAME_METHOD_1(Clear, Clear, PRUint32)
|
NS_IMETHODIMP
|
||||||
|
WebGLContext::Clear(PRUint32 mask)
|
||||||
|
{
|
||||||
|
MakeContextCurrent();
|
||||||
|
gl->fClear(mask);
|
||||||
|
Invalidate();
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
GL_SAME_METHOD_4(ClearColor, ClearColor, float, float, float, float)
|
GL_SAME_METHOD_4(ClearColor, ClearColor, float, float, float, float)
|
||||||
|
|
||||||
@@ -970,7 +1089,7 @@ WebGLContext::DrawElements(GLenum mode, GLuint count, GLenum type, GLuint offset
|
|||||||
return ErrorMessage("glDrawElements: ValidateBuffers failed");
|
return ErrorMessage("glDrawElements: ValidateBuffers failed");
|
||||||
#endif
|
#endif
|
||||||
// XXX uh, is this offset, or offset * elementsize?
|
// XXX uh, is this offset, or offset * elementsize?
|
||||||
gl->fDrawElements(mode, count, type, (GLvoid*) (offset * mBoundElementArrayBuffer->ElementSize()));
|
gl->fDrawElements(mode, count, type, (GLvoid*) (offset));
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
|
||||||
@@ -2423,22 +2542,20 @@ WebGLContext::name(GLint idx, nsICanvasArray *v)
|
|||||||
if (v->NativeType() != LOCAL_GL_INT) { \
|
if (v->NativeType() != LOCAL_GL_INT) { \
|
||||||
return ErrorMessage(#name ": arg not an array"); \
|
return ErrorMessage(#name ": arg not an array"); \
|
||||||
} \
|
} \
|
||||||
WebGLIntArray *wga = static_cast<WebGLIntArray*>(v); \
|
if (v->NativeCount() % c != 0) { \
|
||||||
if (wga->NativeCount() % c != 0) { \
|
|
||||||
return ErrorMessage(#name ": array length not divisible by " #c); \
|
return ErrorMessage(#name ": array length not divisible by " #c); \
|
||||||
} \
|
} \
|
||||||
MakeContextCurrent(); \
|
MakeContextCurrent(); \
|
||||||
gl->f##glname(idx, wga->NativeCount() / c, ( ptrType *)wga->NativePointer()); \
|
gl->f##glname(idx, v->NativeCount() / c, ( ptrType *)v->NativePointer()); \
|
||||||
} else if (glTypeConst == LOCAL_GL_FLOAT) { \
|
} else if (glTypeConst == LOCAL_GL_FLOAT) { \
|
||||||
if (v->NativeType() != LOCAL_GL_FLOAT) { \
|
if (v->NativeType() != LOCAL_GL_FLOAT) { \
|
||||||
return ErrorMessage(#name ": arg not an array"); \
|
return ErrorMessage(#name ": arg not an array"); \
|
||||||
} \
|
} \
|
||||||
WebGLFloatArray *wga = static_cast<WebGLFloatArray*>(v); \
|
if (v->NativeCount() % c != 0) { \
|
||||||
if (wga->NativeCount() % c != 0) { \
|
|
||||||
return ErrorMessage(#name ": array length not divisible by " #c); \
|
return ErrorMessage(#name ": array length not divisible by " #c); \
|
||||||
} \
|
} \
|
||||||
MakeContextCurrent(); \
|
MakeContextCurrent(); \
|
||||||
gl->f##glname(idx, wga->NativeCount() / c, ( ptrType *)wga->NativePointer()); \
|
gl->f##glname(idx, v->NativeCount() / c, ( ptrType *)v->NativePointer()); \
|
||||||
} else { \
|
} else { \
|
||||||
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
||||||
} \
|
} \
|
||||||
@@ -2471,22 +2588,20 @@ WebGLContext::name(GLuint idx, nsICanvasArray *v)
|
|||||||
if (v->NativeType() != LOCAL_GL_INT) { \
|
if (v->NativeType() != LOCAL_GL_INT) { \
|
||||||
return ErrorMessage(#name ": arg not an array"); \
|
return ErrorMessage(#name ": arg not an array"); \
|
||||||
} \
|
} \
|
||||||
WebGLIntArray *wga = static_cast<WebGLIntArray*>(v); \
|
if (v->NativeCount() % c != 0) { \
|
||||||
if (wga->NativeCount() % c != 0) { \
|
return ErrorMessage(#name ": array wrong size %d, expected " #c, v->NativeCount()); \
|
||||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, wga->NativeCount()); \
|
|
||||||
} \
|
} \
|
||||||
MakeContextCurrent(); \
|
MakeContextCurrent(); \
|
||||||
gl->f##glname(idx, ( ptrType *)wga->NativePointer()); \
|
gl->f##glname(idx, ( ptrType *)v->NativePointer()); \
|
||||||
} else if (glTypeConst == LOCAL_GL_FLOAT) { \
|
} else if (glTypeConst == LOCAL_GL_FLOAT) { \
|
||||||
if (v->NativeType() != LOCAL_GL_FLOAT) { \
|
if (v->NativeType() != LOCAL_GL_FLOAT) { \
|
||||||
return ErrorMessage(#name ": arg not an array"); \
|
return ErrorMessage(#name ": arg not an array"); \
|
||||||
} \
|
} \
|
||||||
WebGLFloatArray *wga = static_cast<WebGLFloatArray*>(v); \
|
if (v->NativeCount() % c != 0) { \
|
||||||
if (wga->NativeCount() % c != 0) { \
|
return ErrorMessage(#name ": array wrong size %d, expected " #c, v->NativeCount()); \
|
||||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, wga->NativeCount()); \
|
|
||||||
} \
|
} \
|
||||||
MakeContextCurrent(); \
|
MakeContextCurrent(); \
|
||||||
gl->f##glname(idx, ( ptrType *)wga->NativePointer()); \
|
gl->f##glname(idx, ( ptrType *)v->NativePointer()); \
|
||||||
} else { \
|
} else { \
|
||||||
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
||||||
} \
|
} \
|
||||||
@@ -2519,12 +2634,11 @@ WebGLContext::name(GLint location, GLboolean transpose, nsICanvasArray *value)
|
|||||||
if (value->NativeType() != LOCAL_GL_FLOAT) { \
|
if (value->NativeType() != LOCAL_GL_FLOAT) { \
|
||||||
return ErrorMessage(#name ": arg not an array"); \
|
return ErrorMessage(#name ": arg not an array"); \
|
||||||
} \
|
} \
|
||||||
WebGLFloatArray *wga = static_cast<WebGLFloatArray*>(value); \
|
if (value->NativeCount() % c != 0) { \
|
||||||
if (wga->NativeCount() % c != 0) { \
|
return ErrorMessage(#name ": array wrong size %d, expected " #c, value->NativeCount()); \
|
||||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, wga->NativeCount()); \
|
|
||||||
} \
|
} \
|
||||||
MakeContextCurrent(); \
|
MakeContextCurrent(); \
|
||||||
gl->f##glname(location, wga->NativeCount() / c, transpose, ( ptrType *)wga->NativePointer()); \
|
gl->f##glname(location, value->NativeCount() / c, transpose, ( ptrType *)value->NativePointer()); \
|
||||||
} else { \
|
} else { \
|
||||||
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
||||||
} \
|
} \
|
||||||
@@ -2780,8 +2894,10 @@ WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
|
|||||||
if (size < 1 || size > 4)
|
if (size < 1 || size > 4)
|
||||||
return ErrorMessage("glVertexAttribPointer: invalid element size");
|
return ErrorMessage("glVertexAttribPointer: invalid element size");
|
||||||
|
|
||||||
|
/* XXX make work with bufferSubData & heterogeneous types
|
||||||
if (type != mBoundArrayBuffer->GLType())
|
if (type != mBoundArrayBuffer->GLType())
|
||||||
return ErrorMessage("glVertexAttribPointer: type must match bound VBO type: %d != %d", type, mBoundArrayBuffer->GLType());
|
return ErrorMessage("glVertexAttribPointer: type must match bound VBO type: %d != %d", type, mBoundArrayBuffer->GLType());
|
||||||
|
*/
|
||||||
|
|
||||||
// XXX 0 stride?
|
// XXX 0 stride?
|
||||||
//if (stride < (GLuint) size)
|
//if (stride < (GLuint) size)
|
||||||
@@ -2797,8 +2913,8 @@ WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
|
|||||||
MakeContextCurrent();
|
MakeContextCurrent();
|
||||||
|
|
||||||
gl->fVertexAttribPointer(index, size, type, normalized,
|
gl->fVertexAttribPointer(index, size, type, normalized,
|
||||||
stride * mBoundArrayBuffer->ElementSize(),
|
stride,
|
||||||
(void*) (offset * mBoundArrayBuffer->ElementSize()));
|
(void*) (offset));
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,3 +49,4 @@ DUMMY(NS_NewCanvasShortArray, nsISupports)
|
|||||||
DUMMY(NS_NewCanvasUnsignedShortArray, nsISupports)
|
DUMMY(NS_NewCanvasUnsignedShortArray, nsISupports)
|
||||||
DUMMY(NS_NewCanvasIntArray, nsISupports)
|
DUMMY(NS_NewCanvasIntArray, nsISupports)
|
||||||
DUMMY(NS_NewCanvasUnsignedIntArray, nsISupports)
|
DUMMY(NS_NewCanvasUnsignedIntArray, nsISupports)
|
||||||
|
DUMMY(NS_NewCanvasArrayBuffer, nsISupports)
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ typedef double GLclampd;
|
|||||||
typedef void GLvoid;
|
typedef void GLvoid;
|
||||||
|
|
||||||
typedef char GLchar;
|
typedef char GLchar;
|
||||||
typedef ptrdiff_t GLsizeiptr;
|
typedef PRInt32 GLsizeiptr;
|
||||||
typedef ptrdiff_t GLintptr;
|
typedef PRInt32 GLintptr;
|
||||||
|
|
||||||
#ifndef GLAPIENTRY
|
#ifndef GLAPIENTRY
|
||||||
# ifdef WIN32
|
# ifdef WIN32
|
||||||
|
|||||||
@@ -1335,6 +1335,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||||
NS_DEFINE_CLASSINFO_DATA(WebGLRenderbuffer, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(WebGLRenderbuffer, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||||
|
NS_DEFINE_CLASSINFO_DATA(CanvasArrayBuffer, nsDOMGenericSH,
|
||||||
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||||
NS_DEFINE_CLASSINFO_DATA(CanvasFloatArray, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CanvasFloatArray, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||||
NS_DEFINE_CLASSINFO_DATA(CanvasByteArray, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CanvasByteArray, nsDOMGenericSH,
|
||||||
@@ -1396,6 +1398,7 @@ static const nsConstructorFuncMapData kConstructorFuncMap[] =
|
|||||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Worker, nsDOMWorker::NewWorker)
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Worker, nsDOMWorker::NewWorker)
|
||||||
|
|
||||||
// WebGL Array Types
|
// WebGL Array Types
|
||||||
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasArrayBuffer, NS_NewCanvasArrayBuffer)
|
||||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasFloatArray, NS_NewCanvasFloatArray)
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasFloatArray, NS_NewCanvasFloatArray)
|
||||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasByteArray, NS_NewCanvasByteArray)
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasByteArray, NS_NewCanvasByteArray)
|
||||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasUnsignedByteArray, NS_NewCanvasUnsignedByteArray)
|
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasUnsignedByteArray, NS_NewCanvasUnsignedByteArray)
|
||||||
@@ -3722,6 +3725,10 @@ nsDOMClassInfo::Init()
|
|||||||
DOM_CLASSINFO_MAP_ENTRY(nsIWebGLRenderbuffer)
|
DOM_CLASSINFO_MAP_ENTRY(nsIWebGLRenderbuffer)
|
||||||
DOM_CLASSINFO_MAP_END
|
DOM_CLASSINFO_MAP_END
|
||||||
|
|
||||||
|
DOM_CLASSINFO_MAP_BEGIN(CanvasArrayBuffer, nsICanvasArrayBuffer)
|
||||||
|
DOM_CLASSINFO_MAP_ENTRY(nsICanvasArrayBuffer)
|
||||||
|
DOM_CLASSINFO_MAP_END
|
||||||
|
|
||||||
DOM_CLASSINFO_MAP_BEGIN(CanvasFloatArray, nsICanvasFloatArray)
|
DOM_CLASSINFO_MAP_BEGIN(CanvasFloatArray, nsICanvasFloatArray)
|
||||||
DOM_CLASSINFO_MAP_ENTRY(nsICanvasFloatArray)
|
DOM_CLASSINFO_MAP_ENTRY(nsICanvasFloatArray)
|
||||||
DOM_CLASSINFO_MAP_END
|
DOM_CLASSINFO_MAP_END
|
||||||
|
|||||||
@@ -473,6 +473,7 @@ enum nsDOMClassInfoID {
|
|||||||
eDOMClassInfo_WebGLRenderbuffer_id,
|
eDOMClassInfo_WebGLRenderbuffer_id,
|
||||||
|
|
||||||
// WebGL Buffers
|
// WebGL Buffers
|
||||||
|
eDOMClassInfo_CanvasArrayBuffer_id,
|
||||||
eDOMClassInfo_CanvasFloatArray_id,
|
eDOMClassInfo_CanvasFloatArray_id,
|
||||||
eDOMClassInfo_CanvasByteArray_id,
|
eDOMClassInfo_CanvasByteArray_id,
|
||||||
eDOMClassInfo_CanvasUnsignedByteArray_id,
|
eDOMClassInfo_CanvasUnsignedByteArray_id,
|
||||||
|
|||||||
@@ -59,16 +59,39 @@ typedef long GLfixed;
|
|||||||
//typedef signed octet GLbyte;
|
//typedef signed octet GLbyte;
|
||||||
|
|
||||||
//typedef unsigned long GLintptr;
|
//typedef unsigned long GLintptr;
|
||||||
//typedef unsigned long GLsizeiptr;
|
typedef long GLsizeiptr;
|
||||||
|
|
||||||
|
%{C++
|
||||||
|
namespace mozilla {
|
||||||
|
class WebGLArrayBuffer;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
[ptr] native WebGLArrayBufferPtr (mozilla::WebGLArrayBuffer);
|
||||||
//
|
//
|
||||||
// Array types
|
// Array types
|
||||||
//
|
//
|
||||||
|
[scriptable, uuid(34b6cf8e-47da-458e-ab42-0451a3533ee5)]
|
||||||
|
interface nsICanvasArrayBuffer : nsISupports
|
||||||
|
{
|
||||||
|
readonly attribute unsigned long byteLength;
|
||||||
|
|
||||||
|
[noscript, notxpcom] WebGLArrayBufferPtr GetNativeArrayBuffer();
|
||||||
|
[noscript, notxpcom] voidPtr nativePointer();
|
||||||
|
[noscript, notxpcom] unsigned long nativeSize();
|
||||||
|
};
|
||||||
|
|
||||||
[scriptable, uuid(84ba4e98-8173-7c10-dca0-b5ba7809fcf3)]
|
[scriptable, uuid(84ba4e98-8173-7c10-dca0-b5ba7809fcf3)]
|
||||||
interface nsICanvasArray : nsISupports
|
interface nsICanvasArray : nsISupports
|
||||||
{
|
{
|
||||||
attribute unsigned long length;
|
readonly attribute nsICanvasArrayBuffer buffer;
|
||||||
|
readonly attribute unsigned long byteOffset;
|
||||||
|
readonly attribute unsigned long byteLength;
|
||||||
|
readonly attribute unsigned long length;
|
||||||
|
|
||||||
|
// XXX kill this.
|
||||||
|
unsigned long alignedSizeInBytes();
|
||||||
|
|
||||||
|
nsICanvasArray slice(in unsigned long offset, in unsigned long length);
|
||||||
|
|
||||||
[noscript, notxpcom] unsigned long nativeType();
|
[noscript, notxpcom] unsigned long nativeType();
|
||||||
[noscript, notxpcom] voidPtr nativePointer();
|
[noscript, notxpcom] voidPtr nativePointer();
|
||||||
@@ -80,36 +103,71 @@ interface nsICanvasArray : nsISupports
|
|||||||
[scriptable, Uuid(0f6d0e7b-bcfc-9305-6a1d-a9653b5e8c80)]
|
[scriptable, Uuid(0f6d0e7b-bcfc-9305-6a1d-a9653b5e8c80)]
|
||||||
interface nsICanvasFloatArray : nsICanvasArray
|
interface nsICanvasFloatArray : nsICanvasArray
|
||||||
{
|
{
|
||||||
|
[IndexGetter] float get(in unsigned long index);
|
||||||
|
//[IndexSetter] void set(in unsigned long index, in float value);
|
||||||
|
//void set(in CanvasFloatArray array, [Optional] in unsigned long offset);
|
||||||
|
//void set(in sequence<float> array, [Optional] in unsigned long offset);
|
||||||
|
void set();
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(b29db7cf-fa58-435f-8d45-611cc50979ad)]
|
[scriptable, uuid(b29db7cf-fa58-435f-8d45-611cc50979ad)]
|
||||||
interface nsICanvasByteArray : nsICanvasArray
|
interface nsICanvasByteArray : nsICanvasArray
|
||||||
{
|
{
|
||||||
|
[IndexGetter] long get(in unsigned long index);
|
||||||
|
//[IndexSetter] void set(in unsigned long index, in long value);
|
||||||
|
//void set(in nsICanvasByteArray array, [Optional] in unsigned long offset);
|
||||||
|
//void set(in sequence<long> array, [Optional] in unsigned long offset);
|
||||||
|
void set();
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(3daa67fa-e743-2cbd-a212-805c2fc520cc)]
|
[scriptable, uuid(3daa67fa-e743-2cbd-a212-805c2fc520cc)]
|
||||||
interface nsICanvasUnsignedByteArray : nsICanvasArray
|
interface nsICanvasUnsignedByteArray : nsICanvasArray
|
||||||
{
|
{
|
||||||
|
[IndexGetter] unsigned long get(in unsigned long index);
|
||||||
|
//[IndexSetter] void set(in unsigned long index, in unsigned long value);
|
||||||
|
//void set(in CanvasUnsignedByteArray array, [Optional] in unsigned long offset);
|
||||||
|
//void set(in sequence<unsigned long> array, [Optional] in unsigned long offset);
|
||||||
|
void set();
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(a8a982e3-3977-7364-f012-c497a5ab7681)]
|
[scriptable, uuid(a8a982e3-3977-7364-f012-c497a5ab7681)]
|
||||||
interface nsICanvasShortArray : nsICanvasArray
|
interface nsICanvasShortArray : nsICanvasArray
|
||||||
{
|
{
|
||||||
|
[IndexGetter] long get(in unsigned long index);
|
||||||
|
//[IndexSetter] void set(in unsigned long index, in long value);
|
||||||
|
//void set(in CanvasShortArray array, [Optional] in unsigned long offset);
|
||||||
|
//void set(in sequence<long> array, [Optional] in unsigned long offset);
|
||||||
|
void set();
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(8b9c67cc-c7be-a062-84b0-76a910a5c1e6)]
|
[scriptable, uuid(8b9c67cc-c7be-a062-84b0-76a910a5c1e6)]
|
||||||
interface nsICanvasUnsignedShortArray : nsICanvasArray
|
interface nsICanvasUnsignedShortArray : nsICanvasArray
|
||||||
{
|
{
|
||||||
|
[IndexGetter] unsigned long get(in unsigned long index);
|
||||||
|
//[IndexSetter] void set(in unsigned long index, in unsigned long value);
|
||||||
|
//void set(in CanvasUnsignedShortArray array, [Optional] in unsigned long offset);
|
||||||
|
//void set(in sequence<unsigned long> array, [Optional] in unsigned long offset);
|
||||||
|
void set();
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(b9b2e861-3a28-4311-993c-799e4f77dcba)]
|
[scriptable, uuid(b9b2e861-3a28-4311-993c-799e4f77dcba)]
|
||||||
interface nsICanvasIntArray : nsICanvasArray
|
interface nsICanvasIntArray : nsICanvasArray
|
||||||
{
|
{
|
||||||
|
[IndexGetter] long get(in unsigned long index);
|
||||||
|
//[IndexSetter] void set(in unsigned long index, in long value);
|
||||||
|
//void set(in CanvasIntArray array, [Optional] in unsigned long offset);
|
||||||
|
//void set(in sequence<long> array, [Optional] in unsigned long offset);
|
||||||
|
void set();
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(0d6ee3f8-71b6-460d-b05a-d579cc55edbe)]
|
[scriptable, uuid(0d6ee3f8-71b6-460d-b05a-d579cc55edbe)]
|
||||||
interface nsICanvasUnsignedIntArray : nsICanvasArray
|
interface nsICanvasUnsignedIntArray : nsICanvasArray
|
||||||
{
|
{
|
||||||
|
[IndexGetter] unsigned long get(in unsigned long index);
|
||||||
|
//[IndexSetter] void set(in unsigned long index, in unsigned long value);
|
||||||
|
//void set(in CanvasUnsignedIntArray array, [Optional] in unsigned long offset);
|
||||||
|
//void set(in sequence<unsigned long> array, [Optional] in unsigned long offset);
|
||||||
|
void set();
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -624,6 +682,7 @@ interface nsICanvasRenderingContextWebGL : nsISupports
|
|||||||
// METHODS
|
// METHODS
|
||||||
//
|
//
|
||||||
void present();
|
void present();
|
||||||
|
long sizeInBytes(in GLenum type);
|
||||||
|
|
||||||
void activeTexture (in GLenum texture);
|
void activeTexture (in GLenum texture);
|
||||||
void attachShader (in nsIWebGLProgram program, in nsIWebGLShader shader);
|
void attachShader (in nsIWebGLProgram program, in nsIWebGLShader shader);
|
||||||
@@ -640,10 +699,14 @@ interface nsICanvasRenderingContextWebGL : nsISupports
|
|||||||
|
|
||||||
// Modified: void glBufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage);
|
// Modified: void glBufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage);
|
||||||
// void bufferData (in GLenum target, in GLsizei size, in GLenum usage);
|
// void bufferData (in GLenum target, in GLsizei size, in GLenum usage);
|
||||||
void bufferData (in GLenum target, in nsICanvasArray data, in GLenum usage);
|
// void bufferData (in GLenum target, in nsICanvasArray data, in GLenum usage);
|
||||||
|
// void bufferData (in GLenum target, in nsICanvasArrayBuffer data, in GLenum usage);
|
||||||
|
void bufferData (in GLenum target);
|
||||||
|
|
||||||
// Modified: void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
|
// Modified: void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
|
||||||
void bufferSubData (in GLenum target, in GLuint offset, in nsICanvasArray data);
|
// void bufferSubData (in GLenum target, in GLsizeiptr offset, in nsICanvasArray data);
|
||||||
|
// void bufferSubData (in GLenum target, in GLsizeiptr offset, in CanvasArrayBuffer data);
|
||||||
|
void bufferSubData (in GLenum target, in GLsizeiptr offset);
|
||||||
|
|
||||||
GLenum checkFramebufferStatus (in GLenum target);
|
GLenum checkFramebufferStatus (in GLenum target);
|
||||||
void clear (in GLbitfield mask);
|
void clear (in GLbitfield mask);
|
||||||
|
|||||||
@@ -1077,6 +1077,11 @@ static const nsModuleComponentInfo gComponents[] = {
|
|||||||
NS_CANVASRENDERINGCONTEXTWEBGL_CID,
|
NS_CANVASRENDERINGCONTEXTWEBGL_CID,
|
||||||
"@mozilla.org/content/canvas-rendering-context;1?id=moz-webgl",
|
"@mozilla.org/content/canvas-rendering-context;1?id=moz-webgl",
|
||||||
CreateCanvasRenderingContextWebGL },
|
CreateCanvasRenderingContextWebGL },
|
||||||
|
{ "Canvas WebGL Rendering Context",
|
||||||
|
NS_CANVASRENDERINGCONTEXTWEBGL_CID,
|
||||||
|
"@mozilla.org/content/canvas-rendering-context;1?id=experimental-webgl",
|
||||||
|
CreateCanvasRenderingContextWebGL },
|
||||||
|
|
||||||
|
|
||||||
{ "XML document encoder",
|
{ "XML document encoder",
|
||||||
NS_TEXT_ENCODER_CID,
|
NS_TEXT_ENCODER_CID,
|
||||||
|
|||||||
Reference in New Issue
Block a user