mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 14:46:02 +00:00
Revert previous commits due to weird talos crash.
This commit is contained in:
parent
098c751ef8
commit
51345f632c
@ -38,7 +38,6 @@
|
||||
#ifndef WEBGLARRAY_H_
|
||||
#define WEBGLARRAY_H_
|
||||
|
||||
nsresult NS_NewCanvasArrayBuffer(nsISupports **aNewObject);
|
||||
nsresult NS_NewCanvasFloatArray(nsISupports **aNewObject);
|
||||
nsresult NS_NewCanvasByteArray(nsISupports **aNewObject);
|
||||
nsresult NS_NewCanvasUnsignedByteArray(nsISupports **aNewObject);
|
||||
|
@ -58,7 +58,6 @@ CPPSRCS = \
|
||||
ifdef MOZ_WEBGL
|
||||
|
||||
CPPSRCS += \
|
||||
WebGLArrays.cpp \
|
||||
WebGLContext.cpp \
|
||||
WebGLContextGL.cpp \
|
||||
WebGLContextUtils.cpp \
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
if (type == LOCAL_GL_INT) return sizeof(int);
|
||||
if (type == LOCAL_GL_UNSIGNED_INT) return sizeof(unsigned int);
|
||||
if (type == LOCAL_GL_DOUBLE) return sizeof(double);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
@ -118,10 +118,6 @@ public:
|
||||
data = nsnull;
|
||||
}
|
||||
|
||||
void Zero() {
|
||||
memset(data, 0, capacity);
|
||||
}
|
||||
|
||||
void EnsureCapacity(PRBool preserve, PRUint32 cap) {
|
||||
if (capacity >= cap)
|
||||
return;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,317 +0,0 @@
|
||||
/* -*- 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,17 +6,11 @@
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsDOMError.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxPattern.h"
|
||||
|
||||
#include "CanvasUtils.h"
|
||||
#include "NativeJSContext.h"
|
||||
|
||||
#include "WebGLArray.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
nsresult NS_NewCanvasRenderingContextWebGL(nsICanvasRenderingContextWebGL** aResult);
|
||||
@ -423,6 +417,655 @@ NS_INTERFACE_MAP_BEGIN(WebGLRenderbuffer)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(WebGLRenderbuffer)
|
||||
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; */
|
||||
NS_IMETHODIMP WebGLTexture::GetName(GLuint *aName)
|
||||
{
|
||||
|
@ -58,8 +58,6 @@
|
||||
#include "SimpleBuffer.h"
|
||||
#include "nsGLPbuffer.h"
|
||||
|
||||
#include "WebGLArrays.h"
|
||||
|
||||
class nsIDocShell;
|
||||
|
||||
namespace mozilla {
|
||||
@ -358,10 +356,6 @@ public:
|
||||
mCount = na->NativeCount();
|
||||
}
|
||||
|
||||
void SetCount(GLuint count) {
|
||||
mCount = count;
|
||||
}
|
||||
|
||||
GLenum GLType() { return mGLType; }
|
||||
PRUint32 ByteCount() { return mElementSize * mCount; }
|
||||
PRUint32 Count() { return mCount; }
|
||||
@ -499,6 +493,188 @@ protected:
|
||||
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
|
||||
|
@ -354,20 +354,6 @@ WebGLContext::Present()
|
||||
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); */
|
||||
NS_IMETHODIMP
|
||||
@ -456,8 +442,7 @@ WebGLContext::BindFramebuffer(GLenum target, nsIWebGLFramebuffer *fb)
|
||||
if (target >= LOCAL_GL_COLOR_ATTACHMENT0 &&
|
||||
target < (LOCAL_GL_COLOR_ATTACHMENT0 + mBoundColorFramebuffers.Length()))
|
||||
{
|
||||
int targetOffset = target - LOCAL_GL_COLOR_ATTACHMENT0;
|
||||
mBoundColorFramebuffers[targetOffset] = wfb;
|
||||
mBoundColorFramebuffers[target] = wfb;
|
||||
} else if (target == LOCAL_GL_DEPTH_ATTACHMENT) {
|
||||
mBoundDepthFramebuffer = wfb;
|
||||
} else if (target == LOCAL_GL_STENCIL_ATTACHMENT) {
|
||||
@ -523,28 +508,15 @@ GL_SAME_METHOD_2(BlendFunc, BlendFunc, PRUint32, PRUint32)
|
||||
GL_SAME_METHOD_4(BlendFuncSeparate, BlendFuncSeparate, PRUint32, PRUint32, PRUint32, PRUint32)
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::BufferData(GLenum target)
|
||||
WebGLContext::BufferData(GLenum target, nsICanvasArray *na, GLenum usage)
|
||||
{
|
||||
// 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;
|
||||
|
||||
if (target == LOCAL_GL_ARRAY_BUFFER) {
|
||||
boundBuffer = mBoundArrayBuffer;
|
||||
} else if (target == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
|
||||
// XXX fix type check
|
||||
//if (na->NativeType() != LOCAL_GL_UNSIGNED_SHORT)
|
||||
// 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;
|
||||
} else {
|
||||
@ -555,62 +527,18 @@ WebGLContext::BufferData(GLenum target)
|
||||
return ErrorMessage("glBufferData: no buffer bound!");
|
||||
}
|
||||
|
||||
|
||||
MakeContextCurrent();
|
||||
|
||||
uint32 usage;
|
||||
boundBuffer->Set(na);
|
||||
|
||||
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");
|
||||
}
|
||||
gl->fBufferData(target, na->NativeSize(), na->NativePointer(), usage);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::BufferSubData(GLenum target, GLsizeiptr offset)
|
||||
WebGLContext::BufferSubData(GLenum target, GLuint offset, nsICanvasArray *na)
|
||||
{
|
||||
// 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;
|
||||
|
||||
if (target == LOCAL_GL_ARRAY_BUFFER) {
|
||||
@ -625,63 +553,24 @@ WebGLContext::BufferSubData(GLenum target, GLsizeiptr offset)
|
||||
return ErrorMessage("glBufferSubData: no buffer bound!");
|
||||
}
|
||||
|
||||
/* XXX FIXME
|
||||
// check type
|
||||
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 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
|
||||
// XXX should be bytes
|
||||
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;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
LogMessage("bufferSubData: buffer (%d) for data at offset (%d+%d)", boundBuffer->Count(), offset, arrayBuf->NativeSize());
|
||||
#endif
|
||||
// all good
|
||||
|
||||
MakeContextCurrent();
|
||||
|
||||
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");
|
||||
// check size
|
||||
if ((offset + na->NativeCount()) > boundBuffer->Count()) {
|
||||
return ErrorMessage("glBufferSubData: existing buffer is too small for additional data");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// all good
|
||||
|
||||
MakeContextCurrent();
|
||||
|
||||
gl->fBufferSubData(target, offset * na->NativeElementSize(), na->NativeSize(), na->NativePointer());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -694,15 +583,7 @@ WebGLContext::CheckFramebufferStatus(GLenum target, GLenum *retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::Clear(PRUint32 mask)
|
||||
{
|
||||
MakeContextCurrent();
|
||||
gl->fClear(mask);
|
||||
Invalidate();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
GL_SAME_METHOD_1(Clear, Clear, PRUint32)
|
||||
|
||||
GL_SAME_METHOD_4(ClearColor, ClearColor, float, float, float, float)
|
||||
|
||||
@ -1089,7 +970,7 @@ WebGLContext::DrawElements(GLenum mode, GLuint count, GLenum type, GLuint offset
|
||||
return ErrorMessage("glDrawElements: ValidateBuffers failed");
|
||||
#endif
|
||||
// XXX uh, is this offset, or offset * elementsize?
|
||||
gl->fDrawElements(mode, count, type, (GLvoid*) (offset));
|
||||
gl->fDrawElements(mode, count, type, (GLvoid*) (offset * mBoundElementArrayBuffer->ElementSize()));
|
||||
|
||||
Invalidate();
|
||||
|
||||
@ -2519,7 +2400,7 @@ GL_SAME_METHOD_5(Uniform4f, Uniform4f, GLint, GLfloat, GLfloat, GLfloat, GLfloat
|
||||
// one uint arg followed by an array of c elements of glTypeConst.
|
||||
#define GL_SIMPLE_ARRAY_METHOD(glname, name, c, glTypeConst, ptrType) \
|
||||
NS_IMETHODIMP \
|
||||
WebGLContext::name(GLint idx, nsICanvasArray *v) \
|
||||
WebGLContext::name(GLint idx, nsICanvasArray *v) \
|
||||
{ \
|
||||
NativeJSContext js; \
|
||||
if (NS_FAILED(js.error)) \
|
||||
@ -2542,20 +2423,22 @@ WebGLContext::name(GLint idx, nsICanvasArray *v)
|
||||
if (v->NativeType() != LOCAL_GL_INT) { \
|
||||
return ErrorMessage(#name ": arg not an array"); \
|
||||
} \
|
||||
if (v->NativeCount() % c != 0) { \
|
||||
WebGLIntArray *wga = static_cast<WebGLIntArray*>(v); \
|
||||
if (wga->NativeCount() % c != 0) { \
|
||||
return ErrorMessage(#name ": array length not divisible by " #c); \
|
||||
} \
|
||||
MakeContextCurrent(); \
|
||||
gl->f##glname(idx, v->NativeCount() / c, ( ptrType *)v->NativePointer()); \
|
||||
gl->f##glname(idx, wga->NativeCount() / c, ( ptrType *)wga->NativePointer()); \
|
||||
} else if (glTypeConst == LOCAL_GL_FLOAT) { \
|
||||
if (v->NativeType() != LOCAL_GL_FLOAT) { \
|
||||
return ErrorMessage(#name ": arg not an array"); \
|
||||
} \
|
||||
if (v->NativeCount() % c != 0) { \
|
||||
WebGLFloatArray *wga = static_cast<WebGLFloatArray*>(v); \
|
||||
if (wga->NativeCount() % c != 0) { \
|
||||
return ErrorMessage(#name ": array length not divisible by " #c); \
|
||||
} \
|
||||
MakeContextCurrent(); \
|
||||
gl->f##glname(idx, v->NativeCount() / c, ( ptrType *)v->NativePointer()); \
|
||||
gl->f##glname(idx, wga->NativeCount() / c, ( ptrType *)wga->NativePointer()); \
|
||||
} else { \
|
||||
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
||||
} \
|
||||
@ -2565,7 +2448,7 @@ WebGLContext::name(GLint idx, nsICanvasArray *v)
|
||||
|
||||
#define GL_SIMPLE_ARRAY_METHOD_NO_COUNT(glname, name, c, glTypeConst, ptrType) \
|
||||
NS_IMETHODIMP \
|
||||
WebGLContext::name(GLuint idx, nsICanvasArray *v) \
|
||||
WebGLContext::name(GLuint idx, nsICanvasArray *v) \
|
||||
{ \
|
||||
NativeJSContext js; \
|
||||
if (NS_FAILED(js.error)) \
|
||||
@ -2588,20 +2471,22 @@ WebGLContext::name(GLuint idx, nsICanvasArray *v)
|
||||
if (v->NativeType() != LOCAL_GL_INT) { \
|
||||
return ErrorMessage(#name ": arg not an array"); \
|
||||
} \
|
||||
if (v->NativeCount() % c != 0) { \
|
||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, v->NativeCount()); \
|
||||
WebGLIntArray *wga = static_cast<WebGLIntArray*>(v); \
|
||||
if (wga->NativeCount() % c != 0) { \
|
||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, wga->NativeCount()); \
|
||||
} \
|
||||
MakeContextCurrent(); \
|
||||
gl->f##glname(idx, ( ptrType *)v->NativePointer()); \
|
||||
gl->f##glname(idx, ( ptrType *)wga->NativePointer()); \
|
||||
} else if (glTypeConst == LOCAL_GL_FLOAT) { \
|
||||
if (v->NativeType() != LOCAL_GL_FLOAT) { \
|
||||
return ErrorMessage(#name ": arg not an array"); \
|
||||
} \
|
||||
if (v->NativeCount() % c != 0) { \
|
||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, v->NativeCount()); \
|
||||
WebGLFloatArray *wga = static_cast<WebGLFloatArray*>(v); \
|
||||
if (wga->NativeCount() % c != 0) { \
|
||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, wga->NativeCount()); \
|
||||
} \
|
||||
MakeContextCurrent(); \
|
||||
gl->f##glname(idx, ( ptrType *)v->NativePointer()); \
|
||||
gl->f##glname(idx, ( ptrType *)wga->NativePointer()); \
|
||||
} else { \
|
||||
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
||||
} \
|
||||
@ -2611,7 +2496,7 @@ WebGLContext::name(GLuint idx, nsICanvasArray *v)
|
||||
|
||||
#define GL_SIMPLE_MATRIX_METHOD(glname, name, c, glTypeConst, ptrType) \
|
||||
NS_IMETHODIMP \
|
||||
WebGLContext::name(GLint location, GLboolean transpose, nsICanvasArray *value) \
|
||||
WebGLContext::name(GLint location, GLboolean transpose, nsICanvasArray *value) \
|
||||
{ \
|
||||
NativeJSContext js; \
|
||||
if (NS_FAILED(js.error)) \
|
||||
@ -2634,11 +2519,12 @@ WebGLContext::name(GLint location, GLboolean transpose, nsICanvasArray *value)
|
||||
if (value->NativeType() != LOCAL_GL_FLOAT) { \
|
||||
return ErrorMessage(#name ": arg not an array"); \
|
||||
} \
|
||||
if (value->NativeCount() % c != 0) { \
|
||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, value->NativeCount()); \
|
||||
WebGLFloatArray *wga = static_cast<WebGLFloatArray*>(value); \
|
||||
if (wga->NativeCount() % c != 0) { \
|
||||
return ErrorMessage(#name ": array wrong size %d, expected " #c, wga->NativeCount()); \
|
||||
} \
|
||||
MakeContextCurrent(); \
|
||||
gl->f##glname(location, value->NativeCount() / c, transpose, ( ptrType *)value->NativePointer()); \
|
||||
gl->f##glname(location, wga->NativeCount() / c, transpose, ( ptrType *)wga->NativePointer()); \
|
||||
} else { \
|
||||
return ErrorMessage("Unhandled glTypeConst"); /* need compiler fail */\
|
||||
} \
|
||||
@ -2894,10 +2780,8 @@ WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
|
||||
if (size < 1 || size > 4)
|
||||
return ErrorMessage("glVertexAttribPointer: invalid element size");
|
||||
|
||||
/* XXX make work with bufferSubData & heterogeneous types
|
||||
if (type != mBoundArrayBuffer->GLType())
|
||||
return ErrorMessage("glVertexAttribPointer: type must match bound VBO type: %d != %d", type, mBoundArrayBuffer->GLType());
|
||||
*/
|
||||
|
||||
// XXX 0 stride?
|
||||
//if (stride < (GLuint) size)
|
||||
@ -2913,8 +2797,8 @@ WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
|
||||
MakeContextCurrent();
|
||||
|
||||
gl->fVertexAttribPointer(index, size, type, normalized,
|
||||
stride,
|
||||
(void*) (offset));
|
||||
stride * mBoundArrayBuffer->ElementSize(),
|
||||
(void*) (offset * mBoundArrayBuffer->ElementSize()));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -49,4 +49,3 @@ DUMMY(NS_NewCanvasShortArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasUnsignedShortArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasIntArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasUnsignedIntArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasArrayBuffer, nsISupports)
|
||||
|
@ -66,8 +66,8 @@ typedef double GLclampd;
|
||||
typedef void GLvoid;
|
||||
|
||||
typedef char GLchar;
|
||||
typedef PRInt32 GLsizeiptr;
|
||||
typedef PRInt32 GLintptr;
|
||||
typedef ptrdiff_t GLsizeiptr;
|
||||
typedef ptrdiff_t GLintptr;
|
||||
|
||||
#ifndef GLAPIENTRY
|
||||
# ifdef WIN32
|
||||
|
@ -1335,8 +1335,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(WebGLRenderbuffer, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CanvasArrayBuffer, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CanvasFloatArray, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CanvasByteArray, nsDOMGenericSH,
|
||||
@ -1398,7 +1396,6 @@ static const nsConstructorFuncMapData kConstructorFuncMap[] =
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Worker, nsDOMWorker::NewWorker)
|
||||
|
||||
// WebGL Array Types
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasArrayBuffer, NS_NewCanvasArrayBuffer)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasFloatArray, NS_NewCanvasFloatArray)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasByteArray, NS_NewCanvasByteArray)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(CanvasUnsignedByteArray, NS_NewCanvasUnsignedByteArray)
|
||||
@ -3725,10 +3722,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIWebGLRenderbuffer)
|
||||
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_ENTRY(nsICanvasFloatArray)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -473,7 +473,6 @@ enum nsDOMClassInfoID {
|
||||
eDOMClassInfo_WebGLRenderbuffer_id,
|
||||
|
||||
// WebGL Buffers
|
||||
eDOMClassInfo_CanvasArrayBuffer_id,
|
||||
eDOMClassInfo_CanvasFloatArray_id,
|
||||
eDOMClassInfo_CanvasByteArray_id,
|
||||
eDOMClassInfo_CanvasUnsignedByteArray_id,
|
||||
|
@ -59,39 +59,16 @@ typedef long GLfixed;
|
||||
//typedef signed octet GLbyte;
|
||||
|
||||
//typedef unsigned long GLintptr;
|
||||
typedef long GLsizeiptr;
|
||||
//typedef unsigned long GLsizeiptr;
|
||||
|
||||
%{C++
|
||||
namespace mozilla {
|
||||
class WebGLArrayBuffer;
|
||||
}
|
||||
%}
|
||||
[ptr] native WebGLArrayBufferPtr (mozilla::WebGLArrayBuffer);
|
||||
//
|
||||
// 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)]
|
||||
interface nsICanvasArray : nsISupports
|
||||
{
|
||||
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);
|
||||
attribute unsigned long length;
|
||||
|
||||
[noscript, notxpcom] unsigned long nativeType();
|
||||
[noscript, notxpcom] voidPtr nativePointer();
|
||||
@ -103,71 +80,36 @@ interface nsICanvasArray : nsISupports
|
||||
[scriptable, Uuid(0f6d0e7b-bcfc-9305-6a1d-a9653b5e8c80)]
|
||||
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)]
|
||||
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)]
|
||||
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)]
|
||||
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)]
|
||||
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)]
|
||||
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)]
|
||||
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();
|
||||
};
|
||||
|
||||
//
|
||||
@ -682,7 +624,6 @@ interface nsICanvasRenderingContextWebGL : nsISupports
|
||||
// METHODS
|
||||
//
|
||||
void present();
|
||||
long sizeInBytes(in GLenum type);
|
||||
|
||||
void activeTexture (in GLenum texture);
|
||||
void attachShader (in nsIWebGLProgram program, in nsIWebGLShader shader);
|
||||
@ -699,14 +640,10 @@ interface nsICanvasRenderingContextWebGL : nsISupports
|
||||
|
||||
// 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 nsICanvasArray data, in GLenum usage);
|
||||
// void bufferData (in GLenum target, in nsICanvasArrayBuffer data, in GLenum usage);
|
||||
void bufferData (in GLenum target);
|
||||
void bufferData (in GLenum target, in nsICanvasArray data, in GLenum usage);
|
||||
|
||||
// Modified: void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* 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);
|
||||
void bufferSubData (in GLenum target, in GLuint offset, in nsICanvasArray data);
|
||||
|
||||
GLenum checkFramebufferStatus (in GLenum target);
|
||||
void clear (in GLbitfield mask);
|
||||
|
@ -1077,11 +1077,6 @@ static const nsModuleComponentInfo gComponents[] = {
|
||||
NS_CANVASRENDERINGCONTEXTWEBGL_CID,
|
||||
"@mozilla.org/content/canvas-rendering-context;1?id=moz-webgl",
|
||||
CreateCanvasRenderingContextWebGL },
|
||||
{ "Canvas WebGL Rendering Context",
|
||||
NS_CANVASRENDERINGCONTEXTWEBGL_CID,
|
||||
"@mozilla.org/content/canvas-rendering-context;1?id=experimental-webgl",
|
||||
CreateCanvasRenderingContextWebGL },
|
||||
|
||||
|
||||
{ "XML document encoder",
|
||||
NS_TEXT_ENCODER_CID,
|
||||
|
Loading…
x
Reference in New Issue
Block a user